actor Magnetman_W : BaseMM8BDMWep_CBM
{
tag "$TAGC_3B"
dropitem "MagnetMissileWep"
Weapon.AmmoUse 0
Weapon.AmmoGive 0
Obituary "$OB_MAGNETMISSILE"
Inventory.Pickupmessage "Power up! YOU GOT SOME POWER!!!"
weapon.ammotype "PullCharge"
+WEAPON.Alt_AMMO_OPTIONAL
+WEAPON.NOAUTOAIM
States
{
Spawn:
C_03 B 1
loop

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


Ready:
MAGB A 0 ACS_NamedExecuteWithResult("core_weaponcolor",DYE_MAGNETMAN)
MAGB A 0 A_GunFlash("Flash",1)
goto Ready1
Ready1:
MAGB A 20 A_WeaponReady
wait

Fire:
MAGB A 0 A_JumpIfInventory("IsBot",1,"BotFire")
MAGB A 0 A_TakeInventory("MagnetmanFlag1")
MAGB A 2 A_TakeInventory("MagnetmanFlag2")
MAGB A 0 A_PlaySoundEx("weapon/magnetmissile","Weapon")
MAGB A 1 OffSet(-14,22)A_FireCustomMissile("MagMissileClass",0,1,8,0)
MAGB A 0 A_Refire("FireH")
goto FireH
FireH:
MAGB A 0 A_JumpIfInventory("MagnetmanFlag2",1,"FireEndX")
MAGB A 1 OffSet(-28,12)
MAGB A 0 A_Refire("FireH")
goto FireEnd
FireEndX:
MAGB A 0 A_ClearRefire
MAGB A 3 OffSet(-20,16)A_GiveInventory("MagnetmanFlag1",1)
MAGB A 3 OffSet(-12,20)A_WeaponReady(7)
MAGB A 3 OffSet(-6,24)A_WeaponReady(7)
MAGB A 3 OffSet(-2,28)A_WeaponReady(7)
Goto Ready1
FireEnd:
MAGB B 3 OffSet(-20,16)A_GiveInventory("MagnetmanFlag1",1)
MAGB B 3 OffSet(-12,20)A_WeaponReady(7)
MAGB A 3 OffSet(-6,24)A_WeaponReady(7)
MAGB A 3 OffSet(-2,28)A_WeaponReady(7)
Goto Ready1

Flash:
TNT1 AAAAA 2 A_SpawnItemEx("MagMissileClassFX",random(2,12),0,random(48,56),0,0,frandom(1,2),random(1,16)*20,1,256-CallACS("cbm_countinv_acs",31,0)*256.0f/56.0f)
TNT1 A 0 A_JumpIfInventory("VivifyDelay4",1,"Flash2")
TNT1 AAAAA 2 A_SpawnItemEx("MagMissileClassFX",random(2,12),0,random(48,56),0,0,frandom(1,2),random(1,16)*20,1,256-CallACS("cbm_countinv_acs",31,0)*256.0f/56.0f)
TNT1 A 0 A_JumpIfInventory("VivifyDelay4",1,"Flash2")
TNT1 A 0 A_GiveInventory("PullCharge",1)
loop
Flash2:
TNT1 A 1
TNT1 A 0 A_JumpIfInventory("VivifyDelay5",1,"Flash")
loop

AltFire:
MAGB C 0 A_GiveInventory("CBM_Ratio5_6JumpPowerGiver",1)
MAGB C 0 //ACS_NamedExecuteWithResult("core_stopplayer",0,1)
MAGB C 0 ACS_NamedExecuteWithResult("cbm_cantpushwallsplayer",0,1)
MAGB C 0 A_GiveInventory("PowerMagnetChargeSlow",1)
MAGB C 0 A_GiveInventory("VivifyDelay4",1)
MAGB C 0 A_Refire(1)
MAGB C 1 Offset(1,33)A_PlaySoundEx("weapon/magPush","auto")
MAGB C 2 Offset(1,33)A_GiveInventory("PullCharge",2)
MAGB C 0 A_Refire("Altfire3")
goto AltEndPull
Altfire2:
MAGB C 0 A_JumpIfInventory("PullCharge",56,"AltEndPull")
MAGB C 0 A_PlaySoundEx("weapon/magPush","auto")
MAGB C 0 A_GiveInventory("PowerMagnetChargeSlow",1)
MAGB C 0 A_GiveInventory("VivifyDelay4",1)
MAGB C 3 Offset(1,33)A_GiveInventory("PullCharge",2)
MAGB C 0 A_Refire("Altfire3")
goto AltEndPull
Altfire3:
MAGB C 0 A_JumpIfInventory("PullCharge",56,"AltEndPull")
MAGB C 0 A_GiveInventory("PowerMagnetChargeSlow",1)
MAGB C 0 A_GiveInventory("VivifyDelay4",1)
MAGB C 3 Offset(1,58)A_GiveInventory("PullCharge",2)
MAGB C 0 A_Refire("Altfire2")
goto AltEndPull
AltEndPull:
MAGB A 0 A_PlaySoundEx("weapon/magPush2","auto")
MAGB A 0 A_FireCustomMissile("MagPush1",0,0)
MAGB A 0 A_SpawnItemEx("MagpushFX",0,0,0,momx,momy,momz,0,8,0)
MAGB A 0 A_ClearRefire
MAGB B 2 OffSet(-18,14)A_GiveInventory("VivifyDelay5",1)
MAGB B 2 OffSet(-18,14)
MAGB A 0 A_TakeInventory("CBM_Ratio5_6JumpPower")
MAGB A 0 ACS_NamedExecuteWithResult("cbm_cantpushwallsplayer",0,0)
MAGB A 0 //ACS_NamedExecuteWithResult("core_stopplayer",0,0)
MAGB A 2 OffSet(-9,27)A_TakeInventory("PullCharge",56,1)
MAGB A 2 OffSet(-9,27)
Goto Ready1

BotFire:
MAGB A 0 A_JumpIfCloser(200,"BotAltCheck")
MAGB A 0 A_GiveInventory("BotRetreatFlag",1)
MAGB A 4 OffSet(-9,27)
MAGB A 0 A_PlaySoundEx("weapon/magnetmissile","Weapon")
MAGB A 0 A_FireCustomMissile("MagMissileClassX",0,1,8,0)
MAGB A 4 OffSet(-18,14)
MAGB A 4 OffSet(-9,27)
MAGB A 12 A_WeaponReady(14)
MAGB A 0 A_TakeInventory("BotRetreatFlag",999)
Goto Ready1
Run:
MAGB A 0 A_GiveInventory("BotRetreatFlag",1)
MAGB A 1
MAGB A 0 A_TakeInventory("BotRetreatFlag",999)
Goto Ready1
BotAltCheck:
MAGB A 0 A_JumpIfInventory("PullCharge",56,"AltEndPull")
MAGB A 0 A_Jump(32,"AltEndPull")
MAGB A 0 A_PlaySoundEx("weapon/magPush","auto")
MAGB C 0 A_GiveInventory("PowerMagnetChargeSlow",1)
MAGB C 0 A_GiveInventory("VivifyDelay4",1)
MAGB C 3 Offset(1,33)A_GiveInventory("PullCharge",random(2,4))
MAGB C 0 A_Refire(1)
goto AltEndPull
MAGB C 0 A_GiveInventory("PowerMagnetChargeSlow",1)
MAGB C 0 A_GiveInventory("VivifyDelay4",1)
MAGB C 3 Offset(1,58)A_GiveInventory("PullCharge",random(2,4))
MAGB C 0 A_Refire("BotAltCheck")
goto AltEndPull
}
}

actor PullCharge : Ammo
{
inventory.amount 1
inventory.maxamount 56
+INVENTORY.IGNORESKILL
}

actor MagnetmanFlag1 : Powerup
{
powerup.duration 35
}
actor MagnetmanFlag2 : OnceC{}

actor PowerMagnetChargeSlow : PowerSpeed
{
powerup.duration 7
Speed 0.25
+POWERSPEED.NOTRAIL
}

actor MagMissileClassX : ProjSpawnFuncActor
{
PROJECTILE
damagetype "MagnetM_Shot"
Obituary "$OB_MAGNETMISSILE"
+DONTSEEKINVISIBLE//
+SEEKERMISSILE
+SCREENSEEKER
ReactionTime 85
damage (150)
Radius 8
Height 5
speed 47
scale 2.5

States
{
Spawn:
MAGB T 2 A_SeekerMissile(2,10,3,88,10)
MAGB T 0 A_CountDown
loop
Death:
NMFX ABCE 2
stop
}
}

actor MagMissileClass : ProjSpawnFuncActor
{
var int user_translateLikePlayer;
Translation "192:192=205:205","198:198=41:41"
var int user_P;
PROJECTILE
damagetype "MagnetM_Shot"
Obituary "$OB_MAGNETMISSILE"
+DONTSEEKINVISIBLE//
+SEEKERMISSILE
+SCREENSEEKER
+LOOKALLAROUND
reactiontime 20
damage (120+(user_P*5))
Radius 8
Height 8
speed 35
scale 3.0//2.5
States
{
Spawn:
MAGB T 0 A_JumpIf(!CallACS("cbm_PointerExists",AAPTR_TARGET),"SpawnHomed")
MAGB TTT 1 A_JumpIfInTargetInventory("MagnetmanFlag1",1,"Home")
MAGB T 0 A_SetUserVar("user_P",user_P+1)
MAGB T 0 A_JumpIf(user_P>=16,"Spawn16")
MAGB T 0 A_SpawnItemEx("MagMissileClassFX",random(-8,8),0,Random(-8,8),random(-2,2),0,random(-2,2),random(0,359),9)
loop
Spawn16:
MAGB T 0 A_JumpIf(!CallACS("cbm_PointerExists",AAPTR_TARGET),"SpawnHomed")
MAGB TTT 1 A_JumpIfInTargetInventory("MagnetmanFlag1",1,"Home")
MAGB T 0 A_SetUserVar("user_P",user_P+1)
MAGB T 0 A_JumpIf(user_P>=32,"Spawn32")
MAGB TT 0 A_SpawnItemEx("MagMissileClassFX",random(-8,8),0,Random(-8,8),random(-2,2),0,random(-2,2),random(0,359),9)
loop
Spawn32:
MAGB T 0 A_JumpIf(!CallACS("cbm_PointerExists",AAPTR_TARGET),"SpawnHomed")
MAGB TTT 1 A_JumpIfInTargetInventory("MagnetmanFlag1",1,"Home")
MAGB T 0 A_SetUserVar("user_P",user_P+1)
MAGB TTT 0 A_SpawnItemEx("MagMissileClassFX",random(-8,8),0,Random(-8,8),random(-2,2),0,random(-2,2),random(0,359),9)
loop

SpawnHomed:
MAGB U 2
loop

HomeFlag:
MAGB T 0 A_ChangeFlag("SCREENSEEKER",0)
goto Home+1
Home:
MAGB T 0 A_JumpIf(user_P>=12,"HomeFlag")
MAGB T 0 //A_LogInt(user_P)
MAGB T 0 A_ScaleVelocity(0.75)
MAGB T 0 A_GiveInventory("MagnetmanFlag2",1)
MAGB T 0 A_RearrangePointers(AAPTR_DEFAULT,AAPTR_DEFAULT,AAPTR_NULL)
MAGB T 0 A_PlaySoundEx("S3_K/Beep","Weapon")
MAGB TTTT 0 A_SeekerMissile(user_P*0.5,user_P,7,256,3)
MAGB U 1
MAGB U 0 A_JumpIfInventory("MM8BDMPlayer",1,"HomeCheck",AAPTR_TRACER)
goto SpawnHomed
HomeCheck:
MAGB U 0 A_JumpIf(user_P>=32,"HomeSuper")
//MAGB U 0 A_JumpIfInventory("HeHasMyPowerPower",1,"Home3",AAPTR_TRACER)
goto Home2
Home2:
MAGB UUUUUUUUUUUUUUUUUUUU 1 A_SeekerMissile(user_P*0.5,user_P+1,6,50,3)
MAGB U 0 A_ScaleVelocity(4.0/3.0)
goto SpawnHomed
Home3:
MAGB UUUUUUUUUUUUUUUUUUUU 1 A_SeekerMissile(user_P+1,user_P*2+2,6,50,3)
MAGB U 0 A_ScaleVelocity(4.0/3.0)
goto SpawnHomed
HomeSuper://Peace out
MAGB UUUUUUUUUU 1 A_SeekerMissile(90,90,3,50,3)
MAGB U 0 A_CountDown
loop
Death:
TNT1 A 0 //A_LogInt(user_P)
TNT1 A 0 A_SpawnItemEx("MagMissileClassDeadFX")
TNT1 A 0 A_JumpIfInventory("MagnetmanFlag2",1,2)
TNT1 A 0 A_GiveToTarget("MagnetmanFlag2",1)
TNT1 A 8
stop
}
}

//actor HeHasMyPowerPower : Powerup{Powerup.Duration 90}

actor MagMissileClassDeadFX : BasicGraphicEffect
{
+FORCEXYBILLBOARD
+BRIGHT
States
{
SpawnFrame:
NMFX ABCD 2
stop
}
}

actor MagMissileClassFX : BasicGraphicEffect
{
States
{
SpawnFrame:
TNT1 A 0
TNT1 A 0 A_Jump(256,1,3)
MAGB V 5
MAGB V 1 A_Fadeout(0.1)
wait
MAGB W 5
MAGB W 1 A_Fadeout(0.1)
wait
}
}

actor PainMagnetM_PushHit : Basic_PainFling_H//MagHitKai
{
Args 1,0,2
states
{
Spawn:
TNT1 A 0
TNT1 A 0 A_SetArg(0,1+2.5*CallACS("cbm_countinv_acs_ptr",31,AAPTR_TARGET,AAPTR_TARGET))
goto SpawnCheck
}
}
actor DeathMagnetM_PushHit : Basic_DeathFling_H
{
Args 5,36,0
states
{
Spawn:
TNT1 A 0
TNT1 A 0 A_SetArg(0,5+2.5*CallACS("cbm_countinv_acs_ptr",31,AAPTR_TARGET,AAPTR_TARGET))
goto Fling
}
}

actor MagPush1 : BasicExplosion
{
var int user_P;
damagetype "MagnetM_Push"
Obituary "$OB_MAGNETPUSH"
states
{
Spawn:
TNT1 A 0
TNT1 A 0 A_SetUserVar("user_P",CallACS("cbm_countinv_acs",31,2))
TNT1 A 4 A_Explode(60+(user_P*2.5),128+(user_P*1.75),0,0,16+(user_P*0.875))
TNT1 A 2 A_TakeFromTarget("PullCharge",14)
stop
}
}

actor MagPushFX : BasicGraphicEffect
{
States
{
SpawnFrame:
MAGB JIJ 2
stop
}
}

actor Magnetman_W_NormalBar : NormalBar {Args 87,227}