public static int[] getProtectedItem1(Player p) { int[] protectedItem = new int[2]; protectedItem[0] = -1; for (int i = 0; i < 28; i++) { if(p.getInventory().getSlot(i).itemId == -1) continue; int price = p.getInventory().getSlot(i).getDefinition().getPrice().getMaximumPrice(); if ((price > ItemData.forId(protectedItem[0]).getPrice().getMaximumPrice())) { protectedItem[0] = p.getInventory().getSlot(i).getItemId(); protectedItem[1] = INVENTORY; } } foreach (ItemData.EQUIP equip in Enum.GetValues(typeof(ItemData.EQUIP))) { if (equip == ItemData.EQUIP.NOTHING) continue; if (p.getEquipment().getSlot(equip).itemId == -1) continue; int price = p.getEquipment().getSlot(equip).getDefinition().getPrice().getMaximumPrice(); if (price > ItemData.forId(protectedItem[0]).getPrice().getMaximumPrice()) { protectedItem[0] = p.getEquipment().getSlot(equip).getItemId(); protectedItem[1] = EQUIPMENT; } } return protectedItem; }
public void execute(Player player, string[] arguments) { if (arguments.Length == 0) { player.getPackets().sendMessage("[Info command]: ::info npcId (example ::info 1)"); return; } int npcId = 0; if (!int.TryParse(arguments[0], out npcId)) { player.getPackets().sendMessage("[Info command]: ::info npcId (example ::info 1)"); return; } if (npcId < 0 || npcId > NpcData.getTotalNpcDefinitions()) return; player.getPackets().sendMessage("ATT = " + (int)CombatFormula.getMeleeAttack(player) + " DEF = " + (int)CombatFormula.getMeleeDefence(player, player) + " SPEC = " + (int)CombatFormula.getMeleeAttack(player) * CombatFormula.getSpecialAttackBonus(player.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON))); player.getPackets().sendMessage("NPC ATT = " + (int)CombatFormula.getNPCMeleeAttack(new Npc(npcId)) + " NPC DEF = " + (int)CombatFormula.getNPCMeleeDefence(new Npc(npcId))); }
public static int getStandAnim(Player p) { int id = p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON); string weapon = ItemData.forId(id).getName(); if (weapon.Contains("Dharok")) { return 2065; } if (weapon.Contains("flail")) { return 2061; } if (weapon.Contains("Karil")) { return 2074; } if (weapon.Contains("Tzhaar-ket-om")) { return 0x811; } if (weapon.Equals("Saradomin staff") || weapon.Equals("Guthix staff") || weapon.Equals("Zamorak staff")) { return 0x328; } if (weapon.Contains("Guthan") || weapon.EndsWith("spear") || weapon.EndsWith("halberd") || weapon.Contains("Staff") || weapon.Contains("staff") || weapon.Contains("wand") || weapon.Contains("Dragon longsword") || weapon.Equals("Void knight mace")) { return 809; } if (weapon.Contains("2h") || weapon.EndsWith("godsword") || weapon.Equals("Saradomin sword")) { return 7047; } if (weapon.Equals("Abyssal whip")) { return 10080; } if (weapon.Contains("Granite maul")) { return 1662; } return 808; }
public static int getDefenceAnimation(Player p) { int weaponId = p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON); int shield = p.getEquipment().getItemInSlot(ItemData.EQUIP.SHIELD); ItemData.Item weaponDef = p.getEquipment().getSlot(ItemData.EQUIP.WEAPON).getDefinition(); if (weaponDef == null) return 404; string weapon = weaponDef.getName(); if (shield != -1) { ItemData.Item shieldDef = p.getEquipment().getSlot(ItemData.EQUIP.SHIELD).getDefinition(); if (shieldDef == null) return 1156; string shieldName = shieldDef.getName(); if (shield >= 8844 && shield <= 8850) { // Defenders return 4177; } if (shieldName.Contains("book") || shieldName.Contains("Book")) { return 404; } return 1156; } if (weaponId <= 0) { return 424; } if (weapon.Contains("xil-ul")) { return 425; } if (weapon.EndsWith("whip")) { return 1659; } if (weapon.Contains("Granite maul")) { return 1666; } if (weapon.Contains("Dharok") || weapon.Contains("flail")) { return 2063; } if (weapon.Contains("shortbow") || weapon.Contains("longbow") || weapon.Contains("Karil") || weapon.Contains("Crystal") || weapon.Contains("Dark bow")) { return 425; } if (weapon.Contains("2h") || weapon.Contains("godsword") || weapon.Contains("Saradomin sword")) { return 7050; } if (weapon.Contains("staff") || weapon.Contains("Staff") || weapon.Contains("halberd") || weapon.Contains("warspear") || weapon.Contains("spear")) { return 420; } if (weapon.Contains("claws")) { return 4177; } if (weapon.Contains("wand") || weapon.Contains("longsword") || weapon.EndsWith("_sword") || weapon.Contains("battleaxe") || weapon.Contains("mace") || weapon.Contains("scimitar") || weapon.Contains("axe") || weapon.Contains("warhammer") || weapon.Contains("dagger")) { return 397; } return 404; }
private void handleOperateItem(Player player, Packet packet) { int item = packet.readShortA(); int slot = packet.readLEShort(); int interfaceId = packet.readLEShort(); int childId = packet.readLEShort(); if (slot < 0 || slot > 13 || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null) { return; } ItemData.EQUIP equipSlot = (ItemData.EQUIP)slot; if (player.getEquipment().getItemInSlot(equipSlot) == item) { SkillHandler.resetAllSkills(player); player.getPackets().closeInterfaces(); if (JewelleryTeleport.useJewellery(player, player.getEquipment().getItemInSlot(equipSlot), slot, true)) { return; } else if (equipSlot == ItemData.EQUIP.CAPE && Skillcape.emote(player)) { return; } player.getPackets().sendMessage("This item isn't operable."); } }
private static bool canCastSpell(Player p, Entity target, int i, bool fakeNPC) { // fakeNPC is used to keep location when autocasting. if (fakeNPC) { return !p.isDead(); } if (target.isDead() || p.isDead() || target.isDestroyed() || p.isDestroyed()) { return false; } if (target is Npc) { if (((Npc) target).getHp() <= 0) { return false; } if (i == 47) { p.getPackets().sendMessage("You cannot cast Teleblock upon an NPC."); return false; } } if ((target is Player) && (p is Player)) { if (Location.inFightPits(target.getLocation()) && Location.inFightPits(target.getLocation())) { if (!Server.getMinigames().getFightPits().hasGameStarted()) { return false; } return true; } if (p.getDuel() != null) { if (((Player)target).getDuel() != null) { if (p.getDuel().getPlayer2().Equals(((Player) target)) && ((Player) target).getDuel().getPlayer2().Equals(p)) { if (p.getDuel().ruleEnabled(DuelSession.RULE.NO_MAGIC)) { p.getPackets().sendMessage("Magical combat has been disabled in this duel!"); return false; } if (p.getDuel().getStatus() == 6 && ((Player) target).getDuel().getStatus() == 6) { return true; } } } p.getPackets().sendMessage("That isn't your opponent."); return false; } if (i == 47) { if (((Player)target).getTemporaryAttribute("teleblocked") != null) { p.getPackets().sendMessage("That player already has a teleportation block upon them."); return false; } } if (!Location.inWilderness(target.getLocation())) { p.getPackets().sendMessage("That player isn't in the wilderness."); return false; } if (!Location.inWilderness(p.getLocation())) { p.getPackets().sendMessage("You aren't in the wilderness."); return false; } int killerWildLevel = p.getLocation().wildernessLevel(); int targetWildLevel = ((Player)target).getLocation().wildernessLevel(); int killerCombatLevel = p.getSkills().getCombatLevel(); int targetCombatLevel = ((Player)target).getSkills().getCombatLevel(); int highest = killerCombatLevel > targetCombatLevel ? killerCombatLevel : targetCombatLevel; int lowest = highest == killerCombatLevel ? targetCombatLevel : killerCombatLevel; int difference = (highest - lowest); if (difference > killerWildLevel || difference > targetWildLevel) { ((Player) p).getPackets().sendMessage("You must move deeper into the wilderness to attack that player."); return false; } } if (!Location.inMultiCombat(target.getLocation())) { if (p.getAttacker() != null && !p.getAttacker().Equals(target)) { p.getPackets().sendMessage("You are already in combat!"); return false; } if (target.getAttacker() != null && !target.getAttacker().Equals(p)) { string type = target is Player ? "player" : "npc"; p.getPackets().sendMessage("That " + type + " is already in combat."); return false; } } if (p.getSkills().getCurLevel(Skills.SKILL.MAGIC) < SPELL_LEVEL[i]) { p.getPackets().sendMessage("You need a Magic level of " + SPELL_LEVEL[i] + " to cast that spell."); return false; } if (!hasRunes(p, RUNES[i], RUNE_AMOUNTS[i])) { p.getPackets().sendMessage("You do not have enough runes to cast that spell."); return false; } if (NEEDS_STAFF[i]) { if ((i != 38 && p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON) != STAFF[i]) || (i == 38 && p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON) != 8841 && p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON) != STAFF[i])) { p.getPackets().sendMessage("You need to wield " + STAFF_NAME[i] + " to cast this spell."); return false; } } if (i == 37) { if (p.getEquipment().getItemInSlot(ItemData.EQUIP.CAPE) != 2412) { p.getPackets().sendMessage("You need to wear the Cape of Saradomin to be able to cast Saradomin Strike."); return false; } } if (i == 38) { if (p.getEquipment().getItemInSlot(ItemData.EQUIP.CAPE) != 2413) { p.getPackets().sendMessage("You need to wear the Cape of Guthix to be able to cast Claws of Guthix."); return false; } } if (i == 39) { if (p.getEquipment().getItemInSlot(ItemData.EQUIP.CAPE) != 2414) { p.getPackets().sendMessage("You need to wear the Cape of Zamorak to be able to cast Flames of Zamorak."); return false; } } return true; }
public static int[] getProtectedItem2(Player p) { int[] protectedItem = new int[2]; protectedItem[0] = -1; int[] protectedItem1 = getProtectedItem1(p); bool save; for (int i = 0; i < 28; i++) { if (p.getInventory().getSlot(i).itemId == -1) continue; int amt = p.getInventory().getItemAmount(p.getInventory().getItemInSlot(i)); int price = p.getInventory().getSlot(i).getDefinition().getPrice().getMaximumPrice(); if (price > ItemData.forId(protectedItem[0]).getPrice().getMaximumPrice()) { save = true; if (protectedItem1[1] == INVENTORY) { if (protectedItem1[0] == p.getInventory().getItemInSlot(i)) { if (amt < 2) { save = false; } } } if (save) { protectedItem[0] = p.getInventory().getSlot(i).getItemId(); protectedItem[1] = INVENTORY; } } } foreach (ItemData.EQUIP equip in Enum.GetValues(typeof(ItemData.EQUIP))) { if (equip == ItemData.EQUIP.NOTHING) continue; if (p.getEquipment().getSlot(equip).itemId == -1) continue; int price = p.getEquipment().getSlot(equip).getDefinition().getPrice().getMaximumPrice(); int amt = p.getEquipment().getAmountInSlot(equip); if (price > ItemData.forId(protectedItem[0]).getPrice().getMaximumPrice()) { save = true; if (protectedItem1[1] == EQUIPMENT) { if (protectedItem1[0] == p.getEquipment().getItemInSlot(equip)) { if (amt < 2) { save = false; } } } if (save) { protectedItem[0] = p.getEquipment().getSlot(equip).getItemId(); protectedItem[1] = EQUIPMENT; } } } return protectedItem; }
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()); }
public static bool wearingVerac(Player p) { return p.getEquipment().getItemInSlot(ItemData.EQUIP.LEGS) == 4759 && p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON) == 4755 && p.getEquipment().getItemInSlot(ItemData.EQUIP.CHEST) == 4757 && p.getEquipment().getItemInSlot(ItemData.EQUIP.HAT) == 4753; }
public static bool wearingTorag(Player p) { return p.getEquipment().getItemInSlot(ItemData.EQUIP.LEGS) == 4751 && p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON) == 4747 && p.getEquipment().getItemInSlot(ItemData.EQUIP.CHEST) == 4749 && p.getEquipment().getItemInSlot(ItemData.EQUIP.HAT) == 4745; }
public static bool wearingMeleeVoid(Player p) { return p.getEquipment().getItemInSlot(ItemData.EQUIP.LEGS) == 8840 && p.getEquipment().getItemInSlot(ItemData.EQUIP.CHEST) == 8839 && p.getEquipment().getItemInSlot(ItemData.EQUIP.HAT) == 11665 && p.getEquipment().getItemInSlot(ItemData.EQUIP.HANDS) == 8842; }
public static bool wearingKaril(Player p) { return p.getEquipment().getItemInSlot(ItemData.EQUIP.LEGS) == 4738 && p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON) == 4734 && p.getEquipment().getItemInSlot(ItemData.EQUIP.CHEST) == 4736 && p.getEquipment().getItemInSlot(ItemData.EQUIP.HAT) == 4732; }
public static bool wearingGuthan(Player p) { return p.getEquipment().getItemInSlot(ItemData.EQUIP.LEGS) == 4730 && p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON) == 4726 && p.getEquipment().getItemInSlot(ItemData.EQUIP.CHEST) == 4728 && p.getEquipment().getItemInSlot(ItemData.EQUIP.HAT) == 4724; }
public static bool wearingDharok(Player p) { return p.getEquipment().getItemInSlot(ItemData.EQUIP.LEGS) == 4722 && p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON) == 4718 && p.getEquipment().getItemInSlot(ItemData.EQUIP.CHEST) == 4720 && p.getEquipment().getItemInSlot(ItemData.EQUIP.HAT) == 4716; }
public static bool wearingAhrim(Player p) { return p.getEquipment().getItemInSlot(ItemData.EQUIP.LEGS) == 4714 && p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON) == 4710 && p.getEquipment().getItemInSlot(ItemData.EQUIP.CHEST) == 4712 && p.getEquipment().getItemInSlot(ItemData.EQUIP.HAT) == 4708; }
public static void setAutoCastSpell(Player p, int spell, int spellIndex, bool ancients) { p.getPackets().modifyText(AUTOCAST_NAME[spell], 90, 11); p.getPackets().showChildInterface(90, 83, false); p.getPackets().showChildInterface(90, AUTOCAST_CONFIG[spell], true); p.getPackets().sendConfig(43, 3); p.getPackets().sendTab(83, 90); p.getPackets().modifyText(p.getEquipment().getSlot(ItemData.EQUIP.WEAPON).getDefinition().getName(), 90, 0); p.setTemporaryAttribute("autoCastSpell", spellIndex); p.setTemporaryAttribute("autoCastSpell2", spell); if (ancients) { p.setTemporaryAttribute("autoCastAncients", ancients); } else { p.removeTemporaryAttribute("autoCastAncients"); } }
private static int getHighestDefBonus(Player p) { int bonus = 0; for (int i = 5; i < 8; i++) { if (p.getEquipment().getBonus(i) > bonus) { bonus = p.getEquipment().getBonus(i); } } return bonus; }
private static double getMagicAttack(Player p) { int magicBonus = p.getEquipment().getBonus(Equipment.BONUS.MAGIC_ATTACK); double magicLevel = Convert.ToDouble(p.getSkills().getCurLevel(Skills.SKILL.MAGIC)); double power = 1.800; double amount = 0.0205; if (magicBonus >= 80) { // equivalent of max mage w/ zerker+whip amount = 0.0500; } else if (magicBonus >= 90) { // equivalent of max mage w/whip or mystic + ancient staff amount = 0.0780; } else if (magicBonus >= 105) { // equivalent of max mage w/ ancient staff amount = 0.920; } else if (magicBonus >= 115) { // equivalent of max mage w/ wand or better amount = 0.1110; } power *= (magicBonus * amount) + (magicLevel *= 0.0120); int prayer = p.getPrayers().getMagicPrayer(); if (prayer > 0) { if (prayer == 1) { power *= 1.05; } else if (prayer == 2) { power *= 1.10; } else if (prayer == 3) { power *= 1.15; } } return power; }
private static int getRangeStrength(Player p) { int[][] items = { new int[] { 890, // addy arrow 9143, // addy bolt 810, // addy dart 829, // addy jav 867, // addy knife 804, // addy thrownaxe 881, // barbed bolts 13803, // black bolts 3093, // black dart 869, // black knife 9139, // blurite bolt 4740, // bolt rack 8882, // bone bolts 13280, // broad tipped bolts 882, // bronze arrow 877, // bronze bolts 806, // bronze dart 825, // bronze jav 864, // bronze knife 800, // bronze thrownaxe 4214, // full crystal bow 13953, // corrupt morr jav 13957, // corrupt morr thrownaxe 9340, // diamond bolt 11212, // dragon arrow 9341, // dragon bolts 11230, // dragon dart 9338, // emerald bolts 10142, // guam tar 10145, // harralander tar 78, // ice arrows 884, // iron arrows 9140, // iron bolts 807, // iron dart 826, // iron javelin 863, // iron knife 801, // iron thrownaxe 10158, // kebbit bolts 10159, // long kebbit bolts 888, // mith arrow 9142, // mith bolts 809, // mithril dart 828, // mithril javelin 866, // mith knife 803, // mith thrownaxe 13879, // morrigans javelin 13883, // morrigans thrownaxe 2866, // ogre arrow 9342, // onyx bolts 880, // pearl bolts 10034, // red chinchompa 9339, // ruby bolts 892, // rune arrow 811, // rune dart 830, // rune javelin 868, // rune knife 805, // rune thrownaxe 9144, // rune bolts 9337, // sapphire bolts 9145, // silver bolts 886, // steel arrow 9141, // steel bolts 808, // steel dart 827, // steel javelin 865, // steel knife 802, // steel thrownaxe 10144, // tarromin tar 6522, // obsidian ring 9336, // topaz bolts 9706, // training arrows 879, // opal bolts 9236, // opal bolts (e) 9335, // jade bolts 9237, // jade bolts (e) 9238, // pearl bolts(e) 9239, // topaz bolts (e) 9241, // emerald bolts (e) 9240, // sapphire bolts (e) 9242, // ruby bolts (e) 9243, // diamond bolts (e) 9244, // dragon bolts (e) 9245, // onyx bolts (e) }, new int[] { 31, // addy arrow 100, // addy bolt 10, // addy dart 28, // addy jav 14, // addy knife 23, // addy thrownaxe 12, // barbed bolts 75, // black bolts 6, // black dart 8, // black knife 28, // blurite bolt 55, // bolt rack 49, // bone bolts 100, // broad tipped bolts 7, // bronze arrow 10, // bronze bolts 1, // bronze dart 6, // bronze jav 3, // bronze knife 5, // bronze thrownaxe 70, // full crystal bow 145, // corrupt morr jav 117, // corrupt morr thrownaxe 105, // diamond bolt 60, // dragon arrow 117, // dragon bolts 20, // dragon dart 85, // emerald bolts 16, // guam tar 49, // harralander tar 16, // ice arrows 10, // iron arrows 46, // iron bolts 3, // iron dart 10, // iron javelin 4, // iron knife 7, // iron thrownaxe 28, // kebbit bolts 38, // long kebbit bolts 22, // mith arrow 82, // mith bolts 7, // mithril dart 18, // mithril javelin 10, // mith knife 16, // mith thrownaxe 145, // morrigans javelin 117, // morrigans thrownaxe 22, // ogre arrow 120, // onyx bolts 48, // pearl bolts 15, // red chinchompa 103, // ruby bolts 49, // rune arrow 14, // rune dart 42, // rune javelin 24, // rune knife 36, // rune thrownaxe 115, // rune bolts 83, // sapphire bolts 36, // silver bolts 16, // steel arrow 64, // steel bolts 4, // steel dart 12, // steel javelin 7, // steel knife 11, // steel thrownaxe 31, // tarromin tar 49, // obsidian ring 66, // topaz bolts 7, // training arrows 10, // opal bolts 10, // opal bolts (e) 28, // jade bolts 28, // jade bolts (e) 46, // pearl bolts(e) 64, // topaz bolts (e) 82, // emerald bolts (e) 82, // sapphire bolts (e) 100, // ruby bolts (e) 100, // diamond bolts (e) 117, // dragon bolts (e) 115, // onyx bolts (e) } }; for (int i = 0; i < items[1].Length; i++) { if (p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON) == items[0][i]) { return items[1][i]; } } for (int i = 0; i < items[1].Length; i++) { if (p.getEquipment().getItemInSlot(ItemData.EQUIP.ARROWS) == items[0][i]) { return items[1][i]; } } return 0; }
public static void newMagicAttack(Player p, Entity target, int id, bool ancients) { int index = getSpellIndex(p, id, ancients); bool autoCasting = p.getTemporaryAttribute("autoCasting") != null; bool fakeNPC = target != null && target is Npc && ((Npc)target).getId() == 0; Entity lastAutocastEntity = null; bool frozen = false; if (index == -1) { return; } if (p.getTarget() == null) { if (autoCasting) { if (Location.inMultiCombat(p.getLocation())) { lastAutocastEntity = (Entity) p.getTemporaryAttribute("autocastEntity") == null ? null : (Entity) p.getTemporaryAttribute("autocastEntity"); if (lastAutocastEntity == null || lastAutocastEntity is Player) { p.removeTemporaryAttribute("autoCasting"); Combat.resetCombat(p, 1); return; } if (hitsMulti(p, index)) { Location location = (Location)p.getTemporaryAttribute("autocastLocation"); Entity newTarget = new Npc(0); newTarget.setLocation(location); p.setTarget(newTarget); newMagicAttack(p, newTarget, id, ancients); return; } } else { p.removeTemporaryAttribute("autoCasting"); Combat.resetCombat(p, 1); return; } } else { p.removeTemporaryAttribute("autoCasting"); Combat.resetCombat(p, 1); return; } } else { if (!canCastSpell(p, target, index, fakeNPC)) { p.removeTemporaryAttribute("autoCasting"); Combat.resetCombat(p, 1); return; } } int distance = 8; if (target is Player) { if (((Player)target).getSprites().getPrimarySprite() != -1) { distance = 8; } } if (!fakeNPC) { // we're actually attacking a real npc/player if (!p.getLocation().withinDistance(target.getLocation(), distance)) { p.getFollow().setFollowing(target); Event attemptMagicAttackEvent = new Event(500); int attemptMagicAttackCounter = 0; attemptMagicAttackEvent.setAction(() => { if (p.getLocation().withinDistance(target.getLocation(), distance) && p.getTarget() != null) { attemptMagicAttackEvent.stop(); newMagicAttack(p, target, id, ancients); return; } attemptMagicAttackCounter++; if (attemptMagicAttackCounter >= 12) { attemptMagicAttackEvent.stop(); } }); Server.registerEvent(attemptMagicAttackEvent); return; } } int timeSinceLastCast = autoCasting ? 3500 : 2000; if (Environment.TickCount - p.getLastMagicAttack() < timeSinceLastCast) { p.getWalkingQueue().resetWalkingQueue(); //return; } int time = p.getLastCombatType().Equals(Combat.CombatType.MAGE) ? 1550 : 600; if (Environment.TickCount - p.getLastAttack() < time) { int delay = p.getLastCombatType().Equals(Combat.CombatType.MAGE) ? 1350 : 800; Event attemptMagicAttackEvent = new Event(500); attemptMagicAttackEvent.setAction(() => { if (Environment.TickCount - p.getLastAttack() > delay) { attemptMagicAttackEvent.stop(); newMagicAttack(p, target, id, ancients); } }); Server.registerEvent(attemptMagicAttackEvent); p.getWalkingQueue().resetWalkingQueue(); p.getPackets().clearMapFlag(); p.setLastCombatType(Combat.CombatType.MAGE); return; } if (fakeNPC && !monsterInArea(p, target)) { p.removeTemporaryAttribute("autoCasting"); Combat.resetCombat(p, 1); return; } int endGfx = END_GFX[index]; double damage = misc.random(CombatFormula.getMagicHit(p, target, getSpellMaxHit(p, index))); bool mp = false; bool magicProtect = mp; if (target is Player) { mp = ((Player) target).getPrayers().getHeadIcon() == PrayerData.MAGIC; } if (magicProtect) { damage *= 0.60; } if (p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON) == 8841) { damage *= 1.10; // void mace 10% hit increase. } if (damage == 0 && index != 41 && index != 42 && index != 43 && index != 44 && index != 45 && index != 46 && index != 47) { endGfx = 85; } if (!deleteRunes(p, RUNES[index], RUNE_AMOUNTS[index])) { p.setTarget(null); return; } p.getFollow().setFollowing(null); p.getWalkingQueue().resetWalkingQueue(); p.getPackets().clearMapFlag(); p.setFaceLocation(target.getLocation()); if (HANDS_GFX[index] != -1) { p.setLastGraphics(new Graphics(HANDS_GFX[index], 0 , getStartingGraphicHeight(index))); } p.setLastAnimation(new Animation(SPELL_ANIM[index])); p.getPackets().closeInterfaces(); if (target is Player) { ((Player) target).getPackets().closeInterfaces(); } target.setAttacker(p); p.setTarget(target); target.setLastAttacked(Environment.TickCount); p.setLastAttack(Environment.TickCount); p.setLastMagicAttack(Environment.TickCount); p.setCombatTurns(p.getAttackSpeed()); Combat.setSkull(p, target); if (damage > 0) { frozen = freezeTarget(index, target); if (!frozen && index == 31) { endGfx = 1677; } } if (AIR_GFX[index] != -1 || ((index == 31 || index == 27) && target is Player && ((Player)target).getWalkingQueue().isRunning())) { sendProjectile(index, target, p); } if (damage > target.getHp()) { damage = target.getHp(); } if (index == 47 && misc.random(2) == 0) { endGfx = 85; } Combat.checkIfWillDie(target, damage); Event doMagicAttackEvent = new Event(getSpellHitDelay(index)); doMagicAttackEvent.setAction(() => { doMagicAttackEvent.stop(); if (p == null || p.isDead() || !fakeNPC && (target.isDead() || target.isHidden() || target.isDestroyed())) { return; } if (target.isAutoRetaliating() && target.getTarget() == null && damage > 0) { if (target is Npc) { } else { if (((Player) target).getTemporaryAttribute("autoCastSpell") != null) { int autoCastSpell = (int)((Player) target).getTemporaryAttribute("autoCastSpell"); ((Player) target).setTemporaryAttribute("autoCasting", true); target.setTarget(p); MagicCombat.newMagicAttack((Player) target, p, autoCastSpell, ((Player) target).getTemporaryAttribute("autoCastAncients") != null); } } target.getFollow().setFollowing(p); target.setEntityFocus(p.getClientIndex()); if ((target.getCombatTurns() <= (target.getAttackSpeed() / 2) || target.getCombatTurns() >= (target.getAttackSpeed()))) { target.setCombatTurns(target.getAttackSpeed() / 2); } target.setTarget(p); if (target is Player) { ((Player) target).getWalkingQueue().resetWalkingQueue(); ((Player) target).getPackets().clearMapFlag(); } } addMagicXp(p, target, damage, index, true); target.setLastGraphics(new Graphics(endGfx, 0, getGroundHeight(index, endGfx))); if (index == 47 && endGfx != 85) { // teleblock if (target is Player) { teleblockPlayer(p, (Player)target); } } if (damage != 0) { Combat.checkRecoil(p, target, damage); Combat.checkSmite(p, target, damage); Combat.checkVengeance(p, target, damage); hitInMulti(p, target, index); applyMiasmicEffects(p, target, index); if ((target.getCombatTurns() > 2 || target.getCombatTurns() < 0) && !target.isDead()) { target.setLastAnimation(new Animation(target.getDefenceAnimation())); } if (index != 27) { target.hit((int)damage); if (index == 18 || index == 22 || index == 26 || index == 30) { p.heal(Convert.ToInt32(damage / 4)); } } else if (index == 27){ Event doHitEvent = new Event(1000); doHitEvent.setAction(() => { doHitEvent.stop(); target.hit((int)damage); }); Server.registerEvent(doHitEvent); } } }); Server.registerEvent(doMagicAttackEvent); if (p.getTemporaryAttribute("autoCasting") != null) { if (p.getTemporaryAttribute("autoCastSpell") != null) { if (id != (int)p.getTemporaryAttribute("autoCastSpell")) { p.setTarget(null); return; } } if (!fakeNPC) { p.setTemporaryAttribute("autocastLocation", target.getLocation()); p.setTemporaryAttribute("autocastEntity", target); } Event autoCastSpellEvent = new Event(3500); autoCastSpellEvent.setAction(() => { autoCastSpellEvent.stop(); if (p.getTemporaryAttribute("autoCasting") != null && p.getTemporaryAttribute("autoCastSpell") != null) { int autoCastSpell = (int)p.getTemporaryAttribute("autoCastSpell"); MagicCombat.newMagicAttack(p, p.getTarget(), autoCastSpell, p.getTemporaryAttribute("autoCastAncients") != null); } }); Server.registerEvent(autoCastSpellEvent); } else { p.setTarget(null); } }
private static bool wearingRangeVoid(Player p) { return p.getEquipment().getItemInSlot(ItemData.EQUIP.LEGS) == 8840 && p.getEquipment().getItemInSlot(ItemData.EQUIP.CHEST) == 8839 && p.getEquipment().getItemInSlot(ItemData.EQUIP.HAT) == 11663 && p.getEquipment().getItemInSlot(ItemData.EQUIP.HANDS) == 8842; }
private static bool hasGodCapeAndStaff(Player p) { if (p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON) == 2415 && p.getEquipment().getItemInSlot(ItemData.EQUIP.CAPE) == 2412) { return true; } if ((p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON) == 2416 || p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON) == 8841) && p.getEquipment().getItemInSlot(ItemData.EQUIP.CAPE) == 2413) { return true; } if (p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON) == 2417 && p.getEquipment().getItemInSlot(ItemData.EQUIP.CAPE) == 2414) { return true; } return false; }
public bool doSpecialAttack(Entity killer, Entity target) { int weapon = ((Player)killer).getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON); int currentPower = specialAmount; int neededPower = getRequiredAmount(weapon); bool rangeWeapon = false; if (!usingSpecial) { return(false); } if (p.getDuel() != null) { if (p.getDuel().ruleEnabled(DuelSession.RULE.NO_SPECIAL_ATTACKS)) { p.getPackets().sendMessage("Special attacks have been disabled for this duel!"); usingSpecial = false; refreshBar(); return(false); } } if (neededPower > currentPower) { ((Player)killer).getPackets().sendMessage("You don't have enough special power left."); usingSpecial = false; refreshBar(); return(false); } double damage = -1; double damage2 = -1; double damage3 = -1; double damage4 = -1; bool doubleHit = false; int increasedMaxHit = 0; damage = CombatFormula.getSpecialMeleeHit((Player)killer, target, weapon); damage2 = CombatFormula.getSpecialMeleeHit((Player)killer, target, weapon); int hitDelay = killer.getHitDelay(); //int totalDamage = 0; int usingBow = ((Player)killer).getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON); int usingArrows = ((Player)killer).getEquipment().getItemInSlot(ItemData.EQUIP.ARROWS); bool usingRangePrayer = false; if (target is Player) { usingRangePrayer = ((Player)target).getPrayers().getHeadIcon() == PrayerData.RANGE; } switch (weapon) { case 4151: // Whip. killer.setLastAnimation(new Animation(1658)); target.setLastGraphics(new Graphics(341, 0, 100)); if (misc.random(3) == 0 && damage > 0) { damage = p.getMaxHit(); } else { damage = 0; } if (target is Player) { int energy = ((Player)target).getRunEnergy() / 4; ((Player)killer).setRunEnergy(((Player)killer).getRunEnergy() + energy); ((Player)target).setRunEnergy(((Player)target).getRunEnergy() - energy); if (((Player)killer).getRunEnergy() > 100) { ((Player)killer).setRunEnergy(100); } if (((Player)target).getRunEnergy() < 0) { ((Player)target).setRunEnergy(0); } } break; case 1215: // Dragon daggers. case 1231: case 5680: case 5698: if (damage > 0) { damage = p.getMaxHit(20); damage2 = p.getMaxHit(20); } killer.setLastAnimation(new Animation(1062)); killer.setLastGraphics(new Graphics(252, 0, 100)); doubleHit = true; /*if (misc.random(3) == 0 && CombatFormula.getMeleeHit(p, target) > 0) { * if (damage <= (CombatFormula.getMaxHit(p, 20) / 2) && damage2 <= (CombatFormula.getMaxHit(p, 20) / 2)) { * damage = (CombatFormula.getMaxHit(p, 20) / 2) + (misc.randomDouble() * CombatFormula.getMaxHit(p, 20)) / 2); * damage2 = (CombatFormula.getMaxHit(p, 20) / 2) + (misc.randomDouble() * CombatFormula.getMaxHit(p, 20)) / 2); * } * } else if (misc.random(2) == 0) { * damage = 0; * damage2 = 0; * }*/ double a = damage + damage2; if (damage > target.getHp()) { damage = target.getHp(); } a -= damage; if (damage2 > a) { damage2 = a; } /*if (damage > target.getHp()) { * int randomHp = misc.random(target.getHp()); * damage = randomHp; * damage2 = target.getHp() - randomHp; * } else { * int hpRemaining = target.getHp() - damage; * if (damage2 > hpRemaining) { * damage2 = hpRemaining; * } * }*/ break; case 1305: // Dragon longsword. killer.setLastAnimation(new Animation(1058)); killer.setLastGraphics(new Graphics(248, 0, 100)); damage = p.getMaxHit(30); break; case 11694: // Armadyl godsword. killer.setLastGraphics(new Graphics(1222, 0, 100)); killer.setLastAnimation(new Animation(7074)); damage += p.getMaxHit() * 0.25; break; case 11696: // Bandos godsword. killer.setLastGraphics(new Graphics(1223, 0, 100)); killer.setLastAnimation(new Animation(7073)); damage += p.getMaxHit() * 0.10; break; case 11698: // Saradomin godsword. killer.setLastGraphics(new Graphics(1220, 0, 100)); killer.setLastAnimation(new Animation(7071)); int newHp = (int)(damage * 0.50); int newPrayer = (int)(damage * 0.25); if (newHp < 10) { newHp = 10; } if (newPrayer < 5) { newPrayer = 5; } ((Player)killer).heal(newHp); ((Player)killer).getSkills().setCurLevel(Skills.SKILL.PRAYER, ((Player)killer).getSkills().getCurLevel(Skills.SKILL.PRAYER) + newPrayer); if (((Player)killer).getSkills().getCurLevel(Skills.SKILL.PRAYER) > ((Player)killer).getSkills().getMaxLevel(Skills.SKILL.PRAYER)) { ((Player)killer).getSkills().setCurLevel(Skills.SKILL.PRAYER, ((Player)killer).getSkills().getMaxLevel(Skills.SKILL.PRAYER)); } break; case 11700: // Zamorak godsword killer.setLastGraphics(new Graphics(1221, 0, 100)); killer.setLastAnimation(new Animation(7070)); target.setLastGraphics(new Graphics(369)); MagicCombat.freezeTarget(31, target); break; case 11730: // Saradomin sword target.setLastGraphics(new Graphics(1207, 0, 100)); killer.setLastAnimation(new Animation(7072)); increasedMaxHit = 16; break; case 1434: // Dragon mace hitDelay = 700; killer.setLastGraphics(new Graphics(251, 0, 75)); killer.setLastAnimation(new Animation(1060)); damage = p.getMaxHit(60); break; case 3204: // Dragon halberd // TODO halberd break; case 4587: // Dragon scimitar killer.setLastGraphics(new Graphics(347, 0, 100)); killer.setLastAnimation(new Animation(451)); if (target is Player) { if (((Player)target).getPrayers().getOverheadPrayer() >= 1 && ((Player)target).getPrayers().getOverheadPrayer() <= 3) { ((Player)target).getPrayers().setOverheadPrayer(0); ((Player)target).getPrayers().setHeadIcon(-1); ((Player)target).getPackets().sendMessage("The Dragon scimitar slashes through your prayer protection!"); ((Player)target).getPackets().sendConfig(95, 0); ((Player)target).getPackets().sendConfig(97, 0); ((Player)target).getPackets().sendConfig(98, 0); ((Player)target).getPackets().sendConfig(99, 0); ((Player)target).getPackets().sendConfig(100, 0); ((Player)target).getPackets().sendConfig(96, 0); } } break; case 14484: // Dragon claws doubleHit = true; killer.setLastGraphics(new Graphics(1950)); killer.setLastAnimation(new Animation(10961)); if (misc.random(1) == 0 && damage > 0) { if (damage < p.getMaxHit(20) * 0.75) { damage = (p.getMaxHit(20) * 0.75 + (misc.randomDouble() * (p.getMaxHit(20) * 0.25))); } } damage = (int)Math.Floor(damage); damage2 = (int)Math.Floor(damage * 0.50); damage3 = (int)Math.Floor(damage2 * 0.50); damage4 = (int)Math.Floor(damage3 + 1); break; case 1249: // Dragon spear //TODO leave due to noclipping? break; case 6739: // Dragon axe //TODO find emote and graphic break; case 7158: // Dragon 2h killer.setLastAnimation(new Animation(3157)); killer.setLastGraphics(new Graphics(559)); //TODO multi combat break; case 3101: // Rune claws killer.setLastGraphics(new Graphics(274)); break; case 4153: // Granite maul killer.setLastAnimation(new Animation(1667)); killer.setLastGraphics(new Graphics(340, 0, 100)); //doubleHit = true; break; case 10887: // Barrelchest anchor break; case 11061: // Ancient mace break; case 13902: // Statius' warhammer killer.setLastAnimation(new Animation(10505)); killer.setLastGraphics(new Graphics(1840)); damage += killer.getMaxHit() * 0.25; if (target is Player) { int defenceLevel = ((Player)target).getSkills().getCurLevel(Skills.SKILL.DEFENCE); int newDefence = (int)(defenceLevel * 0.30); if (newDefence < 1) { newDefence = 1; } ((Player)target).getSkills().setCurLevel(Skills.SKILL.DEFENCE, defenceLevel - newDefence); ((Player)target).getPackets().sendSkillLevel(Skills.SKILL.DEFENCE); } break; case 13899: // Vesta's longsword killer.setLastAnimation(new Animation(10502)); damage += killer.getMaxHit() * 0.20; break; case 13905: // Vesta's spear killer.setLastAnimation(new Animation(10499)); killer.setLastGraphics(new Graphics(1835)); break; case 13883: // Morrigans throwing axe break; case 13879: // Morrigans javelin case 8880: // Dorgeshuun crossbow break; case 861: // Magic shortbow case 859: // Magic longbow case 10284: // Magic composite bow rangeWeapon = true; if (p.getEquipment().getAmountInSlot(ItemData.EQUIP.ARROWS) < 2) { p.getPackets().sendMessage("You need 2 arrows to use the Magic bow special attack!"); return(false); } damage = (int)CombatFormula.getRangeHit((Player)killer, target, usingBow, usingArrows); damage2 = (int)CombatFormula.getRangeHit((Player)killer, target, usingBow, usingArrows); damage *= 1.05; damage2 *= 1.05; if (usingRangePrayer) { damage *= 0.60; damage2 *= 0.60; } double a1 = damage + damage2; if (damage > target.getHp()) { damage = target.getHp(); } a1 -= damage; if (damage2 > a1) { damage2 = a1; } /*if (damage >= target.getHp()) { * int randomHp = misc.random(target.getHp()); * damage = randomHp; * damage2 = target.getHp() - randomHp; * } else { * int hpRemaining = target.getHp() - damage; * if (damage2 > hpRemaining) { * damage2 = hpRemaining; * } * }*/ p.setLastAnimation(new Animation(1074)); p.setLastGraphics(new Graphics(256, 0, 90)); RangeCombat.deductArrow(killer); RangeCombat.deductArrow(killer); int arrowType = RangeCombat.getArrowType(killer); hitDelay = 1000; int MSpecCounter = 0; Event displayMSpecProjectileEvent = new Event(0); displayMSpecProjectileEvent.setAction(() => { RangeCombat.displayMSpecProjectile(killer, target); MSpecCounter++; if (MSpecCounter == 1) { displayMSpecProjectileEvent.setTick(500); p.setLastGraphics(new Graphics(256, 0, 90)); Event doMSpecHitEvent = new Event(900); doMSpecHitEvent.setAction(() => { doMSpecHitEvent.stop(); target.hit((int)damage2); RangeCombat.createGroundArrow(killer, target, arrowType); }); Server.registerEvent(doMSpecHitEvent); } else { displayMSpecProjectileEvent.stop(); return; } MSpecCounter++; }); Server.registerEvent(displayMSpecProjectileEvent); break; case 805: // Rune thrownaxe rangeWeapon = true; break; case 6724: // Seercull rangeWeapon = true; break; case 11235: // Dark bow rangeWeapon = true; if (p.getEquipment().getAmountInSlot(ItemData.EQUIP.ARROWS) < 2) { p.getPackets().sendMessage("You need 2 arrows to use the Dark bow!"); return(false); } int minHit = 8; damage = (int)CombatFormula.getRangeHit((Player)killer, target, usingBow, usingArrows); damage2 = (int)CombatFormula.getRangeHit((Player)killer, target, usingBow, usingArrows); if (usingBow == 11235) // Dark bow { if (usingArrows == 11212) // Dragon arrows { minHit = usingRangePrayer ? 4 : 8; damage *= 1.50; damage2 *= 1.50; if (damage < minHit) { damage = minHit; } if (damage2 < minHit) { damage2 = minHit; } } else // Other arrow { minHit = usingRangePrayer ? 3 : 5; damage *= 1.30; damage2 *= 1.30; if (damage < minHit) { damage = minHit; } if (damage2 < minHit) { damage2 = minHit; } } } if (usingRangePrayer) { damage *= 0.60; damage2 *= 0.60; } double a2 = damage + damage2; if (damage > target.getHp()) { damage = target.getHp(); } a2 -= damage; if (damage2 > a2) { damage2 = a2; } /*if (damage >= target.getHp()) { * int randomHp = misc.random(target.getHp()); * damage = randomHp; * damage2 = target.getHp() - randomHp; * } else { * int hpRemaining = target.getHp() - damage; * if (damage2 > hpRemaining) { * damage2 = hpRemaining; * } * }*/ p.setLastGraphics(new Graphics(RangeCombat.getDrawbackGraphic(killer), 0, 90)); RangeCombat.deductArrow(killer); RangeCombat.deductArrow(killer); hitDelay = RangeCombat.getHitDelay(killer, target); int delayHit = hitDelay; hitDelay = 1200; int arrowType1 = RangeCombat.getArrowType(killer); int DBSpecCounter = 0; Event DBSpecProjectile = new Event(0); DBSpecProjectile.setAction(() => { RangeCombat.displayDBSpecProjectile(killer, target); DBSpecCounter++; if (DBSpecCounter == 1) { DBSpecProjectile.setTick(200); Event rangeHitEvent = new Event(delayHit + 600); rangeHitEvent.setAction(() => { target.hit((int)damage2); rangeHitEvent.stop(); RangeCombat.createGroundArrow(killer, target, arrowType1); }); Server.registerEvent(rangeHitEvent); } else { DBSpecProjectile.stop(); return; } DBSpecCounter++; }); Server.registerEvent(DBSpecProjectile); break; } specialAmount -= neededPower; p.setSpecialAmount(specialAmount); usingSpecial = false; refreshBar(); killer.resetCombatTurns(); bool hitDouble = doubleHit; if (target is Player) { if (!rangeWeapon) { if (((Player)target).getPrayers().getHeadIcon() == PrayerData.MELEE) { damage = (int)(damage * 0.60); } } else { if (((Player)target).getPrayers().getHeadIcon() == PrayerData.RANGE) { damage = (int)(damage * 0.60); } } } damage = ((weapon == 4151) ? damage : (misc.randomDouble() * damage)); damage2 = misc.randomDouble() * damage2; int d = (int)((damage == 0 && weapon != 11730) ? 0 : (damage + increasedMaxHit)); int d2 = (int)damage2; int d3 = (int)damage3; // only used for d claws int d4 = (int)damage4; // only used for d claws if (canPoison(weapon)) { if (!target.isPoisoned() && misc.random(5) == 0 && (hitDouble ? (d2 > 0 || d > 0) : d > 0)) { Server.registerEvent(new PoisonEvent(target, POISON_AMOUNT)); } } int hhitDelay = hitDelay; int totDamage = Convert.ToInt32(damage + damage2 + damage3 + damage4); Combat.checkIfWillDie(target, totDamage); Event hitEvent = new Event(hhitDelay); hitEvent.setAction(() => { hitEvent.stop(); if (!target.isDead()) { target.setLastAnimation(new Animation(target.getDefenceAnimation())); } target.hit(d); if (hitDouble) { target.hit(d2); } if (d3 != -1 || d4 != -1) { target.hit(d3); target.hit(d4); } Combat.checkRecoil(killer, target, totDamage); Combat.checkSmite(killer, target, totDamage); Combat.checkVengeance(killer, target, totDamage); Combat.addXp(killer, target, totDamage); }); Server.registerEvent(hitEvent); return(true); }
private void handleEquipItem(Player player, Packet packet) { int item = packet.readLEShort(); int slot = packet.readShortA(); int interfaceId = packet.readInt(); if (slot > 28 || slot < 0 || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null) { return; } SkillHandler.resetAllSkills(player); if (player.getInventory().getItemInSlot(slot) == item) { //player.getPackets().closeInterfaces(); if (RuneCraft.emptyPouch(player, (RuneCraftData.POUCHES)player.getInventory().getItemInSlot(slot))) { return; } player.getEquipment().equipItem(player.getInventory().getItemInSlot(slot), slot); } }
public static void cancelAutoCast(Player p, bool cancelCast) { if (cancelCast) { p.getEquipment().setWeapon(); //p.getPackets().sendConfig(43, 0); resetSpellIcon(p); p.removeTemporaryAttribute("autoCastSpell"); p.removeTemporaryAttribute("autoCastAncients"); p.getPackets().showChildInterface(90, 83, true); p.getPackets().modifyText("Spell", 90, 11); return; } if (p.getTemporaryAttribute("autoCastSpell") != null) { setAutoCastSpell(p, (int)p.getTemporaryAttribute("autoCastSpell2"), (int)p.getTemporaryAttribute("autoCastSpell"), (bool)(p.getTemporaryAttribute("autoCastAncients") != null ? true : false)); } else { //p.getPackets().sendConfig(43, 0); resetSpellIcon(p); p.getEquipment().setWeapon(); p.getPackets().showChildInterface(90, 83, true); p.getPackets().modifyText("Spell", 90, 11); p.removeTemporaryAttribute("autoCastSpell"); p.removeTemporaryAttribute("autoCastAncients"); p.removeTemporaryAttribute("autoCastSpell2"); } }
public static int getAttackSpeed(Player p) { ItemData.Item weaponDef = p.getEquipment().getSlot(ItemData.EQUIP.WEAPON).getDefinition(); if (weaponDef == null) return 5; string weapon = weaponDef.getName(); if (weapon.Contains("dart") || weapon.Contains("knife")) { return 3; } if (weapon.Contains("whip") || weapon.Contains("dagger") || weapon.EndsWith(" sword") || weapon.Contains("scimitar") || weapon.Contains("claws") || weapon.Contains("Toktz-xil-ak") || weapon.Contains("Toktz-xil-ek") || weapon.Contains("Saradomin sword") || weapon.Contains("Saradomin staff") || weapon.Contains("Guthix staff") || weapon.Contains("Zamorak staff") || weapon.Contains("Slayer") || weapon.Contains("ancient") || weapon.Contains("shortbow") || weapon.Contains("Karil") || weapon.Contains("Toktz-xil-ul")) { return 4; } if (weapon.Contains("longsword") || weapon.Contains("mace") || weapon.EndsWith(" axe") || (weapon.Contains("spear") && !weapon.Contains("Guthan")) || weapon.Contains("pickaxe") || weapon.Contains("Tzhaar-ket-em") || weapon.Contains("hammer") || weapon.Contains("flail") || (weapon.Contains("staff") && !weapon.Contains("Guthix") && !weapon.Contains("Saradomin") && !weapon.Contains("Zamorak") && !weapon.Contains("Slayer")) || weapon.Contains("Staff") || weapon.Contains("Iban") || weapon.Contains("composite") || weapon.Contains("Seercull") || weapon.Contains("Crystal") || weapon.Contains("thrownaxe")) { return 5; } if (weapon.EndsWith("battleaxe") || weapon.Contains("warhammer") || weapon.Contains("godsword") || weapon.Contains("Toktz-mej-tal") || weapon.Contains("Ahrim") || weapon.Contains("Zuriel") || weapon.Contains("longbow") || (weapon.EndsWith("crossbow") && !weapon.Contains("Karil")) || weapon.Contains("javelin")) { return 6; } if (weapon.Contains("Guthan") || weapon.Contains("2h") || weapon.Contains("halberd") || weapon.Contains("Granite maul") || weapon.Contains("Tzhaar-ket-om") || weapon.Contains("Dharok")) { return 7; } if (weapon.Contains("ogre")) { return 8; } if (weapon.Contains("Dark bow")) { return 9; } return 5; }
public static int checkForStaffs(Player p, int rune) { for (int i = 0; i < RUNE_REPLACER.Length; i++) { if (p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON) == RUNE_REPLACER[i]) { if (rune == REPLACABLE_RUNES[i]) { rune = -1; break; } } } return rune; }
public static int getAttackAnimation(Player p) { ItemData.Item weaponDef = p.getEquipment().getSlot(ItemData.EQUIP.WEAPON).getDefinition(); if (weaponDef == null) return 422; string weapon = weaponDef.getName(); if (p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON) <= 0) { return 422; } if (weapon.Contains("whip")) { return 1658; } if (weapon.Contains("2h") || weapon.Contains("godsword") || weapon.Contains("Saradomin sword")) { return 7041; } if (weapon.Contains("shortbow") || weapon.Contains("longbow") || weapon.Contains("Crystal bow") || weapon.Contains("Dark bow")) { return 426; } if (weapon.EndsWith("crossbow") && !weapon.Contains("Karil's")) { return 4230; } if (weapon.EndsWith("xil-ul")) { return 2614; } if (weapon.Contains("Karil")) { return 2075; } if (weapon.Contains("claws")) { return 451; } if (weapon.Contains("halberd")) { return 440; } if (weapon.Contains("battleaxe")) { return 395; } if (weapon.Contains("pickaxe") || weapon.Contains("mace") || weapon.Contains("warhammer") || weapon.Contains("staff") || weapon.Contains("Staff") || weapon.Contains("wand")) { return 393; } if (weapon.Contains("Granite maul")) { return 1665; } if (weapon.Contains("dagger")) { return 376; } if (weapon.Contains("Dharok")) { return 2067; } if (weapon.Contains("hammer")) { return 2068; } if (weapon.Contains("flail")) { return 2062; } if (weapon.Contains("Guthan") || weapon.Contains("spear")) { return 2080; } if (weapon.Contains("thrownaxe")) { return 385; } if (weapon.Contains("mace")) { return 393; } if (!weapon.Contains("Dragon") && weapon.Contains("longsword") || weapon.EndsWith(" sword")) { return 400; } if (weapon.Contains("Dragon longsword") || weapon.Contains("scimitar")) { return 451; } return 422; }
public static void configureSelectSpellInterface(Player p) { p.removeTemporaryAttribute("autoCasting"); if (p.getMagicType() == 1) { if (p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON) == 4170) { // Slayer staff. p.getPackets().sendTab(83, 310); return; } else if (p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON) == 8841) { // Void knight mace. p.getPackets().sendTab(83, 406); return; } else { p.getPackets().sendTab(83, 319); } } else if (p.getMagicType() == 2) { if (p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON) == 4675) { // Ancient staff. p.getPackets().sendTab(83, 388); } else { p.getPackets().sendMessage("You cannot autocast Ancient Magic with this staff."); } } }
public static int getWalkAnim(Player p) { int id = p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON); string weapon = ItemData.forId(id).getName(); if (weapon.Equals("Saradomin staff") || weapon.Equals("Guthix staff") || weapon.Equals("Zamorak staff")) { return 0x333; } if (weapon.Contains("flail")) { return 2060; } if (weapon.Contains("Karil")) { return 2076; } if (weapon.Contains("Granite maul")) { return 1663; } if (weapon.Equals("Abyssal whip")) { return 1660; } if (id == 4718 || weapon.EndsWith("2h sword") || weapon.Contains("Tzhaar-ket-om") || weapon.EndsWith("godsword") || weapon.Equals("Saradomin sword")) { return 7046; } if (weapon.Contains("Guthan") || weapon.Contains("spear") || weapon.EndsWith("halberd") || weapon.Contains("Staff") || weapon.Contains("staff") || weapon.Contains("wand") || weapon.Equals("Void knight mace")) { return 1146; } return 819; }
public static double getPlayerMaxHit(Player player, int strBonusIncrease) { AttackStyle.CombatSkill fightType = player.getAttackStyle().getSkill(); double myCurStrength = (double)player.getSkills().getCurLevel(Skills.SKILL.STRENGTH); double myEquipStrengthBonus = (double)(player.getEquipment().getBonus(Equipment.BONUS.STRENGTH) + strBonusIncrease); double fightingStyle = 0; double powerMultiplier = 1; double dharokModifier = 1; double damageMultiplier = 1; int strPrayer = player.getPrayers().getStrengthPrayer(); if (strPrayer == 1) { powerMultiplier += 0.05; } else if (strPrayer == 2) { powerMultiplier += 0.1; } else if (strPrayer == 3) { powerMultiplier += 0.15; } else if (player.getPrayers().getSuperPrayer() == 1) { powerMultiplier += 0.18; } else if (player.getPrayers().getSuperPrayer() == 2) { powerMultiplier += 0.23; } if (wearingMeleeVoid(player)) { damageMultiplier += 0.1; } else if (wearingDharok(player) && misc.random(3) == 0) { dharokModifier = misc.random((int)((player.getSkills().getGreaterLevel(Skills.SKILL.HITPOINTS) - player.getSkills().getCurLevel(Skills.SKILL.HITPOINTS)) * 0.1)); } if (fightType.Equals(AttackStyle.CombatSkill.AGGRESSIVE)) { fightingStyle = 3; } else if (fightType.Equals(AttackStyle.CombatSkill.CONTROLLED)) { fightingStyle = 1; } double cumulativeStrength = ((myCurStrength) * (powerMultiplier) + fightingStyle) * dharokModifier; double maxHit = ((13 + (cumulativeStrength) + (myEquipStrengthBonus / 8) + ((cumulativeStrength * myEquipStrengthBonus) / 64)) * damageMultiplier); // NEW MAX HIT FORMULA maxHit = maxHit / 10; //this is temporary because I haven't yet fully implemented the huge damage system. return maxHit; }