예제 #1
0
        public static void load()
        {
            if (!File.Exists(Misc.getServerPath() + @"\data\npcs.xml"))
            {
                Misc.WriteError(@"Missing data\npcs.xml");
                return;
            }
            try
            {
                //Deserialize text file to a new object.
                StreamReader objStreamReader = new StreamReader(Misc.getServerPath() + @"\data\npcs.xml");
                XmlSerializer serializer = new XmlSerializer(typeof(List<NpcSpawn>));
                List<NpcSpawn> spawns = (List<NpcSpawn>)serializer.Deserialize(objStreamReader);

                foreach (NpcSpawn ns in spawns)
                {
                    Npc n = new Npc(ns.id, ns.location);
                    n.setMinimumCoords(ns.minimumCoords);
                    n.setMaximumCoords(ns.maximumCoords);
                    n.setWalkType(ns.walkType);
                    n.setFaceDirection(ns.faceDirection);
                    Server.getNpcList().Add(n);
                }
            }
            catch (Exception e)
            {
                Misc.WriteError((e.InnerException == null ? e.ToString() : e.InnerException.ToString()));
            }
            Console.WriteLine("Spawned " + Server.getNpcList().Count + " npcs.");
        }
예제 #2
0
 public static bool dialogue(Player p, Npc npc, bool rightClickPay)
 {
     if ((npc.getId() != 1055 && npc.getId() != 437) || (rightClickPay && npc.getId() != 437))
     {
         return false;
     }
     p.setEntityFocus(npc.getClientIndex());
     AreaEvent dialogueAreaEvent = new AreaEvent(p, npc.getLocation().getX() - 1, npc.getLocation().getY() - 1, npc.getLocation().getX() + 1, npc.getLocation().getY() + 1);
     dialogueAreaEvent.setAction(() =>
     {
         npc.setFaceLocation(p.getLocation());
         int status = npc.getId() == 1055 ? 43 : 1;
         if (rightClickPay)
         {
             if (!p.getInventory().hasItemAmount(995, AGILITY_ARENA_PRICE))
             {
                 p.getPackets().sendMessage("You don't have enough money to pay the entrance fee.");
                 return;
             }
             status = 29;
         }
         doDialogue(p, status);
     });
     Server.registerCoordinateEvent(dialogueAreaEvent);
     return true;
 }
예제 #3
0
        public static void interactWithAubury(Player p, Npc n, int option)
        {
            p.setEntityFocus(n.getClientIndex());
            AreaEvent interactWithAuburyAreaEvent = new AreaEvent(p, n.getLocation().getX() - 1, n.getLocation().getY() - 1, n.getLocation().getX() + 1, n.getLocation().getY() + 1);
            interactWithAuburyAreaEvent.setAction(() =>
            {
                n.setFaceLocation(p.getLocation());
                p.setFaceLocation(n.getLocation());
                p.setEntityFocus(65535);
                switch (option)
                {
                    case 1: // talk to

                        break;

                    case 2: // trade
                        p.setShopSession(new ShopSession(p, 3));
                        break;

                    case 3: // teleport
                        RuneCraft.teleportToEssMine(p, n);
                        break;
                }
            });
            Server.registerCoordinateEvent(interactWithAuburyAreaEvent);
        }
예제 #4
0
 public static bool npcAttack(Npc npc, Entity target)
 {
     if (npcHasAttack(npc))
     {
         doNpcAttack(npc, target);
         return true;
     }
     return false;
 }
예제 #5
0
 public NpcSkills(Npc npc)
 {
     this.npc = npc;
     for (int i = 0; i < SKILL_COUNT - 1; i++)
     {
         curLevel[i] = 1;
         maxLevel[i] = 1;
     }
     curLevel[3] = 10;
     maxLevel[3] = 10;
 }
예제 #6
0
 public static void interactWithAliMorissaae(Player p, Npc n)
 {
     p.setEntityFocus(n.getClientIndex());
     AreaEvent interactWithAliMorissaaeAreaEvent = new AreaEvent(p, n.getLocation().getX() - 1, n.getLocation().getY() - 1, n.getLocation().getX() + 1, n.getLocation().getY() + 1);
     interactWithAliMorissaaeAreaEvent.setAction(() =>
     {
         n.setFaceLocation(p.getLocation());
         p.setFaceLocation(n.getLocation());
         p.setEntityFocus(65535);
         showAliDialogue(p, 205);
     });
     Server.registerCoordinateEvent(interactWithAliMorissaaeAreaEvent);
 }
예제 #7
0
 public static bool wantToThieveNpc(Player p, Npc npc)
 {
     for (int i = 0; i < NPCS.Length; i++)
     {
         for (int j = 0; j < NPCS[i].Length; j++)
         {
             if (npc.getId() == NPCS[i][j])
             {
                 thieveNpc(p, npc, i);
                 return true;
             }
         }
     }
     return false;
 }
예제 #8
0
파일: TzHaar.cs 프로젝트: ramatronics/rsps
        public static bool interactTzhaarNPC(Player p, Npc n, int option)
        {
            if (n.getId() != 2622 && n.getId() != 2620 && n.getId() != 2623 && n.getId() != 2619 && n.getId() != 2617 && n.getId() != 2618)
            {
                return false;
            }
            p.setEntityFocus(n.getClientIndex());
            int npcX = n.getLocation().getX();
            int npcY = n.getLocation().getY();
            AreaEvent interactTzhaarNpcAreaEvent = new AreaEvent(p, npcX - 1, npcY - 1, npcX + 1, npcY + 1);
            interactTzhaarNpcAreaEvent.setAction(() =>
            {
                p.setFaceLocation(n.getLocation());
                p.setEntityFocus(65535);
                switch (n.getId())
                {
                    case 2619: // Bankers
                        if (option == 1)
                        { // Talk
                        }
                        else if (option == 2)
                        { // Bank
                            p.getBank().openBank();
                        }
                        else if (option == 3)
                        { // Collect
                        }
                        break;

                    //TODO tzhaar stores
                    case 2622: // Ore shop
                        if (option == 1)
                        { // Speak
                        }
                        else if (option == 2)
                        { // Trade
                            p.setShopSession(new ShopSession(p, 3));
                        }
                        break;
                }
            });
            Server.registerCoordinateEvent(interactTzhaarNpcAreaEvent);
            return true;
        }
예제 #9
0
        public static bool interactWithBoatNPC(Player p, Npc n)
        {
            int id = n.getId();
            if (id != 4540 && id != 1304 && id != 2436 && id != 3781 && id != 1361 && id != 4962)
            {
                return false;
            }
            p.setEntityFocus(n.getClientIndex());
            AreaEvent interactWithBoatNPCAreaEvent = new AreaEvent(p, n.getLocation().getX() - 1, n.getLocation().getY() - 1, n.getLocation().getX() + 1, n.getLocation().getY() + 1);
            interactWithBoatNPCAreaEvent.setAction(() =>
            {
                n.setFaceLocation(p.getLocation());
                p.setFaceLocation(n.getLocation());
                p.setEntityFocus(65535);
                switch (n.getId())
                {
                    case 4540: // Home boat
                        showBentleyDialogue(p, 240);
                        break;

                    case 1304: // Canifis sailor
                        showCanifisSailorDialogue(p, 280);
                        break;

                    case 2436: // Waterbirth isle
                        showJarvaldDialogue(p, 300);
                        break;

                    case 3781: // Pest control squire
                        showSquireDialogue(p, 340);
                        break;

                    case 1361: // Warrior guild
                        showArnorDialogue(p, 370);
                        break;

                    case 4962: // fremmenik shore
                        showCaptainBarnabyDialogue(p, 410);
                        break;
                }
            });
            Server.registerCoordinateEvent(interactWithBoatNPCAreaEvent);
            return true;
        }
예제 #10
0
파일: Fishing.cs 프로젝트: ramatronics/rsps
        public static bool wantToFish(Player p, Npc npc, bool secondOption)
        {
            for (int i = 0; i < SPOT_IDS.Length; i++)
            {
                if (npc.getId() == SPOT_IDS[i])
                {
                    p.setFaceLocation(npc.getLocation());

                    AreaEvent startFishingAreaEvent = new AreaEvent(p, npc.getLocation().getX() - 1, npc.getLocation().getY() - 1, npc.getLocation().getX() + 1, npc.getLocation().getY() + 1);
                    startFishingAreaEvent.setAction(() =>
                    {
                        startFishing(p, i, npc, true, secondOption);
                    });
                    Server.registerCoordinateEvent(startFishingAreaEvent);
                    return true;
                }
            }
            return false;
        }
예제 #11
0
        public void execute(Player player, string[] arguments)
        {
            if (arguments.Length == 0)
            {
                player.getPackets().sendMessage("[SpawnNpc command]: ::npc npc_id");
                return;
            }

            int npcId = 0;
            if (!int.TryParse(arguments[0], out npcId))
            {
                player.getPackets().sendMessage("[SpawnNpc command]: ::npc npc_id");
                return;
            }

            Npc npc = new Npc(npcId, player.getLocation());
            npc.setMinimumCoords(new Location(player.getLocation().getX() - 5, player.getLocation().getY() - 5, player.getLocation().getZ()));
            npc.setMaximumCoords(new Location(player.getLocation().getX() + 5, player.getLocation().getY() + 5, player.getLocation().getZ()));
            Server.getNpcList().Add(npc);
        }
예제 #12
0
        private static void doNpcAttack(Npc npc, Entity target)
        {
            switch (npc.getId())
            {
                case DHAROK:
                case AHRIM:
                case TORAG:
                case VERAC:
                case KARIL:
                case GUTHAN:
                    BarrowNPCAttacks.attack(npc, target);
                    break;

                case 6263:
                case 6260:
                case 6265:
                case 6247:
                case 6250:
                case 6252:
                case 6203:
                case 6208:
                case 6206:
                case 6222:
                case 6223:
                case 6225:
                    GodwarsAttacks.attack(npc, target);
                    break;

                case 2734:
                case 2735:
                case 2739:
                case 2740:
                case 2741:
                case 2742:
                case 2743:
                case 2744:
                case 2745:
                    FightCave.fightCaveAttacks(npc, ((Player)target));
                    break;
            }
        }
예제 #13
0
파일: Slayer.cs 프로젝트: ramatronics/rsps
 public static void checkSlayerKill(Player p, Npc npc)
 {
     if (p.getSlayerTask() == null)
     {
         return;
     }
     SlayerTask task = p.getSlayerTask();
     object[][] data = getMasterData(task.getMasterIndex());
     for (int i = 1; i < data[task.getMonsterIndex()].Length; i++)
     {
         if (npc.getId() == (int)data[task.getMonsterIndex()][i])
         {
             if (npc.getKiller().Equals(p))
             {
                 p.getSkills().addXp(Skills.SKILL.SLAYER, npc.getMaxHp());//(double) data[task.getMonsterIndex()][1]);
                 checkIfCompleteTask(p, task);
                 break;
             }
         }
     }
 }
예제 #14
0
        protected bool checkHitTarget()
        {
            int cannonX = fakeCannonLocation.getX();
            int cannonY = fakeCannonLocation.getY();
            Npc[] npcsToAttack = new Npc[npcsInArea.Count];
            bool hit = false;
            foreach (Npc n in Server.getNpcList())
            {
                hit = false;
                Location l = n.getLocation();
                if (n == null || n.isHidden() || n.isDead() || !n.getLocation().withinDistance(fakeCannonLocation, 8))
                {
                    continue;
                }
                switch (direction)
                {
                    case 0: // North
                        hit = l.inArea(cannonX - 1, cannonY, cannonX + 1, cannonY + 8);
                        break;

                    case 1: // North east
                        break;

                    case 2: // East:
                        hit = l.inArea(cannonX, cannonY - 1, cannonX + 8, cannonY + 1);
                        break;

                    case 3: // South east
                        break;

                    case 4: // South
                        hit = l.inArea(cannonX - 1, cannonY - 8, cannonX + 1, cannonY);
                        break;

                    case 5: // South west
                        break;

                    case 6: // West
                        hit = l.inArea(cannonX - 8, cannonY - 1, cannonX, cannonY + 1);
                        break;

                    case 7: // North west
                        break;
                }
                if (hit)
                {
                    Npc npc = n;
                    p.getPackets().sendProjectile(fakeCannonLocation, n.getLocation(), 30, 53, 50, 38, 38, 40, n);
                    Event doCannonHitEvent = new Event(1000);
                    doCannonHitEvent.setAction(() =>
                    {
                        doCannonHitEvent.stop();
                        int damage = Misc.random(30);
                        p.getSkills().addXp(Skills.SKILL.RANGE, damage * 2);
                        npc.hit(damage);
                        npc.setLastAnimation(new Animation(npc.getDefenceAnimation()));
                    });
                    Server.registerEvent(doCannonHitEvent);
                    return true;
                }
            }
            return false;
        }
예제 #15
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;
            }
        }
예제 #16
0
        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);
            }
        }
예제 #17
0
 public static int getNPCHitDelay(Npc npc)
 {
     /*switch (npc.getId())
     {
     }*/
     return 450;
 }
예제 #18
0
        public static void attack(Npc npc, Entity target)
        {
            if (npc.isDead() || npc.getOwner() == null || npc.isDestroyed() || target.isDead() || target.isDestroyed())
            {
                return;
            }
            int damage = Misc.random(npc.getMaxHit());
            int prayer = ((Player)target).getPrayers().getHeadIcon();
            int hitDelay = npc.getHitDelay();
            bool special = false;
            switch (npc.getId())
            {
                case 2026: // Dharok
                    int healthHit = (npc.getMaxHp() - npc.getHp()) / 2;
                    damage = Misc.random(damage + healthHit);
                    if (Misc.random(1) == 0)
                    {
                        if (damage < (npc.getMaxHp() / 3))
                        {
                            damage = (npc.getMaxHp() / 4) + Misc.random(damage + healthHit) - (npc.getMaxHp() / 4);
                        }
                    }
                    if (prayer == PrayerData.MELEE)
                    {
                        damage = 0;
                    }
                    break;

                case 2025: // Ahrim
                    hitDelay = 1000;
                    ((Player)target).getPackets().sendProjectile(npc.getLocation(), target.getLocation(), 32, 156, 50, 40, 34, 60, target);
                    if (Misc.random(3) == 0)
                    {
                        special = true;
                        Skills.SKILL[] weakenableSkills = (Skills.SKILL[])Enum.GetValues(typeof(Skills.SKILL));
                        Skills.SKILL weakenedSkill = weakenableSkills[Misc.random(0, 2)];
                        int currentLevel = ((Player)target).getSkills().getCurLevel(weakenedSkill);
                        int newLevel = currentLevel - Misc.random(((Player)target).getSkills().getMaxLevel(weakenedSkill) / 12);
                        newLevel = Math.Max(0, newLevel);
                        ((Player)target).getSkills().setCurLevel(weakenedSkill, newLevel);
                        ((Player)target).getPackets().sendSkillLevel(weakenedSkill);
                    }
                    if (prayer == PrayerData.MAGIC)
                    {
                        damage = 0;
                    }
                    break;

                case 2027: // Guthan
                    if (prayer == PrayerData.MELEE)
                    {
                        damage = 0;
                    }
                    if (Misc.random(3) == 0)
                    {
                        special = true;
                        target.setLastGraphics(new Graphics(398));
                        npc.heal(Misc.random(damage));
                    }
                    break;

                case 2030: // Verac
                    if (Misc.random(1) == 0 && prayer != 0)
                    {
                        if (damage <= npc.getMaxHit() / 2)
                        {
                            damage += npc.getMaxHit() / 2;
                            if (damage > npc.getMaxHit())
                            {
                                damage = npc.getMaxHit();
                            }
                        }
                    }
                    break;

                case 2029: // Torag
                    if (Misc.random(3) == 0)
                    {
                        special = true;
                    }
                    if (prayer == PrayerData.MELEE)
                    {
                        damage = 0;
                    }
                    break;

                case 2028: // Karil
                    hitDelay = 700;
                    ((Player)target).getPackets().sendProjectile(npc.getLocation(), target.getLocation(), 32, 27, 50, 40, 34, 40, target);
                    if (Misc.random(10) == 0)
                    {
                        special = true;
                        int agility = ((Player)target).getSkills().getCurLevel(Skills.SKILL.AGILITY);
                        int newAgility = agility / 4;
                        if (newAgility <= 1)
                            newAgility = 1;
                        ((Player)target).getSkills().setCurLevel(Skills.SKILL.AGILITY, newAgility);
                        ((Player)target).getPackets().sendSkillLevel(Skills.SKILL.AGILITY);
                    }
                    if (Misc.random(1) == 0)
                    {
                        damage = damage > 0 ? damage : Misc.random(npc.getMaxHit());
                    }
                    if (prayer == PrayerData.RANGE)
                    {
                        damage = 0;
                    }
                    break;
            }
            npc.setLastAnimation(new Animation(npc.getAttackAnimation()));
            target.setLastAttacked(Environment.TickCount);
            npc.setLastAttack(Environment.TickCount);
            npc.resetCombatTurns();
            target.setAttacker(npc);
            if ((target.getCombatTurns() > 2 || target.getCombatTurns() < 0))
            {
                target.setLastAnimation(new Animation(target.getDefenceAnimation()));
            }
            if (damage > target.getHp())
            {
                damage = target.getHp();
            }
            Event doHitEvent = new Event(hitDelay);
            doHitEvent.setAction(() =>
            {
                if (npc.getId() == 2025)
                {
                    if (special)
                    {
                        target.setLastGraphics(new Graphics(400, 0, 100));
                        ((Player)target).getPackets().sendMessage("You feel weakened.");
                    }
                    target.setLastGraphics(new Graphics(damage == 0 ? 85 : 157, 0, 100));
                }
                else if (npc.getId() == 2027)
                {
                    if (special)
                    {
                        if (!npc.isDead())
                        {
                            int newHp = npc.getHp() + damage;
                            if (newHp > npc.getMaxHp())
                            {
                                newHp = npc.getMaxHp();
                            }
                            npc.setHp(newHp);
                        }
                    }
                }
                else if (npc.getId() == 2029)
                {
                    if (special)
                    {
                        target.setLastGraphics(new Graphics(399, 0, 100));
                        int energy = ((Player)target).getRunEnergy();
                        int newEnergy = energy - (int)(energy * 0.50);
                        if (newEnergy < 0)
                        {
                            newEnergy = 0;
                        }
                        ((Player)target).getPackets().sendMessage("You feel drained of energy.");
                        ((Player)target).setRunEnergy(newEnergy);
                        ((Player)target).getPackets().sendEnergy();
                    }
                }
                else if (npc.getId() == 2028)
                {
                    if (special)
                    {
                        target.setLastGraphics(new Graphics(399));
                        ((Player)target).getPackets().sendMessage("You feel less agile.");
                    }
                }
                target.hit(damage);
                doHitEvent.stop();
            });
        }
예제 #19
0
 private static bool npcHasAttack(Npc npc)
 {
     for (int i = 0; i < NPCS.Length; i++)
     {
         if (npc.getId() == NPCS[i])
         {
             return true;
         }
     }
     return false;
 }
예제 #20
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);
            }
        }
예제 #21
0
        public static void fightCaveAttacks(Npc npc, Player p)
        {
            if (npc.isDead() || npc.isDestroyed() || p.isDead() || p.isDestroyed() || p.isDead() || !Location.inFightCave(p.getLocation()) || p.getTeleportTo() != null)
            {
                return;
            }
            int damage = Misc.random(npc.getMaxHit());
            int prayer = p.getPrayers().getHeadIcon();
            int hitDelay = npc.getHitDelay();
            int animation = npc.getAttackAnimation();
            switch (npc.getId())
            {
                case 2734: // Tz-Kih (lvl 22)
                case 2735:
                    if (prayer == PrayerData.MELEE)
                    {
                        damage = 0;
                    }
                    break;

                case 2739: // Tz-Xil (lvl 90)
                case 2740:
                    if (prayer == PrayerData.RANGE)
                    {
                        damage = 0;
                    }
                    p.getPackets().sendProjectile(npc.getLocation(), p.getLocation(), 32, 1616, 50, 40, 34, 50, p);
                    break;

                case 2741: // Yt-MejKot (lvl 180)
                case 2742:
                    if (prayer == PrayerData.MELEE)
                    {
                        damage = 0;
                    }
                    // TODO healing
                    break;

                case 2743: // Ket-Zek (lvl 360)
                case 2744:
                    if (!p.getLocation().withinDistance(npc.getLocation(), 2))
                    {
                        hitDelay = 1600;
                        animation = 9266;
                        npc.setLastGraphics(new Graphics(1622));
                        damage = Misc.random(49);
                        if (prayer == PrayerData.MAGIC)
                        {
                            damage = 0;
                        }
                        Event sendProjectileToNpc = new Event(300);
                        sendProjectileToNpc.setAction(() =>
                        {
                            sendProjectileToNpc.stop();
                            p.getPackets().sendProjectile(npc.getLocation(), p.getLocation(), 32, 1623, 50, 40, 34, 80, p);
                        });
                        Server.registerEvent(sendProjectileToNpc);
                    }
                    else
                    {
                        damage = Misc.random(64);
                        if (prayer == PrayerData.MELEE)
                        {
                            damage = 0;
                        }
                    }
                    break;

                case 2745: // TzTok Jad (lvl 702)
                    doJadAttacks(p, npc);
                    break;
            }
            if (npc.getId() == 2745)
            {
                return;
            }
            if (animation != 65535)
            {
                npc.setLastAnimation(new Animation(animation));
            }
            p.setLastAttacked(Environment.TickCount);
            npc.setLastAttack(Environment.TickCount);
            p.setAttacker(npc);
            npc.resetCombatTurns();
            if (damage > p.getHp())
            {
                damage = p.getHp();
            }
            int npcId = npc.getId();

            Event losePrayerFightingEvent = new Event(hitDelay);
            losePrayerFightingEvent.setAction(() =>
            {
                losePrayerFightingEvent.stop();
                if (!Location.inFightCave(p.getLocation()) || p.getTeleportTo() != null)
                {
                    return;
                }
                if (npcId == 2734 || npcId == 2735)
                {
                    int prayerLevel = p.getSkills().getCurLevel(Skills.SKILL.PRAYER);
                    int newPrayerLevel = prayerLevel -= (damage + 1);
                    if (newPrayerLevel <= 0)
                    {
                        newPrayerLevel = 0;
                    }
                    p.getSkills().setCurLevel(Skills.SKILL.PRAYER, newPrayerLevel);
                    p.getPackets().sendSkillLevel(Skills.SKILL.PRAYER);
                }
                else if (npcId == 2743 || npcId == 2744)
                {
                    if (Misc.random(1) == 0)
                    {
                        p.setLastGraphics(new Graphics(1624, 0));
                    }
                }
                if ((p.getCombatTurns() > 2 || p.getCombatTurns() < 0))
                {
                    p.setLastAnimation(new Animation(p.getDefenceAnimation()));
                }
                p.hit(damage);
            });
            Server.registerEvent(losePrayerFightingEvent);
        }
예제 #22
0
        public static double getNPCMeleeDefence(Npc npc)
        {
            double power = 0.600;
            double amount = 0.900;

            NpcData npcDef = NpcData.forId(npc.getId());
            int combatLevel = 3;
            if (npcDef == null)
            { //Level 3 if npcDef doesn't exist
                power *= (amount * combatLevel) * power;
                Misc.WriteError("Missing npcDef for npcId: " + npc.getId());
            }
            else
            {
                combatLevel = NpcData.forId(npc.getId()).getCombat();
                power *= (amount * combatLevel) * power;
                if (npcDef.isBoss())
                {
                    power *= 1.4;
                }
            }
            return power;
        }
예제 #23
0
 private static bool canThieveNpc(Player p, Npc npc, int index)
 {
     if (p == null || npc == null || npc.isDead() || npc.isHidden() || npc.isDestroyed() || p.isDead() || p.isDestroyed())
     {
         return false;
     }
     if (!p.getLocation().withinDistance(npc.getLocation(), 2))
     {
         return false;
     }
     if (p.getSkills().getGreaterLevel(Skills.SKILL.THIEVING) < NPC_LVL[index])
     {
         p.getPackets().sendMessage("You need a Thieving level of " + NPC_LVL[index] + " to rob this Npc.");
         p.setFaceLocation(npc.getLocation());
         return false;
     }
     if (p.getInventory().findFreeSlot() == -1)
     {
         p.getPackets().sendMessage("You need a free inventory space for any potential loot.");
         return false;
     }
     if (p.getTemporaryAttribute("stunned") != null)
     {
         return false;
     }
     if (p.getTemporaryAttribute("lastPickPocket") != null)
     {
         if (Environment.TickCount - (int)p.getTemporaryAttribute("lastPickPocket") < 1500)
         {
             return false;
         }
     }
     return true;
 }
예제 #24
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);
 }
예제 #25
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);
 }
예제 #26
0
파일: Fishing.cs 프로젝트: ramatronics/rsps
 private static void startFishing(Player p, int i, Npc npc, bool newFish, bool secondOption)
 {
     if (!newFish && p.getTemporaryAttribute("fishingSpot") == null)
     {
         return;
     }
     if (newFish)
     {
         int j = secondOption ? 1 : 0;
         int[] fish = secondOption ? SECOND_SPOT_FISH[i] : FIRST_SPOT_FISH[i];
         int[] level = secondOption ? SECOND_SPOT_LEVEL[i] : FIRST_SPOT_LEVEL[i];
         double[] xp = secondOption ? SECOND_SPOT_XP[i] : FIRST_SPOT_XP[i];
         p.setTemporaryAttribute("fishingSpot", new Spot(fish, level, i, SPOT_IDS[i], xp, npc.getLocation(), PRIMARY_ITEM[i][j], SECONDARY_ITEM[i][j], PRIMARY_NAME[i][j], SECONDARY_NAME[i][j], secondOption));
     }
     Spot fishingSpot = (Spot)p.getTemporaryAttribute("fishingSpot");
     int k = fishingSpot.isSecondOption() ? 1 : 0;
     int index = getFishToAdd(p, fishingSpot);
     if (!canFish(p, fishingSpot, null, index))
     {
         resetFishing(p);
         p.setLastAnimation(new Animation(65535));
         return;
     }
     if (newFish)
     {
         p.getPackets().sendMessage("You attempt to catch a fish...");
         p.setLastAnimation(new Animation(FISHING_ANIMATION[i][k]));
     }
     string name = fishingSpot.isSecondOption() ? SECOND_CATCH_NAME[fishingSpot.getSpotindex()][index] : FIRST_CATCH_NAME[fishingSpot.getSpotindex()][index];
     string s = fishingSpot.getSpotindex() == 1 && !fishingSpot.isSecondOption() ? "some" : "a";
     Event doFishingEvent = new Event(getFishingDelay(p, fishingSpot));
     doFishingEvent.setAction(() =>
     {
         doFishingEvent.stop();
         if (p.getTemporaryAttribute("fishingSpot") == null)
         {
             resetFishing(p);
             p.setLastAnimation(new Animation(65535));
             return;
         }
         Spot fishingSpot2 = (Spot)p.getTemporaryAttribute("fishingSpot");
         if (!canFish(p, fishingSpot, fishingSpot2, index))
         {
             resetFishing(p);
             p.setLastAnimation(new Animation(65535));
             return;
         }
         p.getPackets().closeInterfaces();
         p.getInventory().deleteItem(fishingSpot2.getSecondaryItem());
         p.setLastAnimation(new Animation(FISHING_ANIMATION2[fishingSpot2.getSpotindex()][k]));
         p.getPackets().sendMessage("You catch " + s + " " + name + ".");
         if (p.getInventory().addItem(fishingSpot2.getFish()[index]))
         {
             p.getSkills().addXp(Skills.SKILL.FISHING, fishingSpot2.getFishingXp()[index]);
         }
         startFishing(p, i, null, false, secondOption);
     });
     Server.registerEvent(doFishingEvent);
 }
예제 #27
0
파일: Barrows.cs 프로젝트: ramatronics/rsps
 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;
 }
예제 #28
0
파일: Barrows.cs 프로젝트: ramatronics/rsps
        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);
        }
예제 #29
0
 public static bool talkToWarriorGuildNPC(Player p, Npc n, int slot)
 {
     if (n.getId() != 4289)
     {
         return false;
     }
     p.setEntityFocus(n.getClientIndex());
     int npcX = n.getLocation().getX();
     int npcY = n.getLocation().getY();
     AreaEvent talkToWarriorGuildNPCAreaEvent = new AreaEvent(p, npcX - 1, npcY - 1, npcX + 1, npcY + 1);
     talkToWarriorGuildNPCAreaEvent.setAction(() =>
     {
         p.setFaceLocation(n.getLocation());
         p.setEntityFocus(65535);
         switch (n.getId())
         {
             case 4289: // Kamfreena
                 Dialogue.doDialogue(p, 77);
                 break;
         }
     });
     Server.registerCoordinateEvent(talkToWarriorGuildNPCAreaEvent);
     return true;
 }
예제 #30
0
        private static void thieveNpc(Player p, Npc npc, int index)
        {
            AreaEvent thieveNpcAreaEvent = new AreaEvent(p, npc.getLocation().getX() - 1, npc.getLocation().getY() - 1, npc.getLocation().getX() + 1, npc.getLocation().getY() + 1);
            thieveNpcAreaEvent.setAction(() =>
            {
                if (!canThieveNpc(p, npc, index))
                {
                    return;
                }
                p.setFaceLocation(npc.getLocation());
                p.setLastAnimation(new Animation(881));
                p.getPackets().sendMessage("You attempt to pick the " + NPC_NAMES[index] + " pocket...");
                p.setTemporaryAttribute("lastPickPocket", Environment.TickCount);

                Event thieveNpcEvent = new Event(1000);
                thieveNpcEvent.setAction(() =>
                {
                    thieveNpcEvent.stop();
                    if (!p.getLocation().withinDistance(npc.getLocation(), 2))
                    {
                        return;
                    }
                    if (successfulThieve(p, index, false))
                    {
                        int rewardIndex = Misc.random(NPC_REWARD[index].Length - 1);
                        int reward = NPC_REWARD[index][rewardIndex];
                        int rewardAmount = NPC_REWARD_AMOUNT[index][rewardIndex];
                        if (index == 7)
                        { // Master farmer.
                            if (Misc.random(15) == 0)
                            {
                                reward = HERB_SEEDS[Misc.random(HERB_SEEDS.Length - 1)];
                            }
                        }
                        p.getSkills().addXp(Skills.SKILL.THIEVING, NPC_XP[index]);
                        p.getInventory().addItem(reward, rewardAmount);
                        p.getPackets().sendMessage("You pick the " + NPC_NAMES[index] + " pocket.");
                    }
                    else
                    {
                        p.getWalkingQueue().resetWalkingQueue();
                        p.getPackets().sendMessage("You fail to pick the " + NPC_NAMES[index] + " pocket.");
                        p.getPackets().sendMessage("You've been stunned!");
                        npc.setForceText("What do you think you're doing?");
                        p.setTemporaryAttribute("unmovable", true);
                        p.setTemporaryAttribute("stunned", true);
                        p.setLastGraphics(new Graphics(80, 0, 100));
                        p.setLastAnimation(new Animation(p.getDefenceAnimation()));
                        p.hit(1);
                        npc.setFaceLocation(p.getLocation());
                        Event removeStunEvent = new Event(5000);
                        removeStunEvent.setAction(() =>
                        {
                            removeStunEvent.stop();
                            p.removeTemporaryAttribute("unmovable");
                            p.removeTemporaryAttribute("stunned");
                            p.setLastGraphics(new Graphics(65535));
                        });
                        Server.registerEvent(removeStunEvent);
                    }
                });
                Server.registerEvent(thieveNpcEvent);
            });
            Server.registerCoordinateEvent(thieveNpcAreaEvent);
        }