actor BounceBallWep : Weapon {}

actor BounceBallWepSH : BaseMM8BDMWep
{ 
+INVENTORY.RESTRICTABSOLUTELY Inventory.RestrictedTo megamans
Weapon.AmmoUse 2
Weapon.AmmoGive 28
Weapon.SlotNumber 3
Inventory.Pickupmessage "$PU_BOUNCEBALL"
Obituary "$OB_BOUNCEBALL"
Tag "$TAG_BOUNCEBALL"
weapon.ammotype "BounceBallAmmo"
inventory.icon "BBALICON"
States
{
SpawnLoop:
11WP D 1
loop
Ready:
BBLL A 0 ACS_ExecuteAlways(998,0,243)
BBLL A 1 A_WeaponReady
Goto Ready+1
Deselect:
TNT1 AAAAAAAAAAAAAAAAAAAAAA 0 A_Lower
BBLL A 1 A_Lower
Loop
Select:
TNT1 AAAAAAAAAAAAAAAAAAAAAA 0 A_Raise
BBLL A 1 A_Raise
Loop
Fire:
BBLL A 0 A_JumpIfNoAmmo("NoAmmo")
BBLL A 0 A_Jump(8,"FireX")
BBLL A 0 A_PlaySoundEx("weapon/bounceshot","Weapon")
BBLL A 0 A_FireCustomMissile("BounceBall",0,1,8,0)
BBLL A 0 A_FireCustomMissile("BounceBall",7.5,0,8,0)
BBLL A 0 A_FireCustomMissile("BounceBall",-7.5,0,8,0)
BBLL ABC 2
BBLL AAAAA 4
BBLL A 0 A_Refire
Goto Ready+1
FireX:
BBLL A 0 A_PlaySoundEx("weapon/bounceshot","Weapon")
BBLL A 0 A_FireCustomMissile("BounceBallX",0,1,8,0)
BBLL A 0 A_FireCustomMissile("BounceBallX",7.5,0,8,0)
BBLL A 0 A_FireCustomMissile("BounceBallX",-7.5,0,8,0)
BBLL ABC 2
BBLL AAAAA 4
BBLL A 0 A_Refire
Goto Ready+1
NoAmmo:
BBLL A 1 ACS_Execute(979,0)
Goto Ready+1
}
}

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

actor BounceBallProtect : PowerProtection
{
Powerup.Duration 2
damagefactor "BounceBall", 0.5
}

actor BounceBall
{
PROJECTILE
+HEXENBOUNCE
+BOUNCEONACTORS
+CANBOUNCEWATER
+USEBOUNCESTATE
WALLBOUNCEFACTOR 2
BOUNCEFACTOR 2
seesound "weapon/bouncebounce"
damagetype "BounceBall"
Obituary "$OB_BOUNCEBALL"
speed 40
Radius 16
Height 16
scale 2.5
damage (13)
States
{
Spawn:
BBAL D 0 A_JumpIfInventory("BounceBallTimer",10,"Pop")
BBAL E 0 A_GiveInventory("BounceBallTimer",1)
BBAL DEDF 4
loop
Bounce:
BBAL D 0 A_ChangeFlag("NOGRAVITY",0)
goto Spawn
Pop:
TNT1 A 0 A_PlaySoundEx("weapon/bounceexplode", "Weapon")
TNT1 A 0 A_SpawnItemEx("BounceBallPop")
TNT1 A 0 A_SpawnItemEx("BounceBallConfettiScatter")
Stop
Bounce.Actor:
BBAL D 0 A_ChangeFlag("THRUACTORS", 1)
BBAL D 0 A_ChangeFlag("NOGRAVITY", 0)
BBAL D 2 A_ChangeVelocity(40.0,0,velz,CVF_RELATIVE|CVF_REPLACE)
BBAL F 2
BBAL F 0 A_ChangeFlag("THRUACTORS",0)
Goto Spawn

}
}
actor BounceBallX : BounceBall
{
States
{
Spawn:
BBAL D 0 A_JumpIfInventory("BounceBallTimer",10,"Pop")
BBAL E 0 A_GiveInventory("BounceBallTimer",1)
BBAL GHGI 4
loop
Bounce:
BBAL I 0 A_ChangeFlag("NOGRAVITY",0)
goto Spawn
Bounce.Actor:
BBAL G 0 A_ChangeFlag("THRUACTORS", 1)
BBAL G 0 A_ChangeFlag("NOGRAVITY", 0)
BBAL G 2 A_ChangeVelocity(40.0,0,velz,CVF_RELATIVE|CVF_REPLACE)
BBAL I 2
BBAL I 0 A_ChangeFlag("THRUACTORS",0)
Goto Spawn

}
}

actor BounceBallPop
{
+NOINTERACTION
States
{
Spawn:
MMFX BCDE 2
Stop
}
}

actor BounceBallConfettiScatter
{
+NOINTERACTION
States
{
Spawn:
TNT1 AAAAAAAAAA 0 A_SpawnItemEx("ConfettiBit",0,0,0,7,0,random(-20,20),random(0,360))
Stop
}
}

actor ConfettiBit
{
+NOINTERACTION
States
{
Spawn:
PCNF ABCDEFGHI 2
Stop
}
}

actor BounceBallTimer : Inventory
{
inventory.amount 1
inventory.maxamount 10
}