Esempio n. 1
0
 public static void checkOverdose(Player p, Skills.SKILL skill)
 {
     if (p.getSkills().getCurLevel(skill) >= p.getSkills().getMaxLevel(skill))
     {
         p.getSkills().setCurLevel(skill, p.getSkills().getMaxLevel(skill));
     }
 }
Esempio n. 2
0
 public void execute(Player player, string[] arguments)
 {
     foreach (Skills.SKILL skill in Enum.GetValues(typeof(Skills.SKILL)))
     {
         player.getSkills().setCurLevel(skill, 99);
         player.getSkills().setXp(skill, Skills.getXpForLevel(99));
     }
     player.getPackets().sendSkillLevels();
     player.getUpdateFlags().setAppearanceUpdateRequired(true);
 }
Esempio n. 3
0
 public static double getMeleeAttack(Player p)
 {
     int attBonus = getHighestAttBonus(p);
     int attLevel = p.getSkills().getCurLevel(Skills.SKILL.ATTACK);
     double power = (attLevel + attBonus) * 0.01365;
     double amount = 1.260;
     power *= (attLevel * (power * 0.12)) + (attBonus * amount) * (power * 0.009);
     if (p.getPrayers().getAttackPrayer() == 1)
     {
         power *= 1.05;
     }
     else if (p.getPrayers().getAttackPrayer() == 2)
     {
         power *= 1.10;
     }
     else if (p.getPrayers().getAttackPrayer() == 3 || p.getPrayers().getSuperPrayer() == 1)
     {
         power *= 1.15;
     }
     else if (p.getPrayers().getSuperPrayer() == 2)
     {
         power *= 1.20;
     }
     if (wearingMeleeVoid(p))
     {
         power *= 1.10;
     }
     return power;
 }
Esempio n. 4
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);
            }
        }
Esempio n. 5
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);
 }
Esempio n. 6
0
        private static int applyBoltGraphic(Player killer, Entity target, int damage, int bolt)
        {
            int hit = Misc.random(10);
            if (hit != 0 || getBowType(killer) != BOW_TYPE.CROSSBOW)
            {
                return damage;
            }
            double maxDamage = getDamage((Player)killer, target, ((Player)killer).getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON), bolt);
            switch (bolt)
            {
                case 9236: // Opal.
                    target.setLastGraphics(new Graphics(749));
                    maxDamage *= 1.25;
                    break;

                case 9237: // Jade.
                    target.setLastGraphics(new Graphics(756));
                    //TODO Falling emote
                    break;

                case 9238: // Pearl.
                    target.setLastGraphics(new Graphics(750));
                    break;

                case 9239: // Topaz.
                    target.setLastGraphics(new Graphics(757, 0, 0));
                    if (target is Player)
                    {
                        int magicLevel = ((Player)target).getSkills().getCurLevel(Skills.SKILL.MAGIC);
                        if (magicLevel == 1)
                            return (int)maxDamage;
                        int magicLevelDeduction = Misc.random(1, 10);
                        magicLevelDeduction = Math.Min(magicLevelDeduction, (magicLevel - 1));
                        string s = magicLevelDeduction == 1 ? "" : "s";
                        ((Player)target).getSkills().setCurLevel(Skills.SKILL.MAGIC, magicLevel - magicLevelDeduction);
                        ((Player)target).getPackets().sendSkillLevel(Skills.SKILL.MAGIC);
                        ((Player)target).getPackets().sendMessage("Your Magic level has been reduced by " + magicLevelDeduction + " level" + s + " !");
                    }
                    break;

                case 9240: // Sapphire.
                    target.setLastGraphics(new Graphics(751));
                    if (target is Player)
                    {
                        int prayerLevel = ((Player)target).getSkills().getCurLevel(Skills.SKILL.PRAYER);
                        if (prayerLevel == 1)
                            return (int)maxDamage;
                        int prayerLevelDeduction = Misc.random(1, 10);
                        prayerLevelDeduction = Math.Min(prayerLevelDeduction, (prayerLevel - 1));
                        string s = prayerLevelDeduction == 1 ? "" : "s";
                        ((Player)target).getSkills().setCurLevel(Skills.SKILL.PRAYER, prayerLevel - prayerLevelDeduction);
                        ((Player)target).getPackets().sendSkillLevel(Skills.SKILL.PRAYER);
                        ((Player)target).getPackets().sendMessage("Your Prayer level has been lowered by " + prayerLevelDeduction + " level" + s + " !");
                        killer.getPackets().sendMessage("You steal " + prayerLevelDeduction + " Prayer point" + s + " from your opponent!");

                        int prayerLevelObtained = Math.Min(killer.getSkills().getCurLevel(Skills.SKILL.PRAYER) + prayerLevelDeduction, killer.getSkills().getMaxLevel(Skills.SKILL.PRAYER));
                        killer.getSkills().setCurLevel(Skills.SKILL.PRAYER, prayerLevelObtained);
                        killer.getPackets().sendSkillLevel(Skills.SKILL.PRAYER);
                    }
                    break;

                case 9241: // Emerald.
                    if (!target.isPoisoned())
                    {
                        Server.registerEvent(new PoisonEvent(target, 6));
                        target.setLastGraphics(new Graphics(752));
                    }
                    break;

                case 9242: // Ruby
                    target.setLastGraphics(new Graphics(754));
                    int currentHP = killer.getHp();
                    bool has11Percent = (currentHP * 0.11) < currentHP;
                    int removeFromOpponent = (int)(target.getHp() * 0.20); //20% off opponents HP.
                    if (has11Percent)
                    {
                        killer.hit((int)(currentHP * 0.10));
                        target.hit(removeFromOpponent);
                        killer.getPackets().sendMessage("You sacrifice some of your own health to deal more damage to your opponent!");
                    }
                    break;

                case 9243: // Diamond.
                    target.setLastGraphics(new Graphics(758));
                    maxDamage *= 1.15;
                    //TODO this affects opponents range defence for X minutes.
                    break;

                case 9244: // Dragon.
                    bool hitsFire = true;
                    if (target is Player)
                    {
                        int shield = ((Player)target).getEquipment().getItemInSlot(ItemData.EQUIP.SHIELD);
                        /*
                         * Opponent has anti-fire shield.
                         */
                        if (shield == 11283 || shield == 1540)
                        {
                            hitsFire = false;
                        }
                    }
                    else
                    {
                        int id = ((Npc)target).getId();
                        /*
                         * NPC is a dragon
                         */
                        if ((id >= 50 && id <= 55) || id == 941 || (id >= 1589 && id <= 1592) || id == 2642 || id == 3376
                            || id == 3588 || id == 3590 || (id >= 4665 && id <= 4684) || id == 5178 || id == 5362 || id == 5363)
                        {
                            hitsFire = false;
                        }
                    }
                    if (hitsFire)
                    {
                        target.setLastGraphics(new Graphics(756));
                        maxDamage *= 1.45; //increase damage by 145%.
                    }
                    break;

                case 9245: // Onyx.
                    target.setLastGraphics(new Graphics(753));
                    maxDamage *= 1.15;
                    killer.heal(Misc.random((int)(maxDamage * 0.60)));
                    break;
            }
            damage = Misc.random((int)maxDamage);
            if (Misc.random(2) == 0 && bolt != 9242)
            {
                damage = (int)((maxDamage * 0.50) + Misc.random((int)(maxDamage * 0.50)));
            }
            if (damage > target.getHp())
            {
                damage = target.getHp();
            }
            return damage;
        }
Esempio n. 7
0
 private static double getMagicAttack(Player p)
 {
     int magicBonus = p.getEquipment().getBonus(Equipment.BONUS.MAGIC_ATTACK);
     double magicLevel = Convert.ToDouble(p.getSkills().getCurLevel(Skills.SKILL.MAGIC));
     double power = 1.800;
     double amount = 0.0205;
     if (magicBonus >= 80)
     { // equivalent of max mage w/ zerker+whip
         amount = 0.0500;
     }
     else if (magicBonus >= 90)
     { // equivalent of max mage w/whip or mystic + ancient staff
         amount = 0.0780;
     }
     else if (magicBonus >= 105)
     { // equivalent of max mage w/ ancient staff
         amount = 0.920;
     }
     else if (magicBonus >= 115)
     { // equivalent of max mage w/ wand or better
         amount = 0.1110;
     }
     power *= (magicBonus * amount) + (magicLevel *= 0.0120);
     int prayer = p.getPrayers().getMagicPrayer();
     if (prayer > 0)
     {
         if (prayer == 1)
         {
             power *= 1.05;
         }
         else if (prayer == 2)
         {
             power *= 1.10;
         }
         else if (prayer == 3)
         {
             power *= 1.15;
         }
     }
     return power;
 }
Esempio n. 8
0
        public static void doDialogue(Player p, int status)
        {
            int newStatus = -1;
            p.getPackets().softCloseInterfaces();
            switch (status)
            {
                case 1:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("Ahoy Cap'n!", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 2;
                    break;

                case 2:
                    p.getPackets().sendNPCHead(437, 241, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 241, 3);
                    p.getPackets().modifyText("Ahoy there!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 3;
                    break;

                case 3:
                    p.getPackets().sendNPCHead(4535, 241, 1);
                    p.getPackets().modifyText("Parrot", 241, 3);
                    p.getPackets().modifyText("Avast ye scurvy swabs!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 1);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 4;
                    break;

                case 4:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("Huh?", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 5;
                    break;

                case 5:
                    p.getPackets().sendNPCHead(437, 241, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 241, 3);
                    p.getPackets().modifyText("Don't mind me parrot, he's Cracked Jenny's Tea Cup!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 6;
                    break;

                case 6:
                    p.getPackets().sendChatboxInterface2(235);
                    p.getPackets().modifyText("What is this place?", 235, 2);
                    p.getPackets().modifyText("What do i do in the arena?", 235, 3);
                    p.getPackets().modifyText("I'd like to use the Agility Arena, please.", 235, 4);
                    p.getPackets().modifyText("Could you sell me a Skillcape of Agility?.", 235, 5);
                    p.getPackets().modifyText("See you later.", 235, 6);
                    newStatus = 7;
                    break;

                case 7:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("What is this place?", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 8;
                    break;

                case 8:
                    p.getPackets().sendNPCHead(437, 242, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 242, 3);
                    p.getPackets().modifyText("This, me hearty, is the entrance to the Brimhaven", 242, 4);
                    p.getPackets().modifyText("Agility Arena!", 242, 5);
                    p.getPackets().animateInterface(9827, 242, 2);
                    p.getPackets().sendChatboxInterface2(242);
                    newStatus = 9;
                    break;

                case 9:
                    p.getPackets().sendNPCHead(437, 242, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 242, 3);
                    p.getPackets().modifyText("I were diggin for buried treasure when I found it!", 242, 4);
                    p.getPackets().modifyText("Amazed I was! It was a sight to behold!", 242, 5);
                    p.getPackets().animateInterface(9827, 242, 2);
                    p.getPackets().sendChatboxInterface2(242);
                    newStatus = 10;
                    break;

                case 10:
                    p.getPackets().sendNPCHead(4535, 241, 1);
                    p.getPackets().modifyText("Parrot", 241, 3);
                    p.getPackets().modifyText("Buried treasure!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 1);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 11;
                    break;

                case 11:
                    p.getPackets().sendNPCHead(437, 242, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 242, 3);
                    p.getPackets().modifyText("It were the biggest thing i'd ever seen! It must've been", 242, 4);
                    p.getPackets().modifyText("atleast a league from side to side!", 242, 5);
                    p.getPackets().animateInterface(9827, 242, 2);
                    p.getPackets().sendChatboxInterface2(242);
                    newStatus = 12;
                    break;

                case 12:
                    p.getPackets().sendNPCHead(437, 241, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 241, 3);
                    p.getPackets().modifyText("It made me list, I were that excited!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 13;
                    break;

                case 13:
                    p.getPackets().sendNPCHead(4535, 241, 1);
                    p.getPackets().modifyText("Parrot", 241, 3);
                    p.getPackets().modifyText("Get on with it!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 1);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 14;
                    break;

                case 14:
                    p.getPackets().sendNPCHead(437, 244, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 244, 3);
                    p.getPackets().modifyText("I'd found a huge cave with all these platforms. I reckon", 244, 4);
                    p.getPackets().modifyText("it be an ancient civilisation that made it. I had to be", 244, 5);
                    p.getPackets().modifyText("mighty careful as there was these traps everywhere!", 244, 6);
                    p.getPackets().modifyText("Dangerous it was!", 244, 7);
                    p.getPackets().animateInterface(9827, 244, 2);
                    p.getPackets().sendChatboxInterface2(244);
                    newStatus = 15;
                    break;

                case 15:
                    p.getPackets().sendNPCHead(4535, 241, 1);
                    p.getPackets().modifyText("Parrot", 241, 3);
                    p.getPackets().modifyText("Danger! Danger!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 1);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 16;
                    break;

                case 16:
                    p.getPackets().sendNPCHead(437, 241, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 241, 3);
                    p.getPackets().modifyText("Entrance is only " + AGILITY_ARENA_PRICE.ToString("#,##0") + " coins!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 6;
                    break;

                case 17:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("What do I do in the arena?", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 18;
                    break;

                case 18:
                    p.getPackets().sendNPCHead(437, 244, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 244, 3);
                    p.getPackets().modifyText("Well, me hearty, it's simple. Ye can cross between two", 244, 4);
                    p.getPackets().modifyText("platforms by using the traps or obstacles strung across", 244, 5);
                    p.getPackets().modifyText("'em. Try and make your way to the pillar that is", 244, 6);
                    p.getPackets().modifyText("indicated by the flashing arrow.", 244, 7);
                    p.getPackets().animateInterface(9827, 244, 2);
                    p.getPackets().sendChatboxInterface2(244);
                    newStatus = 19;
                    break;

                case 19:
                    p.getPackets().sendNPCHead(437, 243, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 243, 3);
                    p.getPackets().modifyText("Ye receive tickets for tagging more than one pillar in a", 243, 4);
                    p.getPackets().modifyText("row. So ye won't get a ticket from the first pillar but", 243, 5);
                    p.getPackets().modifyText("ye will for every platform ye tag in a row after that.", 243, 6);
                    p.getPackets().animateInterface(9827, 243, 2);
                    p.getPackets().sendChatboxInterface2(243);
                    newStatus = 20;
                    break;

                case 20:
                    p.getPackets().sendNPCHead(437, 244, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 244, 3);
                    p.getPackets().modifyText("If ye miss a platform ye will miss out on the next ticket", 244, 4);
                    p.getPackets().modifyText("so try and get every platform you can! When ye be", 244, 5);
                    p.getPackets().modifyText("done, take the tickets to Jackie over there and she'll", 244, 6);
                    p.getPackets().modifyText("exchange them for experience or items.", 244, 7);
                    p.getPackets().animateInterface(9827, 244, 2);
                    p.getPackets().sendChatboxInterface2(244);
                    newStatus = 21;
                    break;

                case 21:
                    p.getPackets().sendNPCHead(4535, 242, 1);
                    p.getPackets().modifyText("Parrot", 242, 3);
                    p.getPackets().modifyText("Tag when green light means tickets!", 242, 4);
                    p.getPackets().modifyText("Tag when red light means green light!", 242, 5);
                    p.getPackets().animateInterface(9827, 242, 1);
                    p.getPackets().sendChatboxInterface2(242);
                    newStatus = 22;
                    break;

                case 22:
                    p.getPackets().sendNPCHead(437, 241, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 241, 3);
                    p.getPackets().modifyText("Thanks me hearty!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 23;
                    break;

                case 23:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("Thanks!", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 6;
                    break;

                case 24:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("I'd like to use the Agility Arena, please.", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 25;
                    break;

                case 25:
                    string message = "";
                    if (p.hasPaidAgilityArena())
                    {
                        message = "Ye've already paid, so down ye goes...";
                    }
                    else
                    {
                        message = "Aye, Entrance be " + AGILITY_ARENA_PRICE.ToString("#,##0") + " coins.";
                        newStatus = 26;
                    }
                    p.getPackets().sendNPCHead(437, 241, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 241, 3);
                    p.getPackets().modifyText(message, 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    break;

                case 26:
                    p.getPackets().sendNPCHead(4535, 241, 1);
                    p.getPackets().modifyText("Parrot", 241, 3);
                    p.getPackets().modifyText("Pieces of eight!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 1);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 27;
                    break;

                case 27:
                    p.getPackets().sendNPCHead(437, 242, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 242, 3);
                    p.getPackets().modifyText("A word of warning me hearty! There are dangerous", 242, 4);
                    p.getPackets().modifyText("traps down there!", 242, 5);
                    p.getPackets().animateInterface(9827, 242, 2);
                    p.getPackets().sendChatboxInterface2(242);
                    newStatus = 28;
                    break;

                case 28:
                    if (!p.getInventory().hasItemAmount(995, AGILITY_ARENA_PRICE))
                    {
                        p.getPackets().sendPlayerHead(64, 2);
                        p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                        p.getPackets().modifyText("I don't have enough money on me at the moment..", 64, 4);
                        p.getPackets().animateInterface(9827, 64, 2);
                        p.getPackets().sendChatboxInterface2(64);
                        newStatus = 31;
                        break;
                    }
                    p.getPackets().modifyText("Ok, here's " + AGILITY_ARENA_PRICE.ToString("#,##0") + " coins.", 228, 2);
                    p.getPackets().modifyText("Never mind.", 228, 3);
                    p.getPackets().sendChatboxInterface(228);
                    newStatus = 29;
                    break;

                case 29:
                    if (p.getInventory().deleteItem(995, AGILITY_ARENA_PRICE))
                    {
                        p.setPaidAgilityArena(true);
                    }
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("Ok, here's " + AGILITY_ARENA_PRICE.ToString("#,##0") + " coins.", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 30;
                    break;

                case 30:
                    p.getPackets().sendMessage("You pay Cap'n Izzy " + AGILITY_ARENA_PRICE.ToString("#,##0") + " coins.");
                    p.getPackets().sendNPCHead(437, 241, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 241, 3);
                    p.getPackets().modifyText("May the wind be in ye sails!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    break;

                case 31:
                    p.getPackets().sendNPCHead(4535, 241, 1);
                    p.getPackets().modifyText("Parrot", 241, 3);
                    p.getPackets().modifyText("*Squawk*", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 1);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 32;
                    break;

                case 32:
                    p.getPackets().sendNPCHead(437, 241, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 241, 3);
                    p.getPackets().modifyText("No coins, no entrance!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    break;

                case 33:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("Never mind.", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    break;

                case 34:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("Could you sell me a Skillcape of Agility?", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 35;
                    break;

                case 35:
                    p.getPackets().sendNPCHead(437, 244, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 244, 3);
                    if (p.getSkills().getMaxLevel(Skills.SKILL.AGILITY) < 99)
                    {
                        p.getPackets().modifyText("Unfortunatly not. I may only sell the Skillcape of Agility", 244, 4);
                        p.getPackets().modifyText("to those that have conquered the obstacles of Runescape,", 244, 5);
                        p.getPackets().modifyText("can climb like a cat and run like the wind! which err..", 244, 6);
                        p.getPackets().modifyText("isnt you. Is there anything else?", 244, 7);
                        newStatus = 6;
                    }
                    else
                    {
                        p.getPackets().modifyText("Indeed! You have reached level 99 Agility and have", 244, 4);
                        p.getPackets().modifyText("become a master of dexterity. It would be a pleasure", 244, 5);
                        p.getPackets().modifyText("to sell you an Agility skillcape and hood for a sum of", 244, 6);
                        p.getPackets().modifyText(SkillHandler.SKILLCAPE_PRICE.ToString("#,##0") + " coins.", 244, 7);
                        newStatus = 36;
                    }
                    p.getPackets().animateInterface(9827, 244, 2);
                    p.getPackets().sendChatboxInterface2(244);
                    break;

                case 36:
                    p.getPackets().modifyText("I'll pay " + SkillHandler.SKILLCAPE_PRICE.ToString("#,##0") + " coins.", 228, 2);
                    p.getPackets().modifyText(SkillHandler.SKILLCAPE_PRICE.ToString("#,##0") + " is a crazy price!", 228, 3);
                    p.getPackets().sendChatboxInterface(228);
                    newStatus = 37;
                    break;

                case 37:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("I'll pay " + SkillHandler.SKILLCAPE_PRICE.ToString("#,##0") + " coins.", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 38;
                    break;

                case 38:
                    if (p.getInventory().getTotalFreeSlots() < 2)
                    {
                        p.getPackets().sendNPCHead(437, 241, 2);
                        p.getPackets().modifyText("Cap'n Izzy No-Beard", 241, 3);
                        p.getPackets().modifyText("Ye require 2 free inventory spaces!", 241, 4);
                        p.getPackets().animateInterface(9827, 241, 2);
                        p.getPackets().sendChatboxInterface2(241);
                        break;
                    }
                    if (p.getInventory().deleteItem(995, SkillHandler.SKILLCAPE_PRICE))
                    {
                        int cape = p.getSkills().hasMultiple99s() ? 9772 : 9771;
                        int hood = 9773;
                        p.getInventory().addItem(cape);
                        p.getInventory().addItem(hood);
                        p.getPackets().sendNPCHead(437, 242, 2);
                        p.getPackets().modifyText("Cap'n Izzy No-Beard", 242, 3);
                        p.getPackets().modifyText("One Agility Skillcape & hood.", 242, 4);
                        p.getPackets().modifyText("Wear it with pride.", 242, 5);
                        p.getPackets().animateInterface(9827, 242, 2);
                        p.getPackets().sendChatboxInterface2(242);
                    }
                    else
                    {
                        p.getPackets().sendNPCHead(437, 241, 2);
                        p.getPackets().modifyText("Cap'n Izzy No-Beard", 241, 3);
                        p.getPackets().modifyText("Ye don't have enough coins!", 241, 4);
                        p.getPackets().animateInterface(9827, 241, 2);
                        p.getPackets().sendChatboxInterface2(241);
                    }
                    break;

                case 39:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText(SkillHandler.SKILLCAPE_PRICE.ToString("#,##0") + " is a crazy price!", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 40;
                    break;

                case 40:
                    p.getPackets().sendNPCHead(437, 241, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 241, 3);
                    p.getPackets().modifyText("I'm sure ye will change your mind eventually..", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    break;

                case 41:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("See you later.", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 42;
                    break;

                case 42:
                    p.getPackets().sendNPCHead(437, 241, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 241, 3);
                    p.getPackets().modifyText("Aye, goodbye " + p.getLoginDetails().getUsername() + ".", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    break;

                /*
                 * NOW TALKING TO JACKIE THE FRUIT
                 */

                case 43:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("Ahoy there!", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 44;
                    break;

                case 44:
                    p.getPackets().sendNPCHead(1055, 241, 2);
                    p.getPackets().modifyText("Pirate Jackie the Fruit", 241, 3);
                    p.getPackets().modifyText("Ahoy!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 45;
                    break;

                case 45:
                    p.getPackets().sendChatboxInterface2(232);
                    p.getPackets().modifyText("What is this place?", 232, 2);
                    p.getPackets().modifyText("What do you do?", 232, 3);
                    p.getPackets().modifyText("I'd like to trade in my tickets, please.", 232, 4);
                    p.getPackets().modifyText("See you later.", 232, 5);
                    newStatus = 46;
                    break;

                case 46:
                    p.getPackets().sendNPCHead(1055, 241, 2);
                    p.getPackets().modifyText("Pirate Jackie the Fruit", 241, 3);
                    p.getPackets().modifyText("Welcome to the Brimhaven Agility Arena!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 47;
                    break;

                case 47:
                    p.getPackets().sendNPCHead(1055, 242, 2);
                    p.getPackets().modifyText("Pirate Jackie the Fruit", 242, 3);
                    p.getPackets().modifyText("If ye want to know more, talk to Cap'n Izzy, after", 242, 4);
                    p.getPackets().modifyText("all... he did find it!", 242, 5);
                    p.getPackets().animateInterface(9827, 242, 2);
                    p.getPackets().sendChatboxInterface2(242);
                    newStatus = 45;
                    break;

                case 48:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("What do you do?", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 49;
                    break;

                case 49:
                    p.getPackets().sendNPCHead(1055, 244, 2);
                    p.getPackets().modifyText("Pirate Jackie the Fruit", 244, 3);
                    p.getPackets().modifyText("I be the jack o' tickets. I exchange the tickets ye", 244, 4);
                    p.getPackets().modifyText("Collect in the Agility arena for more stuff. Ye can", 244, 5);
                    p.getPackets().modifyText("obtain more Agility experience or items ye won't", 244, 6);
                    p.getPackets().modifyText("find anywhere else!", 244, 7);
                    p.getPackets().animateInterface(9827, 244, 2);
                    p.getPackets().sendChatboxInterface2(244);
                    newStatus = 50;
                    break;

                case 50:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("Sounds good!", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 45;
                    break;

                case 51:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("I'd like to trade in my tickets, please.", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 52;
                    break;

                case 52:
                    p.getPackets().sendNPCHead(1055, 241, 2);
                    p.getPackets().modifyText("Pirate Jackie the Fruit", 241, 3);
                    p.getPackets().modifyText("Aye, ye be on the right track.", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 53;
                    break;

                case 53:
                    p.getPackets().displayInterface(6);
                    break;

                case 54:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("See you later.", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 55;
                    break;

                case 55:
                    p.getPackets().sendNPCHead(1055, 241, 2);
                    p.getPackets().modifyText("Pirate Jackie the Fruit", 241, 3);
                    p.getPackets().modifyText("Goodbye.", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    break;
            }
            if (newStatus != -1)
            {
                p.setTemporaryAttribute("dialogue", newStatus);
            }
        }
Esempio n. 9
0
        private static void appendAppearanceUpdate(Player p, PacketBuilder updateBlock)
        {
            PacketBuilder playerProps = new PacketBuilder().setSize(Packet.Size.Bare);

            Appearance app = p.getAppearance();
            playerProps.addByte((byte)(app.getGender() & 0xFF));
            if ((app.getGender() & 0x2) == 2)
            {
                playerProps.addByte((byte)0);
                playerProps.addByte((byte)0);
            }
            playerProps.addByte((byte)p.getPrayers().getPkIcon());
            playerProps.addByte((byte)p.getPrayers().getHeadIcon());
            if (!app.isInvisible())
            {
                if (!app.isNpc())
                {
                    for (int i = 0; i < 4; i++)
                    {
                        if (p.getEquipment().getItemInSlot((ItemData.EQUIP)i) != -1)
                        {
                            playerProps.addUShort(32768 + p.getEquipment().getSlot((ItemData.EQUIP)i).getDefinition().getEquipId());
                        }
                        else
                        {
                            playerProps.addByte((byte)0);
                        }
                    }
                    if (p.getEquipment().getItemInSlot(ItemData.EQUIP.CHEST) != -1)
                    {
                        playerProps.addUShort(32768 + p.getEquipment().getSlot(ItemData.EQUIP.CHEST).getDefinition().getEquipId());
                    }
                    else
                    {
                        playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.AMULET));
                    }
                    if (p.getEquipment().getItemInSlot(ItemData.EQUIP.SHIELD) != -1)
                    {
                        playerProps.addUShort(32768 + p.getEquipment().getSlot(ItemData.EQUIP.SHIELD).getDefinition().getEquipId());
                    }
                    else
                    {
                        playerProps.addByte((byte)0);
                    }
                    Item chest = p.getEquipment().getSlot(ItemData.EQUIP.CHEST);
                    if (chest != null && chest.getDefinition() != null)
                    {
                        if (!ItemData.isFullBody(chest.getDefinition()))
                        {
                            playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.WEAPON));
                        }
                        else
                        {
                            playerProps.addByte((byte)0);
                        }
                    }
                    else
                    {
                        playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.WEAPON));
                    }
                    if (p.getEquipment().getItemInSlot(ItemData.EQUIP.LEGS) != -1)
                    {
                        playerProps.addUShort(32768 + p.getEquipment().getSlot(ItemData.EQUIP.LEGS).getDefinition().getEquipId());
                    }
                    else
                    {
                        playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.SHIELD));
                    }
                    Item hat = p.getEquipment().getSlot(ItemData.EQUIP.HAT);
                    if (hat != null && hat.getDefinition() != null)
                    {
                        if (!ItemData.isFullHat(hat.getDefinition()) && !ItemData.isFullMask(hat.getDefinition()))
                        {
                            playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.HAT));
                        }
                        else
                        {
                            playerProps.addByte((byte)0);
                        }
                    }
                    else
                    {
                        playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.HAT));
                    }
                    if (p.getEquipment().getItemInSlot(ItemData.EQUIP.HANDS) != -1)
                    {
                        playerProps.addUShort(32768 + p.getEquipment().getSlot(ItemData.EQUIP.HANDS).getDefinition().getEquipId());
                    }
                    else
                    {
                        playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.CHEST));
                    }
                    if (p.getEquipment().getItemInSlot(ItemData.EQUIP.FEET) != -1)
                    {
                        playerProps.addUShort(32768 + p.getEquipment().getSlot(ItemData.EQUIP.FEET).getDefinition().getEquipId());
                    }
                    else
                    {
                        playerProps.addUShort(0x100 + app.getLook(6));
                    }
                    if (hat != null && hat.getDefinition() != null)
                    {
                        if (!ItemData.isFullMask(hat.getDefinition()))
                        {
                            playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.CAPE));
                        }
                        else
                        {
                            playerProps.addByte((byte)0);
                        }
                    }
                    else
                    {
                        playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.CAPE));
                    }
                }
                else
                {
                    playerProps.addUShort(-1);
                    playerProps.addUShort(app.getNpcId());
                    playerProps.addByte((byte)255);
                }
            }
            else
            {
                for (int i = 0; i < 12; i++)
                {
                    playerProps.addByte((byte)0);
                }
            }
            foreach (int colour in app.getColoursArray())
            {
                playerProps.addByte((byte)colour);
            }
            playerProps.addUShort(p.getEquipment().getStandWalkAnimation());
            playerProps.addLong(p.getLoginDetails().getLongName());
            playerProps.addByte((byte)p.getSkills().getCombatLevel());
            playerProps.addUShort(0);
            playerProps.addByte((byte)0);
            updateBlock.addByteA((byte)(playerProps.getLength() & 0xFF));
            updateBlock.addBytes(playerProps.toPacket().getData(), 0, playerProps.getLength());
        }
Esempio n. 10
0
 private void resetVariables(Player p)
 {
     p.setSkullCycles(0);
     p.getSpecialAttack().resetSpecial();
     p.setLastkiller(null);
     p.setDead(false);
     p.setEntityFocus(65535);
     p.setPoisonAmount(0);
     p.clearKillersHits();
     p.setLastVengeanceTime(0);
     p.setVengeance(false);
     p.removeTemporaryAttribute("willDie");
     p.setFrozen(false);
     p.removeTemporaryAttribute("unmovable");
     p.setAntifireCycles(0);
     p.setSuperAntipoisonCycles(0);
     p.setTeleblockTime(0);
     p.removeTemporaryAttribute("teleblocked");
     p.setTarget(null);
     p.setAttacker(null);
     foreach (Skills.SKILL skill in Enum.GetValues(typeof(Skills.SKILL)))
         p.getSkills().setCurLevel(skill, p.getSkills().getMaxLevel(skill));
     p.getPackets().sendSkillLevels();
     Prayer.deactivateAllPrayers(p);
     if (p.getTemporaryAttribute("cantDoAnything") != null)
     {
         p.getAppearance().setInvisible(false);
         p.getUpdateFlags().setAppearanceUpdateRequired(true);
         p.removeTemporaryAttribute("cantDoAnything");
         p.removeTemporaryAttribute("unmovable");
         teleportToWaitingRoom(p, false);
         p.getPackets().closeInterfaces();
         p.getPackets().setMinimapStatus(0);
         p.getPackets().clearMapFlag();
     }
 }
Esempio n. 11
0
        private static void drinkPotion(Player p, int i, int j, int slot)
        {
            //TODO antipoisons/antifire
            int lastPotion = -1;
            int delay = 500;
            long lastDrink = 0;
            if (p.isDead() || p.getTemporaryAttribute("willDie") != null)
            {
                return;
            }
            if (p.getDuel() != null)
            {
                if (p.getDuel().ruleEnabled(DuelSession.RULE.NO_DRINKS))
                {
                    p.getPackets().sendMessage("Drinks have been disabled for this duel!");
                    return;
                }
            }
            if (p.getTemporaryAttribute("lastDrankPotion") != null)
            {
                lastPotion = (int)p.getTemporaryAttribute("lastDrankPotion");
            }
            if (p.getTemporaryAttribute("drinkPotionTimer") != null)
            {
                lastDrink = (int)p.getTemporaryAttribute("drinkPotionTimer");
            }
            int time = (j == lastPotion) ? 1000 : 500;
            if (Environment.TickCount - lastDrink < time)
            {
                return;
            }
            p.getPackets().closeInterfaces();
            p.setTemporaryAttribute("drinkPotionTimer", Environment.TickCount);
            p.setTemporaryAttribute("lastDrankPotion", j);
            p.setTarget(null);
            p.resetCombatTurns();
            p.setEntityFocus(65535);
            p.removeTemporaryAttribute("autoCasting");

            Event drinkPotionEvent = new Event(delay);
            drinkPotionEvent.setAction(() =>
            {
                drinkPotionEvent.stop();
                if (p.isDead() || p.getSkills().getCurLevel(Skills.SKILL.HITPOINTS) <= 0)
                {
                    return;
                }
                int item = i != 0 && POTIONS[i - 1][j] != -1 ? POTIONS[i - 1][j] : 229;
                if (!p.getInventory().replaceItemSlot(POTIONS[i][j], item, slot))
                {
                    return;
                }
                string drinkPotion = ItemData.forId(POTIONS[0][j]).getName().Replace("(", "").Replace(")", "").Replace("3", "").Replace("2", "").Replace("1", "").ToLower();
                p.getPackets().sendMessage("You drink some of your " + drinkPotion + ".");
                p.getPackets().sendMessage("You have " + (i == 0 ? "no" : i.ToString()) + " doses of potion left.");
                switch (j)
                {
                    case 0: //Attack potion [+3 and 10% of max attack]
                        statBoost(p, Skills.SKILL.ATTACK, 0.10, 3, false);
                        break;

                    case 1: //Antipoison potion
                        p.setPoisonAmount(0);
                        break;

                    case 2: //Strength potion [+3 and 10% of max strength]
                        statBoost(p, Skills.SKILL.STRENGTH, 0.10, 3, false);
                        break;

                    case 3: //Restore potion [restores randomly between 10-39 points]
                        restorePotion(p, Skills.SKILL.DEFENCE, 10, 39);
                        restorePotion(p, Skills.SKILL.ATTACK, 10, 39);
                        restorePotion(p, Skills.SKILL.STRENGTH, 10, 39);
                        restorePotion(p, Skills.SKILL.RANGE, 10, 39);
                        restorePotion(p, Skills.SKILL.HITPOINTS, 10, 39);
                        break;

                    case 4: //Energy potion [restores 20% energy]
                        double newEnergy = p.getRunEnergy() * 0.20;
                        p.setRunEnergy(((p.getRunEnergy() + (int)newEnergy >= 100) ? 100 : (p.getRunEnergy() + (int)newEnergy)));
                        break;

                    case 5: //Defence potion [Should be +3 and 10% of max defence]
                        statBoost(p, Skills.SKILL.DEFENCE, 0.10, 3, false);
                        break;

                    case 6: //Agility potion [restores 2 or 3 agility points]
                        int newAgility = Misc.random(2, 3) + p.getSkills().getCurLevel(Skills.SKILL.AGILITY);
                        if (newAgility < p.getSkills().getMaxLevel(Skills.SKILL.AGILITY))
                            p.getSkills().setCurLevel(Skills.SKILL.AGILITY, newAgility);
                        break;

                    case 7: //Combat potion [Should be 10% of attack+strength and +3 to each].
                        statBoost(p, Skills.SKILL.ATTACK, 0.10, 3, false);
                        statBoost(p, Skills.SKILL.STRENGTH, 0.10, 3, false);
                        break;

                    case 8: //Prayer potion, [heals 7-31, formula = 7+floor(prayerlevel/4)]
                        int newPrayer = 7 + (int)Math.Floor((double)(p.getSkills().getMaxLevel(Skills.SKILL.PRAYER) / 4)) + p.getSkills().getCurLevel(Skills.SKILL.PRAYER);
                        if (newPrayer < p.getSkills().getCurLevel(Skills.SKILL.PRAYER))
                            p.getSkills().setCurLevel(Skills.SKILL.PRAYER, newPrayer);
                        checkOverdose(p, Skills.SKILL.PRAYER);
                        break;

                    case 9: //Summoning potion [25% of players summoning + 7]
                        int newSummoning = (7 + (int)((double)p.getSkills().getMaxLevel(Skills.SKILL.SUMMONING) * 0.25)) + p.getSkills().getCurLevel(Skills.SKILL.SUMMONING);
                        if (newSummoning < p.getSkills().getCurLevel(Skills.SKILL.SUMMONING))
                            p.getSkills().setCurLevel(Skills.SKILL.SUMMONING, newSummoning);

                        statBoost(p, Skills.SKILL.STRENGTH, 0.10, 3, false);
                        break;

                    case 10: //Super attack potion [15% of players attack + 5]
                        statBoost(p, Skills.SKILL.ATTACK, 0.15, 5, false);
                        break;

                    case 11: // super antipoison
                        p.setPoisonAmount(0);
                        p.setSuperAntipoisonCycles(20);
                        break;

                    case 12: //Fishing potion [fishing +3]
                        if (p.getSkills().getCurLevel(Skills.SKILL.FISHING) < (p.getSkills().getMaxLevel(Skills.SKILL.FISHING) + 3))
                            p.getSkills().setCurLevel(Skills.SKILL.FISHING, p.getSkills().getCurLevel(Skills.SKILL.FISHING) + 3);
                        break;

                    case 13:
                        p.setRunEnergy(p.getRunEnergy() + 20);
                        if (p.getRunEnergy() >= 100)
                        {
                            p.setRunEnergy(100);
                        }
                        break;

                    case 14: //Hunter potion [hunting + 3]
                        if (p.getSkills().getCurLevel(Skills.SKILL.HUNTER) < (p.getSkills().getMaxLevel(Skills.SKILL.HUNTER) + 3))
                            p.getSkills().setCurLevel(Skills.SKILL.HUNTER, p.getSkills().getCurLevel(Skills.SKILL.HUNTER) + 3);
                        break;

                    case 15: //Super strength [strength 15% +5]
                        statBoost(p, Skills.SKILL.STRENGTH, 0.15, 5, false);
                        break;

                    case 16: //restores all skills by 33%.
                        foreach (Skills.SKILL skill in Enum.GetValues(typeof(Skills.SKILL)))
                            superRestorePotion(p, skill, 0.33);
                        break;

                    case 17://Super defence [defence 15% +5]
                        statBoost(p, Skills.SKILL.DEFENCE, 0.15, 5, false);
                        break;

                    case 18: // Antifire potion
                        p.setAntifireCycles(20);
                        break;

                    case 19: //Ranging potions
                        statBoost(p, Skills.SKILL.RANGE, 0.10, 4, false);
                        break;

                    case 20: //Magic potion.
                        if (p.getSkills().getCurLevel(Skills.SKILL.MAGIC) < (p.getSkills().getMaxLevel(Skills.SKILL.MAGIC) + 4))
                            p.getSkills().setCurLevel(Skills.SKILL.MAGIC, p.getSkills().getCurLevel(Skills.SKILL.MAGIC) + 4);
                        break;

                    case 21: //Zamorak brew potion. [Attack %20+2][Strength %12 +2][Defense -10% + -2][hitpoints -10% + 20]
                        statBoost(p, Skills.SKILL.ATTACK, 0.20, 2, false);
                        statBoost(p, Skills.SKILL.STRENGTH, 0.12, 2, false);
                        statBoost(p, Skills.SKILL.DEFENCE, 0.10, 2, true);
                        statBoost(p, Skills.SKILL.HITPOINTS, 0.10, 20, true);
                        break;

                    case 22: //Saradomin brew potion. [Hitpoints +%15][Defense +25%][Strength, Attack, Magic and Ranged -10%]
                        statBoost(p, Skills.SKILL.HITPOINTS, 0.15, 0, false);
                        statBoost(p, Skills.SKILL.DEFENCE, 0.25, 0, false);
                        statBoost(p, Skills.SKILL.STRENGTH, 0.10, 0, true);
                        statBoost(p, Skills.SKILL.ATTACK, 0.10, 0, true);
                        statBoost(p, Skills.SKILL.MAGIC, 0.10, 0, true);
                        statBoost(p, Skills.SKILL.RANGE, 0.10, 0, true);
                        break;
                }
                p.setLastAnimation(new Animation(829));
                p.getPackets().sendSkillLevels();
            });
            Server.registerEvent(drinkPotionEvent);
        }
Esempio n. 12
0
        public static void statBoost(Player p, Skills.SKILL skill, double percentage, int additionalLevels, bool decreaseStat)
        {
            int maxPossibleIncrease = (int)((double)p.getSkills().getMaxLevel(skill) * percentage) + additionalLevels;
            maxPossibleIncrease += p.getSkills().getMaxLevel(skill);

            if (!decreaseStat)
            { //increase stat
                p.getSkills().setCurLevel(skill, maxPossibleIncrease);
            }
            else
            {
                p.getSkills().setCurLevel(skill, p.getSkills().getCurLevel(skill) - maxPossibleIncrease);
                if (p.getSkills().getCurLevel(skill) <= 0)
                    p.getSkills().setCurLevel(skill, 1);
            }
        }
Esempio n. 13
0
 protected static void addMagicXp(Player p, Entity target, double hit, int index, bool baseXp)
 {
     if (target is Npc)
     {
         double xp = 0;
         switch (index)
         {
             case 0: xp = 5.5; break; // Wind strike.
             case 1: xp = 7.5; break;// Water strike
             case 2: xp = 9.5; break;// Earth strike.
             case 3: xp = 11.5; break;// Fire strike.
             case 4: xp = 13.5; break;// Wind bolt.
             case 5: xp = 16.5; break;// Water bolt.
             case 6: xp = 19.5; break;// Earth bolt.
             case 7: xp = 21.5; break;// Fire bolt.
             case 8: xp = 25.5; break;// Wind blast.
             case 9: xp = 28.5; break;// Water blast.
             case 10: xp = 31.5; break;// Earth blast.
             case 11: xp = 34.5; break;// Fire blast.
             case 12: xp = 36.0; break;// Wind wave.
             case 13: xp = 37.5; break;// Water wave.
             case 14: xp = 40.0; break;// Earth wave.
             case 15: xp = 42.5; break;// Fire wave.
             case 32: xp = 24.5; break;// Crumble undead.
             case 33: xp = 30.0; break;// Slayer dart.
             case 34: xp = 30.0; break;// Bind.
             case 35: xp = 30.0; break;// Iban blast.
             case 36: xp = 60.0; break;// Snare.
             case 37: xp = 61.0; break;// Saradomin strike.
             case 38: xp = 61.0; break;// Claws of Guthix.
             case 39: xp = 61.0; break;// Flames of Zamorak.
             case 40: xp = 89.0; break;// Entangle.
             case 41: xp = 13.0; break;// Confuse.
             case 42: xp = 21.0; break;// Weaken.
             case 43: xp = 29.0; break;// Curse.
             case 44: xp = 83.0; break;// Enfeeble.
             case 45: xp = 90.0; break;// Stun.
             case 46: xp = 76.0; break;// Vulnerability.
             case 47: xp = 80.0; break;// Teleblock.
             case 16: xp = 30.0; break;// Smoke rush.
             case 17: xp = 31.0; break;// Shadow rush.
             case 18: xp = 33.0; break;// Blood rush.
             case 19: xp = 34.0; break;// Ice rush.
             case 20: xp = 36.0; break;// Smoke burst.
             case 21: xp = 37.0; break;// Shadow burst.
             case 22: xp = 39.0; break;// Blood burst.
             case 23: xp = 40.0; break;// Ice burst.
             case 24: xp = 42.0; break;// Smoke blitz.
             case 25: xp = 43.0; break;// Shadow blitz.
             case 26: xp = 45.0; break;// Blood blitz.
             case 27: xp = 46.0; break;// Ice blitz.
             case 28: xp = 48.0; break;// Smoke barrage.
             case 29: xp = 48.0; break;// Shadow barrage.
             case 30: xp = 51.0; break;// Blood barrage.
             case 31: xp = 52.0; break;// Ice barrage.
             case 48: xp = 36.0; break;// Miasmic rush.
             case 49: xp = 42.0; break;// Miasmic burst.
             case 50: xp = 48.0; break;// Miasmic blitz.
             case 51: xp = 54.0; break;// Miasmic barrage.
         }
         double finalXp = baseXp ? (xp + (hit * 2)) : (hit * 2);
         p.getSkills().addXp(Skills.SKILL.MAGIC, finalXp);
         p.getSkills().addXp(Skills.SKILL.HITPOINTS, hit * 1.33);
         target.addToHitCount(p, hit);
     }
     else if (target != null)
     {
         target.addToHitCount(p, hit);
     }
 }
Esempio n. 14
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);
        }
Esempio n. 15
0
        public static void levelUp(Player player, SKILL skill)
        {
            int skillIndex = Convert.ToInt32(skill);
            String s = "<br><br><br>";
            String s1 = "<br><br><br><br>";
            if (player.getTemporaryAttribute("teleporting") == null)
            {
                player.setLastGraphics(new Graphics(199, 0, 100));
            }

            int skillFlashFlags = (int)(player.getTemporaryAttribute("skillFlashFlags") == null ? 0 : (int)player.getTemporaryAttribute("skillFlashFlags"));
            skillFlashFlags |= SKILL_FLASH_BITMASKS[skillIndex];
            player.setTemporaryAttribute("skillFlashFlags", skillFlashFlags);

            player.getPackets().sendMessage("You've just advanced a " + SKILL_NAME[skillIndex] + " level! You have reached level " + player.getSkills().getMaxLevel(skillIndex) + ".");
            player.getPackets().modifyText(s + "Congratulations, you have just advanced a " + SKILL_NAME[skillIndex] + " level!", 740, 0);
            player.getPackets().modifyText(s1 + "You have now reached level " + player.getSkills().getMaxLevel(skillIndex) + ".", 740, 1);
            player.getPackets().modifyText("", 740, 2);
            player.getPackets().sendConfig(1179, SKILL_ICON_BITMASKS[skillIndex] | skillFlashFlags); //start flashing appropriate skill icons
            player.getPackets().sendChatboxInterface2(740);
            player.getUpdateFlags().setAppearanceUpdateRequired(true);
        }
Esempio n. 16
0
        public bool savePlayer(Player p)
        {
            if (p == null) return false;
            try
            {
                string username = p.getLoginDetails().getUsername().ToLower();

                /* Character saving code goes here */
                XmlTextWriter writer = new XmlTextWriter(Misc.getServerPath() + @"\accounts\" + username + ".xml", null);
                writer.Formatting = Formatting.Indented;
                writer.WriteStartElement("Player");
                writer.WriteStartElement("Login");
                writer.WriteElementString("Password", p.getLoginDetails().getPassword());
                writer.WriteElementString("Rights", p.getRights().ToString());
                writer.WriteElementString("BankPin", p.getBank().getBankPin());
                writer.WriteEndElement();

                writer.WriteStartElement("Position");
                writer.WriteElementString("X", p.getLocation().getX().ToString());
                writer.WriteElementString("Y", p.getLocation().getY().ToString());
                writer.WriteElementString("Z", p.getLocation().getZ().ToString());
                writer.WriteEndElement();

                writer.WriteStartElement("Settings");
                writer.WriteElementString("RunEnergy", p.getRunEnergy().ToString());
                writer.WriteStartElement("PrivacySettings");
                writer.WriteElementString("Public", p.getFriends().getPrivacyOption(0).ToString());
                writer.WriteElementString("Private", p.getFriends().getPrivacyOption(1).ToString());
                writer.WriteElementString("Trade", p.getFriends().getPrivacyOption(2).ToString());
                writer.WriteEndElement();
                writer.WriteEndElement();

                writer.WriteStartElement("Friends");
                foreach (long friend in p.getFriends().getFriendsList())
                    writer.WriteElementString("Friend", friend.ToString());
                writer.WriteEndElement();

                writer.WriteStartElement("Ignores");
                foreach (long ignore in p.getFriends().getIgnoresList())
                    writer.WriteElementString("Ignore", ignore.ToString());
                writer.WriteEndElement();

                writer.WriteStartElement("Stats");
                foreach (Skills.SKILL skill in Enum.GetValues(typeof(Skills.SKILL)))
                {
                    writer.WriteStartElement(skill.ToString()); //skill name.
                    writer.WriteElementString("CurrentLevel", p.getSkills().getCurLevel(skill).ToString());
                    writer.WriteElementString("XP", p.getSkills().getXp(skill).ToString());
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();

                Item item;
                writer.WriteStartElement("EquipmentItems");
                foreach (ItemData.EQUIP equip in Enum.GetValues(typeof(ItemData.EQUIP)))
                {
                    if (equip == ItemData.EQUIP.NOTHING) continue;
                    item = p.getEquipment().getSlot(equip);
                    if (item.getItemId() == -1) continue; //empty slot.

                    writer.WriteStartElement(equip.ToString());
                    writer.WriteElementString("Id", item.getItemId().ToString());
                    writer.WriteElementString("Amount", item.getItemAmount().ToString());
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();

                writer.WriteStartElement("InventoryItems");
                for (int i = 0; i < Inventory.MAX_INVENTORY_SLOTS; i++)
                {
                    item = p.getInventory().getSlot(i);
                    if (item.getItemId() == -1) continue; //empty slot.

                    writer.WriteStartElement("Item");
                    writer.WriteElementString("Slot", i.ToString());
                    writer.WriteElementString("Id", item.getItemId().ToString());
                    writer.WriteElementString("Amount", item.getItemAmount().ToString());
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();

                writer.WriteStartElement("BankItems");
                for (int i = 0; i < Bank.MAX_BANK_SLOTS; i++)
                {
                    item = p.getBank().getSlot(i);
                    if (item.getItemId() == -1) continue; //empty slot.

                    writer.WriteStartElement("Item");
                    writer.WriteElementString("Slot", i.ToString());
                    writer.WriteElementString("Id", item.getItemId().ToString());
                    writer.WriteElementString("Amount", item.getItemAmount().ToString());
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
                writer.WriteEndElement();
                //Write the XML to file and close the writer
                writer.Close();
            }
            catch (Exception)
            {
                return false;
            }

            return true;
        }
Esempio n. 17
0
        public ReturnCode loadPlayer(Connection connection)
        {
            if (connection == null)
                return ReturnCode.COULD_NOT_COMPLETE;
            LoginDetails loginDetails = connection.getLoginDetails();
            if (loginDetails == null || loginDetails.getUsername() == "" || loginDetails.getLongName() == 0)
                return ReturnCode.INVALID_PASSWORD;//ReturnCode.INVALID_PASSWORD;

            foreach (char c in loginDetails.getUsername().ToCharArray())
            {
                if (!char.IsLetterOrDigit(c) && !char.IsWhiteSpace(c))
                    return ReturnCode.INVALID_PASSWORD;
            }
            Player createdPlayer = new Player(connection);
            connection.setPlayer(createdPlayer); //player finally created.
            createdPlayer.setLoginDetails(loginDetails);

            if (!File.Exists(Misc.getServerPath() + @"\accounts\" + loginDetails.getUsername() + ".xml"))
            {
                createdPlayer.setRights(2); //all new users admins atm (change later).
                createdPlayer.setLocation(new Location(2323, 3174, 0));
                return ReturnCode.LOGIN_OK; //new user.
            }
            //Yeah reading XML files is a bit h**o.
            try
            {
                int temp;
                long lTemp;
                string username = createdPlayer.getLoginDetails().getUsername().ToLower();
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load(Misc.getServerPath() + @"\accounts\" + username + ".xml");

                XmlNode xmlNode = xmlDocument.SelectSingleNode("/Player/Login/Password");
                if (xmlNode == null) return ReturnCode.INVALID_PASSWORD; //no password node.
                if (createdPlayer.getLoginDetails().getPassword() != xmlNode.InnerText)
                    return ReturnCode.INVALID_PASSWORD;

                XmlNode loginElement = xmlDocument.SelectSingleNode("/Player/Login");
                if (loginElement != null && loginElement.HasChildNodes)
                {
                    XmlNodeList childs = loginElement.ChildNodes;

                    foreach (XmlElement element in childs)
                    {
                        switch (element.Name)
                        {
                            case "Rights":
                                if (!int.TryParse(element.InnerText, out temp))
                                    temp = 0;
                                createdPlayer.setRights(temp);
                                break;

                            case "BankPin":
                                if (element.InnerText == "") continue;
                                createdPlayer.getBank().setBankPin(element.InnerText);
                                break;
                        }
                    }
                }

                loginElement = xmlDocument.SelectSingleNode("/Player/Position");
                if (loginElement != null && loginElement.HasChildNodes)
                {
                    XmlNodeList childs = loginElement.ChildNodes;
                    Location location = new Location();
                    foreach (XmlElement element in childs)
                    {
                        switch (element.Name)
                        {
                            case "X":
                                if (!int.TryParse(element.InnerText, out temp))
                                {
                                    createdPlayer.setLocation(Constants.HOME_SPAWN_LOCATION);
                                    break;
                                }
                                location.setX(temp);
                                break;

                            case "Y":
                                if (!int.TryParse(element.InnerText, out temp))
                                {
                                    createdPlayer.setLocation(Constants.HOME_SPAWN_LOCATION);
                                    break;
                                }
                                location.setY(temp);
                                break;

                            case "Z":
                                if (!int.TryParse(element.InnerText, out temp))
                                    temp = 0;
                                location.setZ(temp);
                                break;
                        }
                    }
                    createdPlayer.setLocation(location);
                    if (Location.atDuelArena(createdPlayer.getLocation()))
                        DuelSession.teleportDuelArenaHome(createdPlayer);
                }

                xmlNode = xmlDocument.SelectSingleNode("/Player/Settings/RunEnergy");
                if (xmlNode == null)
                {
                    temp = 100;
                }
                else
                {
                    if (!int.TryParse(xmlNode.InnerText, out temp))
                        temp = 100;
                }
                createdPlayer.setRunEnergyLoad(temp);

                loginElement = xmlDocument.SelectSingleNode("/Player/Settings/PrivacySettings");
                if (loginElement != null && loginElement.HasChildNodes)
                {
                    XmlNodeList childs = loginElement.ChildNodes;
                    Friends.STATUS publicStatus = Friends.STATUS.ON, privateStatus = Friends.STATUS.ON, tradeStatus = Friends.STATUS.ON;

                    foreach (XmlElement element in childs)
                    {
                        switch (element.Name)
                        {
                            case "Public":
                                publicStatus = (Friends.STATUS)Enum.Parse(typeof(Friends.STATUS), element.InnerText, true);
                                break;

                            case "Private":
                                privateStatus = (Friends.STATUS)Enum.Parse(typeof(Friends.STATUS), element.InnerText, true);
                                break;

                            case "Trade":
                                tradeStatus = (Friends.STATUS)Enum.Parse(typeof(Friends.STATUS), element.InnerText, true);
                                break;
                        }
                    }
                    createdPlayer.getFriends().setPrivacyOptions(publicStatus, privateStatus, tradeStatus);
                }

                loginElement = xmlDocument.SelectSingleNode("/Player/Friends");
                if (loginElement != null && loginElement.HasChildNodes)
                {
                    XmlNodeList childs = loginElement.ChildNodes; //number of Friends

                    foreach (XmlElement element in childs)
                    {
                        if (element.Name == "Friend")
                        {
                            if (long.TryParse(element.InnerText, out lTemp))
                                createdPlayer.getFriends().getFriendsList().Add(lTemp);
                        }
                    }
                }

                loginElement = xmlDocument.SelectSingleNode("/Player/Ignores");
                if (loginElement != null && loginElement.HasChildNodes)
                {
                    XmlNodeList childs = loginElement.ChildNodes; //number of Friends

                    foreach (XmlElement element in childs)
                    {
                        if (element.Name == "Ignore")
                        {
                            if (long.TryParse(element.InnerText, out lTemp))
                                createdPlayer.getFriends().getIgnoresList().Add(lTemp);
                        }
                    }
                }

                loginElement = xmlDocument.SelectSingleNode("/Player/Stats");
                if (loginElement != null && loginElement.HasChildNodes)
                {
                    XmlNode skillNode;
                    foreach (Skills.SKILL skill in Enum.GetValues(typeof(Skills.SKILL)))
                    {
                        skillNode = loginElement.SelectSingleNode("/Player/Stats/" + skill.ToString());

                        foreach (XmlElement element in skillNode.ChildNodes)
                        { //CurrentLevel/XP
                            switch (element.Name)
                            {
                                case "CurrentLevel":
                                    if (!int.TryParse(element.InnerText, out temp))
                                    {
                                        if (skill != Skills.SKILL.HITPOINTS)
                                            createdPlayer.getSkills().setCurLevel(skill, 1);
                                        else
                                            createdPlayer.getSkills().setCurLevel(skill, 10);
                                        break;
                                    }
                                    createdPlayer.getSkills().setCurLevel(skill, temp);
                                    break;

                                case "XP":
                                    if (!int.TryParse(element.InnerText, out temp))
                                    {
                                        if (skill != Skills.SKILL.HITPOINTS)
                                            createdPlayer.getSkills().setXp(skill, 0);
                                        else
                                            createdPlayer.getSkills().setXp(skill, 1184);
                                        break;
                                    }
                                    createdPlayer.getSkills().setXp(skill, temp);
                                    break;
                            }
                        }
                    }
                }

                loginElement = xmlDocument.SelectSingleNode("/Player/EquipmentItems");
                if (loginElement != null && loginElement.HasChildNodes)
                {
                    XmlNode skillNode;

                    foreach (ItemData.EQUIP equip in Enum.GetValues(typeof(ItemData.EQUIP)))
                    {
                        if (equip == ItemData.EQUIP.NOTHING) continue;
                        skillNode = loginElement.SelectSingleNode("/Player/EquipmentItems/" + equip.ToString());
                        if (skillNode == null) continue;
                        int id = -1, amount = 0;
                        foreach (XmlElement element in skillNode.ChildNodes)
                        {
                            switch (element.Name)
                            {
                                case "Id":
                                    if (!int.TryParse(element.InnerText, out id))
                                        id = -1;
                                    break;

                                case "Amount":
                                    if (!int.TryParse(element.InnerText, out amount))
                                        amount = 0;
                                    break;
                            }
                        }
                        if (id != -1)
                        {
                            createdPlayer.getEquipment().getEquipment()[(int)equip].setItemId(id);
                            createdPlayer.getEquipment().getEquipment()[(int)equip].setItemAmount(amount);
                        }
                    }
                }

                loginElement = xmlDocument.SelectSingleNode("/Player/InventoryItems");
                if (loginElement != null && loginElement.HasChildNodes)
                {
                    int slot = -1, id = 0, amount = 0;
                    foreach (XmlElement itemElement in loginElement.ChildNodes) //each item.
                    {
                        foreach (XmlElement itemDef in itemElement.ChildNodes) //each item.
                        {
                            switch (itemDef.Name)
                            {
                                case "Slot":
                                    if (!int.TryParse(itemDef.InnerText, out slot))
                                        slot = -1;
                                    if (slot < 0 || slot > Inventory.MAX_INVENTORY_SLOTS) slot = -1;
                                    break;

                                case "Id":
                                    if (!int.TryParse(itemDef.InnerText, out id))
                                        slot = -1;
                                    break;

                                case "Amount":
                                    if (!int.TryParse(itemDef.InnerText, out amount))
                                        slot = -1;
                                    break;
                            }
                        }
                        if (slot != -1)
                        {
                            createdPlayer.getInventory().getItems()[slot].setItemId(id);
                            createdPlayer.getInventory().getItems()[slot].setItemAmount(amount);
                        }
                    }
                }

                loginElement = xmlDocument.SelectSingleNode("/Player/BankItems");
                if (loginElement != null && loginElement.HasChildNodes)
                {
                    int slot = -1, id = 0, amount = 0;
                    foreach (XmlElement itemElement in loginElement.ChildNodes) //each item.
                    {
                        foreach (XmlElement itemDef in itemElement.ChildNodes) //each item.
                        {
                            switch (itemDef.Name)
                            {
                                case "Slot":
                                    if (!int.TryParse(itemDef.InnerText, out slot))
                                        slot = -1;
                                    if (slot < 0 || slot > Inventory.MAX_INVENTORY_SLOTS) slot = -1;
                                    break;

                                case "Id":
                                    if (!int.TryParse(itemDef.InnerText, out id))
                                        slot = -1;
                                    break;

                                case "Amount":
                                    if (!int.TryParse(itemDef.InnerText, out amount))
                                        slot = -1;
                                    break;
                            }
                        }
                        if (slot != -1)
                        {
                            createdPlayer.getBank().getBank()[slot].setItemId(id);
                            createdPlayer.getBank().getBank()[slot].setItemAmount(amount);
                        }
                    }
                }

                return ReturnCode.LOGIN_OK; //new user.
            }
            catch (Exception e)
            {
                Misc.WriteError(e.Message);
                return ReturnCode.COULD_NOT_COMPLETE;
            }
        }
Esempio n. 18
0
        public static void prayerDrainEvent(Player p)
        {
            Event prayerDrainEvent = new Event(5000 + Misc.random(5000));
            prayerDrainEvent.setAction(() =>
            {
                if (p.getTemporaryAttribute("atBarrows") == null)
                {
                    prayerDrainEvent.stop();
                    return;
                }
                int currentPrayer = p.getSkills().getCurLevel(Skills.SKILL.PRAYER);
                int maxLevel = p.getSkills().getMaxLevel(Skills.SKILL.PRAYER);
                int levelBy10 = currentPrayer - (maxLevel / 6);
                if (currentPrayer > 0)
                {
                    p.getSkills().setCurLevel(Skills.SKILL.PRAYER, levelBy10);
                    p.getPackets().sendSkillLevel(Skills.SKILL.PRAYER);
                }
                int[] array = p.getLocation().getZ() == 0 ? HEADS[1] : HEADS[0];
                int head = array[Misc.random(array.Length - 1)];
                int slot = Misc.random(5);
                if (slot == 0)
                {
                    slot = 1;
                }
                p.getPackets().itemOnInterface(24, slot, 100, head);
                p.getPackets().animateInterface(2085, 24, slot);
                prayerDrainEvent.setTick(5000 + Misc.random(15000));

                Event animateEvent = new Event(4000);
                animateEvent.setAction(() =>
                {
                    p.getPackets().itemOnInterface(24, slot, 100, -1);
                    p.getPackets().animateInterface(-1, 24, slot);
                    animateEvent.stop();
                });
                Server.registerEvent(animateEvent);
            });
            Server.registerEvent(prayerDrainEvent);
        }
Esempio n. 19
0
        /**
         * Handles a skill cape emote: checks appropriate levels,
         * finds the correct animation + graphic, etc.
         * @param player
         */
        public static bool emote(Player player)
        {
            Skills.SKILL skill = Skills.SKILL.ATTACK;
            int skillcapeAnimation = -1, skillcapeGraphic = -1;
            Item cape = player.getEquipment().getSlot(ItemData.EQUIP.CAPE);
            if (cape.getItemId() <= 0)
            {
                return false;
            }
            bool didEmote = true;
            switch (cape.getItemId())
            {
                /*
                 * Attack cape.
                 */
                case 9747:
                case 9748:
                    skill = Skills.SKILL.ATTACK;
                    skillcapeAnimation = 4959;
                    skillcapeGraphic = 823;
                    break;
                /*
                 * Defense cape.
                 */
                case 9753:
                case 9754:
                    skill = Skills.SKILL.DEFENCE;
                    skillcapeAnimation = 4961;
                    skillcapeGraphic = 824;
                    break;
                /*
                 * Strength cape.
                 */
                case 9750:
                case 9751:
                    skill = Skills.SKILL.STRENGTH;
                    skillcapeAnimation = 4981;
                    skillcapeGraphic = 828;
                    break;
                /*
                 * Hitpoints cape.
                 */
                case 9768:
                case 9769:
                    skill = Skills.SKILL.HITPOINTS;
                    skillcapeAnimation = 4971;
                    skillcapeGraphic = 833;
                    break;
                /*
                 * Ranging cape.
                 */
                case 9756:
                case 9757:
                    skill = Skills.SKILL.RANGE;
                    skillcapeAnimation = 4973;
                    skillcapeGraphic = 832;
                    break;
                /*
                 * Prayer cape.
                 */
                case 9759:
                case 9760:
                    skill = Skills.SKILL.PRAYER;
                    skillcapeAnimation = 4979;
                    skillcapeGraphic = 829;
                    break;
                /*
                 * Magic cape.
                 */
                case 9762:
                case 9763:
                    skill = Skills.SKILL.MAGIC;
                    skillcapeAnimation = 4939;
                    skillcapeGraphic = 813;
                    break;
                /*
                 * Cooking cape.
                 */
                case 9801:
                case 9802:
                    skill = Skills.SKILL.COOKING;
                    skillcapeAnimation = 4955;
                    skillcapeGraphic = 821;
                    break;
                /*
                 * Woodcutting cape.
                 */
                case 9807:
                case 9808:
                    skill = Skills.SKILL.WOODCUTTING;
                    skillcapeAnimation = 4957;
                    skillcapeGraphic = 822;
                    break;
                /*
                 * Fletching cape.
                 */
                case 9783:
                case 9784:
                    skill = Skills.SKILL.FLETCHING;
                    skillcapeAnimation = 4937;
                    skillcapeGraphic = 812;
                    break;
                /*
                 * Fishing cape.
                 */
                case 9798:
                case 9799:
                    skill = Skills.SKILL.FISHING;
                    skillcapeAnimation = 4951;
                    skillcapeGraphic = 819;
                    break;
                /*
                 * Firemaking cape.
                 */
                case 9804:
                case 9805:
                    skill = Skills.SKILL.FIREMAKING;
                    skillcapeAnimation = 4975;
                    skillcapeGraphic = 831;
                    break;
                /*
                 * Crafting cape.
                 */
                case 9780:
                case 9781:
                    skill = Skills.SKILL.CRAFTING;
                    skillcapeAnimation = 4949;
                    skillcapeGraphic = 818;
                    break;
                /*
                 * Smithing cape.
                 */
                case 9795:
                case 9796:
                    skill = Skills.SKILL.SMITHING;
                    skillcapeAnimation = 4943;
                    skillcapeGraphic = 815;
                    break;
                /*
                 * Mining cape.
                 */
                case 9792:
                case 9793:
                    skill = Skills.SKILL.MINING;
                    skillcapeAnimation = 4941;
                    skillcapeGraphic = 814;
                    break;
                /*
                 * Herblore cape.
                 */
                case 9774:
                case 9775:
                    skill = Skills.SKILL.HERBLORE;
                    skillcapeAnimation = 4969;
                    skillcapeGraphic = 835;
                    break;
                /*
                 * Agility cape.
                 */
                case 9771:
                case 9772:
                    skill = Skills.SKILL.AGILITY;
                    skillcapeAnimation = 4977;
                    skillcapeGraphic = 830;
                    break;
                /*
                 * Thieving cape.
                 */
                case 9777:
                case 9778:
                    skill = Skills.SKILL.THIEVING;
                    skillcapeAnimation = 4965;
                    skillcapeGraphic = 826;
                    break;
                /*
                 * Slayer cape.
                 */
                case 9786:
                case 9787:
                    skill = Skills.SKILL.SLAYER;
                    skillcapeAnimation = 4937;//need animation
                    skillcapeGraphic = 812;//need graphic
                    break;
                /*
                 * Farming cape.
                 */
                case 9810:
                case 9811:
                    skill = Skills.SKILL.FARMING;
                    skillcapeAnimation = 4963;
                    skillcapeGraphic = 825;
                    break;
                /*
                 * Runecraft cape.
                 */
                case 9765:
                case 9766:
                    skill = Skills.SKILL.RUNECRAFTING;
                    skillcapeAnimation = 4947;
                    skillcapeGraphic = 817;
                    break;
                /*
                 * Hunter's cape
                 */
                case 9948:
                case 9949:
                    skill = Skills.SKILL.HUNTER;
                    skillcapeAnimation = 5158;
                    skillcapeGraphic = 907;
                    break;
                /*
                 * Construct. cape.
                 */
                case 9789:
                case 9790:
                    skill = Skills.SKILL.CONSTRUCTION;
                    skillcapeAnimation = 4953;
                    skillcapeGraphic = 820;
                    break;
                /*
                 * Summoning cape.
                 */
                case 12169:
                case 12170:
                    skill = Skills.SKILL.SUMMONING;
                    skillcapeAnimation = 8525;
                    skillcapeGraphic = 1515;
                    break;
                /*
                 * Quest cape.
                 */
                case 9813:
                    skillcapeAnimation = 4945;
                    skillcapeGraphic = 816;
                    player.setLastAnimation(new Animation(skillcapeAnimation));
                    player.setLastGraphics(new Graphics(skillcapeGraphic));
                    return true;

                default:
                    didEmote = false;
                    break;
            }
            if (player.getSkills().getMaxLevel(skill) == 99)
            {
                player.setLastAnimation(new Animation(skillcapeAnimation));
                player.setLastGraphics(new Graphics(skillcapeGraphic));
            }
            else
            {
                didEmote = false;
            }
            return didEmote;
        }
Esempio n. 20
0
 private static bool canCastSpell(Player p, Entity target, int i, bool fakeNPC)
 {
     // fakeNPC is used to keep location when autocasting.
     if (fakeNPC)
     {
         return !p.isDead();
     }
     if (target.isDead() || p.isDead() || target.isDestroyed() || p.isDestroyed())
     {
         return false;
     }
     if (target is Npc)
     {
         if (((Npc)target).getHp() <= 0)
         {
             return false;
         }
         if (i == 47)
         {
             p.getPackets().sendMessage("You cannot cast Teleblock upon an NPC.");
             return false;
         }
     }
     if ((target is Player) && (p is Player))
     {
         if (Location.inFightPits(target.getLocation()) && Location.inFightPits(target.getLocation()))
         {
             if (!Server.getMinigames().getFightPits().hasGameStarted())
             {
                 return false;
             }
             return true;
         }
         if (p.getDuel() != null)
         {
             if (((Player)target).getDuel() != null)
             {
                 if (p.getDuel().getPlayer2().Equals(((Player)target)) && ((Player)target).getDuel().getPlayer2().Equals(p))
                 {
                     if (p.getDuel().ruleEnabled(DuelSession.RULE.NO_MAGIC))
                     {
                         p.getPackets().sendMessage("Magical combat has been disabled in this duel!");
                         return false;
                     }
                     if (p.getDuel().getStatus() == 6 && ((Player)target).getDuel().getStatus() == 6)
                     {
                         return true;
                     }
                 }
             }
             p.getPackets().sendMessage("That isn't your opponent.");
             return false;
         }
         if (i == 47)
         {
             if (((Player)target).getTemporaryAttribute("teleblocked") != null)
             {
                 p.getPackets().sendMessage("That player already has a teleportation block upon them.");
                 return false;
             }
         }
         if (!Location.inWilderness(target.getLocation()))
         {
             p.getPackets().sendMessage("That player isn't in the wilderness.");
             return false;
         }
         if (!Location.inWilderness(p.getLocation()))
         {
             p.getPackets().sendMessage("You aren't in the wilderness.");
             return false;
         }
         int killerWildLevel = p.getLocation().wildernessLevel();
         int targetWildLevel = ((Player)target).getLocation().wildernessLevel();
         int killerCombatLevel = p.getSkills().getCombatLevel();
         int targetCombatLevel = ((Player)target).getSkills().getCombatLevel();
         int highest = killerCombatLevel > targetCombatLevel ? killerCombatLevel : targetCombatLevel;
         int lowest = highest == killerCombatLevel ? targetCombatLevel : killerCombatLevel;
         int difference = (highest - lowest);
         if (difference > killerWildLevel || difference > targetWildLevel)
         {
             ((Player)p).getPackets().sendMessage("You must move deeper into the wilderness to attack that player.");
             return false;
         }
     }
     if (!Location.inMultiCombat(target.getLocation()))
     {
         if (p.getAttacker() != null && !p.getAttacker().Equals(target))
         {
             p.getPackets().sendMessage("You are already in combat!");
             return false;
         }
         if (target.getAttacker() != null && !target.getAttacker().Equals(p))
         {
             string type = target is Player ? "player" : "npc";
             p.getPackets().sendMessage("That " + type + " is already in combat.");
             return false;
         }
     }
     if (p.getSkills().getCurLevel(Skills.SKILL.MAGIC) < SPELL_LEVEL[i])
     {
         p.getPackets().sendMessage("You need a Magic level of " + SPELL_LEVEL[i] + " to cast that spell.");
         return false;
     }
     if (!hasRunes(p, RUNES[i], RUNE_AMOUNTS[i]))
     {
         p.getPackets().sendMessage("You do not have enough runes to cast that spell.");
         return false;
     }
     if (NEEDS_STAFF[i])
     {
         if ((i != 38 && p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON) != STAFF[i]) || (i == 38 && p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON) != 8841 && p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON) != STAFF[i]))
         {
             p.getPackets().sendMessage("You need to wield " + STAFF_NAME[i] + " to cast this spell.");
             return false;
         }
     }
     if (i == 37)
     {
         if (p.getEquipment().getItemInSlot(ItemData.EQUIP.CAPE) != 2412)
         {
             p.getPackets().sendMessage("You need to wear the Cape of Saradomin to be able to cast Saradomin Strike.");
             return false;
         }
     }
     if (i == 38)
     {
         if (p.getEquipment().getItemInSlot(ItemData.EQUIP.CAPE) != 2413)
         {
             p.getPackets().sendMessage("You need to wear the Cape of Guthix to be able to cast Claws of Guthix.");
             return false;
         }
     }
     if (i == 39)
     {
         if (p.getEquipment().getItemInSlot(ItemData.EQUIP.CAPE) != 2414)
         {
             p.getPackets().sendMessage("You need to wear the Cape of Zamorak to be able to cast Flames of Zamorak.");
             return false;
         }
     }
     return true;
 }
Esempio n. 21
0
 public static void restorePotion(Player p, Skills.SKILL skill, int minRestore, int maxRestore)
 {
     int restoreAmount = Misc.random(minRestore, maxRestore);
     if (p.getSkills().getCurLevel(skill) >= p.getSkills().getMaxLevel(skill))
         return;
     int mustRestore = p.getSkills().getMaxLevel(skill) - p.getSkills().getCurLevel(skill);
     if (restoreAmount > mustRestore) restoreAmount = mustRestore;
     p.getSkills().setCurLevel(skill, p.getSkills().getCurLevel(skill) + restoreAmount);
     checkOverdose(p, skill);
 }
Esempio n. 22
0
        private static bool canCastSpell2(Player p, Entity target, int i, bool fakeNPC)
        {
            // fakeNPC is used to keep location when autocasting.
            if (fakeNPC)
            {
                return !p.isDead();
            }
            if (target.isDead() || p.isDead() || target.isDestroyed() || p.isDestroyed())
            {
                return false;
            }
            if (target is Npc)
            {
                if (((Npc)target).getHp() <= 0)
                {
                    return false;
                }
            }
            if ((target is Player) && (p is Player))
            {
                if (Location.inFightPits(target.getLocation()) && Location.inFightPits(target.getLocation()))
                {
                    if (!Server.getMinigames().getFightPits().hasGameStarted())
                    {
                        return false;
                    }
                    return true;
                }
                if (p.getDuel() != null)
                {
                    if (((Player)target).getDuel() != null)
                    {
                        if (p.getDuel().getPlayer2().Equals(((Player)target)) && ((Player)target).getDuel().getPlayer2().Equals(p))
                        {
                            if (p.getDuel().ruleEnabled(DuelSession.RULE.NO_MAGIC))
                            {
                                return false;
                            }
                            if (p.getDuel().getStatus() == 6 && ((Player)target).getDuel().getStatus() == 6)
                            {
                                return true;
                            }
                        }
                    }
                    return false;
                }
                if (!Location.inWilderness(target.getLocation()) && !Location.inWilderness(p.getLocation()))
                    return false;

                int killerWildLevel = p.getLocation().wildernessLevel();
                int targetWildLevel = ((Player)target).getLocation().wildernessLevel();
                int killerCombatLevel = p.getSkills().getCombatLevel();
                int targetCombatLevel = ((Player)target).getSkills().getCombatLevel();
                int highest = killerCombatLevel > targetCombatLevel ? killerCombatLevel : targetCombatLevel;
                int lowest = highest == killerCombatLevel ? targetCombatLevel : killerCombatLevel;
                int difference = (highest - lowest);
                if (difference > killerWildLevel || difference > targetWildLevel)
                {
                    return false;
                }
            }
            return true;
        }
Esempio n. 23
0
 public static void superRestorePotion(Player p, Skills.SKILL skill, double percentage)
 {
     percentage = p.getSkills().getMaxLevel(skill) * percentage;
     if (p.getSkills().getCurLevel(skill) == p.getSkills().getMaxLevel(skill) * percentage)
         return;
     if (p.getSkills().getCurLevel(skill) >= p.getSkills().getMaxLevel(skill))
         return;
     p.getSkills().setCurLevel(skill, p.getSkills().getCurLevel(skill) + (int)percentage);
     checkOverdose(p, skill);
     if (p.getSkills().getCurLevel(skill) <= 0)
         p.getSkills().setCurLevel(skill, 1);
 }
Esempio n. 24
0
        public static void showBentleyDialogue(Player p, int status)
        {
            int newStatus = -1;
            p.getPackets().softCloseInterfaces();
            if (p.getTemporaryAttribute("unmovable") != null)
            {
                return;
            }
            switch (status)
            {
                case 240:
                    p.getPackets().sendNPCHead(4540, 241, 2);
                    p.getPackets().modifyText("Captain Bentley", 241, 3);
                    p.getPackets().modifyText("Well, hello there " + p.getLoginDetails().getUsername() + ", ready to set sail?", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 241;
                    break;

                case 241:
                    p.getPackets().modifyText("I'd like to travel to..", 235, 1);
                    p.getPackets().modifyText("Canifis", 235, 2);
                    p.getPackets().modifyText("Waterbirth Isle", 235, 3);
                    p.getPackets().modifyText("Pest Control", 235, 4);
                    p.getPackets().modifyText("Warrior Guild", 235, 5);
                    p.getPackets().modifyText("Fremmenik Shore", 235, 6);
                    p.getPackets().sendChatboxInterface2(235);
                    newStatus = 242;
                    break;

                case 242: // Canifis
                    travel(p, 0, false);
                    break;

                case 243: // Waterbirth isle
                    travel(p, 1, false);
                    break;

                case 244: // Pest control
                    travel(p, 2, false);
                    break;

                case 245: // Warrior guild
                    int attackLevel = p.getSkills().getMaxLevel(Skills.SKILL.ATTACK);
                    int strengthLevel = p.getSkills().getMaxLevel(Skills.SKILL.STRENGTH);
                    bool hasA99 = attackLevel == 99 || strengthLevel == 99;
                    if (((attackLevel + strengthLevel) >= 130) || hasA99)
                    {
                        travel(p, 3, false);
                    }
                    else
                    {
                        p.getPackets().sendNPCHead(4540, 243, 2);
                        p.getPackets().modifyText("Captain Bentley", 243, 3);
                        p.getPackets().modifyText("I'm sorry " + p.getLoginDetails().getUsername() + ", I cannot take you there.", 243, 4);
                        p.getPackets().modifyText("A combined Attack & Strength level of 130 is ", 243, 5);
                        p.getPackets().modifyText("required to use The Warrior Guild.", 243, 6);
                        p.getPackets().animateInterface(9827, 243, 2);
                        p.getPackets().sendChatboxInterface2(243);
                    }
                    break;

                case 246: // Fremmenik shore
                    travel(p, 4, false);
                    break;
            }
            if (newStatus != -1)
            {
                p.setTemporaryAttribute("dialogue", newStatus);
            }
        }
Esempio n. 25
0
        private static void eatFood(Player p, int i, int j, int slot)
        {
            //delay at which you eat food 0.5 seconds (half a second per eat).
            int delay = 500;
            //If you are dead or yourHp is zero (this should be enough), also if variable is set to die from next attack
            if (p.isDead() || p.getHp() <= 0 || p.getTemporaryAttribute("willDie") != null)
                return;

            //Last time you ate timer was previously set.
            if (p.getTemporaryAttribute("eatFoodTimer") != null)
            {
                //Check if the timer has passed the time of 1.2 seconds
                if (Environment.TickCount - (int)p.getTemporaryAttribute("eatFoodTimer") < 1200)
                {
                    return;
                }
            }
            //if you are in a duel
            if (p.getDuel() != null)
            {
                //dueling with No Food rule enabled
                if (p.getDuel().ruleEnabled(DuelSession.RULE.NO_FOOD))
                {
                    p.getPackets().sendMessage("Food has been disabled for this duel!");
                    return;
                }
            }
            //Set timer right now because you are eating some food.
            p.setTemporaryAttribute("eatFoodTimer", Environment.TickCount);
            //while you are eating the target you are attacking gets reset.
            p.setTarget(null);
            p.resetCombatTurns();
            p.setEntityFocus(65535);
            p.getPackets().closeInterfaces();
            p.removeTemporaryAttribute("autoCasting");

            //start eating the food at delay which is 0.5 of a second / half a second.
            Event eatFoodEvent = new Event(delay);
            eatFoodEvent.setAction(() =>
            {
                //make the food eating event stop after this time.
                eatFoodEvent.stop();
                //if you are dead or your hp is zero aka dead.
                if (p.isDead() || p.getHp() <= 0)
                {
                    return;
                }
                int newHealth = p.getSkills().getCurLevel(Skills.SKILL.HITPOINTS) + FOOD_HEAL[j];
                int item = i != 2 && FOOD[i + 1][j] != -1 ? FOOD[i + 1][j] : -1;
                if (!p.getInventory().replaceItemSlot(FOOD[i][j], item, slot))
                {
                    return;
                }
                p.getPackets().sendMessage("You eat the " + ItemData.forId(FOOD[i][j]).getName().ToLower() + ".");
                p.getSkills().setCurLevel(Skills.SKILL.HITPOINTS, newHealth > p.getSkills().getMaxLevel(Skills.SKILL.HITPOINTS) ? p.getSkills().getMaxLevel(Skills.SKILL.HITPOINTS) : newHealth);
                p.setLastAnimation(new Animation(829));
                p.getPackets().sendSkillLevel(Skills.SKILL.HITPOINTS);
            });
            Server.registerEvent(eatFoodEvent);
        }
Esempio n. 26
0
        public static double getPlayerMaxHit(Player player, int strBonusIncrease)
        {
            AttackStyle.CombatSkill fightType = player.getAttackStyle().getSkill();
            double myCurStrength = (double)player.getSkills().getCurLevel(Skills.SKILL.STRENGTH);
            double myEquipStrengthBonus = (double)(player.getEquipment().getBonus(Equipment.BONUS.STRENGTH) + strBonusIncrease);
            double fightingStyle = 0;
            double powerMultiplier = 1;
            double dharokModifier = 1;
            double damageMultiplier = 1;
            int strPrayer = player.getPrayers().getStrengthPrayer();
            if (strPrayer == 1)
            {
                powerMultiplier += 0.05;
            }
            else if (strPrayer == 2)
            {
                powerMultiplier += 0.1;
            }
            else if (strPrayer == 3)
            {
                powerMultiplier += 0.15;
            }
            else if (player.getPrayers().getSuperPrayer() == 1)
            {
                powerMultiplier += 0.18;
            }
            else if (player.getPrayers().getSuperPrayer() == 2)
            {
                powerMultiplier += 0.23;
            }

            if (wearingMeleeVoid(player))
            {
                damageMultiplier += 0.1;
            }
            else if (wearingDharok(player) && Misc.random(3) == 0)
            {
                dharokModifier = Misc.random((int)((player.getSkills().getGreaterLevel(Skills.SKILL.HITPOINTS) - player.getSkills().getCurLevel(Skills.SKILL.HITPOINTS)) * 0.1));
            }
            if (fightType.Equals(AttackStyle.CombatSkill.AGGRESSIVE))
            {
                fightingStyle = 3;
            }
            else if (fightType.Equals(AttackStyle.CombatSkill.CONTROLLED))
            {
                fightingStyle = 1;
            }

            double cumulativeStrength = ((myCurStrength) * (powerMultiplier) + fightingStyle) * dharokModifier;
            double maxHit = ((13 + (cumulativeStrength) + (myEquipStrengthBonus / 8) + ((cumulativeStrength * myEquipStrengthBonus) / 64)) * damageMultiplier); // NEW MAX HIT FORMULA
            maxHit = maxHit / 10; //this is temporary because I haven't yet fully implemented the huge damage system.
            return maxHit;
        }
Esempio n. 27
0
 private void doRedemption(Player p)
 {
     p.setLastGraphics(new Graphics(437));
     if (lastAttacker == null)
     {
         return;
     }
     if (lastAttacker.isDead() || lastAttacker.isHidden() || lastAttacker.isDestroyed())
     {
         return;
     }
     Location l = p.getLocation();
     int maxHit = (int)(p.getSkills().getMaxLevel(Skills.SKILL.PRAYER) * 0.25);
     if (lastAttacker.getLocation().inArea(l.getX() - 1, l.getY() - 1, l.getX() + 1, l.getY() + 1))
     {
         int damage = Misc.random(maxHit);
         if (damage > lastAttacker.getHp())
         {
             damage = lastAttacker.getHp();
         }
         lastAttacker.hit(damage);
     }
     p.getSkills().setCurLevel(Skills.SKILL.PRAYER, 0);
     p.getPackets().sendSkillLevel(Skills.SKILL.PRAYER);
 }
Esempio n. 28
0
 public static double getRangeMaxHit(Player p, int bow, int arrow)
 {
     double hit = 0;
     double a = p.getSkills().getCurLevel(Skills.SKILL.RANGE);
     double b = 1.00;
     double c = 0;
     int d = getRangeStrength(p);
     int prayer = p.getPrayers().getRangePrayer();
     if (prayer == 1)
     {
         b *= 1.05;
     }
     else if (prayer == 2)
     {
         b *= 1.10;
     }
     else if (prayer == 3)
     {
         b *= 1.15;
     }
     if (wearingRangeVoid(p))
     {
         b *= 1.15;
     }
     c = (a * b);
     if (p.getAttackStyle().getStyle().Equals(AttackStyle.CombatStyle.RANGE_ACCURATE))
     {
         c += 3.00;
     }
     hit = ((c + 8) * (d + 64) / 640);
     return Math.Floor(hit);
 }
Esempio n. 29
0
 private static void appendHitUpdate(Player p, PacketBuilder updateBlock)
 {
     int ratio = p.getSkills().getCurLevel(Skills.SKILL.HITPOINTS) * 255 / p.getSkills().getMaxLevel(Skills.SKILL.HITPOINTS);
     if (p.getSkills().getCurLevel(Skills.SKILL.HITPOINTS) > p.getSkills().getMaxLevel(Skills.SKILL.HITPOINTS))
     {
         ratio = p.getSkills().getMaxLevel(3) * 255 / p.getSkills().getCurLevel(Skills.SKILL.HITPOINTS);
     }
     if (p.getHits().getHitDamage1() < 128) //damage can be either addByte [for damage less then 128 otherwise UShort]
         updateBlock.addByte((byte)p.getHits().getHitDamage1());
     else
         updateBlock.addUShort(p.getHits().getHitDamage1() + 0x8000);
     updateBlock.addByteA((byte)p.getHits().getHitType1());
     updateBlock.addByteS(ratio);
 }
Esempio n. 30
0
        public static void doObstacle(Player p, int index)
        {
            if (p.getTemporaryAttribute("unmovable") != null)
            {
                return;
            }
            switch (index)
            {
                case 0: // 3 planks, northern (east side)
                case 1: // 3 planks, middle (east side)
                case 2: // 3 planks, southern (east side)
                case 3: // 3 planks, northern (west side)
                case 4: // 3 planks, middle (west side)
                case 5: // 3 planks, southern (west side)
                    int logXCoord = index <= 2 ? (int)AGILITY_ARENA_OBJECTS[index][1] + 1 : (int)AGILITY_ARENA_OBJECTS[index][1] - 1;
                    int logDirectionX = index <= 2 ? -7 : +7;
                    CoordinateEvent plankObstaclesCoordinateEvent = new CoordinateEvent(p, new Location(logXCoord, (int)AGILITY_ARENA_OBJECTS[index][2], 3));
                    plankObstaclesCoordinateEvent.setAction(() =>
                    {
                        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(logDirectionX, 0);
                        Event plankObstaclesEvent = new Event(4300);
                        plankObstaclesEvent.setAction(() =>
                        {
                            plankObstaclesEvent.stop();
                            p.removeTemporaryAttribute("unmovable");
                            p.getAppearance().setWalkAnimation(-1);
                            p.getUpdateFlags().setAppearanceUpdateRequired(true);
                            p.getSkills().addXp(Skills.SKILL.AGILITY, (double)AGILITY_ARENA_OBJECTS[index][3]);
                            p.getWalkingQueue().setRunToggled(running);
                        });
                        Server.registerEvent(plankObstaclesEvent);
                    });
                    Server.registerCoordinateEvent(plankObstaclesCoordinateEvent);
                    break;

                case 6: //Handholds obstacle east of planks.
                case 7: //Handholds obstacle west of planks.
                    int handHoldsDirectionX = 1;
                    int handHoldsDirectionY = 1;
                    if (index == 6)
                    {
                        handHoldsDirectionX = -1;
                        handHoldsDirectionY = +1;
                    }
                    else if (index == 7)
                    {
                        handHoldsDirectionX = +1;
                        handHoldsDirectionY = -1;
                    }
                    CoordinateEvent handholdsObstacleCoordinateEvent = new CoordinateEvent(p, new Location((int)AGILITY_ARENA_OBJECTS[index][1], (int)AGILITY_ARENA_OBJECTS[index][2], 3));
                    handholdsObstacleCoordinateEvent.setAction(() =>
                    {
                        bool running = p.getWalkingQueue().isRunToggled();
                        p.getWalkingQueue().setRunToggled(false);
                        p.getWalkingQueue().resetWalkingQueue();
                        p.getPackets().clearMapFlag();
                        p.setTemporaryAttribute("unmovable", true);
                        p.setLastAnimation(new Animation(1121));
                        p.setFaceLocation(new Location(p.getLocation().getX(), p.getLocation().getY() + handHoldsDirectionY, 3));
                        Event handholdsObstaclesEvent = new Event(700);
                        int handholdsObstaclesCounter = 0;
                        handholdsObstaclesEvent.setAction(() =>
                        {
                            p.setLastAnimation(new Animation(1122));
                            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 + handHoldsDirectionX, lY, 0, 5, 0));
                            if (handholdsObstaclesCounter++ >= 7)
                            {
                                p.setLastAnimation(new Animation(65535));
                                handholdsObstaclesEvent.stop();
                                p.removeTemporaryAttribute("unmovable");
                                p.getSkills().addXp(Skills.SKILL.AGILITY, (double)AGILITY_ARENA_OBJECTS[index][3]);
                                p.getWalkingQueue().setRunToggled(running);
                                return;
                            }
                            Event teleportEvent = new Event(500);
                            teleportEvent.setAction(() =>
                            {
                                teleportEvent.stop();
                                p.teleport(new Location(p.getLocation().getX() + handHoldsDirectionX, p.getLocation().getY(), 3));
                            });
                            Server.registerEvent(teleportEvent);
                        });
                        Server.registerEvent(handholdsObstaclesEvent);
                    });
                    Server.registerCoordinateEvent(handholdsObstacleCoordinateEvent);
                    break;
            }
        }