actor MegaWaterBarrierWep_NormalBar : NormalBar { args 196, 118 }
actor MegaWaterBarrierWep_ScriptBar : ScriptBar {}

actor MegaWaterBarrierWep : BaseMM8BDMWep
{
Weapon.AmmoUse 1
Weapon.AmmoGive 28
Weapon.SlotNumber 7
Inventory.Pickupmessage "$PU_MEGAWATERBARRIER"
Obituary "$OB_MEGAWATERBARRIER"
Tag "$TAG_MEGAWATERBARRIER"
weapon.ammotype "MegaWaterBarrierAmmo"
inventory.icon "XTR0WI_T"
States
{
SpawnLoop:
XWI0 T -1
loop

Deselect:
XH0T A 0 A_JumpIfInventory("ShieldCheck",1,"Deactivate")
goto DeselectSwap
Select:
XH0T A 0
goto SelectSwap

Ready:
XH0T A 0 ACS_NamedExecuteWithResult("core_weaponcolor",DYE_MEGAWATERBARRIER)
XH0T A 1 A_WeaponReady
wait

Fire:
XH0T A 0 A_JumpIfNoAmmo("NoAmmo")
XH0T A 0 A_JumpIfInventory("ShieldCheck",1,"Finish")
XH0T A 0 A_GiveInventory("ShieldCheck",1)
XH0T A 0 A_TakeInventory("MegaWaterBarrierAmmo",1,1)
XH0T A 0 A_PlaySound("classes/MWS_Shield",4,1.0)
XH0T BC 2
XH0T C 0 A_GunFlash("Flash",1)
XH0T D 2 A_TakeInventory("StopShield",1)
XH0T D 0 A_GiveInventory("MWB_ShieldHitbox_P",1)
Goto BarrierActive
BarrierActive:
XH0T D 0 A_JumpIfInventory("PlayerPropertyRage",1,4)
XH0T D 0 A_JumpIfNoAmmo("Finish")
XH0T D 0 A_SpawnItemEx("MWB_ShieldFX1",23,0,8,momx,momy,momz,0,1+8)
XH0T D 1 A_WeaponReady
XH0T D 0 A_JumpIfNoAmmo("Finish")
XH0T D 0 A_SpawnItemEx("MWB_ShieldFX1",23,0,8,momx,momy,momz,0,1+8)
XH0T D 1 A_WeaponReady
XH0T D 0 A_JumpIfInventory("PlayerPropertyRage",1,4)
XH0T D 0 A_JumpIfNoAmmo("Finish")
XH0T D 0 A_SpawnItemEx("MWB_ShieldFX2",23,0,8,momx,momy,momz,0,1+8)
XH0T D 1 A_WeaponReady
XH0T D 0 A_JumpIfNoAmmo("Finish")
XH0T D 0 A_SpawnItemEx("MWB_ShieldFX2",23,0,8,momx,momy,momz,0,1+8)
XH0T D 1 A_WeaponReady
XH0T D 0 A_JumpIfInventory("PlayerPropertyRage",1,4)
XH0T D 0 A_JumpIfNoAmmo("Finish")
XH0T D 0 A_SpawnItemEx("MWB_ShieldFX3",23,0,8,momx,momy,momz,0,1+8)
XH0T D 1 A_WeaponReady
XH0T D 0 A_JumpIfNoAmmo("Finish")
XH0T D 0 A_SpawnItemEx("MWB_ShieldFX3",23,0,8,momx,momy,momz,0,1+8)
XH0T D 1 A_WeaponReady
XH0T D 0 A_JumpIfInventory("PlayerPropertyRage",1,4)
XH0T D 0 A_JumpIfNoAmmo("Finish")
XH0T D 0 A_SpawnItemEx("MWB_ShieldFX4",23,0,8,momx,momy,momz,0,1+8)
XH0T D 1 A_WeaponReady
XH0T D 0 A_JumpIfNoAmmo("Finish")
XH0T D 0 A_SpawnItemEx("MWB_ShieldFX4",23,0,8,momx,momy,momz,0,1+8)
XH0T D 1 A_WeaponReady
loop
Finish:
XH0T D 0 A_PlaySound("classes/ShieldPop",4,1.0)
XH0T D 0 A_GiveInventory("StopShield",1)
XH0T D 0 A_TakeInventory("ShieldCheck",9)
XH0T D 0 A_FireCustomMissile("MegaWaterBarrierBlast",0,0,0,0)
XH0T C 2
XH0T BA 2 A_TakeInventory("MWB_ChargeFlag")
XH0T A 5 A_TakeInventory("StopShield",1)
Goto Ready+1
Deactivate:
XH0T D 0 A_PlaySound("classes/ShieldPop",4,1.0)
XH0T D 0 A_GiveInventory("StopShield",1)
XH0T D 0 A_TakeInventory("ShieldCheck",9)
XH0T D 0 A_FireCustomMissile("MegaWaterBarrierBlast",0,0,0,0)
XH0T C 2
XH0T BA 2 A_TakeInventory("MWB_ChargeFlag")
XH0T A 5 A_TakeInventory("StopShield",1)
Goto Deselect+1

Flash:
TNT1 A 2 A_GiveInventory("MWB_ChargeFlag",1)
TNT1 A 0 A_JumpIfInventory("ShieldCheck",1,1)
stop
TNT1 A 2 A_GiveInventory("MWB_ChargeFlag",1)
TNT1 A 0 A_JumpIfInventory("ShieldCheck",1,1)
stop
TNT1 A 2 A_GiveInventory("MWB_ChargeFlag",1)
TNT1 A 0 A_JumpIfInventory("ShieldCheck",1,1)
stop
TNT1 A 2 A_GiveInventory("MWB_ChargeFlag",1)
TNT1 A 0 A_JumpIfInventory("ShieldCheck",1,1)
stop
TNT1 A 2 A_GiveInventory("MWB_ChargeFlag",1)
TNT1 A 0 A_JumpIfInventory("ShieldCheck",1,1)
stop
TNT1 A 2 A_GiveInventory("MWB_ChargeFlag",1)
TNT1 A 0 A_JumpIfInventory("ShieldCheck",1,1)
stop
TNT1 A 2 A_GiveInventory("MWB_ChargeFlag",1)
TNT1 A 0 A_JumpIfInventory("ShieldCheck",1,1)
stop
TNT1 A 2 A_GiveInventory("MWB_ChargeFlag",1)
TNT1 A 0 A_JumpIfInventory("ShieldCheck",1,1)
stop
TNT1 A 2 A_GiveInventory("MWB_ChargeFlag",1)
TNT1 A 0 A_JumpIfInventory("ShieldCheck",1,1)
stop
TNT1 A 0 A_TakeInventory("MegaWaterBarrierAmmo",1,1)
loop
NoAmmo:
XH0T A 1 ACS_NamedExecuteAlways("core_noammo",0)
Goto Ready+1
}
}

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

actor MWB_ChargeFlag : Inventory
{
inventory.amount 1
inventory.maxamount 60
}

actor MWB_ShieldHitbox_P : CustomInventory
{
states
{
Pickup:
TNT1 A 0 A_SpawnItemEx("MWB_ShieldHitbox1",28,-16,8,0,0,0,0,1)
TNT1 A 0 A_SpawnItemEx("MWB_ShieldHitbox2",28,-8,8,0,0,0,0,1)
TNT1 A 0 A_SpawnItemEx("MWB_ShieldHitbox3",28,0,8,0,0,0,0,1)
TNT1 A 0 A_SpawnItemEx("MWB_ShieldHitbox4",28,8,8,0,0,0,0,1)
TNT1 A 0 A_SpawnItemEx("MWB_ShieldHitbox5",28,16,8,0,0,0,0,1)
stop
}
}

actor MWB_ShieldHitbox1 : BasicShieldHitbox
{
Meleerange 28
Accuracy -16
Mass 8
Height 64
States
{
Pain:
TNT1 A 0
TNT1 A 0 A_SpawnItemEx("MWB_ShieldHitFX",0,0,10)
TNT1 A 0 A_PlaySound("item/protoreflect")
goto Spawn
}
}
actor MWB_ShieldHitbox2 : MWB_ShieldHitbox1
{
Accuracy -8
}
actor MWB_ShieldHitbox3 : MWB_ShieldHitbox1
{
Accuracy 0
}
actor MWB_ShieldHitbox4 : MWB_ShieldHitbox1
{
Accuracy 8
}
actor MWB_ShieldHitbox5 : MWB_ShieldHitbox1
{
Accuracy 16
}

actor MWB_ShieldHitFX : BasicGraphicEffect
{
+BRIGHT
alpha 0.9
renderstyle add
Scale 1.5
states
{
SpawnFrame:
XH0T U 0 A_SetScale(scaleX + 0.1, 2.5) 
XH0T U 1 A_FadeOut(0.05)
loop
}
}


actor MWB_ShieldFX1 : BasicGraphicEffect
{
+NOTIMEFREEZE
renderstyle translucent
alpha 0.5
scale 1.25
States
{
SpawnFrame:
XH0T Q 1
stop
}
}

actor MWB_ShieldFX2 : MWB_ShieldFX1
{
States
{
SpawnFrame:
XH0T R 1
stop
}
}
actor MWB_ShieldFX3 : MWB_ShieldFX1
{
States
{
SpawnFrame:
XH0T S 1
stop
}
}
actor MWB_ShieldFX4 : MWB_ShieldFX1
{
States
{
SpawnFrame:
XH0T T 1
stop
}
}

actor PainMegaWaterBarrierHit : Basic_PainFling_H
{
Args 10,0,2
states
{
Spawn:
TNT1 A 0
TNT1 A 0 A_SetArg(0,10+2*CallACS("cbm_countinv_acs_ptr",-305,AAPTR_TARGET,AAPTR_TARGET))
goto SpawnCheck
}
}
actor DeathMegaWaterBarrierHit : Basic_DeathFling_H
{
Args 14,16,0
states
{
Spawn:
TNT1 A 0
TNT1 A 0 A_SetArg(0,14+2*CallACS("cbm_countinv_acs_ptr",305,AAPTR_TARGET,AAPTR_TARGET))
goto Fling
}
}

actor MegaWaterBarrierBlast : BasicExplosion
{
var int user_P;
damagetype "MegaWaterBarrier"
Obituary "$OB_MEGAWATERBARRIER"
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_SetUserVar("user_P",CallACS("cbm_countinv_acs",305,2))//Max 60
TNT1 AAAAA 0 A_SpawnItemEx("MegaWaterBarrierFX",random(-5,5),random(-5,5),-16,random(-5,5),random(-5,5),random(2,6),0,1)
TNT1 AAAAA 0 A_SpawnItemEx("MegaWaterBarrierFX",random(-5,5),random(-5,5),0,random(-5,5),random(-5,5),random(2,6),0,1)
TNT1 AAAAA 0 A_SpawnItemEx("MegaWaterBarrierFX",random(-5,5),random(-5,5),-16,random(-5,5),random(-5,5),random(2,6),0,1)
TNT1 A 0 A_SpawnItemEx("MegaWaterBarrierFX_H1",28)
TNT1 A 4 A_Explode(user_P/6*25+120,user_P/6*20+199,0)
stop
}
}

actor MegaWaterBarrierFX_H1 : BasicHelper
{
States
{
Spawn:
TNT1 A 0 //Transfer MWB_ChargeFlag as an Angle to spawn FX
TNT1 A 2 A_SpawnItemEx("MegaWaterBarrierFX_H2",0,0,0,0,0,0,CallACS("cbm_countinv_acs",-305,2),4)
stop
}
}
actor MegaWaterBarrierFX_H2 : BasicExplosion
{
States
{
Spawn:
TNT1 A 0 //Double spawn to sync online
TNT1 A 1 A_SpawnItemEx("MegaWaterBarrierFX_H3",0,0,0,0,0,0,angle,1+4)
stop
}
}
actor MegaWaterBarrierFX_H3 : BasicClientside
{
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_SetArg(1,Angle)
SpawnL:
TNT1 AA 0 A_SpawnItemEx("MegaWaterBarrierFX",8,0,random(-10,10),frandom(2+Args[1]*0.1,Args[1]*0.5),0,random(3,8),random(0,359),1)
TNT1 A 0 A_CountDownArg(1)
loop
Death:
TNT1 A 1
stop
}
}

actor MegaWaterBarrierFX : BasicGraphicEffectM
{
-NOGRAVITY
+THRUACTORS
speed 25
scale 1.0
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_Jump(256,1,2,3,4,5,6)
XH0T MMNNOO 1 A_FadeOut(0.05)
goto Spawn+2
}
}