@Override protected void onEnter(L2Character character) { if (character instanceof L2PcInstance) { L2PcInstance player = (L2PcInstance) character; character.setInsideZone(L2Character.ZONE_MOTHERTREE, true); if (_enterMsg != 0) player.sendPacket(SystemMessage.getSystemMessage(_enterMsg)); } }
/** * Removing all buffs from player and pet except BUFFS_WHITELIST * * @param ch player */ private static final void removeBuffs(L2Character ch) { for (L2Effect e : ch.getAllEffects()) { if (e == null) continue; L2Skill skill = e.getSkill(); if (skill.isDebuff() || skill.isStayAfterDeath()) continue; if (Arrays.binarySearch(BUFFS_WHITELIST, skill.getId()) >= 0) continue; e.exit(); } if (ch.getPet() != null) { for (L2Effect e : ch.getPet().getAllEffects()) { if (e == null) continue; L2Skill skill = e.getSkill(); if (skill.isDebuff() || skill.isStayAfterDeath()) continue; if (Arrays.binarySearch(BUFFS_WHITELIST, skill.getId()) >= 0) continue; e.exit(); } } }
@Override public boolean onStart() { L2Character target = getEffected(); if (target == null || target.isDead() || target instanceof L2DoorInstance) return false; StatusUpdate su = new StatusUpdate(target); double amount = 0; double power = calc(); boolean full = (power == 100.0); if (full) amount = target.getMaxCp(); else amount = target.getMaxCp() * power / 100.0; amount = Math.min(amount, target.getMaxRecoverableCp() - target.getCurrentCp()); // Prevent negative amounts if (amount < 0) amount = 0; // To prevent -value heals, set the value only if current Cp is less than max recoverable. if (target.getCurrentCp() < target.getMaxRecoverableCp()) target.setCurrentCp(amount + target.getCurrentCp()); SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_CP_WILL_BE_RESTORED); sm.addNumber((int) amount); target.sendPacket(sm); su.addAttribute(StatusUpdate.CUR_CP, (int) target.getCurrentCp()); target.sendPacket(su); return true; }
@Override protected void onExit(L2Character character) { if (character instanceof L2Playable) { character.setInsideZone(L2Character.ZONE_MONSTERTRACK, false); } }
public Location getTeleToLocation(L2Character activeChar, TeleportWhereType teleportWhere) { int[] coord; if (activeChar instanceof L2PcInstance) { L2PcInstance player = ((L2PcInstance) activeChar); Castle castle = null; Fort fort = null; ClanHall clanhall = null; if (player.getClan() != null && !player.isFlyingMounted() && !player.isFlying()) // flying players in gracia cant use teleports to aden continent { // If teleport to clan hall if (teleportWhere == TeleportWhereType.ClanHall) { clanhall = ClanHallManager.getInstance().getAbstractHallByOwner(player.getClan()); if (clanhall != null) { L2ClanHallZone zone = clanhall.getZone(); if (zone != null && !player.isFlyingMounted()) { if (player.getKarma() > 0) return zone.getChaoticSpawnLoc(); return zone.getSpawnLoc(); } } } // If teleport to castle if (teleportWhere == TeleportWhereType.Castle) { castle = CastleManager.getInstance().getCastleByOwner(player.getClan()); // Otherwise check if player is on castle or fortress ground // and player's clan is defender if (castle == null) { castle = CastleManager.getInstance().getCastle(player); if (!(castle != null && castle.getSiege().getIsInProgress() && castle.getSiege().getDefenderClan(player.getClan()) != null)) castle = null; } if (castle != null && castle.getCastleId() > 0) { if (player.getKarma() > 0) return castle.getCastleZone().getChaoticSpawnLoc(); return castle.getCastleZone().getSpawnLoc(); } } // If teleport to fortress if (teleportWhere == TeleportWhereType.Fortress) { fort = FortManager.getInstance().getFortByOwner(player.getClan()); // Otherwise check if player is on castle or fortress ground // and player's clan is defender if (fort == null) { fort = FortManager.getInstance().getFort(player); if (!(fort != null && fort.getSiege().getIsInProgress() && fort.getOwnerClan() == player.getClan())) fort = null; } if (fort != null && fort.getFortId() > 0) { if (player.getKarma() > 0) return fort.getFortZone().getChaoticSpawnLoc(); return fort.getFortZone().getSpawnLoc(); } } // If teleport to SiegeHQ if (teleportWhere == TeleportWhereType.SiegeFlag) { castle = CastleManager.getInstance().getCastle(player); fort = FortManager.getInstance().getFort(player); clanhall = ClanHallManager.getInstance() .getNearbyAbstractHall(activeChar.getX(), activeChar.getY(), 10000); L2SiegeFlagInstance tw_flag = TerritoryWarManager.getInstance().getFlagForClan(player.getClan()); if (tw_flag != null) return new Location(tw_flag.getX(), tw_flag.getY(), tw_flag.getZ()); else if (castle != null) { if (castle.getSiege().getIsInProgress()) { // Check if player's clan is attacker List<L2Npc> flags = castle.getSiege().getFlag(player.getClan()); if (flags != null && !flags.isEmpty()) { // Spawn to flag - Need more work to get player to the nearest flag L2Npc flag = flags.get(0); return new Location(flag.getX(), flag.getY(), flag.getZ()); } } } else if (fort != null) { if (fort.getSiege().getIsInProgress()) { // Check if player's clan is attacker List<L2Npc> flags = fort.getSiege().getFlag(player.getClan()); if (flags != null && !flags.isEmpty()) { // Spawn to flag - Need more work to get player to the nearest flag L2Npc flag = flags.get(0); return new Location(flag.getX(), flag.getY(), flag.getZ()); } } } else if (clanhall != null && clanhall.isSiegableHall()) { SiegableHall sHall = (SiegableHall) clanhall; List<L2Npc> flags = sHall.getSiege().getFlag(player.getClan()); if (flags != null && !flags.isEmpty()) { L2Npc flag = flags.get(0); return new Location(flag.getX(), flag.getY(), flag.getZ()); } } } } if (teleportWhere == TeleportWhereType.Castle_banish) { castle = CastleManager.getInstance().getCastle(player); if (castle != null) return castle.getCastleZone().getBanishSpawnLoc(); } else if (teleportWhere == TeleportWhereType.Fortress_banish) { fort = FortManager.getInstance().getFort(activeChar); if (fort != null) return fort.getFortZone().getBanishSpawnLoc(); } else if (teleportWhere == TeleportWhereType.ClanHall_banish) { clanhall = ClanHallManager.getInstance().getClanHall(activeChar); if (clanhall != null) return clanhall.getZone().getBanishSpawnLoc(); } // Karma player land out of city if (player.getKarma() > 0) { try { L2RespawnZone zone = ZoneManager.getInstance().getZone(player, L2RespawnZone.class); if (zone != null) return getRestartRegion(activeChar, zone.getRespawnPoint((L2PcInstance) activeChar)) .getChaoticSpawnLoc(); return getMapRegion(activeChar).getChaoticSpawnLoc(); } catch (Exception e) { if (player.isFlyingMounted()) // prevent flying players to teleport outside of gracia return _regions.get("union_base_of_kserth").getChaoticSpawnLoc(); return _regions.get("talking_island_town").getChaoticSpawnLoc(); } } // Checking if needed to be respawned in "far" town from the castle; castle = CastleManager.getInstance().getCastle(player); if (castle != null) { if (castle.getSiege().getIsInProgress()) { // Check if player's clan is participating if ((castle.getSiege().checkIsDefender(player.getClan()) || castle.getSiege().checkIsAttacker(player.getClan())) && SevenSigns.getInstance().getSealOwner(SevenSigns.SEAL_STRIFE) == SevenSigns.CABAL_DAWN) return castle.getCastleZone().getOtherSpawnLoc(); } } // Checking if in an instance if (player.getInstanceId() > 0) { Instance inst = InstanceManager.getInstance().getInstance(player.getInstanceId()); if (inst != null) { coord = inst.getSpawnLoc(); if (coord[0] != 0 && coord[1] != 0 && coord[2] != 0) return new Location(coord[0], coord[1], coord[2]); } } } // Get the nearest town try { L2RespawnZone zone = ZoneManager.getInstance().getZone(activeChar, L2RespawnZone.class); if (zone != null) return getRestartRegion(activeChar, zone.getRespawnPoint((L2PcInstance) activeChar)) .getSpawnLoc(); return getMapRegion(activeChar).getSpawnLoc(); } catch (Exception e) { // port to the Talking Island if no closest town found if (Config.DEBUG) _log.log( Level.WARNING, "Not defined respawn point for coords loc X=" + activeChar.getX() + " Y=" + activeChar.getY() + " Z=" + activeChar.getZ()); return _regions.get("talking_island_town").getSpawnLoc(); } }