
// ------------------------------------------------------------
//   Weapon
// ------------------------------------------------------------

ACTOR HDWeapon : Weapon
{
	Weapon.AmmoGive 0
	Weapon.AmmoGive2 0
	weapon.ammouse1 0
	weapon.ammouse2 0
	weapon.bobstyle Alpha
	weapon.bobspeed 2.4
	weapon.bobrangex 0.2
	weapon.bobrangey 0.8
	+weapon.ammo_optional
	+weapon.alt_ammo_optional
	+weapon.noalert
	+inventory.undroppable
	+noclip
	Inventory.PickupSound "misc/w_pkup"
	radius 20
	height 16
	States
	{
	Spawn:
		TNT1 A 0
		stop
	Select:
		TNT1 A 1 A_Raise
		loop
	Deselect:
		TNT1 A 1 A_Lower
		loop
	Ready:
		TNT1 A 1 A_WeaponReady
		loop
	Fire:
	AltFire:
	Hold:
	AltHold:
		TNT1 A 1
		TNT1 A 1 A_Refire
		goto Ready
	}
}
actor HDWeaponPickup : HDPickup
{
	scale 0.65
	height 16
	radius 20
	+usespecial
	inventory.pickupsound "misc/w_pkup"
}

actor NoAmmoKick : ActionItem
{
	States
	{
	Pickup:
	Kick:
		TNT1 A 0 A_JumpIfInventory("JumpPower",70,1)
		fail
		TNT1 A 0 A_TakeInventory("JumpPower",30)

//		TNT1 A 0 ACS_ExecuteAlways(558,0,0,4,1)

		TNT1 A 0 A_JumpIfInventory ("PowerStrength", 1, 1)
		goto Kick2
		TNT1 A 0 A_FireCustomMissile("KickProjectile2",0,0,0,-24)
	Kick2:
		TNT1 AAA 0 A_FireCustomMissile("KickProjectile",0,0,0,-24)
		TNT1 A 0 A_JumpIfInventory ("Timer", 1, 2)
		TNT1 A 0 A_JumpIfHealthLower (40, "doubledamage")
		TNT1 A 0 A_TakeInventory ("Timer", 999)

		TNT1 A 0 A_FireCustomMissile("KickProjectile1",0,0,0,-24)
		fail
	doubledamage:
		TNT1 A 0 A_GiveInventory ("Timer", 1)
		goto Kick2
	}
}
actor KickProjectile
{
	projectile
	height 4
	radius 6
	damage 1
	speed 14
	states
	{
	spawn:
		TNT1 A 3
		TNT1 A 0 A_NoBlocking
		stop
	death:
		TNT1 A 0 A_NoBlocking
		TNT1 A 1 A_RadiusThrust(80,5,1)
		stop
	}
}
actor KickProjectile1 : KickProjectile
{
	deathsound "*fist"
	states
	{
	death:
		TNT1 A 0 A_Scream
		TNT1 A 0 A_NoBlocking
		TNT1 A 1 A_RadiusThrust(80,5,0)
		stop
	}
}
actor KickProjectile2 : KickProjectile
{
	deathsound "*fist"
	damage 10
	states
	{
	death:
		TNT1 A 0 A_NoBlocking
		TNT1 A 1 A_RadiusThrust(120,5,0)
		stop
	}
}
actor KickCheck : ActionItem
{
	States
	{
	Pickup:
		TNT1 A 0 A_JumpIfInventory("WipedOut",1,2)
		TNT1 A 0 A_FireCustomMissile("KickCheckProjectile",0,0,0,-24)
		TNT1 A 0
		fail
	}
}
actor KickCheckProjectile : KickProjectile
{
	speed 20
	damage 0
	+thrughost
	states
	{
	spawn:
		TNT1 A 2
	abort:
		TNT1 A 0 A_NoBlocking
		stop
	xdeath:
		TNT1 A 10 A_NoBlocking
		TNT1 A 0 A_JumpIfInTargetInventory("IsKicking",1,"abort")
		TNT1 A 0 A_GiveToTarget("NoAmmoKick",1)
		stop
	death:
		TNT1 A 0 A_NoBlocking
		stop
	}
}





// ------------------------------------------------------------
//   Fist
// ------------------------------------------------------------

actor HDFistPuff : BulletPuffMedium
{
	damagetype "SmallArms0"
}
actor HDNullPuff : HDFistPuff
{
	+puffonactors
	seesound ""
	states
	{
	spawn:
		TNT1 A 0
		stop
	}
}
actor Ring : Weapon replaces Fist
{
	obituary "%o chewed on %k's fist."
	attacksound "*fist"
	weapon.selectionorder 801
	weapon.kickback 120
	weapon.bobstyle Alpha
	weapon.bobspeed 2.4
	weapon.bobrangex 0.2
	weapon.bobrangey 0.8
	+WEAPON.WIMPY_WEAPON
	+WEAPON.MELEEWEAPON
	+WEAPON.NOALERT
	+WEAPON.NO_AUTO_SWITCH
	+inventory.undroppable
	states
	{
	Select:
		TNT1 A 0 A_TakeInventory ("Reloading", 999)
		PUNG AA 0 A_Raise
		PUNG A 1 A_Raise
		loop
	Deselect:
		TNT1 A 0 A_TakeInventory ("IsKicking", 999)
		TNT1 A 0 A_TakeInventory ("Reloading", 999)
		PUNG AA 0 A_Lower
		PUNG A 1 A_Lower
		loop
	Ready:
		PUNG A 1 A_WeaponReady
		TNT1 A 0 A_TakeInventory("IsKicking",999)
		TNT1 A 0 A_TakeInventory ("Reloading", 999)
		loop
	Fire:
		TNT1 A 0 A_GiveInventory("IsKicking",1)
		PUNG BC 2
		PUNG D 0 A_JumpIfInventory ("PowerStrength", 1, 2)
		PUNG D 0 A_Jump (256, 2)
		PUNG D 0 A_CustomPunch(36, 0, 0, "HDFistPuff", 46)
		PUNG DDDDD 0 A_CustomPunch(1, 0, 0, "HDNullPuff", 46)

		TNT1 A 0 A_JumpIfInventory ("Timer", 1, 2)
		TNT1 A 0 A_JumpIfHealthLower (40, "doubledamage")
		TNT1 A 0 A_TakeInventory ("Timer", 999)

		PUNG D 0 A_CustomPunch(1, 0, 0, "HDFistPuff", 46)

		PUNG D 6
		PUNG CB 4
		PUNG A 6 A_ReFire
		goto Ready
	doubledamage:
		TNT1 A 0 A_GiveInventory ("Timer", 1)
		goto Fire+2
	Hold:
	AltHold:
		TNT1 A 0 A_GiveInventory("IsKicking",1)
		PUNG BC 2
		PUNG C 0 A_JumpIfInventory ("PowerStrength", 1, 2)
		PUNG C 0 A_Jump (256, 2)
		PUNG C 0 A_CustomPunch(27, 0, 0, "HDFistPuff", 42)
		PUNG CCC 0 A_CustomPunch(1, 0, 0, "HDNullPuff", 42)

		TNT1 A 0 A_JumpIfInventory ("Timer", 1, 2)
		TNT1 A 0 A_JumpIfHealthLower (40, "doubledamagehold")
		TNT1 A 0 A_TakeInventory ("Timer", 999)

		PUNG C 0 A_CustomPunch(1, 0, 0, "HDFistPuff", 42)
		PUNG D 5
		PUNG C 4
		PUNG B 5 A_ReFire
		goto Ready
	doubledamagehold:
		TNT1 A 0 A_GiveInventory ("Timer", 1)
		goto Hold+2
	AltFire:
		TNT1 A 0 A_GiveInventory("IsKicking",1)
		TNT1 A 0 A_CheckFloor("Lunge")
		PUNG A 1 offset(0,50)
		PUNG A 1 offset(0,70)
		goto Kick
	Lunge:
		PUNG A 1 offset(0,50) A_Recoil(-4)
		PUNG A 1 offset(0,70) A_Recoil(-4)
	Kick:
		TNT1 A 0 A_GiveInventory("JumpPower",15)
		TNT1 AAAA 0 A_FireCustomMissile("KickProjectile",0,0,0,-24)
		TNT1 A 10 A_GiveInventory("NoAmmoKick",1)
		PUNG A 1 offset(0,70)
		PUNG A 2 offset(0,50)
		PUNG A 0 A_Refire
		goto Ready
	MegaPunch:
		PUNG A 4
		PUNG A 4
		PUNG BC 1 A_Recoil(-4)
		PUNG D 0 A_JumpIfInventory ("PowerStrength", 1, 2)
		PUNG D 0 A_Jump (256, 2)
		PUNG D 0 A_CustomPunch(54, 0, 0, "HDFistPuff", 46)
		PUNG DDDDDDD 0 A_CustomPunch(1, 0, 0, "HDNullPuff", 46)

		TNT1 A 0 A_JumpIfInventory ("Timer", 1, 2)
		TNT1 A 0 A_JumpIfHealthLower (40, "doubledamagemp")
		TNT1 A 0 A_TakeInventory ("Timer", 999)

		PUNG D 0 A_CustomPunch(1, 0, 0, "HDFistPuff", 46)
		PUNG D 8
		PUNG CB 4
		PUNG A 4 A_Refire
		goto Ready
	doubledamagemp:
		TNT1 A 0 A_GiveInventory ("Timer", 1)
		goto MegaPunch+4
	}
}
actor IsKicking : InventoryFlag {}


// ------------------------------------------------------------
//   Chainsaw
// ------------------------------------------------------------

actor Lumberjack : Chainsaw
{
	weapon.selectionorder 802
	weapon.upsound ""
	weapon.readysound ""
	decal "BulletScratch"
	+weapon.noalert
	+inventory.undroppable
	weapon.bobstyle Alpha
	weapon.bobspeed 2.4
	weapon.bobrangex 0.2
	weapon.bobrangey 0.8
	states
	{
	Ready:
		SAWG C 0 A_JumpIfInventory ("SawOn", 1, "Ready2")
		SAWG C 1 A_WeaponReady
		TNT1 A 0 A_TakeInventory ("Reloading", 999)
		loop
	Ready2:
		SAWG C 0 A_PlayWeaponSound ("weapons/sawidle")
		SAWG CCCDDD 1 A_WeaponReady
		loop
	Select:
		SAWG C 0 A_TakeInventory ("SawOn", 999)
		SAWG C 1 A_Raise
		goto Select+1
	Deselect:
		TNT1 A 0 A_TakeInventory ("Reloading", 999)
		SAWG C 0 A_JumpIfHealthLower (0, 2)
		SAWG C 0 A_JumpIfInventory ("SawOn", 1, 2)
		SAWG C 1 A_Lower
		loop
		SAWG AAA 1 A_Lower
		SAWG A 12 A_TakeInventory ("SawOn", 1)
		loop
	Fire:
		SAWG C 4 A_JumpIfInventory("SawOn", 1, 1)
		goto Altfire

		SAWG A 0 A_AlertMonsters
		SAWG A 0 A_CustomPunch (4, 0, 1, "HDSawPuff", 72)
		SAWG A 0 A_JumpIfInventory ("PowerStrength", 1, 2)
		SAWG A 0 A_Jump (256, 2)
		SAWG A 0 A_CustomPunch(12, 0, 0, "HDSawPuff", 46)
		SAWG A 0 ACS_Execute (553, 0, (random(0,1)*2-1)*random(6,16),(random(0,1)*2-1)*random(6,24))
		SAWG A 2 A_Saw ("weapons/sawfull", "weapons/sawhit", 2, "HDSawPuff")
		SAWG B 0 ACS_Execute (553, 0, (random(0,1)*2-1)*random(6,16),(random(0,1)*2-1)*random(6,24))
		SAWG B 2 A_Saw ("weapons/sawfull", "weapons/sawhit", 2, "HDSawPuff")
		SAWG B 0 A_Refire
		goto Ready
	AltFire:
		SAWG A 1 offset(0,33)
		SAWG A 1 offset(0,35)
		SAWG A 1 offset(0,37)
		SAWG A 0 A_JumpIfInventory("SawOn", 1, "AltFire2")
		SAWG A 2 offset(0,39) A_GiveInventory("SawOn", 1)
		SAWG A 0 offset(0,39) A_PlayWeaponSound ("weapons/sawup")
		SAWG A 0 A_AlertMonsters
		SAWG AAAA 1 offset(0,39) ACS_Execute (553, 0, (random(0,1)*2-1)*random(6,16),(random(0,1)*2-1)*random(6,24))
		SAWG A 0 A_Refire
		SAWG A 1 offset(0,37) ACS_Execute (553, 0, (random(0,1)*2-1)*random(6,16),(random(0,1)*2-1)*random(6,24))
		SAWG A 1 offset(0,35) ACS_Execute (553, 0, (random(0,1)*2-1)*random(6,16),(random(0,1)*2-1)*random(6,24))
		SAWG C 1 offset(0,33) ACS_Execute (553, 0, (random(0,1)*2-1)*random(6,16),(random(0,1)*2-1)*random(6,24))
		goto Ready
	AltFire2:
		SAWG AAA 2 offset(0,39) ACS_Execute (553, 0, (random(0,1)*2-1)*random(6,16),(random(0,1)*2-1)*random(6,24))
		SAWG A 2 offset(0,39) A_TakeInventory("SawOn", 999)
		SAWG A 1 offset(0,37)
		SAWG A 1 offset(0,35)
		SAWG C 1 offset(0,33)
		goto Ready
	AltHold:
		SAWG A 0 A_JumpIfInventory("SawOn", 1, 1)
		goto AltFire
	Hold:
		SAWG C 0 A_JumpIfInventory("SawOn", 1, 1)
		goto Altfire

		SAWG A 0 A_AlertMonsters
		SAWG A 0 A_CustomPunch (4, 0, 1, "HDSawPuff", 64)
		SAWG A 0 A_JumpIfInventory ("PowerStrength", 1, 2)
		SAWG A 0 A_Jump (256, 2)
		SAWG A 0 A_CustomPunch(12, 0, 0, "HDSawPuff", 42)
		SAWG A 0 ACS_Execute (553, 0, (random(0,1)*2-1)*random(4,22),(random(0,1)*2-1)*random(4,28))
		SAWG A 2 A_Saw ("weapons/sawfull", "weapons/sawhit", 2, "HDSawPuff")
		SAWG A 0 ACS_Execute (553, 0, (random(0,1)*2-1)*random(4,22),(random(0,1)*2-1)*random(4,28))
		SAWG B 2 A_Saw ("weapons/sawfull", "weapons/sawhit", 2, "HDSawPuff")
		SAWG B 0 A_Refire
		goto Ready
	spawn:
		TNT1 A 0
		TNT1 A 0 A_SpawnItemEx ("ChainsawPickup", 0,0,0,velx,vely,velz,0,32,0)
		stop
		CSAW A -1
		stop
	}
}
actor HDSawPuff : BulletPuffMedium
{
	damagetype "SmallArms1"
}
actor SawOn : InventoryFlag {}
actor ChainsawPickup : HDWeaponPickup replaces Chainsaw
{
	scale 0.6
	inventory.pickupmessage "You got the chainsaw! Go find some meat!"
	states
	{
	spawn:
		CSAW A -1
		stop
	pickup:
		TNT1 A 0 A_JumpIfInventory ("CanPickUpItems", 1, 1)
		fail
		TNT1 A 0 A_JumpIfInventory ("Lumberjack", 1, 2)
		TNT1 A 0 A_GiveInventory ("Lumberjack", 1)
		stop
		TNT1 A 0
		fail
	}
}