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!