private static void makeSupportMagic(L2PcInstance player, L2Npc npc, boolean isSummon) { final int level = player.getLevel(); if (isSummon && !player.hasServitor()) { npc.showChatWindow(player, "data/html/default/SupportMagicNoSummon.htm"); return; } else if (level > HIGHEST_LEVEL) { npc.showChatWindow(player, "data/html/default/SupportMagicHighLevel.htm"); return; } else if (level < LOWEST_LEVEL) { npc.showChatWindow(player, "data/html/default/SupportMagicLowLevel.htm"); return; } else if (player.getClassId().level() == 3) { player.sendMessage( "Only adventurers who have not completed their 3rd class transfer may receive these buffs."); // Custom message return; } if (isSummon) { npc.setTarget(player.getSummon()); for (SkillHolder skill : SUMMON_BUFFS) { npc.doCast(skill.getSkill()); } if (level >= HASTE_LEVEL_2) { npc.doCast(HASTE_2.getSkill()); } else { npc.doCast(HASTE_1.getSkill()); } } else { npc.setTarget(player); if (player.isInCategory(CategoryType.BEGINNER_MAGE)) { for (SkillHolder skill : MAGE_BUFFS) { npc.doCast(skill.getSkill()); } } else { for (SkillHolder skill : FIGHTER_BUFFS) { npc.doCast(skill.getSkill()); } if (level >= HASTE_LEVEL_2) { npc.doCast(HASTE_2.getSkill()); } else { npc.doCast(HASTE_1.getSkill()); } } if ((level >= CUBIC_LOWEST) && (level <= CUBIC_HIGHEST)) { player.doSimultaneousCast(CUBIC.getSkill()); } } }
@Override public String onAttack( L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon, Skill skill) { final L2Playable playable = (isSummon) ? attacker.getSummon() : attacker; final int longRangeGuardRate = npc.getTemplate().getParameters().getInt("LongRangeGuardRate"); final double distance = Util.calculateDistance(npc, playable, true, false); if (npc.isAffectedBySkill(ULTIMATE_DEFENSE.getSkillId()) && (distance <= MIN_DISTANCE)) { npc.stopSkillEffects(true, ULTIMATE_DEFENSE.getSkillId()); } else if ((distance > MIN_DISTANCE) && !npc.isSkillDisabled(ULTIMATE_DEFENSE.getSkillId()) && !((skill != null) && Util.contains(NOT_ALLOWED_SKILLS, skill.getId())) && (getRandom(100) < longRangeGuardRate)) { npc.setTarget(npc); npc.doCast(ULTIMATE_DEFENSE.getSkill()); } return super.onAttack(npc, attacker, damage, isSummon, skill); }
@Override public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) { final QuestState qs = getQuestState(player, false); if (qs == null) { return null; } String htmltext = null; switch (event) { case "ACCEPT": { qs.startQuest(); if ((player.getLevel() > 20) && (player.getLevel() < 31)) { playSound(player, QuestSound.ITEMSOUND_QUEST_ACCEPT); qs.setMemoState(2); qs.setCond(3); htmltext = "30981-04.htm"; } else if (player.getLevel() < 21) { qs.setMemoState(1); qs.setMemoStateEx(1, 0); qs.setCond(2); htmltext = "30981-03.htm"; } else if ((player.getLevel() > 30) && (player.getLevel() < 41)) { qs.setMemoState(3); qs.setCond(4); htmltext = "30981-05.htm"; } else { qs.setMemoState(4); qs.setCond(5); htmltext = "30981-06.htm"; } break; } case "30981-11.html": { if ((qs.getMemoState() >= 9) && (qs.getMemoState() <= 12)) { if (hasAtLeastOneQuestItem(player, MANACLES_OF_PENITENT, PENITENTS_MANACLES1)) { if (hasQuestItems(player, PENITENTS_MANACLES1)) { takeItems(player, PENITENTS_MANACLES1, 1); } if (hasQuestItems(player, MANACLES_OF_PENITENT)) { takeItems(player, MANACLES_OF_PENITENT, 1); } qs.setMemoStateEx(1, player.getLevel()); giveItems(player, PENITENTS_MANACLES, 1); qs.setCond(16); htmltext = event; } } break; } case "30981-14.html": case "30981-17.html": { if ((qs.getMemoState() >= 9) && (qs.getMemoState() <= 12)) { htmltext = event; } break; } case "30981-15t.html": { final L2ItemInstance petItem = player.getInventory().getItemByItemId(PENITENTS_MANACLES); final int petLevel = (petItem == null) ? 0 : petItem.getEnchantLevel(); if ((qs.getMemoState() >= 9) && (qs.getMemoState() <= 12) && (petLevel > qs.getMemoStateEx(1))) { final L2Summon summon = player.getSummon(); if (summon != null) { htmltext = event; } else { int i1 = 0; if (player.getLevel() > qs.getMemoStateEx(1)) { i1 = petLevel - qs.getMemoStateEx(1) - (player.getLevel() - qs.getMemoStateEx(1)); } else { i1 = petLevel - qs.getMemoStateEx(1); } if (i1 < 0) { i1 = 0; } int i0 = getRandom(i1) + 1; if (player.getPkKills() <= i0) { giveItems(player, MANACLES_OF_PENITENT, 1); if (petItem != null) { takeItems(player, PENITENTS_MANACLES, -1); } htmltext = "30981-15.html"; player.setPkKills(0); qs.exitQuest(true, true); } else { giveItems(player, MANACLES_OF_PENITENT, 1); if (petItem != null) { takeItems(player, PENITENTS_MANACLES, -1); } htmltext = "30981-16.html"; player.setPkKills(player.getPkKills() - i0); qs.setMemoStateEx(1, 0); } } } break; } case "30981-18.html": { if ((qs.getMemoState() >= 9) && (qs.getMemoState() <= 12)) { qs.exitQuest(true, true); htmltext = event; } break; } } return htmltext; }