actor MegaBallWep : BaseMM8BDMWep 11093
{
//$Category MM8BDM-Weapons
//$Title Mega Ball
//$Sprite WEA4D0
Weapon.AmmoUse 2
Weapon.AmmoGive 28
Weapon.SlotNumber 2
Inventory.Pickupmessage "$PU_MEGABALL"
Obituary "$OB_MEGABALL"
Tag "$TAG_MEGABALL"
weapon.ammotype "MegaBallAmmo"
inventory.icon "MEGABALI"
States
{
SpawnLoop:
WEA4 D -1
loop
Ready:
MBAL N 0 ACS_ExecuteAlways(998,0,100)
Ready0:
MBAL N 0 A_TakeInventory("BallKickCounter", 999)
Ready1:
MBAL N 0 A_JumpIfInventory("KickedBall",1,"KickConfirm")
MBAL N 1 A_WeaponReady
loop
Deselect:
MBAL N 0 A_TakeInventory("BallFlag", 999)
TNT1 AAAAAAAAAAAAAAAAAAAAAA 0 A_Lower
MBAL N 1 A_Lower
Loop
Select:
TNT1 AAAAAAAAAAAAAAAAAAAAAA 0 A_Raise
MBAL N 1 A_Raise
Loop
Fire:
MBAL N 0 A_JumpIfNoAmmo("NoAmmo")
MBAL N 0 A_JumpIfInventory("BallFlag",1,"NewBall")
MBAL N 0 A_GiveInventory("BallFlag",100)
MBAL N 0 A_PlaySoundEx("weapon/mbuster","Weapon")
MBAL N 0 A_TakeInventory("MegaBallAmmo",2,TIF_NOTAKEINFINITE)
MBAL N 0 A_SpawnItemEx("MegaBallStart",48,8,32,momx*0.01,momy*0.01,0,0,SXF_ABSOLUTEMOMENTUM)
MBAL NOP 2
MBAL N 3
MBAL N 1 A_Refire("AutoKick")
MBAL NNNNN 1 A_JumpIfInventory("KickedBall",1,"MegaBallKick")
CheckForKick:
MBAL N 0 A_GiveInventory("BallKickCounter", 1)
MBAL N 1 A_JumpIfInventory("KickedBall",1,"MegaBallKick")
MBAL N 0 A_JumpIfInventory("BallKickCounter", 10, "Ready0")
loop
AutoKick:
MBAL N 0 A_GiveInventory("BallKickCounter", 1)
MBAL N 0 A_JumpIfInventory("KickedBall",1,"MegaBallKick")
MBAL N 0 A_JumpIfInventory("BallKickCounter", 5, "MegaBallKick")
MBAL N 1 A_Refire("AutoKick")
Goto Ready0
Altfire:
MBAL N 0 A_JumpIfNoAmmo("NoAmmo")
MBAL N 0 A_JumpIfInventory("BallFlag",1,"AltNewBall")
MBAL N 0 A_GiveInventory("BallFlag",100)
MBAL N 0 A_PlaySoundEx("weapon/mbuster","Weapon")
MBAL N 0 A_TakeInventory("MegaBallAmmo", 2, TIF_NOTAKEINFINITE)
MBAL N 0 A_SpawnItemEx("MegaBallDroppedStart",48,8,32,0,0,0,0)
MBAL NOP 2
MBAL NNNNNNNNNNNN 1 A_JumpIfInventory("KickedBall",1,"MegaBallKick")
Goto Ready0
MegaBallKick:
MBAL N 1 A_JumpIfInventory("BallFlag", 1, "KickConfirm")
Goto Ready0
KickConfirm:
MBAL Q 0 A_TakeInventory("KickedBall",1)
MBAL Q 0 A_FireCustomMissile("MegaBallKicked",0,0,0,0)
MBAL Q 0 A_TakeInventory("BallFlag",999)
MBAL Q 2
MBAL R 4
MBAL Q 3
MBAL N 12
Goto Ready1
AltNewBall:
MBAL N 0
MBAL N 0 A_TakeInventory("BallFlag",100)
MBAL NN 2
Goto Altfire+1
NewBall:
MBAL N 0
MBAL N 0 A_TakeInventory("BallFlag",100)
MBAL NN 2
Goto Fire+1
NoAmmo:
MBAL N 1 ACS_Execute(979,0)
Goto Ready1
}
}

actor BallKickCounter : Inventory 
{
inventory.maxamount 9999
}

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

Actor KickedBall : Once {}

Actor BallFlag : Inventory
{
Inventory.Amount 1
Inventory.maxamount 999
}

actor MegaBallStart
{
+MISSILE
damagetype "MegaBall"
Obituary "$OB_MEGABALL"
+DONTREFLECT
+STEPMISSILE
maxstepheight 32
damage (8)
radius 12
height 12
speed 0
scale 2.5
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_SpawnItemEx("MegaBall",0,0,0,momx*100,momy*100,-1,0,8)
stop
Death:
TNT1 A 0 A_SpawnItemEx("ExplosionEffect1", 0, 0, 12.5)
TNT1 A 0 A_TakeFromTarget("BallFlag",999)
TNT1 A 2
stop
}
}

actor MegaBallDroppedStart : MegaBallStart
{
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_SpawnItemEx("MegaBallDropped",0,0,0,momx*100,momy*100,-1,0,8)
stop
}
}

actor MegaBall
{
//$Category MM8BDM-Weapons
PROJECTILE
damagetype "MegaBall"
Obituary "$OB_MEGABALL"
-NOGRAVITY
+NOBLOOD
+DONTSPLASH
//+FIXMAPTHINGPOS
+FORCEXYBILLBOARD
+DONTREFLECT

//+DOOMBOUNCE
+NOEXPLODEFLOOR
+BOUNCEONFLOORS
+BOUNCEONWALLS
+BOUNCEONCEILINGS
+USEBOUNCESTATE

BounceFactor 0.5
WallBounceFactor 0.65
BounceCount 25
reactiontime 1
damage (45)
radius 12
height 12
speed 0
scale 2.5
States
{
Spawn:
MBAL B 0
MBAL B 0 ThrustThingZ(0,1,0,1)//Sync
MBAL B 0 ThrustThing(angle*256/360,0)
Spawn0:
MBAL B 0 A_Jump(256,1,5,9,13,17,21,25)
Spawn1:
MBAL HH 1 A_JumpIfCloser(24,"KickMe")
MBAL H 0 A_JumpIfInTargetInventory("BallFlag",1,2)
MBAL H 1 A_CountDown
wait
MBAL GG 1 A_JumpIfCloser(24,"KickMe")
MBAL G 0 A_JumpIfInTargetInventory("BallFlag",1,2)
MBAL G 1 A_CountDown
wait
MBAL FF 1 A_JumpIfCloser(24,"KickMe")
MBAL F 0 A_JumpIfInTargetInventory("BallFlag",1,2)
MBAL F 1 A_CountDown
wait
MBAL EE 1 A_JumpIfCloser(24,"KickMe")
MBAL E 0 A_JumpIfInTargetInventory("BallFlag",1,2)
MBAL E 1 A_CountDown
wait
MBAL DD 1 A_JumpIfCloser(24,"KickMe")
MBAL D 0 A_JumpIfInTargetInventory("BallFlag",1,2)
MBAL D 1 A_CountDown
wait
MBAL CC 1 A_JumpIfCloser(24,"KickMe")
MBAL C 0 A_JumpIfInTargetInventory("BallFlag",1,2)
MBAL C 1 A_CountDown
wait
MBAL BB 1 A_JumpIfCloser(24,"KickMe")
MBAL B 0 A_JumpIfInTargetInventory("BallFlag",1,"Spawn1")
MBAL B 1 A_CountDown
wait

Bounce.Floor:
MBAL "#" 0 A_JumpIf(sqrt(momx*momx+momy*momy+momz*momz)<=1,"Spawn3Start")
goto Spawn0

Spawn3Start:
MBAL "#" 0 A_ChangeFlag("USEBOUNCESTATE",0)
MBAL "#" 0 A_ChangeFlag("BOUNCEONFLOORS",0)
MBAL "#" 0 A_ChangeVelocity(0,0,0,2)
MBAL "#" 0 ThrustThing(angle*256/360,0)//Sync
MBAL "#" 0 ThrustThingZ(0,0,0,1)
MBAL "##" 1 A_JumpIfCloser(24,"KickMe")
MBAL "#" 0 A_ChangeFlag("BOUNCEONFLOORS",1)
Spawn3:
MBAL "#" 0
MBAL "##" 1 A_JumpIfCloser(24,"KickMe")
MBAL "#" 0 A_TakeFromTarget("BallFlag",1)
MBAL "##" 1 A_JumpIfInTargetInventory("BallFlag",1,"Spawn3")
MBAL "#" 1 A_CountDown
wait

KickMe:
MBAL "#" 0 A_ChangeFlag("USEBOUNCESTATE",0)
MBAL "#" 1 A_GiveToTarget("BallAction",1)
MBAL "#" 1 A_CountDown
wait
Death:
MBAL "#" 0 A_ChangeFlag("NOGRAVITY",1)
MBAL "#" 0 A_Stop
MBAL "#" 0 A_TakeFromTarget("BallFlag",999)
MBAL "#" 2
TNT1 A 0 A_SpawnItemEx("ExplosionEffect1", 0, 0, 12.5)
stop
}
}

actor MegaBallDropped : MegaBall
{
States
{
Spawn:
MBAL B 0
MBAL B 0 ThrustThingZ(0,1,0,1)//Sync
MBAL B 0 ThrustThing(angle*256/360,0)
Spawn0:
MBAL B 0 A_Jump(256,1,5,9,13,17,21,25)
Spawn1:
MBAL HH 1 //A_JumpIfCloser(24,"KickMe")
MBAL H 0 A_JumpIfInTargetInventory("BallFlag",1,2)
MBAL H 1 A_CountDown
wait
MBAL GG 1 //A_JumpIfCloser(24,"KickMe")
MBAL G 0 A_JumpIfInTargetInventory("BallFlag",1,2)
MBAL G 1 A_CountDown
wait
MBAL FF 1 //A_JumpIfCloser(24,"KickMe")
MBAL F 0 A_JumpIfInTargetInventory("BallFlag",1,2)
MBAL F 1 A_CountDown
wait
MBAL EE 1 //A_JumpIfCloser(24,"KickMe")
MBAL E 0 A_JumpIfInTargetInventory("BallFlag",1,2)
MBAL E 1 A_CountDown
wait
MBAL DD 1 //A_JumpIfCloser(24,"KickMe")
MBAL D 0 A_JumpIfInTargetInventory("BallFlag",1,2)
MBAL D 1 A_CountDown
wait
MBAL CC 1 //A_JumpIfCloser(24,"KickMe")
MBAL C 0 A_JumpIfInTargetInventory("BallFlag",1,2)
MBAL C 1 A_CountDown
wait
MBAL BB 1 //A_JumpIfCloser(24,"KickMe")
MBAL B 0 A_JumpIfInTargetInventory("BallFlag",1,"Spawn1")
MBAL B 1 A_CountDown
wait
}
}

actor MegaBallKicked
{
PROJECTILE
seesound "weapon/megaball"
damagetype "MegaBall"
Obituary "$OB_MEGABALL"
+HEXENBOUNCE
-NOGRAVITY
+FORCEXYBILLBOARD
+BOUNCEONACTORS
+USEBOUNCESTATE
bouncecount 8
bouncefactor 0.9
wallbouncefactor 0.9
Gravity 0.50
damage(45)
radius 16
height 16
speed 40
scale 2.5
States
{
Spawn:
MBAL B 2
MBAL B 0 ThrustThingZ(0,20,0,1)
MBAL BCDEFGHI 1 A_SpawnItemEx("MegaBallFX1")
Goto Spawn+2
Bounce.Actor:
MBAL B 0 A_ChangeFlag("THRUACTORS", 1)
MBAL B 1 A_ChangeVelocity(40.0,0,velz,CVF_RELATIVE|CVF_REPLACE)
MBAL CDEF 1
MBAL B 0 A_ChangeFlag("THRUACTORS",0)
Goto Spawn+7
Death:
TNT1 A 0 A_SpawnItemEx("ExplosionEffect1", 0, 0, 12.5)
stop
}
}

actor MegaBallFX1
{
+NOINTERACTION
+FORCEXYBILLBOARD
+CLIENTSIDEONLY
-SOLID
+NOGRAVITY
RenderStyle "add"
Alpha 0.50
Scale 2.5
States
{
Spawn:
TNT1 A 2
MBAL JKLM 3 A_FadeOut
stop
}
}

actor BallAction : CustomInventory
{
States
{
Pickup:
TNT1 A 0
TNT1 A 0 A_JumpIf(z-floorz==0, "KickTheBall")
TNT1 A 0 A_PlaySoundEx("weapon/megaball","Voice")
TNT1 A 1 ThrustThingZ(0,65,0,0)
TNT1 A 1 A_TakeInventory("JumpCancler",1)
stop
KickTheBall:
TNT1 A 0
TNT1 A 0 A_GiveInventory("KickedBall",1)
stop
}
}