actor BusterRodG_W : BaseMM8BDMWep_CBM
{
tag "$TAGC_WTA"
dropitem "BusterRodPoleWep"
Weapon.AmmoUse 0
Weapon.AmmoGive 0
Obituary "$OB_BRGROD"
Inventory.Pickupmessage "Get your hands off this, you damn dirty ape!"
weapon.ammotype "MonkeyMagicAmmo"
States
{
Spawn:
C_WT A 1
loop

Deselect:
BROG A 0
goto DeselectSwap
Select:
BROG A 0
goto SelectSwap

Ready:
BROG A 0 ACS_NamedExecuteWithResult("core_weaponcolor",DYE_BUSTERRODG)
BROG A 0
Ready2:
BROG A 0 A_JumpIfInventory("BRGCloneFlag",1,"ReadyC")
BROG A 0 A_JumpIfInventory("MonkeyMagicAmmo",2,"Ready3")
BROG A 6 A_WeaponReady(WRF_NOSECONDARY)
BROG A 0 A_GiveInventory("MonkeyMagicAmmo",1)
goto Ready2
Ready3:
BROG A 6 A_WeaponReady
BROG A 0 A_JumpIfInventory("BRGCloneFlag",1,"ReadyC")
BROG A 0 A_GiveInventory("MonkeyMagicAmmo",1)
Goto Ready3
ReadyC:
BROG A 1 A_WeaponReady
goto Ready2

Flash:
TNT1 AA 5 A_RailWait
TNT1 AAA 9 A_GiveInventory("BRG_AmmoGiveTake_P")
stop

Fire:
BROG A 1 offset(14,33)A_JumpIfInventory("PlayerPropertyRage",1,1)
BROG A 1 offset(30,37)A_GunFlash("Flash",1)
BROG A 1 offset(48,41)A_JumpIfInventory("PlayerPropertyRage",1,1)

BROG E 1 offset(1,32)A_GiveInventory("BRG_FirePole_P")
BROG E 1
BROG EE 1 offset(3,32)
BROG EE 1 offset(5,32)
Fire2:
BROG EEEEE 1
BROG EEEEE 1

BROG D 2 offset(5,40)
BROG D 2 offset(-2,32)
BROG D 6 offset(-2,32)A_JumpIfInventory("PlayerPropertyRage",1,"FireRageEnd")
//BROG A 2 offset(72,42)

BROG A 2 offset(63,44)
BROG A 2 offset(41,41)
BROG A 2 offset(25,38)
BROG A 2 offset(13,36)
BROG A 2 offset(4,34)
Goto Ready2
FireRage:
BROG D 1 offset(-2,32)A_GunFlash("Flash",1)
BROG E 1 offset(-6,24)A_GiveInventory("BRG_FirePole_P")
BROG EE 1
BROG EE 1 offset(-2,28)
BROG E 1 offset(5,32)
goto Fire2
FireRageEnd:
BROG DDD 2 offset(-2,32)A_ReFire("FireRage")
BROG D 0 A_GiveInventory("BRG_AmmoRageGive_P")
BROG A 2 offset(63,44)A_ReFire("Fire")
BROG A 2 offset(41,41)A_ReFire("Fire")
BROG A 2 offset(25,38)A_ReFire("Fire")
BROG A 2 offset(13,36)A_ReFire("Fire")
BROG A 2 offset(4,34)A_ReFire("Fire")
BROG D 0 A_GiveInventory("BRG_AmmoRageGive_P")
Goto Ready2


AltFire:
BROG A 0 A_JumpIfInventory("MonkeyMagicAmmo",1,"AltFire2")
Goto Ready2
AltFire2:
BROG A 0 A_GiveInventory("VivifyFlag1",1)
BROG B 1 offset(4,32)A_JumpIfInventory("PlayerPropertyRage",1,1)
BROG B 1 offset(2,32)A_TakeInventory("StopShield",1)
BROG C 1 offset(4,32)A_JumpIfInventory("PlayerPropertyRage",1,1)
BROG C 1 offset(2,32)A_TakeInventory("StopShield",1)
BROG F 0 A_GiveInventory("BRGShieldHitbox_P",1)
goto SpinToWin

SpinToWin:
BROG F 0 A_JumpIfInventory("MonkeyMagicAmmo",1,1)
goto AltFireEnd
BROG F 1 offset(1,32)A_GiveInventory("BusterRodG_Alt_P1")
BROG G 1 offset(1,32)A_GiveInventory("BusterRodG_Alt_P0")
BROG G 0 A_Refire(1)
goto AltFireEnd
BROG F 0 A_JumpIfInventory("MonkeyMagicAmmo",1,1)
goto AltFireEnd
BROG F 1 offset(1,32)A_GiveInventory("BusterRodG_Alt_P2")
BROG G 1 offset(1,32)A_GiveInventory("BusterRodG_Alt_P0")
BROG G 0 A_Refire("SpinToWin")
goto AltFireEnd

AltFireEnd:
BROG F 0 A_PlaySoundEx("weapon/topspin","Weapon")
BROG F 0 A_GiveInventory("StopShield",1)
BROG FG 2 offset(1,32)
BROG F 0 A_TakeInventory("VivifyFlag1")
BROG FG 3 offset(1,32)
BROG C 1 offset(2,32)
BROG C 1 offset(4,32)A_JumpIfInventory("PlayerPropertyRage",1,1)
BROG C 1 offset(6,32)
BROG B 1 offset(2,32)A_JumpIfInventory("PlayerPropertyRage",1,1)
BROG B 1 offset(4,32)
BROG B 1 offset(6,32)A_JumpIfInventory("PlayerPropertyRage",1,1)
BROG A 1 offset(-6,32)
BROG A 1 offset(-4,32)A_JumpIfInventory("PlayerPropertyRage",1,1)
BROG A 1 offset(-2,32)
Goto Ready2
}
}

actor MonkeyMagicAmmo : Ammo
{
+INVENTORY.IGNORESKILL
inventory.amount 1
inventory.maxamount 50
}

actor BRGCloneFlag : Inventory{}

actor BRG_CloneItem : BasicClassItem
{
inventory.icon "BRG_ITEM"
inventory.pickupmessage "\ckKing: \cdYou... you can't do this you... monkey butt!"
Tag "BRG Clone Trigger"
states
{
Spawn:
BROG I 1
loop
UseCBM:
TNT1 A 1 A_JumpIfInventory("BRGCloneFlag",1,"Use2")
TNT1 A 1 A_JumpIfInventory("MonkeyMagicAmmo",50,"Use1")
fail
Use1:
TNT1 A 0 A_PlaySound("classes/BRGClone",7,0.7)//SoundSlot7
TNT1 A 0 A_SpawnItemEx("BRG_CloneWatcher")
TNT1 A 0 A_SpawnItemEx("BRGDTFramePre",0,0,0,0,0,0,0,1)
TNT1 A 0 A_GiveInventory("BRGCloneFlag",1)
TNT1 A 0 A_TakeInventory("MonkeyMagicAmmo",2)
fail
Use2:
//TNT1 A 0 A_PlaySoundEX("item/ItemUseMM9","SoundSlot7")
TNT1 A 0 A_PlaySound("classes/BRGClone",7,0.7)//SoundSlot7
TNT1 A 0 A_TakeInventory("BRGCloneFlag",99)
TNT1 A 0 A_TakeInventory("MonkeyMagicAmmo",2)
fail
}
}

actor BRG_FirePole_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_SpawnItemEx("BRGSoundHelper")
TNT1 A 0 A_PlaySoundEx("weapon/BRGStaff","Weapon")
TNT1 A 0 A_FireCustomMissile("CBM_BusterRodWarper",0,0,8,0)
stop
}
}


actor BusterRodG_Alt_P0 : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_JumpIfInventory("PlayerPropertyRage",1,"Spin")
stop
Spin:
TNT1 A 0 A_SpawnItemEx("BRGSoundHelperAlt",0,0,32)
TNT1 A 0 A_SpawnItemEx("BRGSpinBoom",0,-8,32)
TNT1 A 0 A_PlaySoundEx("weapon/BRGSpin","Weapon")
stop
}
}
actor BusterRodG_Alt_P1 : BusterRodG_Alt_P0
{
States
{
Pickup:
TNT1 A 0 A_TakeInventory("MonkeyMagicAmmo",1)
goto Spin
}
}
actor BusterRodG_Alt_P2 : BusterRodG_Alt_P0
{
States
{
Pickup:
TNT1 A 0 A_TakeInventory("MonkeyMagicAmmo",1,1)
goto Spin
}
}

actor BRG_CloneWatcher : BasicHelper
{
Args 1
states
{
Spawn:
TNT1 A 0
TNT1 A 1
TNT1 A 0 A_JumpIfInventory("WeaponCharge",22,7)
TNT1 A 0 A_JumpIfInTargetInventory("BRGCloneFlag",1,2)
TNT1 A 1 A_TakeFromTarget("BRGCloneFlag",99)
stop
TNT1 A 0 A_JumpIfInTargetInventory("MonkeyMagicAmmo",1,3)
TNT1 A 0 A_GiveToTarget("BRGCloneSoundItem",1)
TNT1 A 1 A_TakeFromTarget("BRGCloneFlag",99)
stop
TNT1 A 0 A_GiveInventory("WeaponCharge",1)
goto Spawn
TNT1 A 0 A_JumpIfInTargetInventory("IsDead",1,"Death")
TNT1 A 0 A_SetArg(0,Args[0]*-1)
TNT1 A 0 A_TakeFromTarget("MonkeyMagicAmmo",1,(Args[0]==1))
TNT1 A 0 A_TakeInventory("WeaponCharge",99)
TNT1 A 0 A_JumpIfInTargetInventory("MonkeyMagicAmmo",1,"Spawn")
TNT1 A 0 A_GiveToTarget("BRGCloneSoundItem",1)
TNT1 A 1 A_TakeFromTarget("BRGCloneFlag",99)
stop

Death:
TNT1 A 1 A_TakeFromTarget("BRGCloneFlag",99)
stop
}
}

actor BRGCloneSoundItem : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_PlaySound("classes/BRGClone",7,0.7)//SoundSlot7
stop
}
}

actor BRGSoundHelper : BasicHelper
{
States
{
Spawn:
TNT1 A 1
TNT1 A 0 A_JumpIfInTargetInventory("BRGCloneFlag",1,1)
stop
TNT1 A 1// A_PlaySound("weapon/BRGStaff",4)
TNT1 A 35
TNT1 A 1 A_PlaySound("weapon/BRGStaff",4)
TNT1 A 35
TNT1 A 1 A_PlaySoundEx("weapon/BRGStaff",4)
stop
}
}

actor BRG_AmmoGiveTake_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_JumpIfInventory("BRGCloneFlag",1,2)
TNT1 A 0 A_GiveInventory("MonkeyMagicAmmo",1)
stop
TNT1 A 0 A_TakeInventory("MonkeyMagicAmmo",1,1)
stop
}
}
actor BRG_AmmoRageGive_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_JumpIfInventory("BRGCloneFlag",1,2)
TNT1 A 0 A_GiveInventory("MonkeyMagicAmmo",1)
TNT1 A 0
stop
}
}


actor CBM_BusterRodWarperCheck_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_JumpIfInventory("BRGCloneFlag",1,2,2)
TNT1 A 0 A_SpawnItemEx("CBM_BusterRodWhack",0,0,0,0,0,0,0,SXF_TRANSFERPITCH+SXF_TRANSFERSPECIAL)//512+32768
stop
TNT1 A 0 A_SpawnItemEx("CBM_BusterRodWhack2",0,0,0,0,0,0,0,512+32768)
stop
}
}

actor CBM_BusterRodWarper : BasicExplosion
{
//+SERVERSIDEONLY
+NOTIMEFREEZE
RenderStyle None
ReactionTime 1
Speed 0
Args 0,1,8
States
{
Spawn:
TNT1 A 0
TNT1 A 0 ACS_NamedExecuteWithResult("cbm_CopyPointerAnglePitch",2,0)
TNT1 A 0
Forward:
TNT1 A 0 A_SetArg(0,Args[0]+1)
TNT1 A 0 A_Warp(2,cos(pitch)*(45.0*Args[0]),8.0,32.0-sin(pitch)*(45.0*Args[0]),angle,WARPF_ABSOLUTEANGLE+WARPF_NOCHECKPOSITION)//2+8
TNT1 A 1 A_GiveInventory("CBM_BusterRodWarperCheck_P")
TNT1 A 0 A_JumpIf(!CallACS("cbm_PointerExists",AAPTR_TARGET),"Death")
TNT1 A 0 A_JumpIf(Args[0]>=Args[2],2)
loop
Back:
TNT1 A 0 A_SetArg(0,Args[0]-1)
TNT1 A 0 A_Warp(2,cos(pitch)*(45.0*Args[0]),8.0,32.0-sin(pitch)*(45.0*Args[0]),angle,2+8)
TNT1 A 1 A_GiveInventory("CBM_BusterRodWarperCheck_P")
TNT1 A 0 A_JumpIf(!CallACS("cbm_PointerExists",AAPTR_TARGET),"Death")
TNT1 A 0 A_JumpIf(Args[0]<=1,1)
loop
TNT1 A 0 A_CountDown
goto Forward+1
}
}

actor CBM_BusterRodFX0 : BasicClientSide
{
+NOTIMEFREEZE
RenderStyle None
Args 8
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_SetPitch(Args[1]/100000.0)
TNT1 A 0 A_SetArg(0,Args[0]*4-3)
TNT1 A 0 A_JumpIf(Args[0]<0,"Death")
TNT1 A 0 A_CountDownArg(0)
SpawnL:
TNT1 A 0 A_CountDownArg(0)
TNT1 A 0 A_SpawnItemEx("CBM_BusterRodFX1",-cos(pitch)*(11.25*Args[0]),0,sin(pitch)*(11.25*Args[0]),0,0,0,0,1)
loop
Death:
TNT1 A 0
stop
}
}

actor CBM_BusterRodFX1 : BasicGraphicEffect
{
+NOTIMEFREEZE
States
{
SpawnFrame:
BRGX N 1
stop
}
}
actor CBM_BusterRodFX2 : CBM_BusterRodFX1
{
States
{
SpawnFrame:
BRGX O 1
stop
}
}
actor CBM_BusterRodFX3 : CBM_BusterRodFX1
{
States
{
SpawnFrame:
BRGX P 1
stop
}
}
actor CBM_BusterRodFX4 : CBM_BusterRodFX1
{
Radius 6
States
{
SpawnFrame:
BRGX N 0 A_Jump(256,1,2)
BRGX O 1
stop
BRGX P 1
stop
}
}

actor CBM_BusterRodWhack : BasicExplosion
{
Obituary "$OB_BRGROD"
Damagetype "BRG_Bash"
States
{
Spawn:
TNT1 A 0
TNT1 A 0 ACS_NamedExecuteWithResult("cbm_Re_SetThingSpecial",Args[0], pitch*100000.0)
TNT1 A 0 A_Explode(60,40,0,0,40)
TNT1 A 0 A_SpawnItemEx("CBM_BusterRodFX0",-cos(pitch)*11.25,0,sin(pitch)*11.25,0,0,0,0,1+32768)//1+512+32768//Can't sync pitch[512]
TNT1 A 4 A_SpawnItemEx("CBM_BusterRodFX4",0,0,0,0,0,0,0,1)		//So instead transfer the pitch through an Arg
stop
}
}

actor CBM_BusterRodWhack2 : CBM_BusterRodWhack
{
States
{
Spawn:
TNT1 A 0
TNT1 A 0 ACS_NamedExecuteWithResult("cbm_Re_SetThingSpecial",Args[0], pitch*100000.0)
TNT1 A 0 A_Explode(60,40,0,0,40)
TNT1 A 0 A_SpawnItemEx("CBM_BusterRodFX0",-cos(pitch)*11.25,0,sin(pitch)*11.25,0,0,0,0,1+32768)
TNT1 A 36 A_SpawnItemEx("CBM_BusterRodFX4",0,0,0,0,0,0,0,1)
TNT1 A 0 A_SpawnItemEx("CBM_BusterRodWhackClone")
TNT1 A 0 A_SpawnItemEx("CBM_BusterRodFX0",-cos(pitch)*11.25,0,sin(pitch)*11.25,0,0,0,0,1+32768)
TNT1 A 36 A_SpawnItemEx("CBM_BusterRodFX4",0,0,0,0,0,0,0,1)
TNT1 A 0 A_SpawnItemEx("CBM_BusterRodWhackClone")
TNT1 A 0 A_SpawnItemEx("CBM_BusterRodFX0",-cos(pitch)*11.25,0,sin(pitch)*11.25,0,0,0,0,1+32768)
TNT1 A 4 A_SpawnItemEx("CBM_BusterRodFX4",0,0,0,0,0,0,0,1)
stop
}
}
actor CBM_BusterRodWhackClone : CBM_BusterRodWhack//Second spawn for obit
{
Obituary "$OB_BRGROD2"
States
{
Spawn:
TNT1 A 0
TNT1 A 2 A_Explode(60,40,0,0,40)
stop
}
}


actor BRGShieldHitbox_P : CustomInventory
{
states
{
Pickup:
TNT1 A 0 A_SpawnItemEx("BRGShieldHitbox1",28,-16,8,0,0,0,0,1)
TNT1 A 0 A_SpawnItemEx("BRGShieldHitbox2",28,-8,8,0,0,0,0,1)
TNT1 A 0 A_SpawnItemEx("BRGShieldHitbox3",28,0,8,0,0,0,0,1)
TNT1 A 0 A_SpawnItemEx("BRGShieldHitbox4",28,8,8,0,0,0,0,1)
TNT1 A 0 A_SpawnItemEx("BRGShieldHitbox5",28,16,8,0,0,0,0,1)
stop
}
}

actor BRGShieldHitbox1 : BasicShieldHitbox
{
Meleerange 28
Accuracy -16
Mass 8
States
{
Pain:
TNT1 A 0 A_SpawnItemEx("BRGShieldDeathFX")
TNT1 A 0 A_PlaySound("item/protoreflect")
goto Spawn
}
}
actor BRGShieldHitbox2 : BRGShieldHitbox1
{
Accuracy -8
}
actor BRGShieldHitbox3 : BRGShieldHitbox1
{
Accuracy 0
}
actor BRGShieldHitbox4 : BRGShieldHitbox1
{
Accuracy 8
}
actor BRGShieldHitbox5 : BRGShieldHitbox1
{
Accuracy 16
}

actor BRGShieldHitboxClone : BRGShieldHitbox1
{
Radius 25
States
{
Spawn:
TNT1 A 0
TNT1 A 2
stop
Pain:
TNT1 A 0 A_SpawnItemEx("BRGShieldDeathFX",0,random(-16,16),4)
TNT1 A 1 A_PlaySound("item/protoreflect")
stop
}
}

actor BRGShieldDeathFX : BasicGraphicEffect
{
alpha 0.9
renderstyle add
+BRIGHT
Scale 2.0
states
{
Spawn:
PROC M 0 A_SetScale(scaleX + 0.1, 2.5) 
PROC M 1 A_FadeOut(0.05)
loop
}
}



actor BRGSpinBoom : BasicImplosion
{
Obituary "$OB_BRGSPIN"
Damagetype "BRG_Spin"
States
{
Spawn:
TNT1 A 0
TNT1 A 2 A_Explode(30+CallACS("core_checkrune",RUNE_SPREAD,2)*60,128,0,0,16)
stop
}
}

actor BRGSoundHelperAlt : BasicHelper
{
States
{
Spawn:
TNT1 A 1
TNT1 A 0 A_JumpIfInTargetInventory("BRGCloneFlag",1,1)
stop
TNT1 A 1// A_PlaySound("weapon/topspin",4)
TNT1 A 35
TNT1 A 1 A_SpawnItemEx("BRGShieldHitboxClone",16,-8,-24)
TNT1 A 0 A_PlaySoundEx("weapon/BRGSpin","Weapon")
TNT1 A 0 A_SpawnItemEx("BRGSpinBoom",8,-8,2)
TNT1 A 0 A_SpawnItemEx("BRGShieldHitboxClone",16,-8,-24)
TNT1 A 35
TNT1 A 1 A_SpawnItemEx("BRGShieldHitboxClone",16,-8,-24)
TNT1 A 0 A_PlaySoundEx("weapon/BRGSpin","Weapon")
TNT1 A 0 A_SpawnItemEx("BRGSpinBoom",8,-8,2)
TNT1 A 1 A_SpawnItemEx("BRGShieldHitboxClone",16,-8,-24)
stop
}
}

actor BusterRodG_W_NormalBar : NormalBar {Args 218,221}