Example #1
0
        private static void summonJadHealers(Player p, Npc jad)
        {
            for (int i = 0; i < 4; i++)
            {
                Npc npc = new Npc(2746);
                Location minCoords = new Location((20000 + 2363) + (200 * p.getIndex()), 25502, 0);
                Location maxCoords = new Location((20000 + 2430) + (200 * p.getIndex()), 25123, 0);
                npc.setMinimumCoords(minCoords);
                npc.setMaximumCoords(maxCoords);
                npc.setLocation(new Location((20000 + 2387) + (200 * p.getIndex()) + Misc.random(22), 20000 + 5069 + Misc.random(33), 0));
                npc.setEntityFocus(jad.getClientIndex());
                npc.setOwner(p);
                npc.getFollow().setFollowing(jad);
                npc.setTarget(null);
                Server.getNpcList().Add(npc);

                Event jadHealerEvent = new Event(2000);
                jadHealerEvent.setAction(() =>
                {
                    if (npc.isDead() || npc.isHidden() || npc.isDestroyed())
                    {
                        jadHealerEvent.stop();
                        return;
                    }
                    if (npc.getLocation().withinDistance(jad.getLocation(), 2) && !npc.inCombat())
                    {
                        if (Misc.random(7) == 0)
                        {
                            jad.setLastGraphics(new Graphics(444));
                            npc.setLastAnimation(new Animation(9254));
                            int jadMaxHp = jad.getMaxHp();
                            jad.heal((int)(jadMaxHp * 0.5));
                        }
                    }
                });
                Server.registerEvent(jadHealerEvent);
            }
        }
Example #2
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;
            }
        }
Example #3
0
 private void startGame()
 {
     Event startFightCaveGameEvent = new Event(3000);
     startFightCaveGameEvent.setAction(() =>
     {
         if (completed)
         {
             startFightCaveGameEvent.stop();
             return;
         }
         if (mobAmount > 0 || currentWave > 63)
         {
             return;
         }
         if (gamePaused && currentWave != 63)
         {
             startFightCaveGameEvent.stop();
             p.getPackets().forceLogout();
             return;
         }
         if (currentWave == 62)
         {
             startFightCaveGameEvent.setTick(8000);
             currentWave++;
             showJadMessage();
             return;
         }
         else if (currentWave < 62)
         {
             currentWave++;
         }
         int[] mobs = decryptWave(currentWave);
         int amount = 0;
         for (int i = 0; i < mobs.Length; i++)
         {
             if (mobs[i] > 0)
             {
                 Npc npc = new Npc(mobs[i]);
                 Location minCoords = new Location(((20000 + 2363) + (200 * p.getIndex())), 25051, 0);
                 Location maxCoords = new Location(((20000 + 2430) + (200 * p.getIndex())), 25123, 0);
                 npc.setMinimumCoords(minCoords);
                 npc.setMaximumCoords(maxCoords);
                 npc.setLocation(new Location((20000 + 2387) + (200 * p.getIndex()) + Misc.random(22), 20000 + 5069 + Misc.random(33), 0));
                 npc.setEntityFocus(p.getClientIndex());
                 npc.setOwner(p);
                 npc.setTarget(p);
                 npc.getFollow().setFollowing(p);
                 Server.getNpcList().Add(npc);
                 amount++;
             }
         }
         mobAmount = (byte)amount;
     });
     Server.registerEvent(startFightCaveGameEvent);
 }
Example #4
0
 protected static void createdAnimatedArmour(Player p, int index)
 {
     if (p.getTemporaryAttribute("warriorGuildAnimator") == null)
     {
         return;
     }
     p.setLastAnimation(new Animation(827));
     p.setTemporaryAttribute("unmovable", true);
     for (int i = 0; i < ARMOUR_SETS[index].Length; i++)
     {
         p.getInventory().deleteItem(ARMOUR_SETS[index][i]);
     }
     p.getPackets().sendChatboxInterface(211);
     p.getPackets().modifyText("You place the armour onto the platform where it", 211, 1);
     p.getPackets().modifyText("dissapears...", 211, 2);
     int animatorIndex = (int)p.getTemporaryAttribute("warriorGuildAnimator");
     Event createAnimatedArmourEvent = new Event(1500);
     int createAnimatedArmourCounter = 0;
     Npc npc = null;
     createAnimatedArmourEvent.setAction(() =>
     {
         if (createAnimatedArmourCounter == 0)
         {
             p.getPackets().sendChatboxInterface(211);
             p.getPackets().modifyText("The animator hums, something appears to be working.", 211, 1);
             p.getPackets().modifyText("You stand back.", 211, 2);
             createAnimatedArmourEvent.setTick(500);
         }
         else if (createAnimatedArmourCounter == 1)
         {
             p.getWalkingQueue().forceWalk(0, +3);
             createAnimatedArmourEvent.setTick(2000);
         }
         else if (createAnimatedArmourCounter == 2)
         {
             createAnimatedArmourEvent.setTick(500);
             Location minCoords = new Location(2849, 3534, 0);
             Location maxCoords = new Location(2861, 3545, 0);
             npc = new Npc(ANIMATED_ARMOUR[index]);
             npc.setMinimumCoords(minCoords);
             npc.setMaximumCoords(maxCoords);
             npc.setLocation(new Location(ANIMATOR_LOCATIONS[animatorIndex][0], ANIMATOR_LOCATIONS[animatorIndex][1], 0));
             npc.setWalkType(WalkType.STATIC);
             npc.setForceText("I'm ALIVE!");
             npc.setLastAnimation(new Animation(4166));
             npc.setEntityFocus(p.getClientIndex());
             npc.setOwner(p);
             npc.setTarget(p);
             p.getPackets().setArrowOnEntity(1, npc.getClientIndex());
             Server.getNpcList().Add(npc);
         }
         else
         {
             p.setEntityFocus(npc.getClientIndex());
             p.getPackets().softCloseInterfaces();
             createAnimatedArmourEvent.stop();
             p.removeTemporaryAttribute("unmovable");
             npc.getFollow().setFollowing(p);
         }
         createAnimatedArmourCounter++;
     });
     Server.registerEvent(createAnimatedArmourEvent);
 }
Example #5
0
 public static bool openCoffin(Player p, int objectId)
 {
     if (objectId != 6823 && objectId != 6771 && objectId != 6821 && objectId != 6773 && objectId != 6822 && objectId != 6772)
     {
         return false;
     }
     int cryptIndex = getCryptIndex(p);
     if (cryptIndex == -1)
     {
         return false;
     }
     if (p.getBarrowBrothersKilled(cryptIndex))
     {
         p.getPackets().sendMessage("You don't find anything.");
         return true;
     }
     if (p.getBarrowTunnel() == cryptIndex)
     {
         p.getPackets().modifyText("You find a hidden tunnel, do you want to enter?", 210, 1);
         p.getPackets().sendChatboxInterface(210);
         p.setTemporaryAttribute("barrowTunnel", 1);
         return true;
     }
     foreach (Npc n in Server.getNpcList())
     {
         if (n.getId() == BROTHER_ID[cryptIndex])
         {
             if (n.getOwner().Equals(p))
             {
                 p.getPackets().sendMessage("You don't find anything.");
                 return true;
             }
         }
     }
     Npc npc = new Npc(BROTHER_ID[cryptIndex]);
     npc.setLocation(p.getLocation());
     npc.setEntityFocus(p.getClientIndex());
     npc.setOwner(p);
     npc.setTarget(p);
     npc.setCombatTurns(npc.getAttackSpeed());
     Server.getNpcList().Add(npc);
     p.getPackets().setArrowOnEntity(1, npc.getClientIndex());
     return true;
 }
Example #6
0
        public static void openChest(Player player)
        {
            Player p = player;
            if (p.getLocation().getZ() != 0 || p.getTemporaryAttribute("lootedBarrowChest") != null)
            {
                return;
            }
            if (!p.getLocation().inArea(3551, 9694, 3552, 9694))
            {
                AreaEvent openChestAreaEvent = new AreaEvent(p, 3551, 9694, 3552, 9694);
                openChestAreaEvent.setAction(() =>
                {
                    openChest(p);
                });
                Server.registerCoordinateEvent(openChestAreaEvent);
                return;
            }
            for (int i = 0; i < 6; i++)
            {
                if (!p.getBarrowBrothersKilled(i))
                {
                    foreach (Npc n in Server.getNpcList())
                    {
                        if (n != null)
                        {
                            if (n.getId() == BROTHER_ID[i])
                            {
                                if (n.getOwner().Equals(p))
                                {
                                    return;
                                }
                            }
                        }
                    }
                    Npc npc = new Npc(BROTHER_ID[i]);
                    npc.setLocation(p.getLocation());
                    npc.setEntityFocus(p.getClientIndex());
                    npc.setOwner(p);
                    npc.setTarget(p);
                    npc.setCombatTurns(npc.getAttackSpeed());
                    Server.getNpcList().Add(npc);
                    p.getPackets().setArrowOnEntity(1, npc.getClientIndex());
                    return;
                }
            }
            p.getPackets().sendMessage("You begin to lift open the massive chest...");
            p.setLastAnimation(new Animation(833));

            Event rewardEarthQuakeEvent = new Event(1000);
            rewardEarthQuakeEvent.setAction(() =>
            {
                rewardEarthQuakeEvent.stop();
                p.getPackets().sendMessage("..You loot the chest and the tomb begins to shake!");
                p.getPackets().createObject(6775, new Location(3551, 9695, 0), 0, 10);
                getBarrowReward(p);
                startEarthQuake(p);
            });
            Server.registerEvent(rewardEarthQuakeEvent);
        }