Welcome to the Builder Academy

Question Checking Encumberance

More
28 Sep 2017 18:43 - 28 Sep 2017 18:45 #6928 by Papaya Pete
So sometimes, instead of having a flag that just says, "You cannot use this, Rogue," you want to have a way to stack a fat penalty onto a rogue wearing plate mail armor.

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.
Code:
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!
Last edit: 28 Sep 2017 18:45 by Papaya Pete.
The following user(s) said Thank You: thomas, zusuk

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

More
29 Sep 2017 09:49 #6929 by zusuk
Replied by zusuk on topic Checking Encumberance
Very interesting way of set this up!

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
The following user(s) said Thank You: Papaya Pete

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

More
01 Oct 2017 07:23 - 01 Oct 2017 07:28 #6933 by Papaya Pete
Replied by Papaya Pete on topic Checking Encumberance
Thinking about it, it wouldn't be that difficult. Let's say you want to have your encumbrance have an effect on combat and on movement.

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)
Code:
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.
Last edit: 01 Oct 2017 07:28 by Papaya Pete. Reason: Forgot an idea. And how to format properly.

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

More
01 Oct 2017 17:28 #6940 by zusuk
Replied by zusuk on topic Checking Encumberance
Yeah we have been erring on the side of player-convenience over realism :) People can carry insane amounts of stuff and weight until we sharpen up and make sure the house system works reliably.

Website
www.luminariMUD.com

Main Game Port
luminariMUD.com:4100

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

More
01 Oct 2017 19:12 - 01 Oct 2017 19:20 #6943 by JTP
Replied by JTP on topic Checking Encumberance
Isnt the weight of items vs a players strength limitten How much they Can carry?

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 ?
Last edit: 01 Oct 2017 19:20 by JTP.

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

More
01 Oct 2017 19:21 #6944 by Papaya Pete
Replied by Papaya Pete on topic Checking Encumberance
@Jan it is located in act.item.c, can't remember the exact name but just search for the message, "You can't carry that much!" There might be a movement check too, that would be in act.movement.c.

@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.

Time to create page: 0.197 seconds