///////////////////////
//    POLICE BUNBY   // 				by MegaVile
///////////////////////

actor PoliceBunbyWep_NormalBar : NormalBar{args 69,241}
actor PoliceBunbyWep_ScriptBar : ScriptBar{}
actor PoliceBunbyWep : BaseMM8BDMWep 32010
{
//$Category WilyInc-Weapons
//$Title Police Bunby
//Weapon.AmmoUse 1
Weapon.AmmoGive 28
Weapon.SlotNumber 3
Inventory.Pickupmessage "$PU_POLICEBUNBY"
Obituary "$OB_POLICEBUNBY"
Tag "$TAG_POLICEBUNBY"
weapon.ammotype "PoliceBunbyAmmo"
inventory.icon "PLBNICON"
States
{
SpawnLoop:
PLBN Z -1
loop
Ready:
PLBN A 0 ACS_NamedExecuteWithResult("core_weaponcolor",COLOR_POLICEBUNBY)
PLBN A 1 A_WeaponReady
Goto Ready+1
ReadyC: Goto Ready+1
Ready2:
PLBN A 1 A_WeaponReady(WRF_DISABLESWITCH)
PLBN A 1 A_JumpIfInventory("PoliceBunbyFlightAmmo",1,"Ready2")
PLBN A 2
goto BunbyEnd
//GiveAmmo1:
Deselect:
PLBN A 0 
goto DeselectSwap
Select:
PLBN A 0 
goto SelectSwap
Fire:
PLBN A 0 A_JumpIfInventory("PoliceBunbyHovering",1,"HoverFire")
PLBN A 1 A_JumpIfNoAmmo("NoAmmo")
PLBN B 0 A_JumpIfInventory("PoliceBunbyAmmo",8,1)
goto NoAmmo
PLBN B 0 A_PlaySound("misc/fakeshot", "Weapon")
PLBN A 1
PLBN B 0 A_Stop
PLBN A 0 ThrustThingZ(0,68,0,0)
PLBN B 0 A_SpawnItem("PoliceBunbyCatcher",0,60)
JSTM B 0 A_JumpIfInventory("PlayerPropertyNoGravity",1,2)
JSTM B 0 A_ChangeFlag("NOGRAVITY",1)
PLBN B 0 A_GiveInventory("NoJumpCancel",1)
PLBN AAAAAAAAAAAAAAAAAAAAAA 1 A_ChangeVelocity(0, 0, velz, CVF_REPLACE)
PLBN B 0 A_tAKEInventory("NoJumpCancel",1)
JSTM B 0 A_JumpIfInventory("PlayerPropertyNoGravity",1,2)
JSTM B 0 A_ChangeFlag("NOGRAVITY",0)
PLBN B 0 A_Stop

PLBN B 0 A_GiveInventory("PoliceBunbyGravityGiver",1)
PLBN B 0 A_GiveInventory("PoliceBunbyHovering",1)
TNT1 A 0 A_GiveInventory("PoliceBunbySpeed",1)
PLBN A 1 A_GiveInventory("PoliceBunbyFlightAmmo",175)
PLBN A 1 A_Gunflash
goto Ready2
HoverFire:
PLBN B 0 A_JumpIfInventory("PoliceBunbyFlightAmmo",8,1)
goto BunbyEnd
PLBN B 0 A_PlaySoundEx("misc/fakeshot", "Weapon")
PLBN B 0 A_FireCustomMissile("PoliceBunbyShot",frandom(-3,3),0,8,0,0,frandom(-3,3))
PLBN B 1
PLBN C 2 
PLBN A 1
PLBN A 0 A_Refire
Goto Ready2
BunbyEnd:
PLB0 G 0 A_TakeInventory("PoliceBunbyFlightAmmo",175)
PLB0 G 0 A_TakeInventory("PoliceBunbyAmmo",8)
PLB0 G 0 A_TakeInventory("PoliceBunbyHovering",1)
PLB0 G 0 A_TakeInventory("PoliceBunbySpeed",1)
PLB0 G 0 A_TakeInventory("PoliceBunbyGravity",1)
PLB0 G 0 A_PlaySoundEx("weapon/drillexplode", "Weapon")
PLB0 G 3 A_SpawnItemEX("DrillExplode",0,0,60)
goto BunbyFall
BunbyFall:
PLB0 GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG 1 A_JumpIf(CallACS("core_CheckFooting"),"Landed")
//loop
Landed:
PLB0 G 4
PLB0 HIJK 2
goto Ready+1
Altfire:
PLBN A 0 A_JumpIfInventory("PoliceBunbyHovering", 1,3)
PLBN A 0 A_JumpIfInventory("Vile_ClassAltfire", 1, "ClassAltfire")
PLBN A 0 A_JumpIf(CallACS("Vile_class_altfire"), "ClassAltfire")
PLBN A 1 A_JumpIfInventory("MM8BDMPlayer", 1, 1)
wait
PLBN B 0 A_JumpIfInventory("PoliceBunbyHovering", 1,"BunbyEnd")
PLBN B 0 A_JumpIfNoAmmo("NoAmmo")
PLBN B 0 A_JumpIfInventory("PoliceBunbyAmmo",1,1)
goto NoAmmo
PLBN A 0 A_TakeInventory("PoliceBunbyAmmo",1)
PLBN B 0 A_PlaySoundEx("misc/fakeshot", "Weapon")
PLBN BB 0 A_FireCustomMissile("PoliceBunbyShot",0,1,8,0)
PLBN B 3
PLBN C 1
PLBN A 1
Goto Ready+1
NoAmmo:
PLBN A 0 ACS_NamedExecuteAlways("core_noammo",0)
Goto Ready+1
Flash:
TNT1 A 0 A_JumpIfInventory("PoliceBunbyHovering",1,1)
goto NoFlash
TNT1 A 0 A_TakeInventory("PoliceBunbyFlightAmmo",1)
TNT1 A 0 A_GiveInventory("PoliceBunbyGravityGiver",1)
TNT1 A 0 A_CheckFloor(2)
TNT1 A 0 A_GiveInventory("PoliceBunbySpeed",1)
TNT1 A 1 //A_ChangeVelocity(momx, momy, 0, CVF_REPLACE)
TNT1 A 0 A_JumpIfInventory("PoliceBunbyFlightAmmo",1,"Flash")
stop
ClassAltfire:
DATK A 0 
goto Super::Altfire
}
}

ACTOR PoliceBunbySpeed : PowerSpeed
{
+POWERSPEED.NOTRAIL
  Powerup.Duration 3
  Speed 1.99
}

Actor PoliceBunbyGravityGiver : PowerApropGiver {}

actor PoliceBunbyGravity : Powerup
{
powerup.duration 20
+INVENTORY.ALWAYSPICKUP
}


actor PoliceBunbyAmmo : Ammo
{
inventory.amount 1
inventory.maxamount 28
+INVENTORY.IGNORESKILL
}

actor PoliceBunbyFlightAmmo : Inventory
{
inventory.amount 1
inventory.maxamount 175
+INVENTORY.IGNORESKILL
}

actor PoliceBunbyHovering : Inventory
{
inventory.amount 1
inventory.maxamount 1
+INVENTORY.IGNORESKILL
}

actor PoliceBunbyCatcher : BasicShieldWarper
{
translation "217:217=69:69"
+NOBLOCKMAP
+NOINTERACTION
+NOGRAVITY
height 29
radius 19
reactiontime 50
scale 2.5
States
{
Spawn:
BUNB C 0
TNT1 A 1 A_GiveInventory("MM8BDMProjSpawnFuncClient",1)
BUNB B 1 A_Warp(AAPTR_TARGET,0,0,60+5000,0,WARPF_NOCHECKPOSITION)
BUNB B 1 A_Warp(AAPTR_TARGET,0,0,60+4420,0,WARPF_NOCHECKPOSITION)
BUNB B 1 A_Warp(AAPTR_TARGET,0,0,60+3320,0,WARPF_NOCHECKPOSITION)
BUNB B 1 A_Warp(AAPTR_TARGET,0,0,60+2250,0,WARPF_NOCHECKPOSITION)
BUNB A 1 A_Warp(AAPTR_TARGET,0,0,60+1880,0,WARPF_NOCHECKPOSITION)
BUNB A 1 A_Warp(AAPTR_TARGET,0,0,60+1440,0,WARPF_NOCHECKPOSITION)
BUNB A 1 A_Warp(AAPTR_TARGET,0,0,60+1180,0,WARPF_NOCHECKPOSITION)
BUNB A 1 A_Warp(AAPTR_TARGET,0,0,60+930,0,WARPF_NOCHECKPOSITION)
BUNB B 1 A_Warp(AAPTR_TARGET,0,0,60+800,0,WARPF_NOCHECKPOSITION)
BUNB B 1 A_Warp(AAPTR_TARGET,0,0,60+680,0,WARPF_NOCHECKPOSITION)
BUNB B 1 A_Warp(AAPTR_TARGET,0,0,60+560,0,WARPF_NOCHECKPOSITION)
BUNB B 1 A_Warp(AAPTR_TARGET,0,0,60+490,0,WARPF_NOCHECKPOSITION)
BUNB A 1 A_Warp(AAPTR_TARGET,0,0,60+400,0,WARPF_NOCHECKPOSITION)
BUNB A 1 A_Warp(AAPTR_TARGET,0,0,60+320,0,WARPF_NOCHECKPOSITION)
BUNB A 1 A_Warp(AAPTR_TARGET,0,0,60+250,0,WARPF_NOCHECKPOSITION)
BUNB A 1 A_Warp(AAPTR_TARGET,0,0,60+190,0,WARPF_NOCHECKPOSITION)
BUNB B 1 A_Warp(AAPTR_TARGET,0,0,60+130,0,WARPF_NOCHECKPOSITION)
BUNB B 1 A_Warp(AAPTR_TARGET,0,0,60+90,0,WARPF_NOCHECKPOSITION)
BUNB B 1 A_Warp(AAPTR_TARGET,0,0,60+50,0,WARPF_NOCHECKPOSITION)
BUNB A 1 A_Warp(AAPTR_TARGET,0,0,60+30,0,WARPF_NOCHECKPOSITION)
BUNB A 1 A_Warp(AAPTR_TARGET,0,0,60+10,0,WARPF_NOCHECKPOSITION)
BUNB A 1 A_Warp(AAPTR_TARGET,0,0,60+5,0,WARPF_NOCHECKPOSITION)
TNT1 A 0 ACS_NamedExecuteAlways("vile_shieldwarper_bunbi",0)
SpawnLoop:
BUNB C 0 A_PlaySoundEx("weapon/gyroattack","Weapon")
BUNB CCCCDDDD 1 A_Warp(AAPTR_TARGET,0,0,60,0,WARPF_NOCHECKPOSITION)
loop
Death:
BUNB C 0 A_PlaySoundEx("weapon/drillexplode", "Weapon")
BUNB C 1 A_SpawnItem("DrillExplode")
stop
}
}

actor PoliceBunbyShot : BasicFastProjectile
{
Speed 65
Obituary "$OB_POLICEBUNBY"
damagetype "PoliceBunby"
Damage (CallACS("vile_cbm_damage",11))
radius 10
height 7
scale 2.5
PROJECTILE
States
{
	Spawn:
	BASB A -1
	stop
	Death:
	MMFX BCDE 2 
	stop
}
}
actor PoliceBunbyDestroy : Inventory
{
inventory.amount 1
inventory.maxamount 1
+INVENTORY.IGNORESKILL
}
