[SNIPPET][OBJECT] do_equipment and look_at_char ordering

From: Richard Glover (magik@PYRAMID.NET)
Date: 06/23/98


Apologies in advance if someone has already posted this.  This is not an
official patch nor snippet since I really have no time for either.  If
someone cares to make a patch, feel free...just make sure to credit me for
the code, thanks.

Rick Glover

This code will allow you to see equipment in the order that you (the coder)
want it viewed, by equipment positions from head to foot or whatever you
decide without having to reorder your WEAR_x defines.


In constants.c, after the /* WEAR_x - for stat */ list, which ends with:

  "Held",
  "\n"
};

+/* Wear order to be viewed by players. RG 6/23/98 */
+const int wear_order_index[NUM_WEARS] = {
+  WEAR_HEAD,
+  WEAR_NECK_1,
+  WEAR_NECK_2,
+  WEAR_ABOUT,
+  WEAR_BODY,
+  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
+};

/* ITEM_x (ordinal object types) */
const char *item_types[] = {
  "UNDEFINED",


Then in act.informative.c, at the begging declarations of external
variables:

extern struct char_data *character_list;
extern struct obj_data *object_list;
extern struct str_app_type str_app[];

+extern const int wear_order_index[NUM_WEARS]; /* RG 6/23/98 */

extern char *credits;
extern char *news;
extern char *info;


In the function look_at_char:

void look_at_char(struct char_data * i, struct char_data * ch)
{
  int j, found;
  struct obj_data *tmp_obj;
+  extern int wear_order_index[NUM_WEARS];

  if (!ch->desc)
    return;


Further down:

  if (found) {
    act("\r\n$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(where[j], ch);
-        show_obj_to_char(GET_EQ(i, j), ch, 1);
+      if (GET_EQ(i, wear_order_index[j])
+          && CAN_SEE_OBJ(ch, GET_EQ(i, wear_order_index[j]))) {
+        send_to_char(where[wear_order_index[j]], ch);
+        show_obj_to_char(GET_EQ(i, wear_order_index[j]), ch, 1);
      }
  }


In do_equipment:

ACMD(do_equipment)
{
  int i, found = 0;
+  extern int wear_order_index[NUM_WEARS];

  send_to_char("You are using:\r\n", ch);
  for (i = 0; i < NUM_WEARS; i++) {
-    if (GET_EQ(ch, i)) {
-      if (CAN_SEE_OBJ(ch, GET_EQ(ch, i))) {
-        send_to_char(where[i], ch);
-        show_obj_to_char(GET_EQ(ch, i), ch, 1);
+    if (GET_EQ(ch, wear_order_index[i])) {
+      if (CAN_SEE_OBJ(ch, GET_EQ(ch, wear_order_index[i]))) {
+        send_to_char(where[wear_order_index[i]], ch);
+        show_obj_to_char(GET_EQ(ch, wear_order_index[i]), ch, 1);
        found = TRUE;
      } else {
-        send_to_char(where[i], ch);
+        send_to_char(where[wear_order_index[i]], ch);
        send_to_char("Something.\r\n", ch);
        found = TRUE;
      }

Enjoy,
Rick Glover aka Magik


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST