Пример #1
0
 public static double getMeleeDefence(Player p, Entity e)
 {
     if(e is Npc) {
         return 0.0;
     }
     Player target = (Player) e;
     int defBonus = getHighestDefBonus(target);
     int defLevel = target.getSkills().getCurLevel(Skills.SKILL.DEFENCE);
     double power = (defLevel + defBonus) * 0.0085; // was 0.0095
     double amount = 1.160;
     if (defBonus > 180) {
         amount = 1.568;
     } else if (defBonus > 290) {
         amount = 2.480;
     } else if (defBonus > 355) {
         amount = 3.580;
     }
     power *= (defLevel * (power * 0.10)) + (defBonus * amount) * (power * 0.012);
     if (target.getPrayers().getDefencePrayer() == 1) {
         power *= 1.05;
     } else if (target.getPrayers().getDefencePrayer() == 2) {
         power *= 1.10;
     } else if (target.getPrayers().getDefencePrayer() == 3) {
         power *= 1.15;
     } else if (target.getPrayers().getSuperPrayer() == 1) {
         power *= 1.20;
     } else if (target.getPrayers().getSuperPrayer() == 2) {
         power *= 1.25;
     }
     if (wearingVerac(p)) {
         power = (defLevel * 0.890);
     }
     return power;
 }
Пример #2
0
        public void execute(Player player, string[] arguments)
        {
            //TODO: Possible TODO.
            //I guess this command is for testing where object should be placed to spawnedObjects.cfg / objectLocations.cfg?
              	        //Err I don't like this command too much as the objects spawned are fake..
            //gotta maybe add to WorldObjects, like SpawnNPC :S later.

            if (arguments.Length < 2)
            {
                player.getPackets().sendMessage("[SpawnObject command]: ::obj objectId face");
                return;
            }

            int objectId = 0;
            int face = 0;

            if(!int.TryParse(arguments[0], out objectId)) {
                player.getPackets().sendMessage("[SpawnObject command]: objectId is not a number ::obj objectId face");
                return;
            }

            if(!int.TryParse(arguments[1], out face)) {
                player.getPackets().sendMessage("[SpawnObject command]: face is not a number ::obj objectId face");
                return;
            }

            foreach(Player p in Server.getPlayerList()) {
                p.getPackets().createObject(objectId, player.getLocation(), face, 10);
            }
        }
Пример #3
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);
 }
Пример #4
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);
        }
Пример #5
0
 public Equipment(Player player)
 {
     for (int i = 0; i < slots.Length; i++) {
         slots[i] = new Item(-1, 0);
     }
     this.player = player;
 }
Пример #6
0
 public static int[] getProtectedItem1(Player p)
 {
     int[] protectedItem = new int[2];
     protectedItem[0] = -1;
     for (int i = 0; i < 28; i++) {
         if(p.getInventory().getSlot(i).itemId == -1) continue;
         int price = p.getInventory().getSlot(i).getDefinition().getPrice().getMaximumPrice();
         if ((price > ItemData.forId(protectedItem[0]).getPrice().getMaximumPrice()))
         {
             protectedItem[0] = p.getInventory().getSlot(i).getItemId();
             protectedItem[1] = INVENTORY;
         }
     }
     foreach (ItemData.EQUIP equip in Enum.GetValues(typeof(ItemData.EQUIP))) {
         if (equip == ItemData.EQUIP.NOTHING) continue;
         if (p.getEquipment().getSlot(equip).itemId == -1) continue;
         int price = p.getEquipment().getSlot(equip).getDefinition().getPrice().getMaximumPrice();
         if (price > ItemData.forId(protectedItem[0]).getPrice().getMaximumPrice())
         {
             protectedItem[0] = p.getEquipment().getSlot(equip).getItemId();
             protectedItem[1] = EQUIPMENT;
         }
     }
     return protectedItem;
 }
Пример #7
0
 public static void displayItemsInterface(Player p)
 {
     int amountToKeep = p.isSkulled() ? 0 : 3;
     if (p.getPrayers().isProtectItem()) {
         amountToKeep = p.isSkulled() ? 1 : 4;
     }
     int item1 = getProtectedItem1(p)[0];
     int item2 = getProtectedItem2(p)[0];
     int item3 = getProtectedItem3(p)[0];
     int item4 = amountToKeep == 4 ? getProtectedItem4(p)[0] : -1;
     if (amountToKeep == 1) {
         item2 = 65535;
         item3 = 65535;
         item3 = item1;
     }
     if (amountToKeep == 0) {
         item1 = 65535;
         item2 = 65535;
         item3 = 65535;
         item4 = 65535;
     }
     object[] opts = new object[]{17598720, 20221838, "You're marked with a <col=ff3333>skull<col=ff981f>.", 0, 1, item4, item1, item2, item3, /* Items to keep */ amountToKeep /* Items to keep */, 0};
     p.getPackets().displayInterface(102);
     p.getPackets().sendClientScript2(204, 118, opts, "iiooooiisii");
     p.getPackets().setRightClickOptions(1278, (102 * 65536) + 21, 0, 40);
     p.getPackets().setRightClickOptions(1278, (102 * 65536) + 18, 0, 4);
 }
Пример #8
0
        private int waypointWriteOffset = 0; //location where it can write next waypoint in array.

        #endregion Fields

        #region Constructors

        public WalkingQueue(Player player)
        {
            this.player = player;
            for(int i = 0; i < MAX_WALKING_WAYPOINTS; i++)
                walkingQueue[i] = new Waypoint(0, 0, -1);
            this.lastDirection = 6;
            resetWalkingQueue();
        }
Пример #9
0
        private void handleExamineNPC(Player player, Packet packet)
        {
            int npcId = packet.readUShort();
            if (npcId < 0 || npcId > NpcData.getTotalNpcDefinitions() || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null)
                return;

            player.getPackets().sendMessage(NpcData.forId(npcId).getExamine());
        }
Пример #10
0
        public void handlePacket(Player player, Packet packet)
        {
            switch(packet.getPacketId()) {
                case PacketHandlers.PacketId.EQUIP:
                    handleEquipItem(player, packet);
                    break;

                case PacketHandlers.PacketId.ITEM_ON_ITEM:
                    handleItemOnItem(player, packet);
                    break;

                case PacketHandlers.PacketId.INV_CLICK:
                    handleInvenClickItem(player, packet);
                    break;

                case PacketHandlers.PacketId.ITEM_ON_OBJECT:
                    handleItemOnObject(player, packet);
                    break;

                case PacketHandlers.PacketId.ITEM_ON_GROUND_ITEM:
                    handleItemOnGroundItem(player, packet);
                    break;

                case PacketHandlers.PacketId.INV_OPERATE:
                    handleOperateItem(player, packet);
                    break;

                case PacketHandlers.PacketId.INV_DROP:
                    handleDropItem(player, packet);
                    break;

                case PacketHandlers.PacketId.PICKUP:
                    handlePickupItem(player, packet);
                    break;

                case PacketHandlers.PacketId.INV_SWAP_SLOT:
                    handleSwapSlot(player, packet);
                    break;

                case PacketHandlers.PacketId.INV_SWAP_SLOT2:
                    handleSwapSlot2(player, packet);
                    break;

                case PacketHandlers.PacketId.INV_RIGHT_CLICK_OPTION1:
                    handleRightClickOne(player, packet);
                    break;

                case PacketHandlers.PacketId.INV_RIGHT_CLICK_OPTION2:
                    handleRightClickTwo(player, packet);
                    break;

                case PacketHandlers.PacketId.INV_EXAMINE_ITEM:
                    handleExamineItem(player, packet);
                    break;
            }
        }
Пример #11
0
 public static void antiTeleportMessage(Player p)
 {
     p.getPackets().sendNPCHead(2617, 242, 1);
     p.getPackets().modifyText("TzHaar-Mej-Jal", 242, 3);
     p.getPackets().modifyText("I cannot allow you to teleport from the fight cave.", 242, 4);
     p.getPackets().modifyText("In Tzhaar, you either win, or die!", 242, 5);
     p.getPackets().animateInterface(9827, 242, 1);
     p.getPackets().sendChatboxInterface2(242);
     p.getPackets().sendMessage("You are unable to teleport from the fight cave.");
 }
Пример #12
0
 public static bool betweenDoors(Player p)
 {
     for (int i = 0; i < DB.Length; i++) {
         if (p.getLocation().inArea(DB[i][0], DB[i][1], DB[i][2], DB[i][3]))
         {
             return true;
         }
     }
     return false;
 }
Пример #13
0
 public Patch[] getPatchesForPlayer(Player p, int min, int max)
 {
     int i = 0;
     Patch[] array = new Patch[4];
     for (int j = min; j <= max; j++) {
         Patch patch = patchExists(p, j);
         array[i++] = patch;
     }
     return array;
 }
Пример #14
0
 public static int getMagicHit(Player p, Entity target, int maxDamage)
 {
     double magicAttack = getMagicAttack(p);
     double magicDefence = getMagicDefence(target);
     if ((misc.randomDouble() * magicDefence) > (misc.randomDouble() * magicAttack))
     {
         return 0;
     }
     return maxDamage;
 }
Пример #15
0
 public Patch patchExists(Player p, int index)
 {
     foreach(Patch patch in patches) {
         if (patch.getOwnerName().Equals(p.getLoginDetails().getUsername())) {
             if (patch.getPatchIndex() == index) {
                 return patch;
             }
         }
     }
     return null;
 }
Пример #16
0
 public static void interactWithAliMorissaae(Player p, Npc n)
 {
     p.setEntityFocus(n.getClientIndex());
     AreaEvent interactWithAliMorissaaeAreaEvent = new AreaEvent(p, n.getLocation().getX() - 1, n.getLocation().getY() - 1, n.getLocation().getX() + 1, n.getLocation().getY() + 1);
     interactWithAliMorissaaeAreaEvent.setAction(() => {
         n.setFaceLocation(p.getLocation());
         p.setFaceLocation(n.getLocation());
         p.setEntityFocus(65535);
         showAliDialogue(p, 205);
     });
     Server.registerCoordinateEvent(interactWithAliMorissaaeAreaEvent);
 }
Пример #17
0
 public DwarfCannon(Player player)
 {
     p = player;
     cannonLocation = p.getLocation();
     fakeCannonLocation = new Location(cannonLocation.getX()+1, cannonLocation.getY()+1, cannonLocation.getY());
     firing = false;
     cannonballs = 0;
     constructionStage = 0;
     direction = 0;
     setNpcsInArea();
     newCannon();
 }
Пример #18
0
 public GroundItem(int id, int amount, Location location, Player owner)
     : base(id, amount)
 {
     this.location = location;
     this.owner = owner;
     respawn = false;
     this.dropTime = Environment.TickCount;
     if (owner != null)
     {
         ownerId = owner.getIndex();
     }
 }
Пример #19
0
 public AreaEvent(Player player, int x, int y, int x1, int y2)
     : base(0)
 {
     this.p = player;
     this.x = x;
     this.y = y;
     this.x1 = x1;
     this.y2 = y2;
     if (player != null)
     {
         player.setDistanceEvent(this);
     }
 }
Пример #20
0
 public static int[] getProtectedItem2(Player p)
 {
     int[] protectedItem = new int[2];
     protectedItem[0] = -1;
     int[] protectedItem1 = getProtectedItem1(p);
     bool save;
     for (int i = 0; i < 28; i++) {
         if (p.getInventory().getSlot(i).itemId == -1) continue;
         int amt = p.getInventory().getItemAmount(p.getInventory().getItemInSlot(i));
         int price = p.getInventory().getSlot(i).getDefinition().getPrice().getMaximumPrice();
         if (price > ItemData.forId(protectedItem[0]).getPrice().getMaximumPrice())
         {
             save = true;
             if (protectedItem1[1] == INVENTORY) {
                 if (protectedItem1[0] == p.getInventory().getItemInSlot(i)) {
                     if (amt < 2) {
                         save = false;
                     }
                 }
             }
             if (save) {
                 protectedItem[0] = p.getInventory().getSlot(i).getItemId();
                 protectedItem[1] = INVENTORY;
             }
         }
     }
        foreach (ItemData.EQUIP equip in Enum.GetValues(typeof(ItemData.EQUIP))) {
        if (equip == ItemData.EQUIP.NOTHING) continue;
        if (p.getEquipment().getSlot(equip).itemId == -1) continue;
        int price = p.getEquipment().getSlot(equip).getDefinition().getPrice().getMaximumPrice();
        int amt = p.getEquipment().getAmountInSlot(equip);
         if (price > ItemData.forId(protectedItem[0]).getPrice().getMaximumPrice())
         {
             save = true;
             if (protectedItem1[1] == EQUIPMENT) {
                 if (protectedItem1[0] == p.getEquipment().getItemInSlot(equip))
                 {
                     if (amt < 2) {
                         save = false;
                     }
                 }
             }
             if (save) {
                 protectedItem[0] = p.getEquipment().getSlot(equip).getItemId();
                 protectedItem[1] = EQUIPMENT;
             }
         }
     }
     return protectedItem;
 }
Пример #21
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);
 }
Пример #22
0
        public void execute(Player player, string[] arguments)
        {
            if(arguments.Length == 0) {
                player.getPackets().sendMessage("[Yell command]: what are you expecting.. to yell blank message?");
                return;
            }

            string yellMsg = string.Join(" ", arguments);

            foreach(Player p in Server.getPlayerList()) {
                if (p != null) {
                    p.getPackets().sendMessage(player.getLoginDetails().getUsername() + ": " + yellMsg);
                }
            }
        }
Пример #23
0
        public void execute(Player player, string[] arguments)
        {
            if (arguments.Length < 2)
            {
                player.getPackets().sendMessage("[SetLevel command]: ::setLevel skillId level or ::setLevel skillName level");
                return;
            }

            int skillId = -1;
            int newLevel = 1;
            if (!int.TryParse(arguments[1], out newLevel)) {
                player.getPackets().sendMessage("[SetLevel command]: ::setLevel skillId level or ::setLevel skillName level");
                return;
            }

            if (newLevel > 99) newLevel = 99;

            if (!int.TryParse(arguments[0], out skillId))
            {
                //string based skills
                arguments[0] = arguments[0].ToUpper();

                if(!Enum.IsDefined(typeof(Skills.SKILL), arguments[0])) {
                    player.getPackets().sendMessage("[SetLevel command]: wrong.. try like ::setlevel attack 99 or ::setlevel 0 99");
                    return;
                }
                try
                {
                    Skills.SKILL skillName = (Skills.SKILL)Enum.Parse(typeof(Skills.SKILL), arguments[0], true);
                    player.getSkills().setXp(skillName, 0);
                    player.getSkills().setCurLevel(skillName, newLevel);
                    player.getSkills().addXp(skillName, Skills.getXpForLevel(newLevel));
                    player.getPackets().sendSkillLevel(skillName);
                } catch (ArgumentException) {
                    player.getPackets().sendMessage("[SetLevel command]: wrong.. try like ::setlevel attack 99 or ::setlevel 0 99");
                }
            } else {
                if(!Enum.IsDefined(typeof(Skills.SKILL), skillId)) {
                    player.getPackets().sendMessage("[SetLevel command]: wrong.. try like ::setlevel attack 99 or ::setlevel 0 99");
                    return;
                }
                Skills.SKILL skillName = (Skills.SKILL)skillId;
                player.getSkills().setXp(skillName, 0);
                player.getSkills().setCurLevel(skillName, newLevel);
                player.getSkills().addXp(skillName, Skills.getXpForLevel(newLevel));
                player.getPackets().sendSkillLevel(skillName);
            }
        }
Пример #24
0
 /*
  * The config to remove roofs is 1270
  * The door is 6713
  *
  * Random door configs
  * CONFIG = 452    0
    CONFIG = 452    32
    CONFIG = 452    96
    CONFIG = 452    16480
    CONFIG = 452    278624
    CONFIG = 452    802912
    CONFIG = 452    2900064
    CONFIG = 452    2637920
    CONFIG = 452    2638944
    CONFIG = 452    2640992
    CONFIG = 452    2645088
    CONFIG = 452    2653280
    CONFIG = 452    2649184
  */
 public static bool enterCrypt(Player p)
 {
     for (int i = 0; i < MOUND_COORDS.Length; i++) {
         for (int j = 0; j < MOUND_COORDS[i].Length; j++) {
             if (p.getLocation().inArea(MOUND_COORDS[i][0], MOUND_COORDS[i][1], MOUND_COORDS[i][2], MOUND_COORDS[i][3]) && p.getLocation().getZ() == 0)
             {
                 p.teleport(new Location(STAIR_COORDS[i][0], STAIR_COORDS[i][1], 3));
                 if (p.getBarrowTunnel() == -1) {
                     p.setBarrowTunnel(misc.random(5));
                 }
                 return true;
             }
         }
     }
     return false;
 }
Пример #25
0
 private void handleFifthClickNPC(Player player, Packet packet)
 {
     int npcIndex = packet.readLEShort();
     if (npcIndex < 0 || npcIndex > Constants.MAX_NPCS || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null) {
         return;
     }
     Npc npc = Server.getNpcList()[npcIndex];
     if (npc == null || npc.isDestroyed()) {
         return;
     }
     Console.WriteLine("Fifth click NPC " + npc.getId());
     SkillHandler.resetAllSkills(player);
     if (Slayer.openPointsInterface(player, npc)) {
         return;
     }
 }
Пример #26
0
        public void execute(Player player, string[] arguments)
        {
            if (arguments.Length == 0)
            {
                player.getPackets().sendMessage("[Animation command]: ::emote emote_number");
                return;
            }

            int animation = 0;
            if (!int.TryParse(arguments[0], out animation))
            {
                player.getPackets().sendMessage("[Animation command]: ::emote emote_number");
                return;
            }

            player.setLastAnimation(new model.Animation(animation));
        }
Пример #27
0
 public static int getCryptIndex(Player p)
 {
     if (p.getLocation().inArea(3567, 9701, 3580, 9711)) {
         return VERAC;
     } else if (p.getLocation().inArea(3548, 9709, 3561, 9721)) {
         return DHAROK;
     } else if (p.getLocation().inArea(3549, 9691, 3562, 9706)) {
         return AHRIM;
     } else if (p.getLocation().inArea(3532, 9698, 3546, 9710)) {
         return GUTHAN;
     } else if (p.getLocation().inArea(3544, 9677, 3559, 9689)) {
         return KARIL;
     } else if (p.getLocation().inArea(3563, 9680, 3577, 9694)) {
         return TORAG;
     }
     return -1;
 }
Пример #28
0
        public void execute(Player player, string[] arguments)
        {
            if (arguments.Length == 0)
            {
                player.getPackets().sendMessage("[Height command]: ::height 0 [0,1,2,3] are possible");
                return;
            }

            int heightLevel = 0;
            if (!int.TryParse(arguments[0], out heightLevel))
            {
                player.getPackets().sendMessage("[Height command]: ::height 0 [0,1,2,3] are possible");
                return;
            }

            player.teleport(new Location(player.getLocation().getX(), player.getLocation().getY(), heightLevel));
        }
Пример #29
0
        public void execute(Player player, string[] arguments)
        {
            if (arguments.Length == 0)
            {
                player.getPackets().sendMessage("[Interface command]: ::inter interface_number");
                return;
            }

            int intreface = 0;
            if (!int.TryParse(arguments[0], out intreface))
            {
                player.getPackets().sendMessage("[Interface command]: ::inter interface_number");
                return;
            }

            player.getPackets().displayInterface(intreface);
        }
Пример #30
0
        public void execute(Player player, string[] arguments)
        {
            if (arguments.Length == 0)
            {
                player.getPackets().sendMessage("[PlayerAsNpc command]: ::pnpc npcId");
                return;
            }

            int npcId = 0;
            if (!int.TryParse(arguments[0], out npcId))
            {
                player.getPackets().sendMessage("[PlayerAsNpc command]: ::pnpc npcId [npcId is not a number error]");
                return;
            }

            player.getAppearance().setNpcId(npcId);
            player.getUpdateFlags().setAppearanceUpdateRequired(true);
        }