actor RendingShieldWep_NormalBar : NormalBar{args 217, 3}
actor RendingShieldWep_ScriptBar : ScriptBar{}
actor RendingShieldWep : BaseMM8BDMWep{
Weapon.AmmoUse 10
Weapon.AmmoGive 30
Weapon.SlotNumber 7
Inventory.Pickupmessage "$PU_RENDINGSHIELD"
Obituary "$OB_RENDINGSHIELD"
Tag "$TAG_RENDINGSHIELD"
weapon.ammotype "RendingShieldAmmo"
inventory.icon "RSHLICON"
States
{
SpawnLoop:
RSHL Z 1
loop
Ready:
RSHL A 0 ACS_NamedExecuteWithResult("core_weaponcolor",COLOR_RENDINGSHIELD)
RSHL A 1 A_WeaponReady
Goto Ready+1
ReadyC: Goto Ready+1
Deselect:
RSHL A 0 
RSHL A 0 A_TakeInventory("WeaponCharge",999)
goto DeselectSwap
Select:
RSHL A 0 
RSHL A 0 A_TakeInventory("WeaponCharge",999)
goto SelectSwap
Fire:
RSHL A 0 A_JumpIfNoAmmo("NoAmmo")
Goto ShieldsUp
ShieldsUp:
RSHL A 0 A_TakeInventory("RendingShieldAmmo",10,TIF_NOTAKEINFINITE)
RSHL BBCC 1 A_GiveInventory("WeaponCharge",33)
RSHL C 0 A_PlaySoundEx("weapon/RabidBurst","Weapon")
RSHL C 0 A_SpawnItemEx("RendingShieldMaster",40*cos(pitch), 0, 40*sin(-pitch)+32,momx,momy,momz,0,8,0)
RSHL B 0 A_Refire("Shield")
goto FireRelease

Shield:
RSHL D 2 A_TakeInventory("WeaponCharge",1)
RSHL D 0 A_Refire("ShieldCheck")
goto FireRelease
ShieldCheck:
RSHL D 0 A_JumpIfInventory("WeaponCharge",1,"Shield")
RSHL D 2
goto FireRelease

Altfire:
RSHL A 0 A_JumpIfInventory("Vile_ClassAltfire", 1, "ClassAltfire")
RSHL A 0 A_JumpIf(CallACS("Vile_class_altfire"), "ClassAltfire")
RSHL A 1 A_JumpIfInventory("MM8BDMPlayer", 1, 1)
wait
RSHL A 0 A_TakeInventory("RendingShieldAmmo",10,TIF_NOTAKEINFINITE)
FireRelease:
RSHL B 0 A_TakeInventory("WeaponCharge",999)
RSHL BC 2
RSHL D 0 A_PlaySoundEx("Weapon/RiotMissileFire","Weapon")
RSHL D 10 A_FireCustomMissile("RendingShieldBullet",0,0,0)
RSHL C 4
RSHL A 2
RSHL A 20
goto Ready+1
ClassAltfire:
RSHL A 0 
goto Super::Altfire
NoAmmo:
RSHL A 0 ACS_NamedExecuteAlways("core_noammo",0)
Goto Ready+1
}
}

actor RendingShieldMaster : ProjSpawnFuncActor
{
	+MISSILE
	-SHOOTABLE
	+NODAMAGETHRUST
	+NOBLOOD
	+MOVEWITHSECTOR
	+CANBOUNCEWATER
	+DONTSPLASH
	+STEPMISSILE
	+DONTREFLECT
	+NOTAUTOAIMED
	+DONTDRAIN
	+NOGRAVITY
	+EXPLODEONDEATH
	+NOTARGETSWITCH
	+RIPPER
	+THRUSPECIES +CANTSEEK //no foolery allowed.

    +BRIGHT
    painchance 256
    Scale 2.5
    height 48
    radius 48
	damagetype "RendingShield"
    Obituary "$OB_RENDINGSHIELD"
	species "TheRendingShield"
    var int user_radius;
    var int user_angle;
    var int user_angleadd;
    var int user_expandtime;

	+NOINTERACTION

    States
    {
    Spawn:
		TNT1 A 0
		TNT1 A 0 A_GiveInventory("MM8BDMProjSpawnFunc",1)
		TNT1 A 0 A_SetUserVar(user_radius, 0)
		TNT1 A 0 A_SetUserVar(user_angleadd, 0)
		TNT1 A 0 A_SetUserVar(user_expandtime, 20)
		TNT1 A 0 A_SetUserVar(user_angle, angle)
		goto Expand
    SpawnLoop:
		TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("core_targetexists")==0,"End")
		TNT1 A 0 A_SpawnItemEx("RendingShieldHitbox",0,0,0,0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX",0,cos(pitch)	   *user_radius,(-sin(pitch)     *user_radius)+24,0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX",0,cos(pitch+120) *user_radius,(-sin(pitch+120) *user_radius)+24,0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX",0,cos(pitch+240) *user_radius,(-sin(pitch+240) *user_radius)+24,0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX3",0,cos(pitch)	   *user_radius,(-sin(pitch)     *user_radius)+24,0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX3",0,cos(pitch+120) *user_radius,(-sin(pitch+120) *user_radius)+24,0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX3",0,cos(pitch+240) *user_radius,(-sin(pitch+240) *user_radius)+24,0,0,0,0)
		TNT1 E 0 A_SetPitch(pitch%360+10)
		TNT1 A 1 A_Warp(AAPTR_TARGET, 48, 0, 20, 0, WARPF_INTERPOLATE|WARPF_NOCHECKPOSITION) 
		TNT1 A 0 A_JumpIfInTargetInventory("WeaponCharge", 1, "SpawnLoop")
		TNT1 A 2
		goto Detonate
    Expand:
		TNT1 A 0 A_SetUserVar(user_radius, user_radius+2)
		TNT1 A 0 A_SetUserVar(user_expandtime, user_expandtime-1)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX",0,cos(pitch)	   *user_radius,(-sin(pitch)     *user_radius)+24,0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX",0,cos(pitch+120) *user_radius,(-sin(pitch+120) *user_radius)+24,0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX",0,cos(pitch+240) *user_radius,(-sin(pitch+240) *user_radius)+24,0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX3",0,cos(pitch)	   *user_radius,(-sin(pitch)     *user_radius)+24,0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX3",0,cos(pitch+120) *user_radius,(-sin(pitch+120) *user_radius)+24,0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX3",0,cos(pitch+240) *user_radius,(-sin(pitch+240) *user_radius)+24,0,0,0,0)
		TNT1 E 0 A_SetPitch(pitch%360+10)
		TNT1 A 0 A_SpawnItemEx("RendingShieldHitbox",0,0,0,0,0,0,0)
		TNT1 B 1 A_Warp(AAPTR_TARGET, 48, 0, 20, 0, WARPF_INTERPOLATE|WARPF_NOCHECKPOSITION)
		TNT1 C 0 A_JumpIf(user_expandtime <= 0, "SpawnLoop")
		TNT1 C 0 A_JumpIfInTargetInventory("WeaponCharge", 1, "Expand")
		TNT1 A 2
		goto Detonate
    Death:
    Detonate:
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX",0,cos(pitch)	   *40,(-sin(pitch)     *40)+24,0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX",0,cos(pitch+120)  *40,(-sin(pitch+120) *40)+24,0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX",0,cos(pitch+240)  *40,(-sin(pitch+240) *40)+24,0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX3",0,cos(pitch)	   *40,(-sin(pitch)     *40)+24,0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX3",0,cos(pitch+120) *40,(-sin(pitch+120) *40)+24,0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX3",0,cos(pitch+240) *40,(-sin(pitch+240) *40)+24,0,0,0,0)
		TNT1 A 1 A_SetPitch(pitch%360+10)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX",-16,cos(pitch)	   *30,(-sin(pitch)     *30)+24,0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX",-16,cos(pitch+120)  *30,(-sin(pitch+120) *30)+24,0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX",-16,cos(pitch+240)  *30,(-sin(pitch+240) *30)+24,0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX3",-16,cos(pitch)	   *30,(-sin(pitch)     *30)+24,0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX3",-16,cos(pitch+120) *30,(-sin(pitch+120) *30)+24,0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX3",-16,cos(pitch+240) *30,(-sin(pitch+240) *30)+24,0,0,0,0)
		TNT1 A 1 A_SetPitch(pitch%360+10)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX",-24,cos(pitch)	   *20,(-sin(pitch)     *20)+24,0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX",-24,cos(pitch+120)  *20,(-sin(pitch+120) *20)+24,0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX",-24,cos(pitch+240)  *20,(-sin(pitch+240) *20)+24,0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX3",-24,cos(pitch)	   *20,(-sin(pitch)     *20)+24,0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX3",-24,cos(pitch+120) *20,(-sin(pitch+120) *20)+24,0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX3",-24,cos(pitch+240) *20,(-sin(pitch+240) *20)+24,0,0,0,0)
		TNT1 A 1 A_SetPitch(pitch%360+10)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX",-32,cos(pitch)	   *10,(-sin(pitch)     *10)+24,0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX",-32,cos(pitch+120)  *10,(-sin(pitch+120) *10)+24,0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX",-32,cos(pitch+240)  *10,(-sin(pitch+240) *10)+24,0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX3",-32,cos(pitch)	   *10,(-sin(pitch)     *10)+24,0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX3",-32,cos(pitch+120) *10,(-sin(pitch+120) *10)+24,0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("RendingShieldFX3",-32,cos(pitch+240) *10,(-sin(pitch+240) *10)+24,0,0,0,0)
		TNT1 A 1 A_SetPitch(pitch%360+10)
		RSHL X 1
		stop
    End:
		TNT1 A 0
		stop
    }
}

actor RendingShieldBullet : BasicProjectile
{
damagetype "RendingShield"
Obituary "$OB_RENDINGSHIELD"
species "TheRendingShield"
damage (CallACS("vile_cbm_damage",34))
Radius 32
Height 32
speed 20
scale 2.5
States
{
Spawn:
TNT1 A 0
RSHL X 4
TNT1 A 0 A_SpawnItemEx("RendingShieldFX2",0,cos(pitch)	 *5,(-sin(pitch)    *5),0,0,0,0)
TNT1 A 0 A_SpawnItemEx("RendingShieldFX2",0,cos(pitch+120)*5,(-sin(pitch+120)*5),0,0,0,0)
TNT1 A 0 A_SpawnItemEx("RendingShieldFX2",0,cos(pitch+240)*5,(-sin(pitch+240)*5),0,0,0,0)
TNT1 E 1 A_SetPitch(pitch%360+15)
TNT1 A 0 A_SpawnItemEx("RendingShieldFX2",0,cos(pitch)	 *10,(-sin(pitch)    *10),0,0,0,0)
TNT1 A 0 A_SpawnItemEx("RendingShieldFX2",0,cos(pitch+120)*10,(-sin(pitch+120)*10),0,0,0,0)
TNT1 A 0 A_SpawnItemEx("RendingShieldFX2",0,cos(pitch+240)*10,(-sin(pitch+240)*10),0,0,0,0)
TNT1 E 1 A_SetPitch(pitch%360+15)
Spawn2:
TNT1 A 0 A_SpawnItemEx("RendingShieldFX2",0,cos(pitch)	 *15,(-sin(pitch)    *15),0,0,0,0)
TNT1 A 0 A_SpawnItemEx("RendingShieldFX2",0,cos(pitch+120)*15,(-sin(pitch+120)*15),0,0,0,0)
TNT1 A 0 A_SpawnItemEx("RendingShieldFX2",0,cos(pitch+240)*15,(-sin(pitch+240)*15),0,0,0,0)
TNT1 E 1 A_SetPitch(pitch%360+15)
loop
Death:
TNT1 A 0 A_SpawnItemEx("SpurShotFlashyEndStar",0,cos(pitch)	 *15,(-sin(pitch)    *15),0,0,0,0)
TNT1 A 0 A_SpawnItemEx("SpurShotFlashyEndStar",0,cos(pitch+120)*15,(-sin(pitch+120)*15),0,0,0,0)
TNT1 A 5 A_SpawnItemEx("SpurShotFlashyEndStar",0,cos(pitch+240)*15,(-sin(pitch+240)*15),0,0,0,0)
stop
}
}

actor RendingShieldHitbox : BasicProjectile
{
PROJECTILE
+SHOOTABLE
-NOBLOCKMAP
+DONTRIP
+DONTREFLECT
+REFLECTIVE
+NOTARGETSWITCH
+DEFLECT
-SOLID
+SHOOTABLE
+NOBLOOD
+NOTARGETSWITCH
species "TheRendingShield"
+THRUSPECIES
+NORADIUSDMG
//+THRUGHOST
Health 99999
renderstyle "translucent"
+MISSILE
damagetype "RendingShieldShield"
Obituary "$OB_RENDINGSHIELD"
damage (CallACS("vile_cbm_damage",5))
Radius 48
Height 48
speed 0
painchance 256
+USEDAMAGEEVENTSCRIPT
var int user_NoOwnerDamage;
States
{
Spawn:
TNT1 A 0
TNT1 D 1
goto Death
Crash:
XDeath:
Death:
TNT1 A 1 
stop
Pain:
TNT1 A 0 A_SpawnItemEx("RendingShieldBigDeathFX",0,0,20)
TNT1 A 0 A_PlaySound("item/protoreflect")//A_Pain
TNT1 A 0 A_TakeFromTarget("WeaponCharge",8)
TNT1 A 1
goto Death
}
}

actor RendingShieldDeathFX : BasicGraphicEffect
{
+NOINTERACTION
+CLIENTSIDEONLY
alpha 0.9
renderstyle add
+BRIGHT
states
{
SpawnFrame:
RSHL V 0 A_SetScale(scaleX + 0.2, 3.0) 
RSHL V 1 A_FadeOut(0.1)
loop
}
}

actor RendingShieldBigDeathFX : BasicGraphicEffect
{
+NOINTERACTION
+CLIENTSIDEONLY
alpha 0.9
renderstyle add
+BRIGHT
states
{
SpawnFrame:
RSHL U 0 A_SetScale(scaleX + 0.2, 3.0) 
RSHL U 1 A_FadeOut(0.1)
loop
}
}


actor RendingShieldFX : BasicGraphicEffect
{
+BRIGHT
states
{
SpawnFrame:
RSHL W 1 
stop
}
}

actor RendingShieldFX2 : BasicGraphicEffect
{
Scale 2.0
+BRIGHT
states
{
SpawnFrame:
RSHL X 1 
stop
}
}

actor RendingShieldFX3 : BasicGraphicEffect
{
renderstyle translucent
alpha 0.6
+BRIGHT
states
{
SpawnFrame:
RSHL X 1 
stop
}
}

actor RendingShieldAmmo : Ammo
{
inventory.amount 1
inventory.maxamount 30
+INVENTORY.IGNORESKILL
}

actor RendingShieldDeflect : CustomInventory
{
States
{
Pickup:
TNT1 A 0
TNT1 A 0 A_JumpIf(CallACS("vile_isprojectilecheck"),"DoNot") //A_JumpIfInventory("MM8BDMPlayer",1,"DoNot")
TNT1 A 0 A_SpawnItemEx("RendingShieldDeathFX")
TNT1 A 0 A_ChangeFlag("THRUSPECIES",1)
TNT1 A 0 A_RearrangePointers(AAPTR_Master,AAPTR_Null,AAPTR_Default)
TNT1 A 0 A_FaceTracer(0,180)
TNT1 A 0 A_ChangeVelocity(30,0,0,CVF_RELATIVE|CVF_REPLACE)
stop
DoNot:
TNT1 A 0
stop
}
}

actor RendingShieldProtection : PowerProtection
{Damagefactor "RendingShieldShield", 0.0 Powerup.Duration 8}

actor HazardTag_RendingShield : BasicACSDamager { damagetype "RendingShield_Real" Obituary "$OB_RENDINGSHIELD" }
