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 == 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("[Test Damage command]: ::testdmg dmg ::testdmg 2000"); return; } int dmg = 0; Hits.Hit hit; if (!int.TryParse(arguments[0], out dmg)) { dmg = 0; hit = new Hits.Hit(dmg, Hits.HitType.NO_DAMAGE); } else { hit = new Hits.Hit(dmg, Hits.HitType.NORMAL_DAMAGE); } player.getHits().setHit1(hit); player.getUpdateFlags().setHitUpdateRequired(true); }
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); }
private void resetVariables(Player p) { p.setSkullCycles(0); p.getSpecialAttack().resetSpecial(); p.setLastkiller(null); p.setDead(false); p.setEntityFocus(65535); p.setPoisonAmount(0); p.clearKillersHits(); p.setLastVengeanceTime(0); p.setVengeance(false); p.removeTemporaryAttribute("willDie"); p.setFrozen(false); p.removeTemporaryAttribute("unmovable"); p.setAntifireCycles(0); p.setSuperAntipoisonCycles(0); p.setTeleblockTime(0); p.removeTemporaryAttribute("teleblocked"); p.setTarget(null); p.setAttacker(null); foreach (Skills.SKILL skill in Enum.GetValues(typeof(Skills.SKILL))) p.getSkills().setCurLevel(skill, p.getSkills().getMaxLevel(skill)); p.getPackets().sendSkillLevels(); Prayer.deactivateAllPrayers(p); if (p.getTemporaryAttribute("cantDoAnything") != null) { p.getAppearance().setInvisible(false); p.getUpdateFlags().setAppearanceUpdateRequired(true); p.removeTemporaryAttribute("cantDoAnything"); p.removeTemporaryAttribute("unmovable"); teleportToWaitingRoom(p, false); p.getPackets().closeInterfaces(); p.getPackets().setMinimapStatus(0); p.getPackets().clearMapFlag(); } }
public void useOrb(Player p, int button) { if (p.getTemporaryAttribute("teleporting") != null) { return; } if (button == -1) { AreaEvent useOrbAreaEvent = new AreaEvent(p, 2398, 5171, 2400, 5173); useOrbAreaEvent.setAction(() => { p.getPackets().displayInventoryInterface(374); p.getAppearance().setInvisible(true); p.getUpdateFlags().setAppearanceUpdateRequired(true); p.setTemporaryAttribute("cantDoAnything", true); p.setTemporaryAttribute("unmovable", true); p.getPackets().setMinimapStatus(2); Event useOrbEvent = new Event(500); useOrbEvent.setAction(() => { useOrbEvent.stop(); int random = misc.random(4); p.teleport(new Location(ORB_COORDINATES[1][random], ORB_COORDINATES[2][random], 0)); }); Server.registerEvent(useOrbEvent); }); Server.registerCoordinateEvent(useOrbAreaEvent); } else { if (p.getTemporaryAttribute("cantDoAnything") != null) { if (button == 5) { Event useOrbTwoEvent = new Event(500); useOrbTwoEvent.setAction(() => { useOrbTwoEvent.stop(); p.getAppearance().setInvisible(false); p.getUpdateFlags().setAppearanceUpdateRequired(true); p.removeTemporaryAttribute("cantDoAnything"); p.removeTemporaryAttribute("unmovable"); teleportToWaitingRoom(p, false); p.getPackets().closeInterfaces(); p.getPackets().setMinimapStatus(0); p.getPackets().clearMapFlag(); }); Server.registerEvent(useOrbTwoEvent); return; } for (int i = 0; i < ORB_COORDINATES[0].Length; i++) { if (button == ORB_COORDINATES[0][i]) { int j = i; p.setTemporaryAttribute("teleporting", true); Event teleportToOrbEvent = new Event(500); teleportToOrbEvent.setAction(() => { teleportToOrbEvent.stop(); p.teleport(new Location(ORB_COORDINATES[1][j], ORB_COORDINATES[2][j], 0)); Teleport.resetTeleport(p); }); Server.registerEvent(teleportToOrbEvent); return; } } } } }
public bool tileAvailable(Player p) { Location l = p.getLocation(); int regionX = p.getUpdateFlags().getLastRegion().getRegionX(); int regionY = p.getUpdateFlags().getLastRegion().getRegionY(); int x = l.getX() - ((regionX - 6) * 8); int y = l.getY() - ((regionY - 6) * 8); return (regionData[l.getZ(), x, y]) == 0; }
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); } }
public void setHeadIcon(PrayerHeadIcon headIcon) { this.headIcon = headIcon; p.getUpdateFlags().setAppearanceUpdateRequired(true); }
private static void appendForceMovement(Player p, PacketBuilder updateBlock) { Location myLocation = p.getUpdateFlags().getLastRegion(); ForceMovement fm = p.getForceMovement(); updateBlock.addByteC(fm.getX1()); updateBlock.addByte((byte)(fm.getY1())); updateBlock.addByteA(fm.getX2()); updateBlock.addByte((byte)fm.getY2()); updateBlock.addLEShort(fm.getSpeed1()); updateBlock.addLEShort(fm.getSpeed2()); updateBlock.addByteC(fm.getDirection()); }
/** * Update the specified player. * @param p */ public static void update(Player player) { //Creates a list of new players in area. [This only happens once.. no rebuilding like all runescape 2 servers.] player.getLocalEnvironment().updatePlayersInArea(); //Attempt to skip a pointless update if possible. //Any current users on screen got a update for me. bool hasAppearanceUpdate = player.getLocalEnvironment().getSeenPlayers().Exists(new Predicate<Player>(delegate(Player p) { return p.getUpdateFlags().hasAnyUpdate(); })); //No new pending players and no players pending to get removed from screen. bool hasAddRemoveUpdate = (player.getLocalEnvironment().getNewPlayers().Count > 0 || player.getLocalEnvironment().getRemovedPlayers().Count > 0); //no updates.. exit. if (!hasAppearanceUpdate && !hasAddRemoveUpdate && !player.getUpdateFlags().hasAnyUpdate() && !player.getUpdateFlags().didMapRegionChange() && player.getConnection().getPingCount() < 7) return; player.getConnection().resetPingCount(); if(player.getUpdateFlags().didMapRegionChange()) player.getPackets().sendMapRegion(); PacketBuilder mainPacket = new PacketBuilder().setId(225).setSize(Packet.Size.VariableShort).initBitAccess(); PacketBuilder updateBlock = new PacketBuilder().setSize(Packet.Size.Bare); if (player.getUpdateFlags().isTeleporting()) { //teleport mainPacket.addBits(1, 1); mainPacket.addBits(2, 3); mainPacket.addBits(7, player.getLocation().getLocalY(player.getUpdateFlags().getLastRegion())); //currentX mainPacket.addBits(1, 1); mainPacket.addBits(2, player.getLocation().getZ()); //heightLevel mainPacket.addBits(1, player.getUpdateFlags().isUpdateRequired() ? 1 : 0); mainPacket.addBits(7, player.getLocation().getLocalX(player.getUpdateFlags().getLastRegion())); //currentY } else { if (player.getSprites().getPrimarySprite() == -1) { //no movement mainPacket.addBits(1, player.getUpdateFlags().isUpdateRequired() ? 1 : 0); if (player.getUpdateFlags().isUpdateRequired()) mainPacket.addBits(2, 0); } else { //movement. mainPacket.addBits(1, 1); if (player.getSprites().getSecondarySprite() == -1) { //not running mainPacket.addBits(2, 1); mainPacket.addBits(3, player.getSprites().getPrimarySprite()); //walk mainPacket.addBits(1, player.getUpdateFlags().isUpdateRequired() ? 1 : 0); } else { mainPacket.addBits(2, 2); mainPacket.addBits(1, 1); mainPacket.addBits(3, player.getSprites().getPrimarySprite()); //walk mainPacket.addBits(3, player.getSprites().getSecondarySprite()); //run mainPacket.addBits(1, player.getUpdateFlags().isUpdateRequired() ? 1 : 0); } } } if(player.getUpdateFlags().isUpdateRequired()) appendUpdateBlock(player, updateBlock, false); //update my own updates. mainPacket.addBits(8, player.getLocalEnvironment().getSeenPlayers().Count); //All players I've seen already (not new players) //Send information of all the players in our own location. foreach (Player p in player.getLocalEnvironment().getSeenPlayers()) { if (player.getLocalEnvironment().getRemovedPlayers().Contains(p)) { mainPacket.addBits(1, 1); //update required. mainPacket.addBits(2, 3); //delete player. continue; } else if (p.getSprites().getPrimarySprite() == -1) { if(p.getUpdateFlags().isUpdateRequired()) { mainPacket.addBits(1, 1); //update required. mainPacket.addBits(2, 0); //finish } else { mainPacket.addBits(1, 0); //no update required, either region changed or no movement change. } } else if (p.getSprites().getPrimarySprite() != -1 && p.getSprites().getSecondarySprite() == -1) { mainPacket.addBits(1, 1); //update required. mainPacket.addBits(2, 1); //update just walk direction sprite mainPacket.addBits(3, p.getSprites().getPrimarySprite()); mainPacket.addBits(1, p.getUpdateFlags().isUpdateRequired() ? 1 : 0); } else if (p.getSprites().getPrimarySprite() != -1 && p.getSprites().getSecondarySprite() != -1) { //Bit 2 = 2, updates both sprites. mainPacket.addBits(1, 1); //update required. mainPacket.addBits(2, 2); //update both walk & run sprites. mainPacket.addBits(1, 1); mainPacket.addBits(3, p.getSprites().getPrimarySprite()); mainPacket.addBits(3, p.getSprites().getSecondarySprite()); mainPacket.addBits(1, p.getUpdateFlags().isUpdateRequired() ? 1 : 0); } if (p.getUpdateFlags().isUpdateRequired()) appendUpdateBlock(p, updateBlock, false); } //Send information of all the new players in our own location. foreach (Player p in player.getLocalEnvironment().getNewPlayers()) { int yPos = p.getLocation().getY() - player.getLocation().getY(); int xPos = p.getLocation().getX() - player.getLocation().getX(); mainPacket.addBits(11, p.getIndex()); //playerId of new player. mainPacket.addBits(1, 1); mainPacket.addBits(5, xPos < 0 ? xPos + 32 : xPos); mainPacket.addBits(3, p.getWalkingQueue().getLastDirection()); mainPacket.addBits(1, 1); mainPacket.addBits(5, yPos < 0 ? yPos + 32 : yPos); appendUpdateBlock(p, updateBlock, true); //force appearance update. } if (updateBlock.getLength() > 0) mainPacket.addBits(11, 2047); //2047 max players in server,area. mainPacket.finishBitAccess(); if (updateBlock.getLength() > 0) mainPacket.addBytes(updateBlock.toPacket().getData()); if (player.getConnection() != null) player.getConnection().SendPacket(mainPacket.toPacket()); /** * Done with with all our updates.. fine to refine our environment lists. * Remove players who either moved away from our location or plain old disconnected. * Mix new players with old players into one playerlist. * Clear new players list, for more new players again */ player.getLocalEnvironment().organizePlayers(); }
private static void appendUpdateBlock(Player p, PacketBuilder updateBlock, bool forceAppearance) { int mask = 0x0; AppearanceUpdateFlags flags = p.getUpdateFlags(); if (flags.isHitUpdateRequired()) { mask |= 0x1; } if (flags.isEntityFocusUpdateRequired()) { mask |= 0x2; } if (flags.isAppearanceUpdateRequired() || forceAppearance) { mask |= 0x4; } if (flags.isAnimationUpdateRequired()) { mask |= 0x8; } if (flags.isForceTextUpdateRequired()) { mask |= 0x20; } if (flags.isFaceLocationUpdateRequired()) { mask |= 0x40; } if (flags.isChatTextUpdateRequired()) { mask |= 0x80; } if (flags.isGraphicsUpdateRequired()) { mask |= 0x100; } if (flags.isHit2UpdateRequired()) { mask |= 0x200; } if (flags.isForceMovementRequired()) { mask |= 0x400; //mask |= 0x800; } if (mask >= 0x100) //0x100=256 [full byte], so use two bytes. { mask |= 0x10; updateBlock.addLEShort(mask); //updateBlock.addByte((byte)(mask & 0xFF)); //updateBlock.addByte((byte)(mask >> 8)); } else { updateBlock.addByte((byte)(mask & 0xFF)); } if (flags.isChatTextUpdateRequired()) { appendChatTextUpdate(p, updateBlock); } if (flags.isHitUpdateRequired()) { appendHitUpdate(p, updateBlock); } if (flags.isAnimationUpdateRequired()) { appendAnimationUpdate(p, updateBlock); } if (flags.isAppearanceUpdateRequired() || forceAppearance) { appendAppearanceUpdate(p, updateBlock); } if (flags.isEntityFocusUpdateRequired()) { appendFaceEntityUpdate(p, updateBlock); } if (flags.isForceMovementRequired()) { appendForceMovement(p, updateBlock); } if (flags.isForceTextUpdateRequired()) { appendForceTextUpdate(p, updateBlock); } if (flags.isHit2UpdateRequired()) { appendHit2Update(p, updateBlock); } if (flags.isGraphicsUpdateRequired()) { appendGraphicsUpdate(p, updateBlock); } if (flags.isFaceLocationUpdateRequired()) { appendFaceLocationUpdate(p, updateBlock); } }
/** * Handles a player emote: does the appropriate animation. * @param player * @param buttonId * @return */ public static bool emote(Player player, int buttonId) { if (buttonId == 2) { player.setLastAnimation(new Animation(855, 0)); } else if (buttonId == 3) { player.setLastAnimation(new Animation(856, 0)); } else if (buttonId == 4) { player.setLastAnimation(new Animation(858, 0)); } else if (buttonId == 5) { player.setLastAnimation(new Animation(859, 0)); } else if (buttonId == 6) { player.setLastAnimation(new Animation(857, 0)); } else if (buttonId == 7) { player.setLastAnimation(new Animation(863, 0)); } else if (buttonId == 8) { player.setLastAnimation(new Animation(2113, 0)); } else if (buttonId == 9) { player.setLastAnimation(new Animation(862, 0)); } else if (buttonId == 10) { player.setLastAnimation(new Animation(864, 0)); } else if (buttonId == 11) { player.setLastAnimation(new Animation(861, 0)); } else if (buttonId == 12) { player.setLastAnimation(new Animation(2109, 0)); } else if (buttonId == 13) { player.setLastAnimation(new Animation(2111, 0)); } else if (buttonId == 14) { player.setLastAnimation(new Animation(866, 0)); } else if (buttonId == 15) { player.setLastAnimation(new Animation(2106, 0)); } else if (buttonId == 16) { player.setLastAnimation(new Animation(2107, 0)); } else if (buttonId == 17) { player.setLastAnimation(new Animation(2108, 0)); } else if (buttonId == 18) { player.setLastAnimation(new Animation(860, 0)); } else if (buttonId == 19) { player.setLastAnimation(new Animation(0x558, 0)); player.setLastGraphics(new Graphics(574, 0)); } else if (buttonId == 20) { player.setLastAnimation(new Animation(2105, 0)); } else if (buttonId == 21) { player.setLastAnimation(new Animation(2110, 0)); } else if (buttonId == 22) { player.setLastAnimation(new Animation(865, 0)); } else if (buttonId == 23) { player.setLastAnimation(new Animation(2112, 0)); } else if (buttonId == 24) { player.setLastAnimation(new Animation(0x84F, 0)); } else if (buttonId == 25) { player.setLastAnimation(new Animation(0x850, 0)); } else if (buttonId == 26) { player.setLastAnimation(new Animation(1131, 0)); } else if (buttonId == 27) { player.setLastAnimation(new Animation(1130, 0)); } else if (buttonId == 28) { player.setLastAnimation(new Animation(1129, 0)); } else if (buttonId == 29) { player.setLastAnimation(new Animation(1128, 0)); } else if (buttonId == 30) { player.setLastAnimation(new Animation(4275, 0)); } else if (buttonId == 31) { player.setLastAnimation(new Animation(1745, 0)); } else if (buttonId == 32) { player.setLastAnimation(new Animation(4280, 0)); } else if (buttonId == 33) { player.setLastAnimation(new Animation(4276, 0)); } else if (buttonId == 34) { player.setLastAnimation(new Animation(3544, 0)); } else if (buttonId == 35) { player.setLastAnimation(new Animation(3543, 0)); } else if (buttonId == 36) { player.setLastAnimation(new Animation(7272, 0)); player.setLastGraphics(new Graphics(1244, 0)); } else if (buttonId == 37) { player.setLastAnimation(new Animation(2836, 0)); } else if (buttonId == 38) { player.setLastAnimation(new Animation(6111, 0)); } else if (buttonId == 39) { Skillcape.emote(player); } else if (buttonId == 40) { player.setLastAnimation(new Animation(7531, 0)); } else if (buttonId == 41) { player.setLastAnimation(new Animation(2414, 0)); player.setLastGraphics(new Graphics(1537, 0)); } else if (buttonId == 42) { player.setLastAnimation(new Animation(8770, 0)); player.setLastGraphics(new Graphics(1553, 0)); } else if (buttonId == 43) // Explore { player.setLastAnimation(new Animation(9990, 0)); player.setLastGraphics(new Graphics(1734, 0)); } else if (buttonId == 44) { // Trick player.setLastAnimation(new Animation(10530, 0)); player.setLastGraphics(new Graphics(1864, 0)); } else if (buttonId == 45) { // Freeze player.setLastAnimation(new Animation(11044, 0)); player.setLastGraphics(new Graphics(1973, 0)); } else if (buttonId == 46) { //TODO: lol todo.. umm ya.. unmovable remover is here so.. //it can be used to cheat to remove unmovable spells haha. //to fix: make another unmovable check so there would be 2 ways to become unmovable. //trigger the turkey emote event which changes animation/graphic based on delay. if (player.getTemporaryAttribute("turkeyEmoteInProgress") == null) { player.setTemporaryAttribute("turkeyEmoteStage", 11); player.setTemporaryAttribute("turkeyEmoteInProgress", 1); } else { //Force cancellation of the turkeyEmote Event. player.setTemporaryAttribute("turkeyEmoteStage", -1); //Don't create a new event until the old one is stopped. return false; } Event turkeyEmoteEvent = new Event(500); //500 milliseconds per stage timer (adjust this for better results). turkeyEmoteEvent.setAction(() => { int turkeyEmoteStage = (int)(player.getTemporaryAttribute("turkeyEmoteStage") == null ? -1 : (int)player.getTemporaryAttribute("turkeyEmoteStage")); if (turkeyEmoteStage <= 0) { //kill off this event. turkeyEmoteEvent.stop(); player.removeTemporaryAttribute("unmovable"); player.setTemporaryAttribute("turkeyEmoteInProgress", null); return; } if (turkeyEmoteStage == 11) { player.setLastAnimation(new Animation(10994, 0)); } else if (turkeyEmoteStage == 10) { player.setLastGraphics(new Graphics(1714, 0)); } else if (turkeyEmoteStage == 9) { player.setLastAnimation(new Animation(10996, 0)); player.setTemporaryAttribute("unmovable", true); player.getAppearance().setNpcId(8499); player.getUpdateFlags().setAppearanceUpdateRequired(true); } else if (turkeyEmoteStage == 1) { player.setLastAnimation(new Animation(10995, 0)); player.setLastGraphics(new Graphics(1714, 0)); player.getAppearance().setNpcId(-1); player.getUpdateFlags().setAppearanceUpdateRequired(true); player.removeTemporaryAttribute("unmovable"); player.removeTemporaryAttribute("turkeyEmoteStage"); } if (turkeyEmoteStage > 0) { turkeyEmoteStage--; player.setTemporaryAttribute("turkeyEmoteStage", turkeyEmoteStage); } }); Server.registerEvent(turkeyEmoteEvent); } else { return false; } return true; }
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 static void crossDitch(Player p, int x, int y) { if (p.getTemporaryAttribute("unmovable") != null) { return; } AreaEvent crossDitchAreaEvent = new AreaEvent(p, x, y - 1, x, y + 2); crossDitchAreaEvent.setAction(() => { p.getPackets().closeInterfaces(); p.getWalkingQueue().resetWalkingQueue(); p.setTemporaryAttribute("unmovable", true); int newY = p.getLocation().getY() >= 3523 ? p.getLocation().getY()-3 : p.getLocation().getY()+3; int dir = newY == 3 ? 0 : 4; Location faceLocation = new Location(p.getLocation().getX(), dir == 3 ? 3523 : 3520, 0); p.setFaceLocation(faceLocation); Event crossDitchMoveEvent = new Event(500); crossDitchMoveEvent.setAction(() => { crossDitchMoveEvent.stop(); p.setLastAnimation(new Animation(6132)); int regionX = p.getUpdateFlags().getLastRegion().getRegionX(); int regionY = p.getUpdateFlags().getLastRegion().getRegionY(); int lX = (p.getLocation().getX() - ((regionX - 6) * 8)); int lY = (p.getLocation().getY() - ((regionY - 6) * 8)); ForceMovement movement = new ForceMovement(lX, lY, lX, newY, 33, 60, dir); p.setForceMovement(movement); p.setFaceLocation(new Location(x, y, 0)); Event crossDitchTeleportEvent = new Event(1250); crossDitchTeleportEvent.setAction(() => { crossDitchTeleportEvent.stop(); int playerY = p.getLocation().getY(); int nY = playerY >= 3523 ? 3520 : 3523; p.teleport(new Location(p.getLocation().getX(), nY, 0)); p.removeTemporaryAttribute("unmovable"); }); Server.registerEvent(crossDitchTeleportEvent); }); Server.registerEvent(crossDitchMoveEvent); }); Server.registerCoordinateEvent(crossDitchAreaEvent); }
public static void doObstacle(Player p, int index) { if (p.getTemporaryAttribute("unmovable") != null) { return; } switch (index) { case 0: // 3 planks, northern (east side) case 1: // 3 planks, middle (east side) case 2: // 3 planks, southern (east side) case 3: // 3 planks, northern (west side) case 4: // 3 planks, middle (west side) case 5: // 3 planks, southern (west side) int logXCoord = index <= 2 ? (int)AGILITY_ARENA_OBJECTS[index][1] + 1 : (int)AGILITY_ARENA_OBJECTS[index][1] - 1; int logDirectionX = index <= 2 ? -7 : +7; CoordinateEvent plankObstaclesCoordinateEvent = new CoordinateEvent(p, new Location(logXCoord, (int)AGILITY_ARENA_OBJECTS[index][2], 3)); plankObstaclesCoordinateEvent.setAction(() => { bool running = p.getWalkingQueue().isRunToggled(); p.getWalkingQueue().setRunToggled(false); p.getWalkingQueue().resetWalkingQueue(); p.getPackets().clearMapFlag(); p.setTemporaryAttribute("unmovable", true); p.getAppearance().setWalkAnimation(155); p.getUpdateFlags().setAppearanceUpdateRequired(true); p.getWalkingQueue().forceWalk(logDirectionX, 0); Event plankObstaclesEvent = new Event(4300); plankObstaclesEvent.setAction(() => { plankObstaclesEvent.stop(); p.removeTemporaryAttribute("unmovable"); p.getAppearance().setWalkAnimation(-1); p.getUpdateFlags().setAppearanceUpdateRequired(true); p.getSkills().addXp(Skills.SKILL.AGILITY, (double)AGILITY_ARENA_OBJECTS[index][3]); p.getWalkingQueue().setRunToggled(running); }); Server.registerEvent(plankObstaclesEvent); }); Server.registerCoordinateEvent(plankObstaclesCoordinateEvent); break; case 6: //Handholds obstacle east of planks. case 7: //Handholds obstacle west of planks. int handHoldsDirectionX = 1; int handHoldsDirectionY = 1; if (index == 6) { handHoldsDirectionX = -1; handHoldsDirectionY = +1; } else if (index == 7) { handHoldsDirectionX = +1; handHoldsDirectionY = -1; } CoordinateEvent handholdsObstacleCoordinateEvent = new CoordinateEvent(p, new Location((int)AGILITY_ARENA_OBJECTS[index][1], (int)AGILITY_ARENA_OBJECTS[index][2], 3)); handholdsObstacleCoordinateEvent.setAction(() => { bool running = p.getWalkingQueue().isRunToggled(); p.getWalkingQueue().setRunToggled(false); p.getWalkingQueue().resetWalkingQueue(); p.getPackets().clearMapFlag(); p.setTemporaryAttribute("unmovable", true); p.setLastAnimation(new Animation(1121)); p.setFaceLocation(new Location(p.getLocation().getX(), p.getLocation().getY() + handHoldsDirectionY, 3)); Event handholdsObstaclesEvent = new Event(700); int handholdsObstaclesCounter = 0; handholdsObstaclesEvent.setAction(() => { p.setLastAnimation(new Animation(1122)); int regionX = p.getUpdateFlags().getLastRegion().getRegionX(); int regionY = p.getUpdateFlags().getLastRegion().getRegionY(); int lX = (p.getLocation().getX() - ((regionX - 6) * 8)); int lY = (p.getLocation().getY() - ((regionY - 6) * 8)); p.setForceMovement(new ForceMovement(lX, lY, lX + handHoldsDirectionX, lY, 0, 5, 0)); if (handholdsObstaclesCounter++ >= 7) { p.setLastAnimation(new Animation(65535)); handholdsObstaclesEvent.stop(); p.removeTemporaryAttribute("unmovable"); p.getSkills().addXp(Skills.SKILL.AGILITY, (double)AGILITY_ARENA_OBJECTS[index][3]); p.getWalkingQueue().setRunToggled(running); return; } Event teleportEvent = new Event(500); teleportEvent.setAction(() => { teleportEvent.stop(); p.teleport(new Location(p.getLocation().getX() + handHoldsDirectionX, p.getLocation().getY(), 3)); }); Server.registerEvent(teleportEvent); }); Server.registerEvent(handholdsObstaclesEvent); }); Server.registerCoordinateEvent(handholdsObstacleCoordinateEvent); break; } }