Simple do_equipment sorting

  • Halenbane
  • Topic Author
  • Offline
  • Gold Boarder
  • Gold Boarder
More
1 year 11 months ago #6345 by Halenbane
Simple do_equipment sorting was created 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.

  • Halenbane
  • Topic Author
  • Offline
  • Gold Boarder
  • Gold Boarder
More
1 year 11 months ago #6352 by Halenbane
Replied by Halenbane on topic Simple do_equipment sorting
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
1 year 11 months ago #6353 by WhiskyTest
Replied by WhiskyTest on topic Simple do_equipment sorting
Based on your changes I would make a function out of your do_equipment code that you can call as need.. eg:
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:
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:
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.

  • Halenbane
  • Topic Author
  • Offline
  • Gold Boarder
  • Gold Boarder
More
1 year 11 months ago #6357 by Halenbane
Replied by Halenbane on topic Simple do_equipment sorting
Thanks for the assist. Got it :)

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

  • Halenbane
  • Topic Author
  • Offline
  • Gold Boarder
  • Gold Boarder
More
1 year 11 months ago #6359 by Halenbane
Replied by Halenbane on topic Simple do_equipment sorting
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
1 year 11 months ago #6360 by WhiskyTest
Replied by WhiskyTest on topic Simple do_equipment sorting
i think auto_equip() in objsave.c ?

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

  • Halenbane
  • Topic Author
  • Offline
  • Gold Boarder
  • Gold Boarder
More
1 year 11 months ago #6362 by Halenbane
Replied by Halenbane on topic Simple do_equipment sorting
I have the cases added there... maybe i'm missing something..

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

  • Halenbane
  • Topic Author
  • Offline
  • Gold Boarder
  • Gold Boarder
More
1 year 11 months ago #6363 by Halenbane
Replied by Halenbane on topic Simple do_equipment sorting
Ah I think I see, in my cases I had CAN_WEAR instead of !CAN_WEAR

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

  • Halenbane
  • Topic Author
  • Offline
  • Gold Boarder
  • Gold Boarder
More
1 year 11 months ago #6364 by Halenbane
Replied by Halenbane on topic Simple do_equipment sorting
Thanks, your advice made me look there again and more closely :) It is normally the smaller things hehe

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

Time to create page: 1.440 seconds