/** * Claims the hero status for the given player. * * @param player the player to become hero */ public void claimHero(L2PcInstance player) { _heroes.get(player.getObjectId()).set(CLAIMED, true); final L2Clan clan = player.getClan(); if ((clan != null) && (clan.getLevel() >= 5)) { clan.addReputationScore(Config.HERO_POINTS, true); final SystemMessage sm = SystemMessage.getSystemMessage( SystemMessageId.CLAN_MEMBER_C1_BECAME_HERO_AND_GAINED_S2_REPUTATION_POINTS); sm.addString(CharNameTable.getInstance().getNameById(player.getObjectId())); sm.addInt(Config.HERO_POINTS); clan.broadcastToOnlineMembers(sm); } player.setHero(true); player.broadcastPacket(new SocialAction(player.getObjectId(), 20016)); // Hero Animation player.sendPacket(new UserInfo(player)); player.sendPacket(new ExBrExtraUserInfo(player)); player.broadcastUserInfo(); // Set Gained hero and reload data setHeroGained(player.getObjectId()); loadFights(player.getObjectId()); loadDiary(player.getObjectId()); _heroMessage.put(player.getObjectId(), ""); updateHeroes(false); }
public static void showFishSkillList(L2PcInstance player) { final List<L2SkillLearn> skills = SkillTreesData.getInstance().getAvailableFishingSkills(player); final AcquireSkillList asl = new AcquireSkillList(AcquireSkillType.FISHING); int count = 0; for (L2SkillLearn s : skills) { final Skill sk = SkillData.getInstance().getSkill(s.getSkillId(), s.getSkillLevel()); if (sk == null) { continue; } count++; asl.addSkill(s.getSkillId(), s.getSkillLevel(), s.getSkillLevel(), s.getLevelUpSp(), 1); } if (count == 0) { final int minlLevel = SkillTreesData.getInstance() .getMinLevelForNewSkill(player, SkillTreesData.getInstance().getFishingSkillTree()); if (minlLevel > 0) { SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.DO_NOT_HAVE_FURTHER_SKILLS_TO_LEARN_S1); sm.addInt(minlLevel); player.sendPacket(sm); } else { player.sendPacket(SystemMessageId.NO_MORE_SKILLS_TO_LEARN); } } else { player.sendPacket(asl); } }
@Override public void onStart(BuffInfo info) { L2Character target = info.getEffected(); if ((target == null) || target.isDead() || target.isDoor()) { return; } double amount = 0; double power = _power; boolean full = (power == 100.0); amount = full ? target.getMaxMp() : (target.getMaxMp() * power) / 100.0; // Prevents overheal and negative amount amount = Math.max(Math.min(amount, target.getMaxRecoverableMp() - target.getCurrentMp()), 0); if (amount != 0) { target.setCurrentMp(amount + target.getCurrentMp()); } SystemMessage sm; if (info.getEffector().getObjectId() != target.getObjectId()) { sm = SystemMessage.getSystemMessage(SystemMessageId.S2_MP_RESTORED_BY_C1); sm.addCharName(info.getEffector()); } else { sm = SystemMessage.getSystemMessage(SystemMessageId.S1_MP_RESTORED); } sm.addInt((int) amount); target.sendPacket(sm); }
private String giveReputation( L2Npc npc, L2PcInstance player, int count, int itemId, int itemCount) { if (getQuestItemsCount(player, itemId) >= itemCount) { takeItems(player, itemId, itemCount); player.getClan().addReputationScore(count, true); final SystemMessage sm = SystemMessage.getSystemMessage( SystemMessageId.YOUR_CLAN_HAS_ADDED_S1_POINT_S_TO_ITS_CLAN_REPUTATION); sm.addInt(count); player.sendPacket(sm); return npc.getId() + "-04.html"; } return npc.getId() + "-03.html"; }
@Override public boolean useUserCommand(int id, L2PcInstance activeChar) { if (id != COMMAND_IDS[0]) { return false; } int nobleObjId = activeChar.getObjectId(); final L2Object target = activeChar.getTarget(); if (target != null) { if (target.isPlayer() && target.getActingPlayer().isNoble()) { nobleObjId = target.getObjectId(); } else { activeChar.sendPacket(SystemMessageId.NOBLESSE_ONLY); return false; } } else if (!activeChar.isNoble()) { activeChar.sendPacket(SystemMessageId.NOBLESSE_ONLY); return false; } final SystemMessage sm = SystemMessage.getSystemMessage( SystemMessageId .THE_CURRENT_RECORD_FOR_THIS_OLYMPIAD_SESSION_IS_S1_MATCHES_S2_WINS_S3_DEFEATS_YOU_HAVE_EARNED_S4_OLYMPIAD_POINTS); sm.addInt(Olympiad.getInstance().getCompetitionDone(nobleObjId)); sm.addInt(Olympiad.getInstance().getCompetitionWon(nobleObjId)); sm.addInt(Olympiad.getInstance().getCompetitionLost(nobleObjId)); sm.addInt(Olympiad.getInstance().getNoblePoints(nobleObjId)); activeChar.sendPacket(sm); final SystemMessage sm2 = SystemMessage.getSystemMessage( SystemMessageId .YOU_HAVE_S1_MATCHES_REMAINING_THAT_YOU_CAN_PARTECIPATE_IN_THIS_WEEK_S2_CLASSED_S3_NON_CLASSED_S4_TEAM); sm2.addInt(Olympiad.getInstance().getRemainingWeeklyMatches(nobleObjId)); sm2.addInt(Olympiad.getInstance().getRemainingWeeklyMatchesClassed(nobleObjId)); sm2.addInt(Olympiad.getInstance().getRemainingWeeklyMatchesNonClassed(nobleObjId)); sm2.addInt(Olympiad.getInstance().getRemainingWeeklyMatchesTeam(nobleObjId)); activeChar.sendPacket(sm2); return true; }
/** * Do the countdown and send message to players if necessary * * @return current count */ public int countdown() { _countdown--; if (_countdown > 3) { return _countdown; } // Broadcast countdown to duelists SystemMessage sm = null; if (_countdown > 0) { sm = SystemMessage.getSystemMessage(SystemMessageId.THE_DUEL_WILL_BEGIN_IN_S1_SECOND_S); sm.addInt(_countdown); } else { sm = SystemMessage.getSystemMessage(SystemMessageId.LET_THE_DUEL_BEGIN); } broadcastToTeam1(sm); broadcastToTeam2(sm); return _countdown; }
@Override public void onStart(BuffInfo info) { L2Character target = info.getEffected(); L2Character activeChar = info.getEffector(); if ((target == null) || target.isDead() || target.isDoor() || target.isInvul()) { return; } double amount = _power; double staticShotBonus = 0; int mAtkMul = 1; boolean sps = info.getSkill().isMagic() && activeChar.isChargedShot(ShotType.SPIRITSHOTS); boolean bss = info.getSkill().isMagic() && activeChar.isChargedShot(ShotType.BLESSED_SPIRITSHOTS); if (((sps || bss) && (activeChar.isPlayer() && activeChar.getActingPlayer().isMageClass())) || activeChar.isSummon()) { staticShotBonus = info.getSkill().getMpConsume(); // static bonus for spiritshots mAtkMul = bss ? 4 : 2; staticShotBonus *= bss ? 2.4 : 1.0; } else if ((sps || bss) && activeChar.isNpc()) { staticShotBonus = 2.4 * info.getSkill().getMpConsume(); // always blessed spiritshots mAtkMul = 4; } else { // no static bonus // grade dynamic bonus final L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance(); if (weaponInst != null) { mAtkMul = weaponInst.getItem().getCrystalType() == CrystalType.S84 ? 4 : weaponInst.getItem().getCrystalType() == CrystalType.S80 ? 2 : 1; } // shot dynamic bonus mAtkMul = bss ? mAtkMul * 4 : mAtkMul + 1; } if (!info.getSkill().isStatic()) { amount += staticShotBonus + Math.sqrt(mAtkMul * activeChar.getMAtk(activeChar, null)); amount = target.calcStat(Stats.HEAL_EFFECT, amount, null, null); // Heal critic, since CT2.3 Gracia Final if (info.getSkill().isMagic() && Formulas.calcMCrit(activeChar.getMCriticalHit(target, info.getSkill()))) { amount *= 3; activeChar.sendPacket(SystemMessageId.M_CRITICAL); activeChar.sendPacket( new ExMagicAttackInfo( activeChar.getObjectId(), target.getObjectId(), ExMagicAttackInfo.CRITICAL_HEAL)); if (target.isPlayer() && (target != activeChar)) { target.sendPacket( new ExMagicAttackInfo( activeChar.getObjectId(), target.getObjectId(), ExMagicAttackInfo.CRITICAL_HEAL)); } } } // Prevents overheal and negative amount final double healAmount = Math.max(Math.min(amount, target.getMaxRecoverableHp() - target.getCurrentHp()), 0); if (healAmount != 0) { target.setCurrentHp(healAmount + target.getCurrentHp()); } if (target.isPlayer()) { if (info.getSkill().getId() == 4051) { target.sendPacket(SystemMessageId.REJUVENATING_HP); } else if (healAmount != 0) { if (activeChar.isPlayer() && (activeChar != target)) { SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S2_HP_HAS_BEEN_RESTORED_BY_C1); sm.addString(activeChar.getName()); sm.addInt((int) healAmount); target.sendPacket(sm); } else { SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HP_HAS_BEEN_RESTORED); sm.addInt((int) healAmount); target.sendPacket(sm); } } amount = Math.max( Math.min(amount - healAmount, target.getMaxRecoverableCp() - target.getCurrentCp()), 0); if (amount != 0) { target.setCurrentCp(amount + target.getCurrentCp()); if (activeChar.isPlayer() && (activeChar != target)) { SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S2_CP_HAS_BEEN_RESTORED_BY_C1); sm.addString(activeChar.getName()); sm.addInt((int) amount); target.sendPacket(sm); } else { SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_CP_HAS_BEEN_RESTORED); sm.addInt((int) amount); target.sendPacket(sm); } } } }
public void usePumping(int dmg, int pen) { _anim = 1; if (Rnd.get(100) > 90) { _fisher.sendPacket(SystemMessageId.THE_FISH_HAS_RESISTED_YOUR_ATTEMPT_TO_BRING_IT_IN); _goodUse = 0; changeHp(0, pen); return; } if (_fisher == null) { return; } if (_mode == 0) { if (_deceptiveMode == 0) { // Pumping is successful. Damage: $s1 SystemMessage sm = SystemMessage.getSystemMessage( SystemMessageId.YOUR_PUMPING_IS_SUCCESSFUL_CAUSING_S1_DAMAGE); sm.addInt(dmg); _fisher.sendPacket(sm); if (pen > 0) { sm = SystemMessage.getSystemMessage(SystemMessageId.PUMPING_SUCCESSFUL_MASTERY_PENALTY_S1); sm.addInt(pen); _fisher.sendPacket(sm); } _goodUse = 1; changeHp(dmg, pen); } else { // Pumping failed, Regained: $s1 SystemMessage sm = SystemMessage.getSystemMessage( SystemMessageId.YOU_FAILED_TO_DO_ANYTHING_WITH_THE_FISH_AND_IT_REGAINS_S1_HP); sm.addInt(dmg); _fisher.sendPacket(sm); _goodUse = 2; changeHp(-dmg, pen); } } else { if (_deceptiveMode == 0) { // Pumping failed, Regained: $s1 SystemMessage sm = SystemMessage.getSystemMessage( SystemMessageId.YOU_FAILED_TO_DO_ANYTHING_WITH_THE_FISH_AND_IT_REGAINS_S1_HP); sm.addInt(dmg); _fisher.sendPacket(sm); _goodUse = 2; changeHp(-dmg, pen); } else { // Pumping is successful. Damage: $s1 SystemMessage sm = SystemMessage.getSystemMessage( SystemMessageId.YOUR_PUMPING_IS_SUCCESSFUL_CAUSING_S1_DAMAGE); sm.addInt(dmg); _fisher.sendPacket(sm); if (pen > 0) { sm = SystemMessage.getSystemMessage(SystemMessageId.PUMPING_SUCCESSFUL_MASTERY_PENALTY_S1); sm.addInt(pen); _fisher.sendPacket(sm); } _goodUse = 1; changeHp(dmg, pen); } } }
public void useReeling(int dmg, int pen) { _anim = 2; if (Rnd.get(100) > 90) { _fisher.sendPacket(SystemMessageId.THE_FISH_HAS_RESISTED_YOUR_ATTEMPT_TO_BRING_IT_IN); _goodUse = 0; changeHp(0, pen); return; } if (_fisher == null) { return; } if (_mode == 1) { if (_deceptiveMode == 0) { // Reeling is successful, Damage: $s1 SystemMessage sm = SystemMessage.getSystemMessage( SystemMessageId.YOU_REEL_THAT_FISH_IN_CLOSER_AND_CAUSE_S1_DAMAGE); sm.addInt(dmg); _fisher.sendPacket(sm); if (pen > 0) { sm = SystemMessage.getSystemMessage(SystemMessageId.REELING_SUCCESSFUL_MASTERY_PENALTY_S1); sm.addInt(pen); _fisher.sendPacket(sm); } _goodUse = 1; changeHp(dmg, pen); } else { // Reeling failed, Damage: $s1 SystemMessage sm = SystemMessage.getSystemMessage( SystemMessageId.YOU_FAILED_TO_REEL_THAT_FISH_IN_FURTHER_AND_IT_REGAINS_S1_HP); sm.addInt(dmg); _fisher.sendPacket(sm); _goodUse = 2; changeHp(-dmg, pen); } } else { if (_deceptiveMode == 0) { // Reeling failed, Damage: $s1 SystemMessage sm = SystemMessage.getSystemMessage( SystemMessageId.YOU_FAILED_TO_REEL_THAT_FISH_IN_FURTHER_AND_IT_REGAINS_S1_HP); sm.addInt(dmg); _fisher.sendPacket(sm); _goodUse = 2; changeHp(-dmg, pen); } else { // Reeling is successful, Damage: $s1 SystemMessage sm = SystemMessage.getSystemMessage( SystemMessageId.YOU_REEL_THAT_FISH_IN_CLOSER_AND_CAUSE_S1_DAMAGE); sm.addInt(dmg); _fisher.sendPacket(sm); if (pen > 0) { sm = SystemMessage.getSystemMessage(SystemMessageId.REELING_SUCCESSFUL_MASTERY_PENALTY_S1); sm.addInt(pen); _fisher.sendPacket(sm); } _goodUse = 1; changeHp(dmg, pen); } } }
@Override protected void runImpl() { L2PcInstance activeChar = getClient().getActiveChar(); if (activeChar == null) { _log.fine("RequestCrystalizeItem: activeChar was null"); return; } if (!getClient().getFloodProtectors().getTransaction().tryPerformAction("crystallize")) { activeChar.sendMessage("You are crystallizing too fast."); return; } if (_count <= 0) { Util.handleIllegalPlayerAction( activeChar, "[RequestCrystallizeItem] count <= 0! ban! oid: " + _objectId + " owner: " + activeChar.getName(), Config.DEFAULT_PUNISH); return; } if ((activeChar.getPrivateStoreType() != PrivateStoreType.NONE) || !activeChar.isInCrystallize()) { activeChar.sendPacket( SystemMessageId .WHILE_OPERATING_A_PRIVATE_STORE_OR_WORKSHOP_YOU_CANNOT_DISCARD_DESTROY_OR_TRADE_AN_ITEM); return; } int skillLevel = activeChar.getSkillLevel(CommonSkill.CRYSTALLIZE.getId()); if (skillLevel <= 0) { activeChar.sendPacket( SystemMessageId .YOU_MAY_NOT_CRYSTALLIZE_THIS_ITEM_YOUR_CRYSTALLIZATION_SKILL_LEVEL_IS_TOO_LOW); activeChar.sendPacket(ActionFailed.STATIC_PACKET); if ((activeChar.getRace() != Race.DWARF) && (activeChar.getClassId().ordinal() != 117) && (activeChar.getClassId().ordinal() != 55)) { _log.info( "Player " + activeChar.getClient() + " used crystalize with classid: " + activeChar.getClassId().ordinal()); } return; } PcInventory inventory = activeChar.getInventory(); if (inventory != null) { L2ItemInstance item = inventory.getItemByObjectId(_objectId); if (item == null) { activeChar.sendPacket(ActionFailed.STATIC_PACKET); return; } if (item.isHeroItem()) { return; } if (_count > item.getCount()) { _count = activeChar.getInventory().getItemByObjectId(_objectId).getCount(); } } final L2ItemInstance itemToRemove = activeChar.getInventory().getItemByObjectId(_objectId); if ((itemToRemove == null) || itemToRemove.isShadowItem() || itemToRemove.isTimeLimitedItem()) { return; } if (!itemToRemove.getItem().isCrystallizable() || (itemToRemove.getItem().getCrystalCount() <= 0) || (itemToRemove.getItem().getCrystalType() == CrystalType.NONE)) { _log.warning( activeChar.getName() + " (" + activeChar.getObjectId() + ") tried to crystallize " + itemToRemove.getItem().getId()); return; } if (!activeChar.getInventory().canManipulateWithItemId(itemToRemove.getId())) { activeChar.sendMessage("You cannot use this item."); return; } // Check if the char can crystallize items and return if false; boolean canCrystallize = true; switch (itemToRemove.getItem().getCrystalTypePlus()) { case D: { if (skillLevel < 1) { canCrystallize = false; } break; } case C: { if (skillLevel < 2) { canCrystallize = false; } break; } case B: { if (skillLevel < 3) { canCrystallize = false; } break; } case A: { if (skillLevel < 4) { canCrystallize = false; } break; } case S: { if (skillLevel < 5) { canCrystallize = false; } break; } case R: { if (skillLevel < 6) { canCrystallize = false; } break; } } if (!canCrystallize) { activeChar.sendPacket( SystemMessageId .YOU_MAY_NOT_CRYSTALLIZE_THIS_ITEM_YOUR_CRYSTALLIZATION_SKILL_LEVEL_IS_TOO_LOW); activeChar.sendPacket(ActionFailed.STATIC_PACKET); return; } // activeChar.setInCrystallize(true); // unequip if needed SystemMessage sm; if (itemToRemove.isEquipped()) { L2ItemInstance[] unequiped = activeChar.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getLocationSlot()); InventoryUpdate iu = new InventoryUpdate(); for (L2ItemInstance item : unequiped) { iu.addModifiedItem(item); } activeChar.sendPacket(iu); if (itemToRemove.getEnchantLevel() > 0) { sm = SystemMessage.getSystemMessage(SystemMessageId.THE_EQUIPMENT_S1_S2_HAS_BEEN_REMOVED); sm.addInt(itemToRemove.getEnchantLevel()); sm.addItemName(itemToRemove); } else { sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED); sm.addItemName(itemToRemove); } activeChar.sendPacket(sm); } // remove from inventory final L2ItemInstance removedItem = activeChar.getInventory().destroyItem("Crystalize", _objectId, _count, activeChar, null); final InventoryUpdate iu = new InventoryUpdate(); iu.addRemovedItem(removedItem); activeChar.sendPacket(iu); final int crystalId = itemToRemove.getItem().getCrystalItemId(); final int crystalAmount = itemToRemove.getCrystalCount(); final List<ItemChanceHolder> items = new ArrayList<>(); items.add(new ItemChanceHolder(crystalId, 100, crystalAmount)); final CrystalizationData data = ItemCrystalizationData.getInstance().getCrystalization(itemToRemove.getId()); if (data != null) { data.getItems().stream().filter(holder -> (holder.getId() != crystalId)).forEach(items::add); } for (ItemChanceHolder holder : items) { final double rand = Rnd.nextDouble() * 100; if (rand < holder.getChance()) { // add crystals final L2ItemInstance createdItem = activeChar .getInventory() .addItem("Crystalize", holder.getId(), holder.getCount(), activeChar, activeChar); sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S2_S1_S); sm.addItemName(createdItem); sm.addLong(holder.getCount()); activeChar.sendPacket(sm); } } sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_BEEN_CRYSTALLIZED); sm.addItemName(removedItem); activeChar.sendPacket(sm); activeChar.broadcastUserInfo(); L2World.getInstance().removeObject(removedItem); activeChar.setInCrystallize(false); }