Re: [CODE] Water Currents/Proficiency System/

From: Chuck Reed (creed@I-55.COM)
Date: 05/02/98


>Now, I'll let my newbieness (to CircleMUD and this list) show.. I looked
>on the FTP site, but I couldn't find your water currents code.  Checked
>incoming..  Is there a special "snippets" site or something?  (Nevermind
>if it's in the FAQ for this list.. I'm going to scan that for
keyword:snippets
>next..

It's not your "newbieness" don't worry.  It's my lack of time.  I haven't
been able to put it in until now.  Here's the actuall HOW-TO SNIPPET for
the currents.  If anyone knows how to make this really random (and not just
when someone types in a command), please tell me because it's really
pissing me off :)

Oh yeah, another thing I'm going to be adding to this is another field in
the current_info struct for how many times the current will move you in a
certain direction.  But until then . . .

STEP 1
------
Add this somewhere in structs.h:

struct current_info {
   int room_vnum;
   int direction;
   int percent;
};


STEP 2
------
Add this somewhere in act.movement.c (this seemed appropriate):

/* Add new rooms above the { -1, -1, -1 } line.  That must always be last. */
struct current_info current[] = {
/*  Room  Direction Percent
  -------------------------  */
  { 3001, SOUTH,    34 },
  { -1, -1, -1 }
};


STEP 3
------
This checks the percentage to get swept away evertime somene in the room
types a command.
If you want to change that, it's no prob.

Add this in spec_procs.c:

SPECIAL(current_proc)
{

   extern const char *dirs[];
   extern struct current_info current[];
   int i, found, perm_num, new_room;

   found = FALSE;
   perm_num = 0;

   if(!cmd)
      return FALSE;


   for(i=0; current[i].room_vnum != -1;i++)
      if(ch->in_room == real_room(current[i].room_vnum)) {
         perm_num = i;
         found = TRUE;
         break;
       }

   if(found)
      if(number(0,100) < current[perm_num].percent) {
         sprintf(buf, "The strong current carries you %s!\r\n",
                   dirs[current[perm_num].direction]);
         send_to_char(buf, ch);
         sprintf(buf, "$n is taken %s by the rough current!",
                       dirs[current[perm_num].direction]);
         act(buf, FALSE, ch, 0, 0, TO_NOTVICT);

/* You can use your favorite way to record errors here. */

if(!EXIT(ch, current[perm_num].direction)) {
   send_to_char("Error in this room.  Please report this! ERROR 1\r\n", ch);
   return FALSE;
 }

if(EXIT(ch, current[perm_num].direction)->to_room == NOWHERE) {
   send_to_char("Error in this room.  Please report this! ERROR 2\r\n", ch);
   return FALSE;
  }

         /* Here we want to use char_from_room / char_to_room instead of a
do_simple_move
            because the current should take them no matter if they have a
boat, no
            movement points left, etc. */
         new_room = EXIT(ch, current[perm_num].direction)->to_room;
         char_from_room(ch);
         char_to_room(ch, new_room);
         act("$n is swept into the room by the rough current!", FALSE, ch,
0, 0, TO_NOTVICT);
       }
 return FALSE;
}



STEP 4
------
Add a prototype of the current_proc in spec_assign.c right below other
prototypes like so:

SPECIAL(current_proc);

STEP 5
------
Add all current rooms in spec_assign.c like so:

ASSIGNROOM(<vnum>, current_proc);

That Should be it.


"Jesus saves . . . . he passes to Moses.  Moses shoots, HE SCORES!"


     +------------------------------------------------------------+
     | 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