Initial commit

This commit is contained in:
Ubuntu
2026-06-19 00:00:16 -04:00
commit 73701ff86e
7100 changed files with 1952988 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
using Server.Mobiles;
using System;
namespace Server.Items
{
public class BountiedHead : Head
{
[CommandProperty(AccessLevel.Counselor)]
public DateTime Created { get; set; }
[CommandProperty(AccessLevel.Counselor)]
public int Bounty { get; set; }
[CommandProperty(AccessLevel.Counselor)]
public PlayerMobile Player { get; set; }
public BountiedHead(string owner) : base(owner)
{
}
public BountiedHead(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
writer.Write(Created);
writer.Write(Bounty);
writer.Write(Player);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
Created = reader.ReadDateTime();
Bounty = reader.ReadInt();
Player = reader.ReadMobile<PlayerMobile>();
}
}
}
+250
View File
@@ -0,0 +1,250 @@
using Server.Misc;
using Server.Network;
using System.Collections.Generic;
using System.Linq;
using Server.Network.Misc;
using Server.Mobiles;
namespace Server.Items
{
public class BountyBoard : BaseBulletinBoard
{
private static readonly List<BountyBoard> AllBoards = new List<BountyBoard>();
[Constructable]
public BountyBoard() : base(0x1E5E)
{
BoardName = "bounty board";
AllBoards.Add(this);
GetInitialBounties();
}
private void GetInitialBounties()
{
var bountyPlayers = BountyInformation.GetValidBounties().Select(x=>x.BountyPlayer);
foreach (var bounty in bountyPlayers)
{
AddBountyToBoard(bounty);
}
}
public BountyBoard(Serial serial) : base(serial)
{
AllBoards.Add(this);
}
public override void OnSingleClick(Mobile from)
{
LabelTo(from,
string.Format("a bounty board with {0} posted bount{1}", Items.Count, Items.Count == 1 ? "y" : "ies"));
}
public override void GetProperties(ObjectPropertyList list)
{
list.Add("Bounty Board");
list.Add("{0} posted bount{1}", Items.Count, Items.Count == 1 ? "y" : "ies");
}
public override void OnDoubleClick(Mobile from)
{
if (CheckRange(from))
{
Cleanup();
var state = from.NetState;
state.Send(new BBDisplayBoard(this));
if (state.ContainerGridLines)
state.Send(new BountyPackets.BBContent6017(from, this));
else
state.Send(new BountyPackets.BBContent(from, this));
}
else
{
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
}
}
public override void OnItemAdded(Item item)
{
if (!(item is BountyMessage))
{
var bm = item as BulletinMessage;
if (bm != null && bm.Poster != null)
bm.Poster.SendMessage("This board is for bounty messages only.");
item.Delete();
}
}
public override void Cleanup()
{
// Remove any outdated bounties, and remove any posts made by players. Cannot deny player postings without editing BaseBulletinBoard.
var validBountyPlayers = BountyInformation.GetValidBounties().Select(x=>x.BountyPlayer);
Items.Where(x => !validBountyPlayers.Contains(((BountyMessage)x).BountyPlayer))
.ToList()
.ForEach( message => message.Delete() );
}
public override void Delete()
{
AllBoards.Remove(this);
base.Delete();
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
private static void GloballyCreateMessage(Mobile m)
{
foreach(var bb in AllBoards)
bb.AddBountyToBoard(m);
}
private static void GloballyDeleteMessage(Mobile m)
{
foreach (var bb in AllBoards)
{
var curMsg = bb.Items.FirstOrDefault(x => x is BountyMessage && ((BountyMessage)x).BountyPlayer == m);
if (curMsg != null)
curMsg.Delete();
}
}
private void AddBountyToBoard(Mobile m)
{
AddItem(new BountyMessage(m));
}
public static void UpdateBounty(PlayerMobile pk)
{
// Unfortunately BulletinMessage does not allow updating of the subject. So we have to delete and remake the bounty message.
GloballyDeleteMessage(pk);
GloballyCreateMessage(pk);
}
}
public class BountyMessage : BulletinMessage
{
public Mobile BountyPlayer;
public int BountyAmount;
public BountyMessage(Mobile m) : this(m, BountyInformation.GetBounty(m))
{
}
public BountyMessage(Mobile bountied, int bounty) : base(bountied, null, bounty + " gold pieces", CreateDescription(bountied))
{
BountyPlayer = bountied;
BountyAmount = bounty;
}
public static string[] CreateDescription(Mobile bountyPlayer)
{
string subtext1 = null;
string subtext2 = null;
switch (Utility.Random(18))
{
case 0: subtext1 = "hath murdered one too many!"; break;
case 1: subtext1 = "shall not slay again!"; break;
case 2: subtext1 = "hath slain too many!"; break;
case 3: subtext1 = "cannot continue to kill!"; break;
case 4: subtext1 = "must be stopped."; break;
case 5: subtext1 = "is a bloodthirsty monster."; break;
case 6: subtext1 = "is a killer of the worst sort."; break;
case 7: subtext1 = "hath no conscience!"; break;
case 8: subtext1 = "hath cowardly slain many."; break;
case 9: subtext1 = "must die for all our sakes."; break;
case 10: subtext1 = "sheds innocent blood!"; break;
case 11: subtext1 = "must fall to preserve us."; break;
case 12: subtext1 = "must be taken care of."; break;
case 13: subtext1 = "is a thug and must die."; break;
case 14: subtext1 = "cannot be redeemed."; break;
case 15: subtext1 = "is a shameless butcher."; break;
case 16: subtext1 = "is a callous monster."; break;
case 17: subtext1 = "is a cruel, casual killer."; break;
}
switch (Utility.Random(7))
{
case 0: subtext2 = "A bounty is hereby offered"; break;
case 1: subtext2 = "Lord British sets a price"; break;
case 2: subtext2 = "Claim the reward! 'Tis"; break;
case 3: subtext2 = "Lord Blackthorn set a price"; break;
case 4: subtext2 = "The Paladins set a price"; break;
case 5: subtext2 = "The Merchants set a price"; break;
case 6: subtext2 = "Lord British's bounty"; break;
}
var text = string.Format("The foul scum known as {0} {1} For {2} is responsible for {3} murders. {4} of {5} gold pieces for {6} head!", bountyPlayer.RawName, subtext1, (bountyPlayer.Body.IsFemale ? "she" : "he"), bountyPlayer.Kills, subtext2, BountyInformation.GetBounty(bountyPlayer).ToString(), (bountyPlayer.Body.IsFemale ? "her" : "his"));
var current = 0;
var linesList = new List<string>();
// break up the text into single line length pieces
while (current < text.Length)
{
// make each line 25 chars long
var length = text.Length - current;
if (length > 25)
{
length = 25;
while (text[current + length] != ' ')
length--;
length++;
linesList.Add(text.Substring(current, length));
}
else
{
linesList.Add(string.Format("{0} ", text.Substring(current, length)));
}
current += length;
}
return linesList.ToArray();
}
public BountyMessage(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0); // version
writer.Write(BountyPlayer);
writer.Write(BountyAmount);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
BountyPlayer = reader.ReadMobile();
BountyAmount = reader.ReadInt();
if (BountyPlayer == null)
Delete();
}
}
}
+122
View File
@@ -0,0 +1,122 @@
using System;
using System.Collections.Generic;
using Server.Misc;
using Server.Mobiles;
namespace Server.Items
{
/*
This class is a bit of a hack to make the system drag droppable. We are specifically looking to "override" Carve
(which is not virtual in the first place). To do this, the old corpse handler is deregistered. Instead, we call the old
CreateCorpseHandler if the corpse should not have a bounty.
*/
public class BountyCorpse : Corpse, ICarvable
{
[CallPriority(1)]
public new static void Initialize()
{
Mobile.CreateCorpseHandler -= Corpse.Mobile_CreateCorpseHandler;
Mobile.CreateCorpseHandler += Mobile_CreateCorpseHandler;
}
public new static Container Mobile_CreateCorpseHandler(Mobile owner, HairInfo hair, FacialHairInfo facialhair,
List<Item> initialContent, List<Item> equipItems)
{
var pm = owner as PlayerMobile;
if (pm == null || BountyInformation.GetBounty(pm) <= 0)
return Corpse.Mobile_CreateCorpseHandler(owner, hair, facialhair, initialContent, equipItems);
Corpse c = new BountyCorpse(owner, hair, facialhair, equipItems);
owner.Corpse = c;
for (var i = 0; i < initialContent.Count; ++i)
{
var item = initialContent[i];
if (Core.AOS && item.Parent == owner.Backpack)
c.AddItem(item);
else
c.DropItem(item);
if (Core.AOS)
c.SetRestoreInfo(item, item.Location);
}
if (Core.AOS)
{
c.RestoreEquip = pm.EquipSnapshot;
}
var loc = owner.Location;
var map = owner.Map;
if (map == null || map == Map.Internal)
{
loc = owner.LogoutLocation;
map = owner.LogoutMap;
}
c.MoveToWorld(loc, map);
return c;
}
public BountyCorpse(Mobile owner, HairInfo hair, FacialHairInfo facialhair, List<Item> equipItems)
: base(owner, hair, facialhair, equipItems)
{
}
public BountyCorpse(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int) 0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
public new void Carve(Mobile from, Item item)
{
base.Carve(from, item);
var charName = Owner.Name;
var itemsInRange = GetItemsInRange(0);
Head oldHead = null;
foreach (var it in itemsInRange)
{
var h = it as Head;
if (h == null || h is BountiedHead || h.PlayerName != charName)
continue;
oldHead = h;
break;
}
/* RunUO 2.2 IPooledEnumerable does not support ToList()?
var oldHead = GetItemsInRange(0)
.ToList()
.FirstOrDefault(x => x is Head && ((Head) x).PlayerName == charName);*/
if (oldHead == null)
return;
var bh = new BountiedHead(charName)
{
Player = Owner as PlayerMobile,
Bounty = BountyInformation.GetBounty(Owner),
Created = DateTime.UtcNow
};
bh.MoveToWorld(oldHead.Location, oldHead.Map);
oldHead.Delete();
}
}
}
+124
View File
@@ -0,0 +1,124 @@
using Server.Items;
using Server.Misc;
using System;
using System.Collections.Generic;
namespace Server.Mobiles
{
public class BountyGuard : WarriorGuard
{
[Constructable]
public BountyGuard()
{
}
private static readonly List<int> RejectedHeadSayings = new List<int>()
{
500661, // I shall place this on my mantle!
500662, // This tasteth like chicken.
500663, // This tasteth just like the juicy peach I just ate.
500664, // Ahh! That was the one piece I was missing!
500665, // Somehow, it reminds me of mother.
500666, // It's a sign! I can see Elvis in this!
500667, // Thanks, I was missing mine.
500668, // I'll put this in the lost-and-found box.
500669 // My family will eat well tonight!
};
public override bool OnDragDrop(Mobile from, Item dropped)
{
var bh = dropped as BountiedHead;
if (bh != null && bh.Player != null && !bh.Player.Deleted &&
bh.Created + TimeSpan.FromDays(1.0) > DateTime.UtcNow)
{
SayTo(from, 500670); // Ah, a head! Let me check to see if there is a bounty on this.
Timer.DelayCall(TimeSpan.FromSeconds(5.0), CheckBountyOnHead, new object[] {bh, from});
return true;
}
else if (dropped is Head)
{
Say(RejectedHeadSayings[Utility.Random(RejectedHeadSayings.Count)]);
dropped.Delete();
return true;
}
SayTo(from, 500660); // If this were the head of a murderer, I would check for a bounty.
return false;
}
private void CheckBountyOnHead(object[] states)
{
var head = (BountiedHead) states[0];
var bountyHunter = (Mobile) states[1];
var bi = BountyInformation.GetBountyInformation(head.Player);
if (bi == null)
{
Say("The reward on this scoundrel's head has already been claimed!");
head.Delete();
return;
}
var totalBounty = bi.Bounty;
var headBounty = head.Bounty;
var difference = totalBounty - headBounty;
if (difference < 0)
{
Say("The reward on this scoundrel's head has already been claimed!");
head.Delete();
return;
}
bi.SubtractBounty(headBounty);
AwardBounty(bountyHunter, head.PlayerName, headBounty);
head.Delete();
}
private void AwardBounty(Mobile bountyHunter, string killer, int total)
{
var bountySize = 0;
if (total > 15000)
bountySize = 2;
else if (total > 100)
bountySize = 1;
switch (bountySize)
{
case 2:
bountyHunter.PlaySound(0x2E6);
Say("Thou hast brought the infamous " + killer + " to justice! Thy reward of " + total + "gp hath been deposited in thy bank account.");
break;
case 1:
bountyHunter.PlaySound(0x2E5);
Say("Tis a minor criminal, thank thee. Thy reward of " + total + "gp hath been deposited in thy bank account.");
break;
default:
bountyHunter.PlaySound(0x2E4);
Say("Thou hast wasted thy time for " + total + "gp.");
break;
}
Banker.Deposit(bountyHunter, total);
}
public BountyGuard(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
}
}
+239
View File
@@ -0,0 +1,239 @@
using Server.Commands;
using Server.Gumps;
using Server.Mobiles;
using Server.Targeting;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml;
using Server.Items;
namespace Server.Misc
{
public class BountyInformation
{
public static void Configure()
{
EventSink.WorldLoad += Load;
EventSink.WorldSave += Save;
CommandSystem.Register("BountyProps", AccessLevel.Counselor, BeginBountyProps);
}
private static void BeginBountyProps(CommandEventArgs e)
{
e.Mobile.BeginTarget(-1, false, TargetFlags.None, ShowBountyProps);
}
private static void ShowBountyProps(Mobile from, object targeted)
{
var pm = targeted as PlayerMobile;
if (pm == null)
{
from.SendMessage("Only players can have bounties.");
return;
}
var bounty = AllInfo.FirstOrDefault(x => x.BountyPlayer == pm);
if (bounty == null)
{
from.SendMessage("That player has no bounty.");
return;
}
from.SendGump(new PropertiesGump(from, bounty));
}
private static void Save(WorldSaveEventArgs e)
{
if (!Directory.Exists("Saves/Bounties"))
Directory.CreateDirectory("Saves/Bounties");
var fullPath = Path.Combine("Saves/Bounties", "BountyInformation.xml");
using (var op = new StreamWriter(fullPath))
{
var xml = new XmlTextWriter(op)
{
Formatting = Formatting.Indented,
IndentChar = '\t',
Indentation = 1
};
xml.WriteStartDocument(true);
xml.WriteStartElement("bounties");
xml.WriteAttributeString("count", AllInfo.Count.ToString());
var toSave = GetValidBounties();
foreach (var bi in toSave)
{
bi.SaveBounty(xml);
}
xml.WriteEndElement();
xml.Close();
}
}
private static void Load()
{
if (!Directory.Exists("Saves/Bounties"))
return;
var fullPath = Path.Combine("Saves/Bounties", "BountyInformation.xml");
if (!File.Exists(fullPath))
return;
var saveFile = new XmlDocument();
saveFile.Load(fullPath);
var root = saveFile["bounties"];
var noFail = true;
var tried = 0;
foreach (XmlElement bountyInfo in root.GetElementsByTagName("bounty"))
{
LoadBounty(bountyInfo, ref noFail);
tried++;
}
if (noFail)
{
Console.WriteLine("\n" + AllInfo.Count + " bounties loaded successfully.");
}
else
{
Console.WriteLine("An error occurred while loading bounties." + AllInfo.Count + " out of " + tried +
" loaded successfully.");
}
}
public static List<BountyInformation> AllInfo = new List<BountyInformation>();
private PlayerMobile _bountyPlayer;
[CommandProperty(AccessLevel.Counselor)]
public PlayerMobile BountyPlayer { get { return _bountyPlayer; } }
private int _bounty;
[CommandProperty(AccessLevel.Counselor)]
public int Bounty
{
get { return _bounty; }
set
{
var changed = _bounty != value;
_bounty = value;
if (changed)
UpdateBountyBoards();
}
}
private void UpdateBountyBoards()
{
BountyBoard.UpdateBounty(BountyPlayer);
}
[CommandProperty(AccessLevel.Counselor)]
public DateTime LastBounty { get; set; }
public bool Expired
{
get
{
return BountyPlayer.Deleted || BountyPlayer.Kills < 5 || Bounty <= 0 ||
LastBounty + TimeSpan.FromDays(14.0) < DateTime.UtcNow;
}
}
public static BountyInformation AddBounty(PlayerMobile pm, int bounty, bool updateBoards)
{
var bi = AllInfo.FirstOrDefault(info => info.BountyPlayer == pm);
if (bi == null)
{
bi = new BountyInformation { _bountyPlayer = pm};
AllInfo.Add(bi);
}
bi.AddBounty(bounty, updateBoards);
return bi;
}
public static List<BountyInformation> GetValidBounties()
{
AllInfo = AllInfo.Where(x => !x.Expired).ToList();
return AllInfo;
}
private void AddBounty(int bounty, bool updateBoards)
{
if (updateBoards)
Bounty += bounty;
else
_bounty += bounty;
LastBounty = DateTime.UtcNow;
}
public void SubtractBounty(int headBounty)
{
Bounty -= headBounty;
}
public static BountyInformation GetBountyInformation(Mobile bountyPlayer)
{
return AllInfo.FirstOrDefault(info => info.BountyPlayer == bountyPlayer);
}
public static int GetBounty(Mobile bountyPlayer)
{
var bi = GetBountyInformation(bountyPlayer);
return bi == null ? 0 : bi.Bounty;
}
private static void LoadBounty(XmlElement node, ref bool noFail)
{
try
{
var serial = Utility.GetXMLInt32(Utility.GetText(node["serial"], "-1"), -1);
var mob = World.FindMobile(serial) as PlayerMobile;
var bounty = Utility.GetXMLInt32(Utility.GetText(node["bountyAmount"], "-1"), -1);
var lastBounty = Utility.GetXMLDateTime(Utility.GetText(node["lastBountyTime"], null), DateTime.UtcNow);
if (mob == null || bounty == -1 || lastBounty + TimeSpan.FromDays(14.0) < DateTime.UtcNow)
return;
var bi = AddBounty(mob, bounty, false);
bi.LastBounty = lastBounty;
}
catch
{
noFail = false;
}
}
private void SaveBounty(XmlTextWriter xml)
{
xml.WriteStartElement("bounty");
xml.WriteStartElement("serial");
xml.WriteString(BountyPlayer.Serial.Value.ToString());
xml.WriteEndElement();
xml.WriteStartElement("bountyAmount");
xml.WriteString(Bounty.ToString());
xml.WriteEndElement();
xml.WriteStartElement("lastBountyTime");
xml.WriteString(XmlConvert.ToString(LastBounty, XmlDateTimeSerializationMode.Utc));
xml.WriteEndElement();
xml.WriteEndElement();
}
}
}
+96
View File
@@ -0,0 +1,96 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Server.Items;
namespace Server.Network.Misc
{
// The entire reason this class exists is to sort the bounties. "Items" only has a get accessor.
public class BountyPackets
{
public sealed class BBContent : Packet
{
public BBContent(Mobile beholder, Item beheld) : base(0x3C)
{
List<Item> items = new List<Item>(beheld.Items);
items = items.Where(x => x is BountyMessage).OrderByDescending(x => ((BountyMessage)x).BountyAmount).ToList();
int count = items.Count;
this.EnsureCapacity(5 + (count * 19));
long pos = m_Stream.Position;
int written = 0;
m_Stream.Write((ushort)0);
for (int i = 0; i < count; ++i)
{
Item child = items[i];
if (!child.Deleted && beholder.CanSee(child))
{
Point3D loc = child.Location;
m_Stream.Write((int)child.Serial);
m_Stream.Write((ushort)child.ItemID);
m_Stream.Write((byte)0); // signed, itemID offset
m_Stream.Write((ushort)child.Amount);
m_Stream.Write((short)loc.X);
m_Stream.Write((short)loc.Y);
m_Stream.Write((int)beheld.Serial);
m_Stream.Write((ushort)(child.Hue));
++written;
}
}
m_Stream.Seek(pos, SeekOrigin.Begin);
m_Stream.Write((ushort)written);
}
}
public sealed class BBContent6017 : Packet
{
public BBContent6017(Mobile beholder, Item beheld) : base(0x3C)
{
List<Item> items = new List<Item>(beheld.Items);
items = items.Where(x => x is BountyMessage).OrderByDescending(x => ((BountyMessage)x).BountyAmount).ToList();
int count = items.Count;
this.EnsureCapacity(5 + (count * 20));
long pos = m_Stream.Position;
int written = 0;
m_Stream.Write((ushort)0);
for (int i = 0; i < count; ++i)
{
Item child = items[i];
if (!child.Deleted && beholder.CanSee(child))
{
Point3D loc = child.Location;
m_Stream.Write((int)child.Serial);
m_Stream.Write((ushort)child.ItemID);
m_Stream.Write((byte)0); // signed, itemID offset
m_Stream.Write((ushort)child.Amount);
m_Stream.Write((short)loc.X);
m_Stream.Write((short)loc.Y);
m_Stream.Write((byte)0); // Grid Location?
m_Stream.Write((int)beheld.Serial);
m_Stream.Write((ushort)(child.Hue));
++written;
}
}
m_Stream.Seek(pos, SeekOrigin.Begin);
m_Stream.Write((ushort)written);
}
}
}
}
+230
View File
@@ -0,0 +1,230 @@
using System;
using System.Collections.Generic;
using Server.Misc;
using Server.Network;
using Server.Mobiles;
using System.Linq;
using Server.Items;
namespace Server.Gumps
{
public class ReportMurdererBountyGump : Gump
{
private int _idx;
private readonly List<Mobile> _killers;
private readonly Mobile _victim;
[CallPriority(1)]
public static void Initialize()
{
EventSink.PlayerDeath -= ReportMurdererGump.EventSink_PlayerDeath;
EventSink.PlayerDeath += EventSink_PlayerDeath;
}
public static void EventSink_PlayerDeath(PlayerDeathEventArgs e)
{
var m = e.Mobile;
var killers = new List<Mobile>();
var toGive = new List<Mobile>();
foreach (var ai in m.Aggressors)
{
if (ai.Attacker.Player && ai.CanReportMurder && !ai.Reported)
{
// Note: The default reportmurderer script only allows reporting the same player once every 10 minutes in the Core.SE expansion.
// This was also the case in the T2A era, so I'm not sure why it was set to a minimum expansion of Core.SE
if (!((PlayerMobile) m).RecentlyReported.Contains(ai.Attacker))
{
killers.Add(ai.Attacker);
ai.Reported = true;
ai.CanReportMurder = false;
}
}
if (ai.Attacker.Player && DateTime.UtcNow - ai.LastCombatTime < TimeSpan.FromSeconds(30.0) &&
!toGive.Contains(ai.Attacker))
toGive.Add(ai.Attacker);
}
toGive.AddRange(
m.Aggressed.Where(
x =>
x.Defender is PlayerMobile && DateTime.UtcNow - x.LastCombatTime < TimeSpan.FromSeconds(30.0) &&
!toGive.Contains(x.Defender)).Select(x => x.Defender));
foreach (var g in toGive)
{
var n = Notoriety.Compute(g, m);
var ourKarma = g.Karma;
var innocent = n == Notoriety.Innocent;
var criminal = n == Notoriety.Criminal || n == Notoriety.Murderer;
var fameAward = m.Fame/200;
var karmaAward = 0;
if (innocent)
karmaAward = ourKarma > -2500 ? -850 : -110 - m.Karma/100;
else if (criminal)
karmaAward = 50;
Titles.AwardFame(g, fameAward, false);
Titles.AwardKarma(g, karmaAward, true);
}
if (m is PlayerMobile && ((PlayerMobile) m).NpcGuild == NpcGuild.ThievesGuild || killers.Count == 0)
return;
var gump = m.FindGump(typeof (ReportMurdererBountyGump)) as ReportMurdererBountyGump;
if (gump != null)
gump.TryAddKillers(killers);
else
new GumpTimer(m, killers).Start();
}
private class GumpTimer : Timer
{
private readonly Mobile _victim;
private readonly List<Mobile> _killers;
public GumpTimer(Mobile victim, List<Mobile> killers) : base(TimeSpan.FromSeconds(4.0))
{
_victim = victim;
_killers = killers;
}
protected override void OnTick()
{
_victim.SendGump(new ReportMurdererBountyGump(_victim, _killers));
}
}
public ReportMurdererBountyGump(Mobile victum, List<Mobile> killers) : this(victum, killers, 0)
{
}
private ReportMurdererBountyGump(Mobile victum, List<Mobile> killers, int idx) : base(0, 0)
{
_killers = killers;
_victim = victum;
_idx = idx;
BuildGump();
}
private void BuildGump()
{
AddBackground(265, 205, 393, 270, 70000);
AddImage(265, 205, 1140);
Closable = false;
Resizable = false;
AddPage(0);
AddHtml(325, 255, 300, 60,
"<BIG>Would you like to report " + _killers[_idx].Name + " as a murderer?</BIG>", false, false);
var bountymax = Banker.GetBalance(_victim);
if (_killers[_idx].Kills >= 4 && bountymax > 0)
{
AddHtml(325, 325, 300, 60, "<BIG>Optional Bounty: [" + bountymax + " max] </BIG>", false, false);
AddImage(323, 343, 0x475);
AddTextEntry(329, 346, 311, 16, 0, 1, "");
}
AddButton(385, 395, 0x47B, 0x47D, 1, GumpButtonType.Reply, 0);
AddButton(465, 395, 0x478, 0x47A, 2, GumpButtonType.Reply, 0);
}
private void TryAddKillers(IEnumerable<Mobile> killers)
{
_killers.AddRange(
killers.Where(
killer =>
!_killers.Contains(killer) && !((PlayerMobile) _victim).RecentlyReported.Contains(killer)));
}
public static void ReportedListExpiry_Callback(object state)
{
var states = (object[]) state;
var from = (PlayerMobile) states[0];
var killer = (Mobile) states[1];
if (from.RecentlyReported.Contains(killer))
{
from.RecentlyReported.Remove(killer);
}
}
public override void OnResponse(NetState state, RelayInfo info)
{
var from = state.Mobile;
switch (info.ButtonID)
{
case 1:
{
var killer = _killers[_idx];
if (killer != null && !killer.Deleted)
{
killer.Kills++;
killer.ShortTermMurders++;
((PlayerMobile) from).RecentlyReported.Add(killer);
Timer.DelayCall(TimeSpan.FromMinutes(10), new TimerStateCallback(ReportedListExpiry_Callback),
new object[] {from, killer});
var pk = (PlayerMobile) killer;
if (info.GetTextEntry(1) != null)
{
var c = info.GetTextEntry(1);
if (c != null)
{
var bounty = Math.Min( Utility.ToInt32(c.Text), Banker.GetBalance(from) );
if (bounty > 0)
{
Banker.Withdraw(from, bounty);
BountyInformation.AddBounty(pk, bounty, true);
pk.SendMessage("{0} has placed a bounty of {1} {2} on your head!", from.Name,
bounty, bounty == 1 ? "gold piece" : "gold pieces");
pk.Say(500546); // I am now bounty hunted!
from.SendMessage("You place a bounty of {0}gp on {1}'s head.", bounty, pk.Name);
}
}
}
pk.ResetKillTime();
pk.SendLocalizedMessage(1049067); //You have been reported for murder!
if (pk.Kills == 5)
{
pk.SendLocalizedMessage(502134); //You are now known as a murderer!
}
else if (SkillHandlers.Stealing.SuspendOnMurder && pk.Kills == 1 &&
pk.NpcGuild == NpcGuild.ThievesGuild)
{
pk.SendLocalizedMessage(501562); // You have been suspended by the Thieves Guild.
}
}
break;
}
case 2:
{
break;
}
}
_idx++;
if (_idx < _killers.Count)
from.SendGump(new ReportMurdererBountyGump(from, _killers, _idx));
}
}
}