
// ARACHNOTRON
//
ACTOR RLArachnotron : RLArachnotronBase 16411
{
  Health 500
  GibHealth -70
  Radius 58
  Height 56
  
  DamageFactor "Melee", 2
  DamageFactor "Ice", 0.7
  
  PainSound "arachnotron/pain"
  
  Obituary "%o was blasted to ashes by an Arachnotron."
  Tag "Arachnotron"
    //$category "MP Standard"
  
	// Guncaster compatibility
	DropItem "Amber"
	DropItem "Ruby", 192
  States
  {
  Spawn:
    ARAC ACDF Random(9,10) A_Look
    Goto Spawn
  ClearTarget:
    TNT1 A 0 A_ClearTarget
    TNT1 A 0 A_LookEx (LOF_NOSEESOUND, 0, 0, 0, 360, "SeeLoop")
    Goto SeeLoop
	
  See:
    ARAC A 20
  SeeLoop:
    TNT1 A 0 A_PlaySound("baby/walk", CHAN_BODY, 1, 0, 1.25)
    ARAC AABBCC 3 A_Chase ("", "Missile")
    TNT1 A 0 A_PlaySound("baby/walk", CHAN_BODY, 1, 0, 1.25)
    ARAC DDEEFF 3 A_Chase ("", "Missile")
    Goto SeeLoop
	
  MissileProper:
    ARAC AAAA 5 A_FaceTarget
  RepeatProper:
    TNT1 A 0 A_CheckFlag ("FRIENDLY", "SummonMissile") // Friendly monsters do not harm you
    ARAC G 4 Bright A_CustomMissile("RLArachnotronPlasmaBallMkII", 24, 0, 0)
    ARAC H 4 Bright
    ARAC H 1 Bright A_SpidRefire
    Goto RepeatFriendlyCheck
  SummonMissile:
    ARAC G 4 Bright A_CustomMissile("RLSummonArachnotronPlasmaBallMkII", 24, 0, 0)
    ARAC H 4 Bright
    ARAC H 1 Bright A_SpidRefire
    Goto RepeatFriendlyCheck
	
  PainMain:
    ARAC I 3
    ARAC I 3 A_Pain
    Goto SeeLoop
	
  XDeathMain:
  DeathMain:
    TNT1 A 0 A_BossDeath
    TNT1 A 0 A_GiveInventory ("RLArachnotronKillIncrementer", 1, AAPTR_PLAYER1) // Used for tallying total kills and bestiary info
    TNT1 A 0 A_SpawnItemEx ("RLReducedGibber", 0,0,0, VelX,VelY,VelZ, 0, SXF_ABSOLUTEMOMENTUM | SXF_USEBLOODCOLOR | SXF_NOCHECKPOSITION)
    ARAC J 20 A_Scream
    ARAC K 7 A_NoBlocking
    ARAC LMNO 7
    TNT1 A 0 A_SpawnItem ("RLGibThud", 0, 0, 0, 0)
    ARAC P 0
    "####" "#" 0 A_Jump(256, "DeathEnd")
    Goto DeathEnd
  DeathFrame:
    ARAC P 0 A_BossDeath
    "####" "#" 0 A_Jump(256, "DeathEnd")
    Goto DeathEnd
  SimpleXDeathMain:
    TNT1 A 0 A_BossDeath
    TNT1 A 0 A_GiveInventory ("RLArachnotronKillIncrementer", 1, AAPTR_PLAYER1) // Used for tallying total kills and bestiary info
    ARAC J 20 A_Scream
    ARAC K 7 A_NoBlocking
    ARAC LMNO 7
    ARAC P 0
    "####" "#" 0 A_Jump(256, "DeathEnd")
    Goto DeathEnd
	
	//Ice
  GenericFreezeDeath:
	"####" "#" 0 A_GiveInventory ("RLArachnotronKillIncrementer", 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)
    ARAC P 2
    TNT1 A 0 A_ChangeFlag ("NOPAIN", 0)
    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) 
    ARAC P 5
    ARAC ONMLKJ 5
    Goto SeeLoop
  NightmareRaise:
    TNT1 A 0 A_SpawnItemEx ("RLNightmareResurrectionFire", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION) 
    TNT1 A 0 A_Die ("NightmareRemoval")
  Death.NightmareRemoval:
    TNT1 A 0 A_SpawnItemEx ("RLNightmareArachnotronReborn", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION) 
    Stop
  CyberneticRaise:
    TNT1 A 0 A_SpawnItemEx ("RLCyberneticResurrectionSparks", 0, 0, 20, 0, 0, 0, 0, SXF_NOCHECKPOSITION)
    TNT1 A 0 A_Die ("CyberneticRemoval")
  Death.CyberneticRemoval:
    TNT1 A 0 A_SpawnItemEx ("RLCyberneticArachnotronReborn", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION) 
    Stop
	
  CrushDRLA:
    "####" "#" 0 A_BossDeath
    TNT1 A 0 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)
    D2F1 M 2 Bright
    Goto See
  Pain.NeuralStun:
    D2F1 M 2 Bright
    Goto See
  Pain.CyberDisruptor:
    TNT1 A 0
    Goto Pain.LightningBlue
	
  Death.RigelBlast:
    TNT1 A 0 A_BossDeath
    TNT1 A 0 A_GiveInventory ("RLDuke2Score", 1000, AAPTR_TARGET)
    TNT1 A 0 A_GiveInventory ("RLArachnotronKillIncrementer", 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_BossDeath
    TNT1 A 0 A_GiveInventory ("RLDuke2Score", 1000, AAPTR_TARGET)
    TNT1 A 0 A_GiveInventory ("RLArachnotronKillIncrementer", 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  --
//==============================================================================
  ShadowAuraMissileAttack:
    ARAC AAAA 5 A_FaceTarget
  ShadowAuraRepeatAttack:
    ARAC G 2 Bright A_CustomMissile ("RLArachnotronPlasmaBallMkI", 24, 0, frandom(-2.5,2.5), CMF_OFFSETPITCH, frandom(-1,1))
    ARAC H 1 Bright
    ARAC H 0 Bright A_SpidRefire
    Goto RepeatFriendlyCheck
	
//==============================================================================
//					--	Final Doomer Compatibility Stuff  --
//==============================================================================
  DeathXSparkFrame:
    "####" "#" 0 A_JumpIfInTargetInventory("Mana",0,2)
    "####" "#" 0 A_DropItem("MajorManaPod",-1,54)
    ARAC I 0 A_BossDeath
    "####" "#" 0 A_Jump(256, "DeathXSpark")
	Goto DeathXSpark
	
//==============================================================================
//					--	Guncaster Compatibility Stuff  --
//==============================================================================
	MidasFrame1:
		ARAC I 0 A_SpawnItemEx("Midas_Statue_Arach", 0,0,0, 0,0,0, 0,SXF_TRANSFERPOINTERS|SXF_TRANSFERSPRITEFRAME)
		TNT1 A 0 A_JumpIf(1, "DestroyedEnd")
		Goto DestroyedEnd
	MidasFrame2:
		ARAC I 0 A_SpawnItemEx("Midas_Statue_Arach", 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:
		ARAC I 0 A_SpawnItemEx("Midas_Statue_Arach", 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:
		ARAC I 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
		ARAC I 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
		ARAC I 0 A_ChangeFlag("NOPAIN",1)
		"####" "#" 0 A_SetUserVar("User_LightningLock", User_LightningLock + 10)
		"####" "#" 0 A_Jump(256,"BlueLightningLock")
		Goto BlueLightningLock
  }
}

ACTOR RLArachnotronPlasmaBallMkII : ArachnotronPlasma
{
   +NOTIMEFREEZE
   +THRUGHOST
   +BLOODSPLATTER
   Alpha 0.85
   Scale 0.4
   Decal "GreenPlasmaScorch"
   DamageType "Plasma"
   SeeSound "rlmonsters/plasmamkii"
   States
   {
   Spawn:
      PL2B ACBC 4 Bright
      Goto Spawn
   Death:
	  TNT1 A 0 A_SetScale(1)
      PL2B GHIJ 5 Bright
      Stop
   }
}

ACTOR RLArachnotronPlasmaBallMkI
{
  Radius 8
  Height 8
  Speed 25
  Damage 5
  DamageType "Plasma"
  Projectile
  +THRUGHOST
  +NOTIMEFREEZE
  +RANDOMIZE
  +BLOODSPLATTER
  RenderStyle Add 
  Alpha 0.75
  Decal "GreenPlasmaScorch"
  SeeSound "weapons/plasmaf"
  DeathSound "weapons/plasmax"
  States
  {
  Spawn:
    APLS AB 6 Bright
    Loop
  Death:
    APBX ABCDE 4 Bright
    Stop
  }
}

ACTOR RLSummonArachnotronPlasmaBallMkII : RLArachnotronPlasmaBallMkII
{
   +MTHRUSPECIES
}

ACTOR RLDRPGSummonedArachnotron : RLArachnotron
{
  -COUNTKILL
  +AVOIDMELEE
  +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 RLCCArachnotron : RLArachnotron
{
  +TOUCHY
  States
  {
  See:
    ARAC A 20
    ARAC AABBCC 3
    ARAC DDEEFF 3
    Goto See+1
  Missile:
    ARAC A 20
    ARAC G 4 Bright
    ARAC H 5 Bright
    ARAC G 4 Bright
    ARAC H 5 Bright
    ARAC G 4 Bright
    ARAC H 5 Bright
    Goto See
  Melee:
    Stop
  Death:
    ARAC J 20 A_Scream
    ARAC K 7 A_NoBlocking
    ARAC LMNO 7
    ARAC P -1 A_BossDeath
    Stop
  }
}
