protected static void createdAnimatedArmour(Player p, int index) {
		    if (p.getTemporaryAttribute("warriorGuildAnimator") == null) {
			    return;
		    }
		    p.setLastAnimation(new Animation(827));
		    p.setTemporaryAttribute("unmovable", true);
		    for (int i = 0; i < ARMOUR_SETS[index].Length; i++) {
			    p.getInventory().deleteItem(ARMOUR_SETS[index][i]);
		    }
		    p.getPackets().sendChatboxInterface(211);
		    p.getPackets().modifyText("You place the armour onto the platform where it", 211, 1);
		    p.getPackets().modifyText("dissapears...", 211, 2);
		    int animatorIndex = (int) p.getTemporaryAttribute("warriorGuildAnimator");
            Event createAnimatedArmourEvent = new Event(1500);
            int createAnimatedArmourCounter = 0;
            Npc npc = null;
            createAnimatedArmourEvent.setAction(() => {
                if (createAnimatedArmourCounter == 0)
                {
					p.getPackets().sendChatboxInterface(211);
					p.getPackets().modifyText("The animator hums, something appears to be working.", 211, 1);
					p.getPackets().modifyText("You stand back.", 211, 2);
					createAnimatedArmourEvent.setTick(500);
                }
                else if (createAnimatedArmourCounter == 1)
                {
					p.getWalkingQueue().forceWalk(0, + 3);
					createAnimatedArmourEvent.setTick(2000);
                }
                else if (createAnimatedArmourCounter == 2)
                {
					createAnimatedArmourEvent.setTick(500);
					Location minCoords = new Location(2849, 3534, 0);
					Location maxCoords = new Location(2861, 3545, 0);
					npc = new Npc(ANIMATED_ARMOUR[index]);
					npc.setMinimumCoords(minCoords);
					npc.setMaximumCoords(maxCoords);
					npc.setLocation(new Location(ANIMATOR_LOCATIONS[animatorIndex][0], ANIMATOR_LOCATIONS[animatorIndex][1], 0));
					npc.setWalkType(WalkType.STATIC);
					npc.setForceText("I'm ALIVE!");
					npc.setLastAnimation(new Animation(4166));
					npc.setEntityFocus(p.getClientIndex());
					npc.setOwner(p);
					npc.setTarget(p);
					p.getPackets().setArrowOnEntity(1, npc.getClientIndex());
					Server.getNpcList().Add(npc);
				} else {
					p.setEntityFocus(npc.getClientIndex());
					p.getPackets().softCloseInterfaces();
					createAnimatedArmourEvent.stop();
					p.removeTemporaryAttribute("unmovable");
					npc.getFollow().setFollowing(p);
				}
                createAnimatedArmourCounter++;
		    });
            Server.registerEvent(createAnimatedArmourEvent);
	    }
	    private void startArena() {
            Event startArenaEvent = new Event(0);
            startArenaEvent.setAction(() => {
				currentPillar = misc.random(AGILITY_ARENA_PILLARS.Length - 1);
				updateArrow();
				startArenaEvent.setTick(30000 + misc.random(30000));
		    });
            Server.registerEvent(startArenaEvent);
	    }
	    private void startWaitingEvent() {
            Event gameWaitingEvent = new Event(10000);
            gameWaitingEvent.setAction(() => {
				if (!gameInProgress) {
					if (playersWaiting.Count() >= 2 || (playersWaiting.Count() >= 1 && playersPlaying.Count() == 1)) {
						startGame();
						gameWaitingEvent.setTick(1000);
					}
				} else {
					if (playersPlaying.Count() <= 1) {
						gameInProgress = false;
						gameWaitingEvent.setTick(40000);
						setWinner();
					} else {
						if (Environment.TickCount - gameStartedTime >= (MAX_GAME_LENGTH * 60000)) {
							spawnMonsters();
						}
					}
				}
		    });
            Server.registerEvent(gameWaitingEvent);
	    }
 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);
 }
	    private void startGame() {
            Event startFightCaveGameEvent = new Event(3000);
            startFightCaveGameEvent.setAction(() => {
				if (completed) {
					startFightCaveGameEvent.stop();
					return;
				}
				if (mobAmount > 0 || currentWave > 63) {
					return;
				}
				if (gamePaused && currentWave != 63) {
					startFightCaveGameEvent.stop();
					p.getPackets().forceLogout();
					return;
				}
				if (currentWave == 62) {
					startFightCaveGameEvent.setTick(8000);
					currentWave++;
					showJadMessage();
					return;
				} else if (currentWave < 62){
					currentWave++;
				}
				int[] mobs = decryptWave(currentWave);
				int amount = 0;
				for (int i = 0; i < mobs.Length; i++) {
					if (mobs[i] > 0) {
						Npc npc = new Npc(mobs[i]);
						Location minCoords = new Location(((20000 + 2363) + (200 * p.getIndex())), 25051, 0);
						Location maxCoords = new Location(((20000 + 2430) + (200 * p.getIndex())), 25123, 0);
						npc.setMinimumCoords(minCoords);
						npc.setMaximumCoords(maxCoords);
						npc.setLocation(new Location((20000 + 2387) + (200 * p.getIndex()) + misc.random(22), 20000 + 5069 + misc.random(33), 0));
						npc.setEntityFocus(p.getClientIndex());
						npc.setOwner(p);
						npc.setTarget(p);
						npc.getFollow().setFollowing(p);
						Server.getNpcList().Add(npc);
						amount++;
					}
				}
				mobAmount = (byte)amount;
		    });
            Server.registerEvent(startFightCaveGameEvent);
	    }
 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 void showAliDialogue(Player p, int status) {
		    int newStatus = -1;
		    p.getPackets().softCloseInterfaces();
		    if (p.getTemporaryAttribute("unmovable") != null) {
			    return;
		    }
		    switch(status) {
			    case 205:
				    p.getPackets().sendNPCHead(1862, 241, 2);
				    p.getPackets().modifyText("Ali Morissane", 241, 3);
				    p.getPackets().modifyText("Would you like to go back to Lletya?", 241, 4);
				    p.getPackets().animateInterface(9827, 241, 2);
				    p.getPackets().sendChatboxInterface2(241);
				    newStatus = 206;
				    break;
				
			    case 206:
				    p.getPackets().sendChatboxInterface2(228);
				    p.getPackets().modifyText("Yes please, let's go", 228, 2);
				    p.getPackets().modifyText("Not yet", 228, 3);
				    newStatus = 207;
				    break;
				
			    case 207:
				    p.getPackets().sendPlayerHead(64, 2);
				    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
				    p.getPackets().modifyText("Yes please, let's go.", 64, 4);
				    p.getPackets().animateInterface(9827, 64, 2);
				    p.getPackets().sendChatboxInterface2(64);
				    newStatus = 208;
				    break;
				
			    case 208:
				    p.getPackets().sendNPCHead(1862, 241, 2);
				    p.getPackets().modifyText("Ali Morissane", 241, 3);
				    p.getPackets().modifyText("Very well.", 241, 4);
				    p.getPackets().animateInterface(9827, 241, 2);
				    p.getPackets().sendChatboxInterface2(241);
				    newStatus = 209;
				    break;
				
			    case 209:
				    p.setTemporaryAttribute("unmovable", true);
				    p.getPackets().displayInterface(120);
				    p.getPackets().sendMessage("Your camel trots off slowly out of the desert..");
                    Event moveBackToLletyaEvent = new Event(2000);
                    int moveBackToLletyaCounter = 0;
                    moveBackToLletyaEvent.setAction(() => {
                        if (moveBackToLletyaCounter == 0)
                        {
                            moveBackToLletyaCounter++;
                            moveBackToLletyaEvent.setTick(600);
							p.teleport(new Location(2340, 3799, 0));
						} else {
                            moveBackToLletyaEvent.stop();
							p.removeTemporaryAttribute("unmovable");
							p.getPackets().sendMessage("..You and Ali are back in Lletya.");
							p.getPackets().closeInterfaces();
						}	
				    });
                    Server.registerEvent(moveBackToLletyaEvent);
				    break;
				
			    case 210:
				    p.getPackets().sendPlayerHead(64, 2);
				    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
				    p.getPackets().modifyText("Not yet.", 64, 4);
				    p.getPackets().animateInterface(9827, 64, 2);
				    p.getPackets().sendChatboxInterface2(64);
				    newStatus = 211;
				    break;
				
			    case 211:
				    p.getPackets().sendNPCHead(1862, 241, 2);
				    p.getPackets().modifyText("Ali Morissane", 241, 3);
				    p.getPackets().modifyText("No problem, I will be here when you decide to leave.", 241, 4);
				    p.getPackets().animateInterface(9827, 241, 2);
				    p.getPackets().sendChatboxInterface2(241);
				    break;
				
		    }
		    if (newStatus != -1) {
			    p.setTemporaryAttribute("dialogue", newStatus);
		    }
	    }
	    private static void travel(Player p, int index, bool returning) {
		    p.setTemporaryAttribute("unmovable", true);
		    p.getPackets().displayInterface(120);
		    if (returning) {
			    p.getPackets().sendMessage("You sail off back to Oo'glog..");
		    } else {
			    p.getPackets().sendMessage("You climb aboard Captain Bentley's boat and set sail to " + DESTINATION_NAMES[index] + ".");
		    }
            Event travelEvent = new Event(2000);
            int travelCounter = 0;
		    travelEvent.setAction(() => {
                if (travelCounter == 0)
                {
                    travelCounter++;
					travelEvent.setTick(600);
					if (returning) {
						p.teleport(new Location(2622, 2857, 0));
					} else {
						p.teleport(new Location(LOCATIONS[index][0], LOCATIONS[index][1], LOCATIONS[index][2]));
					}
				} else {
					travelEvent.stop();
					p.getPackets().sendOverlay(170);
					p.removeTemporaryAttribute("unmovable");
					p.getPackets().sendMessage(returning ? "The boat arrives back in Oo'glog." : DESTINATION_MESSAGES[index]);
					p.getPackets().closeInterfaces();
                    Event removeOverlayEvent = new Event(2000);
                    removeOverlayEvent.setAction(() => {
                        removeOverlayEvent.stop();
						p.getPackets().sendRemoveOverlay();
						if (index == 1) {
							p.removeTemporaryAttribute("snowInterface");
						}
					});
                    Server.registerEvent(removeOverlayEvent);
				}
		    });
            Server.registerEvent(travelEvent);
	    }
 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);
 }
	    private static void doJadAttacks(Player p, Npc npc) {
		    if (npc.getHp() <= (npc.getMaxHp() * 0.50)) {
			    if (p.getFightCave() != null) {
                    if (!p.getFightCave().isHealersSpawned())
                    {
					    summonJadHealers(p, npc);
					    p.getFightCave().setHealersSpawned(true);
				    }
			    }
		    }
		    npc.resetCombatTurns();
		    npc.setEntityFocus(p.getClientIndex());
		    switch(misc.random(1)) {
			    case 0: // Range
				    npc.setLastAnimation(new Animation(9276));
				    npc.setLastGraphics(new Graphics(1625));
                    Event jadRangeAttackEvent = new Event(1600);
                    int jadRangeAttackStatus = 0;
                    jadRangeAttackEvent.setAction(() => {
					    double hit = 0;
                        PrayerData.PrayerHeadIcon prayerHeadIcon = p.getPrayers().getHeadIcon();
                        if (jadRangeAttackStatus == 0)
                        {
                            jadRangeAttackStatus++;
							jadRangeAttackEvent.setTick(1500);
							p.setLastGraphics(new Graphics(451));
                            if (prayerHeadIcon == PrayerData.PrayerHeadIcon.RANGE)
								hit = 0;
							else
								hit = misc.randomDouble(96);
						} else {
                            if (prayerHeadIcon != PrayerData.PrayerHeadIcon.RANGE)
								hit = misc.randomDouble(96);
							jadRangeAttackEvent.stop();
                            p.setLastAttacked(Environment.TickCount);
                            npc.setLastAttack(Environment.TickCount);
							p.setAttacker(npc);
							if (hit > p.getHp()) {
								hit = p.getHp();
							}
							if (!Location.inFightCave(p.getLocation()) || p.getTeleportTo() != null) {
								return;
							}
							if ((p.getCombatTurns() > 2 || p.getCombatTurns() < 0)) {
								p.setLastAnimation(new Animation(p.getDefenceAnimation()));
							}
							p.hit(hit);
                            Event animationEvent = new Event(100);
                            animationEvent.setAction(() => {
								animationEvent.stop();
								p.setLastGraphics(new Graphics(157, 0, 100));
							});
                            Server.registerEvent(animationEvent);
						}
				    });
                    Server.registerEvent(jadRangeAttackEvent);
				    break;
	
			    case 1: // Magic
				    npc.setLastGraphics(new Graphics(1626));
                    Event jadMagicAttackEvent = new Event(300);
                    int jadMagicAttackStatus = 0;
                    jadMagicAttackEvent.setAction(() => {
					    double hit = 0;
						PrayerData.PrayerHeadIcon prayerHeadIcon = p.getPrayers().getHeadIcon();
						npc.setLastAnimation(new Animation(9278));
                        if (jadMagicAttackStatus == 0)
                        {
                            jadMagicAttackStatus++;
							jadMagicAttackEvent.setTick(1600);
							p.getPackets().sendProjectile(npc.getLocation(), p.getLocation(), 32, 1627, 50, 40, 34, 90, p);
						} else {
							jadMagicAttackEvent.stop();
                            if (prayerHeadIcon == PrayerData.PrayerHeadIcon.MAGIC)
                            {
								hit = 0;
							} else {
								hit = misc.randomDouble(96);
							}
                            p.setLastAttacked(Environment.TickCount);
                            npc.setLastAttack(Environment.TickCount);
							p.setAttacker(npc);
							if (hit > p.getHp()) {
								hit = p.getHp();
							}
							if (!Location.inFightCave(p.getLocation()) || p.getTeleportTo() != null) {
								return;
							}
							if ((p.getCombatTurns() > 2 || p.getCombatTurns() < 0)) {
								p.setLastAnimation(new Animation(p.getDefenceAnimation()));
							}
							p.hit(hit);
                            Event animationEvent = new Event(100);
                            animationEvent.setAction(() => {
								animationEvent.stop();
								p.setLastGraphics(new Graphics(157, 0, 100));
							});
                            Server.registerEvent(animationEvent);
						}
				    });
                    Server.registerEvent(jadMagicAttackEvent);
				    break;
		    }
	    }
Esempio n. 11
0
        /**
	     * Registers a 'coordiante' event.
	     * @param event
	     */
	    public static void registerCoordinateEvent(CoordinateEvent coordinateEvent) {
            Event newCoordinateEvent = new Event(0);
            newCoordinateEvent.setAction(() => {
				bool standingStill = coordinateEvent.getPlayer().getSprites().getPrimarySprite() == -1 && coordinateEvent.getPlayer().getSprites().getSecondarySprite() == -1;
				if(coordinateEvent.getPlayer().getDistanceEvent() == null || !coordinateEvent.getPlayer().getDistanceEvent().Equals(coordinateEvent)) {
					newCoordinateEvent.stop();
					return;
				}
				if (standingStill) {
					if((coordinateEvent.getPlayer().getLocation().Equals(coordinateEvent.getTargetLocation()) && coordinateEvent.getPlayer().getLocation().Equals(coordinateEvent.getOldLocation())) || coordinateEvent.getFailedAttempts() >= 15) {
						if(newCoordinateEvent.getTick() == 0) {
							coordinateEvent.run();
							newCoordinateEvent.stop();
							coordinateEvent.setPlayerNull();
						} else {
							if(!coordinateEvent.hasReached()) {
								coordinateEvent.setReached(true);
							} else {
								coordinateEvent.run();
								newCoordinateEvent.stop();
								coordinateEvent.setPlayerNull();
							}
						}
					}
				} else {
					if(!coordinateEvent.getPlayer().getLocation().Equals(coordinateEvent.getOldLocation())) {
						coordinateEvent.setOldLocation(coordinateEvent.getPlayer().getLocation());
					} else {
						coordinateEvent.incrementFailedAttempts();
					}
				}
				newCoordinateEvent.setTick(200);
		    });
            registerEvent(newCoordinateEvent);
	    }
 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);
 }
Esempio n. 13
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);
	    }
Esempio n. 14
0
        public static void registerCoordinateEvent(AreaEvent areaEvent)
        {
            Event newCoordinateEvent = new Event(0);
            newCoordinateEvent.setAction(() => {
				bool standingStill = areaEvent.getPlayer().getSprites().getPrimarySprite() == -1 && areaEvent.getPlayer().getSprites().getSecondarySprite() == -1;
				if(areaEvent.getPlayer().getDistanceEvent() == null || !areaEvent.getPlayer().getDistanceEvent().Equals(areaEvent)) {
					newCoordinateEvent.stop();
					return;
				}
				if (standingStill) {
					if(areaEvent.inArea()) {
						areaEvent.run();
						newCoordinateEvent.stop();
                        areaEvent.setDistanceEventNull();
						return;
					}
				}
				newCoordinateEvent.setTick(500);
		    });
            registerEvent(newCoordinateEvent);
	    }
        public bool doSpecialAttack(Entity killer, Entity target)
        {
            int weapon = ((Player) killer).getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON);
            int currentPower = specialAmount;
            int neededPower = getRequiredAmount(weapon);
            bool rangeWeapon = false;
            if (!usingSpecial) {
                return false;
            }
            if (p.getDuel() != null) {
                if (p.getDuel().ruleEnabled(DuelSession.RULE.NO_SPECIAL_ATTACKS))  {
                    p.getPackets().sendMessage("Special attacks have been disabled for this duel!");
                    usingSpecial = false;
                    refreshBar();
                    return false;
                }
            }
            if (neededPower > currentPower) {
                ((Player) killer).getPackets().sendMessage("You don't have enough special power left.");
                usingSpecial = false;
                refreshBar();
                return false;
            }
            double damage = -1;
            double damage2 = -1;
            double damage3 = -1;
            double damage4 = -1;
            bool doubleHit = false;
            int increasedMaxHit = 0;
            damage = CombatFormula.getSpecialMeleeHit((Player) killer, target, weapon);
            damage2 = CombatFormula.getSpecialMeleeHit((Player) killer, target, weapon);
            int hitDelay = killer.getHitDelay();
            int usingBow = ((Player)killer).getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON);
            int usingArrows = ((Player)killer).getEquipment().getItemInSlot(ItemData.EQUIP.ARROWS);
            bool usingRangePrayer = false;

            if (target is Player)
                usingRangePrayer = ((Player)target).getPrayers().isPrayerActive(PrayerData.Prayer.PROTECT_FROM_RANGED);
            switch(weapon) {
                case 4151: // Whip.
                    killer.setLastAnimation(new Animation(1658));
                    target.setLastGraphics(new Graphics(341, 0, 100));
                    if (misc.random(3) == 0 && damage > 0) {
                        damage = p.getMaxHit();
                    } else {
                        damage = 0;
                    }
                    if (target is Player) {
                        int energy = ((Player) target).getRunEnergy() / 4;
                        ((Player) killer).setRunEnergy(((Player) killer).getRunEnergy() + energy);
                        ((Player) target).setRunEnergy(((Player) target).getRunEnergy() - energy);
                        if (((Player) killer).getRunEnergy() > 100) {
                            ((Player) killer).setRunEnergy(100);
                        }
                        if (((Player) target).getRunEnergy() < 0) {
                            ((Player) target).setRunEnergy(0);
                        }
                    }
                    break;

                case 1215: // Dragon daggers.
                case 1231:
                case 5680:
                case 5698:
                    if (damage > 0) {
                        damage = p.getMaxHit(20);
                        damage2 = p.getMaxHit(20);
                    }
                    killer.setLastAnimation(new Animation(1062));
                    killer.setLastGraphics(new Graphics(252, 0, 100));
                    doubleHit = true;
                    /*if (misc.random(3) == 0 && CombatFormula.getMeleeHit(p, target) > 0) {
                        if (damage <= (CombatFormula.getPlayerMaxHit(p, 20) / 2) && damage2 <= (CombatFormula.getPlayerMaxHit(p, 20) / 2))
                        {
                            damage = (CombatFormula.getPlayerMaxHit(p, 20) / 2) + (misc.randomDouble(CombatFormula.getPlayerMaxHit(p, 20)) / 2);
                            damage2 = (CombatFormula.getPlayerMaxHit(p, 20) / 2) + (misc.randomDouble(CombatFormula.getPlayerMaxHit(p, 20)) / 2);
                        }
                    } else if (misc.random(2) == 0) {
                        damage = 0;
                        damage2 = 0;
                    }*/
                    double a = damage + damage2;
                    if (damage > target.getHp()) {
                        damage = target.getHp();
                    }
                    a -= damage;
                    if (damage2 > a) {
                        damage2 = a;
                    }
                    /*if (damage > target.getHp()) {
                        int randomHp = misc.random(target.getHp());
                        damage = randomHp;
                        damage2 = target.getHp() - randomHp;
                    } else {
                        int hpRemaining = target.getHp() - damage;
                        if (damage2 > hpRemaining) {
                            damage2 = hpRemaining;
                        }
                    }*/
                    break;

                case 1305: // Dragon longsword.
                    killer.setLastAnimation(new Animation(1058));
                    killer.setLastGraphics(new Graphics(248, 0, 100));
                    damage = p.getMaxHit(30);
                    break;

                case 11694: // Armadyl godsword.
                    killer.setLastGraphics(new Graphics(1222, 0, 100));
                    killer.setLastAnimation(new Animation(7074));
                    damage += p.getMaxHit() * 0.25; //25% decrease.
                    break;

                case 11696: // Bandos godsword.
                    killer.setLastGraphics(new Graphics(1223, 0, 100));
                    killer.setLastAnimation(new Animation(7073));
                    damage += p.getMaxHit() * 0.10; //10% decrease.
                    break;

                case 11698: // Saradomin godsword.
                    killer.setLastGraphics(new Graphics(1220, 0, 100));
                    killer.setLastAnimation(new Animation(7071));
                    int newHp = (int) (damage * 0.50); //50% decrease.
                    int newPrayer = (int) (damage * 0.25); //25% decrease
                    if (newHp < 10) {
                        newHp = 10;
                    }
                    if (newPrayer < 5) {
                        newPrayer = 5;
                    }
                    ((Player) killer).heal(newHp);
                    ((Player) killer).getSkills().setCurLevel(Skills.SKILL.PRAYER, ((Player) killer).getSkills().getCurLevel(Skills.SKILL.PRAYER) + newPrayer);
                    if (((Player) killer).getSkills().getCurLevel(Skills.SKILL.PRAYER) > ((Player) killer).getSkills().getMaxLevel(Skills.SKILL.PRAYER)) {
                        ((Player) killer).getSkills().setCurLevel(Skills.SKILL.PRAYER, ((Player) killer).getSkills().getMaxLevel(Skills.SKILL.PRAYER));
                    }
                    break;

                case 11700: // Zamorak godsword
                    killer.setLastGraphics(new Graphics(1221, 0, 100));
                    killer.setLastAnimation(new Animation(7070));
                    target.setLastGraphics(new Graphics(369));
                    MagicCombat.freezeTarget(31, target);
                    break;

                case 11730: // Saradomin sword
                    target.setLastGraphics(new Graphics(1207, 0, 100));
                    killer.setLastAnimation(new Animation(7072));
                    increasedMaxHit = 16;
                    break;

                case 1434: // Dragon mace
                    hitDelay = 700;
                    killer.setLastGraphics(new Graphics(251, 0, 75));
                    killer.setLastAnimation(new Animation(1060));
                    damage = p.getMaxHit(60);
                    break;

                case 3204: // Dragon halberd
                    // TODO halberd
                    break;

                case 4587: // Dragon scimitar
                    killer.setLastGraphics(new Graphics(347, 0, 100));
                    killer.setLastAnimation(new Animation(451));
                    if (target is Player) {
                        if (((Player)target).getPrayers().isPrayerActive(PrayerData.Prayer.PROTECT_FROM_MELEE) ||
                            ((Player)target).getPrayers().isPrayerActive(PrayerData.Prayer.PROTECT_FROM_MAGIC) ||
                            ((Player)target).getPrayers().isPrayerActive(PrayerData.Prayer.PROTECT_FROM_RANGED) ||
                            ((Player)target).getPrayers().isPrayerActive(PrayerData.Prayer.RETRIBUTION) ||
                            ((Player)target).getPrayers().isPrayerActive(PrayerData.Prayer.REDEMPTION) ||
                            ((Player)target).getPrayers().isPrayerActive(PrayerData.Prayer.SMITE))
                        {
                            ((Player)target).getPackets().sendMessage("The Dragon scimitar slashes through your prayer protection!");
                            Prayer.forcePrayerOff((Player)target, PrayerData.Prayer.PROTECT_FROM_MELEE);
                            Prayer.forcePrayerOff((Player)target, PrayerData.Prayer.PROTECT_FROM_MAGIC);
                            Prayer.forcePrayerOff((Player)target, PrayerData.Prayer.PROTECT_FROM_RANGED);
                            Prayer.forcePrayerOff((Player)target, PrayerData.Prayer.RETRIBUTION);
                            Prayer.forcePrayerOff((Player)target, PrayerData.Prayer.REDEMPTION);
                            Prayer.forcePrayerOff((Player)target, PrayerData.Prayer.SMITE);
                        }
                    }
                    break;

                case 14484: // Dragon claws
                    doubleHit = true;
                    killer.setLastGraphics(new Graphics(1950));
                    killer.setLastAnimation(new Animation(10961));
                    if (misc.random(1) == 0 && damage > 0) {
                        if (damage < p.getMaxHit(20) * 0.75) {
                            damage = (p.getMaxHit(20) * 0.75 + (misc.randomDouble((p.getMaxHit(20) * 0.25))));
                        }
                    }
                    damage = Math.Floor(damage);
                    damage2 = Math.Floor(damage * 0.50); //50% decrease
                    damage3 = Math.Floor(damage2 * 0.50); //50% decrease
                    damage4 = Math.Floor(damage3 + 1);
                    break;

                case 1249: // Dragon spear
                    //TODO leave due to noclipping?
                    break;

                case 6739: // Dragon axe
                    //TODO find emote and graphic
                    break;

                case 7158: // Dragon 2h
                    killer.setLastAnimation(new Animation(3157));
                    killer.setLastGraphics(new Graphics(559));
                    //TODO multi combat
                    break;

                case 3101: // Rune claws
                    killer.setLastGraphics(new Graphics(274));
                    break;

                case 4153: // Granite maul
                    killer.setLastAnimation(new Animation(1667));
                    killer.setLastGraphics(new Graphics(340, 0, 100));
                    //doubleHit = true;
                    break;

                case 10887: // Barrelchest anchor
                    break;

                case 11061: // Ancient mace
                    break;

                case 13902: // Statius' warhammer
                    killer.setLastAnimation(new Animation(10505));
                    killer.setLastGraphics(new Graphics(1840));
                    damage += killer.getMaxHit() * 0.25; //25% decrease
                    if (target is Player) {
                        int defenceLevel = ((Player) target).getSkills().getCurLevel(Skills.SKILL.DEFENCE);
                        int newDefence = (int)(defenceLevel * 0.30); //30% decrease.
                        if (newDefence < 1)
                            newDefence = 1;

                        ((Player) target).getSkills().setCurLevel(Skills.SKILL.DEFENCE, defenceLevel - newDefence);
                        ((Player) target).getPackets().sendSkillLevel(Skills.SKILL.DEFENCE);
                    }
                    break;

                case 13899: // Vesta's longsword
                    killer.setLastAnimation(new Animation(10502));
                    damage += killer.getMaxHit() * 0.20; //20% decrease
                    break;

                case 13905: // Vesta's spear
                    killer.setLastAnimation(new Animation(10499));
                    killer.setLastGraphics(new Graphics(1835));
                    break;

                case 13883: // Morrigans throwing axe
                    break;

                case 13879: // Morrigans javelin

                case 8880: // Dorgeshuun crossbow
                    break;

                case 861: // Magic shortbow
                case 859: // Magic longbow
                case 10284: // Magic composite bow
                    rangeWeapon = true;
                    if (p.getEquipment().getAmountInSlot(ItemData.EQUIP.ARROWS) < 2) {
                        p.getPackets().sendMessage("You need 2 arrows to use the Magic bow special attack!");
                        return false;
                    }
                    damage = CombatFormula.getRangeHit((Player)killer, target, usingBow, usingArrows);
                    damage2 = CombatFormula.getRangeHit((Player)killer, target, usingBow, usingArrows);
                    damage *= 1.05; //5% increase.
                    damage2 *= 1.05; //5% increase.
                    if (usingRangePrayer) {
                        damage *= 0.60; //60% decrease.
                        damage2 *= 0.60; //60% decrease.
                    }
                    double a1 = damage + damage2;
                    if (damage > target.getHp()) {
                        damage = target.getHp();
                    }
                    a1 -= damage;
                    if (damage2 > a1) {
                        damage2 = a1;
                    }
                    /*if (damage >= target.getHp()) {
                        int randomHp = misc.random(target.getHp());
                        damage = randomHp;
                        damage2 = target.getHp() - randomHp;
                    } else {
                        int hpRemaining = target.getHp() - damage;
                        if (damage2 > hpRemaining) {
                            damage2 = hpRemaining;
                        }
                    }*/
                    p.setLastAnimation(new Animation(1074));
                    p.setLastGraphics(new Graphics(256, 0, 90));
                    RangeCombat.deductArrow(killer);
                    RangeCombat.deductArrow(killer);
                    int arrowType = RangeCombat.getArrowType(killer);
                    hitDelay = 1000;
                    int MSpecCounter = 0;
                    Event displayMSpecProjectileEvent = new Event(0);
                    displayMSpecProjectileEvent.setAction(() => {
                        RangeCombat.displayMSpecProjectile(killer, target);
                        MSpecCounter++;
                        if (MSpecCounter == 1)
                        {
                            displayMSpecProjectileEvent.setTick(500);
                            p.setLastGraphics(new Graphics(256, 0, 90));
                            Event doMSpecHitEvent = new Event(900);
                            doMSpecHitEvent.setAction(() => {
                                doMSpecHitEvent.stop();
                                target.hit(damage2);
                                RangeCombat.createGroundArrow(killer, target, arrowType);
                            });
                            Server.registerEvent(doMSpecHitEvent);
                        } else {
                            displayMSpecProjectileEvent.stop();
                            return;
                        }
                        MSpecCounter++;
                    });
                    Server.registerEvent(displayMSpecProjectileEvent);
                    break;

                case 805: // Rune thrownaxe
                    rangeWeapon = true;
                    break;

                case 6724: // Seercull
                    rangeWeapon = true;
                    break;

                case 11235: // Dark bow
                    rangeWeapon = true;
                    if (p.getEquipment().getAmountInSlot(ItemData.EQUIP.ARROWS) < 2) {
                        p.getPackets().sendMessage("You need 2 arrows to use the Dark bow!");
                        return false;
                    }
                    int minHit = 8;
                    damage = CombatFormula.getRangeHit((Player)killer, target, usingBow, usingArrows);
                    damage2 = CombatFormula.getRangeHit((Player)killer, target, usingBow, usingArrows);
                    if (usingBow == 11235) { // Dark bow
                        if (usingArrows == 11212) { // Dragon arrows
                            minHit = usingRangePrayer ? 4 : 8;
                            damage *= 1.50; //50% increase.
                            damage2 *= 1.50; //50% increase.
                            if (damage < minHit) {
                                damage = minHit;
                            }
                            if (damage2 < minHit) {
                                damage2 = minHit;
                            }
                        } else { // Other arrow
                            minHit = usingRangePrayer ? 3 : 5;
                            damage *= 1.30; //30% increase.
                            damage2 *= 1.30; //30% increase.
                            if (damage < minHit) {
                                damage = minHit;
                            }
                            if (damage2 < minHit) {
                                damage2 = minHit;
                            }
                        }
                    }
                    if (usingRangePrayer) {
                        damage *= 0.60; //60% decrease.
                        damage2 *= 0.60; //60% decrease.
                    }
                    double a2 = damage + damage2;
                    if (damage > target.getHp()) {
                        damage = target.getHp();
                    }
                    a2 -= damage;
                    if (damage2 > a2) {
                        damage2 = a2;
                    }
                    /*if (damage >= target.getHp()) {
                        int randomHp = misc.random(target.getHp());
                        damage = randomHp;
                        damage2 = target.getHp() - randomHp;
                    } else {
                        int hpRemaining = target.getHp() - damage;
                        if (damage2 > hpRemaining) {
                            damage2 = hpRemaining;
                        }
                    }*/
                    p.setLastGraphics(new Graphics(RangeCombat.getDrawbackGraphic(killer), 0, 90));
                    RangeCombat.deductArrow(killer);
                    RangeCombat.deductArrow(killer);
                    hitDelay = RangeCombat.getHitDelay(killer, target);
                    int delayHit = hitDelay;
                    hitDelay = 1200;
                    int arrowType1 = RangeCombat.getArrowType(killer);
                    int DBSpecCounter = 0;
                    Event DBSpecProjectile = new Event(0);
                    DBSpecProjectile.setAction(() => {

                        RangeCombat.displayDBSpecProjectile(killer, target);
                        DBSpecCounter++;
                        if (DBSpecCounter == 1)
                        {
                            DBSpecProjectile.setTick(200);
                            Event rangeHitEvent = new Event(delayHit + 600);
                            rangeHitEvent.setAction(() => {
                                target.hit(damage2);
                                rangeHitEvent.stop();
                                RangeCombat.createGroundArrow(killer, target, arrowType1);
                            });
                            Server.registerEvent(rangeHitEvent);
                        } else {
                            DBSpecProjectile.stop();
                            return;
                        }
                        DBSpecCounter++;
                    });
                    Server.registerEvent(DBSpecProjectile);
                    break;
            }
            specialAmount -= neededPower;
            p.setSpecialAmount(specialAmount);
            usingSpecial = false;
            refreshBar();
            killer.resetCombatTurns();
            bool hitDouble = doubleHit;
            if (target is Player) {
                if (!rangeWeapon) {
                    if (((Player) target).getPrayers().getHeadIcon() == PrayerData.PrayerHeadIcon.MELEE) {
                        damage = (damage * 0.60); //60% decrease.
                    }
                } else {
                    if (((Player) target).getPrayers().getHeadIcon() == PrayerData.PrayerHeadIcon.RANGE) {
                        damage = (damage * 0.60); //60% decrease
                    }
                }
            }
            damage = ((weapon == 4151) ? damage : misc.randomDouble(damage));
            damage2 = misc.randomDouble(damage2);
            double d = ((damage == 0 && weapon != 11730) ? 0 : (damage + increasedMaxHit));
            double d2 = damage2;
            double d3 = damage3; // only used for d claws
            double d4 = damage4; // only used for d claws
            if (canPoison(weapon)) {
                if (!target.isPoisoned() && misc.random(5) == 0 && (hitDouble ? (d2 > 0 || d > 0) : d > 0)) {
                    Server.registerEvent(new PoisonEvent(target, POISON_AMOUNT));
                }
            }
            int hhitDelay = hitDelay;
            double totalDamage = (damage + damage2 + damage3 + damage4);
            Combat.checkIfWillDie(target, totalDamage);
            Event hitEvent = new Event(hhitDelay);
            hitEvent.setAction(() => {
                hitEvent.stop();
                if (!target.isDead()) {
                    target.setLastAnimation(new Animation(target.getDefenceAnimation()));
                }
                target.hit(d);
                if (hitDouble) {
                    target.hit(d2);
                }
                if (d3 != -1|| d4 != -1) {
                    target.hit(d3);
                    target.hit(d4);
                }
                Combat.checkRecoilRing(killer, target, totalDamage);
                Combat.checkSmite(killer, target, totalDamage);
                Combat.checkVengeance(killer, target, totalDamage);
                Combat.addXp(killer, target, totalDamage);
            });
            Server.registerEvent(hitEvent);
            return true;
        }
Esempio n. 16
0
	    public static void startEarthQuake(Player player) {
		    Player p = player;
		    p.getPackets().newEarthquake(4, 4, 4, 4, 4);
		    p.setTemporaryAttribute("lootedBarrowChest", true);
		    p.getPackets().createObject(6775, new Location(3551, 9695, 0), 0, 10);
		    p.setBarrowKillCount(0);
		    p.getPackets().sendConfig(453, 0);
            Event takeEarthQuakeDamageEvent = new Event(3000 + misc.random(10000)); //every 3-13 seconds.
		    takeEarthQuakeDamageEvent.setAction(() => {
				if (p.getTemporaryAttribute("lootedBarrowChest") == null) {
					takeEarthQuakeDamageEvent.stop();
					return;
				}
				p.setLastGraphics(new Graphics(405));
				p.setLastAnimation(new Animation(p.getDefenceAnimation()));
				p.hit(7 + misc.random(15)); //take 7-15 damage
				takeEarthQuakeDamageEvent.setTick(8000 + misc.random(20000)); //reset damage time to 8-20 seconds.
		    });
            Server.registerEvent(takeEarthQuakeDamageEvent);
	    }
        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;
            }
        }
Esempio n. 18
0
	    public static void showAliDialogue(Player p, int status) {
		    int newStatus = -1;
		    p.getPackets().softCloseInterfaces();
		    if (p.getTemporaryAttribute("unmovable") != null) {
			    return;
		    }
		    switch(status) {
			    case 156:
				    p.getPackets().sendPlayerHead(64, 2);
				    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
				    p.getPackets().modifyText("Hello?", 64, 4);
				    p.getPackets().animateInterface(9827, 64, 2);
				    p.getPackets().sendChatboxInterface2(64);
				    newStatus = 157;
				    break;
				
			    case 157:
				    p.getPackets().sendNPCHead(1862, 241, 2);
				    p.getPackets().modifyText("Ali Morissane", 241, 3);
				    p.getPackets().modifyText("Well, hello there " + p.getLoginDetails().getUsername() + ", can i help you?", 241, 4);
				    p.getPackets().animateInterface(9827, 241, 2);
				    p.getPackets().sendChatboxInterface2(241);
				    newStatus = 158;
				    break;
				
			    case 158:
				    p.getPackets().sendChatboxInterface2(230);
				    p.getPackets().modifyText("Can you take me to Al-Kharid please?", 230, 2);
				    p.getPackets().modifyText("You don't look like you're from around here..", 230, 3);
				    p.getPackets().modifyText("Nothing, sorry to bother you", 230, 4);
				    newStatus = 159;
				    break;
				
			    case 159:
				    p.getPackets().sendPlayerHead(64, 2);
				    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
				    p.getPackets().modifyText("Can you take me to Al-Kharid please?", 64, 4);
				    p.getPackets().animateInterface(9827, 64, 2);
				    p.getPackets().sendChatboxInterface2(64);
				    newStatus = 160;
				    break;
				
			    case 160:
                    p.getPackets().sendNPCHead(1862, 241, 2);
                    p.getPackets().modifyText("Ali Morissane", 241, 3);
                    p.getPackets().modifyText("Certainly, let's go..", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
				    newStatus = 161;
				    break;
				
			    case 161:
				    p.setTemporaryAttribute("unmovable", true);
				    p.getPackets().displayInterface(120);
				    p.getPackets().sendMessage("You follow Ali across vast lands..");
                    Event moveToAlKharidEvent = new Event(2000);
                    int moveToAlKharidCounter = 0;
                    moveToAlKharidEvent.setAction(() => {
                        if (moveToAlKharidCounter == 0)
                        {
                            moveToAlKharidCounter++;
                            moveToAlKharidEvent.setTick(600);
							p.teleport(new Location(3311 + misc.random(2),3199 + misc.random(3), 0));
						} else {
                            moveToAlKharidEvent.stop();
                            p.getPackets().sendOverlay(170);
							p.removeTemporaryAttribute("unmovable");
                            p.getPackets().sendMessage("..Eventually, you find yourself in Al-Kharid.");
                            p.getPackets().closeInterfaces();
                            Event removeOverlayEvent = new Event(2000);
                            removeOverlayEvent.setAction(() => {
                                removeOverlayEvent.stop();
                                p.getPackets().sendRemoveOverlay();
							});
                            Server.registerEvent(removeOverlayEvent);
						}	
				    });
                    Server.registerEvent(moveToAlKharidEvent);
				    break;
				
			    case 162:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("You don't look like you're from around here..", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
				    newStatus = 163;
				    break;
				
			    case 163:
                    p.getPackets().sendNPCHead(1862, 241, 2);
                    p.getPackets().modifyText("Ali Morissane", 241, 3);
                    p.getPackets().modifyText("That's because i'm not!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
				    newStatus = 164;
				    break;
				
			    case 164:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("I thought as much, Where are you from?", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
				    newStatus = 165;
				    break;
				
			    case 165:
                    p.getPackets().sendNPCHead(1862, 241, 2);
                    p.getPackets().modifyText("Ali Morissane", 241, 3);
                    p.getPackets().modifyText("I usually reside in a small desert town, called Al-Kharid.", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
				    newStatus = 166;
				    break;
				
			    case 166:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("What does Al-Kharid have to offer?", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
				    newStatus = 167;
				    break;
				
			    case 167:
				    p.getPackets().sendNPCHead(1862, 244, 2);
				    p.getPackets().modifyText("Ali Morissane", 244, 3);
				    p.getPackets().modifyText("Sand! lots, and lots of sand! On a more serious note..", 244, 4);
				    p.getPackets().modifyText("A mine full of ore rich rocks, a duel arena where", 244, 5);
				    p.getPackets().modifyText("I hear fortunes are gained and lost. Also, a small market,", 244, 6);
				    p.getPackets().modifyText("which has been attracting crafty thieves as of late!", 244, 7);
				    p.getPackets().animateInterface(9827, 244, 2);
				    p.getPackets().sendChatboxInterface2(244);
				    newStatus = 168;
				    break;
				
			    case 168:
				    p.getPackets().sendPlayerHead(64, 2);
				    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
				    p.getPackets().modifyText("I may have to pay Al-Kharid a visit...", 64, 4);
				    p.getPackets().animateInterface(9827, 64, 2);
				    p.getPackets().sendChatboxInterface2(64);
				    newStatus = 169;
				    break;
				
			    case 169:
				    p.getPackets().sendNPCHead(1862, 242, 2);
				    p.getPackets().modifyText("Ali Morissane", 242, 3);
				    p.getPackets().modifyText("There is one problem. We have also been having", 242, 4);
				    p.getPackets().modifyText("trouble with some of the locals recently.", 242, 5);
				    p.getPackets().animateInterface(9827, 242, 2);
				    p.getPackets().sendChatboxInterface2(242);
				    newStatus = 170;
				    break;
				
			    case 170:
				    p.getPackets().sendPlayerHead(64, 2);
				    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
				    p.getPackets().modifyText("Trouble with the locals?", 64, 4);
				    p.getPackets().animateInterface(9827, 64, 2);
				    p.getPackets().sendChatboxInterface2(64);
				    newStatus = 171;
				    break;
				
			    case 171:
				    p.getPackets().sendNPCHead(1862, 243, 2);
				    p.getPackets().modifyText("Ali Morissane", 243, 3);
				    p.getPackets().modifyText("Yes. Although I really shouldn't say anything but", 243, 4);
				    p.getPackets().modifyText("perhaps you can help. Bandits have overtaken some of", 243, 5);
				    p.getPackets().modifyText("the empty tents in Al-Kharid, and are quite aggressive...", 243, 6);
				    p.getPackets().animateInterface(9827, 243, 2);
				    p.getPackets().sendChatboxInterface2(243);
				    newStatus = 172;
				    break;
				
			    case 172:
				    p.getPackets().sendNPCHead(1862, 244, 2);
				    p.getPackets().modifyText("Ali Morissane", 244, 3);
				    p.getPackets().modifyText("..And that's not all! Deep under the town lies a beast,", 244, 4);
				    p.getPackets().modifyText("I hear it's a mixture of a bug and a fly...I expect it", 244, 5);
				    p.getPackets().modifyText("would take a fine warrior to defeat it and no doubt", 244, 6);
				    p.getPackets().modifyText("he would be generously rewarded.", 244, 7);
				    p.getPackets().animateInterface(9827, 244, 2);
				    p.getPackets().sendChatboxInterface2(244);
				    newStatus = 173;
				    break;
				
			    case 173:
				    p.getPackets().sendPlayerHead(65, 2);
				    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 65, 3);
				    p.getPackets().modifyText("Do you have a map, or directions", 65, 4);
				    p.getPackets().modifyText("to Al-Kharid?", 65, 5);
				    p.getPackets().animateInterface(9827, 65, 2);
				    p.getPackets().sendChatboxInterface2(65);
				    newStatus = 174;
				    break;
				
			    case 174:
				    p.getPackets().sendNPCHead(1862, 243, 2);
				    p.getPackets().modifyText("Ali Morissane", 243, 3);
				    p.getPackets().modifyText("I don't i'm afraid, although I travel back reguarly and", 243, 4);
				    p.getPackets().modifyText("happen to have room for a passenger. So if you'd", 243, 5);
				    p.getPackets().modifyText("ever like to go to Al-Kharid, don't hesitate to ask me.", 243, 6);
				    p.getPackets().animateInterface(9827, 243, 2);
				    p.getPackets().sendChatboxInterface2(243);
				    newStatus = 175;
				    break;
				
			    case 175:
				    p.getPackets().sendPlayerHead(64, 2);
				    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
				    p.getPackets().modifyText("Thankyou for the offer, I may take you up on it soon.", 64, 4);
				    p.getPackets().animateInterface(9827, 64, 2);
				    p.getPackets().sendChatboxInterface2(64);
				    newStatus = 176;
				    break;
				
			    case 176:
				    p.getPackets().sendNPCHead(1862, 241, 2);
				    p.getPackets().modifyText("Ali Morissane", 241, 3);
				    p.getPackets().modifyText("I'll see you then!", 241, 4);
				    p.getPackets().animateInterface(9827, 241, 2);
				    p.getPackets().sendChatboxInterface2(241);
				    break;
				
			    case 177:
				    p.getPackets().sendPlayerHead(64, 2);
				    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
				    p.getPackets().modifyText("Nothing, sorry to bother you!", 64, 4);
				    p.getPackets().animateInterface(9827, 64, 2);
				    p.getPackets().sendChatboxInterface2(64);
				    break;
				
		    }
		    if (newStatus != -1) {
			    p.setTemporaryAttribute("dialogue", newStatus);
		    }
	    }
        public static void doCourse(Player p, int objectX, int objectY, object[] objectArray)
        {
            if (p.getTemporaryAttribute("unmovable") != null) {
                return;
            }
            switch((int)objectArray[0]) {
                case 2309: //Entrance log
                    CoordinateEvent startEntranceLogCoordinateEvent = new CoordinateEvent(p, new Location((int)objectArray[1], (int)objectArray[2], 0));
                    startEntranceLogCoordinateEvent.setAction(() => {
                        bool running = p.getWalkingQueue().isRunToggled();
                        Event comeToLogEvent = new Event(500);
                        comeToLogEvent.setAction(() => {
                            p.getWalkingQueue().setRunToggled(false);
                            p.getWalkingQueue().resetWalkingQueue();
                            p.getPackets().clearMapFlag();
                            p.setTemporaryAttribute("unmovable", true);
                            p.getWalkingQueue().forceWalk(0, 1); //go past gate, no animation yet.
                            comeToLogEvent.stop();
                        });
                        Server.registerEvent(comeToLogEvent);
                        int doLogWalkCounter = 0;
                        Event doLogWalkEvent = new Event(800);
                        doLogWalkEvent.setAction(() => {
                            if (doLogWalkCounter == 0) { //start the animation
                                p.getAppearance().setWalkAnimation(155);
                                p.getUpdateFlags().setAppearanceUpdateRequired(true);
                                doLogWalkEvent.setTick(500); //500 milliseconds required to make animations realistic.
                            } else if(doLogWalkCounter < 16) { //15 steps foward, 1 step is just quickfix TODO: Add gate opener.
                                p.getWalkingQueue().forceWalk(0, 1);
                            } else if(doLogWalkCounter == 17) { //stop the animation add the xp.
                                doLogWalkEvent.stop();
                                p.getAppearance().setWalkAnimation(-1);
                                p.getUpdateFlags().setAppearanceUpdateRequired(true);
                                p.removeTemporaryAttribute("unmovable");
                                p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
                                p.getWalkingQueue().setRunToggled(running);
                            }
                            doLogWalkCounter++;
                        });
                        Server.registerEvent(doLogWalkEvent);
                    });
                    Server.registerCoordinateEvent(startEntranceLogCoordinateEvent);
                    break;
                case 2288: // Tunnel
                    AreaEvent startTunnelAreaEvent = new AreaEvent(p, 3003, 3937, 3005, 3938);
                    startTunnelAreaEvent.setAction(() => {
                        int newMove = 0;
                        int pX = p.getLocation().getX();
                        int pY = p.getLocation().getY();
                        if (pX == objectX + 1 && pY == objectY) // right side
                            newMove = 1;
                        else if (pX == objectX - 1 && pY == objectY) // left side
                            newMove = 2;
                        if (newMove > 0) {
                            int walkTunnelCounter = 0;
                            Event walkTunnelEvent = new Event(500);
                            walkTunnelEvent.setAction(() => {
                                if (walkTunnelCounter == 0) {
                                    p.getWalkingQueue().forceWalk(0, -1);
                                } else if (walkTunnelCounter == 1) {
                                    p.getWalkingQueue().forceWalk(newMove == 1 ? -1 : +1, 0);
                                } else {
                                    doCourse(p, objectX, objectY, objectArray);
                                    walkTunnelEvent.stop();
                                }
                                walkTunnelCounter++;
                            });
                            Server.registerEvent(walkTunnelEvent);
                            return;
                        }
                        Event squeezeIntoPipeEvent = new Event(0);
                        squeezeIntoPipeEvent.setAction(() => {
                            squeezeIntoPipeEvent.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);
                            Event squeezeOutOfPipeEvent = new Event(1000);
                            int squeezeOutOfPipeCounter = 0;
                            squeezeOutOfPipeEvent.setAction(() => {
                                if (squeezeOutOfPipeCounter == 0) {
                                    p.teleport(new Location(p.getLocation().getX(), p.getLocation().getY() + 9, 0));
                                    squeezeOutOfPipeEvent.setTick(850);
                                } else if (squeezeOutOfPipeCounter == 1) {
                                    ForceMovement movement = new ForceMovement(lX, lY + 9, lX, lY + 12, 10, 90, 0);
                                    p.setForceMovement(movement);
                                    squeezeOutOfPipeEvent.setTick(1100);
                                } else if (squeezeOutOfPipeCounter == 2) {
                                    squeezeOutOfPipeEvent.setTick(500);
                                    p.setLastAnimation(new Animation(10579));
                                    p.setForceMovement(new ForceMovement(lX, lY + 12, lX, lY + 13, 10, 40, 0));
                                } else {
                                    p.getPackets().sendMessage("...You squeeze out of the pipe.");
                                    squeezeOutOfPipeEvent.stop();
                                    p.removeTemporaryAttribute("unmovable");
                                    p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
                                    p.getWalkingQueue().setRunToggled(running);
                                    p.teleport(new Location(3004, 3950, 0));
                                }
                                squeezeOutOfPipeCounter++;
                            });
                            Server.registerEvent(squeezeOutOfPipeEvent);
                        });
                        Server.registerEvent(squeezeIntoPipeEvent);
                    });
                    Server.registerCoordinateEvent(startTunnelAreaEvent);
                    break;

                case 2283: // Rope swing
                    AreaEvent startRopeSwingAreaEvent = new AreaEvent(p, 3004, 3951, 3006, 3953);
                    startRopeSwingAreaEvent.setAction(() => {
                        int newMove = 0;
                        int pX = p.getLocation().getX();
                        int pY = p.getLocation().getY();
                        if (pX == objectX - 1 && pY == objectY + 1) // front left
                            newMove = 1;
                        else if (pX == objectX + 1 && pY == objectY + 1) // front right
                            newMove = 2;
                        else if (pX == objectX - 1 && pY == objectY) // back left
                            newMove = 3;
                        else if (pX == objectX + 1 && pY == objectY) // back right
                            newMove = 4;
                        else if (pX == objectX && pY == objectY - 1) // very back middle
                            newMove = 5;
                        else if (pX == objectX && pY == objectY) //  middle
                            newMove = 6;
                        if (newMove > 0) {
                            int path = newMove;
                            int walkRopeSwingCounter = 0;
                            Event walkRopeSwingEvent = new Event(500);
                            walkRopeSwingEvent.setAction(() => {
                                p.setFaceLocation(new Location(3005, 3958, 0));
                                if (path == 1 || path == 2) {
                                    if (walkRopeSwingCounter == 0)
                                    {
                                        p.getWalkingQueue().forceWalk(path == 1 ? +1 : -1, 0);
                                    }
                                    else if (walkRopeSwingCounter >= 1)
                                    {
                                        walkRopeSwingEvent.stop();
                                        doCourse(p, objectX, objectY, objectArray);
                                    }
                                } else if (path == 3 || path == 4) {
                                    if (walkRopeSwingCounter == 0)
                                    {
                                        p.getWalkingQueue().forceWalk(path == 3 ? +1 : -1, +1);
                                    }
                                    else if (walkRopeSwingCounter >= 1)
                                    {
                                        walkRopeSwingEvent.stop();
                                        doCourse(p, objectX, objectY, objectArray);
                                    }
                                } else if (path == 5 || path == 6) {
                                    if (walkRopeSwingCounter == 0)
                                    {
                                        p.getWalkingQueue().forceWalk(0, path == 5 ? +2 : +1);
                                    }
                                    else if (walkRopeSwingCounter >= 1)
                                    {
                                        walkRopeSwingEvent.stop();
                                        doCourse(p, objectX, objectY, objectArray);
                                    }
                                }
                                walkRopeSwingCounter++;
                            });
                            Server.registerEvent(walkRopeSwingEvent);
                            return;
                        }
                        Event setupRopeSwingEvent = new Event(0);
                        setupRopeSwingEvent.setAction(() => {
                            setupRopeSwingEvent.stop();
                            bool running = p.getWalkingQueue().isRunToggled();
                            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));
                            int newY = p.getLocation().getY() + 5;
                            int dir = 4;
                            p.setLastAnimation(new Animation(751));
                            p.setForceMovement(new ForceMovement(lX, lY, lX, lY+5, 25, 57, dir));
                            p.getWalkingQueue().resetWalkingQueue();
                            p.getPackets().clearMapFlag();
                            p.setTemporaryAttribute("unmovable", true);
                            Location objectLocation = new Location(3005, 3952, 0);
                            Event doRopeSwingAnimationEvent = new Event(30);
                            doRopeSwingAnimationEvent.setAction(() => {
                                doRopeSwingAnimationEvent.stop();
                                foreach(Player nearbyPlayers in Server.getPlayerList()) {
                                    if (nearbyPlayers != null) {
                                        nearbyPlayers.getPackets().newObjectAnimation(objectLocation, 497);
                                    }
                                }
                            });
                            Server.registerEvent(doRopeSwingAnimationEvent);

                            Event finishRopeSwingEvent = new Event(1300);
                            finishRopeSwingEvent.setAction(() => {
                                finishRopeSwingEvent.stop();
                                p.getAppearance().setWalkAnimation(-1);
                                p.getUpdateFlags().setAppearanceUpdateRequired(true);
                                p.removeTemporaryAttribute("unmovable");
                                p.teleport(new Location(p.getLocation().getX(), newY, 0));
                                p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
                                p.getWalkingQueue().setRunToggled(running);
                            });
                            Server.registerEvent(finishRopeSwingEvent);
                        });
                        Server.registerEvent(setupRopeSwingEvent);
                    });
                    Server.registerCoordinateEvent(startRopeSwingAreaEvent);
                    break;

                case 37704: // Stepping stones
                    CoordinateEvent startSteppingStonesCoordinateEvent = new CoordinateEvent(p, new Location(3002, 3960, 0));
                    startSteppingStonesCoordinateEvent.setAction(() => {
                        bool running = p.getWalkingQueue().isRunToggled();
                        int dir = 4;
                        p.getWalkingQueue().setRunToggled(false);
                        p.getWalkingQueue().resetWalkingQueue();
                        p.getPackets().clearMapFlag();
                        p.setTemporaryAttribute("unmovable", true);
                        int stepStoneCounter = 0;
                        Event stepStoneEvent = new Event(600);
                        stepStoneEvent.setAction(() => {
                            if (stepStoneCounter >= 6)
                            {
                                stepStoneEvent.stop();
                                p.removeTemporaryAttribute("unmovable");
                                p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
                                p.getWalkingQueue().setRunToggled(running);
                            } else {
                                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.setLastAnimation(new Animation(741));
                                p.setForceMovement(new ForceMovement(lX, lY, lX - 1, lY, 5, 35, dir));
                                Event teleportStepStoneEvent = new Event(550);
                                teleportStepStoneEvent.setAction(() => {
                                    teleportStepStoneEvent.stop();
                                    p.teleport(new Location(p.getLocation().getX()-1, p.getLocation().getY(), 0));
                                });
                                Server.registerEvent(teleportStepStoneEvent);
                                stepStoneEvent.setTick(stepStoneCounter == 6 ? 300 : 1100);
                                stepStoneCounter++;
                                p.setFaceLocation(new Location(2995, 3960, 0));
                            }
                        });
                        Server.registerEvent(stepStoneEvent);
                    });
                    Server.registerCoordinateEvent(startSteppingStonesCoordinateEvent);
                    break;

                case 2297: // Log
                    AreaEvent startLogAreaEvent = new AreaEvent(p, 3001, 3944, 3002, 3946);
                    startLogAreaEvent.setAction(() => {
                        int distanceToWalk = p.getLocation().getX() == 3001 ? -7 : -8;
                        int newMove = 0;
                        int pX = p.getLocation().getX();
                        int pY = p.getLocation().getY();
                        if (pX == objectX && pY == objectY - 1)
                            newMove = 1;
                        else if (pX == objectX && pY == objectY + 1)
                            newMove = 2;
                        else if (pX == objectX + 1 && pY == objectY + 1)
                            newMove = 3;
                        else if (pX == objectX + 1 && pY == objectY - 1)
                            newMove = 4;
                        if (newMove > 0) {
                            int path = newMove;
                            int doLogWalkCounter = 0;
                            Event doLogWalkEvent = new Event(500);
                            doLogWalkEvent.setAction(() => {
                                if (doLogWalkCounter == 0)
                                {
                                    if (path == 1 || path == 2) {
                                        p.getWalkingQueue().forceWalk(0, path == 1 ? +1 : -1);
                                    } else if (path == 3 || path == 4) {
                                        p.getWalkingQueue().forceWalk(0, path == 4 ? +1 : -1);
                                    }
                                } else {
                                    doCourse(p, objectX, objectY, objectArray);
                                    doLogWalkEvent.stop();
                                }
                                doLogWalkCounter++;
                            });
                            Server.registerEvent(doLogWalkEvent);
                            return;
                        }
                        Event doLogAnimationEvent = new Event(0);
                        doLogAnimationEvent.setAction(() => {
                            doLogAnimationEvent.stop();
                            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(distanceToWalk, 0);
                            int delay = distanceToWalk == -7 ? 4100 : 4600;
                            Event doLogFinishEvent = new Event(delay);
                            doLogFinishEvent.setAction(() => {
                                doLogFinishEvent.stop();
                                p.getAppearance().setWalkAnimation(-1);
                                p.getUpdateFlags().setAppearanceUpdateRequired(true);
                                p.removeTemporaryAttribute("unmovable");
                                p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
                                p.getWalkingQueue().setRunToggled(running);
                            });
                            Server.registerEvent(doLogFinishEvent);
                        });
                        Server.registerEvent(doLogAnimationEvent);
                    });
                    Server.registerCoordinateEvent(startLogAreaEvent);
                    break;

                case 2328: // Rocks
                    AreaEvent startRocksAreaEvent = new AreaEvent(p, 2993, 3937, 2995, 3937);
                    startRocksAreaEvent.setAction(() => {
                        int doRocksAnimationCounter = 0;
                        Event doRocksAnimationEvent = new Event(0);
                        doRocksAnimationEvent.setAction(() => {
                            if (doRocksAnimationCounter == 0)
                            {
                                p.setFaceLocation(new Location(p.getLocation().getX(), p.getLocation().getY() - 5, 0));
                                doRocksAnimationCounter++;
                                doRocksAnimationEvent.setTick(500);
                                return;
                            }
                            doRocksAnimationEvent.stop();
                            p.setLastAnimation(new Animation(740));
                            p.getWalkingQueue().resetWalkingQueue();
                            p.getPackets().clearMapFlag();
                            p.getAppearance().setWalkAnimation(0);
                            p.getUpdateFlags().setAppearanceUpdateRequired(true);
                            p.setTemporaryAttribute("unmovable", true);
                            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, 5, 80, 4));
                            Event finishRocksEvent = new Event(1500);
                            finishRocksEvent.setAction(() => {
                                finishRocksEvent.stop();
                                p.teleport(new Location(p.getLocation().getX(), p.getLocation().getY() - 4, 0));
                                p.setLastAnimation(new Animation(65535));
                                p.removeTemporaryAttribute("unmovable");
                                p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
                            });
                            Server.registerEvent(finishRocksEvent);
                        });
                        Server.registerEvent(doRocksAnimationEvent);
                    });
                    Server.registerCoordinateEvent(startRocksAreaEvent);
                    break;
            }
        }
        public static void doCourse(Player p, int objectX, int objectY, object[] objectArray)
        {
            if (p.getTemporaryAttribute("unmovable") != null)
                return;

            switch((int)objectArray[0]) {
                case 20210: // Entrance tunnel
                    AreaEvent entranceTunnelAreaEvent = new AreaEvent(p, 2551, 3558, 2553, 3561);
                    entranceTunnelAreaEvent.setAction(() => {
                        entranceTunnelAreaEvent.stop();
                        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 == objectX - 1 && pY == objectY + 1)
                            newMove = 3;
                        else if (pX == objectX + 1 && pY == objectY + 1)
                            newMove = 4;
                        if (newMove > 0) {
                            int path = newMove;
                            int doCourseCounter = 0;
                            Event doCourseEvent = new Event(500);
                            doCourseEvent.setAction(() => {
                                if (doCourseCounter == 0)
                                {
                                    p.getWalkingQueue().forceWalk(0, (path == 1 || path == 2) ? -1 : (path == 3 || path == 4) ? +1 : 0);
                                }
                                else if (doCourseCounter == 1)
                                {
                                    p.getWalkingQueue().forceWalk((path == 1 || path == 4) ? -1 : (path == 2 || path == 3) ? +1 : 0, 0);
                                } else {
                                    doCourse(p, objectX, objectY, objectArray);
                                    doCourseEvent.stop();
                                }
                                doCourseCounter++;
                            });
                            Server.registerEvent(doCourseEvent);
                            return;
                        }
                        int startEnterTunnelCounter = 0;
                        Event startEnterTunnelEvent = new Event(0);
                        startEnterTunnelEvent.setAction(() => {
                            if (startEnterTunnelCounter == 0)
                            {
                                p.setFaceLocation(new Location(p.getLocation().getX(), p.getLocation().getY() <= 3558 ? 3561 : 3558, 0));
                                startEnterTunnelEvent.setTick(500);
                                startEnterTunnelCounter++;
                            } else {
                                startEnterTunnelEvent.stop();
                                bool running = p.getWalkingQueue().isRunToggled();
                                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));
                                int newLocalY = p.getLocation().getY() == 3558 ? lY + 3 : lY - 3;
                                int newY = newLocalY > lY ? p.getLocation().getY() + 3 : p.getLocation().getY() - 3;
                                int dir = newLocalY > lY ? 0 : 4;
                                p.setForceMovement(new ForceMovement(lX, lY, lX, newLocalY, 10, 60, dir));
                                p.setLastAnimation(new Animation(10580));
                                p.getWalkingQueue().resetWalkingQueue();
                                p.getPackets().clearMapFlag();
                                p.setTemporaryAttribute("unmovable", true);
                                Event enterTunnelEvent = new Event(1500);
                                enterTunnelEvent.setAction(() => {
                                    enterTunnelEvent.stop();
                                    p.removeTemporaryAttribute("unmovable");
                                    p.teleport(new Location(p.getLocation().getX(), newY, 0));
                                    p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
                                    p.getWalkingQueue().setRunToggled(running);
                                });
                                Server.registerEvent(enterTunnelEvent);
                            }
                        });
                        Server.registerEvent(startEnterTunnelEvent);
                    });
                    Server.registerCoordinateEvent(entranceTunnelAreaEvent);
                    break;

                case 2282: // Swing
                    AreaEvent swingAreaEvent = new AreaEvent(p, 2550, 3554, 2552, 3555);
                    swingAreaEvent.setAction(() => {
                        int newMove = 0;
                        int pX = p.getLocation().getX();
                        int pY = p.getLocation().getY();
                        if (pX == objectX - 1 && pY == objectY + 4) // front left
                            newMove = 1;
                        else if (pX == objectX + 1 && pY == objectY + 4) // front right
                            newMove = 2;
                        else if (pX == objectX - 1 && pY == objectY + 5) // back left
                            newMove = 3;
                        else if (pX == objectX + 1 && pY == objectY + 5) // back right
                            newMove = 4;
                        else if (pX == objectX && pY == objectY + 5) // back middle
                            newMove = 5;
                        if (newMove > 0) {
                            int path = newMove;
                            int doCourseCounter = 0;
                            Event doCourseEvent = new Event(500);
                            doCourseEvent.setAction(() => {
                                p.setFaceLocation(new Location(2551, 3549, 0));
                                if (path == 1 || path == 2) {
                                    if (doCourseCounter == 0)
                                    {
                                        p.getWalkingQueue().forceWalk(path == 1 ? +1 : -1, 0);
                                    }
                                    else if (doCourseCounter >= 1)
                                    {
                                        doCourseEvent.stop();
                                        doCourse(p, objectX, objectY, objectArray);
                                    }
                                } else if (path == 3 || path == 4) {
                                    if (doCourseCounter == 0)
                                    {
                                        p.getWalkingQueue().forceWalk(path == 3 ? +1 : -1, -1);
                                    }
                                    else if (doCourseCounter >= 1)
                                    {
                                        doCourseEvent.stop();
                                        doCourse(p, objectX, objectY, objectArray);
                                    }
                                } else if (path == 5) {
                                    if (doCourseCounter == 0)
                                    {
                                        p.getWalkingQueue().forceWalk(0, -1);
                                    }
                                    else if (doCourseCounter >= 1)
                                    {
                                        doCourseEvent.stop();
                                        doCourse(p, objectX, objectY, objectArray);
                                    }
                                }
                                doCourseCounter++;
                            });
                            Server.registerEvent(doCourseEvent);
                            return;
                        }

                        Event doSwingEvent = new Event(0);
                        doSwingEvent.setAction(() => {
                            doSwingEvent.stop();
                            bool running = p.getWalkingQueue().isRunToggled();
                            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));
                            int newY = p.getLocation().getY() - 5;
                            int dir = 4;
                            p.setLastAnimation(new Animation(751));
                            p.setForceMovement(new ForceMovement(lX, lY, lX, lY-5, 25, 57, dir));
                            p.getWalkingQueue().resetWalkingQueue();
                            p.getPackets().clearMapFlag();
                            p.setTemporaryAttribute("unmovable", true);
                            Location objectLocation = new Location(2551, 3550, 0);
                            Event showObjectAnimationEvent = new Event(30);
                            showObjectAnimationEvent.setAction(() => {
                                showObjectAnimationEvent.stop();
                                foreach(Player nearbyPlayers in Server.getPlayerList()) {
                                    if (nearbyPlayers != null) {
                                        nearbyPlayers.getPackets().newObjectAnimation(objectLocation, 497);
                                    }
                                }
                            });
                            Server.registerEvent(showObjectAnimationEvent);
                            Event finishSwingEvent = new Event(1300);
                            finishSwingEvent.setAction(() => {
                                finishSwingEvent.stop();
                                p.getAppearance().setWalkAnimation(-1);
                                p.getUpdateFlags().setAppearanceUpdateRequired(true);
                                p.removeTemporaryAttribute("unmovable");
                                p.teleport(new Location(p.getLocation().getX(), newY, 0));
                                p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
                                p.getWalkingQueue().setRunToggled(running);
                            });
                            Server.registerEvent(finishSwingEvent);
                        });
                        Server.registerEvent(doSwingEvent);
                    });
                    Server.registerCoordinateEvent(swingAreaEvent);
                    break;

                case 2294: // Log
                    AreaEvent logAreaEvent = new AreaEvent(p, 2550, 3545, 2551, 3547);
                    logAreaEvent.setAction(() => {
                        int distanceToWalk = p.getLocation().getX() == 2550 ? -9 : -10;
                        int newMove = 0;
                        int pX = p.getLocation().getX();
                        int pY = p.getLocation().getY();
                        if (pX == objectX && pY == objectY - 1)
                            newMove = 1;
                        else if (pX == objectX&& pY == objectY + 1)
                            newMove = 2;
                        if (newMove > 0) {
                            int path = newMove;
                            int doLogCounter = 0;
                            Event doLogEvent = new Event(500);
                            doLogEvent.setAction(() => {
                                if (doLogCounter++ == 0)
                                {
                                    p.getWalkingQueue().forceWalk(0, path == 1 ? +1 : -1);
                                } else {
                                    doCourse(p, objectX, objectY, objectArray);
                                    doLogEvent.stop();
                                }
                            });
                            Server.registerEvent(doLogEvent);
                            return;
                        }
                        Event startLogEvent = new Event(0);
                        startLogEvent.setAction(() => {
                            startLogEvent.stop();
                            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(distanceToWalk, 0);
                            int delay = distanceToWalk == -9 ? 5400 : 5900;
                            Event endLogEvent = new Event(delay);
                            endLogEvent.setAction(() => {
                                endLogEvent.stop();
                                p.getAppearance().setWalkAnimation(-1);
                                p.getUpdateFlags().setAppearanceUpdateRequired(true);
                                p.removeTemporaryAttribute("unmovable");
                                p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
                                p.getWalkingQueue().setRunToggled(running);
                            });
                            Server.registerEvent(endLogEvent);
                        });
                        Server.registerEvent(startLogEvent);
                    });
                    Server.registerCoordinateEvent(logAreaEvent);
                    break;

                case 20211: // Net
                    AreaEvent netAreaEvent = new AreaEvent(p, 2539, 3545, 2539, 3546);
                    netAreaEvent.setAction(() => {
                        p.setLastAnimation(new Animation(828));
                        p.getWalkingQueue().resetWalkingQueue();
                        p.getPackets().clearMapFlag();
                        p.setFaceLocation(new Location(p.getLocation().getX()-1, p.getLocation().getY(), 0));
                        p.setTemporaryAttribute("unmovable", true);
                        Event netEvent = new Event(1000);
                        netEvent.setAction(() => {
                            netEvent.stop();
                            p.removeTemporaryAttribute("unmovable");
                            p.teleport(new Location(p.getLocation().getX()-2, p.getLocation().getY(), 1));
                            p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
                        });
                        Server.registerEvent(netEvent);
                    });
                    Server.registerCoordinateEvent(netAreaEvent);
                    break;

                case 2302: // Balance beam
                    CoordinateEvent balanceBeamCoordinateEvent = new CoordinateEvent(p, new Location((int)objectArray[3], (int)objectArray[4], 1));
                    balanceBeamCoordinateEvent.setAction(() => {
                        bool running = p.getWalkingQueue().isRunToggled();
                        p.getWalkingQueue().setRunToggled(false);
                        p.getWalkingQueue().resetWalkingQueue();
                        p.getPackets().clearMapFlag();
                        p.setTemporaryAttribute("unmovable", true);
                        p.getAppearance().setWalkAnimation(157);
                        p.getUpdateFlags().setAppearanceUpdateRequired(true);
                        p.getWalkingQueue().forceWalk(-4, 0);
                        Event balanceBeamEvent = new Event(2450);
                        balanceBeamEvent.setAction(() => {
                            balanceBeamEvent.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(balanceBeamEvent);
                    });
                    Server.registerCoordinateEvent(balanceBeamCoordinateEvent);
                    break;

                case 1948: // Crumbling wall
                    AreaEvent crumblingWallAreaEvent = new AreaEvent(p, objectX - 1, objectY - 1, objectX, objectY + 1);
                    crumblingWallAreaEvent.setAction(() => {
                        int newMove = 0;
                        int pX = p.getLocation().getX();
                        int pY = p.getLocation().getY();
                        if (pX == objectX && pY == objectY - 1)
                            newMove = 1;
                        else if (pX == objectX && pY == objectY + 1)
                            newMove = 2;
                        if (newMove > 0) {
                            int path = newMove;
                            Event startCrumblingWallEvent = new Event(500);
                            int startCrumblingWallCounter = 0;
                            startCrumblingWallEvent.setAction(() => {
                                if (startCrumblingWallCounter == 0)
                                {
                                    p.getWalkingQueue().forceWalk(-1, 0);
                                }
                                else if (startCrumblingWallCounter == 1)
                                {
                                    p.getWalkingQueue().forceWalk(0, path == 1 ? +1 : -1);
                                } else {
                                    doCourse(p, objectX, objectY, objectArray);
                                    startCrumblingWallEvent.stop();
                                }
                                startCrumblingWallCounter++;
                            });
                            Server.registerEvent(startCrumblingWallEvent);
                            return;
                        }
                        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+2, lY, 10, 60, 1));
                        p.setLastAnimation(new Animation(4853));
                        p.getWalkingQueue().resetWalkingQueue();
                        p.getPackets().clearMapFlag();
                        p.setTemporaryAttribute("unmovable", true);
                        Event finishCrumblingWallEvent = new Event(1250);
                        finishCrumblingWallEvent.setAction(() => {
                            finishCrumblingWallEvent.stop();
                            p.setFaceLocation(new Location(p.getLocation().getX()+1, p.getLocation().getY(), 0));
                            p.removeTemporaryAttribute("unmovable");
                            p.teleport(new Location(p.getLocation().getX()+2, p.getLocation().getY(), 0));
                            p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
                        });
                        Server.registerEvent(finishCrumblingWallEvent);
                    });
                    Server.registerCoordinateEvent(crumblingWallAreaEvent);
                    break;
            }
        }
        public static void teleportToPatch(Player p, int option)
        {
            p.setTemporaryAttribute("unmovable", true);
            p.getWalkingQueue().resetWalkingQueue();
            p.getPackets().softCloseInterfaces();
            p.getPackets().displayInterface(120);

            Event teleportToPatchEvent = new Event(2000);
            int teleportToPatchCounter = 0;
            teleportToPatchEvent.setAction(() => {
                if (teleportToPatchCounter == 0)
                {
                    teleportToPatchCounter++;
                    teleportToPatchEvent.setTick(600);
                    p.teleport(new Location((int)PATCHES[option][0] + misc.random((int)PATCHES[option][2]), (int)PATCHES[option][1] + misc.random((int)PATCHES[option][3]), 0));
                }
                else
                {
                    teleportToPatchEvent.stop();
                    p.removeTemporaryAttribute("unmovable");
                    p.getPackets().sendMessage("You are teleported to the " + PATCHES[option][4] + ".");
                    p.getPackets().closeInterfaces();
                }
            });
        }