actor Skullman_W : BaseMM8BDMWep_CBM
{
tag "$TAGC_4H"
dropitem "SkullmanWepDroppedX"
Weapon.AmmoUse 2
Weapon.AmmoGive 2
Weapon.AmmoUse2 1
Weapon.AmmoGive2 2
Obituary "$OB_SKULLBUSTER"
Inventory.Pickupmessage "Power up! Skull Buster!"
weapon.ammotype "AlasPoorYorickAmmo"
weapon.ammotype2 "SpookyScaryAmmo"
+WEAPON.NOAUTOAIM
States
{
Spawn:
C_04 H 1
loop

Deselect:
SKUB A 0 A_TakeInventory("ShieldCheck")
SKUB A 0 A_TakeInventory("ShieldHits")
goto DeselectSwap
Select:
SKUB A 0
goto SelectSwap

Ready:
SKUB A 0 ACS_NamedExecuteWithResult("core_weaponcolor",DYE_SKULLMAN)
goto Ready1

Ready1D:
SKUB A 0 A_JumpIfInventory("AlasPoorYorickAmmo",2,"Ready2D")
SKUB A 0 A_JumpIfInventory("SpookyScaryAmmo",112,"Ready3D")
SKUB A 0 A_JumpIfInventory("PowerSkullCounter",1,2)
SKUB AA 2 A_WeaponReady(12)
SKUB A 0 A_GiveInventory("SpookyScaryReady_P")
goto Ready1
Ready2D:
SKUB A 0 A_JumpIfInventory("SpookyScaryAmmo",112,"Ready4D")
SKUB A 0 A_JumpIfInventory("PowerSkullCounter",1,2)
SKUB AA 2 A_WeaponReady(8)
SKUB A 0 A_GiveInventory("SpookyScaryReady_P")
goto Ready2
Ready3D:
SKUB A 0 A_JumpIfInventory("AlasPoorYorickAmmo",2,"Ready4D")
SKUB A 0 A_JumpIfInventory("PowerSkullCounter",1,2)
SKUB AA 2 A_WeaponReady(4)
SKUB A 0 A_GiveInventory("SpookyScaryReady_P")
goto Ready3
Ready4D:
SKUB A 0 A_JumpIfInventory("PowerSkullCounter",1,2)
SKUB AA 2 A_WeaponReady
SKUB A 0 A_GiveInventory("SpookyScaryReady_P")
goto Ready4

Ready1:
SKUB A 0 A_JumpIfInventory("AlasPoorYorickAmmo",2,"Ready2")
SKUB A 0 A_JumpIfInventory("SpookyScaryAmmo",112,"Ready3")
SKUB A 0 A_JumpIfInventory("PowerSkullCounter",1,2)
SKUB AA 2 A_WeaponReady(12)
SKUB A 0 A_GiveInventory("SpookyScaryReady_P")
SKUB A 0 A_GiveInventory("AlasPoorYorickAmmo",3)
loop
Ready2:
SKUB A 0 A_JumpIfInventory("SpookyScaryAmmo",112,"Ready4")
SKUB A 0 A_JumpIfInventory("PowerSkullCounter",1,2)
SKUB AA 2 A_WeaponReady(8)
SKUB A 0 A_GiveInventory("SpookyScaryReady_P")
SKUB A 0 A_GiveInventory("AlasPoorYorickAmmo",3)
loop
Ready3:
SKUB A 0 A_JumpIfInventory("AlasPoorYorickAmmo",2,"Ready4")
SKUB A 0 A_JumpIfInventory("PowerSkullCounter",1,2)
SKUB AA 2 A_WeaponReady(4)
SKUB A 0 A_GiveInventory("SpookyScaryReady_P")
SKUB A 0 A_GiveInventory("AlasPoorYorickAmmo",3)
loop
Ready4:
SKUB A 0 A_JumpIfInventory("PowerSkullCounter",1,2)
SKUB AA 2 A_WeaponReady
SKUB A 0 A_GiveInventory("SpookyScaryReady_P")
SKUB A 0 A_GiveInventory("AlasPoorYorickAmmo",3)
loop

Fire:
SKUB A 0 A_JumpIfNoAmmo("NoAmmo")
SKUB A 0 A_JumpIfInventory("PowerSkullCounter",1,"FireRage")
SKUB A 0 A_PlaySoundEx("weapon/skullbust","Weapon")
SKUB A 0 A_FireCustomMissile("SkullShot",0,1,8,0)
SKUB BCA 4 A_GiveInventory("SpookyScaryFire_P")
SKUB A 0 A_Refire
SKUB A 0 A_GiveInventory("SpookyScaryFire_P")
Goto Ready1D
FireRage:
SKUB A 0 A_PlaySoundEx("weapon/skullbust","Weapon")
SKUB A 0 A_FireCustomMissile("SkullShotRage",0,1,8,0)
SKUB B 2
SKUB C 2 A_GiveInventory("SpookyScaryFire_P")
SKUB A 2
SKUB A 0 A_Refire
Goto Ready1D

NoAmmo:
SKUB A 0
Goto Ready1D

AltFire:
SKUB A 0 A_JumpIfInventory("ShieldCheck",1,"Ready1")
SKUB A 0 A_JumpIfInventory("SpookyScaryAmmo",112,"Activate")
Goto Ready1
Activate:
SKUB A 0 A_GiveInventory("VivifyDelay4",1)
SKUB A 0 A_Refire(1)
SKUB A 0 A_GiveInventory("RareSkullHud_P",1)
SKUB A 0 A_GiveInventory("ShieldCheck",1)
SKUB A 0 A_GiveInventory("SkullBarrierCounter",1)
SKUB A 0 A_TakeInventory("SpookyScaryAmmo",12)
SKUB A 0 A_SpawnItemEx("SkullmanShieldWarper",0,0,28,0,0,0,0,1)
SKUB A 8 A_GunFlash("Flash",1)
SKUB A 0 A_GiveInventory("AlasPoorYorickAmmo",9)
Goto Ready1

Flash:
TNT1 A 0 A_JumpIfInventory("PowerRareSkullHud",1,"Flash.Skull")
SKUB DEFGGG 1 A_SpawnItemEx("SkullM_CounterChecker",0,0,0,momx,momy,momz,0,8,0)
SKUB GG 1
SKUB G 0 ACS_NamedExecuteWithResult("core_hitshield",1)//old core skullbarrier script
SKUB G 1 //urgh hopefully this tic wont come back to bite me [Muz]
SKUB G 0 A_JumpIfInventory("SkullRageFlag",1,"RageBarrier")//This is being done so that there can be different sprites for a rage barrier and a missed rage [Muz]
SKUB G 0 ACS_NamedExecuteWithResult("core_invulnerableplayer",0,0)
SKUB GFFF 1
SKUB F 1 A_JumpIfInventory("ShieldHits",1,1)
Goto MissedHit
SKUB FEEE 1
SKUB E 0 A_TakeInventory("SpookyScaryAmmo",4)
SKUB E 1 A_JumpIfInventory("ShieldHits",1,1)
Goto MissedHit
SKUB EDDD 1
SKUB D 1 A_JumpIfInventory("ShieldHits",1,"MissWait")
Goto MissedHit

Flash.Skull:
SKUB HIJKKK 1 A_SpawnItemEx("SkullM_CounterChecker",0,0,0,momx,momy,momz,0,8,0)
SKUB K 1
SKUB K 0 ACS_NamedExecuteWithResult("core_hitshield",1)
SKUB K 1
SKUB K 0 A_JumpIfInventory("SkullRageFlag",1,"RageBarrier.Skull")
SKUB K 0 ACS_NamedExecuteWithResult("core_invulnerableplayer",0,0)
SKUB KJJJ 1
SKUB J 1 A_JumpIfInventory("ShieldHits",1,1)
Goto MissedHit
SKUB JIII 1
SKUB I 0 A_TakeInventory("SpookyScaryAmmo",2)
SKUB I 1 A_JumpIfInventory("ShieldHits",1,1)
Goto MissedHit
SKUB IHHH 1
SKUB H 1 A_JumpIfInventory("ShieldHits",1,"MissWait")
Goto MissedHit

MissWait:
TNT1 AAAA 1
TNT1 A 0 A_TakeInventory("SpookyScaryAmmo",2)
TNT1 A 1 A_JumpIfInventory("ShieldHits",1,1)
Goto MissedHit
TNT1 AAAA 1
TNT1 A 0 A_TakeInventory("SpookyScaryAmmo",2,1)
TNT1 A 1 A_JumpIfInventory("ShieldHits",1,1)
Goto MissedHit
TNT1 A 0 A_JumpIfInventory("SpookyScaryAmmo",1,"MissWait")
goto MissedEnd
MissedHit:
TNT1 A 1
TNT1 A 0 A_PlaySoundEx("S3_K/MetalSpark","Weapon")
TNT1 A 0 A_GiveInventory("SkullBarrierProtection",1)
Goto MissedEnd
MissedEnd:
TNT1 A 1
TNT1 A 0 A_GiveInventory("SkullM_BarrierEnd_P2")
TNT1 A 1 A_TakeInventory("SpookyScaryAmmo",112,1)
//TNT1 A 0 A_JumpIfINventory("ShieldCheck",1,"missedEnd")//A_TakeInventory("ShieldCheck",99)//Just to double make sure
stop//Goto FlashAmmo


RageBarrier.Skull:
SKUB K 0 A_TakeInventory("SpookyScaryAmmo",26,1)
SKUB KJJJJIII 1
SKUB I 0 A_TakeInventory("SpookyScaryAmmo",26,1)
SKUB IHHHH 1
goto FlashWait+5
RageBarrier://SKUB FED 4
SKUB G 0 A_TakeInventory("SpookyScaryAmmo",26,1)
SKUB GFFFFEEE 1
SKUB E 0 A_TakeInventory("SpookyScaryAmmo",26,1)
SKUB EDDDD 1
goto FlashWait+5

FlashWait:
TNT1 AAAAAAAA 1
TNT1 A 0 A_TakeInventory("SpookyScaryAmmo",26)
TNT1 A 1 A_JumpIfInventory("ShieldCheck",1,2)
TNT1 A 0 A_GiveInventory("SkullM_BarrierEnd_P",1)
stop//goto FlashAmmo
TNT1 A 0 A_JumpIfInventory("SpookyScaryAmmo",1,"FlashWait")
TNT1 A 0 A_GiveInventory("SkullM_BarrierEnd_P",1)
stop//goto FlashAmmo
FlashAmmo:
TNT1 A 0 A_JumpIfInventory("SpookyScaryAmmo",112,"NoFlash")
TNT1 AAAA 1
TNT1 A 0 A_GiveInventory("SpookyScaryAmmo",3)
TNT1 AAAA 1
TNT1 A 0 A_GiveInventory("SpookyScaryAmmo",3)
goto FlashAmmo
}
}

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

actor SpookyScaryAmmo : Ammo
{
inventory.amount 1
inventory.maxamount 112
+INVENTORY.IGNORESKILL
}

actor SkullRageFlag : Inventory
{
inventory.amount 1
inventory.maxamount 56
}

actor PowerSkullCounter : Powerup
{
powerup.Duration 56
}

actor PowerSkullCounterSpeed : PowerSpeed
{
Speed 1.6
powerup.Duration 35
}

actor PowerSkullBarrierBlast : Powerup
{
powerup.Duration 8
}
actor PowerRareSkullHud : Powerup
{
powerup.Duration 8
}

actor SkullmanWepDroppedX : BasicHelper
{
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_Jump(256,1,2)
TNT1 A 1 A_SpawnItemEx("SkullBarrierWep",0,0,0,momx,momy,momz,0,8)
stop
TNT1 A 1 A_SpawnItemEx("SkullSniperWep",0,0,0,momx,momy,momz,0,8)
stop
}
}

actor SpookyScaryReady_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_JumpIfInventory("ShieldCheck",1,3)
TNT1 A 0 A_JumpIfInventory("PowerSkullCounter",1,3)
TNT1 A 0 A_GiveInventory("SpookyScaryAmmo",4)//3
TNT1 A 0
stop
TNT1 A 0 A_GiveInventory("SpookyScaryAmmo",4)//5
stop
}
}
actor SpookyScaryFire_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_JumpIfInventory("ShieldCheck",1,2)
TNT1 A 0 A_GiveInventory("SpookyScaryAmmo",2)
TNT1 A 0
stop
}
}

actor RareSkullHud_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_Jump(8,"Pickup.Skull")
stop
Pickup.Skull:
TNT1 A 0 A_GiveInventory("PowerRareSkullHud",1)
stop
}
}

actor SkullM_CounterTime_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_Blast(0,255,192,40.0,"SkullRepulsionFX")
TNT1 A 0 A_JumpIfInventory("PowerSkullBarrierBlast",1,"Pickup1")
TNT1 A 0 A_GiveInventory("PowerSkullBarrierBlast",1)
TNT1 A 0 A_FireCustomMissile("SkullM_BarrierBlast",0,0,0,0)
goto Pickup1
Pickup1:
TNT1 A 0 A_JumpIfInventory("SkullRageFlag",1,2)
TNT1 A 0 A_SpawnItemEx("SkullRageFlag_H")
TNT1 A 0 A_SetBlend(white,0.95,5)
TNT1 A 0 A_PlaySoundEx("classes/skullabs","Body")
TNT1 A 0 A_GiveInventory("PowerSkullCounter",1)
TNT1 A 0 A_GiveInventory("PowerSkullCounterSpeed",1)
TNT1 A 0 A_GiveInventory("AlasPoorYorickAmmo",28)
TNT1 A 0 A_GiveInventory("SkullRageFlag",56)//32
stop
}
}
actor SkullM_CounterRefresh_P : SkullM_CounterTime_P
{
States
{
Pickup:
TNT1 A 0
goto Pickup1
}
}

actor SkullBarrierCounter : CustomInventory
{
States
{
Pickup:
//TNT1 A 0 A_ChangeFlag("SHOOTABLE",0)
TNT1 A 0 ACS_NamedExecuteWithResult("core_invulnerableplayer",0,1)
TNT1 A 0 A_SpawnItemEx("SkullM_BarrierSnd_H")
stop
}
}

actor SkullM_BarrierEnd_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_JumpIfInventory("Skullman_W",1,"InGame")
stop
InGame:
TNT1 A 0 ACS_NamedExecuteWithResult("core_invulnerableplayer",0,0)
TNT1 A 0 A_TakeInventory("ShieldCheck")
TNT1 A 0 A_TakeInventory("ShieldHits")
stop
}
}
actor SkullM_BarrierEnd_P2 : SkullM_BarrierEnd_P
{
States
{
Pickup:
goto InGame+1
}
}

actor SkullM_BarrierSnd_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_PlaySound("classes/SkullShieldBuzz",7,1.0)//SoundSlot7
stop
}
}

actor SkullRageFlag_H : BasicHelper
{
States
{
Spawn:
TNT1 A 0
TNT1 A 1 A_TakeFromTarget("SkullRageFlag",1)
TNT1 A 0 A_JumpIfInTargetInventory("IsDead",1,2)
TNT1 A 0 A_JumpIfInTargetInventory("SkullRageFlag",1,"Spawn")
TNT1 A 0
stop
}
}

actor SkullM_BarrierSnd_H : BasicHelper
{
States
{
Spawn:
TNT1 A 0
TNT1 A 12 A_GiveToTarget("SkullM_BarrierSnd_P",1)
TNT1 A 0 A_JumpIfInTargetInventory("IsDead",1,2)
TNT1 A 0 A_JumpIfInTargetInventory("ShieldCheck",1,"Spawn")
TNT1 A 0
stop
}
}

actor SkullRepulsionFX : BasicGraphicEffect
{
States
{
Spawn:
TNT1 A 0
TNT1 A 1
stop
}
}

actor SkullShot : ProjSpawnFuncActorFast
{
var int user_POWER;
PROJECTILE
damagetype "SkullM_Shot"
Obituary "$OB_SKULLBUSTER"
+FORCEXYBILLBOARD
+BRIGHT
Damage (100-user_POWER)
radius 10
height 6
Speed 150
scale 2.5
States
{
Spawn:
Q_0D BBBBB 1 nodelay A_SpawnItemex("SkullShotFX",0,Random(8,-8),Random(8,-8),0,0,0,0,1)
Q_0D BBBBBBB 2 A_SetUserVar("user_POWER",user_POWER+10)
Q_0D B 3
wait
Death:
TNT1 A 1
stop
}
}

actor SkullShotFX : BasicGraphicEffect
{
+FORCEXYBILLBOARD
+BRIGHT
Renderstyle Translucent
Alpha 0.6
States
{
SpawnFrame:
SKUB UV 1 A_Fadeout
loop
}
}

actor SkullShotRage : SkullShot
{
damagetype "SkullM_ShotX"
Damage (120)
States
{
Spawn:
Q_0D B 0
Q_0D BBB 0 A_SpawnItemex("SkullShotRageFX",0,Random(24,-24),Random(24,-24),0,0,0,0,1)
Q_0D B 1
loop
}
}

actor SkullShotRageFX : SkullShotFX
{
Alpha 0.9
}

actor SkullmanShieldWarper : ShieldWarper_CBM
{
+BRIGHT
+NOTIMEFREEZE
States
{
Shield:
//SKUB M 0 A_JumpIfInTargetInventory("",1,"Shield2")
SKUB MNOPQRST 1 A_Warp(2,0,0,28,0,24)
loop
}
}

actor PainSkullM_BarrierHit : Basic_PainFling_H{Args 32,0,2}
actor DeathSkullM_BarrierHit : Basic_DeathFling_H{Args 36,40,0}

actor SkullM_BarrierBlast : BasicExplosion
{
damagetype "SkullM_Barrier"
Obituary "$OB_SKULLBARRIER"
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_SpawnItemEx("SkullM_BarrierBlastRingFX",0,0,0,0,0,0,random(0,35),1)
TNT1 AAAAAAAAAAAAAAAAAAAA 0 A_SpawnItemEx("SkullM_BarrierBlastFX",0,0,28,22,0,random2(256/12),random(0,359),1)
TNT1 A 3 A_Explode(100,192,0,0,56)
stop
}
}

actor SkullM_BarrierBlastFX : BasicGraphicEffect
{
+FORCEXYBILLBOARD
+BRIGHT
Renderstyle Translucent
Alpha 0.95
States
{
SpawnFrame:
SKUB W random(1,3)
SKUB VUV 3
stop
}
}

actor SkullM_BarrierBlastRingFX : BasicGraphicEffect
{
Reactiontime 10
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_SpawnItemEx("SkullM_BarrierBlastFX",32,0,0,10,0,frandom(-1,1),Reactiontime*36,1)
TNT1 A 0 A_Countdown
loop
}
}



actor SkullM_CounterChecker
{
var int user_USER;
-SOLID
+NOGRAVITY
+DONTDRAIN
+SERVERSIDEONLY
damagefactor "SkullM_Barrier", 0.0
renderstyle "none"
health 1
radius 40
height 56
scale 2.5
States
{
Spawn:
PLAY A 0
PLAY A 0 A_RearrangePointers(0,0,2)
PLAY A 0 A_ChangeFlag("SHOOTABLE",1)
PLAY A 0 A_ChangeFlag("DONTRIP",1)
PLAY A 1
PLAY A 1
stop
Death:
PLAY A 0 ACS_NamedExecuteWithResult("cbm_GiveIfPlayerHitMe",47)
PLAY A 1
stop
}
}


actor Skullman_W_NormalBar : NormalBar {Args 4,94}
actor Skullman_W_SecondBar : SecondBar {Args 192,197}
actor Skullman_W_ScriptBar : ScriptBar {}