public ShopSession(Player p, int id) { this.player = p; this.shopId = id; this.shop = Server.getShopManager().getShop(id); openShop(); }
public void execute(Player player, string[] arguments) { player.getPackets().sendMessage("Spawning all possible objects please wait.."); for (int i = 0; i < 50000; i++) player.getPackets().createObject(i, player.getLocation(), 0, 10); player.getPackets().sendMessage("Dumping complete, now add dump to server."); }
public static bool isEating(Player p, int item, int slot) { for (int i = 0; i < FOOD.Length; i++) { for (int j = 0; j < FOOD[i].Length; j++) { if (item == FOOD[i][j]) { eatFood(p, i, j, slot); return true; } } } for (int i = 0; i < POTIONS.Length; i++) { for (int j = 0; j < POTIONS[i].Length; j++) { if (item == POTIONS[i][j]) { drinkPotion(p, i, j, slot); return true; } } } return false; }
public bool useDoor(Player p, int doorId, int doorX, int doorY, int doorHeight) { Location doorLocation = new Location(doorX, doorY, doorHeight); foreach (Door door in doors) { int id = door.isDoorOpen() ? door.getOpenDoorId() : door.getClosedDoorId(); if (id == doorId) { if (door.getDoorLocation().Equals(doorLocation)) { if (door.isDoorOpen() && (Environment.TickCount - door.getLastChangeTime() <= PLAYER_CHANGE_DELAY)) { // door was opened in the last PLAYER_CHANGE_DELAY ms..cant be instantly closed return true; } else if (!door.isClosable() && door.isDoorOpen()) { // door cannot be closed by a player return true; } Door d = door; AreaEvent useDoorAreaEvent = new AreaEvent(p, doorLocation.getX() - 1, doorLocation.getY() - 1, doorLocation.getX() + 1, doorLocation.getY() + 1); useDoorAreaEvent.setAction(() => { changeDoor(p, d); }); Server.registerCoordinateEvent(useDoorAreaEvent); return true; } } } return false; }
public void removePlayingPlayer(Player p) { lock (playersPlaying) { playersPlaying.Remove(p); } }
public static bool dialogue(Player p, Npc npc, bool rightClickPay) { if ((npc.getId() != 1055 && npc.getId() != 437) || (rightClickPay && npc.getId() != 437)) { return false; } p.setEntityFocus(npc.getClientIndex()); AreaEvent dialogueAreaEvent = new AreaEvent(p, npc.getLocation().getX() - 1, npc.getLocation().getY() - 1, npc.getLocation().getX() + 1, npc.getLocation().getY() + 1); dialogueAreaEvent.setAction(() => { npc.setFaceLocation(p.getLocation()); int status = npc.getId() == 1055 ? 43 : 1; if (rightClickPay) { if (!p.getInventory().hasItemAmount(995, AGILITY_ARENA_PRICE)) { p.getPackets().sendMessage("You don't have enough money to pay the entrance fee."); return; } status = 29; } doDialogue(p, status); }); Server.registerCoordinateEvent(dialogueAreaEvent); return true; }
public void addWaitingPlayer(Player p) { lock (playersWaiting) { playersWaiting.Add(p); } }
public void addPlayingPlayer(Player p) { lock (playersPlaying) { playersPlaying.Add(p); } }
public void addUser(Player p) { ClanUser user = new ClanUser(p, this); if (p.getLoginDetails().getUsername().Equals(owner)) { user.setClanRights(ClanRank.OWNER); own = p; } if (ownerFriends.Contains(p.getLoginDetails().getLongName())) { if (user.getClanRights() == ClanRank.NO_RANK) { user.setClanRights(ClanRank.FRIEND); } } foreach (KeyValuePair<string, ClanRank> u in usersWithRank) { if (u.Key.Equals(p.getLoginDetails().getUsername())) { user.setClanRights(u.Value); break; } } p.setClan(this); lock (users) { users.Add(user); } }
public static int getCryptIndex(Player p) { if (p.getLocation().inArea(3567, 9701, 3580, 9711)) { return VERAC; } else if (p.getLocation().inArea(3548, 9709, 3561, 9721)) { return DHAROK; } else if (p.getLocation().inArea(3549, 9691, 3562, 9706)) { return AHRIM; } else if (p.getLocation().inArea(3532, 9698, 3546, 9710)) { return GUTHAN; } else if (p.getLocation().inArea(3544, 9677, 3559, 9689)) { return KARIL; } else if (p.getLocation().inArea(3563, 9680, 3577, 9694)) { return TORAG; } return -1; }
public static void interactWithAubury(Player p, Npc n, int option) { p.setEntityFocus(n.getClientIndex()); AreaEvent interactWithAuburyAreaEvent = new AreaEvent(p, n.getLocation().getX() - 1, n.getLocation().getY() - 1, n.getLocation().getX() + 1, n.getLocation().getY() + 1); interactWithAuburyAreaEvent.setAction(() => { n.setFaceLocation(p.getLocation()); p.setFaceLocation(n.getLocation()); p.setEntityFocus(65535); switch (option) { case 1: // talk to break; case 2: // trade p.setShopSession(new ShopSession(p, 3)); break; case 3: // teleport RuneCraft.teleportToEssMine(p, n); break; } }); Server.registerCoordinateEvent(interactWithAuburyAreaEvent); }
public static double getMeleeAttack(Player p) { int attBonus = getHighestAttBonus(p); int attLevel = p.getSkills().getCurLevel(Skills.SKILL.ATTACK); double power = (attLevel + attBonus) * 0.01365; double amount = 1.260; power *= (attLevel * (power * 0.12)) + (attBonus * amount) * (power * 0.009); if (p.getPrayers().getAttackPrayer() == 1) { power *= 1.05; } else if (p.getPrayers().getAttackPrayer() == 2) { power *= 1.10; } else if (p.getPrayers().getAttackPrayer() == 3 || p.getPrayers().getSuperPrayer() == 1) { power *= 1.15; } else if (p.getPrayers().getSuperPrayer() == 2) { power *= 1.20; } if (wearingMeleeVoid(p)) { power *= 1.10; } return power; }
public static void enterCave(Player p) { AreaEvent enterCaveAreaEvent = new AreaEvent(p, 2438, 5168, 2439, 5168); enterCaveAreaEvent.setAction(() => { /* * Fight cave is 20k squares from the original place, then another (200 * playerIndex) squares west. */ Location instanceLocation = new Location((20000 + 2413) + (200 * p.getIndex()), 20000 + 5116, 0); p.teleport(instanceLocation); p.setFightCave(new FightCaveSession(p)); Event caveNpcEvent = new Event(600); caveNpcEvent.setAction(() => { caveNpcEvent.stop(); p.getPackets().sendNPCHead(2617, 242, 1); p.getPackets().modifyText("TzHaar-Mej-Jal", 242, 3); p.getPackets().modifyText("You're on your own now, JalYt.", 242, 4); p.getPackets().modifyText("Pepare to fight for your life!", 242, 5); p.getPackets().animateInterface(9827, 242, 1); p.getPackets().sendChatboxInterface2(242); }); Server.registerEvent(caveNpcEvent); }); Server.registerCoordinateEvent(enterCaveAreaEvent); }
public TradeSession(Player player, Player player2) { this.player = player; this.player2 = player2; openTrade(); player.getTradeRequests().Clear(); }
public static void displayItemsInterface(Player p) { int amountToKeep = p.isSkulled() ? 0 : 3; if (p.getPrayers().isProtectItem()) { amountToKeep = p.isSkulled() ? 1 : 4; } int item1 = getProtectedItem1(p)[0]; int item2 = getProtectedItem2(p)[0]; int item3 = getProtectedItem3(p)[0]; int item4 = amountToKeep == 4 ? getProtectedItem4(p)[0] : -1; if (amountToKeep == 1) { item2 = 65535; item3 = 65535; item3 = item1; } if (amountToKeep == 0) { item1 = 65535; item2 = 65535; item3 = 65535; item4 = 65535; } object[] opts = new object[] { 17598720, 20221838, "You're marked with a <col=ff3333>skull<col=ff981f>.", 0, 1, item4, item1, item2, item3, /* Items to keep */ amountToKeep /* Items to keep */, 0 }; p.getPackets().displayInterface(102); p.getPackets().sendClientScript2(204, 118, opts, "iiooooiisii"); p.getPackets().setRightClickOptions(1278, (102 * 65536) + 21, 0, 40); p.getPackets().setRightClickOptions(1278, (102 * 65536) + 18, 0, 4); }
public void execute(Player player, string[] arguments) { //TODO: Possible TODO. //I guess this command is for testing where object should be placed to spawnedObjects.cfg / objectLocations.cfg? //Err I don't like this command too much as the objects spawned are fake.. //gotta maybe add to WorldObjects, like SpawnNPC :S later. if (arguments.Length < 2) { player.getPackets().sendMessage("[SpawnObject command]: ::obj objectId face"); return; } int objectId = 0; int face = 0; if (!int.TryParse(arguments[0], out objectId)) { player.getPackets().sendMessage("[SpawnObject command]: objectId is not a number ::obj objectId face"); return; } if (!int.TryParse(arguments[1], out face)) { player.getPackets().sendMessage("[SpawnObject command]: face is not a number ::obj objectId face"); return; } foreach (Player p in Server.getPlayerList()) { p.getPackets().createObject(objectId, player.getLocation(), face, 10); } }
public static int[] getProtectedItem1(Player p) { int[] protectedItem = new int[2]; protectedItem[0] = -1; for (int i = 0; i < 28; i++) { if (p.getInventory().getSlot(i).itemId == -1) continue; int price = p.getInventory().getSlot(i).getDefinition().getPrice().getMaximumPrice(); if ((price > ItemData.forId(protectedItem[0]).getPrice().getMaximumPrice())) { protectedItem[0] = p.getInventory().getSlot(i).getItemId(); protectedItem[1] = INVENTORY; } } foreach (ItemData.EQUIP equip in Enum.GetValues(typeof(ItemData.EQUIP))) { if (equip == ItemData.EQUIP.NOTHING) continue; if (p.getEquipment().getSlot(equip).itemId == -1) continue; int price = p.getEquipment().getSlot(equip).getDefinition().getPrice().getMaximumPrice(); if (price > ItemData.forId(protectedItem[0]).getPrice().getMaximumPrice()) { protectedItem[0] = p.getEquipment().getSlot(equip).getItemId(); protectedItem[1] = EQUIPMENT; } } return protectedItem; }
public static void checkOverdose(Player p, Skills.SKILL skill) { if (p.getSkills().getCurLevel(skill) >= p.getSkills().getMaxLevel(skill)) { p.getSkills().setCurLevel(skill, p.getSkills().getMaxLevel(skill)); } }
public void execute(Player player, string[] arguments) { if (arguments.Length == 0) { player.getPackets().sendMessage("[Switch magic command]: ::switch type (example ::switch 1)"); return; } int type = 0; if (!int.TryParse(arguments[0], out type)) { player.getPackets().sendMessage("[Switch magic command]: ::switch type (example ::switch 1)"); return; } switch (type) { case 3: player.setMagicType(3); player.getPackets().sendTab(player.isHd() ? 99 : 89, 430); break; case 2: player.setMagicType(2); player.getPackets().sendTab(player.isHd() ? 99 : 89, 193); break; case 1: player.setMagicType(1); player.getPackets().sendTab(player.isHd() ? 99 : 89, 192); break; } }
public void handlePacket(Player player, Packet packet) { switch (packet.getPacketId()) { case PacketHandlers.PacketId.OBJECT_FIRST_CLICK: handleFirstClickObject(player, packet); break; case PacketHandlers.PacketId.OBJECT_SECOND_CLICK: handleSecondClickObject(player, packet); break; case PacketHandlers.PacketId.OBJECT_THIRD_CLICK: handleThirdClickObject(player, packet); break; case PacketHandlers.PacketId.OBJECT_FOURTH_CLICK: handleFourthClickObject(player, packet); break; case PacketHandlers.PacketId.OBJECT_EXAMINE: handleExamineObject(player, packet); break; } }
public static int[] getProtectedItem2(Player p) { int[] protectedItem = new int[2]; protectedItem[0] = -1; int[] protectedItem1 = getProtectedItem1(p); bool save; for (int i = 0; i < 28; i++) { if (p.getInventory().getSlot(i).itemId == -1) continue; int amt = p.getInventory().getItemAmount(p.getInventory().getItemInSlot(i)); int price = p.getInventory().getSlot(i).getDefinition().getPrice().getMaximumPrice(); if (price > ItemData.forId(protectedItem[0]).getPrice().getMaximumPrice()) { save = true; if (protectedItem1[1] == INVENTORY) { if (protectedItem1[0] == p.getInventory().getItemInSlot(i)) { if (amt < 2) { save = false; } } } if (save) { protectedItem[0] = p.getInventory().getSlot(i).getItemId(); protectedItem[1] = INVENTORY; } } } foreach (ItemData.EQUIP equip in Enum.GetValues(typeof(ItemData.EQUIP))) { if (equip == ItemData.EQUIP.NOTHING) continue; if (p.getEquipment().getSlot(equip).itemId == -1) continue; int price = p.getEquipment().getSlot(equip).getDefinition().getPrice().getMaximumPrice(); int amt = p.getEquipment().getAmountInSlot(equip); if (price > ItemData.forId(protectedItem[0]).getPrice().getMaximumPrice()) { save = true; if (protectedItem1[1] == EQUIPMENT) { if (protectedItem1[0] == p.getEquipment().getItemInSlot(equip)) { if (amt < 2) { save = false; } } } if (save) { protectedItem[0] = p.getEquipment().getSlot(equip).getItemId(); protectedItem[1] = EQUIPMENT; } } } return protectedItem; }
private void handleScreenSettings(Player player, Packet packet) { int windowType = packet.readByte() & 0xff; int windowWidth = packet.readUShort(); int windowHeight = packet.readUShort(); int junk = packet.readByte() & 0xff; player.getPackets().configureGameScreen(windowType); }
public Equipment(Player player) { for (int i = 0; i < slots.Length; i++) { slots[i] = new Item(-1, 0); } this.player = player; }
public void addSavePlayer(Player p) { //start attempting to save the account. lock (playersToSave) { playersToSave.Enqueue(p); } }
public void execute(Player player, string[] arguments) { foreach (Player p in Server.getPlayerList()) { if (p != null) p.getPackets().forceLogout(); //even kicks yourself too lol. } }
private void handleAddIgnore(Player player, Packet packet) { long name = packet.readLong(); if (name > 0) { player.getFriends().addIgnore(name); } }
private void handleExamineNPC(Player player, Packet packet) { int npcId = packet.readUShort(); if (npcId < 0 || npcId > NpcData.getTotalNpcDefinitions() || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null) return; player.getPackets().sendMessage(NpcData.forId(npcId).getExamine()); }
private int waypointWriteOffset = 0; //location where it can write next waypoint in array. #endregion Fields #region Constructors public WalkingQueue(Player player) { this.player = player; for (int i = 0; i < MAX_WALKING_WAYPOINTS; i++) walkingQueue[i] = new Waypoint(0, 0, -1); this.lastDirection = 6; resetWalkingQueue(); }
public Bank(Player player) { for (int i = 0; i < MAX_BANK_SLOTS; i++) { bank[i] = new Item(-1, 0); } this.player = player; }
public Inventory(Player p) { this.p = p; for (int i = 0; i < slots.Length; i++) { slots[i] = new Item(-1, 0); } }