public Bounty(XmlElement node) { m_datePlaced = BountyKeeper.GetDateTime(BountyKeeper.GetText(node["date"], null), DateTime.Now); m_reward = BountyKeeper.GetInt32(BountyKeeper.GetText(node["amount"], "0"), 0); int serial = BountyKeeper.GetInt32(BountyKeeper.GetText(node["wanted"], "0"), 0); player_wanted = (PlayerMobile)World.FindMobile(serial); serial = BountyKeeper.GetInt32(BountyKeeper.GetText(node["placed"], "0"), 0); player_placed = (PlayerMobile)World.FindMobile(serial); string strValue = BountyKeeper.GetText(node["LBBonus"], "true"); if (strValue.Equals("true")) { m_bLordBritishBonus = true; } else { m_bLordBritishBonus = false; } string strTest = BountyKeeper.GetText(node["placername"], null); if (strTest != null) { m_placername = strTest; } }
public override void OnResponse(NetState state, RelayInfo info) { Mobile from = state.Mobile; switch (info.ButtonID) { case 1: { try { TextRelay getTehText = info.GetTextEntry(0); m_Amount = Convert.ToInt32(getTehText.Text); } catch { m_Victim.SendMessage("Bounty Amount was improperly formatted!"); m_Victim.SendGump(new BountyGump(m_Victim, m_Killer)); break; } Container cont = m_Victim.BankBox; if (m_Amount < 500) { m_Victim.SendMessage("No one would hunt for that low of a bounty!"); m_Victim.SendGump(new BountyGump(m_Victim, m_Killer)); break; } else if (cont != null && cont.ConsumeTotal(typeof(Gold), m_Amount)) { BountyKeeper.Add(new Bounty((PlayerMobile)m_Victim, (PlayerMobile)m_Killer, m_Amount, true)); m_Victim.SendMessage("You have posted a bounty for the head of " + m_Killer.Name + "!"); m_Victim.SendMessage("Amount of GP removed from your bank: " + m_Amount); } else { m_Victim.SendMessage("You do not have that much GP in your bank!"); m_Victim.SendGump(new BountyGump(m_Victim, m_Killer)); break; } break; } case 2: { m_Victim.SendMessage("You decide not to post a bounty."); break; } } }
public override void Execute(CommandEventArgs e, object obj) { Mobile m = (Mobile)obj; //CommandLogging.WriteLine( e.Mobile, "{0} {1} {2} {3}", e.Mobile.AccessLevel, CommandLogging.Format( e.Mobile ), m_Value ? "hiding" : "unhiding", CommandLogging.Format( m ) ); if (e.Length == 1) { if ((m is PlayerMobile) && (m.AccessLevel == AccessLevel.Player)) // Can't put bounty on staff. { PlayerMobile bountyPlacer = (PlayerMobile)e.Mobile; Container cont = bountyPlacer.BankBox; int amount = 0; try { amount = Int32.Parse(e.GetString(0)); } catch { AddResponse("Bounty Amount was improperly formatted!"); return; } if (amount < 500) { AddResponse("No one would hunt for that low of a bounty!"); } else if (cont != null && cont.ConsumeTotal(typeof(Gold), amount)) { BountyKeeper.Add(new Bounty(bountyPlacer, (PlayerMobile)m, amount, false)); AddResponse("You have posted a bounty for the head of " + m.Name + "!"); AddResponse("Amount of GP removed from your bank: " + amount); ((PlayerMobile)m).SendMessage(bountyPlacer.Name + " has just placed a bounty on your head for " + amount + " gold."); //Flag player criminal, but don't guardwhack //bountyPlacer.Criminal = true; //Flag to only the player you place the bounty on. if (!bountyPlacer.PermaFlags.Contains(m)) { bountyPlacer.PermaFlags.Add(m); bountyPlacer.Delta(MobileDelta.Noto); ExpireTimer et = new ExpireTimer(bountyPlacer, m, TimeSpan.FromMinutes(2.0)); et.Start(); } } else { AddResponse("You do not have that much GP in your bank!"); } } else { AddResponse("Please target a player."); } } else { AddResponse("You must specify the amount of the bounty."); } }
//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); }
public BountyDisplayGump(Mobile from, int page) : base(50, 10) { from.CloseGump(typeof(BountyDisplayGump)); m_Page = page; m_From = from; AddPage(0); AddImage(30, 30, 5400); if (BountyKeeper.NumberOfUniqueBounties != 0) //only put scroll-up and scroll-down if there are bounties { AddButton(393, 145, 2084, 2084, 4, GumpButtonType.Reply, 0); // Scroll up AddButton(390, 371, 2085, 2085, 5, GumpButtonType.Reply, 0); // Scroll down } string title = "<CENTER>Bounty Board</CENTER>"; //board.Title; if (title != null) { AddHtml(183, 68, 180, 23, title, false, false); } if (BountyKeeper.NumberOfUniqueBounties > 0) { AddLabel(440, 89, LabelHue, (page + 1).ToString()); AddLabel(455, 89, LabelHue, "/"); AddLabel(470, 89, LabelHue, BountyKeeper.NumberOfUniqueBounties.ToString()); } if (BountyKeeper.NumberOfUniqueBounties == 0) { AddHtml(150, 240, 250, 100, "There are no current bounties listed for collection. All the citizens of Britannia have been good!", false, false); } else //list the bounties! { if ((page >= 0) && (page < BountyKeeper.NumberOfUniqueBounties)) { Bounty b = BountyKeeper.GetBounty(page); int thisplayerbounties = BountyKeeper.BountiesOnPlayer(b.WantedPlayer); bool eligibleforlbbonus = BountyKeeper.IsEligibleForLBBonus(b.WantedPlayer); string output = ""; if (eligibleforlbbonus) { if (thisplayerbounties > 1) { output = string.Format("Lord British and {0} others have placed a bounty on the head of {1}.", thisplayerbounties, b.WantedPlayer.Name); } else { output = string.Format("Lord British and {0} have placed a bounty on the head of {1}.", b.PlacerName, b.WantedPlayer.Name); } } else { if (thisplayerbounties > 1) { output = string.Format("{0} people have placed a bounty on the head of {1}.", thisplayerbounties, b.WantedPlayer.Name); } else { output = string.Format("{0} has placed a bounty on the head of {1}.", b.PlacerName, b.WantedPlayer.Name); } } AddHtml(150, 180, 250, 60, output, false, false); if (eligibleforlbbonus) { output = string.Format("The reward is {0} gold!", BountyKeeper.RewardForPlayer(b.WantedPlayer) + BountyKeeper.CurrentLBBonusAmount); } else { output = string.Format("The reward is {0} gold!", BountyKeeper.RewardForPlayer(b.WantedPlayer)); } AddHtml(150, 240, 250, 60, output, false, false); } } }
public override void OnResponse(NetState state, RelayInfo info) { Mobile from = state.Mobile; switch (info.ButtonID) { case 1: { try { TextRelay getTehText = info.GetTextEntry(0); m_Amount = Convert.ToInt32(getTehText.Text); } catch { m_Victim.SendMessage("Bounty Amount was improperly formatted!"); m_Victim.SendGump(new BountyGump(m_Victim, m_Killer)); break; } Container cont = m_Victim.BankBox; if (m_Amount < 500) { m_Victim.SendMessage("No one would hunt for that low of a bounty!"); m_Victim.SendGump(new BountyGump(m_Victim, m_Killer)); break; } else if (cont != null && cont.ConsumeTotal(typeof(Gold), m_Amount)) { int bountyAmount = m_Amount % 10000; int murderCounts = m_Amount / 10000; bool GuardsAcceptBribe = true; // don't allow the adding additional murder counts if we're not talking about a *real* murderer if (m_Killer.Murderer == false) { bountyAmount = m_Amount; murderCounts = 0; GuardsAcceptBribe = false; } if (bountyAmount > 0) { BountyKeeper.Add(new Bounty((PlayerMobile)m_Victim, (PlayerMobile)m_Killer, bountyAmount, true)); m_Victim.SendMessage("You have posted a bounty for the head of " + m_Killer.Name + "!"); m_Killer.SendMessage("{0} has placed a bounty on your head!", m_Victim.Name); } if (murderCounts > 0) { m_Victim.SendMessage("{0}'s sentence has been increased by {1} term{2}.", m_Killer.Name, murderCounts, murderCounts == 1 ? "" : "s"); m_Killer.SendMessage("{0} bribed the court and your sentence has been increased by {1} term{2}.", m_Victim.Name, murderCounts, murderCounts == 1 ? "" : "s"); m_Killer.ShortTermMurders += murderCounts; m_Killer.LongTermMurders += murderCounts; LogHelper Logger = new LogHelper("BountySystem.log", false, true); Logger.Log(LogType.Mobile, m_Killer, string.Format("STM before {0}, STM after {1}, LTM before {2}, LTM after {3}", m_Killer.ShortTermMurders - murderCounts, m_Killer.ShortTermMurders, m_Killer.LongTermMurders - murderCounts, m_Killer.LongTermMurders)); Logger.Finish(); } if (GuardsAcceptBribe == false) { m_Victim.SendMessage("The Angel Island Prison guards refuse your bribe."); } m_Victim.SendMessage("A total of {0} GP has been removed from your bank.", m_Amount); } else { m_Victim.SendMessage("You do not have that much GP in your bank!"); m_Victim.SendGump(new BountyGump(m_Victim, m_Killer)); break; } break; } case 2: { m_Victim.SendMessage("You decide not to post a bounty."); break; } } }
// 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); }