#W# Added: I am now tracking monster kills. Points are based on mob fame. Also added a nice [StatusBar command.
This commit is contained in:
parent
86b15bbc8e
commit
ce9983b081
4 changed files with 178 additions and 2 deletions
|
|
@ -825,13 +825,19 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
{
|
||||
if (m_TithingPoints != value)
|
||||
{
|
||||
int oldValue = m_TithingPoints;
|
||||
m_TithingPoints = value;
|
||||
|
||||
Delta(MobileDelta.TithingPoints);
|
||||
OnTithingPointsChange(oldValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void OnTithingPointsChange(int oldValue)
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int Followers
|
||||
{
|
||||
|
|
|
|||
114
Projects/UOContent/Gumps/StatusBar.cs
Normal file
114
Projects/UOContent/Gumps/StatusBar.cs
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Commands;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Custom.UI
|
||||
{
|
||||
public class StatusBar
|
||||
{
|
||||
// Safely tracks if a player prefers the vertical (true) or horizontal (false) layout
|
||||
public static ConcurrentDictionary<Mobile, bool> Preferences = new ConcurrentDictionary<Mobile, bool>();
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
CommandSystem.Register("StatusBar", AccessLevel.Player, new CommandEventHandler(OnCommand));
|
||||
}
|
||||
|
||||
[Usage("StatusBar")]
|
||||
[Description("Opens a quick-view status bar for Fame, Karma, Hunger, Thirst, Tithing, and Kills.")]
|
||||
public static void OnCommand(CommandEventArgs e)
|
||||
{
|
||||
if (e.Mobile is PlayerMobile pm)
|
||||
{
|
||||
// Get their saved preference, defaulting to horizontal (false)
|
||||
bool isVert = Preferences.GetOrAdd(pm, false);
|
||||
|
||||
// ModernUO Generics: Notice the brackets and empty parentheses!
|
||||
pm.CloseGump<StatusBarGump>();
|
||||
pm.SendGump(new StatusBarGump(pm, isVert));
|
||||
}
|
||||
}
|
||||
|
||||
public static void Refresh(Mobile from, bool force = false)
|
||||
{
|
||||
if (from is PlayerMobile pm && pm.NetState != null)
|
||||
{
|
||||
// ModernUO Generics: HasGump takes 0 arguments now
|
||||
if (pm.HasGump<StatusBarGump>() || force)
|
||||
{
|
||||
bool isVert = Preferences.GetOrAdd(pm, false);
|
||||
|
||||
pm.CloseGump<StatusBarGump>();
|
||||
pm.SendGump(new StatusBarGump(pm, isVert));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class StatusBarGump : Gump
|
||||
{
|
||||
private PlayerMobile m_Player;
|
||||
private bool m_IsVertical;
|
||||
|
||||
public StatusBarGump(PlayerMobile pm, bool isVertical) : base(50, 50)
|
||||
{
|
||||
m_Player = pm;
|
||||
m_IsVertical = isVertical;
|
||||
|
||||
Closable = true;
|
||||
Disposable = true;
|
||||
Draggable = true;
|
||||
Resizable = false;
|
||||
|
||||
AddPage(0);
|
||||
|
||||
if (m_IsVertical)
|
||||
{
|
||||
AddBackground(0, 0, 150, 200, 9270);
|
||||
|
||||
AddHtml(15, 15, 120, 20, $"<BASEFONT COLOR=#FCCA03>Fame:</BASEFONT> <BASEFONT COLOR=#FFFFFF>{pm.Fame}</BASEFONT>", false, false);
|
||||
AddHtml(15, 40, 120, 20, $"<BASEFONT COLOR=#FCCA03>Karma:</BASEFONT> <BASEFONT COLOR=#FFFFFF>{pm.Karma}</BASEFONT>", false, false);
|
||||
AddHtml(15, 65, 120, 20, $"<BASEFONT COLOR=#FCCA03>Hunger:</BASEFONT> <BASEFONT COLOR=#FFFFFF>{pm.Hunger}/20</BASEFONT>", false, false);
|
||||
AddHtml(15, 90, 120, 20, $"<BASEFONT COLOR=#FCCA03>Thirst:</BASEFONT> <BASEFONT COLOR=#FFFFFF>{pm.Thirst}/20</BASEFONT>", false, false);
|
||||
AddHtml(15, 115, 120, 20, $"<BASEFONT COLOR=#FCCA03>Tithing:</BASEFONT> <BASEFONT COLOR=#FFFFFF>{pm.TithingPoints}</BASEFONT>", false, false);
|
||||
AddHtml(15, 140, 120, 20, $"<BASEFONT COLOR=#FCCA03>Kills:</BASEFONT> <BASEFONT COLOR=#FFFFFF>{pm.MonsterKillPoints}</BASEFONT>", false, false);
|
||||
|
||||
AddButton(115, 167, 9720, 9722, 2, GumpButtonType.Reply, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddBackground(0, 0, 650, 45, 9270);
|
||||
|
||||
AddHtml(15, 12, 110, 20, $"<BASEFONT COLOR=#FCCA03>Fame:</BASEFONT> <BASEFONT COLOR=#FFFFFF>{pm.Fame}</BASEFONT>", false, false);
|
||||
AddHtml(110, 12, 110, 20, $"<BASEFONT COLOR=#FCCA03>Karma:</BASEFONT> <BASEFONT COLOR=#FFFFFF>{pm.Karma}</BASEFONT>", false, false);
|
||||
AddHtml(215, 12, 110, 20, $"<BASEFONT COLOR=#FCCA03>Hunger:</BASEFONT> <BASEFONT COLOR=#FFFFFF>{pm.Hunger}/20</BASEFONT>", false, false);
|
||||
AddHtml(315, 12, 110, 20, $"<BASEFONT COLOR=#FCCA03>Thirst:</BASEFONT> <BASEFONT COLOR=#FFFFFF>{pm.Thirst}/20</BASEFONT>", false, false);
|
||||
AddHtml(410, 12, 110, 20, $"<BASEFONT COLOR=#FCCA03>Tithing:</BASEFONT> <BASEFONT COLOR=#FFFFFF>{pm.TithingPoints}</BASEFONT>", false, false);
|
||||
AddHtml(510, 12, 110, 20, $"<BASEFONT COLOR=#FCCA03>Kills:</BASEFONT> <BASEFONT COLOR=#FFFFFF>{pm.MonsterKillPoints}</BASEFONT>", false, false);
|
||||
|
||||
AddButton(625, 15, 9720, 9722, 2, GumpButtonType.Reply, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, in RelayInfo info)
|
||||
{
|
||||
if (m_Player == null || m_Player.Deleted)
|
||||
return;
|
||||
|
||||
switch (info.ButtonID)
|
||||
{
|
||||
case 1: // Refresh the gump without changing layout
|
||||
m_Player.SendGump(new StatusBarGump(m_Player, m_IsVertical));
|
||||
break;
|
||||
case 2: // Toggle the layout and save their preference
|
||||
StatusBar.Preferences[m_Player] = !m_IsVertical;
|
||||
m_Player.SendGump(new StatusBarGump(m_Player, !m_IsVertical));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3453,6 +3453,17 @@ namespace Server.Mobiles
|
|||
Paragon.GiveArtifactTo(mob);
|
||||
}
|
||||
}
|
||||
if (mob is PlayerMobile player)
|
||||
{
|
||||
int points = this.Fame / 200;
|
||||
|
||||
if (points > 0)
|
||||
{
|
||||
player.MonsterKillPoints += points;
|
||||
|
||||
player.SendMessage(0x43, $"You earned {points} kill points. (Total: {player.MonsterKillPoints})");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnDeath(Container c)
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ using BaseMLQuestGump = Server.Engines.MLQuests.Gumps.BaseMLQuestGump;
|
|||
using CalcMoves = Server.Movement.Movement;
|
||||
using QuestOfferGump = Server.Engines.MLQuests.Gumps.QuestOfferGump;
|
||||
using RankDefinition = Server.Guilds.RankDefinition;
|
||||
|
||||
using Server.Custom.UI;
|
||||
namespace Server.Mobiles
|
||||
{
|
||||
[Flags]
|
||||
|
|
@ -729,6 +729,22 @@ namespace Server.Mobiles
|
|||
[CommandProperty(AccessLevel.Counselor, canModify: true)]
|
||||
public VirtueContext Virtues => VirtueSystem.GetOrCreateVirtues(this);
|
||||
|
||||
|
||||
private int m_MonsterKillPoints;
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int MonsterKillPoints {
|
||||
get => m_MonsterKillPoints;
|
||||
set
|
||||
{
|
||||
int oldValue = m_MonsterKillPoints;
|
||||
if (oldValue != value)
|
||||
{
|
||||
m_MonsterKillPoints = value;
|
||||
OnMonsterKillPointsChanged(oldValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public HonorContext ReceivedHonorContext { get; set; }
|
||||
|
||||
public QuestArrow QuestArrow
|
||||
|
|
@ -2771,6 +2787,11 @@ namespace Server.Mobiles
|
|||
|
||||
switch (version)
|
||||
{
|
||||
case 35:
|
||||
{
|
||||
m_MonsterKillPoints = reader.ReadInt();
|
||||
goto case 34;
|
||||
}
|
||||
case 34: // Acquired Recipes is now a Set
|
||||
case 33: // Removes champion title
|
||||
case 32: // Removes virtue properties
|
||||
|
|
@ -3118,7 +3139,9 @@ namespace Server.Mobiles
|
|||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(34); // version
|
||||
writer.Write(35); // version
|
||||
|
||||
writer.Write(MonsterKillPoints);
|
||||
|
||||
if (Stabled == null)
|
||||
{
|
||||
|
|
@ -3793,10 +3816,32 @@ namespace Server.Mobiles
|
|||
|
||||
public override void OnKarmaChange(int oldValue)
|
||||
{
|
||||
StatusBar.Refresh(this);
|
||||
}
|
||||
|
||||
public override void OnFameChange(int oldValue)
|
||||
{
|
||||
StatusBar.Refresh(this);
|
||||
}
|
||||
|
||||
public override void OnHungerChanged(int oldValue)
|
||||
{
|
||||
StatusBar.Refresh(this);
|
||||
}
|
||||
|
||||
public override void OnThirstChanged(int oldValue)
|
||||
{
|
||||
StatusBar.Refresh(this);
|
||||
}
|
||||
|
||||
public override void OnTithingPointsChange(int oldValue)
|
||||
{
|
||||
StatusBar.Refresh(this);
|
||||
}
|
||||
|
||||
public virtual void OnMonsterKillPointsChanged(int oldValue)
|
||||
{
|
||||
StatusBar.Refresh(this);
|
||||
}
|
||||
|
||||
public override void OnSkillChange(SkillName skill, double oldBase)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue