示例#1
0
 public static double getMeleeAttack(Player p)
 {
     int attBonus = getHighestAttBonus(p);
     int attLevel = p.getSkills().getCurLevel(Skills.SKILL.ATTACK);
     double power = (attLevel + attBonus) * 0.01365;
     double amount = 1.260;
     power *= (attLevel * (power * 0.12)) + (attBonus * amount) * (power * 0.009);
     if (p.getPrayers().getAttackPrayer() == 1)
     {
         power *= 1.05;
     }
     else if (p.getPrayers().getAttackPrayer() == 2)
     {
         power *= 1.10;
     }
     else if (p.getPrayers().getAttackPrayer() == 3 || p.getPrayers().getSuperPrayer() == 1)
     {
         power *= 1.15;
     }
     else if (p.getPrayers().getSuperPrayer() == 2)
     {
         power *= 1.20;
     }
     if (wearingMeleeVoid(p))
     {
         power *= 1.10;
     }
     return power;
 }
示例#2
0
 public static void displayItemsInterface(Player p)
 {
     int amountToKeep = p.isSkulled() ? 0 : 3;
     if (p.getPrayers().isProtectItem())
     {
         amountToKeep = p.isSkulled() ? 1 : 4;
     }
     int item1 = getProtectedItem1(p)[0];
     int item2 = getProtectedItem2(p)[0];
     int item3 = getProtectedItem3(p)[0];
     int item4 = amountToKeep == 4 ? getProtectedItem4(p)[0] : -1;
     if (amountToKeep == 1)
     {
         item2 = 65535;
         item3 = 65535;
         item3 = item1;
     }
     if (amountToKeep == 0)
     {
         item1 = 65535;
         item2 = 65535;
         item3 = 65535;
         item4 = 65535;
     }
     object[] opts = new object[] { 17598720, 20221838, "You're marked with a <col=ff3333>skull<col=ff981f>.", 0, 1, item4, item1, item2, item3, /* Items to keep */ amountToKeep /* Items to keep */, 0 };
     p.getPackets().displayInterface(102);
     p.getPackets().sendClientScript2(204, 118, opts, "iiooooiisii");
     p.getPackets().setRightClickOptions(1278, (102 * 65536) + 21, 0, 40);
     p.getPackets().setRightClickOptions(1278, (102 * 65536) + 18, 0, 4);
 }
示例#3
0
        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());
        }
示例#4
0
 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;
 }
示例#5
0
 public static double getRangeMaxHit(Player p, int bow, int arrow)
 {
     double hit = 0;
     double a = p.getSkills().getCurLevel(Skills.SKILL.RANGE);
     double b = 1.00;
     double c = 0;
     int d = getRangeStrength(p);
     int prayer = p.getPrayers().getRangePrayer();
     if (prayer == 1)
     {
         b *= 1.05;
     }
     else if (prayer == 2)
     {
         b *= 1.10;
     }
     else if (prayer == 3)
     {
         b *= 1.15;
     }
     if (wearingRangeVoid(p))
     {
         b *= 1.15;
     }
     c = (a * b);
     if (p.getAttackStyle().getStyle().Equals(AttackStyle.CombatStyle.RANGE_ACCURATE))
     {
         c += 3.00;
     }
     hit = ((c + 8) * (d + 64) / 640);
     return Math.Floor(hit);
 }
示例#6
0
        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;
        }
示例#7
0
 public static void teleblockPlayer(Player killer, Player target)
 {
     int teleblockDelay = 300000;
     if (target.getPrayers().getHeadIcon() == PrayerData.MAGIC)
     {
         teleblockDelay = 150000;
     }
     target.setTemporaryAttribute("teleblocked", true);
     target.setTeleblockTime(Environment.TickCount + teleblockDelay);
     Event removeTeleBlockEvent = new Event(teleblockDelay);
     removeTeleBlockEvent.setAction(() =>
     {
         removeTeleBlockEvent.stop();
         if (target != null)
         {
             target.removeTemporaryAttribute("teleblocked");
             target.setTeleblockTime(0);
         }
     });
     Server.registerEvent(removeTeleBlockEvent);
 }
示例#8
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;
            }
            int damage = Misc.random(npc.getMaxHit());
            int prayer = p.getPrayers().getHeadIcon();
            int hitDelay = npc.getHitDelay();
            int animation = npc.getAttackAnimation();
            switch (npc.getId())
            {
                case 2734: // Tz-Kih (lvl 22)
                case 2735:
                    if (prayer == PrayerData.MELEE)
                    {
                        damage = 0;
                    }
                    break;

                case 2739: // Tz-Xil (lvl 90)
                case 2740:
                    if (prayer == PrayerData.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 (prayer == PrayerData.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.random(49);
                        if (prayer == PrayerData.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.random(64);
                        if (prayer == PrayerData.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 -= (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);
        }
示例#9
0
        private static void doJadAttacks(Player p, Npc npc)
        {
            if (npc.getHp() <= (npc.getMaxHp() * 0.50))
            {
                if (p.getFightCave() != null)
                {
                    if (!p.getFightCave().isHealersSpawned())
                    {
                        summonJadHealers(p, npc);
                        p.getFightCave().setHealersSpawned(true);
                    }
                }
            }
            npc.resetCombatTurns();
            npc.setEntityFocus(p.getClientIndex());
            switch (Misc.random(1))
            {
                case 0: // Range
                    npc.setLastAnimation(new Animation(9276));
                    npc.setLastGraphics(new Graphics(1625));
                    Event jadRangeAttackEvent = new Event(1600);
                    int jadRangeAttackStatus = 0;
                    jadRangeAttackEvent.setAction(() =>
                    {
                        int hit = 0;
                        int prayer = p.getPrayers().getHeadIcon();
                        if (jadRangeAttackStatus == 0)
                        {
                            jadRangeAttackStatus++;
                            jadRangeAttackEvent.setTick(1500);
                            p.setLastGraphics(new Graphics(451));
                            if (prayer == PrayerData.RANGE)
                            {
                                hit = 0;
                            }
                            else
                            {
                                hit = Misc.random(96);
                            }
                        }
                        else
                        {
                            if (prayer != PrayerData.RANGE)
                            {
                                hit = Misc.random(96);
                            }
                            jadRangeAttackEvent.stop();
                            p.setLastAttacked(Environment.TickCount);
                            npc.setLastAttack(Environment.TickCount);
                            p.setAttacker(npc);
                            if (hit > p.getHp())
                            {
                                hit = p.getHp();
                            }
                            if (!Location.inFightCave(p.getLocation()) || p.getTeleportTo() != null)
                            {
                                return;
                            }
                            if ((p.getCombatTurns() > 2 || p.getCombatTurns() < 0))
                            {
                                p.setLastAnimation(new Animation(p.getDefenceAnimation()));
                            }
                            p.hit(hit);
                            Event animationEvent = new Event(100);
                            animationEvent.setAction(() =>
                            {
                                animationEvent.stop();
                                p.setLastGraphics(new Graphics(157, 0, 100));
                            });
                            Server.registerEvent(animationEvent);
                        }
                    });
                    Server.registerEvent(jadRangeAttackEvent);
                    break;

                case 1: // Magic
                    npc.setLastGraphics(new Graphics(1626));
                    Event jadMagicAttackEvent = new Event(300);
                    int jadMagicAttackStatus = 0;
                    jadMagicAttackEvent.setAction(() =>
                    {
                        int hit = 0;
                        int prayer = p.getPrayers().getHeadIcon();
                        npc.setLastAnimation(new Animation(9278));
                        if (jadMagicAttackStatus == 0)
                        {
                            jadMagicAttackStatus++;
                            jadMagicAttackEvent.setTick(1600);
                            p.getPackets().sendProjectile(npc.getLocation(), p.getLocation(), 32, 1627, 50, 40, 34, 90, p);
                        }
                        else
                        {
                            jadMagicAttackEvent.stop();
                            if (prayer == PrayerData.MAGIC)
                            {
                                hit = 0;
                            }
                            else
                            {
                                hit = Misc.random(96);
                            }
                            p.setLastAttacked(Environment.TickCount);
                            npc.setLastAttack(Environment.TickCount);
                            p.setAttacker(npc);
                            if (hit > p.getHp())
                            {
                                hit = p.getHp();
                            }
                            if (!Location.inFightCave(p.getLocation()) || p.getTeleportTo() != null)
                            {
                                return;
                            }
                            if ((p.getCombatTurns() > 2 || p.getCombatTurns() < 0))
                            {
                                p.setLastAnimation(new Animation(p.getDefenceAnimation()));
                            }
                            p.hit(hit);
                            Event animationEvent = new Event(100);
                            animationEvent.setAction(() =>
                            {
                                animationEvent.stop();
                                p.setLastGraphics(new Graphics(157, 0, 100));
                            });
                            Server.registerEvent(animationEvent);
                        }
                    });
                    Server.registerEvent(jadMagicAttackEvent);
                    break;
            }
        }