示例#1
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);
        }
示例#2
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);
        }
示例#3
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);
        }
示例#4
0
文件: gui.cs 项目: kiloOhm/Bounty
        public void sendBounty(BasePlayer player, Bounty bounty)
        {
#if DEBUG
            player.ChatMessage($"sendBounty: {bounty.placerName} -> {bounty.targetName}");
#endif
            closeBounty(player);
            GuiContainer c = new GuiContainer(this, "bountyPreview");

            //template
            Rectangle templatePos = new Rectangle(623, 26, 673, 854, resX, resY, true);
            c.addImage("template", templatePos, "bounty_template", GuiContainer.Layer.hud, FadeIn: FadeIn, FadeOut: FadeOut);

            //targetName
            Rectangle targetNamePos  = new Rectangle(680, 250, 560, 65, resX, resY, true);
            int       fontsize       = guiCreator.getFontsizeByFramesize(bounty.targetName.Length, targetNamePos);
            GuiText   targetNameText = new GuiText(bounty.targetName, fontsize);
            c.addText("targetName", targetNamePos, GuiContainer.Layer.hud, targetNameText, FadeIn, FadeOut);

            //image
            if (config.showSteamImage)
            {
                Rectangle imagePos = new Rectangle(828, 315, 264, 264, resX, resY, true);
                c.addImage("image", imagePos, bounty.targetID.ToString(), GuiContainer.Layer.hud, FadeIn: FadeIn, FadeOut: FadeOut);
            }

            //reward
            Rectangle rewardPos  = new Rectangle(680, 579, 560, 53, resX, resY, true);
            string    reward     = $"{bounty.rewardAmount} {bounty.reward.info.displayName.english}";
            GuiText   rewardText = new GuiText(reward, guiCreator.getFontsizeByFramesize(reward.Length, rewardPos));
            c.addText("reward", rewardPos, GuiContainer.Layer.hud, rewardText, FadeIn, FadeOut);

            //reason
            Rectangle reasonPos  = new Rectangle(680, 681, 560, 53, resX, resY, true);
            GuiText   reasonText = new GuiText(bounty.reason, 14);
            c.addText("reason", reasonPos, GuiContainer.Layer.hud, reasonText, FadeIn, FadeOut);

            //placerName
            Rectangle placerNamePos  = new Rectangle(680, 771, 560, 36, resX, resY, true);
            GuiText   placerNameText = new GuiText(bounty.placerName, guiCreator.getFontsizeByFramesize(bounty.placerName.Length, placerNamePos));
            c.addText("placerName", placerNamePos, GuiContainer.Layer.hud, placerNameText, FadeIn, FadeOut);

            //exitButton
            Rectangle closeButtonPos = new Rectangle(1296, 52, 60, 60, resX, resY, true);
            c.addButton("close", closeButtonPos, GuiContainer.Layer.hud, darkRed, FadeIn, FadeOut, new GuiText("X", 24, lightRed), blur: GuiContainer.Blur.medium);

            c.display(player);

            //button
            if (bounty.hunt != null)
            {
                huntButton(player, bounty, huntErrorType.huntActive);
            }
            else
            {
                huntButton(player, bounty);
            }
        }
示例#5
0
            public static void AddBounty(Bounty bounty)
            {
                if (!initialized)
                {
                    init();
                }
                instance.bounties.Add(bounty.noteUid, bounty);
                save();
#if DEBUG
                PluginInstance.PrintToChat($"added Bounty {bounty.placerName} -> {bounty.targetName} {bounty.rewardAmount} to data");
#endif
            }
示例#6
0
            public static Bounty GetBounty(Item item)
            {
                if (!initialized)
                {
                    init();
                }
                if (!instance.bounties.ContainsKey(item.uid))
                {
                    return(null);
                }
                Bounty bounty = instance.bounties[item.uid];

                return(bounty);
            }
示例#7
0
        private void bountyCommand(BasePlayer player, string command, string[] args)
        {
            if (!hasPermission(player, permissions.use))
            {
                PrintToChat(player, lang.GetMessage("noPermission", this, player.UserIDString));
                return;
            }

            if (args.Length == 0)
            {
                sendCreator(player);
                return;
            }
            switch (args[0])
            {
            case "add":
            case "place":
                if (!hasPermission(player, permissions.admin))
                {
                    PrintToChat(player, lang.GetMessage("noPermission", this, player.UserIDString));
                    return;
                }

                //bounty add name reward reason
                if (args.Length != 4)
                {
                    player.ChatMessage(lang.GetMessage("usageAdd", this, player.UserIDString));
                    return;
                }
                BasePlayer target = findPlayer(args[1], player);
                int        reward = 0;
                int.TryParse(args[2], out reward);
                if (reward < config.minReward)
                {
                    player.ChatMessage(string.Format(lang.GetMessage("minReward", this, player.UserIDString), config.minReward));
                    return;
                }
                ItemDefinition itemDef = ItemManager.FindItemDefinition(config.currency);
                if (player.inventory.GetAmount(itemDef.itemid) < reward)
                {
                    player.ChatMessage(string.Format(lang.GetMessage("notEnough", this, player.UserIDString), itemDef.displayName.english));
                }
                player.inventory.Take(null, itemDef.itemid, reward);
                Bounty bounty = new Bounty(player, target, reward, args[3]);
                break;
            }
        }
示例#8
0
文件: hunt.cs 项目: kiloOhm/Bounty
 public Hunt(Bounty bounty, BasePlayer hunter)
 {
     if (bounty.hunt != null)
     {
         PluginInstance.Puts($"Hunt Constructor: Bounty {bounty.placerName} -> {bounty.targetName} already has an ongoing hunt!");
     }
     timestamp   = DateTime.Now;
     this.bounty = bounty;
     hunterID    = hunter.userID;
     hunterName  = hunter.displayName;
     initTicker();
     PluginInstance.sendHunterIndicator(hunter, this);
     PluginInstance.sendTargetIndicator(target, this);
     HuntData.addHunt(this);
     if (PluginInstance.hasPermission(hunter, permissions.mask))
     {
         hunter.ChatMessage("<color=#00ff33>Hunt started!</color> Remember that you can use /mask and /unmask to randomize your name for some extra stealth!");
     }
     PluginInstance.LogToFile(huntLogFileName, $"{DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss")} Hunt started: {hunter.displayName}[{hunter.UserIDString}] hunting {target.displayName}[{target.UserIDString}], placed by {bounty.placerName}[{bounty.placerID}]", PluginInstance);
 }
示例#9
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);
 }
示例#10
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);
        }
示例#11
0
        void OnPlayerDeath(PlayerSession player, EntityEffectSourceData source)
        {
            if (!isEcoLoaded())
            {
                PrintError("Economybanks not loaded. BountyHunters will not function"); return;
            }
            var tmpName = GetNameOfObject(source.EntitySource);

            if (tmpName.Length < 3)
            {
                return;
            }
            var murdererName = tmpName.Remove(tmpName.Length - 3);

            var murderer = getSession(murdererName);
            var isPlayer = (murderer != null) ? true : false;

            if (source.EntitySource.name == null || !isPlayer || murderer == null)
            {
                return;
            }


            var deceased   = player;
            var deceasedId = (ulong)player.SteamId;

            if (isPlayer)
            {
                PlayerSession session = murderer;
                var           stat    = session.WorldPlayerEntity.GetComponent <EntityStats>();

                if (SameStake(murderer.SteamId, deceased.SteamId))
                {
                    hurt.SendChatMessage(murderer, "Can't claim bounties from your friends.");
                    //If they are of the same stake, make them wanted.
                    //stat.GetFluidEffect(EEntityFluidEffectType.Infamy).AddValue(100f, source);
                    return;
                }

                for (int i = Bounties.Count - 1; i >= 0; i--)
                {
                    Bounty Reward = Bounties[i];
                    if (Reward.target == deceasedId && !SameStake(murderer.SteamId, deceased.SteamId))
                    {
                        AddCash(murderer, Reward.reward);
                        BountiesClaimed.Add(new Hunters((ulong)murderer.SteamId, murdererName, Reward.target, Reward.targetName, Reward.submitter, Reward.submitterName, Reward.reward));
                        hurt.BroadcastChat("Bounty", Color(GetMsg("broadcast_BountyClaimed")
                                                           .Replace("{moneySymbol}", MoneySym)
                                                           .Replace("{amount}", Reward.reward.ToString())
                                                           .Replace("{target}", Reward.targetName), "bad"));
                        hurt.SendChatMessage(murderer, GetMsg("msg_BountyRewarded", player)
                                             .Replace("{target}", deceased.Name)
                                             .Replace("{moneySymbol}", MoneySym)
                                             .Replace("{amount}", Reward.reward.ToString()));
                        //stat.GetFluidEffect(EEntityFluidEffectType.Infamy).AddValue(-100f, EntityEffectSourceData.None);
                        Bounties.RemoveAt(i);
                    }
                }
                SaveBounties();
            }
        }
示例#12
0
文件: gui.cs 项目: kiloOhm/Bounty
            public void init(BasePlayer placer)
            {
                Bounty b = new Bounty(placer, target, reward, reason);

                placer.inventory.Take(null, b.reward.info.itemid, reward);
            }
示例#13
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);
                    }
                });
            }
        }