Пример #1
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);
        }
Пример #2
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();
     }
 }