Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define minimum weight (prevent negatives) #73

Closed
jedininja28 opened this issue Jan 11, 2020 · 4 comments · Fixed by #1621
Closed

Define minimum weight (prevent negatives) #73

jedininja28 opened this issue Jan 11, 2020 · 4 comments · Fixed by #1621
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@jedininja28
Copy link

jedininja28 commented Jan 11, 2020

Hey, in my tinkering with runuo 2.5 and 2.6 i noticed that if negative weight compounded beyond a certain limit it would default to max weight. I wanted to make a bag that would randomly generate with a weight from 1 to -150 and thus would allow an extra 100 ores (in that area). I got the bag to spawn off of an npc vendor but when i started bug checking the bag i ran into all kinds of default weight errors.

Things i noticed:

Stacking negitive weight bags with no other items would additionally subtract weight through the chain of bags until the player weight reached some sort of threshold and defaulted to max weight.

Having multiple items in a bag with negative weight subtracted as it should but the weight modifier could not keep up with alot of fast changes (bag sorting, pot use, so on) and defaulted to max weight.

Negative weight bags on pets with pack did nothing so far as i could see.

So i concluded that deffing a minimum negative weight would resolve most of the issues i was having the consequence i was going to use was not being able to pick items off of the ground if player weight fell below a minimum weight. Thus using it would require planning.

I searched around alot for similar errors but never really found a good solution.

The last thing i was working on was getting the player total weight and subtracting 200 if the weight exceeded the players carry capacity before stamina burn.

Ill post my scripts on runuo's git when i can. I figured that if your going to rework the entire arcitecture deffining minium weight and some negitive handeling would prevent alot of needless crashing.

Excuse by bad spelling.

@kamronbatman kamronbatman added bug Something isn't working good first issue Good for newcomers labels Jan 12, 2020
@kamronbatman
Copy link
Contributor

Is negative weight an ACTUAL thing? Should we treat any negative value as something special and default to weight of 0?

What happens on actual UO servers?

@Krubster
Copy link

I've never seen such functionality on offical servers and negative weight sounds weird. This feature can be done with overriding TotalWeight property

@kamronbatman
Copy link
Contributor

kamronbatman commented Jan 12, 2020

So I will keep this as a bug, and we should default any negative number to 0. Overriding that can be done on a per item basis by overriding the weight functions I assume.

This is up for grabs for anyone that wants to fix it. :)

Edit: is weight an int or uint to the client? Let's find out.

@kamronbatman kamronbatman changed the title Define minum negative weight!!! Define minimum weight (prevent negatives) Jan 16, 2021
@malbolger
Copy link

Two quick changes should fix this and stop the attribute settings from the [props menu.

In Item.cs inside the "public double Weight" (around line 496) You need to change:

if (info.m_Weight == -1)

to:

if (info.m_Weight <= -1)

and also in Item.cs inside the "VerifyCompactInfo()" (around line 1724) You need to change:

|| info.m_Weight != -1;

to:

|| info.m_Weight > -1;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants