Ejemplo n.º 1
0
        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)));
        }
Ejemplo n.º 2
0
 public double getMaxHit(int strengthModifier)
 {
     return(CombatFormula.getPlayerMaxHit(this, strengthModifier));
 }
Ejemplo n.º 3
0
 public override double getMaxHit()
 {
     return(CombatFormula.getPlayerMaxHit(this, 0));
 }
Ejemplo n.º 4
0
        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  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().isPrayerActive(PrayerData.Prayer.PROTECT_FROM_RANGED);
            }
            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.getPlayerMaxHit(p, 20) / 2) && damage2 <= (CombatFormula.getPlayerMaxHit(p, 20) / 2))
                 * {
                 * damage = (CombatFormula.getPlayerMaxHit(p, 20) / 2) + (misc.randomDouble(CombatFormula.getPlayerMaxHit(p, 20)) / 2);
                 * damage2 = (CombatFormula.getPlayerMaxHit(p, 20) / 2) + (misc.randomDouble(CombatFormula.getPlayerMaxHit(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;                 //25% decrease.
                break;

            case 11696:             // Bandos godsword.
                killer.setLastGraphics(new Graphics(1223, 0, 100));
                killer.setLastAnimation(new Animation(7073));
                damage += p.getMaxHit() * 0.10;     //10% decrease.
                break;

            case 11698:             // Saradomin godsword.
                killer.setLastGraphics(new Graphics(1220, 0, 100));
                killer.setLastAnimation(new Animation(7071));
                int newHp     = (int)(damage * 0.50);              //50% decrease.
                int newPrayer = (int)(damage * 0.25);              //25% decrease
                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().isPrayerActive(PrayerData.Prayer.PROTECT_FROM_MELEE) ||
                        ((Player)target).getPrayers().isPrayerActive(PrayerData.Prayer.PROTECT_FROM_MAGIC) ||
                        ((Player)target).getPrayers().isPrayerActive(PrayerData.Prayer.PROTECT_FROM_RANGED) ||
                        ((Player)target).getPrayers().isPrayerActive(PrayerData.Prayer.RETRIBUTION) ||
                        ((Player)target).getPrayers().isPrayerActive(PrayerData.Prayer.REDEMPTION) ||
                        ((Player)target).getPrayers().isPrayerActive(PrayerData.Prayer.SMITE))
                    {
                        ((Player)target).getPackets().sendMessage("The Dragon scimitar slashes through your prayer protection!");
                        Prayer.forcePrayerOff((Player)target, PrayerData.Prayer.PROTECT_FROM_MELEE);
                        Prayer.forcePrayerOff((Player)target, PrayerData.Prayer.PROTECT_FROM_MAGIC);
                        Prayer.forcePrayerOff((Player)target, PrayerData.Prayer.PROTECT_FROM_RANGED);
                        Prayer.forcePrayerOff((Player)target, PrayerData.Prayer.RETRIBUTION);
                        Prayer.forcePrayerOff((Player)target, PrayerData.Prayer.REDEMPTION);
                        Prayer.forcePrayerOff((Player)target, PrayerData.Prayer.SMITE);
                    }
                }
                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  = Math.Floor(damage);
                damage2 = Math.Floor(damage * 0.50);                 //50% decrease
                damage3 = Math.Floor(damage2 * 0.50);                //50% decrease
                damage4 = 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;                 //25% decrease
                if (target is Player)
                {
                    int defenceLevel = ((Player)target).getSkills().getCurLevel(Skills.SKILL.DEFENCE);
                    int newDefence   = (int)(defenceLevel * 0.30);                   //30% decrease.
                    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; //20% decrease
                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   = CombatFormula.getRangeHit((Player)killer, target, usingBow, usingArrows);
                damage2  = CombatFormula.getRangeHit((Player)killer, target, usingBow, usingArrows);
                damage  *= 1.05;                //5% increase.
                damage2 *= 1.05;                //5% increase.
                if (usingRangePrayer)
                {
                    damage  *= 0.60;                    //60% decrease.
                    damage2 *= 0.60;                    //60% decrease.
                }
                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(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  = CombatFormula.getRangeHit((Player)killer, target, usingBow, usingArrows);
                damage2 = CombatFormula.getRangeHit((Player)killer, target, usingBow, usingArrows);
                if (usingBow == 11235)                   // Dark bow
                {
                    if (usingArrows == 11212)            // Dragon arrows
                    {
                        minHit   = usingRangePrayer ? 4 : 8;
                        damage  *= 1.50;                        //50% increase.
                        damage2 *= 1.50;                        //50% increase.
                        if (damage < minHit)
                        {
                            damage = minHit;
                        }
                        if (damage2 < minHit)
                        {
                            damage2 = minHit;
                        }
                    }
                    else                         // Other arrow
                    {
                        minHit   = usingRangePrayer ? 3 : 5;
                        damage  *= 1.30;                        //30% increase.
                        damage2 *= 1.30;                        //30% increase.
                        if (damage < minHit)
                        {
                            damage = minHit;
                        }
                        if (damage2 < minHit)
                        {
                            damage2 = minHit;
                        }
                    }
                }
                if (usingRangePrayer)
                {
                    damage  *= 0.60;                    //60% decrease.
                    damage2 *= 0.60;                    //60% decrease.
                }
                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(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.PrayerHeadIcon.MELEE)
                    {
                        damage = (damage * 0.60);                 //60% decrease.
                    }
                }
                else
                {
                    if (((Player)target).getPrayers().getHeadIcon() == PrayerData.PrayerHeadIcon.RANGE)
                    {
                        damage = (damage * 0.60);                 //60% decrease
                    }
                }
            }
            damage  = ((weapon == 4151) ? damage : misc.randomDouble(damage));
            damage2 = misc.randomDouble(damage2);
            double d  = ((damage == 0 && weapon != 11730) ? 0 : (damage + increasedMaxHit));
            double d2 = damage2;
            double d3 = damage3; // only used for d claws
            double d4 = 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;
            double totalDamage = (damage + damage2 + damage3 + damage4);

            Combat.checkIfWillDie(target, totalDamage);
            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.checkRecoilRing(killer, target, totalDamage);
                Combat.checkSmite(killer, target, totalDamage);
                Combat.checkVengeance(killer, target, totalDamage);
                Combat.addXp(killer, target, totalDamage);
            });
            Server.registerEvent(hitEvent);
            return(true);
        }
Ejemplo n.º 5
0
 public override int getMaxHit()
 {
     return((int)CombatFormula.getPlayerMaxHit(this, 0));
 }