// For creatures that can drain life of target when they are hit in combat. From the life_drain_aura.js script
var iSpecialAttack = 25; // This is the % chance the attacker will attempt to drain life
function onAttack(pAttacker, pDefender, damageValue, damageType )
{
var iCurrentHps = pDefender.maxhp;
var iNum = RandomNumber( 0, 100 );
if (iNum < iSpecialAttack) // there is a 25% chance the attack for a chance to drain life
{
if( pDefender.health < iCurrentHps )
{
var mSpell = Spells[8];
pDefender.SpellStaticEffect( mSpell );
pDefender.SoundEffect( 0x01E6, true );
hpDrain = RandomNumber( 3, 10 );
// Apply damage to target
pDefender.Damage( hpDrain, 1 );
if( pDefender.socket != null )
pDefender.EmoteMessage("You feel your life force being stolen away!");
iCurrentHps = pDefender.health;
// Restore HP for creature
if( pAttacker.health >= hpDrain )
pAttacker.health += hpDrain;
else
pAttacker.health += damaged.health;
}
}
}
var iSpecialAttack = 25; // This is the % chance the attacker will attempt to drain life
function onAttack(pAttacker, pDefender, damageValue, damageType )
{
var iCurrentHps = pDefender.maxhp;
var iNum = RandomNumber( 0, 100 );
if (iNum < iSpecialAttack) // there is a 25% chance the attack for a chance to drain life
{
if( pDefender.health < iCurrentHps )
{
var mSpell = Spells[8];
pDefender.SpellStaticEffect( mSpell );
pDefender.SoundEffect( 0x01E6, true );
hpDrain = RandomNumber( 3, 10 );
// Apply damage to target
pDefender.Damage( hpDrain, 1 );
if( pDefender.socket != null )
pDefender.EmoteMessage("You feel your life force being stolen away!");
iCurrentHps = pDefender.health;
// Restore HP for creature
if( pAttacker.health >= hpDrain )
pAttacker.health += hpDrain;
else
pAttacker.health += damaged.health;
}
}
}