actor Brightman_W : BaseMM8BDMWep_CBM 
{
tag "$TAGC_4A"
dropitem "FlashBulbWep"
Weapon.AmmoGive 28
Inventory.Pickupmessage "Power up! Flash Stopper??"
weapon.ammotype "WattIsMyAmmo"
weapon.ammotype2 "BrightIdeasAmmo"
+WEAPON.NOAUTOAIM
Obituary "$OB_BRIGHTBUSTER"
States
{
Spawn:
C_04 A 1
loop

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

Ready:
FSTB A 0 ACS_NamedExecuteWithResult("core_weaponcolor",DYE_BRIGHTMAN)
FSTB A 0 A_GunFlash("Flash",0)
FSTB JI 2
goto Ready1

Ready1:
FSTB A 0 A_JumpIfInventory("WattIsMyAmmo",28,"Ready2")
FSTB A 0 A_JumpIfInventory("VivifyDelay4",1,"FlashStopper")
FSTB A 2 A_WeaponReady(8)
FSTB A 0 A_GiveInventory("WattIsMyAmmo",1)
loop
Ready2:
FSTB A 0 A_JumpIfInventory("VivifyDelay4",1,"FlashStopper")
FSTB A 1 A_WeaponReady
FSTB A 0 A_JumpIfInventory("VivifyDelay4",1,"FlashStopper")
FSTB A 1 A_WeaponReady
FSTB A 0 A_GiveInventory("WattIsMyAmmo",1)
loop

Fire:
FSTB A 0 A_JumpIfInventory("IsBot",1,"BotFire")
FSTB A 0 A_GiveInventory("WattIsMyAmmo",1)
FSTB A 0 A_PlaySoundEx("weapon/mbuster","Weapon")
FSTB A 0 A_FireCustomMissile("BrightShot",random(-2,2),0,8,0)
FSTB BC 3
FSTB A 1
FSTB A 0 A_TakeInventory("VivifyDelay4",1)
goto Ready1
AltFire:
FSTB A 0 A_JumpIfInventory("WattIsMyAmmo",28,"AltFireToss")
goto Ready1
AltFireToss:
FSTB A 0 A_TakeInventory("WattIsMyAmmo",14)
FSTB A 0 A_TakeInventory("WattIsMyAmmo",14,1)
FSTB A 0 A_PlaySoundEx("weapon/BombThrow","Weapon")
FSTB A 0 A_FireCustomMissile("BrightBulbToss",0,0,-8,0)
FSTB I 4 A_GunFlash("Flash.BulbToss",1)
FSTB JJJI 4
Goto Ready1
FlashStopper:
FSTB I 0 A_GiveInventory("CBM_DisableJumpPowerGiver",1)
FSTB I 0 ACS_NamedExecuteWithResult("core_stopplayer",0,1)
FSTB I 0 A_PlaySoundEx("weapon/flashstopper","Weapon")
FSTB I 0 A_FireCustomMissile("BrightmanFlashStopper",0,1,0,0)
FSTB I 0 A_GunFlash("Flash",0)
FSTB I 5 A_SetBlend(white,0.95,5)
FSTB I 2 A_TakeInventory("BrightFlashStock",99)
FSTB I 2 A_TakeInventory("BrightIdeasAmmo",28,1)
FSTB I 2 A_TakeInventory("BrightFlashStock",99)
FSTB I 2 A_TakeInventory("BrightIdeasAmmo",14)
FSTB I 2
FSTB I 0 A_TakeInventory("BrightIdeasAmmo",28,1)
FSTB I 0 A_TakeInventory("BrightFlashStock",99)
FSTB I 0 A_TakeInventory("CBM_DisableJumpPower")
FSTB I 0 ACS_NamedExecuteWithResult("core_stopplayer",0,0)
goto Ready1
Flash:
TNT1 A 1 A_GiveInventory("Brightman_Flash_P")
loop
Flash.BulbToss:
FSTB DDDEEEFFFGGGHHH 1 A_GiveInventory("Brightman_Flash_P")
goto Flash

BotFire:
FSTB A 0 A_JumpIfInventory("BrightIdeasAmmo",28,"BotFire2")
FSTB A 0 A_JumpIfInventory("WattIsMyAmmo",28,"BotFire1")
goto Fire+1
BotFire1:
FSTB A 0 A_Jump(64,"AltFireToss")
goto Fire+1
BotFire2:
TNT1 A 0 A_JumpIfCloser(350,"FlashStopper")
TNT1 A 0 A_Jump(64,"BotFire3")
goto BotFire+1
BotFire3:
TNT1 A 0 A_FaceTarget
TNT1 A 0 A_JumpIfCloser(350,"FlashStopper")
goto BotFire+1
}
}

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

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

actor BrightFlashStock : Inventory
{
inventory.amount 1
inventory.maxamount 999
}


actor BrightmanPowerLightAmp : PowerLightAmp
{//Needs gl_enhanced_nightvision false, shouldn't force user
Powerup.Duration 0x7FFFFFFC
//powerup.color purple 0.5
}

actor FlashStopperUseItem : BasicClassItem
{
inventory.icon "BriIcon"
inventory.pickupmessage "Careful, this bulb is one of a kind, known as the 'Eternal Light' to some."
Tag "Execute Flash Stopper"
states
{
Spawn:
WEA3 E 1
loop
UseCBM:
TNT1 A 0 A_JumpIfInventory("BrightIdeasAmmo",28,"Success")
fail
Success:
TNT1 A 0 A_GiveInventory("VivifyDelay4",1)
fail
}
}

actor Brightman_Flash_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_GiveInventory("BrightmanSparkleFX_P",1)
TNT1 A 0 A_JumpIfInventory("BrightFlashStock",10,"Success")
TNT1 A 0 A_GiveInventory("BrightFlashStock",1+CallACS("core_checkrune",RUNE_RAGE))
stop
Success:
TNT1 A 0 A_TakeInventory("BrightFlashStock",10)
TNT1 A 0 A_GiveInventory("BrightIdeasAmmo",1)
stop
}
}


actor BrightmanSparkleFX_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_JumpIfInventory("BrightIdeasAmmo",28,1)
stop
TNT1 A 0 A_JumpIfInventory("BrightSparkleDelayF",1,2)
TNT1 A 0 A_GiveInventory("BrightmanSparkleFX2_P")
TNT1 A 0
stop
}
}

actor BrightSparkleDelayF : Powerup
{
Powerup.Duration 22
}

actor BrightmanSparkleFX2_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_GiveInventory("BrightSparkleDelayF",1)
TNT1 A 0 A_SpawnItemEx("BrightmanSparkleFX",random(2,12),0,random(68,76),0,0,0,random(1,16)*20,1)
//TNT1 A 0 A_SpawnItemEx("BrightmanSparkleFX_Helper",0,0,0,0,0,0,0,1)
stop
}
}

actor BrightmanSparkleFX_Helper : BasicHelper
{
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_SpawnItemEx("BrightmanSparkleFX",random(2,12),0,random(68,76),0,0,0,random(1,16)*20,1)
TNT1 A 1
stop
}
}

actor BrightmanSparkleFX : BasicClientSide
{
+FORCEXYBILLBOARD
+BRIGHT
Renderstyle "Translucent"
Alpha 0.95
Scale 2.25
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_GiveInventory("MM8BDMProjSpawnFuncClient")
TNT1 A 0 A_Jump(256,"Spawn1","Spawn2","Spawn3","Spawn4")
Spawn1:
FSTB UVWX 2
stop
Spawn2:
FSTB UVVWWXX 1
stop
Spawn3:
FSTB VUUVWX 1
stop
Spawn4:
FSTB VUVWX 1
stop
}
}

actor BrightBulbToss : ProjSpawnFuncActor
{
PROJECTILE
damagetype "BrightM_Bulb"
Obituary "$OB_BRIGHTBULB"
-NOGRAVITY
+SKYEXPLODE
+EXPLODEONWATER
Damage (100)
Radius 20
Height 16
Speed 32
scale 2.5
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_ChangeVelocity(0,0,8.5)
TNT1 A 0 A_Jump(256,1,2,3,4,5,6,7,8)
goto SpawnL
SpawnL:
FSTB KLMN 2
loop
SpawnL2:
FSTB NMLK 2
loop

Death:
TNT1 A 0 A_SetGravity(0.0)
TNT1 A 0 A_SetArg(2,(ceilingz-z<=16)*-4+(z-floorz==0)*4)
TNT1 AAAAAAA 0 A_SpawnItemEx("BrightBulbShardFX",0,0,Args[2],random(-10+abs(Args[2]),10-abs(Args[2])),random(-10+abs(Args[2]),10-abs(Args[2])),random(-2+abs(Args[2]),2+abs(Args[2])),0,1,32)
TNT1 A 0 A_SpawnItemEx("BrightBulbTossBoom",0,0,10)
TNT1 A 2
stop
}
}

actor BrightBulbShardFX
{
+MISSILE
+CLIENTSIDEONLY
+THRUACTORS
+DOOMBOUNCE
+RANDOMIZE
BounceFactor 0.3
WallBounceFactor 0.3
renderstyle translucent
Radius 4
Height 4
Speed 20
scale 2.5
States
{
Spawn:
FSTB O 0
FSTB O 0 A_Jump(256,1,2,3,4)
FSTB OPQRSOPQRSOPQRSOPQRSOPQRSOPQRSOPQRSOPQRSOPQRSOPQRSOPQRS 4
stop
Death:
FSTB S 0 A_Jump(256,1,2,3)
FSTB SSSSSSSSSSSS 2
FSTB SSSSS 1 A_FadeOut(0.175)
stop
}
}

actor BrightBulbTossBoom : BasicExplosion
{
damagetype "BrightM_Bulb"
Obituary "$OB_BRIGHTBULB"
+FORCEXYBILLBOARD
+BRIGHT
scale 3.0
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_PlaySoundEx("weapon/centaurflash","Voice")
TNT1 A 1 A_Explode(100,156,0,0,32)
TNT1 A 0 ACS_NamedExecuteWithResult("core_flashstopperlight",156)
TNT1 A 9 A_SpawnItemEx("BasicBoom6FX_4_210",0,0,0,0,0,0,0,1+SXF_TRANSFERSCALE)//16384
//211
stop
}
}

actor BrightShot : ProjSpawnFuncActor
{
PROJECTILE
damagetype "BrightM_Shot"
Obituary "$OB_BRIGHTBUSTER"
+FORCEXYBILLBOARD
+BRIGHT
Damage (100)
radius 6
height 6
Speed 42
scale 2.5
States
{
Spawn:
TNT1 A 1
FSTB T 19
FSTB TT 1 A_SetScale(ScaleX-0.5)
stop
}
}

actor BrightmanFlashStopper : BasicExplosion
{
Obituary "$OB_BRIGHTFLASH"
damagetype "BrightM_Stopper"
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_SpawnItemEx("BrightmanFlashStopperFX",0,0,64-28,0,0,0,0,1)
TNT1 A 2 A_Explode(60,512,0,0,256)
stop
}
}

actor BrightmanFlashStopperFX : BasicClientSide
{
+FORCEXYBILLBOARD
+BRIGHT
renderstyle translucent
alpha 1.0
scale 5.0
States
{
Spawn:
Q_4A ABCDEF 1 A_FadeOut(0.12)
stop
}
}

actor PowerBrightFlashWeaken : PowerProtection
{
Powerup.Duration 70
damagefactor "BrightM_Stopper", 2.0
//damagefactor "BrightM_Bulb", 1.5
//damagefactor "BrightM_Shot", 2.0
}

actor BossFlashStoppered : BasicHelper
{
reactiontime 69
States
{
Spawn:
TNT1 A 0
TNT1 A 0 //A_GiveToTarget("PowerBrightFlashWeaken",1)
TNT1 A 0 A_GiveToTarget("PlayerPropertyGroundedOn",1)
TNT1 A 1 A_GiveToTarget("BossFlashStopperedStop",1)
TNT1 A 0 A_TakeFromTarget("EternalPainFlag",1)
goto Spawn2
Spawn2:
TNT1 A 0 A_JumpIfInTargetInventory("EternalPainFlag",1,"Death")
TNT1 A 1 A_GiveToTarget("BossFlashStopperedStop",1)
TNT1 A 0 A_CountDown
loop
Death:
TNT1 A 0
TNT1 A 0 //A_TakeFromTarget("PowerBrightFlashWeaken",1)
TNT1 A 1 A_GiveToTarget("PlayerPropertyGroundedOff",1)
stop
}
}

actor BossFlashStopperedStop : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_Stop
TNT1 A 0 A_GiveInventory("DashingStraitjacket_F",1)
TNT1 A 0 A_SpawnItemEx("BossFlashStopperedStopFX",random(16,32),0,random(12,42),0,0,0,random(1,16)*20,0,32)
stop
}
}

actor BossFlashStopperedStopFX
{
translation "211:211=224:224","225:225=226:226"
scale 0.75
-SOLID
+NOGRAVITY
+CLIENTSIDEONLY
+FORCEXYBILLBOARD
+BRIGHT
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_Jump(256,"Spawn1","Spawn2","Spawn3","Spawn4")
Spawn1:
FSTB UVWX 2
stop
Spawn2:
FSTB UVVWWXX 1
stop
Spawn3:
FSTB VUUVWX 1
stop
Spawn4:
FSTB VUVWX 1
stop
}
}


actor Brightman_W_NormalBar : NormalBar {Args 4,225}
actor Brightman_W_SecondBar : SecondBar {Args 4,239}