示例#1
0
        private static bool canTeleport(Player p, JewellerySlot js)
        {
            if (p.getTemporaryAttribute("teleporting") != null)
            {
                return(false);
            }
            if (p.getDuel() != null)
            {
                if (p.getDuel().getStatus() < 4)
                {
                    p.getDuel().declineDuel();
                }
                else if (p.getDuel().getStatus() == 5 || p.getDuel().getStatus() == 6)
                {
                    p.getPackets().sendMessage("You cannot teleport whilst in a duel.");
                    return(false);
                }
                else if (p.getDuel().getStatus() == 8)
                {
                    p.getDuel().recieveWinnings(p);
                }
            }
            int wildLvl = js.index == 1 || js.index == 2 ? 30 : 20;

            if (Location.inWilderness(p.getLocation()) && p.getLocation().wildernessLevel() >= wildLvl)
            {
                p.getPackets().sendMessage("You cannot teleport above level " + wildLvl + " wilderness!");
                return(false);
            }
            if (Location.inFightCave(p.getLocation()))
            {
                FightCave.antiTeleportMessage(p);
                return(false);
            }
            if (p.getTemporaryAttribute("teleblocked") != null)
            {
                p.getPackets().sendMessage("A magical force prevents you from teleporting!");
                return(false);
            }
            if (Location.inFightPits(p.getLocation()))
            {
                p.getPackets().sendMessage("You are unable to teleport from the fight pits.");
                return(false);
            }
            if (p.getTemporaryAttribute("unmovable") != null)
            {
                return(false);
            }
            return(true);
        }
示例#2
0
        public static bool teleport(Player p, int opt, JewellerySlot js)
        {
            if (js == null)
            {
                return(false);
            }
            if (js.index == -1 || js.index > 3 || opt > 6)
            {
                return(false);
            }
            if (!canTeleport(p, js))
            {
                p.getPackets().closeInterfaces();
                return(true);
            }
            if ((js.index == 2 && opt == 4) || (js.index != 2 && opt == 6))
            {
                p.getPackets().sendMessage("You stay where you are.");
                p.getPackets().closeInterfaces();
                return(true);
            }
            opt -= 2; // Used to get the 'index' from the button id.
            p.setLastGraphics(new Graphics(1684));
            p.setLastAnimation(new Animation(9603));
            p.getWalkingQueue().resetWalkingQueue();
            p.getPackets().clearMapFlag();
            p.setTemporaryAttribute("teleporting", true);
            p.setTemporaryAttribute("unmovable", true);
            p.removeTemporaryAttribute("autoCasting");
            p.removeTemporaryAttribute("lootedBarrowChest");
            p.setTarget(null);
            changeJewellery(p, js);
            int option = opt;

            p.getPackets().closeInterfaces();
            Event teleportEvent = new Event(2000);

            teleportEvent.setAction(() =>
            {
                teleportEvent.stop();
                p.teleport(new Location(TELEPORT_COORDINATES[js.index][option][0], TELEPORT_COORDINATES[js.index][option][1], 0));
                p.setLastAnimation(new Animation(65535));
                Teleport.resetTeleport(p);
                p.removeTemporaryAttribute("unmovable");
            });
            Server.registerEvent(teleportEvent);
            return(true);
        }
示例#3
0
 public static bool teleport(Player p, int opt, JewellerySlot js)
 {
     if (js == null)
     {
         return false;
     }
     if (js.index == -1 || js.index > 3 || opt > 6)
     {
         return false;
     }
     if (!canTeleport(p, js))
     {
         p.getPackets().closeInterfaces();
         return true;
     }
     if ((js.index == 2 && opt == 4) || (js.index != 2 && opt == 6))
     {
         p.getPackets().sendMessage("You stay where you are.");
         p.getPackets().closeInterfaces();
         return true;
     }
     opt -= 2; // Used to get the 'index' from the button id.
     p.setLastGraphics(new Graphics(1684));
     p.setLastAnimation(new Animation(9603));
     p.getWalkingQueue().resetWalkingQueue();
     p.getPackets().clearMapFlag();
     p.setTemporaryAttribute("teleporting", true);
     p.setTemporaryAttribute("unmovable", true);
     p.removeTemporaryAttribute("autoCasting");
     p.removeTemporaryAttribute("lootedBarrowChest");
     p.setTarget(null);
     changeJewellery(p, js);
     int option = opt;
     p.getPackets().closeInterfaces();
     Event teleportEvent = new Event(2000);
     teleportEvent.setAction(() =>
     {
         teleportEvent.stop();
         p.teleport(new Location(TELEPORT_COORDINATES[js.index][option][0], TELEPORT_COORDINATES[js.index][option][1], 0));
         p.setLastAnimation(new Animation(65535));
         Teleport.resetTeleport(p);
         p.removeTemporaryAttribute("unmovable");
     });
     Server.registerEvent(teleportEvent);
     return true;
 }
示例#4
0
 private static bool canTeleport(Player p, JewellerySlot js)
 {
     if (p.getTemporaryAttribute("teleporting") != null)
     {
         return false;
     }
     if (p.getDuel() != null)
     {
         if (p.getDuel().getStatus() < 4)
         {
             p.getDuel().declineDuel();
         }
         else if (p.getDuel().getStatus() == 5 || p.getDuel().getStatus() == 6)
         {
             p.getPackets().sendMessage("You cannot teleport whilst in a duel.");
             return false;
         }
         else if (p.getDuel().getStatus() == 8)
         {
             p.getDuel().recieveWinnings(p);
         }
     }
     int wildLvl = js.index == 1 || js.index == 2 ? 30 : 20;
     if (Location.inWilderness(p.getLocation()) && p.getLocation().wildernessLevel() >= wildLvl)
     {
         p.getPackets().sendMessage("You cannot teleport above level " + wildLvl + " wilderness!");
         return false;
     }
     if (Location.inFightCave(p.getLocation()))
     {
         FightCave.antiTeleportMessage(p);
         return false;
     }
     if (p.getTemporaryAttribute("teleblocked") != null)
     {
         p.getPackets().sendMessage("A magical force prevents you from teleporting!");
         return false;
     }
     if (Location.inFightPits(p.getLocation()))
     {
         p.getPackets().sendMessage("You are unable to teleport from the fight pits.");
         return false;
     }
     if (p.getTemporaryAttribute("unmovable") != null)
     {
         return false;
     }
     return true;
 }
示例#5
0
 protected static void changeJewellery(Player p, JewellerySlot js)
 {
     bool gloryAmulet = js.index < 2;
     bool newItem = true;
     string s = js.index == 2 ? "Ring of Dueling" : js.index == 3 ? "Games necklace" : "Amulet of Glory";
     for (int i = 0; i < JEWELLERY[js.index].Length; i++)
     {
         int charges = i;
         if (!js.wearing)
         {
             Item item = p.getInventory().getSlot(js.slot);
             if (item.getItemId() == JEWELLERY[js.index][i])
             {
                 if (gloryAmulet)
                 {
                     charges--;
                 }
                 string t = charges > 1 ? " charges" : " charge";
                 if (charges > 0)
                 {
                     p.getPackets().sendMessage("The " + s + " now has " + charges + t + " .");
                 }
                 else if (gloryAmulet && charges == 0)
                 {
                     p.getPackets().sendMessage("The Amulet of Glory has run out of charges.");
                 }
                 else if (!gloryAmulet && charges <= 1)
                 {
                     newItem = false;
                     p.getPackets().sendMessage("The " + s + " crumbles to dust.");
                     p.getInventory().deleteItem(item.getItemId(), js.slot, 1);
                 }
                 if (newItem)
                 {
                     item.setItemId(JEWELLERY[js.index][i - 1]);
                     p.getPackets().refreshInventory();
                 }
                 break;
             }
         }
         else
         {
             Item item = p.getEquipment().getSlot((ItemData.EQUIP)js.slot);
             if (item.getItemId() == JEWELLERY[js.index][i])
             {
                 if (gloryAmulet)
                 {
                     charges--;
                 }
                 string t = charges > 1 ? " charges" : " charge";
                 if (charges > 0)
                 {
                     p.getPackets().sendMessage("The " + s + " now has " + charges + t + " .");
                 }
                 else if (gloryAmulet && charges == 0)
                 {
                     p.getPackets().sendMessage("The Amulet of Glory has run out of charges.");
                 }
                 else if (!gloryAmulet && charges <= 1)
                 {
                     newItem = false;
                     p.getPackets().sendMessage("The " + s + " crumbles to dust.");
                     item.setItemId(-1);
                     item.setItemAmount(0);
                 }
                 if (newItem)
                 {
                     item.setItemId(JEWELLERY[js.index][i - 1]);
                 }
                 p.getPackets().refreshEquipment();
                 break;
             }
         }
     }
 }
示例#6
0
        protected static void changeJewellery(Player p, JewellerySlot js)
        {
            bool   gloryAmulet = js.index < 2;
            bool   newItem     = true;
            string s           = js.index == 2 ? "Ring of Dueling" : js.index == 3 ? "Games necklace" : "Amulet of Glory";

            for (int i = 0; i < JEWELLERY[js.index].Length; i++)
            {
                int charges = i;
                if (!js.wearing)
                {
                    Item item = p.getInventory().getSlot(js.slot);
                    if (item.getItemId() == JEWELLERY[js.index][i])
                    {
                        if (gloryAmulet)
                        {
                            charges--;
                        }
                        string t = charges > 1 ? " charges" : " charge";
                        if (charges > 0)
                        {
                            p.getPackets().sendMessage("The " + s + " now has " + charges + t + " .");
                        }
                        else if (gloryAmulet && charges == 0)
                        {
                            p.getPackets().sendMessage("The Amulet of Glory has run out of charges.");
                        }
                        else if (!gloryAmulet && charges <= 1)
                        {
                            newItem = false;
                            p.getPackets().sendMessage("The " + s + " crumbles to dust.");
                            p.getInventory().deleteItem(item.getItemId(), js.slot, 1);
                        }
                        if (newItem)
                        {
                            item.setItemId(JEWELLERY[js.index][i - 1]);
                            p.getPackets().refreshInventory();
                        }
                        break;
                    }
                }
                else
                {
                    Item item = p.getEquipment().getSlot((ItemData.EQUIP)js.slot);
                    if (item.getItemId() == JEWELLERY[js.index][i])
                    {
                        if (gloryAmulet)
                        {
                            charges--;
                        }
                        string t = charges > 1 ? " charges" : " charge";
                        if (charges > 0)
                        {
                            p.getPackets().sendMessage("The " + s + " now has " + charges + t + " .");
                        }
                        else if (gloryAmulet && charges == 0)
                        {
                            p.getPackets().sendMessage("The Amulet of Glory has run out of charges.");
                        }
                        else if (!gloryAmulet && charges <= 1)
                        {
                            newItem = false;
                            p.getPackets().sendMessage("The " + s + " crumbles to dust.");
                            item.setItemId(-1);
                            item.setItemAmount(0);
                        }
                        if (newItem)
                        {
                            item.setItemId(JEWELLERY[js.index][i - 1]);
                        }
                        p.getPackets().refreshEquipment();
                        break;
                    }
                }
            }
        }