RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Backpack of Weight Reduction

snicker7

Sorceror
[1.0-2.0] Backpack of Weight Reduction

This has been updated to function for RunUO 2.0. Please see this thread:
http://www.runuo.com/forums/showthread.php?t=71035

I have seen several "weightless" containers before and noticed flaws in all of them. Some of them simply made the items inside weightless, and they remained weightless when they were removed, these containers allowed the maximum limit on weight of the container to be exceeded. I have noticed others that only set the weight of the bag to a negative number, which sometimes works but is risky. Anyways... someone asked me about these yesterday so I whipped it up... which is interesting, because later that evening there was a lot of talk about quivers and weight reduction. Hopefully this will help some of you out.

If you want to have a container that is completely weightless, set ReduxPercent to 100%. A normal container is 0%. You can have values anywhere between these as long as they are integers.

Code:
/*
BackpackOfReduction.cs
snicker7
v1.1 [RunUO 1.0] 
06/07/06

Description:
The backpack of reduction is a container
that accurately reduces its total weight
by a percentage without actually changing
the weight of the items inside or the
maximum weight that the container can carry.

Properties:
int ReduxPercent - This is a value from 0
	to 100 which corresponds to the
	percentage amount of weight reduction
	desired. 100% would mean the container
	would always weigh 0 stones.
	
Constructors:
BackpackOfReduction()
	defaults to 100% reduction
BackpackOfReduction(int redux)
	reduction rate as specified by the
	redux param

This code is public domain, however, I do
ask that you simply give credit where it
is due if you use it, for the sake of your
own conscience.
*/

Current Versions:
RunUO 1.0: v1.1
 

Attachments

  • BackpackOfReduction.cs
    2.5 KB · Views: 311

snicker7

Sorceror
no. m_Redux is a double. So is 1.0 (technically speaking).

A double times a double results in a double.

TotalWeight is an int.

A double times an int results in a double.

You have to cast the whole thing as an int before storing it back into TotalWeight, which is an int.


the 1.0 - m_Redux gives the weight that the container should have. if you have a 30% reduction, the container should weigh 70% of its real total weight. base.UpdateTotals() calculates this real total weight. Then I multiply it by (taking numbers from the above example) 1.0-0.3 (1.0 - m_Redux), which is 0.7, or 70%.

UpdateTotals() is called on things like deserialization, and also when you change the percent of weight reduction property. This is what makes sure that after you reboot the server, the weights are shown properly.
 

ArteGordon

Wanderer
you are going to need to restrict containers from this backpack otherwise you will have problems. The add and remove item methods will not be able to detect addition and removal of items from nested containers within the backpack and so will not properly adjust weight.
For example, add a container with items in it to the pack. Then open that container and add or remove items.
 

snicker7

Sorceror
Updated to 1.1. Subcontainers now work properly. However, some very strange things start to happen when putting Backpacks of Reduction within eachother with different rates of reduction. Maybe someday I'll fix it, until then, deal with the strangeness! w0o0o00000oooooooooooooo!
 

Lubomir

Wanderer
Not reducing weight

I have added this to my test shard. When I place an item in the bag the bag shows a weight of zero. But, the weight on my status bar does not change and if I am overweight I still run out of stamina.

It appears that even though the bag shows a weight of zero the items inside are still being used to calculate the weight carried.

Any help with this would be greatly appreciated.

Thank you,

Lubomir
 

snicker7

Sorceror
Is this on RunUO 2.0 or 1.0?

Edit:
Okay, I see the problem with 2.0. I will take care of it soon

Edit:
bleh, this is going to take more time than I have right now, I will figure it out in the near future.
 
Top