Welcome to the Builder Academy

Question Checking Encumberance

More
01 Oct 2017 19:39 #6945 by JTP
Replied by JTP on topic Checking Encumberance
On tbamud it seems when i cant carry more, auto loot still picks up.

Is that intended ?

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

More
01 Oct 2017 21:46 #6946 by Papaya Pete
Replied by Papaya Pete on topic Checking Encumberance
Not sure, there is no check for weight under simple_move, so I have the feeling it will refuse to pick things up.

I am planning on writing this up into a snippet (armor skill penalties and encumbrance, along with a slightly different output for "inventory" command) and posting it as well.

Not sure who uses these snippets, but at least if something happens to my copy it will be posted on here.

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

More
01 Oct 2017 22:25 #6948 by JTP
Replied by JTP on topic Checking Encumberance
Look forward to see what you have done

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

More
02 Oct 2017 05:59 #6949 by zusuk
Replied by zusuk on topic Checking Encumberance
Morgan, players report that sometimes they return to their house and there is nothing there. I think there is a stock issue with losing house contents during certain crashes, but I am not 100% sure. It is on our todo list, but because we are slowly moving more and more of the saved data to databases instead of files, it may be a while until we get to it ;p

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 06:01 #6950 by zusuk
Replied by zusuk on topic Checking Encumberance
Wait I think Ripley did fix houses on our MUD ;p I guess we just haven't gotten to implementing an encumbrance system yet :)

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 08:47 #6951 by Papaya Pete
Replied by Papaya Pete on topic Checking Encumberance
Ah glad to hear that issue was resolved! I think that problem is likely something very beyond my very meager programming skills; I likely wouldn't have player housing (but it would be very awesome).

So I reworked the inventory display a little bit, and also got the above rough draft of the check_encumbrance function up and running. Not only does it count the weight in a player's inventory, it also includes the equipment worn as well!

Over in act.informative, here's do_inventory redone.
Code:
ACMD(do_inventory) { send_to_char(ch, "Current Weight: %d Max Weight: %d\r\n\r\n", check_encumbrance(ch, SIT_INV_WNUMBER), CAN_CARRY_W(ch)); send_to_char(ch, " Items: %d Max Items: %d\r\n", IS_CARRYING_N(ch), CAN_CARRY_N(ch)); send_to_char(ch, " Encumbrance Rating: "); check_encumbrance(ch, SIT_INV_MESSAGE); send_to_char(ch, "\r\nInventory:\r\n"); list_obj_to_char(ch->carrying, ch, SHOW_OBJ_SHORT, TRUE); }

Over in structs.h, added in these.
Code:
/* How much weight is a character carrying? Light, moderate, or heavy load? */ #define ENC_LIGHT 1 #define ENC_MOD 2 #define ENC_HEAVY 3 #define ENC_NONE 4 /* Used for determining situations that come up when inquiring about encumbrance. */ #define SIT_MOVEMENT 1 #define SIT_INV_MESSAGE 2 #define SIT_INV_WNUMBER 3

Over in act.items, here's the check_encumbrance function.
Code:
int check_encumbrance(struct char_data *ch, int situation) { int maxcarry = CAN_CARRY_W(ch); int current = IS_CARRYING_N(ch); int condition = 0, penalty = 0; float percent = 0; /* So we've got the max carry and current weight carried. Time to check EQ slots and tally that weight up! */ if (GET_EQ(ch, WEAR_LIGHT)) current += GET_OBJ_WEIGHT(GET_EQ(ch, WEAR_LIGHT)); if (GET_EQ(ch, WEAR_FINGER_R)) current += GET_OBJ_WEIGHT(GET_EQ(ch, WEAR_FINGER_R)); if (GET_EQ(ch, WEAR_FINGER_L)) current += GET_OBJ_WEIGHT(GET_EQ(ch, WEAR_FINGER_L)); if (GET_EQ(ch, WEAR_NECK_1)) current += GET_OBJ_WEIGHT(GET_EQ(ch, WEAR_NECK_1)); if (GET_EQ(ch, WEAR_NECK_2)) current += GET_OBJ_WEIGHT(GET_EQ(ch, WEAR_NECK_2)); if (GET_EQ(ch, WEAR_BODY)) current += GET_OBJ_WEIGHT(GET_EQ(ch, WEAR_BODY)); if (GET_EQ(ch, WEAR_HEAD)) current += GET_OBJ_WEIGHT(GET_EQ(ch, WEAR_HEAD)); if (GET_EQ(ch, WEAR_LEGS)) current += GET_OBJ_WEIGHT(GET_EQ(ch, WEAR_LEGS)); if (GET_EQ(ch, WEAR_FEET)) current += GET_OBJ_WEIGHT(GET_EQ(ch, WEAR_FEET)); if (GET_EQ(ch, WEAR_HANDS)) current += GET_OBJ_WEIGHT(GET_EQ(ch, WEAR_HANDS)); if (GET_EQ(ch, WEAR_ARMS)) current += GET_OBJ_WEIGHT(GET_EQ(ch, WEAR_ARMS)); if (GET_EQ(ch, WEAR_SHIELD)) current += GET_OBJ_WEIGHT(GET_EQ(ch, WEAR_SHIELD)); if (GET_EQ(ch, WEAR_ABOUT)) current += GET_OBJ_WEIGHT(GET_EQ(ch, WEAR_ABOUT)); if (GET_EQ(ch, WEAR_WAIST)) current += GET_OBJ_WEIGHT(GET_EQ(ch, WEAR_WAIST)); if (GET_EQ(ch, WEAR_WRIST_R)) current += GET_OBJ_WEIGHT(GET_EQ(ch, WEAR_WRIST_R)); if (GET_EQ(ch, WEAR_WRIST_L)) current += GET_OBJ_WEIGHT(GET_EQ(ch, WEAR_WRIST_L)); if (GET_EQ(ch, WEAR_WIELD)) current += GET_OBJ_WEIGHT(GET_EQ(ch, WEAR_WIELD)); if (GET_EQ(ch, WEAR_HOLD)) current += GET_OBJ_WEIGHT(GET_EQ(ch, WEAR_HOLD)); if (GET_EQ(ch, WEAR_BACKPACK)) current += GET_OBJ_WEIGHT(GET_EQ(ch, WEAR_BACKPACK)); if (GET_EQ(ch, WEAR_DWIELD)) current += GET_OBJ_WEIGHT(GET_EQ(ch, WEAR_DWIELD)); if (GET_EQ(ch, WEAR_BODYARM)) current += GET_OBJ_WEIGHT(GET_EQ(ch, WEAR_BODYARM)); if (GET_EQ(ch, WEAR_ARMARM)) current += GET_OBJ_WEIGHT(GET_EQ(ch, WEAR_ARMARM)); if (GET_EQ(ch, WEAR_LEGARM)) current += GET_OBJ_WEIGHT(GET_EQ(ch, WEAR_LEGARM)); percent = (float)current / (float)maxcarry; if (percent <= .25) condition = ENC_NONE; else if (percent <= .50) condition = ENC_LIGHT; else if (percent <= .75) condition = ENC_MOD; else if (percent <= 1) condition = ENC_HEAVY; /* If the situation is combat, penalty of 1, 2, or 4 is applied to attacks. However, if the situation is movement, penalty is a multiplier to the movement cost. Light encumbrance would offer no penalty. */ switch (situation) { case SIT_MOVEMENT: switch (condition) { case ENC_LIGHT: penalty = 1; break; case ENC_MOD: penalty = 2; break; case ENC_HEAVY: penalty = 3; break; default: penalty = 1; break; } break; case SIT_INV_MESSAGE: switch (condition) { case ENC_LIGHT: send_to_char(ch, "\tGLight\tn"); break; case ENC_MOD: send_to_char(ch, "\tYModerate\tn"); break; case ENC_HEAVY: send_to_char(ch, "\tRHeavy\tn"); break; default: send_to_char(ch, "\tWNone\tn"); break; } return (0); break; case SIT_INV_WNUMBER: return (current); break; } return (penalty); }

I removed the combat penalty portion, though that could be very easily added once again. So far, it doesn't have any added effect other than "Oh no I'm close to carrying my limit!" Oh wait... forgot one last bit of code. Still in act.item.
Code:
if (!IS_NPC(ch) && !PRF_FLAGGED(ch, PRF_NOHASSLE)) { if (IS_CARRYING_N(ch) >= CAN_CARRY_N(ch)) { act("$p: you can't carry that many items.", FALSE, ch, obj, 0, TO_CHAR); return (0); } else if ((check_encumbrance(ch, SIT_INV_WNUMBER) + GET_OBJ_WEIGHT(obj)) > CAN_CARRY_W(ch)) { // <----- This is the only line that is changed. act("$p: you can't carry that much weight.", FALSE, ch, obj, 0, TO_CHAR); return (0); } }

Now the player's total carried weight (inventory + eq) is considered instead of just their inventory weight.

Will do more tomorrow.

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

Time to create page: 0.198 seconds