Welcome to the Builder Academy

Question Updated do_equipment

More
13 Aug 2012 22:59 #663 by Halenbane
Hey guys,

I saw on another forum where someone had been asking about showing all equipment slots , regardless of whether or not something was being worn there. I did this recently so thought I would give it for anyone that may want to do this.

Very minor changes to do_equipment in act.informative.c are needed.

Simply overwrite your current do_equipment function.
Code:
ACMD(do_equipment) { int i; send_to_char(ch, "You are using:\r\n"); for (i = 0; i < NUM_WEARS; i++) { if (GET_EQ(ch, i)) { if (CAN_SEE_OBJ(ch, GET_EQ(ch, i))) { send_to_char(ch, "%s", wear_where[i]); show_obj_to_char(GET_EQ(ch, i), ch, SHOW_OBJ_SHORT); } else { send_to_char(ch, "%s", wear_where[i]); send_to_char(ch, "Something.\r\n"); } } else { send_to_char(ch, "%s", wear_where[i]); send_to_char(ch, "Nothing\r\n"); } } }
The following user(s) said Thank You: zusuk

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

More
14 Aug 2012 00:43 #664 by Halenbane
Replied by Halenbane on topic Re: Updated do_equipment
After seeing Liko's reference to equipment ordering I incorporated that into this equipment change. I'll post the how to's in just a while.

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

More
14 Aug 2012 01:36 #669 by Halenbane
Replied by Halenbane on topic Re: Updated do_equipment
Below are the modifications for my equipment command to show empty slots as well
as re-ordering eq locations. I also changed the format eq is shown in to what I feel
looks a bit cleaner. You may have to make minor modifications to fit your MUD.


constants.c


Change wear_where if you feel like, to get away from the staggering <worn blahblah>
Code:
/** Describes the position in the equipment listing. * @pre Must be in the same order as the defines. * Not used in sprinttype() so no \n. */ const char *wear_where[] = { "[Light ] ", "[Finger ] ", "[Finger ] ", "[Neck ] ", "[Neck ] ", "[Chest ] ", "[Head ] ", "[Legs ] ", "[Feet ] ", "[Hands ] ", "[Arms ] ", "[Shield ] ", "[Back ] ", "[Waist ] ", "[Wrist ] ", "[Wrist ] ", "[Wielded ] ", "[Held ] ", "[Shoulders] ", "[Face ] " };

Right below this, under equipment_types add the following
Code:
const int wear_order_index[NUM_WEARS] = { WEAR_HEAD, WEAR_FACE, WEAR_NECK_1, WEAR_NECK_2, WEAR_SHOULDERS, WEAR_CHEST, WEAR_BACK, WEAR_WAIST, WEAR_ARMS, WEAR_WRIST_R, WEAR_WRIST_L, WEAR_HANDS, WEAR_FINGER_R, WEAR_FINGER_L, WEAR_WIELD, WEAR_HOLD, WEAR_LIGHT, WEAR_SHIELD, WEAR_LEGS, WEAR_FEET };

In act.informative.c look for & add
Code:
static void look_at_char(struct char_data *i, struct char_data *ch) { int j, found; + extern int wear_order_index[NUM_WEARS]; if (!ch->desc) return; // If you wanted, you could also make it so others see the empty slots on your character when they look at you // I chose not to do this but I added the "empty" to the equipment command to make it easier for you to see what equipment you are lacking.

Further down below :
Code:
if (found) { send_to_char(ch, "\r\n"); /* act() does capitalization. */ act("$n is using:", FALSE, i, 0, ch, TO_VICT); for (j = 0; j < NUM_WEARS; j++) - if (GET_EQ(i, j) && CAN_SEE_OBJ(ch, GET_EQ(i, j))) { - send_to_char(ch, "%s", wear_where[j]); - show_obj_to_char(GET_EQ(i, j), ch, SHOW_OBJ_SHORT); + if (GET_EQ(i, wear_order_index[j]) + && CAN_SEE_OBJ(ch, GET_EQ(i, wear_order_index[j]))) { + send_to_char(ch, "%s", wear_where[wear_order_index[j]]); + show_obj_to_char(GET_EQ(i, wear_order_index[j]), ch, SHOW_OBJ_SHORT);

And finally in your do_equipment function, replace it with the following :
Code:
ACMD(do_equipment) { int i; extern int wear_order_index[NUM_WEARS]; send_to_char(ch, "You are using:\r\n"); for (i = 0; i < NUM_WEARS; i++) { if (GET_EQ(ch, wear_order_index[i])) { if (CAN_SEE_OBJ(ch, GET_EQ(ch, wear_order_index[i]))) { send_to_char(ch, "%s", wear_where[wear_order_index[i]]); show_obj_to_char(GET_EQ(ch, wear_order_index[i]), ch, SHOW_OBJ_SHORT); } else { send_to_char(ch, "%s", wear_where[wear_order_index[i]]); send_to_char(ch, "Invisible Item\r\n"); } } else { send_to_char(ch, "%s", wear_where[wear_order_index[i]]); send_to_char(ch, "Empty\r\n"); } } }

Hope this helps. If you have any questions let me know.

-Halenbane

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

More
17 Aug 2012 00:56 #692 by Liko
Replied by Liko on topic Re: Updated do_equipment
Add this to constants.h under extern const char *equipment_types[];
Code:
extern const int wear_order_index[NUM_WEARS];

close constants.h and open act.informative.c and find void look_at_character
and remove the following
Code:
- extern int wear_order_index[NUM_WEARS];

then search for do_equipment and remove
Code:
- extern int wear_order_index[NUM_WEARS];

Close and compile.

Nice code halenbane. I Added the extern int wear_order_index to constants.h so you wouldn't have to define it in do_equipment and look_at_character. I hope this helps :)

Randian(0.0.0)
Owner/Developer
The following user(s) said Thank You: thomas

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

More
17 Aug 2012 01:12 #693 by Halenbane
Replied by Halenbane on topic Re: Updated do_equipment
Thanks Liko :D

I appreciate your modifications!

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

More
11 Apr 2024 02:18 #10382 by Fubar
Replied by Fubar on topic Updated do_equipment
Thank you!

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

Time to create page: 0.220 seconds