actor Magicman_W : BaseMM8BDMWep_CBM 
{
tag "$TAGC_BF"
dropitem "MagicCardWep"
Weapon.AmmoUse 25
Weapon.AmmoGive 300
Obituary "$OB_FAKEMAGICCARD"//$OB_MAGICCARD
Inventory.Pickupmessage "Magic... away!"
weapon.ammotype "SnortSnortAmmo"
inventory.icon "MAGII"
States
{
Spawn:
C_0B F 1
loop//MCAR X 1

Deselect:
MGCH A 0
goto DeselectSwap
Select:
MGCH A 0
goto SelectSwap

Ready:
MGCH A 0 ACS_NamedExecuteWithResult("core_weaponcolor",DYE_MAGICMAN)
MGCH A 0 //A_GunFlash
goto Ready1
Ready1:
MGCH A 0 A_JumpIfInventory("SnortSnortAmmo",25,"Ready2")
MGCH A 2 A_WeaponReady(4)
MGCH A 0 A_GiveInventory("SnortSnortAmmo",3)
loop
Ready2:
MGCH A 2 A_WeaponReady
MGCH A 0 A_GiveInventory("SnortSnortAmmo",3)
loop

Fire:
MGCH A 0 A_GiveInventory("Magicman_Fire_P")
MGCH JKLMNOPQQ 2
MGCH A 2 Offset(23,43)
MGCH A 2 Offset(13,37)
MGCH A 2 Offset(7,35)
MGCH A 1 Offset(3,33)
Goto Ready1//25

AltFire:
MGCH A 1 Offset(-20,29)A_GiveInventory("SnortSnortAmmo",1)
MGCH A 0 A_PlaySound("weapon/MagicM_Orb",1,0.70)
MGCH A 0 A_FireCustomMissile("MagicM_OrbShot",0,0,8,0)
MGCH BCAA 2 Offset(-40,13)A_GiveInventory("SnortSnortAmmo",2)
MGCH A 2 Offset(-28,15)A_GiveInventory("SnortSnortAmmo",2)
MGCH A 2 Offset(-16,18)A_GiveInventory("SnortSnortAmmo",2)
MGCH A 2 Offset(-9,22)A_GiveInventory("SnortSnortAmmo",2)
MGCH A 2 Offset(-3,27)A_GiveInventory("SnortSnortAmmo",2)
Goto Ready1//17

BotFire:
MGCH A 0 A_Jump(128,"Altfire")
MGCH A 0 A_GiveInventory("SnortSnortAmmo",50)
goto Fire+1
}
}

actor Magicman_W2 : BaseMM8BDMWep_CBM
{
tag "$TAGC_BF2"
dropitem "MagicCardWep"
inventory.icon "MAGII2"
Weapon.AmmoUse 0
Weapon.AmmoGive 300
Obituary "$OB_MAGICCARD"
Inventory.Pickupmessage "Magic... away!"
weapon.ammotype "SnortSnortAmmo"
States
{
Spawn:
C_0B F 1
loop//MGB8 X 1

Deselect:
MGCH R 0
goto DeselectSwap
Select:
MGCH R 0
goto SelectSwap

Ready:
MGCH R 0 ACS_NamedExecuteWithResult("core_weaponcolor",DYE_MAGICMAN)
MGCH R 0 //A_GunFlash
goto Ready1
Ready1:
MGCH R 0 A_JumpIfInventory("SnortSnortAmmo",150,"Ready2")
MGCH R 2 A_WeaponReady(WRF_NOFIRE)
MGCH R 0 A_GiveInventory("SnortSnortAmmo",3)
loop
Ready2:
MGCH R 2 A_WeaponReady
MGCH R 0 A_GiveInventory("SnortSnortAmmo",3)
loop

Fire:
MGCH S 0 A_JumpIfInventory("IsBot",1,"BotFire")
MGCH S 0 A_GunFlash("Flash.Fire")
MGCH S 1 A_JumpIfInventory("PlayerPropertyRage",1,1)
MGCH S 1 A_TakeInventory("FakeMagicFlag")
goto BallThrow

Altfire:
MGCH S 1 A_JumpIfInventory("PlayerPropertyRage",1,1)
MGCH S 1 A_GiveInventory("FakeMagicFlag",1)
goto BallThrow

BallThrow:
MGCH T 1 A_GiveInventory("MagicBallThrow_P",1)
MGCH ST 1 
MGCH S 0 A_PlaySound("weapon/MagicShot",1,1.0)
MGCH S 0 A_SpawnItemEx("MagicBallEmergency",0,0,28)
MGCH S 0 A_SpawnItemEx("MagicHologram",0,0,0,0,0,0,0,1,0)
MGCH S 0 A_SpawnItemEx("MagicBall",cos(-pitch)*0,0,28+sin(-pitch),cos(-pitch)*22,0,sin(-pitch)*22,0,33)
MGCH S 0 A_Stop
MGCH S 0 ACS_NamedExecuteWithResult("core_nonshootableplayer",0,true)
MGCH S 0 ACS_NamedExecuteWithResult("core_invulnerableplayer",0,true)
MGCH S 0 ACS_NamedExecuteWithResult("cbm_noteleportplayer",0,true)
MGCH S 0 ACS_NamedExecuteWithResult("core_invisibleplayer",0,true)
MGCH S 0 A_GiveInventory("CBM_00_AlphaPowerGiver",1)
MGCH S 0 ACS_NamedExecuteWithResult("core_unsolidplayer",0,USP_TOGGLEON)
MGCH S 1 ACS_NamedExecuteWithResult("cbm_pickupdisableplayer",0,true)
goto InvisibleLoop

InvisibleLoop:
MGCH S 1
MGCH S 0 A_JumpIfInventory("MagicBallEnd",1,"InvisibleEnd")
MGCH S 1
MGCH S 0 A_JumpIfInventory("MagicBallEnd",1,"InvisibleEnd")
MGCH T 1
MGCH T 0 A_JumpIfInventory("MagicBallEnd",1,"InvisibleEnd")
MGCH T 1
MGCH T 0 A_JumpIfInventory("MagicBallEnd",1,"InvisibleEnd")
loop

InvisibleEnd:
MGCH T 1 A_JumpIf(256,1)
wait
InvisibleEnd2:
MGCH T 1 A_GiveInventory("MagicBallEnd",1)
MGCH T 0 ACS_NamedExecuteWithResult("core_nonshootableplayer",0,false)
MGCH T 0 ACS_NamedExecuteWithResult("core_invulnerableplayer",0,false)
MGCH T 0 ACS_NamedExecuteWithResult("cbm_pickupdisableplayer",0,false)
MGCH T 0 ACS_NamedExecuteWithResult("cbm_noteleportplayer",0,false)
MGCH T 0 ACS_NamedExecuteWithResult("core_invisibleplayer",0,false)
MGCH T 0 A_TakeInventory("CBM_00_AlphaPower")
MGCH T 0 ACS_NamedExecuteWithResult("core_unsolidplayer",0,USP_TOGGLEOFF_DAMAGE,CallACS("core_getmaxhealth")/10)
MGCH T 0 A_JumpIfInventory("IsBot",1,"BotFire2")
goto BallEnd2
BallEnd2:
MGCH T 0 ThrustThingZ(0,1,0,1)
MGCH TST 2
MGCH SR 2 A_GiveInventory("SnortSnortAmmoResync_P",1)
MGCH R 12 A_TakeInventory("ProjectilePortDead",99)
Goto Ready+2

Flash.Fire:
MGCH U 0
MGCH UVWXYZ 1
stop
BotFire:
MGCH R 0 A_Jump(128,"Altfire")
goto Fire+1
BotFire2:
MGCH R 0 A_SelectWeapon("Magicman_W")
goto Ready+2

}
}

actor SnortSnortAmmo : Ammo
{
inventory.amount 1
inventory.maxamount 300
+INVENTORY.IGNORESKILL
}

actor MagicBallEnd : Inventory{}
actor MagicBallEndFix : Inventory{}
actor MagicBallCooldown : Powerup
{
Powerup.Duration 35
}
actor FakeMagicFlag : Inventory{}


actor Magicman_Fire_P : CustomInventory
{
States
{
Pickup:
//TNT1 A 0 A_TakeInventory("SnortSnortAmmo",25)
TNT1 A 0 A_PlaySound("weapon/magiccard",1)
TNT1 A 0 A_FireCustomMissile("MagicCardB",0,1,0,0)
stop
}
}
actor MagicBallThrow_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_GiveInventory("CBM_BeatBoostRemoveCheck_P")
TNT1 A 0 A_TakeInventory("MagicBallEndFix")
TNT1 A 0 A_TakeInventory("MagicBallEnd")
TNT1 A 0 A_TakeInventory("SnortSnortAmmo",75)
TNT1 A 0 A_TakeInventory("SnortSnortAmmo",75,1)
stop
}
}

actor SnortSnortAmmoResync_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_GiveInventory("SnortSnortAmmo",1)
TNT1 A 0 A_TakeInventory("SnortSnortAmmo",1)
stop
}
}

actor MagicCardB : ProjSpawnFuncActor
{
PROJECTILE
Damagetype "MagicM_Card" 
Obituary "$OB_MAGICCARD"
+NOCLIP
+NOINTERACTION
+THRUGHOST
+NOTARGETSWITCH
+DONTREFLECT
+SEEKERMISSILE
ReactionTime 70
damage (0)
Radius 5
Height 5
speed 50
scale 2.5
States
{
Spawn://CDEFGH IJ
Q_BH A 0
Q_BH A 0 A_SpawnItemEx("MagicCardB_WallCheck",0,0,0,momx,momy,momz,0,1+8)
Q_BH A 0 A_RearrangePointers(0,0,2)
Q_BH AA 1 A_SpawnItemEx("MagicCardDamagerB",0,0,0,momx,momy,momz,0,8+32)
Q_BH IIJJCCDD 1 A_SpawnItemEx("MagicCardDamagerB",0,0,0,momx,momy,momz,0,8+32)
Q_BH E 0 A_ScaleVelocity(0.5)
Q_BH EE 1 A_SpawnItemEx("MagicCardDamagerB",0,0,0,momx,momy,momz,0,8+32)
Q_BH F 0 A_ScaleVelocity(0.5)
Q_BH FF 1 A_SpawnItemEx("MagicCardDamagerB",0,0,0,momx,momy,momz,0,8+32)
Q_BH G 0 A_ScaleVelocity(-2.0)
Q_BH GG 1 A_SpawnItemEx("MagicCardDamagerB",0,0,0,momx,momy,momz,0,8+32)
//Q_BH R 0 A_SpawnItemEx("ReturningMagicCardB",0,0,0,0,0,0,0,1)
Spawn2:
Q_BH G 0
Q_BH G 0 A_FaceTarget
Q_BH G 0 A_SpawnItemEx("MagicCardB_WallCheck2",0,0,0,momx,momy,momz,0,1+8)
goto Spawn3
Spawn3:
Q_BH H 0
Q_BH H 0 A_JumpIfCloser(64,"Death")
Q_BH HH 0 A_SeekerMissile(90,90,2)
Q_BH HH 1 A_SpawnItemEx("MagicCardDamagerB",0,0,0,momx,momy,momz,0,8+32)
Q_BH I 0 A_JumpIfCloser(64,"Death")
Q_BH II 1 A_SpawnItemEx("MagicCardDamagerB",0,0,0,momx,momy,momz,0,8+32)
Q_BH J 0 A_JumpIfCloser(64,"Death")
Q_BH JJ 1 A_SpawnItemEx("MagicCardDamagerB",0,0,0,momx,momy,momz,0,8+32)
Q_BH C 0 A_JumpIfCloser(64,"Death")
Q_BH CC 1 A_SpawnItemEx("MagicCardDamagerB",0,0,0,momx,momy,momz,0,8+32)

Q_BH DD 0 A_SeekerMissile(90,90,2)
Q_BH D 0 A_JumpIfCloser(64,"Death")
Q_BH DD 1 A_SpawnItemEx("MagicCardDamagerB",0,0,0,momx,momy,momz,0,8+32)
Q_BH E 0 A_JumpIfCloser(64,"Death")
Q_BH EE 1 A_SpawnItemEx("MagicCardDamagerB",0,0,0,momx,momy,momz,0,8+32)
Q_BH F 0 A_JumpIfCloser(64,"Death")
Q_BH FF 1 A_SpawnItemEx("MagicCardDamagerB",0,0,0,momx,momy,momz,0,8+32)
Q_BH G 0 A_JumpIfCloser(64,"Death")
Q_BH GG 1 A_SpawnItemEx("MagicCardDamagerB",0,0,0,momx,momy,momz,0,8+32)

Q_BH H 0 A_CountDown
Q_BH H 0 A_JumpIf(!CallACS("cbm_PointerExists",AAPTR_TARGET),"Death")
loop
Death:
Q_BH A 0
Stop
}
}

actor MagicCardB_WallCheck : BasicGraphicEffectM
{
+THRUACTORS
+DONTREFLECT
renderstyle "none"
damage (0)
Radius 5
Height 5
speed 50
States
{
SpawnFrame:
TNT1 A 0
TNT1 AA 1
TNT1 AAAAAAAA 1
TNT1 A 0 A_ScaleVelocity(0.5)
TNT1 AA 1
TNT1 A 0 A_ScaleVelocity(0.5)
TNT1 AA 1
TNT1 A 0 A_ScaleVelocity(-2.0)
TNT1 AA 1
stop
Death:
DeathFX:
TNT1 A 0 A_SpawnItemEx("MagicCardB_WallHitFX",-momx,-momy,-momz,0,0,0,0,1+SXF_ABSOLUTEPOSITION)//2
stop
}
}
actor MagicCardB_WallCheck2 : MagicCardB_WallCheck
{
+SEEKERMISSILE
ReactionTime 70
States
{
SpawnFrame:
TNT1 A 0
TNT1 A 0 A_JumpIfCloser(64,"End")
TNT1 AA 0 A_SeekerMissile(90,90,2)
TNT1 AAAAAAAA 1 A_JumpIfCloser(64,"End")
TNT1 AA 0 A_SeekerMissile(90,90,2)
TNT1 AAAAAAAA 1 A_JumpIfCloser(64,"End")
TNT1 A 0 A_CountDown
TNT1 A 0 A_JumpIf(!CallACS("cbm_PointerExists",AAPTR_TARGET),"End")
loop
End:
TNT1 A 0
stop
Death:
TNT1 A 0 A_JumpIf(ReactionTime != 0,"DeathFX")
stop
}
}

actor MagicCardB_WallHitFX : BasicGraphicEffect
{
+FORCEXYBILLBOARD
+BRIGHT
States
{
SpawnFrame:
Q_BH KLMN 2
stop
}
}

actor MagicCardDamagerB
{
PROJECTILE
Damagetype "MagicM_Card" 
Obituary "$OB_MAGICCARD"
+THRUGHOST
+DONTBLAST
+DONTSPLASH
RenderStyle None
Damage (90)
radius 16
height 8
States
{
Spawn:
TNT1 A 1
stop
}
}

actor MagicM_CardProtect : PowerProtection
{
Powerup.Duration 5
DamageFactor "MagicM_Card", 0.0
}


actor PainMagicM_CardHit : CustomInventory
{
States
{
Pickup:
TNT1 A 0 //A_JumpIf(CheckClass("Magicman",2),"GiveHealth")//This works, but not on the first hit
//stop
//GiveHealth:
TNT1 A 0 A_JumpIfInventory("MagicStackedDeckFlag1",1,"Stack_1")
TNT1 A 0 A_JumpIfInventory("MagicStackedDeckFlag2",1,"Stack_1")
TNT1 A 0 A_JumpIfInventory("MagicStackedDeckFlag3",1,"Stack_2")
TNT1 A 0 A_JumpIfInventory("MagicStackedDeckFlag4",1,"Stack_3")
TNT1 A 0 A_JumpIfInventory("MagicStackedDeckFlag5",1,"Stack_4")
goto Stack_5
Stack_1:
TNT1 A 0 A_GiveInventory("MagicStackedDeckFlag1",1)
TNT1 A 0 A_SpawnItemEx("MagicCardHealth_1",0,0,28,0,0,0,0,1)
stop
Stack_2:
TNT1 A 0 A_GiveInventory("MagicStackedDeckFlag2",1)
TNT1 A 0 A_SpawnItemEx("MagicCardHealth_2",0,0,28,0,0,0,0,1)
stop
Stack_3:
TNT1 A 0 A_GiveInventory("MagicStackedDeckFlag3",1)
TNT1 A 0 A_SpawnItemEx("MagicCardHealth_3",0,0,28,0,0,0,0,1)
stop
Stack_4:
TNT1 A 0 A_GiveInventory("MagicStackedDeckFlag4",1)
TNT1 A 0 A_SpawnItemEx("MagicCardHealth_4",0,0,28,0,0,0,0,1)
stop
Stack_5:
TNT1 A 0 A_GiveInventory("MagicStackedDeckFlag5",1)
TNT1 A 0 A_SpawnItemEx("MagicCardHealth_5",0,0,28,0,0,0,0,1)
stop

No:
TNT1 A 0
stop
}
}

actor MagicStackedDeckFlag1 : Powerup
{
Powerup.Duration -3
}
actor MagicStackedDeckFlag2 : MagicStackedDeckFlag1 {}
actor MagicStackedDeckFlag3 : MagicStackedDeckFlag1 {}
actor MagicStackedDeckFlag4 : MagicStackedDeckFlag1 {}
actor MagicStackedDeckFlag5 : MagicStackedDeckFlag1 {}

actor MagicCardHealth_1 : ProjSpawnFuncActor
{
PROJECTILE
+DONTBLAST
+NOINTERACTION
+NOCLIP
+SEEKERMISSILE
ReactionTime 100
Damage (0)
Radius 2
Height 2
speed 35
scale 2.5
states
{
Spawn:
Q_BH X 0
Q_BH X 0 A_TransferPointer(2,0,2,2)
Q_BH X 0 A_RearrangePointers(0,0,2)
Q_BH X 1 A_FaceTarget
goto Spawn2
Spawn2:
Q_BH X 1 A_JumpIfCloser(64,"Giver")Q_BH X 0 A_SeekerMissile(90,90,2)
Q_BH X 1 A_JumpIfCloser(64,"Giver")Q_BH X 0 A_SeekerMissile(90,90,2)
Q_BH X 1 A_JumpIfCloser(64,"Giver")Q_BH X 0 A_SeekerMissile(90,90,2)
Q_BH X 1 A_JumpIfCloser(64,"Giver")Q_BH X 0 A_SeekerMissile(90,90,2)
Q_BH X 1 A_JumpIfCloser(64,"Giver")Q_BH X 0 A_SeekerMissile(90,90,2)
Q_BH X 1 A_JumpIfCloser(64,"Giver")Q_BH X 0 A_SeekerMissile(90,90,2)
Q_BH Y 1 A_JumpIfCloser(64,"Giver")Q_BH Y 0 A_SeekerMissile(90,90,2)
Q_BH Y 1 A_JumpIfCloser(64,"Giver")Q_BH Y 0 A_SeekerMissile(90,90,2)
Q_BH Y 1 A_JumpIfCloser(64,"Giver")Q_BH Y 0 A_SeekerMissile(90,90,2)
Q_BH Y 1 A_JumpIfCloser(64,"Giver")Q_BH Y 0 A_SeekerMissile(90,90,2)
Q_BH Y 1 A_JumpIfCloser(64,"Giver")Q_BH Y 0 A_SeekerMissile(90,90,2)
Q_BH Y 1 A_JumpIfCloser(64,"Giver")Q_BH Y 0 A_SeekerMissile(90,90,2)
Q_BH X 0 A_JumpIf(!CallACS("cbm_PointerExists",AAPTR_TARGET),"SuperDeath")
Q_BH X 0 A_CountDown
loop
SuperDeath:
TNT1 A 1
stop
Giver:
TNT1 A 0 A_GiveToTarget("CBM_HealThing10_PU")
goto End
End:
TNT1 A 0 A_Stop
TNT1 A 1 A_SpawnItemEx("MagicCardHealthFX",-8,0,-8,0,0,0,0,1)
stop
Death:
TNT1 A 1
stop
}
}

actor MagicCardHealthFX : BasicExplosion
{
RenderStyle None
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_PlaySoundEx("item/energyup","Weapon")
TNT1 A 2 A_SpawnItemEx("MagicCardHealthFX2",0,0,0,0,0,0,0,1)
stop
}
}

actor MagicCardHealthFX2 : BasicGraphicEffect
{
+BRIGHT
States
{
SpawnFrame:
MGB9 ABCDEFG 3
stop
}
}

actor MagicCardHealth_2 : MagicCardHealth_1
{
States
{
Giver:
TNT1 A 0 A_GiveToTarget("CBM_HealThing20_PU")
goto End
}
}
actor MagicCardHealth_3 : MagicCardHealth_1{States{Giver:TNT1 A 0 A_GiveToTarget("CBM_HealThing30_PU")goto End}}
actor MagicCardHealth_4 : MagicCardHealth_1{States{Giver:TNT1 A 0 A_GiveToTarget("CBM_HealThing40_PU")goto End}}
actor MagicCardHealth_5 : MagicCardHealth_1{States{Giver:TNT1 A 0 A_GiveToTarget("CBM_HealThing50_PU")goto End}}


actor MagicM_OrbShot : ProjSpawnFuncActor
{
PROJECTILE
Damagetype "MagicM_Orb"
Obituary "$OB_MAGICBALL"
+SKYEXPLODE
+EXPLODEONWATER
ReactionTime 7
Damage (110)
Radius 14
Height 20
Speed 40
scale 2.5
states
{
Spawn:
MGB9 Q 0
MGB9 Q 0
MGB9 QR 2 A_SpawnItemEx("MagicM_OrbShotFX1",random(-8,2),random(-18,18),random(-18,18),momx*0.25,momy*0.25,momz*0.25,0,1+8)
MGB9 Q 0 A_CountDown
loop
Death:
MGB9 SSTT 2 A_SpawnItemEx("MagicM_OrbShotFX2",random(-6,4),random(-20,20),random(-20,20),0,0,0,0,1)
stop
}
}

actor MagicM_OrbShotFX1 : BasicGraphicEffect
{
Renderstyle "None"
States
{
SpawnFrame:
TNT1 A 0
TNT1 A 0 A_SetArg(3,random(0,15))
TNT1 AA 1 A_SpawnItemEx("MagicM_OrbShotFX2",random(-8,8),random(-24,24),random(-24,24),momx*(-1+0.05*Args[3]),momy*(-1+0.05*Args[3]),momz*(-1+0.05*Args[3]),0,1+8,32)
stop
}
}
actor MagicM_OrbShotFX2 : BasicGraphicEffect
{
Scale 2.0
States
{
SpawnFrame:
TNT1 A 0
TNT1 A random(0,1)A_SetScale(ScaleX+random(-5,5)*0.1)
MGB9 U random(1,2)A_Jump(128,1)
MGB9 V random(1,2)A_Jump(64,1)
MGB9 W random(1,2)A_Jump(16,1)
MGB9 X random(1,2)
stop
}
}

actor MagicBall : ProjSpawnFuncActor
{
PROJECTILE
Damagetype "MagicM_Ball"
Obituary "$OB_MAGICBALL"
+DONTBLAST
+DONTREFLECT
+THRUGHOST
+SKYEXPLODE
+EXPLODEONWATER
-NOGRAVITY
Gravity 0.50
ReactionTime 60
Damage (0)
Radius 16
Height 56
Speed 20
scale 2.5
states
{
Spawn:
MGB8 M 0
MGB8 M 0 ACS_NamedExecuteWithResult("cbm_MakeTargetFollowMe",200)//200
MGB8 M 0 A_ChangeVelocity(0,0,5)//ThrustThingZ(0,20,0,1)
MGB8 M 0 A_GiveToTarget("MagicBallPickupSync",1)
MGB8 M 1 A_JumpIfInTargetInventory("MagicBallEnd",1,"Death")
MGB8 M 0 A_GiveToTarget("MagicBallPickupSync",1)
MGB8 M 1 A_JumpIfInTargetInventory("MagicBallEnd",1,"Death")
goto Spawn2+2
Spawn2:
MGB8 M 0 A_GiveToTarget("MagicBallCooldown",1)
MGB8 MMNNOOPP 1 A_JumpIfInTargetInventory("MagicBallEnd",1,"Death")
MGB8 M 0 A_CountDown
loop
Death:
TNT1 A 0 A_GiveInventory("ProjectilePortDead",1)
TNT1 A 0 A_ChangeFlag("NOINTERACTION",1)
TNT1 A 0 A_Stop
TNT1 A 0 A_SetGravity(0.0)
TNT1 A 0 A_GiveToTarget("MagicBallEnd",1)
TNT1 A 0 //A_GiveToTarget("MagicBallPickupSync2",1)
TNT1 A 0 //A_PlaySound("weapon/napalm",1,1.0)
TNT1 A 0 A_SpawnItemEx("MagicBallFirework",0,0,9,0,0,12,0,0)
TNT1 A 0 A_SpawnItemEx("MagicBallFX",0,0,0,0,0,0,0,1)
TNT1 A 0 A_JumpIfInTargetInventory("FakeMagicFlag",1,"Death2")
TNT1 A 0 A_SpawnItemEx("MagicBallExplosion",0,0,16)
TNT1 AA 1 A_GiveToTarget("MagicBallPickupSync2",1)
stop
Death2:
TNT1 A 2 A_SpawnItemEx("MagicBallExplosion2",0,0,16)
TNT1 AA 1 A_GiveToTarget("MagicBallPickupSync2",1)
stop
}
}

actor MagicBallEmergency : MagicBall
{
+NOINTERACTION
+NOGRAVITY
ReactionTime 240
Radius 2
Height 2
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_GiveToTarget("MagicBallPickupSync",1)
Spawn2:
TNT1 AA 1 A_JumpIfInTargetInventory("MagicBallEnd",1,"Death3")
TNT1 A 0 A_CountDown
TNT1 A 0 A_JumpIfInTargetInventory("MagicBallCooldown",1,"Spawn2")
goto Death3
Death:
TNT1 A 0 A_GiveToTarget("MagicBallEndFix",1)
goto Death3
Death3:
TNT1 A 0 A_GiveToTarget("MagicBallEnd",1)
TNT1 AA 1 A_GiveToTarget("MagicBallPickupSync2",1)
stop
}
}

actor MagicBallExplosion : BasicImplosion
{
Damagetype "MagicM_Ball"
Obituary "$OB_MAGICBALL"
States
{
Spawn:
TNT1 A 0
TNT1 A 2 A_Explode(180+CallACS("core_checkrune",RUNE_SPREAD,2)*360,64,0,0,18)
stop
}
}

actor MagicBallExplosion2 : MagicBallExplosion
{
Obituary "$OB_FAKEMAGICBALL"
}

actor MagicBallPickupSync : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_GiveInventory("MagicBallCooldown",1)
TNT1 A 0 //A_SetTranslucent(0.0,0)
stop
}
}

actor MagicBallPickupSync2 : CustomInventory
{
States
{
Pickup:
TNT1 A 0 //A_SetTranslucent(1.0,0)
stop
}
}

actor MagicBallFX : BasicGraphicEffect
{
States
{
SpawnFrame:
MGB8 Q 2
TNT1 A 2
MGB8 R 2
TNT1 A 2
MGB8 S 2
TNT1 A 2
MGB8 T 2
stop
}
}

actor MagicBallFirework : BasicExplosion
{
States
{
Spawn:
TNT1 A 0
TNT1 A 4
TNT1 A 0 A_Stop
TNT1 A 0 A_SpawnItemEx("MagicBallFireworkFX",random(-15,15),random(-15,15),10,0,0,0,0,1)
TNT1 A 4
TNT1 A 0 A_SpawnItemEx("MagicBallFireworkFX",random(-15,15),random(-15,15),0,0,0,0,0,1)
TNT1 A 4
TNT1 A 0 A_SpawnItemEx("MagicBallFireworkFX",random(-15,15),random(-15,15),-10,0,0,0,0,1)
TNT1 A 4
stop
}
}
actor MagicBallFireworkFX : BasicGraphicEffect
{
+BRIGHT
scale 2.0
States
{
SpawnFrame:
MGB9 HJKLMN 4
stop
}
}

actor MagicBirdsSound : BasicHelper
{
States
{
Spawn:
TNT1 A 0
TNT1 A 2 A_PlaySound("weapon/MagicBirds",1,1.0)
stop
}
}

actor MagicHomingBirds : ProjSpawnFuncActor
{
PROJECTILE
damagetype "MagicM_Bird"
Obituary "$OB_MAGICBIRD"
+DONTSEEKINVISIBLE//
+SEEKERMISSILE
reactiontime 10
damage (30)
Radius 6
Height 5
speed 19
scale 2.0
States
{
Spawn:
TNT1 A 1
TNT1 A 0 A_Jump(256,1,2,3,4,5,6,7,8,9,10,11,12)
Spawn2:
MGB8 AAABBBCCCDDD 1 A_SeekerMissile(1,4,3,64,3)
MGB8 A 0 A_CountDown
loop
Death:
NMFX ABCD 2
stop
}
}

actor ConfettiMagicSpawner : BasicHelper
{
ReactionTime 10//10
States
{
Spawn:
TNT1 A 0
TNT1 A 1 A_PlaySoundEx("misc/partyball",1)
goto Spawn2
Spawn2:
TNT1 AAA 0 A_SpawnItemEx("MagicMDeath_Confetti",random(-16,16),random(-16,16),Random(8,16),random(-3,3),random(-3,3),random(1,-1),0,1)
TNT1 A 1 A_CountDown
Loop
}
}

actor ConfettiPickup : CustomInventory
{
states
{
Pickup:
TNT1 A 0 A_SpawnItemEx("ConfettiMagicSpawner",0,0,28,0,0,0,0,1)
stop
}
}

actor MagicHologram
{
var int user_TID;
-SOLID
+NOGRAVITY
+DONTBLAST
+DONTREFLECT
+THRUACTORS
//+NOINTERACTION
height 56
radius 16
scale 2.5
renderstyle translucent
alpha 0.5
States
{
Spawn:
TNT1 A 0
TNT1 A 0 ACS_NamedExecuteWithResult("core_copytranslation")
MGIC G 0
Spawn2:
MGIC G 0 A_JumpIf(!CallACS("cbm_PointerExists",AAPTR_TARGET),"Death")
MGIC G 0 A_JumpIfInTargetInventory("MagicBallEnd",1,"End")
MGIC G 1
loop
End:
TNT1 A 0 A_JumpIfInTargetInventory("MagicBallEndFix",1,2)
TNT1 A 0 A_JumpIfInTargetInventory("FakeMagicFlag",1,"TeleportBack")
TNT1 A 0 A_GiveInventory("ConfettiPickup",1)
TNT1 A 0 A_GiveToTarget("ConfettiPickup",1)
TNT1 A 0 A_GiveToTarget("MagicTeleportScaleV",1)
EndBirds:
TNT1 A 0 A_ChangeFlag("MISSILE",1)
TNT1 A 0 //ACS_ExecuteAlways(790,0)
TNT1 A 0 A_GiveInventory("MagicBirdAttack",1)
goto Death
TeleportBack:
TNT1 A 0 A_GiveToTarget("MagicBirdAttack2",1)
TNT1 A 0 A_GiveToTarget("MagicTeleportScaleV",1)
//TNT1 A 1
//TNT1 A 0 Thing_Move(CallACS("core_gettarget"),0,1)
TNT1 A 0 A_SetUserVar("user_TID",CallACS("core_gettarget"))
TNT1 A 0 Thing_ChangeTID(0,-6700-user_TID)
TNT1 A 0 Thing_Move(user_TID,TID,1)
TNT1 A 0 A_GiveToTarget("Nudge",1)
//TNT1 A 0 Thing_ChangeTID(0,0)
goto Death
Death:
TNT1 A 1
stop
}
}

actor MagicHologramBirds : MagicHologram
{
States
{
Spawn:
TNT1 A 0
//TNT1 A 0 ACS_NamedExecuteWithResult("core_copytranslation")
goto EndBirds
}
}

actor MagicBirdAttack2 : CustomInventory
{
states
{
Pickup:
TNT1 A 0 A_SpawnItemEx("MagicHologramBirds",0,0,0,0,0,0,0,1)
stop
}
}

actor MagicTeleportScaleV : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_Stop//A_ScaleVelocity(0.1)
TNT1 A 0 A_GiveInventory("PowerWallJumpSpeed",1)
stop
}
}

actor MagicBirdAttack : CustomInventory
{
states
{
Pickup:
TNT1 A 0 A_SpawnItemEx("MagicBirdsSound",0,0,16)
TNT1 A 0
TNT1 A 0 A_SpawnItemEx("MagicHomingBirds",4,0,70,16,0,0.65,0,1)
TNT1 A 0 A_SpawnItemEx("MagicHomingBirds",4,28,42,16,0,0.35,-4,1)
TNT1 A 0 A_SpawnItemEx("MagicHomingBirds",4,-28,42,16,0,0.35,4,1)
TNT1 A 0 A_SpawnItemEx("MagicHomingBirds",4,0,28,16,0,0,0,1)
TNT1 A 0 A_SpawnItemEx("MagicHomingBirds",4,28,14,16,0,-0.35,-4,1)
TNT1 A 0 A_SpawnItemEx("MagicHomingBirds",4,-28,14,16,0,-0.35,4,1)
TNT1 A 0 A_SpawnItemEx("MagicHomingBirds",4,0,-14,16,0,-0.65,0,1)
TNT1 A 0 A_JumpIfInTargetInventory("PlayerPropertySpread",1,"Pickup_S")
//SpawnItemEx Simulation of the below
//TNT1 A 0 A_CustomMissile("MagicHomingBirds",70,0,0,2,2)
//TNT1 A 0 A_CustomMissile("MagicHomingBirds",42,28,-4,2,1)
//TNT1 A 0 A_CustomMissile("MagicHomingBirds",42,-28,4,2,1)
//TNT1 A 0 A_CustomMissile("MagicHomingBirds",28,0,0,2,0)
//TNT1 A 0 A_CustomMissile("MagicHomingBirds",14,28,-4,2,-1)
//TNT1 A 0 A_CustomMissile("MagicHomingBirds",14,-28,4,2,-1)
//TNT1 A 0 A_CustomMissile("MagicHomingBirds",-14,0,0,2,-2)
stop
Pickup_S:
TNT1 A 0 A_SpawnItemEx("MagicHomingBirds",4,0,70,16,0,0.65,15,1)
TNT1 A 0 A_SpawnItemEx("MagicHomingBirds",4,28,42,16,0,0.35,11,1)
TNT1 A 0 A_SpawnItemEx("MagicHomingBirds",4,-28,42,16,0,0.35,19,1)
TNT1 A 0 A_SpawnItemEx("MagicHomingBirds",4,0,28,16,0,0,15,1)
TNT1 A 0 A_SpawnItemEx("MagicHomingBirds",4,28,14,16,0,-0.35,11,1)
TNT1 A 0 A_SpawnItemEx("MagicHomingBirds",4,-28,14,16,0,-0.35,19,1)
TNT1 A 0 A_SpawnItemEx("MagicHomingBirds",4,0,-14,16,0,-0.65,15,1)

TNT1 A 0 A_SpawnItemEx("MagicHomingBirds",4,0,70,16,0,0.65,-15,1)
TNT1 A 0 A_SpawnItemEx("MagicHomingBirds",4,28,42,16,0,0.35,-19,1)
TNT1 A 0 A_SpawnItemEx("MagicHomingBirds",4,-28,42,16,0,0.35,-11,1)
TNT1 A 0 A_SpawnItemEx("MagicHomingBirds",4,0,28,16,0,0,-15,1)
TNT1 A 0 A_SpawnItemEx("MagicHomingBirds",4,28,14,16,0,-0.35,-19,1)
TNT1 A 0 A_SpawnItemEx("MagicHomingBirds",4,-28,14,16,0,-0.35,-11,1)
TNT1 A 0 A_SpawnItemEx("MagicHomingBirds",4,0,-14,16,0,-0.65,-15,1)
stop
}
}

actor Magicman_W_NormalBar : NormalBar {Args 236,3}
actor Magicman_W2_NormalBar : NormalBar {Args 236,3}