// Proxy mine inventory
actor ProxyMine : InventoryItem {
	inventory.icon "mineicon"
	tag "Proxy C4 -mine"
	inventory.maxamount 6
	states {
	Use:
		TNT1 A 0 A_JumpIfInventory("IsInSpawnRoom", 1, "Failure")
		TNT1 A 0 A_JumpIfInventory ("IsMech", 1, "Use.Mech")
		TNT1 A 0 A_JumpIf (ACS_ExecuteWithResult(346, 2) == 0, "Limit")
		TNT1 A 0 A_JumpIfInventory ("PowerBerserk", 1, "Failure")
		TNT1 A 0 A_PlaySound ("c4/proxy", CHAN_ITEM)
		TNT1 A 0 A_JumpIfInventory ("IsBlue", 1, "UseBlue")
		TNT1 A 0 A_SpawnItemEx ("ProxyMineRed", 32,0,1, 0,0,0, 0, SXF_TRANSFERPOINTERS)
		TNT1 A 0 ACS_ExecuteAlways (349, 0, 2)
		stop
	UseBlue:
		TNT1 A 0 A_SpawnItemEx ("ProxyMineBlue", 32,0,1, 0,0,0, 0, SXF_TRANSFERPOINTERS)
		TNT1 A 0 ACS_ExecuteAlways (349, 0, 2)
		stop
	Limit:
		TNT1 A 0 ACS_ExecuteAlways (349, 0, 2)
		fail
	}
}

actor ProxyMineCount : Inventory {
	inventory.maxamount 6
}

Actor ProxyMineBase // Data used by all mines
{
	MONSTER
	-SOLID
	-FRIENDLY
	-COUNTKILL
	+FLOORCLIP
	+NOICEDEATH
	+NOTARGET
	+NEVERRESPAWN
	+NOBLOOD
	+NOCLIP
	+LOOKALLAROUND
	+AMBUSH
	+QUICKTORETALIATE
	+CANPASS
//	Obituary "$OB_MINEBARREL"
	Radius 8
	Height 14
	Health 160
	Damage 0
	Speed 0
	Scale .2
	Mass 0x7FFFFFFF

	DamageFactor "Flash",			0.0
	DamageFactor "Fist",			0.0
	DamageFactor "Knife",			0.5
	DamageFactor "Bullet",			0.0
	DamageFactor "Rifle",			0.0
	DamageFactor "Explosion",		0.0
	DamageFactor "MassDriver",		0.0
	DamageFactor "AntiArmor",		0.0
	DamageFactor "Mine",			0.0
	DamageFactor "Fire",			0.0
	DamageFactor "FireSpecial",		0.0
	DamageFactor "Chemical",		0.0
	DamageFactor "ChemicalSpecial",	0.0
	DamageFactor "Energy",			1.0
	DamageFactor "Plasma",			0.0
	DamageFactor "EnergyDecay",		1.0
	DamageFactor "Ice",				0.0
	DamageFactor "Time",			0.0
	DamageFactor "Suicide",         0.0
	DamageFactor "Superweapon",		0.0
	DamageFactor "Disarm",			1.0
	DamageFactor "Deconstruction",	0.0
	DamageFactor "Mechstomp",		0.0
	DamageFactor "Monster",			0.0
//	Translation "112:127=228:246"	// Red
//	Translation "112:127=194:207"	// Blue
	States
	{
	Spawn:
		PC4T AA 0 //A_CheckSight("Death.Deconstruction") [Cata] Unintended behavior from Zandro 3.0. Deprecating this.
		PC4T A 0 ACS_ExecuteAlways (980, 0)
		PC4T A 2 A_ChangeFlag("Friendly", 0)
		goto Idle
	Idle:
		PC4T A 4 A_LookEx (LOF_NOSOUNDCHECK, 0, 64)
		Loop
	See: // Due an issue with mines blowing up teammates this was changed.
//		PC4T A 0 A_JumpIfInTargetInventory ("IsTeam", 1, "Clear") // Check team if its a temamate ignore.
		PC4T A 2 A_JumpIfCloser(64, "Death") // Checks if they are close enough. If so just blow.
		goto Clear
	Clear:
		PC4T A 2 A_ClearTarget
		goto Idle
	Melee:
//		PC4T A 1 A_JumpIfInTargetInventory ("IsTeam", 1, "Clear") // Check team if its a temamate ignore.
		goto Death
	Death:
		TNT1 A 0 ACS_ExecuteAlways (980, 0)
		TNT1 A 0 A_NoBlocking
		TNT1 A 0 A_PlaySound ("weapons/rocklx")
		TNT1 A 0 A_CustomMissile ("ProxyMineExplosion")
		TNT1 A 1
		stop
	Death.Fist:
	Death.Bullet:
	Death.Rifle:
		// [Dusk] If the mine was shot, it does the damage itself, thus
		// acting like a barrel. This way someone can be fragged by
		// detonating his own mines.
		TNT1 A 0 ACS_ExecuteAlways (980, 0)
		TNT1 A 0 A_NoBlocking
		TNT1 A 0 A_PlaySound ("weapons/rocklx")
		TNT1 A 0 A_SpawnItemEx ("ExplosionMain")
		TNT1 A 1 A_Explode (50, 128, 1)
		stop
	Death.Knife:
	Death.Energy:
	Death.EnergyDecay:
	Death.Deconstruction:
	Death.Disarm:
		PC4T A 18 A_PlaySound("c4/disarm")
		PC4T A 1 A_Fadeout(0.1)
		wait
	}
}

Actor ProxyMineRed : ProxyMineBase
{
	Translation "112:127=228:246"
	States
	{
	See:
		PC4T A 0 A_JumpIfInTargetInventory ("IsRed", 1, "Clear")
		PC4T A 2 A_JumpIfCloser(64, "Death")
		goto Clear
	Melee:
		PC4T A 1 A_JumpIfInTargetInventory ("IsRed", 1, "Clear")
		goto Death
	}
}

actor ProxyMineBlue : ProxyMineBase
{
	Translation "112:127=194:207"
	States
	{
	See:
		PC4T A 0 A_JumpIfInTargetInventory ("Isblue", 1, "Clear")
		PC4T A 2 A_JumpIfCloser(64, "Death")
		goto Clear
	Melee:
		PC4T A 1 A_JumpIfInTargetInventory ("Isblue", 1, "Clear")
		goto Death
	}
}

// Xindage: Originally this thing caused massdriver damage (similar to explosion) an amount of 150
// this damage type was reduced to an amount of 70% to player resulting in 45, as rifle was doing 50
// so this was supposed all along or not? I do changed it back to 45 now it does damage that only grade reduces.
actor ProxyMineExplosion : ProxyMineBase {
	PROJECTILE
	-RANDOMIZE
	+NOCLIP
	Speed 1
	Damage 0
	Obituary "$OB_MINE"
	DamageType "Mine"
	states {
	Spawn:
		TNT1 A 0
		TNT1 A 0 A_SpawnItemEx ("ExplosionMain")
		TNT1 A 1 A_Explode (45, 128, 1)
		stop
	}  
}

//==============================================================================
//These are for AOW13 (Space Camp) They're seperate from the original mines
Actor ProxyMineRedSpawn : Custominventory 30003 {	
	States {
	Spawn:
		TNT1 A 6
        TNT1 A 0 A_SpawnItemex ("ProxyMineRedd")
		stop
	}
}
Actor ProxyMineBlueSpawn : Custominventory 30004 {	
	States {
	Spawn:
		TNT1 A 6
        TNT1 A 0 A_SpawnItemex ("ProxyMineBluee")
		stop
	}
}
Actor ProxyMineRedd {
	MONSTER
	-SOLID
	-FRIENDLY
	-COUNTKILL
	+FLOORCLIP
	+NOICEDEATH
	+NOTARGET
	+NEVERRESPAWN
	+NOBLOOD
	+NOCLIP
	+LOOKALLAROUND
	+AMBUSH
	+QUICKTORETALIATE
	+CANPASS

	Obituary "%k tripped over a proxy mine."
	Radius 8
	Height 14
	Health 160
	Damage 0
	Speed 0
	Scale .2
	Mass 0x7FFFFFFF

	DamageFactor "Flash",			0.0
	DamageFactor "Fist",			0.0
	DamageFactor "Knife",			0.5
	DamageFactor "Bullet",			0.0
	DamageFactor "Rifle",			0.0
	DamageFactor "Explosion",		0.0
	DamageFactor "MassDriver",		0.0
	DamageFactor "AntiArmor",		0.0
	DamageFactor "Mine",			0.0
	DamageFactor "Fire",			0.0
	DamageFactor "FireSpecial",		0.0
	DamageFactor "Chemical",		0.0
	DamageFactor "ChemicalSpecial",	0.0
	DamageFactor "Energy",			1.0
	DamageFactor "Plasma",			0.0
	DamageFactor "EnergyDecay",		1.0
	DamageFactor "Ice",				0.0
	DamageFactor "Time",			0.0
	DamageFactor "Suicide",         0.0
	DamageFactor "Superweapon",		0.0
	DamageFactor "Disarm",			1.0
	DamageFactor "Deconstruction",	0.0
	DamageFactor "Mechstomp",		0.0
	DamageFactor "Monster",			0.0
	translation "112:127=228:246"
	
	States {
	Spawn:
		PC4T A 0
	Idle:
		PC4T A 6 A_LookEx (LOF_NOSOUNDCHECK, 0, 64)
		Loop
	See:
		PC4T A 0 A_JumpIfCloser(64, "Melee") //Checks if they are close enough. If so goes to Melee.
		PC4T A 2 A_JumpIfTargetInLOS ("Melee") //Not sure what this is for....
		PC4T A 2 A_ClearTarget
		goto Idle
	Clear:
		PC4T A 2 A_ClearTarget
		goto Idle
	Melee:
		PC4T A 0
		PC4T AA 1 A_JumpIfInTargetInventory ("IsBlue", 1, "Death") //If you are blue, you get blown up
		goto Clear
	Death:
		TNT1 A 0 A_NoBlocking
		TNT1 A 0 A_PlaySound ("weapons/rocklx")
		TNT1 A 0 A_CustomMissile ("ProxyMineExplosion")
		TNT1 A 1
		stop
	Death.Fist:
	Death.Bullet:
	Death.Rifle:
		// [Dusk] If the mine was shot, it does the damage itself, thus
		// acting like a barrel. This way someone can be fragged by
		// detonating his own mines.
		TNT1 A 0 A_NoBlocking
		TNT1 A 0 A_PlaySound ("weapons/rocklx")
        TNT1 A 0 A_SpawnItemEx ("ExplosionMain")
		TNT1 A 1 A_Explode (50, 128, 1)
		stop
	Death.Knife:
	Death.Energy:
	Death.EnergyDecay:
	Death.Deconstruction:
	Death.Disarm:
		PC4T A 18 A_PlaySound("c4/disarm")
		PC4T A 1 A_Fadeout(0.1) 
		wait
	}
}
Actor ProxyMineBluee {
	MONSTER
	-SOLID
	-FRIENDLY
	-COUNTKILL
	+FLOORCLIP
	+NOICEDEATH
	+NOTARGET
	+NEVERRESPAWN
	+NOBLOOD
	+NOCLIP
	+LOOKALLAROUND
	+AMBUSH
	+QUICKTORETALIATE
	+CANPASS

	Obituary "%k tripped over a proxy mine."
	Radius 8
	Height 14
	Health 160
	Damage 0
	Speed 0
	Scale .2
	Mass 0x7FFFFFFF

	DamageFactor "Flash",			0.0
	DamageFactor "Fist",			0.0
	DamageFactor "Knife",			0.5
	DamageFactor "Normal",          0.0
	DamageFactor "Bullet",			0.0
	DamageFactor "Rifle",			0.0
	DamageFactor "Explosion",		0.0
	DamageFactor "MassDriver",		0.0
	DamageFactor "AntiArmor",		0.0
	DamageFactor "Mine",			0.0
	DamageFactor "Fire",			0.0
	DamageFactor "FireSpecial",		0.0
	DamageFactor "Chemical",		0.0
	DamageFactor "ChemicalSpecial",	0.0
	DamageFactor "Energy",			1.0
	DamageFactor "Plasma",			0.0
	DamageFactor "EnergyDecay",		1.0
	DamageFactor "Time",			0.0
	DamageFactor "Suicide",         0.0
	DamageFactor "Superweapon",		0.0
	DamageFactor "Disarm",			1.0
	DamageFactor "Deconstruction",	0.0
	DamageFactor "Mechstomp",		0.0
	DamageFactor "Monster",			0.0
	translation "112:127=194:207"
	
	States {
	Spawn:
		PC4T A 0
	Idle:
		PC4T A 6 A_LookEx (LOF_NOSOUNDCHECK, 0, 64)
		Loop
	See:
		PC4T A 0 A_JumpIfCloser(64, "Melee") //Checks if they are close enough. If so goes to Melee.
		PC4T A 2 A_JumpIfTargetInLOS ("Melee") //Not sure what this is for....
		PC4T A 2 A_ClearTarget
		goto Idle
	Clear:
		PC4T A 2 A_ClearTarget
		goto Idle
	Melee:
		PC4T A 0
		PC4T AA 1 A_JumpIfInTargetInventory ("IsRed", 1, "Death") //If you are red, you get blown up
		goto Clear
	Death:
		TNT1 A 0 A_NoBlocking
		TNT1 A 0 A_PlaySound ("weapons/rocklx")
		TNT1 A 0 A_CustomMissile ("ProxyMineExplosion")
		TNT1 A 1
		stop
	Death.Fist:
	Death.Bullet:
	Death.Rifle:
		// [Dusk] If the mine was shot, it does the damage itself, thus
		// acting like a barrel. This way someone can be fragged by
		// detonating his own mines.
		TNT1 A 0 A_NoBlocking
		TNT1 A 0 A_PlaySound ("weapons/rocklx")
        TNT1 A 0 A_SpawnItemEx ("ExplosionMain")
		TNT1 A 1 A_Explode (50, 128, 1)
		stop
	Death.Knife:
	Death.Energy:
	Death.EnergyDecay:
	Death.Deconstruction:
	Death.Disarm:
		PC4T A 18 A_PlaySound("c4/disarm")
		PC4T A 1 A_Fadeout(0.1) 
		wait
	}
}
//==============================================================================
