
// MECHTRE
//
ACTOR RLCyberneticSpectre : RLDemonBase 16540
{
  Health 400
  GibHealth -70
  BloodType "RLNashGore_CyberBlood", "RLMNullActor", "RLNashGore_SlashBlood"
  
  PainChance 180
  PainChance "Plasma", 256
  
  RenderStyle "Translucent"
  Alpha 0
  
  SeeSound "mechdemon/sight"
  PainSound "technolord/pain"
  DeathSound "mechdemon/death"
  ActiveSound "technolord/active"
  
  Obituary "%o felt the cold steel of a Mechtre's bite."
  Tag "Mechtre"
    //$category "MP Technophobia"
  
	// Guncaster compatibility
	DropItem "Dosh1"
	DropItem "Dosh1"
	DropItem "Dosh1", 128
	DropItem "Dosh25"
  States
  {
  Spawn:
    CSPE AB Random(9,10) A_Look
    Loop
	
  See:
    TNT1 A 0 A_JumpIfHealthLower (200,"HurtSee")
    TNT1 A 0 A_Jump (250,3)
    TNT1 A 0 A_SpawnItemEx ("RLMechtreElectricDischarge", 0, 0, random(10, 20), 0, 0, 0, 0, SXF_NOCHECKPOSITION) 
    TNT1 A 0 A_SetTranslucent (1,0)
    TNT1 A 0 A_JumpIfHealthLower (200,"HurtSee")
    TNT1 A 0 A_FadeTo (0,0.1)
    CSPE A 2 Fast A_Chase ("Melee", "")
    TNT1 A 0 A_Jump (250,3)
    TNT1 A 0 A_SpawnItemEx ("RLMechtreElectricDischarge", 0, 0, random(10, 20), 0, 0, 0, 0, SXF_NOCHECKPOSITION) 
    TNT1 A 0 A_SetTranslucent (1,0)
    TNT1 A 0 A_JumpIfHealthLower (200,"HurtSee")
    TNT1 A 0 A_FadeTo (0,0.1)
    CSPE A 2 Fast A_Chase ("Melee", "")
    TNT1 A 0 A_Jump (250,3)
    TNT1 A 0 A_SpawnItemEx ("RLMechtreElectricDischarge", 0, 0, random(10, 20), 0, 0, 0, 0, SXF_NOCHECKPOSITION) 
    TNT1 A 0 A_SetTranslucent (1,0)
    TNT1 A 0 A_JumpIfHealthLower (200,"HurtSee")
    TNT1 A 0 A_FadeTo (0,0.1)
    CSPE B 2 Fast A_Chase ("Melee", "")
    TNT1 A 0 A_Jump (250,3)
    TNT1 A 0 A_SpawnItemEx ("RLMechtreElectricDischarge", 0, 0, random(10, 20), 0, 0, 0, 0, SXF_NOCHECKPOSITION) 
    TNT1 A 0 A_SetTranslucent (1,0)
    TNT1 A 0 A_JumpIfHealthLower (200,"HurtSee")
    TNT1 A 0 A_FadeTo (0,0.1)
    CSPE B 2 Fast A_Chase ("Melee", "")
    TNT1 A 0 A_PlaySound("mechdemon/walk", 7, 1, 0, 1.25)
    TNT1 A 0 A_Jump (250,3)
    TNT1 A 0 A_SpawnItemEx ("RLMechtreElectricDischarge", 0, 0, random(10, 20), 0, 0, 0, 0, SXF_NOCHECKPOSITION) 
    TNT1 A 0 A_SetTranslucent (1,0)
    TNT1 A 0 A_JumpIfHealthLower (200,"HurtSee")
    TNT1 A 0 A_FadeTo (0,0.1)
    CSPE C 2 Fast A_Chase ("Melee", "")
    TNT1 A 0 A_Jump (250,3)
    TNT1 A 0 A_SpawnItemEx ("RLMechtreElectricDischarge", 0, 0, random(10, 20), 0, 0, 0, 0, SXF_NOCHECKPOSITION) 
    TNT1 A 0 A_SetTranslucent (1,0)
    TNT1 A 0 A_JumpIfHealthLower (200,"HurtSee")
    TNT1 A 0 A_FadeTo (0,0.1)
    CSPE C 2 Fast A_Chase ("Melee", "")
    TNT1 A 0 A_Jump (250,3)
    TNT1 A 0 A_SpawnItemEx ("RLMechtreElectricDischarge", 0, 0, random(10, 20), 0, 0, 0, 0, SXF_NOCHECKPOSITION) 
    TNT1 A 0 A_SetTranslucent (1,0)
    TNT1 A 0 A_JumpIfHealthLower (200,"HurtSee")
    TNT1 A 0 A_FadeTo (0,0.1)
    CSPE D 2 Fast A_Chase ("Melee", "")
    TNT1 A 0 A_Jump (250,3)
    TNT1 A 0 A_SpawnItemEx ("RLMechtreElectricDischarge", 0, 0, random(10, 20), 0, 0, 0, 0, SXF_NOCHECKPOSITION) 
    TNT1 A 0 A_SetTranslucent (1,0)
    TNT1 A 0 A_JumpIfHealthLower (200,"HurtSee")
    TNT1 A 0 A_FadeTo (0,0.1)
    CSPE D 2 Fast A_Chase ("Melee", "")
    TNT1 A 0 A_PlaySound("mechdemon/walk", 7, 1, 0, 1.25)
    Loop
  HurtSee:
    TNT1 A 0 A_SetTranslucent (1,0)
    TNT1 A 0 A_PlaySound("mechdemon/walk", 7, 1, 0, 1.25)
    CSPE AABB 2 Fast A_Chase ("Melee", "")
    TNT1 A 0 A_PlaySound("mechdemon/walk", 7, 1, 0, 1.25)
    CSPE CCDD 2 Fast A_Chase ("Melee", "")
    Loop
	
  MeleeProper:
    TNT1 A 0 A_PlaySound("mechdemon/attack", CHAN_VOICE)
    CSPE E 8 Fast A_FaceTarget
    TNT1 A 0 A_SetTranslucent (1,0)
    TNT1 A 0 A_JumpIfHealthLower (200,2)
    TNT1 A 0 A_SpawnItemEx ("RLMechtreElectricDischarge", 0, 0, random(10, 20), 0, 0, 0, 0, SXF_NOCHECKPOSITION) 
    CSPE F 8 Fast A_FaceTarget
    CSPE G 8 Fast A_CustomMeleeAttack (5 * random(1, 10), "", "", "Melee")
    Goto See
	
  PainMain:
    TNT1 A 0 A_SetTranslucent (1,0)
    TNT1 A 0 A_JumpIfHealthLower (200,2)
    TNT1 A 0 A_SpawnItemEx ("RLMechtreElectricDischarge", 0, 0, random(10, 20), 0, 0, 0, 0, SXF_NOCHECKPOSITION) 
    CSPE H 2 Fast
    CSPE H 2 Fast A_Pain
    Goto See
	
  XDeathMain:
  DeathMain:
    TNT1 A 0 A_GiveInventory ("RLCyberneticSpectreKillIncrementer", 1, AAPTR_PLAYER1) // Used for tallying total kills and bestiary info
    TNT1 A 0 A_SetTranslucent (1,0)
    CSPE I 8
    CSPE J 8 A_Scream
    CSPE K 4
    CSPE L 4 A_NoBlocking
    TNT1 A 0 A_SpawnItem ("RLBodyThud", 0, 0, 0, 0)
    CSPE M 4
    CSPE N 0
    "####" "#" 0 A_Jump(256, "DeathEnd")
    Goto DeathEnd
  SimpleXDeathMain:
    TNT1 A 0 A_GiveInventory ("RLCyberneticSpectreKillIncrementer", 1, AAPTR_PLAYER1) // Used for tallying total kills and bestiary info
    TNT1 A 0 A_SetTranslucent (1,0)
    CSPE I 8
    CSPE J 8 A_Scream
    CSPE K 4
    CSPE L 4 A_NoBlocking
    CSPE M 4
    CSPE N 0
    "####" "#" 0 A_Jump(256, "DeathEnd")
    Goto DeathEnd
  DeathFrame:
    CSPE N 0
    "####" "#" 0 A_Jump(256, "DeathEnd")
    Goto DeathEnd
	
	//Ice
  GenericFreezeDeath:
	"####" "#" 0 A_GiveInventory ("RLCyberneticSpectreKillIncrementer", 1, AAPTR_PLAYER1) // Used for tallying total kills and bestiary info
    "####" "#" 0 A_Jump(256, "GenericFreezeMana")
    Goto GenericFreezeMana
	
  Raise:
	TNT1 A 0 ACS_NamedExecuteAlways("DRLA_Normalization") // Removes any palette abnormalities
	TNT1 A 0 A_SetScale(1) // resets altered enemies to default, make sure to match the scale factor in properties here!
    TNT1 A 0 A_ChangeFlag ("NOBLOCKMAP", 0)
    TNT1 A 0 A_ChangeFlag ("NOPAIN", 1)
    CSPE N 2
    TNT1 A 0 A_JumpIfInventory ("RLNightmareResurrectionToken", 1, "NightmareRaise")
    TNT1 A 0 A_JumpIfInventory ("RLCyberneticResurrectionToken", 1, "CyberneticRaise")
    TNT1 A 0 A_SpawnItemEx ("RLResurrectionFire", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION)
  RaiseContinue:
    TNT1 A 0 A_ChangeFlag ("NOPAIN", 0)
    CSPE NMLKJI 5
    Goto See
  NightmareRaise:
    TNT1 A 0 A_SpawnItemEx ("RLNightmareResurrectionFire", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION) 
    Goto RaiseContinue
  CyberneticRaise:
    TNT1 A 0 A_SpawnItemEx ("RLCyberneticResurrectionSparks", 0, 0, 20, 0, 0, 0, 0, SXF_NOCHECKPOSITION)
    Goto RaiseContinue
	
  CrushDRLA:
    TNT1 A 30 A_SpawnItemEx("RLCrushedMedium",0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION)
    "####" "#" 0 A_Jump(256, "CrushEnd")
    Goto CrushEnd
//==============================================================================
//					--	DOOMRL ARSENAL STUFF  --
//==============================================================================
  Pain.RigelBlast:
    TNT1 A 0 A_PlaySound("weapons/dn2gunhit", CHAN_BODY)
    D2F2 J 2 Bright
    Goto See
  Pain.NeuralStun:
    D2F2 J 2 Bright
    Goto See
  Pain.CyberDisruptor:
    TNT1 A 0
    Goto Pain.LightningBlue
	
  Death.NeuralStun:
    TNT1 A 0
    Goto Death
  Death.RigelBlast:
    TNT1 A 0 A_GiveInventory ("RLDuke2Score", 800, AAPTR_TARGET)
    TNT1 A 0 A_GiveInventory ("RLCyberneticSpectreKillIncrementer", 1, AAPTR_PLAYER1) // Used for tallying total kills and bestiary info
    TNT1 A 0 A_PlaySound("weapons/dn2gunexplosion", CHAN_BODY)
    TNT1 A 0 A_NoBlocking
    TNT1 A 0 A_SpawnItemEx ("RLDuke2BasicEnemyExplosions", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION)
    TNT1 A 35
    Stop
  XDeath.RigelBlast:
	TNT1 A 0 A_JumpIf(CallACS("DRLA_Gibs"), 1)
	Goto Death.RigelBlast
    TNT1 A 0 A_GiveInventory ("RLDuke2Score", 800, AAPTR_TARGET)
    TNT1 A 0 A_GiveInventory ("RLCyberneticSpectreKillIncrementer", 1, AAPTR_PLAYER1) // Used for tallying total kills and bestiary info
    TNT1 A 0 A_PlaySound("weapons/dn2gungib", CHAN_BODY)
    TNT1 A 0 A_NoBlocking
    TNT1 A 0 A_SpawnItemEx ("RLDuke2BasicEnemyExplosions", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION)
    TNT1 A 0 A_SpawnItemEx ("RLDuke2RedGibber", 0,0,0, VelX,VelY,VelZ, 0, SXF_ABSOLUTEMOMENTUM | SXF_NOCHECKPOSITION)
    TNT1 A 35
    Stop
	
//==============================================================================
//					--	Special Monster Attacks  --
//==============================================================================
  ShadowAuraMeleeAttack:
    TNT1 A 0 A_PlaySound("mechdemon/attack", CHAN_VOICE)
    CSPE EF 3 A_FaceTarget
    CSPE G 3 A_CustomMeleeAttack (3 * random(1, 10), "", "", "Melee")
    Goto See
	
//==============================================================================
//					--	Final Doomer Compatibility Stuff  --
//==============================================================================
  DeathXSparkFrame:
    "####" "#" 0 A_JumpIfInTargetInventory("Mana",0,2)
    "####" "#" 0 A_DropItem("MinorManaPod",-1,54)
    CSPE H 0
    "####" "#" 0 A_Jump(256, "DeathXSpark")
	Goto DeathXSpark
	
//==============================================================================
//					--	Guncaster Compatibility Stuff  --
//==============================================================================
	MidasFrame1:
		CSPE H 0 A_SpawnItemEx("Midas_Statue_Demon", 0,0,0, 0,0,0, 0,SXF_TRANSFERPOINTERS|SXF_TRANSFERSPRITEFRAME)
		TNT1 A 0 A_JumpIf(1, "DestroyedEnd")
		Goto DestroyedEnd
	MidasFrame2:
		CSPE H 0 A_SpawnItemEx("Midas_Statue_Demon", 0,0,0, frandom(-10.0,-12.0),0,frandom(1.0,3.0), 0,SXF_TRANSFERPOINTERS|SXF_SETMASTER|SXF_TRANSFERSPRITEFRAME)
		TNT1 A 10 A_KillChildren
		TNT1 A 0 A_JumpIf(1, "DestroyedEnd")
		Goto DestroyedEnd
	MidasFrame3:
		CSPE H 0 A_SpawnItemEx("Midas_Statue_Demon", 0,0,0, frandom(-15.0,-20.0),0,frandom(10.0,15.0), 0,SXF_TRANSFERPOINTERS|SXF_SETMASTER|SXF_TRANSFERSPRITEFRAME)
		TNT1 A 10 A_KillChildren
		TNT1 A 0 A_JumpIf(1, "DestroyedEnd")
		Goto DestroyedEnd
		
	//Gumpop
	Death.Acid:
		CSPE H 1 A_ChangeFlag("SOLID",0)
		"####" "#" 1 A_Playsound("Gumpop/Expand",5)
		"####" "###################################" 1 A_SetScale(ScaleX+frandom(0.01,0.025))
		"####" "#" 1 A_Playsound("Gumpop/Pop",5)
		"####" "#" 0 A_Jump(256,"XDeathMain")
		Goto XDeathMain
		
	//Thunderstruck
	Pain.Lightning:
		"####" "#" 0 A_Jump(164,1)
		Goto Pain
		CSPE H 0 A_ChangeFlag("NOPAIN",1)
		"####" "#" 0 A_SetUserVar("User_LightningLock", User_LightningLock + 10)
		"####" "#" 0 A_Jump(256,"LightningLock")
		Goto LightningLock
		
	//Cauterizer
	Pain.LightningBlue:
		"####" "#" 0 A_Jump(48,1)
		Goto Pain
		CSPE H 0 A_ChangeFlag("NOPAIN",1)
		"####" "#" 0 A_SetUserVar("User_LightningLock", User_LightningLock + 10)
		"####" "#" 0 A_Jump(256,"BlueLightningLock")
		Goto BlueLightningLock
  }
}

ACTOR RLMechtreElectricDischarge
{
  Radius 8
  Height 8
  +NOGRAVITY
  Alpha 0.3
  RenderStyle Add
  Scale 1.2
  States
  {
  Spawn:
    TNT1 A 0
    TNT1 A 0 A_PlaySound("mechtre/cloakshort", 6)
  Zap1:
    TNT1 A 0 A_Jump (256,1,2,3)
    CZAP A 1 Bright
    Goto Zap2
    CZAP B 1 Bright
    Goto Zap2
    CZAP C 1 Bright
    Goto Zap2
  Zap2:
    TNT1 A 0 A_Jump (256,1,2,3)
    CZAP D 1 Bright
    Goto Zap3
    CZAP E 1 Bright
    Goto Zap3
    CZAP F 1 Bright
    Goto Zap3
  Zap3:
    TNT1 A 0 A_Jump (256,1,2,3)
    CZAP A 1 Bright
    Goto Zap4
    CZAP B 1 Bright
    Goto Zap4
    CZAP C 1 Bright
    Goto Zap4
  Zap4:
    TNT1 A 0 A_Jump (256,1,2,3)
    CZAP D 1 Bright
    Stop
    CZAP E 1 Bright
    Stop
    CZAP F 1 Bright
    Stop
  }
}

ACTOR RLCyberneticSpectreReborn : RLCyberneticSpectre
{
  +LOOKALLAROUND
  +NOPAIN
  States
  {
  Spawn:
    TNT1 A 0 NoDelay A_JumpIfInventory("RLResurrectionComplete", 1, "SpawnNormal")
    CSPE NMLKJI 5
    TNT1 A 0 A_ChangeFlag("NOPAIN", 0)
    TNT1 A 0 A_GiveInventory("RLResurrectionComplete", 1)
  SpawnNormal:
    CSPE AB 10 A_Look
    Loop
  }
}

ACTOR RLDRPGSummonedCyberneticSpectre : RLCyberneticSpectre
{
  -COUNTKILL
  +NOBLOCKMONST
  +NOTELESTOMP
  +NOFEAR
  +SEEINVISIBLE
  +DONTDRAIN
  +ALWAYSFAST
  +QUICKTORETALIATE
  +MISSILEMORE
  +THRUSPECIES
  Species "Player"
  States
  {
  Spawn:
	TNT1 A 0 NoDelay ACS_NamedExecuteAlways("MonsterInit", 0)
    TNT1 A 0 A_GiveInventory ("RLMonsterInitializerToken", 1)
    TNT1 A 0 A_GiveInventory ("DRPGDRLASummonedMonsterToken", 1)
	Goto Super::Spawn
	See:
	TNT1 A 0 ACS_NamedExecuteAlways("MonsterInit", 0)
    TNT1 A 0 A_GiveInventory ("RLMonsterInitializerToken", 1)
    TNT1 A 0 A_GiveInventory ("DRPGDRLASummonedMonsterToken", 1)
	Goto Super::See
  Raise:
    Stop
  }
}

ACTOR RLCCCyberneticSpectre : RLCyberneticSpectre
{
  Alpha 0.8
  +TOUCHY
  States
  {
  See:
    CSPE AABBCCDD 2
    Loop
  Missile:
    Stop
  Melee:
    CSPE EF 8
    CSPE G 8
    Goto See
  Death:
    CSPE I 8
    CSPE J 8 A_Scream
    CSPE K 4
    CSPE L 4 A_NoBlocking
    CSPE M 4
    CSPE N -1
    Stop
  }
}
