//==============================================================================
// Panzerkreuz Mark III
//==============================================================================

ACTOR PNZoomed : Inventory { Inventory.MaxAmount 1 }

ACTOR HDPanzerfaust : KriegslandHeavyWeapon
{
	+WEAPON.NOAUTOFIRE
	+INVENTORY.UNDROPPABLE
	Weapon.SelectionOrder 1100
	Weapon.AmmoUse 		0 // for the new ACS
	Weapon.SlotNumber 	5
	Weapon.AmmoGive 	6
	Weapon.AmmoType "BOEX1"
	Inventory.Pickupmessage "You got the Panzerkreuz MK. III!"
	Inventory.PickupSound 	"weapons/generic/pickup3"
	Tag "Panzerkreuz Mk. III"
	States
	{
	Deselect:
		TNT1 A 0 A_TakeInventory("PNZoomed",1)
		TNT1 A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_StopSound(6)
		TNT1 A 0 A_StopSound(7)
		WPLG A 1 Offset(2, 34)
		WPLG A 1 Offset(7, 39)
		WPLG A 1 Offset(10, 47)
		WPLG A 1 Offset(22, 58)
		WPLG A 1 Offset(32, 69)
		WPLG A 1 Offset(54, 81)
		WPLG A 1 Offset(67, 100)
		WPLG A 1 A_Lower
		Wait 
	Ready:
		TNT1 A 0 A_JumpIfInventory("PNZoomed",1,"ReadyZoomed")
		WPLG A 1 A_WeaponReady(WRF_ALLOWZOOM)
		TNT1 A 0 A_JumpifInventory("IsKicking",1,"Kick")
		TNT1 A 0 A_JumpIfInventory("IsKnifing",1,"Knife")
		NULL A 0 A_JumpIfInventory("SlidePlayer",1,"IsSliding")
		TNT1 A 0 A_JumpifInventory("IsBombing",1,"ThrowGrenade")
		NULL A 0 A_TakeInventory("IAmUnzooming",1)
		Loop
	ReadyZoomed:
		NULL A 0 A_PlaySound("FKPlayer/breath",6,0.7,1)
		WPLZ A 1 A_WeaponReady(WRF_ALLOWZOOM)
		NULL A 0 A_SetAngle(angle-frandom(-0.12,0.12))
		NULL A 0 A_SetPitch(pitch-frandom(-0.12,0.12))
		WPLZ A 1 A_WeaponReady(WRF_ALLOWZOOM)
		NULL A 0 A_SetAngle(angle+frandom(-0.12,0.12))
		NULL A 0 A_SetPitch(pitch-frandom(-0.12,0.12))
		NULL A 0 A_JumpifInventory("IsKicking",1,"Kick")
		NULL A 0 A_JumpIfInventory("IsKnifing",1,"Knife")
		NULL A 0 A_JumpIfInventory("SlidePlayer",1,"IsSliding")
		NULL A 0 A_TakeInventory("IAmZooming",1)
		Goto Ready
	Select:
		TNT1 A 0 A_Playsound("weapons/generic/select6",7)
		WPLG A 1 Offset(67, 100)
		WPLG A 1 Offset(54, 81)
		WPLG A 1 Offset(32, 69)
		WPLG A 1 Offset(22, 58)
		WPLG A 1 Offset(10, 47)
		WPLG A 1 Offset(7, 39)
		WPLG A 1 Offset(2, 34)
		WPLG A 1 A_Raise
		Wait
	Fire:
		TNT1 A 0 A_JumpIfInventory("BOEX1",3,1)
		Goto Dryfire
		TNT1 A 0 A_JumpIfInventory("PNZoomed",1,"FireZoomed")
		TNT1 A 0 A_Playsound("weapons/PZR/fire",7)
		NULL A 0 A_JumpIf(ACS_NamedExecuteWithResult("OldAmmoToggle")==1,2)
		NULL A 0 A_TakeInventory("BOEX1",1)
		NULL A 0 A_TakeInventory("BOEX1",1)
		NULL A 0 A_TakeInventory("BOEX1",1)
		TNT1 A 0 A_FireCustomMissile("PanzerRocket",Random(2,-2),0,5,0,0,Random(2,-2))
		TNT1 A 0 A_AlertMonsters
		TNT1 A 0 A_Gunflash
		TNT1 A 0 A_FireCustomMissile("GunSmokeSpawner",0,0,8,0,0,0)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPLF A 1 BRIGHT A_ZoomFactor(1.05)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("RecoilToggle")==0,2)
		TNT1 A 0 A_SetPitch(pitch -6.5)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPLF B 1 Offset(9,40) BRIGHT A_ZoomFactor(1)
		TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("RecoilToggle")==0,2)
		TNT1 A 0 A_SetPitch(pitch +1)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPLG A 1 Offset(7,38) BRIGHT
		TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("RecoilToggle")==0,2)
		TNT1 A 0 A_SetPitch(pitch +1)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPLG A 1 Offset(5,36)
		TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("RecoilToggle")==0,2)
		TNT1 A 0 A_SetPitch(pitch +0.5)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPLG A 1 Offset(3,35)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPLG A 1 Offset(2,34)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPLG A 1 Offset(1,33)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPLG A 1 Offset(0,32)
		WPLG A 15 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		Goto Ready
	FireZoomed:
		TNT1 A 0 A_JumpIfInventory("BOEX1",3,1)
		Goto Dryfire
		TNT1 A 0 A_Playsound("weapons/PZR/fire",7)
		NULL A 0 A_JumpIf(ACS_NamedExecuteWithResult("OldAmmoToggle")==1,2)
		NULL A 0 A_TakeInventory("BOEX1",1)
		NULL A 0 A_TakeInventory("BOEX1",1)
		NULL A 0 A_TakeInventory("BOEX1",1)
		TNT1 A 0 A_FireCustomMissile("PanzerRocket",0,0,0,4,0)
		TNT1 A 0 A_AlertMonsters
		TNT1 A 0 A_Gunflash
		TNT1 A 0 A_FireCustomMissile("GunSmokeSpawner",0,0,0)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPLZ B 1 BRIGHT
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("RecoilToggle")==0,2)
		TNT1 A 0 A_SetPitch(pitch -0.7)
		WPLZ A 1 Offset(0,37) A_ZoomFactor(1.75)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPLZ A 1 Offset(0,36) A_ZoomFactor(1.7)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPLZ A 1 Offset(0,35) A_ZoomFactor(1.65)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPLZ A 1 Offset(0,34) A_ZoomFactor(1.6)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPLZ A 1 Offset(0,33) A_ZoomFactor(1.55)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPLZ A 1 Offset(0,32) A_ZoomFactor(1.5)
		WPLZ A 16 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		Goto Ready
	Zoom:
		TNT1 A 0 A_JumpIfInventory("IAmUnzooming",1,"Ready")
		TNT1 A 0 A_JumpIfInventory("IAmZooming",1,"ReadyZoomed")
		TNT1 A 0 A_JumpIfInventory("PNZoomed",1,"UnZoom")
		TNT1 A 0 A_GiveInventory("PNZoomed",1)
		TNT1 A 0 A_Playsound("weapons/generic/select",7)
		WPLG B 2
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPLG C 1
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPLZ A 1 A_ZoomFactor(1.1)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPLZ A 1 A_ZoomFactor(1.3)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPLZ A 1 A_ZoomFactor(1.5)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		NULL A 0 A_GiveInventory("IAmZooming",3)
		Goto Ready
	UnZoom:
		TNT1 A 0 A_Playsound("weapons/generic/select",7)
		NULL A 0 A_StopSound(6)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPLZ A 1 A_ZoomFactor(1.4)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPLZ A 1 A_ZoomFactor(1.2)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPLZ A 1 A_ZoomFactor(1.0)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPLG C 1
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPLG B 2
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		TNT1 A 0 A_TakeInventory("PNZoomed",1)
		NULL A 0 A_GiveInventory("IAmUnzooming",6)
		Goto Ready
	Dryfire:
		TNT1 A 0 A_Print("No ammo",1)
		Goto Ready
	Kick:
		TNT1 A 0 A_JumpIfInventory("PNZoomed",1,"UnZoom")
		WPLG BC 1
		TNT1 A 3
		KICF A 1 Offset(-10,32)
		KICF CE 1
		KICF FG 1 A_Recoil(-1)
		TNT1 A 0 A_Jump(128,2)
		TNT1 A 0 A_PlaySound("FKPlayer/Grunt")
		KICF H 5 A_CustomPunch(6,0,0,"FightPuff") 
		KICF IGFEDC 1 
		KICF BA 1 A_Recoil(+0.5)
		TNT1 A 3
		WPLG CB 1
		Goto Ready
	IsSliding:
		TNT1 A 0 A_JumpIfInventory("PNZoomed",1,"UnZoom")
		TNT1 A 0 A_TakeInventory("SlidePlayer",1)
		TNT1 A 0 A_JumpIfInventory("CrouchPlayer",1,"Ready")
		WPLG BC 1
		TNT1 A 0 A_PlaySound("FKPlayer/slide/start",4)
		TNT1 A 0 A_PlaySound("FKPlayer/slide/loop",5,0.5,TRUE)
		TNT1 A 0 A_SetPitch(pitch+0.8)
		SLDK ABCDEF 2
		TNT1 A 0 A_SetPitch(pitch-0.8)
		SLDK G 6 A_FireCustomMissile("KickAttack",0,0,0,0)
		TNT1 A 0 A_StopSound(5)
		TNT1 A 0 A_PlaySound("FKPlayer/slide/end",6)
		SLDK HI 2
		Goto Ready
	Knife:
		TNT1 A 0 A_JumpIfInventory("PNZoomed",1,"UnZoom")
		WPLG BC 1
 		NULL A 0 Offset(-10,32)
		NULL A 5
		WP1L AB 1
		NULL A 0 A_Jump(86,2)
		NULL A 0 A_PlaySound("FKPlayer/Grunt")
		WP1L C 1 A_CustomPunch(8,0,0,"KnifePuff")
		WP1L DEF 1
		NULL A 5
		WPLG CB 1
		Goto Ready
	Throwgrenade:
		TNT1 A 0 A_JumpIfInventory("SniperZoomed2",1,"UnZoom")
		TNT1 A 0 A_JumpIf(waterlevel>2,"Dryfire")
		TNT1 A 0 A_JumpIfInventory("BOGR1",1,1)
		Goto Dryfire
		WPLG BC 1
		TNT1 A 0 A_StopSound(1)
		TNT1 A 0 Offset(-20,32)
		TNT1 A 3 Offset(-20,32)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		MND2 A 1 Offset(0,28)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		MND2 B 1 Offset(0,24)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		MND2 C 1 Offset(0,23)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		MND2 D 1 Offset(0,26) A_PlaySound("weapons/SHG/throw")
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		MND2 D 1 Offset(0,28)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		TNT1 A 0 A_SpawnItemEx("RealGrenade",0,1,24,cos(pitch)*40,0,sin(-pitch)*40,3,SXF_TRANSFERPITCH|SXF_NOCHECKPOSITION)
		TNT1 A 0 A_TakeInventory("BOGR1",1)
		MND2 E 1 Offset(-3,30)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		MND2 E 1 Offset(-6,31)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		MND2 F 1 Offset(-9,32)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		MND2 F 1 Offset(-12,33)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		TNT1 A 0 A_TakeInventory("GetOnWithIt", 100)
		TNT1 A 0 A_JumpIfNoAmmo("Dryfire")
		TNT1 A 5 Offset (75, 152)
		TNT1 A 1 Offset (6, 42)
		WPLG CB 1
		Goto Ready
	Flash:
		TNT1 A 4 Bright A_Light1
		Goto LightDone
		TNT1 A 4 Bright A_Light2
		Goto LightDone
 	Spawn:
		WPLP A -1
		Stop
	}
}

//==============================================================================
// Panzerkreuz projectile actors
//==============================================================================

ACTOR PanzerRocket
{
	+RANDOMIZE
	+DEHEXPLOSION
	+ROCKETTRAIL
	Radius 3
	Height 3
	Speed 50
	Damage 45
	Projectile
	Damagetype 	Explode
	SeeSound 	"weapons/PZR/loop"
	DeathSound  "weapons/LW6/explode"
	Obituary 	"$OB_MPROCKET"
	Decal 		"Crater"
	Scale 0.9
	States
	{
	Spawn:
		TNT1 AAAAAA 0 NoDelay A_SpawnItem("GunSmokeSpawner",0,0,0)
		WPLB A 1 BRIGHT
		Loop
	Death:
		TNT1 A 0 A_StopSound(6)
		TNT1 A 1 A_Explode(156,156)
		TNT1 A 0 A_PlaySound("weapons/explosion/ear",5,1,0,1)
		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 A 0 A_SpawnItemEx("DetectFloorCrater",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
		TNT1 A 0 A_SpawnItem("FirstOneExplosionSpawner")
		TNT1 AAAAAAAAAAAAAAA 0 A_SpawnDebris("BulletSparks")
		TNT1 A 0 A_SetScale(1.36)
		TNT1 A 0 A_SetTranslucent(0.65, 1)
		BLAM ABCDEFGHIJKLMNOP 2 BRIGHT
		Stop	
	}
}

ACTOR SmallRocket : PanzerRocket
{
	Scale 0.3
	Speed 25
	Damage 2
	States
	{
	Spawn:
		TNT1 A 0 NoDelay A_SpawnItem("GunSmokeSpawner",0,0,0)
		WPLB A 1 BRIGHT
		Loop
	Death:
		TNT1 A 0 A_StopSound(6)
		TNT1 A 1 A_Explode(48,96)
		TNT1 A 0 Radius_Quake (2, 36, 0, 15, 0)
		TNT1 A 0 A_NoBlocking
		TNT1 A 0 A_Scream
		TNT1 A 0 A_SpawnItemEx("DetectFloorCrater",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
		TNT1 A 0 A_SpawnItem("FirstOneExplosionSpawner")
		TNT1 A 0 A_SpawnDebris("BulletSparks")
		TNT1 A 0 A_SetScale(1.36)
		TNT1 A 0 A_SetTranslucent(0.65, 1)
		BLAM ABCDEFGHIJKLMNOP 2 BRIGHT
		Stop	
	}
}