Пример #1
0
 public static void castCharge(Player p)
 {
     p.removeTemporaryAttribute("autoCasting");
     if (p.getSkills().getCurLevel(Skills.SKILL.MAGIC) < 80) {
         p.getPackets().sendMessage("You need a Magic level of 80 to cast Charge.");
         return;
     }
     if (!hasRunes(p, CHARGE_RUNES, CHARGE_RUNE_AMOUNT)) {
         p.getPackets().sendMessage("You do not have enough runes to cast Charge.");
         return;
     }
     if (p.getTemporaryAttribute("godCharged") != null) {
         p.getPackets().sendMessage("You have already charged your god spells.");
         return;
     }
     if (hasGodCapeAndStaff(p)) {
         p.getPackets().sendMessage("You must wear a God cape and wield the matching staff to cast Charge.");
         return;
     }
     if (!deleteRunes(p, CHARGE_RUNES, CHARGE_RUNE_AMOUNT)) {
         return;
     }
     p.setTemporaryAttribute("godCharged", true);
     p.setLastGraphics(new Graphics(308, 800, 90));
     p.setLastAnimation(new Animation(811));
     p.getPackets().sendMessage("You feel charged with magical power..");
     int delay = 60000 + misc.random(120000); //60 seconds + possible 120 seconds so, 1 minute to 2 minutes.
     Event removeGodChargeEvent = new Event(delay);
     removeGodChargeEvent.setAction(() => {
         removeGodChargeEvent.stop();
         p.removeTemporaryAttribute("godCharged");
         p.getPackets().sendMessage("Your magical charge fades away.");
     });
     Server.registerEvent(removeGodChargeEvent);
 }
Пример #2
0
 public static void createAmmo(Player p, int sets, int type, bool bolt, bool newFletch)
 {
     Ammo item = null;
     if (newFletch || Fletching.getFletchItem(p) == null) {
         item = getAmmo(type, bolt, sets);
         Fletching.setFletchItem(p, item);
     }
     item = (Ammo) Fletching.getFletchItem(p);
     if (item == null || p == null) {
         return;
     }
     if (!canFletch(p, item)) {
         p.getPackets().closeInterfaces();
         return;
     }
     int amt = getArrowAmount(p, item);
     if (amt <= 0) {
         return;
     }
     if (p.getInventory().deleteItem(item.getItemOne(), amt) && p.getInventory().deleteItem(item.getItemTwo(), amt)) {
         p.getInventory().addItem(item.getFinishedItem(), amt);
         p.getSkills().addXp(Skills.SKILL.FLETCHING, item.getXp() * amt);
         p.getPackets().sendMessage(getMessage(item, amt));
         item.decreaseAmount();
         p.getPackets().closeInterfaces();
     }
     if (item.getAmount() >= 1) {
         Event createMoreAmmoEvent = new Event(1500);
         createMoreAmmoEvent.setAction(() => {
             createAmmo(p, -1, -1, false, false);
             createMoreAmmoEvent.stop();
         });
         Server.registerEvent(createMoreAmmoEvent);
     }
 }
Пример #3
0
        public static void enterCave(Player p)
        {
            AreaEvent enterCaveAreaEvent = new AreaEvent(p, 2438, 5168, 2439, 5168);
            enterCaveAreaEvent.setAction(() => {
                /*
                 * Fight cave is 20k squares from the original place, then another (200 * playerIndex) squares west.
                 */
                Location instanceLocation = new Location((20000 + 2413) + (200 * p.getIndex()), 20000 + 5116, 0);
                p.teleport(instanceLocation);
                p.setFightCave(new FightCaveSession(p));

                Event caveNpcEvent = new Event(600);
                caveNpcEvent.setAction(() => {
                        caveNpcEvent.stop();
                        p.getPackets().sendNPCHead(2617, 242, 1);
                        p.getPackets().modifyText("TzHaar-Mej-Jal", 242, 3);
                        p.getPackets().modifyText("You're on your own now, JalYt.", 242, 4);
                        p.getPackets().modifyText("Pepare to fight for your life!", 242, 5);
                        p.getPackets().animateInterface(9827, 242, 1);
                        p.getPackets().sendChatboxInterface2(242);
                });
                Server.registerEvent(caveNpcEvent);
            });
            Server.registerCoordinateEvent(enterCaveAreaEvent);
        }
Пример #4
0
        public void processPatches()
        {
            /*
             * If something has to be removed from the ArrayList in this loop, use it.remove() not patches.remove()
             * or else we end up with a ConcurrentModificationException and it'll break out the loop :$.
             */
            Event processPatchesEvent = new Event(3000);
            processPatchesEvent.setAction(() => {

                foreach(Patch patch in patches) {
                    if (patch == null) {
                        removedPatches.Add(patch);
                    } else if (patch.isSapling()) {
                        if (Farming.growSapling(patch)) {
                            removedPatches.Add(patch);
                        }
                    } else if (!patch.patchOccupied()) {
                        if (Farming.regrowWeeds(patch)) { // true if we should remove from the list
                            removedPatches.Add(patch);
                        }
                    } else if (!patch.isFullyGrown() && patch.patchOccupied()) {
                        long currentTime = Environment.TickCount;
                        long lastUpdatedTime = patch.getLastUpdate();
                        int delay = (int) (patch.getTimeToGrow() / patch.getConfigLength());
                        //if (currentTime - lastUpdatedTime >= delay) {
                            Farming.growPatch(patch);
                        //}
                    }
                }
                patches.RemoveAll(new Predicate<Patch>(delegate(Patch x) { return removedPatches.Contains(x); }));
            });
            Server.registerEvent(processPatchesEvent);
        }
Пример #5
0
        public ShopManager()
        {
            if (!File.Exists(misc.getServerPath() + @"\data\shops.xml"))
            {
                misc.WriteError(@"Missing data\shops.xml");
                return;
            }
            try
            {
                //Deserialize text file to a new object.
                StreamReader objStreamReader = new StreamReader(misc.getServerPath() + @"\data\shops.xml");
                XmlSerializer serializer = new XmlSerializer(typeof(List<Shop>));

                List<Shop> listShops = (List<Shop>)serializer.Deserialize(objStreamReader);
                shops = new Dictionary<int, Shop>();
                foreach (Shop shop in listShops)
                {
                    shops.Add(shop.id, shop);
                }
            }
            catch (Exception e)
            {
                misc.WriteError((e.InnerException == null ? e.ToString() : e.InnerException.ToString()));
            }

            //shops = (Map<Integer, Shop>) XStreamUtil.getXStream().fromXML(new FileInputStream("data/shops.xml"));
            Event updateShopAmountsEvent = new Event(60000);
            updateShopAmountsEvent.setAction(() => {
                updateShopAmounts();
            });
            Server.registerEvent(updateShopAmountsEvent);
            Console.WriteLine("Loaded " + shops.Count + " shops.");
        }
Пример #6
0
 public static void craftDragonHide(Player p, int amount, int itemIndex, int leatherType, bool newCraft)
 {
     if (newCraft) {
         itemIndex = leatherType != 0 ? itemIndex += leatherType : itemIndex;
         p.setTemporaryAttribute("craftItem", new CraftItem(leatherType, itemIndex, amount, (double) LEATHER_ITEMS[itemIndex][2], (int) LEATHER_ITEMS[itemIndex][0], (string) LEATHER_ITEMS[itemIndex][4], (int) LEATHER_ITEMS[itemIndex][1]));
     }
     CraftItem item = (CraftItem) p.getTemporaryAttribute("craftItem");
     if (item == null || p == null || item.getAmount() <= 0) {
         Crafting.resetCrafting(p);
         return;
     }
     p.getPackets().closeInterfaces();
     int index = item.getCraftItem();
     if (p.getSkills().getGreaterLevel(Skills.SKILL.CRAFTING) < item.getLevel()) {
         p.getPackets().sendMessage("You need a Crafting level of " + item.getLevel() + " to craft that item.");
         Crafting.resetCrafting(p);
         return;
     }
     if (!p.getInventory().hasItemAmount(TANNED_HIDE[item.getCraftType()], (int) LEATHER_ITEMS[index][3])) {
         p.getPackets().sendMessage("You need " + (int) LEATHER_ITEMS[index][3] + " dragonhide to craft that.");
         Crafting.resetCrafting(p);
         return;
     }
     if (!p.getInventory().hasItem(NEEDLE)) {
         p.getPackets().sendMessage("You need a needle if you wish to craft leather.");
         Crafting.resetCrafting(p);
         return;
     }
     if (!p.getInventory().hasItemAmount(THREAD, (int)LEATHER_ITEMS[index][3])) {
         p.getPackets().sendMessage("You need " + (int)LEATHER_ITEMS[index][3] + " thread to craft that.");
         Crafting.resetCrafting(p);
         return;
     }
     string s = index < 4 ? "a" : "a pair of";
     for (int j = 0; j < (int) LEATHER_ITEMS[index][3]; j++) {
         if (!p.getInventory().deleteItem(TANNED_HIDE[item.getCraftType()])) {
             return;
         }
     }
     p.getInventory().deleteItem(THREAD, (int) LEATHER_ITEMS[index][3]);
     p.getInventory().addItem(item.getFinishedItem());
     p.getSkills().addXp(Skills.SKILL.CRAFTING, item.getXp());
     p.setLastAnimation(new Animation(1249));
     p.getPackets().sendMessage("You craft " + s + " " + item.getMessage() + ".");
     item.decreaseAmount();
     if (item.getAmount() >= 1) {
         Event craftMoreDragonHide = new Event(1500);
         craftMoreDragonHide.setAction(() => {
                 craftDragonHide(p, -1, -1, -1, false);
                 craftMoreDragonHide.stop();
         });
         Server.registerEvent(craftMoreDragonHide);
     }
 }
Пример #7
0
 public static void exitCave(Player p, int objectX, int objectY)
 {
     AreaEvent exitCaveAreaEvent = new AreaEvent(p, objectX, objectY - 1, objectX + 2, objectY - 1);
     exitCaveAreaEvent.setAction(() => {
         p.setTemporaryAttribute("unmovable", true);
         Event teleFromCaveEvent = new Event(600);
         teleFromCaveEvent.setAction(() => {
             teleFromCaveEvent.stop();
             p.getFightCave().teleFromCave(true);
         });
         Server.registerEvent(teleFromCaveEvent);
     });
     Server.registerCoordinateEvent(exitCaveAreaEvent);
 }
Пример #8
0
 public static void craftClay(Player p, int amount, int craftType, int craftItem, bool newCraft)
 {
     if (newCraft) {
         if ((craftType != 1 && craftType != 2) || craftItem < 0 || craftItem > 4) {
             return;
         }
         int index = craftItem;
         int endItem = craftType == 1 ? 0 : 1;
         int xp = craftType == 1 ? 3 : 4;
         p.setTemporaryAttribute("craftItem", new CraftItem(craftType, craftItem, amount, (double) CLAY_ITEMS[index][xp], (int) CLAY_ITEMS[index][endItem], (string) CLAY_ITEMS[index][5], (int) CLAY_ITEMS[index][2]));
     }
     CraftItem item = (CraftItem) p.getTemporaryAttribute("craftItem");
     if (item == null || p == null || item.getAmount() <= 0) {
         Crafting.resetCrafting(p);
         return;
     }
     int neededItem = item.getCraftType() == 1 ? CLAY : (int) CLAY_ITEMS[item.getCraftItem()][0];
     string s = item.getCraftType() == 1 ? "You mould the clay into a " + item.getMessage() : "You bake the " + item.getMessage() + " in the oven";
     string s1 = item.getCraftType() == 1 ? "You need some soft clay to mould a " + item.getMessage() : "You need a pre-made " + item.getMessage() + " to put in the oven";
     int animation = item.getCraftType() == 1 ? 883 : 899;
     if (p.getSkills().getGreaterLevel(Skills.SKILL.CRAFTING) < item.getLevel()) {
         p.getPackets().sendMessage("You need a Crafting level of " + item.getLevel() + " to make a " + item.getMessage() + ".");
         Crafting.resetCrafting(p);
         return;
     }
     if (!p.getInventory().hasItem(neededItem)) {
         p.getPackets().sendMessage(s1 + ".");
         Crafting.resetCrafting(p);
         return;
     }
     p.getPackets().closeInterfaces();
     if (p.getInventory().deleteItem(neededItem)) {
         if (p.getInventory().addItem(item.getFinishedItem())) {
             p.getSkills().addXp(Skills.SKILL.CRAFTING, item.getXp());
             p.getPackets().sendMessage(s + ".");
             p.setLastAnimation(new Animation(animation));
         }
     }
     item.decreaseAmount();
     if (item.getAmount() >= 1) {
         Event craftMoreClayEvent = new Event(1500);
         craftMoreClayEvent.setAction(() =>
         {
             craftClay(p, -1, -1, -1, false);
             craftMoreClayEvent.stop();
         });
         Server.registerEvent(craftMoreClayEvent);
     }
 }
Пример #9
0
        public GrandExchange()
        {
            buyOffers = new Dictionary<int, GEItem[]>();
            sellOffers = new Dictionary<int, GEItem[]>();

            /* Load grand exchange items */
            Console.WriteLine("Loading Grand Exchange Items");
            try
            { //TODO: Convert to ADO.NET / MDB clientside database.
                if (File.Exists(misc.getServerPath() + @"\buyOffers.xml")) {
                    //Deserialize text file to a new object.
                    StreamReader objStreamReader = new StreamReader(misc.getServerPath() + @"\buyOffers.xml");
                    XmlSerializer serializer = new XmlSerializer(typeof(GEDictionaryWrapper), new Type[] { typeof(BuyOffer) });
                    GEDictionaryWrapper geDictionaryWrapper = (GEDictionaryWrapper)serializer.Deserialize(objStreamReader);
                    objStreamReader.Close();
                    buyOffers = geDictionaryWrapper.GetMap();
                    Console.WriteLine("Loaded " + buyOffers.Count + " buy offers in Grand Exchange");
                }
                if (File.Exists(misc.getServerPath() + @"\sellOffers.xml"))
                {
                    //Deserialize text file to a new object.
                    StreamReader objStreamReader = new StreamReader(misc.getServerPath() + @"\sellOffers.xml");
                    XmlSerializer serializer = new XmlSerializer(typeof(GEDictionaryWrapper), new Type[] { typeof(SellOffer) });
                    GEDictionaryWrapper geDictionaryWrapper = (GEDictionaryWrapper)serializer.Deserialize(objStreamReader);
                    objStreamReader.Close();
                    sellOffers = geDictionaryWrapper.GetMap();
                    Console.WriteLine("Loaded " + sellOffers.Count + " sell offers in Grand Exchange");
                }

            }
            catch (Exception e)
            {
                misc.WriteError(e.Message);
            }

            Event startGEEvent = new Event(5000);
            startGEEvent.setAction(() =>
            {
                processSales();
            });
            Server.registerEvent(startGEEvent);
            /*
             * This saves the grand exchange every 60 seconds.
             * Decided not to make it a event because it will impact performance when
             * grand exchange really packs up, as it does I/O operations to harddrive.
             */
            new Thread(saveGrandExchange).Start();
        }
Пример #10
0
 public static void cutGem(Player p, int index, int amount, bool newCut)
 {
     index -= 50;
     if (newCut) {
         p.setTemporaryAttribute("craftItem", new CraftItem(5, index, amount, (double) GEMS[index][3], (int) GEMS[index][1], (string) GEMS[index][4], (int) GEMS[index][2]));
     }
     CraftItem item = (CraftItem) p.getTemporaryAttribute("craftItem");
     if (item == null || p == null || item.getAmount() <= 0 || item.getCraftType() != 5) {
         Crafting.resetCrafting(p);
         return;
     }
     p.getPackets().closeInterfaces();
     if (!p.getInventory().hasItem(CHISEL)) {
         p.getPackets().sendMessage("You cannot cut gems without a chisel.");
         Crafting.resetCrafting(p);
         return;
     }
     if (!p.getInventory().hasItem((int)GEMS[item.getCraftItem()][0])) {
         if (newCut) {
             p.getPackets().sendMessage("You have no " + item.getMessage() + " to cut.");
         } else {
             p.getPackets().sendMessage("You have no more " + item.getMessage() + "'s to cut.");
         }
         Crafting.resetCrafting(p);
         return;
     }
     if (p.getSkills().getGreaterLevel(Skills.SKILL.CRAFTING) < item.getLevel()) {
         p.getPackets().sendMessage("You need a Crafting level of " + item.getLevel() + " to cut that gem.");
         Crafting.resetCrafting(p);
         return;
     }
     if (p.getInventory().deleteItem((int)GEMS[item.getCraftItem()][0])) {
         p.getInventory().addItem(item.getFinishedItem());
         p.getSkills().addXp(Skills.SKILL.CRAFTING, item.getXp());
         p.setLastAnimation(new Animation((int) GEMS[item.getCraftItem()][5]));
         p.getPackets().sendMessage("You cut the " + item.getMessage() + ".");
     }
     item.decreaseAmount();
     if (item.getAmount() >= 1) {
         Event cutMoreGemEvent = new Event(1500);
         cutMoreGemEvent.setAction(() => {
             cutGem(p, -1, -1, false);
             cutMoreGemEvent.stop();
         });
         Server.registerEvent(cutMoreGemEvent);
     }
 }
Пример #11
0
        public void fireCannon()
        {
            if (firing) {
                loadCannon();
                return;
            }

            firing = true;
            int cannonTurnAnimation = 515;
            Event attemptFireCannonEvent = new Event(1000);
            attemptFireCannonEvent.setAction(() => {
                if (!firing)
                {
                    attemptFireCannonEvent.stop();
                    return;
                }
                p.getPackets().newObjectAnimation(cannonLocation, cannonTurnAnimation);
                Event fireCannonEvent = new Event(600);
                fireCannonEvent.setAction(() => {
                    if (!firing)
                    {
                        fireCannonEvent.stop();
                        return;
                    }
                    if (stopCannon && cannonTurnAnimation == 514)
                    {
                        cannonTurnAnimation = 514;
                        fireCannonEvent.stop();
                        firing = false;
                        return;
                    }
                    if (!stopCannon) {
                        if (checkHitTarget())
                            checkCannonballs();
                    }
                    if (direction++ == 7)
                        direction = 0;
                    if (++cannonTurnAnimation > 521)
                        cannonTurnAnimation = 514;
                   fireCannonEvent.stop();
                });
                Server.registerEvent(fireCannonEvent);
            });
            Server.registerEvent(attemptFireCannonEvent);
        }
Пример #12
0
 public static void newSilverItem(Player p, int amount, int index, bool newCraft)
 {
     index -= 120;
     if (newCraft) {
         p.setTemporaryAttribute("craftItem", new CraftItem(3, index, amount, (double) SILVER_ITEMS[index][3], (int) SILVER_ITEMS[index][0], (string) SILVER_ITEMS[index][4], (int) SILVER_ITEMS[index][2]));
     }
     CraftItem item = (CraftItem) p.getTemporaryAttribute("craftItem");
     if (item == null || p == null || item.getAmount() <= 0 || item.getCraftType() != 3) {
         Crafting.resetCrafting(p);
         return;
     }
     p.getPackets().closeInterfaces();
     string s = item.getCraftItem() == 0 ? "an" : "a";
     if (!p.getInventory().hasItem((int)SILVER_ITEMS[item.getCraftItem()][1])) {
         p.getPackets().sendMessage("You need " + s + " " + item.getMessage() + " mould to make that.");
         Crafting.resetCrafting(p);
         return;
     }
     if (!p.getInventory().hasItem(SILVER_BAR)) {
         p.getPackets().sendMessage("You don't have a Silver bar.");
         Crafting.resetCrafting(p);
         return;
     }
     if (p.getSkills().getGreaterLevel(Skills.SKILL.CRAFTING) < item.getLevel()) {
         p.getPackets().sendMessage("You need a Crafting level of " + item.getLevel() + " to smelt that.");
         Crafting.resetCrafting(p);
         return;
     }
     if (p.getInventory().deleteItem(SILVER_BAR)) {
         p.getInventory().addItem(item.getFinishedItem());
         p.getSkills().addXp(Skills.SKILL.CRAFTING, item.getXp());
         p.setLastAnimation(new Animation(3243));
         p.getPackets().sendMessage("You smelt the Silver bar in to " + s + " " + item.getMessage() + ".");
     }
     item.decreaseAmount();
     if (item.getAmount() >= 1) {
         Event makeMoreSilverItemEvent = new Event(1500);
         makeMoreSilverItemEvent.setAction(() =>
         {
             newSilverItem(p, -1, -1, false);
             makeMoreSilverItemEvent.stop();
         });
         Server.registerEvent(makeMoreSilverItemEvent);
     }
 }
Пример #13
0
 public static bool freezeTarget(int i, Entity target)
 {
     if ((i != 34 && i != 36 && i != 40 && i != 19 && i != 23 && i != 27 && i != 31) || target.isFrozen()) {
         return false;
     }
     int delay = getFreezeDelay(i);
     target.setFrozen(true);
     if (target is Player) {
         ((Player)target).getPackets().sendMessage("You have been frozen!");
         ((Player)target).getWalkingQueue().resetWalkingQueue();
     }
     Event unFreezeEvent = new Event(delay);
     unFreezeEvent.setAction(() => {
         unFreezeEvent.stop();
         target.setFrozen(false);
     });
     Server.registerEvent(unFreezeEvent);
     return true;
 }
Пример #14
0
 public void newCannon()
 {
     setupTime = Environment.TickCount;
     Event setupNewCannonEvent = new Event(1000);
     setupNewCannonEvent.setAction(() => {
         string prefixMsg = (constructionStage == 0) ? "You place the " : "You add the ";
         string suffixMsg = (constructionStage == 0) ? " on the ground." : ".";
         if (p.getInventory().deleteItem(CANNON_PIECES[constructionStage]))
         {
             p.getPackets().createObject(CANNON_OBJECTS[constructionStage], cannonLocation, 0, 10);
             p.getPackets().sendMessage(prefixMsg + CONSTRUCTION_MESSAGE[constructionStage] + suffixMsg);
             if (++constructionStage >= 4) {
                 constructionStage--;
                 setupNewCannonEvent.stop();
                 return;
             }
             p.setLastAnimation(new Animation(827));
         } else {
             setupNewCannonEvent.stop();
         }
     });
     Server.registerEvent(setupNewCannonEvent);
 }
Пример #15
0
 private static void thieveStall(Player p, int index, ushort stallId, int x, int y)
 {
     int stallFace = Server.getGlobalObjects().getFace(stallId, new Location(x, y, 0));
     int[] areaCoords = new int[4];
     if (index == 2 || index == 4 || index == 5 || index == 12 || index == 13) { // Ape atoll stalls
         areaCoords[0] = x - 1;
         areaCoords[1] = y - 1;
         areaCoords[2] = x + 1;
         areaCoords[3] = y + 1;
     } else {
         areaCoords = getAreaCoords(stallFace, x, y);
     }
     AreaEvent thieveStallAreaEvent = new AreaEvent(p, areaCoords[0], areaCoords[1], areaCoords[2], areaCoords[3]);
     thieveStallAreaEvent.setAction(() => {
         if (!canThieveStall(p, index, stallId, x, y)) {
             return;
         }
         p.setLastAnimation(new Animation(833));
         Event thieveStallEvent = new Event(1000);
         thieveStallEvent.setAction(() => {
             thieveStallEvent.stop();
             if (Server.getGlobalObjects().originalObjectExists(stallId, new Location(x, y, 0))) {
                 Server.getGlobalObjects().lowerHealth(stallId, new Location(x, y, 0));
                 p.getSkills().addXp(Skills.SKILL.THIEVING, STALL_XP[index]);
                 int rewardIndex = misc.random(STALL_REWARD[index].Length - 1);
                 int reward = STALL_REWARD[index][rewardIndex];
                 if (index == 7) { // Seed stall
                     if (misc.random(15) == 0) {
                         reward = HERB_SEEDS[misc.random(HERB_SEEDS.Length - 1)];
                     }
                 } else if (index == 13) { // Scimitar stall
                     if (misc.random(75) == 0) {
                         reward = 1333; // Rune scimitar.
                     } else if (misc.random(250) == 0) {
                         reward = 4587; // Dragon scimitar.
                     }
                 }
                 int amount = misc.random(STALL_REWARD_AMOUNTS[index][rewardIndex]);
                 if (amount <= 0) {
                     amount = 1;
                 }
                 p.getInventory().addItem(reward, amount);
             }
         });
         Server.registerEvent(thieveStallEvent);
     });
     Server.registerCoordinateEvent(thieveStallAreaEvent);
 }
Пример #16
0
        private static void thieveNpc(Player p, Npc npc, int index)
        {
            AreaEvent thieveNpcAreaEvent = new AreaEvent(p, npc.getLocation().getX()-1, npc.getLocation().getY()-1, npc.getLocation().getX()+1, npc.getLocation().getY()+1);
            thieveNpcAreaEvent.setAction(() => {
                if (!canThieveNpc(p, npc, index)) {
                    return;
                }
                p.setFaceLocation(npc.getLocation());
                p.setLastAnimation(new Animation(881));
                p.getPackets().sendMessage("You attempt to pick the " + NPC_NAMES[index] + " pocket...");
                p.setTemporaryAttribute("lastPickPocket", Environment.TickCount);

                Event thieveNpcEvent = new Event(1000);
                thieveNpcEvent.setAction(() => {
                    thieveNpcEvent.stop();
                    if (!p.getLocation().withinDistance(npc.getLocation(), 2)) {
                        return;
                    }
                    if (successfulThieve(p, index, false)) {
                        int rewardIndex = misc.random(NPC_REWARD[index].Length - 1);
                        int reward = NPC_REWARD[index][rewardIndex];
                        int rewardAmount = NPC_REWARD_AMOUNT[index][rewardIndex];
                        if (index == 7) { // Master farmer.
                            if (misc.random(15) == 0) {
                                reward = HERB_SEEDS[misc.random(HERB_SEEDS.Length - 1)];
                            }
                        }
                        p.getSkills().addXp(Skills.SKILL.THIEVING, NPC_XP[index]);
                        p.getInventory().addItem(reward, rewardAmount);
                        p.getPackets().sendMessage("You pick the " + NPC_NAMES[index] + " pocket.");
                    } else {
                        p.getWalkingQueue().resetWalkingQueue();
                        p.getPackets().sendMessage("You fail to pick the " + NPC_NAMES[index] + " pocket.");
                        p.getPackets().sendMessage("You've been stunned!");
                        npc.setForceText("What do you think you're doing?");
                        p.setTemporaryAttribute("unmovable", true);
                        p.setTemporaryAttribute("stunned", true);
                        p.setLastGraphics(new Graphics(80, 0, 100));
                        p.setLastAnimation(new Animation(p.getDefenceAnimation()));
                        p.hit(1);
                        npc.setFaceLocation(p.getLocation());
                        Event removeStunEvent = new Event(5000);
                        removeStunEvent.setAction(() => {
                            removeStunEvent.stop();
                            p.removeTemporaryAttribute("unmovable");
                            p.removeTemporaryAttribute("stunned");
                            p.setLastGraphics(new Graphics(65535));
                        });
                        Server.registerEvent(removeStunEvent);
                    }
                });
                Server.registerEvent(thieveNpcEvent);
            });
            Server.registerCoordinateEvent(thieveNpcAreaEvent);
        }
Пример #17
0
 private static void thieveChest(Player p, int index, ushort chestId, int x, int y)
 {
     AreaEvent thieveChestAreaEvent = new AreaEvent(p, x-1, y-1, x+1, y+1);
     thieveChestAreaEvent.setAction(() => {
         p.setFaceLocation(new Location(x, y, p.getLocation().getZ()));
         if (!canThieveChest(p, index, chestId, x, y)) {
             return;
         }
         p.getPackets().sendMessage("You attempt to pick the chest lock..");
         p.setLastAnimation(new Animation(833));
         Event thieveChestEvent = new Event(1000);
         thieveChestEvent.setAction(() => {
             thieveChestEvent.stop();
             if (misc.random(5) == 0) {
                 p.hit(p.getSkills().getMaxLevel(Skills.SKILL.HITPOINTS) / 10);
                 p.setForceText("Ouch!");
                 p.getPackets().sendMessage("You activate a trap whilst trying to pick the lock!");
                 return;
             }
             if (Server.getGlobalObjects().originalObjectExists(chestId, new Location(x, y, 0))) {
                 Server.getGlobalObjects().lowerHealth(chestId, new Location(x, y, 0));
                 for (int i = 0; i < CHEST_REWARD[index].Length; i++) {
                     p.getInventory().addItem(CHEST_REWARD[index][i], CHEST_REWARD_AMOUNTS[index][i]);
                 }
                 p.getSkills().addXp(Skills.SKILL.THIEVING, CHEST_XP[index]);
                 p.getPackets().sendMessage("You successfully pick the lock and loot the chest!");
             }
         });
         Server.registerEvent(thieveChestEvent);
     });
     Server.registerCoordinateEvent(thieveChestAreaEvent);
 }
Пример #18
0
 public static void craftNormalLeather(Player p, int index, int amount, bool newCraft)
 {
     index -= 28;
     if (newCraft) {
         p.setTemporaryAttribute("craftItem", new CraftItem(4, index, amount, (double) NORMAL_LEATHER[index][2], (int) NORMAL_LEATHER[index][0], (string) NORMAL_LEATHER[index][3], (int) NORMAL_LEATHER[index][1]));
     }
     CraftItem item = (CraftItem) p.getTemporaryAttribute("craftItem");
     if (item == null || p == null || item.getAmount() <= 0 || item.getCraftType() != 4 || item.getCraftItem() < 0) {
         Crafting.resetCrafting(p);
         return;
     }
     p.getPackets().closeInterfaces();
     if (!p.getInventory().hasItem(TANNED_HIDE[4])) {
         p.getPackets().sendMessage("You have no Leather.");
         Crafting.resetCrafting(p);
         return;
     }
     if (!p.getInventory().hasItem(NEEDLE)) {
         p.getPackets().sendMessage("You need a needle if you wish to craft leather.");
         Crafting.resetCrafting(p);
         return;
     }
     if (!p.getInventory().hasItem(THREAD)) {
         p.getPackets().sendMessage("You have no thread.");
         Crafting.resetCrafting(p);
         return;
     }
     if (p.getSkills().getGreaterLevel(Skills.SKILL.CRAFTING) < item.getLevel()) {
         p.getPackets().sendMessage("You need a Crafting level of " + item.getLevel() + " to craft that item.");
         Crafting.resetCrafting(p);
         return;
     }
     int i = item.getCraftItem();
     string s = i == 0 || i == 5 || i == 6 ? "a" : "a pair of";
     if (p.getInventory().deleteItem(THREAD) && p.getInventory().deleteItem(TANNED_HIDE[4])) {
         p.getInventory().addItem(item.getFinishedItem());
         p.getSkills().addXp(Skills.SKILL.CRAFTING, item.getXp());
         p.setLastAnimation(new Animation(1249));
         p.getPackets().sendMessage("You make " + s + " " + item.getMessage() + ".");
     }
     item.decreaseAmount();
     if (item.getAmount() >= 1) {
         Event craftMoreNormalLeather = new Event(1500);
         craftMoreNormalLeather.setAction(() => {
             craftNormalLeather(p, -1, -1, false);
             craftMoreNormalLeather.stop();
         });
         Server.registerEvent(craftMoreNormalLeather);
     }
 }
Пример #19
0
 protected static void applyMiasmicEffects(Player p, Entity target, int index)
 {
     if (index < 48 || index > 51) {
         return;
     }
     if (target.getMiasmicEffect() == 0) {
         target.setMiasmicEffect(index - 47);
         if (target is Player) {
             ((Player) target).getPackets().sendMessage("Your attack speed has been decreased!");
         }
         int delay = 0;
         switch(index) {
             case 48: delay = 12000; break; // Miasmic rush.
             case 49: delay = 24000; break;// Miasmic burst.
             case 50: delay = 36000; break;// Miasmic blitz.
             case 51: delay = 48000; break;// Miasmic barrage.
         }
         Event miasmicEffectRemoveEvent = new Event(delay);
         miasmicEffectRemoveEvent.setAction(() => {
             miasmicEffectRemoveEvent.stop();
             target.setMiasmicEffect(0);
         });
         Server.registerEvent(miasmicEffectRemoveEvent);
     }
 }
Пример #20
0
 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);
 }
Пример #21
0
        public static void fightCaveAttacks(Npc npc, Player p)
        {
            if (npc.isDead() || npc.isDestroyed() || p.isDead() || p.isDestroyed() || p.isDead() || !Location.inFightCave(p.getLocation()) || p.getTeleportTo() != null) {
                return;
            }
            int damage = misc.random(npc.getMaxHit());
            int prayer = p.getPrayers().getHeadIcon();
            int hitDelay = npc.getHitDelay();
            int animation = npc.getAttackAnimation();
            switch(npc.getId()) {
                case 2734: // Tz-Kih (lvl 22)
                case 2735:
                    if (prayer == PrayerData.MELEE) {
                        damage = 0;
                    }
                    break;

                case 2739: // Tz-Xil (lvl 90)
                case 2740:
                    if (prayer == PrayerData.RANGE) {
                        damage = 0;
                    }
                    p.getPackets().sendProjectile(npc.getLocation(), p.getLocation(), 32, 1616, 50, 40, 34, 50, p);
                    break;

                case 2741: // Yt-MejKot (lvl 180)
                case 2742:
                    if (prayer == PrayerData.MELEE) {
                        damage = 0;
                    }
                    // TODO healing
                    break;

                case 2743: // Ket-Zek (lvl 360)
                case 2744:
                    if (!p.getLocation().withinDistance(npc.getLocation(), 2)) {
                        hitDelay = 1600;
                        animation = 9266;
                        npc.setLastGraphics(new Graphics(1622));
                        damage = misc.random(49);
                        if (prayer == PrayerData.MAGIC) {
                            damage = 0;
                        }
                        Event sendProjectileToNpc = new Event(300);
                        sendProjectileToNpc.setAction(() => {
                            sendProjectileToNpc.stop();
                            p.getPackets().sendProjectile(npc.getLocation(), p.getLocation(), 32, 1623, 50, 40, 34, 80, p);
                        });
                        Server.registerEvent(sendProjectileToNpc);
                    } else {
                        damage = misc.random(64);
                        if (prayer == PrayerData.MELEE) {
                            damage = 0;
                        }
                    }
                    break;

                case 2745: // TzTok Jad (lvl 702)
                    doJadAttacks(p, npc);
                    break;
            }
            if (npc.getId() == 2745){
                return;
            }
            if (animation != 65535) {
                npc.setLastAnimation(new Animation(animation));
            }
            p.setLastAttacked(Environment.TickCount);
            npc.setLastAttack(Environment.TickCount);
            p.setAttacker(npc);
            npc.resetCombatTurns();
            if (damage > p.getHp()) {
                damage = p.getHp();
            }
            int npcId = npc.getId();

            Event losePrayerFightingEvent = new Event(hitDelay);
            losePrayerFightingEvent.setAction(() => {
                losePrayerFightingEvent.stop();
                if (!Location.inFightCave(p.getLocation()) || p.getTeleportTo() != null) {
                    return;
                }
                if (npcId == 2734 || npcId == 2735) {
                    int prayerLevel = p.getSkills().getCurLevel(Skills.SKILL.PRAYER);
                    int newPrayerLevel = prayerLevel -= (damage + 1);
                    if (newPrayerLevel <= 0) {
                        newPrayerLevel = 0;
                    }
                    p.getSkills().setCurLevel(Skills.SKILL.PRAYER, newPrayerLevel);
                    p.getPackets().sendSkillLevel(Skills.SKILL.PRAYER);
                } else if (npcId == 2743 || npcId == 2744) {
                    if (misc.random(1) == 0) {
                        p.setLastGraphics(new Graphics(1624, 0));
                    }
                }
                if ((p.getCombatTurns() > 2 || p.getCombatTurns() < 0)) {
                    p.setLastAnimation(new Animation(p.getDefenceAnimation()));
                }
                p.hit(damage);
            });
            Server.registerEvent(losePrayerFightingEvent);
        }
Пример #22
0
        public static void rangeCombatLoop(Entity killer, Entity target)
        {
            if (!hasValidBowArrow(killer)) {
                killer.setTarget(null);
                return;
            }
            int hitDelay = getHitDelay(killer, target);
            if (killer is Player) {
                ((Player)killer).getWalkingQueue().resetWalkingQueue();
                ((Player)killer).getPackets().closeInterfaces();
                ((Player)killer).getPackets().clearMapFlag();
                ((Player)killer).setLastCombatType(Combat.CombatType.RANGE);
            }
            int drawback = getDrawbackGraphic(killer);
            if (drawback != -1) {
                killer.setLastGraphics(new Graphics(drawback, 0, 90));
            }
            displayProjectile(killer, target);
            deductArrow(killer);
            int arrowType = getArrowType(killer);
            int usingBow = ((Player)killer).getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON);
            int usingArrows = ((Player)killer).getEquipment().getItemInSlot(ItemData.EQUIP.ARROWS);
            int damage1 = misc.random((int)getDamage((Player) killer, target, usingBow, usingArrows));
            int damage2 = usingBow == DARK_BOW ? misc.random((int)getDamage((Player) killer, target, usingBow, usingArrows)) : 0;

            /*
             * If the damage of the first attack will kill the target.
             * Make sure the target doesn't die from that first attack.
             * But instead split the attack into two attacks.
             */
            if (damage1 >= target.getHp()) {
                int randomHp = misc.random(target.getHp());
                damage1 = randomHp;
                damage2 = target.getHp() - randomHp;
            } else {
                int hpRemaining = target.getHp() - damage1;
                if (damage2 > hpRemaining) {
                    damage2 = hpRemaining;
                }
            }
            int totalDamage = damage1 + damage2;

            Combat.checkIfWillDie(target, (damage1 + damage2));
            Event doRangedAttackEvent = new Event(hitDelay);
            doRangedAttackEvent.setAction(() => {
                int damage = damage1;
                if (getBowType(killer) == BOW_TYPE.CROSSBOW) {
                    damage = applyBoltGraphic((Player)killer, target, damage1, arrowType);
                    totalDamage = damage + damage2;
                }
                if ((target.getCombatTurns() > 2 || target.getCombatTurns() < 0) && !target.isDead()) {
                    target.setLastAnimation(new Animation(target.getDefenceAnimation()));
                }
                target.hit(damage);
                Combat.addXp(killer, target, totalDamage);
                Combat.checkRecoil(killer, target, totalDamage);
                Combat.checkSmite(killer, target, totalDamage);
                Combat.checkVengeance(killer, target, totalDamage);
                if (killer is Player && arrowType != -1 && arrowType != BOLT_RACK) {
                    createGroundArrow(killer, target, arrowType);
                }
                doRangedAttackEvent.stop();
            });
            Server.registerEvent(doRangedAttackEvent);
            //If the bow you are using is a darkbow do a second attack and animation.
            if (getBowType(killer) == BOW_TYPE.DARK_BOW) {
                deductArrow(killer);
                Event displayProjectileEvent = new Event(200);
                displayProjectileEvent.setAction(() => {
                        displayProjectile(killer, target);
                        displayProjectileEvent.stop();
                });
                Server.registerEvent(displayProjectileEvent);

                Event shootArrowEvent = new Event(hitDelay+400);
                shootArrowEvent.setAction(() => {
                    target.hit(damage2);
                    if (killer is Player && arrowType != -1 && arrowType != BOLT_RACK) {
                        createGroundArrow(killer, target, arrowType);
                    }
                    shootArrowEvent.stop();
                });
                Server.registerEvent(shootArrowEvent);
            }
        }
Пример #23
0
 public static void stringAmulet(Player p, int index, int amount, bool newString)
 {
     index -= 100;
     if (newString) {
         p.setTemporaryAttribute("craftItem", new CraftItem(4, index, amount, STRINGING_XP, STRUNG_AMULETS[index][0], (string) GEMS[index][4] + " amulet", 1));
     }
     CraftItem item = (CraftItem) p.getTemporaryAttribute("craftItem");
     if (item == null || p == null || item.getAmount() <= 0 || item.getCraftType() != 4) {
         Crafting.resetCrafting(p);
         return;
     }
     p.getPackets().closeInterfaces();
     if (!p.getInventory().hasItem(BALL_OF_WOOL)) {
         p.getPackets().sendMessage("You do not have a Ball of wool.");
         Crafting.resetCrafting(p);
         return;
     }
     if (!p.getInventory().hasItem(STRUNG_AMULETS[item.getCraftItem()][1])) {
         string s = item.getCraftItem() == 1 || item.getCraftItem() == 5 ? "an" : "a";
         p.getPackets().sendMessage("You don't have " + s + " " + GEMS[item.getCraftItem()][4] + " unstrung amulet to string.");
         Crafting.resetCrafting(p);
         return;
     }
     if (p.getInventory().deleteItem(STRUNG_AMULETS[item.getCraftItem()][1]) && p.getInventory().deleteItem(BALL_OF_WOOL)) {
         p.getInventory().addItem(item.getFinishedItem());
         p.getSkills().addXp(Skills.SKILL.CRAFTING, STRINGING_XP);
         p.getPackets().sendMessage("You add a string to the amulet.");
     }
     item.decreaseAmount();
     if (item.getAmount() >= 1) {
         Event stringMoreAmuletEvent = new Event(1000);
         stringMoreAmuletEvent.setAction(() => {
                 stringAmulet(p, -1, -1, false);
                 stringMoreAmuletEvent.stop();
         });
         Server.registerEvent(stringMoreAmuletEvent);
     }
 }
Пример #24
0
        private static void summonJadHealers(Player p,  Npc jad)
        {
            for (int i = 0; i < 4; i++) {
                Npc npc = new Npc(2746);
                Location minCoords = new Location((20000 + 2363) + (200 * p.getIndex()), 25502, 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(jad.getClientIndex());
                npc.setOwner(p);
                npc.getFollow().setFollowing(jad);
                npc.setTarget(null);
                Server.getNpcList().Add(npc);

                Event jadHealerEvent = new Event(2000);
                jadHealerEvent.setAction(() => {
                    if (npc.isDead() || npc.isHidden() || npc.isDestroyed()) {
                        jadHealerEvent.stop();
                        return;
                    }
                    if (npc.getLocation().withinDistance(jad.getLocation(), 2) && !npc.inCombat()) {
                        if (misc.random(7) == 0) {
                            jad.setLastGraphics(new Graphics(444));
                            npc.setLastAnimation(new Animation(9254));
                            int jadMaxHp = jad.getMaxHp();
                            jad.heal((int) (jadMaxHp * 0.5));
                        }
                    }
                });
                Server.registerEvent(jadHealerEvent);
            }
        }
Пример #25
0
        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(() => {
                        int hit = 0;
                        int prayer = p.getPrayers().getHeadIcon();
                        if (jadRangeAttackStatus == 0)
                        {
                            jadRangeAttackStatus++;
                            jadRangeAttackEvent.setTick(1500);
                            p.setLastGraphics(new Graphics(451));
                            if (prayer == PrayerData.RANGE) {
                                hit = 0;
                            } else {
                                hit = misc.random(96);
                            }
                        } else {
                            if (prayer != PrayerData.RANGE) {
                                hit = misc.random(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(() => {
                        int hit = 0;
                        int prayer = 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 (prayer == PrayerData.MAGIC) {
                                hit = 0;
                            } else {
                                hit = misc.random(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;
            }
        }
Пример #26
0
 public static void makeJewellery(Player p, int buttonId, int amount, bool newCraft)
 {
     int index = -1;
     if (newCraft) {
         int itemType = getIndex(buttonId, true);
         object[][] items = getItemArray(p, itemType);
         index = getIndex(buttonId, false);
         if (index == -1) {
             p.getPackets().closeInterfaces();
             return;
         }
         p.setTemporaryAttribute("craftItem", new CraftItem(itemType, index, amount, (double)items[index][2], (int)items[index][0], (string)items[index][3], (int)items[index][1]));
     }
     CraftItem item = (CraftItem) p.getTemporaryAttribute("craftItem");
     if (item == null || p == null || item.getAmount() <= 0) {
         Crafting.resetCrafting(p);
         p.getPackets().closeInterfaces();
         return;
     }
     p.getPackets().closeInterfaces();
     index = item.getCraftItem();
     Console.WriteLine(index);
     int index2 = index;
     string gemType = (string) GEMS[index2-1][4];
     string s = index == 3 ? "an" : "a";
     if (p.getSkills().getGreaterLevel(Skills.SKILL.CRAFTING) < item.getLevel()) {
         p.getPackets().sendMessage("You need a Crafting level of " + item.getLevel() + " to craft a " + gemType + " " + item.getMessage() + ".");
         Crafting.resetCrafting(p);
         return;
     }
     if (!p.getInventory().hasItem(JEWELLERY_INTERFACE_VARS[item.getCraftType()][0])) {
         p.getPackets().sendMessage("You need " + s + " " + item.getMessage() + " mould to craft that.");
         Crafting.resetCrafting(p);
         return;
     }
     if (!p.getInventory().hasItem(GOLD_BAR)) {
         p.getPackets().sendMessage("You need a Gold bar to craft an item of jewellery.");
         Crafting.resetCrafting(p);
         return;
     }
     if (index2 > 0) { // We dont need gems for gold bars
         if (!p.getInventory().hasItem((int) GEMS[index2-1][1])) {
             p.getPackets().sendMessage("You don't have a cut " + (string) GEMS[index2-1][4] + ".");
             Crafting.resetCrafting(p);
             return;
         }
     }
     if (p.getInventory().deleteItem(GOLD_BAR)) {
         if (index2 > 0) {
             if (!p.getInventory().deleteItem((int) GEMS[index2-1][1])) {
                 return;
             }
         }
         p.setLastAnimation(new Animation(3243));
         p.getInventory().addItem(item.getFinishedItem());
         p.getSkills().addXp(Skills.SKILL.CRAFTING, item.getXp());
         string message = index2 == 0 ? "You smelt the gold bar into a Gold " + item.getMessage() : "You fuse the Gold bar and " + (string) GEMS[index2-1][4] + " together, and create a " + (string) GEMS[index2-1][4] + " " + item.getMessage();
         p.getPackets().sendMessage(message + ".");
     }
     item.decreaseAmount();
     if (item.getAmount() >= 1) {
         Event makeMoreJewelleryEvent = new Event(1500);
         makeMoreJewelleryEvent.setAction(() => {
             makeJewellery(p, -1, -1, false);
             makeMoreJewelleryEvent.stop();
         });
         Server.registerEvent(makeMoreJewelleryEvent);
     }
 }
Пример #27
0
        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 totalDamage = 0;
            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().getHeadIcon() == PrayerData.RANGE;
            }
            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.getMaxHit(p, 20) / 2) && damage2 <= (CombatFormula.getMaxHit(p, 20) / 2)) {
                            damage = (CombatFormula.getMaxHit(p, 20) / 2) + (misc.randomDouble() * CombatFormula.getMaxHit(p, 20)) / 2);
                            damage2 = (CombatFormula.getMaxHit(p, 20) / 2) + (misc.randomDouble() * CombatFormula.getMaxHit(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;
                    break;

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

                case 11698: // Saradomin godsword.
                    killer.setLastGraphics(new Graphics(1220, 0, 100));
                    killer.setLastAnimation(new Animation(7071));
                    int newHp = (int) (damage * 0.50);
                    int newPrayer = (int) (damage * 0.25);
                    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().getOverheadPrayer() >= 1 && ((Player) target).getPrayers().getOverheadPrayer() <= 3) {
                            ((Player) target).getPrayers().setOverheadPrayer(0);
                            ((Player) target).getPrayers().setHeadIcon(-1);
                            ((Player) target).getPackets().sendMessage("The Dragon scimitar slashes through your prayer protection!");
                            ((Player) target).getPackets().sendConfig(95, 0);
                            ((Player) target).getPackets().sendConfig(97, 0);
                            ((Player) target).getPackets().sendConfig(98, 0);
                            ((Player) target).getPackets().sendConfig(99, 0);
                            ((Player) target).getPackets().sendConfig(100, 0);
                            ((Player) target).getPackets().sendConfig(96, 0);
                        }
                    }
                    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 = (int) Math.Floor(damage);
                    damage2 = (int) Math.Floor(damage * 0.50);
                    damage3 = (int) Math.Floor(damage2 * 0.50);
                    damage4 = (int) 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;
                    if (target is Player) {
                        int defenceLevel = ((Player) target).getSkills().getCurLevel(Skills.SKILL.DEFENCE);
                        int newDefence = (int)(defenceLevel * 0.30);
                        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;
                    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 = (int) CombatFormula.getRangeHit((Player)killer, target, usingBow, usingArrows);
                    damage2 = (int) CombatFormula.getRangeHit((Player)killer, target, usingBow, usingArrows);
                    damage *= 1.05;
                    damage2 *= 1.05;
                    if (usingRangePrayer) {
                        damage *= 0.60;
                        damage2 *= 0.60;
                    }
                    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((int)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 = (int) CombatFormula.getRangeHit((Player)killer, target, usingBow, usingArrows);
                    damage2 = (int) CombatFormula.getRangeHit((Player)killer, target, usingBow, usingArrows);
                    if (usingBow == 11235) { // Dark bow
                        if (usingArrows == 11212) { // Dragon arrows
                            minHit = usingRangePrayer ? 4 : 8;
                            damage *= 1.50;
                            damage2 *= 1.50;
                            if (damage < minHit) {
                                damage = minHit;
                            }
                            if (damage2 < minHit) {
                                damage2 = minHit;
                            }
                        } else { // Other arrow
                            minHit = usingRangePrayer ? 3 : 5;
                            damage *= 1.30;
                            damage2 *= 1.30;
                            if (damage < minHit) {
                                damage = minHit;
                            }
                            if (damage2 < minHit) {
                                damage2 = minHit;
                            }
                        }
                    }
                    if (usingRangePrayer) {
                        damage *= 0.60;
                        damage2 *= 0.60;
                    }
                    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((int)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.MELEE) {
                        damage = (int) (damage * 0.60);
                    }
                } else {
                    if (((Player) target).getPrayers().getHeadIcon() == PrayerData.RANGE) {
                        damage = (int) (damage * 0.60);
                    }
                }
            }
            damage = ((weapon == 4151) ? damage : (misc.randomDouble() * damage));
            damage2 = misc.randomDouble() * damage2;
            int d = (int)((damage == 0 && weapon != 11730) ? 0 : (damage + increasedMaxHit));
            int d2 = (int)damage2;
            int d3 = (int)damage3; // only used for d claws
            int d4 = (int)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;
            int totDamage = Convert.ToInt32(damage + damage2 + damage3 + damage4);
            Combat.checkIfWillDie(target, totDamage);
            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.checkRecoil(killer, target, totDamage);
                Combat.checkSmite(killer, target, totDamage);
                Combat.checkVengeance(killer, target, totDamage);
                Combat.addXp(killer, target, totDamage);
            });
            Server.registerEvent(hitEvent);
            return true;
        }
Пример #28
0
        protected bool checkHitTarget()
        {
            int cannonX = fakeCannonLocation.getX();
            int cannonY = fakeCannonLocation.getY();
            Npc[] npcsToAttack = new Npc[npcsInArea.Count];
            bool hit = false;
            foreach(Npc n in Server.getNpcList()) {
                hit = false;
                Location l = n.getLocation();
                if (n == null || n.isHidden() || n.isDead() || !n.getLocation().withinDistance(fakeCannonLocation, 8)) {
                    continue;
                }
                switch(direction) {
                    case 0: // North
                        hit = l.inArea(cannonX-1, cannonY, cannonX+1, cannonY+8);
                        break;

                    case 1: // North east
                        break;

                    case 2: // East:
                        hit = l.inArea(cannonX, cannonY-1, cannonX+8, cannonY+1);
                        break;

                    case 3: // South east
                        break;

                    case 4: // South
                        hit = l.inArea(cannonX-1, cannonY-8, cannonX+1, cannonY);
                        break;

                    case 5: // South west
                        break;

                    case 6: // West
                        hit = l.inArea(cannonX-8, cannonY-1, cannonX, cannonY+1);
                        break;

                    case 7: // North west
                        break;
                }
                if (hit) {
                    Npc npc = n;
                    p.getPackets().sendProjectile(fakeCannonLocation, n.getLocation(), 30, 53, 50, 38, 38, 40, n);
                    Event doCannonHitEvent = new Event(1000);
                    doCannonHitEvent.setAction(() => {
                        doCannonHitEvent.stop();
                        int damage = misc.random(30);
                        p.getSkills().addXp(Skills.SKILL.RANGE, damage * 2);
                        npc.hit(damage);
                        npc.setLastAnimation(new Animation(npc.getDefenceAnimation()));
                    });
                    Server.registerEvent(doCannonHitEvent);
                    return true;
                }
            }
            return false;
        }
Пример #29
0
 public void refresh()
 {
     getFriends().login();
     getPackets().sendConfig(171, !chat ? 1 : 0);
     getPackets().sendConfig(287, split ? 1 : 0);
     if (split) {
         getPackets().sendBlankClientScript(83, "s");
     }
     getPackets().sendConfig(170, !mouse ? 1 : 0);
     getPackets().sendConfig(427, aid ? 1 : 0);
     getPackets().sendConfig(172, !autoRetaliate ? 1 : 0);
     if (magicType != 1) {
         getPackets().sendTab(isHd() ? 99 : 89, magicType == 2 ? 193 : 430);
     }
     if (achievementDiaryTab) {
         getPackets().sendTab(isHd() ? 95 : 85, 259);
     }
     RuneCraft.toggleRuin(this, getEquipment().getItemInSlot(ItemData.EQUIP.HAT), RuneCraft.wearingTiara(this));
     getSpecialAttack().setSpecialAmount(specialAmount);
     setPoisonAmount(poisonAmount);
     if (poisonAmount > 0) {
         Server.registerEvent(new PoisonEvent((Entity) this, poisonAmount));
     }
     if (teleblockTime > 0) {
         if (teleblockTime > Environment.TickCount) {
             long delay = teleblockTime - Environment.TickCount;
             setTemporaryAttribute("teleblocked", true);
             Event removeTeleBlockEvent = new Event(delay);
             removeTeleBlockEvent.setAction(() =>
             {
                 removeTeleBlockEvent.stop();
                 removeTemporaryAttribute("teleblocked");
                 teleblockTime = 0;
             });
             Server.registerEvent(removeTeleBlockEvent);
         }
     }
     Farming.refreshPatches(this);
     getEquipment().refreshBonuses();
     if (fightCave != null) {
         fightCave.setPlayer(this);
         fightCave.resumeGame();
     }
     setSkullCycles(skullCycles); // This method updates the appearance, so have this last.
 }
Пример #30
0
        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;
            }
        }