From: JTRhone <ujtr@lady.cs.sunyit.edu>
Subject: Re: Sac code

Note: this is not my code, this is code that someone posted, and I feel
like fixing up a bit.  Also please note, that I use an extremely iterative
version with something like this.  If you are having trouble with some
code, it's better not to try to mimic some of the gurus on here with
squishing up 45 tasks in a small block of code.  It's better, if you are
not entirely comfortable with C, to split up the tasks into a readable
format so you actually understand what's going on :)  This is not a
flame, merely a suggestion.

ACMD(do_sac)
{
   struct obj_data *obj;
 
   one_argument(argument, arg);

   // note, I like to take care of no arg and wrong args up front, not
   // at the end of a function, lets get the wrongness out of the way :) 
   if (!*arg)
   {
     send_to_char("  << Sac what? message >> \n\r",ch);
     return;
   }

   // if it's not in the room, we ain't gonna sac it
   if (!(obj = get_obj_in_list_vis(ch, arg, world[ch->in_room].contents)))
   {
     send_to_char(" << That obj aint here messg >> \n\r",ch);
     return;
   }

   // nifty, got the object in the room, now check its flags
   if (!CAN_WEAR(obj, ITEM_WEAR_TAKE))
   {
     send_to_char(" << You can't sacrifice that! message >>\n\r",ch);
     return;
   }

   // seems as if everything checks out eh? ok now do it
   act("$n sacrifices $p.", FALSE, ch, obj, 0, TO_ROOM);
   act("You sacrifice $p to your god.\r\nYou have been rewarded by your deity.",
	FALSE, ch, obj, 0, TO_CHAR); 
   extract_obj(obj);
}

jtrhone aka vall RoA
