// --------------------------------------------------------------------------
//
// Molotov (Demo weapon "Appears on weapons training")
//
// --------------------------------------------------------------------------

ACTOR "Molotov" : CSDMOWeapon //5010
{

	//+WEAPON.CHEATNOTWEAPON

	Weapon.SelectionOrder 1900
	Weapon.AmmoUse 1
	Weapon.AmmoGive 1
	Weapon.AmmoType "MolotovAmmo"
	obituary "%k killed %o with Molotov."
	+WEAPON.WIMPY_WEAPON
	Inventory.Pickupmessage "Pickep up a Molotov."
	Tag "Molotov"
	Weapon.UpSound "HEGRENADE/Ready"
	AttackSound "HEGRENADE/Fire" 
	Scale 0.2
	 +IGNORESKILL
	 +WEAPON.EXPLOSIVE
	//+NOAUTOFIRE

	States
	{
	Ready:
		W25B G 1 A_WeaponReady
		Loop



	Deselect:
TNT1 A 1 A_TakeInventory("Grenade_BlockMemo",1)
	TNT1 A 0 ACS_NamedExecuteAlways("HSPreviousWeapon", 0, 2, 0, 0)
    TNT1 A 0
	Goto DeselectLoop


	Select:
	TNT1 A 1 A_Raise
	TNT1 AA 0 A_Raise
	TNT1 A 0 ACS_ExecuteAlways(798, 0, 245, 0, 0)//Weapon Weight
	TNT1 A 1 A_TakeInventory("CrosshairType",2)

	TNT1 A 0 ACS_NamedExecuteAlways("HSPreviousWeapon", 0, 1, 0, 0)
//	TNT1 A 1 A_Print("Test Animation", 0.5)
		W25A ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W25B ABCDEF 1 A_WEAPONREADY(WRF_NOFIRE)
		Goto Ready

	SelectUsed:
		W25A A 1 A_PlaySound("HEGRENADE/Ready")
		W25A BCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W25B ABCDEF 1 A_WEAPONREADY(WRF_NOFIRE)
		Goto Ready


//made it into 5 tics each fire state to don't spam that many fire states. A balance between code save and responsiveness
	Fire:
TNT1 A 0 A_GiveInventory("Grenade_BlockMemo",1)
	TNT1 A 0 A_JumpIfInventory("IsBot",1,"BotFire")
			TNT1 A 0 A_PlaySound("Molotov/Pinpull")
		W25D ABCDE 1 A_WEAPONREADY(WRF_NOFIRE)
		W25D F 1 A_Refire("Fire_2")
		Goto Throw

	Fire_2:
	/*
		W25D FGHIJ 1 A_WEAPONREADY(WRF_NOFIRE)
		W25D K 1 A_Refire("Fire_3")
		Goto Throw

	Fire_3:
		W25D KLMNO 1 A_WEAPONREADY(WRF_NOFIRE)
		W25D P 1 A_Refire("Fire_4")
		Goto Throw

	Fire_4:
		W25D PQRST 1 A_WEAPONREADY(WRF_NOFIRE)
		W25D U 1 A_Refire("Fire_5")
		Goto Throw

	Fire_5:
		W25D UVWXY 1 A_WEAPONREADY(WRF_NOFIRE)
		W25D Z 1 A_Refire("Fire_6")
		Goto Throw

	Fire_6:
		W25D Z 1 A_WEAPONREADY(WRF_NOFIRE)
		W25E ABCD 1 A_WEAPONREADY(WRF_NOFIRE)
		W25E E 1 A_Refire("Fire_7")
		Goto Throw

	Fire_7:
		W25E EFGH 1 A_WEAPONREADY(WRF_NOFIRE)
		W25E I 1 A_Refire("Fire_loop")
		Goto Throw
*/

//        W25D A 1 A_WeaponReady(WRF_NOFIRE)		TNT1 A 0 A_Refire(1)		Goto Throw
//        W25D B 1 A_WeaponReady(WRF_NOFIRE)		TNT1 A 0 A_Refire(1)		Goto Throw
//        W25D C 1 A_WeaponReady(WRF_NOFIRE)		TNT1 A 0 A_Refire(1)		Goto Throw
//        W25D D 1 A_WeaponReady(WRF_NOFIRE)		TNT1 A 0 A_Refire(1)		Goto Throw
//        W25D E 1 A_WeaponReady(WRF_NOFIRE)		TNT1 A 0 A_Refire(1)		Goto Throw
        W25D F 1 A_WeaponReady(WRF_NOFIRE)		TNT1 A 0 A_Refire(1)		Goto Throw
        W25D G 1 A_WeaponReady(WRF_NOFIRE)		TNT1 A 0 A_Refire(1)		Goto Throw
        W25D H 1 A_WeaponReady(WRF_NOFIRE)		TNT1 A 0 A_Refire(1)		Goto Throw
        W25D I 1 A_WeaponReady(WRF_NOFIRE)		TNT1 A 0 A_Refire(1)		Goto Throw
        W25D J 1 A_WeaponReady(WRF_NOFIRE)		TNT1 A 0 A_Refire(1)		Goto Throw
        W25D K 1 A_WeaponReady(WRF_NOFIRE)		TNT1 A 0 A_Refire(1)		Goto Throw
        W25D L 1 A_WeaponReady(WRF_NOFIRE)		TNT1 A 0 A_Refire(1)		Goto Throw
        W25D M 1 A_WeaponReady(WRF_NOFIRE)		TNT1 A 0 A_Refire(1)		Goto Throw
        W25D N 1 A_WeaponReady(WRF_NOFIRE)		TNT1 A 0 A_Refire(1)		Goto Throw
        W25D O 1 A_WeaponReady(WRF_NOFIRE)		TNT1 A 0 A_Refire(1)		Goto Throw
        W25D P 1 A_WeaponReady(WRF_NOFIRE)		TNT1 A 0 A_Refire(1)		Goto Throw
        W25D Q 1 A_WeaponReady(WRF_NOFIRE)		TNT1 A 0 A_Refire(1)		Goto Throw
        W25D R 1 A_WeaponReady(WRF_NOFIRE)		TNT1 A 0 A_Refire(1)		Goto Throw
        W25D S 1 A_WeaponReady(WRF_NOFIRE)		TNT1 A 0 A_Refire(1)		Goto Throw
        W25D T 1 A_WeaponReady(WRF_NOFIRE)		TNT1 A 0 A_Refire(1)		Goto Throw
        W25D U 1 A_WeaponReady(WRF_NOFIRE)		TNT1 A 0 A_Refire(1)		Goto Throw
        W25D V 1 A_WeaponReady(WRF_NOFIRE)		TNT1 A 0 A_Refire(1)		Goto Throw
        W25D W 1 A_WeaponReady(WRF_NOFIRE)		TNT1 A 0 A_Refire(1)		Goto Throw
        W25D X 1 A_WeaponReady(WRF_NOFIRE)		TNT1 A 0 A_Refire(1)		Goto Throw
        W25D Y 1 A_WeaponReady(WRF_NOFIRE)		TNT1 A 0 A_Refire(1)		Goto Throw
        W25D Z 1 A_WeaponReady(WRF_NOFIRE)		TNT1 A 0 A_Refire(1)		Goto Throw

        W25E A 1 A_WeaponReady(WRF_NOFIRE)		TNT1 A 0 A_Refire(1)		Goto Throw
        W25E B 1 A_WeaponReady(WRF_NOFIRE)		TNT1 A 0 A_Refire(1)		Goto Throw
        W25E C 1 A_WeaponReady(WRF_NOFIRE)		TNT1 A 0 A_Refire(1)		Goto Throw
        W25E D 1 A_WeaponReady(WRF_NOFIRE)		TNT1 A 0 A_Refire(1)		Goto Throw
        W25E E 1 A_WeaponReady(WRF_NOFIRE)		TNT1 A 0 A_Refire(1)		Goto Throw
        W25E F 1 A_WeaponReady(WRF_NOFIRE)		TNT1 A 0 A_Refire(1)		Goto Throw
        W25E G 1 A_WeaponReady(WRF_NOFIRE)		TNT1 A 0 A_Refire(1)		Goto Throw

	Fire_loop:
		W25E H 1 A_WEAPONREADY(WRF_NOFIRE)
		W25E H 1 A_Refire("Fire_loop")
		Goto Throw





/*
	Fire:
	TNT1 A 0 A_JumpIfInventory("IsBot",1,"BotFire")
		TNT1 A 4 A_FireCustomMissile(HEGRENADEPROJECTILE,0,1,0,3,0,4)//A_GunFlash
		W16F EFGH 1 A_WEAPONREADY(WRF_NOFIRE)
		TNT1 A 3 A_WEAPONREADY(WRF_NOFIRE)
		TNT1 A 1 A_JumpIfNoAmmo("PreviousWeapon")
		Goto SelectUsed
*/




	BotFire:
	Throw:
		TNT1 A 4 A_FireCustomMissile(MolotovGrenadePROJECTILE,0,1,0,3,0,4)//A_GunFlash
		W16F EFGH 1 A_WEAPONREADY(WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 3 A_WEAPONREADY(WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 1 A_JumpIfNoAmmo("PreviousWeapon")
		Goto SelectUsed


//	AltFire:
//		TNT1 A 0 A_FireCustomMissile(AccurateGRENADEPROJECTILE,0,0,0,3,0,4)
//		W16B J 16 A_WeaponReady
//		Goto Ready


//		W16F ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)








	PreviousWeapon:
		TNT1 A 6 //A_PlaySound("HEGRENADE/Ready")
		TNT1 A 3 //A_PlaySound("HEGRENADE/Ready")
TNT1 A 1 A_TakeInventory("Grenade_BlockMemo",1)
	TNT1 A 0 ACS_NamedExecuteAlways("HSPreviousWeapon", 0, 0, 0, 0)
Goto SetWeapon


             SetWeapon:  
        TNT1 A 1 A_WeaponReady(WRF_NOFIRE)//A_SelectWeapon("Knife")
        Goto Ready	


	Flash:
		TNT1 A 0 Bright //A_Light1
		TNT1 A 0 A_TakeInventory("Slot8Filled", 1)//A_AlertMonsters
		TNT1 A 2 A_FireCustomMissile(MolotovGrenadePROJECTILE,0,0,3,3,0,4)
		Goto LightDone
 	Spawn:
		W25Z A -1
		Stop
	}
}




ACTOR MolotovGrenadePROJECTILE
{
	Game Doom
//	SpawnID 216
	Radius 8
	Height 8
	Speed 30
	Damage 75
	Projectile
    DamageType "Fire"
	-NOGRAVITY
	+RANDOMIZE
	+DEHEXPLOSION
	//+GRENADETRAIL
	//+GHOST
	+DOOMBOUNCE
	//+THRUSPECIES
	BounceFactor 0.05
WallBounceFactor 0.25
BounceCount 2

	ReactionTime 35
	Gravity 0.6
	SeeSound "301/FireEnd"
	//DeathSound "301/Explode"
	//BounceSound "301/Bounce"
	Obituary "$OB_GRENADE"
	DamageType Grenade
Scale 0.125
	States
	{
	Spawn:
			W25X ABCDEFGH 3 Bright 

		Loop
	Death:
		MISL B 0
//		NULL A 0 A_Explode(512,312,0)
		MISL B 0 A_SpawnItemEx("NewExplosionMedium",0,0,0,0,0,0,0,32)
//		MISL B 0 Bright A_Explode
		MISL C 0 Bright
		MISL D 0 Bright
		TNT1 A 1 A_PlaySound("301/FireStart", 6)
		TNT1 A 0 A_PlaySoundEx("301/FireLoop", "firesnd", 1)
		TNT1 A 0 A_PlaySound("molotov_detonate/Distant", 5)
//	TNT1 AAAAAAAAAAAAAAAAAAAAA 0 A_SpawnItemEx("FTFlameTrailVC",0,0,0,random(1,3),0,random(8,12),random(1,360),32,0)
		MISL B 0 A_SpawnItemEx("RedeemExplosionMediumSprite",0,0,0,0,0,0,0,32)
		MISL B 0 A_SpawnItemEx("IncendiaryDamageRadius",0,0,0,0,0,0,0,32)
		TNT1 A 1 A_PlaySound("301/Explode", 7)
		TNT1 A 36 Light("OrangeMediumFlicker2")
		MISL B 0 A_SpawnItemEx("RedeemExplosionMediumSprite",0,0,0,0,0,0,0,32)
		TNT1 A 36 Light("OrangeMediumFlicker2")
		MISL B 0 A_SpawnItemEx("RedeemExplosionMediumSprite",0,0,0,0,0,0,0,32)
		TNT1 A 36 Light("OrangeMediumFlicker2")
		MISL B 0 A_SpawnItemEx("RedeemExplosionMediumSprite",0,0,0,0,0,0,0,32)
		TNT1 A 36 Light("OrangeMediumFlicker2")
		MISL B 0 A_SpawnItemEx("RedeemExplosionMediumSprite",0,0,0,0,0,0,0,32)
		TNT1 A 36 Light("OrangeMediumFlicker2")
		MISL B 0 A_SpawnItemEx("RedeemExplosionMediumSprite",0,0,0,0,0,0,0,32)
		TNT1 A 36 Light("OrangeMediumFlicker2")
		MISL B 0 A_SpawnItemEx("RedeemExplosionMediumSprite",0,0,0,0,0,0,0,32)
		TNT1 A 1 A_PlaySound("301/FireEnd", 7)
		TNT1 A 1 A_StopSoundEx("Firesnd")
		Stop
	Grenade:
		TNT1 A 1000 A_Die
		Wait

	Detonate:
		MISL B 0 
//		NULL A 0 A_Explode(512,312,0)
		MISL B 0 A_SpawnItemEx("NewExplosionMedium",0,0,0,0,0,0,0,32)
		MISL B 0 A_Scream
		MISL C 0 A_Detonate
		MISL D 0
		TNT1 A 1 A_PlaySound("301/FireStart", 6)
		TNT1 A 0 A_PlaySoundEx("301/FireLoop", "firesnd", 1)
		TNT1 A 0 A_PlaySound("molotov_detonate/Distant", 5)
//	TNT1 AAAAAAAAAAAAAAAAAAAAA 0 A_SpawnItemEx("FTFlameTrailVC",0,0,0,random(1,3),0,random(8,12),random(1,360),32,0)
		MISL B 0 A_SpawnItemEx("RedeemExplosionMediumSprite",0,0,0,0,0,0,0,32)
		MISL B 0 A_SpawnItemEx("IncendiaryDamageRadius",0,0,0,0,0,0,0,32)
		TNT1 A 1 A_PlaySound("301/Explode", 7)
		TNT1 A 36 Light("OrangeMediumFlicker2")
		MISL B 0 A_SpawnItemEx("RedeemExplosionMediumSprite",0,0,0,0,0,0,0,32)
		TNT1 A 36 Light("OrangeMediumFlicker2")
		MISL B 0 A_SpawnItemEx("RedeemExplosionMediumSprite",0,0,0,0,0,0,0,32)
		TNT1 A 36 Light("OrangeMediumFlicker2")
		MISL B 0 A_SpawnItemEx("RedeemExplosionMediumSprite",0,0,0,0,0,0,0,32)
		TNT1 A 36 Light("OrangeMediumFlicker2")
		MISL B 0 A_SpawnItemEx("RedeemExplosionMediumSprite",0,0,0,0,0,0,0,32)
		TNT1 A 36 Light("OrangeMediumFlicker2")
		MISL B 0 A_SpawnItemEx("RedeemExplosionMediumSprite",0,0,0,0,0,0,0,32)
		TNT1 A 36 Light("OrangeMediumFlicker2")
		MISL B 0 A_SpawnItemEx("RedeemExplosionMediumSprite",0,0,0,0,0,0,0,32)
		TNT1 A 36 Light("OrangeMediumFlicker2")
		TNT1 A 1 A_PlaySound("301/FireEnd", 7)
		TNT1 A 1 A_StopSoundEx("Firesnd")
		Stop
	Mushroom:
		MISL B 0 A_Mushroom
		Goto Death

	}
}