actor LightningBoltWep : BaseMM8BDMWep 10019
{
//$Category MM8BDM-Weapons
//$Title Lightning Bolt
//$Sprite LIBOA0
Weapon.AmmoUse 7
Weapon.AmmoGive 28
Weapon.SlotNumber 6
Inventory.Pickupmessage "$PU_LIGHTNINGBOLT"
Obituary "$OB_LIGHTNINGBOLT"
Tag "$TAG_LIGHTNINGBOLT"
weapon.ammotype "LightningBoltAmmo"
inventory.icon "LIGHTNI"
States
{
SpawnLoop:
LIBO A -1
loop
Ready:
LIBO B 0 ACS_ExecuteAlways(998,0,177)
LIBO B 1 A_WeaponReady
Goto Ready+1
Deselect:
TNT1 AAAAAAAAAAAAAAAAAAAAAA 0 A_Lower
LIBO B 1 A_Lower
Loop
Select:
TNT1 AAAAAAAAAAAAAAAAAAAAAA 0 A_Raise
LIBO B 1 A_Raise
Loop
Fire:
LIBO B 0 A_JumpIfNoAmmo("NoAmmo")
LIBO B 0 A_JumpIfInventory("LightningBoltCooldown",1,"NoAmmo")
LIBO B 0 A_PlaySoundEx("weapon/lightningbolt","Weapon")
LIBO B 0 A_Stop
LIBO B 0 ACS_NamedExecuteAlways("core_flyplayer",0,0,1)
LIBO B 0 ACS_NamedExecuteAlways("core_freezeplayer",0,0,1)//SetPlayerProperty(0,1,4)
LIBO C 2 A_SpawnItemEx("LightningStartFX1",4,0,48)
LIBO D 2 A_SpawnItemEx("LightningStartFX2",4,0,48)
LIBO EF 2
TNT1 A 10
TNT1 A 1 A_FireCustomMissile("LightningBoltTracer", 0, 1, 8, 0)
TNT1 A 0 A_FireCustomMissile("LightningBoltTracer2", 345, 0, 8, 0)
TNT1 A 1 A_FireCustomMissile("LightningBoltTracer", 30, 0, 8, 0)
TNT1 A 0 A_FireCustomMissile("LightningBoltTracer2", 315, 0, 8, 0)
TNT1 A 1 A_FireCustomMissile("LightningBoltTracer", 60, 0, 8, 0)
TNT1 A 0 A_FireCustomMissile("LightningBoltTracer2", 285, 0, 8, 0)
TNT1 A 1 A_FireCustomMissile("LightningBoltTracer", 90, 0, 8, 0)
TNT1 A 0 A_FireCustomMissile("LightningBoltTracer2", 255, 0, 8, 0)
TNT1 A 1 A_FireCustomMissile("LightningBoltTracer", 120, 0, 8, 0)
TNT1 A 0 A_FireCustomMissile("LightningBoltTracer2", 225, 0, 8, 0)
TNT1 A 1 A_FireCustomMissile("LightningBoltTracer", 150, 0, 8, 0)
TNT1 A 0 A_FireCustomMissile("LightningBoltTracer2", 195, 0, 8, 0)
TNT1 A 1 A_FireCustomMissile("LightningBoltTracer", 180, 0, 8, 0)
TNT1 A 0 A_FireCustomMissile("LightningBoltTracer2", 165, 0, 8, 0)
TNT1 A 1 A_FireCustomMissile("LightningBoltTracer", 210, 0, 8, 0)
TNT1 A 0 A_FireCustomMissile("LightningBoltTracer2", 135, 0, 8, 0)
TNT1 A 1 A_FireCustomMissile("LightningBoltTracer", 240, 0, 8, 0)
TNT1 A 0 A_FireCustomMissile("LightningBoltTracer2", 105, 0, 8, 0)
TNT1 A 1 A_FireCustomMissile("LightningBoltTracer", 270, 0, 8, 0)
TNT1 A 0 A_FireCustomMissile("LightningBoltTracer2", 75, 0, 8, 0)
TNT1 A 1 A_FireCustomMissile("LightningBoltTracer", 300, 0, 8, 0)
TNT1 A 0 A_FireCustomMissile("LightningBoltTracer2", 45, 0, 8, 0)
TNT1 A 1 A_FireCustomMissile("LightningBoltTracer", 330, 0, 8, 0)
TNT1 A 0 A_FireCustomMissile("LightningBoltTracer2", 15, 0, 8, 0)
TNT1 A 10
LIBO FEDC 2
LIBO B 0 ACS_NamedExecuteAlways("core_flyplayer",0,0,0)
LIBO B 0 ACS_NamedExecuteAlways("core_freezeplayer",0,0,0)
LIBO B 1 A_GiveInventory("LightningBoltCooldown",1)
LIBO B 0 A_Refire
Goto Ready+1
NoAmmo:
LIBO B 1 ACS_Execute(979,0)
Goto Ready+1
}
}

actor LightningBoltCooldown : Powerup
{
    powerup.duration 20
}

actor LightningStartFX1
{
translation "229:229=246:246", "210:210=59:59"
    +NOINTERACTION
    -SOLID
    +NOGRAVITY
    +NONETID
    +FORCEYBILLBOARD
    +BRIGHT
    Scale 2.5
    States
    {
    Spawn:
        LBFX BCD 3
        stop
    }
}

actor LightningStartFX2 : LightningStartFX1
{
translation "229:229=246:246", "210:210=59:59"
    -FORCEYBILLBOARD
    States
    {
    Spawn:
        LBFX EFGHIJ 3
        stop
    }
}

actor LightningBoltFX : LightningStartFX1
{
translation "229:229=246:246", "210:210=59:59"
    -FORCEYBILLBOARD
    +FORCEXYBILLBOARD
    States
    {
    Spawn:
        LBFX K 0
        LBFX K 0 A_ChangeVelocity(Random(-2, 2), Random(-2, 2), Random(-2, 2), CVF_REPLACE)
        LBFX KLM 1
        stop
    }
}


actor LightningBoltTracer 
{
translation "229:229=246:246", "210:210=59:59"
    PROJECTILE
    +DONTSPLASH
    +NOEXPLODEFLOOR
    +NOCLIP
    +DONTBLAST
    Damage (0)
    Speed 60
    Radius 16
    Height 96
    Scale 2.5
    ReactionTime 10
    States
    {
    Spawn:
        TNT1 A 0
        TNT1 A 0 A_ChangeFlag("FLOORHUGGER",1)
        TNT1 A 0 A_Changeflag("NOCLIP",0)
        TNT1 A 1 A_CountDown
        wait
    Death:
        TNT1 A 0 A_JumpIf(reactiontime <= 0, "XDeath")
        stop
    Crash:
    XDeath:
        TNT1 A 0
        TNT1 A 0 A_SpawnItemEx("LightningBolt")
        stop
    }
}

actor LightningBoltTracer2 : LightningBoltTracer
{
    ReactionTime 5
}

actor LightningBolt
{
translation "229:229=246:246", "210:210=59:59"
    PROJECTILE
    +THRUACTORS
    +NOEXPLODEFLOOR
    +FORCEYBILLBOARD
    +FLOORHUGGER
    +DONTBLAST
    +BRIGHT
    Damage (0)
    DamageType "LightningBolt"
    Obituary "$OB_LIGHTNINGBOLT"
    height 32
    radius 16
    scale 2.5
    states
    {
    Spawn:
        LIBO G 0
        LIBO G 1 A_SpawnItemEx("LightningExtend", 0, 0, 355)
        LIBO G 0 A_PlaySoundEx("weapon/lightningbolt","Weapon")
        LIBO G 0 A_Explode(47, 128, 0)
        LIBO H 1
        LIBO I 0 A_SpawnItemEx("LightningBoltFX", Random(32, 96), Random(32, 96), 32)
        LIBO I 0 A_SpawnItemEx("LightningBoltFX", Random(-32, -96), Random(-32, -96), 64)
        LIBO I 0 A_SpawnItemEx("LightningBoltFX", Random(32, 96), Random(32, 96), 96)
        LIBO I 0 A_SpawnItemEx("LightningBoltFX", Random(-32, -96), Random(-32, -96), 128)
        LIBO I 0 A_SpawnItemEx("LightningBoltFX", Random(32, 96), Random(32, 96), 160)
        LIBO I 0 A_SpawnItemEx("LightningBoltFX", Random(-32, -96), Random(-32, -96), 192)
        LIBO IJK 1
        Stop
    }
}

Actor LightningExtend : LightningBolt
{
translation "229:229=246:246", "210:210=59:59"
    -FLOORHUGGER
    +CLIENTSIDEONLY
    +NOINTERACTION
    States
    {
    Spawn:
        LIBO L 0 
        LIBO L 0 A_JumpIf(ceilingz-z <= 32, "Death")
        LIBO L 0 A_SpawnItemEx("LightningExtend", 0, 0, 160)
        LIBO LLMN 1
        stop
    Death:
        TNT1 A 0 
        stop
    }
}

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