Welcome to the Builder Academy

Question Checking Encumberance

More
02 Oct 2017 09:18 #6952 by zusuk
Replied by zusuk on topic Checking Encumberance
Yeah houses are part of stock TBA, you would have to check with other folks with regular players that actually use the house code to dispute/verify the crash issue with saving items in a house though :) It very well could be something we messed up along the way.

Thanks for your encumbrance contribution! If we decide to add that mechanic I will definitely stop back at this thread :)

Website
www.luminariMUD.com

Main Game Port
luminariMUD.com:4100

Please Log in or Create an account to join the conversation.

More
02 Oct 2017 09:57 #6953 by JTP
Replied by JTP on topic Checking Encumberance
I added a backpack slot, so items in a container like a bag also needs to be alculated. Or just a container from People's inventory.

Please Log in or Create an account to join the conversation.

More
02 Oct 2017 17:41 #6954 by Papaya Pete
Replied by Papaya Pete on topic Checking Encumberance
@Mosheh You're welcome! I enjoy building on a mud, but it is just as satisfying (if not more) to code something in. I want to say I remember reading about an issue with crashes and housing, but that was a while back.

@Jan Ah ha, they already are calculated. :) The character I tested with had a backpack full of miscellaneous items and a pair of old scale mail sleeves. The backpack normally weighed 2, but with all the items in it total was 32. Sleeves weighed 6. All of it showed up in the inventory screen's "Current Weight" readout. :)

Just at a glance, I was worried too that I would have to figure out how to calculate the total weight of all items in a container. Thankfully, the code is already there, for which I am very grateful.

Please Log in or Create an account to join the conversation.

More
02 Oct 2017 19:09 #6955 by JTP
Replied by JTP on topic Checking Encumberance
Good that you already tested containers. Was just a thought :)

Please Log in or Create an account to join the conversation.

More
05 Oct 2017 18:24 #6962 by Papaya Pete
Replied by Papaya Pete on topic Checking Encumberance
Sorry about not posting this sooner. I was working on adding in items for crafting skills.

So using these functions, check_armor and check_encumbrance, is pretty easy. For encumbrance increasing movement cost, you just do the following:
Code:
/* All checks passed, nothing will prevent movement now other than lack of * move points. */ /* move points needed is avg. move loss for src and destination sect type */ need_movement = (movement_loss[SECT(was_in)] + movement_loss[SECT(going_to)]) / 2; need_movement *= check_encumbrance(ch, SIT_MOVEMENT); // <----- Add me! /* Move Point Requirement Check */ if (GET_MOVE(ch) < need_movement && !IS_NPC(ch)) { if (need_specials_check && ch->master) send_to_char(ch, "You are too exhausted to follow.\r\n"); else send_to_char(ch, "You are too exhausted.\r\n"); return (0); }

Very simple, just a single line needs to be added. It's almost just as easy for doing armor penalties. Let's say you want to make it so that guy in full plate can't sneak and hide so easily. Add this...
Code:
int armorpenalty = check_armor(ch); /* Insert whatever skill code here */ percent = rand_number(1, 101) + armorpenalty;

The armorpenalty variable will just add onto the die roll. Just keep in mind that in structs.h... well... let me just show you an example.
Code:
#define ARM_HEAVY 70 #define ARM_MEDIUM 30 #define ARM_LIGHT 10 #define ARM_NONE 0

So whenever check_armor(ch) is called, ch's penalty to select skills when wearing heavy armor will be 70, 30 for medium armor, 10 for light. If he's wearing VERY light armor then no penalty is applied.

I haven't tested this much at all; still working on adding in crafting items. When I find any bugs I'll fix as best as I can and post them here. Or, if you find something, lemme know and I'll get to work on it. Thanks for reading!

Please Log in or Create an account to join the conversation.

More
05 Oct 2017 18:48 - 05 Oct 2017 18:50 #6963 by Papaya Pete
Replied by Papaya Pete on topic Checking Encumberance
So right after I posted that, I found one little bug: shops also checked to see if you could carry an item before selling it to you! So, I found that every time it made a reference to IS_CARRYING_W(ch), you replaced it with check_encumbrance(ch, SIT_INV_WNUMBER); compiles just fine but still working on other things before testing.

Also, it was mentioned that items with no weight in one mud being very powerful. Now, such items can be created by adding the flag ITEM_NOWEIGHT in the same #define list as ARM_HEAVY, ARM_LIGHT, etc. In check_encumbrance I added another condition it checks for when counting the weight of your worn gear. Here's a line to show an example. Well, a few lines.
Code:
if (GET_EQ(ch, WEAR_LIGHT) && !OBJ_FLAGGED(GET_EQ(ch, WEAR_LIGHT), ITEM_NOWEIGHT)) current += GET_OBJ_WEIGHT(GET_EQ(ch, WEAR_LIGHT)); if (GET_EQ(ch, WEAR_FINGER_R) && !OBJ_FLAGGED(GET_EQ(ch, WEAR_FINGER_R), ITEM_NOWEIGHT)) current += GET_OBJ_WEIGHT(GET_EQ(ch, WEAR_FINGER_R)); if (GET_EQ(ch, WEAR_FINGER_L) && !OBJ_FLAGGED(GET_EQ(ch, WEAR_FINGER_L), ITEM_NOWEIGHT)) current += GET_OBJ_WEIGHT(GET_EQ(ch, WEAR_FINGER_L)); if (GET_EQ(ch, WEAR_NECK_1) && !OBJ_FLAGGED(GET_EQ(ch, WEAR_NECK_1), ITEM_NOWEIGHT)) current += GET_OBJ_WEIGHT(GET_EQ(ch, WEAR_NECK_1)); if (GET_EQ(ch, WEAR_NECK_2) && !OBJ_FLAGGED(GET_EQ(ch, WEAR_NECK_2), ITEM_NOWEIGHT)) current += GET_OBJ_WEIGHT(GET_EQ(ch, WEAR_NECK_2)); if (GET_EQ(ch, WEAR_BODY) && !OBJ_FLAGGED(GET_EQ(ch, WEAR_BODY), ITEM_NOWEIGHT)) current += GET_OBJ_WEIGHT(GET_EQ(ch, WEAR_BODY));

Not that this is all of the wear positions, but you get the idea. :)

What about items laying about in your inventory? The code adds and subtracts weight from IS_CARRYING_W when items are picked up and dropped/given away in handler.c. So, made the following small changes, which compile fine but still haven't tested yet.

In obj_to_char function...
Code:
ch->carrying = object; object->carried_by = ch; IN_ROOM(object) = NOWHERE; if (!OBJ_FLAGGED(object, ITEM_NOWEIGHT)) IS_CARRYING_W(ch) += GET_OBJ_WEIGHT(object); // <--- Changed by adding that if statement to the front. IS_CARRYING_N(ch)++;

And obj_from_char function...
Code:
if (!IS_NPC(object->carried_by)) SET_BIT_AR(PLR_FLAGS(object->carried_by), PLR_CRASH); if (!OBJ_FLAGGED(object, ITEM_NOWEIGHT)) IS_CARRYING_W(object->carried_by) -= GET_OBJ_WEIGHT(object); // <---- Same thing. New if statement. IS_CARRYING_N(object->carried_by)--; object->carried_by = NULL;

I'm still working on some other stuff but when I finish with that I'll undoubtedly test all of this out and fix any OTHER mistakes I have made. Durp.

Edit:
You know, like forgetting that weight check when pick-pocketing an item? Did this small change to fix.
Code:
if (check_encumbrance(ch, SIT_INV_WNUMBER) + GET_OBJ_WEIGHT(obj) < CAN_CARRY_W(ch)) { // changed IS_CARRYING_W(ch) with check_encumbrance

that was found in do_steal in act.other.c.
Last edit: 05 Oct 2017 18:50 by Papaya Pete.

Please Log in or Create an account to join the conversation.

Time to create page: 0.292 seconds