- Posts: 217
- Thank you received: 22
Checking Encumberance
- Papaya Pete
- Topic Author
- Offline
- Elite Member
-
As I was starting to get back into building for my mud, I realized I forgot to put this in. I decided to write a function in the act.item.c file, called check_encumbrance.
int check_encumbrance(struct char_data *ch) {
int encumbrance = 0;
if (GET_EQ(ch, WEAR_BODYARM)) {
if (OBJ_FLAGGED(GET_EQ(ch, WEAR_BODYARM), ITEM_ISLIGHT))
encumbrance = ENC_LIGHT;
if (OBJ_FLAGGED(GET_EQ(ch, WEAR_BODYARM), ITEM_ISMEDIUM) && encumbrance != ENC_HEAVY)
encumbrance = ENC_MEDIUM;
if (OBJ_FLAGGED(GET_EQ(ch, WEAR_BODYARM), ITEM_ISHEAVY))
encumbrance = ENC_HEAVY;
}
if (GET_EQ(ch, WEAR_ARMARM)) {
send_to_char(ch, "Ok, you're wearing arm armor.\r\n");
if (OBJ_FLAGGED(GET_EQ(ch, WEAR_ARMARM), ITEM_ISLIGHT) && encumbrance != ENC_MEDIUM && encumbrance != ENC_HEAVY) {
send_to_char(ch, "And it is light.\r\n");
encumbrance = ENC_LIGHT;
}
if (OBJ_FLAGGED(GET_EQ(ch, WEAR_ARMARM), ITEM_ISMEDIUM) && encumbrance != ENC_HEAVY) {
send_to_char(ch, "And it is moderate.\r\n");
encumbrance = ENC_MEDIUM;
}
if (OBJ_FLAGGED(GET_EQ(ch, WEAR_ARMARM), ITEM_ISHEAVY)) {
send_to_char(ch, "And it is heavy.\r\n");
encumbrance = ENC_HEAVY;
}
}
if (GET_EQ(ch, WEAR_LEGARM)) {
if (OBJ_FLAGGED(GET_EQ(ch, WEAR_LEGARM), ITEM_ISLIGHT) && encumbrance != ENC_MEDIUM && encumbrance != ENC_HEAVY)
encumbrance = ENC_LIGHT;
if (OBJ_FLAGGED(GET_EQ(ch, WEAR_LEGARM), ITEM_ISMEDIUM) && encumbrance != ENC_HEAVY)
encumbrance = ENC_MEDIUM;
if (OBJ_FLAGGED(GET_EQ(ch, WEAR_LEGARM), ITEM_ISHEAVY))
encumbrance = ENC_HEAVY;
}
if (GET_EQ(ch, WEAR_HEAD)) {
if (OBJ_FLAGGED(GET_EQ(ch, WEAR_HEAD), ITEM_ISLIGHT) && encumbrance != ENC_MEDIUM && encumbrance != ENC_HEAVY)
encumbrance = ENC_LIGHT;
if (OBJ_FLAGGED(GET_EQ(ch, WEAR_HEAD), ITEM_ISMEDIUM) && encumbrance != ENC_HEAVY)
encumbrance = ENC_MEDIUM;
if (OBJ_FLAGGED(GET_EQ(ch, WEAR_HEAD), ITEM_ISHEAVY))
encumbrance = ENC_HEAVY;
}
if (GET_EQ(ch, WEAR_FEET)) {
if (OBJ_FLAGGED(GET_EQ(ch, WEAR_FEET), ITEM_ISLIGHT) && encumbrance != ENC_MEDIUM && encumbrance != ENC_HEAVY)
encumbrance = ENC_LIGHT;
if (OBJ_FLAGGED(GET_EQ(ch, WEAR_FEET), ITEM_ISMEDIUM) && encumbrance != ENC_HEAVY)
encumbrance = ENC_MEDIUM;
if (OBJ_FLAGGED(GET_EQ(ch, WEAR_FEET), ITEM_ISHEAVY))
encumbrance = ENC_HEAVY;
}
if (GET_EQ(ch, WEAR_WAIST)) {
if (OBJ_FLAGGED(GET_EQ(ch, WEAR_WAIST), ITEM_ISLIGHT) && encumbrance != ENC_MEDIUM && encumbrance != ENC_HEAVY)
encumbrance = ENC_LIGHT;
if (OBJ_FLAGGED(GET_EQ(ch, WEAR_WAIST), ITEM_ISMEDIUM) && encumbrance != ENC_HEAVY)
encumbrance = ENC_MEDIUM;
if (OBJ_FLAGGED(GET_EQ(ch, WEAR_WAIST), ITEM_ISHEAVY))
encumbrance = ENC_HEAVY;
}
if (GET_EQ(ch, WEAR_NECK_1)) {
if (OBJ_FLAGGED(GET_EQ(ch, WEAR_NECK_1), ITEM_ISLIGHT) && encumbrance != ENC_MEDIUM && encumbrance != ENC_HEAVY)
encumbrance = ENC_LIGHT;
if (OBJ_FLAGGED(GET_EQ(ch, WEAR_NECK_1), ITEM_ISMEDIUM) && encumbrance != ENC_HEAVY)
encumbrance = ENC_MEDIUM;
if (OBJ_FLAGGED(GET_EQ(ch, WEAR_NECK_1), ITEM_ISHEAVY))
encumbrance = ENC_HEAVY;
}
if (GET_EQ(ch, WEAR_NECK_2)) {
if (OBJ_FLAGGED(GET_EQ(ch, WEAR_NECK_2), ITEM_ISLIGHT) && encumbrance != ENC_MEDIUM && encumbrance != ENC_HEAVY)
encumbrance = ENC_LIGHT;
if (OBJ_FLAGGED(GET_EQ(ch, WEAR_NECK_2), ITEM_ISMEDIUM) && encumbrance != ENC_HEAVY)
encumbrance = ENC_MEDIUM;
if (OBJ_FLAGGED(GET_EQ(ch, WEAR_NECK_2), ITEM_ISHEAVY))
encumbrance = ENC_HEAVY;
}
if (GET_EQ(ch, WEAR_WRIST_L)) {
if (OBJ_FLAGGED(GET_EQ(ch, WEAR_WRIST_L), ITEM_ISLIGHT) && encumbrance != ENC_MEDIUM && encumbrance != ENC_HEAVY)
encumbrance = ENC_LIGHT;
if (OBJ_FLAGGED(GET_EQ(ch, WEAR_WRIST_L), ITEM_ISMEDIUM) && encumbrance != ENC_HEAVY)
encumbrance = ENC_MEDIUM;
if (OBJ_FLAGGED(GET_EQ(ch, WEAR_WRIST_L), ITEM_ISHEAVY))
encumbrance = ENC_HEAVY;
}
if (GET_EQ(ch, WEAR_WRIST_R)) {
if (OBJ_FLAGGED(GET_EQ(ch, WEAR_WRIST_R), ITEM_ISLIGHT) && encumbrance != ENC_MEDIUM && encumbrance != ENC_HEAVY)
encumbrance = ENC_LIGHT;
if (OBJ_FLAGGED(GET_EQ(ch, WEAR_WRIST_R), ITEM_ISMEDIUM) && encumbrance != ENC_HEAVY)
encumbrance = ENC_MEDIUM;
if (OBJ_FLAGGED(GET_EQ(ch, WEAR_WRIST_R), ITEM_ISHEAVY))
encumbrance = ENC_HEAVY;
}
if (GET_EQ(ch, WEAR_SHIELD)) {
if (OBJ_FLAGGED(GET_EQ(ch, WEAR_SHIELD), ITEM_ISLIGHT) && encumbrance != ENC_MEDIUM && encumbrance != ENC_HEAVY)
encumbrance = ENC_LIGHT;
if (OBJ_FLAGGED(GET_EQ(ch, WEAR_SHIELD), ITEM_ISMEDIUM) && encumbrance != ENC_HEAVY)
encumbrance = ENC_MEDIUM;
if (OBJ_FLAGGED(GET_EQ(ch, WEAR_SHIELD), ITEM_ISHEAVY))
encumbrance = ENC_HEAVY;
}
send_to_char(ch, "Your encumbrance value is %d.\r\n", encumbrance);
switch (encumbrance) {
case ENC_LIGHT:
send_to_char(ch, "\tgSome of the armor you're wearing is slightly restricting you, making some skills a little harder to perform.\tn\t\n");
break;
case ENC_MEDIUM:
send_to_char(ch, "\tySome of your armor is making it pretty hard to perform some skills...\tn\r\n");
break;
case ENC_HEAVY:
send_to_char(ch, "\tRSome of your armor is really heavy, making some skills VERY difficult to do!\tn\r\n");
break;
default:
/* You're not encumbered and are Ok. */
send_to_char(ch, "You're not encumbered at all. This message is for testing purposes only.\r\n");
break;
}
return (encumbrance);
}
I've added wear slots for wearing arm, leg, and body armor over the arm, leg, and body wear slots (you can wear clothes under that plate mail, PLEASE WEAR CLOTHES UNDER THE PLATE MAIL). So, WEAR_ARMARM is referencing Arm Armor. I threw in the send_to_char statements in there for testing purposes (my admin character has a pair of sleeves so that's why I put it in there).
Here's the problem I'm having so far: the function is called just fine (check_encumbrance(ch) at the very end of the perform_wear function in the same file). However, it fails any check to see if--
....
....
....
And I just realized the problem. Those sleeves were set to be worn on the arms as clothing, not armor. Nevermind!
Uhhh.... so... have a new snippet? Thanksbye!
Edit: Thank you, Thomas, for the idea of adding values to struct like #define ENC_LIGHT 2, helps me out a whole lot!
Please Log in or Create an account to join the conversation.
- zusuk
-
- Offline
- Elite Member
-
- LuminariMUD Developer
It got me thinking how complicated it would be to set up a full encumbrance system, including items worn and items carried. I remember a MUD having a system like that, it made "weightless" bags (bags that would reduce the weight of its contents) extremely valuable.
Website
www.luminariMUD.com
Main Game Port
luminariMUD.com:4100
Please Log in or Create an account to join the conversation.
- Papaya Pete
- Topic Author
- Offline
- Elite Member
-
- Posts: 217
- Thank you received: 22
I'm not really going to write the code itself (just pseudo-code?), but now that you've given me the idea, this is kind of how I would go about doing it. (Note, in this example, I'd replace my check_encumbrance's name with check_armor)
int check_encumbrance (struct char_data *ch, int situation)
{
int maxcarry = *insert max carry of ch*;
int current = *insert current weight of ch*;
int condition = 0, penalty = 0;
float 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_COMBAT:
switch (condition) {
case ENC_LIGHT:
penalty = 1;
break;
case ENC_MOD:
penalty = 2;
break;
case ENC_HEAVY:
penalty = 4;
break;
case default:
penalty = 0;
break;
}
break;
case SIT_MOVEMENT:
switch (condition) {
case ENC_LIGHT:
penalty = 1;
break;
case ENC_LIGHT:
penalty = 2;
break;
case ENC_HEAVY:
penalty = 3;
break;
case default:
penalty = 1;
break;
}
break;
case default:
send_to_char(ch, "Not supposed to see this.\r\n");
break;
}
return (penalty);
It would be easy enough to add a skill penalty as well to encumbrance. Add another case statement to the switch (situation). It depends on how detailed you want to get.
People will probably want to hang me high and dry if I put this into my mud (if I ever open it... getting out of one area involves going through mountains and fighting the elements/illnesses that could be fatal). Still a very cool idea.
Edit:
You could add more info into the inventory screen, saying not only how much a player can carry but also how many items they can hold in inventory and current encumbrance level. I'd want something that would tell the player easy enough why it's costing him 10 movement points to go down the street in town, but not in a way that spams him too much.
Please Log in or Create an account to join the conversation.
- zusuk
-
- Offline
- Elite Member
-
- LuminariMUD Developer
Website
www.luminariMUD.com
Main Game Port
luminariMUD.com:4100
Please Log in or Create an account to join the conversation.
- JTP
- Offline
- Platinum Member
-
- Posts: 937
- Thank you received: 17
So If they cant carry anymore just make do_move Or is it perform_move prevent them from moving. Where is it checked if they cant carry anymore ?
Please Log in or Create an account to join the conversation.
- Papaya Pete
- Topic Author
- Offline
- Elite Member
-
- Posts: 217
- Thank you received: 22
@Mosheh reliable player housing? What improvements are you going to make?
Side note, you would have to make a list of checks to see if a player has something worn in slot x, y, z, etc. And add that to the total encumbrance.
Please Log in or Create an account to join the conversation.
- JTP
- Offline
- Platinum Member
-
- Posts: 937
- Thank you received: 17
Is that intended ?
Please Log in or Create an account to join the conversation.
- Papaya Pete
- Topic Author
- Offline
- Elite Member
-
- Posts: 217
- Thank you received: 22
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.
- JTP
- Offline
- Platinum Member
-
- Posts: 937
- Thank you received: 17
Please Log in or Create an account to join the conversation.
- zusuk
-
- Offline
- Elite Member
-
- LuminariMUD Developer
Website
www.luminariMUD.com
Main Game Port
luminariMUD.com:4100
Please Log in or Create an account to join the conversation.
- zusuk
-
- Offline
- Elite Member
-
- LuminariMUD Developer
Website
www.luminariMUD.com
Main Game Port
luminariMUD.com:4100
Please Log in or Create an account to join the conversation.
- Papaya Pete
- Topic Author
- Offline
- Elite Member
-
- Posts: 217
- Thank you received: 22
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.
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.
/* 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.
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.
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.
- zusuk
-
- Offline
- Elite Member
-
- LuminariMUD Developer
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.
- JTP
- Offline
- Platinum Member
-
- Posts: 937
- Thank you received: 17
Please Log in or Create an account to join the conversation.
- Papaya Pete
- Topic Author
- Offline
- Elite Member
-
- Posts: 217
- Thank you received: 22
@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.
- JTP
- Offline
- Platinum Member
-
- Posts: 937
- Thank you received: 17
Please Log in or Create an account to join the conversation.
- Papaya Pete
- Topic Author
- Offline
- Elite Member
-
- Posts: 217
- Thank you received: 22
So using these functions, check_armor and check_encumbrance, is pretty easy. For encumbrance increasing movement cost, you just do the following:
/* 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...
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.
#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.
- Papaya Pete
- Topic Author
- Offline
- Elite Member
-
- Posts: 217
- Thank you received: 22
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.
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...
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...
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.
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.
Please Log in or Create an account to join the conversation.
- Papaya Pete
- Topic Author
- Offline
- Elite Member
-
- Posts: 217
- Thank you received: 22
int check_encumbrance(struct char_data *ch, int situation) {
int maxcarry = CAN_CARRY_W(ch);
int current = IS_CARRYING_W(ch); // <---------------- W instead of N, was messing everything up.
int condition = 0, penalty = 0;
float percent = 0;
Seems to be fixed after that. I noticed it when I took of my goods-laden backpack.
On a side note, I also found another couple bugs and a crash with object durability; I was redoing how item damage is done, making a new function that is called. I added in some code, too, reusing some of the OVALs so that object material is more easily stored. Better than using flags. My plan is to add in fire, steam, electrical, etc. damage that will deal different amounts of damage to gear based on the material of the piece of equipment. Not going to have damage dealt to bags and clothes just to be convenient (and a little kinder) to players. Also, doing item damage this way means I can differentiate between, say, copper and iron other than giving one higher durability than the other.
Please Log in or Create an account to join the conversation.