[Long] [Code] do_sac - update

From: Lord Kyu (shapeshifter@TKA.COM)
Date: 05/31/98


        I have noticed that the sacrifice on a lot of muds is nice, but sometimes
there are a few problems with the way it is coded, at least as far as I am
concerned. On some muds, you are able to sacrifice most items with the
code, not just corpses. It is okay that way, but not really what I was
looking for where as junk does a good enough job as far as that is
concerned. On other muds, I have noticed that when you sacrifice a corpse
everything in the corpse is junked. This is good for clearing space and not
having items around, but a lot of the players get upset when they have
autoloot on and have too many items in their inventory, and that awesome
item they killed that really hard mob for get junked along with the corpse.
Some muds fixed this by only allowing you to sacrifice empty corpses, but
then you run into a problem with invisible items.

        In short, the following sac code sacrifices only corpses, and anything
that may be in the corpse is moved into the room when the corpse is
removed. If you have any questions, comments, or suggestions about the code
or ways to improve it, please let me know. Thanks.

- Lord Kyu -
-----------------
In interpreter.c:
-----------------
  ACMD(do_return);
+ ACMD(do_sac);
  ACMD(do_save);

-----------------
In interpreter.c (further down)
-----------------
  { "'"         , POS_RESTING , do_say      , 0, 0 },
+ { "sacrifice" , POS_STANDING, do_sac      , 0, 0 },
  { "save"      , POS_SLEEPING, do_save     , 0, 0 },

-----------------
In act.item.c (end of file)
-----------------
+ ACMD(do_sac)
+ {
+   struct obj_data *j, *next_thing, *jj, *next_thing2;
+
+  one_argument(argument, arg);
+
+   if (!*arg)
+   {
+     send_to_char("Sacrifice what?\n\r",ch);
+     return;
+   }
+
+   if (!(j = get_obj_in_list_vis(ch, arg, world[ch->in_room].contents)) &&
+      (!(j = get_obj_in_list_vis(ch, arg, ch->carrying))))
+   {
+     send_to_char("It doesn't seem to be here.\n\r",ch);
+     return;
+   }
+
+   if (!((GET_OBJ_TYPE(j) == ITEM_CONTAINER) && (GET_OBJ_VAL(j, 3))))
+   {
+     send_to_char("You can't sacrifice that!\n\r",ch);
+     return;
+   }
+
+   act("$n sacrifices $p.", FALSE, ch, j, 0, TO_ROOM);
+   act("You sacrifice $p.", FALSE, ch, j, 0, TO_CHAR);
+
+   for (jj = j->contains; jj; jj = next_thing2) {
+     next_thing2 = jj->next_content;       /* Next in inventory */
+     obj_from_obj(jj);
+
+     if (j->carried_by)
+       obj_to_room(jj, j->carried_by->in_room);
+     else if (j->in_room != NOWHERE)
+       obj_to_room(jj, j->in_room);
+     else
+       assert(FALSE);
+   }
+   extract_obj(j);
+ }


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