actor Starman_W : BaseMM8BDMWep_CBM
{
tag "$TAGC_5E"
dropitem "StarCrashWep"
weapon.ammouse 1
Weapon.AmmoGive 0
Obituary "$OB_STARCRASH"
weapon.ammotype "SuperStarPowerAmmo"
+WEAPON.ALT_AMMO_OPTIONAL
States
{
Spawn:
C_05 E 1
loop

Deselect:
STAC A 0 A_TakeInventory("ShieldCheck")
STAC A 0 A_TakeInventory("GuardUpFlag")
STAC A 0 A_TakeInventory("StarArmorPower")
STAC A 0 //A_FireCustomMissile("StarCrash",0,0,0,0)
goto DeselectSwap
Select:
STAC A 0
goto SelectSwap

Ready:
STAC A 0 ACS_NamedExecuteWithResult("core_weaponcolor",DYE_STARMAN)
Ready1:
STAC A 0 A_JumpIfInventory("SuperStarPowerAmmo",9,"Ready2")
STAC A 7 A_WeaponReady(WRF_NOFIRE)
STAC A 0 A_GiveInventory("SuperStarPowerAmmo",2)
loop
Ready2:
STAC A 0 A_JumpIfInventory("SuperStarPowerAmmo",14,"Ready3")
STAC A 7 A_WeaponReady(WRF_NOPRIMARY)
STAC A 0 A_GiveInventory("SuperStarPowerAmmo",2)
loop
Ready3:
STAC A 7 A_WeaponReady
STAC A 0 A_GiveInventory("SuperStarPowerAmmo",2)
loop

Fire:
STAC A 1 A_JumpIfInventory("ShieldCheck",1,"ShieldThrow")
//STAC A 0 A_JumpIfInventory("SuperStarPowerAmmo",14,"ShieldActive")

STAC A 0 A_JumpIfNoAmmo("NoAmmo")
//STAC A 0 A_TakeInventory("SuperStarPowerAmmo",1)
STAC A 0 A_PlaySoundEx("weapon/StarMain","Weapon")
STAC A 0 ACS_NamedExecuteWithResult("cbm_HalfHitStunplayer",0,true)
STAC A 0 A_GiveInventory("GuardUpFlag",1)
STAC A 0 A_GiveInventory("StarArmorPower",1)
STAC A 0 A_GiveInventory("ShieldCheck",1)
goto ShieldActive

ShieldActive:
STAC A 0 A_SpawnItemEx("StarmanShieldWarper",0,0,28,0,0,0,0,1)
STAC AB 2
STAC B 0 A_SpawnItemEx("StarM_HugExplosion",0,0,32)
STAC BB 2
STAC B 0 A_SpawnItemEx("StarM_HugExplosion",0,0,32)
goto Shield
Shield:
STAC BB 2 A_WeaponReady
STAC B 0 A_SpawnItemEx("StarM_HugExplosion",0,0,32)
STAC BB 2 A_WeaponReady
STAC B 0 A_SpawnItemEx("StarM_HugExplosion",0,0,32)
STAC B 0 A_TakeInventory("SuperStarPowerAmmo",1)
STAC B 0 A_JumpIfNoAmmo("ShieldThrow")
STAC BB 2 A_WeaponReady
STAC B 0 A_SpawnItemEx("StarM_HugExplosion",0,0,32)
STAC BB 2 A_WeaponReady
STAC B 0 A_SpawnItemEx("StarM_HugExplosion",0,0,32)
STAC B 0 A_TakeInventory("SuperStarPowerAmmo",1,1)
STAC B 0 A_JumpIfNoAmmo("ShieldThrow")
loop

ShieldThrow:
STAC B 0 A_TakeInventory("ShieldCheck",999)
STAC B 0 A_TakeInventory("SuperStarPowerAmmo",7,1)
STAC B 5 A_FireCustomMissile("StarmanShield",0,0,0,0)
STAC A 0 ACS_NamedExecuteWithResult("cbm_HalfHitStunplayer",0,false)
STAC A 0 A_TakeInventory("GuardUpFlag",99)
STAC A 0 A_TakeInventory("StarArmorPower",99)
STAC C 5
STAC A 20
goto Ready1

AltFire:
STAC A 0 A_JumpIfInventory("ShieldCheck",1,"ShieldThrow")
STAC A 0 A_GiveInventory("Starman_Alt_P")
STAC BC 3
STAC A 13
STAC A 0
goto Ready1

NoAmmo:
STAC A 0 A_TakeInventory("ShieldCheck",999)
STAC A 0 A_TakeInventory("GuardUpFlag",99)
STAC A 0 A_TakeInventory("StarArmorPower",99)
goto Ready1

}
}

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

actor StarArmorPower : BasePowerPro
{
damagefactor "Normal", 0.75
}

actor Starman_Alt_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_PlaySoundEx("weapon/StarMain","Weapon")
TNT1 A 0 A_TakeInventory("SuperStarPowerAmmo",3)
TNT1 A 0 A_TakeInventory("SuperStarPowerAmmo",6,1)
TNT1 A 0 A_SpawnItemEx("StarFlurryLauncher_H",0,0,32)
stop
}
}

actor StarmanShieldWarper : ShieldWarper_CBM
{
+NOTIMEFREEZE
+FORCEXYBILLBOARD
+BRIGHT
States
{
Shield:
STAC D 0 A_JumpIfInTargetInventory("PlayerPropertyRage",1,"ShieldR")
STAC DDEEFFGG 1 A_Warp(AAPTR_TARGET,0,0,28,0,24)
loop
ShieldR:
STAC DEFG 1 A_Warp(AAPTR_TARGET,0,0,28,0,24)
goto Shield
}
}

actor StarM_HugExplosion : BasicImplosion
{
Damagetype "StarM_Crash"
Obituary "$OB_STARCRASH"
States
{
Spawn:
TNT1 A 0
TNT1 A 1 A_Explode(80+CallACS("core_checkrune",RUNE_SPREAD,2)*160,160,0)
stop
}
}


actor StarFlurryLauncher_H : BasicExplosion
{
states
{
Spawn:
TNT1 A 0
TNT1 A 0
TNT1 A 0 ACS_NamedExecuteWithResult("cbm_CopyPointerAnglePitch",2,1)
TNT1 A 0 A_SpawnItemEx("StarFlurryLauncher",0,0,0,0,0,0,0,SXF_TRANSFERPITCH)//512
TNT1 A 0 A_JumpIfInTargetInventory("PlayerPropertySpread",1,1)
stop
TNT1 A 0 A_SpawnItemEx("StarFlurryLauncher",0,0,0,0,0,0,15,512)
TNT1 A 0 A_SpawnItemEx("StarFlurryLauncher",0,0,0,0,0,0,-15,512)
stop
}
}

actor StarFlurryLauncher : ProjSpawnFuncActor
{
var int user_C;
PROJECTILE
+THRUACTORS
-NOGRAVITY
+NOINTERACTION
//+DONTBLAST
+FORCEXYBILLBOARD
+BRIGHT
ReactionTime 8
damage (0)
radius 2
height 2
speed 0
scale 2.5
states
{
Spawn:
TNT1 A 0
STAC D 0 //ACS_NamedExecuteWithResult("cbm_CopyPointerAnglePitch",2,1)
STAC D 14
STAC DDDDEEEEFFFFGGGDDDEEEFFGGDDEFGDEFG 1 A_JumpIf(!CallACS("cbm_PointerExists",AAPTR_TARGET),"StopFlurry")
STAC D 0 A_PlaySoundEx("weapon/StarDakka","Weapon")
STAC D 0 A_SetUserVar("user_C",cos(-pitch)*4)
Shoot:
STAC H 1 A_SpawnItemEx("StarFlurryShot",user_C+sin(-pitch)*(0),36,8+cos(-pitch)*(4+0),cos(-pitch)*30,0,sin(-pitch)*30,0,1)
STAC I 1 A_SpawnItemEx("StarFlurryShot",user_C+sin(-pitch)*(-25),25,8+cos(-pitch)*(4+25),cos(-pitch)*30,0,sin(-pitch)*30,0,1)
STAC H 1 A_SpawnItemEx("StarFlurryShot",user_C+sin(-pitch)*(-36),0,8+cos(-pitch)*(4+36),cos(-pitch)*30,0,sin(-pitch)*30,0,1)
STAC I 1 A_SpawnItemEx("StarFlurryShot",user_C+sin(-pitch)*(-25),-25,8+cos(-pitch)*(4+25),cos(-pitch)*30,0,sin(-pitch)*30,0,1)
STAC H 1 A_SpawnItemEx("StarFlurryShot",user_C+sin(-pitch)*(0),-36,8+cos(-pitch)*(4+0),cos(-pitch)*30,0,sin(-pitch)*30,0,1)
STAC I 1 A_SpawnItemEx("StarFlurryShot",user_C+sin(-pitch)*(25),-25,8+cos(-pitch)*(4-25),cos(-pitch)*30,0,sin(-pitch)*30,0,1)
STAC H 1 A_SpawnItemEx("StarFlurryShot",user_C+sin(-pitch)*(36),0,8+cos(-pitch)*(4-36),cos(-pitch)*30,0,sin(-pitch)*30,0,1)
STAC I 1 A_SpawnItemEx("StarFlurryShot",user_C+sin(-pitch)*(25),25,8+cos(-pitch)*(4-25),cos(-pitch)*30,0,sin(-pitch)*30,0,1)
STAC D 0 A_JumpIf(!CallACS("cbm_PointerExists",AAPTR_TARGET),"StopFlurry")
STAC D 0 A_CountDown
loop
StopFlurry:
Death:
STAC D 0
stop
}
}

actor StarFlurryShot : ProjSpawnFuncActor
{
PROJECTILE
Damagetype "StarM_Flurry"
Obituary "$OB_STARFLURRY"
+DONTSPLASH
+FORCEXYBILLBOARD
+BRIGHT
Damage (50)
Radius 10
Height 10
Speed 20
scale 2.5
States
{
Spawn:
TNT1 A 0
SpawnL:
STAP ABCD 2 
loop
}
}

actor StarmanShieldBoom : BasicImplosion
{
Damagetype "StarM_Throw2"
Obituary "$OB_STARCRASH"
States
{
Spawn:
TNT1 A 0
TNT1 A 1 A_Explode(120,90,0)
stop
}
}

actor StarmanShield : ProjSpawnFuncActor
{
PROJECTILE
damagetype "StarM_Throw"
Obituary "$OB_STARCRASH"
+DONTSPLASH
+RIPPER
+FORCEXYBILLBOARD
+BRIGHT
Damage (20)
Radius 12
Height 12
Speed 20
scale 2.5
States
{
Spawn:
STAC D 2
STAC E 2 A_SpawnItemEx("StarmanShieldBoom",0,0,0)
STAC F 2
STAC G 2 A_SpawnItemEx("StarmanShieldBoom",0,0,0)
loop
}
}

actor Starman_W_NormalBar : NormalBar {Args 229,220}
actor Starman_W_ScriptBar : ScriptBar {}