Welcome to the Builder Academy

Question Simple do_equipment sorting

More
05 Dec 2016 04:16 #6345 by Halenbane
This is a small variation on an old snippet. Instead of trying to change around all of your defines for re-sorting your equipment, just add a small array.

ACMD(do_equipment)
{
int i, k, found = 0;
const int eq_remap[NUM_WEARS] = { 0, 6, 3, 4, 5,
12, 10, 14, 15,
9, 1, 2, 13, 7, 8,
11, 16, 17 };

send_to_char(ch, "You have the following items equipped:\r\n");
for (k = 0; k < NUM_WEARS; k++) {
i = eq_remap[k];
if (GET_EQ(ch, i)) {
found = TRUE;
if (CAN_SEE_OBJ(ch, GET_EQ(ch, i))) {
send_to_char(ch, "%s", wear_where);
show_obj_to_char(GET_EQ(ch, i), ch, SHOW_OBJ_SHORT);
} else {
send_to_char(ch, "%s", wear_where);
send_to_char(ch, "Something.\r\n");
}
}
}
if (!found)
send_to_char(ch, " Nothing.\r\n");
}


(Yeah I know it's ugly) :P

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

More
05 Dec 2016 07:00 #6352 by Halenbane
I realized after I did this that when you look at another character it still shows in the old order. I tried to make a few minor changes as I did with do_equipment to look_at_char but was unsuccessful. Is there a simple way to do this based on my changes to do_equipment?

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

More
05 Dec 2016 21:43 #6353 by WhiskyTest
Based on your changes I would make a function out of your do_equipment code that you can call as need.. eg:
Code:
void show_equipment(struct char_data *ch, struct char_data *target) { int i, k, found = 0; const int eq_remap[NUM_WEARS] = { 0, 6, 3, 4, 5, 12, 10, 14, 15, 9, 1, 2, 13, 7, 8, 11, 16, 17 }; for (k = 0; k < NUM_WEARS; k++) { i = eq_remap[k]; if (GET_EQ(target, i)) { found = TRUE; if (CAN_SEE_OBJ(ch, GET_EQ(target, i))) { send_to_char(ch, "%s", wear_where[i]); show_obj_to_char(GET_EQ(target, i), ch, SHOW_OBJ_SHORT); } else { send_to_char(ch, "%s", wear_where[i]); send_to_char(ch, "Something.\r\n"); } } } if (!found) send_to_char(ch, " Nothing.\r\n"); }

Then update do_equipment to be this:
Code:
ACMD(do_equipment) { send_to_char(ch, "You have the following items equipped:\r\n"); show_equipment(ch, ch); }

And change look_at_char() to this:
Code:
static void look_at_char(struct char_data *i, struct char_data *ch) { int j, found; if (!ch->desc) return; if (i->player.description) send_to_char(ch, "%s", i->player.description); else act("You see nothing special about $m.", FALSE, i, 0, ch, TO_VICT); diag_char_to_char(i, ch); show_equipment(ch, i); if (ch != i && (IS_THIEF(ch) || GET_LEVEL(ch) >= LVL_IMMORT)) { act("\r\nYou attempt to peek at $s inventory:", FALSE, i, 0, ch, TO_VICT); list_obj_to_char(i->carrying, ch, SHOW_OBJ_SHORT, TRUE); } }

So anywhere you want a list of equipment, use that new show_equipment(ch, target) function
The following user(s) said Thank You: Halenbane

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

More
06 Dec 2016 01:01 #6357 by Halenbane
Thanks for the assist. Got it :)

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

More
06 Dec 2016 04:13 #6359 by Halenbane
For some reason the items aren't staying equipped after a reboot for the new wear slots I have added. Where is this handled? I thought maybe objsave.c but doesn't seem to.

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

More
06 Dec 2016 04:27 #6360 by WhiskyTest
i think auto_equip() in objsave.c ?

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

Time to create page: 0.205 seconds