Пример #1
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;
            }
        }
Пример #2
0
        public static void doCourse(Player p, int objectX, int objectY, object[] objectArray)
        {
            if (p.getTemporaryAttribute("unmovable") != null) {
                return;
            }
            switch((int)objectArray[0]) {
                case 2309: //Entrance log
                    CoordinateEvent startEntranceLogCoordinateEvent = new CoordinateEvent(p, new Location((int)objectArray[1], (int)objectArray[2], 0));
                    startEntranceLogCoordinateEvent.setAction(() => {
                        bool running = p.getWalkingQueue().isRunToggled();
                        Event comeToLogEvent = new Event(500);
                        comeToLogEvent.setAction(() => {
                            p.getWalkingQueue().setRunToggled(false);
                            p.getWalkingQueue().resetWalkingQueue();
                            p.getPackets().clearMapFlag();
                            p.setTemporaryAttribute("unmovable", true);
                            p.getWalkingQueue().forceWalk(0, 1); //go past gate, no animation yet.
                            comeToLogEvent.stop();
                        });
                        Server.registerEvent(comeToLogEvent);
                        int doLogWalkCounter = 0;
                        Event doLogWalkEvent = new Event(800);
                        doLogWalkEvent.setAction(() => {
                            if (doLogWalkCounter == 0) { //start the animation
                                p.getAppearance().setWalkAnimation(155);
                                p.getUpdateFlags().setAppearanceUpdateRequired(true);
                                doLogWalkEvent.setTick(500); //500 milliseconds required to make animations realistic.
                            } else if(doLogWalkCounter < 16) { //15 steps foward, 1 step is just quickfix TODO: Add gate opener.
                                p.getWalkingQueue().forceWalk(0, 1);
                            } else if(doLogWalkCounter == 17) { //stop the animation add the xp.
                                doLogWalkEvent.stop();
                                p.getAppearance().setWalkAnimation(-1);
                                p.getUpdateFlags().setAppearanceUpdateRequired(true);
                                p.removeTemporaryAttribute("unmovable");
                                p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
                                p.getWalkingQueue().setRunToggled(running);
                            }
                            doLogWalkCounter++;
                        });
                        Server.registerEvent(doLogWalkEvent);
                    });
                    Server.registerCoordinateEvent(startEntranceLogCoordinateEvent);
                    break;
                case 2288: // Tunnel
                    AreaEvent startTunnelAreaEvent = new AreaEvent(p, 3003, 3937, 3005, 3938);
                    startTunnelAreaEvent.setAction(() => {
                        int newMove = 0;
                        int pX = p.getLocation().getX();
                        int pY = p.getLocation().getY();
                        if (pX == objectX + 1 && pY == objectY) // right side
                            newMove = 1;
                        else if (pX == objectX - 1 && pY == objectY) // left side
                            newMove = 2;
                        if (newMove > 0) {
                            int walkTunnelCounter = 0;
                            Event walkTunnelEvent = new Event(500);
                            walkTunnelEvent.setAction(() => {
                                if (walkTunnelCounter == 0) {
                                    p.getWalkingQueue().forceWalk(0, -1);
                                } else if (walkTunnelCounter == 1) {
                                    p.getWalkingQueue().forceWalk(newMove == 1 ? -1 : +1, 0);
                                } else {
                                    doCourse(p, objectX, objectY, objectArray);
                                    walkTunnelEvent.stop();
                                }
                                walkTunnelCounter++;
                            });
                            Server.registerEvent(walkTunnelEvent);
                            return;
                        }
                        Event squeezeIntoPipeEvent = new Event(0);
                        squeezeIntoPipeEvent.setAction(() => {
                            squeezeIntoPipeEvent.stop();
                            p.getPackets().sendMessage("You squeeze into the pipe...");
                            int regionX = p.getUpdateFlags().getLastRegion().getRegionX();
                            int regionY = p.getUpdateFlags().getLastRegion().getRegionY();
                            int lX = (p.getLocation().getX() - ((regionX - 6) * 8));
                            int lY = (p.getLocation().getY() - ((regionY - 6) * 8));
                            p.setForceMovement(new ForceMovement(lX, lY, lX, lY + 3, 10, 60, 0));
                            p.setFaceLocation(new Location(p.getLocation().getX(), p.getLocation().getY() + 1, 0));
                            p.setLastAnimation(new Animation(10578));
                            bool running = p.getWalkingQueue().isRunToggled();
                            p.getWalkingQueue().setRunToggled(false);
                            p.getWalkingQueue().resetWalkingQueue();
                            p.getPackets().clearMapFlag();
                            p.setTemporaryAttribute("unmovable", true);
                            Event squeezeOutOfPipeEvent = new Event(1000);
                            int squeezeOutOfPipeCounter = 0;
                            squeezeOutOfPipeEvent.setAction(() => {
                                if (squeezeOutOfPipeCounter == 0) {
                                    p.teleport(new Location(p.getLocation().getX(), p.getLocation().getY() + 9, 0));
                                    squeezeOutOfPipeEvent.setTick(850);
                                } else if (squeezeOutOfPipeCounter == 1) {
                                    ForceMovement movement = new ForceMovement(lX, lY + 9, lX, lY + 12, 10, 90, 0);
                                    p.setForceMovement(movement);
                                    squeezeOutOfPipeEvent.setTick(1100);
                                } else if (squeezeOutOfPipeCounter == 2) {
                                    squeezeOutOfPipeEvent.setTick(500);
                                    p.setLastAnimation(new Animation(10579));
                                    p.setForceMovement(new ForceMovement(lX, lY + 12, lX, lY + 13, 10, 40, 0));
                                } else {
                                    p.getPackets().sendMessage("...You squeeze out of the pipe.");
                                    squeezeOutOfPipeEvent.stop();
                                    p.removeTemporaryAttribute("unmovable");
                                    p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
                                    p.getWalkingQueue().setRunToggled(running);
                                    p.teleport(new Location(3004, 3950, 0));
                                }
                                squeezeOutOfPipeCounter++;
                            });
                            Server.registerEvent(squeezeOutOfPipeEvent);
                        });
                        Server.registerEvent(squeezeIntoPipeEvent);
                    });
                    Server.registerCoordinateEvent(startTunnelAreaEvent);
                    break;

                case 2283: // Rope swing
                    AreaEvent startRopeSwingAreaEvent = new AreaEvent(p, 3004, 3951, 3006, 3953);
                    startRopeSwingAreaEvent.setAction(() => {
                        int newMove = 0;
                        int pX = p.getLocation().getX();
                        int pY = p.getLocation().getY();
                        if (pX == objectX - 1 && pY == objectY + 1) // front left
                            newMove = 1;
                        else if (pX == objectX + 1 && pY == objectY + 1) // front right
                            newMove = 2;
                        else if (pX == objectX - 1 && pY == objectY) // back left
                            newMove = 3;
                        else if (pX == objectX + 1 && pY == objectY) // back right
                            newMove = 4;
                        else if (pX == objectX && pY == objectY - 1) // very back middle
                            newMove = 5;
                        else if (pX == objectX && pY == objectY) //  middle
                            newMove = 6;
                        if (newMove > 0) {
                            int path = newMove;
                            int walkRopeSwingCounter = 0;
                            Event walkRopeSwingEvent = new Event(500);
                            walkRopeSwingEvent.setAction(() => {
                                p.setFaceLocation(new Location(3005, 3958, 0));
                                if (path == 1 || path == 2) {
                                    if (walkRopeSwingCounter == 0)
                                    {
                                        p.getWalkingQueue().forceWalk(path == 1 ? +1 : -1, 0);
                                    }
                                    else if (walkRopeSwingCounter >= 1)
                                    {
                                        walkRopeSwingEvent.stop();
                                        doCourse(p, objectX, objectY, objectArray);
                                    }
                                } else if (path == 3 || path == 4) {
                                    if (walkRopeSwingCounter == 0)
                                    {
                                        p.getWalkingQueue().forceWalk(path == 3 ? +1 : -1, +1);
                                    }
                                    else if (walkRopeSwingCounter >= 1)
                                    {
                                        walkRopeSwingEvent.stop();
                                        doCourse(p, objectX, objectY, objectArray);
                                    }
                                } else if (path == 5 || path == 6) {
                                    if (walkRopeSwingCounter == 0)
                                    {
                                        p.getWalkingQueue().forceWalk(0, path == 5 ? +2 : +1);
                                    }
                                    else if (walkRopeSwingCounter >= 1)
                                    {
                                        walkRopeSwingEvent.stop();
                                        doCourse(p, objectX, objectY, objectArray);
                                    }
                                }
                                walkRopeSwingCounter++;
                            });
                            Server.registerEvent(walkRopeSwingEvent);
                            return;
                        }
                        Event setupRopeSwingEvent = new Event(0);
                        setupRopeSwingEvent.setAction(() => {
                            setupRopeSwingEvent.stop();
                            bool running = p.getWalkingQueue().isRunToggled();
                            int regionX = p.getUpdateFlags().getLastRegion().getRegionX();
                            int regionY = p.getUpdateFlags().getLastRegion().getRegionY();
                            int lX = (p.getLocation().getX() - ((regionX - 6) * 8));
                            int lY = (p.getLocation().getY() - ((regionY - 6) * 8));
                            int newY = p.getLocation().getY() + 5;
                            int dir = 4;
                            p.setLastAnimation(new Animation(751));
                            p.setForceMovement(new ForceMovement(lX, lY, lX, lY+5, 25, 57, dir));
                            p.getWalkingQueue().resetWalkingQueue();
                            p.getPackets().clearMapFlag();
                            p.setTemporaryAttribute("unmovable", true);
                            Location objectLocation = new Location(3005, 3952, 0);
                            Event doRopeSwingAnimationEvent = new Event(30);
                            doRopeSwingAnimationEvent.setAction(() => {
                                doRopeSwingAnimationEvent.stop();
                                foreach(Player nearbyPlayers in Server.getPlayerList()) {
                                    if (nearbyPlayers != null) {
                                        nearbyPlayers.getPackets().newObjectAnimation(objectLocation, 497);
                                    }
                                }
                            });
                            Server.registerEvent(doRopeSwingAnimationEvent);

                            Event finishRopeSwingEvent = new Event(1300);
                            finishRopeSwingEvent.setAction(() => {
                                finishRopeSwingEvent.stop();
                                p.getAppearance().setWalkAnimation(-1);
                                p.getUpdateFlags().setAppearanceUpdateRequired(true);
                                p.removeTemporaryAttribute("unmovable");
                                p.teleport(new Location(p.getLocation().getX(), newY, 0));
                                p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
                                p.getWalkingQueue().setRunToggled(running);
                            });
                            Server.registerEvent(finishRopeSwingEvent);
                        });
                        Server.registerEvent(setupRopeSwingEvent);
                    });
                    Server.registerCoordinateEvent(startRopeSwingAreaEvent);
                    break;

                case 37704: // Stepping stones
                    CoordinateEvent startSteppingStonesCoordinateEvent = new CoordinateEvent(p, new Location(3002, 3960, 0));
                    startSteppingStonesCoordinateEvent.setAction(() => {
                        bool running = p.getWalkingQueue().isRunToggled();
                        int dir = 4;
                        p.getWalkingQueue().setRunToggled(false);
                        p.getWalkingQueue().resetWalkingQueue();
                        p.getPackets().clearMapFlag();
                        p.setTemporaryAttribute("unmovable", true);
                        int stepStoneCounter = 0;
                        Event stepStoneEvent = new Event(600);
                        stepStoneEvent.setAction(() => {
                            if (stepStoneCounter >= 6)
                            {
                                stepStoneEvent.stop();
                                p.removeTemporaryAttribute("unmovable");
                                p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
                                p.getWalkingQueue().setRunToggled(running);
                            } else {
                                int regionX = p.getUpdateFlags().getLastRegion().getRegionX();
                                int regionY = p.getUpdateFlags().getLastRegion().getRegionY();
                                int lX = (p.getLocation().getX() - ((regionX - 6) * 8));
                                int lY = (p.getLocation().getY() - ((regionY - 6) * 8));
                                p.setLastAnimation(new Animation(741));
                                p.setForceMovement(new ForceMovement(lX, lY, lX - 1, lY, 5, 35, dir));
                                Event teleportStepStoneEvent = new Event(550);
                                teleportStepStoneEvent.setAction(() => {
                                    teleportStepStoneEvent.stop();
                                    p.teleport(new Location(p.getLocation().getX()-1, p.getLocation().getY(), 0));
                                });
                                Server.registerEvent(teleportStepStoneEvent);
                                stepStoneEvent.setTick(stepStoneCounter == 6 ? 300 : 1100);
                                stepStoneCounter++;
                                p.setFaceLocation(new Location(2995, 3960, 0));
                            }
                        });
                        Server.registerEvent(stepStoneEvent);
                    });
                    Server.registerCoordinateEvent(startSteppingStonesCoordinateEvent);
                    break;

                case 2297: // Log
                    AreaEvent startLogAreaEvent = new AreaEvent(p, 3001, 3944, 3002, 3946);
                    startLogAreaEvent.setAction(() => {
                        int distanceToWalk = p.getLocation().getX() == 3001 ? -7 : -8;
                        int newMove = 0;
                        int pX = p.getLocation().getX();
                        int pY = p.getLocation().getY();
                        if (pX == objectX && pY == objectY - 1)
                            newMove = 1;
                        else if (pX == objectX && pY == objectY + 1)
                            newMove = 2;
                        else if (pX == objectX + 1 && pY == objectY + 1)
                            newMove = 3;
                        else if (pX == objectX + 1 && pY == objectY - 1)
                            newMove = 4;
                        if (newMove > 0) {
                            int path = newMove;
                            int doLogWalkCounter = 0;
                            Event doLogWalkEvent = new Event(500);
                            doLogWalkEvent.setAction(() => {
                                if (doLogWalkCounter == 0)
                                {
                                    if (path == 1 || path == 2) {
                                        p.getWalkingQueue().forceWalk(0, path == 1 ? +1 : -1);
                                    } else if (path == 3 || path == 4) {
                                        p.getWalkingQueue().forceWalk(0, path == 4 ? +1 : -1);
                                    }
                                } else {
                                    doCourse(p, objectX, objectY, objectArray);
                                    doLogWalkEvent.stop();
                                }
                                doLogWalkCounter++;
                            });
                            Server.registerEvent(doLogWalkEvent);
                            return;
                        }
                        Event doLogAnimationEvent = new Event(0);
                        doLogAnimationEvent.setAction(() => {
                            doLogAnimationEvent.stop();
                            bool running = p.getWalkingQueue().isRunToggled();
                            p.getWalkingQueue().setRunToggled(false);
                            p.getWalkingQueue().resetWalkingQueue();
                            p.getPackets().clearMapFlag();
                            p.setTemporaryAttribute("unmovable", true);
                            p.getAppearance().setWalkAnimation(155);
                            p.getUpdateFlags().setAppearanceUpdateRequired(true);
                            p.getWalkingQueue().forceWalk(distanceToWalk, 0);
                            int delay = distanceToWalk == -7 ? 4100 : 4600;
                            Event doLogFinishEvent = new Event(delay);
                            doLogFinishEvent.setAction(() => {
                                doLogFinishEvent.stop();
                                p.getAppearance().setWalkAnimation(-1);
                                p.getUpdateFlags().setAppearanceUpdateRequired(true);
                                p.removeTemporaryAttribute("unmovable");
                                p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
                                p.getWalkingQueue().setRunToggled(running);
                            });
                            Server.registerEvent(doLogFinishEvent);
                        });
                        Server.registerEvent(doLogAnimationEvent);
                    });
                    Server.registerCoordinateEvent(startLogAreaEvent);
                    break;

                case 2328: // Rocks
                    AreaEvent startRocksAreaEvent = new AreaEvent(p, 2993, 3937, 2995, 3937);
                    startRocksAreaEvent.setAction(() => {
                        int doRocksAnimationCounter = 0;
                        Event doRocksAnimationEvent = new Event(0);
                        doRocksAnimationEvent.setAction(() => {
                            if (doRocksAnimationCounter == 0)
                            {
                                p.setFaceLocation(new Location(p.getLocation().getX(), p.getLocation().getY() - 5, 0));
                                doRocksAnimationCounter++;
                                doRocksAnimationEvent.setTick(500);
                                return;
                            }
                            doRocksAnimationEvent.stop();
                            p.setLastAnimation(new Animation(740));
                            p.getWalkingQueue().resetWalkingQueue();
                            p.getPackets().clearMapFlag();
                            p.getAppearance().setWalkAnimation(0);
                            p.getUpdateFlags().setAppearanceUpdateRequired(true);
                            p.setTemporaryAttribute("unmovable", true);
                            int regionX = p.getUpdateFlags().getLastRegion().getRegionX();
                            int regionY = p.getUpdateFlags().getLastRegion().getRegionY();
                            int lX = (p.getLocation().getX() - ((regionX - 6) * 8));
                            int lY = (p.getLocation().getY() - ((regionY - 6) * 8));
                            p.setForceMovement(new ForceMovement(lX, lY, lX, lY - 4, 5, 80, 4));
                            Event finishRocksEvent = new Event(1500);
                            finishRocksEvent.setAction(() => {
                                finishRocksEvent.stop();
                                p.teleport(new Location(p.getLocation().getX(), p.getLocation().getY() - 4, 0));
                                p.setLastAnimation(new Animation(65535));
                                p.removeTemporaryAttribute("unmovable");
                                p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
                            });
                            Server.registerEvent(finishRocksEvent);
                        });
                        Server.registerEvent(doRocksAnimationEvent);
                    });
                    Server.registerCoordinateEvent(startRocksAreaEvent);
                    break;
            }
        }
Пример #3
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;
        }
Пример #4
0
 private static void travel(Player p, int index, bool returning)
 {
     p.setTemporaryAttribute("unmovable", true);
     p.getPackets().displayInterface(120);
     if (returning) {
         p.getPackets().sendMessage("You sail off back to Oo'glog..");
     } else {
         p.getPackets().sendMessage("You climb aboard Captain Bentley's boat and set sail to " + DESTINATION_NAMES[index] + ".");
     }
     Event travelEvent = new Event(2000);
     int travelCounter = 0;
     travelEvent.setAction(() => {
         if (travelCounter == 0)
         {
             travelCounter++;
             travelEvent.setTick(600);
             if (returning) {
                 p.teleport(new Location(2622, 2857, 0));
             } else {
                 p.teleport(new Location(LOCATIONS[index][0], LOCATIONS[index][1], LOCATIONS[index][2]));
             }
         } else {
             travelEvent.stop();
             p.getPackets().sendOverlay(170);
             p.removeTemporaryAttribute("unmovable");
             p.getPackets().sendMessage(returning ? "The boat arrives back in Oo'glog." : DESTINATION_MESSAGES[index]);
             p.getPackets().closeInterfaces();
             Event removeOverlayEvent = new Event(2000);
             removeOverlayEvent.setAction(() => {
                 removeOverlayEvent.stop();
                 p.getPackets().sendRemoveOverlay();
                 if (index == 1) {
                     p.removeTemporaryAttribute("snowInterface");
                 }
             });
             Server.registerEvent(removeOverlayEvent);
         }
     });
     Server.registerEvent(travelEvent);
 }
Пример #5
0
 public static void startEarthQuake(Player player)
 {
     Player p = player;
     p.getPackets().newEarthquake(4, 4, 4, 4, 4);
     p.setTemporaryAttribute("lootedBarrowChest", true);
     p.getPackets().createObject(6775, new Location(3551, 9695, 0), 0, 10);
     p.setBarrowKillCount(0);
     p.getPackets().sendConfig(453, 0);
     Event takeEarthQuakeDamageEvent = new Event(3000 + misc.random(10000)); //every 3-13 seconds.
     takeEarthQuakeDamageEvent.setAction(() => {
         if (p.getTemporaryAttribute("lootedBarrowChest") == null) {
             takeEarthQuakeDamageEvent.stop();
             return;
         }
         p.setLastGraphics(new Graphics(405));
         p.setLastAnimation(new Animation(p.getDefenceAnimation()));
         p.hit(7 + misc.random(15)); //take 7-15 damage
         takeEarthQuakeDamageEvent.setTick(8000 + misc.random(20000)); //reset damage time to 8-20 seconds.
     });
     Server.registerEvent(takeEarthQuakeDamageEvent);
 }
Пример #6
0
        public static void prayerDrainEvent(Player p)
        {
            Event prayerDrainEvent = new Event(5000 + misc.random(5000));
            prayerDrainEvent.setAction(() => {
                if (p.getTemporaryAttribute("atBarrows") == null) {
                    prayerDrainEvent.stop();
                    return;
                }
                int currentPrayer = p.getSkills().getCurLevel(Skills.SKILL.PRAYER);
                int maxLevel = p.getSkills().getMaxLevel(Skills.SKILL.PRAYER);
                int levelBy10 = currentPrayer - (maxLevel / 6);
                if (currentPrayer > 0) {
                    p.getSkills().setCurLevel(Skills.SKILL.PRAYER, levelBy10);
                    p.getPackets().sendSkillLevel(Skills.SKILL.PRAYER);
                }
                int[] array = p.getLocation().getZ() == 0 ? HEADS[1] : HEADS[0];
                int head = array[misc.random(array.Length - 1)];
                int slot = misc.random(5);
                if (slot == 0) {
                    slot=1;
                }
                p.getPackets().itemOnInterface(24, slot, 100,head);
                p.getPackets().animateInterface(2085, 24, slot);
                prayerDrainEvent.setTick(5000 + misc.random(15000));

                Event animateEvent = new Event(4000);
                animateEvent.setAction(() => {
                    p.getPackets().itemOnInterface(24, slot, 100, -1);
                    p.getPackets().animateInterface(-1, 24, slot);
                    animateEvent.stop();
                });
                Server.registerEvent(animateEvent);
            });
            Server.registerEvent(prayerDrainEvent);
        }
Пример #7
0
        public static void showAliDialogue(Player p, int status)
        {
            int newStatus = -1;
            p.getPackets().softCloseInterfaces();
            if (p.getTemporaryAttribute("unmovable") != null) {
                return;
            }
            switch(status) {
                case 205:
                    p.getPackets().sendNPCHead(1862, 241, 2);
                    p.getPackets().modifyText("Ali Morissane", 241, 3);
                    p.getPackets().modifyText("Would you like to go back to Lletya?", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 206;
                    break;

                case 206:
                    p.getPackets().sendChatboxInterface2(228);
                    p.getPackets().modifyText("Yes please, let's go", 228, 2);
                    p.getPackets().modifyText("Not yet", 228, 3);
                    newStatus = 207;
                    break;

                case 207:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("Yes please, let's go.", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 208;
                    break;

                case 208:
                    p.getPackets().sendNPCHead(1862, 241, 2);
                    p.getPackets().modifyText("Ali Morissane", 241, 3);
                    p.getPackets().modifyText("Very well.", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 209;
                    break;

                case 209:
                    p.setTemporaryAttribute("unmovable", true);
                    p.getPackets().displayInterface(120);
                    p.getPackets().sendMessage("Your camel trots off slowly out of the desert..");
                    Event moveBackToLletyaEvent = new Event(2000);
                    int moveBackToLletyaCounter = 0;
                    moveBackToLletyaEvent.setAction(() => {
                        if (moveBackToLletyaCounter == 0)
                        {
                            moveBackToLletyaCounter++;
                            moveBackToLletyaEvent.setTick(600);
                            p.teleport(new Location(2340, 3799, 0));
                        } else {
                            moveBackToLletyaEvent.stop();
                            p.removeTemporaryAttribute("unmovable");
                            p.getPackets().sendMessage("..You and Ali are back in Lletya.");
                            p.getPackets().closeInterfaces();
                        }
                    });
                    Server.registerEvent(moveBackToLletyaEvent);
                    break;

                case 210:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("Not yet.", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 211;
                    break;

                case 211:
                    p.getPackets().sendNPCHead(1862, 241, 2);
                    p.getPackets().modifyText("Ali Morissane", 241, 3);
                    p.getPackets().modifyText("No problem, I will be here when you decide to leave.", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    break;

            }
            if (newStatus != -1) {
                p.setTemporaryAttribute("dialogue", newStatus);
            }
        }
Пример #8
0
        public static void teleportToPatch(Player p, int option)
        {
            p.setTemporaryAttribute("unmovable", true);
            p.getWalkingQueue().resetWalkingQueue();
            p.getPackets().softCloseInterfaces();
            p.getPackets().displayInterface(120);

            Event teleportToPatchEvent = new Event(2000);
            int teleportToPatchCounter = 0;
            teleportToPatchEvent.setAction(() => {
                if (teleportToPatchCounter == 0)
                {
                    teleportToPatchCounter++;
                    teleportToPatchEvent.setTick(600);
                    p.teleport(new Location((int)PATCHES[option][0] + misc.random((int)PATCHES[option][2]), (int)PATCHES[option][1] + misc.random((int)PATCHES[option][3]), 0));
                }
                else
                {
                    teleportToPatchEvent.stop();
                    p.removeTemporaryAttribute("unmovable");
                    p.getPackets().sendMessage("You are teleported to the " + PATCHES[option][4] + ".");
                    p.getPackets().closeInterfaces();
                }
            });
        }