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 Equipment(Player player) { for (int i = 0; i < slots.Length; i++) { slots[i] = new Item(-1, 0); } this.player = player; }
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 void enterTzhaar(Player p) { AreaEvent enterTzhaarAreaEvent = new AreaEvent(p, 2866, 9570, 2866, 9572); enterTzhaarAreaEvent.setAction(() => { p.teleport(new Location(2480, 5175, 0)); }); Server.registerCoordinateEvent(enterTzhaarAreaEvent); }
public static bool interactTzhaarNPC(Player p, Npc n, int option) { if (n.getId() != 2622 && n.getId() != 2620 && n.getId() != 2623 && n.getId() != 2619 && n.getId() != 2617 && n.getId() != 2618) { return false; } p.setEntityFocus(n.getClientIndex()); int npcX = n.getLocation().getX(); int npcY = n.getLocation().getY(); AreaEvent interactTzhaarNpcAreaEvent = new AreaEvent(p, npcX-1, npcY-1, npcX+1, npcY+1); interactTzhaarNpcAreaEvent.setAction(() => { p.setFaceLocation(n.getLocation()); p.setEntityFocus(65535); switch(n.getId()) { case 2619: // Bankers if (option == 1) { // Talk } else if (option == 2) { // Bank p.getBank().openBank(); } else if (option == 3) { // Collect } break; //TODO tzhaar stores case 2622: // Ore shop if (option == 1) { // Speak } else if (option == 2) { // Trade p.setShopSession(new ShopSession(p, 3)); } break; } }); Server.registerCoordinateEvent(interactTzhaarNpcAreaEvent); return true; }
public static void exitTzhaar(Player p) { AreaEvent exitTzhaarAreaEvent = new AreaEvent(p, 2479, 5175, 2481, 5175); exitTzhaarAreaEvent.setAction(() => { p.teleport(new Location(2866, 9571, 0)); }); Server.registerCoordinateEvent(exitTzhaarAreaEvent); }
public ShopSession(Player p, int id) { this.player = p; this.shopId = id; this.shop = Server.getShopManager().getShop(id); openShop(); }
public static bool useAnimator(Player p, int itemId, int objectId, int objectX, int objectY) { if (objectId != ANIMATOR_ID) { return false; } int animatorIndex = -1; for (int i = 0; i < ANIMATOR_LOCATIONS.Length; i++) { if (objectX == ANIMATOR_LOCATIONS[i][0] && objectY == ANIMATOR_LOCATIONS[i][1]) { animatorIndex = i; break; } } if (animatorIndex == -1) { return false; } p.setTemporaryAttribute("warriorGuildAnimator", animatorIndex); CoordinateEvent createAnimatedArmorCoordinateEvent = new CoordinateEvent(p, new Location(ANIMATOR_LOCATIONS[animatorIndex][0], (ANIMATOR_LOCATIONS[animatorIndex][1] + 1), 0)); createAnimatedArmorCoordinateEvent.setAction(() => { int armourIndex = hasArmour(p, itemId); if (armourIndex != -1) { createdAnimatedArmour(p, armourIndex); } }); Server.registerCoordinateEvent(createAnimatedArmorCoordinateEvent); return true; }
public void execute(Player player, string[] arguments) { if (arguments.Length == 0) { player.getPackets().sendMessage("[Pickup command]: ::item itemId amount or just ::item itemId"); return; } int itemId = 0; if (!int.TryParse(arguments[0], out itemId)) itemId = 0; int amount = 0; if(arguments.Length >= 2 && !int.TryParse(arguments[1], out amount)) amount = 0; if (!player.inCombat()) { if (amount > 1 && !ItemData.forId(itemId).isNoted() && !ItemData.forId(itemId).isStackable()) { for (int i = 0; i < amount; i++) { if (!player.getInventory().addItem(itemId)) { break; } } } else if(amount == 0) { player.getInventory().addItem(itemId); } else { player.getInventory().addItem(itemId, amount); } } }
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 static void showCanifisSailorDialogue(Player p, int status) { int newStatus = -1; p.getPackets().softCloseInterfaces(); if (p.getTemporaryAttribute("unmovable") != null) { return; } switch(status) { case 280: p.getPackets().sendPlayerHead(64, 2); p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3); p.getPackets().modifyText("Could you take me back to Oo'glog please?", 64, 4); p.getPackets().animateInterface(9827, 64, 2); p.getPackets().sendChatboxInterface2(64); newStatus = 281; break; case 281: p.getPackets().sendNPCHead(1304, 241, 2); p.getPackets().modifyText("Sailor", 241, 3); p.getPackets().modifyText("As you wish, i'll fetch the boat.", 241, 4); p.getPackets().animateInterface(9827, 241, 2); p.getPackets().sendChatboxInterface2(241); newStatus = 282; break; case 282: travel(p, 0, true); break; } if (newStatus != -1) { p.setTemporaryAttribute("dialogue", newStatus); } }
public Inventory(Player p) { this.p = p; for (int i = 0; i < slots.Length; i++) { slots[i] = new Item(-1, 0); } }
public Bank(Player player) { for (int i = 0; i < MAX_BANK_SLOTS; i++) { bank[i] = new Item(-1, 0); } this.player = player; }
public void handlePacket(Player player, Packet packet) { switch(packet.getPacketId()) { case PacketHandlers.PacketId.NPC_FIRST_CLICK: handleFirstClickNPC(player, packet); break; case PacketHandlers.PacketId.NPC_SECOND_CLICK: handleSecondClickNPC(player, packet); break; case PacketHandlers.PacketId.NPC_THIRD_CLICK: handleThirdClickNPC(player, packet); break; case PacketHandlers.PacketId.NPC_FOURTH_CLICK: handleFourthClickNPC(player, packet); return; case PacketHandlers.PacketId.NPC_FIFTH_CLICK: handleFifthClickNPC(player, packet); break; case PacketHandlers.PacketId.NPC_EXAMINE: handleExamineNPC(player, packet); break; case PacketHandlers.PacketId.MAGIC_ON_NPC: handleMagicOnNPC(player, packet); break; case PacketHandlers.PacketId.ITEM_ON_NPC: handleItemOnNPC(player, packet); break; } }
public TradeSession(Player player, Player player2) { this.player = player; this.player2 = player2; openTrade(); player.getTradeRequests().Clear(); }
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_FIFTH_CLICK: handleFifthClickObject(player, packet); break; case PacketHandlers.PacketId.OBJECT_EXAMINE: handleExamineObject(player, packet); break; } }
public void handlePacket(Player player, Packet packet) { int size = packet.getLength(); if(packet.getPacketId() == PacketHandlers.PacketId.WALK_2) { size -= 14; } player.getWalkingQueue().resetWalkingQueue(); int steps = (size - 5) / 2; if (steps > WalkingQueue.MAX_WALKING_WAYPOINTS) { misc.WriteError("Warning: Walk command contains too many steps (" + steps + ") currently set to 50 [maybe need increase?]"); return; } player.getWalkingQueue().setIsRunning(packet.readByteA() == 1); bool following = false; if (!canWalk(player, packet, following)) { player.getPackets().clearMapFlag(); player.getWalkingQueue().resetWalkingQueue(); return; } int firstX = packet.readUShort() - (player.getLocation().getRegionX() - 6) * 8; int firstY = packet.readShortA() - (player.getLocation().getRegionY() - 6) * 8; player.getWalkingQueue().addToWalkingQueue(firstX, firstY); for (int i = 0; i < steps; i++) //all the waypoints. player.getWalkingQueue().addToWalkingQueue((packet.readByteA() + firstX), (packet.readByteS() + firstY)); if (player.getTeleportTo() != null) //is teleporting? player.getWalkingQueue().resetWalkingQueue(); if (player.getTemporaryAttribute("homeTeleporting") != null) { player.removeTemporaryAttribute("homeTeleporting"); } SkillHandler.resetAllSkills(player); if (player.getTrade() != null) player.getTrade().decline(); if (player.getDuel() != null) { if (player.getDuel().getStatus() < 4) player.getDuel().declineDuel(); else if (player.getDuel().getStatus() == 8) player.getDuel().recieveWinnings(player); } if (player.getTarget() != null) { if (!following && player.getTarget().getAttacker() != null && player.getTarget().getAttacker().Equals(player)) player.getTarget().setAttacker(null); } if (!following) { player.getFollow().setFollowing(null); player.setTarget(null); player.removeTemporaryAttribute("autoCasting"); if (player.getEntityFocus() != 65535) player.setEntityFocus(65535); } player.getPackets().closeInterfaces(); }
public static void doDialogue(Player p, int status) { if (status > 0 && status < 76) { AgilityArena.doDialogue(p, status); } else if (status > 76 && status < 100) { WarriorGuild.talkToKamfreena(p, status); } else if (status > 100 && status < 125) { BrokenBarrows.showBobDialogue(p, status); } else if (status > 155 && status < 200) { HomeArea.showAliDialogue(p, status); } else if (status > 200 && status < 235) { AlKharid.showAliDialogue(p, status); } else if (status > 239 && status < 270) { BoatOptions.showBentleyDialogue(p, status); } else if (status > 279 && status < 300) { BoatOptions.showCanifisSailorDialogue(p, status); } else if (status > 299 && status < 330) { BoatOptions.showJarvaldDialogue(p, status); } else if (status > 339 && status < 360) { BoatOptions.showSquireDialogue(p, status); } else if (status > 370 && status < 400) { BoatOptions.showArnorDialogue(p, status); } else if (status > 410 && status < 430) { BoatOptions.showCaptainBarnabyDialogue(p, status); } }
private bool canWalk(Player player, Packet packet, bool following) { if (player.getTemporaryAttribute("smeltingBar") != null) { Smelting.setAmountToZero(player); return false; } else if (player.getTemporaryAttribute("teleporting") != null && player.getTemporaryAttribute("homeTeleporting") == null) { return false; } else if (player.isFrozen()) { player.getPackets().sendMessage("A magic force prevents you from moving!"); return false; } else if (player.getDuel() != null) { if (player.getDuel().ruleEnabled(DuelSession.RULE.NO_MOVEMENT)) { if (player.getDuel().getStatus() == 5 || player.getDuel().getStatus() == 6) { if(player.getTarget() == null) player.getPackets().sendMessage("Movement is disabled for this duel."); return false; } } } else if (player.getTemporaryAttribute("unmovable") != null || player.getTemporaryAttribute("cantDoAnything") != null) { return false; } else if (player.isDead()) { return false; } else if (player.getTeleportTo() != null) { return false; } return true; }
public static void tagPillar(Player p, int pillarIndex) { AreaEvent tagPillarAreaEvent = new AreaEvent(p, AGILITY_ARENA_PILLARS[pillarIndex][1]-1, AGILITY_ARENA_PILLARS[pillarIndex][2]-1, AGILITY_ARENA_PILLARS[pillarIndex][1]+1, AGILITY_ARENA_PILLARS[pillarIndex][2]+1); tagPillarAreaEvent.setAction(() => { if (p.getLocation().getZ() == 3) { p.setFaceLocation(new Location(AGILITY_ARENA_PILLARS[pillarIndex][1], AGILITY_ARENA_PILLARS[pillarIndex][2], 3)); if (pillarIndex != currentPillar) { p.getPackets().sendMessage("You can only get a ticket when the flashing arrow is above the pillar!"); return; } if (p.isTaggedLastAgilityPillar()) { p.getPackets().sendMessage("You have already tagged this pillar, wait until the arrow moves again."); return; } int currentStatus = p.getAgilityArenaStatus(); if (currentStatus == 0) { p.getPackets().sendConfig(309, 4); p.getPackets().sendMessage("You get tickets by tagging more than one pillar in a row. Tag the next pillar!"); } else { p.getInventory().addItem(2996); p.getPackets().sendMessage("You recieve an Agility Arena ticket!"); } p.setAgilityArenaStatus(currentStatus == 0 ? 1 : 1); p.setTaggedLastAgilityPillar(true); } }); Server.registerCoordinateEvent(tagPillarAreaEvent); }
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; } }
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 static bool leaveCrypt(Player player, int stairs, int x, int y) { if (stairs != 6707 && stairs != 6703 && stairs != 6702 && stairs != 6704 && stairs != 6705 && stairs != 6706) { return false; } Player p = player; Location stairLocation; Location moundLocation; int cryptIndex = getCryptIndex(p); if (cryptIndex == -1) { return false; } stairLocation = new Location(STAIR_COORDS[cryptIndex][0], STAIR_COORDS[cryptIndex][1], 3); moundLocation = new Location(MOUND_COORDS[cryptIndex][0] + misc.random(3), MOUND_COORDS[cryptIndex][1] + misc.random(3), 0); if (p.getLocation().Equals(stairLocation)) { p.setFaceLocation(new Location(x, y, 3)); p.teleport(moundLocation); return true; } CoordinateEvent teleportMoundCoordinateEvent = new CoordinateEvent(p, stairLocation); teleportMoundCoordinateEvent.setAction(() => { p.teleport(moundLocation); }); Server.registerCoordinateEvent(teleportMoundCoordinateEvent); return true; }
public static int[] getProtectedItem1(Player p) { int[] protectedItem = new int[2]; protectedItem[0] = -1; foreach (Item item in p.getInventory().getItems()) { if(item.getItemId() == -1) continue; int price = item.getDefinition().getPrice().getMaximumPrice(); if ((price > ItemData.forId(protectedItem[0]).getPrice().getMaximumPrice())) { protectedItem[0] = item.getItemId(); protectedItem[1] = INVENTORY; } } foreach(Item item in p.getEquipment().getEquipment()) { if (item.getItemId() == -1) continue; int price = item.getDefinition().getPrice().getMaximumPrice(); if (price > ItemData.forId(protectedItem[0]).getPrice().getMaximumPrice()) { protectedItem[0] = item.getItemId(); protectedItem[1] = EQUIPMENT; } } return protectedItem; }
public static double getSpecialMeleeHit(Player p, Entity target, int weapon) { double targetDefence = getMeleeDefence(p, target); double attackerAttack = getMeleeAttack(p) * getSpecialAttackBonus(weapon); double hit = misc.randomDouble(getPlayerMaxHit(p, 0)); double playerMaxHit = getPlayerMaxHit(p, 0); if (misc.randomDouble(attackerAttack) < misc.randomDouble(targetDefence)) { p.setLastHit(0); return 0; } if (hit < (playerMaxHit * 0.50)) { if (p.getLastHit() == 0) { if (misc.random(6) == 0) { hit = (playerMaxHit * 0.50) + misc.randomDouble(playerMaxHit * 0.50); } } else if (p.getLastHit() > misc.random(6)) { if (misc.random(6) == 0) { hit = (playerMaxHit * 0.50) + misc.randomDouble(playerMaxHit * 0.50); } } } return hit; }
public static bool useJewellery(Player p, int item, int slot, bool wearingItem) { if (item == 1704 || item == 10362) { // Blank amulets p.getPackets().sendMessage("This amulet has no charges remaining."); return true; } if (p.getTemporaryAttribute("unmovable") != null || p.getTemporaryAttribute("cantDoAnything") != null) { return true; } int index = getItemIndex(item); if (index == -1) { return false; } string s = index == 2 ? "ring" : "amulet"; p.getPackets().sendMessage("You rub the " + s + "..."); p.getPackets().closeInterfaces(); int interfaceId = index == 2 ? 230 : 235; int j = 2; p.getPackets().modifyText("Teleport to where?", interfaceId, 1); for (int i = 0; i < LOCATIONS[index].Length; i++) { p.getPackets().modifyText(LOCATIONS[index][i], interfaceId, (i + j)); } if (index == 2) { p.getPackets().sendChatboxInterface2(interfaceId); } else { p.getPackets().sendChatboxInterface2(interfaceId); } JewellerySlot js = new JewelleryTeleport.JewellerySlot(index, slot, wearingItem); p.setTemporaryAttribute("jewelleryTeleport", js); return true; }
public void handlePacket(Player player, Packet packet) { switch(packet.getPacketId()) { case PacketHandlers.PacketId.EQUIP: handleEquipItem(player, packet); break; case PacketHandlers.PacketId.ITEM_ON_ITEM: handleItemOnItem(player, packet); break; case PacketHandlers.PacketId.INV_CLICK: handleInvenClickItem(player, packet); break; case PacketHandlers.PacketId.ITEM_ON_OBJECT: handleItemOnObject(player, packet); break; case PacketHandlers.PacketId.ITEM_ON_GROUND_ITEM: handleItemOnGroundItem(player, packet); break; case PacketHandlers.PacketId.INV_OPERATE: handleOperateItem(player, packet); break; case PacketHandlers.PacketId.INV_DROP: handleDropItem(player, packet); break; case PacketHandlers.PacketId.PICKUP: handlePickupItem(player, packet); break; case PacketHandlers.PacketId.INV_SWAP_SLOT: handleSwapSlot(player, packet); break; case PacketHandlers.PacketId.INV_SWAP_SLOT2: handleSwapSlot2(player, packet); break; case PacketHandlers.PacketId.INV_RIGHT_CLICK_OPTION1: handleRightClickOne(player, packet); break; case PacketHandlers.PacketId.INV_RIGHT_CLICK_OPTION2: handleRightClickTwo(player, packet); break; case PacketHandlers.PacketId.INV_EXAMINE_ITEM: handleExamineItem(player, packet); break; case PacketHandlers.PacketId.INV_EXAMINE_ITEM_GE: handleExamineItemGE(player, packet); break; } }
public Packet(Player player, byte pID, byte[] pData, Size s) { this.player = player; this.pID = pID; this.pData = pData; this.pLength = pData.Length; this.size = s; }
public ChatMessage(int colour, string chatText, int effect, Player p, byte[] packed) { this.colour = colour; this.chatText = chatText; this.effect = effect; this.player = p; this.packed = packed; }
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(); }