Exemplo n.º 1
0
void move_mob( D_MOBILE *dMob, const char *dir )
{
   D_EXIT *exit;
   
   if( !dMob || !dir )
      return;
      
   if( !dMob->room )
   {
      bug( "Error: Player (%s) without room. Sending to the void...", dMob->name );
      dMob->room = frbv( 1 );//default to the void if they don't have a room assigned to them
      if( !dMob->room ) //if the void doesn't even exist...
      {
         bug( "Error: Can Not Find The Void Room!" );
         return;
      }
   }
   
   exit = febn( dir, dMob->room->exits );
   if( !exit || !exit->dest )
   {
      if( exit && !exit->dest )
         bug( "Error: Exit with non-existent room in room %i.", dMob->room->vnum );
      text_to_mobile( dMob, "Alas, you can not go that way.\r\n" );
      return;
   }
   switch( exit->state )
   {
      case STATE_OPEN:
      case STATE_DOOR_OPEN:
      case STATE_DOOR_OPEN_BROKEN:
      {
         break;
      }
      case STATE_DOOR_CLOSED:
      case STATE_DOOR_CLOSED_BROKEN:
      case STATE_DOOR_CLOSED_LOCKED:
      {
         text_to_mobile( dMob, "The %s is closed.\r\n", exit->desc );
         return;
      }
      default:
      {
         bug( "Exit \'%s\' in invalid state in room %i.", exit->name, dMob->room->vnum );
         return;
      }
   }

   DetachFromList( dMob, dMob->room->mobiles );
   dMob->room = exit->dest;
   AttachToList( dMob, dMob->room->mobiles );
   
   cmd_look( dMob, "" );
   
   return;
}
Exemplo n.º 2
0
/*
 * Check_help()
 *
 */
bool check_help(D_MOBILE *dMob, char *helpfile)
{
  char buf[MAX_HELP_ENTRY + 80];
  char *entry, *hFile;

  hFile = capitalize(helpfile);
  if ((entry = read_help_entry(hFile)) == NULL)
    return FALSE;

  snprintf(buf, MAX_HELP_ENTRY + 80, "=== %s ===\n\r%s", hFile, entry);
  text_to_mobile(dMob, buf);

  return TRUE;
}
Exemplo n.º 3
0
void handle_cmd_input(D_SOCKET *dsock, char *argument)
{
  D_MOBILE *dMob;
  char command[MAX_BUFFER];
  bool found_cmd = FALSE;
  int i;

  if ((dMob = dsock->player) == NULL)
    return;
    /*
     * Strip leading spaces.
     */
    while (isspace(*argument))
        argument++;
    if (argument[0] == '\0')
        return;
    if (!isalpha(argument[0]) && !isdigit(argument[0])) {
        command[0] = argument[0];
        command[1] = '\0';
        argument++;
        while (isspace(*argument))
            argument++;
    } else {

  argument = one_argument(argument, command);
    }

  for (i = 0; tabCmd[i].cmd_name[0] != '\0' && !found_cmd; i++)
  {
    if (tabCmd[i].level > dMob->level) continue;

    if (is_prefix(command, tabCmd[i].cmd_name))
    {
      found_cmd = TRUE;
      (*tabCmd[i].cmd_funct)(dMob, argument);
    }
  }

  if( !found_cmd
#ifdef IMC
        &&   !imc_command_hook( dMob, command, argument )
#endif
     )
    text_to_mobile(dMob, "No such command.\n\r");
}
Exemplo n.º 4
0
Arquivo: move.c Projeto: pfchrono/cmud
void do_movement(D_MOBILE *dMob, int dir)
{
  D_MOBILE *xMob;
  ITERATOR *pIter;
  bool leftr = FALSE;

  pIter = AllocIterator(dmobile_list);
  while ((xMob = (D_MOBILE *) NextInList(pIter)) != NULL)
   {
     if (xMob == dMob) continue;
     if ((dMob->coordx != xMob->coordx) && (dMob->coordz != xMob->coordz) && (dMob->coordy != xMob->coordy))
	leftr = TRUE;
   }
  switch (dir)
  {
    case NORTH:
      /* North */
      stcf(dMob, "You leave for the north.\n\r");
      dMob->coordy++; 
      break; 
    case SOUTH: 
      /* South */
      stcf(dMob, "You leave for the south.\n\r");
      dMob->coordy--;
      break; 
    case EAST: 
      /* East */
      stcf(dMob, "You head eastward.\n\r");
      dMob->coordx++;
      break; 
    case WEST:
      /* West */
      stcf(dMob, "You head westward.\n\r");
      dMob->coordx--;
      break;
    case UP:
      /* Up */
      stcf(dMob, "You fly upwards.\n\r");
      dMob->coordz++;
      break;
    case DOWN:
      /* Down */
      stcf(dMob, "You you head downwards.\n\r");
      dMob->coordz--;
      break;
    case NORTHEAST:
      /* NorthEast */
      dMob->coordy++; 
      dMob->coordx++;
      break;
    case SOUTHEAST:
      /* SouthEast */
      dMob->coordy--; 
      dMob->coordx++;
      break;
    case SOUTHWEST:
      /* SouthWest */
      dMob->coordy--; 
      dMob->coordx--;
      break;
    case NORTHWEST:
      /* NorthWest */
      dMob->coordy++; 
      dMob->coordx--;
      break;
  } 

  if (dMob->coordx > HI_XLIMIT) 
  {
  dMob->coordx--; 
  text_to_mobile(dMob, "You can't move there!\n\r");
  return;
  }
  if (dMob->coordy > HI_YLIMIT) 
  {
  dMob->coordy--;
  text_to_mobile(dMob, "You can't move there!\n\r");
  return;
  }
  if (dMob->coordz > HI_ZLIMIT) 
  {
    dMob->coordz--;
    text_to_mobile(dMob, "You can't move there!\n\r");
  return;
  }
  if (dMob->coordx < LO_XLIMIT) 
  {
    dMob->coordx++;
    text_to_mobile(dMob, "You can't move there!\n\r");
  return;
  }
  if (dMob->coordy < LO_YLIMIT) 
  {
    dMob->coordy++;
    text_to_mobile(dMob, "You can't move there!\n\r");
  return;
  }
  if (dMob->coordz < LO_ZLIMIT) 
  {
    dMob->coordz++;
    text_to_mobile(dMob, "You can't move there!\n\r");
  return;
  }
  if (leftr)
     stcf(xMob, "%s has left the room.\n\r",dMob->name);

  cmd_look(dMob, NULL);
  return;
}