actor TeslaCoil
{
	obituary "%o was zapped by a tesla coil."
	health 750
	radius 16
	height 56
	mass 10000
	speed 0
	MONSTER
	-ISMONSTER //Makes it spawnable where ever you want it to be spawned
	
	+FLOORCLIP
	+FASTER
	+FRIENDLY
	+NOBLOOD
	+LOOKALLAROUND
	+SHORTMISSILERANGE
	+NEVERRESPAWN
	
	// protect from marine damage
	damagefactor "MarineFire", 0.0
	damageFactor "MarineFire2", 0.0
        DamageFactor "BFGSplash", 0.0
        DamageFactor "BFGSpray", 0.0
	damagefactor "NoProfitKill", 0.0
	//Make spawnable inside monsters
	-SOLID
	
	states
	{
		Spawn:
			TESL A 1 A_Look
			NULL A 0 A_JumpIfHealthLower(300,"Spawn2")
			TESL A 0 A_PlaySoundEx ("Tesla/Loop", "SoundSlot5", 1)
			goto Spawn
		Spawn2:
			NULL A 0 A_SpawnItem("Smoke",0,56)
			TESL A 1 A_Look
			TESL A 0 A_PlaySoundEx ("Tesla/Loop", "SoundSlot5", 1)
			TESL A 1 A_Look
			TESL A 0 A_PlaySoundEx ("Tesla/Loop", "SoundSlot5", 1)
			TESL A 1 A_Look
			TESL A 0 A_PlaySoundEx ("Tesla/Loop", "SoundSlot5", 1)
			TESL A 1 A_Look
			TESL A 0 A_PlaySoundEx ("Tesla/Loop", "SoundSlot5", 1)
			TESL A 1 A_Look
			TESL A 0 A_PlaySoundEx ("Tesla/Loop", "SoundSlot5", 1)
			
			goto Spawn2
		See:
			NULL A 0 A_JumpIfHealthLower(300,"See2")
			TESL AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 1 A_Chase
			TESL A 0 A_PlaySoundEx ("Tesla/Loop", "SoundSlot5", 1)
			goto See
		See2:
			NULL A 0 A_SpawnItem("Smoke",0,56)
			TESL AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 1 A_Chase
			TESL A 0 A_PlaySoundEx ("Tesla/Loop", "SoundSlot5", 1)
			goto See2

		Missile:
			TESL A 9 A_FaceTarget
			TESL A 1 bright
			TESL A 0 bright A_PlaySound ("Tesla/Attack")
			TESL A 0 bright A_SpawnItem ("TeslaZapper", 0, 60)
			TESL A 1 bright
			TESL A 59
			goto See
		Death:
			TESL A 1 bright A_SpawnItemEx ("Boom", 0, 0, 60, 0, 0, 0, 0, 160)
			TESL A 0 bright A_StopSoundEx ("SoundSlot5")
			TESL A 0 bright A_PlaySound ("weapons/rocklx")
                        NULL A 0 A_NoBlocking
			TESL B -1
			stop
	}
}

actor TeslaZapper
{
  obituary "%o was zapped by a tesla coil."
  radius 2
  height 2
  //Decal "CrossbowScorch2"
  +NOGRAVITY
  +LOOKALLAROUND
  +NOCLIP
  +INVULNERABLE
  states
  {
  Spawn:
    TNT1 A 1 A_FaceTarget
  Missile:
    TNT1 AAAAA 0 bright A_CustomRailgun (20, 0, none, lightblue, 1, 0, 1000, "InvisiblePuff")
    TNT1 AAAAA 0 bright A_CustomRailgun (20, 0, none, white, 1, 0, 1000, "InvisiblePuff")
    stop
  }
}

ACTOR TurretRail
{
	obituary "%o was blasted by a Rail Turret."
	health 450
	radius 16
	height 56
	mass 0x7FFFFFF
	speed 0
	MONSTER
	-ISMONSTER //Makes it spawnable where ever you want it to be spawned
	+FLOORCLIP
	+FRIENDLY
	+FASTER
	+NOBLOOD
	+LOOKALLAROUND
	+SHORTMISSILERANGE
	+NEVERRESPAWN
	PainSound "turret/pain"
	
	// protect from marine damage
	damagefactor "MarineFire", 0.0
	damageFactor "MarineFire2", 0.0
        DamageFactor "BFGSplash", 0.0
        DamageFactor "BFGSpray", 0.0

	//Make spawnable inside monsters
	-SOLID
	
	states
	{
		Spawn:
			TRT1 A 1 A_Look
			TRT1 A 5  A_PlaySound("turret/active", CHAN_AUTO, 6)
			loop
		See:
			TRT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 1 A_Chase
			TRT1 A 5  A_PlaySound("turret/active", CHAN_AUTO, 6)
			loop
		Missile:
			TRT1 A 1 A_PlaySound("turret/sight", CHAN_AUTO)
			TRT1 ABCD 1 A_FaceTarget
			TRT1 E 4 bright A_CustomRailgun(10*random(1,8), 0, "00 FF FF", "FF FF FF", 0, 1, 0, "InvisiblePuff")
			TRT1 A 1
			goto See
		Pain:
			TRT1 A 1
			TRT1 A 1 A_Pain
			goto See
		Death:
			//BTRT A 1 bright A_SpawnItemEx ("Boom", 0, 0, 60, 0, 0, 0, 0, 160)
			BTRT A 0
			BTRT A 0 A_KillChildren
            NULL A 0 A_NoBlocking
			BTRT A 1 bright A_SpawnItemEx("explosionemitter_t", 0)
			BTRT A 0 bright A_StopSoundEx ("SoundSlot5")
			BTRT A 0 bright A_PlaySound ("weapons/rocklx")
			BTRT B 1
            NULL A 0 A_NoBlocking
			POSS A 0 A_SpawnDebris("splatSandbag1")
			POSS A 0 A_SpawnDebris("splatSandbag2")
			POSS A 0 A_SpawnDebris("splatSandbag3")
			POSS A 0 A_SpawnDebris("splatSandbag1")
			POSS A 0 A_SpawnDebris("splatSandbag2")
			POSS A 0 A_SpawnDebris("splatShard1")
			POSS A 0 A_SpawnDebris("splatShard2")
			POSS A 0 A_SpawnDebris("splatShard3")
			POSS A 0 A_SpawnDebris("splatShard4")
			POSS A 0 A_SpawnDebris("splatShard1")
			POSS A 0 A_SpawnDebris("splatShard2")
			POSS A 0 A_SpawnDebris("splatShard3")
			POSS A 0 A_SpawnDebris("splatShard4")
			MISL B 8 bright
			MISL C 6 bright
			MISL D 4 bright
			stop
	}
}

ACTOR TurretShotgun
{
	obituary "%o was splattered by a Shotgun Turret."
	health 750
	radius 16
	height 56
	mass 10000
	speed 0
	MONSTER
	-ISMONSTER //Makes it spawnable where ever you want it to be spawned
	+FLOORCLIP
	+FRIENDLY
	+FASTER
	+NOBLOOD
	+LOOKALLAROUND
	+SHORTMISSILERANGE
	+NEVERRESPAWN
	PainSound "turret/pain"
	
	// protect from marine damage
	damagefactor "MarineFire", 0.0
	damageFactor "MarineFire2", 0.0
        DamageFactor "BFGSplash", 0.0
        DamageFactor "BFGSpray", 0.0
	damagefactor "NoProfitKill", 0.0
	//Make spawnable inside monsters
	-SOLID
	
	states
	{
		Spawn:
			TRT1 A 1 A_Look
			TRT1 A 5  A_PlaySound("turret/active", CHAN_AUTO, 6)
			loop
		See:
			TRT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 1 A_Chase
			TRT1 A 5  A_PlaySound("turret/active", CHAN_AUTO, 6)
			loop
		Missile:
			TRT1 A 2 A_FaceTarget
			TRT1 A 1 A_PlaySound("turret/sight", CHAN_AUTO)
			TRT1 ABCD 1 bright
			TRT1 E 1 bright A_CustomBulletAttack(22.5, 0, 3, 5, "BulletPuffTurret")
			TNT1 A 0 A_PlaySound("w2/fire")
			TRT1 D 1 A_CustomMissile("splatShellCasing", 32, 2, 45+random(-8,8), 0, 3)
			TRT1 E 1 bright A_CustomBulletAttack(22.5, 0, 3, 5, "BulletPuffTurret")
			TNT1 A 0 A_PlaySound("w2/fire")
			TRT1 D 1 A_CustomMissile("splatShellCasing", 32, 2, 45+random(-8,8), 0, 3)
			TRT1 E 1 bright A_CustomBulletAttack(22.5, 0, 3, 5, "BulletPuffTurret")
			TNT1 A 0 A_PlaySound("w2/fire")
			TRT1 D 1 A_CustomMissile("splatShellCasing", 32, 2, 45+random(-8,8), 0, 3)
			TRT1 E 1 bright A_CustomBulletAttack(22.5, 0, 3, 5, "BulletPuffTurret")
			TNT1 A 0 A_PlaySound("w2/fire")
			TRT1 D 1 A_CustomMissile("splatShellCasing", 32, 2, 45+random(-8,8), 0, 3)
			TRT1 E 1 bright A_CustomBulletAttack(22.5, 0, 3, 5, "BulletPuffTurret")
			TNT1 A 0 A_PlaySound("w2/fire")
			TRT1 D 1 A_CustomMissile("splatShellCasing", 32, 2, 45+random(-8,8), 0, 3)
			TRT1 E 1 bright A_CustomBulletAttack(22.5, 0, 3, 5, "BulletPuffTurret")
			TNT1 A 0 A_PlaySound("w2/fire")
			TRT1 D 1 A_CustomMissile("splatShellCasing", 32, 2, 45+random(-8,8), 0, 3)
			TRT1 E 1 bright A_CustomBulletAttack(22.5, 0, 3, 5, "BulletPuffTurret")
			TNT1 A 0 A_PlaySound("w2/fire")
			TRT1 D 1 A_CustomMissile("splatShellCasing", 32, 2, 45+random(-8,8), 0, 3)
			TRT1 E 1 bright A_CustomBulletAttack(22.5, 0, 3, 5, "BulletPuffTurret")
			TNT1 A 0 A_PlaySound("w2/fire")
			TRT1 D 1 A_CustomMissile("splatShellCasing", 32, 2, 45+random(-8,8), 0, 3)
			TRT1 E 1 bright A_CustomBulletAttack(22.5, 0, 3, 5, "BulletPuffTurret")
			TNT1 A 0 A_PlaySound("w2/fire")
			TRT1 D 1 A_CustomMissile("splatShellCasing", 32, 2, 45+random(-8,8), 0, 3)
			TRT1 E 1 bright A_CustomBulletAttack(22.5, 0, 3, 5, "BulletPuffTurret")
			TNT1 A 0 A_PlaySound("w2/fire")
			TRT1 D 1 A_CustomMissile("splatShellCasing", 32, 2, 45+random(-8,8), 0, 3)
			TRT1 E 1 bright A_CustomBulletAttack(22.5, 0, 3, 5, "BulletPuffTurret")
			TNT1 A 0 A_PlaySound("w2/fire")
			TRT1 D 1 A_CustomMissile("splatShellCasing", 32, 2, 45+random(-8,8), 0, 3)
			TNT1 A 0 A_PlaySound("w2/fire")
			TRT1 A 1 bright
			TRT1 A 22
			goto See
		Pain:
			TRT1 A 1
			TRT1 A 1 A_Pain
			goto See
		Death:
			TRT1 A 1 bright A_SpawnItemEx ("Boom", 0, 0, 60, 0, 0, 0, 0, 160)
			TRT1 A 0 bright A_StopSoundEx ("SoundSlot5")
                        NULL A 0 A_NoBlocking
			TRT1 A 0 bright A_PlaySound ("weapons/rocklx")
			TESL B -1
			stop
	}
}

actor BulletPuffTurret : BulletPuff { damagetype "MarineFire" }

actor InvisiblePuff { damagetype "MarineFire" }

//////////////////
// INVENTORY MANAGEMENT

ACTOR TurretBullet_Build : Inventory
{
	radius 64
	height 32
	
	inventory.pickupmessage "You have activated the build protocol!"
	
	//+COUNTITEM
	inventory.amount 0
inventory.amount 0
	
	renderstyle add
	
	states
	{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_GiveInventory("build_check")
			TNT1 A 0 A_SpawnItem("TurretBullet_Building")
		Spawn2:
			BULD A 1 A_SpawnItem("BuildableMarker")
			loop
	}
}

ACTOR TurretBullet_Building : BuildBase
{
	renderstyle add
	
	states
	{
		Spawn2:
			BULD ABCDEFGHI 40
			BULD I 0 A_SpawnItem ("TurretBullet", 0, 128, 0, 0)
                        BULD I 1 A_SpawnItem ("splatEmitter_CFX", 0, 128, 0, 0)
			stop
	}
}

ACTOR TurretRocket_Build : Inventory
{
	radius 64
	height 32
	
	inventory.pickupmessage "You have activated the build protocol!"
	
	//+COUNTITEM
	inventory.amount 0
	
	renderstyle add
	
	states
	{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_GiveInventory("build_check")
			TNT1 A 0 A_SpawnItem("TurretRocket_Building")
		Spawn2:
			BULD A 1 A_SpawnItem("BuildableMarker")
			loop
	}
}

ACTOR TurretRocket_Building : BuildBase
{
	renderstyle add
	
	states
	{
		Spawn2:
			BULD ABCDEFGHI 40
			BULD I 0 A_SpawnItem ("TurretRocket", 0, 128, 0, 0)
                        BULD I 1 A_SpawnItem ("splatEmitter_CFX", 0, 128, 0, 0)
			stop
	}
}


ACTOR TurretPlasma_Build : Inventory
{
	radius 64
	height 32
	
	inventory.pickupmessage "You have activated the build protocol!"
	
	//+COUNTITEM
	inventory.amount 0
	
	renderstyle add
	
	states
	{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_GiveInventory("build_check")
			TNT1 A 0 A_SpawnItem("TurretPlasma_Building")
		Spawn2:
			BULD A 1 A_SpawnItem("BuildableMarker")
			loop
	}
}

ACTOR TurretPlasma_Building : BuildBase
{
	renderstyle add
	
	states
	{
		Spawn2:
			BULD ABCDEFGHI 40
			BULD I 0 A_SpawnItem ("TurretPlasma", 0, 128, 0, 0)
                        BULD I 1 A_SpawnItem ("splatEmitter_CFX", 0, 128, 0, 0)
			stop
	}
}

ACTOR TurretRail_Build : Inventory
{
	radius 64
	height 32
	
	inventory.pickupmessage "You have activated the build protocol!"
	
	//+COUNTITEM
	inventory.amount 0
	
	renderstyle add
	
	states
	{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_GiveInventory("build_check")
			TNT1 A 0 A_SpawnItem("TurretRail_Building")
		Spawn2:
			BULD A 1 A_SpawnItem("BuildableMarker")
			loop
	}
}

ACTOR TurretRail_Building : BuildBase
{
	renderstyle add
	
	states
	{
		Spawn2:
			BULD ABCDEFGHI 40
			BULD I 0 A_SpawnItem ("TurretRail", 0, 128, 0, 0)
                        BULD I 1 A_SpawnItem ("splatEmitter_CFX", 0, 128, 0, 0)
			stop
	}
}

ACTOR TurretShotgun_Build : Inventory
{
	radius 64
	height 32
	
	inventory.pickupmessage "You have activated the build protocol!"
	
	//+COUNTITEM
	inventory.amount 0
	
	renderstyle add
	
	states
	{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_GiveInventory("build_check")
			TNT1 A 0 A_SpawnItem("TurretShotgun_Building")
		Spawn2:
			BULD A 1 A_SpawnItem("BuildableMarker")
			loop
	}
}

ACTOR TurretShotgun_Building : BuildBase
{
	renderstyle add
	
	states
	{
		Spawn2:
			BULD ABCDEFGHI 40
			BULD I 0 A_SpawnItem ("TurretShotgun", 0, 128, 0, 0)
                        BULD I 1 A_SpawnItem ("splatEmitter_CFX", 0, 128, 0, 0)
			stop
	}
}

ACTOR TurretTesla_Build : Inventory
{
	radius 64
	height 32
	
	inventory.pickupmessage "You have activated the build protocol!"
	
	//+COUNTITEM
	inventory.amount 0
	
	renderstyle add
	
	states
	{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_GiveInventory("build_check")
			TNT1 A 0 A_SpawnItem("TurretTesla_Building")
		Spawn2:
			BULD A 1 A_SpawnItem("BuildableMarker")
			loop
	}
}

ACTOR TurretTesla_Building : BuildBase
{
	renderstyle add
	
	states
	{
		Spawn2:
			BULD ABCDEFGHI 40
			BULD I 0 A_SpawnItem ("TeslaCoil", 0, 128, 0, 0)
                        BULD I 1 A_SpawnItem ("splatEmitter_CFX", 0, 128, 0, 0)
			stop
	}
}

ACTOR TurretFlame_Build : Inventory
{
	radius 64
	height 32
	
	inventory.pickupmessage "You have activated the build protocol!"
	
	//+COUNTITEM
	inventory.amount 0
	
	renderstyle add
	
	states
	{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_GiveInventory("build_check")
			TNT1 A 0 A_SpawnItem("TurretFlame_Building")
		Spawn2:
			BULD A 1 A_SpawnItem("BuildableMarker")
			loop
	}
}

ACTOR TurretFlame_Building : BuildBase
{
	renderstyle add
	
	states
	{
		Spawn2:
			BULD ABCDEFGHI 40
			BULD I 0 A_SpawnItem ("TurretFlame", 0, 128, 0, 0)
                        BULD I 1 A_SpawnItem ("splatEmitter_CFX", 0, 128, 0, 0)
			stop
	}
}



ACTOR BuildableMarker : MapMarker
{
	scale 0.1
	renderstyle add
	states
	{
		Spawn:
			BULD A 2
			Stop
	}
}

// MOVE TO RIGHT ONE IF ITS WROONG

ACTOR Smoke
{
  RenderStyle Translucent
  Alpha 0.5
  VSpeed 1
  +NOBLOCKMAP 
  +NOGRAVITY 
  +DONTSPLASH
  +NOTELEPORT
  States
  {
  Spawn:
    RSMK A 0 A_Jump(32,"A")
	RSMK A 0 A_Jump(32,"B")
	RSMK A 0 A_Jump(32,"C")
	RSMK A 0 A_Jump(32,"D")
	RSMK A 1
	loop
    A:
    RSMK A 1 A_FadeOut(0.01)
	loop
	B:
    RSMK B 1 A_FadeOut(0.01)
	loop
	C:
    RSMK C 1 A_FadeOut(0.01)
	loop
	D:
    RSMK D 1 A_FadeOut(0.01)
	loop
	
  }
}

