actor TimeBenderWep_NormalBar : NormalBar { args 34, 239 }
actor TimeBenderWep_ScriptBar : ScriptBar {}

actor TimeBenderWep : BaseMM8BDMWep
{
Weapon.AmmoUse 28
Weapon.AmmoGive 28
Weapon.SlotNumber 6
Inventory.Pickupmessage "$PU_TIMEBENDER"
Obituary "$OB_TIMEBENDER"
Tag "$TAG_TIMEBENDER"
weapon.ammotype "YouBrokeItAmmo"
inventory.icon "XTR0WI_E"
States
{
SpawnLoop:
XWI0 E -1
loop

Deselect:
XH0E A 0
goto DeselectSwap
Select:
XH0E A 0 A_TakeInventory("TimeBenderFlag")
goto SelectSwap

Ready:
XH0E A 0 ACS_NamedExecuteWithResult("core_weaponcolor",DYE_TIMEBENDER)
XH0E A 1 A_WeaponReady
wait

Fire:
XH0E A 0 A_JumpIfInventory("YouBrokeItAmmo",0,1)
goto NoAmmo

//XH0E A 0 A_JumpIfNoAmmo("NoAmmo")
XH0E BC 2
XH0E D 0 A_PlaySoundEx("weapon/timestopper","Weapon")
XH0E D 0 A_FireCustomMissile("TimeBenderRadius",0,1,0,0)
XH0E D 0 A_GiveInventory("TimeBenderFlag",28)
XH0E D 1 ACS_NamedExecuteAlways("core_whiteflash",0)
Goto TimeStop
TimeStop:
XH0E D 4 A_TakeInventory("TimeBenderFlag",1)
//XH0E D 0 A_JumpIfInventory("YouBrokeItAmmo",28,"Fire")
XH0E D 0 A_JumpIfInventory("TimeBenderFlag",1,"TimeStop")
XH0E A 0 A_Jump(256,"NoAmmo")
Goto NoAmmo
NoAmmo:
XH0E A 0 A_TakeInventory("TimeBenderFlag",28)
XH0E A 1 ACS_NamedExecuteAlways("core_noammo",0)
Goto Ready+1
}
}

actor TimeBenderFlag : Inventory
{
inventory.amount 1
inventory.maxamount 28
}

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

actor TimeBenderRadius : BasicExplosion
{
damagetype "TimeBender"
Obituary "$OB_TIMEBENDER"
+PIERCEARMOR
//+FOILINVUL
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_SpawnItemEx("TimeBenderRadiusFX_H")
TNT1 A 4 A_Explode(77,512,0,0,256)
stop
}
}

actor TimeBenderRadiusFX_H : BasicGraphicEffect
{
RenderStyle None
ReactionTime 3
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_GiveInventory("ProjTeamColor2")
SpawnL:
TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 0 A_SpawnItemEx("TimeBenderRadiusFX1",random(-384,384),random(-384,384),random(-384,384),0,0,0,0,1+128)
TNT1 AAAAAAAAAA 0 A_SpawnItemEx("TimeBenderRadiusFX2",random(-384,384),random(-384,384),random(-384,384),0,0,0,0,1+128)
TNT1 A 2 A_CountDown
loop
}
}

actor TimeBenderRadiusFX1 : BasicGraphicEffect
{
+BRIGHT
Renderstyle "Translucent"
Alpha 0.95
ReactionTime 10
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_Jump(256,1,2,3)
SpawnL:
XH0E QRS 2 A_CountDown
loop
}
}

actor TimeBenderRadiusFX2 : BasicGraphicEffect
{
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_Jump(256,1,2,3,4,5,6)
Spawn1:
XH0E TUV 2 A_CountDown
loop
Spawn2:
XH0E WXY 2 A_CountDown
loop
}
}


actor TimeBenderPain_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_Stop
TNT1 A 0 A_SpawnItemEx("TimeBenderPainFX",random(16,64),0,random(4,64),0,0,0,random(0,71)*5)
stop
}
}

actor TimeBenderPainFX : BasicGraphicEffect
{
//Translation "192:192=4:4","198:198=4:4"
+FORCEXYBILLBOARD
+BRIGHT
Renderstyle "Translucent"
Alpha 0.95
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_Jump(256,1,5,9,13,17)
XH0E MNOP 3
stop
XH0E M random(1,3)
XH0E NO 3
XH0E P random(1,3)
stop
XH0E MNOP 2
stop
XH0E MNOP random(2,3)
stop
XH0E MNOP random(1,3)
stop
}
}


actor TimeBenderCamera_F : Inventory {}
actor IsTimeBended_F : Inventory {}
actor TimeBenderFreezeDuration : Powerup
{
Powerup.Duration 111//131//101 is true duration
}

actor TimeBenderStart_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_GiveInventory("CBM_FrozenPainSound_P")//CBM Weakness sound
TNT1 A 0 A_JumpIfInventory("TimeBenderFreezeDuration",1,"Reset")
TNT1 A 0 A_GiveInventory("EternalPainFlag",1)
TNT1 A 0 A_SpawnItemEx("TimeBenderWatcher_H")
TNT1 A 0 ACS_NamedExecuteWithResult("core_freezeplayer",0,1)//SetPlayerProperty(0,1,4)
TNT1 A 0 ACS_NamedExecuteWithResult("cbm_TimeBenderCameraLook")

Reset:
TNT1 A 0 A_GiveInventory("IsTimeBended_F",1)
TNT1 A 0 A_GiveInventory("TimeBenderFreezeDuration",1)
stop
}
}

actor TimeBenderWatcher_H : BasicWatcher
{//This watcher is to assist in instances when a class breaks out of the pain state
+SERVERSIDEONLY//Such as the Melee state happening
States
{
Spawn:
TNT1 A 0
TNT1 A 1 A_GiveToTarget("TimeBenderPain_P",1)
TNT1 A 0 A_TakeFromTarget("EternalPainFlag",1)
Spawn1:
TNT1 A 0 A_GiveToTarget("TimeBenderPain_P",1)
TNT1 A 1 A_JumpIf(!CallACS("cbm_PointerExists",AAPTR_TARGET),"Death")
TNT1 A 0 A_JumpIfInTargetInventory("EternalPainFlag",1,"Spawn2")
TNT1 A 0 A_JumpIfInTargetInventory("TimeBenderFreezeDuration",1,"Spawn1")
goto Spawn2
Spawn2:
TNT1 A 0
TNT1 A 2 A_GiveToTarget("TimeBenderEnd_P",1)
stop
}
}

actor TimeBenderEnd_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_TakeInventory("TimeBenderFreezeDuration")
TNT1 A 0 A_JumpIfInventory("IsTimeBended_F",1,2)
TNT1 A 0 A_TakeInventory("IsTimeBended_F")
stop
TNT1 A 0 A_TakeInventory("IsTimeBended_F")
TNT1 A 0 ACS_NamedExecuteWithResult("core_freezeplayer",0,0)
stop
}
}

