コード例 #1
0
ファイル: MagicCombat.cs プロジェクト: Krill156/SharpEMU
 public static void castCharge(Player p)
 {
     p.removeTemporaryAttribute("autoCasting");
     if (p.getSkills().getCurLevel(Skills.SKILL.MAGIC) < 80) {
         p.getPackets().sendMessage("You need a Magic level of 80 to cast Charge.");
         return;
     }
     if (!hasRunes(p, CHARGE_RUNES, CHARGE_RUNE_AMOUNT)) {
         p.getPackets().sendMessage("You do not have enough runes to cast Charge.");
         return;
     }
     if (p.getTemporaryAttribute("godCharged") != null) {
         p.getPackets().sendMessage("You have already charged your god spells.");
         return;
     }
     if (hasGodCapeAndStaff(p)) {
         p.getPackets().sendMessage("You must wear a God cape and wield the matching staff to cast Charge.");
         return;
     }
     if (!deleteRunes(p, CHARGE_RUNES, CHARGE_RUNE_AMOUNT)) {
         return;
     }
     p.setTemporaryAttribute("godCharged", true);
     p.setLastGraphics(new Graphics(308, 800, 90));
     p.setLastAnimation(new Animation(811));
     p.getPackets().sendMessage("You feel charged with magical power..");
     int delay = 60000 + misc.random(120000); //60 seconds + possible 120 seconds so, 1 minute to 2 minutes.
     Event removeGodChargeEvent = new Event(delay);
     removeGodChargeEvent.setAction(() => {
         removeGodChargeEvent.stop();
         p.removeTemporaryAttribute("godCharged");
         p.getPackets().sendMessage("Your magical charge fades away.");
     });
     Server.registerEvent(removeGodChargeEvent);
 }
コード例 #2
0
        public static void levelUp(Player player, SKILL skill)
        {
            int    skillIndex = Convert.ToInt32(skill);
            String s          = "<br><br><br>";
            String s1         = "<br><br><br><br>";

            if (player.getTemporaryAttribute("teleporting") == null)
            {
                player.setLastGraphics(new Graphics(199, 0, 100));
            }

            int skillFlashFlags = (int)(player.getTemporaryAttribute("skillFlashFlags") == null ? 0 : (int)player.getTemporaryAttribute("skillFlashFlags"));

            skillFlashFlags |= SKILL_FLASH_BITMASKS[skillIndex];
            player.setTemporaryAttribute("skillFlashFlags", skillFlashFlags);

            player.getPackets().sendMessage("You've just advanced a " + SKILL_NAME[skillIndex] + " level! You have reached level " + player.getSkills().getMaxLevel(skillIndex) + ".");
            player.getPackets().modifyText(s + "Congratulations, you have just advanced a " + SKILL_NAME[skillIndex] + " level!", 740, 0);
            player.getPackets().modifyText(s1 + "You have now reached level " + player.getSkills().getMaxLevel(skillIndex) + ".", 740, 1);
            player.getPackets().modifyText("", 740, 2);
            player.getPackets().sendConfig(1179, SKILL_ICON_BITMASKS[skillIndex] | skillFlashFlags); //start flashing appropriate skill icons
            player.getPackets().sendChatboxInterface2(740);
            player.getUpdateFlags().setAppearanceUpdateRequired(true);
        }
コード例 #3
0
ファイル: FightCave.cs プロジェクト: Krill156/SharpEMU
        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);
        }
コード例 #4
0
ファイル: FightCave.cs プロジェクト: Krill156/SharpEMU
        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;
            }
        }
コード例 #5
0
ファイル: MagicCombat.cs プロジェクト: Krill156/SharpEMU
        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);
            }
        }
コード例 #6
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 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);
        }
コード例 #7
0
ファイル: LaddersAndStairs.cs プロジェクト: Krill156/SharpEMU
 public static void useLever(Player p, int id, Location leverLocation)
 {
     if (p.getTemporaryAttribute("teleporting") != null)
     {
         return;
     }
     foreach (LoadedLaddersAndStairs.Lever lever in LoadedLaddersAndStairs.levers)
     {
         if (lever.getId() == id)
         {
             if (lever.getLeverLocation().Equals(leverLocation))
             {
                 LoadedLaddersAndStairs.Lever l = lever;
                 //TODO when in use it cant be used (in use = lever is facing down)
                 CoordinateEvent useLeverCoordinateEvent = new CoordinateEvent(p, l.getLeverLocation());
                 useLeverCoordinateEvent.setAction(() =>
                 {
                     p.setFaceLocation(l.getFaceLocation());
                     if (p.getTemporaryAttribute("teleblocked") != null)
                     {
                         p.getPackets().sendMessage("A magical force prevents you from teleporting!");
                         return;
                     }
                     else if ((p.getTemporaryAttribute("teleporting") != null))
                     {
                         return;
                     }
                     p.setLastAnimation(new Animation(2140));
                     p.getPackets().closeInterfaces();
                     p.setTemporaryAttribute("teleporting", true);
                     p.getWalkingQueue().resetWalkingQueue();
                     p.getPackets().clearMapFlag();
                     SkillHandler.resetAllSkills(p);
                     l.setInUse(true);
                     Event useLeverEvent = new Event(700);
                     useLeverEvent.setAction(() =>
                     {
                         useLeverEvent.stop();
                         p.setLastAnimation(new Animation(8939, 0));
                         p.setLastGraphics(new Graphics(1576, 0));
                         l.setInUse(false);
                         Event setLeverTeleportEvent = new Event(1800);
                         setLeverTeleportEvent.setAction(() =>
                         {
                             setLeverTeleportEvent.stop();
                             p.teleport(l.getTeleLocation());
                             p.setLastAnimation(new Animation(8941, 0));
                             p.setLastGraphics(new Graphics(1577, 0));
                             Teleport.resetTeleport(p);
                         });
                         Server.registerEvent(setLeverTeleportEvent);
                     });
                     Server.registerEvent(useLeverEvent);
                 });
                 Server.registerCoordinateEvent(useLeverCoordinateEvent);
                 break;
             }
         }
     }
 }