//==CHAINGUN==
//Blaz gets gun parts to boost the Blazter's primary fire
//Doomslayer gets the Hydra repeater, a powerful machinegun

Actor GMOTAChaingun : custominventory replaces chaingun
{
	Radius 14
	Height 14
	+quiet
    +DONTGIB
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 1
		TNT1 A 0 a_custommissile ("BlazGunSprite",0,0,0,CMF_AIMDIRECTION)
		TNT1 A 0 a_custommissile ("DoomslayerChaingunSprite",0,0,0,CMF_AIMDIRECTION)
	spawn1:
		ITRO ABCDEFGH 1 Bright
		loop
	Pickup:
		TNT1 A 0
		TNT1 A 0 A_JumpIfInventory ("IamLordBlaz",1,"BlazGun")
		TNT1 A 0 A_JumpIfInventory ("IamDoomSlayer",1,"DoomSlayerChaingun")
		TNT1 A 1
		stop
	BlazGun:
		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 A 0 a_log ("Gun parts!")
		TNT1 A 0 acs_namedexecutewithresult ("BlazGun")
		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 ("spikes",10)
		TNT1 A 0 a_giveinventory ("hydraRepeater",1)
		TNT1 A 0 a_giveinventory ("GotHydraRepeater",1)
		TNT1 A 1
		stop
	}
}


actor gunparts : inventory
{inventory.maxamount 3}

actor GotHydraRepeater : inventory
{
	+UNTOSSABLE
	inventory.maxamount 1
}

actor BlazGunSprite : 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
		HRPU 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)
		HRPU A 1 bright
		goto death
	death:
		TNT1 A 1
		stop
    }
}

