Top Mud Sites Forum

Top Mud Sites Forum (http://www.topmudsites.com/forums/index.php)
-   MUD Coding (http://www.topmudsites.com/forums/forumdisplay.php?f=9)
-   -   Jog Command (http://www.topmudsites.com/forums/showthread.php?t=494)

Jaegar 04-05-2004 01:35 PM

I have just implemented an old jog command that I had found but am having a problem with it accepting some of the input.

The code is supposed to accept numbers before the direction and interpret it into the movement as well as accept an "o" for open then a direction to open.

Here is how the code should read the directions input

jog 12eos3ses4w

However the code will not accept the #'s and the open is not recognized either.

Here is the code from act_move.c

This is for a Rom2.4 mud.


 void do_jog( CHAR_DATA *ch, char *argument )
  {
     char buf[MAX_INPUT_LENGTH], arg[MAX_INPUT_LENGTH];
     char *p;
     bool dFound = FALSE;

     if (!ch->desc || *argument == '\0')
     {
        send_to_char("You run in place!\n\r", ch);
        return;
     }

     buf[0] = '\0';
     while (*argument != '\0')
     {
        argument = one_argument(argument,arg);
        strcat(buf,arg);
     }

     for ( p = buf + strlen(buf) -1; p >= buf; p-- )
     {
        if (!isdigit(*p))
        {
           switch( *p )
           {
              case 'n':
              case 's':
              case 'e':
              case 'w':
              case 'u':
              case 'd': dFound = TRUE;
                 break;
              case 'o':
                 break;
              default: send_to_char("Invalid direction!\n\r",ch);
                 return;
           }
        }
        else if (!dFound) *p = '\0';
     }

     if (!dFound)
     {
        send_to_char("No directions specified!\n\r",ch);
        return;
     }

     ch->desc->run_buf = str_dup( buf );
     ch->desc->run_head = ch->desc->run_buf;
     send_to_char("You start running...\n\r",ch);
     return;
  }


Any help would be appreciated.

Jaegar

erdos 04-06-2004 11:03 AM

Is that the ENTIRE snippet?  It looks to me like it goes to all the work of storing the dirs and all, but never does anything with them.  you sure there isnt something else you forgot to put in, in update.c or something?

If I were to code this from scratch in SMAUG i would use skill timers, see for example do_dig, do_search.  But I'm not sure if your codebase has that ability (it looks very similar to smaug so it might)

On an unrelated subject, these jog/jet/run commands are utterly stupid and never ever ever work well.  my recommendation is, leave it the heII out.

Davairus 04-07-2004 04:00 AM

You are going to need to have an update function in update.c, have it called every half-second or something, and just put a call to do_jog in it.  It'll look something like this.

[code]
void jog_update(void)
{
  CHAR_DATA *wch;
   for( wch = char_list; wch != NULL; wch = wch->next)
      if(IS_AWAKE(wch) && ch->position == POS_STANDING)
          do_jog(ch, ch->jogdata);
}
[/quote]

then in update_handler, make sure your update is getting called every 3 pulses or something.  maybe copy the aggr_update framework, thats close enough

I am not claiming thats going to work perfectly or anything, its just to get you started with something working, if you can find a better implementation go with that.

Zakmyrr 04-07-2004 07:33 PM

On the contrary, has implemented the run command very nicely.  An example of a run involving opening a door would look something like this:  run 3sen10ed; open n; ne2n

Perhaps the owner (Lasher) would help you out?


Dre 04-09-2004 04:41 AM

I can understand the o is giving problems as you break from the switch but you don't do anything with it.

I wonder what your specs really are, what do you want to achieve?

If you want them to set a path and then walk that path you have to call move_char a couple of times either here (which will make it really quick) or in update.c or something similar.

But seems to me you need to think up how you want to parse the buffer first. I'd read in the buffer for numbers till I find a char. Put any numbers you find in a buffer and then you get the char, you start moving the char. Then when you are done moving it X times then parse the next part etc.

When you get to the character open you read the next char for direction open the door and then continue parsing. Perhaps you also want to make a check if a door really opened or after finding one direction in error that the function will stop parsing as the rest of the path will most likely be void as well.

Greetings,


All times are GMT -4. The time now is 04:37 PM.

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright Top Mud Sites.com 2022