Ejemplo n.º 1
0
        //returns:
        //true if head taken, false if not
        //goldRewarded is the gold placed in the placer's back
        //message is:
        //		-1: default - meaningless
        //		-2: player head - no bounty
        //		-3: player head, bounty, illegal return, no bounty given
        //		1: player head - bounty given
        public static bool CollectBounty(Head h, Mobile from, Mobile collector, ref int goldGiven, ref int message)
        {
            bool bReturn = false;

            goldGiven = 0;
            message   = -1;
            try
            {
                int  goldRewarded       = 0;
                int  goldForLBBonus     = 0;
                bool eligibleforlbbonus = false;
                if (h.IsPlayerHead)
                {
                    if (BountyKeeper.CanCollectReward((PlayerMobile)from, h.Player))
                    {
                        ArrayList found_bounties = new ArrayList();
                        foreach (Bounty b in BountyKeeper.Bounties)
                        {
                            if (b.WantedPlayer == h.Player)
                            {
                                if (h.Time > b.RewardDate)
                                {
                                    goldRewarded += b.Reward;
                                    if (b.LBBonus)
                                    {
                                        eligibleforlbbonus = true;
                                    }
                                    found_bounties.Add(b);
                                }
                            }
                        }

                        if (eligibleforlbbonus)
                        {
                            goldForLBBonus = BountyKeeper.CurrentLBBonusAmount;
                        }
                        bool bRewardGiven = false;
                        if (goldRewarded > 0)
                        {
                            message = 1;
                            //collector.Say( string.Format("My thanks for slaying this vile person.  Here's the reward of {0} gold!", goldRewarded) );
                            Container c = from.Backpack;
                            if (c != null)
                            {
                                //Gold g = new Gold(goldRewarded + goldForLBBonus);
                                BankCheck g = new BankCheck(goldRewarded + goldForLBBonus);
                                goldGiven            = goldRewarded + goldForLBBonus;
                                BountyKeeper.LBFund -= goldForLBBonus;
                                from.AddToBackpack(g);
                                bReturn      = true;
                                bRewardGiven = true;
                            }
                        }
                        else
                        {
                            message = -2;
                            //collector.Say("You disgusting miscreant!  Why are you giving me an innocent person's head?");
                        }

                        if (bRewardGiven)
                        {
                            foreach (Bounty b in found_bounties)
                            {
                                BountyKeeper.Bounties.Remove(b);
                            }
                            found_bounties.Clear();
                        }
                    }
                    else
                    {
                        message = -3;
                        //collector.Say("I suspect treachery....");
                        //collector.Say("I'll take that head, you just run along now.");
                        bReturn = true;
                    }
                }
            }
            catch (Exception e)
            {
                LogHelper.LogException(e);
                System.Console.WriteLine("Error (nonfatal) in BaseGuard.OnDragDrop(): " + e.Message);
                System.Console.WriteLine(e.StackTrace);
            }

            return(bReturn);
        }
Ejemplo n.º 2
0
        // returns:
        // true if head taken, false if not
        // goldRewarded is the gold placed in the placer's back
        // message is:
        //		-1: default - meaningless
        //		-2: player head - innocent person's head, no bounty
        //		-3: player head - illegal return (friend return, same account return), no bounty given
        //		-4: player head - bounty given
        //		-5: player head - bounty already collected
        public static bool CollectBounty(Head h, Mobile from, Mobile collector, ref int goldGiven, ref int message)
        {
            bool bReturn = false;

            goldGiven = 0;
            message   = -1;
            try
            {
                int  goldRewarded       = 0;
                int  goldForLBBonus     = 0;
                bool eligibleforlbbonus = false;
                if (h.IsPlayerHead)
                {
                    if (BountyKeeper.CanCollectReward((PlayerMobile)from, h))
                    {
                        ArrayList found_bounties = new ArrayList();
                        foreach (Bounty b in BountyKeeper.Bounties)
                        {
                            if (b.WantedPlayer == h.Player)
                            {
                                if (h.Time > b.RewardDate)
                                {
                                    goldRewarded += b.Reward;
                                    if (b.LBBonus)
                                    {
                                        eligibleforlbbonus = true;
                                    }
                                    found_bounties.Add(b);
                                }
                            }
                        }

                        if (eligibleforlbbonus)
                        {
                            goldForLBBonus = BountyKeeper.CurrentLBBonusAmount;
                        }
                        bool bRewardGiven = false;

                        // adam: issue the reward even if there is only a lord brit bonus
                        // see the commants at the top of this file for exploit potential
                        if (goldRewarded > 0 || goldForLBBonus > 0)
                        {
                            message = -4;                             // My thanks for slaying this vile person.  Here's the reward of {0} gold!, goldGiven
                            Container c = from.Backpack;
                            if (c != null)
                            {
                                BankCheck g = new BankCheck(goldRewarded + goldForLBBonus);
                                goldGiven            = goldRewarded + goldForLBBonus;
                                BountyKeeper.LBFund -= goldForLBBonus;
                                from.AddToBackpack(g);
                                bReturn      = true;
                                bRewardGiven = true;

                                LogHelper Logger = new LogHelper("BountySystem.log", false, true);
                                string    p1     = Logger.Format(LogType.Mobile, from);
                                string    p2     = Logger.Format(LogType.Mobile, h.Player);
                                Logger.Log(LogType.Text,
                                           string.Format("({0}) received {2} gold ({3} reward + {4} LB bonus) for turing in the head of ({1}). ", p1, p2, goldGiven, goldRewarded, goldForLBBonus)
                                           );
                                Logger.Finish();
                            }
                        }
                        else
                        {
                            if (Engines.TCCS.FindEntry(h.Player) == null)
                            {
                                message = -2;                                 // You disgusting miscreant!  Why are you giving me an innocent person's head?
                            }
                            else
                            {
                                message = -5;                                 // My thanks for slaying this vile person, but the bounty has already been collected.
                            }
                        }

                        if (bRewardGiven)
                        {
                            foreach (Bounty b in found_bounties)
                            {
                                BountyKeeper.Bounties.Remove(b);
                            }
                            found_bounties.Clear();
                        }

                        //Call UpdateAnnouncements to update any messages on the town crier from the PJUM
                        // system that are affected by bounties being collected.
                        try
                        {
                            PJUM.PJUM.UpdateAnnouncements();
                        }
                        catch (Exception e)
                        {
                            LogHelper.LogException(e);
                        }
                    }
                    else
                    {
                        message = -3;                           // I suspect treachery....
                        // I'll take that head, you just run along now.
                        bReturn = true;
                    }
                }
            }
            catch (Exception e)
            {
                LogHelper.LogException(e);
                System.Console.WriteLine("Error (nonfatal) in BaseGuard.OnDragDrop(): " + e.Message);
                System.Console.WriteLine(e.StackTrace);
            }

            return(bReturn);
        }