Re: [CODE][LONG] Reposting of two hand code.

From: Chris Jacobson (fear@ATHENET.NET)
Date: 10/01/97


On 10/1/97 6:27 PM, John Evans (evansj@HI-LINE.NET) stated:

>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;
>}


Mailer code follows:

faster?  method

#define NUM_HAND_POSITIONS (5)

int hand_position[NUM_HAND_POSITIONS] = {
   WEAR_SHIELD,
   WEAR_WIELD_1,
   WEAR_WIELD_2,
   WEAR_HOLD_1,
   WEAR_HOLD_2
}

int hands_full(struct char_data *ch) {
   int counter, worn_count;
   struct obj_data * weapon;
   worn_count = 0;
   for (counter = 0; counter < NUM_HAND_POSITIONS; counter ++)
      if (GET_EQ(ch, hand_position[counter]))
         worn_count++;
   if (worn_count >= 2)
      return TRUE;
   if ((weapon = GET_EQ(ch, WEAR_WIELD_1)) || (weapon = GET_EQ(ch,
WEAR_WIELD_2)))
      if (TWO_HANDED(weapon))
         return TRUE;
   return FALSE;
}


- Chris Jacobson


     +------------------------------------------------------------+
     | 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