Actor NecromancerNecronomicon : Weapon
{
  Inventory.PickupSound "misc/w_pkup"
  Weapon.AmmoGive 10
  Weapon.AmmoType "Darkmana"
  Inventory.PickupMessage "You got the Necronomicon!"
  Inventory.RestrictedTo "NecromancerClass"
  Tag "Necronomicon"
  +FloatBob
  States
  {
  Spawn:
    NCRO A -1
    Loop

  Ready:
    NECR A 1 A_WeaponReady(Wrf_AllowReload|Wrf_AllowZoom)
    Loop

  Deselect:
    NECR A 1 A_Lower
    TNT1 A 0 A_Lower
    TNT1 A 0 A_Lower
    Loop

  Select:
    NECR A 1 A_Raise
    TNT1 A 0 A_Raise
    TNT1 A 0 A_Raise
    Loop

  // ===== Primary Fire =====
  Fire:
    TNT1 A 0 A_JumpIfInventory("Darkmana", 5, "FireDo")
    Goto Ready

  FireDo:
    NECR A 30 A_PlaySound("Weapons/Incant")
    NECR B 10
    NECR C 8
    NECR D 2
    NECR E 16 A_FireCustomMissile("NecronomiconGhostEgg_AutoShotgunGuy", 0, 1, 0, 0)
    TNT1 A 0 A_TakeInventory("Darkmana", 5)
    NECR D 4
    NECR C 4
    NECR B 4
    NECR A 4
    Goto Ready

  // ===== Alt Fire =====
  AltFire:
    TNT1 A 0 A_JumpIfInventory("Darkmana", 10, "AltFireDo")
    Goto Ready

  AltFireDo:
    NECR A 30 A_PlaySound("Weapons/Incant")
    NECR B 10
    NECR C 8
    NECR D 2
    NECR E 16 A_FireCustomMissile("NecronomiconGhostEgg_HellKnight", 0, 1, 0, 0)
    TNT1 A 0 A_TakeInventory("Darkmana", 10)
    NECR D 4
    NECR C 4
    NECR B 4
    NECR A 4
    Goto Ready
	
  // ===== Reload (Mancubus Summon) =====
  Reload:
    TNT1 A 0 A_JumpIfInventory("Darkmana", 15, "ReloadDo")
    Goto Ready

  ReloadDo:
    TNT1 A 0 A_TakeInventory("Darkmana", 15)
    NECR A 30 A_PlaySound("Weapons/Incant")
    NECR B 10
    NECR C 8
    NECR D 2
    NECR E 16 A_FireCustomMissile("NecronomiconGhostEgg_Mancubs", 0, 1, 0, 0)
    NECR D 4
    NECR C 4
    NECR B 4
    NECR A 4
    Goto Ready

  // ===== Zoom (Arachnotron Summon) =====
  Zoom:
    TNT1 A 0 A_JumpIfInventory("Darkmana", 20, "ZoomDo")

    Goto Ready

  ZoomDo:
    TNT1 A 0 A_TakeInventory("Darkmana", 20)
    NECR A 30 A_PlaySound("Weapons/Incant")
    NECR B 10
    NECR C 8
    NECR D 2
    NECR E 16 A_FireCustomMissile("NecronomiconGhostEgg_Arachnotron", 0, 1, 0, 0)
    NECR D 4
    NECR C 4
    NECR B 4
    NECR A 4
    Goto Ready
  }
}


// ===== Summon Projectiles =====
Actor NecronomiconGhostEgg_AutoShotgunGuy
{
  Radius 13
  Height 8
  Speed 25
  Damage 0
  SeeSound "Weapons/Spirit1"
  Projectile
  States
  {
  Spawn:
    TNT1 A 5
    Goto Death
  Death:
    TNT1 A 0 A_SpawnItem("FriendlyAutoShotgunGuy", 32, 0, 0)
    Stop
  }
}

Actor NecronomiconGhostEgg_HellKnight : NecronomiconGhostEgg_AutoShotgunGuy
{
  States
  {
  Spawn:
    TNT1 A 7
    Goto Death
  Death:
    TNT1 A 0 A_SpawnItem("FriendlyHellKnight", 32, 0, 0)
    Stop
  }
}

Actor NecronomiconGhostEgg_Mancubs : NecronomiconGhostEgg_AutoShotgunGuy
{
  States
  {
  Spawn:
    TNT1 A 7
    Goto Death
  Death:
    TNT1 A 0 A_SpawnItem("FriendlyMancubus", 32, 0, 0)
    Stop
  }
}

Actor NecronomiconGhostEgg_Arachnotron : NecronomiconGhostEgg_AutoShotgunGuy
{
  States
  {
  Spawn:
    TNT1 A 7
    Goto Death
  Death:
    TNT1 A 0 A_SpawnItem("FriendlyArachnotron", 32, 0, 0)
    Stop
  }
}


// ===== Allied Monsters =====
ACTOR FriendlyAutoShotgunGuy
{
    Health 500
    Radius 20
    Height 56
	Mass 100
    Speed 16
    PainChance 1
    MONSTER
	+MISSILEMORE
    +MISSILEEVENMORE
    +FRIENDLY
    +THRUSPECIES
    +FLOORCLIP
	+NOBLOOD
	-COUNTKILL
	-SOLID
    +FLOORCLIP
	Species "Player"
	Tag "Autoshotgun Guy"
	Species "Player"
    SeeSound "grunt/sight"
    AttackSound "asgguy/asgfir"
    PainSound "grunt/pain"
    DeathSound "grunt/death"
    ActiveSound "grunt/active"
    Obituary "%o got emmenthal'd by an ASG guy."
    DropItem Shell
    States
    {
    Spawn:
        ASGZ AB 10 A_Look
        Goto See
    See:
        ASGZ AABBCCDD 4 A_Chase
        Loop
    Missile:
    	TNT1 A 0 A_JumpIfInventory ("ASGZAmmo", 16, "Reload")
    	ASGZ E 4 A_FaceTarget
    	TNT1 A 0 A_GiveInventory ("ASGZAmmo", 1)
    	ASGZ F 3 Bright A_CustomBulletAttack (5, 4, 3, 4, "FriendlyZombiePuff", 0)
    	ASGZ E 4
    	TNT1 A 0 A_JumpIfInventory ("ASGZAmmo", 16, "Reload")
    	TNT1 A 0 A_PlaySound("asgguy/asgld1")
    	ASGZ E 4 A_CPosRefire
    	TNT1 A 0 A_GiveInventory ("ASGZAmmo", 1)
    	ASGZ F 3 Bright A_CustomBulletAttack (5, 4, 3, 4, "FriendlyZombiePuff", 0)
    	ASGZ E 4
    	TNT1 A 0 A_JumpIfInventory ("ASGZAmmo", 16, "Reload")
    	TNT1 A 0 A_PlaySound("asgguy/asgld1")
    	ASGZ E 4 A_CPosRefire
    	TNT1 A 0 A_GiveInventory ("ASGZAmmo", 1)
    	ASGZ F 3 Bright A_CustomBulletAttack (5, 4, 3, 4, "FriendlyZombiePuff", 0)
    	ASGZ E 4
    	TNT1 A 0 A_JumpIfInventory ("ASGZAmmo", 16, "Reload")
    	TNT1 A 0 A_PlaySound("asgguy/asgld1")
    	ASGZ E 4 A_CPosRefire
    	TNT1 A 0 A_GiveInventory ("ASGZAmmo", 1)
    	ASGZ F 3 Bright A_CustomBulletAttack (5, 4, 3, 4, "FriendlyZombiePuff", 0)
    	ASGZ E 4
    	TNT1 A 0 A_PlaySound("asgguy/asgld1")
		TNT1 A 0 A_JumpIfInventory ("ASGZAmmo", 16, "Reload")
        Goto See
    Reload:
    	TNT1 A 0 A_ChangeFlag("NoPain", 1)
    	TNT1 A 0 A_PlaySound("asgguy/asgout")
    	ASGZ E 24 A_TakeInventory ("ASGZAmmo", 16)
    	ASGZ E 8 A_PlaySound("asgguy/asgin")
    	TNT1 A 0 A_ChangeFlag("NoPain", 0)
    	Goto See
    Pain:
        ASGZ G 3
        ASGZ G 3 A_Pain
        Goto See
    Death:
        ASGZ H 5
        ASGZ I 5 A_Scream
        ASGZ J 5 A_Fall
        ASGZ KLM 5
        ASGZ N 1 A_FadeOut (0.1)
        Stop
    XDeath:
        ASGZ O 5
        ASGZ P 5 A_XScream
        ASGZ Q 5 A_Fall
        ASGZ RSTUV 5
        ASGZ W 1 A_Fadeout (0.1)
        Stop
    Raise:
        ASGZ NMLKJIH 5
        Goto See
    }
}

ACTOR ASGZAmmo: Ammo
{
     Inventory.MaxAmount 16
}

// ----- Projectiles -----
actor FriendlyBaronBall : BaronBall
{
	+MTHRUSPECIES
    +THRUSPECIES
	Damage 75
	RenderStyle "STYLE_Subtract"
    Species "Player"
}

actor FriendlyFatShot : FatShot
{
	+MTHRUSPECIES
    +THRUSPECIES
	Damage 50
	RenderStyle "STYLE_Subtract"
    Species "Player"
}

actor FriendlyPlasmaBall : ArachnotronPlasma
{
	+MTHRUSPECIES
    +THRUSPECIES
	Damage 25
	RenderStyle "STYLE_Subtract"
    Species "Player"
}

Actor FriendlyZombiePuff : BulletPuff
{
	+MTHRUSPECIES
	+ThruSpecies
	Species "Player"
}

// ----- Friendly HellKnight -----
actor FriendlyHellKnight : HellKnight
{
    Health 1000
    Speed 14 // original 10
    Tag "Allied HellKnight"
    +NOPAIN
	+MISSILEMORE
    +MISSILEEVENMORE
    +FRIENDLY
    +THRUSPECIES
    +FLOORCLIP
    +NOBLOOD
	-COUNTKILL
	-SOLID
	RenderStyle "STYLE_Subtract"
    Species "Player"
    ReactionTime 0
    States
    {
	 Spawn:
		BOS2 AB 10 A_Look
		Goto See
	Missile:
        BOS2 E 4 A_FaceTarget
        BOS2 F 4 A_FaceTarget
        BOS2 G 4 Bright A_CustomMissile("FriendlyBaronBall", 32, 0)
        Goto See
	 Death:
		BOS2 I 8
		BOS2 J 8 A_Scream
		BOS2 K 8
		BOS2 L 8 A_NoBlocking
		BOS2 MN 8
		BOS2 O 1 A_FadeOut (0.1)
    Stop
    }
}

// ----- Friendly Mancubus -----
actor FriendlyMancubus : Fatso
{
    Health 1200
    Speed 10 // original 8
    Tag "Allied Mancubus"
    +NOPAIN
	+MISSILEMORE
    +MISSILEEVENMORE
    +FRIENDLY
    +THRUSPECIES
    +FLOORCLIP
    +NOBLOOD
	-COUNTKILL
	-SOLID
	RenderStyle "STYLE_Subtract"
    Species "Player"
    States
    {
	Spawn:
		FATT AB 15 A_Look
		Goto See
    Missile:
        FATT G 4 A_FaceTarget // faster raise
        FATT H 4 Bright A_CustomMissile("FriendlyFatShot", 32, 0)
        FATT I 2 A_FaceTarget
        FATT G 2
        FATT H 4 Bright A_CustomMissile("FriendlyFatShot", 32, 0, 0, 16)
        FATT I 2 A_FaceTarget
        FATT G 2
        FATT H 4 Bright A_CustomMissile("FriendlyFatShot", 32, 0, 0, -16)
        FATT I 4 A_FaceTarget
        Goto See
	Death:
		FATT K 6
		FATT L 6 A_Scream
		FATT M 6 A_NoBlocking
		FATT NOPQRS 6
		FATT T 1 A_FadeOut(0.1)
		Stop
    }
}

// ----- Friendly Arachnotron -----
actor FriendlyArachnotron : Arachnotron
{
    Health 1000
    Speed 14 // original 10
    Tag "Allied Arachnotron"
    +NOPAIN
	+MISSILEMORE
    +MISSILEEVENMORE
    +FRIENDLY
    +THRUSPECIES
    +FLOORCLIP
    +NOBLOOD
	-COUNTKILL
	-SOLID
	RenderStyle "STYLE_Subtract"
    Species "Player"
    States
    {
	Spawn:
    BSPI AB 10 A_Look
    Goto See
	Missile:
        BSPI A 7 Bright A_FaceTarget // shortened from 20
        BSPI G 2 Bright A_CustomMissile("FriendlyPlasmaBall", 32, 0)
        BSPI H 2 Bright
        BSPI H 1 Bright A_SpidRefire
        Goto Missile+1
	Death:
		BSPI J 20 A_Scream
		BSPI K 7 A_NoBlocking
		BSPI LMNO 7
		BSPI P 1 A_FadeOut (0.1)
    Stop
    }
}