actor PresentSurpriseWep_NormalBar : NormalBar { args 108, 40 }
actor PresentSurpriseWep : BaseMM8BDMWep
{
Weapon.AmmoUse 4
Weapon.AmmoGive 28
Weapon.SlotNumber 5
Inventory.Pickupmessage "$PU_PRESENTSURPRISE"
Obituary "$OB_PRESENTSURPRISE"
Tag "$TAG_PRESENTSURPRISE"
weapon.ammotype "PresentSurpriseAmmo"
inventory.icon "PSRPICON"
States
{
SpawnLoop:
PSRP Z -1
loop
Ready:
PSRP N 0 ACS_NamedExecuteWithResult("core_weaponcolor",COLOR_PRESENTSURPRISE)
Ready0:
PSRP N 0 A_TakeInventory("BallKickCounter", 999)
Ready1:
PSRP N 0 A_JumpIfInventory("KickedBall",1,"KickConfirm")
PSRP N 1 A_WeaponReady
loop
ReadyC: Goto Ready1
Deselect:
PSRP N 0 A_TakeInventory("BallFlag", 999)
goto DeselectSwap
Select:
PSRP N 0
goto SelectSwap
Fire:
PSRP N 0 A_JumpIfNoAmmo("NoAmmo")
PSRP N 0 A_JumpIfInventory("BallFlag",1,"NewBall")
PSRP N 0 A_GiveInventory("BallFlag",100)
PSRP N 0 A_PlaySoundEx("weapon/presentsurprise","Weapon")
PSRP N 0 A_TakeInventory("PresentSurpriseAmmo",4,TIF_NOTAKEINFINITE)
PSRP N 0 A_SpawnItemEx("PresentSurpriseStart",0,8,32,1.0,0,0,0,SXF_MULTIPLYSPEED)
PSRP NOP 2
PSRP N 4
PSRP N 1 A_Refire("AutoKick")
PSRP NNNNN 1 A_JumpIfInventory("KickedBall",1,"PresentSurpriseKick")
CheckForKick:
PSRP N 0 A_GiveInventory("BallKickCounter", 1)
PSRP N 1 A_JumpIfInventory("KickedBall",1,"PresentSurpriseKick")
PSRP N 0 A_JumpIfInventory("BallKickCounter", 10, "Ready0")
loop
AutoKick:
PSRP N 0 A_GiveInventory("BallKickCounter", 1)
PSRP N 0 A_JumpIfInventory("KickedBall",1,"PresentSurpriseKick")
PSRP N 0 A_JumpIfInventory("BallKickCounter", 5, "PresentSurpriseKick")
PSRP N 1 A_Refire("AutoKick")
Goto Ready0
Altfire:
PSRP N 0 A_JumpIfInventory("Vile_ClassAltfire", 1, "ClassAltfire")
PSRP N 0 A_JumpIf(CallACS("Vile_class_altfire"), "ClassAltfire")
PSRP N 1 A_JumpIfInventory("MM8BDMPlayer", 1, 1)
wait
PSRP N 0 A_JumpIfNoAmmo("NoAmmo")
PSRP N 0 A_JumpIfInventory("BallFlag",1,"AltNewBall")
PSRP N 0 A_GiveInventory("BallFlag",100)
PSRP N 0 A_PlaySoundEx("weapon/presentsurprise","Weapon")
PSRP N 0 A_TakeInventory("PresentSurpriseAmmo", 4, TIF_NOTAKEINFINITE)
PSRP N 0 A_SpawnItemEx("PresentSurpriseDroppedStart",0,8,32,1.0,0,0,0,SXF_MULTIPLYSPEED)
PSRP NOP 2
PSRP NNNNNNNNNNNNNNN 1 A_JumpIfInventory("KickedBall",1,"PresentSurpriseKick")
Goto Ready0
ClassAltfire:
PSRP N 0 
goto Super::Altfire
PresentSurpriseKick:
PSRP N 1 A_JumpIfInventory("BallFlag", 1, "KickConfirm")
PSRP NNNNNNNNN 1
Goto Ready0
KickConfirm:
PSRP Q 0 A_TakeInventory("BallFlag",999)
PSRP Q 0 A_TakeInventory("KickedBall",1)
PSRP Q 0 A_TakeInventory("BallKickCounter", 9999)
PSRP Q 0 A_PlaySoundEx("weapons/mm8/megaballkick", "SoundSlot5")
PSRP Q 0 A_FireCustomMissile("PresentSurpriseKicked",0,0,0,0)
PSRP Q 2
PSRP R 5
PSRP Q 4
PSRP N 18
PSRP Q 0 A_TakeInventory("BallFlag",999)
PSRP Q 0 A_TakeInventory("KickedBall",1)
PSRP Q 0 A_TakeInventory("BallKickCounter", 9999)
Goto Ready1
AltNewBall:
PSRP N 0
PSRP N 0 A_TakeInventory("BallFlag",100)
PSRP NN 2
Goto Altfire+1
NewBall:
PSRP N 0
PSRP N 0 A_TakeInventory("BallFlag",100)
PSRP NN 2
Goto Fire+1
NoAmmo:
PSRP N 1 ACS_NamedExecuteAlways("core_noammo",0)
Goto Ready1
}
}

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

actor PresentSurpriseStart : FastProjectile
{
+MISSILE
damagetype "PresentSurprise"
Obituary "$OB_PRESENTSURPRISE"
+DONTREFLECT
+STEPMISSILE
maxstepheight 32
damage (0)
radius 12
height 12
speed 48
scale 2.5
reactiontime 1
States
{
Spawn:
TNT1 A 0
TNT1 A 1 A_CountDown
wait
Death:
TNT1 A 0 A_SpawnItemEx("PresentSurprise",0,0,0,0,0,-1,0,SXF_ABSOLUTEMOMENTUM)
TNT1 A 2
stop
}
}

actor PresentSurpriseDroppedStart : PresentSurpriseStart
{
States
{
Death:
TNT1 A 0 A_SpawnItemEx("PresentSurpriseDropped",0,0,0,0,0,-1,0,SXF_ABSOLUTEMOMENTUM)
TNT1 A 2
stop
}
}

actor PresentSurprise : BasicBouncer
{
translation "198:198=40:40", "192:192=108:108"
damagetype "PresentSurprise"
Obituary "$OB_PRESENTSURPRISE"
-NOGRAVITY
+NOBLOOD
+DONTSPLASH
//+FIXMAPTHINGPOS
+DONTREFLECT
//+DOOMBOUNCE
+NOEXPLODEFLOOR
+USEBOUNCESTATE
BounceFactor 0.001
WallBounceFactor 0.65
BounceCount 25
reactiontime 3
var int user_startupdamage;
damage (CallACS("vile_cbm_damage",5+user_startupdamage))
radius 24
height 16
speed 0
var int user_TranslateWhiteColors;
States
{
Spawn:
PSRP B 0
PSRP B 0 ACS_NamedExecuteWithResult("core_copymomentum")
PSRP A 1 A_JumpIfCloser(24,"KickMe")
PSRP A 0 A_JumpIfInTargetInventory("BallFlag",1,2)
PSRP A 0 A_CountDown
PSRP A 1 A_JumpIfCloser(24,"KickMe")
PSRP A 0 A_JumpIfInTargetInventory("BallFlag",1,2)
PSRP A 0 A_CountDown
PSRP B 1 A_JumpIfCloser(24,"KickMe")
PSRP A 0 A_JumpIfInTargetInventory("BallFlag",1,"Spawn2")
PSRP A 0 A_CountDown
PSRP B 1 A_JumpIfCloser(24,"KickMe")
PSRP A 0 A_JumpIfInTargetInventory("BallFlag",1,"Spawn2")
PSRP A 0 A_CountDown
Spawn2:
PSRP C 1 A_SetUserVar("user_startupdamage",15)
PSRP C 1 A_JumpIfInTargetInventory("BallFlag",1,"Spawn2")
PSRP C 1 A_CountDown
TNT1 A 0 
stop

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

Spawn3Start:
PSRP C 0 A_ChangeFlag("USEBOUNCESTATE",0)
PSRP C 0 A_ChangeFlag("BOUNCEONFLOORS",0)
PSRP C 0 A_ChangeVelocity(0,0,0,2)
PSRP C 0 ThrustThing(angle*256/360,0)//Sync
PSRP C 0 ThrustThingZ(0,0,0,1)
PSRP C 1 A_JumpIfCloser(24,"KickMe")
PSRP C 0 A_ChangeFlag("BOUNCEONFLOORS",1)
Spawn3:
PSRP C 0
PSRP CC 1 A_JumpIfCloser(24,"KickMe")
PSRP C 0 A_TakeFromTarget("BallFlag",1)
PSRP C 1 A_JumpIfCloser(24,"KickMe")
PSRP C 1 A_JumpIfInTargetInventory("BallFlag",1,"Spawn3")
PSRP C 1 A_CountDown
TNT1 A 0 
stop

KickMe:
TNT1 A 0 A_ChangeFlag("USEBOUNCESTATE",0)
TNT1 A 1 A_GiveToTarget("PresentSurpriseAction",1)
TNT1 A 0 A_SpawnItemEx("PresentSurpriseExplosion")

stop
Death:
TNT1 C 0 A_ChangeFlag("NOGRAVITY",1)
TNT1 C 0 A_Stop
TNT1 C 0 A_TakeFromTarget("BallFlag",999)
TNT1 C 0 A_SpawnItemEx("PresentSurpriseExplosion")
TNT1 A 0 A_PlaySoundEx("weapons/mm7/dangerwrapexplode", "Weapon")
TNT1 A 3 
stop
}
}

actor PresentSurpriseDropped : PresentSurprise
{
States
{
Spawn:
PSRP A 0
PSRP A 0 ThrustThingZ(0,1,0,1)//Sync
PSRP A 0 ThrustThing(angle*256/360,0)
PSRP AABB 1 //A_JumpIfCloser(24,"KickMe")
Spawn2:
PSRP C 1 A_SetUserVar("user_startupdamage",15)
PSRP C 1 A_JumpIfInTargetInventory("BallFlag",1,"Spawn2")
PSRP C 1 A_CountDown
TNT1 A 0 
wait

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

}
}

actor PresentSurpriseKicked : BasicProjectile
{
translation "198:198=40:40", "192:192=108:108"
PROJECTILE
scale 2.5
Obituary "$OB_PRESENTSURPRISE"
Damagetype "PresentSurprise" 
+DONTBLAST
-NOGRAVITY
Height 16
Radius 24
+STEPMISSILE
+NOEXPLODEFLOOR
maxstepheight 16
Speed 40
Damage (CallACS("vile_cbm_damage",20))
States
{
Spawn:
PSRP CC 1 A_CheckFloor("Death")
loop
Death:
TNT1 A 0 A_JumpIf(z-floorz==0,"Death2")
goto XDeath
XDeath:
TNT1 A 0 A_PlaySoundEx("weapons/mm7/dangerwrapexplode", "Weapon")
TNT1 A 0 A_SpawnItemEx("PresentSurpriseExplosion")
TNT1 A 3
stop
Death2:
TNT1 A 1 A_SpawnItemEx("PresentSurpriseGround",0,0,0,40,0,0,0,0,0)
stop
}
}

actor PresentSurpriseGround : BasicProjectile
{
translation "198:198=40:40", "192:192=108:108"
PROJECTILE
-NOGRAVITY
+NOEXPLODEFLOOR
+STEPMISSILE
maxstepheight 16
+BOUNCEONCEILINGS
+FORCEXYBILLBOARD
BounceCount 1
Damage (CallACS("vile_cbm_damage",20))
DamageType "PresentSurprise"
Obituary "$OB_PRESENTSURPRISE"
Height 16
Radius 24
Scale 2.5
speed 24
States
{
Spawn:
PSRP CC 2
loop
Death:
TNT1 A 0 A_PlaySoundEx("weapons/mm7/dangerwrapexplode", "Weapon")
TNT1 A 0 A_SpawnItemEx("PresentSurpriseExplosion")
TNT1 A 3
stop
}
}

actor PresentSurpriseAction : CustomInventory
{
States
{
Pickup:
TNT1 A 0
TNT1 A 0 A_JumpIf(z-floorz==0, "KickTheBall")
TNT1 A 0 A_PlaySoundEx("weapons/mm7/dangerwrapexplode", "Weapon")
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
}
}

actor PresentSurpriseExplosion : BasicExplosion
{
Obituary "$OB_PRESENTSURPRISE"
damagetype "PresentSurprise"
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_SpawnItemEx("ExplosionEffect2", 0, 0, 12.5, 0, 0, 0, 0, SXF_WEPFXCOLOR)
TNT1 A 1 A_Explode(CallACS("vile_cbm_damage",30), 64, 0, 0, 32)
stop
}
}