ACTOR NecromancerVilestaff : Weapon
{
    Inventory.PickupSound "misc/w_pkup" 
    Weapon.AmmoGive 10 
    Weapon.AmmoType "Darkmana"
    Inventory.PickupSound "misc/w_pkup" 
    Inventory.PickupMessage "You got the staff of the vile!"
    Inventory.RestrictedTo "NecromancerClass"
    Tag "Vile Staff"

    States
    {
    Spawn:
        REVI H -1
        Loop

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

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

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

    // ===== Primary Fire =====
    Fire:
        TNT1 A 0 A_JumpIfInventory("Darkmana", 25, "FireDo") // Has enough ammo?
        Goto Ready

    FireDo:
        REVI A 0
        REVI B 1
        REVI C 1
        REVI D 1
        REVI E 1 A_PlaySound("weapons/vilesht2")
        TNT1 A 0 A_TakeInventory("Darkmana", 25)
        TNT1 A 0 A_SpawnItemEx("FriendlyMinigunner", 96, 0, 0, 0, 0, 0, 0, 1)
        REVI D 1
        REVI C 1
        REVI B 1
        REVI A 10
        Goto Ready

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

    AltFireDo:
        REVI A 0
        REVI E 0 A_PlaySound("weapons/vilesht1")
        TNT1 A 0 A_TakeInventory("Darkmana", 50)
        TNT1 A 0 A_SpawnItemEx("FriendlyBaronofHell", 96, 0, 0, 0, 0, 0, 0, SXF_TRANSFERPOINTERS|SXF_NOCHECKPOSITION)
        REVI D 1
        REVI C 1
        REVI B 1
        REVI A 10
        Goto Ready

    // ===== Reload (Spider Mastermind) =====
    Reload:
        TNT1 A 0 A_JumpIfInventory("Darkmana", 75, "ReloadDo")
        Goto Ready

    ReloadDo:
        REVI A 0
        REVI E 0 A_PlaySound("weapons/vilesht1")
        TNT1 A 0 A_TakeInventory("Darkmana", 75)
        TNT1 A 0 A_SpawnItemEx("FriendlySpiderMastermind", 96, 0, 0, 0, 0, 0, 0, SXF_TRANSFERPOINTERS|SXF_NOCHECKPOSITION)
        REVI D 1
        REVI C 1
        REVI B 1
        REVI A 10
        Goto Ready

    // ===== Zoom (Cyberdemon) =====
    Zoom:
        TNT1 A 0 A_JumpIfInventory("Darkmana", 100, "ZoomDo")
        Goto Ready

    ZoomDo:
        REVI A 0
        REVI E 0 A_PlaySound("weapons/vilesht1")
        TNT1 A 0 A_SpawnItemEx("FriendlyCyberdemon", 96, 0, 0, 0, 0, 0, 0, SXF_TRANSFERPOINTERS|SXF_NOCHECKPOSITION)
        TNT1 A 0 A_TakeInventory("Darkmana", 100)
        REVI D 1
        REVI C 1
        REVI B 1
        REVI A 10
        Goto Ready
    }
}



ACTOR FriendlyMinigunner
{
	SeeSound "grunt/sight"
	PainSound "grunt/pain"
	DeathSound "grunt/death"
	ActiveSound "gunrt/active"
	AttackSound "minigunner/fire"
	Tag "Minigun Dude"
	DropItem "Clip"
	Obituary "%o was shredded by a minigun zombie."
	Health 750
	Speed 12
	PainChance 1
	Monster
    +NOPAIN
	+MISSILEMORE
    +MISSILEEVENMORE
    +FRIENDLY
    +THRUSPECIES
    +FLOORCLIP
    -COUNTKILL
    -SOLID
	Species "Player"
	Mass 100
	Radius 20
	Height 56
	States
	{
		Spawn:
		MINZ AB 10 A_Look
		Goto See
		See:
		MINZ AABBCCDD 3 A_Chase
		loop
		Missile:
		MINZ E 10 A_FaceTarget
		MINZ FE 1 Bright A_CustomBulletAttack(30, 0, 1, random(1,4)*3, "FriendlyZombiePuff", 0, CBAF_NORANDOM)
		MINZ E 0 A_CPosRefire
		Goto Missile+1
		Pain:
		MINZ G 3
		MINZ G 3 A_Pain
		Goto See
		Death:
		MINZ H 6
		MINZ I 6 A_Scream
		MINZ J 6 A_Fall
		MINZ KLM 6
		MINZ N -1
		Stop
		XDeath:
		MINZ O 4
		MINZ P 4 A_XScream
		MINZ Q 4 A_Fall
		MINZ RSTUV 4
		MINZ W -1
		Stop
		Raise:
		MINZ NMLKJIH 5
		Goto See
	}
}

actor FriendlyBaronofHell : BaronofHell
{
    Health 2000
    Speed 14 // original 10
    Tag "Allied Baron of Hell"
    +NOPAIN
	+MISSILEMORE
    +MISSILEEVENMORE
    +FRIENDLY
    +THRUSPECIES
    +FLOORCLIP
	+NOBLOOD
	-COUNTKILL
	-SOLID
	RenderStyle "STYLE_Subtract"
    Species "Player"
    ReactionTime 0

    States
    {
	Spawn:
		BOSS AB 10 A_Look
		Goto See
    Missile:
        BOSS E 6 A_FaceTarget
        BOSS F 6 A_FaceTarget
        BOSS G 6 Bright A_CustomMissile("FriendlyBaronBall", 32, 0)
        Goto See
	Death:
		BOSS I 8
		BOSS J 8 A_Scream
		BOSS K 8
		BOSS L 8 A_NoBlocking
		BOSS MN 8
		BOSS O 1 A_FadeOut (0.1)
		Stop
    }
}


ACTOR FriendlySpiderMastermind : SpiderMastermind
{
   Health 6000
   DamageFactor "Normal", 0.50
   Tag "Allied Spider Mastermind"
  +NOPAIN
  +MissileEvenMore
  +MissileMore
  +FRIENDLY
  +THRUSPECIES
  +FloorClip
  +NOBLOOD
  -COUNTKILL
  -SOLID
  Speed 25
  RenderStyle "STYLE_Subtract"
   Species "Player"
   ReactionTime 0
   States
   {
    Spawn:
		SPID AB 10 A_Look
		Goto See
 	Missile:
		SPID A 20 BRIGHT A_FaceTarget
		SPID G 2 BRIGHT A_CustomBulletAttack(22.5, 0, 3, 50, "FriendlyMastermindPuff", 0, CBAF_NORANDOM)
		SPID H 2 BRIGHT A_CustomBulletAttack(22.5, 0, 3, 50, "FriendlyMastermindPuff", 0, CBAF_NORANDOM)
		SPID H 1 BRIGHT A_SpidRefire
		Goto Missile+1
	Death:
		SPID J 20 A_Scream
		SPID K 10 A_NoBlocking
		SPID LMNOPQR 10
		SPID S 30
		SPID S 1 A_FadeOut(0.1)
		Stop
	}
}

Actor FriendlyMastermindPuff : BulletPuff
{
	+MTHRUSPECIES
	+ThruSpecies
	+FOILINVUL
	Species "Player"
}

// ----- Friendly Cyberdemon Rocket -----
actor FriendlyCyberRocket : Rocket
{
    +THRUSPECIES
	+FORCERADIUSDMG
	RenderStyle "STYLE_Subtract"
    Species "Player"
	Damage 150
	Speed 75
}

// ----- Friendly Cyberdemon -----
actor FriendlyCyberdemon : Cyberdemon
{
    Health 8000
    Speed 15 // original 10
    DamageFactor "Normal", 0.50
    Tag "Allied Cyberdemon"
    +NOPAIN
	+MISSILEMORE
    +MISSILEEVENMORE
    +FRIENDLY
    +THRUSPECIES
    +FLOORCLIP
	+NOBLOOD
    -COUNTKILL
    -SOLID
	RenderStyle "STYLE_Subtract"
    Species "Player"
    ReactionTime 0
    States
    {
	Spawn:
		CYBR AB 10 A_Look
		Goto See
    Missile:
        CYBR E 5 A_FaceTarget
        CYBR F 5 Bright A_CustomMissile("FriendlyCyberRocket", 32, 0)
        CYBR E 3 A_FaceTarget
        CYBR F 5 Bright A_CustomMissile("FriendlyCyberRocket", 32, 0)
        CYBR E 3 A_FaceTarget
        CYBR F 5 Bright A_CustomMissile("FriendlyCyberRocket", 32, 0)
        Goto See
	Death:
		CYBR H 10
		CYBR I 10 A_Scream
		CYBR JKL 10
		CYBR M 10 A_NoBlocking
		CYBR NO 10
		CYBR P 30
		CYBR P 1 A_FadeOut(0.1)
		Stop
    }
}