Пример #1
0
	    public static bool interactTzhaarNPC(Player p, Npc n, int option) {
		    if (n.getId() != 2622 && n.getId() != 2620 && n.getId() != 2623 && n.getId() != 2619 && n.getId() != 2617 && n.getId() != 2618) {
			    return false;
		    }
		    p.setEntityFocus(n.getClientIndex());
		    int npcX = n.getLocation().getX();
		    int npcY = n.getLocation().getY();
            AreaEvent interactTzhaarNpcAreaEvent = new AreaEvent(p, npcX-1, npcY-1, npcX+1, npcY+1);
            interactTzhaarNpcAreaEvent.setAction(() => {
				p.setFaceLocation(n.getLocation());
				p.setEntityFocus(65535);
				switch(n.getId()) {
					case 2619: // Bankers
						if (option == 1) { // Talk
							
						} else if (option == 2) { // Bank
							p.getBank().openBank();
						} else if (option == 3) { // Collect
							
						}
						break;
				
						//TODO tzhaar stores
					case 2622: // Ore shop
						if (option == 1) { // Speak
							
						} else if (option == 2) { // Trade
							p.setShopSession(new ShopSession(p, 3));
						}
						break;
				}
		    });
            Server.registerCoordinateEvent(interactTzhaarNpcAreaEvent);
		    return true;
	    }
	    public static void 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 bool useDoor(Player p, int doorId, int doorX, int doorY, int doorHeight) {
		    Location doorLocation = new Location(doorX, doorY, doorHeight);
		    foreach(Door door in doors) {
			    int id = door.isDoorOpen() ? door.getOpenDoorId() : door.getClosedDoorId();
			    if (id == doorId) {
				    if (door.getDoorLocation().Equals(doorLocation)) {
					    if (door.isDoorOpen() && (Environment.TickCount - door.getLastChangeTime() <= PLAYER_CHANGE_DELAY)) {
						    // door was opened in the last PLAYER_CHANGE_DELAY ms..cant be instantly closed
						    return true;
					    } else if (!door.isClosable() && door.isDoorOpen()) {
						    // door cannot be closed by a player
						    return true;
					    }
					    Door d = door;
                        AreaEvent useDoorAreaEvent = new AreaEvent(p, doorLocation.getX() - 1, doorLocation.getY() - 1, doorLocation.getX() + 1, doorLocation.getY() + 1);
                        useDoorAreaEvent.setAction(() => {
							changeDoor(p, d);
					    });
                        Server.registerCoordinateEvent(useDoorAreaEvent);
					    return true;
				    }
			    }
		    }
		    return false;
	    }
Пример #4
0
 public static void displayEmptyRockMessage(Player player, Location rockLocation)
 {
     AreaEvent displayEmptyRockMessageAreaEvent = new AreaEvent(player, rockLocation.getX() - 1, rockLocation.getY() - 1, rockLocation.getX() + 1, rockLocation.getY() + 1);
     displayEmptyRockMessageAreaEvent.setAction(() => {
         player.getPackets().sendMessage("There is currently no ore available from this rock.");
     });
 }
Пример #5
0
	    public static void enterTzhaar(Player p) {
            AreaEvent enterTzhaarAreaEvent = new AreaEvent(p, 2866, 9570, 2866, 9572);
            enterTzhaarAreaEvent.setAction(() => {
		        p.teleport(new Location(2480, 5175, 0));
		    });
            Server.registerCoordinateEvent(enterTzhaarAreaEvent);
	    }
Пример #6
0
	    public static void exitTzhaar(Player p) {
            AreaEvent exitTzhaarAreaEvent = new AreaEvent(p, 2479, 5175, 2481, 5175);
            exitTzhaarAreaEvent.setAction(() => {
		        p.teleport(new Location(2866, 9571, 0));
		    });
            Server.registerCoordinateEvent(exitTzhaarAreaEvent);
	    }
Пример #7
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);
	    }
Пример #8
0
	    public static void exitCave(Player p, int objectX, int objectY) {
            AreaEvent exitCaveAreaEvent = new AreaEvent(p, objectX, objectY - 1, objectX + 2, objectY - 1);
            exitCaveAreaEvent.setAction(() => {
				p.setTemporaryAttribute("unmovable", true);
                Event teleFromCaveEvent = new Event(600);
                teleFromCaveEvent.setAction(() => {
					teleFromCaveEvent.stop();
					p.getFightCave().teleFromCave(true);
				});
                Server.registerEvent(teleFromCaveEvent);
		    });
            Server.registerCoordinateEvent(exitCaveAreaEvent);
	    }
	    public static bool useWildernessObelisk(Player p, int id, Location loc) {
		    for(int i = 0; i < OBELISK_ID.Length; i++) {
			    if (id == OBELISK_ID[i]) {
				    if (loc.inArea(OBELISK_LOCATIONS[i][0] - 2, OBELISK_LOCATIONS[i][1] - 2, OBELISK_LOCATIONS[i][0] + 2, OBELISK_LOCATIONS[i][1] + 2)) {
                        AreaEvent useWildernessObeliskAreaEvent = new AreaEvent(p, loc.getX() - 1, loc.getY() - 1, loc.getX() + 1, loc.getY() + 1);
                        useWildernessObeliskAreaEvent.setAction(() => {
							    activateObelisk(i);				
					    });
                        Server.registerCoordinateEvent(useWildernessObeliskAreaEvent);
				    }
				    return true;
			    }
		    }
		    return false;
	    }
Пример #10
0
        public static bool wantToFish(Player p, Npc npc, bool secondOption)
        {
            for (int i = 0; i < SPOT_IDS.Length; i++) {
                if (npc.getId() == SPOT_IDS[i]){
                    p.setFaceLocation(npc.getLocation());

                    AreaEvent startFishingAreaEvent = new AreaEvent(p, npc.getLocation().getX() - 1, npc.getLocation().getY() - 1, npc.getLocation().getX() + 1, npc.getLocation().getY() + 1);
                    startFishingAreaEvent.setAction(() => {
                        startFishing(p, i, npc, true, secondOption);
                    });
                    Server.registerCoordinateEvent(startFishingAreaEvent);
                    return true;
                }
            }
            return false;
        }
	    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 void chopTendrils(Player p, int x, int y)
 {
     int var = x == 3057 ? x+2 : x-1;
     AreaEvent chopTendrilsAreaEvent = new AreaEvent(p, var, y, var, y+2);
     chopTendrilsAreaEvent.setAction(() => {
         if (!Woodcutting.hasAxe(p)) {
             p.getPackets().sendMessage("You need an axe to get past this obstacle.");
             return;
         }
         p.getWalkingQueue().resetWalkingQueue();
         p.setFaceLocation(new Location(x + 1, y, 0));
         p.setLastAnimation(new Animation(Woodcutting.getAxeAnimation(p)));
         p.setTemporaryAttribute("unmovable", true);
         Event chopTendrilsEvent = new Event(1900);
         chopTendrilsEvent.setAction(() => {
             int status = 0;
             int[] TENDRILS = {7161, 7162, 7163};
             if (status < 3) {
                 p.getPackets().createObject(TENDRILS[status], new Location(x, y, 0), x == 3057 ? 3 : 1, 10);
             }
             status++;
             if (status == 1) {
                 p.setLastAnimation(new Animation(Woodcutting.getAxeAnimation(p)));
                 chopTendrilsEvent.setTick(1300);
             }
             if (status == 3) {
                 p.getPackets().sendMessage("You clear your way through the tendrils.");
                 p.setLastAnimation(new Animation(65535));
                 chopTendrilsEvent.setTick(800);
             }
             if (status == 4) {
                 chopTendrilsEvent.stop();
                 teleportPastObstacle(p);
                 p.removeTemporaryAttribute("unmovable");
             }
         });
         Server.registerEvent(chopTendrilsEvent);
         return;
     });
     Server.registerCoordinateEvent(chopTendrilsAreaEvent);
 }
	    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;
	    }
Пример #14
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);
	    }
 public static void burnBoil(Player p, int x, int y)
 {
     AreaEvent burnBoilAreaEvent = new AreaEvent(p, x-1, y-1, x +3, y+2);
     burnBoilAreaEvent.setAction(() => {
         if (!p.getInventory().hasItem(590)) {
             p.getPackets().sendMessage("You need a tinderbox to get past this obstacle.");
             return;
         }
         p.setFaceLocation(new Location(x + 1, y, 0));
         p.setLastAnimation(new Animation(733));
         p.setTemporaryAttribute("unmovable", true);
         Event burnBoilEvent = new Event(1900);
         burnBoilEvent.setAction(() => {
             int status = 0;
             int[] BOIL = {7165, 7166, 7167};
             if (status < 3) {
                 p.getPackets().createObject(BOIL[status], new Location(x, y, 0), x == 3060 ? 3 : 1, 10);
             }
             status++;
             if (status == 1) {
                 burnBoilEvent.setTick(1300);
             }
             if (status == 3) {
                 p.setLastAnimation(new Animation(65535));
                 burnBoilEvent.setTick(1000);
             }
             if (status == 4) {
                 burnBoilEvent.stop();
                 teleportPastObstacle(p);
                 p.removeTemporaryAttribute("unmovable");
             }
         });
         Server.registerEvent(burnBoilEvent);
         return;
     });
     Server.registerCoordinateEvent(burnBoilAreaEvent);
 }
Пример #16
0
	    public static void enterCave(Player p) {
            AreaEvent enterCaveAreaEvent = new AreaEvent(p, 2438, 5168, 2439, 5168);
            enterCaveAreaEvent.setAction(() => {
				/*
				 * Fight cave is 20k squares from the original place, then another (200 * playerIndex) squares west.
				 */
				Location instanceLocation = new Location((20000 + 2413) + (200 * p.getIndex()), 20000 + 5116, 0);
				p.teleport(instanceLocation);
				p.setFightCave(new FightCaveSession(p));
				
                Event caveNpcEvent = new Event(600);
                caveNpcEvent.setAction(() => {
						caveNpcEvent.stop();
						p.getPackets().sendNPCHead(2617, 242, 1);
						p.getPackets().modifyText("TzHaar-Mej-Jal", 242, 3);
						p.getPackets().modifyText("You're on your own now, JalYt.", 242, 4);
						p.getPackets().modifyText("Pepare to fight for your life!", 242, 5);
						p.getPackets().animateInterface(9827, 242, 1);
						p.getPackets().sendChatboxInterface2(242);
				});
                Server.registerEvent(caveNpcEvent);
		    });
            Server.registerCoordinateEvent(enterCaveAreaEvent);
	    }
	    public 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;
	    }
Пример #18
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);
	    }
Пример #19
0
        public static void slashWeb(Player p, ushort webId, Location webLocation)
        {
            AreaEvent slashWebAreaEvent = new AreaEvent(p, webLocation.getX() - 1, webLocation.getY() - 1, webLocation.getX() + 1, webLocation.getY() + 1);
            slashWebAreaEvent.setAction(() => {
				long lastSlash = 0;
				p.setFaceLocation(webLocation);
				if (p.getTemporaryAttribute("lastWebSlash") != null) {
					lastSlash = (int)p.getTemporaryAttribute("lastWebSlash");
				}
				if (Environment.TickCount - lastSlash <= 800) {
					return;
				}
				if (Server.getGlobalObjects().originalObjectExists(webId, webLocation)) {
					p.setLastAnimation(new Animation(p.getAttackAnimation()));
					p.setTemporaryAttribute("lastWebSlash", Environment.TickCount);
                    Event attemptCutWebEvent = new Event(500);
                    attemptCutWebEvent.setAction(() => {
                        attemptCutWebEvent.stop();
						bool webExists = Server.getGlobalObjects().originalObjectExists(webId, webLocation);
						Server.getGlobalObjects().lowerHealth(webId, webLocation);
						if (Server.getGlobalObjects().originalObjectExists(webId, webLocation)) {
							p.getPackets().sendMessage("You fail to cut through the web.");
						} else {
							if (webExists) { // This means we slashed it, if !webExists, someone else slashed it in the last 500ms
                                p.getPackets().sendMessage("You slash through the web!");
							}
						}
					});
                    Server.registerEvent(attemptCutWebEvent);
				}
		    });
            Server.registerCoordinateEvent(slashWebAreaEvent);

	    }
Пример #20
0
 public static bool interactWithPatch(Player p,  int objectId, int objectX, int objectY,  int seedId)
 {
     for (int i = 0; i < PATCHES.Length; i++) {
         if (objectId == (int)PATCHES[i][1]) {
             Location patchLocation = new Location(objectX, objectY, 0);
             int j = i;
             int[] data = Farming.getPatchDistances(i, objectX, objectY);
             AreaEvent interactWithPatchAreaEvent = new AreaEvent(p, data[0], data[1], data[2], data[3]);
             interactWithPatchAreaEvent.setAction(() => {
                     tendToPatch(p, patchLocation, seedId, j);
             });
             Server.registerCoordinateEvent(interactWithPatchAreaEvent);
             return true;
         }
     }
     return false;
 }
        public static void doCourse(Player p, int objectX, int objectY, object[] objectArray)
        {
            if (p.getTemporaryAttribute("unmovable") != null) {
                return;
            }
            int agilityStage = (int) (p.getTemporaryAttribute("agilityStage") == null ? 0 : p.getTemporaryAttribute("agilityStage"));
            switch((int)objectArray[0]) {
                case 2295: // Log
                    CoordinateEvent doLogCoordinateEvent = new CoordinateEvent(p, new Location((int)objectArray[3], (int)objectArray[4], 0));
                    doLogCoordinateEvent.setAction(() => {
                        shoutNPCs[0].setForceText(SHOUT_MESSAGES[0]);
                        p.getPackets().sendMessage("You walk carefully across the slippery log...");
                        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(0, -7);
                        Event doLogEvent = new Event(4300);
                            doLogEvent.setAction(() => {
                                doLogEvent.stop();
                                p.getPackets().sendMessage("...and make it safely to the other side.");
                                p.removeTemporaryAttribute("unmovable");
                                p.getAppearance().setWalkAnimation(-1);
                                p.getUpdateFlags().setAppearanceUpdateRequired(true);
                                p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
                                p.getWalkingQueue().setRunToggled(running);
                        });
                        Server.registerEvent(doLogEvent);
                    });
                    Server.registerCoordinateEvent(doLogCoordinateEvent);
                    break;

                case 2285: // Net #1
                    AreaEvent doNetOneAreaEvent = new AreaEvent(p, 2471, 3426, 2476, 3426);
                    doNetOneAreaEvent.setAction(() => {
                        shoutNPCs[1].setForceText(SHOUT_MESSAGES[1]);
                        p.getPackets().sendMessage("You climb the netting...");
                        p.setLastAnimation(new Animation(828));
                        p.getWalkingQueue().resetWalkingQueue();
                        p.getPackets().clearMapFlag();
                        p.setFaceLocation(new Location(p.getLocation().getX(), p.getLocation().getY()-1, 0));
                        p.setTemporaryAttribute("unmovable", true);
                        Event doNetOneEvent = new Event(1000);
                        doNetOneEvent.setAction(() => {
                            doNetOneEvent.stop();
                            p.removeTemporaryAttribute("unmovable");
                            p.teleport(new Location(2473, p.getLocation().getY()-2, 1));
                            p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
                        });
                        Server.registerEvent(doNetOneEvent);
                    });
                    Server.registerCoordinateEvent(doNetOneAreaEvent);
                    break;

                case 35970: // Tree climb
                    AreaEvent treeClimbAreaEvent = new AreaEvent(p, 2472, 3422, 2474, 3423);
                    treeClimbAreaEvent.setAction(() => {
                        shoutNPCs[2].setForceText(SHOUT_MESSAGES[2]);
                        p.getPackets().sendMessage("You climb the tree...");
                        p.setLastAnimation(new Animation(828));
                        p.getWalkingQueue().resetWalkingQueue();
                        p.getPackets().clearMapFlag();
                        p.setFaceLocation(new Location(2473, 3422, 1));
                        p.setTemporaryAttribute("unmovable", true);
                        Event treeClimbEvent = new Event(1000);
                        treeClimbEvent.setAction(() => {
                            treeClimbEvent.stop();
                            p.getPackets().sendMessage("...to the platform above.");
                            p.removeTemporaryAttribute("unmovable");
                            p.teleport(new Location(2473, 3420, 2));
                            p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
                        });
                        Server.registerEvent(treeClimbEvent);
                    });
                    Server.registerCoordinateEvent(treeClimbAreaEvent);
                    break;

                case 2312: // Rope balance
                    CoordinateEvent ropeBalanceCoordinateEvent = new CoordinateEvent(p, new Location((int)objectArray[3], (int)objectArray[4], 2));
                    ropeBalanceCoordinateEvent.setAction(() => {
                        shoutNPCs[3].setForceText(SHOUT_MESSAGES[3]);
                        p.getPackets().sendMessage("You carefully cross the tightrope.");
                        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(+6, 0);
                        Event ropeBalanceEvent = new Event(3700);
                        ropeBalanceEvent.setAction(() => {
                                ropeBalanceEvent.stop();
                                p.removeTemporaryAttribute("unmovable");
                                p.getAppearance().setWalkAnimation(-1);
                                p.getUpdateFlags().setAppearanceUpdateRequired(true);
                                p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
                                p.getWalkingQueue().setRunToggled(running);
                        });
                        Server.registerEvent(ropeBalanceEvent);

                    });
                    Server.registerCoordinateEvent(ropeBalanceCoordinateEvent);
                    break;

                case 2314: // Tree climb #2
                    AreaEvent treeclimbTwoAreaEvent = new AreaEvent(p, 2485, 3418, 2486, 3420);
                    treeclimbTwoAreaEvent.setAction(() => {
                        p.getPackets().sendMessage("You climb down the tree...");
                        p.setLastAnimation(new Animation(828));
                        p.getWalkingQueue().resetWalkingQueue();
                        p.getPackets().clearMapFlag();
                        p.setFaceLocation(new Location(2486, 3419, 2));
                        p.setTemporaryAttribute("unmovable", true);
                        Event treeClimbTwoEvent = new Event(1000);
                        treeClimbTwoEvent.setAction(() => {
                            treeClimbTwoEvent.stop();
                            p.getPackets().sendMessage("You land on the ground.");
                            p.removeTemporaryAttribute("unmovable");
                            p.teleport(new Location(2486, 3420, 0));
                            p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
                        });
                        Server.registerEvent(treeClimbTwoEvent);
                    });
                    Server.registerCoordinateEvent(treeclimbTwoAreaEvent);
                    break;

                case 2286: // Net #2
                    AreaEvent doNetTwoAreaEvent = new AreaEvent(p, 2483, 3425, 2488, 3425);
                    doNetTwoAreaEvent.setAction(() => {
                        shoutNPCs[4].setForceText(SHOUT_MESSAGES[4]);
                        p.getPackets().sendMessage("You climb the netting...");
                        p.setLastAnimation(new Animation(828));
                        p.getWalkingQueue().resetWalkingQueue();
                        p.getPackets().clearMapFlag();
                        p.setFaceLocation(new Location(p.getLocation().getX(), p.getLocation().getY()+1, 0));
                        p.setTemporaryAttribute("unmovable", true);
                        Event doNetTwoEvent = new Event(1000);
                        doNetTwoEvent.setAction(() => {
                            doNetTwoEvent.stop();
                            p.removeTemporaryAttribute("unmovable");
                            p.teleport(new Location(p.getLocation().getX(), p.getLocation().getY()+2, 0));
                            p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
                        });
                        Server.registerEvent(doNetTwoEvent);
                    });
                    Server.registerCoordinateEvent(doNetTwoAreaEvent);
                    break;

                case 4058: // Right obstacle pipe
                    AreaEvent passRightObstraclePipeAreaEvent = new AreaEvent(p, 2486, 3430, 2488, 3431);
                    passRightObstraclePipeAreaEvent.setAction(() => {
                        int newMove = 0;
                        int pX = p.getLocation().getX();
                        int pY = p.getLocation().getY();
                        if (pX == objectX + 1 && pY == objectY)
                            newMove = 1;
                        else if (pX == objectX - 1 && pY == objectY)
                            newMove = 2;
                        if (newMove > 0) {
                            int path = newMove;
                            int doCourseCounter = 0;
                            Event doCourseEvent = new Event(500);
                            doCourseEvent.setAction(() => {
                                if (doCourseCounter == 0)
                                {
                                    p.getWalkingQueue().forceWalk(0, -1);
                                }
                                else if (doCourseCounter == 1)
                                {
                                    p.getWalkingQueue().forceWalk(path == 1 ? -1 : +1, 0);
                                } else {
                                    doCourse(p, objectX, objectY, objectArray);
                                    doCourseEvent.stop();
                                }
                                doCourseCounter++;
                            });
                            Server.registerEvent(doCourseEvent);
                            return;
                        }
                        Event squeezeIntoRightPipeEvent = new Event(0);
                        squeezeIntoRightPipeEvent.setAction(() => {
                            squeezeIntoRightPipeEvent.stop();
                            p.getPackets().sendMessage("You squeeze into the pipe...");
                            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, lY + 4, 10, 60, 0));
                            p.setFaceLocation(new Location(p.getLocation().getX(), p.getLocation().getY() + 1, 0));
                            p.setLastAnimation(new Animation(10578));
                            bool running = p.getWalkingQueue().isRunToggled();
                            p.getWalkingQueue().setRunToggled(false);
                            p.getWalkingQueue().resetWalkingQueue();
                            p.getPackets().clearMapFlag();
                            p.setTemporaryAttribute("unmovable", true);
                            int squeezeOutOfRightPipeCounter = 0;
                            Event squeezeOutOfRightPipeEvent = new Event(1150);
                            squeezeOutOfRightPipeEvent.setAction(() => {
                                if (squeezeOutOfRightPipeCounter == 0)
                                {
                                    p.teleport(new Location(p.getLocation().getX(), p.getLocation().getY() + 3, 0));
                                    squeezeOutOfRightPipeEvent.setTick(450);
                                    squeezeOutOfRightPipeCounter++;
                                    return;
                                }
                                else if (squeezeOutOfRightPipeCounter == 1)
                                {
                                    p.setForceMovement(new ForceMovement(lX, lY + 3, lX, lY + 6, 10, 60, 0));
                                    squeezeOutOfRightPipeEvent.setTick(900);
                                    squeezeOutOfRightPipeCounter++;
                                }
                                else if (squeezeOutOfRightPipeCounter == 2)
                                {
                                    squeezeOutOfRightPipeEvent.setTick(500);
                                    p.setLastAnimation(new Animation(10579));
                                    p.setForceMovement(new ForceMovement(lX, lY + 6, lX, lY + 7, 10, 40, 0));
                                    squeezeOutOfRightPipeCounter++;
                                } else {
                                    p.getPackets().sendMessage("...You squeeze out of the pipe.");
                                    squeezeOutOfRightPipeEvent.stop();
                                    p.removeTemporaryAttribute("unmovable");
                                    p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
                                    p.getWalkingQueue().setRunToggled(running);
                                    p.teleport(new Location(p.getLocation().getX(), p.getLocation().getY() + 5, 0));
                                }
                            });
                            Server.registerEvent(squeezeOutOfRightPipeEvent);
                        });
                        Server.registerEvent(squeezeIntoRightPipeEvent);
                    });
                    Server.registerCoordinateEvent(passRightObstraclePipeAreaEvent);
                    break;

                case 154: // Left obstacle pipe
                    AreaEvent passLeftObstraclePipeAreaEvent = new AreaEvent(p, 2483, 3430, 2485, 3431);
                    passLeftObstraclePipeAreaEvent.setAction(() => {
                        int newMove = 0;
                        int pX = p.getLocation().getX();
                        int pY = p.getLocation().getY();
                        if (pX == objectX + 1 && pY == objectY)
                            newMove = 1;
                        else if (pX == objectX - 1 && pY == objectY)
                            newMove = 2;
                        else if (pX == 2483)
                            newMove = 3;
                        else if (pX == 2485)
                            newMove = 4;
                        if (newMove > 0) {
                            int path = newMove;
                            int doCourseCounter = 0;
                            Event doCourseEvent = new Event(500);
                            doCourseEvent.setAction(() => {
                                if (path == 3 || path == 4) {
                                    p.getWalkingQueue().forceWalk(path == 3 ? +1 : -1, 0);
                                    doCourseCounter = 2;
                                }
                                if (doCourseCounter == 0)
                                {
                                    p.getWalkingQueue().forceWalk(0, -1);
                                }
                                else if (doCourseCounter == 1)
                                {
                                    p.getWalkingQueue().forceWalk(path == 1 ? -1 : +1, 0);
                                } else {
                                    doCourse(p, objectX, objectY, objectArray);
                                    doCourseEvent.stop();
                                }
                                doCourseCounter++;
                            });
                            Server.registerEvent(doCourseEvent);
                            return;
                        }
                        Event squeezeIntoLeftPipeEvent = new Event(0);
                        squeezeIntoLeftPipeEvent.setAction(() => {
                            squeezeIntoLeftPipeEvent.stop();
                            p.getPackets().sendMessage("You squeeze into the pipe...");
                            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, lY + 3, 10, 60, 0));
                            p.setFaceLocation(new Location(p.getLocation().getX(), p.getLocation().getY() + 1, 0));
                            p.setLastAnimation(new Animation(10578));
                            bool running = p.getWalkingQueue().isRunToggled();
                            p.getWalkingQueue().setRunToggled(false);
                            p.getWalkingQueue().resetWalkingQueue();
                            p.getPackets().clearMapFlag();
                            p.setTemporaryAttribute("unmovable", true);
                            int squeezeOutOfLeftPipeCounter = 0;
                            Event squeezeOutOfLeftPipeEvent = new Event(1150);
                            squeezeOutOfLeftPipeEvent.setAction(() => {
                                if (squeezeOutOfLeftPipeCounter == 0)
                                {
                                    p.teleport(new Location(p.getLocation().getX(), p.getLocation().getY() + 3, 0));
                                    squeezeOutOfLeftPipeEvent.setTick(450);
                                    squeezeOutOfLeftPipeCounter++;
                                    return;
                                }
                                else if (squeezeOutOfLeftPipeCounter == 1)
                                {
                                    p.setForceMovement(new ForceMovement(lX, lY + 3, lX, lY + 6, 10, 60, 0));
                                    squeezeOutOfLeftPipeEvent.setTick(900);
                                    squeezeOutOfLeftPipeCounter++;
                                }
                                else if (squeezeOutOfLeftPipeCounter == 2)
                                {
                                    squeezeOutOfLeftPipeEvent.setTick(500);
                                    p.setLastAnimation(new Animation(10579));
                                    p.setForceMovement(new ForceMovement(lX, lY + 6, lX, lY + 7, 10, 40, 0));
                                    squeezeOutOfLeftPipeCounter++;
                                } else {
                                    p.getPackets().sendMessage("...You squeeze out of the pipe.");
                                    squeezeOutOfLeftPipeEvent.stop();
                                    p.removeTemporaryAttribute("unmovable");
                                    p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
                                    p.getWalkingQueue().setRunToggled(running);
                                    p.teleport(new Location(p.getLocation().getX(), p.getLocation().getY() + 5, 0));
                                }
                            });
                            Server.registerEvent(squeezeOutOfLeftPipeEvent);
                        });
                        Server.registerEvent(squeezeIntoLeftPipeEvent);
                    });
                    Server.registerCoordinateEvent(passLeftObstraclePipeAreaEvent);
                    break;
            }
        }
Пример #22
0
	    public static bool openTunnelDoor(Player player, int doorId, int x, int y) {
		    if (doorId < 6716 || (doorId > 6731 && doorId < 6735) || doorId > 6750) {
			    return false;
		    }
		    int index = getDoorIndex(doorId, x, y);
		    int index2 = getOtherDoor(x, y); // index of the door next to the one you clicked.
		    if (index == -1 || index2 == -1) {
			    return false;
		    }
            bool betweenDoors = player.getTemporaryAttribute("betweenDoors") != null;
            Location clickedDoor = new Location(DOOR_LOCATION[index][0], DOOR_LOCATION[index][1], 0);
            Location otherDoor = new Location(DOOR_LOCATION[index2][0], DOOR_LOCATION[index2][1], 0);
            int openDoorId = DOOR_OPEN_DIRECTION[index][0];
            int openDoorId2 = DOOR_OPEN_DIRECTION[index2][0];
            int openDirection = DOOR_OPEN_DIRECTION[index][2];
		    int newX = openDirection == 1 ? x+1 : openDirection == 2 ? x : openDirection == 3 ? x-1 : openDirection == 4 ? x : x;
		    int newY = openDirection == 1 ? y : openDirection == 2 ? y+1 : openDirection == 3 ? y : openDirection == 4 ? y-1 : y;
            int newX2 = openDirection == 1 ? DOOR_LOCATION[index2][0] + 1 : openDirection == 2 ? DOOR_LOCATION[index2][0] : openDirection == 3 ? DOOR_LOCATION[index2][0] - 1 : openDirection == 4 ? DOOR_LOCATION[index2][0] : DOOR_LOCATION[index2][0];
            int newY2 = openDirection == 1 ? DOOR_LOCATION[index2][1] : openDirection == 2 ? DOOR_LOCATION[index2][1] + 1 : openDirection == 3 ? DOOR_LOCATION[index2][1] : openDirection == 4 ? DOOR_LOCATION[index2][1] - 1 : DOOR_LOCATION[index2][1];
            int[] doorStandCoordinates = getDoorCoordinates(player, index, index2, betweenDoors);
            int[] walkDirections = getWalkDirections(player, index, index2, betweenDoors);
            player.setFaceLocation(clickedDoor);
            AreaEvent doorsWalkAreaEvent = new AreaEvent(player, doorStandCoordinates[0], doorStandCoordinates[1], doorStandCoordinates[2] + 1, doorStandCoordinates[3] + 1);
            doorsWalkAreaEvent.setAction(() => {
                player.setTemporaryAttribute("unmovable", true);

                Event forceWalkDoorEvent = new Event(800);
                forceWalkDoorEvent.setAction(() => {
                    player.getWalkingQueue().resetWalkingQueue();
					foreach(Player p in Server.getPlayerList()) { //change door for all logged in players? uhh what?
						p.getPackets().removeObject(clickedDoor, openDoorId == 6713 ? 4 : 3, 0);
						p.getPackets().removeObject(otherDoor, openDoorId2 == 6732 ? 3 : 4, 0);
                        p.getPackets().createObject(openDoorId, new Location(newX, newY, 0), DOOR_OPEN_DIRECTION[index][1], 0);
                        p.getPackets().createObject(openDoorId2, new Location(newX2, newY2, 0), DOOR_OPEN_DIRECTION[index2][1], 0);
					}
                    player.getWalkingQueue().forceWalk(walkDirections[0], walkDirections[1]);
					forceWalkDoorEvent.stop();
				});
                Server.registerEvent(forceWalkDoorEvent);
                Event betweenDoorsEvent = new Event(betweenDoors ? 2200 : 1900);
                betweenDoorsEvent.setAction(() => {
					int face = openDirection == 3 ? 0 : openDirection == 4 ? 3 : openDirection == 2 ? 1 : 2;
					foreach(Player p in Server.getPlayerList()) {
						p.getPackets().removeObject(new Location(newX, newY, 0), openDoorId == 6713 ? 4 : 3, 0);
						p.getPackets().removeObject(new Location(newX2, newY2, 0), openDoorId2 == 6732 ? 3 : 4, 0);
						p.getPackets().createObject(DOORS[index], clickedDoor, face, 0);
						p.getPackets().createObject(DOORS[index2], otherDoor, face, 0);
					}
                    player.removeTemporaryAttribute("unmovable");
					if (!betweenDoors) {
                        player.getPackets().sendConfig(1270, 1);
                        player.setTemporaryAttribute("betweenDoors", true);
					} else {
                        player.getPackets().sendConfig(1270, 0);
                        player.removeTemporaryAttribute("betweenDoors");
					}
					betweenDoorsEvent.stop();
				});
                Server.registerEvent(betweenDoorsEvent);
		    });
            Server.registerCoordinateEvent(doorsWalkAreaEvent);
		    return true;
	    }
Пример #23
0
	    public static void openChest(Player player) {
		    Player p = player;
		    if (p.getLocation().getZ() != 0 || p.getTemporaryAttribute("lootedBarrowChest") != null) {
			    return;
		    }
		    if (!p.getLocation().inArea(3551, 9694, 3552, 9694)) {
                AreaEvent openChestAreaEvent = new AreaEvent(p, 3551, 9694, 3552, 9694);
                openChestAreaEvent.setAction(() => {
				    openChest(p);
			    });
                Server.registerCoordinateEvent(openChestAreaEvent);
			    return;
		    }
		    for (int i = 0; i < 6; i++) {
			    if (!p.getBarrowBrothersKilled(i)) {
				    foreach(Npc n in Server.getNpcList()) {
					    if (n != null) {
						    if (n.getId() == BROTHER_ID[i]) {
							    if (n.getOwner().Equals(p)) {
								    return;
							    }
						    }
					    }
				    }
				    Npc npc = new Npc(BROTHER_ID[i]);
				    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;
			    }
		    }
		    p.getPackets().sendMessage("You begin to lift open the massive chest...");
		    p.setLastAnimation(new Animation(833));

            Event rewardEarthQuakeEvent = new Event(1000);
            rewardEarthQuakeEvent.setAction(() => {
				rewardEarthQuakeEvent.stop();
				p.getPackets().sendMessage("..You loot the chest and the tomb begins to shake!");
				p.getPackets().createObject(6775, new Location(3551, 9695, 0), 0, 10);
				getBarrowReward(p);
				startEarthQuake(p);
		    });
            Server.registerEvent(rewardEarthQuakeEvent);
	    }
 public static void useAgilityTunnel(Player p, int x, int y)
 {
     AreaEvent useAgilityTunnelAreaEvent = new AreaEvent(p, x-2, y-2, y+2, y+2);
     useAgilityTunnelAreaEvent.setAction(() => {
         p.getWalkingQueue().resetWalkingQueue();
         p.setLastAnimation(new Animation(844));
         p.setTemporaryAttribute("unmovable", true);
         p.setFaceLocation(new Location(x, y, 0));
         Event useAgilityTunnelEvent = new Event(1000);
         useAgilityTunnelEvent.setAction(() => {
             p.getPackets().sendMessage("You squeeze through the gap.");
             teleportPastObstacle(p);
             p.removeTemporaryAttribute("unmovable");
             useAgilityTunnelEvent.stop();
         });
         Server.registerEvent(useAgilityTunnelEvent);
         return;
     });
     Server.registerCoordinateEvent(useAgilityTunnelAreaEvent);
 }
Пример #25
0
	    public static bool tryOpenCoffin(Player player, int objectId) {
		    if (objectId != 6823 && objectId != 6771 && objectId != 6821 && objectId != 6773 && objectId != 6822 && objectId != 6772) {
			    return false;
		    }
		    Player p = player;
		    int cryptIndex = getCryptIndex(p);
		    if (cryptIndex == -1) {
			    return false;
		    }
            AreaEvent openCoffinAreaEvent = new AreaEvent(p, COFFIN_AREA[cryptIndex][0], COFFIN_AREA[cryptIndex][1], COFFIN_AREA[cryptIndex][2], COFFIN_AREA[cryptIndex][3]);
            openCoffinAreaEvent.setAction(() => {
				    openCoffin(p, objectId);
		    });
            Server.registerCoordinateEvent(openCoffinAreaEvent);
		    return true;
	    }
 public static void passEyes(Player p, int  x, int y)
 {
     int var = x == 3058 ? x+2 : x-1;
     AreaEvent passEyesAreaEvent = new AreaEvent(p, var, y, var, y+2);
     passEyesAreaEvent.setAction(() => {
         p.getWalkingQueue().resetWalkingQueue();
         p.setFaceLocation(new Location(x, y, 0));
         p.setTemporaryAttribute("unmovable", true);
         p.getPackets().sendMessage("You attempt to distract the eyes...");
         Event passEyesEvent = new Event(1900);
         passEyesEvent.setAction(() => {
             int status = 0;
             int[] EYES = {7168, 7169, 7170};
             if (status == 0) {
                 p.getPackets().createObject(EYES[1], new Location(x, y, 0), x == 3058 ? 3 : 1, 10);
             }
             status++;
             if (status == 1) {
                 passEyesEvent.setTick(1300);
             }
             if (status == 2) {
                 p.setLastAnimation(new Animation(65535));
                 passEyesEvent.setTick(800);
             }
             if (status == 3) {
                 passEyesEvent.stop();
                 p.getPackets().sendMessage("You distract the eyes and pass them.");
                 teleportPastObstacle(p);
                 p.removeTemporaryAttribute("unmovable");
             }
         });
         Server.registerEvent(passEyesEvent);
         return;
     });
     Server.registerCoordinateEvent(passEyesAreaEvent);
 }
 public static void mineRock(Player p, int x, int y)
 {
     AreaEvent mineRockAreaEvent = new AreaEvent(p, x-1, y-1, x +3, y+1);
     mineRockAreaEvent.setAction(() => {
         if (!Mining.hasPickaxe(p)) {
             p.getPackets().sendMessage("You need a pickaxe to get past this obstacle.");
             return;
         }
         p.getWalkingQueue().resetWalkingQueue();
         p.setFaceLocation(new Location(x + 1, y, 0));
         p.setLastAnimation(new Animation(Mining.getPickaxeAnimation(p)));
         p.setTemporaryAttribute("unmovable", true);
         Event mineRockEvent = new Event(1900);
         mineRockEvent.setAction(() => {
             int status = 0;
             int[] ROCKS = {7158, 7159, 7160};
             if (status < 3) {
                 p.getPackets().createObject(ROCKS[status], new Location(x, y, 0), 0, 10);
             }
             status++;
             if (status == 1) {
                 mineRockEvent.setTick(1300);
             }
             if (status == 3) {
                 p.setLastAnimation(new Animation(65535));
                 mineRockEvent.setTick(800);
             }
             if (status == 4) {
                 mineRockEvent.stop();
                 teleportPastObstacle(p);
                 p.removeTemporaryAttribute("unmovable");
             }
         });
         Server.registerEvent(mineRockEvent);
         return;
     });
     Server.registerCoordinateEvent(mineRockAreaEvent);
 }
 public static void tryCutTree(Player p, ushort treeId, Location treeLocation, int i, bool newCut)
 {
     int index = getTreeIndex(treeId);
     if (index == -1) {
         return;
     }
     int s = TREE_SIZE[index];
     int dis = s;
     AreaEvent tryCutTreeAreaEvent = new AreaEvent(p, treeLocation.getX()-s, treeLocation.getY()-s, treeLocation.getX()+s, treeLocation.getY()+s);
     tryCutTreeAreaEvent.setAction(() => {
         cutTree(p, treeId, treeLocation, i, newCut, dis);
     });
     Server.registerCoordinateEvent(tryCutTreeAreaEvent);
 }
Пример #29
0
	    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;
					    }
				    }
			    }
		    }
	    }
Пример #30
0
 public static bool wantToSmithOnAnvil(Player p, int item, Location anvilLoc)
 {
     for (int i = 0; i < BARS.Length; i++) {
         if (item == BARS[i]) {
             AreaEvent displaySmithOptionsAreaEvent = new AreaEvent(p, anvilLoc.getX() - 1, anvilLoc.getY() - 1, anvilLoc.getX() + 1, anvilLoc.getY() + 1);
             displaySmithOptionsAreaEvent.setAction(() => {
                 displaySmithOptions(p, i);
             });
             Server.registerCoordinateEvent(displaySmithOptionsAreaEvent);
             return true;
         }
     }
     return false;
 }