rendered paste body /** * Checks if attacker can attack target * * @param attacker * @param target * @param ctrlPressed * @param sendSysMsg - send systemMessages. Depends on bySkill switch. * @param bySkill - false: simple attack , true: check is used in skills * @return */ public static boolean isPcEnemies(final L2PcInstance attacker, final L2PcInstance target, boolean ctrlPressed, boolean sendSysMsg, boolean bySkill) { if (attacker == target) return false; // cannot attack self if (target.isTransformed() && !target.getTransformation().canBeAttacked()) return false; // ========================= // ZONE_PEACE checks // ========================= if (attacker.isInsideZone(L2Character.ZONE_PEACE)) { if (ctrlPressed && sendSysMsg) { if (bySkill) attacker.getSkillUseManager().setFailureSysMsg(SystemMessageId.A_MALICIOUS_SKILL_CANNOT_BE_USED_IN_PEACE_ZONE); else attacker.sendPacket(SystemMessageId.CANT_ATK_PEACEZONE); } return false; // cannot attack in peace zone } if (target.isInsideZone(L2Character.ZONE_PEACE)) { if (ctrlPressed && sendSysMsg) { if (bySkill) attacker.getSkillUseManager().setFailureSysMsg(SystemMessageId.CANT_USE_BAD_MAGIC_WHEN_OPPONENT_IN_PEACE_ZONE); else attacker.sendPacket(SystemMessageId.TARGET_IN_PEACEZONE); } return false; // cannot attack in peace zone } // ========================= // PK protection // ========================= if (target.isPkProtected() && (attacker.getLevel() - target.getLevel()) >= 10 && attacker.getKarma() > 0 && !(target.isInsideZone(L2Character.ZONE_BATTLE))) { // If attacker have karma and have level >= 10 than his target and target have // Newbie Protection Buff, attacker.getActingPlayer().sendPacket(SystemMessageId.TARGET_IS_INCORRECT); return false; } if (attacker.isPkProtected() && (target.getLevel() - attacker.getLevel()) >= 10 && target.getKarma() > 0 && !(target.isInsideZone(L2Character.ZONE_BATTLE))) { // If target have karma and have level >= 10 than his target and actor have // Newbie Protection Buff, attacker.sendPacket(SystemMessageId.TARGET_IS_INCORRECT); return false; } // ========================= // Cursed Weapons // ========================= if (target.isCursedWeaponEquipped() && attacker.getLevel() <= 20) { attacker.sendPacket(SystemMessageId.TARGET_IS_INCORRECT); return false; } if (attacker.isCursedWeaponEquipped() && target.getLevel() <= 20) { attacker.sendPacket(SystemMessageId.TARGET_IS_INCORRECT); return false; } // ========================= // Olympiad check // ========================= if (attacker.getOlympiadEx().isInOlympiadMode()) { if (target.getOlympiadEx().isInOlympiadMode() && target.getOlympiadEx().isOlympiadStart() && attacker.getOlympiadEx().getOlympiadGameId() == target.getOlympiadEx().getOlympiadGameId()) return true; else return false; } // ========================= // Duel check // ========================= if (attacker.isInDuel() && target.isInDuel() && (target.getDuelId() == attacker.getDuelId())) return true; // duel can attack // ========================= // ZONE_BATTLE / ZONE_BATTLEFIELD // ========================= if (isInSameZone(attacker, target, L2Character.ZONE_BATTLE) || isInSameZone(attacker, target, L2Character.ZONE_BATTLEFIELD)) { if (attacker.isInParty() && target.isInParty()) { if (attacker.getParty() == target.getParty() || attacker.getParty().getCommandChannel() == target.getParty().getCommandChannel()) return ctrlPressed;// Same party } return true; } // ========================= // Normal field checks // ========================= if (attacker.isInParty() && target.isInParty()) { // same party || same command channel if (attacker.getParty() == target.getParty() || attacker.getParty().getCommandChannel() == target.getParty().getCommandChannel()) return ctrlPressed;// Same party } if (attacker.getClan() != null && target.getClan() != null) { // ========================= // Siege handling // ========================= if (attacker.isInSiege()) { if (attacker.isInTempSiegeAlly(target.getActingPlayer())) { if (sendSysMsg && ctrlPressed) { if (DominionSiege.getIsInProgress()) attacker.sendPacket(SystemMessageId.YOU_CANNOT_ATTACK_A_MEMBER_OF_THE_SAME_TERRITORY); else attacker.sendPacket(SystemMessageId.FORCED_ATTACK_IS_IMPOSSIBLE_AGAINST_SIEGE_SIDE_TEMPORARY_ALLIED_MEMBERS); } return false; } else return true; } // ========================= // Unrelated player // ========================= if (ctrlPressed) return true; // allow force attack if (attacker.getClanId() == target.getClanId()) return false; if ((attacker.getAllyId() > 0 || target.getAllyId() > 0) && (attacker.getAllyId() == target.getAllyId())) return false; if (attacker.getClan().isAtWarWith(target.getClanId()) && target.getClan().isAtWarWith(attacker.getClanId()) && attacker.getWantsPeace() == 0 && target.getWantsPeace() == 0 && !attacker.isAcademyMember()) return true; } if (target.getPvpFlag() > 0 || target.getKarma() > 0) return true; return ctrlPressed; }