//==============================================================================
// Puls-Kanone (Based on TNO's LaserKraftWerk)
//==============================================================================

ACTOR HDBFG9000 : KriegslandHeavyWeapon
{
	+INVENTORY.UNDROPPABLE
	Weapon.SelectionOrder 100
	Weapon.AmmoUse 50
	Weapon.SlotNumber 7
	Weapon.AmmoGive 60
	Weapon.AmmoType "BOCE1"
	Inventory.Pickupmessage "You got the VFR-245 Puls-Kanone!"
	Inventory.PickupSound 	"weapons/generic/pickup3"
	Tag "VFR-245 Puls-Kanone"
	Scale 1.0
	States
	{
	Deselect:
		TNT1 A 0 A_StopSound(6)
		TNT1 A 0 A_StopSound(7)
		WPAG A 1 Offset(2, 34)
		WPAG A 1 Offset(7, 39)
		WPAG A 1 Offset(10, 47)
		WPAG A 1 Offset(22, 58)
		WPAG A 1 Offset(32, 69)
		WPAG A 1 Offset(54, 81)
		WPAG A 1 Offset(67, 100)
		WPAG A 1 A_Lower
		Wait 
	Ready:
		TNT1 A 0 A_Playsound("weapons/PKN/idle",6,1,1)
		WPAG A 4 A_WeaponReady
		NULL A 0 A_JumpifInventory("IsBombing",1,"ThrowGrenade")
		NULL A 0 A_JumpIfInventory("SlidePlayer",1,"IsSliding")
		NULL A 0 A_JumpIfInventory("IsKnifing",1,"Knife")
		NULL A 0 A_JumpifInventory("IsKicking",1,"Kick")
		WPAG B 4 A_WeaponReady
		NULL A 0 A_JumpifInventory("IsBombing",1,"ThrowGrenade")
		NULL A 0 A_JumpIfInventory("SlidePlayer",1,"IsSliding")
		NULL A 0 A_JumpIfInventory("IsKnifing",1,"Knife")
		NULL A 0 A_JumpifInventory("IsKicking",1,"Kick")
		WPAG C 4 A_WeaponReady
		NULL A 0 A_JumpifInventory("IsBombing",1,"ThrowGrenade")
		NULL A 0 A_JumpIfInventory("SlidePlayer",1,"IsSliding")
		NULL A 0 A_JumpIfInventory("IsKnifing",1,"Knife")
		NULL A 0 A_JumpifInventory("IsKicking",1,"Kick")
		WPAG D 4 A_WeaponReady
		NULL A 0 A_JumpifInventory("IsBombing",1,"ThrowGrenade")
		NULL A 0 A_JumpIfInventory("SlidePlayer",1,"IsSliding")
		NULL A 0 A_JumpIfInventory("IsKnifing",1,"Knife")
		NULL A 0 A_JumpifInventory("IsKicking",1,"Kick")
		WPAG C 4 A_WeaponReady
		NULL A 0 A_JumpifInventory("IsBombing",1,"ThrowGrenade")
		NULL A 0 A_JumpIfInventory("SlidePlayer",1,"IsSliding")
		NULL A 0 A_JumpIfInventory("IsKnifing",1,"Knife")
		NULL A 0 A_JumpifInventory("IsKicking",1,"Kick")
		WPAG B 4 A_WeaponReady
		NULL A 0 A_JumpifInventory("IsBombing",1,"ThrowGrenade")
		NULL A 0 A_JumpIfInventory("SlidePlayer",1,"IsSliding")
		NULL A 0 A_JumpIfInventory("IsKnifing",1,"Knife")
		NULL A 0 A_JumpifInventory("IsKicking",1,"Kick")
		Loop
	Select:
		TNT1 A 0 A_Playsound("weapons/generic/select6",7)
		WPAG A 1 Offset(67, 100)
		WPAG A 1 Offset(54, 81)
		WPAG A 1 Offset(32, 69)
		WPAG A 1 Offset(22, 58)
		WPAG A 1 Offset(10, 47)
		WPAG A 1 Offset(7, 39)
		WPAG A 1 Offset(2, 34)
		WPAG A 1 A_Raise
		Wait
	Fire:	
		TNT1 A 0 A_JumpIfInventory("BOCE1",1,1)
		Goto Dryfire
		TNT1 A 0 A_Playsound("weapons/PKN/fire",7)
		WPAG B 3 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPAG C 3 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPAG D 3 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPAG E 3 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPAG F 3 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		TNT1 A 0 A_FireCustomMissile("PulsBall",1,1,15,-5,0,2)
		TNT1 A 0 A_AlertMonsters
		TNT1 A 0 A_Gunflash
		TNT1 A 0 A_FireCustomMissile("GunSmokeSpawner",0,0,10,0,0,0)
		TNT1 A 0 A_Gunflash
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPAF A 2 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.9)
		WPAG F 1 Offset(18,48)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPAG F 1 Offset(16,44)
		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.8)
		WPAG F 1 Offset(14,42)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPAG F 1 Offset(12,40)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPAG F 1 Offset(10,38)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPAG F 1 Offset(8,36)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPAG F 1 Offset(4,34)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		WPAG F 1 Offset(0,33)
		WPAG EDCBA 4 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		TNT1 A 0 A_ReFire
		Goto Ready
	Dryfire:
		TNT1 A 0 A_Print("No ammo",1)
		Goto Ready
	Kick:
		WPAT AB 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
		WPAT BA 1
		Goto Ready
	IsSliding:
		TNT1 A 0 A_TakeInventory("SlidePlayer",1)
		TNT1 A 0 A_JumpIfInventory("CrouchPlayer",1,"Ready")
		WPAT AB 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:
		WPAT AB 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
		WPAT BA 1
		Goto Ready
	Throwgrenade:
		TNT1 A 0 A_JumpIf(waterlevel>2,"Dryfire")
		TNT1 A 0 A_JumpIfInventory("BOGR1",1,1)
		Goto Dryfire
		WPAT AB 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)
		WPAH BA 1
		Goto Ready
	Flash:
		TNT1 A 7 A_Light2
		TNT1 A 7 A_Light1
		TNT1 A 2 A_Light0
		Stop
 	Spawn:
		WPAP A -1
		Stop
	}
}

//==============================================================================
// Puls-Kanone projectile actors
//==============================================================================

ACTOR 2704Ball2 : Plasmaball
{
	SeeSound "weapons/EHW/fire"
	DeathSound "weapons/plasma/death"
	Decal RedPlasmaScorch
	States
	{
	Spawn:
		BBG2 AB 6 BRIGHT
		Loop
	Death:
		BBG2 CDEF 3 BRIGHT
		BBG2 GHI 3 BRIGHT ThrustThingZ(0,5,0,0)
		Stop
	}
}

ACTOR PulsBall : BFGBall
{
  Radius 2
  Height 4
  Speed 20
  Damage 120
  Projectile
  RenderStyle Add
  ExplosionDamage 120
  DamageType Plas
  Decal Scorch
  Var int user_lmine;
  VSpeed 0
  Alpha 1.0
  States
  {
	Spawn:
		WPAB ABCD 1 BRIGHT
	Ball:	
		WPAB EE 1 BRIGHT A_CustomMissile("2704Ball2", 0, 0, random(-179, 179), 1, random(-15, 15))
		WPAB FF 1 BRIGHT A_CustomMissile("2704Ball2", 0, 0, random(-179, 179), 1, random(-15, 15))
		WPAB GG 1 BRIGHT A_CustomMissile("2704Ball2", 0, 0, random(-179, 179), 1, random(-15, 15))
		WPAB HH 1 BRIGHT A_CustomMissile("2704Ball2", 0, 0, random(-179, 179), 1, random(-15, 15))
		WPAB II 1 BRIGHT A_CustomMissile("2704Ball2", 0, 0, random(-179, 179), 1, random(-15, 15))
		Loop
	Death:
		TNT1 A 1 A_Explode(120,240,XF_HURTSOURCE)
		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_SetTranslucent(0.65, 1)
	Blast:
		TNT1 A 0 A_CustomMissile("MineBlastVisual",0,0,user_lmine,CMF_AIMDIRECTION)
		TNT1 A 0 A_SetUserVar("user_lmine",user_lmine+1)
		TNT1 A 0 A_JumpIf(user_lmine==360,"EndBlast")
		Loop
	EndBlast:
		TNT1 A 0
		WPAB JKL 3 BRIGHT
		WPAB M 3 BRIGHT
		WPAB NOPQ 3 BRIGHT
		Stop
  }
}