
// IMP
//
ACTOR RLImp : RLImpBase 16404
{
  Health 60
  
  DamageFactor "Fire", 0.75
  
  Obituary "%o was burnt by an Imp."
  HitObituary "%o was slashed by an Imp."
  Tag "Imp"
    //$category "MP Standard"
  
	// Guncaster compatibility
	DropItem "Dosh1"
	DropItem "Dosh1", 192
	DropItem "Dosh1", 192
	DropItem "Dosh5", 128
	DropItem "Dosh10", 96
  States
  {
  Spawn:
    TNT1 A 0 A_JumpIfInventory ("RLImpActiveToken", 1, "Wander")
    IMP0 A Random(9,10)
    IMP0 B Random(9,10) A_Look
  SpawnLoop:
    IMP0 AB Random(9,10) A_Look
    Loop
	
  See:
    TNT1 A 0 A_Jump (128, "SeeLoop")
    TNT1 A 0 A_GiveInventory ("RLImpActiveToken", 1)
  SeeLoop:
    IMP0 AABBCCDD 3 A_Chase
    Goto SeeLoop
  Wander:
    TNT1 A 0 A_Look
    IMP0 A 4 A_Wander
    TNT1 A 0 A_Look
    IMP0 A 4 A_Wander
    TNT1 A 0 A_Look
    IMP0 B 4 A_Wander
    TNT1 A 0 A_Look
    IMP0 B 4 A_Wander
    TNT1 A 0 A_Look
    IMP0 C 4 A_Wander
    TNT1 A 0 A_Look
    IMP0 C 4 A_Wander
    TNT1 A 0 A_Look
    IMP0 D 4 A_Wander
    TNT1 A 0 A_Look
    IMP0 D 4 A_Wander
    Loop
	
  MeleeProper:
  MissileProper:
    IMP0 EF 8 A_FaceTarget
    TNT1 A 0 A_CheckFlag ("FRIENDLY", "SummonMissile") // Friendly monsters do not harm you
    IMP0 G 6 A_CustomComboAttack("RLImpFireball", 32, 3 * random(1, 8), "imp/melee")
    Goto SeeLoop
	
  SummonMissile:
    IMP0 G 6 A_CustomComboAttack("RLSummonImpFireball", 32, 3 * random(1, 8), "imp/melee")
    Goto SeeLoop
	
  PainMain:
    IMP0 H 2
    IMP0 H 2 A_Pain
    Goto SeeLoop
	
  DeathMain:
    TNT1 A 0 A_GiveInventory ("RLImpKillIncrementer", 1, AAPTR_PLAYER1) // Used for tallying total kills and bestiary info
    IMP0 I 8
    IMP0 J 8 A_Scream
    IMP0 K 6
    IMP0 L 6 A_NoBlocking
    TNT1 A 0 A_SpawnItem ("RLBodyThud", 0, 0, 0, 0)
    IMP0 M 0
    "####" "#" 0 A_Jump(256, "DeathEnd")
    Goto DeathEnd
  DeathFrame:
    IMP0 M 0
    "####" "#" 0 A_Jump(256, "DeathEnd")
    Goto DeathEnd
	
  XDeathMain:
    TNT1 A 0 A_GiveInventory ("RLImpKillIncrementer", 1, AAPTR_PLAYER1) // Used for tallying total kills and bestiary info
    TNT1 A 0 A_SpawnItemEx ("RLGibber", 0,0,0, VelX,VelY,VelZ, 0, SXF_ABSOLUTEMOMENTUM | SXF_USEBLOODCOLOR | SXF_NOCHECKPOSITION)
    IMP0 N 5
    IMP0 O 5 A_XScream
    IMP0 P 5
    IMP0 Q 5 A_NoBlocking
    IMP0 R 5
    TNT1 A 0 A_SpawnItem ("RLGibThud", 0, 0, 0, 0)
    IMP0 ST 5
    IMP0 U 0
    "####" "#" 0 A_Jump(256, "XDeathEnd")
    Goto XDeathEnd
  SimpleXDeathMain:
    TNT1 A 0 A_GiveInventory ("RLImpKillIncrementer", 1, AAPTR_PLAYER1) // Used for tallying total kills and bestiary info
    IMP0 N 5
    IMP0 O 5 A_XScream
    IMP0 P 5
    IMP0 Q 5 A_NoBlocking
    IMP0 R 5
    IMP0 ST 5
    IMP0 U 0
    "####" "#" 0 A_Jump(256, "XDeathEnd")
    Goto XDeathEnd
	
	//Ice
  GenericFreezeDeath:
	"####" "#" 0 A_GiveInventory ("RLImpKillIncrementer", 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)
    IMP0 M 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) 
    TNT1 A 0 A_TakeInventory ("RLImpActiveToken", 1)
    IMP0 MLKJI 8
    Goto See
  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 ("RLNightmareImpReborn", 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 ("RLCyberneticImpReborn", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION) 
    Stop
	
  CrushDRLA:
    TNT1 A 0 A_SpawnItemEx("RLCrushedSmall",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 H 2 Bright
    Goto See
  Pain.NeuralStun:
    D2F1 H 2 Bright
    Goto See
	
  Death.NeuralStun:
    TNT1 A 0 A_GiveInventory ("RLImpKillIncrementer", 1, AAPTR_PLAYER1) // Used for tallying total kills and bestiary info
    TNT1 A 0 A_NoBlocking
    TNT1 A 0 A_SpawnItemEx ("RLNeuralStunStars", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER)
    TNT1 A 0 A_Stop
    TNT1 A 0 ThrustThingZ (0, 20, 0, 0)
    CKD1 D -1
    Stop
  Death.RigelBlast:
    TNT1 A 0 A_GiveInventory ("RLDuke2Score", 200, AAPTR_TARGET)
    TNT1 A 0 A_GiveInventory ("RLImpKillIncrementer", 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", 200, AAPTR_TARGET)
    TNT1 A 0 A_GiveInventory ("RLImpKillIncrementer", 1, AAPTR_PLAYER1) // Used for tallying total kills and bestiary info
    TNT1 A 0 A_GiveInventory ("RLMonsterKillIncrementer", 1, AAPTR_PLAYER1) // Used for tallying total kills of all enemies
    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:
  ShadowAuraMissileAttack:
    IMP0 EF 8 A_FaceTarget
    TNT1 AAAA 0 A_CustomMissile ("RLImpFireball", 32, 0, frandom(-5,5), CMF_OFFSETPITCH, frandom(-5,5))
    IMP0 G 8 A_CustomComboAttack("RLImpFireball", 32, 3 * random(1, 8), "imp/melee")
    IMP0 F 4 A_FaceTarget
    Goto SeeLoop
	
//==============================================================================
//					--	Final Doomer Compatibility Stuff  --
//==============================================================================
  DeathXSparkFrame:
    "####" "#" 0 A_JumpIfInTargetInventory("Mana",0,2)
    "####" "#" 0 A_DropItem("MinorManaPod",-1,54)
    IMP0 H 0
    "####" "#" 0 A_Jump(256, "DeathXSpark")
	Goto DeathXSpark
	
//==============================================================================
//					--	Guncaster Compatibility Stuff  --
//==============================================================================
	MidasFrame1:
		IMP0 H 0 A_SpawnItemEx("Midas_Statue_Pimp", 0,0,0, 0,0,0, 0,SXF_TRANSFERPOINTERS|SXF_TRANSFERSPRITEFRAME)
		TNT1 A 0 A_JumpIf(1, "DestroyedEnd")
		Goto DestroyedEnd
	MidasFrame2:
		IMP0 H 0 A_SpawnItemEx("Midas_Statue_Pimp", 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:
		IMP0 H 0 A_SpawnItemEx("Midas_Statue_Pimp", 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:
		IMP0 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
		IMP0 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
		IMP0 H 0 A_ChangeFlag("NOPAIN",1)
		"####" "#" 0 A_SetUserVar("User_LightningLock", User_LightningLock + 10)
		"####" "#" 0 A_Jump(256,"BlueLightningLock")
		Goto BlueLightningLock
  }
}

Actor RLImpActiveToken : Inventory
{
inventory.maxamount 1
}

ACTOR RLImpFireball : DoomImpBall
{
   +NOTIMEFREEZE
   +THRUGHOST
   +BLOODSPLATTER
   Decal "DoomImpScorch"
   DamageType "Fire"
   PainType "SmallFireball"
   DeathType "SmallFireball"
  States
  {
  Spawn:
    BAL1 AB 4 Bright
    Goto Spawn
//  Death:
//    BAL1 CDE 6 Bright
//    Stop
  }
}

ACTOR RLSummonImpFireball : RLImpFireball
{
   +MTHRUSPECIES
}

ACTOR RLDRPGSummonedImp : RLImp
{
  -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 RLCCImp : RLImp
{
  +TOUCHY
  States
  {
  Spawn:
    IMP0 AB 10
    Loop
  See:
    IMP0 AABBCCDD 3
    Loop
  Melee:
    IMP0 EF 8
    IMP0 G 6
    Goto See
  Missile:
    IMP0 EF 8
    IMP0 G 6
    Goto See
  Death:
    IMP0 I 8
    IMP0 J 8 A_Scream
    IMP0 K 6
    IMP0 L 6 A_NoBlocking
    IMP0 M -1
    Stop
  }
}
