コード例 #1
0
        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);
        }
コード例 #2
0
        private static long getFishingDelay(Player p, Spot fishingSpot)
        {
            int[] time       = fishingSpot.isSecondOption() ? SECOND_SPOT_TIME : FIRST_SPOT_TIME;
            int[] minTime    = fishingSpot.isSecondOption() ? SECOND_SPOT_MINTIME : FIRST_SPOT_MINTIME;
            int   baseTime   = time[fishingSpot.getSpotindex()];
            int   min        = minTime[fishingSpot.getSpotindex()];
            int   finalDelay = baseTime -= misc.random(min);

            return(finalDelay);
        }
コード例 #3
0
 private static long getFishingDelay(Player p, Spot fishingSpot)
 {
     int[] time = fishingSpot.isSecondOption() ? SECOND_SPOT_TIME : FIRST_SPOT_TIME;
     int[] minTime = fishingSpot.isSecondOption() ? SECOND_SPOT_MINTIME : FIRST_SPOT_MINTIME;
     int baseTime = time[fishingSpot.getSpotindex()];
     int min = minTime[fishingSpot.getSpotindex()];
     int finalDelay = baseTime -= misc.random(min);
     return finalDelay;
 }