do_sacrifice function [by JTRhone]
Snippet Posted Wednesday, August 12th @ 11:26:30 PM, by George Greer in the Commands dept.
Added Jan 16, 1997. Click the link below to read it or download it.

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


<< dnslookup server code [by Rasmus Ronlev] | Reply | View as text | Threaded | Drunk Language Code [by Haddixx] >>

 


Related Links
  download
Related Articles
More by greerga
 
 

CircleMUD Snippets
 
Note: Not all of these snippets will work perfectly with your version of code, so be prepared to fix one or two bugs that may arise, and please let me know what you needed to do to fix it. Sending a corrected version is always welcome.
Finally, if you wish to use any of the snippets from this page, you are more than welcome, just mention the authors in your credits. If you wish to release any of these snippets to the public on another site, contact me FIRST.