// BloodFiend from Realm667
// Original Creator: ??? (There wasn't a credit in the wad file)

// Changes made for Satanic Redux: Bloodfiend fires three Bloodshot instead of 
// two. Also dmgfactors to null damage from blood attacks. ~amv2k9

ACTOR Satanic_Bloodfiend : Demon 
{ 
	DamageFactor MEagleAlt,			0
	DamageFactor NoDamage,			0
	DamageFactor GhostFriend, 		0
	DamageFactor DrainHealthEver,	0
	DamageFactor DrainHealth,		0
	DamageFactor DrainMana,			0
	PainChance MEagleAlt,			0
	PainChance NoDamage,			0
	PainChance GhostFriend, 		0
	PainChance DrainHealthEver,	0
	PainChance DrainHealth,		0
	PainChance DrainMana,			0
	PainChance "Turn", 255 
	Health 300 
	PainChance 140
	Speed 15 
	Radius 30 
	Height 56 
	Mass 450 
	MONSTER
	-FRIENDLY
	+FloorClip
	+LongMeleeRange
	+DontHurtSpecies
	OBITUARY "%o died from the toxic blood of a bloodfiend."
	HITOBITUARY "%o was eaten by a bloodfiend."
	SEESOUND "monster/sg2sit" 
	ATTACKSOUND "monster/sg2atk" 
	PAINSOUND "demon/pain" 
	DEATHSOUND "demon/death" 
	ACTIVESOUND "demon/sg2act"
	states 
	{ 
	Spawn: 
		SAR2 AB 10 A_Look 
		Loop 
	See: 
		TNT1 A 0 A_JumpIfInventory("PowerNecShroud",1,"Wander",AAPTR_PLAYER1)
		SAR2 AA 2 A_Chase
		TNT1 A 0 A_JumpIfInventory("PowerNecShroud",1,"Wander",AAPTR_PLAYER1)
		SAR2 BB 2 A_Chase
		TNT1 A 0 A_JumpIfInventory("PowerNecShroud",1,"Wander",AAPTR_PLAYER1)
		SAR2 CC 2 A_Chase
		TNT1 A 0 A_JumpIfInventory("PowerNecShroud",1,"Wander",AAPTR_PLAYER1)
		SAR2 DD 2 A_Chase 
		Loop
	Wander:
		TNT1 A 0 A_JumpIfInventory("PowerNecShroud",1,1,AAPTR_PLAYER1)
		Goto See
		SAR2 AA 2 A_Chase
		TNT1 A 0 A_JumpIfInventory("PowerNecShroud",1,1,AAPTR_PLAYER1)
		Goto See
		SAR2 BB 2 A_Chase
		TNT1 A 0 A_JumpIfInventory("PowerNecShroud",1,1,AAPTR_PLAYER1)
		Goto See
		SAR2 CC 2 A_Chase
		TNT1 A 0 A_JumpIfInventory("PowerNecShroud",1,1,AAPTR_PLAYER1)
		SAR2 DD 2 A_Chase
		Goto See
	Melee: 
       SAR2 EF 8 A_FaceTarget 
       SAR2 G 8 A_SargAttack
       Goto See
	Missile:
       SAR2 GF 8 A_FaceTarget 
       SAR2 E 0 A_PlaySound ("Weapons/bloodf")
       SAR2 E 0 A_CustomMissile ("Bloodshot",22,0,-2,0,0)
       SAR2 E 0 A_CustomMissile ("Bloodshot",22,0,0,0,0)
	   SAR2 E 8 A_CustomMissile ("Bloodshot",22,0,2,0,0)
       Goto See
	Pain.Bludgeon:	
		SAR2 H 0 ThrustThing(45,15,0)
		SAR2 H 3
		SAR2 H 3 A_Pain
		Goto See
	Pain.Turn:
		TNT1 A 0 A_PlaySound("Satanic/Weapons/BellRing",CHAN_WEAPON)
	   TNT1 A 0 ACS_Execute(824,0,20,0,0)
	   SAR2 H 2 
       TNT1 A 0 A_ChangeFlag("Friendly",1)
	   SAR2 H 2 A_Pain 
       Goto See
	Pain: 
       SAR2 H 2 
       SAR2 H 2 A_Pain 
       Goto See 
	Death: 
       SAR2 I 8 
       SAR2 J 8 A_Scream 
       SAR2 K 4 
       SAR2 L 4 A_NoBlocking 
       SAR2 M 4 
       SAR2 N -1 
       Stop
    XDeath:
       SAR2 O 5
       SAR2 P 5 A_XScream
       SAR2 Q 5 A_NoBlocking
       SAR2 RSTUV 5
       SAR2 W -1
       Stop
	Raise:
		SAR2 M 1 
		SAR2 M 1  A_SetInvulnerable
		SAR2 M 1  A_UnsetSolid
		SAR2 M 1  A_UnsetShootable
		SAR2 M 1  ACS_ExecuteAlways(788,0,0,0,0)
		SAR2 M 1
		Stop
	Raise_Spirit:
		SAR2 LKJI 6 light ("smallbipedshadow")
		SAR2 I 0 light ("smallbipedshadow") A_SpawnItem("Satanic_RaisedImp")
		Stop
	Raise_ManaRitual:
		SAR2 LK 4 
		SAR2 J 4 A_SpawnItem("Satanic_HealthSpirit")
		SAR2 I 4  ACS_ExecuteAlways(779,0,9,0,0)
		BLFB A 4  A_SpawnItem("Satanic_HealthSpiritExplosion")
		BLFB BCDEFGHIJ 4
		SARB N 0 A_SpawnItem("Satanic_BloodFiendBurnedCorpse")
		Stop
	}
}

Actor Satanic_BloodFiendBurnedCorpse
{
	Radius 20
	Height 4
	
	States
	{
	Spawn:
		BLFB J -1
		Stop
	}
}

ACTOR Bloodshot
{
   Radius 3
   Height 3
   Speed 20
   Damage 2
   PROJECTILE
   RENDERSTYLE TRANSLUCENT
   ALPHA 0.80
   +THRUGHOST
   DeathSound "weapons/bloodx"
   States
   {
   Spawn:
      FBLD A 2 Bright A_CStaffMissileSlither
      FBLD A 0 A_SpawnItem("Bloodtrail",0,0)
      FBLD B 2 Bright A_CStaffMissileSlither
      FBLD B 0 A_SpawnItem("Bloodtrail",0,0)
      loop
   Death:
      FBLD CDE 3 Bright
      stop
   }
}

ACTOR Bloodtrail
{   
   Radius 1
   Height 1
   PROJECTILE
   RENDERSTYLE TRANSLUCENT
   ALPHA 0.67
   States
   {
   Spawn:
      NULL A 3
      FBLD FGH 3 BRIGHT
      Stop 
   }
}

ACTOR Runner_BloodFiend : Satanic_BloodFiend
{
	DropItem "HeartHealth" 16
}