Some of the approved stuff.

Post Reply
Drake.PC-LoT
Apprentice Scribe
Posts: 16
Joined: Tue Apr 15, 2025 11:15 am

Some of the approved stuff.

Post by Drake.PC-LoT »

I was bored, figured i'd hammer out some of the stuff request and approved.

from the website, it says the server uses client 5.0.9, so that's what i designed these to work with.

AOS Stats Gump.

Code: Select all

using System;
using Server;
using Server.Gumps;
using Server.Commands;
using Server.Items;
using Server.Mobiles;
using System.Collections.Generic;

namespace Server.Gumps
{
    public class PlayerStatsGump : Gump
    {
        public PlayerStatsGump(Mobile from) : base(50, 50)
        {
            from.CloseGump(typeof(PlayerStatsGump));

            AddPage(0);
            AddBackground(0, 0, 350, 425, 9270);
            AddAlphaRegion(10, 10, 330, 405);

            AddLabel(110, 20, 1152, "Your Equipment Stats");

            int y = 50;
            Dictionary<string, int> stats = GetEquipmentBonuses(from);
            foreach (var stat in stats)
            {
                AddLabel(30, y, 0, $"{stat.Key}:");
                AddLabel(200, y, 1153, stat.Value.ToString());
                y += 25;
            }

            double swingSpeed = GetWeaponSwingSpeed(from);
            AddLabel(30, y, 0, "Current Swing Speed:");
            AddLabel(200, y, 1153, $"{swingSpeed:0.00}s");
        }

        private Dictionary<string, int> GetEquipmentBonuses(Mobile m)
        {
            Dictionary<string, int> totals = new Dictionary<string, int>()
            {
                { "Swing Speed Increase", 0 },
                { "Spell Damage Increase", 0 },
                { "Mana Regen", 0 },
                { "Health Regen", 0 },
                { "Damage Increase", 0 },
                { "LRC", 0 },
                { "LMC", 0 },
                { "Reflect Phys Dmg", 0 },
                { "Hit Chance Increase", 0 },
                { "Defense Chance Increase", 0 },
                { "FCR", 0 },
                { "FC", 0 },
                { "Luck", 0 }
            };

            foreach (Item item in m.Items)
            {
                if (item == null || item.Deleted)
                    continue;

                AosAttributes a = item.Attributes;
                if (a != null)
                {
                    AddStat(totals, "Swing Speed Increase", a.WeaponSpeed);
                    AddStat(totals, "Spell Damage Increase", a.SpellDamage);
                    AddStat(totals, "Mana Regen", a.RegenMana);
                    AddStat(totals, "Health Regen", a.RegenHits);
                    AddStat(totals, "Damage Increase", a.WeaponDamage);
                    AddStat(totals, "LRC", a.LowerRegCost);
                    AddStat(totals, "LMC", a.LowerManaCost);
                    AddStat(totals, "Reflect Phys Dmg", a.ReflectPhysical);
                    AddStat(totals, "Hit Chance Increase", a.AttackChance);
                    AddStat(totals, "Defense Chance Increase", a.DefendChance);
                    AddStat(totals, "FCR", a.CastRecovery);
                    AddStat(totals, "FC", a.CastSpeed);
                    AddStat(totals, "Luck", a.Luck);
                }
            }

            return totals;
        }

        private void AddStat(Dictionary<string, int> dict, string key, int value)
        {
            if (value > 0)
                dict[key] += value;
        }

        private double GetWeaponSwingSpeed(Mobile m)
        {
            if (m.Weapon is BaseWeapon weapon)
            {
                int ssi = GetEquipmentBonuses(m)["Swing Speed Increase"];
                double stam = m.Stam;
                double baseSpeed = weapon.Speed;

                double swingTime = (baseSpeed * (100 - Math.Min(60, ssi))) / 100.0;
                swingTime = swingTime * 40 / (Math.Max(1, stam + 1));
                swingTime = Math.Max(1.25, swingTime);
                return swingTime;
            }

            return 0.0;
        }
    }

    public class PlayerStatsCommand
    {
        public static void Initialize()
        {
            CommandSystem.Register("StatsGump", AccessLevel.Player, new CommandEventHandler(Stats_OnCommand));
        }

        [Usage("StatsGump")]
        [Description("Displays equipment stats.")]
        private static void Stats_OnCommand(CommandEventArgs e)
        {
            e.Mobile.SendGump(new PlayerStatsGump(e.Mobile));
        }
    }
}
Call PlayerStatsCommand.Initialize() from your Initialize() in Scripts/Commands.cs or similar.

Code: Select all

public static void Initialize()
{
    // Other command initializations
    PlayerStatsCommand.Initialize(); // ← Add this if it's not there
}
[StatsGump




2nd Hand
Inside BaseWeapon, add this at the top of the class

Code: Select all

private HashSet<Mobile> _uniqueEquippers = new HashSet<Mobile>();
Override OnEquip in BaseWeapon

Code: Select all

public override bool OnEquip(Mobile from)
{
    if (from != null && from.Player)
    {
        if (!_uniqueEquippers.Contains(from))
        {
            _uniqueEquippers.Add(from);
            from.SendMessage(33, $"You are player #{_uniqueEquippers.Count} to equip this weapon.");
        }
    }

    return base.OnEquip(from);
}
Add serialization logic to persist player data
Add this to the BaseWeapon class (or extend its existing methods)

Code: Select all

public override void Serialize(GenericWriter writer)
{
    base.Serialize(writer);
    writer.Write(0); // version

    writer.Write(_uniqueEquippers.Count);
    foreach (Mobile m in _uniqueEquippers)
        writer.Write(m);
}

public override void Deserialize(GenericReader reader)
{
    base.Deserialize(reader);
    int version = reader.ReadInt();

    int count = reader.ReadInt();
    _uniqueEquippers = new HashSet<Mobile>();
    for (int i = 0; i < count; i++)
    {
        Mobile m = reader.ReadMobile();
        if (m != null)
            _uniqueEquippers.Add(m);
    }
}
Add this inside GetProperties in BaseWeapon:

Code: Select all

public override void GetProperties(ObjectPropertyList list)
{
    base.GetProperties(list);

    if (_uniqueEquippers != null && _uniqueEquippers.Count > 0)
        list.Add($"Equipped by {_uniqueEquippers.Count} unique player{(_uniqueEquippers.Count == 1 ? "" : "s")}");
}


these are the ones i could do on short notice and without access to specific scripts already on the server.


[edit]

small edit, forgot to add luck, also cleaned the gump up a bit to read stats from any item from any property section.
Post Reply