ACTOR GatekeeperMorpher : PowerupGiver 
{
Scale 2
radius 48
height 128
powerup.type Gatekeeper
inventory.pickupmessage ""
powerup.duration 99999999999999
states
{
Spawn:
TNT1 A 6
loop
 }
 }


actor PowerGatekeeper : PowerMorph
{
powerup.duration 99999999999999
PowerMorph.PlayerClass "GatekeeperPlayer"
}

ACTOR GatekeeperPlayer : PlayerPawn
{
  Health 1000
  Radius 30
  Height 64
  Speed 0.9
  mass 2000
  Player.ColorRange 0, 0
  Player.JumpZ 6
  Player.MaxHealth 16000
  Player.ViewHeight 60
  Player.DisplayName "Gatekeeper"
  Player.SoundClass "Gatekeeper"
  Player.MorphWeapon "GatekeeperWeapon0"
  Player.StartItem "Mana", 100
  DamageFactor "Boss", 0.0
  limitedtoteam 1
  damagefactor "boss", 0
  SeeSound "Gatekeeper/Taunt"
  PainSound "Gatekeeper/Pain"
  DeathSound "Gatekeeper/Death1"
  bloodcolor Green
  PainChance 32
  +NOSKIN
  -PICKUP
  states
{
	Spawn:
	    TNT1 A 0 SetPlayerProperty(0, 1, 1)
		SKCL AB 10  
		Loop
	See:
	    TNT1 A 0 SetPlayerProperty(0, 1, 1)
		SKCL AAAAAABBBBBBCCCCCCDDDDDD 1
		Loop
	Missile:
		SKCL EF 6 Bright  
		SKCL G 8 Bright 
		Goto Spawn
	Pain:
        SKCL H 3
        SKCL H 3 A_Pain
        Goto Spawn
	Death:
		TNT1 A 0 A_PlaySound("Gatekeeper/Death1",CHAN_VOICE,1.0,FALSE,ATTN_NONE)
		TNT1 A 0 a_givetotarget("BOSSKILLEDSTAT", 1)
		TNT1 A 0 a_givetotarget("reward", 1)
		SKCL HHH 30
		SKCL AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 0 A_SpawnItemEx ("GateKeeperBoom", 0, 0,Random(12,32),random(-9,9),random(-9,9),random(5,9), 48, 128)
		SKCL A 0 A_PlaySound("Gatekeeper/Death2",CHAN_ITEM,1.0,FALSE,ATTN_NONE)
		SKCL IJK 3 
    	SKCL L 3 A_NoBlocking
    	SKCL MNO 3
    	SKCL O -1
    	Stop  
}
}

ACTOR GatekeeperWeapon0 : Weapon 
{
 Weapon.SelectionOrder 800
 Obituary "%o was engulfed in flames by %k"
 Inventory.PickupMessage ""
 Inventory.PickupSound "misc/pk_up"
 Weapon.AmmoUse 5
 Weapon.AmmoGive 0
 Weapon.AmmoType "Mana"
 +WEAPON.NOAUTOAIM
  States
 {
  Spawn:
       TNT1 A -1
       Loop
  Ready:
       TNT1 A 1 A_WeaponReady
       goto AltFire
  Fire:
  TNT1 A 1
  goto AltFire
  Deselect:
       TNT1 A 1 A_Lower
       Loop
  Select:
       TNT1 A 0 A_Raise
       Loop
  AltFire:
       TNT1 A 0 A_GiveInventory("GatekeeperWeapon")
       TNT1 A 0 A_SelectWeapon("GatekeeperWeapon")
       TNT1 A 0 
       goto deselect
  Flash:
       SNIF F 3 Bright A_Light2
       SNIF F 3 Bright A_Light1
       SNIF F 0 Bright A_Light0
       Goto LightDone     
       }
}


actor Gatekeeperattackmode1 : Inventory
{
Inventory.Amount 1
Inventory.MaxAmount 1
  States
  {
  Spawn:
    TNT1 A -1
    Stop
  }
}

actor Gatekeeperattackmode2 : Inventory
{
Inventory.Amount 1
Inventory.MaxAmount 1
  States
  {
  Spawn:
    TNT1 A -1
    Stop
  }
}

actor Gatekeeperattackmode3 : Inventory
{
Inventory.Amount 1
Inventory.MaxAmount 1
  States
  {
  Spawn:
    TNT1 A -1
    Stop
  }
}

actor GatekeeperSwitch : Inventory
{
Inventory.Amount 1
Inventory.MaxAmount 1
  States
  {
  Spawn:
    TNT1 A -1
    Stop
  }
}

ACTOR GatekeeperWeapon : Weapon 
{
 Weapon.SelectionOrder 800
 Obituary "%o was engulfed in flames by %k"
 Inventory.PickupMessage ""
 Inventory.PickupSound "misc/pk_up"
 Weapon.AmmoUse 0
 Weapon.AmmoGive 0
 Weapon.AmmoType "Mana"
 +WEAPON.NOAUTOAIM
 +INVENTORY.UNDROPPABLE
  States
 {
  Spawn:
       TNT1 A -1
       Loop
  Ready:
       TNT1 A 0 A_jumpIfinventory("GatekeeperSwitch", 1, "ReadyMelee")
       CLA2 A 1 A_WeaponReady(WRF_ALLOWRELOAD)
       goto ready
  ReadyMelee:
       CLA3 A 1 A_WeaponReady(WRF_ALLOWRELOAD)
       goto ready
  Deselect:
       CLA2 A 1 A_Lower
       Loop
  Select:
       CLA2 A 0 A_Raise
       Loop 
  Fire:
       CLA2 A 0 A_jumpIfinventory("Gatekeeperattackmode1", 1, "OneTargetAttackcheck")
       CLA2 A 0 A_jumpIfinventory("Gatekeeperattackmode2", 1, "MultiTargetAttackcheck")
       CLA2 A 0 A_jumpIfinventory("Gatekeeperattackmode3", 1, "SpecialAttackcheck")
	   Goto ready
  AltFire:
  	   CLA2 A 1 ACS_execute(812)
       CLA2 A 1
       CLA2 A 13
       goto ready
  OneTargetAttack:
       TNT1 A 0 A_jumpIfinventory("GatekeeperSwitch", 1, "OneTargetSwitch")
       CLA2 A 0 A_Takeinventory("mana", 20)
	   CLA2 A 4 A_GunFlash
	   CLA2 BBBBB 2 A_FireCustomMissile("GatekeeperSerpentAttack",0,0,0,0)
       CLA2 B 6
	   TNT1 A 0 A_TakeInventory("GateKeeperSpread",1)
       goto ready
  OneTargetSwitch:
	   TNT1 A 0 A_PlayWeaponSound("Centaur/Melee")
	   TNT1 A 0 A_Recoil(-10)
	   CLA3 BBB 2 Bright A_CustomPunch(100 , 1 , 0, "BulletPuffCent", 108)
	   CLA3 BA 6
	   TNT1 A 0 A_TakeInventory("GateKeeperSpread",1)
       Goto Ready
  MultiTargetAttack:
       CLA2 A 0 A_Takeinventory("mana", 45)
	   CLA2 A 0 A_GunFlash
	   TNT1 A 0 A_PlaySound("FlameSword/Attack", CHAN_WEAPON)
       CLA2 B 12 Bright A_FireCustomMissile ("GateKeeperFireSlash",0,0,0)
       CLA2 B 6
	   TNT1 A 0 A_TakeInventory("GateKeeperSpread",1)
       goto ready
  MultiTargetSwitch:
       TNT1 A 0 A_jumpIfinventory("mana", 60, "MultiTargetSwitchAttack")  
       goto ready
  MultiTargetSwitchAttack:
        TNT1 A 0 A_GunFlash
		TNT1 A 0 A_TakeInventory("GateKeeperSpread",1)
        TNT1 A 0 A_Takeinventory("mana", 60)
	    TNT1 A 0 A_Stop
		TNT1 A 0 A_PlaySound("Gatekeeper/Scream",CHAN_VOICE,1.0,FALSE,ATTN_NONE)
		TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 0 A_SpawnItemEx("GateKeeperConsacrationParticle", 0, 0, 4, Random(10,25), Random(10,25), Random(0,25), Random(0, 360), 128)
        TNT1 A 0 A_FireCustomMissile("GateKeeperConsecrate")
	    CLA3 BA 20
        Goto Ready
  SpecialAttack:
       CLA2 A 0 A_Takeinventory("mana", 40)
       CLA2 E 0 A_PlaySound("weapons/draugrrend",CHAN_7,1.0,0,ATTN_NONE)
       CLA2 E 0 A_FireCustomMissile("GateKeeperLaevatein",0,0,0,0)
       CLA2 BA 10
	   TNT1 A 0 A_TakeInventory("GateKeeperSpread",1)
       Goto Ready
  SpecialSwitch: 
        TNT1 A 0 A_jumpIfinventory("mana", 70, "SpecialSwitchAttack")  
        goto ready
  SpecialSwitchAttack:
        CLA3 A 0 A_Takeinventory("mana", 70)
		TNT1 A 0 A_PlaySound("Gatekeeper/Scream",CHAN_VOICE,1.0,FALSE,ATTN_NONE)
		CLA3 B 0 BRIGHT A_PlaySound("Gatekeeper/Charge",CHAN_7,1.0,FALSE,ATTN_NONE)
	    CLA3 A 0 BRIGHT A_GiveInventory("GateKeeperSpread",1)
		Goto Ready
  OneTargetAttackcheck:
       TNT1 A 0 A_jumpIfinventory("GatekeeperSwitch", 1, "OneTargetSwitch")
       TNT1 A 0 A_jumpIfinventory("mana", 20, "OneTargetAttack")
  goto ready
  MultiTargetAttackcheck:
       TNT1 A 0 A_jumpIfinventory("GatekeeperSwitch", 1, "MultiTargetSwitch")
       TNT1 A 0 A_jumpIfinventory("mana", 45, "MultiTargetAttack")  
  goto ready
  SpecialAttackcheck:
       TNT1 A 0 A_jumpIfinventory("GatekeeperSwitch", 1, "SpecialSwitch")
       TNT1 A 0 A_jumpIfinventory("mana", 40, "SpecialAttack")  
  goto ready
  Reload:
       TNT1 A 0 A_PlayWeaponSound("Gatekeeper/Melee")
       CLA2 A 0 A_jumpIfinventory("GatekeeperSwitch", 1, "Switch")
	   CLA2 A 15 A_GiveInventory("GatekeeperSwitch", 1)
       goto ready
  Switch:
       TNT1 A 0 A_PlayWeaponSound("Gatekeeper/Range")
       CLA2 A 15 A_Takeinventory("GatekeeperSwitch", 1)
	   Goto Ready
  Flash:
       SNIF F 3 Bright A_Light2
       SNIF F 3 Bright A_Light1
       SNIF F 0 Bright A_Light0
       Goto LightDone     
       }
}

ACTOR GatekeeperSerpentAttack : CStaffMissile
{
 Damage (1)
 Speed 50
 Seesound "weapons/firmfi"
 DeathSound "weapons/firex5"
  DamageType "Boss"
 Obituary "%o was killed by the Gatekeeper."
 Decal DoomImpScorch
 +HITTRACER
 States
 {
 Spawn:
        HIB2 ABCD 1 Bright 
        Loop
    Death:
	    TNT1 A 0 Acs_NamedExecuteAlways("GateKeeperPoison",0,0,0,0)
        HIB2 E 0 Bright A_SetTranslucent(0.75, 1)
        HIB2 EFGHIJ 3 Bright
        Stop
		}
}

Actor GateKeeperConsecrate
{
    Radius 1
    Height 1
    Speed 0
	ReactionTime 12
	DamageType "Boss"
	+NOCLIP
	+NOBLOCKMAP
    States
    {
    Spawn:
	    TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, 0)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, 10)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, 20)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, 30)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, 40)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, 50)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, 60)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, 70)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, 80)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, 90)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, 100)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, 110)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, 120)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, 130)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, 140)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, 150)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, 160)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, 170)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, 180)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, -10)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, -20)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, -30)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, -40)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, -50)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, -60)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, -70)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, -80)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, -90)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, -100)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, -110)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, -120)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, -130)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, -140)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, -150)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, -160)
		TNT1 A 0 A_Custommissile ("GateKeeperConsecrate2", 5, 0, -170)
		TNT1 A 0 A_PlaySound("Gatekeeper/Consacration")
		TNT1 AAAAAAAAAAAAAAAAAAAA 2 A_SpawnItemEx("GateKeeperGoldenParticle", Random(12, 36), 0, 4, 0, 0, (Random(20, 35)*0.1), Random(0, 360), 128)
		TNT1 A 0 A_Countdown
		Loop
    }
}

ACTOR GateKeeperConsecrate2
{
	Radius 1
    Height 1
    Speed 10
    Damage 10
    PROJECTILE
    RENDERSTYLE ADD
	Scale 0.66
    ALPHA 0.9
    +NOCLIP
	+FLOORHUGGER
	damagetype "boss"
    	States
    	{
    	Spawn:
		XXBF ABCDEFGHIJKLMNOPQRST 2 Bright A_Explode(16,64,0)
     	Stop       
   	}
}

Actor GateKeeperParticleSpawnerGolden : CustomInventory
{
    States
    {
    Pickup:
        TNT1 A 0 A_SpawnItemEx("GateKeeperGoldenParticle", Random(12, 36), 0, 4, 0, 0, (Random(20, 35)*0.1), Random(0, 360), 128)
        Stop
    }
}

Actor GateKeeperParticleSpawnerAzure : CustomInventory
{
    States
    {
    Pickup:
        TNT1 A 0 A_SpawnItemEx("GateKeeperAzureParticle", Random(12, 36), 0, 4, 0, 0, (Random(20, 35)*0.1), Random(0, 360), 128)
        Stop
    }
}

Actor GateKeeperAzureParticle
{
	Projectile
	Damage 0
	+NoBlockMap
	+BloodLessImpact
	+ClientSideOnly 
    -BloodSplatter
    +DontSplash
    +ForceXYBillBoard
	Speed 0
	Radius 1
	Height 1
	RenderStyle Add
	Alpha 1.0
	States
	{
  Spawn:
  Death:
    SWET F 1 Bright A_FadeOut(0.04)
    Loop
	}
}

Actor GateKeeperGoldenParticle : GateKeeperAzureParticle
{
	States
	{
  Spawn:
  Death:
    SWET G 1 Bright A_FadeOut(0.04)
    Loop
	}
}

Actor GateKeeperConsacrationParticle : GateKeeperGoldenParticle
{
	-NoBlockMap
	+HexenBounce
	BounceCount 2
	States
	{
	Spawn:
	  SWET G 0 A_ScaleVelocity(0.92)
	  SWET G 1 Bright A_FadeOut(0.02)
	  Loop
	}
}

ACTOR GateKeeperLaevatein
{
  Radius 6
  Height 16
  Speed 40
  Damage (200)
  Projectile
  +RANDOMIZE
  RenderStyle Add
  DamageType "Boss"
  SeeSound "weapons/draugrrend"
  Decal "BaronScorch"
  States
  {
  Spawn:
    TNT1 A 1 Bright A_CustomMissile("GateKeeperLaevateinOrb", 0, 0, 0, CMF_AIMDIRECTION | CMF_TRACKOWNER)
    Loop
  Death:
    TNT1 A 1 Bright 
    Stop
  }
}

ACTOR GateKeeperLaevateinOrb
{
  Radius 15
  Speed 0
  Height 8
  Scale 2.0
  Damage (75)
  Projectile
  -ACTIVATEIMPACT
  -ACTIVATEPCROSS
  RenderStyle Add
  reactiontime 175
  DamageType "Boss"
  Translation "0:255=%[2.00,0.55,0.55]:[0.00,0.00,0.00]"
  Deathsound "RazorLHit"
  States
  {
  Spawn:
    BAL2 AB 1 Bright
	BAL2 A 0 A_CountDown
	Loop
  Death:
    BAL2 CDE 6 Bright
    Stop
  }
}

Actor GateKeeperSpread : PowerSpread
{
    PowerUp.Duration 99999999999999
}

Actor GateKeeperFireSlash
{
    Radius 16
    Height 8
    Speed 60
    Damage (200)
    RenderStyle Add
    DamageType "Boss"
    Scale 0.90
    Projectile
    +DONTSPLASH
	DeathSound "PyroCannon/Explosion"
   States
  {
  Spawn:
	GKFS A 1 Bright A_SpawnItemEx("GateKeeperFireSlashTrail", 0, 0, 0, 0, 0, 0, 0, 128)
	Loop
  Death:
	RPGX AAAAAAAAAAAAAAA 0 A_SpawnItemEx("GuardianExplosiveFireBallParticle",0,0,5,random(-10,10),random(-10,10),random(0,10),random(1,360))
    TNT1 A 0 A_Explode(144,160)
    RPGX BCEFGHIJKLMNOPQRSTUV 2 Bright
    Stop
  }
}

Actor GateKeeperFireSlashTrail
{
    Radius 1
    Height 1
    Speed 0
    Damage 0
	Scale 0.9
	RenderStyle Add
    PROJECTILE
    +DONTSPLASH
	+CLIENTSIDEONLY
    States
    {
    Spawn: 
        GKFS A 1 Bright A_FadeOut(0.04)
	    Loop
    }
}

ACTOR GateKeeperBoom
{
   Radius 1
   Height 1
   Speed 5
   RenderStyle Add
   Projectile
   Translation "0:255=%[0.00,0.00,0.00]:[2.00,2.00,0.00]"
   +CLIENTSIDEONLY
   +NOCLIP
   States
   {
   Spawn:
    GGA4 GH 2 BRIGHT
    GGA4 I 4 BRIGHT
    GGA4 J 6 BRIGHT A_PlaySound ("GGR/DeathBoom")
    GGA4 K 4 BRIGHT
	GGA4 L 2 BRIGHT
    Stop
   }
}