[CODE] [LONG] Equipment occupying multiple spots

From: John Evans (evansj@HI-LINE.NET)
Date: 09/22/97


On Mon, 22 Sep 1997, Chris Jacobson wrote:

> Has anyone here imp'd bitvector EQ / EQ that can occupy multiple spots?
> For example, a Two-Handed-Sword that occupies both HOLD and WIELD... or a
> Full suit of platemail?  Perhaps cursed (unremoveable) handcuffs that
> occupy HOLD, WIELD, and LIGHT?  :-)

I did something similar, but it was only for the hold/wield/shield spots.
Not for the rest of the body. I would be interested in the others, if
you figure it out.

I'll try to explain it as best as I can. Here goes....

Stock code gives you 4 hands: light, held, shield, wield.
Despite this you can't 'hold' two things at the same time. I didn't like
this, so I changed it.

I removed the 'light' position.
I added a flag for objs called LIGHT_ITEM.
I recoded the checks for wether someone is using a light item. (It loops
        through all the EQ spots and checks for the flag or it the item
        is of type 'LIGHT' and held.)

I renamed hold and wield to hold_1 and wield_1.
I added hold_2, and wield_2 positions.

Of V0-V3 on weapons, V0 was unused (claimed to be to-dam bonus, but was,
        in reality, unused), so recoded that to be 0=one-handed, 1=two-handed.

I made a macro called ONE_HAND_FULL in utils.h. (See code below.)
I made a function called hands_full() in utils.c. (See code below.)

Of course, I had to re-code wear_message(), and perform_wear(). I'm going
to be a nice guy and stick the code for perform_wear() at the end. You
should be able to figure out wear_message() just fine. It's a simple
function.

That will give each player (and mobs) TWO HANDS and two hands only. They
can hold two items, wield two weapons, hold something and wield
something, wield something and wear a shield, wield a two-handed weapon,
or any combination like that.

Someone once told me: But wait! All light items are held (torches,
        lanterns, candles and the like.) That would be making the game
        more realistic at the same time as damaging its playability (and
        therefore, reducing its fun!)

My response was similar to: What about those hats that spelunkers wear
        with the flashlight built into them? How about a shield that
        is magically imbued to glow? Or a glowing sword? etc. etc. etc.


/* Code below */
#define TWO_HANDED(obj)         (GET_OBJ_TYPE((obj)) == ITEM_WEAPON && \
                                 GET_OBJ_VAL((obj), 0))

#define ONE_HAND_FULL(ch)       (GET_EQ(ch, WEAR_WIELD_1) || \
                                 GET_EQ(ch, WEAR_WIELD_2) || \
                                 GET_EQ(ch, WEAR_SHIELD)  ||  \
                                 GET_EQ(ch, WEAR_HOLD_1)  || \
                                 GET_EQ(ch, WEAR_HOLD_2))

int hands_full(struct char_data *ch)
{
  if ((GET_EQ(ch, WEAR_WIELD_1) && GET_EQ(ch, WEAR_HOLD_1 )) ||
      (GET_EQ(ch, WEAR_WIELD_1) && GET_EQ(ch, WEAR_HOLD_2 )) ||
      (GET_EQ(ch, WEAR_WIELD_1) && GET_EQ(ch, WEAR_SHIELD )) ||
      (GET_EQ(ch, WEAR_WIELD_1) && GET_EQ(ch, WEAR_WIELD_2)) ||
      (GET_EQ(ch, WEAR_HOLD_1 ) && GET_EQ(ch, WEAR_HOLD_2 )) ||
      (GET_EQ(ch, WEAR_HOLD_1 ) && GET_EQ(ch, WEAR_SHIELD )) ||
      (GET_EQ(ch, WEAR_HOLD_1 ) && GET_EQ(ch, WEAR_WIELD_2)) ||
      (GET_EQ(ch, WEAR_HOLD_2 ) && GET_EQ(ch, WEAR_SHIELD )) ||
      (GET_EQ(ch, WEAR_HOLD_2 ) && GET_EQ(ch, WEAR_WIELD_2)) ||
      (GET_EQ(ch, WEAR_SHIELD ) && GET_EQ(ch, WEAR_WIELD_2))) {
    return TRUE;
  }
  else if (GET_EQ(ch, WEAR_WIELD_1)) {
    if (TWO_HANDED(GET_EQ(ch, WEAR_WIELD_1))) {
      return TRUE;
    }
  }
  else if (GET_EQ(ch, WEAR_WIELD_2)) {
    if (TWO_HANDED(GET_EQ(ch, WEAR_WIELD_2))) {
      return TRUE;
    }
  }
  return FALSE;
}


void perform_wear(struct char_data * ch, struct obj_data * obj, int where)
{
  int wear_bitvectors[] = {
    ITEM_WEAR_FINGER, ITEM_WEAR_FINGER, ITEM_WEAR_NECK, ITEM_WEAR_NECK,
    ITEM_WEAR_BODY, ITEM_WEAR_HEAD, ITEM_WEAR_LEGS, ITEM_WEAR_FEET,
    ITEM_WEAR_HANDS, ITEM_WEAR_ARMS, ITEM_WEAR_SHIELD, ITEM_WEAR_ABOUT,
    ITEM_WEAR_WAIST, ITEM_WEAR_WRIST, ITEM_WEAR_WRIST, ITEM_WEAR_WIELD,
    ITEM_WEAR_WIELD, ITEM_WEAR_TAKE, ITEM_WEAR_TAKE};
  char *already_wearing[] = {
    "YOU SHOULD NEVER SEE THIS MESSAGE.  PLEASE REPORT.\r\n",
    "You're already wearing something on both of your ring fingers.\r\n",
    "YOU SHOULD NEVER SEE THIS MESSAGE.  PLEASE REPORT.\r\n",
    "You can't wear anything else around your neck.\r\n",
    "You're already wearing something on your body.\r\n",
    "You're already wearing something on your head.\r\n",
    "You're already wearing something on your legs.\r\n",
    "You're already wearing something on your feet.\r\n",
    "You're already wearing something on your hands.\r\n",
    "You're already wearing something on your arms.\r\n",
    "Your hands are already full.\r\n", /* SHIELD */
    "You're already wearing something about your body.\r\n",
    "You already have something around your waist.\r\n",
    "YOU SHOULD NEVER SEE THIS MESSAGE.  PLEASE REPORT.\r\n",
    "You're already wearing something around both of your wrists.\r\n",
    "Your hands are already full.\r\n", /* WIELD_1 */
    "Your hands are already full.\r\n", /* WIELD_2 */
    "Your hands are already full.\r\n", /* HOLD_1 */
    "Your hands are already full.\r\n"  /* HOLD_2 */
  };
  /* first, make sure that the wear position is valid. */
  if (!CAN_WEAR(obj, wear_bitvectors[where])) {
    act("You can't wear $p there.", FALSE, ch, obj, 0, TO_CHAR);
    return;
  }
  /* for neck, finger, wrist, wield and hold
     try pos 2 if pos 1 is already full */
  if ((where == WEAR_FINGER_R) ||
      (where == WEAR_NECK_1) ||
      (where == WEAR_HOLD_1) ||
      (where == WEAR_WIELD_1) ||
      (where == WEAR_WRIST_R))
    if (GET_EQ(ch, where))
      where++;

  /* Florentine check */
  if (((where == WEAR_WIELD_1) || (where == WEAR_WIELD_2)) &&
      !GET_SKILL(ch, SKILL_FLORENTINE) &&
      (GET_EQ(ch, WEAR_WIELD_1) || GET_EQ(ch, WEAR_WIELD_2))) {
    send_to_char("You aren't skilled enough to wield two "
                 "weapons at the same time.\r\n", ch);
    return;
  }

  /* Make sure the player is only using two hands at once. */
  if (TWO_HANDED(obj) && ONE_HAND_FULL(ch) &&
      ((where == WEAR_WIELD_1) || (where == WEAR_WIELD_2))) {
    send_to_char("You need both hands free to wield that.\r\n", ch);
    return;
  }
  else if ((where == WEAR_WIELD_1) || (where == WEAR_WIELD_2) ||
           (where == WEAR_SHIELD) || (where == WEAR_HOLD_1) ||
           (where == WEAR_HOLD_2)) {
    if (hands_full(ch)) {
      send_to_char(already_wearing[where], ch);
      return;
    }
  }
  else if (GET_EQ(ch, where)) {
    send_to_char(already_wearing[where], ch);
    return;
  }
  wear_message(ch, obj, where);
  obj_from_char(obj);
  equip_char(ch, obj, where);
}


John Evans

May the source be with you.


     +------------------------------------------------------------+
     | 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/08/00 PST