public static int getWalkAnim(Player p)
        {
            int    id     = p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON);
            string weapon = ItemData.forId(id).getName();

            if (weapon.Equals("Saradomin staff") || weapon.Equals("Guthix staff") || weapon.Equals("Zamorak staff"))
            {
                return(0x333);
            }
            if (weapon.Contains("flail"))
            {
                return(2060);
            }
            if (weapon.Contains("Karil"))
            {
                return(2076);
            }
            if (weapon.Contains("Granite maul"))
            {
                return(1663);
            }
            if (weapon.Equals("Abyssal whip"))
            {
                return(1660);
            }
            if (id == 4718 || weapon.EndsWith("2h sword") || weapon.Contains("Tzhaar-ket-om") || weapon.EndsWith("godsword") || weapon.Equals("Saradomin sword"))
            {
                return(7046);
            }
            if (weapon.Contains("Guthan") || weapon.Contains("spear") || weapon.EndsWith("halberd") || weapon.Contains("Staff") || weapon.Contains("staff") || weapon.Contains("wand") || weapon.Equals("Void knight mace"))
            {
                return(1146);
            }
            return(819);
        }
        public static int getStandAnim(Player p)
        {
            int    id     = p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON);
            string weapon = ItemData.forId(id).getName();

            if (weapon.Contains("Dharok"))
            {
                return(2065);
            }
            if (weapon.Contains("flail"))
            {
                return(2061);
            }
            if (weapon.Contains("Karil"))
            {
                return(2074);
            }
            if (weapon.Contains("Tzhaar-ket-om"))
            {
                return(0x811);
            }
            if (weapon.Equals("Saradomin staff") || weapon.Equals("Guthix staff") || weapon.Equals("Zamorak staff"))
            {
                return(0x328);
            }
            if (weapon.Contains("Guthan") || weapon.EndsWith("spear") || weapon.EndsWith("halberd") || weapon.Contains("Staff") || weapon.Contains("staff") || weapon.Contains("wand") || weapon.Contains("Dragon longsword") || weapon.Equals("Void knight mace"))
            {
                return(809);
            }
            if (weapon.Contains("2h") || weapon.EndsWith("godsword") || weapon.Equals("Saradomin sword"))
            {
                return(7047);
            }
            if (weapon.Equals("Abyssal whip"))
            {
                return(10080);
            }
            if (weapon.Contains("Granite maul"))
            {
                return(1662);
            }
            return(808);
        }
 public bool addToStack(int id, int amount, Location location, Player p)
 {
     if (!ItemData.forId(id).isStackable())
     {
         return(false);
     }
     foreach (GroundItem i in items)
     {
         if (i.getLocation().Equals(location) && i.getItemId() == id)
         {
             if (!i.isGlobal() && i.getOwner().Equals(p))
             {
                 i.setItemAmount(i.getItemAmount() + amount);
                 p.getPackets().clearGroundItem(i);
                 p.getPackets().createGroundItem(i);
                 return(true);
             }
         }
     }
     return(false);
 }
示例#4
0
 public static int[] getProtectedItem1(Player p)
 {
     int[] protectedItem = new int[2];
     protectedItem[0] = -1;
     for (int i = 0; i < 28; i++)
     {
         if (p.getInventory().getSlot(i).itemId == -1)
         {
             continue;
         }
         int price = p.getInventory().getSlot(i).getDefinition().getPrice().getMaximumPrice();
         if ((price > ItemData.forId(protectedItem[0]).getPrice().getMaximumPrice()))
         {
             protectedItem[0] = p.getInventory().getSlot(i).getItemId();
             protectedItem[1] = INVENTORY;
         }
     }
     foreach (ItemData.EQUIP equip in Enum.GetValues(typeof(ItemData.EQUIP)))
     {
         if (equip == ItemData.EQUIP.NOTHING)
         {
             continue;
         }
         if (p.getEquipment().getSlot(equip).itemId == -1)
         {
             continue;
         }
         int price = p.getEquipment().getSlot(equip).getDefinition().getPrice().getMaximumPrice();
         if (price > ItemData.forId(protectedItem[0]).getPrice().getMaximumPrice())
         {
             protectedItem[0] = p.getEquipment().getSlot(equip).getItemId();
             protectedItem[1] = EQUIPMENT;
         }
     }
     return(protectedItem);
 }
        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);
        }
        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);
        }
示例#7
0
        public static int[] getProtectedItem2(Player p)
        {
            int[] protectedItem = new int[2];
            protectedItem[0] = -1;
            int[] protectedItem1 = getProtectedItem1(p);
            bool  save;

            for (int i = 0; i < 28; i++)
            {
                if (p.getInventory().getSlot(i).itemId == -1)
                {
                    continue;
                }
                int amt   = p.getInventory().getItemAmount(p.getInventory().getItemInSlot(i));
                int price = p.getInventory().getSlot(i).getDefinition().getPrice().getMaximumPrice();
                if (price > ItemData.forId(protectedItem[0]).getPrice().getMaximumPrice())
                {
                    save = true;
                    if (protectedItem1[1] == INVENTORY)
                    {
                        if (protectedItem1[0] == p.getInventory().getItemInSlot(i))
                        {
                            if (amt < 2)
                            {
                                save = false;
                            }
                        }
                    }
                    if (save)
                    {
                        protectedItem[0] = p.getInventory().getSlot(i).getItemId();
                        protectedItem[1] = INVENTORY;
                    }
                }
            }
            foreach (ItemData.EQUIP equip in Enum.GetValues(typeof(ItemData.EQUIP)))
            {
                if (equip == ItemData.EQUIP.NOTHING)
                {
                    continue;
                }
                if (p.getEquipment().getSlot(equip).itemId == -1)
                {
                    continue;
                }
                int price = p.getEquipment().getSlot(equip).getDefinition().getPrice().getMaximumPrice();
                int amt   = p.getEquipment().getAmountInSlot(equip);
                if (price > ItemData.forId(protectedItem[0]).getPrice().getMaximumPrice())
                {
                    save = true;
                    if (protectedItem1[1] == EQUIPMENT)
                    {
                        if (protectedItem1[0] == p.getEquipment().getItemInSlot(equip))
                        {
                            if (amt < 2)
                            {
                                save = false;
                            }
                        }
                    }
                    if (save)
                    {
                        protectedItem[0] = p.getEquipment().getSlot(equip).getItemId();
                        protectedItem[1] = EQUIPMENT;
                    }
                }
            }
            return(protectedItem);
        }