actor Elecman_W : BaseMM8BDMWep_CBM
{
tag "$TAGC_1F"
dropitem "ThunderBeamWep"
Weapon.AmmoUse 2
Weapon.AmmoGive 28
Obituary "$OB_THUNDERBEAM"
weapon.ammotype "ElectrifyingAmmo"
+WEAPON.NOAUTOAIM
States
{
Spawn:
C_01 F 1
loop

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

Ready:
ELEA A 0 ACS_NamedExecuteWithResult("core_weaponcolor",DYE_ELECMAN)
goto Ready1

Ready1:
ELEA A 0 A_JumpIfInventory("ElectrifyingAmmo",14,"Ready2")
ELEA A 2 A_WeaponReady(8)
goto Recharge1+1
Recharge1:
ELEA A 0 A_JumpIfInventory("ElectrifyingAmmo",14,"Recharge2")
ELEA A 4 A_WeaponReady(8)
ELEA A 0 A_GiveInventory("ElectrifyingAmmo",1)
loop
Ready2:
ELEA A 2 A_WeaponReady
goto Recharge2
Recharge2:
ELEA A 4 A_WeaponReady
ELEA A 0 A_GiveInventory("ElectrifyingAmmo",1)
loop

Fire:
ELEA E 0 A_JumpIfInventory("IsBot",1,"BotFire")
ELEA EDCC 2
ELEA D 0 A_GiveInventory("Elecman_Fire_P")
ELEA D 2
ELEA E 10
ELEA A 4
Goto Ready1
Altfire:
ELEA A 0 A_JumpIfInventory("ElectrifyingAmmo",14,"TeleportE")
Goto Ready1
TeleportE:
ELEA E 0 A_GiveInventory("VivifyDelay6",1)
ELEA E 0 A_ReFire(1)
ELEA E 0 A_SpawnItemEx("ThunderExtendHelper")
ELEA EDC 3 A_SpawnItemEx("ElecmanTeleportDamage",0,0,28,momx,momy,momz,0,8)
ELEA C 0 A_SpawnItemEx("ElecTeleFXHelper")
ELEA C 0 A_GiveInventory("ElecM_DashThrust_P")
ELEA C 1 ACS_NamedExecuteWithResult("core_invisibleplayer",0,true)
ELEA C 0 A_ChangeVelocity(16,0,momz,3)
ELEA C 0 //A_ScaleVelocity(0.03)//A_Stop
ELEA C 0 A_ChangeFlag("FLOORHUGGER",0)
ELEA C 0 ACS_NamedExecuteWithResult("core_unsolidplayer",0,USP_TOGGLEOFF_DAMAGE,CallACS("core_getmaxhealth")/10)
ELEA C 0 ThrustThingZ(0,1,0,1)
ELEA C 0 A_SpawnItemEx("ElecmanTeleportDamage2",0,0,28,momx,momy,momz,0,8)
ELEA C 3 ACS_NamedExecuteWithResult("core_invisibleplayer",0,false)
ELEA DEA 3
Goto Ready1

BotFire:
ELEA E 0 A_JumpIfInventory("ElectrifyingAmmo",14,"TeleportE")
ELEA E 0 A_GiveInventory("ElectrifyingAmmo",random(1,3))
Goto Fire+1
}
}

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

actor ElecM_DashThrust_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 //A_Stop
TNT1 A 0 A_JumpIf(CallACS("cbm_IsDashingDisabled"),2)
TNT1 A 0 A_ChangeVelocity(450,0,momz,3)
TNT1 A 0 A_PlaySoundEx("weapon/ElecTeleport","Weapon")
TNT1 A 0 ACS_NamedExecuteWithResult("core_unsolidplayer",0,USP_TOGGLEON)
TNT1 A 0 A_ChangeFlag("FLOORHUGGER",1)
TNT1 A 0 A_TakeInventory("ElectrifyingAmmo",7)
TNT1 A 0 A_TakeInventory("ElectrifyingAmmo",7,1)
stop
}
}

actor Elecman_Fire_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_PlaySoundEx("weapon/thunderbeam","Weapon")
TNT1 A 0 A_JumpIfInventory("ElectrifyingAmmo",1,"Pickup2")
goto End
Pickup2:
TNT1 A 0 //A_FireCustomMissile("ThunderManBeam",90,0,-24,0)
TNT1 A 0 //A_FireCustomMissile("ThunderManBeam",-90,0,24,0)
TNT1 A 0 A_SpawnItemEx("ThunderManBeam",24,16,28,30,0,0,90)
TNT1 A 0 A_SpawnItemEx("ThunderManBeam",24,-16,28,30,0,0,-90)
TNT1 A 0 A_JumpIfInventory("PlayerPropertySpread",1,"Pickup_Spread")
goto End
Pickup_Spread:
TNT1 A 0 A_SpawnItemEx("ThunderManBeam",24,16,28,30,0,0,90+15)
TNT1 A 0 A_SpawnItemEx("ThunderManBeam",24,-16,28,30,0,0,-90+15)

TNT1 A 0 A_SpawnItemEx("ThunderManBeam",24,16,28,30,0,0,90-15)
TNT1 A 0 A_SpawnItemEx("ThunderManBeam",24,-16,28,30,0,0,-90-15)
goto End
End:
TNT1 A 0 A_FireCustomMissile("ThunderManBeam",0,1,0,0)
stop
}
}

actor ThunderManBeam : ProjSpawnFuncActor
{
PROJECTILE
damagetype "ElecM_Beam"
Obituary "$OB_THUNDERBEAM"
+RIPPER
+BRIGHT
Damage (140)
Radius 12
Height 12
Speed 30
scale 2.5
States
{
Spawn:
ELEA TUVWXYZ 3
loop
Death:
TNT1 A 0 A_SpawnItemEX("ElectrifyEffect")
stop
}
}


actor ElecmanThunderDamageX : BasicImplosion
{
Obituary "$OB_THUNDERZAP"
damagetype "ElecM_Zap"
States
{
Spawn:
TNT1 A 0
TNT1 A 1 A_Explode(450,450,0)
stop
}
}

actor ElecmanTeleportDamage : BasicImplosion
{
Obituary "$OB_THUNDERZAP"
damagetype "ElecM_TeleZap"
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_SpawnItemEX("ElectrifyEffect")
TNT1 A 1 A_Explode(40+CallACS("core_checkrune",RUNE_SPREAD,2)*80,80,0,0,80)
stop
}
}

actor ElecmanTeleportDamage2 : ElecmanTeleportDamage
{
Obituary "$OB_THUNDERZAP"
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_SpawnItemEX("ElectrifyEffect")
TNT1 A 1 A_Explode(150+CallACS("core_checkrune",RUNE_SPREAD,2)*300,96,0,0,96)
stop
}
}

actor ThunderExtendHelper : BasicHelper
{
ReactionTime 4
States
{
Spawn:
TNT1 A 0
TNT1 A 1 A_GiveToTarget("ThunderExtendItemI",1)
TNT1 A 1 A_GiveToTarget("ThunderExtendItemJ",1)
TNT1 A 0 A_CountDown
loop
}
}

actor ThunderExtendItemI : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_SpawnItemEx("ThunderShieldI",0,0,32)
stop
}
}
actor ThunderExtendItemJ : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_SpawnItemEx("ThunderShieldJ",0,0,32)
stop
}
}


actor ElecM_TeleExtendFX
{
+MISSILE
+NOGRAVITY
+THRUACTORS
+NOEXPLODEFLOOR
+DONTBLAST
+CLIENTSIDEONLY
+NOINTERACTION
+FORCEYBILLBOARD
+BRIGHT
Damage (0)
height 12
radius 10
scale 2.5
states
{
Spawn:
ELEA F 0
ELEA F 0 A_JumpIf(ceilingz-z <= 12, "Death")
ELEA F 0 A_SpawnItemEx("ElecM_TeleExtendFX",0,0,60,0,0,0,0,1)
ELEA FGHFGHFGHFGH 2
stop
Death:
TNT1 A 1
stop
}
}

actor ThunderShieldI : BasicGraphicEffect
{
States
{
SpawnFrame:
ELEA I 0
ELEA I 1
stop
}
}

actor ThunderShieldJ : BasicGraphicEffect
{
States
{
SpawnFrame:
ELEA J 0
ELEA J 1
stop
}
}

actor ElecTeleFX
{
+MISSILE
+RIPPER
+THRUACTORS
+DONTBLAST
+NOTIMEFREEZE
+CLIENTSIDEONLY
+FLOORHUGGER
+NOGRAVITY
ReactionTime 5
Damage (0)
Height 4
Radius 4
scale 2.5
States
{
Spawn:
TNT1 A 0
TNT1 A 1
TNT1 A 0 A_Stop
goto RNG
RNG:
TNT1 A 0 A_CountDown
TNT1 A 0 A_FadeOut(0.05)
TNT1 A 0 A_Jump(256,1,2,3,4,5,6,7,8,9)
ELEA K 1
goto RNG
ELEA L 1
goto RNG
ELEA M 1
goto RNG
ELEA N 1
goto RNG
ELEA O 1
goto RNG
ELEA P 1
goto RNG
ELEA Q 1
goto RNG
ELEA R 1
goto RNG
ELEA S 1
goto RNG
Death:
TNT1 A 0
stop
}
}

actor ElecTeleFX0 : ElecTeleFX { speed 0   ReactionTime 20}
actor ElecTeleFX1 : ElecTeleFX { speed 20  ReactionTime 21}
actor ElecTeleFX2 : ElecTeleFX { speed 40  ReactionTime 22}
actor ElecTeleFX3 : ElecTeleFX { speed 60  ReactionTime 23}
actor ElecTeleFX4 : ElecTeleFX { speed 75  ReactionTime 24}
actor ElecTeleFX5 : ElecTeleFX { speed 95  ReactionTime 25}
actor ElecTeleFX6 : ElecTeleFX { speed 120 ReactionTime 26}
actor ElecTeleFX7 : ElecTeleFX { speed 140 ReactionTime 27}
actor ElecTeleFX8 : ElecTeleFX { speed 160 ReactionTime 28}
actor ElecTeleFX9 : ElecTeleFX { speed 180 ReactionTime 29}
actor ElecTeleFX10: ElecTeleFX { speed 200 ReactionTime 30}

actor ElecTeleFXEND : ElecTeleFX
{
States
{
Spawn:
TNT1 A 0
TNT1 A 1
TNT1 A 0 A_Stop
goto Death
Death:
TNT1 A 1 A_SpawnItemEx("ElecM_TeleExtendFX",0,0,60,0,0,0,0,1)
stop
}
}

actor ElecTeleFXHelper : BasicExplosion
{
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_SpawnItemEx("ElecTeleFX0",0,0,32,0,0,0,0,1)
TNT1 A 0 A_SpawnItemEx("ElecTeleFX1",0,0,32,20,0,0,0,1)
TNT1 A 0 A_SpawnItemEx("ElecTeleFX2",0,0,32,40,0,0,0,1)
TNT1 A 0 A_SpawnItemEx("ElecTeleFX3",0,0,32,60,0,0,0,1)
TNT1 A 0 A_SpawnItemEx("ElecTeleFX4",0,0,32,80,0,0,0,1)
TNT1 A 0 A_SpawnItemEx("ElecTeleFX5",0,0,32,100,0,0,0,1)
TNT1 A 0 A_SpawnItemEx("ElecTeleFX6",0,0,32,120,0,0,0,1)
TNT1 A 0 A_SpawnItemEx("ElecTeleFX7",0,0,32,140,0,0,0,1)
TNT1 A 0 A_SpawnItemEx("ElecTeleFX8",0,0,32,160,0,0,0,1)
TNT1 A 0 A_SpawnItemEx("ElecTeleFX9",0,0,32,180,0,0,0,1)
TNT1 A 0 A_SpawnItemEx("ElecTeleFX10",0,0,32,200,0,0,0,1)
TNT1 A 0 A_SpawnItemEx("ElecTeleFXEND",0,0,32,200,0,0,0,1)
stop
}
}

actor Elecman_W_NormalBar : NormalBar {Args 215,94}