//==CHAINGUN==
//Blaz gets a shatter effect on the stun shot, which drops
//painful shrapnel if the projectile hits walls and floors

//Doomslayer gets the Hydra repeater, a powerful machinegun

//Kustam unlocks a potent stun missile that's fired
//alongside his normal hitscan attack

Actor GMOTAChaingun : custominventory replaces chaingun
{
	Radius 14
	Height 14
	+quiet
    +DONTGIB
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 1
		TNT1 A 0 A_CustomMissile ("BlazShatterSprite",0,0,0,CMF_AIMDIRECTION)
		TNT1 A 0 A_CustomMissile ("DoomslayerChaingunSprite",0,0,0,CMF_AIMDIRECTION)
        TNT1 A 0 A_CustomMissile ("KustamLaserComboSprite",0,0,0,CMF_AIMDIRECTION)
	spawn1:
		ITRO ABCDEFGH 1 Bright
		loop
	Pickup:
		TNT1 A 0
		TNT1 A 0 A_JumpIfInventory ("IamLordBlaz",1,"BlazShatter")
		TNT1 A 0 A_JumpIfInventory ("IamDoomSlayer",1,"DoomSlayerChaingun")
		TNT1 A 0 A_JumpIfInventory ("IamKustam",1,"KustamLaserCombo")
		TNT1 A 1
		stop
	BlazShatter:
		TNT1 A 0
		TNT1 A 0
		TNT1 A 0 A_SetBlend (FFFF00,0.1,5)
		TNT1 A 0 A_PlaySound ("powerups/upgrade",CHAN_ITEM)
		TNT1 A 0 ACS_NamedExecuteAlways("WeaponLog",0,3,0,0)			
		TNT1 AA 0 A_GiveInventory ("BlazterEnergy",10)
		TNT1 A 0 A_GiveInventory ("ShatterUpgrade",1)
		TNT1 A 1 
		stop
	DoomslayerChaingun:
		TNT1 A 0
		TNT1 A 0 ACS_NamedExecuteAlways("WeaponLog",0,3,0,0)			
		//TNT1 A 0 a_log ("You got the Hydra Repeater!")
		TNT1 A 0 A_PlaySound ("misc/w_pkup",CHAN_ITEM)
		TNT1 A 0 A_SetBlend (FFFF00,0.1,5)
		TNT1 A 0 A_GiveInventory ("SlayerGrit",10)
		TNT1 A 0 A_GiveInventory ("ReignStorm",1)
		TNT1 A 1
		stop
	KustamLaserCombo:
		TNT1 A 0
		TNT1 A 0 ACS_NamedExecuteAlways("WeaponLog",0,3,0,0)			
		TNT1 A 0 A_PlaySound ("Kustam/upgradeget",CHAN_ITEM)
		TNT1 A 0 A_SetBlend (FFFF00,0.1,5)
		TNT1 A 0 A_GiveInventory ("KustamLaserBattery",5)
		TNT1 A 0 A_GiveInventory ("LaserComboUpgrade",1)
		TNT1 A 1
		stop
	}
}

//Blaz Item Token
actor ShatterUpgrade : inventory
{inventory.maxamount 1}

//Kustam item token
actor LaserComboUpgrade : inventory
{inventory.maxamount 1}



//Item sprites
actor BlazShatterSprite : GMOTAweaponsprite
{
    VisibleToPlayerClass LordBlaz
    States
    {
	spawn:
		TNT1 A 0
		GUPG A 1 bright
		TNT1 A 0 a_warp (AAPTR_TARGET,0,0,0,0,WARPF_INTERPOLATE|WARPF_NOCHECKPOSITION)
		TNT1 A 0 a_checkflag ("SPECIAL","spawn",AAPTR_TARGET)
		GUPG A 1 bright
		goto death
	death:
		TNT1 A 1
		stop
    }
}

actor DoomSlayerChainGunSprite : GMOTAweaponsprite
{
    VisibleToPlayerClass DoomSlayer
    States
    {
	spawn:
		TNT1 A 0
		RSPU A 1 bright
		TNT1 A 0 a_warp (AAPTR_TARGET,0,0,0,0,WARPF_INTERPOLATE|WARPF_NOCHECKPOSITION)
		TNT1 A 0 a_checkflag ("SPECIAL","spawn",AAPTR_TARGET)
		RSPU A 1 bright
		goto death
	death:
		TNT1 A 1
		stop
    }
}

actor KustamLaserComboSprite : GMOTAWeaponsprite
{
    VisibleToPlayerClass Kustam
    States
    {
	spawn:
		TNT1 A 0
		HCSG A 1 bright
		TNT1 A 0 a_warp (AAPTR_TARGET,0,0,0,0,WARPF_INTERPOLATE|WARPF_NOCHECKPOSITION)
		TNT1 A 0 a_checkflag ("SPECIAL","spawn",AAPTR_TARGET)
		HCSG A 1 bright
		goto death
	death:
		TNT1 A 0
		TNT1 A 1
		stop
    }
}
