actor NebulousGuardWep_NormalBar : NormalBar{args 101, 3}
actor NebulousGuardWep_ScriptBar : ScriptBar{}
actor NebulousGuardWep : BaseMM8BDMWep 
{
Weapon.AmmoUse 5
Weapon.AmmoGive 28
Weapon.SlotNumber 7
Inventory.Pickupmessage "$PU_NEBULOUSGUARD"
Obituary "$OB_NEBULOUSGUARD"
Tag "$TAG_NEBULOUSGUARD"
weapon.ammotype "NebulousGuardAmmo"
inventory.icon "NLSGICON"
States
{
SpawnLoop:
NLSG Z 1
loop
Ready:
NLSG A 0 ACS_NamedExecuteWithResult("core_weaponcolor",COLOR_NEBULOUSGUARD)
NLSG A 1 A_WeaponReady
Goto Ready+1
ReadyC: Goto Ready+1
Deselect:
NLSG A 0 
goto DeselectSwap
Select:
NLSG A 0 
goto SelectSwap
Fire:
NLSG A 0 A_JumpIfNoAmmo("NoAmmo")
Goto ShieldsUp
ShieldsUp:
NLSG BB 1
NLSG B 0 A_Refire("Shield1")
goto FireReleaseX

Shield1:
NLSG C 0 A_PlaySoundEx("weapon/blackholestart","Weapon")
NLSG C 0 A_GiveInventory("WeaponCharge",1)
NLSG C 0 A_SpawnItemEx("NebulousGuardShield1",40*cos(pitch), 0, 40*sin(-pitch)+32,momx,momy,momz,0,8,0)
NLSG C 1 A_JumpIfInventory("WeaponCharge",132,"FireRelease")
NLSG C 0 A_GiveInventory("WeaponCharge",1)
NLSG C 0 A_SpawnItemEx("NebulousGuardShieldFX1",40*cos(pitch), 0, 40*sin(-pitch)+32,momx,momy,momz,0,8,0)
NLSG C 1 A_JumpIfInventory("WeaponCharge",132,"FireRelease")
NLSG C 0 A_Refire("Shield2")
goto FireRelease
Shield2:
NLSG C 0 A_GiveInventory("WeaponCharge",1)
NLSG C 0 A_SpawnItemEx("NebulousGuardShield2",40*cos(pitch), 0, 40*sin(-pitch)+32,momx,momy,momz,0,8,0)
NLSG C 1 A_JumpIfInventory("WeaponCharge",132,"FireRelease")
NLSG C 0 A_GiveInventory("WeaponCharge",1)
NLSG C 0 A_SpawnItemEx("NebulousGuardShieldFX2",40*cos(pitch), 0, 40*sin(-pitch)+32,momx,momy,momz,0,8,0)
NLSG C 1 A_JumpIfInventory("WeaponCharge",132,"FireRelease")
NLSG C 0 A_Refire("Shield3")
goto FireRelease
Shield3:
NLSG C 0 A_GiveInventory("WeaponCharge",1)
NLSG C 0 A_SpawnItemEx("NebulousGuardShield3",40*cos(pitch), 0, 40*sin(-pitch)+32,momx,momy,momz,0,8,0)
NLSG C 1 A_JumpIfInventory("WeaponCharge",132,"FireRelease")
NLSG C 0 A_GiveInventory("WeaponCharge",1)
NLSG C 0 A_SpawnItemEx("NebulousGuardShieldFX3",40*cos(pitch), 0, 40*sin(-pitch)+32,momx,momy,momz,0,8,0)
NLSG C 1 A_JumpIfInventory("WeaponCharge",132,"FireRelease")
NLSG C 0 A_Refire("Shield4")
goto FireRelease
Shield4:
NLSG C 0 A_GiveInventory("WeaponCharge",1)
NLSG C 0 A_SpawnItemEx("NebulousGuardShield4",40*cos(pitch), 0, 40*sin(-pitch)+32,momx,momy,momz,0,8,0)
NLSG C 1 A_JumpIfInventory("WeaponCharge",132,"FireRelease")
NLSG C 0 A_GiveInventory("WeaponCharge",1)
NLSG C 0 A_SpawnItemEx("NebulousGuardShieldFX4",40*cos(pitch), 0, 40*sin(-pitch)+32,momx,momy,momz,0,8,0)
NLSG C 1 A_JumpIfInventory("WeaponCharge",132,"FireRelease")
NLSG C 0 A_Refire("Shield5")
goto FireRelease
Shield5:
NLSG C 0 A_GiveInventory("WeaponCharge",1)
NLSG C 0 A_SpawnItemEx("NebulousGuardShield5",40*cos(pitch), 0, 40*sin(-pitch)+32,momx,momy,momz,0,8,0)
NLSG C 1 A_JumpIfInventory("WeaponCharge",132,"FireRelease")
NLSG C 0 A_GiveInventory("WeaponCharge",1)
NLSG C 0 A_SpawnItemEx("NebulousGuardShieldFX5",40*cos(pitch), 0, 40*sin(-pitch)+32,momx,momy,momz,0,8,0)
NLSG C 1 A_JumpIfInventory("WeaponCharge",132,"FireRelease")
NLSG C 0 A_Refire("Shield6")
goto FireRelease
Shield6:
NLSG C 0 A_GiveInventory("WeaponCharge",1)
NLSG C 0 A_SpawnItemEx("NebulousGuardShield4",40*cos(pitch), 0, 40*sin(-pitch)+32,momx,momy,momz,0,8,0)
NLSG C 1 A_JumpIfInventory("WeaponCharge",132,"FireRelease")
NLSG C 0 A_GiveInventory("WeaponCharge",1)
NLSG C 0 A_SpawnItemEx("NebulousGuardShieldFX4",40*cos(pitch), 0, 40*sin(-pitch)+32,momx,momy,momz,0,8,0)
NLSG C 1 A_JumpIfInventory("WeaponCharge",132,"FireRelease")
NLSG C 0 A_Refire("Shield7")
goto FireRelease
Shield7:
NLSG C 0 A_GiveInventory("WeaponCharge",1)
NLSG C 0 A_SpawnItemEx("NebulousGuardShield3",40*cos(pitch), 0, 40*sin(-pitch)+32,momx,momy,momz,0,8,0)
NLSG C 1 A_JumpIfInventory("WeaponCharge",132,"FireRelease")
NLSG C 0 A_GiveInventory("WeaponCharge",1)
NLSG C 0 A_SpawnItemEx("NebulousGuardShieldFX3",40*cos(pitch), 0, 40*sin(-pitch)+32,momx,momy,momz,0,8,0)
NLSG C 1 A_JumpIfInventory("WeaponCharge",132,"FireRelease")
NLSG C 0 A_Refire("Shield8")
goto FireRelease
Shield8:
NLSG C 0 A_GiveInventory("WeaponCharge",1)
NLSG C 0 A_SpawnItemEx("NebulousGuardShield2",40*cos(pitch), 0, 40*sin(-pitch)+32,momx,momy,momz,0,8,0)
NLSG C 1 A_JumpIfInventory("WeaponCharge",132,"FireRelease")
NLSG C 0 A_GiveInventory("WeaponCharge",1)
NLSG C 0 A_SpawnItemEx("NebulousGuardShieldFX2",40*cos(pitch), 0, 40*sin(-pitch)+32,momx,momy,momz,0,8,0)
NLSG C 1 A_JumpIfInventory("WeaponCharge",132,"FireRelease")
NLSG C 0 A_PlaySoundEx("weapon/pshot","Body")
NLSG A 0 A_FireCustomMissile("NebulousSpreadShot",-12,0,0,4)
NLSG A 0 A_FireCustomMissile("NebulousSpreadShot",12,0,0,4)
NLSG A 0 A_FireCustomMissile("NebulousSpreadShot",0,0,0,4)
NLSG C 0 A_Refire("Shield1")
goto FireRelease

FireRelease:
NLSG B 0 A_PlaySoundEx("weapons/mmb/copyvisionshoot","Weapon")
NLSG A 0 A_FireCustomMissile("NebulousGuardShot1",0,1,0)
NLSG A 0 A_FireCustomMissile("NebulousGuardShot2",0,0,0)
NLSG C 8
NLSG B 14
NLSG A 3 
FireCooldown:
NLSG A 1 A_TakeInventory("WeaponCharge",3)
NLSG A 1 A_JumpIfInventory("WeaponCharge",1,"FireCooldown")
NLSG A 2
goto Ready+1

Altfire:
NLSG A 0 A_JumpIfInventory("Vile_ClassAltfire", 1, "ClassAltfire")
NLSG A 0 A_JumpIf(CallACS("Vile_class_altfire"), "ClassAltfire")
NLSG A 1 A_JumpIfInventory("MM8BDMPlayer", 1, "FireReleaseX")
wait
FireReleaseX:
NLSG B 0 A_PlaySoundEx("weapons/mmb/copyvisionshoot","Weapon")
NLSG B 0 A_TakeInventory("WeaponCharge",9999)
NLSG A 0 A_FireCustomMissile("NebulousGuardShot1",0,1,0)
NLSG A 0 A_FireCustomMissile("NebulousGuardShot2",0,0,0)
NLSG BC 4
NLSG A 18
NLSG A 4
goto Ready+1

ClassAltfire:
NLSG A 0 
goto Super::Altfire

NoAmmo:
NSMR A 0 ACS_NamedExecuteAlways("core_noammo",0)
Goto Ready+1
}
}

actor NebulousSpreadShot : BasicProjectile
{
PROJECTILE
damagetype "NebulousGuard"
Obituary "$OB_NEBULOUSGUARD"
Speed 28
Damage (CallACS("vile_cbm_damage",12))
radius 7
height 5
scale 2.5
species "NebulousGuard"
+THRUSPECIES
States
{
Spawn:
NBSS ABCABC 2
NBSS A 0 A_ChangeFlag("THRUSPECIES",0)
loop
}
}


actor NebulousGuardShield1 : BasicProjectile
{
PROJECTILE
+SHOOTABLE
-NOBLOCKMAP
+DONTRIP
+DONTREFLECT
//+GHOST
//+NOINTERACTION
+NOTARGETSWITCH
-SOLID
+SHOOTABLE
+NOBLOOD
+NOTARGETSWITCH
species "NebulousGuard"
+THRUSPECIES
+NORADIUSDMG
//+THRUGHOST
Health 99999
renderstyle "translucent"
+MISSILE
damagetype "NebulousGuardShield"
Obituary "$OB_NEBULOUSGUARD"
damage (CallACS("vile_cbm_damage",1))
Radius 32
Height 32
speed 0
scale 3.0
painchance 256
States
{
Spawn:
TNT1 A 0
TNT1 D 1
goto Death
Crash:
XDeath:
Death:
NLSG "#" 1 ACS_NamedExecuteWithResult("core_alphaprojectile", CallACS("core_getptrtid", AAPTR_TARGET), APROJ_TEAM, 32765, 40) // 6553 = 0.1 * 65536
stop
Pain:
NLSG "#" 0 A_PlaySound("item/protoreflect")//A_Pain
NLSG "#" 1 A_SpawnItemEx("NebulousGuardDeathFX")
goto Death
}
}

actor NebulousGuardDeathFX : BasicGraphicEffect
{
scale 3.0
+NOINTERACTION
+CLIENTSIDEONLY
alpha 0.9
renderstyle add
+BRIGHT
states
{
SpawnFrame:
NLSG I 0 A_SetScale(scaleX + 0.2, 3.0) 
NLSG I 1 A_FadeOut(0.1)
loop
}
}

actor NebulousGuardShield2 : NebulousGuardShield1
{
States
{
Spawn:
TNT1 A 0
TNT1 E 1
goto Death
}
}

actor NebulousGuardShield3 : NebulousGuardShield1
{
States
{
Spawn:
TNT1 A 0
TNT1 F 1
goto Death
}
}

actor NebulousGuardShield4 : NebulousGuardShield1
{
States
{
Spawn:
TNT1 A 0
TNT1 G 1
goto Death
}
}

actor NebulousGuardShield5 : NebulousGuardShield1
{
States
{
Spawn:
TNT1 A 0
TNT1 H 1
goto Death
}
}

actor NebulousGuardShieldFX1 : NebulousGuardShield1 {damage (0)}
actor NebulousGuardShieldFX2 : NebulousGuardShield2 {damage (0)}
actor NebulousGuardShieldFX3 : NebulousGuardShield3 {damage (0)}
actor NebulousGuardShieldFX4 : NebulousGuardShield4 {damage (0)}
actor NebulousGuardShieldFX5 : NebulousGuardShield5 {damage (0)}

actor NebulousGuardShot1 : BasicProjectile
{
var int user_DIRECTION;
PROJECTILE
+SHOOTABLE
+SHOOTABLE
-NOBLOCKMAP
+DONTRIP
+DONTREFLECT
//+GHOST
//+NOINTERACTION
+NOTARGETSWITCH
-SOLID
+SHOOTABLE
+NOBLOOD
+NOTARGETSWITCH
+INVULNERABLE
species "NebulousGuard"
+THRUSPECIES
+NORADIUSDMG
//+THRUGHOST
+MISSILE
damagetype "NebulousGuard"
Obituary "$OB_NEBULOUSGUARD"
damage (CallACS("vile_cbm_damage",14))
Radius 32
Height 32
speed 15
scale 3.0
States
{
Spawn:
TNT1 A 1
TNT1 A 0 A_SetUserVar("user_DIRECTION",1)
goto SpawnStart
SpawnStart:
NLSG DDEEF 1
SpawnLoop:
NLSG FGGHHGGFFEEDDEEF 1 A_Weave(3.5*user_DIRECTION, 0.0, 3.5, 3.5)
loop
Death:
TNT1 A 1
stop
}
}

actor NebulousGuardShot2 : NebulousGuardShot1
{
States
{
Spawn:
TNT1 A 1
TNT1 A 0 A_SetUserVar("user_DIRECTION",-1)
goto SpawnStart
}
}

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


actor NebulousGuardKnockback : Vile_KnockbackHelper
{
Mass 6
Accuracy 0
}
