Actor NecromancerLeech : Weapon
{
  Weapon.SelectionOrder 3700
  Weapon.Kickback 0
  Inventory.PickupSound "Idles"
  +WEAPON.MELEEWEAPON
  Tag "Necrotic Leech"
  Inventory.PickupMessage "Oh god, what is this thing!? Get it off!"
  Obituary "%o's blood was sucked out by %k's Demonic Leech."
  Inventory.RestrictedTo "NecromancerClass"

  States
  {
  Deselect:
    DLEI A 1 A_Lower
	TNT1 A 0 A_Lower
	TNT1 A 0 A_Lower 
    Loop
  Select: 
    DLEI A 1 A_Raise
	TNT1 A 0 A_Raise
	TNT1 A 0 A_Raise
    Loop
  Ready:
    DLEI AAAAAA 4 A_WeaponReady
  TNT1 A 0 A_Jump(2, "PlayIdle")
    DLEI BB 4 A_WeaponReady
    Loop

  PlayIdle:
    TNT1 A 0 A_PlaySound("Idles")
    Goto Ready


Fire:
  DLEF A 1 A_FIRECUSTOMMISSILE("LeechAttack")
  TNT1 A 0 A_PLAYWEAPONSOUND("NoSlurps/Missed")
  DLEF BCDEFG 3
  TNT1 A 0 A_ReFire
  Goto Ready

  AltFire:
    DLEF GFEDCBA 2
    DLEF A 5 A_PlaySound("Barfs")
    DLEF A 5 A_JumpIfHealthLower(11, "TooWeak")
    DLEF A 0 DamageThing (10)
    DLEF A 2 A_FireCustomMissile("GoreRandom", 0, 0, 5, 10, 0, 8)
    Goto Ready

  TooWeak:
  DLEF A 1 A_Print("You're too weak to use the alt-fire!",2)
    Goto Ready
  }
}

//Gore//
Actor GoreRandom : RandomSpawner
{
	DropItem "Gore1"
	DropItem "Gore2"
	DropItem "Gore3"
	DropItem "Gore4"

}

actor Gore1
{
    PROJECTILE
	BounceType Doom
	-NOGRAVITY
    -NOBLOCKMAP
    -NOTELEPORT
    +RANDOMIZE
	-GrenadeTrail
	-ROCKETTRAIL
	+DontFall
	+CanBounceWater
	+FORCEPAIN
	BounceFactor 1
	BounceCount 4
	BounceSound "Splaty"
    Radius 2
    Damage (random(20,35))
    Speed 25
	Scale 1
	DamageType "Necrosis"
	PoisonDamageType "Necrosis"
	PoisonDamage 10,15,10
	Obituary "%o's suffered deadly necrosis from %k's Demonic Leech."
    States
    {
    Spawn:
        GUT1 ABCDEFGH 2 A_SpawnItem("GoreTrail")
        loop
    Death:
		GUT1 H 1
        Stop
    }
}

actor Gore2 : Gore1
{
    States
    {
    Spawn:
        GUT2 ABCDEFGH 2 A_SpawnItem("GoreTrail")
        loop
    }
}

actor Gore3 : Gore1
{
    States
    {
    Spawn:
        GUT3 ABCDEFGH 2 A_SpawnItem("GoreTrail")
        loop
    }
}

actor Gore4 : Gore1
{
    States
    {
    Spawn:
        GUT4 ABCDEFGH 2 A_SpawnItem("GoreTrail")
        loop
    }
}

//GoreTrail//
Actor GoreTrail
{
	+NOCLIP
	+NOINTERACTION
	-NOGRAVITY
	Scale 0.5
	States
	{
	Spawn:
		DLBL AABBCC 2
		Stop
	}
}

//GorePuff//
Actor LeechAttack
{
Projectile
    Speed 64
    Damage (25)
    Height 24
    Radius 8
    Mass 2000
	Scale 0.5
	+NOBLOCKMAP
	+NOGRAVITY
	+RANDOMIZE
    +PUFFONACTORS
    +PUFFGETSOWNER
	+bright
	+BLOODSPLATTER
	+HITTRACER
	+FORCEPAIN
	+NoExtremeDeath
	Obituary "%o's blood was sucked out by %k's Demonic Leech."
	States
	{
	Spawn:
        DLBL A 1
		TNT1 A 0 a_alertmonsters//<--- add more As for more range
		Stop
	Death:
		DLBL ABC 2
		Stop
	XDeath:
		TNT1 A 1 A_GiveInventory("LeechDamageHealCustomInventory",1,AAPTR_TARGET)
		TNT1 A 0 A_PlaySound("misc/health_pkup")
		DLBL ABC 4 Bright A_Playsound("Slurps")
		Stop
		}
}

Actor LeechDamageThresholdHeal : Inventory
{
	Inventory.MAxamount 1
}

Actor LeechDamageHealCustomInventory : CustomInventory
{
States
  {
  Spawn:
    KONI A -1 
    Stop
	Pickup:
	  Tnt1 A 0 A_giveinventory("LeechDamageThresholdHeal",1)
	  Tnt1 A 0 A_jumpifinventory("LeechDamageThresholdHeal",0,"Succesfulheal")
	  Stop
	Succesfulheal:
	  TNT1 A 0 ACS_NamedExecuteWithResult("GiveHealthWithItem",15,0)
	  TNT1 A 0 ACS_NamedExecuteWithResult("GiveArmorWithItem",15,0)
	  tnt1 A 0 A_takeinventory("LeechDamageThresholdHeal",0)
	  Goto CheckPickup
	CheckPickup:
	  TNT1 A 0 A_JumpIfInventory("PickedUp", 0, "PickedUp")
	  Stop
	PickedUp:
	  TNT1 A 1 A_GiveInventory("LeechLifeStealSound",1, AAPTR_TARGET)
	  TNT1 A 0 
	  Stop
	
  }
}

Actor LeechLifeStealSound : CustomInventory
{
 -INVENTORY.NOSCREENFLASH
 Inventory.pickupsound "Slurps"
 States 
{
 Spawn:
  TNT1 A 0
  Stop
 Pickup:
	TNT1 A 0 A_SpawnItemEX("Space12HealParticle", 75, random(-75, 75), random(20, 75))
  TNT1 A 0 A_PlaySound("Slurps")
  Stop
}
}