public static void exitCave(Player p, int objectX, int objectY) { AreaEvent exitCaveAreaEvent = new AreaEvent(p, objectX, objectY - 1, objectX + 2, objectY - 1); exitCaveAreaEvent.setAction(() => { p.setTemporaryAttribute("unmovable", true); Event teleFromCaveEvent = new Event(600); teleFromCaveEvent.setAction(() => { teleFromCaveEvent.stop(); p.getFightCave().teleFromCave(true); }); Server.registerEvent(teleFromCaveEvent); }); Server.registerCoordinateEvent(exitCaveAreaEvent); }
/** * Unregister a player. * @param p as Player */ public static void unregister(Player p) { if (p.getTrade() != null) { p.getTrade().decline(); p.setTrade(null); } minigames.getFightPits().removeWaitingPlayer(p); minigames.getFightPits().removePlayingPlayer(p); if (p.getTemporaryAttribute("cantDoAnything") != null && Location.inFightPits(p.getLocation())) { minigames.getFightPits().useOrb(p, 5); return; } if (Location.inFightPits(p.getLocation())) { Server.getMinigames().getFightPits().teleportToWaitingRoom(p, false); return; } if (p.getFightCave() != null) { if (!p.getFightCave().isGamePaused()) { p.getFightCave().teleFromCave(true); return; } else { p.setLocation(new Location(2439, 5169, 0)); } } if (!Combat.isXSecondsSinceCombat(p, p.getLastAttacked(), 10000) || p.isDead() || p.getTemporaryAttribute("unmovable") != null) { return; } if (p.getDuel() != null) { if (p.getDuel().getStatus() == 8) { if (p.getDuel().getWinner().Equals(p)) { p.getDuel().recieveWinnings(p); } } else { if (p.getDuel().getStatus() == 5 || p.getDuel().getStatus() == 6) { p.getDuel().finishDuel(true, true); } } } removeAllPlayersNPCs(p); foreach(Player p2 in players) { if(p == p2) continue; //Remove me from anyone who has Seen me.. or attempting to see me (new players). if (p2.getLocalEnvironment().getSeenPlayers().Contains(p) || p2.getLocalEnvironment().getNewPlayers().Contains(p)) p2.getLocalEnvironment().getRemovedPlayers().Add(p); } clanManager.leaveChannel(p); loginHandler.addSavePlayer(p); players.Remove(p); p.getFriends().unregistered(); Console.WriteLine("Unregistered " + p.getLoginDetails().getUsername() + " [online = " + players.Count + "]"); }
private static void doJadAttacks(Player p, Npc npc) { if (npc.getHp() <= (npc.getMaxHp() * 0.50)) { if (p.getFightCave() != null) { if (!p.getFightCave().isHealersSpawned()) { summonJadHealers(p, npc); p.getFightCave().setHealersSpawned(true); } } } npc.resetCombatTurns(); npc.setEntityFocus(p.getClientIndex()); switch(misc.random(1)) { case 0: // Range npc.setLastAnimation(new Animation(9276)); npc.setLastGraphics(new Graphics(1625)); Event jadRangeAttackEvent = new Event(1600); int jadRangeAttackStatus = 0; jadRangeAttackEvent.setAction(() => { double hit = 0; PrayerData.PrayerHeadIcon prayerHeadIcon = p.getPrayers().getHeadIcon(); if (jadRangeAttackStatus == 0) { jadRangeAttackStatus++; jadRangeAttackEvent.setTick(1500); p.setLastGraphics(new Graphics(451)); if (prayerHeadIcon == PrayerData.PrayerHeadIcon.RANGE) hit = 0; else hit = misc.randomDouble(96); } else { if (prayerHeadIcon != PrayerData.PrayerHeadIcon.RANGE) hit = misc.randomDouble(96); jadRangeAttackEvent.stop(); p.setLastAttacked(Environment.TickCount); npc.setLastAttack(Environment.TickCount); p.setAttacker(npc); if (hit > p.getHp()) { hit = p.getHp(); } if (!Location.inFightCave(p.getLocation()) || p.getTeleportTo() != null) { return; } if ((p.getCombatTurns() > 2 || p.getCombatTurns() < 0)) { p.setLastAnimation(new Animation(p.getDefenceAnimation())); } p.hit(hit); Event animationEvent = new Event(100); animationEvent.setAction(() => { animationEvent.stop(); p.setLastGraphics(new Graphics(157, 0, 100)); }); Server.registerEvent(animationEvent); } }); Server.registerEvent(jadRangeAttackEvent); break; case 1: // Magic npc.setLastGraphics(new Graphics(1626)); Event jadMagicAttackEvent = new Event(300); int jadMagicAttackStatus = 0; jadMagicAttackEvent.setAction(() => { double hit = 0; PrayerData.PrayerHeadIcon prayerHeadIcon = p.getPrayers().getHeadIcon(); npc.setLastAnimation(new Animation(9278)); if (jadMagicAttackStatus == 0) { jadMagicAttackStatus++; jadMagicAttackEvent.setTick(1600); p.getPackets().sendProjectile(npc.getLocation(), p.getLocation(), 32, 1627, 50, 40, 34, 90, p); } else { jadMagicAttackEvent.stop(); if (prayerHeadIcon == PrayerData.PrayerHeadIcon.MAGIC) { hit = 0; } else { hit = misc.randomDouble(96); } p.setLastAttacked(Environment.TickCount); npc.setLastAttack(Environment.TickCount); p.setAttacker(npc); if (hit > p.getHp()) { hit = p.getHp(); } if (!Location.inFightCave(p.getLocation()) || p.getTeleportTo() != null) { return; } if ((p.getCombatTurns() > 2 || p.getCombatTurns() < 0)) { p.setLastAnimation(new Animation(p.getDefenceAnimation())); } p.hit(hit); Event animationEvent = new Event(100); animationEvent.setAction(() => { animationEvent.stop(); p.setLastGraphics(new Graphics(157, 0, 100)); }); Server.registerEvent(animationEvent); } }); Server.registerEvent(jadMagicAttackEvent); break; } }