Hmmm, well, you could do it with a count variable and a char variable to
hold the short description or whatever you're comparing it to... the
only problem would be that however many different types of items are
being sacked/dropped/etc., it would have to run through the list that
many times so that it could combine all the different types of items...
this means that if someone were to go into a donation room or something,
with 500 different items in it, and type sac all or get all, the code
would run through the in_room->contents list 500 times and still build
500 different strings consisting of "(1) whatever item" in each one, and
you'd still have crashable output... you'd probably be better off just
using a BUFFER * variable and doing a page_to_char at the end of the
list... that way if one of the other people in the room didn't want to
see this person getting 500 items, when it hits the first "[Hit Return
to continue]" message, they can just type lskdjf and hit enter and it
kills the output there...

Richard Lindsey


-----Original Message-----
From: Hiddukel [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 31, 2004 9:04 AM
To: [email protected]
Subject: Combining objects

I have recently begun a project to try to clean up some of the
unnecessary
spam messages on my mud, most notably the ones that occur very often and
which have the most potential for flooding a character (and anyone else
in
the room with them) off of the mud.  One of my thoughts on this was to
combine objects in the output of things like "sacrifice all", "drop
all",
"put all in container" etc...  Here is some output of what I am trying
to
explain and what I would rather have it output:

Hiddukel gives you 300 gold coins for the sacrifice of (Relic) Ebony
Staff
Hiddukel gives you 330 gold coins for the sacrifice of Cloak of Holding
Hiddukel gives you 330 gold coins for the sacrifice of Ancient
Breastplate
Hiddukel gives you 330 gold coins for the sacrifice of Ring of Thieves
Hiddukel gives you 300 gold coins for the sacrifice of (Relic) Ebony
Staff
Hiddukel gives you 300 gold coins for the sacrifice of (Relic) Ebony
Staff
Hiddukel gives you 300 gold coins for the sacrifice of (Relic) Ebony
Staff
Hiddukel gives you 300 gold coins for the sacrifice of (Relic) Ebony
Staff
Hiddukel gives you 300 gold coins for the sacrifice of (Relic) Ebony
Staff
Hiddukel gives you 300 gold coins for the sacrifice of (Relic) Ebony
Staff
Hiddukel gives you 300 gold coins for the sacrifice of (Relic) Ebony
Staff
Hiddukel gives you 330 gold coins for the sacrifice of Cloak of Holding
Hiddukel gives you 330 gold coins for the sacrifice of Cloak of Holding
Hiddukel gives you 330 gold coins for the sacrifice of Cloak of Holding
Hiddukel gives you 330 gold coins for the sacrifice of Ancient
Breastplate

What I would like to see instead:
Hiddukel gives you 2400 gold coins for the sacrifice of (8) (Relic)
Ebony
Staff
Hiddukel gives you 1320 gold coins for the sacrifice of (4) Cloak of
Holding
Hiddukel gives you 660 gold coins for the sacrifice of (2) Ancient
Breastplate
Hiddukel gives you 330 gold coins for the sacrifice of Ring of Thieves

I am not sure how to achieve this, I am thinking a structure that
contains a
single instance of each unique object and the count of how many there
are
being sacrificed or dropped or whatever.  The code that creates the
topmost
output is as follows:

     if (!str_cmp("all", arg) || !str_prefix("all.", arg))
     {
          OBJ_DATA *obj_next;
          bool found = FALSE;

          for (obj = ch->in_room->contents; obj; obj = obj_next)
          {
               obj_next = obj->next_content;

               if (arg[3] != '\0' && !is_name(&arg[4],
obj->description))
                    continue;

               if ((!CAN_WEAR(obj, ITEM_TAKE) || CAN_WEAR(obj,
ITEM_NO_SAC))
                   || (obj->item_type == ITEM_CORPSE_PC &&
obj->contains))
                    continue;

               gold = UMAX(1, obj->level * 3);

               if (obj->item_type != ITEM_CORPSE_NPC && obj->item_type
!=
ITEM_CORPSE_PC)
                    gold = UMIN(gold, obj->cost);

               found = TRUE;
               sprintf(buf, "{W%s {Dgives you {y%d gold {Dcoins for the
sacrifice of %s{x\n\r", 
                       god_table[ch->god].name, gold, obj->short_descr);
               stc(buf, ch);
               act("{W$n {Dsacrifices {x$p{x {Dto {W$g{D.", ch, obj,
NULL,
TO_ROOM);
               ch->gold += gold;
               extract_obj(obj);

               if (IS_SET(ch->act, PLR_AUTOSPLIT))
               {
                    members = 0;
                    for (gch = ch->in_room->people; gch; gch =
gch->next_in_room)
                         if (is_same_group(ch, gch))
                              members++;

                    if (members > 1 && gold > 1)
                    {
                         sprintf(buf, "%d", gold);
                         do_split(ch, buf);
                    }    
               }
          }
          if (found)
               wiznet(ch, "$N sends up everything in that room as a
burnt
offering.", ch, obj, WIZ_SACCING);
          else
               stc("There is nothing sacrificable in this room.\n\r",
ch);

          return;
     }

Any help on this would be much appreciated.


-- 
ROM mailing list
[email protected]
http://www.rom.org/cgi-bin/mailman/listinfo/rom

Reply via email to