コード例 #1
0
        void OnItemDropped(Item item, BaseEntity entity)
        {
            if (item.info.shortname != "note")
            {
                return;
            }
            if (!item.HasFlag(global::Item.Flag.OnFire))
            {
                return;
            }
            Bounty bounty = BountyData.GetBounty(item);

            if (bounty == null)
            {
                return;
            }

            //attach portableBounty
            WorldItem      wItem   = entity as WorldItem;
            PortableBounty pBounty = wItem.gameObject.AddComponent <PortableBounty>();

            pBounty.bounty = bounty;

            //remove Bounty from Data
            BountyData.removeBounty(item.uid);
        }
コード例 #2
0
ファイル: data_management.cs プロジェクト: kiloOhm/Bounty
 partial void initData()
 {
     BountyData.init();
     HuntData.init();
     HuntData.restartHunts();
     CooldownData.init();
 }
コード例 #3
0
        object CanMoveItem(Item item, PlayerInventory playerLoot, uint targetContainer, int targetSlot, int amount)
        {
            if (item == null)
            {
                return(null);
            }
            if (item.info.shortname != "note")
            {
                return(null);
            }
            if (!item.HasFlag(global::Item.Flag.OnFire))
            {
                return(null);
            }
            Bounty bounty = BountyData.GetBounty(item);

            if (bounty == null)
            {
                return(null);
            }

            item.text = bounty.text;
            item.MarkDirty();

            return(null);
        }
コード例 #4
0
        public static void WriteBountyData(Player player, int wantedLevel)
        {
            bool          foundPlayer = false;
            List <string> playerIds   = player.Identifiers.ToList();

            foreach (var bountyData in BountyDatas)
            {
                if (playerIds[1] == bountyData.SteamID)
                {
                    bountyData.Name            = player.Name;
                    bountyData.LastWantedLevel = wantedLevel;
                    foundPlayer = true;
                    break;
                }
            }
            if (!foundPlayer)
            {
                BountyData bountyData = new BountyData
                {
                    Name    = player.Name,
                    SteamID = playerIds[1]
                };
                BountyDatas.Add(bountyData);
            }
            using (StreamWriter writer = new StreamWriter(bountyDataLocation))
            {
                writer.WriteLine(JsonConvert.SerializeObject(BountyDatas));
            }
        }
コード例 #5
0
        object OnItemPickup(Item item, BasePlayer player)
        {
            WorldItem wItem = item.GetWorldEntity() as WorldItem;

            if (wItem.item == null)
            {
                return(null);
            }
            if (item.info.shortname == "note")
            {
                PortableBounty pBounty = wItem.gameObject.GetComponent <PortableBounty>();
                if (pBounty != null)
                {
                    Bounty bounty = pBounty.bounty;
                    if (bounty == null)
                    {
                        Puts($"pBounty.bounty on Note[{item.uid}] is null. This shouldn't happen!");
                        return(null);
                    }
                    BountyData.AddBounty(bounty);
                }
            }

            return(null);
        }
コード例 #6
0
 public GenericBountyCoroutine(int questId)
     : base(questId)
 {
     Bounty = BountyDataFactory.GetBountyData(questId);
     ObjectiveSearchRadius      = 1000;
     AutoSetNearbyNodesExplored = true;
     AutoSetNearbyNodesRadius   = 30;
 }
コード例 #7
0
 public static void ResetBountyData(BountyData toRemove)
 {
     BountyDatas.Remove(toRemove);
     using (StreamWriter writer = new StreamWriter(bountyDataLocation))
     {
         writer.WriteLine(JsonConvert.SerializeObject(BountyDatas));
     }
 }
コード例 #8
0
ファイル: BountyList.cs プロジェクト: oxters168/HighwayMan
    public void AddBountyOption(BountyData bounty, AbstractDriver bountyHunter)
    {
        var bountyOption = bountyOptionsPool.Get <BountyOption>();

        bountyOption.bounty            = bounty;
        bountyOption.compassRelativeTo = bountyHunter;
        bountyOption.vehicles          = viewedVehicle;
        //Debug.Log("Vehicle switcher being set is null: " + (viewedVehicle == null));
        bountyOption.viewButton.onClick.AddListener(() => { ViewBountyPressed(bountyOption); });
        shownBounties.Add(bountyOption);
    }
コード例 #9
0
ファイル: CmdBounty.cs プロジェクト: takaaptech/MCGalaxy
        public override void Use(Player p, string message, CommandData data)
        {
            string[] args = message.SplitSpaces();
            if (args.Length < 2)
            {
                Help(p); return;
            }

            Player target = PlayerInfo.FindMatches(p, args[0]);

            if (target == null)
            {
                return;
            }

            int amount = 0;

            if (!CommandParser.GetInt(p, args[1], "Bounty amount", ref amount, 1, 256))
            {
                return;
            }

            if (p.money < amount)
            {
                p.Message("You do not have enough " + Server.Config.Currency + " to place such a large bountry."); return;
            }

            BountyData old = ZSGame.Instance.FindBounty(target.name);

            if (old != null && old.Amount >= amount)
            {
                p.Message("There is already a larger active bounty for " + p.FormatNick(target)); return;
            }

            string msg;

            if (old == null)
            {
                msg = string.Format("Looks like someone really wants the brains of {0}&S! A bounty of &a{1} &S{2} was placed on them.",
                                    target.ColoredName, amount, Server.Config.Currency);
            }
            else
            {
                msg = string.Format("{0} &Sis popular! The bounty on them was increased from &a{3} &Sto &a{1} &S{2}.",
                                    target.ColoredName, amount, Server.Config.Currency, old.Amount);
                ZSGame.Instance.Bounties.Remove(old);
            }
            ZSGame.Instance.Map.Message(msg);

            ZSGame.Instance.Bounties.Add(new BountyData(p.name, target.name, amount));
            p.SetMoney(p.money - amount);
        }
コード例 #10
0
ファイル: data_management.cs プロジェクト: kiloOhm/Bounty
 public static void load()
 {
     try
     {
         instance = bountyDataFile.ReadObject <BountyData>();
     }
     catch (Exception E)
     {
         StringBuilder sb = new StringBuilder($"loading {typeof(BountyData).Name} failed. Make sure that all classes you're saving have a default constructor!\n");
         sb.Append(E.Message);
         PluginInstance.Puts(sb.ToString());
     }
 }
コード例 #11
0
ファイル: BountyList.cs プロジェクト: oxters168/HighwayMan
    public int GetBountyOptionIndex(BountyData bounty)
    {
        int optionIndex = -1;

        for (int i = 0; i < shownBounties.Count; i++)
        {
            if (shownBounties[i].bounty == bounty)
            {
                optionIndex = i;
                break;
            }
        }
        return(optionIndex);
    }
コード例 #12
0
        public override void Use(Player p, string message)
        {
            string[] args = message.SplitSpaces();
            if (args.Length < 2)
            {
                Help(p); return;
            }

            Player who = PlayerInfo.FindMatches(p, args[0]);

            if (who == null)
            {
                return;
            }

            byte amount = 0;

            if (!CommandParser.GetByte(p, args[1], "Bounty amount", ref amount))
            {
                return;
            }

            if (p.money < amount)
            {
                Player.Message(p, "You do not have enough " + ServerConfig.Currency + " to place such a large bountry."); return;
            }

            BountyData old = Server.zombie.FindBounty(who.name);

            if (old != null && old.Amount >= amount)
            {
                Player.Message(p, "There is already a larger active bounty for " + who.name + "."); return;
            }

            if (old == null)
            {
                Chat.MessageGlobal("Looks like someone really wants the brains of {0}%S! A bounty of &a{1} %S{2} was placed on them.",
                                   who.ColoredName, amount, ServerConfig.Currency);
            }
            else
            {
                Chat.MessageGlobal("{0} %Sis popular! The bounty on them was increased from &a{3} %Sto &a{1} %S{2}.",
                                   who.ColoredName, amount, ServerConfig.Currency, old.Amount);
                Server.zombie.Bounties.Remove(old);
            }

            Server.zombie.Bounties.Add(new BountyData(p.name, who.name, amount));
            p.SetMoney(p.money - amount);
        }
コード例 #13
0
ファイル: TakeWaypointTag.cs プロジェクト: xinhuaer/Trinity
        public override async Task <bool> MainTask()
        {
            var bountiesNoCoroutines = ZetaDia.Storage.Quests.Bounties.Where(
                b =>
            {
                BountyData bd = BountyDataFactory.GetBountyData((int)b.Quest);
                if (bd != null && bd.Coroutines.Count == 0)
                {
                    return(true);
                }

                return(false);
            }).ToList();

            var bounties = ZetaDia.Storage.Quests.Bounties.Where(
                b =>
                BountyDataFactory.GetBountyData((int)b.Quest) == null &&
                b.State != QuestState.Completed)
                           .ToList();

            if (bountiesNoCoroutines.Count != 0)
            {
                Core.Logger.Debug("No coroutines:");
                foreach (var bounty in bountiesNoCoroutines)
                {
                    DumpBountyInfo(bounty);
                }
            }

            if (bounties.Count != 0)
            {
                Core.Logger.Debug("Not supported:");
                foreach (var bounty in bounties)
                {
                    DumpBountyInfo(bounty);
                }
            }

            if (bounties.Count != 0 || bountiesNoCoroutines.Count != 0)
            {
                BotMain.Stop(reason: "Unsupported bounty found!");
            }

            Done();
            await Coroutine.Sleep(1000);

            return(true);
        }
コード例 #14
0
ファイル: BountyList.cs プロジェクト: oxters168/HighwayMan
    public BountyOption GetBountyOption(BountyData bounty)
    {
        BountyOption optionInList = null;
        var          optionIndex  = GetBountyOptionIndex(bounty);

        if (optionIndex >= 0 && optionIndex < shownBounties.Count)
        {
            optionInList = shownBounties[optionIndex];
        }
        else
        {
            Debug.LogError("BountyList: Bounty data does not exist in list");
        }

        return(optionInList);
    }
コード例 #15
0
ファイル: hunt.cs プロジェクト: kiloOhm/Bounty
            public void end(BasePlayer winner = null)
            {
#if DEBUG
                PluginInstance.PrintToChat($"ending hunt {hunterName} -> {bounty.targetName}, winner: {winner?.displayName ?? "null"}");
#endif
                if (huntTimer != null)
                {
                    huntTimer.Destroy();
                }
                if (ticker != null)
                {
                    ticker.Destroy();
                }

                PluginInstance.rename(hunter, hunterName);

                if (winner == hunter)
                {
                    Interface.Oxide.CallHook("OnBountyCompleted", winner, target);
                    //msg
                    PluginInstance.huntSuccessfullMsg(this);

                    //payout
                    hunter.GiveItem(bounty.reward);
                }
                else if (winner == target)
                {
                    //msg
                    PluginInstance.huntFailedMsg(this);

                    //payout
                    target.GiveItem(bounty.reward);
                }
                else
                {
                    //msg
                    PluginInstance.huntExpiredMsg(this);
                    bounty.noteUid = bounty.giveNote(hunter);
                    BountyData.AddBounty(bounty);
                }
                PluginInstance.closeIndicators(target);
                PluginInstance.closeIndicators(hunter);
                bounty.hunt = null;
                HuntData.removeHunt(this);
                CooldownData.addCooldown(target);
            }
コード例 #16
0
 void OnActiveItemChanged(BasePlayer player, Item oldItem, Item newItem)
 {
     if (player == null)
     {
         return;
     }
     if (newItem != null)
     {
         if (newItem?.info?.shortname == "note" && newItem.HasFlag(global::Item.Flag.OnFire))
         {
             Bounty bounty = BountyData.GetBounty(newItem);
             if (bounty != null)
             {
                 sendBounty(player, bounty);
                 return;
             }
         }
     }
     closeBounty(player);
 }
コード例 #17
0
            public Bounty(BasePlayer placer, BasePlayer target, int reward, string reason)
            {
                timestamp    = DateTime.Now;
                placerID     = placer.userID;
                placerName   = placer.displayName;
                targetID     = target.userID;
                targetName   = target.displayName;
                rewardAmount = reward;
                this.reason  = reason;

                noteUid = giveNote(placer);

                if (config.showSteamImage)
                {
                    PluginInstance.GetSteamUserData(targetID, (ps) =>
                                                    PluginInstance.guiCreator.registerImage(PluginInstance, targetID.ToString(), ps.avatarfull)
                                                    );
                }

                BountyData.AddBounty(this);
                PluginInstance.LogToFile(bountyLogFileName, $"{DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss")} {placerName}[{placerID}] placed a bounty of {rewardAmount} {config.currency} on {targetName}[{targetID}]'s head. Reason: {reason}", PluginInstance);
            }
コード例 #18
0
        object OnServerCommand(ConsoleSystem.Arg arg)
        {
            if (arg == null)
            {
                return(null);
            }
            //note.update UID Content
            BasePlayer player = arg.Player();

            if (player == null)
            {
                return(null);
            }
            if (arg.cmd.FullName == "note.update")
            {
#if DEBUG
                player.ChatMessage($"note.update {arg.FullString}");
#endif
                Item note = findItemByUID(player.inventory, uint.Parse(arg.Args[0]));
                if (note == null)
                {
                    return(null);
                }
                Bounty bounty = BountyData.GetBounty(note);
                if (bounty == null)
                {
                    return(null);
                }
                timer.Once(0.2f, () =>
                {
                    note.text = bounty.text;
                    note.MarkDirty();
                });
            }
            return(null);
        }
コード例 #19
0
 private int GetBountyIndex(BountyData bounty)
 {
     return(System.Array.IndexOf(currentBounties, bounty));
 }
コード例 #20
0
 public void Reset()
 {
     State       = States.NotStarted;
     _bountyData = null;
 }
コード例 #21
0
ファイル: gui.cs プロジェクト: kiloOhm/Bounty
        public void huntButton(BasePlayer player, Bounty bounty, huntErrorType error = huntErrorType.none)
        {
            GuiContainer c         = new GuiContainer(this, "huntButton", "bountyPreview");
            Rectangle    ButtonPos = new Rectangle(710, 856, 500, 100, resX, resY, true);

            List <GuiText> textOptions = new List <GuiText>
            {
                new GuiText("Start Hunting", guiCreator.getFontsizeByFramesize(13, ButtonPos), lightGreen),
                new GuiText("You are already hunting", guiCreator.getFontsizeByFramesize(23, ButtonPos), lightRed),
                new GuiText("Target is already being hunted", guiCreator.getFontsizeByFramesize(30, ButtonPos), lightRed),
                new GuiText("Target can't be hunted yet", guiCreator.getFontsizeByFramesize(26, ButtonPos), lightRed),
                new GuiText("Hunt Active", guiCreator.getFontsizeByFramesize(11, ButtonPos), lightRed),
                new GuiText("You can't hunt yourself!", guiCreator.getFontsizeByFramesize(24, ButtonPos), lightRed),
                new GuiText("Target is offline", guiCreator.getFontsizeByFramesize(17, ButtonPos), lightRed),
                new GuiText("Too close to the target!", guiCreator.getFontsizeByFramesize(24, ButtonPos), lightRed),
            };

            Action <BasePlayer, string[]> cb = (p, a) =>
            {
                TimeSpan targetCooldown   = TimeSpan.Zero;
                TimeSpan creationCooldown = new TimeSpan(0, 0, config.creationCooldown - (int)bounty.timeSinceCreation.TotalSeconds);
                if (error == huntErrorType.huntActive)
                {
                    return;
                }
                else if (bounty.target == null)
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    huntButton(player, bounty, huntErrorType.offline);
                }
                else if (bounty.target.IsSleeping())
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    huntButton(player, bounty, huntErrorType.offline);
                }
                else if (bounty.hunt != null || HuntData.getHuntByHunter(p) != null)
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    huntButton(player, bounty, huntErrorType.hunterAlreadyHunting);
                }
                else if (HuntData.getHuntByTarget(bounty.target) != null)
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    huntButton(player, bounty, huntErrorType.targetAlreadyHunted);
                }
                else if ((bounty.timeSinceCreation.TotalSeconds < config.creationCooldown || CooldownData.isOnCooldown(bounty.target, out targetCooldown)) && !hasPermission(player, permissions.admin))
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    huntButton(player, bounty, huntErrorType.targetCooldown);
                    TimeSpan select = creationCooldown;
                    if (targetCooldown > creationCooldown)
                    {
                        select = targetCooldown;
                    }
                    player.ChatMessage($"Cooldown: {select.ToString(@"hh\:mm\:ss")}");
                }
                else if (bounty.target == player && !hasPermission(player, permissions.admin))
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    huntButton(player, bounty, huntErrorType.selfHunt);
                }
                else if (Vector3.Distance(player.transform.position, bounty.target.transform.position) < config.safeDistance && !hasPermission(player, permissions.admin))
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    huntButton(player, bounty, huntErrorType.tooClose);
                }
                else
                {
                    Effect.server.Run(successSound, player.transform.position);
                    bounty.startHunt(p);
                    BountyData.removeBounty(bounty.noteUid);
                    player.GetActiveItem()?.Remove();
                    closeBounty(player);
                }
            };

            c.addPlainButton("button", ButtonPos, GuiContainer.Layer.hud, (error == huntErrorType.none)?darkGreen:darkRed, FadeIn, FadeOut, textOptions[(int)error], cb, blur: GuiContainer.Blur.medium);
            c.display(player);

            if (error != huntErrorType.none && error != huntErrorType.huntActive)
            {
                PluginInstance.timer.Once(2f, () =>
                {
                    if (GuiTracker.getGuiTracker(player).getContainer(this, "bountyPreview") != null)
                    {
                        huntButton(player, bounty);
                    }
                });
            }
        }
コード例 #22
0
 private bool NotStarted()
 {
     State = States.InProgress;
     BountyData.Reset();
     return(false);
 }
コード例 #23
0
 public void ReplaceBounty(BountyData bounty)
 {
     ReplaceBounty(GetBountyIndex(bounty));
 }
コード例 #24
0
ファイル: BountyList.cs プロジェクト: oxters168/HighwayMan
 public bool HasBounty(BountyData bountyData)
 {
     return(GetBountyOptionIndex(bountyData) >= 0);
 }
コード例 #25
0
ファイル: BountyList.cs プロジェクト: oxters168/HighwayMan
 public void RemoveShownBounty(BountyData bounty)
 {
     RemoveShownBounty(GetBountyOptionIndex(bounty));
 }