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 void sendSkillLevel(Skills.SKILL skill) { connection.SendPacket(new PacketBuilder().setId(38) .addByteA((byte)player.getSkills().getCurLevel(skill)) .addInt1((int)player.getSkills().getXp(skill)) .addByte((byte)skill).toPacket()); }
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); } }
public static void addXp(Entity killer, Entity target, double damage) { int xpRate = 230; if ((killer is Player) && (target is Npc)) { Player p = (Player)killer; CombatType type = p.getLastCombatType(); AttackStyle.CombatSkill fightType = p.getAttackStyle().getSkill(); AttackStyle.CombatStyle fightStyle = p.getAttackStyle().getStyle(); if (type == CombatType.MELEE) { if (!fightType.Equals(AttackStyle.CombatSkill.CONTROLLED)) { Skills.SKILL skill = Skills.SKILL.ATTACK; if (fightType.Equals(AttackStyle.CombatSkill.ACCURATE)) { skill = Skills.SKILL.ATTACK; } else if (fightType.Equals(AttackStyle.CombatSkill.DEFENSIVE)) { skill = Skills.SKILL.DEFENCE; } else if (fightType.Equals(AttackStyle.CombatSkill.AGGRESSIVE)) { skill = Skills.SKILL.STRENGTH; } p.getSkills().addXp(skill, (xpRate * damage)); p.getSkills().addXp(Skills.SKILL.HITPOINTS, (xpRate * 0.30)); } else { p.getSkills().addXp(Skills.SKILL.ATTACK, ((xpRate * 0.30) * damage)); p.getSkills().addXp(Skills.SKILL.DEFENCE, ((xpRate * 0.30) * damage)); p.getSkills().addXp(Skills.SKILL.STRENGTH, ((xpRate * 0.30) * damage)); p.getSkills().addXp(Skills.SKILL.HITPOINTS, (0.25 * damage)); } } else { if (fightStyle.Equals(AttackStyle.CombatStyle.RANGE_ACCURATE) || fightStyle.Equals(AttackStyle.CombatStyle.RANGE_RAPID)) { p.getSkills().addXp(Skills.SKILL.RANGE, (xpRate * damage)); } else if (fightStyle.Equals(AttackStyle.CombatStyle.RANGE_DEFENSIVE)) { p.getSkills().addXp(Skills.SKILL.RANGE, ((xpRate * 0.50) * damage)); p.getSkills().addXp(Skills.SKILL.DEFENCE, ((xpRate * 0.50) * damage)); } p.getSkills().addXp(Skills.SKILL.HITPOINTS, ((xpRate * 0.30) * damage)); } } target.addToHitCount(killer, damage); }
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); }
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 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); } } }
public static void attack(Npc npc, Entity target) { if (npc.isDead() || npc.getOwner() == null || npc.isDestroyed() || target.isDead() || target.isDestroyed()) { return; } int damage = Misc.random(npc.getMaxHit()); int prayer = ((Player)target).getPrayers().getHeadIcon(); int hitDelay = npc.getHitDelay(); bool special = false; switch (npc.getId()) { case 2026: // Dharok int healthHit = (npc.getMaxHp() - npc.getHp()) / 2; damage = Misc.random(damage + healthHit); if (Misc.random(1) == 0) { if (damage < (npc.getMaxHp() / 3)) { damage = (npc.getMaxHp() / 4) + Misc.random(damage + healthHit) - (npc.getMaxHp() / 4); } } if (prayer == PrayerData.MELEE) { damage = 0; } break; case 2025: // Ahrim hitDelay = 1000; ((Player)target).getPackets().sendProjectile(npc.getLocation(), target.getLocation(), 32, 156, 50, 40, 34, 60, target); if (Misc.random(3) == 0) { special = true; Skills.SKILL[] weakenableSkills = (Skills.SKILL[])Enum.GetValues(typeof(Skills.SKILL)); Skills.SKILL weakenedSkill = weakenableSkills[Misc.random(0, 2)]; int currentLevel = ((Player)target).getSkills().getCurLevel(weakenedSkill); int newLevel = currentLevel - Misc.random(((Player)target).getSkills().getMaxLevel(weakenedSkill) / 12); newLevel = Math.Max(0, newLevel); ((Player)target).getSkills().setCurLevel(weakenedSkill, newLevel); ((Player)target).getPackets().sendSkillLevel(weakenedSkill); } if (prayer == PrayerData.MAGIC) { damage = 0; } break; case 2027: // Guthan if (prayer == PrayerData.MELEE) { damage = 0; } if (Misc.random(3) == 0) { special = true; target.setLastGraphics(new Graphics(398)); npc.heal(Misc.random(damage)); } break; case 2030: // Verac if (Misc.random(1) == 0 && prayer != 0) { if (damage <= npc.getMaxHit() / 2) { damage += npc.getMaxHit() / 2; if (damage > npc.getMaxHit()) { damage = npc.getMaxHit(); } } } break; case 2029: // Torag if (Misc.random(3) == 0) { special = true; } if (prayer == PrayerData.MELEE) { damage = 0; } break; case 2028: // Karil hitDelay = 700; ((Player)target).getPackets().sendProjectile(npc.getLocation(), target.getLocation(), 32, 27, 50, 40, 34, 40, target); if (Misc.random(10) == 0) { special = true; int agility = ((Player)target).getSkills().getCurLevel(Skills.SKILL.AGILITY); int newAgility = agility / 4; if (newAgility <= 1) { newAgility = 1; } ((Player)target).getSkills().setCurLevel(Skills.SKILL.AGILITY, newAgility); ((Player)target).getPackets().sendSkillLevel(Skills.SKILL.AGILITY); } if (Misc.random(1) == 0) { damage = damage > 0 ? damage : Misc.random(npc.getMaxHit()); } if (prayer == PrayerData.RANGE) { damage = 0; } break; } npc.setLastAnimation(new Animation(npc.getAttackAnimation())); target.setLastAttacked(Environment.TickCount); npc.setLastAttack(Environment.TickCount); npc.resetCombatTurns(); target.setAttacker(npc); if ((target.getCombatTurns() > 2 || target.getCombatTurns() < 0)) { target.setLastAnimation(new Animation(target.getDefenceAnimation())); } if (damage > target.getHp()) { damage = target.getHp(); } Event doHitEvent = new Event(hitDelay); doHitEvent.setAction(() => { if (npc.getId() == 2025) { if (special) { target.setLastGraphics(new Graphics(400, 0, 100)); ((Player)target).getPackets().sendMessage("You feel weakened."); } target.setLastGraphics(new Graphics(damage == 0 ? 85 : 157, 0, 100)); } else if (npc.getId() == 2027) { if (special) { if (!npc.isDead()) { int newHp = npc.getHp() + damage; if (newHp > npc.getMaxHp()) { newHp = npc.getMaxHp(); } npc.setHp(newHp); } } } else if (npc.getId() == 2029) { if (special) { target.setLastGraphics(new Graphics(399, 0, 100)); int energy = ((Player)target).getRunEnergy(); int newEnergy = energy - (int)(energy * 0.50); if (newEnergy < 0) { newEnergy = 0; } ((Player)target).getPackets().sendMessage("You feel drained of energy."); ((Player)target).setRunEnergy(newEnergy); ((Player)target).getPackets().sendEnergy(); } } else if (npc.getId() == 2028) { if (special) { target.setLastGraphics(new Graphics(399)); ((Player)target).getPackets().sendMessage("You feel less agile."); } } target.hit(damage); doHitEvent.stop(); }); }
/** * 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); }