Weight tallying script and weight issues.

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.

Moderator: POL Developer

Post Reply
Yukiko
Distro Developer
Posts: 2825
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Weight tallying script and weight issues.

Post by Yukiko »

I am trying to see if the weight of a character is being properly sent to my client. There's a discrepancy between what the client says the maximum weight my character can be versus what I can actually carry on her. So I wrote a script to tally up all the weight of items in a container and I want to know if it will give me an accurate number. Will it do what I need?

I have a script that will unequip my character's backpack and drop it on the ground. With my character completely naked and with her backpack unequipped she is reported by the client in the status gump as having a weight of 10 stones. Does anyone know what the weight of a naked character is supposed to be?

I can tell you that the total weight of items in her backpack that is reported by my script plus my character's "naked" weight is more than what the status gump says she weighs with the backpack equipped. The gump says she should be able to carry 390 stone. The weight of the items in the backpack reported by my script is 352. Her weight is 10. The backpack weight is set to 1 in the itemdesc.cfg file. So the total combined weight (if my script is working properly) is 363 stone. However when I equip her backpack the status gump reports her weight as 260 stone and she cannot pick-up any more items. If the status gump is reporting her maximum weight accurately she should be able to add 130 more stone weight to her pack. The max weight capacity for the backpack is 800 stone so I know that isn't limiting things.

I'm sorry for the mixed topics here but I am getting bug reports about the weight issue and I'd really like to know if my script is working. In particular I was not sure if I needed to convert weights to reals. Some of our items do have fractional weights so I assumed so.

Code: Select all

use uo;

program textcmd_addupweight (me)
	var num := 0;
	var sum := 0;
	var stuff := {};

	SendSysMessage(me, "Target the container you wish to know the weight of.");
	var it := Target(me);
	if (!it)
		return;
	endif

	if (!it.isa (POLCLASS_CONTAINER))
		SendSysMessage(me,"That is not a container!");
		return;
	endif
	sum := CDbl(sum);
	stuff := EnumerateItemsInContainer(it,0);
	foreach item in stuff
		sum := sum + CDbl(item.weight);
	endforeach

	SendSysMessage(me, "The total weight of the items in that container is " + CStr(sum), 1, 66);
endprogram
Polytropon
New User
Posts: 19
Joined: Wed Sep 15, 2010 9:47 pm

Re: Weight tallying script and weight issues.

Post by Polytropon »

I tested the weight of naked character (checking layer by layer, so I have no invisible item equipped), and it's 10 stones. Hooked the status, and the core is sending the same number. Couldn´t find where that "ten" comes from, tough.

"Character.weigth" seems to return 10 + the sum of all equipped items weight (and backpack.weight = the weight of the bag item + everything inside). You are using EnumerateItemInContainer() without the ENUMERATE_ROOT_ONLY flag, so everything you have inside in a sub-container is counted twice (well, as many times as bags inside the bags you have) as it weights the container and the item contained.


The 260 issue sounds like a problem with the 250 default max weight + the character 10-weight. Be careful not to confuse the Admin backpack with the player backpack, as the are defined as different items, the problem could be there.
Yukiko
Distro Developer
Posts: 2825
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Re: Weight tallying script and weight issues.

Post by Yukiko »

Thanks for your reply. I suppose I should have posted the itemdesc.cfg entry for the pack I have equipped on my character so that its weight limit/item limit wouldn't be assumed to be the problem. So here is the definition of the backpack my character has equipped:

Code: Select all

Container 0x966c
{
    Name                staffpack
    graphic             0x0E75
    desc                backpack
    Gump                0x003C
    MinX                44
    MaxX                143
    MinY                65
    MaxY                140
    RequiresAttention   0
    movable             1
    MaxItems            1000
    MaxWeight           10000
    weight              1
    CanInsertScript     ::canInsert
    OnInsertScript      ::onInsert
    CanRemoveScript     ::canRemove
    OnRemoveScript      ::onRemove
}
I wanted to be sure that there was no container limit conflict involved. Thanks for reminding me that I could simply do a character.weight check. Sometimes the simple things just escape me.
*grins*

So when I do that (character.weight) I get 260 stone which is what the status gump says she weighs. I'll try experimenting with different backpacks and weight limits but I think 10,000 stone limit on a pack should suffice. I know I don't have 1000 items in the pack so it isn't an item limit issue. This has me flummoxed as to what the problem might be. Again, I appreciate any help with this.
Polytropon
New User
Posts: 19
Joined: Wed Sep 15, 2010 9:47 pm

Re: Weight tallying script and weight issues.

Post by Polytropon »

The number "250" makes me think immediately in this setting in servspecopt.cfg:

Code: Select all

#
# DefaultContainerMaxItems, DefaultContainerMaxWeight
# These values will be used for containers that do not define "MaxItems" and "MaxWeight"
# in their itemdesc.cfg entries.
#
DefaultContainerMaxItems=125
DefaultContainerMaxWeight=250

But you defined a MaxWeight, so the default value should be ignored. The only explanation I have is that the backpack you are using isn´t the same backpack you think you are using. Why don´t you give it a backpack.objtype to rule it out? (or read it from data/pcs.txt)

By default in the distro I have (097?), the admin account has the backpack 0x966c (staffpack) while every other player account has the backpack 0xE75 (backpackcore).

BTW, Maxweight line works fine for me.
Yukiko
Distro Developer
Posts: 2825
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Re: Weight tallying script and weight issues.

Post by Yukiko »

Initially my character had the standard backpack (V) but when I noticed the weight issue I re-equipped her with the staffpck just to be sure the issue wasn't due to item/weight limits. I even switched back to the regular backpack again just to verify the issue still existed wiith that pack. I'm really at a loss here as to what the issue might be. I appreciate the suggestions. Unfortunately, I think I've tried them already but thanks anyway for trying. I still wonder if there's some setting I missed in a config file or some missing parameter in a packet that is causing this.
Post Reply