@Override public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon) { QuestState st = getQuestState(killer, false); if (st == null) { return null; } final int npcId = npc.getId(); if (killer.getParty() != null) { final List<QuestState> PartyMembers = new ArrayList<>(); for (L2PcInstance member : killer.getParty().getMembers()) { st = getQuestState(member, false); if ((st != null) && st.isStarted() && !st.hasQuestItems(TISSUE_WA)) { PartyMembers.add(st); } } if (!PartyMembers.isEmpty()) { rewardItem(npcId, PartyMembers.get(getRandom(PartyMembers.size()))); } } else if (st.isStarted() && !st.hasQuestItems(TISSUE_WA)) { rewardItem(npcId, st); } return null; }
/** * Restore player conditions * * @param abnormalDuelEnd true if the duel was the duel canceled */ public void restorePlayerConditions(boolean abnormalDuelEnd) { // update isInDuel() state for all players if (_partyDuel) { for (L2PcInstance temp : _playerA.getParty().getMembers()) { temp.setIsInDuel(0); temp.setTeam(Team.NONE); temp.broadcastUserInfo(); } for (L2PcInstance temp : _playerB.getParty().getMembers()) { temp.setIsInDuel(0); temp.setTeam(Team.NONE); temp.broadcastUserInfo(); } } else { _playerA.setIsInDuel(0); _playerA.setTeam(Team.NONE); _playerA.broadcastUserInfo(); _playerB.setIsInDuel(0); _playerB.setTeam(Team.NONE); _playerB.broadcastUserInfo(); } // if it is an abnormal DuelEnd do not restore hp, mp, cp if (abnormalDuelEnd) { return; } // restore player conditions _playerConditions.values().forEach(c -> c.restoreCondition()); }
/** * This function is called whenever a player was defeated in a duel * * @param player the player defeated. */ public void onPlayerDefeat(L2PcInstance player) { // Set player as defeated player.setDuelState(DUELSTATE_DEAD); if (_partyDuel) { boolean teamdefeated = true; for (L2PcInstance temp : player.getParty().getMembers()) { if (temp.getDuelState() == DUELSTATE_DUELLING) { teamdefeated = false; break; } } if (teamdefeated) { L2PcInstance winner = _playerA; if (_playerA.getParty().getMembers().contains(player)) { winner = _playerB; } for (L2PcInstance temp : winner.getParty().getMembers()) { temp.setDuelState(DUELSTATE_WINNER); } } } else { if ((player != _playerA) && (player != _playerB)) { _log.warning("Error in onPlayerDefeat(): player is not part of this 1vs1 duel"); } if (_playerA == player) { _playerB.setDuelState(DUELSTATE_WINNER); } else { _playerA.setDuelState(DUELSTATE_WINNER); } } }
private String checkConditions(L2PcInstance player) { if (player.getParty() == null) { return "gk-noparty.htm"; } else if (!player.getParty().isLeader(player)) { return "gk-noleader.htm"; } return null; }
/** Save the current player condition: hp, mp, cp, location */ public void savePlayerConditions() { if (_partyDuel) { for (L2PcInstance player : _playerA.getParty().getMembers()) { _playerConditions.put(player.getObjectId(), new PlayerCondition(player, _partyDuel)); } for (L2PcInstance player : _playerB.getParty().getMembers()) { _playerConditions.put(player.getObjectId(), new PlayerCondition(player, _partyDuel)); } } else { _playerConditions.put(_playerA.getObjectId(), new PlayerCondition(_playerA, _partyDuel)); _playerConditions.put(_playerB.getObjectId(), new PlayerCondition(_playerB, _partyDuel)); } }
/** * Broadcast a packet to the challenged team * * @param packet */ public void broadcastToTeam2(L2GameServerPacket packet) { if (_playerB == null) { return; } if (_partyDuel && (_playerB.getParty() != null)) { for (L2PcInstance temp : _playerB.getParty().getMembers()) { temp.sendPacket(packet); } } else { _playerB.sendPacket(packet); } }
/** Playback the bow animation for all looser */ public void playKneelAnimation() { L2PcInstance looser = getLooser(); if (looser == null) { return; } if (_partyDuel && (looser.getParty() != null)) { for (L2PcInstance temp : looser.getParty().getMembers()) { temp.broadcastPacket(new SocialAction(temp.getObjectId(), 7)); } } else { looser.broadcastPacket(new SocialAction(looser.getObjectId(), 7)); } }
@Override public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon) { final List<L2PcInstance> randomList = new ArrayList<>(); final QuestState st = killer.getQuestState(getName()); if ((st != null) && st.isStarted()) { randomList.add(killer); randomList.add(killer); } final int monsterChance = MONSTER_DROP_CHANCES.get(npc.getId()); if (killer.isInParty()) { for (L2PcInstance member : killer.getParty().getMembers()) { final QuestState qs = member.getQuestState(getName()); if ((qs != null) && qs.isStarted()) { randomList.add(member); } } } if (!randomList.isEmpty()) { final L2PcInstance player = randomList.get(getRandom(randomList.size())); if ((getRandom(1000) < monsterChance) && Util.checkIfInRange(1500, npc, player, true)) { giveItems(player, REMNANTS_OF_OLD_DWARVES_DREAMS, 1); playSound(player, QuestSound.ITEMSOUND_QUEST_ITEMGET); } } return super.onKill(npc, killer, isSummon); }
@Override public void onStart(BuffInfo info) { if ((info.getEffector() == null) || (info.getEffected() == null) || !info.getEffector().isPlayer() || !info.getEffected().isAttackable()) { return; } final L2PcInstance player = info.getEffector().getActingPlayer(); final L2Attackable monster = (L2Attackable) info.getEffected(); if (!monster.checkSpoilOwner(player, false)) { return; } if (!player .getInventory() .checkInventorySlotsAndWeight(monster.getSpoilLootItems(), false, false)) { return; } final Collection<ItemHolder> items = monster.takeSweep(); if (items != null) { for (ItemHolder item : items) { if (player.isInParty()) { player.getParty().distributeItem(player, item, true, monster); } else { player.addItem("Sweeper", item, info.getEffected(), true); } } } }
private boolean checkTeleport(L2PcInstance player) { final L2Party party = player.getParty(); if (party == null) { return false; } if (!party.isLeader(player)) { player.sendPacket(SystemMessageId.ONLY_PARTY_LEADER_CAN_ENTER); return false; } for (L2PcInstance partyMember : party.getMembers()) { if (partyMember.getLevel() < 78) { final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_LEVEL_REQUIREMENT_NOT_SUFFICIENT); sm.addPcName(partyMember); party.broadcastPacket(sm); return false; } if (!Util.checkIfInRange(500, player, partyMember, true)) { final SystemMessage sm = SystemMessage.getSystemMessage( SystemMessageId.C1_IS_IN_LOCATION_THAT_CANNOT_BE_ENTERED); sm.addPcName(partyMember); party.broadcastPacket(sm); return false; } if (InstanceManager.getInstance().getPlayerWorld(player) != null) { final SystemMessage sm = SystemMessage.getSystemMessage( SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER); sm.addPcName(partyMember); party.broadcastPacket(sm); return false; } Long reentertime = InstanceManager.getInstance().getInstanceTime(partyMember.getObjectId(), TEMPLATE_ID); if (System.currentTimeMillis() < reentertime) { SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_MAY_NOT_REENTER_YET); sm.addPcName(partyMember); party.broadcastPacket(sm); return false; } if (partyMember.getInventory().getInventoryItemCount(SEAL_BREAKER_5, -1, false) < 1) { SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_QUEST_REQUIREMENT_NOT_SUFFICIENT); sm.addPcName(partyMember); party.broadcastPacket(sm); return false; } } return true; }
public void addDuel(L2PcInstance playerA, L2PcInstance playerB, int partyDuel) { if ((playerA == null) || (playerB == null)) { return; } // return if a player has PvPFlag String engagedInPvP = "The duel was canceled because a duelist engaged in PvP combat."; if (partyDuel == 1) { boolean playerInPvP = false; for (L2PcInstance temp : playerA.getParty().getMembers()) { if (temp.getPvpFlag() != 0) { playerInPvP = true; break; } } if (!playerInPvP) { for (L2PcInstance temp : playerB.getParty().getMembers()) { if (temp.getPvpFlag() != 0) { playerInPvP = true; break; } } } // A player has PvP flag if (playerInPvP) { for (L2PcInstance temp : playerA.getParty().getMembers()) { temp.sendMessage(engagedInPvP); } for (L2PcInstance temp : playerB.getParty().getMembers()) { temp.sendMessage(engagedInPvP); } return; } } else { if ((playerA.getPvpFlag() != 0) || (playerB.getPvpFlag() != 0)) { playerA.sendMessage(engagedInPvP); playerB.sendMessage(engagedInPvP); return; } } final int duelId = _currentDuelId.incrementAndGet(); _duels.put(duelId, new Duel(playerA, playerB, partyDuel, duelId)); }
@Override public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon) { if (killer.isInParty()) { for (L2PcInstance member : killer.getParty().getMembers()) { giveItem(npc, member); } } else { giveItem(npc, killer); } return super.onKill(npc, killer, isSummon); }
@Override public String onFactionCall(L2Npc npc, L2Npc caller, L2PcInstance attacker, boolean isPet) { L2Character originalAttackTarget = (isPet ? attacker.getPet() : attacker); if (attacker.isInParty() && attacker.getParty().isInDimensionalRift()) { byte riftType = attacker.getParty().getDimensionalRift().getType(); byte riftRoom = attacker.getParty().getDimensionalRift().getCurrentRoom(); if (caller instanceof L2RiftInvaderInstance && !DimensionalRiftManager.getInstance() .getRoom(riftType, riftRoom) .checkIfInZone(npc.getX(), npc.getY(), npc.getZ())) { return null; } } // By default, when a faction member calls for help, attack the caller's attacker. // Notify the AI with EVT_AGGRESSION npc.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, originalAttackTarget, 1); return null; }
/** Teleports all players to a free arena. */ public void teleportPlayers() { if (!_partyDuel) { return; } final String instanceName = DuelManager.getInstance().getDuelArena(); final L2OlympiadStadiumZone zone = ZoneManager.getInstance() .getAllZones(L2OlympiadStadiumZone.class) // .stream() .filter(z -> z.getInstanceTemplate().equals(instanceName)) .findFirst() .orElse(null); if (zone == null) { throw new RuntimeException("Unable to find a party duel arena!"); } final List<Location> spawns = zone.getSpawns(); _duelInstanceId = InstanceManager.getInstance().createDynamicInstance(instanceName); // Remove Olympiad buffers for (L2Npc buffer : InstanceManager.getInstance().getInstance(getDueldInstanceId()).getNpcs()) { if ((buffer instanceof L2OlympiadManagerInstance) && buffer.isVisible()) { buffer.decayMe(); } } final Location spawn1 = spawns.get(Rnd.get(spawns.size() / 2)); for (L2PcInstance temp : _playerA.getParty().getMembers()) { temp.teleToLocation(spawn1.getX(), spawn1.getY(), spawn1.getZ(), 0, _duelInstanceId, 0); } final Location spawn2 = spawns.get(Rnd.get(spawns.size() / 2, spawns.size())); for (L2PcInstance temp : _playerB.getParty().getMembers()) { temp.teleToLocation(spawn2.getX(), spawn2.getY(), spawn2.getZ(), 0, _duelInstanceId, 0); } }
private void removeForeigners(int managerId, L2Party party) { if ((party != null) && ZONES.containsKey(managerId) && (ZoneManager.getInstance().getZoneById(ZONES.get(managerId)) != null)) { L2ZoneType zone = ZoneManager.getInstance().getZoneById(ZONES.get(managerId)); for (L2PcInstance player : zone.getPlayersInside()) { if (player != null) { L2Party charParty = player.getParty(); if ((charParty == null) || (charParty.getLeaderObjectId() != party.getLeaderObjectId())) { player.teleToLocation(16110, 243841, 11616); } } } } }
@Override public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon) { final L2PcInstance partyMember = getRandomPartyMember(player, 1); if (partyMember == null) { return super.onKill(npc, player, isSummon); } final QuestState st = getQuestState(partyMember, false); switch (npc.getId()) { case GORGOLOS: { st.giveItems(CET_1_SHEET, 1); st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET); break; } case LAST_TITAN_UTENUS: { st.giveItems(CET_2_SHEET, 1); st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET); break; } case GIANT_MARPANAK: { st.giveItems(CET_3_SHEET, 1); st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET); break; } case HEKATON_PRIME: { if (player.isInParty()) { for (L2PcInstance pl : player.getParty().getMembers()) { final QuestState qs = getQuestState(pl, false); if ((qs != null) && qs.isCond(1)) { qs.setCond(2, true); } } saveGlobalQuestVar( "Respawn", Long.toString(System.currentTimeMillis() + RESPAWN_DELAY)); } break; } } return super.onKill(npc, player, isSummon); }
@Override public final String onFirstTalk(L2Npc npc, L2PcInstance player) { final int npcId = npc.getId(); if (npcId == CONTROLLER) { if (_lock == null) { return "18492-02.htm"; } return "18492-01.htm"; } else if ((npcId >= ROOM_MANAGER_FIRST) && (npcId <= ROOM_MANAGER_LAST)) { if (_activeRooms.containsKey(npcId) && !_activeRooms.get(npcId)) { if (player.getParty() == null) { player.sendPacket(SystemMessageId.CAN_OPERATE_MACHINE_WHEN_IN_PARTY); return null; } return "manager.htm"; } } return super.onFirstTalk(npc, player); }
private void enterInstance(L2PcInstance player, String template) { InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player); if (world != null) { if (world instanceof DPFWorld) { teleportPlayer(player, ENTRY_POINT, world.getInstanceId()); return; } player.sendPacket(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER); return; } if (!checkTeleport(player)) { return; } world = new DPFWorld(); world.setInstanceId(InstanceManager.getInstance().createDynamicInstance(template)); world.setTemplateId(TEMPLATE_ID); world.addAllowed(player.getObjectId()); world.setStatus(0); InstanceManager.getInstance().addWorld(world); teleportPlayer(player, ENTRY_POINT, world.getInstanceId()); _log.info( "Tower of Infinitum - Demon Prince floor started " + template + " Instance: " + world.getInstanceId() + " created by player: " + player.getName()); for (L2PcInstance partyMember : player.getParty().getMembers()) { teleportPlayer(partyMember, ENTRY_POINT, world.getInstanceId()); partyMember.destroyItemByItemId("Quest", SEAL_BREAKER_5, 1, null, true); world.addAllowed(partyMember.getObjectId()); } }
@Override protected void runImpl() { L2PcInstance _activeChar = getClient().getActiveChar(); if (_activeChar == null) return; if (!_activeChar.isInPartyMatchRoom() && _activeChar.getParty() != null && _activeChar.getParty().getLeader() != _activeChar) { _activeChar.sendPacket(new SystemMessage(SystemMessageId.CANT_VIEW_PARTY_ROOMS)); _activeChar.sendPacket(ActionFailed.STATIC_PACKET); return; } if (_activeChar.isInPartyMatchRoom()) { // If Player is in Room show him room, not list PartyMatchRoomList _list = PartyMatchRoomList.getInstance(); if (_list == null) return; PartyMatchRoom _room = _list.getPlayerRoom(_activeChar); if (_room == null) return; _activeChar.sendPacket(new PartyMatchDetail(_activeChar, _room)); _activeChar.sendPacket(new ExPartyRoomMember(_activeChar, _room, 2)); _activeChar.setPartyRoom(_room.getId()); // _activeChar.setPartyMatching(1); _activeChar.broadcastUserInfo(); } else { // Add to waiting list PartyMatchWaitingList.getInstance().addPlayer(_activeChar); // Send Room list ListPartyWating matchList = new ListPartyWating(_activeChar, _auto, _loc, _lvl); _activeChar.sendPacket(matchList); } }
/** * Register a surrender request * * @param player the player that surrenders. */ public void doSurrender(L2PcInstance player) { // already received a surrender request if (_surrenderRequest != 0) { return; } // stop the fight stopFighting(); // TODO: Can every party member cancel a party duel? or only the party leaders? if (_partyDuel) { if (_playerA.getParty().getMembers().contains(player)) { _surrenderRequest = 1; for (L2PcInstance temp : _playerA.getParty().getMembers()) { temp.setDuelState(DUELSTATE_DEAD); } for (L2PcInstance temp : _playerB.getParty().getMembers()) { temp.setDuelState(DUELSTATE_WINNER); } } else if (_playerB.getParty().getMembers().contains(player)) { _surrenderRequest = 2; for (L2PcInstance temp : _playerB.getParty().getMembers()) { temp.setDuelState(DUELSTATE_DEAD); } for (L2PcInstance temp : _playerA.getParty().getMembers()) { temp.setDuelState(DUELSTATE_WINNER); } } } else { if (player == _playerA) { _surrenderRequest = 1; _playerA.setDuelState(DUELSTATE_DEAD); _playerB.setDuelState(DUELSTATE_WINNER); } else if (player == _playerB) { _surrenderRequest = 2; _playerB.setDuelState(DUELSTATE_DEAD); _playerA.setDuelState(DUELSTATE_WINNER); } } }
@Override protected void runImpl() { L2PcInstance activeChar = getClient().getActiveChar(); L2PcInstance targetChar = L2World.getInstance().getPlayer(_player); if (activeChar == null) { return; } if (targetChar == null) { activeChar.sendPacket( SystemMessageId.THERE_IS_NO_OPPONENT_TO_RECEIVE_YOUR_CHALLENGE_FOR_A_DUEL); return; } if (activeChar == targetChar) { activeChar.sendPacket( SystemMessageId.THERE_IS_NO_OPPONENT_TO_RECEIVE_YOUR_CHALLENGE_FOR_A_DUEL); return; } // Check if duel is possible if (!activeChar.canDuel()) { activeChar.sendPacket(SystemMessageId.YOU_ARE_UNABLE_TO_REQUEST_A_DUEL_AT_THIS_TIME); return; } else if (!targetChar.canDuel()) { activeChar.sendPacket(targetChar.getNoDuelReason()); return; } // Players may not be too far apart else if (!activeChar.isInsideRadius(targetChar, 250, false, false)) { SystemMessage msg = SystemMessage.getSystemMessage( SystemMessageId.C1_IS_TOO_FAR_AWAY_TO_RECEIVE_A_DUEL_CHALLENGE); msg.addString(targetChar.getName()); activeChar.sendPacket(msg); return; } else if (Config.FACTION_SYSTEM_ENABLED && ((activeChar.isEvil() && targetChar.isGood()) || (activeChar.isGood() && targetChar.isEvil()))) { activeChar.sendPacket(SystemMessageId.YOU_ARE_UNABLE_TO_REQUEST_A_DUEL_AT_THIS_TIME); return; } // Duel is a party duel if (_partyDuel == 1) { // Player must be in a party & the party leader if (!activeChar.isInParty() || !activeChar.getParty().isLeader(activeChar)) { activeChar.sendMessage( "You have to be the leader of a party in order to request a party duel."); return; } // Target must be in a party else if (!targetChar.isInParty()) { activeChar.sendPacket( SystemMessageId .SINCE_THE_PERSON_YOU_CHALLENGED_IS_NOT_CURRENTLY_IN_A_PARTY_THEY_CANNOT_DUEL_AGAINST_YOUR_PARTY); return; } // Target may not be of the same party else if (activeChar.getParty().containsPlayer(targetChar)) { activeChar.sendMessage("This player is a member of your own party."); return; } // Check if every player is ready for a duel for (L2PcInstance temp : activeChar.getParty().getMembers()) { if (!temp.canDuel()) { activeChar.sendMessage("Not all the members of your party are ready for a duel."); return; } } L2PcInstance partyLeader = null; // snatch party leader of targetChar's party for (L2PcInstance temp : targetChar.getParty().getMembers()) { if (partyLeader == null) { partyLeader = temp; } if (!temp.canDuel()) { activeChar.sendPacket( SystemMessageId .THE_OPPOSING_PARTY_IS_CURRENTLY_UNABLE_TO_ACCEPT_A_CHALLENGE_TO_A_DUEL); return; } } // Send request to targetChar's party leader if (partyLeader != null) { if (!partyLeader.isProcessingRequest()) { activeChar.onTransactionRequest(partyLeader); partyLeader.sendPacket(new ExDuelAskStart(activeChar.getName(), _partyDuel)); if (Config.DEBUG) { _log.fine(activeChar.getName() + " requested a duel with " + partyLeader.getName()); } SystemMessage msg = SystemMessage.getSystemMessage( SystemMessageId.C1_S_PARTY_HAS_BEEN_CHALLENGED_TO_A_DUEL); msg.addString(partyLeader.getName()); activeChar.sendPacket(msg); msg = SystemMessage.getSystemMessage( SystemMessageId.C1_S_PARTY_HAS_CHALLENGED_YOUR_PARTY_TO_A_DUEL); msg.addString(activeChar.getName()); targetChar.sendPacket(msg); } else { SystemMessage msg = SystemMessage.getSystemMessage( SystemMessageId.C1_IS_ON_ANOTHER_TASK_PLEASE_TRY_AGAIN_LATER); msg.addString(partyLeader.getName()); activeChar.sendPacket(msg); } } } else // 1vs1 duel { if (!targetChar.isProcessingRequest()) { activeChar.onTransactionRequest(targetChar); targetChar.sendPacket(new ExDuelAskStart(activeChar.getName(), _partyDuel)); if (Config.DEBUG) { _log.fine(activeChar.getName() + " requested a duel with " + targetChar.getName()); } SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_BEEN_CHALLENGED_TO_A_DUEL); msg.addString(targetChar.getName()); activeChar.sendPacket(msg); msg = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_CHALLENGED_YOU_TO_A_DUEL); msg.addString(activeChar.getName()); targetChar.sendPacket(msg); } else { SystemMessage msg = SystemMessage.getSystemMessage( SystemMessageId.C1_IS_ON_ANOTHER_TASK_PLEASE_TRY_AGAIN_LATER); msg.addString(targetChar.getName()); activeChar.sendPacket(msg); } } }
@Override protected void runImpl() { final L2PcInstance activeChar = getActiveChar(); if (activeChar == null) { return; } if (Config.DEBUG) { _log.info( getType() + ": " + activeChar + " requested action use ID: " + _actionId + " Ctrl pressed:" + _ctrlPressed + " Shift pressed:" + _shiftPressed); } // Don't do anything if player is dead or confused if ((activeChar.isFakeDeath() && (_actionId != 0)) || activeChar.isDead() || activeChar.isOutOfControl()) { sendPacket(ActionFailed.STATIC_PACKET); return; } final BuffInfo info = activeChar.getEffectList().getBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY); if (info != null) { for (AbstractEffect effect : info.getEffects()) { if (!effect.checkCondition(_actionId)) { activeChar.sendPacket( SystemMessageId .YOU_HAVE_BEEN_REPORTED_AS_AN_ILLEGAL_PROGRAM_USER_SO_YOUR_ACTIONS_HAVE_BEEN_RESTRICTED); activeChar.sendPacket(ActionFailed.STATIC_PACKET); return; } } } // Don't allow to do some action if player is transformed if (activeChar.isTransformed()) { int[] allowedActions = activeChar.isTransformed() ? ExBasicActionList.ACTIONS_ON_TRANSFORM : ExBasicActionList.DEFAULT_ACTION_LIST; if (!(Arrays.binarySearch(allowedActions, _actionId) >= 0)) { sendPacket(ActionFailed.STATIC_PACKET); _log.warning( "Player " + activeChar + " used action which he does not have! Id = " + _actionId + " transform: " + activeChar.getTransformation()); return; } } final L2Summon pet = activeChar.getPet(); final L2Summon servitor = activeChar.getAnyServitor(); final L2Object target = activeChar.getTarget(); switch (_actionId) { case 0: // Sit/Stand if (activeChar.isSitting() || !activeChar.isMoving() || activeChar.isFakeDeath()) { useSit(activeChar, target); } else { // Sit when arrive using next action. // Creating next action class. final NextAction nextAction = new NextAction( CtrlEvent.EVT_ARRIVED, CtrlIntention.AI_INTENTION_MOVE_TO, () -> useSit(activeChar, target)); // Binding next action to AI. activeChar.getAI().setNextAction(nextAction); } break; case 1: // Walk/Run if (activeChar.isRunning()) { activeChar.setWalking(); } else { activeChar.setRunning(); } break; case 10: // Private Store - Sell activeChar.tryOpenPrivateSellStore(false); break; case 15: // Change Movement Mode (Pets) if (validateSummon(pet, true)) { ((L2SummonAI) pet.getAI()).notifyFollowStatusChange(); } break; case 16: // Attack (Pets) if (validateSummon(pet, true)) { if (pet.canAttack(_ctrlPressed)) { pet.doAttack(); } } break; case 17: // Stop (Pets) if (validateSummon(pet, true)) { pet.cancelAction(); } break; case 19: // Unsummon Pet if (!validateSummon(pet, true)) { break; } if (pet.isDead()) { sendPacket(SystemMessageId.DEAD_PETS_CANNOT_BE_RETURNED_TO_THEIR_SUMMONING_ITEM); break; } if (pet.isAttackingNow() || pet.isInCombat() || pet.isMovementDisabled()) { sendPacket(SystemMessageId.A_PET_CANNOT_BE_UNSUMMONED_DURING_BATTLE); break; } if (pet.isHungry()) { if (!((L2PetInstance) pet).getPetData().getFood().isEmpty()) { sendPacket(SystemMessageId.YOU_MAY_NOT_RESTORE_A_HUNGRY_PET); } else { sendPacket( SystemMessageId .THE_MINION_PET_CANNOT_BE_RETURNED_BECAUSE_THERE_IS_NOT_MUCH_TIME_REMAINING_UNTIL_IT_LEAVES); } break; } pet.unSummon(activeChar); break; case 21: // Change Movement Mode (Servitors) if (validateSummon(servitor, false)) { ((L2SummonAI) servitor.getAI()).notifyFollowStatusChange(); } break; case 22: // Attack (Servitors) if (validateSummon(servitor, false)) { if (servitor.canAttack(_ctrlPressed)) { servitor.doAttack(); } } break; case 23: // Stop (Servitors) if (validateSummon(servitor, false)) { servitor.cancelAction(); } break; case 28: // Private Store - Buy activeChar.tryOpenPrivateBuyStore(); break; case 32: // Wild Hog Cannon - Wild Cannon useSkill("DDMagic", false); break; case 36: // Soulless - Toxic Smoke useSkill("RangeDebuff", false); break; case 37: // Dwarven Manufacture if (activeChar.isAlikeDead()) { sendPacket(ActionFailed.STATIC_PACKET); return; } if (activeChar.getPrivateStoreType() != PrivateStoreType.NONE) { activeChar.setPrivateStoreType(PrivateStoreType.NONE); activeChar.broadcastUserInfo(); } if (activeChar.isSitting()) { activeChar.standUp(); } sendPacket(new RecipeShopManageList(activeChar, true)); break; case 38: // Mount/Dismount activeChar.mountPlayer(pet); break; case 39: // Soulless - Parasite Burst useSkill("RangeDD", false); break; case 41: // Wild Hog Cannon - Attack if (validateSummon(servitor, false)) { if ((target != null) && (target.isDoor() || (target instanceof L2SiegeFlagInstance))) { useSkill(4230, false); } else { sendPacket(SystemMessageId.INVALID_TARGET); } } break; case 42: // Kai the Cat - Self Damage Shield useSkill("HealMagic", false); break; case 43: // Merrow the Unicorn - Hydro Screw useSkill("DDMagic", false); break; case 44: // Big Boom - Boom Attack useSkill("DDMagic", false); break; case 45: // Boxer the Unicorn - Master Recharge useSkill("HealMagic", activeChar, false); break; case 46: // Mew the Cat - Mega Storm Strike useSkill("DDMagic", false); break; case 47: // Silhouette - Steal Blood useSkill("DDMagic", false); break; case 48: // Mechanic Golem - Mech. Cannon useSkill("DDMagic", false); break; case 51: // General Manufacture // Player shouldn't be able to set stores if he/she is alike dead (dead or fake death) if (activeChar.isAlikeDead()) { sendPacket(ActionFailed.STATIC_PACKET); return; } if (activeChar.getPrivateStoreType() != PrivateStoreType.NONE) { activeChar.setPrivateStoreType(PrivateStoreType.NONE); activeChar.broadcastUserInfo(); } if (activeChar.isSitting()) { activeChar.standUp(); } sendPacket(new RecipeShopManageList(activeChar, false)); break; case 52: // Unsummon Servitor if (validateSummon(servitor, false)) { if (servitor.isAttackingNow() || servitor.isInCombat()) { sendPacket(SystemMessageId.A_SERVITOR_WHOM_IS_ENGAGED_IN_BATTLE_CANNOT_BE_DE_ACTIVATED); break; } servitor.unSummon(activeChar); } break; case 53: // Move to target (Servitors) if (validateSummon(servitor, false)) { if ((target != null) && (servitor != target) && !servitor.isMovementDisabled()) { servitor.setFollowStatus(false); servitor.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, target.getLocation()); } } break; case 54: // Move to target (Pets) if (validateSummon(pet, true)) { if ((target != null) && (pet != target) && !pet.isMovementDisabled()) { pet.setFollowStatus(false); pet.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, target.getLocation()); } } break; case 61: // Private Store Package Sell activeChar.tryOpenPrivateSellStore(true); break; case 65: // Bot Report Button if (Config.BOTREPORT_ENABLE) { BotReportTable.getInstance().reportBot(activeChar); } else { activeChar.sendMessage("This feature is disabled."); } break; case 67: // Steer if (activeChar.isInAirShip()) { if (activeChar.getAirShip().setCaptain(activeChar)) { activeChar.broadcastUserInfo(); } } break; case 68: // Cancel Control if (activeChar.isInAirShip() && activeChar.getAirShip().isCaptain(activeChar)) { if (activeChar.getAirShip().setCaptain(null)) { activeChar.broadcastUserInfo(); } } break; case 69: // Destination Map AirShipManager.getInstance().sendAirShipTeleportList(activeChar); break; case 70: // Exit Airship if (activeChar.isInAirShip()) { if (activeChar.getAirShip().isCaptain(activeChar)) { if (activeChar.getAirShip().setCaptain(null)) { activeChar.broadcastUserInfo(); } } else if (activeChar.getAirShip().isInDock()) { activeChar.getAirShip().oustPlayer(activeChar); } } break; case 71: case 72: case 73: useCoupleSocial(_actionId - 55); break; case 78: case 79: case 80: case 81: if ((activeChar.getParty() != null) && (activeChar.getTarget() != null) && (activeChar.getTarget().isCharacter())) { activeChar .getParty() .addTacticalSign(_actionId - 77, (L2Character) activeChar.getTarget()); } else { sendPacket(ActionFailed.STATIC_PACKET); } break; case 82: case 83: case 84: case 85: if (activeChar.getParty() != null) { activeChar.getParty().setTargetBasedOnTacticalSignId(activeChar, _actionId - 81); } else { sendPacket(ActionFailed.STATIC_PACKET); } break; case 90: // /instancedzone action since Lindvior activeChar.sendPacket(new ExInzoneWaiting(activeChar)); break; case 1000: // Siege Golem - Siege Hammer if ((target != null) && target.isDoor()) { useSkill(4079, false); } break; case 1001: // Sin Eater - Ultimate Bombastic Buster if (validateSummon(pet, true) && (pet.getId() == SIN_EATER_ID)) { pet.broadcastPacket( new NpcSay( pet.getObjectId(), ChatType.NPC_GENERAL, pet.getId(), NPC_STRINGS[Rnd.get(NPC_STRINGS.length)])); } break; case 1003: // Wind Hatchling/Strider - Wild Stun useSkill("PhysicalSpecial", true); break; case 1004: // Wind Hatchling/Strider - Wild Defense useSkill("Buff", activeChar, true); break; case 1005: // Star Hatchling/Strider - Bright Burst useSkill("DDMagic", true); break; case 1006: // Star Hatchling/Strider - Bright Heal useSkill("Heal", activeChar, true); break; case 1007: // Feline Queen - Blessing of Queen useSkill("Buff1", activeChar, false); break; case 1008: // Feline Queen - Gift of Queen useSkill("Buff2", activeChar, false); break; case 1009: // Feline Queen - Cure of Queen useSkill("DDMagic", false); break; case 1010: // Unicorn Seraphim - Blessing of Seraphim useSkill("Buff1", activeChar, false); break; case 1011: // Unicorn Seraphim - Gift of Seraphim useSkill("Buff2", activeChar, false); break; case 1012: // Unicorn Seraphim - Cure of Seraphim useSkill("DDMagic", false); break; case 1013: // Nightshade - Curse of Shade useSkill("DeBuff1", false); break; case 1014: // Nightshade - Mass Curse of Shade useSkill("DeBuff2", false); break; case 1015: // Nightshade - Shade Sacrifice useSkill("Heal", false); break; case 1016: // Cursed Man - Cursed Blow useSkill("PhysicalSpecial1", false); break; case 1017: // Cursed Man - Cursed Strike useSkill("PhysicalSpecial2", false); break; case 1031: // Feline King - Slash useSkill("PhysicalSpecial1", false); break; case 1032: // Feline King - Spinning Slash useSkill("PhysicalSpecial2", false); break; case 1033: // Feline King - Hold of King useSkill("PhysicalSpecial3", false); break; case 1034: // Magnus the Unicorn - Whiplash useSkill("PhysicalSpecial1", false); break; case 1035: // Magnus the Unicorn - Tridal Wave useSkill("PhysicalSpecial2", false); break; case 1036: // Spectral Lord - Corpse Kaboom useSkill("PhysicalSpecial1", false); break; case 1037: // Spectral Lord - Dicing Death useSkill("PhysicalSpecial2", false); break; case 1038: // Spectral Lord - Dark Curse useSkill("PhysicalSpecial3", false); break; case 1039: // Swoop Cannon - Cannon Fodder useSkill(5110, false); break; case 1040: // Swoop Cannon - Big Bang useSkill(5111, false); break; case 1041: // Great Wolf - Bite Attack useSkill("Skill01", true); break; case 1042: // Great Wolf - Maul useSkill("Skill03", true); break; case 1043: // Great Wolf - Cry of the Wolf useSkill("Skill02", true); break; case 1044: // Great Wolf - Awakening useSkill("Skill04", true); break; case 1045: // Great Wolf - Howl useSkill(5584, true); break; case 1046: // Strider - Roar useSkill(5585, true); break; case 1047: // Divine Beast - Bite useSkill(5580, false); break; case 1048: // Divine Beast - Stun Attack useSkill(5581, false); break; case 1049: // Divine Beast - Fire Breath useSkill(5582, false); break; case 1050: // Divine Beast - Roar useSkill(5583, false); break; case 1051: // Feline Queen - Bless The Body useSkill("buff3", false); break; case 1052: // Feline Queen - Bless The Soul useSkill("buff4", false); break; case 1053: // Feline Queen - Haste useSkill("buff5", false); break; case 1054: // Unicorn Seraphim - Acumen useSkill("buff3", false); break; case 1055: // Unicorn Seraphim - Clarity useSkill("buff4", false); break; case 1056: // Unicorn Seraphim - Empower useSkill("buff5", false); break; case 1057: // Unicorn Seraphim - Wild Magic useSkill("buff6", false); break; case 1058: // Nightshade - Death Whisper useSkill("buff3", false); break; case 1059: // Nightshade - Focus useSkill("buff4", false); break; case 1060: // Nightshade - Guidance useSkill("buff5", false); break; case 1061: // Wild Beast Fighter, White Weasel - Death blow useSkill(5745, true); break; case 1062: // Wild Beast Fighter - Double attack useSkill(5746, true); break; case 1063: // Wild Beast Fighter - Spin attack useSkill(5747, true); break; case 1064: // Wild Beast Fighter - Meteor Shower useSkill(5748, true); break; case 1065: // Fox Shaman, Wild Beast Fighter, White Weasel, Fairy Princess - Awakening useSkill(5753, true); break; case 1066: // Fox Shaman, Spirit Shaman - Thunder Bolt useSkill(5749, true); break; case 1067: // Fox Shaman, Spirit Shaman - Flash useSkill(5750, true); break; case 1068: // Fox Shaman, Spirit Shaman - Lightning Wave useSkill(5751, true); break; case 1069: // Fox Shaman, Fairy Princess - Flare useSkill(5752, true); break; case 1070: // White Weasel, Fairy Princess, Improved Baby Buffalo, Improved Baby Kookaburra, // Improved Baby Cougar, Spirit Shaman, Toy Knight, Turtle Ascetic - Buff control useSkill(5771, true); break; case 1071: // Tigress - Power Strike useSkill("DDMagic", true); break; case 1072: // Toy Knight - Piercing attack useSkill(6046, true); break; case 1073: // Toy Knight - Whirlwind useSkill(6047, true); break; case 1074: // Toy Knight - Lance Smash useSkill(6048, true); break; case 1075: // Toy Knight - Battle Cry useSkill(6049, true); break; case 1076: // Turtle Ascetic - Power Smash useSkill(6050, true); break; case 1077: // Turtle Ascetic - Energy Burst useSkill(6051, true); break; case 1078: // Turtle Ascetic - Shockwave useSkill(6052, true); break; case 1079: // Turtle Ascetic - Howl useSkill(6053, true); break; case 1080: // Phoenix Rush useSkill(6041, false); break; case 1081: // Phoenix Cleanse useSkill(6042, false); break; case 1082: // Phoenix Flame Feather useSkill(6043, false); break; case 1083: // Phoenix Flame Beak useSkill(6044, false); break; case 1084: // Switch State if (pet instanceof L2BabyPetInstance) { useSkill(SWITCH_STANCE_ID, true); } break; case 1086: // Panther Cancel useSkill(6094, false); break; case 1087: // Panther Dark Claw useSkill(6095, false); break; case 1088: // Panther Fatal Claw useSkill(6096, false); break; case 1089: // Deinonychus - Tail Strike useSkill(6199, true); break; case 1090: // Guardian's Strider - Strider Bite useSkill(6205, true); break; case 1091: // Guardian's Strider - Strider Fear useSkill(6206, true); break; case 1092: // Guardian's Strider - Strider Dash useSkill(6207, true); break; case 1093: // Maguen - Maguen Strike useSkill(6618, true); break; case 1094: // Maguen - Maguen Wind Walk useSkill(6681, true); break; case 1095: // Elite Maguen - Maguen Power Strike useSkill(6619, true); break; case 1096: // Elite Maguen - Elite Maguen Wind Walk useSkill(6682, true); break; case 1097: // Maguen - Maguen Return useSkill(6683, true); break; case 1098: // Elite Maguen - Maguen Party Return useSkill(6684, true); break; case 1099: // All servitor attack activeChar .getServitors() .values() .forEach( s -> { if (validateSummon(s, false)) { if (s.canAttack(_ctrlPressed)) { s.doAttack(); } } }); break; case 1100: // All servitor move to activeChar .getServitors() .values() .forEach( s -> { if (validateSummon(s, false)) { if ((target != null) && (s != target) && !s.isMovementDisabled()) { s.setFollowStatus(false); s.getAI() .setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, target.getLocation()); } } }); break; case 1101: // All servitor stop activeChar .getServitors() .values() .forEach( summon -> { if (validateSummon(summon, false)) { summon.cancelAction(); } }); break; case 1102: // Unsummon all servitors boolean canUnsummon = true; OUT: for (L2Summon s : activeChar.getServitors().values()) { if (validateSummon(s, false)) { if (s.isAttackingNow() || s.isInCombat()) { sendPacket( SystemMessageId.A_SERVITOR_WHOM_IS_ENGAGED_IN_BATTLE_CANNOT_BE_DE_ACTIVATED); canUnsummon = false; break OUT; } s.unSummon(activeChar); } } if (canUnsummon) { activeChar .getServitors() .values() .stream() .forEach( s -> { s.unSummon(activeChar); }); } break; case 1103: // seems to be passive mode break; case 1104: // seems to be defend mode break; case 1106: // Cute Bear - Bear Claw useServitorsSkill(11278); break; case 1107: // Cute Bear - Bear Tumbling useServitorsSkill(11279); break; case 1108: // Saber Tooth Cougar- Cougar Bite useServitorsSkill(11280); break; case 1109: // Saber Tooth Cougar - Cougar Pounce useServitorsSkill(11281); break; case 1110: // Grim Reaper - Reaper Touch useServitorsSkill(11282); break; case 1111: // Grim Reaper - Reaper Power useServitorsSkill(11283); break; case 1113: // Golden Lion - Lion Roar useSkill(10051, false); break; case 1114: // Golden Lion - Lion Claw useSkill(10052, false); break; case 1115: // Golden Lion - Lion Dash useSkill(10053, false); break; case 1116: // Golden Lion - Lion Flame useSkill(10054, false); break; case 1117: // Thunder Hawk - Thunder Flight useSkill(10794, false); break; case 1118: // Thunder Hawk - Thunder Purity useSkill(10795, false); break; case 1120: // Thunder Hawk - Thunder Feather Blast useSkill(10797, false); break; case 1121: // Thunder Hawk - Thunder Sharp Claw useSkill(10798, false); break; case 1122: // Tree of Life - Blessing of Tree useServitorsSkill(11806); break; case 1124: // Wynn Kai the Cat - Feline Aggression useServitorsSkill(11323); break; case 1125: // Wynn Kai the Cat - Feline Stun useServitorsSkill(11324); break; case 1126: // Wynn Feline King - Feline Bite useServitorsSkill(11325); break; case 1127: // Wynn Feline King - Feline Pounce useServitorsSkill(11326); break; case 1128: // Wynn Feline Queen - Feline Touch useServitorsSkill(11327); break; case 1129: // Wynn Feline Queen - Feline Power useServitorsSkill(11328); break; case 1130: // Wynn Merrow - Unicorn's Aggression useServitorsSkill(11332); break; case 1131: // Wynn Merrow - Unicorn's Stun useServitorsSkill(11333); break; case 1132: // Wynn Magnus - Unicorn's Bite useServitorsSkill(11334); break; case 1133: // Wynn Magnus - Unicorn's Pounce useServitorsSkill(11335); break; case 1134: // Wynn Seraphim - Unicorn's Touch useServitorsSkill(11336); break; case 1135: // Wynn Seraphim - Unicorn's Power useServitorsSkill(11337); break; case 1136: // Wynn Nightshade - Phantom Aggression useServitorsSkill(11341); break; case 1137: // Wynn Nightshade - Phantom Stun useServitorsSkill(11342); break; case 1138: // Wynn Spectral Lord - Phantom Bite useServitorsSkill(11343); break; case 1139: // Wynn Spectral Lord - Phantom Pounce useServitorsSkill(11344); break; case 1140: // Wynn Soulless - Phantom Touch useServitorsSkill(11345); break; case 1141: // Wynn Soulless - Phantom Power useServitorsSkill(11346); break; case 1142: // Blood Panther - Panther Roar useServitorsSkill(10087); break; case 1143: // Blood Panther - Panther Rush useServitorsSkill(10088); break; case 5000: // Baby Rudolph - Reindeer Scratch useSkill(23155, true); break; case 5001: // Deseloph, Hyum, Rekang, Lilias, Lapham, Mafum - Rosy Seduction useSkill(23167, true); break; case 5002: // Deseloph, Hyum, Rekang, Lilias, Lapham, Mafum - Critical Seduction useSkill(23168, true); break; case 5003: // Hyum, Lapham, Hyum, Lapham - Thunder Bolt useSkill(5749, true); break; case 5004: // Hyum, Lapham, Hyum, Lapham - Flash useSkill(5750, true); break; case 5005: // Hyum, Lapham, Hyum, Lapham - Lightning Wave useSkill(5751, true); break; case 5006: // Deseloph, Hyum, Rekang, Lilias, Lapham, Mafum, Deseloph, Hyum, Rekang, Lilias, // Lapham, Mafum - Buff Control useSkill(5771, true); break; case 5007: // Deseloph, Lilias, Deseloph, Lilias - Piercing Attack useSkill(6046, true); break; case 5008: // Deseloph, Lilias, Deseloph, Lilias - Spin Attack useSkill(6047, true); break; case 5009: // Deseloph, Lilias, Deseloph, Lilias - Smash useSkill(6048, true); break; case 5010: // Deseloph, Lilias, Deseloph, Lilias - Ignite useSkill(6049, true); break; case 5011: // Rekang, Mafum, Rekang, Mafum - Power Smash useSkill(6050, true); break; case 5012: // Rekang, Mafum, Rekang, Mafum - Energy Burst useSkill(6051, true); break; case 5013: // Rekang, Mafum, Rekang, Mafum - Shockwave useSkill(6052, true); break; case 5014: // Rekang, Mafum, Rekang, Mafum - Ignite useSkill(6053, true); break; case 5015: // Deseloph, Hyum, Rekang, Lilias, Lapham, Mafum, Deseloph, Hyum, Rekang, Lilias, // Lapham, Mafum - Switch Stance useSkill(6054, true); break; // Social Packets case 12: // Greeting tryBroadcastSocial(2); break; case 13: // Victory tryBroadcastSocial(3); break; case 14: // Advance tryBroadcastSocial(4); break; case 24: // Yes tryBroadcastSocial(6); break; case 25: // No tryBroadcastSocial(5); break; case 26: // Bow tryBroadcastSocial(7); break; case 29: // Unaware tryBroadcastSocial(8); break; case 30: // Social Waiting tryBroadcastSocial(9); break; case 31: // Laugh tryBroadcastSocial(10); break; case 33: // Applaud tryBroadcastSocial(11); break; case 34: // Dance tryBroadcastSocial(12); break; case 35: // Sorrow tryBroadcastSocial(13); break; case 62: // Charm tryBroadcastSocial(14); break; case 66: // Shyness tryBroadcastSocial(15); break; case 87: // Propose tryBroadcastSocial(28); break; case 88: // Provoke tryBroadcastSocial(29); break; case 89: // Beauty Shop tryBroadcastSocial(30); activeChar.broadcastInfo(); break; default: _log.warning(activeChar.getName() + ": unhandled action type " + _actionId); break; } }
@Override public final String onAdvEvent(String event, L2Npc npc, L2PcInstance player) { String htmltext = event; // Timer. Spawns Naia Lock if (event.equalsIgnoreCase("spawn_lock")) { htmltext = null; _lock = (L2MonsterInstance) addSpawn(LOCK, 16409, 244438, 11620, -1048, false, 0, false); _counter = 90; } // Timer. Depending of _challengeState despans all spawned spores, or spores, reached assembly // point else if (event.equalsIgnoreCase("despawn_total")) { // Spores is not attacked too long - despawn them all, reinit values if (_challengeState == STATE_SPORE_IDLE_TOO_LONG) { for (L2Npc spore : _sporeSpawn) { if ((spore != null) && !spore.isDead()) { spore.deleteMe(); } } _sporeSpawn.clear(); initSporeChallenge(); } // Spores are moving to assembly point. Despawn all reached, check for reached spores count. else if ((_challengeState == STATE_SPORE_CHALLENGE_SUCCESSFULL) && (_winIndex >= 0)) { // Requirements are met, despawn all spores, spawn Epidos if ((_despawnedSporesCount >= 10) || _sporeSpawn.isEmpty()) { if (!_sporeSpawn.isEmpty()) { for (L2Npc spore : _sporeSpawn) { if ((spore != null) && !spore.isDead()) { spore.deleteMe(); } } } _sporeSpawn.clear(); _despawnedSporesCount = 0; int[] coords = SPORES_MERGE_POSITION[_winIndex]; addSpawn(EPIDOSES[_winIndex], coords[0], coords[1], coords[2], 0, false, 0, false); initSporeChallenge(); } // Requirements aren't met, despawn reached spores else { Iterator<L2Npc> it = _sporeSpawn.iterator(); while (it.hasNext()) { L2Npc spore = it.next(); if ((spore != null) && !spore.isDead() && (spore.getX() == spore.getSpawn().getX()) && (spore.getY() == spore.getSpawn().getY())) { spore.deleteMe(); it.remove(); _despawnedSporesCount++; } } startQuestTimer("despawn_total", 3000, null, null); } } } if (npc == null) { return null; } final int npcId = npc.getId(); if (event.equalsIgnoreCase("despawn_spore") && !npc.isDead() && (_challengeState == STATE_SPORE_CHALLENGE_IN_PROGRESS)) { htmltext = null; _sporeSpawn.remove(npc); npc.deleteMe(); if (npcId == SPORE_BASIC) { spawnRandomSpore(); spawnRandomSpore(); } else if ((npcId >= SPORE_FIRE) && (npcId <= SPORE_EARTH)) { _despawnedSporesCount++; if (_despawnedSporesCount < SELF_DESPAWN_LIMIT) { spawnOppositeSpore(npcId); } else { _challengeState = STATE_SPORE_IDLE_TOO_LONG; startQuestTimer("despawn_total", 60000, null, null); } } } else if (event.equalsIgnoreCase("18492-05.htm")) { if ((_lock == null) || (_lock.getCurrentHp() > (_lock.getMaxHp() / 10))) { htmltext = null; if (_lock != null) { _lock.deleteMe(); _lock = null; } cancelQuestTimers("spawn_lock"); startQuestTimer("spawn_lock", 300000, null, null); npc.setTarget(player); npc.doCast(SkillData.getInstance().getSkill(5527, 1)); } } else if (event.equalsIgnoreCase("teleport") && (_lock != null)) { htmltext = null; L2Party party = player.getParty(); if (party != null) { if (Util.checkIfInRange(3000, party.getLeader(), npc, true)) { for (L2PcInstance partyMember : party.getMembers()) { if (Util.checkIfInRange(2000, partyMember, npc, true)) { partyMember.teleToLocation(-47271, 246098, -9120, true); } } _lock.deleteMe(); _lock = null; cancelQuestTimers("spawn_lock"); startQuestTimer("spawn_lock", 1200000, null, null); } else { npc.setTarget(player); npc.doCast(SkillData.getInstance().getSkill(5527, 1)); } } else { player.teleToLocation(-47271, 246098, -9120); _lock.deleteMe(); _lock = null; cancelQuestTimers("spawn_lock"); startQuestTimer("spawn_lock", 1200000, null, null); } } else if (event.equalsIgnoreCase("go") && _activeRooms.containsKey(npcId) && !_activeRooms.get(npcId)) { htmltext = null; L2Party party = player.getParty(); if (party != null) { removeForeigners(npcId, party); startRoom(npcId); ThreadPoolManager.getInstance().scheduleGeneral(new StopRoomTask(npcId), 300000); } else { player.sendPacket(SystemMessageId.CAN_OPERATE_MACHINE_WHEN_IN_PARTY); } } return htmltext; }
/** Stops all players from attacking. Used for duel timeout / interrupt. */ private void stopFighting() { ActionFailed af = ActionFailed.STATIC_PACKET; if (_partyDuel) { for (L2PcInstance temp : _playerA.getParty().getMembers()) { temp.abortCast(); temp.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE); temp.setTarget(null); temp.sendPacket(af); if (temp.hasSummon()) { for (L2Summon summon : temp.getServitors().values()) { if (!summon.isDead()) { summon.abortCast(); summon.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE); summon.setTarget(null); summon.sendPacket(af); } } } } for (L2PcInstance temp : _playerB.getParty().getMembers()) { temp.abortCast(); temp.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE); temp.setTarget(null); temp.sendPacket(af); if (temp.hasSummon()) { for (L2Summon summon : temp.getServitors().values()) { if (!summon.isDead()) { summon.abortCast(); summon.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE); summon.setTarget(null); summon.sendPacket(af); } } } } } else { _playerA.abortCast(); _playerB.abortCast(); _playerA.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE); _playerA.setTarget(null); _playerB.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE); _playerB.setTarget(null); _playerA.sendPacket(af); _playerB.sendPacket(af); if (_playerA.hasSummon()) { for (L2Summon summon : _playerA.getServitors().values()) { if (!summon.isDead()) { summon.abortCast(); summon.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE); summon.setTarget(null); summon.sendPacket(af); } } } if (_playerB.hasSummon()) { for (L2Summon summon : _playerB.getServitors().values()) { if (!summon.isDead()) { summon.abortCast(); summon.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE); summon.setTarget(null); summon.sendPacket(af); } } } } }
/** Starts the duel */ public void startDuel() { if ((_playerA == null) || (_playerB == null) || _playerA.isInDuel() || _playerB.isInDuel()) { _playerConditions.clear(); DuelManager.getInstance().removeDuel(this); return; } if (_partyDuel) { // Set duel state and team for (L2PcInstance temp : _playerA.getParty().getMembers()) { temp.cancelActiveTrade(); temp.setIsInDuel(_duelId); temp.setTeam(Team.BLUE); temp.broadcastUserInfo(); broadcastToTeam2(new ExDuelUpdateUserInfo(temp)); } for (L2PcInstance temp : _playerB.getParty().getMembers()) { temp.cancelActiveTrade(); temp.setIsInDuel(_duelId); temp.setTeam(Team.RED); temp.broadcastUserInfo(); broadcastToTeam1(new ExDuelUpdateUserInfo(temp)); } // Send duel packets broadcastToTeam1(ExDuelReady.PARTY_DUEL); broadcastToTeam2(ExDuelReady.PARTY_DUEL); broadcastToTeam1(ExDuelStart.PARTY_DUEL); broadcastToTeam2(ExDuelStart.PARTY_DUEL); // Open arena doors for (L2DoorInstance door : InstanceManager.getInstance().getInstance(getDueldInstanceId()).getDoors()) { if ((door != null) && !door.getOpen()) { door.openMe(); } } } else { // Set duel state and team _playerA.setIsInDuel(_duelId); _playerA.setTeam(Team.BLUE); _playerB.setIsInDuel(_duelId); _playerB.setTeam(Team.RED); // Send duel Start packets // Send duel packets broadcastToTeam1(ExDuelReady.PLAYER_DUEL); broadcastToTeam2(ExDuelReady.PLAYER_DUEL); broadcastToTeam1(ExDuelStart.PLAYER_DUEL); broadcastToTeam2(ExDuelStart.PLAYER_DUEL); broadcastToTeam1(new ExDuelUpdateUserInfo(_playerB)); broadcastToTeam2(new ExDuelUpdateUserInfo(_playerA)); _playerA.broadcastUserInfo(); _playerB.broadcastUserInfo(); } // play sound broadcastToTeam1(B04_S01); broadcastToTeam2(B04_S01); // start dueling task ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleDuelTask(this), 1000); }
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()); } } } }
@Override public L2Object[] getTargetList( Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target) { List<L2Character> targetList = new ArrayList<>(); if (onlyFirst) { return new L2Character[] {activeChar}; } final L2PcInstance player = activeChar.getActingPlayer(); if (player == null) { return EMPTY_TARGET_LIST; } targetList.add(player); final int radius = skill.getAffectRange(); final boolean hasClan = player.getClan() != null; final boolean hasParty = player.isInParty(); if (Skill.addPet(activeChar, player, radius, false)) { targetList.add(player.getPet()); } player .getServitors() .values() .forEach( s -> { if (Skill.addCharacter(activeChar, s, radius, false)) { targetList.add(s); } }); // if player in clan and not in party if (!(hasClan || hasParty)) { return targetList.toArray(new L2Character[targetList.size()]); } // Get all visible objects in a spherical area near the L2Character final Collection<L2PcInstance> objs = activeChar.getKnownList().getKnownPlayersInRadius(radius); int maxTargets = skill.getAffectLimit(); for (L2PcInstance obj : objs) { if (obj == null) { continue; } // olympiad mode - adding only own side if (player.isInOlympiadMode()) { if (!obj.isInOlympiadMode()) { continue; } if (player.getOlympiadGameId() != obj.getOlympiadGameId()) { continue; } if (player.getOlympiadSide() != obj.getOlympiadSide()) { continue; } } if (player.isInDuel()) { if (player.getDuelId() != obj.getDuelId()) { continue; } if (hasParty && obj.isInParty() && (player.getParty().getLeaderObjectId() != obj.getParty().getLeaderObjectId())) { continue; } } if (!((hasClan && (obj.getClanId() == player.getClanId())) || (hasParty && obj.isInParty() && (player.getParty().getLeaderObjectId() == obj.getParty().getLeaderObjectId())))) { continue; } // Don't add this target if this is a Pc->Pc pvp // casting and pvp condition not met if (!player.checkPvpSkill(obj, skill)) { continue; } if (!TvTEvent.checkForTvTSkill(player, obj, skill)) { continue; } if (Skill.addPet(activeChar, obj, radius, false)) { targetList.add(obj.getPet()); } obj.getServitors() .values() .forEach( s -> { if (Skill.addCharacter(activeChar, s, radius, false)) { targetList.add(s); } }); if (!Skill.addCharacter(activeChar, obj, radius, false)) { continue; } if ((maxTargets > 0) && (targetList.size() >= maxTargets)) { break; } targetList.add(obj); } return targetList.toArray(new L2Character[targetList.size()]); }
public synchronized void start(L2PcInstance player, byte type, L2Npc npc) { boolean canPass = true; if (!player.isInParty()) { showHtmlFile(player, "data/html/seven_signs/rift/NoParty.htm", npc); return; } if (player.getParty().getPartyLeaderOID() != player.getObjectId()) { showHtmlFile(player, "data/html/seven_signs/rift/NotPartyLeader.htm", npc); return; } if (player.getParty().isInDimensionalRift()) { handleCheat(player, npc); return; } if (player.getParty().getMemberCount() < Config.RIFT_MIN_PARTY_SIZE) { NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId()); html.setFile(player.getHtmlPrefix(), "data/html/seven_signs/rift/SmallParty.htm"); html.replace("%npc_name%", npc.getName()); html.replace("%count%", Integer.toString(Config.RIFT_MIN_PARTY_SIZE)); player.sendPacket(html); return; } // max parties inside is rooms count - 1 if (!isAllowedEnter(type)) { player.sendMessage("Rift is full. Try later."); return; } for (L2PcInstance p : player.getParty().getPartyMembers()) if (!checkIfInPeaceZone(p.getX(), p.getY(), p.getZ())) { canPass = false; break; } if (!canPass) { showHtmlFile(player, "data/html/seven_signs/rift/NotInWaitingRoom.htm", npc); return; } L2ItemInstance i; int count = getNeededItems(type); for (L2PcInstance p : player.getParty().getPartyMembers()) { i = p.getInventory().getItemByItemId(DIMENSIONAL_FRAGMENT_ITEM_ID); if (i == null) { canPass = false; break; } if (i.getCount() > 0) { if (i.getCount() < getNeededItems(type)) { canPass = false; break; } } else { canPass = false; break; } } if (!canPass) { NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId()); html.setFile(player.getHtmlPrefix(), "data/html/seven_signs/rift/NoFragments.htm"); html.replace("%npc_name%", npc.getName()); html.replace("%count%", Integer.toString(count)); player.sendPacket(html); return; } for (L2PcInstance p : player.getParty().getPartyMembers()) { i = p.getInventory().getItemByItemId(DIMENSIONAL_FRAGMENT_ITEM_ID); if (!p.destroyItem("RiftEntrance", i, count, null, false)) { NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId()); html.setFile(player.getHtmlPrefix(), "data/html/seven_signs/rift/NoFragments.htm"); html.replace("%npc_name%", npc.getName()); html.replace("%count%", Integer.toString(count)); player.sendPacket(html); return; } } byte room; FastList<Byte> emptyRooms; do { emptyRooms = getFreeRooms(type); room = emptyRooms.get(Rnd.get(1, emptyRooms.size()) - 1); } // find empty room while (_rooms.get(type).get(room).ispartyInside()); new DimensionalRift(player.getParty(), type, room); }