Пример #1
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);
 }
        public static double getPlayerMaxHit(Player player, int strBonusIncrease)
        {
            AttackStyle.CombatSkill fightType = player.getAttackStyle().getSkill();
            double myCurStrength = player.getSkills().getCurLevel(Skills.SKILL.STRENGTH);
            double myEquipStrengthBonus = (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))
            {
                dharokModifier = (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;
            //Can't change this. For huge damage it's a visual effect, not real maxHit!
            double maxHit = ((13 + (cumulativeStrength) + (myEquipStrengthBonus / 8) + ((cumulativeStrength * myEquipStrengthBonus) / 64)) * damageMultiplier) / 10; // NEW MAX HIT FORMULA
            return maxHit;
        }
Пример #3
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);
            }
        }
Пример #4
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;
		    }
		    double damage = misc.randomDouble(npc.getMaxHit());
            PrayerData.PrayerHeadIcon prayerHeadIcon = p.getPrayers().getHeadIcon();
		    int hitDelay = npc.getHitDelay();
		    int animation = npc.getAttackAnimation();
		    switch(npc.getId()) {
			    case 2734: // Tz-Kih (lvl 22)
			    case 2735:
                    if (prayerHeadIcon == PrayerData.PrayerHeadIcon.MELEE)
                    {
					    damage = 0;
				    }
				    break;
				
			    case 2739: // Tz-Xil (lvl 90)
			    case 2740:
                    if (prayerHeadIcon == PrayerData.PrayerHeadIcon.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 (prayerHeadIcon == PrayerData.PrayerHeadIcon.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.randomDouble(49);
                        if (prayerHeadIcon == PrayerData.PrayerHeadIcon.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.randomDouble(64);
                        if (prayerHeadIcon == PrayerData.PrayerHeadIcon.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 -= (int)(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);
	    }
	    private void doRedemption(Player p) {
		    p.setLastGraphics(new Graphics(437));
		    if (lastAttacker == null) {
			    return;
		    }
		    if (lastAttacker.isDead() || !lastAttacker.isVisible() || lastAttacker.isDestroyed()) {
			    return;
		    }
		    Location l = p.getLocation();
		    double maxHit = p.getSkills().getMaxLevel(Skills.SKILL.PRAYER) * 0.25;
		    if (lastAttacker.getLocation().inArea(l.getX() - 1, l.getY() - 1, l.getX() + 1, l.getY() + 1)) {
			    double damage = misc.randomDouble(maxHit);
			    if (damage > lastAttacker.getHp()) {
				    damage = lastAttacker.getHp();
			    }
			    lastAttacker.hit(damage);
		    }
		    p.getSkills().setCurLevel(Skills.SKILL.PRAYER, 0);
            p.getPackets().sendSkillLevel(Skills.SKILL.PRAYER);
	    }
	    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);
		    }
	    }
Пример #7
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);
	    }
Пример #8
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();
		    }
	    }
	    public static double getRangeMaxHit(Player p, int bow, int arrow) {
            /*
            int a = p.getEquipment().getBonus(Equipment.BONUS.CRUSH_ATTACK);
            int b = p.getEquipment().getBonus(Equipment.BONUS.CRUSH_DEFENCE);
            int c = p.getEquipment().getBonus(Equipment.BONUS.MAGIC_ATTACK);
            int d = p.getEquipment().getBonus(Equipment.BONUS.MAGIC_DEFENCE);
            int e = p.getEquipment().getBonus(Equipment.BONUS.PRAYER);
            int f = p.getEquipment().getBonus(Equipment.BONUS.RANGED_ATTACK);
            int g = p.getEquipment().getBonus(Equipment.BONUS.RANGED_DEFENCE);
            int h = p.getEquipment().getBonus(Equipment.BONUS.SLASH_ATTACK);
            int i = p.getEquipment().getBonus(Equipment.BONUS.SLASH_DEFENCE);
            int j = p.getEquipment().getBonus(Equipment.BONUS.STAB_ATTACK);
            int k = p.getEquipment().getBonus(Equipment.BONUS.STAB_DEFENCE);
            int l = p.getEquipment().getBonus(Equipment.BONUS.STRENGTH);
            int m = p.getEquipment().getBonus(Equipment.BONUS.SUMMONING);
            */

            double rangeLevel = p.getSkills().getCurLevel(Skills.SKILL.RANGE);
            //TODO: use rangeAttackBonus in the formula somehow!.
            double rangeAttackBonus = p.getEquipment().getBonus(Equipment.BONUS.RANGED_ATTACK);
		    double rangeAttackMultipler = 1.00;
		    double rangeAttack = 0;
            int rangedWeaponArrowStrength = getRangeWeaponArrowStrength(p);
		    int rangePrayer = p.getPrayers().getRangePrayer();

            if (rangePrayer == 1)
                rangeAttackMultipler *= 1.05; //5% increase
            else if (rangePrayer == 2)
                rangeAttackMultipler *= 1.10; //10% increase
            else if (rangePrayer == 3)
                rangeAttackMultipler *= 1.15; //15% increase

		    if (wearingRangeVoid(p)) {
                rangeAttackMultipler *= 1.15; //15% increase
		    }
            rangeAttack = (rangeLevel * rangeAttackMultipler);
		    if (p.getAttackStyle().getStyle().Equals(AttackStyle.CombatStyle.RANGE_ACCURATE)) {
                rangeAttack += 3.00;
		    }
            double rangeMaxHit = ((rangeAttack + 8) * (rangedWeaponArrowStrength + 64) / 640);
            return rangeMaxHit;
	    }
Пример #10
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;
            }
	    }
        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;
        }
	    public static double getMeleeAttack(Player p) {
            //TODO: implement all Equipment Bonuses to be used for all of these Defence/Melee Attack functions.
            /*
            int a = p.getEquipment().getBonus(Equipment.BONUS.CRUSH_ATTACK);
            int b = p.getEquipment().getBonus(Equipment.BONUS.CRUSH_DEFENCE);
            int c = p.getEquipment().getBonus(Equipment.BONUS.MAGIC_ATTACK);
            int d = p.getEquipment().getBonus(Equipment.BONUS.MAGIC_DEFENCE);
            int e = p.getEquipment().getBonus(Equipment.BONUS.PRAYER);
            int f = p.getEquipment().getBonus(Equipment.BONUS.RANGED_ATTACK);
            int g = p.getEquipment().getBonus(Equipment.BONUS.RANGED_DEFENCE);
            int h = p.getEquipment().getBonus(Equipment.BONUS.SLASH_ATTACK);
            int i = p.getEquipment().getBonus(Equipment.BONUS.SLASH_DEFENCE);
            int j = p.getEquipment().getBonus(Equipment.BONUS.STAB_ATTACK);
            int k = p.getEquipment().getBonus(Equipment.BONUS.STAB_DEFENCE);
            int l = p.getEquipment().getBonus(Equipment.BONUS.STRENGTH);
            int m = p.getEquipment().getBonus(Equipment.BONUS.SUMMONING);
            */

		    int highestAttackBonus = getHighestAttackBonus(p);
            int attackLevel = p.getSkills().getCurLevel(Skills.SKILL.ATTACK);
            double multipler = 1.00;

		    if (p.getPrayers().getAttackPrayer() == 1) {
                multipler *= 1.05; //5% increase
		    } else if (p.getPrayers().getAttackPrayer() == 2) {
                multipler *= 1.10; //10% increase
		    } else if (p.getPrayers().getAttackPrayer() == 3 || p.getPrayers().getSuperPrayer() == 1) {
                multipler *= 1.15; //15% increase
		    } else if (p.getPrayers().getSuperPrayer() == 2) {
                multipler *= 1.20; //20% increase
		    }
		    if (wearingMeleeVoid(p)) {
                multipler *= 1.10; //10% increase
		    }

            double effectiveAttack = (attackLevel * multipler);
            return effectiveAttack * (highestAttackBonus > 0 ? highestAttackBonus : 1);
	    }
        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;
                double dTemp;
                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.randomSpawn());
                                    break;
                                }
                                location.setX(temp);
                                break;
                            case "Y":
                                if (!int.TryParse(element.InnerText, out temp)) {
                                    createdPlayer.setLocation(Constants.HOME_SPAWN_LOCATION.randomSpawn());
                                    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 (!Double.TryParse(element.InnerText, out dTemp))
                                    {
                                        if (skill != Skills.SKILL.HITPOINTS)
                                            createdPlayer.getSkills().setXp(skill, 0);
                                        else
                                            createdPlayer.getSkills().setXp(skill, 1184);
                                        break;
                                    }
                                    createdPlayer.getSkills().setXp(skill, dTemp);
                                    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;
            }
        }
	    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);
	    }		
	    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));
		    }
	    }
 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);
 }
	    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);
	    }
	    private static double getMagicAttack(Player p) {
            int magicAttackBonus = 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 (magicAttackBonus >= 80)  // equivalent of max mage w/ zerker+whip
			    amount = 0.0500;
            else if (magicAttackBonus >= 90) // equivalent of max mage w/whip or mystic + ancient staff
			    amount = 0.0780;
            else if (magicAttackBonus >= 105) // equivalent of max mage w/ ancient staff
			    amount = 0.920;
            else if (magicAttackBonus >= 115) // equivalent of max mage w/ wand or better
			    amount = 0.1110;
            power *= (magicAttackBonus * amount) + (magicLevel *= 0.0120);
		    int magicPrayer = p.getPrayers().getMagicPrayer();
            if (magicPrayer > 0)
            {
                if (magicPrayer == 1)
				    power *= 1.05; //5% increase
                else if (magicPrayer == 2)
				    power *= 1.10; //10% increase
                else if (magicPrayer == 3)
				    power *= 1.15; //15% increase
		    }
		    return power;
	    }
        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(Skills.SKILL.HITPOINTS) * 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);
        }
        public static double getRangeDefence(Player p)
        {
            int rangedDefenceBonus = p.getEquipment().getBonus(Equipment.BONUS.RANGED_DEFENCE);
            double defenceLevel = p.getSkills().getCurLevel(Skills.SKILL.DEFENCE);
            AttackStyle.CombatSkill fightType = p.getAttackStyle().getSkill();
            if (fightType.Equals(AttackStyle.CombatSkill.DEFENSIVE))
                defenceLevel *= 1.10; //%10 increase.

            if(p.getPrayers().isPrayerActive(PrayerData.Prayer.THICK_SKIN))
                defenceLevel *= 1.05; //5% increase.
            else if (p.getPrayers().isPrayerActive(PrayerData.Prayer.ROCK_SKIN))
                defenceLevel *= 1.10; //10% increase.
            else if (p.getPrayers().isPrayerActive(PrayerData.Prayer.STEEL_SKIN))
                defenceLevel *= 1.15; //15% increase.
            else if (p.getPrayers().isPrayerActive(PrayerData.Prayer.SMITE))
                defenceLevel *= 1.20; //20% increase.
            else if (p.getPrayers().isPrayerActive(PrayerData.Prayer.CHIVALRY))
                defenceLevel *= 1.25; //25% increase.

            double rangeDefence = (defenceLevel * rangedDefenceBonus) / 200;
            return rangeDefence;

        }
        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());
	    }
Пример #22
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;
        }
	    private static double applyBoltGraphic(Player killer, Entity target, double damage, int bolt) {
            //10% chance that damage is returned if attacker's bow isn't a crossbow.
            if (misc.random(10) != 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 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 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;
				    double removeFromOpponent = (target.getHp() * 0.20); //20% off opponents HP.
				    if (has11Percent) {
					    killer.hit(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; //15% increase.
				    //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 45%.
				    }
				    break;
				
			    case 9245: // Onyx.
				    target.setLastGraphics(new Graphics(753));
				    maxDamage *= 1.15; //15% increase.
				    killer.heal(misc.random((int)(maxDamage * 0.60)));
				    break;
		    }
		    damage = misc.randomDouble(maxDamage);
		    if (misc.random(2) == 0 && bolt != 9242) {
			    damage = ((maxDamage * 0.50) + misc.randomDouble(maxDamage * 0.50));
		    }
		    if (damage > target.getHp()) {
			    damage = target.getHp();
		    }
		    return damage;
	    }
	    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);
		    }
	    }
Пример #25
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);
        }
	    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);
		    }
	    }
	    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);
	    }