예제 #1
0
        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 void resetWalkingQueue()
 {
     walkingQueue[0].x   = player.getLocation().getLocalX();
     walkingQueue[0].y   = player.getLocation().getLocalY();
     walkingQueue[0].dir = -1;
     waypointReadOffset  = waypointWriteOffset = 1;
 }
예제 #3
0
	    /*
	     * The config to remove roofs is 1270
	     * The door is 6713
	     * 
	     * Random door configs 
	     * CONFIG = 452    0
           CONFIG = 452    32
           CONFIG = 452    96
           CONFIG = 452    16480
           CONFIG = 452    278624
           CONFIG = 452    802912
           CONFIG = 452    2900064
           CONFIG = 452    2637920
           CONFIG = 452    2638944
           CONFIG = 452    2640992
           CONFIG = 452    2645088
           CONFIG = 452    2653280
           CONFIG = 452    2649184
	     */
	
	
	
	    public static bool enterCrypt(Player p) {
		    for (int i = 0; i < MOUND_COORDS.Length; i++) {
			    for (int j = 0; j < MOUND_COORDS[i].Length; j++) {
                    if (p.getLocation().inArea(MOUND_COORDS[i][0], MOUND_COORDS[i][1], MOUND_COORDS[i][2], MOUND_COORDS[i][3]) && p.getLocation().getZ() == 0)
                    {
                        p.teleport(new Location(STAIR_COORDS[i][0], STAIR_COORDS[i][1], 3));
					    if (p.getBarrowTunnel() == -1) {
						    p.setBarrowTunnel(misc.random(5));
					    }
					    return true;
				    }
			    }
		    }
		    return false;
	    }
 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 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);
	    }
예제 #6
0
        public void addItemOrGround(int item, int amount)
        {
            /*
             * We try to add the item to the inventory..
             */
            if (addItem(item, amount))
            {
                return;
            }

            /*
             * It didn't add the item above, yet we have room for it?..odd.
             */
            if (getTotalFreeSlots() > 0)
            {
                return;
            }

            /*
             * Add the item to the ground.
             */
            GroundItem g = new GroundItem(item, amount, p.getLocation(), p);

            Server.getGroundItems().newEntityDrop(g);
        }
        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);
		    }
        }
예제 #8
0
        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));
        }
예제 #9
0
	    public static void interactWithAliMorissaae(Player p, Npc n) {
		    p.setEntityFocus(n.getClientIndex());
            AreaEvent interactWithAliMorissaaeAreaEvent = new AreaEvent(p, n.getLocation().getX() - 1, n.getLocation().getY() - 1, n.getLocation().getX() + 1, n.getLocation().getY() + 1);
            interactWithAliMorissaaeAreaEvent.setAction(() => {
				n.setFaceLocation(p.getLocation());
				p.setFaceLocation(n.getLocation());
				p.setEntityFocus(65535);
				showAliDialogue(p, 205);
		    });
            Server.registerCoordinateEvent(interactWithAliMorissaaeAreaEvent);
	    }
 public DwarfCannon(Player player)
 {
     p = player;
     cannonLocation = p.getLocation();
     fakeCannonLocation = new Location(cannonLocation.getX()+1, cannonLocation.getY()+1, cannonLocation.getY());
     firing = false;
     cannonballs = 0;
     constructionStage = 0;
     direction = 0;
     setNpcsInArea();
     newCannon();
 }
예제 #11
0
 public DwarfCannon(Player player)
 {
     p = player;
     cannonLocation     = p.getLocation();
     fakeCannonLocation = new Location(cannonLocation.getX() + 1, cannonLocation.getY() + 1, cannonLocation.getY());
     firing             = false;
     cannonballs        = 0;
     constructionStage  = 0;
     direction          = 0;
     setNpcsInArea();
     newCannon();
 }
        	public void execute(Player player, string[] arguments) {
                if (arguments.Length == 0)
                {

                    /*
                     * Testing the newStillGraphics, 
                     * it seems to do exactly what packet sent in mask appendGraphicsUpdate does
                     * only extra feature about it is you control how far in tiles you want it to appear
                     */
                    for(byte i = 0; i < 255; i++)
                        player.getPackets().newStillGraphics(player.getLocation(), new Graphics(392, 0, 100), i);
                    return;

                }

	        }
	    public static void talkToBob(Player p, Npc npc, int item, int option) {
		    p.setEntityFocus(npc.getClientIndex());
            AreaEvent talkToBobAreaEvent = new AreaEvent(p, npc.getLocation().getX() - 1, npc.getLocation().getY() - 1, npc.getLocation().getX() + 1, npc.getLocation().getY() + 1);
            talkToBobAreaEvent.setAction(() => {
				npc.setFaceLocation(p.getLocation());
				p.setFaceLocation(npc.getLocation());
				p.setEntityFocus(65535);
				if (option == 0) { // use item on bob
					if (item > 0) {
						p.setTemporaryAttribute("bobsAxesBarrowItem", item);
						showBobDialogue(p, 101);
					}
				} else if (option == 1) { // talk
					showBobDialogue(p, 107);
				} else if (option == 2) { // trade
					p.setShopSession(new ShopSession(p, 4));
				}
		    });
            Server.registerCoordinateEvent(talkToBobAreaEvent);
	    }
	    public static bool interactWithBoatNPC(Player p, Npc n) {
		    int id = n.getId();
		    if (id != 4540 && id != 1304 && id != 2436 && id != 3781 && id != 1361 && id != 4962) {
			    return false;
		    }
		    p.setEntityFocus(n.getClientIndex());
            AreaEvent interactWithBoatNPCAreaEvent = new AreaEvent(p, n.getLocation().getX() - 1, n.getLocation().getY() - 1, n.getLocation().getX() + 1, n.getLocation().getY() + 1);
            interactWithBoatNPCAreaEvent.setAction(() => {
				n.setFaceLocation(p.getLocation());
				p.setFaceLocation(n.getLocation());
				p.setEntityFocus(65535);
				switch(n.getId()) {
					case 4540: // Home boat
						showBentleyDialogue(p, 240);
						break;
						
					case 1304: // Canifis sailor
						showCanifisSailorDialogue(p, 280);
						break;
						
					case 2436: // Waterbirth isle
						showJarvaldDialogue(p, 300);
						break;
						
					case 3781: // Pest control squire
						showSquireDialogue(p, 340);
						break;
						
					case 1361: // Warrior guild
						showArnorDialogue(p, 370);
						break;
					
					case 4962: // fremmenik shore
						showCaptainBarnabyDialogue(p, 410);
						break;
				}
		    });
            Server.registerCoordinateEvent(interactWithBoatNPCAreaEvent);
		    return true;
	    }
예제 #15
0
        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);
        }
예제 #16
0
	    public static void interactWithAubury(Player p, Npc n, int option) {
		    p.setEntityFocus(n.getClientIndex());
            AreaEvent interactWithAuburyAreaEvent = new AreaEvent(p, n.getLocation().getX() - 1, n.getLocation().getY() - 1, n.getLocation().getX() + 1, n.getLocation().getY() + 1);
            interactWithAuburyAreaEvent.setAction(() => {
				n.setFaceLocation(p.getLocation());
				p.setFaceLocation(n.getLocation());
				p.setEntityFocus(65535);
				switch(option) {
					case 1: // talk to
						
						break;
						
					case 2: // trade
						p.setShopSession(new ShopSession(p, 3));
						break;
						
					case 3: // teleport
						RuneCraft.teleportToEssMine(p, n);
						break;
				}
		    });
            Server.registerCoordinateEvent(interactWithAuburyAreaEvent);
	    }
예제 #17
0
	    public void useDoor(Player p, int doorId) {
		    bool running =  p.getWalkingQueue().isRunToggled();
		    if (doorId == 9369) { // main entrance
			    int y = p.getLocation().getY() >= 5177 ? 5177 : 5175;
                CoordinateEvent mainEntranceCoordinateEvent = new CoordinateEvent(p, new Location(2399, y, 0));
                mainEntranceCoordinateEvent.setAction(() => {
					p.getWalkingQueue().setRunToggled(false);
                    p.getWalkingQueue().resetWalkingQueue();
					p.getPackets().clearMapFlag();
					p.setTemporaryAttribute("unmovable", true);
					p.getWalkingQueue().forceWalk(0, y == 5177 ? -2 : +2);
                    Event useMainDoorEvent = new Event(1000);
                    useMainDoorEvent.setAction(() => {
                        useMainDoorEvent.stop();
						p.removeTemporaryAttribute("unmovable");
						p.getWalkingQueue().setRunToggled(running);
					});
                    Server.registerEvent(useMainDoorEvent);
			    });
                Server.registerCoordinateEvent(mainEntranceCoordinateEvent);
            }
            else if (doorId == 9368)
            { // game door
                int y = p.getLocation().getY() >= 5169 ? 5169 : 5167;
                CoordinateEvent gameDoorCoordinateEvent = new CoordinateEvent(p, new Location(2399, y, 0));
                gameDoorCoordinateEvent.setAction(() =>
                {
                    if (playersPlaying.Count == 1)
                    {
                        sendNPCMessage(p, "Here is some TokKul, as a reward.");
                        p.getInventory().addItemOrGround(6529, tokkulReward);
                    }
                    removePlayingPlayer(p);
                    p.getWalkingQueue().setRunToggled(false);
                    p.getWalkingQueue().resetWalkingQueue();
                    p.getPackets().clearMapFlag();
                    if (y == 5167)
                    {
                        p.getWalkingQueue().forceWalk(0, +2);
                    }
                    else
                    {
                        p.getPackets().sendMessage("You are unable to bypass the hot barrier.");
                        return;
                    }
                    p.setTemporaryAttribute("unmovable", true);
                    Event gameDoorEvent = new Event(1000);
                    gameDoorEvent.setAction(() =>
                    {
                        gameDoorEvent.stop();
                        p.removeTemporaryAttribute("unmovable");
                        p.getWalkingQueue().setRunToggled(running);
                        p.getPackets().sendMessage("You leave the fight pit.");
                        resetVariables(p);
                    });
                    Server.registerEvent(gameDoorEvent);
                });
                Server.registerCoordinateEvent(gameDoorCoordinateEvent);
            }
	    }
	    public void refreshGlobalItems(Player p) {
		    if (Location.inFightCave(p.getLocation())) {
			    return;
		    }
		    foreach(GroundItem i in items) {
			    if (i != null) {
				    if ((i.isGlobal() && ((i.getOwner() != null && i.getOwner().Equals(p))))  // is your item after shown to other players (only shows for you)
						    || (!i.isGlobal() && i.getOwner() != null && i.getOwner().Equals(p)) // is your item before shown to other players
						    || (i.getOwner() == null && i.isGlobal())) { // is nobodys item after shown to other players (applies to 'regular' drops)
					    if (p.getLocation().withinDistance(i.getLocation(), 60)) {
						    p.getPackets().clearGroundItem(i);
						    p.getPackets().createGroundItem(i);
					    }
				    }
			    }
		    }
	    }
예제 #19
0
        /**
         * Update the specified player's Npcs.
         * @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().updateNpcsInArea();
            //Attempt to skip a pointless update if possible.
            //Any current npcs on screen got a update for me, if no we just return this whole method.
            bool hasAppearanceUpdate = player.getLocalEnvironment().getSeenNpcs().Exists(new Predicate<Npc>(delegate(Npc n) { return n.getUpdateFlags().isUpdateRequired(); }));
            //No new pending npcs and no npcs pending to get removed from screen.
            bool hasAddRemoveUpdate = (player.getLocalEnvironment().getNewNpcs().Count > 0 || player.getLocalEnvironment().getRemovedNpcs().Count > 0);
            //no updates.. exit.
            if (!hasAppearanceUpdate && !hasAddRemoveUpdate) return;

		    PacketBuilder mainPacket = new PacketBuilder().setId(32).setSize(Packet.Size.VariableShort).initBitAccess();
		    PacketBuilder updateBlock = new PacketBuilder().setSize(Packet.Size.Bare);
		    mainPacket.addBits(8, player.getLocalEnvironment().getSeenNpcs().Count);

            //Send information of all the npcs in our own location.
            foreach (Npc n in player.getLocalEnvironment().getSeenNpcs())
            {
                if (player.getLocalEnvironment().getRemovedNpcs().Contains(n)) {
                    mainPacket.addBits(1, 1); //update required.
                    mainPacket.addBits(2, 3); //delete npc.
                    continue;
                } else {
                    if (n.getSprites().getPrimarySprite() == -1)
                    {
                        if (n.getUpdateFlags().isUpdateRequired())
                        {
                            mainPacket.addBits(1, 1);
                            mainPacket.addBits(2, 0);
                        }
                        else
                        {
                            mainPacket.addBits(1, 0);
                        }
                    }
                    else if (n.getSprites().getSecondarySprite() == -1)
                    {
                        mainPacket.addBits(1, 1);
                        mainPacket.addBits(2, 1);
                        mainPacket.addBits(3, XLATE_DIRECTION_TO_CLIENT[n.getSprites().getPrimarySprite()]);
                        mainPacket.addBits(1, n.getUpdateFlags().isUpdateRequired() ? 1 : 0);
                    }
                    else
                    {
                        mainPacket.addBits(1, 1);
                        mainPacket.addBits(2, 2);
                        mainPacket.addBits(3, n.getSprites().getPrimarySprite());
                        mainPacket.addBits(3, n.getSprites().getSecondarySprite());
                        mainPacket.addBits(1, n.getUpdateFlags().isUpdateRequired() ? 1 : 0);
                    }
                    if (n.getUpdateFlags().isUpdateRequired())
                        appendUpdateBlock(n, updateBlock);
                }
            }

            //Send information of all the new npcs in our own location.
            foreach (Npc n in player.getLocalEnvironment().getNewNpcs())
            {
                int yPos = n.getLocation().getY() - player.getLocation().getY();
                int xPos = n.getLocation().getX() - player.getLocation().getX();

                mainPacket.addBits(15, n.getIndex());
                mainPacket.addBits(1, 1);
                mainPacket.addBits(3, n.getFaceDirection());
                mainPacket.addBits(1, n.getUpdateFlags().isUpdateRequired() ? 1 : 0);
                mainPacket.addBits(5, yPos < 0 ? yPos + 32 : yPos);
                mainPacket.addBits(14, n.getId());
                mainPacket.addBits(5, xPos < 0 ? xPos + 32 : xPos);

                if (n.getUpdateFlags().isUpdateRequired())
                    appendUpdateBlock(n, updateBlock);
            }

		    if(updateBlock.getLength() >= 3) {
			    mainPacket.addBits(15, 32767);
		    }
		    mainPacket.finishBitAccess();
		    mainPacket.addBytes(updateBlock.toPacket().getData());
		    player.getConnection().SendPacket(mainPacket.toPacket());

            /**
             * Done with with all our updates.. time to refine our environment lists.
             * Remove npcs who either moved away from our location or hidden / dead etc..
             * Mix new npcs with old npcs into one npclist.
             * Clear new npc list, for more new npcs again
             */
            player.getLocalEnvironment().organizeNpcs();
	    }
 public void execute(Player player, string[] arguments)
 {
     player.teleport(new Location(player.getLocation().getX(), player.getLocation().getY() + 6400, 0));
 }
	    public void refreshGlobalObjects(Player p) {
		    foreach(WorldObject o in objects) {
			    if (o != null && (o.isFire() || o.getOwner() == null || o.getOwner() == p) || o.isSpawnedObject() || o.shouldDeleteObject()) {
				    if (o.getLocation().withinDistance(p.getLocation(), 60)) {
					    if (o.shouldDeleteObject()) {
						    p.getPackets().removeObject(o.getLocation(), o.getFace(), o.getType());
					    } else if (!o.isFire()) {
						    p.getPackets().createObject(o.isSecondForm() ? o.getSecondaryId() : o.getOriginalId(), o.getLocation(), o.getFace(), o.getType());
					    } else {
						    p.getPackets().createObject(o.getOriginalId(), o.getLocation(), o.getFace(), o.getType());
					    }
				    }
			    }
		    }
		    doors.refreshDoorsForPlayer(p);
		    if (RuneCraft.wearingTiara(p)) {
			    RuneCraft.toggleRuin(p, p.getEquipment().getItemInSlot(0), true);
		    }
	    }
 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;
 }
예제 #23
0
	    public static bool openCoffin(Player p, int objectId) {
		    if (objectId != 6823 && objectId != 6771 && objectId != 6821 && objectId != 6773 && objectId != 6822 && objectId != 6772) {
			    return false;
		    }
		    int cryptIndex = getCryptIndex(p);
		    if (cryptIndex == -1) {
			    return false;
		    }
		    if (p.getBarrowBrothersKilled(cryptIndex)) {
			    p.getPackets().sendMessage("You don't find anything.");
			    return true;
		    }
		    if (p.getBarrowTunnel() == cryptIndex){
			    p.getPackets().modifyText("You find a hidden tunnel, do you want to enter?", 210, 1);
			    p.getPackets().sendChatboxInterface(210);
			    p.setTemporaryAttribute("barrowTunnel", 1);
			    return true;
		    }
		    foreach(Npc n in Server.getNpcList()) {
			    if (n.getId() == BROTHER_ID[cryptIndex]) {
				    if (n.getOwner().Equals(p)) {
					    p.getPackets().sendMessage("You don't find anything.");
					    return true;
				    }
			    }
		    }
		    Npc npc = new Npc(BROTHER_ID[cryptIndex]);
		    npc.setLocation(p.getLocation());
		    npc.setEntityFocus(p.getClientIndex());
		    npc.setOwner(p);
		    npc.setTarget(p);
		    npc.setCombatTurns(npc.getAttackSpeed());
		    Server.getNpcList().Add(npc);
		    p.getPackets().setArrowOnEntity(1, npc.getClientIndex());
		    return true;
	    }
예제 #24
0
	    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;
            }
	    }
예제 #25
0
	    public static int getCryptIndex(Player p) {
		    if (p.getLocation().inArea(3567, 9701, 3580, 9711)) {
			    return VERAC; 
		    } else if (p.getLocation().inArea(3548, 9709, 3561, 9721)) {
			    return DHAROK;
		    } else if (p.getLocation().inArea(3549, 9691, 3562, 9706)) {
			    return AHRIM;
		    } else if (p.getLocation().inArea(3532, 9698, 3546, 9710)) {
			    return GUTHAN;
		    } else if (p.getLocation().inArea(3544, 9677, 3559, 9689)) {
			    return KARIL;
		    } else if (p.getLocation().inArea(3563, 9680, 3577, 9694)) {
			    return TORAG;
		    }
		    return -1;
	    }
	    public static bool dialogue(Player p, Npc npc, bool rightClickPay) {
		    if ((npc.getId() != 1055 && npc.getId() != 437) || (rightClickPay && npc.getId() != 437)) {
			    return false;
		    }
		    p.setEntityFocus(npc.getClientIndex());
            AreaEvent dialogueAreaEvent = new AreaEvent(p, npc.getLocation().getX()-1, npc.getLocation().getY()-1, npc.getLocation().getX()+1, npc.getLocation().getY()+1);
            dialogueAreaEvent.setAction(() => {
				npc.setFaceLocation(p.getLocation());
				int status = npc.getId() == 1055 ? 43 : 1;
				if (rightClickPay) {
					if (!p.getInventory().hasItemAmount(995, AGILITY_ARENA_PRICE)) {
						p.getPackets().sendMessage("You don't have enough money to pay the entrance fee.");
						return;
					}
					status = 29;
				}
				doDialogue(p, status);
		    });
            Server.registerCoordinateEvent(dialogueAreaEvent);
		    return true;
	    }
예제 #27
0
	    public static bool betweenDoors(Player p) {
		    for (int i = 0; i < DB.Length; i++) {
                if (p.getLocation().inArea(DB[i][0], DB[i][1], DB[i][2], DB[i][3]))
                {
				    return true;
			    }
		    }
		    return false;
	    }
예제 #28
0
	    private void doRedemption(Player p) {
		    p.setLastGraphics(new Graphics(437));
		    if (lastAttacker == null) {
			    return;
		    }
		    if (lastAttacker.isDead() || !lastAttacker.isVisible() || lastAttacker.isDestroyed()) {
			    return;
		    }
		    Location l = p.getLocation();
		    double maxHit = p.getSkills().getMaxLevel(Skills.SKILL.PRAYER) * 0.25;
		    if (lastAttacker.getLocation().inArea(l.getX() - 1, l.getY() - 1, l.getX() + 1, l.getY() + 1)) {
			    double damage = misc.randomDouble(maxHit);
			    if (damage > lastAttacker.getHp()) {
				    damage = lastAttacker.getHp();
			    }
			    lastAttacker.hit(damage);
		    }
		    p.getSkills().setCurLevel(Skills.SKILL.PRAYER, 0);
            p.getPackets().sendSkillLevel(Skills.SKILL.PRAYER);
	    }
	    public void refreshDoorsForPlayer(Player p) {
		    foreach(Door door in doors) {
			    if (door.getDoorLocation().withinDistance(p.getLocation(), 60)) {
                    int id = door.isDoorOpen() ? door.getOpenDoorId() : door.getClosedDoorId();
				    Location loc = door.isDoorOpen() ? door.getOpenDoorLocation() : door.getClosedDoorLocation();
				    int direction = door.isDoorOpen() ? door.getOpenDirection() : door.getClosedDirection();
				    Location loc1 = door.isDoorOpen() ? door.getClosedDoorLocation() : door.getOpenDoorLocation();
				    int direction1 = door.isDoorOpen() ? door.getClosedDirection() : door.getOpenDirection();
                    p.getPackets().removeObject(loc1, direction1, 0);
                    p.getPackets().createObject(id, loc, direction, 0);
			    }
		    }
	    }
예제 #30
0
	    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 void execute(Player player, string[] arguments)
 {
     Location loc = player.getLocation();
     player.getPackets().sendMessage("Coordinates are X = [" + loc.getX() + "] Y = [" + loc.getY() + "] Z = [" + loc.getZ() + "]");
 }
예제 #32
0
	    public static void prayerDrainEvent(Player p) {
            Event prayerDrainEvent = new Event(5000 + misc.random(5000));
            prayerDrainEvent.setAction(() => {
				if (p.getTemporaryAttribute("atBarrows") == null) {
					prayerDrainEvent.stop();
					return;
				}
				int currentPrayer = p.getSkills().getCurLevel(Skills.SKILL.PRAYER);
				int maxLevel = p.getSkills().getMaxLevel(Skills.SKILL.PRAYER);
				int levelBy10 = currentPrayer - (maxLevel / 6);
				if (currentPrayer > 0) {
					p.getSkills().setCurLevel(Skills.SKILL.PRAYER, levelBy10);
					p.getPackets().sendSkillLevel(Skills.SKILL.PRAYER);
				}
				int[] array = p.getLocation().getZ() == 0 ? HEADS[1] : HEADS[0];
				int head = array[misc.random(array.Length - 1)];
				int slot = misc.random(5);
				if (slot == 0) {
					slot=1;
				}
				p.getPackets().itemOnInterface(24, slot, 100,head);
				p.getPackets().animateInterface(2085, 24, slot);
				prayerDrainEvent.setTick(5000 + misc.random(15000));
				
                Event animateEvent = new Event(4000);
                animateEvent.setAction(() => {
                    p.getPackets().itemOnInterface(24, slot, 100, -1);
                    p.getPackets().animateInterface(-1, 24, slot);
					animateEvent.stop();
				});
                Server.registerEvent(animateEvent);
		    });
            Server.registerEvent(prayerDrainEvent);
	    }
	    private static bool canTeleport(Player p, JewellerySlot js) {
		    if (p.getTemporaryAttribute("teleporting") != null) {
			    return false;
		    }
		    if (p.getDuel() != null) {
			    if (p.getDuel().getStatus() < 4) {
				    p.getDuel().declineDuel();
			    } else if (p.getDuel().getStatus() == 5 || p.getDuel().getStatus() == 6) {
				    p.getPackets().sendMessage("You cannot teleport whilst in a duel.");
				    return false;
			    } else if (p.getDuel().getStatus() == 8) {
				    p.getDuel().recieveWinnings(p);
			    }
		    }
		    int wildLvl = js.index == 1 || js.index == 2 ? 30 : 20;
            if (Location.inWilderness(p.getLocation()) && p.getLocation().wildernessLevel() >= wildLvl)
            {
                p.getPackets().sendMessage("You cannot teleport above level " + wildLvl + " wilderness!");
			    return false;
		    }
		    if (Location.inFightCave(p.getLocation())) {
			    FightCave.antiTeleportMessage(p);
			    return false;
		    }
		    if (p.getTemporaryAttribute("teleblocked") != null) {
			    p.getPackets().sendMessage("A magical force prevents you from teleporting!");
			    return false;
		    }
		    if (Location.inFightPits(p.getLocation())) {
                p.getPackets().sendMessage("You are unable to teleport from the fight pits.");
			    return false;
		    }
		    if (p.getTemporaryAttribute("unmovable") != null) {
			    return false;
		    }
		    return true;
	    }