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; } }
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 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 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 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 static void displayWildernessLeverOptions(Player p, int leverIndex) { int dialogueIndex = 140 + leverIndex; p.setTemporaryAttribute("dialogue", dialogueIndex); string option1 = leverIndex == 0 ? "Edgeville" : "Home"; p.getPackets().modifyText(option1, 230, 2); p.getPackets().modifyText("Mage bank", 230, 3); p.getPackets().modifyText("Nowhere", 230, 4); p.getPackets().sendChatboxInterface2(230); }
public void execute(Player player, string[] arguments) { if (arguments.Length == 0) { player.getPackets().sendMessage("[Reload Ladders & Stairs XML File]: This command is only for server developers."); player.getPackets().sendMessage("Reloading... [Could crash server if populated, as all ladders get erased]"); LaddersAndStairs.load(); player.getPackets().sendMessage("Reloaded."); } }
public static void openInterface(Player p) { p.getPackets().displayInterface(771); p.getPackets().sendPlayerHead(771, 79); p.getPackets().animateInterface(9804, 771, 79); p.getPackets().sendConfig(1262, p.getAppearance().getGender() == 2 ? 1 : 8); p.getAppearance().setTemporaryAppearance(new Appearance()); p.getAppearance().getTemporaryAppearance().setColoursArray(p.getAppearance().getColoursArray()); p.getAppearance().getTemporaryAppearance().setLookArray(p.getAppearance().getLookArray()); p.getAppearance().getTemporaryAppearance().setGender(p.getAppearance().getGender()); p.removeTemporaryAttribute("hairToggle"); }
public void leaveChannel(Player p) { foreach(Clan c in clans) { if (c != null) { if (c.getUser(p) != null) { c.removeUser(p); p.getPackets().resetClanInterface(); p.getPackets().sendMessage("You have left the channel. :clan:"); updateClan(c); 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 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 addToStack(int id, int amount, Location location, Player p) { if (!ItemData.forId(id).isStackable()) { return false; } foreach(GroundItem i in items) { if(i.getLocation().Equals(location) && i.getItemId() == id) { if (!i.isGlobal() && i.getOwner().Equals(p)) { i.setItemAmount(i.getItemAmount() + amount); p.getPackets().clearGroundItem(i); p.getPackets().createGroundItem(i); 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 void execute(Player player, string[] arguments) { if (arguments.Length == 0) { player.getPackets().sendMessage("[Height command]: ::height 0 [0,1,2,3] are possible"); return; } int heightLevel = 0; if (!int.TryParse(arguments[0], out heightLevel)) { player.getPackets().sendMessage("[Height command]: ::height 0 [0,1,2,3] are possible"); return; } player.teleport(new Location(player.getLocation().getX(), player.getLocation().getY(), heightLevel)); }
public void execute(Player player, string[] arguments) { if (arguments.Length == 0) { player.getPackets().sendMessage("[Interface command]: ::inter interface_number"); return; } int intreface = 0; if (!int.TryParse(arguments[0], out intreface)) { player.getPackets().sendMessage("[Interface command]: ::inter interface_number"); return; } player.getPackets().displayInterface(intreface); }
public void execute(Player player, string[] arguments) { if (arguments.Length == 0) { player.getPackets().sendMessage("[Animation command]: ::emote emote_number"); return; } int animation = 0; if (!int.TryParse(arguments[0], out animation)) { player.getPackets().sendMessage("[Animation command]: ::emote emote_number"); return; } player.setLastAnimation(new model.Animation(animation)); }
public void execute(Player player, string[] arguments) { if (!Server.isUpdateInProgress()) { //could of hardcoded the Event right inside this command :S player.getPackets().sendMessage("Started a system update, this cannot be stopped!"); Server.registerEvent(new SystemUpdateEvent()); Server.setUpdateInProgress(true); } }
public void execute(Player player, string[] arguments) { if (arguments.Length < 2) { player.getPackets().sendMessage("[Teleport command]: ::tele x y or even ::tele x y z"); return; } int x,y,z = 0; if (!int.TryParse(arguments[0], out x) || !int.TryParse(arguments[1], out y)) { player.getPackets().sendMessage("Bad x,y coordinate, teleporting home, You entered:[x=" + arguments[0] + ", y=" + arguments[1] + "]"); player.teleport(Constants.HOME_SPAWN_LOCATION.randomSpawn()); return; } if (arguments.Length >= 3) int.TryParse(arguments[2], out z); player.teleport(new Location(x, y, z)); }
public void execute(Player player, string[] arguments) { if (arguments.Length == 0) { player.getPackets().sendMessage("[PlayerAsNpc command]: ::pnpc npcId"); return; } int npcId = 0; if (!int.TryParse(arguments[0], out npcId)) { player.getPackets().sendMessage("[PlayerAsNpc command]: ::pnpc npcId [npcId is not a number error]"); return; } player.getAppearance().setNpcId(npcId); player.getUpdateFlags().setAppearanceUpdateRequired(true); }
public void execute(Player player, string[] arguments) { if (arguments.Length == 0) { player.getPackets().sendMessage("[Animation command]: ::t emote_number"); return; } int animation = 0; if (!int.TryParse(arguments[0], out animation)) { player.getPackets().sendMessage("[Animation command]: ::emote emote_number"); return; } //1179 flash + skill icon , 1230 = make box player.getPackets().playSoundEffect(animation, 1, 0); }
public void execute(Player player, string[] arguments) { if (arguments.Length == 0) { player.getPackets().sendMessage("[Kick command]: ::kick playerName, or else try ::kickall"); return; } arguments[0] = arguments[0].ToLower(); foreach (Player p in Server.getPlayerList()) { if (p != null) { if (p.getLoginDetails().getUsername().ToLower().Equals(arguments[0])) { p.getPackets().logout(); player.getPackets().sendMessage("You have successfully kicked " + arguments[0]); break; } } } }
public void execute(Player player, string[] arguments) { foreach (Skills.SKILL skill in Enum.GetValues(typeof(Skills.SKILL))) { player.getSkills().setCurLevel(skill, 99); player.getSkills().setXp(skill, Skills.getXpForLevel(99)); } player.getPackets().sendSkillLevels(); player.getUpdateFlags().setAppearanceUpdateRequired(true); }
public void execute(Player player, string[] arguments) { if (arguments.Length < 2) { player.getPackets().sendMessage("[Config command]: ::config id value (example ::config 1 1)"); return; } int id = 0; int value = 0; if (!int.TryParse(arguments[0], out id) && !int.TryParse(arguments[1], out value)) { player.getPackets().sendMessage("[Config command]: ::config id value (example ::config 1 1)"); return; } player.getPackets().sendConfig(id, value); }
public void execute(Player player, string[] arguments) { if (arguments.Length == 0) { player.getPackets().sendMessage("[SpawnNpc command]: ::npc npc_id"); return; } int npcId = 0; if (!int.TryParse(arguments[0], out npcId)) { player.getPackets().sendMessage("[SpawnNpc command]: ::npc npc_id"); return; } Npc npc = new Npc(npcId, player.getLocation()); npc.setMinimumCoords(new Location(player.getLocation().getX() - 5, player.getLocation().getY() - 5, player.getLocation().getZ())); npc.setMaximumCoords(new Location(player.getLocation().getX() + 5, player.getLocation().getY() + 5, player.getLocation().getZ())); Server.getNpcList().Add(npc); }
public void execute(Player player, string[] arguments) { if (arguments.Length == 0) { player.getPackets().sendMessage("[Graphic command]: ::gfx gfx_number"); return; } int gfxId = 0; if (!int.TryParse(arguments[0], out gfxId)) gfxId = 0; player.setLastGraphics(new Graphics(gfxId, 0, 100)); }
public void execute(Player player, string[] arguments) { if (arguments.Length > 0) { int shopIndex = 0; if (!int.TryParse(arguments[0], out shopIndex)) { player.getPackets().sendMessage("[OpenShop command]: ::shop shop_number or just ::shop to open first one."); return; } Shop shop = Server.getShopManager().getShop(shopIndex); if (shop == null) { player.getPackets().sendMessage("[OpenShop command]: shop #" + shopIndex + " doesn't exist on server"); return; } player.setShopSession(new ShopSession(player, shopIndex)); } player.setShopSession(new ShopSession(player, 1)); }
public static void display(Player player, int buttonId) { int j = 0; for (int i = 125; i < 149; i++) { if (buttonId == i) { int skillFlashFlags = (int)(player.getTemporaryAttribute("skillFlashFlags") == null ? 0 : (int)player.getTemporaryAttribute("skillFlashFlags")); if ((skillFlashFlags & getSkillFlashingIcon(j)) == getSkillFlashingIcon(j)) { skillFlashFlags &= ~getSkillFlashingIcon(j); //turn off this skill icon flashing animation bit. player.getPackets().sendConfig(1179, skillFlashFlags); //stop flashing the skill you clicked on, if it was flashing. player.setTemporaryAttribute("skillFlashFlags", skillFlashFlags); //update the variable for remaining flashing skill icons. } player.getPackets().displayInterface(499); player.getPackets().sendConfig(965, MENU_ID[j]); player.setTemporaryAttribute("SkillMenu", (int) MENU_ID[j]); break; } j++; } }
public void execute(Player player, string[] arguments) { if (arguments.Length == 0) { player.getPackets().sendMessage("[Info command]: ::info npcId (example ::info 1)"); return; } int npcId = 0; if (!int.TryParse(arguments[0], out npcId)) { player.getPackets().sendMessage("[Info command]: ::info npcId (example ::info 1)"); return; } if (npcId < 0 || npcId > NpcData.getTotalNpcDefinitions()) return; player.getPackets().sendMessage("ATT = " + (int)CombatFormula.getMeleeAttack(player) + " DEF = " + (int)CombatFormula.getMeleeDefence(player, player) + " SPEC = " + (int)CombatFormula.getMeleeAttack(player) * CombatFormula.getSpecialAttackBonus(player.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON))); player.getPackets().sendMessage("NPC ATT = " + (int)CombatFormula.getNPCMeleeAttack(new Npc(npcId)) + " NPC DEF = " + (int)CombatFormula.getNPCMeleeDefence(new Npc(npcId))); }
public void enterChannel(Player p, string owner) { if (p.getClan() != null) { return; } p.getPackets().sendMessage("Attempting to join channel...:clan:"); if (owner.Equals(p.getLoginDetails().getUsername())) { Clan newClan = new Clan(p, owner, owner); addChannel(newClan); } Event enterChannelEvent = new Event(700); enterChannelEvent.setAction(() => { enterChannelEvent.stop(); foreach(Clan c in clans) { if (c != null) { if (c.getClanOwner().Equals(owner)) { if(c.getUserList().Count >= 100) { p.getPackets().sendMessage("The channel is full."); return; } if (!owner.Equals(p.getLoginDetails().getUsername())) { if (c.getEnterRights() != Clan.ClanRank.NO_RANK) { if (c.getEnterRights() == Clan.ClanRank.FRIEND) { if (!c.isFriendOfOwner(p) && !c.userHasRank(p.getLoginDetails().getUsername())) { p.getPackets().sendMessage("You do not have a high enough rank to enter this clan chat."); return; } } else { bool canEnter = true; foreach (KeyValuePair<string, Clan.ClanRank> u in c.getUsersWithRank()) { if(u.Key.Equals(p.getLoginDetails().getUsername())) { if (u.Value < c.getEnterRights()) { canEnter = false; break; } } } if (!canEnter) { p.getPackets().sendMessage("You do not have a high enough rank to enter this clan chat."); return; } } } } c.addUser(p); updateClan(c); p.getPackets().sendMessage("Now talking in channel : " + misc.formatPlayerNameForDisplay(c.getClanName() + ":clan:")); p.getPackets().sendMessage("To talk, start each line of chat with the / symbol. :clan:"); return; } } } p.getPackets().sendMessage("The channel you tried to join does not exist. :clan:"); }); Server.registerEvent(enterChannelEvent); }
public void setCurLevel(SKILL skill, int lvl) { int i_skill = Convert.ToInt32(skill); curLevel[i_skill] = lvl; //Hitpoints and prayer are the only two skills which can hit 0. if (curLevel[i_skill] <= 0) { if (skill == SKILL.HITPOINTS || skill == SKILL.PRAYER) { curLevel[i_skill] = 0; if (player.isActive() && skill == SKILL.PRAYER) { player.getPackets().sendMessage("You have run out of Prayer points, please recharge your prayer at an altar."); Prayer.deactivateAllPrayers(player); } } else { curLevel[i_skill] = 1; } } }
public GESession(Player p, bool isGrandExchangeOrCollectBox) { this.p = p; //Load offers. myGEItems = Server.getGrandExchange().getOffersByPlayer(p); foreach (GEItem geItem in myGEItems) { if (geItem != null) { p.getPackets().updateGEProgress(geItem); } } if (isGrandExchangeOrCollectBox) { openExchange(); } else { openCollectBox(); } }
public static void levelUp(Player player, SKILL skill) { int skillIndex = Convert.ToInt32(skill); String s = "<br><br><br>"; String s1 = "<br><br><br><br>"; if (player.getTemporaryAttribute("teleporting") == null) { player.setLastGraphics(new Graphics(199, 0, 100)); } int skillFlashFlags = (int)(player.getTemporaryAttribute("skillFlashFlags") == null ? 0 : (int)player.getTemporaryAttribute("skillFlashFlags")); skillFlashFlags |= SKILL_FLASH_BITMASKS[skillIndex]; player.setTemporaryAttribute("skillFlashFlags", skillFlashFlags); player.getPackets().sendMessage("You've just advanced a " + SKILL_NAME[skillIndex] + " level! You have reached level " + player.getSkills().getMaxLevel(skillIndex) + "."); player.getPackets().modifyText(s + "Congratulations, you have just advanced a " + SKILL_NAME[skillIndex] + " level!", 740, 0); player.getPackets().modifyText(s1 + "You have now reached level " + player.getSkills().getMaxLevel(skillIndex) + ".", 740, 1); player.getPackets().modifyText("", 740, 2); player.getPackets().sendConfig(1179, SKILL_ICON_BITMASKS[skillIndex] | skillFlashFlags); //start flashing appropriate skill icons player.getPackets().sendChatboxInterface2(740); player.getUpdateFlags().setAppearanceUpdateRequired(true); }
public void clearAll() { for (int i = 0; i < slots.Length; i++) { slots[i].setItemId(-1); slots[i].setItemAmount(0); } p.getPackets().refreshInventory(); }
public void openBank() { player.getWalkingQueue().resetWalkingQueue(); player.getPackets().clearMapFlag(); //int items = 20 * 1024^0 + 3 * 1024^1 + 4 * 1024^2; // Used with config2 1246 if (!banking) { if (!pinCorrect && bankPin != null) { if (isPinPending()) { verifyPin(false); return; } if (!isPinPending()) { pinStatus = 0; tempPin1 = new int[4]; openEnterPin(); return; } } player.getPackets().sendConfig(563, 0x400000); player.getPackets().sendConfig(1248, -0x78000000); player.getPackets().sendConfig(1249, lastXAmount); player.getPackets().sendBankOptions(); refreshBank(); player.getPackets().displayInventoryInterface(763); player.getPackets().displayInterface(762); player.getPackets().showChildInterface(762, 18, false); player.getPackets().showChildInterface(762, 19, false); player.getPackets().showChildInterface(762, 23, false); //setTabConfig(); banking = true; } }
public void refresh() { player.getPackets().setPrivacyOptions(); player.getPackets().setFriendsListStatus(); foreach (long friend in friends) { player.getPackets().sendFriend(friend, getWorld(friend)); } long[] array = new long[ignores.Count]; int i = 0; foreach (long ignore in ignores) { array[i++] = ignore; } player.getPackets().sendIgnores(array); }
public void newCannon() { setupTime = Environment.TickCount; Event setupNewCannonEvent = new Event(1000); setupNewCannonEvent.setAction(() => { string prefixMsg = (constructionStage == 0) ? "You place the " : "You add the "; string suffixMsg = (constructionStage == 0) ? " on the ground." : "."; if (p.getInventory().deleteItem(CANNON_PIECES[constructionStage])) { p.getPackets().createObject(CANNON_OBJECTS[constructionStage], cannonLocation, 0, 10); p.getPackets().sendMessage(prefixMsg + CONSTRUCTION_MESSAGE[constructionStage] + suffixMsg); if (++constructionStage >= 4) { constructionStage--; setupNewCannonEvent.stop(); return; } p.setLastAnimation(new Animation(827)); } else { setupNewCannonEvent.stop(); } }); Server.registerEvent(setupNewCannonEvent); }
private void openTrade() { player.getPackets().displayInterface(335); player.getPackets().displayInventoryInterface(336); player.getPackets().setRightClickOptions(1278, (335 * 65536) + 30, 0, 27); player.getPackets().setRightClickOptions(1026, (335 * 65536) + 32, 0, 27); player.getPackets().setRightClickOptions(1278, (336 * 65536), 0, 27); player.getPackets().setRightClickOptions(2360446, (336 * 65536), 0, 27); object[] opts1 = new object[] { "", "", "", "Value", "Remove X", "Remove All", "Remove 10", "Remove 5", "Remove 1", -1, 0, 7, 4, 90, 21954590 }; object[] opts2 = new object[] { "", "", "Lend", "Value", "Offer X", "Offer All", "Offer 10", "Offer 5", "Offer 1", -1, 0, 7, 4, 93, 22020096 }; object[] opts3 = new object[] { "", "", "", "", "", "", "", "", "Value", -1, 0, 7, 4, 90, 21954592 }; player.getPackets().sendClientScript(150, opts1, "IviiiIsssssssss"); player.getPackets().sendClientScript(150, opts2, "IviiiIsssssssss"); player.getPackets().sendClientScript(695, opts3, "IviiiIsssssssss"); player.getPackets().modifyText("Trading with: " + player2.getLoginDetails().getUsername(), 335, 15); player.getPackets().modifyText(player2.getLoginDetails().getUsername() + " has " + player2.getInventory().getTotalFreeSlots() + " free inventory slots.", 335, 21); player.getPackets().modifyText("", 335, 36); refreshTrade(); }
public bool tradeItem(int slot, int amount) { int itemId = player.getInventory().getItemInSlot(slot); bool stackable = ItemData.forId(itemId).isStackable(); int tradeSlot = findItem(itemId); if (amount <= 0 || itemId == -1 || status > 2) { return(false); } if (ItemData.forId(itemId).isPlayerBound()) { player.getPackets().sendMessage("You cannot trade that item."); return(false); } if (!stackable) { tradeSlot = findFreeSlot(); if (tradeSlot == -1) { player.getPackets().sendMessage("An error occured whilst trying to find free a trade slot."); return(false); } if (amount > player.getInventory().getItemAmount(itemId)) { amount = player.getInventory().getItemAmount(itemId); } for (int i = 0; i < amount; i++) { tradeSlot = findFreeSlot(); if (!player.getInventory().deleteItem(itemId) || tradeSlot == -1) { break; } items[tradeSlot] = new Item(itemId, 1); } if (status == 2 || player2.getTrade().getStatus() == 2) { this.status = 1; player2.getTrade().setStatus(1); player.getPackets().modifyText("", 335, 36); player2.getPackets().modifyText("", 335, 36); } refreshTrade(); return(true); } else if (stackable) { tradeSlot = findItem(itemId); if (tradeSlot == -1) { tradeSlot = findFreeSlot(); if (tradeSlot == -1) { player.getPackets().sendMessage("An error occured whilst trying to find free a trade slot."); return(false); } } if (amount > player.getInventory().getAmountInSlot(slot)) { amount = player.getInventory().getAmountInSlot(slot); } if (player.getInventory().deleteItem(itemId, amount)) { if (items[tradeSlot] == null) { items[tradeSlot] = new Item(itemId, amount); } else { if (items[tradeSlot].getItemId() == itemId) { items[tradeSlot].setItemId(itemId); items[tradeSlot].setItemAmount(items[tradeSlot].getItemAmount() + amount); } } if (status == 2 || player2.getTrade().getStatus() == 2) { this.status = 1; player2.getTrade().setStatus(1); player.getPackets().modifyText("", 335, 36); player2.getPackets().modifyText("", 335, 36); } refreshTrade(); return(true); } } return(false); }
public bool equipItem(int itemID, int slot) { ItemData.EQUIP equipType = ItemData.getItemType(itemID); int amount = player.getInventory().getAmountInSlot(slot); bool stackable = ItemData.forId(itemID).isStackable(); bool twoHanded = ItemData.isTwoHanded(itemID); if (equipType == ItemData.EQUIP.NOTHING) { player.getPackets().sendMessage("Unable to find an item slot for item : " + itemID + " , please report this to a staff member."); return(false); } if (duelRuleActive(equipType)) { return(true); } if (twoHanded) { if (player.getInventory().getTotalFreeSlots() < getNeeded2HSlots()) { player.getPackets().sendMessage("Not enough space in your inventory."); return(false); } } if (!player.getInventory().deleteItem(itemID, slot, amount)) { return(false); } if (twoHanded && getItemInSlot(ItemData.EQUIP.SHIELD) != -1) { if (!unequipItem(ItemData.EQUIP.SHIELD)) { return(false); } } if (equipType == ItemData.EQUIP.SHIELD) { if (getItemInSlot(ItemData.EQUIP.WEAPON) != -1) { if (ItemData.isTwoHanded(slots[3].getItemId())) { if (!unequipItem(ItemData.EQUIP.WEAPON)) { return(false); } } } } int equipSlot = Convert.ToInt32(equipType); if (slots[equipSlot].getItemId() != itemID && slots[equipSlot].getItemId() > 0) { if (!player.getInventory().addItem(slots[equipSlot].getItemId(), slots[equipSlot].getItemAmount(), slot)) { return(false); } if (equipType == ItemData.EQUIP.HAT) { RuneCraft.toggleRuin(player, slots[equipSlot].getItemId(), false); if (RuneCraft.getTiaraIndex(itemID) != -1) // switching from tiara to tiara. { RuneCraft.toggleRuin(player, itemID, true); } } } else if (stackable && slots[equipSlot].getItemId() == itemID) { amount = slots[equipSlot].getItemAmount() + amount; } else if (slots[equipSlot].getItemId() != -1) { player.getInventory().addItem(slots[equipSlot].getItemId(), slots[equipSlot].getItemAmount(), slot); } slots[equipSlot].setItemId(itemID); slots[equipSlot].setItemAmount(amount); player.getPackets().refreshEquipment(); player.getUpdateFlags().setAppearanceUpdateRequired(true); if (equipType == ItemData.EQUIP.HAT) { RuneCraft.toggleRuin(player, itemID, RuneCraft.wearingTiara(player)); } if (equipType == ItemData.EQUIP.WEAPON) { setWeapon(); MagicData.cancelAutoCast(player, true); } refreshBonuses(); player.setEntityFocus(65535); return(true); }
public bool doSpecialAttack(Entity killer, Entity target) { int weapon = ((Player)killer).getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON); int currentPower = specialAmount; int neededPower = getRequiredAmount(weapon); bool rangeWeapon = false; if (!usingSpecial) { return(false); } if (p.getDuel() != null) { if (p.getDuel().ruleEnabled(DuelSession.RULE.NO_SPECIAL_ATTACKS)) { p.getPackets().sendMessage("Special attacks have been disabled for this duel!"); usingSpecial = false; refreshBar(); return(false); } } if (neededPower > currentPower) { ((Player)killer).getPackets().sendMessage("You don't have enough special power left."); usingSpecial = false; refreshBar(); return(false); } double damage = -1; double damage2 = -1; double damage3 = -1; double damage4 = -1; bool doubleHit = false; int increasedMaxHit = 0; damage = CombatFormula.getSpecialMeleeHit((Player)killer, target, weapon); damage2 = CombatFormula.getSpecialMeleeHit((Player)killer, target, weapon); int hitDelay = killer.getHitDelay(); int usingBow = ((Player)killer).getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON); int usingArrows = ((Player)killer).getEquipment().getItemInSlot(ItemData.EQUIP.ARROWS); bool usingRangePrayer = false; if (target is Player) { usingRangePrayer = ((Player)target).getPrayers().isPrayerActive(PrayerData.Prayer.PROTECT_FROM_RANGED); } switch (weapon) { case 4151: // Whip. killer.setLastAnimation(new Animation(1658)); target.setLastGraphics(new Graphics(341, 0, 100)); if (misc.random(3) == 0 && damage > 0) { damage = p.getMaxHit(); } else { damage = 0; } if (target is Player) { int energy = ((Player)target).getRunEnergy() / 4; ((Player)killer).setRunEnergy(((Player)killer).getRunEnergy() + energy); ((Player)target).setRunEnergy(((Player)target).getRunEnergy() - energy); if (((Player)killer).getRunEnergy() > 100) { ((Player)killer).setRunEnergy(100); } if (((Player)target).getRunEnergy() < 0) { ((Player)target).setRunEnergy(0); } } break; case 1215: // Dragon daggers. case 1231: case 5680: case 5698: if (damage > 0) { damage = p.getMaxHit(20); damage2 = p.getMaxHit(20); } killer.setLastAnimation(new Animation(1062)); killer.setLastGraphics(new Graphics(252, 0, 100)); doubleHit = true; /*if (misc.random(3) == 0 && CombatFormula.getMeleeHit(p, target) > 0) { * if (damage <= (CombatFormula.getPlayerMaxHit(p, 20) / 2) && damage2 <= (CombatFormula.getPlayerMaxHit(p, 20) / 2)) * { * damage = (CombatFormula.getPlayerMaxHit(p, 20) / 2) + (misc.randomDouble(CombatFormula.getPlayerMaxHit(p, 20)) / 2); * damage2 = (CombatFormula.getPlayerMaxHit(p, 20) / 2) + (misc.randomDouble(CombatFormula.getPlayerMaxHit(p, 20)) / 2); * } * } else if (misc.random(2) == 0) { * damage = 0; * damage2 = 0; * }*/ double a = damage + damage2; if (damage > target.getHp()) { damage = target.getHp(); } a -= damage; if (damage2 > a) { damage2 = a; } /*if (damage > target.getHp()) { * int randomHp = misc.random(target.getHp()); * damage = randomHp; * damage2 = target.getHp() - randomHp; * } else { * int hpRemaining = target.getHp() - damage; * if (damage2 > hpRemaining) { * damage2 = hpRemaining; * } * }*/ break; case 1305: // Dragon longsword. killer.setLastAnimation(new Animation(1058)); killer.setLastGraphics(new Graphics(248, 0, 100)); damage = p.getMaxHit(30); break; case 11694: // Armadyl godsword. killer.setLastGraphics(new Graphics(1222, 0, 100)); killer.setLastAnimation(new Animation(7074)); damage += p.getMaxHit() * 0.25; //25% decrease. break; case 11696: // Bandos godsword. killer.setLastGraphics(new Graphics(1223, 0, 100)); killer.setLastAnimation(new Animation(7073)); damage += p.getMaxHit() * 0.10; //10% decrease. break; case 11698: // Saradomin godsword. killer.setLastGraphics(new Graphics(1220, 0, 100)); killer.setLastAnimation(new Animation(7071)); int newHp = (int)(damage * 0.50); //50% decrease. int newPrayer = (int)(damage * 0.25); //25% decrease if (newHp < 10) { newHp = 10; } if (newPrayer < 5) { newPrayer = 5; } ((Player)killer).heal(newHp); ((Player)killer).getSkills().setCurLevel(Skills.SKILL.PRAYER, ((Player)killer).getSkills().getCurLevel(Skills.SKILL.PRAYER) + newPrayer); if (((Player)killer).getSkills().getCurLevel(Skills.SKILL.PRAYER) > ((Player)killer).getSkills().getMaxLevel(Skills.SKILL.PRAYER)) { ((Player)killer).getSkills().setCurLevel(Skills.SKILL.PRAYER, ((Player)killer).getSkills().getMaxLevel(Skills.SKILL.PRAYER)); } break; case 11700: // Zamorak godsword killer.setLastGraphics(new Graphics(1221, 0, 100)); killer.setLastAnimation(new Animation(7070)); target.setLastGraphics(new Graphics(369)); MagicCombat.freezeTarget(31, target); break; case 11730: // Saradomin sword target.setLastGraphics(new Graphics(1207, 0, 100)); killer.setLastAnimation(new Animation(7072)); increasedMaxHit = 16; break; case 1434: // Dragon mace hitDelay = 700; killer.setLastGraphics(new Graphics(251, 0, 75)); killer.setLastAnimation(new Animation(1060)); damage = p.getMaxHit(60); break; case 3204: // Dragon halberd // TODO halberd break; case 4587: // Dragon scimitar killer.setLastGraphics(new Graphics(347, 0, 100)); killer.setLastAnimation(new Animation(451)); if (target is Player) { if (((Player)target).getPrayers().isPrayerActive(PrayerData.Prayer.PROTECT_FROM_MELEE) || ((Player)target).getPrayers().isPrayerActive(PrayerData.Prayer.PROTECT_FROM_MAGIC) || ((Player)target).getPrayers().isPrayerActive(PrayerData.Prayer.PROTECT_FROM_RANGED) || ((Player)target).getPrayers().isPrayerActive(PrayerData.Prayer.RETRIBUTION) || ((Player)target).getPrayers().isPrayerActive(PrayerData.Prayer.REDEMPTION) || ((Player)target).getPrayers().isPrayerActive(PrayerData.Prayer.SMITE)) { ((Player)target).getPackets().sendMessage("The Dragon scimitar slashes through your prayer protection!"); Prayer.forcePrayerOff((Player)target, PrayerData.Prayer.PROTECT_FROM_MELEE); Prayer.forcePrayerOff((Player)target, PrayerData.Prayer.PROTECT_FROM_MAGIC); Prayer.forcePrayerOff((Player)target, PrayerData.Prayer.PROTECT_FROM_RANGED); Prayer.forcePrayerOff((Player)target, PrayerData.Prayer.RETRIBUTION); Prayer.forcePrayerOff((Player)target, PrayerData.Prayer.REDEMPTION); Prayer.forcePrayerOff((Player)target, PrayerData.Prayer.SMITE); } } break; case 14484: // Dragon claws doubleHit = true; killer.setLastGraphics(new Graphics(1950)); killer.setLastAnimation(new Animation(10961)); if (misc.random(1) == 0 && damage > 0) { if (damage < p.getMaxHit(20) * 0.75) { damage = (p.getMaxHit(20) * 0.75 + (misc.randomDouble((p.getMaxHit(20) * 0.25)))); } } damage = Math.Floor(damage); damage2 = Math.Floor(damage * 0.50); //50% decrease damage3 = Math.Floor(damage2 * 0.50); //50% decrease damage4 = Math.Floor(damage3 + 1); break; case 1249: // Dragon spear //TODO leave due to noclipping? break; case 6739: // Dragon axe //TODO find emote and graphic break; case 7158: // Dragon 2h killer.setLastAnimation(new Animation(3157)); killer.setLastGraphics(new Graphics(559)); //TODO multi combat break; case 3101: // Rune claws killer.setLastGraphics(new Graphics(274)); break; case 4153: // Granite maul killer.setLastAnimation(new Animation(1667)); killer.setLastGraphics(new Graphics(340, 0, 100)); //doubleHit = true; break; case 10887: // Barrelchest anchor break; case 11061: // Ancient mace break; case 13902: // Statius' warhammer killer.setLastAnimation(new Animation(10505)); killer.setLastGraphics(new Graphics(1840)); damage += killer.getMaxHit() * 0.25; //25% decrease if (target is Player) { int defenceLevel = ((Player)target).getSkills().getCurLevel(Skills.SKILL.DEFENCE); int newDefence = (int)(defenceLevel * 0.30); //30% decrease. if (newDefence < 1) { newDefence = 1; } ((Player)target).getSkills().setCurLevel(Skills.SKILL.DEFENCE, defenceLevel - newDefence); ((Player)target).getPackets().sendSkillLevel(Skills.SKILL.DEFENCE); } break; case 13899: // Vesta's longsword killer.setLastAnimation(new Animation(10502)); damage += killer.getMaxHit() * 0.20; //20% decrease break; case 13905: // Vesta's spear killer.setLastAnimation(new Animation(10499)); killer.setLastGraphics(new Graphics(1835)); break; case 13883: // Morrigans throwing axe break; case 13879: // Morrigans javelin case 8880: // Dorgeshuun crossbow break; case 861: // Magic shortbow case 859: // Magic longbow case 10284: // Magic composite bow rangeWeapon = true; if (p.getEquipment().getAmountInSlot(ItemData.EQUIP.ARROWS) < 2) { p.getPackets().sendMessage("You need 2 arrows to use the Magic bow special attack!"); return(false); } damage = CombatFormula.getRangeHit((Player)killer, target, usingBow, usingArrows); damage2 = CombatFormula.getRangeHit((Player)killer, target, usingBow, usingArrows); damage *= 1.05; //5% increase. damage2 *= 1.05; //5% increase. if (usingRangePrayer) { damage *= 0.60; //60% decrease. damage2 *= 0.60; //60% decrease. } double a1 = damage + damage2; if (damage > target.getHp()) { damage = target.getHp(); } a1 -= damage; if (damage2 > a1) { damage2 = a1; } /*if (damage >= target.getHp()) { * int randomHp = misc.random(target.getHp()); * damage = randomHp; * damage2 = target.getHp() - randomHp; * } else { * int hpRemaining = target.getHp() - damage; * if (damage2 > hpRemaining) { * damage2 = hpRemaining; * } * }*/ p.setLastAnimation(new Animation(1074)); p.setLastGraphics(new Graphics(256, 0, 90)); RangeCombat.deductArrow(killer); RangeCombat.deductArrow(killer); int arrowType = RangeCombat.getArrowType(killer); hitDelay = 1000; int MSpecCounter = 0; Event displayMSpecProjectileEvent = new Event(0); displayMSpecProjectileEvent.setAction(() => { RangeCombat.displayMSpecProjectile(killer, target); MSpecCounter++; if (MSpecCounter == 1) { displayMSpecProjectileEvent.setTick(500); p.setLastGraphics(new Graphics(256, 0, 90)); Event doMSpecHitEvent = new Event(900); doMSpecHitEvent.setAction(() => { doMSpecHitEvent.stop(); target.hit(damage2); RangeCombat.createGroundArrow(killer, target, arrowType); }); Server.registerEvent(doMSpecHitEvent); } else { displayMSpecProjectileEvent.stop(); return; } MSpecCounter++; }); Server.registerEvent(displayMSpecProjectileEvent); break; case 805: // Rune thrownaxe rangeWeapon = true; break; case 6724: // Seercull rangeWeapon = true; break; case 11235: // Dark bow rangeWeapon = true; if (p.getEquipment().getAmountInSlot(ItemData.EQUIP.ARROWS) < 2) { p.getPackets().sendMessage("You need 2 arrows to use the Dark bow!"); return(false); } int minHit = 8; damage = CombatFormula.getRangeHit((Player)killer, target, usingBow, usingArrows); damage2 = CombatFormula.getRangeHit((Player)killer, target, usingBow, usingArrows); if (usingBow == 11235) // Dark bow { if (usingArrows == 11212) // Dragon arrows { minHit = usingRangePrayer ? 4 : 8; damage *= 1.50; //50% increase. damage2 *= 1.50; //50% increase. if (damage < minHit) { damage = minHit; } if (damage2 < minHit) { damage2 = minHit; } } else // Other arrow { minHit = usingRangePrayer ? 3 : 5; damage *= 1.30; //30% increase. damage2 *= 1.30; //30% increase. if (damage < minHit) { damage = minHit; } if (damage2 < minHit) { damage2 = minHit; } } } if (usingRangePrayer) { damage *= 0.60; //60% decrease. damage2 *= 0.60; //60% decrease. } double a2 = damage + damage2; if (damage > target.getHp()) { damage = target.getHp(); } a2 -= damage; if (damage2 > a2) { damage2 = a2; } /*if (damage >= target.getHp()) { * int randomHp = misc.random(target.getHp()); * damage = randomHp; * damage2 = target.getHp() - randomHp; * } else { * int hpRemaining = target.getHp() - damage; * if (damage2 > hpRemaining) { * damage2 = hpRemaining; * } * }*/ p.setLastGraphics(new Graphics(RangeCombat.getDrawbackGraphic(killer), 0, 90)); RangeCombat.deductArrow(killer); RangeCombat.deductArrow(killer); hitDelay = RangeCombat.getHitDelay(killer, target); int delayHit = hitDelay; hitDelay = 1200; int arrowType1 = RangeCombat.getArrowType(killer); int DBSpecCounter = 0; Event DBSpecProjectile = new Event(0); DBSpecProjectile.setAction(() => { RangeCombat.displayDBSpecProjectile(killer, target); DBSpecCounter++; if (DBSpecCounter == 1) { DBSpecProjectile.setTick(200); Event rangeHitEvent = new Event(delayHit + 600); rangeHitEvent.setAction(() => { target.hit(damage2); rangeHitEvent.stop(); RangeCombat.createGroundArrow(killer, target, arrowType1); }); Server.registerEvent(rangeHitEvent); } else { DBSpecProjectile.stop(); return; } DBSpecCounter++; }); Server.registerEvent(DBSpecProjectile); break; } specialAmount -= neededPower; p.setSpecialAmount(specialAmount); usingSpecial = false; refreshBar(); killer.resetCombatTurns(); bool hitDouble = doubleHit; if (target is Player) { if (!rangeWeapon) { if (((Player)target).getPrayers().getHeadIcon() == PrayerData.PrayerHeadIcon.MELEE) { damage = (damage * 0.60); //60% decrease. } } else { if (((Player)target).getPrayers().getHeadIcon() == PrayerData.PrayerHeadIcon.RANGE) { damage = (damage * 0.60); //60% decrease } } } damage = ((weapon == 4151) ? damage : misc.randomDouble(damage)); damage2 = misc.randomDouble(damage2); double d = ((damage == 0 && weapon != 11730) ? 0 : (damage + increasedMaxHit)); double d2 = damage2; double d3 = damage3; // only used for d claws double d4 = damage4; // only used for d claws if (canPoison(weapon)) { if (!target.isPoisoned() && misc.random(5) == 0 && (hitDouble ? (d2 > 0 || d > 0) : d > 0)) { Server.registerEvent(new PoisonEvent(target, POISON_AMOUNT)); } } int hhitDelay = hitDelay; double totalDamage = (damage + damage2 + damage3 + damage4); Combat.checkIfWillDie(target, totalDamage); Event hitEvent = new Event(hhitDelay); hitEvent.setAction(() => { hitEvent.stop(); if (!target.isDead()) { target.setLastAnimation(new Animation(target.getDefenceAnimation())); } target.hit(d); if (hitDouble) { target.hit(d2); } if (d3 != -1 || d4 != -1) { target.hit(d3); target.hit(d4); } Combat.checkRecoilRing(killer, target, totalDamage); Combat.checkSmite(killer, target, totalDamage); Combat.checkVengeance(killer, target, totalDamage); Combat.addXp(killer, target, totalDamage); }); Server.registerEvent(hitEvent); return(true); }
public void openExchange() { p.getPackets().sendConfig(1109, -1); p.getPackets().sendConfig(1110, 0); p.getPackets().sendConfig(1111, 0); p.getPackets().sendConfig(1112, -1); p.getPackets().sendConfig(1113, -1); p.getPackets().sendConfig(1114, 0); p.getPackets().sendConfig(1115, 0); p.getPackets().sendConfig(1116, 0); p.getPackets().displayInterface(105); //opens Grand Exchange. p.getPackets().setRightClickOptions(6, 6881491, 65535, 65535); p.getPackets().setRightClickOptions(6, 6881489, 65535, 65535); }
public void getNextPlayerMovement() { //Does a walking action such as new player movement direction (if any) or new coordinates when teleporting. player.getUpdateFlags().setDidMapRegionChange(false); player.getUpdateFlags().setTeleporting(false); player.getSprites().setSprites(-1, -1); if (player.getTeleportTo() != null) { player.getUpdateFlags().setDidMapRegionChange(true); Location lastRegion = player.getUpdateFlags().getLastRegion(); if (lastRegion != null) { int rX = player.getTeleportTo().getLocalX(lastRegion); int rY = player.getTeleportTo().getLocalY(lastRegion); if (rX >= 2 * 8 && rX < 11 * 8 && rY >= 2 * 8 && rY < 11 * 8) { player.getUpdateFlags().setDidMapRegionChange(false); } } if (player.getUpdateFlags().didMapRegionChange()) { player.getUpdateFlags().setLastRegion(player.getTeleportTo()); } player.setLocation(player.getTeleportTo()); player.setDistanceEvent(null); resetWalkingQueue(); player.getUpdateFlags().setTeleporting(true); player.resetTeleportTo(); } else { if (player.getUpdateFlags().getLastRegion() == null) { return; } Location oldLocation = (Location)player.getLocation().Clone(); int walkDir = getNextWalkingDirection(); int runDir = -1; if (running || runToggled) { if (player.getRunEnergy() > 0) { runDir = getNextWalkingDirection(); if (runDir != -1) { player.setRunEnergy(player.getRunEnergy() - 1); } } else { if (runToggled) { player.getPackets().sendConfig(173, 0); runToggled = running = false; } running = false; } } Location lastRegion = player.getUpdateFlags().getLastRegion(); int rX = oldLocation.getLocalX(lastRegion); int rY = oldLocation.getLocalY(lastRegion); if ((rX < 2 * 8 || rX >= 11 * 8 || rY < 2 * 8 || rY >= 11 * 8)) { player.getUpdateFlags().setDidMapRegionChange(true); if (walkDir != -1) { waypointReadOffset--; } if (runDir != -1) { waypointReadOffset--; } walkDir = -1; runDir = -1; player.setLocation(oldLocation); } player.getSprites().setSprites(walkDir, runDir); } }