actor PowerOrbWep_NormalBar : NormalBar{args 4, 198}
actor PowerOrbWep_ScriptBar : ScriptBar{}
actor PowerOrbWep : BaseMM8BDMWep
{
Weapon.AmmoUse 7
Weapon.AmmoGive 28
Weapon.SlotNumber 7
Inventory.Pickupmessage "$PU_POWERORB"
Obituary "$OB_POWERORB"
Tag "$TAG_POWERORB"
weapon.ammotype "PowerOrbAmmo"
inventory.icon "PORBICON"
States
{
SpawnLoop:
PORB Z 1
loop
Ready:
PORB A 0 ACS_NamedExecuteWithResult("core_weaponcolor",COLOR_POWERORB)
PORB A 0 A_WeaponReady
PORB A 1 A_JumpIfInventory("PowerOrbFlag",1,"Ready2")
Goto Ready+1
ReadyC: Goto Ready+1
Ready2:
PORB A 0 A_JumpIfInventory("IsBot",1,"ReadyBot")
PORB A 0 A_SpawnItemEx("PowerOrbFloorCheck",0,0,8,0,0,0,SXF_NOCHECKPOSITION)
PORB A 0 A_SpawnItemEx("PowerOrbHitbox",0,0,0,0,0,0,SXF_NOCHECKPOSITION)
PORB AAAA 1 A_WeaponReady(WRF_DISABLESWITCH|WRF_NOSECONDARY)
PORB A 0 A_JumpIfInventory("PowerOrbFlag",9,"DestroyOrb")
Goto Ready+1
ReadyBot:
PORB A 0 A_SpawnItemEx("PowerOrbFloorCheck",0,0,8,0,0,0,SXF_NOCHECKPOSITION)
PORB A 0 A_SpawnItemEx("PowerOrbHitbox",0,0,0,0,0,0,SXF_NOCHECKPOSITION)
PORB AAAA 1
PORB A 0 A_JumpIfInventory("PowerOrbFlag",9,"DestroyOrb")
Goto Ready+1
FloorBounce:
PORB A 1 A_GiveInventory("PowerOrbFloor",1)//ACS_NamedExecute("PowerOrbBounceHandle",0)
goto Ready2
CeilingBounce:
PORB A 1 A_GiveInventory("PowerOrbCeilingBounce",1)//ACS_NamedExecute("PowerOrbBounceHandle",0)
goto Ready2
Deselect:
PORB A 0 
goto DeselectSwap
Select:
PORB A 0 
goto SelectSwap
Fire:
PORB A 0 A_JumpifInventory("PowerOrbAmmo",7,1)
goto NoAmmo
PORB A 0 A_JumpIfInventory("PowerOrbFlag",1,"DestroyOrb")
PORB A 0 A_Stop
PORB BBBCCC 1 A_Stop
PORB A 0 A_PlaySoundEx("weapon/timestopper", "Weapon")
PORB A 0 A_SpawnItemEx("PowerOrbWatcher")
PORB A 0 A_GiveInventory("PowerOrbFlag",1)
PORB A 0 A_GiveInventory("PowerOrbSpeed",1)
PORB A 0 A_GiveInventory("PowerOrbArmor",1)
PORB A 0 A_GiveInventory("NoJumpCancel",1)
PORB A 0 A_TakeInventory("PowerOrbAmmo",7)
PORB DDDDDDDDDDDDDD 1 A_Stop
PORB CCCBBB 1 A_Stop
PORB AAA 1 A_Stop
Goto Ready+1
Altfire:
PORB A 0 A_JumpIfInventory("PowerOrbFlag",1,"DestroyOrb")
goto Super::Altfire

DestroyOrb:
PORB A 2
PORB BBBCCC 1 
PORB A 0 A_PlaySoundEx("weapon/centaurflash", "Weapon")
PORB AAAAAAAAAAAA 0 A_SpawnItemEx("PowerOrbShatter",0,0,8,random(-8,8),random(-8,8),0,random(0,360))
PORB A 0 A_TakeInventory("WeaponCharge",90)
PORB D 1
PORB A 0 A_TakeInventory("PowerOrbFlag",999)
PORB A 0 A_TakeInventory("PowerOrbBounce",999)
PORB A 0 A_TakeInventory("NoJumpCancel",1)
PORB A 0 A_TakeInventory("PowerOrbSpeed",1)
PORB A 0 A_TakeInventory("PowerOrbArmor",1)
PORB DDDCCCBBBAAAAAA 5
PORB A 0 A_WeaponReady
Goto Ready+1
NoAmmo:
PORB A 1 ACS_NamedExecuteAlways("core_noammo",0)
Goto Ready+1
}
}

actor PowerOrbArmor : PowerProtection
{
damagefactor "Normal", 0.44
damagefactor "Crush", 1.0
damagefactor "Telefrag",1.0
damagefactor "Falling", 1.0
damagefactor "Fire", 0.0
damagefactor "Drowning", 0.0
damagefactor "Slime", 0.0
damagefactor "Ice", 0.0
damagefactor "Spiney", 0.0
powerup.duration 0x7FFFFFFD
}


actor PowerOrbShatter : BasicProjectile
{
PROJECTILE
damagetype "PowerOrb"
Obituary "$OB_POWERORB"
Speed 0
+HEXENBOUNCE
+BOUNCEONCEILINGS
+BOUNCEONWALLS
bouncefactor 1.0
wallbouncefactor 1.0
-BOUNCEONFLOORS
-NOGRAVITY
Damage (CallACS("vile_cbm_damage",8))
radius 10
height 10
scale 2.5
States
{
Spawn:
TNT1 A 0
TNT1 A 0 ThrustThingZ(0,50,0,1)
TNT1 A 0 A_Jump(256,"1","2","3")
1:
PWRB E 6 ThrustThingZ(0,1,1,1)
loop
2:
PWRB F 6 ThrustThingZ(0,1,1,1)
loop
3:
PWRB G 6 ThrustThingZ(0,1,1,1)
loop
}
}

actor PowerOrbFloorCheck
{
PROJECTILE
+THRUACTORS
+DONTBLAST
+DONTREFLECT
+RIPPER
-NOGRAVITY
+FORCEPAIN
+NOTARGETSWITCH
obituary "$OB_POWERORB"
damagetype "PowerOrb"
//renderstyle none
Damage (0)
Radius 4
Height 4
States
{
Spawn:
tnt1 A 1
tnt1 AAA 1 A_Warp(AAPTR_TARGET, 0, 0, 0, 0, WARPF_INTERPOLATE|WARPF_NOCHECKPOSITION)
stop
Death:
WallCheck:
TNT1 A 0 A_JumpIf(z-floorz > 8, "Ceiling")
TNT1 A 1 A_JumpIf(CallACS("core_CheckFooting"),"Floor")
stop
XDeath:
TNT1 A 1 A_GiveToTarget("PowerOrbWallBounce",1)
stop
Wall:
TNT1 A 1 //A_GiveToTarget("PowerOrbfWallBounce",1)
stop
Floor:
TNT1 A 1 A_GiveToTarget("PowerOrbFloor",1)//ACS_NamedExecute("PowerOrbBounceHandle",0)
stop
Ceiling:
TNT1 A 1 A_GiveToTarget("PowerOrbCeilingBounce",1)
stop
Nope:
TNT1 A 0
stop
}
}

actor PowerOrbFX1 : BasicGraphicEffect
{
+NOINTERACTION
+NOGRAVITY
+CLIENTSIDEONLY
+FORCEXYBILLBOARD
-SOLID
+BRIGHT
scale 2.5
height 0
radius 0
States
{
SpawnFrame:
PWRB A 1
stop
}
}

actor PowerOrbFX2 : PowerOrbFX1
{
States
{
SpawnFrame:
PWRB B 1
stop 
}
}

actor PowerOrbFX3 : PowerOrbFX1
{
States
{
SpawnFrame:
PWRB C 1
stop 
}
}

actor PowerOrbFX4 : PowerOrbFX1
{
States
{
SpawnFrame:
PWRB D 1
stop 
}
}

actor PowerOrbVisualFX : CustomInventory
{
States
{
Pickup:
TNT1 A 0
TNT1 A 0 A_JumpIfInventory("PowerOrbFlag",7,"Display4")
TNT1 A 0 A_JumpIfInventory("PowerOrbFlag",5,"Display3")
TNT1 A 0 A_JumpIfInventory("PowerOrbFlag",3,"Display2")
Display1:
TNT1 A 0 A_SpawnItemEx("PowerOrbFX1",0, 0, 32, momx*0.5, momy*0.5, momz*0.5, 0, SXF_ABSOLUTEMOMENTUM,0)
stop
Display2:
TNT1 A 0 A_SpawnItemEx("PowerOrbFX2",0, 0, 32, momx*0.5, momy*0.5, momz*0.5, 0, SXF_ABSOLUTEMOMENTUM,0)
stop
Display3:
TNT1 A 0 A_SpawnItemEx("PowerOrbFX3",0, 0, 32, momx*0.5, momy*0.5, momz*0.5, 0, SXF_ABSOLUTEMOMENTUM,0)
stop
Display4:
TNT1 A 0 A_SpawnItemEx("PowerOrbFX4",0, 0, 32, momx*0.5, momy*0.5, momz*0.5, 0, SXF_ABSOLUTEMOMENTUM,0)
stop
}
}

actor PowerOrbWatcher : BasicWatcher
{
PROJECTILE
+NOINTERACTION
+DONTBLAST
states
{
Spawn:
TNT1 A 0
TNT1 A 1 A_GiveToTarget("PowerOrbVisualFX",1)
TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("core_targetexists")==0,"Death")
TNT1 A 1 A_JumpIfInTargetInventory("PowerOrbFlag",1,"Spawn")
Death:
TNT1 A 0
stop
}}


actor PowerOrbHitbox
{
Obituary "$OB_POWERORB"
PROJECTILE
+DONTSPLASH
radius 68
height 68//28
PainSound "item/protoreflect"
Damagetype "PowerOrb"
Damage (CallACS("vile_cbm_damage",13))//(15)
States
{
Spawn:
TNT1 A 1 //A_Explode(6,78,0,0,78)
stop
Pain:
TNT1 A 0
stop
}
}


actor PowerOrbWallBounce : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_JumpIfInventory("DontBounceAgain",1,"Nope")
TNT1 A 0 A_PlaySoundEx("misc/fatland","Weapon")
TNT1 A 0 A_ChangeVelocity(-25,0,6,CVF_RELATIVE)
TNT1 AAA 0 A_SpawnItemEx("PowerOrbShatter",0,0,8,random(-8,8),random(-8,8),0,random(0,360))
goto Degrade
Nope:
TNT1 A 0
stop
Degrade:
TNT1 A 0 A_JumpIfInventory("PowerOrbFlag",9,"Nope")
TNT1 A 0 A_TakeInventory("PowerOrbBounce",8)
TNT1 A 0 A_GiveInventory("PowerOrbFlag",1)
TNT1 A 0 A_GiveInventory("WeaponCharge",1)
stop
}
}

actor PowerOrbFloorBounce : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_JumpIfInventory("DontBounceAgain",1,"Nope")
TNT1 A 0 A_PlaySoundEx("misc/fatland","Weapon")
TNT1 A 0 A_ChangeVelocity(0,0,10,CVF_RELATIVE)
TNT1 AAA 0 A_SpawnItemEx("PowerOrbShatter",0,0,8,random(-8,8),random(-8,8),0,random(0,360))
goto Degrade
Nope:
TNT1 A 0
stop
Degrade:
TNT1 A 0 A_JumpIfInventory("PowerOrbFlag",9,"Nope")
TNT1 A 0 A_TakeInventory("PowerOrbBounce",8)
TNT1 A 0 A_GiveInventory("PowerOrbFlag",1)
TNT1 A 0 A_GiveInventory("WeaponCharge",1)
stop
}
}

actor PowerOrbFloor : CustomInventory
{
States
{
Pickup:
TNT1 A 0 ACS_NamedExecute("vile_PowerOrbBounceHandle",0)
Nope:
TNT1 A 0
stop
}
}


actor PowerOrbFloorBounce2 : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_JumpIfInventory("DontBounceAgain",1,"Nope")
TNT1 A 0 A_PlaySoundEx("misc/fatland","Weapon")
TNT1 A 0 A_ChangeVelocity(0,0,18,CVF_RELATIVE)
TNT1 AAA 0 A_SpawnItemEx("PowerOrbShatter",0,0,8,random(-8,8),random(-8,8),0,random(0,360))
goto Degrade
Nope:
TNT1 A 0
stop
Degrade:
TNT1 A 0 A_JumpIfInventory("PowerOrbFlag",9,"Nope")
TNT1 A 0 A_TakeInventory("PowerOrbBounce",8)
TNT1 A 0 A_GiveInventory("PowerOrbFlag",1)
TNT1 A 0 A_GiveInventory("WeaponCharge",1)
stop
}
}

actor PowerOrbCeilingBounce : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_JumpIfInventory("DontBounceAgain",1,"Nope")
TNT1 A 0 A_PlaySoundEx("misc/fatland","Weapon")
TNT1 A 0 A_ChangeVelocity(0,0,-10,CVF_RELATIVE)
TNT1 AAA 0 A_SpawnItemEx("PowerOrbShatter",0,0,8,random(-8,8),random(-8,8),0,random(0,360))
goto Degrade
Nope:
TNT1 A 0
stop
Degrade:
TNT1 A 0 A_JumpIfInventory("PowerOrbFlag",9,"Nope")
TNT1 A 0 A_GiveInventory("PowerOrbFlag",1)
TNT1 A 0 A_GiveInventory("WeaponCharge",1)
stop
}
}

ACTOR PowerOrbSpeed : PowerSpeed
{
+POWERSPEED.NOTRAIL
  Powerup.Duration 0x7FFFFFFD
  Speed 2.55
}

actor DontBounceAgain : PowerUp
{
Powerup.Duration 7
}

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

actor PowerOrbFlag : Inventory
{
inventory.amount 1
inventory.maxamount 9
}

actor PowerOrbBounce : Inventory
{
inventory.amount 1
inventory.maxamount 8
}