activeSummon.getOwner().sendPacket(sm);
}
if (!miss && (damage > 0))
{
L2Weapon weapon = getActiveWeaponItem();
boolean isBow = ((weapon != null) && weapon.getItemType().toString().equalsIgnoreCase("Bow"));
if (!isBow) // Do not reflect or absorb if weapon is of type bow
{
// Reduce HP of the target and calculate reflection damage to reduce HP of attacker if necessary
double reflectPercent = target.getStat().calcStat(Stats.REFLECT_DAMAGE_PERCENT, 0, null, null);
if (reflectPercent > 0)
{
int reflectedDamage = (int) ((reflectPercent / 100.) * damage);
damage -= reflectedDamage;
if (reflectedDamage > target.getMaxHp())
{
reflectedDamage = target.getMaxHp();
}
getStatus().reduceHp(reflectedDamage, target, true);
// Custom messages - nice but also more network load
/*
* if (target instanceof L2PcInstance) ((L2PcInstance)target).sendMessage("You reflected " + reflectedDamage + " damage."); else if (target instanceof L2Summon) ((L2Summon)target).getOwner().sendMessage("Summon reflected " + reflectedDamage + " damage."); if (this instanceof
* L2PcInstance) ((L2PcInstance)this).sendMessage("Target reflected to you " + reflectedDamage + " damage."); else if (this instanceof L2Summon) ((L2Summon)this).getOwner().sendMessage("Target reflected to your summon " + reflectedDamage + " damage.");
*/
}
// Absorb HP from the damage inflicted
double absorbPercent = getStat().calcStat(Stats.ABSORB_DAMAGE_PERCENT, 0, null, null);
if (absorbPercent > 0)
{
int maxCanAbsorb = (int) (getMaxHp() - getCurrentHp());
int absorbDamage = (int) ((absorbPercent / 100.) * damage);
if (absorbDamage > maxCanAbsorb)
{
absorbDamage = maxCanAbsorb; // Can't absord more than max hp
}
if (absorbDamage > 0)
{
setCurrentHp(getCurrentHp() + absorbDamage);
// Custom messages - nice but also more network load
/*
* if (this instanceof L2PcInstance) ((L2PcInstance)this).sendMessage("You absorbed " + absorbDamage + " damage."); else if (this instanceof L2Summon) ((L2Summon)this).getOwner().sendMessage("Summon absorbed " + absorbDamage + " damage."); else if (Config.DEBUG)
* _log.info(getName() + " absorbed " + absorbDamage + " damage.");
*/
}
}
}
target.reduceCurrentHp(damage, this);
// Notify AI with EVT_ATTACKED
target.getAI().notifyEvent(CtrlEvent.EVT_ATTACKED, this);
getAI().clientStartAutoAttack();
// Manage attack or cast break of the target (calculating rate, sending message...)
if (!target.isRaid() && Formulas.getInstance().calcAtkBreak(target, damage))
{
target.breakAttack();
target.breakCast();
}
}
// Launch weapon Special ability effect if available
L2Weapon activeWeapon = getActiveWeaponItem();
if (activeWeapon != null)
{
activeWeapon.getSkillEffects(this, target, crit);
}
/*
* COMMENTED OUT BY nexus - 2006-08-17 We must not discharge the soulshouts at the onHitTimer method, as this can cause unwanted soulshout consumption if the attacker recharges the soulshot right after an attack request but before his hit actually lands on the target. The soulshot
* discharging has been moved to the doAttack method: As soon as we know that we didn't missed the hit there, then we must discharge any charged soulshots.