actor MagnetMissileBoss : BaseMM8BDMWep_CBM
{
tag "$TAGC_3B"
dropitem "MagnetMissileWepCDropped"
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
Ready:
MAGB A 0 ACS_ExecuteAlways(998,0,DYE_MAGNETMAN)
MAGB A 0 A_GunFlash
goto Ready1
Ready1:
MAGB A 20 A_WeaponReady
wait

Deselect:
MAGB AAAAAAAAAAAAAAAAAAAAAA 0 A_Lower
MAGB A 1 A_Lower
Loop
Select:
MAGB AAAAAAAAAAAAAAAAAAAAAA 0 A_Raise
MAGB A 1 A_Raise
Loop

Fire:
MAGB A 0 A_JumpIfInventory("IsBot",1,"BotFire")
MAGB A 0 A_TakeInventory("MagnetmanFlag1",9)
MAGB A 2 A_TakeInventory("MagnetmanFlag2",9)
MAGB A 0 A_PlaySoundEx("weapon/magnetmissile","Weapon")
MAGB A 1 OffSet(-14,22)A_GiveInventory("MagnetmanMain_CI",1)
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 A 0 A_JumpIfInventory("IsDead",1,"NoFlash")
TNT1 A 0 A_JumpIfInventory("VivifyDelay4",1,"Flash2")
TNT1 AAAAA 2 A_GiveInventory("PullChargeFX_P")
TNT1 A 0 A_JumpIfInventory("IsDead",1,"NoFlash")
TNT1 A 0 A_JumpIfInventory("VivifyDelay4",1,"Flash2")
TNT1 AAAAA 2 A_GiveInventory("PullChargeFX_P")
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("IsDead",1,"NoFlash")
TNT1 A 0 A_JumpIfInventory("VivifyDelay5",1,"Flash")
loop

AltFire:
MAGB C 0 ACS_ExecuteAlways(CORE_ACS_191,0,APROP_JumpZ,10,1)
MAGB C 0 //SetPlayerProperty(0,1,0)
MAGB C 0 A_GiveInventory("LadderDisable",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")
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 ACS_ExecuteAlways(CORE_ACS_191,0,APROP_JumpZ,12,1)
MAGB A 0 A_GiveInventory("LadderEnable",1)
MAGB A 0 //SetPlayerProperty(0,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_GiveInventory("MagnetmanMainX_CI",1)
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 : OnceC{}
actor MagnetmanFlag2 : OnceC{}

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

actor MagMissileClassX
{
Translation "192:192=4:4", "198:198=41:41"
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:
TMFX ABCD 2
stop
}
}

actor MagMissileClassXB : MagMissileClassX{translation "192:192=205:205", "198:198=74:74"}
actor MagMissileClassXR : MagMissileClassX{translation "192:192=171:171", "198:198=41:41"}
actor MagMissileClassXO : MagMissileClassX{translation "192:192=104:104", "198:198=128:128"}
actor MagMissileClassXP : MagMissileClassX{translation "192:192=229:229", "198:198=232:232"}

actor MagMissileClass
{
var int user_P;
Translation "192:192=4:4","198:198=41:41","250:250=4:4","249:249=205:205"
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(ACS_ExecuteWithResult(C_CHECK_TARGET_OOC)==0,"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(ACS_ExecuteWithResult(C_CHECK_TARGET_OOC)==0,"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(ACS_ExecuteWithResult(C_CHECK_TARGET_OOC)==0,"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("IsInGame",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_JumpIfInventory("MagnetmanFlag2",1,"Death2")
TNT1 A 0 A_GiveToTarget("MagnetmanFlag2",1)
TMFX ABCD 2
stop
Death2:
WMFX ABCD 2
stop
}
}


actor MagMissileClassB : MagMissileClass{Translation "192:192=205:205","198:198=74:74","250:250=196:196","249:249=199:199","195:195=74:74"}
actor MagMissileClassR : MagMissileClass{Translation "192:192=171:171","198:198=41:41","250:250=170:170","249:249=43:43","195:195=41:41"}
actor MagMissileClassO : MagMissileClass{Translation "192:192=104:104","198:198=128:128","250:250=138:138","249:249=131:131","195:195=128:128"}
actor MagMissileClassP : MagMissileClass{Translation "192:192=229:229","198:198=232:232","250:250=214:214","249:249=223:223","195:195=232:232"}

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


actor PullChargeFX_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 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)
stop
}
}

actor MagMissileClassFX : BasicClientSide
{
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_Jump(256,1,3)
X_0C E 5
X_0C E 1 A_Fadeout(0.1)
wait
X_0C F 5
X_0C F 1 A_Fadeout(0.1)
wait
}
}

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
{
-SOLID
+NOGRAVITY
+DONTSPLASH
+NONETID
Radius 2
Height 2
scale 2.5
States
{
Spawn:
MAGB JIJ 2
stop
}
}

actor MagnetmanMain_CI : TeamColor_CI
{
states
{
FireX:
TNT1 A 0 A_FireCustomMissile("MagMissileClass",0,1,8,0)
goto Done
FireB:
TNT1 A 0 A_FireCustomMissile("MagMissileClassB",0,1,8,0)
goto Done
FireR:
TNT1 A 0 A_FireCustomMissile("MagMissileClassR",0,1,8,0)
goto Done
FireO:
TNT1 A 0 A_FireCustomMissile("MagMissileClassO",0,1,8,0)
goto Done
FireP:
TNT1 A 0 A_FireCustomMissile("MagMissileClassP",0,1,8,0)
goto Done
}
}


actor MagnetmanMainX_CI : TeamColor_CI
{
states
{
FireX:
TNT1 A 0 A_FireCustomMissile("MagMissileClassX",0,1,8,0)
goto Done
FireB:
TNT1 A 0 A_FireCustomMissile("MagMissileClassXB",0,1,8,0)
goto Done
FireR:
TNT1 A 0 A_FireCustomMissile("MagMissileClassXR",0,1,8,0)
goto Done
FireO:
TNT1 A 0 A_FireCustomMissile("MagMissileClassXO",0,1,8,0)
goto Done
FireP:
TNT1 A 0 A_FireCustomMissile("MagMissileClassXP",0,1,8,0)
goto Done
}
}

