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.