Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Updated do_equipment

Updated do_equipment 9 months 1 week ago #663

  • Halenbane
  • Halenbane's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 143
  • Thank you received: 7
  • Karma: 3
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.
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 administrator has disabled public write access.
The following user(s) said Thank You: zusuk

Re: Updated do_equipment 9 months 1 week ago #664

  • Halenbane
  • Halenbane's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 143
  • Thank you received: 7
  • Karma: 3
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.
The administrator has disabled public write access.

Re: Updated do_equipment 9 months 1 week ago #669

  • Halenbane
  • Halenbane's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 143
  • Thank you received: 7
  • Karma: 3
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>
/** 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
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
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 :
  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 :
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
The administrator has disabled public write access.

Re: Updated do_equipment 9 months 1 week ago #692

  • Liko
  • Liko's Avatar
  • OFFLINE
  • Gold Boarder
  • Posts: 238
  • Thank you received: 8
  • Karma: 1
Add this to constants.h under extern const char *equipment_types[];
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
 - extern int wear_order_index[NUM_WEARS];

then search for do_equipment and remove
- 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 :)
Green Lantern Universe - Owner/Programmer
Mud Url: Coming Soon
Mud Website: Coming Soon.
The administrator has disabled public write access.

Re: Updated do_equipment 9 months 1 week ago #693

  • Halenbane
  • Halenbane's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 143
  • Thank you received: 7
  • Karma: 3
Thanks Liko :D

I appreciate your modifications!
The administrator has disabled public write access.
  • Page:
  • 1
Time to create page: 0.102 seconds