actor NetherImp
{
  obituary "%o was cursed by a Nether Imp."
  hitobituary "%o was touched by a Nether Imp." // ;)
  health 200
  radius 20
  height 56
  mass 100
  speed 9
  Scale 1.1
  painchance 80
  PainChance "SoulToxic", 60
  PainChance "FatFlamer", 60
  PainChance "FiendFire", 60
  DamageFactor "ImpComet", 0.0
  DropItem "LifeEssence" 125
  DropItem "ArmorBonusMax" 125
  DropItem "DemonAmmo" 70 60
  Tag "Nether Imp"
  Species "Imps"
  seesound "devil/Sight"
  painsound "voidimp/Pain"
  deathsound "devil/Death"
  activesound "superimp/Active"
  MeleeSound "imps/melee"
  BloodColor "Green"
  MONSTER
  +FLOORCLIP
  +MissileMore
  +QUICKTORETALIATE
  states
  {
  Spawn:
    NIMP A 5 A_Look
    loop
  See:
  	TNT1 A 0 A_Jump(46,"Evade")
    NIMP AABB 3 A_Chase
	TNT1 A 0 A_SpawnItem("HumanishStep",0,0,0,0)
	NIMP CCDD 3 A_Chase
	TNT1 A 0 A_SpawnItem("HumanishStep",0,0,0,0)
    loop
  Evade:
	TNT1 A 0 A_Jump(128,7)
	TNT1 A 0 ThrustThing(Angle*256/360+64,16,0,0)
	NIMP AAAA 3 A_Chase
	TNT1 A 0 A_Stop
	Goto See
	TNT1 A 0 ThrustThing(Angle*256/360+192,16,0,0)
	NIMP AAAA 3 A_Chase
	TNT1 A 0 A_Stop
	TNT1 A 0 A_JumpIfTargetInLOS("Missile")
	Goto See
  Melee: 
    NIMP EF 5 A_FaceTarget
    NIMP G 4 A_CustomMeleeAttack(20, "imps/melee")
	NIMP FE 5 A_FaceTarget
    Goto See 
  Missile:
    NIMP E 0 A_Jump (256, "Attack1", "Attack2")
    Goto See
  Attack1:
    NIMP EF 8 A_FaceTarget
    NIMP G 6 A_CustomMissile ("NetherLightning", 34, 0, 0)
    NIMP FEF 8 A_FaceTarget
    NIMP G 6 A_CustomMissile ("NetherLightning", 34, 0, 0)
    Goto See
  Attack2:
    NIMP IJ 8 A_FaceTarget
    NIMP K 0 A_CustomMissile ("NetherBall", 34, 0, 5)
    NIMP K 0 A_CustomMissile ("NetherBall", 34, 0, -5)
    NIMP K 6 A_CustomMissile ("NetherBall", 34, 0, 0)
    Goto See
  Pain:
    NIMP H 2 
    NIMP H 2 A_Pain
    goto See
  Death:
    NIMP L 8 A_Scream
    NIMP MN 6
    NIMP O 6 A_Fall
    NIMP P -1
    Stop
  XDeath:
    NIMP Q 3 
	NIMP R 3 A_XScream
	NIMP S 3 A_SpawnItemEx("GreenGibbedGenerator",0,0,0,0,0,0,0,128,0)
	NIMP T 3 A_Fall
	NIMP UVW 3
	NIMP X -1
    Stop
  Raise:
	TNT1 A 0
	TNT1 A 0 A_SpawnItemEx("VileHealEffect",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
	NIMP PONML 6
	Goto See
  }
}

actor NetherBall
{
	Damagetype "ImpComet"
    Radius 8
    Height 6
    Speed 20
    Damage 12
    PROJECTILE
    RENDERSTYLE ADD
    ALPHA 0.67
    SeeSound "imp/attack"
    DeathSound "imp/shotx"
    Decal DoomImpScorch
    States
    {
    Spawn:
        IBAL AAAABBBB 1 Bright A_SpawnItemEx ("Kaboom7", 0, 0, 0, random(0, -4), random(-2, 2), random(-2, 2), 0, 0, 0)
        Loop
    Death:
		TNT1 A 0 A_SpawnItemEx("GreenParticleSpawner", 0, 0, 0, 0, 0, 0, 0, 128)
		TNT1 AAA 0 A_CustomMissile("Kaboom4", 0, 0, random(0,360), 2, random(0,360))
		TNT1 AAA 0 A_CustomMissile("SmokeFX4", 0, 0, random(0,360), 2, random(0,360))
        IBAL CDE 4 Bright
        Stop
    }
}

actor NetherLightning
{
	Damagetype "ImpComet"
    Radius 8
    Height 6
    Speed 40
    Damage 4
    PROJECTILE
    +RIPPER
    RENDERSTYLE ADD
    ALPHA 0.75
    Scale 0.75
    SeeSound "NetherLightning"
    DeathSound "imp/shotx"
    Decal DoomImpScorch
    States
    {
    Spawn:
        NLIT AA 1 Bright A_SpawnItemEx ("NetherLightningTrail", 0, 0, 0, 0, 0, 0, 0, 0, 0)
        NLIT A 0 Bright A_SpawnItemEx ("NetherLightningSpark", 0, 0, 0, random(0, -4), random(-2, 2), random(-2, 2), 0, 0, 0)
        NLIT AA 1 Bright A_SpawnItemEx ("NetherLightningTrail", 0, 0, 0, 0, 0, 0, 0, 0, 0)
        NLIT A 0 Bright A_SpawnItemEx ("NetherLightningSpark", 0, 0, 0, random(0, -4), random(-2, 2), random(-2, 2), 0, 0, 0)
        loop
    Death:
		TNT1 A 0 A_SpawnItemEx("YellowParticleSpawner", 0, 0, 0, 0, 0, 0, 0, 128)
		TNT1 AAA 0 A_CustomMissile("KaboomGoldBabySent", 0, 0, random(0,360), 2, random(0,360))
		TNT1 AAA 0 A_CustomMissile("SmokeFX4", 0, 0, random(0,360), 2, random(0,360))
        NLIT ABCDEFG 1 Bright
        Stop
    }
}

actor NetherLightningTrail : ImpBallTrail
{
    Radius 8
    Height 6
    Speed 1
    Damage 0
    PROJECTILE
    +RIPPER
    RENDERSTYLE ADD
    ALPHA 0.75
    Scale 0.75
    States
    {
    Spawn:
        NLIT A 1 A_FadeOut (0.025)
        NLIT A 0 A_Jump (32, "Spark")
        loop
    Spark:
        NLIT A 0 A_SpawnItemEx ("NetherLightningSpark", 0, 0, 0, random(0, -4), random(-2, 2), random(-2, 2), 0, 0, 0)
        goto Spawn
    }
}

actor NetherLightningSpark : ImpBallTrail
{
    Radius 1
    Height 1
    Speed 0
    Damage 0
    +NOGRAVITY
    Scale 0.3
    States
    {
    Spawn:
		TNT1 A 0
		TNT1 A 0 A_JumpIf(ACS_ExecuteWithResult(304) == 1, "Toaster")
        NLIT BCDEFG 1 Bright
        stop
    }
}
