//Submitted: Captain Toenail
//Decorate: Captain Toenail
//GLDEFs: Captain Toenail
//Sounds: Free Radical Design
//Sprites: Raven Software
//Sprite Edit: Captain Toenail

actor UndeadPriest
{
  obituary "%o was bagged by an undead priest."
  health 200
  gibhealth 60
  radius 20
  height 56
  mass 125
  speed 8
  painchance 30
  dropitem "Shell" 96
  dropitem "Shell" 128
  decal BulletChip
  painsound "UndeadPriest/Pain"
  deathsound "UndeadPriest/Die"
  DamageFactor "UndeadPriest", 0
  MONSTER
  +FLOORCLIP
  
  DropItem "UndeadPriestLoot"
  
  states
  {
  Spawn:

  	UNDP A 0 A_SetTranslucent(0.0, 2)
  	UNDP N 6 A_SetTranslucent(0.2, 2)
	UNDP N 6 A_SetTranslucent(0.4, 2)
	UNDP N 6 A_SetTranslucent(0.6, 2)
	UNDP N 6 A_SetTranslucent(0.8, 2)
	UNDP N 6 A_SetTranslucent(1.0, 0) //opaque
	UNDP NMLKJIH 7 //Play death animation in reverse so it looks
	              //like it's coming out of the ground
   Idle:
   SpawnLook:
	UNDP AABBCCDD 4 A_Wander
    UNDP A 0 A_LookEx(0, 0, 2000.0, 3000.0, 0, "See") 
	UNDP AABBCCDD 4 A_Wander
    UNDP A 0 A_LookEx(0, 0, 2000.0, 3000.0, 0, "See") 
	UNDP AABBCCDD 4 A_Wander
    UNDP A 0 A_LookEx(0, 0, 2000.0, 3000.0, 0, "See") 
	UNDP AABBCCDD 4 A_Wander
	UNDP AABBCCDD 4 A_Wander
    UNDP A 0 A_LookEx(0, 0, 2000.0, 3000.0, 0, "See") 
	UNDP AABBCCDD 4 A_Wander
    UNDP A 0 A_LookEx(0, 0, 2000.0, 3000.0, 0, "See") 
	UNDP AABBCCDD 4 A_Wander
    UNDP A 0 A_LookEx(0, 0, 2000.0, 3000.0, 0, "See") 
	UNDP AABBCCDD 4 A_Wander
    UNDP A 0 A_LookEx(0, 0, 2000.0, 3000.0, 0, "See") 
	UNDP AABBCCDD 4 A_Wander
    UNDP A 0 A_LookEx(0, 0, 2000.0, 3000.0, 0, "See") 
	UNDP AABBCCDD 4 A_Wander
	UNDP A 0 A_CheckSight("Remove")
    loop
  See:
    UNDP A 0 A_Jump (32, "Run")
    UNDP AABBCCDD 3 A_Chase
    UNDP AABBCCDD 3 A_Chase
    UNDP AABBCCDD 3 A_Chase
    UNDP AABBCCDD 3 A_Chase
    UNDP AABBCCDD 3 A_Chase
    UNDP AABBCCDD 3 A_Chase
	UNDP A 0 A_CheckSight("Remove")
    loop
  Run:
    UNDP A 0 A_Jump (24, "See")
    UNDP AABBCCDD 2 A_Chase
    UNDP AABBCCDD 2 A_Chase
    UNDP AABBCCDD 2 A_Chase
    UNDP AABBCCDD 2 A_Chase
	UNDP A 0 A_CheckSight("Remove")
    loop
  Missile:
    UNDP E 10 A_FaceTarget
    UNDP F 5 bright A_CustomBulletAttack (7, 7, 5, 2, PriestPuff)
    UNDP F 0 bright A_PlaySoundEx ("UndeadPriest/Shoot","SoundSlot6")
    UNDP E 2 A_SentinelRefire
    UNDP E 10 A_FaceTarget
    UNDP F 5 bright A_CustomBulletAttack (7, 7, 5, 3, PriestPuff)
    UNDP F 0 bright A_PlaySoundEx ("UndeadPriest/Shoot2","SoundSlot7")
    UNDP E 10
    goto See
  Pain:
    UNDP G 3
    UNDP G 3 A_Pain
    goto See
  Death:
	TNT1 A 0 A_GiveToTarget("UndeadPriestKillXP", 1)
  Death.NoXP:
  Death.SentryTurret:
    UNDP H 6
    UNDP I 6 A_Scream
    UNDP JK 6
    UNDP L 6 A_NoBlocking
    UNDP M 6
    UNDP N 1050
    Stop
  XDeath:
    UNDP O 5 A_XScream
    UNDP P 5
    UNDP R 5 A_NoBlocking
    UNDP STUVW 5
    UNDP X 1050
    Stop
  Raise:
    UNDP NMLKJIH 6
    goto See
  Remove:
	TNT1 A 0 
	//Remove ourselves if we're too far from the player frustrum.
	TNT1 A 5 ACS_ExecuteAlways(501, 0)
	Stop
  }
}

Actor PriestPuff : BulletPuff
{
DamageType UndeadPriest
}
