Re: [NEWBIE] Stacking

From: Starfleet MUD97 (mud@starfleetmud.org)
Date: 04/06/99


On Tue, 6 Apr 1999, Phillip A Ames wrote:

> OK, being called a crappy coder by someone earlier today,

Did I call you crappy?  Ermm ok, maybe I was gloating over how simple this
was.  Basically I just hacked around the object/mob stacking system to it
looked at the characters inventory list..and that was it.

Anyway sorry to call you crappy, shouldn't do it to a fellow coder, but
well it was meant in a friendly way...anyway this is my take on the
stacking of objs in a players inventory when looking at them.  Few thing
you will probably want to change like all my class declarations which
won't work anywhere but Starfleet MUD, and the makedrunk code, unless you
have drunk code in that accepts that.

Hope this is useful (and this is the first piece of code I have ever
released).

Colin Hassall - administrator/coder/Q - Starfleet MUD.

telnet: starfleetmud.org 4000

--------[ SNIP ]-------

void look_at_char(struct char_data * i, struct char_data * ch) {
   int j;
   struct obj_data *t, *obj_list[100];
   int num, counter, locate_list[100], found=FALSE, found2=FALSE;

   if(!ch->desc)
      return;

   if (i->player.description)
      send_to_char(makedrunk(i->player.description, ch), ch);
   else
      act("You see nothing special about $m.", FALSE, i, 0, ch, TO_VICT);

   diag_char_to_char(i, ch);

   found = FALSE;
   for (j = 0; !found && j < NUM_WEARS; j++)
      if (GET_EQ(i, j) && CAN_SEE_OBJ(ch, GET_EQ(i, j)))
         found = TRUE;

   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(makedrunk(where[j], ch), ch);
            show_obj_to_char(GET_EQ(i, j), ch, 1);
         }
   }

   if (ch != i && ((GET_CLASS_ACTUAL(ch) == CLASS_CIVILLIAN_THIEF) ||
      (GET_CLASS_ACTUAL(ch) == CLASS_E_ONLY_TAX_COLLECTOR) ||
      (GET_CLASS_ACTUAL(ch) == CLASS_ENGINEER_SCAVENGER) ||
      (GET_CLASS_ACTUAL(ch) == CLASS_E_ONLY_OBSIDIAN_ORDER) ||
      (GET_CLASS_ACTUAL(ch) == CLASS_SOLDIER_ESPIONAGE) ||
      (GET_CLASS_ACTUAL(ch) == CLASS_E_ONLY_TAL_SHIAR) ||
      (GET_CLASS_ACTUAL(ch) == CLASS_E_ONLY_FCA) ||
      (GET_CLASS_ACTUAL(ch) ==  CLASS_SCIENCES_ESPIONAGE) ||
      (GET_CLASS_GROUP(ch) == GROUP_MERCENARY) ||
      (GET_LEVEL(ch) >= LVL_JNR))) {

      found = FALSE;
      act("\r\nYou attempt to peek at $s inventory:", FALSE, i, 0, ch, TO_VICT);

      num = 0;
      for(t=i->carrying; t; t = t->next_content) {
         if(CAN_SEE_OBJ(ch, t)) {
            found2 = TRUE;
            if(num< 100) {
               found = FALSE;
               for(counter=0;(counter<num&& !found);counter++) {
                  if(GET_OBJ_VNUM(t) ==  GET_OBJ_VNUM(obj_list[counter])) {
                     locate_list[counter] += 1;
                     found=TRUE;
                  }
               }
               if(!found) {
                  obj_list[num] = t;
                  locate_list[num] = 1;
                  num++;
               }
            } else {
               show_obj_to_char(t, ch, 1);
            }
         }
      }

      if(num) {
         for(counter=0; counter<num; counter++) {
            if(locate_list[counter] > 1) {
               sprintf(buf, "%3dx ", locate_list[counter]);
               send_to_char(buf, ch);
               show_obj_to_char(obj_list[counter], ch, 1);
            } else {
               show_obj_to_char(obj_list[counter], ch, 1);
            }
         }
      }

      if (!found2)
         send_to_char("You can't see anything.\r\n", ch);
   }
}


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



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