Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package margazeas.gold.gameserver.skills.l2skills;
- import margazeas.gold.commons.data.StatSet;
- import margazeas.gold.gameserver.data.xml.MapRegionData;
- import margazeas.gold.gameserver.data.xml.MapRegionData.TeleportType;
- import margazeas.gold.gameserver.enums.ZoneId;
- import margazeas.gold.gameserver.enums.items.ShotType;
- import margazeas.gold.gameserver.enums.skills.SkillType;
- import margazeas.gold.gameserver.model.WorldObject;
- import margazeas.gold.gameserver.model.actor.Creature;
- import margazeas.gold.gameserver.model.actor.Player;
- import margazeas.gold.gameserver.model.location.Location;
- import margazeas.gold.gameserver.skills.L2Skill;
- public class L2SkillTeleport extends L2Skill
- {
- private final String _recallType;
- private final Location _loc;
- public L2SkillTeleport(StatSet set)
- {
- super(set);
- _recallType = set.getString("recallType", "");
- String coords = set.getString("teleCoords", null);
- if (coords != null)
- {
- String[] valuesSplit = coords.split(",");
- _loc = new Location(Integer.parseInt(valuesSplit[0]), Integer.parseInt(valuesSplit[1]), Integer.parseInt(valuesSplit[2]));
- }
- else
- _loc = null;
- }
- @Override
- public void useSkill(Creature activeChar, WorldObject[] targets)
- {
- if (activeChar instanceof Player)
- {
- // Check invalid states.
- //if (activeChar.isAfraid() || ((Player) activeChar).isInOlympiadMode() || activeChar.isInsideZone(ZoneId.BOSS))
- if (activeChar.isAfraid() || ((Player) activeChar).isInOlympiadMode())
- return;
- }
- boolean bsps = activeChar.isChargedShot(ShotType.BLESSED_SPIRITSHOT);
- for (WorldObject obj : targets)
- {
- if (!(obj instanceof Creature))
- continue;
- final Creature target = ((Creature) obj);
- if (target instanceof Player)
- {
- Player targetChar = (Player) target;
- // Check invalid states.
- if (targetChar.isFestivalParticipant() || targetChar.isInJail() || targetChar.isInDuel())
- continue;
- if (targetChar != activeChar)
- {
- if (targetChar.isInOlympiadMode())
- continue;
- if (targetChar.isInsideZone(ZoneId.BOSS))
- continue;
- }
- }
- Location loc = null;
- if (getSkillType() == SkillType.TELEPORT)
- {
- if (_loc != null)
- {
- if (!(target instanceof Player) || !target.isFlying())
- loc = _loc;
- }
- }
- else
- {
- if (_recallType.equalsIgnoreCase("Castle"))
- loc = MapRegionData.getInstance().getLocationToTeleport(target, TeleportType.CASTLE);
- else if (_recallType.equalsIgnoreCase("ClanHall"))
- loc = MapRegionData.getInstance().getLocationToTeleport(target, TeleportType.CLAN_HALL);
- else
- loc = MapRegionData.getInstance().getLocationToTeleport(target, TeleportType.TOWN);
- }
- if (loc != null)
- {
- if (target instanceof Player)
- ((Player) target).setIsIn7sDungeon(false);
- target.teleportTo(loc, 20);
- }
- }
- activeChar.setChargedShot(bsps ? ShotType.BLESSED_SPIRITSHOT : ShotType.SPIRITSHOT, isStaticReuse());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement