Water Currents [by Chuck Reed]
Snippet Posted Wednesday, August 12th @ 11:38:51 PM, by George Greer in the Specials dept.
Added Jul 6, 1998. Click the link below to read it or download it.

From: Chuck Reed <creed@I-55.COM>
Subject: Water Currents/Proficiency System/

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.


<< Vwear command, cont. [by James A. Young] | Reply | View as text | Flattened | Who command update [by Nashak] >>

 


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.
 
 


Randomly Flowing
by BoxBoy (boruki@as-if.com) on Sunday, November 12th @ 01:47:59 AM
http://
Could you not have some kind of pulse check, or a new pulse that is called every so often?

Just a though
[ Reply to this comment ]