/** * Validates the given summon and sends a system message to the master. * * @param summon the summon to validate * @param checkPet if {@code true} it'll validate a pet, if {@code false} it will validate a * servitor * @return {@code true} if the summon is not null and whether is a pet or a servitor depending on * {@code checkPet} value, {@code false} otherwise */ private boolean validateSummon(L2Summon summon, boolean checkPet) { if ((summon != null) && ((checkPet && summon.isPet()) || summon.isServitor())) { if (summon.isPet() && ((L2PetInstance) summon).isUncontrollable()) { sendPacket(SystemMessageId.WHEN_YOUR_PET_S_HUNGER_GAUGE_IS_AT_0_YOU_CANNOT_USE_YOUR_PET); return false; } if (summon.isBetrayed()) { sendPacket(SystemMessageId.YOUR_PET_SERVITOR_IS_UNRESPONSIVE_AND_WILL_NOT_OBEY_ANY_ORDERS); return false; } return true; } if (checkPet) { sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_A_PET); } else { sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_A_SERVITOR); } return false; }
public final void reduceHp( double value, L2Character attacker, boolean awake, boolean isDOT, boolean isHPConsumption, boolean ignoreCP) { if (getActiveChar().isDead()) { return; } // If OFFLINE_MODE_NO_DAMAGE is enabled and player is offline and he is in store/craft mode, no // damage is taken. if (Config.OFFLINE_MODE_NO_DAMAGE && (getActiveChar().getClient() != null) && getActiveChar().getClient().isDetached() && ((Config.OFFLINE_TRADE_ENABLE && ((getActiveChar().getPrivateStoreType() == L2PcInstance.STORE_PRIVATE_SELL) || (getActiveChar().getPrivateStoreType() == L2PcInstance.STORE_PRIVATE_BUY))) || (Config.OFFLINE_CRAFT_ENABLE && (getActiveChar().isInCraftMode() || (getActiveChar().getPrivateStoreType() == L2PcInstance.STORE_PRIVATE_MANUFACTURE))))) { return; } if (getActiveChar().isInvul() && !(isDOT || isHPConsumption)) { return; } if (!isHPConsumption) { getActiveChar().stopEffectsOnDamage(awake); // Attacked players in craft/shops stand up. if (getActiveChar().isInCraftMode() || getActiveChar().isInStoreMode()) { getActiveChar().setPrivateStoreType(L2PcInstance.STORE_PRIVATE_NONE); getActiveChar().standUp(); getActiveChar().broadcastUserInfo(); } else if (getActiveChar().isSitting()) { getActiveChar().standUp(); } if (!isDOT) { if (getActiveChar().isStunned() && (Rnd.get(10) == 0)) { getActiveChar().stopStunning(true); } } } int fullValue = (int) value; int tDmg = 0; int mpDam = 0; if ((attacker != null) && (attacker != getActiveChar())) { final L2PcInstance attackerPlayer = attacker.getActingPlayer(); if (attackerPlayer != null) { if (attackerPlayer.isGM() && !attackerPlayer.getAccessLevel().canGiveDamage()) { return; } if (getActiveChar().isInDuel()) { if (getActiveChar().getDuelState() == Duel.DUELSTATE_DEAD) { return; } else if (getActiveChar().getDuelState() == Duel.DUELSTATE_WINNER) { return; } // cancel duel if player got hit by another player, that is not part of the duel if (attackerPlayer.getDuelId() != getActiveChar().getDuelId()) { getActiveChar().setDuelState(Duel.DUELSTATE_INTERRUPTED); } } } // Check and calculate transfered damage final L2Summon summon = getActiveChar().getSummon(); if (getActiveChar().hasSummon() && summon.isServitor() && Util.checkIfInRange(1000, getActiveChar(), summon, true)) { tDmg = ((int) value * (int) getActiveChar() .getStat() .calcStat(Stats.TRANSFER_DAMAGE_PERCENT, 0, null, null)) / 100; // Only transfer dmg up to current HP, it should not be killed tDmg = Math.min((int) summon.getCurrentHp() - 1, tDmg); if (tDmg > 0) { summon.reduceCurrentHp(tDmg, attacker, null); value -= tDmg; fullValue = (int) value; // reduce the announced value here as player will get a message about // summon damage } } mpDam = ((int) value * (int) getActiveChar().getStat().calcStat(Stats.MANA_SHIELD_PERCENT, 0, null, null)) / 100; if (mpDam > 0) { mpDam = (int) (value - mpDam); if (mpDam > getActiveChar().getCurrentMp()) { getActiveChar().sendPacket(SystemMessageId.MP_BECAME_0_ARCANE_SHIELD_DISAPPEARING); getActiveChar().getFirstEffect(1556).stopEffectTask(); value = mpDam - getActiveChar().getCurrentMp(); getActiveChar().setCurrentMp(0); } else { getActiveChar().reduceCurrentMp(mpDam); SystemMessage smsg = SystemMessage.getSystemMessage( SystemMessageId.ARCANE_SHIELD_DECREASED_YOUR_MP_BY_S1_INSTEAD_OF_HP); smsg.addNumber(mpDam); getActiveChar().sendPacket(smsg); return; } } final L2PcInstance caster = getActiveChar().getTransferingDamageTo(); if ((caster != null) && (getActiveChar().getParty() != null) && Util.checkIfInRange(1000, getActiveChar(), caster, true) && !caster.isDead() && (getActiveChar() != caster) && getActiveChar().getParty().getMembers().contains(caster)) { int transferDmg = 0; transferDmg = ((int) value * (int) getActiveChar() .getStat() .calcStat(Stats.TRANSFER_DAMAGE_TO_PLAYER, 0, null, null)) / 100; transferDmg = Math.min((int) caster.getCurrentHp() - 1, transferDmg); if ((transferDmg > 0) && (attacker instanceof L2Playable)) { int membersInRange = 0; for (L2PcInstance member : caster.getParty().getMembers()) { if (Util.checkIfInRange(1000, member, caster, false) && (member != caster)) { membersInRange++; } } if (caster.getCurrentCp() > 0) { if (caster.getCurrentCp() > transferDmg) { reduceCp(transferDmg); } else { transferDmg = (int) (transferDmg - caster.getCurrentCp()); reduceCp((int) caster.getCurrentCp()); } } caster.reduceCurrentHp(transferDmg / membersInRange, attacker, null); value -= transferDmg; fullValue = (int) value; } } if (!ignoreCP && (attacker instanceof L2Playable)) { if (getCurrentCp() >= value) { setCurrentCp(getCurrentCp() - value); // Set Cp to diff of Cp vs value value = 0; // No need to subtract anything from Hp } else { value -= getCurrentCp(); // Get diff from value vs Cp; will apply diff to Hp setCurrentCp(0, false); // Set Cp to 0 } } if ((fullValue > 0) && !isDOT) { SystemMessage smsg; // Send a System Message to the L2PcInstance smsg = SystemMessage.getSystemMessage(SystemMessageId.C1_RECEIVED_DAMAGE_OF_S3_FROM_C2); smsg.addString(getActiveChar().getName()); smsg.addCharName(attacker); smsg.addNumber(fullValue); getActiveChar().sendPacket(smsg); if (tDmg > 0) { smsg = SystemMessage.getSystemMessage(SystemMessageId.C1_RECEIVED_DAMAGE_OF_S3_FROM_C2); smsg.addString(getActiveChar().getSummon().getName()); smsg.addCharName(attacker); smsg.addNumber(tDmg); getActiveChar().sendPacket(smsg); if (attackerPlayer != null) { smsg = SystemMessage.getSystemMessage( SystemMessageId.GIVEN_S1_DAMAGE_TO_YOUR_TARGET_AND_S2_DAMAGE_TO_SERVITOR); smsg.addNumber(fullValue); smsg.addNumber(tDmg); attackerPlayer.sendPacket(smsg); } } } } if (value > 0) { value = getCurrentHp() - value; if (value <= 0) { if (getActiveChar().isInDuel()) { getActiveChar().disableAllSkills(); stopHpMpRegeneration(); if (attacker != null) { attacker.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE); attacker.sendPacket(ActionFailed.STATIC_PACKET); } // let the DuelManager know of his defeat DuelManager.getInstance().onPlayerDefeat(getActiveChar()); value = 1; } else { value = 0; } } setCurrentHp(value); } if (getActiveChar().getCurrentHp() < 0.5) { getActiveChar().abortAttack(); getActiveChar().abortCast(); if (getActiveChar().isInOlympiadMode()) { stopHpMpRegeneration(); getActiveChar().setIsDead(true); getActiveChar().setIsPendingRevive(true); if (getActiveChar().hasSummon()) { getActiveChar().getSummon().getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE, null); } return; } getActiveChar().doDie(attacker); if (!Config.DISABLE_TUTORIAL) { QuestState qs = getActiveChar().getQuestState("255_Tutorial"); if (qs != null) { qs.getQuest().notifyEvent("CE30", null, getActiveChar()); } } } }