
// FORMER HUMAN SERGEANT
//
ACTOR RLFormerSergeantCombatShotgun : RLShotgunGuyBase
{
  Health 30
  
  Obituary "%o was blatted by a Former Human Sergeant."
  Tag "Former Sergeant [Combat Shotgun]"
    //$category "MP Standard"
  
	DropItem "RLFormerSergeantCombatShotgunDrop"
	// Guncaster compatibility
	DropItem "Dosh1"
	DropItem "Dosh1"
	DropItem "Dosh1", 192
	DropItem "Dosh1", 192
	DropItem "Dosh10", 128
  States
  {
  Spawn:
    ZSSH AB Random(9,10) A_Look
    Loop
	
  See:
    TNT1 A 0 A_JumpIfInventory ("RLFormerSergeantCombatShotgunShotCounter", 5, "RetreatReload")
    ZSSH AABBCCDD 3 A_Chase ("", "Missile")
    Loop
  RetreatReload:
    TNT1 A 0 A_ChangeFlag ("FRIGHTENED", 1)
    ZSSH AA 3 A_Wander
    TNT1 A 0 A_JumpIfCloser (180, 2)
    TNT1 A 0 A_Jump (32, "Reload")
    ZSSH BB 3 A_Wander
    TNT1 A 0 A_JumpIfCloser (180, 2)
    TNT1 A 0 A_Jump (32, "Reload")
    ZSSH CC 3 A_Wander
    TNT1 A 0 A_JumpIfCloser (180, 2)
    TNT1 A 0 A_Jump (32, "Reload")
    ZSSH DD 3 A_Wander
    TNT1 A 0 A_JumpIfCloser (180, 2)
    TNT1 A 0 A_Jump (32, "Reload")
    TNT1 A 0
    Goto RetreatReload+1

  MissileProper:
    ZSSH E 10 A_FaceTarget
    TNT1 A 0 A_JumpIfInventory ("RLFormerSergeantCombatShotgunShotCounter", 5, "RetreatReload")
    TNT1 A 0 A_JumpIfInventory ("RLFormerSergeantCombatShotgunPumpCounter", 1, "Pump")
    TNT1 A 0 A_GiveInventory ("RLFormerSergeantCombatShotgunShotCounter", 1)
    TNT1 A 0 A_GiveInventory ("RLFormerSergeantCombatShotgunPumpCounter", 1)
    TNT1 A 0 A_PlaySound("rlmonsters/combatshotgun", CHAN_WEAPON, 1, 0, 0.75)
    TNT1 A 0 A_PlaySound("rlmonsters/combatshotgun", CHAN_ITEM, 0.05, 0, 0.20)
    TNT1 AA 0 A_CustomBulletAttack (22.5, 0, 1, random(1,5)*2, "RLEnemyBulletPuff", 0, CBAF_NORANDOM)
    ZSSH F 7 Bright A_CustomBulletAttack (22.5, 0, 1, random(1,5)*2, "RLEnemyBulletPuff", 0, CBAF_NORANDOM)
    ZSSH E 4
    TNT1 A 0 A_JumpIfInventory ("RLFormerSergeantCombatShotgunShotCounter", 5, "RetreatReload")
    Goto Pump
  Pump:
    ZSSH V 3 A_FaceTarget
    TNT1 A 0 A_TakeInventory ("RLFormerSergeantCombatShotgunPumpCounter", 1)
    TNT1 A 0 A_PlaySound("rlmonsters/combatshotgunpump", 7)
    ZSSH W 3 A_FaceTarget
    ZSSH V 3 A_FaceTarget
    Goto See
	
  Reload:
    ZSSH VV 3
    TNT1 A 0 A_PlaySound("rlmonsters/combatshotgunload", 7)
    TNT1 A 0 A_TakeInventory ("RLFormerSergeantCombatShotgunShotCounter", 1)
    ZSSH VV 5
    TNT1 A 0 A_JumpIfInventory ("RLFormerSergeantCombatShotgunShotCounter", 1, 1)
    Goto ReloadFinish
    TNT1 A 0
    Goto Reload+2
  ReloadFinish:
    TNT1 A 0 A_JumpIfInventory ("RLFormerSergeantCombatShotgunPumpCounter", 1, "Pump")
    ZSSH VE 4
    Goto See
	
  PainMain:
    ZSSH G 3
    ZSSH G 3 A_Pain
    Goto See
	
  DeathMain:
    TNT1 A 0 A_GiveInventory ("RLFormerSergeantKillIncrementer", 1, AAPTR_PLAYER1) // Used for tallying total kills and bestiary info
    TNT1 A 0 A_Jump(128, "Death2")
    ZSSH H 5
    ZSSH I 5 A_Scream
    ZSSH J 5 A_NoBlocking
    ZSSH K 5
    TNT1 A 0 A_SpawnItem ("RLBodyThud", 0, 0, 0, 0)
    ZSSH L 0
    "####" "#" 0 A_Jump(256, "DeathEnd")
    Goto DeathEnd
  Death2:
    ZSS2 A 8
    ZSS2 B 8 A_Scream
    ZSS2 C 8 A_NoBlocking
    ZSS2 D 8
    TNT1 A 0 A_SpawnItem ("RLBodyThud", 0, 0, 0, 0)
    ZSS2 E 0
    "####" "#" 0 A_Jump(256, "DeathEnd")
    Goto DeathEnd
  DeathFrame:
    ZSS2 L 0
    "####" "#" 0 A_Jump(256, "DeathEnd")
    Goto DeathEnd
	
  XDeathMain:
    TNT1 A 0 A_GiveInventory ("RLFormerSergeantKillIncrementer", 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)
    ZSSH M 5
    ZSSH N 5 A_XScream
    ZSSH O 5 A_NoBlocking
    ZSSH PQ 5
    TNT1 A 0 A_SpawnItem ("RLGibThud", 0, 0, 0, 0)
    ZSSH RST 5
    ZSSH U 0
    "####" "#" 0 A_Jump(256, "XDeathEnd")
    Goto XDeathEnd
  SimpleXDeathMain:
    TNT1 A 0 A_GiveInventory ("RLFormerSergeantKillIncrementer", 1, AAPTR_PLAYER1) // Used for tallying total kills and bestiary info
    ZSSH M 5
    ZSSH N 5 A_XScream
    ZSSH O 5 A_NoBlocking
    ZSSH PQ 5
    ZSSH RST 5
    ZSSH U 0
    "####" "#" 0 A_Jump(256, "XDeathEnd")
    Goto XDeathEnd
	
	//Ice
  GenericFreezeDeath:
	"####" "#" 0 A_GiveInventory ("RLFormerSergeantKillIncrementer", 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)
    ZSSH L 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_JumpIfInventory ("RLCyberneticResurrectionToken", 1, 2)
    TNT1 A 0 A_ChangeFlag ("NOPAIN", 0)
    TNT1 A 0 A_TakeInventory ("RLFormerSergeantCombatShotgunShotCounter", 5)
    ZSSH K 5
    ZSSH J 5
    ZSSH I 5
    ZSSH H 5
    Goto See
  NightmareRaise:
    TNT1 A 0 A_SpawnItemEx ("RLNightmareResurrectionFire", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION) 
    TNT1 A 0 A_ChangeFlag ("ALWAYSFAST", 1)
    Goto RaiseContinue
  CyberneticRaise:
    TNT1 A 0 A_SpawnItemEx ("RLCyberneticResurrectionSparks", 0, 0, 20, 0, 0, 0, 0, SXF_NOCHECKPOSITION)
    TNT1 A 0 A_ChangeFlag ("NOPAIN", 1) 
    TNT1 A 0 A_ChangeFlag ("SEEINVISIBLE", 1)
    TNT1 A 0 A_ChangeFlag ("MISSILEMORE", 1)
    Goto RaiseContinue
	
  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 D 2 Bright
    Goto See
  Pain.NeuralStun:
    D2F1 D 2 Bright
    Goto See
	
  Death.NeuralStun:
    TNT1 A 0 A_GiveInventory ("RLFormerSergeantKillIncrementer", 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 B -1
    Stop
  Death.RigelBlast:
    TNT1 A 0 A_GiveInventory ("RLDuke2Score", 200, AAPTR_TARGET)
    TNT1 A 0 A_GiveInventory ("RLFormerSergeantKillIncrementer", 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 ("RLFormerSergeantKillIncrementer", 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  --
//==============================================================================
  Duke2LaserAttack:
    ZSSH E 10 A_FaceTarget
    TNT1 A 0 A_CustomMissile ("RLDuke2EnemyBasicShot", 30, 12, frandom(-16,-14), CMF_OFFSETPITCH, frandom(-1,1))
    TNT1 A 0 A_CustomMissile ("RLDuke2EnemyBasicShot", 30, 12, frandom(14,16), CMF_OFFSETPITCH, frandom(-1,1))
    ZSSH F 10 Bright A_CustomMissile ("RLDuke2EnemyBasicShot", 30, 12, frandom(-1,1), CMF_OFFSETPITCH, frandom(-1,1))
    ZSSH E 10
    Goto See
	
  ShadowAuraMissileAttack:
    ZSSH E 15 A_FaceTarget
    TNT1 A 0 A_JumpIfInventory ("RLFormerSergeantCombatShotgunShotCounter", 5, "Reload")
    TNT1 A 0 A_JumpIfInventory ("RLFormerSergeantCombatShotgunPumpCounter", 1, "Pump")
    TNT1 A 0 A_GiveInventory ("RLFormerSergeantCombatShotgunShotCounter", 1)
    TNT1 A 0 A_GiveInventory ("RLFormerSergeantCombatShotgunPumpCounter", 1)
    TNT1 A 0 A_PlaySound("rlmonsters/plascombatshotgun", CHAN_WEAPON, 1, 0, 0.7)
    TNT1 A 0 A_PlaySound("rlmonsters/plascombatshotgun", CHAN_ITEM, 0.05, 0, 0.20)
    TNT1 AA 0 A_CustomBulletAttack (11, 0, 1, random(1,5)*2, "RLEnemyPlasmaticPuff", 0, CBAF_NORANDOM)
    ZSSH F 7 Bright A_CustomBulletAttack (11, 0, 1, random(1,5)*2, "RLEnemyPlasmaticPuff", 0, CBAF_NORANDOM)
    ZSSH E 4
    TNT1 A 0 A_JumpIfInventory ("RLFormerSergeantCombatShotgunShotCounter", 5, "Reload")
    Goto Pump
	
//==============================================================================
//					--	Final Doomer Compatibility Stuff  --
//==============================================================================
  DeathXSparkFrame:
    "####" "#" 0 A_JumpIfInTargetInventory("Mana",0,2)
    "####" "#" 0 A_DropItem("MinorManaPod",-1,54)
    ZSSH G 0
    "####" "#" 0 A_Jump(256, "DeathXSpark")
	Goto DeathXSpark
	
//==============================================================================
//					--	Guncaster Compatibility Stuff  --
//==============================================================================
	MidasFrame1:
		ZSSH G 0 A_SpawnItemEx("Midas_Statue_ShotgunGuy", 0,0,0, 0,0,0, 0,SXF_TRANSFERPOINTERS|SXF_TRANSFERSPRITEFRAME)
		TNT1 A 0 A_JumpIf(1, "DestroyedEnd")
		Goto DestroyedEnd
	MidasFrame2:
		ZSSH G 0 A_SpawnItemEx("Midas_Statue_ShotgunGuy", 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:
		ZSSH G 0 A_SpawnItemEx("Midas_Statue_ShotgunGuy", 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:
		ZSSH G 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
		ZSSH G 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
		ZSSH G 0 A_ChangeFlag("NOPAIN",1)
		"####" "#" 0 A_SetUserVar("User_LightningLock", User_LightningLock + 10)
		"####" "#" 0 A_Jump(256,"BlueLightningLock")
		Goto BlueLightningLock
  }
}

Actor RLFormerSergeantCombatShotgunShotCounter : Inventory
{
inventory.maxamount 5
}

Actor RLFormerSergeantCombatShotgunPumpCounter : Inventory
{
inventory.maxamount 1
}

ACTOR RLCCFormerSergeantCombatShotgun : RLFormerSergeantCombatShotgun
{
  +TOUCHY
  States
  {
  See:
    ZSSH AABBCCDD 3
    Loop
  Missile:
    ZSSH E 10
    ZSSH F 7 Bright
    ZSSH E 4
    ZSSH V 3
    ZSSH W 3
    ZSSH V 3
    Goto See
  Melee:
    Stop
  Death:
    ZSSH H 5
    ZSSH I 5 A_Scream
    ZSSH J 5 A_NoBlocking
    ZSSH K 5
    ZSSH L -1
    Stop
  }
}

//==============================================================================
//							MONSTER'S ITEM POOL

ACTOR RLFormerSergeantCombatShotgunDrop : RLEnemyWeaponDrop
{
	States
	{
	WeaponDrop: // Drops for DRLA Arsenal + Monsterpack
		TNT1 A 0 A_DropItem("RLCombatShotgunPickup")
		Stop
	WeaponDropNoArsenal: // Drops for Monsterpack
		TNT1 A 0 A_DropItem("Shotgun")
		Stop
	WeaponDropVanilla: // Drops for Monsterpack if vanilla drops option is enabled
		TNT1 A 0 A_DropItem("Shotgun")
		Stop
	DonutstealDrop: // Drops for Demonsteele
		TNT1 A 0 A_DropItem("Shell")
		Stop
	}
}
