ACTOR SerpentTurboToken : Inventory
{
	inventory.maxamount 1
	-INVBAR
}

ACTOR GreenChaosSerpent : Demon1 16513
{
	//$Category Monsters
	//$Title Chaos Serpent (Green)
	Game Heretic
	Speed 8
	Mass 600
	Height 100
	health 750
	+BOSS
	+DONTMORPH
	+NORADIUSDMG
	States
	{
	Spawn:
		DEMN AA 10 A_Look
		Loop
	See:
		// DEMN A 0 A_JumpIfInventory("SerpentTurboToken", 1, "TurboChase")
		DEMN AABBCCDD 3 A_Chase
		Loop
	TurboChase:
		DEMN AAABBBCCCDDD 1 A_Chase
		DEMN AAABBBCCCDDD 1 A_Chase
		DEMN A 0 A_TakeInventory("SerpentTurboToken", 1)
		Loop
	Pain:
		DEMN E 4
		DEMN E 4 A_Pain
		// DEMN E 0 A_JumpIfHealthLower(250, 1)
		Goto See
		DEMN E 0 A_GiveInventory("SerpentTurboToken")
		Goto See
	Melee:
		DEMN E 6 A_FaceTarget
		DEMN F 8 A_FaceTarget
		DEMN G 6 A_CustomMeleeAttack(random[DemonAttack1](1,6)*3)
		Goto See
	Missile:
		// DEMN E 0 A_JumpIfHealthLower(250, "MissilePlus")
		DEMN E 5 A_FaceTarget
		DEMN F 6 A_FaceTarget
		DEMN G 0 A_CustomMissile("FireSerpFX", 62, 0, -4, 0)
		DEMN G 0 A_CustomMissile("FireSerpFX", 62, 0)
		DEMN G 5 A_CustomMissile("FireSerpFX", 62, 0, 4, 0)
		Goto See
	MissilePlus:
		DEMN E 3 A_FaceTarget
		DEMN F 4 A_FaceTarget
		DEMN G 0 A_CustomMissile("FireSerpFX", 62, 0, -4, 0)
		DEMN G 0 A_CustomMissile("FireSerpFX", 62, 0)
		DEMN G 3 A_CustomMissile("FireSerpFX", 62, 0, 4, 0)
		Goto See
	Death:
		DEMN HI 6
		DEMN J 6 A_Scream
		DEMN K 6 A_NoBlocking
		DEMN L 6 A_QueueCorpse
		DEMN MNO 6
		DEMN P -1
		Stop
	XDeath:
		DEMN H 6
		DEMN I 0 A_SpawnItemEx("Demon1Chunk1", 0,0,45, 1+(random[DemonChunks](0,255)*0.015625),
							   1+(random[DemonChunks](0,255)*0.015625), ChunkFlags, 90)
		DEMN I 0 A_SpawnItemEx("Demon1Chunk2", 0,0,45, 1+(random[DemonChunks](0,255)*0.015625),
							   1+(random[DemonChunks](0,255)*0.015625), ChunkFlags, 270)
		DEMN I 0 A_SpawnItemEx("Demon1Chunk3", 0,0,45, 1+(random[DemonChunks](0,255)*0.015625),
							   1+(random[DemonChunks](0,255)*0.015625), ChunkFlags, 270)
		DEMN I 0 A_SpawnItemEx("Demon1Chunk4", 0,0,45, 1+(random[DemonChunks](0,255)*0.015625),
							   1+(random[DemonChunks](0,255)*0.015625), ChunkFlags, 270)
		DEMN I 6 A_SpawnItemEx("Demon1Chunk5", 0,0,45, 1+(random[DemonChunks](0,255)*0.015625),
							   1+(random[DemonChunks](0,255)*0.015625), ChunkFlags, 270)
		Goto Death+2	
	Ice:
		DEMN Q 5 A_FreezeDeath
		DEMN Q 1 A_FreezeDeathChunks
		Wait
	}
}

ACTOR FireSerpFX : SorcererFX1
{
	Damage 6
	DamageType Fire
	+SPAWNSOUNDSOURCE
	SeeSound "DemonMissileFire"
	DeathSound "DemonMissileExplode"
	States
	{
	Spawn:
		FX14 ABC 6 BRIGHT
		Loop
	Death:
		FX14 DEFGH 5 BRIGHT
		Stop
	}
}

ACTOR PoisonSerpFX : FireSerpFX
{
	Damage 6
	DamageType Poison
	States
	{
	Spawn:
		D2FX ABCDEF 4 Bright
		Loop
	Death:
		D2FX GHIJ 4 Bright
		D2FX KL 3 Bright
		Stop
	}
}

ACTOR BrownChaosSerpent : GreenChaosSerpent 16514
{
	//$Category Monsters
	//$Title Chaos Serpent (Brown)
	Obituary "$OB_DEMON2"
	// Species "BrownChaosSerpent"
	States
	{
	Spawn:
		DEM2 AA 10 A_Look
		Loop
	See:
		DEM2 A 0 A_JumpIfInventory("SerpentTurboToken", 1, "TurboChase")
		DEM2 AABBCCDD 3 A_Chase
		Loop
	TurboChase:
		DEM2 AAABBBCCCDDD 1 A_Chase
		DEM2 AAABBBCCCDDD 1 A_Chase
		DEM2 A 0 A_TakeInventory("SerpentTurboToken", 1)
		Loop
	Pain:
		DEM2 E 4
		DEM2 E 4 A_Pain
		DEM2 E 0 A_JumpIfHealthLower(250, 1)
		Goto See
		DEM2 E 0 A_GiveInventory("SerpentTurboToken")
		Goto See
	Melee:
		DEM2 E 6 A_FaceTarget
		DEM2 F 8 A_FaceTarget
		DEM2 G 6 A_CustomMeleeAttack(random[DemonAttack1](1,6)*3)
		Goto See
	Missile:
		DEM2 E 0 A_JumpIfHealthLower(250, "MissilePlus")
		DEM2 E 5 A_FaceTarget
		DEM2 F 6 A_FaceTarget
		DEM2 G 5 A_CustomMissile("PoisonSerpFX", 62, 0)
		Goto See
	MissilePlus:
		DEM2 E 3 A_FaceTarget
		DEM2 F 4 A_FaceTarget
		DEM2 G 0 A_CustomMissile("PoisonSerpFX", 62, 0, -4, 0)
		DEM2 G 0 A_CustomMissile("PoisonSerpFX", 62, 0)
		DEM2 G 3 A_CustomMissile("PoisonSerpFX", 62, 0, 4, 0)
		Goto See
	Death:
		DEM2 HI 6
		DEM2 J 6 A_Scream
		DEM2 K 6 A_NoBlocking
		DEM2 L 6 A_QueueCorpse
		DEM2 MNO 6
		DEM2 P -1
		Stop
	XDeath:
		DEM2 H 6
		DEM2 I 0 A_SpawnItemEx("Demon2Chunk1", 0,0,45, 1+(random[DemonChunks](0,255)*0.015625),
							   1+(random[DemonChunks](0,255)*0.015625), ChunkFlags, 90)
		DEM2 I 0 A_SpawnItemEx("Demon2Chunk2", 0,0,45, 1+(random[DemonChunks](0,255)*0.015625),
							   1+(random[DemonChunks](0,255)*0.015625), ChunkFlags, 270)
		DEM2 I 0 A_SpawnItemEx("Demon2Chunk3", 0,0,45, 1+(random[DemonChunks](0,255)*0.015625),
							   1+(random[DemonChunks](0,255)*0.015625), ChunkFlags, 270)
		DEM2 I 0 A_SpawnItemEx("Demon2Chunk4", 0,0,45, 1+(random[DemonChunks](0,255)*0.015625),
							   1+(random[DemonChunks](0,255)*0.015625), ChunkFlags, 270)
		DEM2 I 6 A_SpawnItemEx("Demon2Chunk5", 0,0,45, 1+(random[DemonChunks](0,255)*0.015625),
							   1+(random[DemonChunks](0,255)*0.015625), ChunkFlags, 270)
	Goto Death+2	
	}
}

Actor RedChaosSerpent : GreenChaosSerpent 16555
{
	//$Category Monsters
	//$Title Chaos Serpent (Red)
  	// Species "RedChaosSerpent"
  	Obituary "$OB_DEMON3"
  	HitObituary "$OB_DEMON3H"
	Tag "$FN_DEMON3"
	States
	{
	Spawn:
		RDMN AA 10 A_Look
		Loop
	See:
		RDMN A 0 A_JumpIfInventory("SerpentTurboToken", 1, "TurboChase")
		RDMN AABBCCDD 3 A_Chase
		Loop
	TurboChase:
		RDMN AAABBBCCCDDD 1 A_Chase
		RDMN AAABBBCCCDDD 1 A_Chase
		RDMN A 0 A_TakeInventory("SerpentTurboToken", 1)
		Loop
	Pain:
		RDMN E 4
		RDMN E 4 A_Pain
		RDMN E 0 A_JumpIfHealthLower(250, 1)
		Goto See
		RDMN E 0 A_GiveInventory("SerpentTurboToken")
		Goto See
	Melee:
		RDMN E 6 A_FaceTarget
		RDMN F 8 A_FaceTarget
		RDMN G 6 A_CustomMeleeAttack(random[DemonAttack1](1,6)*3)
		Goto See
	Missile:
		RDMN E 0 A_JumpIfCloser(300, "Breath")
		RDMN E 0 A_JumpIfHealthLower(250, "MissilePlus")
		RDMN E 0 A_Jump(90, "Missile2")
		RDMN E 3 A_FaceTarget
		RDMN F 4 A_FaceTarget
		RDMN G 0 Bright A_CustomMissile ("RedDemonFX", 64, 0, -8)
		RDMN G 6 Bright A_CustomMissile ("RedDemonFX", 64, 0, 8)
		RDMN G 0 Bright A_CustomMissile ("RedDemonFX", 64, 0, 0)
		Goto See
	Missile2:
		RDMN E 4 A_FaceTarget
		RDMN F 4 Bright A_CustomMissile ("RedDemonFX", 64, 0, -16)
		RDMN G 0 Bright A_FaceTarget
		RDMN G 4 Bright A_CustomMissile ("RedDemonFX", 64, 0, -8)
		RDMN F 0 Bright A_FaceTarget
		RDMN F 4 Bright A_CustomMissile ("RedDemonFX", 64, 0, 0)
		RDMN G 0 Bright A_FaceTarget
		RDMN G 4 Bright A_CustomMissile ("RedDemonFX", 64, 0, 8)
		RDMN F 0 Bright A_FaceTarget
		RDMN F 4 Bright A_CustomMissile ("RedDemonFX", 64, 0, 16)
		RDMN G 0 Bright A_FaceTarget
		RDMN G 4 Bright A_CustomMissile ("RedDemonFX", 64, 0, 32)
		Goto See
	MissilePlus:
		RDMN E 0 A_Jump(90, "MissilePlus2")
		RDMN E 3 A_FaceTarget
		RDMN F 4 A_FaceTarget
		RDMN G 2 Bright A_CustomMissile ("RedDemonFX", 64, 0, random(-8,8))
		RDMN G 2 Bright A_CustomMissile ("RedDemonFX", 64, 0, random(-8,8))
		RDMN G 2 Bright A_CustomMissile ("RedDemonFX", 64, 0, random(-8,8))
		RDMN G 2 Bright A_CustomMissile ("RedDemonFX", 64, 0, random(-8,8))
		RDMN G 2 Bright A_CustomMissile ("RedDemonFX", 64, 0, random(-8,8))
		RDMN G 2 Bright A_CustomMissile ("RedDemonFX", 64, 0, random(-8,8))
		RDMN G 2 Bright A_CustomMissile ("RedDemonFX", 64, 0, random(-8,8))
		RDMN G 2 Bright A_CustomMissile ("RedDemonFX", 64, 0, random(-8,8))
		RDMN G 2 Bright A_CustomMissile ("RedDemonFX", 64, 0, random(-8,8))
		RDMN G 2 Bright A_CustomMissile ("RedDemonFX", 64, 0, random(-8,8))
		RDMN G 2 Bright A_CustomMissile ("RedDemonFX", 64, 0, random(-8,8))
		RDMN G 2 Bright A_CustomMissile ("RedDemonFX", 64, 0, random(-8,8))
		RDMN G 2 Bright A_CustomMissile ("RedDemonFX", 64, 0, random(-8,8))
		Goto See
	MissilePlus2:
		RDMN E 8 A_FaceTarget
		RDMN F 8 A_FaceTarget
		RDMN G 0 Bright A_CustomMissile ("RedDemonFX", 64, 0, -64)
		RDMN G 0 Bright A_CustomMissile ("RedDemonFX", 64, 0, 64)
		RDMN G 0 Bright A_CustomMissile ("RedDemonFX", 64, 0, -56)
		RDMN G 0 Bright A_CustomMissile ("RedDemonFX", 64, 0, 56)
		RDMN G 0 Bright A_CustomMissile ("RedDemonFX", 64, 0, -48)
		RDMN G 0 Bright A_CustomMissile ("RedDemonFX", 64, 0, 48)
		RDMN G 0 Bright A_CustomMissile ("RedDemonFX", 64, 0, -40)
		RDMN G 0 Bright A_CustomMissile ("RedDemonFX", 64, 0, 40)
		RDMN G 0 Bright A_CustomMissile ("RedDemonFX", 64, 0, -32)
		RDMN G 0 Bright A_CustomMissile ("RedDemonFX", 64, 0, 32)
		RDMN G 0 Bright A_CustomMissile ("RedDemonFX", 64, 0, -24)
		RDMN G 0 Bright A_CustomMissile ("RedDemonFX", 64, 0, 24)
		RDMN G 0 Bright A_CustomMissile ("RedDemonFX", 64, 0, -16)
		RDMN G 0 Bright A_CustomMissile ("RedDemonFX", 64, 0, 16)
		RDMN G 0 Bright A_CustomMissile ("RedDemonFX", 64, 0, -8)
		RDMN G 0 Bright A_CustomMissile ("RedDemonFX", 64, 0, 8)
		RDMN G 6 Bright A_CustomMissile ("RedDemonFX", 64, 0, 0)
		Goto See
	Breath:
    	RDMN G 0 bright A_PlaySoundEx("DemonToast", auto)
    	RDMN G 0 bright A_FaceTarget
    	RDMN GGG 2 bright A_CustomMissile("SerpentFireBreath", 64, 0, random(-10,10), CMF_CHECKTARGETDEAD)
    	RDMN G 0 bright A_PlaySoundEx("DemonToast", auto)
    	RDMN G 0 bright A_FaceTarget
    	RDMN GGG 2 bright A_CustomMissile("SerpentFireBreath", 64, 0, random(-10,10), CMF_CHECKTARGETDEAD)
    	RDMN G 0 bright A_PlaySoundEx("DemonToast", auto)
    	RDMN G 0 bright A_FaceTarget
    	RDMN GGG 2 bright A_CustomMissile("SerpentFireBreath", 64, 0, random(-10,10), CMF_CHECKTARGETDEAD)
    	RDMN G 0 bright A_PlaySoundEx("DemonToast", auto)
    	RDMN G 0 bright A_FaceTarget
    	RDMN GGG 2 bright A_CustomMissile("SerpentFireBreath", 64, 0, random(-10,10), CMF_CHECKTARGETDEAD)
    	RDMN G 0 bright A_PlaySoundEx("DemonToast", auto)
    	RDMN G 0 bright A_FaceTarget
    	RDMN GGG 2 bright A_CustomMissile("SerpentFireBreath", 64, 0, random(-10,10), CMF_CHECKTARGETDEAD)
    	goto See
  	Death:
    	RDMN HI 6
    	RDMN J 6 A_Scream
    	RDMN K 6 A_NoBlocking
    	RDMN L 6  A_QueueCorpse
    	RDMN MNO 6
    	RDMN P -1
    	Stop	
  	XDeath:
    	RDMN H 6
    	RDMN I 0 A_SpawnItemEx("MagmaChunk1", 0,0,45, 1+(random[DemonChunks](0,255)*0.015625),
                           1+(random[DemonChunks](0,255)*0.015625), ChunkFlags, 90)
    	RDMN I 0 A_SpawnItemEx("MagmaChunk2", 0,0,45, 1+(random[DemonChunks](0,255)*0.015625),
                           1+(random[DemonChunks](0,255)*0.015625), ChunkFlags, 270)
    	RDMN I 0 A_SpawnItemEx("MagmaChunk3", 0,0,45, 1+(random[DemonChunks](0,255)*0.015625),
                           1+(random[DemonChunks](0,255)*0.015625), ChunkFlags, 270)
    	RDMN I 0 A_SpawnItemEx("MagmaChunk4", 0,0,45, 1+(random[DemonChunks](0,255)*0.015625),
                           1+(random[DemonChunks](0,255)*0.015625), ChunkFlags, 270)
    	RDMN I 6 A_SpawnItemEx("MagmaChunk5", 0,0,45, 1+(random[DemonChunks](0,255)*0.015625),
                           1+(random[DemonChunks](0,255)*0.015625), ChunkFlags, 270)
    	Goto Death+2	
	Ice:
		DEMN Q 5 A_FreezeDeath
		DEMN Q 1 A_FreezeDeathChunks
		Wait
	}
}

ACTOR MagmaChunk1 : DemonChunk
{
  States
  {
  Spawn:
    RDMA A 4
    RDMA A 10
    RDMA A 20
    Wait
  Death:
    RDMA A -1
    Stop
  }
}

ACTOR MagmaChunk2 : DemonChunk
{
  States
  {
  Spawn:
    RDMB A 4
    RDMB A 10
    RDMB A 20
    Wait
  Death:
    RDMB A -1
    Stop
  }
}

ACTOR MagmaChunk3 : DemonChunk
{
  States
  {
  Spawn:
    RDMC A 4
    RDMC A 10
    RDMC A 20
    Wait
  Death:
    RDMC A -1
    Stop
  }
}

ACTOR MagmaChunk4 : DemonChunk
{
  States
  {
  Spawn:
    RDMD A 4
    RDMD A 10
    RDMD A 20
    Wait
  Death:
    RDMD A -1
    Stop
  }
}

ACTOR MagmaChunk5 : DemonChunk
{
  States
  {
  Spawn:
    RDME A 4
    RDME A 10
    RDME A 20
    Wait
  Death:
    RDME A -1
    Stop
  }
}

ACTOR SerpentFireBreath
{
  radius 12
  height 8
  speed 8
  damage 4
  alpha 0.2
  projectile
  -NOBLOCKMAP
  -ACTIVATEIMPACT
  -ACTIVATEPCROSS
  +WINDTHRUST
  +SPAWNSOUNDSOURCE
  +BLOODLESSIMPACT
  +FIREDAMAGE
  RenderStyle Add
  states
  {
  Spawn:
    FRBS EFGEFGEFGEFGEFGEFGEFGEFGEFGEFG 2 bright
  Death:
    FRBS EFG 2 bright
    stop
  }
}

ACTOR RedDemonFX : BeastBall
{
  Speed 15
  Damage 5
  DeathSound "DemonMissileExplode2"
  States
  {
  Spawn:
    RDFX ABC 4 BRIGHT
    Loop
  Death:
    XPL1 A 4 BRIGHT
    XPL1 B 4 BRIGHT A_Explode(16, 64)
    XPL1 CDEF 4 BRIGHT
    Stop
  }
}
