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

ACTOR "Decoy" : CSDMOWeapon //5010
{

	+WEAPON.CHEATNOTWEAPON

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

	States
	{
	Ready:
		W08B J 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)

		TNT1 A 7 A_WEAPONREADY(WRF_NOFIRE)
		W08A JKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W08B ABCDEFGHI 1 A_WEAPONREADY(WRF_NOFIRE)
		Goto Ready

	SelectUsed:
		TNT1 A 9 A_PlaySound("HEGRENADE/Ready")
		W08A JKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W08B ABCDEFGHI 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("HEGRENADE/pinpull")
		W08D ABCDE 1 A_WEAPONREADY(WRF_NOFIRE)
		W08D F 1 A_Refire("Fire_2")
		Goto Throw

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

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

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

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

	Fire_6:
		W08D Z 1 A_WEAPONREADY(WRF_NOFIRE)
		W08E ABCD 1 A_WEAPONREADY(WRF_NOFIRE)
		W08E E 1 A_Refire("Fire_7")
		Goto Throw

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

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

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

	Fire_loop:
		W08E H 1 A_WEAPONREADY(WRF_NOFIRE)
		W08E 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(DecoyGrenadePROJECTILE,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 0 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(DecoyGrenadePROJECTILE,0,1,0,3,0,4)
		Goto LightDone
 	Spawn:
		W08Z A -1
		Stop
	}
}





// --------------------------------------------------------------------------
//
// Grenade -- Taken and adapted from Skulltag, with MBF stuff added to it
//
// --------------------------------------------------------------------------

ACTOR DecoyGrenadeProjectile
{
	Game Doom
//	SpawnID 216
	Radius 8
	Height 8
	Speed 25
	Damage 20
	Projectile
	-NOGRAVITY
	+RANDOMIZE
	+DEHEXPLOSION
	+GRENADETRAIL
	+doombounce
	//BounceType "Doom"
//	Gravity 0.25
	SeeSound "HEGRENADE/BOUNCE"
	DeathSound "HEGRENADE/EXPLODE"
	//BounceSound "weapons/grbnce"
	Obituary "%k killed %o with Decoy."
	DamageType Grenade

   ExplosionRadius 192
   ExplosionDamage 256
  Speed 35
  BounceFactor 0.7
  ReactionTime 60


	States
	{
	Spawn:
			W08X ABCDEFGH 3 Bright 

		Loop
	Death:
	TNT1 A 1 A_NoGravity
MISL B 1 A_AlertMonsters
		MISL B 7 Bright A_Explode
		MISL C 6 Bright
		MISL D 4 Bright
		Stop
	Grenade:
		MISL A 1000 A_Die
		Wait
	Detonate:
	TNT1 A 1 A_NoGravity
MISL B 1 A_AlertMonsters
		MISL B 3 A_Scream
		MISL C 6 A_Detonate
		MISL D 10
		Stop
	Mushroom:
		MISL B 8 A_Mushroom
		Goto Death+1
	}
}




