// --------------------------------------------------------------------------
//
// TNT (Dynamite)
//
// --------------------------------------------------------------------------
ACTOR GetOnWithIt : Inventory { Inventory.MaxAmount 150 }
ACTOR Dynamite : LowWeapon
{
	+WEAPON.EXPLOSIVE
	+INVENTORY.UNDROPPABLE
	+WEAPON.AMMO_OPTIONAL
	Weapon.SlotNumber 7
	Weapon.AmmoType "TNTAmmo"
	Weapon.AmmoUse 1
	Weapon.AmmoGive 1
	Weapon.UpSound "weapons/upwp2"
	Inventory.Pickupmessage "T.N.T."
	Scale 0.9
	Tag "Dynamite"
	States
	{
	Ready:
		TNT1 A 0 A_JumpIf(waterlevel>2,"ReadyNoAmmo")
		TNT1 A 0 A_JumpIfNoAmmo("ReadyNoAmmo")
		SDYG A 1 A_WeaponReady
		Goto TrueReady
	TrueReady:
		TNT1 A 0 A_JumpIf(waterlevel>2,"ReadyNoAmmo")
		SDYG A 1 A_WeaponReady
		TNT1 A 0 A_JumpifInventory("IsKicking",1,"Kick")
		Loop
	ReadyNoAmmo:
		TNT1 A 1 A_WeaponReady
		TNT1 A 0 A_JumpifInventory("IsKicking",1,"Kick")
		Loop
	Deselect:
		TNT1 A 0 A_JumpIfInventory("TNTammo",1,1)
		Goto Drylower
		TNT1 A 0 A_PlaySound("weapons/swap",6)
		SDYG A 1 Offset (8, 0) A_Lower
		TNT1 A 0 A_Lower
		SDYG A 1 Offset (16, 0) A_Lower
		TNT1 A 0 A_Lower
		SDYG A 1 Offset (24, 0) A_Lower
		TNT1 A 0 A_Lower
		SDYG A 1 Offset (32, 0) A_Lower
		TNT1 A 0 A_Lower
		SDYG A 1 Offset (40, 0) A_Lower
		TNT1 A 0 A_Lower
		SDYG A 1 Offset (48, 0) A_Lower
		TNT1 A 0 A_Lower
		SDYG A 1 Offset (56, 0) A_Lower
		TNT1 A 0 A_Lower
		SDYG A 1 Offset (64, 0) A_Lower
		TNT1 A 1 A_Lower
		Wait
	Drylower:
		TNT1 A 0 A_PlaySound("weapons/swap",6)
		TNT1 A 1 A_Lower
		Wait
	Select:
		TNT1 A 0 A_JumpIf(waterlevel>2,"ReadyNoAmmo")
		TNT1 A 0 A_JumpIfInventory("TNTammo",1,1)
		Goto ReadyNoAmmo
		SDYG A 1 Offset (64, 0) A_Raise
		TNT1 A 0 A_Raise
		SDYG A 1 Offset (56, 0) A_Raise
		TNT1 A 0 A_Raise
		SDYG A 1 Offset (48, 0) A_Raise
		TNT1 A 0 A_Raise
		SDYG A 1 Offset (40, 0) A_Raise
		TNT1 A 0 A_Raise
		SDYG A 1 Offset (32, 0) A_Raise
		TNT1 A 0 A_Raise
		SDYG A 1 Offset (24, 0) A_Raise
		TNT1 A 0 A_Raise
		SDYG A 1 Offset (16, 0) A_Raise
		TNT1 A 0 A_Raise
		SDYG A 1 Offset (8, 0) A_Raise
		TNT1 A 0 A_Raise
		Wait
	Fire:
		TNT1 A 0 A_JumpIf(waterlevel>2,"ReadyNoAmmo")
		TNT1 A 0 A_JumpIfInventory("TNTammo",1,1)
		Goto Dryfire
		SDYG A 1 Offset (5, 40)
		SDYG A 1 Offset (15, 56)
		SDYG A 1 Offset (25, 72)
		SDYG A 1 Offset (35, 88)
		SDYG A 1 Offset (45, 104)
		SDYG A 1 Offset (55, 120)
		SDYG A 1 Offset (65, 136)
		SDYG A 1 Offset (75, 152)
		SDYG A 3 A_PlaySound ("weapons/tntlt")
		SDYG A 3 A_PlaySound ("weapons/tntfs")
		TNT1 A 1 A_ReFire("Hold")
		Goto Realfire
	Hold:
		TNT1 A 0 A_JumpIf(waterlevel>2,"ReadyNoAmmo")
		TNT1 A 0 A_JumpIfInventory("GetOnWithIt", 150, "Realfire")
		TNT1 A 1 A_GiveInventory("GetOnWithIt",1)
		TNT1 A 0 A_Refire
	Realfire:
		TNT1 A 0 A_JumpIf(waterlevel>2,"ReadyNoAmmo")
		TNT1 A 0 A_StopSound(1)
		TNT1 A 0 Offset(-20,32)
		MAND BCD 2
		MAND E 2 A_PlaySound ("weapons/tnttr")
		MAND C 0 A_FireCustomMissile("STNT")
		MAND FEDCB 2
		TNT1 A 0 A_TakeInventory("GetOnWithIt", 150)
		TNT1 A 0 A_JumpIfNoAmmo("Dryfire")
		SDYG A 1 Offset (75, 152)
		SDYG A 1 Offset (65, 136)
		SDYG A 1 Offset (55, 120)
		SDYG A 1 Offset (45, 104)
		SDYG A 1 Offset (35, 88)
		SDYG A 1 Offset (25, 72)
		SDYG A 1 Offset (15, 56)
		SDYG A 1 Offset (5, 40)
		Goto Ready
	Dryfire:
		TNT1 A 1 A_WeaponReady
		Loop
	Spawn:
		TNTS A -1
		Stop
//  Kick Actions
	Kick:
		TNT1 A 0 A_JumpIfInventory("TNTammo",1,1)
		Goto DryKick
		TNT1 A 0 A_JumpIf (momZ > 0, "AirKick")
		TNT1 A 0 A_JumpIf (momZ < 0, "AirKick")
		TNT1 A 0 A_JumpIfInventory("SuperBlow",1,"BerserkKick")
		KKKR A 1 Offset(0,32)
		KKKR BCDE 1
		KKKR FG 1 A_Recoil(-1)
		KKKR H 2 A_CustomPunch (5,0,0,"FightPuff3") 
		KKKR IHGFEDC 1 
		KKKR BA 1 A_Recoil(+1)
		Goto Ready
	AirKick:
		TNT1 A 0 A_JumpIfInventory("SuperBlow",1,"AirBerserkKick")
		FISG B 1
		FISG B 1 Offset(0,36)
		TNT1 A 0 Offset(-1,32)
		KI3K ABCDE 1
		KI3K F 3 A_CustomPunch (9,0,0,"FightPuff3") 
		KI3K GHIJK 2 
		Goto Ready
	BerserkKick:
		TNT1 A 0 A_JumpIfInventory("TNTammo",1,1)
		Goto BerserkDryKick
		KKKR A 1 Offset(0,32)
		KKKR BCDE 1
		KKKR FG 1 A_Recoil(-1)
		KKKR H 2 A_CustomPunch (9,0,0,"FightPuff3") 
		KKKR IHGFEDC 1 
		KKKR BA 1 A_Recoil(+1)
		Goto Ready
	AirBerserkKick:
		FISG B 1
		FISG B 1 Offset(0,36)
		TNT1 A 0 Offset(-1,32)
		KI3K ABCDE 1 A_Recoil(-2)
		KI3K F 3 A_CustomPunch (12,0,0,"FightPuff3") 
		KI3K GHIJK 2 
		Goto Ready
	DryKick:
		TNT1 A 0 A_JumpIf (momZ > 0, "AirKick")
		TNT1 A 0 A_JumpIf (momZ < 0, "AirKick")
		TNT1 A 0 A_JumpIfInventory("SuperBlow",1,"BerserkDryKick")
		KICF A 1 Offset(0,32)
		KICF BCDE 1
		KICF FG 1 A_Recoil(-1)
		KICF H 2 A_CustomPunch (5,0,0,"FightPuff3") 
		KICF IHGFEDC 1 
		KICF BA 1 A_Recoil(+1)
		Goto Ready
	BerserkDryKick:
		KICF A 1 Offset(0,32)
		KICF BCDE 1
		KICF FG 1 A_Recoil(-1)
		KICF H 2 A_CustomPunch (9,0,0,"FightPuff3") 
		KICF IHGFEDC 1 
		KICF BA 1 A_Recoil(+1)
		Goto Ready
	}
}


// TNT -------------------------------------------------------------

ACTOR STNT
{
	Radius 2
	Height 2
	Speed 35
	Damage 0
	Projectile
	-NOGRAVITY
	-GRENADETRAIL
	+RANDOMIZE
	+DEHEXPLOSION
	+SHOOTABLE
	+SKYEXPLODE
	+CANBOUNCEWATER
	Obituary "You died."
	BounceType "Doom"
	BounceFactor 0.4
	WallBounceFactor 0.3
	ActiveSound "weapons/tntfs"
	DeathSound "misc/explosion"
	BounceSound "weapons/tntbn"
	DamageType Explosive
	Decal Scorch
	Gravity 0.85
	Scale 0.3
	States
	{
	Spawn:
		TNT1 A 0 A_JumpIf(waterlevel>2,"Waterdeath")
	    STNT A 1 bright A_SpawnItemEx("GunSmokeSpawner",0,0,0,0,0,1,0,128)
		STNT A 1 bright A_LoopActiveSound
		STNT B 1 bright A_SpawnItemEx("GunSmokeSpawner",0,0,0,0,0,1,0,128)
		STNT B 1 bright A_LoopActiveSound
		STNT C 1 bright A_SpawnItemEx("GunSmokeSpawner",0,0,0,0,0,1,0,128)
		STNT C 1 bright A_LoopActiveSound
		STNT D 1 bright A_SpawnItemEx("GunSmokeSpawner",0,0,0,0,0,1,0,128)
		STNT D 1 bright A_LoopActiveSound
		STNT E 1 bright A_SpawnItemEx("GunSmokeSpawner",0,0,0,0,0,1,0,128)
		STNT E 1 bright A_LoopActiveSound
		STNT F 1 bright A_SpawnItemEx("GunSmokeSpawner",0,0,0,0,0,1,0,128)
		STNT F 1 bright A_LoopActiveSound
		STNT G 1 bright A_SpawnItemEx("GunSmokeSpawner",0,0,0,0,0,1,0,128)
		STNT G 1 bright A_LoopActiveSound
		STNT H 1 bright A_SpawnItemEx("GunSmokeSpawner",0,0,0,0,0,1,0,128)
		STNT H 1 bright A_LoopActiveSound
		Loop
	Death: 
		TNT1 A 0 A_JumpIf(waterlevel>2,"Waterdeath")
		TNT1 A 1 A_Explode(256,156) //40% stronger (according to Zaero :)
		TNT1 A 0 A_AlertMonsters
		TNT1 A 0 Radius_Quake (2, 36, 0, 15, 0)
		TNT1 A 0 A_NoBlocking
		TNT1 A 0 A_Scream
		TNT1 AAAAAAAAAAAAAAA 0 A_SpawnDebris("BulletSparks")
		TNT1 A 1 A_SpawnItem("Detonation2")
		Stop
	Grenade:
		STNT IJK 1000 A_Die
		Wait
	Detonate:
		Stop
	WaterDeath:
		TNT1 A 1 A_SpawnItem("WaterSplashBase")
		Stop
	}
}