//==============================================================================
//		RARITY BEAMS
//==============================================================================

actor RLRarityBeam
{
	Radius 16
	Height 8
    Scale 0.2
    Alpha 0.15
    RenderStyle Add 
	VisibleToPlayerClass "DoomRLTechnician"
	+THRUACTORS
    +FORCEYBILLBOARD
	+NOTONAUTOMAP
	+DONTSPLASH
	+NOTELEPORT
    States
    {
    Spawn:
	    TNT1 A random(0,15)
    Pulse1:
		TNT1 A 0 A_JumpIf(CallACS("DRLA_RarityBeams"), "Pulse1NotDisabled")
		Goto WaitingForCVARToPlay
    Pulse1NotDisabled:
	    TNT1 A 0 A_JumpIf(alpha > 0.74, "Pulse2")
        RARE X 1 Bright A_FadeTo (0.75, 0.05, 0)
        RARE X 0 Bright A_CheckFlag("SPECIAL", "Pulse1Warp", AAPTR_MASTER)
        Stop
    Pulse1Warp:
        RARE X 0 Bright A_Warp(AAPTR_MASTER, 0, 0, 0, 0, WARPF_COPYINTERPOLATION | WARPF_TOFLOOR | WARPF_NOCHECKPOSITION, "Pulse1")
        Stop
    Pulse2:
	    TNT1 A 0 A_JumpIf(alpha == 0.0, "Invisible")
        RARE X 1 Bright A_FadeTo (0.0, 0.01, 0)
        RARE X 0 Bright A_CheckFlag("SPECIAL", "Pulse2Warp", AAPTR_MASTER)
        Stop
    Pulse2Warp:
        RARE X 0 Bright A_Warp(AAPTR_MASTER, 0, 0, 0, 0, WARPF_COPYINTERPOLATION | WARPF_TOFLOOR | WARPF_NOCHECKPOSITION, "Pulse2")
        Stop
    Invisible:
        TNT1 AAAAAAAAAAAAAAAAAAAA 1 A_Warp(AAPTR_MASTER, 0, 0, 0, 0, WARPF_COPYINTERPOLATION | WARPF_TOFLOOR | WARPF_NOCHECKPOSITION)
        TNT1 A 1 A_Warp(AAPTR_MASTER, 0, 0, 0, 0, WARPF_COPYINTERPOLATION | WARPF_TOFLOOR | WARPF_NOCHECKPOSITION, "Pulse1")
        Stop
		
    WaitingForCVARToPlay:
		TNT1 A 0 A_JumpIf(CallACS("DRLA_RarityBeams"), "Pulse1")
        TNT1 A random(20,30)
        TNT1 A 0 A_CheckFlag("SPECIAL", "WaitingForCVARToPlayWarp", AAPTR_MASTER)
        Stop
    WaitingForCVARToPlayWarp:
        TNT1 A 0 A_Warp(AAPTR_MASTER, 0, 0, 0, 0, WARPF_COPYINTERPOLATION | WARPF_TOFLOOR | WARPF_NOCHECKPOSITION, "WaitingForCVARToPlay")
        Stop
    }
}

actor RLRarityBeamStandard : RLRarityBeam
{
}

actor RLRarityBeamOnyx : RLRarityBeam
{
    Translation "0:255=%[0.0,0.0,0.0]:[0.5,0.5,0.5]"
}

actor RLRarityBeamAssembled : RLRarityBeam
{
    Translation "0:255=%[0.0,0.0,0.0]:[0.0,0.0,1.0]"
}

actor RLRarityBeamAssembledWorld : RLRarityBeam
{
    Translation "0:255=%[0.0,0.0,0.0]:[0.0,0.0,1.0]"
    States
    {
    Invisible:
        TNT1 AAAAAAAAAAAAAAAAAAAA 1 A_Warp(AAPTR_MASTER, 0, 0, 0, 0, WARPF_COPYINTERPOLATION | WARPF_TOFLOOR | WARPF_NOCHECKPOSITION)
        TNT1 A 0 A_GiveInventory ("RLUniqueRarityBeamSoundToken", 1)
        TNT1 A 0 A_JumpIfInventory ("RLUniqueRarityBeamSoundToken", 17, "Ding")
        TNT1 A 1 A_Warp(AAPTR_MASTER, 0, 0, 0, 0, WARPF_COPYINTERPOLATION | WARPF_TOFLOOR | WARPF_NOCHECKPOSITION, "Pulse1")
        Stop
    Ding:
        TNT1 A 0 A_TakeInventory ("RLUniqueRarityBeamSoundToken", 17)
		TNT1 A 0 A_PlaySound("weapons/masternearby", 5, 0.75, 0, 0.25)
        TNT1 A 1 A_Warp(AAPTR_MASTER, 0, 0, 0, 0, WARPF_COPYINTERPOLATION | WARPF_TOFLOOR | WARPF_NOCHECKPOSITION, "Pulse1")
        Stop
    }
}

actor RLRarityBeamAssembledDRPG : RLRarityBeam
{
    Translation "0:255=%[0.0,0.0,0.0]:[0.0,1.0,1.0]"
}

actor RLRarityBeamAssembledWorldDRPG : RLRarityBeamAssembledWorld
{
    Translation "0:255=%[0.0,0.0,0.0]:[0.0,1.0,1.0]"
}

actor RLRarityBeamExotic : RLRarityBeam
{
    Translation "0:255=%[0.0,0.0,0.0]:[1.0,0.0,1.0]"
}

actor RLRarityBeamSuperior : RLRarityBeam
{
    Translation "0:255=%[0.0,0.0,0.0]:[1.0,0.6,0.0]"
}

actor RLRarityBeamUnique : RLRarityBeam
{
    Translation "0:255=%[0.0,0.0,0.0]:[0.5,1.0,0.4]"
}

actor RLRarityBeamUniqueWorld : RLRarityBeam
{
    Translation "0:255=%[0.0,0.0,0.0]:[0.5,1.0,0.4]"
    States
    {
    Invisible:
        TNT1 AAAAAAAAAAAAAAAAAAAA 1 A_Warp(AAPTR_MASTER, 0, 0, 0, 0, WARPF_COPYINTERPOLATION | WARPF_TOFLOOR | WARPF_NOCHECKPOSITION)
        TNT1 A 0 A_GiveInventory ("RLUniqueRarityBeamSoundToken", 1)
        TNT1 A 0 A_JumpIfInventory ("RLUniqueRarityBeamSoundToken", 20, "Ding")
        TNT1 A 1 A_Warp(AAPTR_MASTER, 0, 0, 0, 0, WARPF_COPYINTERPOLATION | WARPF_TOFLOOR | WARPF_NOCHECKPOSITION, "Pulse1")
        Stop
    Ding:
        TNT1 A 0 A_TakeInventory ("RLUniqueRarityBeamSoundToken", 20)
		TNT1 A 0 A_PlaySound("weapons/uniquenearby", 5, 1, 0, 0.25)
        TNT1 A 1 A_Warp(AAPTR_MASTER, 0, 0, 0, 0, WARPF_COPYINTERPOLATION | WARPF_TOFLOOR | WARPF_NOCHECKPOSITION, "Pulse1")
        Stop
    }
}

actor RLRarityBeamDemonic : RLRarityBeam
{
    Translation "0:255=%[0.0,0.0,0.0]:[1.0,0.0,0.0]"
}

actor RLRarityBeamDemonicWorld : RLRarityBeam
{
    Translation "0:255=%[0.0,0.0,0.0]:[1.0,0.0,0.0]"
    States
    {
    Invisible:
        TNT1 AAAAAAAAAAAAAAAAAAAA 1 A_Warp(AAPTR_MASTER, 0, 0, 0, 0, WARPF_COPYINTERPOLATION | WARPF_TOFLOOR | WARPF_NOCHECKPOSITION)
        TNT1 A 0 A_GiveInventory ("RLUniqueRarityBeamSoundToken", 1)
        TNT1 A 0 A_JumpIfInventory ("RLUniqueRarityBeamSoundToken", 14, "Ding")
        TNT1 A 1 A_Warp(AAPTR_MASTER, 0, 0, 0, 0, WARPF_COPYINTERPOLATION | WARPF_TOFLOOR | WARPF_NOCHECKPOSITION, "Pulse1")
        Stop
    Ding:
        TNT1 A 0 A_TakeInventory ("RLUniqueRarityBeamSoundToken", 14)
		TNT1 A 0 A_PlaySound("weapons/demonicnearby", 5, 1, 0, 0.25)
        TNT1 A 1 A_Warp(AAPTR_MASTER, 0, 0, 0, 0, WARPF_COPYINTERPOLATION | WARPF_TOFLOOR | WARPF_NOCHECKPOSITION, "Pulse1")
        Stop
    }
}

actor RLRarityBeamLegendary : RLRarityBeam
{
    Translation "0:255=%[0.0,0.0,0.0]:[1.0,1.0,0.4]"
}

actor RLRarityBeamLegendaryWorld : RLRarityBeam
{
    Translation "0:255=%[0.0,0.0,0.0]:[1.0,1.0,0.4]"
    States
    {
    Invisible:
        TNT1 AAAAAAAAAAAAAAAAAAAA 1 A_Warp(AAPTR_MASTER, 0, 0, 0, 0, WARPF_COPYINTERPOLATION | WARPF_TOFLOOR | WARPF_NOCHECKPOSITION)
        TNT1 A 0 A_GiveInventory ("RLUniqueRarityBeamSoundToken", 1)
        TNT1 A 0 A_JumpIfInventory ("RLUniqueRarityBeamSoundToken", 11, "Ding")
        TNT1 A 1 A_Warp(AAPTR_MASTER, 0, 0, 0, 0, WARPF_COPYINTERPOLATION | WARPF_TOFLOOR | WARPF_NOCHECKPOSITION, "Pulse1")
        Stop
    Ding:
        TNT1 A 0 A_TakeInventory ("RLUniqueRarityBeamSoundToken", 11)
		TNT1 A 0 A_PlaySound("weapons/legendarynearby", 5, 1, 0, 0.25)
        TNT1 A 1 A_Warp(AAPTR_MASTER, 0, 0, 0, 0, WARPF_COPYINTERPOLATION | WARPF_TOFLOOR | WARPF_NOCHECKPOSITION, "Pulse1")
        Stop
    }
}

actor RLDemonArtifactSoundEffect : RLRarityBeam
{
    States
    {
    Spawn:
	    TNT1 A 0
	    TNT1 A 0 A_Jump (256, "SpawnLoop")
		Goto SpawnLoop
    SpawnLoop:
	    TNT1 A 1 A_PlaySound ("misc/demonartifactloop", 7, 0.8, 1, 0.4)
        TNT1 A 0 A_CheckFlag("SPECIAL", "Warp", AAPTR_MASTER)
        Stop
    Warp:
        TNT1 A 0 A_Warp(AAPTR_MASTER, 0, 0, 0, 0, WARPF_COPYINTERPOLATION | WARPF_TOFLOOR | WARPF_NOCHECKPOSITION, "SpawnLoop")
        Stop
    }
}

// DoomRPG Rarity Beams
// muh beam experience
/*
actor RLRarityBeamShield : RLRarityBeam
{
    Translation "0:255=%[0.0,0.0,0.0]:[0.2,0.7,1.0]"
}

actor RLRarityBeamCard : RLRarityBeam
{
    Translation "0:255=%[0.0,0.0,0.0]:[1.0,0.2,0.6]"
}
*/
Actor RLUniqueRarityBeamSoundToken : RLPermanentInventory
{
inventory.maxamount 20
}

Actor RLFistMessageSpamPreventer : Powerup
{
	Powerup.Duration 25 // Stops infinite fist dropping message spam
  +INVENTORY.UNTOSSABLE
}

// EOF