Actor ApprenticeofDsparil 30000
{
  Health 400
  Radius 20
  Height 56
  Speed 8
  PainChance 100
  Monster
  +FloorClip
  +NoGravity
  +Float
  +DontHurtSpecies
  SeeSound "Wizard2/Sight"
  PainSound "Wizard2/Pain"
  DeathSound "Wizard2/Death"
  ActiveSound "Wizard2/Active"
  Obituary "%o was spooked by one of D'sparil's Apprentices."
  
  DropItem "ApprenticeOfDsparilLoot"
  
  States
  {
    TNT1 A 0 A_UnsetShootable
	TNT1 A 35 //Let the monster drop to the ground since we spawn
			  //them way above ground level so they don't get stuck
			  //in the floor.
	TNT1 A 0 A_SetTranslucent(0.0, 2)
	APDP M 6 A_SetTranslucent(0.2, 2)
	APDP M 6 A_SetTranslucent(0.4, 2)
	APDP M 6 A_SetTranslucent(0.6, 2)
	APDP M 6 A_SetTranslucent(0.8, 2)
	APDP M 6 A_SetTranslucent(1.0, 0) //opaque
	APDP MLKJI 7 //Play death animation in reverse so it looks
	              //like it's coming out of the ground
    APDP A 0 A_SetShootable
  SpawnLook:
	APDP AABB 4 A_Wander
    APDP A 0 A_LookEx(0, 0, 2000.0, 3000.0, 0, "See")
	APDP AABB 4 A_Wander
    APDP A 0 A_LookEx(0, 0, 2000.0, 3000.0, 0, "See")
	APDP AABB 4 A_Wander
    APDP A 0 A_LookEx(0, 0, 2000.0, 3000.0, 0, "See")
	APDP AABB 4 A_Wander
    APDP A 0 A_LookEx(0, 0, 2000.0, 3000.0, 0, "See")
	APDP AABB 4 A_Wander
    APDP A 0 A_LookEx(0, 0, 2000.0, 3000.0, 0, "See")
	APDP AABB 4 A_Wander
    APDP A 0 A_LookEx(0, 0, 2000.0, 3000.0, 0, "See")
	APDP AABB 4 A_Wander
    APDP A 0 A_LookEx(0, 0, 2000.0, 3000.0, 0, "See")
	APDP A 0 A_CheckSight("Remove")
    Loop
  See:
    APDP A 0 A_SetTranslucent(1, 0)
    APDP AABBAABB 3 A_Chase
    APDP AABBAABB 3 A_Chase
    APDP AABBAABB 3 A_Chase
    APDP AABBAABB 3 A_Chase
    APDP AABBAABB 3 A_Chase
    APDP AABBAABB 3 A_Chase
    APDP AABBAABB 3 A_Chase
    APDP AABBAABB 3 A_Chase
	APDP A 0 A_CheckSight("Remove")
    Loop
  Missile:
    APDP C 0 A_FaceTarget
    APDP C 2 A_SetTranslucent(0.50, 0)
    APDP C 2 A_SetTranslucent(1, 0)
    APDP C 2 A_SetTranslucent(0.50, 0)
    APDP C 2 A_SetTranslucent(1, 0)
    APDP C 2 A_SetTranslucent(0.50, 0)
    APDP C 2 A_SetTranslucent(1, 0)
    APDP C 2 A_SetTranslucent(0.50, 0)
    APDP C 2 A_SetTranslucent(1, 0)
    APDP C 0 A_Jump(64, "Missile2")
    APDP C 0 A_Jump(64, "Missile3")
    APDP C 0 A_Playsound("Wizard2/Attack")
    APDP D 0 A_CustomMissile("FireBlast", 30, -10, 4)
    APDP D 0 A_CustomMissile("FireBlast", 30, 0, 0)
    APDP D 6 A_CustomMissile("FireBlast", 30, 10, -4)
    Goto See
  Missile2:
    APDP D 1 A_SetTranslucent(0.90, 0)
    APDP D 1 A_SetTranslucent(0.80, 0)
    APDP D 1 A_SetTranslucent(0.70, 0)
    APDP D 1 A_SetTranslucent(0.60, 0)
    APDP D 1 A_SetTranslucent(0.50, 0)
    APDP D 1 A_SetTranslucent(0.40, 0)
    APDP D 1 A_SetTranslucent(0.30, 0)
    APDP D 1 A_SetTranslucent(0.20, 0)
    APDP D 1 A_SetTranslucent(0.10, 0)
    APDP D 1 A_SetTranslucent(0.00, 0)
    APDP D 0 A_SetInvulnerable
    APDP D 0 A_Stop
    APDP DDDDDDDDDDDDDDDD 2 A_Wander
    APDP D 0 A_FaceTarget
    APDP C 0 A_Playsound("Wizard2/Attack")
    APDP D 0 A_CustomMissile("FireBlast", 30, -10, 4)
    APDP D 0 A_CustomMissile("FireBlast", 30, 0, 0)
    APDP D 6 A_CustomMissile("FireBlast", 30, 10, -4)
    APDP DDDDDDDDDDDDDDDD 2 A_Wander
    APDP D 0 A_FaceTarget
    APDP C 0 A_Playsound("Wizard2/Attack")
    APDP D 0 A_CustomMissile("FireBlast", 30, -10, 4)
    APDP D 0 A_CustomMissile("FireBlast", 30, 0, 0)
    APDP D 6 A_CustomMissile("FireBlast", 30, 10, -4)
    APDP DDDDDDDDDDDDDDDD 2 A_Wander
    APDP D 0 A_FaceTarget
    APDP C 0 A_Playsound("Wizard2/Attack")
    APDP D 0 A_CustomMissile("FireBlast", 30, -10, 4)
    APDP D 0 A_CustomMissile("FireBlast", 30, 0, 0)
    APDP D 6 A_CustomMissile("FireBlast", 30, 10, -4)
    APDP DDDDDDDDDDDDDDDD 2 A_Wander
    APDP D 0 A_FaceTarget
    APDP C 0 A_Playsound("Wizard2/Attack")
    APDP D 0 A_CustomMissile("FireBlast", 30, -10, 4)
    APDP D 0 A_CustomMissile("FireBlast", 30, 0, 0)
    APDP D 6 A_CustomMissile("FireBlast", 30, 10, -4)
    APDP DDDDDDDDDDDDDDDD 2 A_Wander
    APDP D 1 A_SetTranslucent(0.10, 0)
    APDP D 1 A_SetTranslucent(0.20, 0)
    APDP D 1 A_SetTranslucent(0.30, 0)
    APDP D 1 A_SetTranslucent(0.40, 0)
    APDP D 1 A_SetTranslucent(0.50, 0)
    APDP D 1 A_SetTranslucent(0.60, 0)
    APDP D 1 A_SetTranslucent(0.70, 0)
    APDP D 1 A_SetTranslucent(0.80, 0)
    APDP D 1 A_SetTranslucent(0.90, 0)
    APDP D 1 A_UnSetInvulnerable
    APDP D 1 A_SetTranslucent(1, 0)
    Goto See
  Missile3:
    APDP C 0 A_FaceTarget
    APDP C 0 A_Playsound("Wizard2/Attack")
    APDP D 4 A_CustomMissile("SuperFireBlast", 15, 0, 0)
    Goto See
  Pain:
    APDP E 0 A_SetTranslucent(1,0)
    APDP E 4
    APDP E 4 A_Pain
    Goto See
  Death:
	TNT1 A 0 A_GiveToTarget("ApprenticeOfDsparilKillXP", 1)
  Death.NoXP:
  Death.SentryTurret:
    APDP E 0 A_SetTranslucent(1,0)
    APDP E 6
    APDP F 6
    APDP G 6 A_Scream
    APDP H 6 A_SpawnItemEx("AoDGhost", 0, 0, 8, 0, 0, 0, 0, 128)
    APDP I 6 A_Fall
    APDP JKL 6
    APDP M 1050
    Stop
  Raise:
    APDP ML 8
    APDP KJI 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 AoDGhost
{
  Radius 1
  Height 1
  Speed 0
  Projectile
  RenderStyle Translucent
  Alpha 0.75
  +NoClip
  SeeSound "AoD/Ghost"
  States
  {
  Spawn:
  Death:
    AODG ABCDEF 5 Bright
    AODG G 5 Bright A_Fadeout
    Stop
  }
}

Actor FireBlast
{
  Speed 18
  Scale 0.75
  Damage 4
  Projectile
  +StrifeDamage
  +NoGravity
  Deathsound "FireBlast/Explode"
  Decal Scorch
  states
  {
  Spawn:
    PROJ ABC 4 Bright
    Loop
  Death:
    PROJ D 4 Bright A_Explode(8, 64, 0)
    PROJ EFGH 4 Bright
    PROJ I 4 Bright A_Fadeout(0.50)
    Stop
  }
}

Actor SuperFireBlast : FireBlast
{
  Speed 13
  Scale 1.5
  Damage (10*Random(2, 4))
  Deathsound "SuperFireBlast/Explode"
  Decal BigScorch
  states
  {
  Spawn:
    PROJ ABC 4 Bright
    Loop
  Death:
    PROJ D 4 Bright A_Explode(128, 128, 0)
    PROJ EFGH 4 Bright
    PROJ I 4 Bright A_Fadeout(0.50)
    Stop
  }
}
