Iomega0318

Vita-Nex Sponsor
ServUO Version
Publish 57
Ultima Expansion
Endless Journey
So been playing around with having items and weight in your backpack be scalable, weight based on strength, it works great I just have one issue with it I'm not sure how to solve. It doesn't change in real time, meaning when you gain stats the weight of the bag only changes when you move something or add something to the bag to update, is there a way this can be done on stat change?

C#:
        public override int DefaultMaxWeight
        {
            get
            {
                if (Core.ML)
                {
                    Mobile m = ParentEntity as Mobile;
                    if (m != null && m.Player && m.Backpack == this)
                    {
                        if (GetMultipliert() > 1)
                            return ((int)Math.Ceiling(Config.Get("CarryWeight.PlayerBackbackMax", 550) * GetMultipliert() / 10.0)) * 15;
                        return Config.Get("CarryWeight.PlayerBackbackMax", 550) + (int)(Config.Get("CarryWeight.CarryWeightPerStr", 3.5) * m.RawStr);
                    }
                    else
                    {
                        return base.DefaultMaxWeight;
                    }
                }
                else
                {
                    return base.DefaultMaxWeight;
                }
            }
        }
 

Lemke

Citizen
Try add one of these:
A) m.InvalidateProperties();
B) m.Delta(MobileDelta.Weight);
C#:
if (m != null && m.Player && m.Backpack == this)
                    {
                        if (GetMultipliert() > 1)
                            return ((int)Math.Ceiling(Config.Get("CarryWeight.PlayerBackbackMax", 550) * GetMultipliert() / 10.0)) * 15;
                        return Config.Get("CarryWeight.PlayerBackbackMax", 550) + (int)(Config.Get("CarryWeight.CarryWeightPerStr", 3.5) * m.RawStr);
                        m.Delta(MobileDelta.Weight);
                    }
 

Iomega0318

Vita-Nex Sponsor
Hmm I didn't know if InvalidateProperties would work there I'll give it a test here in a few.

I've never seen the delta one before, what is that?

**EDIT**
Just finished testing and neither appeared to work.
 
Last edited:

Lemke

Citizen
This code is from Mobile.cs :

C#:
public virtual void UpdateTotal(Item sender, TotalType type, int delta)
        {
            if (delta == 0 || sender.IsVirtualItem)
            {
                return;
            }

            switch (type)
            {
                case TotalType.Gold:
                    m_TotalGold += delta;
                    Delta(MobileDelta.Gold);
                    break;

                case TotalType.Items:
                    m_TotalItems += delta;
                    break;

                case TotalType.Weight:
                    m_TotalWeight += delta;
                    Delta(MobileDelta.Weight);
                    OnWeightChange(m_TotalWeight - delta);
                    break;
            }
        }
 

Iomega0318

Vita-Nex Sponsor
This code is from Mobile.cs :

C#:
public virtual void UpdateTotal(Item sender, TotalType type, int delta)
        {
            if (delta == 0 || sender.IsVirtualItem)
            {
                return;
            }

            switch (type)
            {
                case TotalType.Gold:
                    m_TotalGold += delta;
                    Delta(MobileDelta.Gold);
                    break;

                case TotalType.Items:
                    m_TotalItems += delta;
                    break;

                case TotalType.Weight:
                    m_TotalWeight += delta;
                    Delta(MobileDelta.Weight);
                    OnWeightChange(m_TotalWeight - delta);
                    break;
            }
        }
Oh I see, no clue how it works but I see where you pulled it from now :)

So because this is a stat gain should I maybe look at putting the delta update where the gain takes place so it sends the weight update too perhaps? I'd have to find it first but just a thought.
 

Iomega0318

Vita-Nex Sponsor
So I took what you posted and tried it everywhere I could find some kind of stat update in Mobile.cs and still no luck with it updating when the str stat changes.. any other ideas?