Exemplo n.º 1
0
/*
 * The main entry point for executing commands.
 * Can be recursively called from 'at', 'order', 'force'.
 */
void interpret( CHAR_DATA * ch, char *argument )
{
   char command[MAX_INPUT_LENGTH];
   char logline[MAX_INPUT_LENGTH];
   char logname[MAX_INPUT_LENGTH];
   char log_buf[MAX_STRING_LENGTH];
   char *origarg = argument;
   char *buf;
   TIMER *timer = NULL;
   CMDTYPE *cmd = NULL;
   int trust;
   int loglvl;
   bool found;
   struct timeval time_used;
   long tmptime;

   if( !ch )
   {
      bug( "%s: null ch!", __FUNCTION__ );
      return;
   }

   if( !ch->in_room )
   {
      bug( "%s: null in_room!", __FUNCTION__ );
      return;
   }

   found = FALSE;
   if( ch->substate == SUB_REPEATCMD )
   {
      DO_FUN *fun;

      if( ( fun = ch->last_cmd ) == NULL )
      {
         ch->substate = SUB_NONE;
         bug( "%s: SUB_REPEATCMD with NULL last_cmd", __FUNCTION__ );
         return;
      }
      else
      {
         int x;

         /*
          * yes... we lose out on the hashing speediness here...
          * but the only REPEATCMDS are wizcommands (currently)
          */
         for( x = 0; x < 126; x++ )
         {
            for( cmd = command_hash[x]; cmd; cmd = cmd->next )
               if( cmd->do_fun == fun )
               {
                  found = TRUE;
                  break;
               }
            if( found )
               break;
         }
         if( !found )
         {
            cmd = NULL;
            bug( "%s: SUB_REPEATCMD: last_cmd invalid", __FUNCTION__ );
            return;
         }
         snprintf( logline, MAX_INPUT_LENGTH, "(%s) %s", cmd->name, argument );
      }
   }

   if( !cmd )
   {
      /*
       * Changed the order of these ifchecks to prevent crashing. 
       */
      if( !argument || !strcmp( argument, "" ) )
      {
         bug( "%s: null argument!", __FUNCTION__ );
         return;
      }

      /*
       * Strip leading spaces.
       */
      while( isspace( *argument ) )
         argument++;
      if( argument[0] == '\0' )
         return;

      /*
       * xREMOVE_BIT( ch->affected_by, AFF_HIDE ); 
       */

      /*
       * Implement freeze command.
       */
      if( !IS_NPC( ch ) && xIS_SET( ch->act, PLR_FREEZE ) )
      {
         send_to_char( "You're totally frozen!\r\n", ch );
         return;
      }

      /*
       * Grab the command word.
       * Special parsing so ' can be a command,
       *   also no spaces needed after punctuation.
       */
      mudstrlcpy( logline, argument, MAX_INPUT_LENGTH );
      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 );

      /*
       * Look for command in command table.
       * Check for council powers and/or bestowments
       */
      trust = get_trust( ch );
      for( cmd = command_hash[LOWER( command[0] ) % 126]; cmd; cmd = cmd->next )
         if( !str_prefix( command, cmd->name )
             && ( cmd->level <= trust
                  || ( !IS_NPC( ch ) && ch->pcdata->council
                       && is_name( cmd->name, ch->pcdata->council->powers )
                       && cmd->level <= ( trust + MAX_CPD ) )
                  || ( !IS_NPC( ch ) && ch->pcdata->bestowments && ch->pcdata->bestowments[0] != '\0'
                       && is_name( cmd->name, ch->pcdata->bestowments ) && cmd->level <= ( trust + sysdata.bestow_dif ) ) ) )
         {
            found = TRUE;
            break;
         }

      /*
       * Turn off afk bit when any command performed.
       */
      if( !IS_NPC( ch ) && xIS_SET( ch->act, PLR_AFK ) && ( str_cmp( command, "AFK" ) ) )
      {
         xREMOVE_BIT( ch->act, PLR_AFK );
         act( AT_GREY, "$n is no longer afk.", ch, NULL, NULL, TO_CANSEE );
      }
   }

   /*
    * Log and snoop.
    */
   snprintf( lastplayercmd, ( MAX_INPUT_LENGTH * 2 ), "%s used %s", ch->name, logline );

   if( found && cmd->log == LOG_NEVER )
      mudstrlcpy( logline, "XXXXXXXX XXXXXXXX XXXXXXXX", MAX_INPUT_LENGTH );

   loglvl = found ? cmd->log : LOG_NORMAL;

   /*
    * Write input line to watch files if applicable
    */
   if( !IS_NPC( ch ) && ch->desc && valid_watch( logline ) )
   {
      if( found && IS_SET( cmd->flags, CMD_WATCH ) )
         write_watch_files( ch, cmd, logline );
      else if( IS_SET( ch->pcdata->flags, PCFLAG_WATCH ) )
         write_watch_files( ch, NULL, logline );
   }

   if( ( !IS_NPC( ch ) && xIS_SET( ch->act, PLR_LOG ) )
       || fLogAll || loglvl == LOG_BUILD || loglvl == LOG_HIGH || loglvl == LOG_ALWAYS )
   {
      /*
       * Added by Narn to show who is switched into a mob that executes
       * a logged command.  Check for descriptor in case force is used. 
       */
      if( ch->desc && ch->desc->original )
         snprintf( log_buf, MAX_STRING_LENGTH, "Log %s (%s): %s", ch->name, ch->desc->original->name, logline );
      else
         snprintf( log_buf, MAX_STRING_LENGTH, "Log %s: %s", ch->name, logline );

      /*
       * Make it so a 'log all' will send most output to the log
       * file only, and not spam the log channel to death   -Thoric
       */
      if( fLogAll && loglvl == LOG_NORMAL && ( IS_NPC( ch ) || !xIS_SET( ch->act, PLR_LOG ) ) )
         loglvl = LOG_ALL;

      log_string_plus( log_buf, loglvl, get_trust( ch ) );
   }

   if( ch->desc && ch->desc->snoop_by )
   {
      snprintf( logname, MAX_INPUT_LENGTH, "%s", ch->name );
      write_to_buffer( ch->desc->snoop_by, logname, 0 );
      write_to_buffer( ch->desc->snoop_by, "% ", 2 );
      write_to_buffer( ch->desc->snoop_by, logline, 0 );
      write_to_buffer( ch->desc->snoop_by, "\r\n", 2 );
   }

   /*
    * check for a timer delayed command (search, dig, detrap, etc) 
    */
   if( ( timer = get_timerptr( ch, TIMER_DO_FUN ) ) != NULL )
   {
      int tempsub;

      tempsub = ch->substate;
      ch->substate = SUB_TIMER_DO_ABORT;
      ( timer->do_fun ) ( ch, "" );
      if( char_died( ch ) )
         return;
      if( ch->substate != SUB_TIMER_CANT_ABORT )
      {
         ch->substate = tempsub;
         extract_timer( ch, timer );
      }
      else
      {
         ch->substate = tempsub;
         return;
      }
   }

   /*
    * Look for command in skill and socials table.
    */
   if( !found )
   {
      if( !check_skill( ch, command, argument ) && !check_ability( ch, command, argument )   // Racial Abilities Support - Kayle 7-8-07
          && !rprog_command_trigger( ch, origarg )
          && !mprog_command_trigger( ch, origarg )
          && !oprog_command_trigger( ch, origarg )
          && !check_social( ch, command, argument ) && !news_cmd_hook( ch, command, argument )
#ifdef IMC
          && !imc_command_hook( ch, command, argument )
#endif
          )
      {
         EXIT_DATA *pexit;

         /*
          * check for an auto-matic exit command 
          */
         if( ( pexit = find_door( ch, command, TRUE ) ) != NULL && IS_SET( pexit->exit_info, EX_xAUTO ) )
         {
            if( IS_SET( pexit->exit_info, EX_CLOSED )
                && ( !IS_AFFECTED( ch, AFF_PASS_DOOR ) || IS_SET( pexit->exit_info, EX_NOPASSDOOR ) ) )
            {
               if( !IS_SET( pexit->exit_info, EX_SECRET ) )
                  act( AT_PLAIN, "The $d is closed.", ch, NULL, pexit->keyword, TO_CHAR );
               else
                  send_to_char( "You cannot do that here.\r\n", ch );
               return;
            }
            if( check_pos( ch, POS_STANDING ) )
               move_char( ch, pexit, 0 );
            return;
         }
         send_to_char( "Huh?\r\n", ch );
      }
      return;
   }

   /*
    * Character not in position for command?
    */
   if( !check_pos( ch, cmd->position ) )
      return;

   /*
    * Berserk check for flee.. maybe add drunk to this?.. but too much
    * hardcoding is annoying.. -- Altrag
    * This wasn't catching wimpy --- Blod
    * if ( !str_cmp(cmd->name, "flee") &&
    * IS_AFFECTED(ch, AFF_BERSERK) )
    * {
    * send_to_char( "You aren't thinking very clearly..\r\n", ch);
    * return;
    * } 
    */

   /*
    * So we can check commands for things like Posses and Polymorph
    * *  But still keep the online editing ability.  -- Shaddai
    * *  Send back the message to print out, so we have the option
    * *  this function might be usefull elsewhere.  Also using the
    * *  send_to_char_color so we can colorize the strings if need be. --Shaddai
    */

   buf = check_cmd_flags( ch, cmd );

   if( buf[0] != '\0' )
   {
      send_to_char_color( buf, ch );
      return;
   }

   /*
    * Nuisance stuff -- Shaddai
    */

   if( !IS_NPC( ch ) && ch->pcdata->nuisance && ch->pcdata->nuisance->flags > 9
       && number_percent(  ) < ( ( ch->pcdata->nuisance->flags - 9 ) * 10 * ch->pcdata->nuisance->power ) )
   {
      send_to_char( "You can't seem to do that just now.\r\n", ch );
      return;
   }

   /*
    * Dispatch the command.
    */
   ch->prev_cmd = ch->last_cmd;  /* haus, for automapping */
   ch->last_cmd = cmd->do_fun;
   start_timer( &time_used );
   ( *cmd->do_fun ) ( ch, argument );
   end_timer( &time_used );
   /*
    * Update the record of how many times this command has been used (haus)
    */
   update_userec( &time_used, &cmd->userec );
   tmptime = UMIN( time_used.tv_sec, 19 ) * 1000000 + time_used.tv_usec;

   /*
    * laggy command notice: command took longer than 1.5 seconds 
    */
   if( tmptime > 1500000 )
   {
      log_printf_plus( LOG_NORMAL, get_trust( ch ), "[*****] LAG: %s: %s %s (R:%d S:%ld.%06ld)", ch->name,
                       cmd->name, ( cmd->log == LOG_NEVER ? "XXX" : argument ),
                       ch->in_room ? ch->in_room->vnum : 0, time_used.tv_sec, time_used.tv_usec );
      cmd->lag_count++; /* count the lag flags */
   }

   tail_chain(  );
}
Exemplo n.º 2
0
/*
 * The main entry point for executing commands.
 * Can be recursively called from 'at', 'order', 'force'.
 */
void interpret( CHAR_DATA *ch, char *argument )
{
    char command[MAX_INPUT_LENGTH];
    char logline[MAX_INPUT_LENGTH];
    int cmd;
    int trust;
    int position;
    bool found;

/* inserting wait check for mobiles here to get around order etc. */
    if ( ch->wait > 0 ) {
       send_to_char("You're still busy with the last thing you did!\n\r", ch );
       return;
    }

    /*
     * Strip leading spaces.
     */
    while ( isspace(*argument) )
	argument++;
    if ( argument[0] == '\0' )
	return;

    if ( IS_NPC( ch ) && ch->desc == NULL )
      interp_doer = 0;
    else
      interp_doer = UMIN( MAX_LEVEL, get_trust( ch ) );

    /*
     * Implement freeze command.
     */
    if ( !IS_NPC(ch) && IS_SET(ch->act, PLR_FREEZE) )
    {
	send_to_char( "You're totally frozen!\n\r", ch );
	interp_doer = 0;
	return;
    }

    /*
     * Grab the command word.
     * Special parsing so ' can be a command,
     *   also no spaces needed after punctuation.
     */
    strcpy( logline, argument );
    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 );
    }

    /*
     * Look for command in command table.
     */
    found = FALSE;
    trust = get_trust( ch );
    for ( cmd = 0; cmd_table[cmd].name[0] != '\0'; cmd++ )
    {
	if ( command[0] == cmd_table[cmd].name[0]
	&&   !str_prefix( command, cmd_table[cmd].name )
	&&   cmd_table[cmd].level <= trust )
	{
	    found = TRUE;
	    break;
	}
    }


    if (IS_SET(ch->act, PLR_AFK) 
	 && (cmd_table[cmd].level < AFK)) {    
        // quick & dirty hack to allow wizcmds without breaking afk
	send_to_char("You are gone, remember?\n\r", ch);
	interp_doer = 0;
	return;
    }

    /*
     * No hiding.
     */
    if ( cmd_table[cmd].motion == TRUE )
	REMOVE_BIT( ch->affected_by, AFF_HIDE );

    /*
     * Lose concentration.
     */
    if ( cmd_table[cmd].concentration == TRUE && ch->predelay_time > 0 )
    {
	send_to_char( "You stop concentrating...\n\r", ch );
	ch->predelay_time = 0;
	free_predelay( ch->predelay_info );
	ch->predelay_info = NULL;
    }

    /*
     * Log and snoop.
     */
    if ( cmd_table[cmd].log == LOG_NEVER )
	strcpy( logline, "XXXXXXXX XXXXXXXX XXXXXXXX" );

    if ( ( !IS_NPC(ch) && IS_SET(ch->act, PLR_LOG) )
    ||   fLogAll
    ||   cmd_table[cmd].log == LOG_ALWAYS )
    {
	sprintf( log_buf, "Log %s: %s", ch->name, logline );
	log_string( log_buf );
    }

    if ( ch->desc != NULL && ch->desc->snoop_by != NULL )
    {
	write_to_buffer( ch->desc->snoop_by, "% ",    2 );
	write_to_buffer( ch->desc->snoop_by, logline, 0 );
	write_to_buffer( ch->desc->snoop_by, "\n\r",  2 );
    }

    /*
     * Character not in position for command?
     */
    position = ch->position;
    if ( check_fighting( ch ) && ch->position == POS_STANDING )
	position = POS_FIGHTING;

    if ( found && position < cmd_table[cmd].position )
    {
	switch( position )
	{
	case POS_DEAD:
	    send_to_char( "Lie still; you are DEAD.\n\r", ch );
	    break;

	case POS_MORTAL:
	case POS_INCAP:
	    send_to_char( "You are hurt far too bad for that.\n\r", ch );
	    break;

	case POS_STUNNED:
	    send_to_char( "You are too stunned to do that.\n\r", ch );
	    break;

	case POS_SLEEPING:
	    send_to_char( "In your dreams, or what?\n\r", ch );
	    break;

	case POS_RESTING:
	    send_to_char( "Nah... You feel too relaxed...\n\r", ch);
	    break;

	case POS_FIGHTING:
	    send_to_char( "No way!  You are fighting for your life!\n\r", ch);
	    break;

	}
	interp_doer = 0;
	return;
    }

    if ( check_specials( ch, command,
	    ( found ? *cmd_table[cmd].do_fun : NULL ),
	    argument ) )
    {
        interp_doer = 0;
	return;
    }

    /*
     * Dispatch the command.
     */
    if ( found )
    {
	if ( cmd_table[cmd].delay_fun == NULL )
	    (*cmd_table[cmd].do_fun) ( ch, argument );
	else
	    (*cmd_table[cmd].delay_fun) ( ch, argument );
    }
    else
    {
	/*
	 * Look for command in socials table.
	 */
	if ( !check_social( ch, command, argument ) )
	    send_to_char( "Huh?\n\r", ch );
        interp_doer = 0;
	return;
    }

    interp_doer = 0;
    tail_chain( );
    return;
}
Exemplo n.º 3
0
/*
 * The main entry point for executing commands.
 * Can be recursively called from 'at', 'order', 'force'.
 */
void interpret (CHAR_DATA * ch, char *argument)
{
    char command[MAX_INPUT_LENGTH];
    char logline[MAX_INPUT_LENGTH];
    int cmd;
    int trust;
    bool found;

    /*
     * Strip leading spaces.
     */
    while (isspace (*argument))
        argument++;
    if (argument[0] == '\0')
        return;

    /*
     * No hiding.
     */
    REMOVE_BIT (ch->affected_by, AFF_HIDE);

    /*
     * Implement freeze command.
     */
    if (!IS_NPC (ch) && IS_SET (ch->act, PLR_FREEZE))
    {
        send_to_char ("You're totally frozen!\n\r", ch);
        return;
    }

    /*
     * Grab the command word.
     * Special parsing so ' can be a command,
     * also no spaces needed after punctuation.
     */
    strcpy (logline, argument);
    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);
    }

    /*
     * Look for command in command table.
     */
    found = FALSE;
    trust = get_trust (ch);
    for (cmd = 0; cmd_table[cmd].name[0] != '\0'; cmd++)
    {
        if (command[0] == cmd_table[cmd].name[0]
            && !str_prefix (command, cmd_table[cmd].name)
            && cmd_table[cmd].level <= trust)
        {
            found = TRUE;
            break;
        }
    }

    /*
     * Log and snoop.
     */
    smash_dollar(logline);
    
    if (cmd_table[cmd].log == LOG_NEVER)
        strcpy (logline, "");

	/* Replaced original block of code with fix from Edwin
	 * to prevent crashes due to dollar signs in logstrings.
	 * I threw in the above call to smash_dollar() just for
	 * the sake of overkill :) JR -- 10/15/00
	 */
    if ( ( !IS_NPC(ch) && IS_SET(ch->act, PLR_LOG) )
		||   fLogAll
		||   cmd_table[cmd].log == LOG_ALWAYS )
	{
    	char    s[2*MAX_INPUT_LENGTH],*ps;
    	int     i;

    	ps=s; 
    	sprintf( log_buf, "Log %s: %s", ch->name, logline );
    	/* Make sure that was is displayed is what is typed */
    	for (i=0;log_buf[i];i++)
    	{ 
			*ps++=log_buf[i];  
			if (log_buf[i]=='$')
	    		*ps++='$';
			if (log_buf[i]=='{')
	    		*ps++='{';
    	}
    	*ps=0;
    	wiznet(s,ch,NULL,WIZ_SECURE,0,get_trust(ch));
    	log_string( log_buf );
	}

    if (ch->desc != NULL && ch->desc->snoop_by != NULL)
    {
        write_to_buffer (ch->desc->snoop_by, "% ", 2);
        write_to_buffer (ch->desc->snoop_by, logline, 0);
        write_to_buffer (ch->desc->snoop_by, "\n\r", 2);
    }

    if (!found)
    {
        /*
         * Look for command in socials table.
         */
        if (!check_social (ch, command, argument)

           )
            send_to_char ("Huh?\n\r", ch);
        return;
    }

    /*
     * Character not in position for command?
     */
    if (ch->position < cmd_table[cmd].position)
    {
        switch (ch->position)
        {
            case POS_DEAD:
                send_to_char ("Lie still; you are DEAD.\n\r", ch);
                break;

            case POS_MORTAL:
            case POS_INCAP:
                send_to_char ("You are hurt far too bad for that.\n\r", ch);
                break;

            case POS_STUNNED:
                send_to_char ("You are too stunned to do that.\n\r", ch);
                break;

            case POS_SLEEPING:
                send_to_char ("In your dreams, or what?\n\r", ch);
                break;

            case POS_RESTING:
                send_to_char ("Nah... You feel too relaxed...\n\r", ch);
                break;

            case POS_SITTING:
                send_to_char ("Better stand up first.\n\r", ch);
                break;

            case POS_FIGHTING:
                send_to_char ("No way!  You are still fighting!\n\r", ch);
                break;

        }
        return;
    }

    /*
     * Dispatch the command.
     */
    (*cmd_table[cmd].do_fun) (ch, argument);

    tail_chain ();
    return;
}
Exemplo n.º 4
0
/*
 * The main entry point for executing commands.
 * Can be recursively called from 'at', 'order', 'force'.
 */
void interpret( CHAR_DATA *ch, char *argument )
{
    /* BUG with aliases: they can call themselves, which is
     * a Bad Thing.  When an alias calls interp, we'll add
     * a '~' char as the first char.  Checking for this will
     * tell us if we need to check aliases again. -S-
     */
   
    bool alias_call;
    char command[MAX_INPUT_LENGTH];
    char logline[MAX_INPUT_LENGTH];
    int cmd;
    int trust;
    bool found;

    alias_call = FALSE;
    
    if ( ch->position == POS_WRITING ) 
    /* if player is writing, pass argument straight to write_interpret */
    {
	write_interpret( ch, argument );
	return;
    }
    
    if ( ch->position == POS_BUILDING )
    {
	if (argument[0]==':')
	 argument++;
	else
	{
	 build_interpret(ch,argument);
	 return;
	}
    }    
	
    
    /*
     * Strip leading spaces.
     */
    while ( isspace(*argument) )
	argument++;
    if ( argument[0] == '\0' )
	return;


    if ( argument[0] == '~' )
    {
       argument++;
       alias_call = TRUE;
    }

    /*
     * No hiding.
     */
    REMOVE_BIT( ch->affected_by, AFF_HIDE );


    /*
     * Implement freeze command.
     */
    if ( !IS_NPC(ch) && IS_SET(ch->act, PLR_FREEZE) )
    {
        send_to_char( "@@a@@fYou're totally frozen!@@N\n\r", ch );
	return;
    }

    if ( ch->stunTimer > 0 )
    {
      send_to_char( "You are too@@aSTUNNED@@N to act!\n\r", ch );
      return;
    }

    /*
     * Grab the command word.
     * Special parsing so ' can be a command,
     *   also no spaces needed after punctuation.
     */
    strcpy( logline, argument );
    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 );
    }

    
    
    
    
    /*
     * Look for command in command table.
     */
    found = FALSE;
    trust = get_trust( ch );
    for ( cmd = 0; cmd_table[cmd].name[0] != '\0'; cmd++ )
    {
	
	/* Stephen Mod:  if level == CLAN_ONLY then for clan member only.
				  == BOSS_ONLY have to be leader.  
                                  == -3 vamp
                                  == -4 wolf  */
	
	if ( cmd_table[cmd].level == CLAN_ONLY 
	     &&  !IS_NPC( ch )
	     &&  ch->pcdata->clan == 0 )
	     continue;
	     
	if ( cmd_table[cmd].level == BOSS_ONLY
	     &&  !IS_NPC( ch )
	     &&  !IS_SET( ch->pcdata->pflags, PFLAG_CLAN_BOSS ) )
	     continue;
	
	if ( cmd_table[cmd].level == VAMP_ONLY
	     &&  !IS_NPC( ch )
	     &&  !IS_VAMP( ch )
             &&  ( ch->level != L_GOD )   )
	     continue;

	if ( cmd_table[cmd].level == WOLF_ONLY
	     &&  !IS_NPC( ch )
	     &&  !IS_WOLF( ch ) 
             &&  ( ch->level != L_GOD )  )
	     continue;
	
	
	
	if ( command[0] == cmd_table[cmd].name[0]
	&&   !str_prefix( command, cmd_table[cmd].name )
	&&   ( cmd_table[cmd].level <= trust
	      || MP_Commands( ch ) ) )
	{
	
	   
	
	    found = TRUE;
	    break;
	}
    
	
    
    
    
    }

    /*
     * Log and snoop.
     */
    if ( cmd_table[cmd].log == LOG_NEVER )
        strcpy( logline, "XXXXXXXX XXXXXXXX XXXXXXXX@@N");

    if ( ( !IS_NPC(ch) && IS_SET(ch->act, PLR_LOG) )
    ||   fLogAll
    ||   cmd_table[cmd].log == LOG_ALWAYS )
    {
        sprintf( log_buf, "Log %s: %s", ch->name, logline );
	log_string( log_buf );
        if ( IS_SET( ch->act, PLR_LOG ) )
          monitor_chan( log_buf, MONITOR_BAD );
        else
        if ( cmd_table[cmd].level > LEVEL_HERO )
           monitor_chan( log_buf, MONITOR_GEN_IMM );
        else
           monitor_chan( log_buf, MONITOR_GEN_MORT );
    
    }

    if ( ch->desc != NULL && ch->desc->snoop_by != NULL ) /* -S- Mod */
    {
       char snp[MAX_STRING_LENGTH];
       sprintf( snp, "[Snoop:%s] %s\n\r", ch->name, logline );
       write_to_buffer( ch->desc->snoop_by, snp, 0 );
    }

    if ( !found && !IS_NPC( ch ) && (!alias_call) )
    {
       int cnt;
       char foo[MAX_STRING_LENGTH];
       /* Check aliases -S- */
       
       for ( cnt = 0; cnt < MAX_ALIASES; cnt++ )
       {
	  if ( !str_cmp( ch->pcdata->alias_name[cnt], command )
          && str_cmp( ch->pcdata->alias_name[cnt], "<none>@@N") )
	  {
	     found = TRUE;
             sprintf( foo, "~%s %s", ch->pcdata->alias[cnt], argument );
	     interpret( ch, foo );
	     return;
	  }
       }  
    }
    
    
    if ( !found )
    {
	/*
	 * Look for command in socials table.
	 */
	if ( !check_social( ch, command, argument )
#ifdef IMC
	&&   !imc_command_hook( ch, command, argument )
#endif
      )
            send_to_char( "Huh?\n\r", ch );
	return;
    }

    /*
     * Character not in position for command?
     */
    if ( ch->position < cmd_table[cmd].position )
    {
	switch( ch->position )
	{
	case POS_DEAD:
            send_to_char( "Lie still; you are @@dDEAD@@N.\n\r", ch );
	    break;

	case POS_MORTAL:
	case POS_INCAP:
            send_to_char( "You are @@Rhurt@@N far too bad for that.\n\r", ch );
	    break;

	case POS_STUNNED:
            send_to_char( "You are too @@estunned@@N to do that.\n\r", ch );
	    break;

	case POS_SLEEPING:
            send_to_char( "Oh, go back to @@Wsleep!@@N\n\r", ch );
	    break;

	case POS_RESTING:
            send_to_char( "Naaaaaah... You feel too @@brelaxed@@N...\n\r", ch);
	    break;

	case POS_FIGHTING:
            send_to_char( "Not until you @@Rstop@@N fighting!\n\r", ch);
	    break;

	}
	return;
    }

    /*
     * Dispatch the command.
     */
    if (  !IS_NPC( ch )
       && (  ( ch->stance == STANCE_AMBUSH     )
          || ( ch->stance == STANCE_AC_BEST    )     )  
       && (  ( str_prefix( command, "kill"     ) )
          && ( str_prefix( command, "murder"   ) )
          && ( str_prefix( command, "backstab" ) )
          && ( str_prefix( command, "bs"       ) )
          && ( str_prefix( command, "whisper"  ) )
          && ( str_prefix( command, "stake"    ) )
          && ( str_prefix( command, "steal"    ) ) ) )


    {
      send_to_char( "You step out of the shadows.\n\r", ch );
      ch->stance = STANCE_WARRIOR;
      ch->stance_ac_mod = 0;
      ch->stance_dr_mod = 0;
      ch->stance_hr_mod = 0;
      act( "$n steps out of the Shadows!", ch, NULL, NULL, TO_ROOM );
    }
    comlog(ch, cmd, argument);
    (*cmd_table[cmd].do_fun) ( ch, argument );

    tail_chain( );
    return;
}
Exemplo n.º 5
0
/*
 * The main entry point for executing commands.
 * Can be recursively called from 'at', 'order', 'force'.
 */
void interpret( CHAR_DATA *ch, const char *argument0 )
{
  char command[MAX_INPUT_LENGTH];
  char logline[MAX_INPUT_LENGTH];
  int cmd;
  int trust;
  bool found;
  // Added by SinaC 2001, true if it's a mob program command
  bool found_mob;

  char *argument = new char [MAX_INPUT_LENGTH];
  strcpy(argument,argument0);
  for( char *s = argument; *s; s++ )
    *s = ( *s == '~' ? '-' : *s );

  /*
   * Strip leading spaces.
   */
  while ( isspace(*argument) )
    argument++;
  if ( argument[0] == '\0' )
    return;

  // Added by SinaC 2001
  if ( ch->in_room == NULL ) {
    send_to_char("You're not in a room ... How did you do that ?", ch );
    return;
  }


  /*
   * No hiding.
   */
  /* Oxtal> I still don't figure out what this does */
  // when we're Hiding, if we do something, Hide disappears  SinaC 2000
  if (IS_SET(ch->bstat(affected_by),AFF_HIDE)) {
    REMOVE_BIT( ch->bstat(affected_by), AFF_HIDE );
    recompute(ch);
  }

  /*
   * Implement freeze command.
   */
  if ( !IS_NPC(ch) && IS_SET(ch->act, PLR_FREEZE) ) {
    send_to_char( "You're totally frozen!\n\r", ch );
    return;
  }

  /*
   * Grab the command word.
   * Special parsing so ' can be a command,
   *   also no spaces needed after punctuation.
   */
  strcpy( logline, argument );

  sprintf(last_command,"%s(%d) in room[%d]: %s.",
	  ch->name,
	  IS_NPC(ch)?ch->pIndexData->vnum:-1,
	  ch->in_room?ch->in_room->vnum:-1,
	  argument );

  const char* argument2;
  if ( !isalpha(argument[0]) && !isdigit(argument[0])) {
    command[0] = argument[0];
    command[1] = '\0';
    argument++;
    while ( isspace(*argument) )
      argument++;

    argument2 = argument;
  }
  else {
    // Added by SinaC 2003, really crappy
    if ( !str_prefix( "jog", argument ) || !str_prefix( "jo", argument ) ) // for jog command
      argument2 = no_lower_one_argument( argument, command );
    else
      argument2 = one_argument( argument, command );
  }

  /*
   * Look for command in command table.
   */
  // Added by SinaC 2001
  found_mob = FALSE;
  found = FALSE;
  trust = get_trust( ch );
  //for ( cmd = 0; cmd_table[cmd].name[0] != '\0'; cmd++ ) {
  for ( cmd = 0; cmd < MAX_COMMANDS; cmd++ ) {
    if ( command[0] == cmd_table[cmd].name[0]
	 &&   !str_prefix( command, cmd_table[cmd].name )
	 &&   cmd_table[cmd].level <= trust ) {
      found = TRUE;
      break;
    }
  }

  /*
   * Log and snoop.
   */
  if ( found && cmd_table[cmd].log == LOG_NEVER )
    strcpy( logline, "" );

  if ( found && 
       ( ( !IS_NPC(ch) && IS_SET(ch->act, PLR_LOG) )
	 ||   fLogAll
	 ||   cmd_table[cmd].log == LOG_ALWAYS ) ) {
    // Modified by SinaC 2000
    sprintf( log_buf, "Log %s: %s (%s)", 
	     ch->name, 
	     logline, 
	     cmd_table[cmd].name
	     );
    wiznet(log_buf,ch,NULL,WIZ_SECURE,0,get_trust(ch));
    log_string( log_buf );
  }

  
  // Added by SinaC 2001, if player was afk, afk is removed.
  if ( IS_SET(ch->comm,COMM_AFK)
       // unless player is trying to remove afk with afk command
       && ( found && str_cmp(cmd_table[cmd].name,"afk") )
       && !IS_IMMORTAL(ch) ) {
    send_to_char("{GAFK{x mode removed.\n\r",ch);
    if (buf_string(ch->pcdata->buffer)[0] != '\0' )
      send_to_char("{rYou have received tells: Type {Y'replay'{r to see them.{x\n\r",ch);
    REMOVE_BIT(ch->comm,COMM_AFK);
  }


  if ( ch->desc != NULL && ch->desc->snoop_by != NULL ) {
    write_to_buffer( ch->desc->snoop_by, "% ",    2 );
    write_to_buffer( ch->desc->snoop_by, logline, 0 );
    write_to_buffer( ch->desc->snoop_by, "\n\r",  2 );
  }

  if ( !found ) {
    if( !check_social( ch, command, argument2 ) ) {
      // Modified by SinaC 2000
      //	    send_to_char( "Huh?\n\r", ch );
      random_error( ch );
      if ( SCRIPT_VERBOSE > 0 ) {
	if ( IS_NPC(ch) ) // Added by SinaC 2003
	  log_stringf("%s (%d) tries to use command: %s %s", 
		      NAME(ch), ch->pIndexData->vnum,
		      command, argument2 );
      }
    }
      
      return;
  }
  else {
    if ( check_disabled(&cmd_table[cmd]) ) {
      send_to_char( "This command has been temporarily disabled.\n\r", ch );
      return;
    }
    // Added by SinaC 2001 for player disabled commands
    if ( check_disabled_plr( ch, &cmd_table[cmd] ) ) {
      send_to_char( "The gods has removed your ability to use that command.\n\r", ch );
      return;
    }
  }

  /*
   * Character not in position for command?
   */
  if ( ch->position < cmd_table[cmd].position ) {
    switch( ch->position ) {
    case POS_DEAD:
      send_to_char( "Lie still; you are DEAD.\n\r", ch );
      break;

    case POS_MORTAL:
    case POS_INCAP:
      send_to_char( "You are hurt far too bad for that.\n\r", ch );
      break;

      // Added by SinaC 2003
    case POS_PARALYZED:
      send_to_char( "You are paralyzed, you can't move.\n\r", ch);
      break;

    case POS_STUNNED:
      send_to_char( "You are too stunned to do that.\n\r", ch );
      break;

    case POS_SLEEPING:
      send_to_char( "In your dreams, or what?\n\r", ch );
      break;

    case POS_RESTING:
      send_to_char( "Nah... You feel too relaxed...\n\r", ch);
      break;

    case POS_SITTING:
      send_to_char( "Better stand up first.\n\r",ch);
      break;

    case POS_FIGHTING:
      send_to_char( "No way!  You are still fighting!\n\r", ch);
      break;

    }
    return;
  }

  /*
   * Dispatch the command.
   */

  /* Oxtal -- Output the commands */
  /* SinaC --- We don't need that for the moment
   *if ( cmd_table[cmd].log != LOG_NEVER ) {
   * char *strtime;
   *
   * strtime = ctime( &current_time );
   * strtime[strlen(strtime)-1] = '\0';
   * fprintf( stdout, "%s %15s [%5d] %s %s\n",
   *  strtime,
   *  ch->name,
   *  ch->in_room ? ch->in_room->vnum : 0,
   *  cmd_table[cmd].name,
   *  argument);
   *}
   */ // removed by SinaC 2000
  
  // Modified by SinaC 2001 to detect memory leak
  char buf[MAX_STRING_LENGTH];

  // Modified by SinaC 2001
  if ( found )
    (*cmd_table[cmd].do_fun) ( ch, argument2 );

  return;
}
Exemplo n.º 6
0
/*
 * The main entry point for executing commands.
 * Can be recursively called from 'at', 'order', 'force'.
 */
void interpret(CHAR_DATA * ch, char *argument) {
    char command[MAX_INPUT_LENGTH];
    char logline[MAX_INPUT_LENGTH];
    int cmd;
    int trust;
    bool found;
    /*
     * Strip leading spaces.
     */
    while(isspace(*argument)) {
        argument++;
    }
    if(argument[0] == '\0') {
        return;
    }
    /*
     * No hiding.
     */
    REMOVE_BIT(ch->affected_by, AFF_HIDE);
    /*
     * Implement freeze command.
     */
    if(!IS_NPC(ch) && IS_SET(ch->act, PLR_FREEZE)) {
        send_to_char("You're totally frozen!\r\n", ch);
        return;
    }
    /*
     * Grab the command word.
     * Special parsing so ' can be a command,
     *   also no spaces needed after punctuation.
     */
    strcpy(logline, argument);
    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);
    }
    /*
     * Look for command in command table.
     */
    found = FALSE;
    trust = get_trust(ch);
    for(cmd = 0; cmd_table[cmd].name[0] != '\0'; cmd++) {
        if(command[0] == cmd_table[cmd].name[0]
                && !str_prefix(command, cmd_table[cmd].name) && (cmd_table[cmd].level <= trust || MP_Commands(ch))) {
            found = TRUE;
            break;
        }
    }
    /*
     * Log and snoop.
     */
    if(cmd_table[cmd].log == LOG_NEVER) {
        strcpy(logline, "XXXXXXXX XXXXXXXX XXXXXXXX");
    }
    if((!IS_NPC(ch) && IS_SET(ch->act, PLR_LOG)) || fLogAll || cmd_table[cmd].log == LOG_ALWAYS) {
        sprintf(log_buf, "Log %s: %s", ch->name, logline);
        log_string(log_buf);
    }
    if(ch->desc != NULL && ch->desc->snoop_by != NULL) {
        write_to_buffer(ch->desc->snoop_by, "% ", 2);
        write_to_buffer(ch->desc->snoop_by, logline, 0);
        write_to_buffer(ch->desc->snoop_by, "\r\n", 2);
    }
    if(!found) {
        /*
         * Look for command in socials table.
         */
        if(!check_social(ch, command, argument)
#ifdef IMC
                && !imc_command_hook(ch, command, argument)
#endif
          ) {
            send_to_char("Huh?\r\n", ch);
        }
        return;
    }
    /*
     * Character not in position for command?
     */
    if(ch->position < cmd_table[cmd].position) {
        switch(ch->position) {
        case POS_DEAD:
            send_to_char("Lie still; you are DEAD.\r\n", ch);
            break;
        case POS_MORTAL:
        case POS_INCAP:
            send_to_char("You are hurt far too bad for that.\r\n", ch);
            break;
        case POS_STUNNED:
            send_to_char("You are too stunned to do that.\r\n", ch);
            break;
        case POS_SLEEPING:
            send_to_char("In your dreams, or what?\r\n", ch);
            break;
        case POS_RESTING:
            send_to_char("Nah... You feel too relaxed...\r\n", ch);
            break;
        case POS_FIGHTING:
            send_to_char("No way!  You are still fighting!\r\n", ch);
            break;
        }
        return;
    }
    /*
     * Dispatch the command.
     */
    (*cmd_table[cmd].do_fun)(ch, argument);
    tail_chain();
    return;
}
Exemplo n.º 7
0
void
interpret (CHAR_DATA * ch, char *argy)
{
  char command[SML_LENGTH];
  char logline[SML_LENGTH];
  COMMAND *com = NULL;
  COMMAND *cm = NULL;
  bool found = FALSE;
  grep[0] = '\0';
  if (!argy || argy[0] == '\0')
    return;
  if (!ch || (!ch->desc && IS_PLAYER(ch)) || !ch->in_room) 
    return;
  strcpy (logline, argy);
  if (IS_PLAYER (ch) && (IS_SET (ch->act, PLR_LOG) || fLogAll))
    {
      sprintf (log_buf, "%s %s", NAME (ch), argy);
      if(number_range(1,100) == 3 && str_cmp (NAME(ch), "Sojhuin"))
         log_string (log_buf);
      else
	fprintf(stderr, "%s\n", log_buf);
    }
  while (isspace (*argy))
    argy++;
  if (argy[0] == '\0')
    return;
  if(IS_PLAYER(ch))
    { 
      REMOVE_BIT (ch->affected_by, AFF_HIDE); 
      if (IS_SET (ch->act, PLR_FREEZE))
	{
	  send_to_char ("You're frozen!  Please be patient and wait for a god to unfreeze you!\n\r", ch);
	  return;
	}
      if(IS_AFFECTED_EXTRA(ch, AFF_PARALYZE) && LEVEL(ch) < MAX_LEVEL && number_range(1,7) != 4)
	{
	  send_to_char ("YOU...CAN'T...MOVE...\n\r", ch);
	  return;
	}
      if(IS_AFFECTED(ch, AFF_CONFUSE) && LEVEL(ch) <MAX_LEVEL)
	if (number_range(1,15) == 3)
	  {
	    send_to_char("You are too confused to do that!\n\r", ch);
	    return;
	  }  
    }
  if (!isalpha (argy[0]) && !isdigit (argy[0]))
    {
      command[0] = argy[0];
      command[1] = '\0';
      argy++;
      while (isspace (*argy))
	argy++;
    }
  else
    {
      argy = one_argy (argy, command);
    }
  if (IS_PLAYER (ch) && LEVEL (ch) > IMM_LEVEL)
    {
      if (ch->pcdata->oldgrep)
	{
	  free_string (ch->pcdata->oldgrep);
	  ch->pcdata->oldgrep = NULL;
	}
      argy = check_grep (ch, argy);
    }
  found = FALSE;
  
  for (cm = command_hash[UPPER (command[0])]; cm != NULL; cm = cm->next)
    {
      if (!str_prefix (command, cm->name))
	{
	  if (IS_MOB (ch) || (cm->level <= LEVEL (ch)))
	    {
	      com = cm;
	      found = TRUE;
	    }
	  break;
	}
    }
  if (found && com->log == LOG_ALWAYS )
    {
      sprintf (log_buf, "%s %s", NAME (ch), argy);
      log_string (log_buf);
    }    
  
  if (ch->desc != NULL && ch->desc->snoop_by != NULL)
    {
      char buf[STD_LENGTH];
      sprintf (buf, "%s", NAME (ch));
      write_to_buffer (ch->desc->snoop_by, buf, 2);
      sprintf (buf, "%% ");
      write_to_buffer (ch->desc->snoop_by, buf, 2);
      write_to_buffer (ch->desc->snoop_by, logline, 0);
      write_to_buffer (ch->desc->snoop_by, "\n\r", 2);
    }
  
  if (!found && (!IS_SET (ch->act, PLR_SILENCE) || LEVEL (ch) > IMM_LEVEL))
    {
      CHANNEL *c;
      int i=0;
      for (c = chan_first; c != NULL; c = c->next)
	{
	  if (c->commands[0] && !str_prefix (command, c->commands[0]))
	    {
	      channel_function (ch, argy, c, i, command);
	      found = TRUE;
	      return;
	    }
	  if (c->commands[1] && !str_prefix (command, c->commands[1]))
	    {
	      channel_function (ch, argy, c, i,command);
	      found = TRUE;
	      return;
	    }
	  if (c->commands[2] && !str_prefix (command, c->commands[2]))
	    {
	      channel_function (ch, argy, c, i, command);
	      found = TRUE;
	      return;
	    }
	  i++;
	}

    }
if(!found)
{
      if (!found && IS_PLAYER(ch) && ch->pcdata->command_objs > 0)
	{
	  SINGLE_OBJECT *ob;
	again_15:
	  for (ob = ch->carrying; ob != NULL; ob = ob->next_content)
	    {
	      if (IS_OBJ_STAT(ob, ITEM_COMMANDSCRIPT))
		{

		  /* Haven't found the command... check objects the char is holding! */
		  SINGLE_TRIGGER *tr;
		  SCRIPT_INFO *s;

		  for (tr = trigger_list[TCOMMAND]; tr != NULL; tr = tr->next)
		    {

		      if (ob->pIndexData->vnum == tr->attached_to_obj)
			{

			  if (tr->running_info && !tr->interrupted)
			    continue;	/* Already running, interrupted, but script says not to allow interruptions. */
			  if (!tr->keywords || tr->keywords[0] == '\0' || !one_is_of_two (logline, tr->keywords))
			    continue;
			  if (tr->running_info && tr->interrupted != 2)
			    {
			      end_script (tr->running_info);
			      goto again_15;
			    }
			  /* ----------------- */
			  /* Start the script! */
			  /* ----------------- */
			  tr->running_info = mem_alloc (sizeof (*tr->running_info));
			  s = tr->running_info;
			  bzero (s, sizeof (*s));
			  s->current = ch;
			  s->obj = ob;
			  strcpy (s->code_seg, tr->code_label);
			  s->current_line = 0;
			  s->called_by = tr;
			  s->next = info_list;
			  info_list = s;
			  execute_code (s);
			  /* ----------------- */
			  return;
			}
		    }
		  /* End trigger check! */
		}
	    }
	}
/* Haven't found the command... check the command on mobs in the room! */
      if (!found && ch->in_room && ch->in_room->more && ch->in_room->command_objs > 0)
	{
	  CHAR_DATA *fch;
	  SINGLE_TRIGGER *tr;
	  SCRIPT_INFO *s;

	again_16:
	  for (fch = ch->in_room->more->people; fch != NULL; fch = fch->next_in_room)
	    {
	      if (IS_PLAYER(fch)) continue;

	      if (IS_SET(fch->pIndexData->act4, ACT4_COMMANDSCRIPT))
		{

		  for (tr = trigger_list[TCOMMAND]; tr != NULL; tr = tr->next)
		    {

		      if (IS_MOB (fch) && fch->pIndexData->vnum == tr->attached_to_mob)
			{

			  if (tr->running_info && !tr->interrupted)
			    continue;	/* Already running, interrupted, but script says not to allow interruptions. */
			  if (!tr->keywords || tr->keywords[0] == '\0' || !one_is_of_two (logline, tr->keywords))
			    continue;

			  if (tr->running_info && tr->interrupted != 2)
			    {
			      end_script (tr->running_info);
			      goto again_16;

			    }
			  /* ----------------- */
			  /* Start the script! */
			  /* ----------------- */
			  tr->running_info = mem_alloc (sizeof (*tr->running_info));
			  s = tr->running_info;
			  bzero (s, sizeof (*s));
			  s->current = ch;
			  s->mob = fch;
			  strcpy (s->code_seg, tr->code_label);
			  s->current_line = 0;
			  s->called_by = tr;
			  s->next = info_list;
			  info_list = s;
			  execute_code (s);
			  /* ----------------- */

			  return;
			}
		    }
		}
	    }
	}
      /* End trigger check! */
      
      /* Haven't found the command... check the command on objs in the room! */
      if (!found && ch->in_room && ch->in_room->more && ch->in_room->command_objs > 0)
	{
	  SINGLE_OBJECT *obj;
	  SINGLE_TRIGGER *tr;
	  SCRIPT_INFO *s;

	again_199:
	  for (obj = ch->in_room->more->contents; obj != NULL; obj = obj->next_content)
	    {
	      if (IS_OBJ_STAT(obj, ITEM_COMMANDSCRIPT)) 
		{
		  for (tr = trigger_list[TCOMMAND]; tr != NULL; tr = tr->next)
		    {
		      if (obj->pIndexData->vnum == tr->attached_to_obj)
			{
			  if (tr->running_info && !tr->interrupted)
			    continue;	/* Already running, interrupted, but script says not to allow interruptions. */
			  if (!tr->keywords || tr->keywords[0] == '\0' || !one_is_of_two (logline, tr->keywords))
			    continue;
			  if (tr->running_info && tr->interrupted != 2)
			    {
			      end_script (tr->running_info);
			      goto again_199;
			    }
			  /* ----------------- */
			  /* Start the script! */
			  /* ----------------- */
			  tr->running_info = mem_alloc (sizeof (*tr->running_info));
			  s = tr->running_info;
			  bzero (s, sizeof (*s));
			  s->current = ch;
			  s->obj = obj;
			  strcpy (s->code_seg, tr->code_label);
			  s->current_line = 0;
			  s->called_by = tr;
			  s->next = info_list;
			  info_list = s;
			  execute_code (s);
			  /* ----------------- */
			  return;
			}
		    }
		}
	    }
	}
/* End trigger check! */



/* Haven't found the command... check the command on the room! */
      if (!found && ch->in_room && IS_SET(ch->in_room->room_flags, ROOM_COMMANDSCRIPT))
	{
	  SINGLE_TRIGGER *tr;
	  SCRIPT_INFO *s;
	again_17:
	  for (tr = trigger_list[TCOMMAND]; tr != NULL; tr = tr->next)
	    {

	      if (ch->in_room->vnum == tr->attached_to_room)
		{

		  if (tr->running_info && !tr->interrupted)
		    continue;	/* Already running, interrupted, but script says not to allow interruptions. */
		  if (!tr->keywords || tr->keywords[0] == '\0' || !one_is_of_two (logline, tr->keywords))
		    continue;

		  if (tr->running_info && tr->interrupted != 2)
		    {
		      end_script (tr->running_info);
		      goto again_17;
		    }
		  /* ----------------- */
		  /* Start the script! */
		  /* ----------------- */
		  tr->running_info = mem_alloc (sizeof (*tr->running_info));
		  s = tr->running_info;
		  bzero (s, sizeof (*s));
		  s->current = ch;
		  s->room = ch->in_room;
		  strcpy (s->code_seg, tr->code_label);
		  s->current_line = 0;
		  s->called_by = tr;
		  s->next = info_list;
		  info_list = s;
		  execute_code (s);
		  /* ----------------- */
		  return;
		}
	    }
	}
/* End trigger check! */




      if (!check_social (ch, command, argy))
	if (number_range (1, 3) == 2)
	  {
	    send_to_char ("Huh?\n\r", ch);
	  }
	else if (number_range (1, 3) == 2)
	  {
	    send_to_char ("Unrecognized command.\n\r", ch);
	  }
	else
	  send_to_char ("What?  (Type HELP for help).\n\r", ch);
      return;
    }
/*
   * Character not in position for command?
 */
  if (ch->position < com->position)
    {
      sprintf(logline, "You cannot %s while you are %s.\n\r", command, position_name[ch->position]);
      send_to_char(logline, ch);
      return;
    }


  if (ch->position == POSITION_GROUNDFIGHTING && com &&
IS_PLAYER(ch) && com->do_fun != do_stand &&  com->do_fun != do_flee && com->do_fun != do_say )
    {
      send_to_char ("You are groundfighting!  You can only stand, flee, or say.\n\r", ch);
      return;
    }
  (*com->do_fun) (ch, argy);
  FORCE_LEVEL = IMM_LEVEL - 1;
  return;
}
Exemplo n.º 8
0
void 
dam_message (CHAR_DATA * ch, CHAR_DATA * victim, int dam, int dt, int p)
{
  char buf[256], buf1[256], buf2[256], buf3[256];
  char *tt;
  int ty;
  char hit_you_far[2000];
  char other_hit_far[2000];
  char subbuf[256], *bufptr;
  char attack[256];
  char bare[256];
  char punct;
  SINGLE_OBJECT *obj = NULL;
  you_hit[0] = '\0';
  bare[0] = '\0';
  attack[0] = '\0';
  other_hit[0] = '\0';
  hit_you[0] = '\0';
  hit_you_far[0] = '\0';
  other_hit_far[0] = '\0';
  nocolor = FALSE;
  if (FIGHTING (ch) != NULL && FIGHTING (ch)->position == POSITION_GROUNDFIGHTING && dam < 3)
    dam += 3;

  if(IS_MOB(ch) && ch->pIndexData->mobtype == MOB_DUMMY) return;
  general_hit (dam, ch, victim);

  punct = (dam <= 20) ? '.' : '!';
  if (IS_MOB (ch))
    {
      if (!ch->pIndexData->attackname || !str_cmp ("(null)", ch->pIndexData->attackname) || !str_cmp ("N/A", ch->pIndexData->attackname) || ch->pIndexData->attackname == NULL || ch->pIndexData->attackname[0] == ' ')
	{
	  if (!str_cmp (mob_type_attack (ch->pIndexData->mobtype), "punch") && FIGHTING (ch) != NULL &&
	      FIGHTING (ch)->position == POSITION_GROUNDFIGHTING)
	    strcpy (bare, "stomp");
	  else
	    strcpy (bare, mob_type_attack (ch->pIndexData->mobtype));
	}
      else
	{
	  if (!str_cmp (ch->pIndexData->attackname, "punch") && FIGHTING (ch) != NULL && FIGHTING (ch)->position == POSITION_GROUNDFIGHTING)
	    strcpy (bare, "stomp");
	  else
	    strcpy (bare, ch->pIndexData->attackname);
	}
    }
  else
    {
      if (FIGHTING (ch) != NULL && FIGHTING (ch)->position == POSITION_GROUNDFIGHTING)
	strcpy (bare, "stomp");
      else
	strcpy (bare, "punch");
      if (is_member(ch, GUILD_MONK))
      {
        int randhit = number_range(1,12);
        if (randhit == 1)
          strcpy (bare, "punch");
        else if (randhit == 2)
          strcpy (bare, "kick");
        else if (randhit == 3)
          strcpy (bare, "leg sweep");
        else if (randhit == 4)
          strcpy (bare, "elbow");
        else if (randhit == 5)
          strcpy (bare, "flipkick");
        else if (randhit == 6)
          strcpy (bare, "headbutt");
        else if (randhit == 7)
          strcpy (bare, "shinkick");
        else if (randhit == 8)
          strcpy (bare, "palm strike");
        else if (randhit == 9)
          strcpy (bare, "knee");
        else if (randhit == 10)
          strcpy (bare, "backfist");
        else if (randhit == 11)
          strcpy (bare, "uppercut");
        else if (randhit == 12)
          strcpy (bare, "quick jab");
      }
    }
  if (dt == gsn_circle)
    {
      if ((obj = get_item_held (ch, ITEM_WEAPON)) == NULL)
	return;
      if (dam > 0)
	{
	  sprintf (buf1, "\x1B[1;37m$n\x1B[0;37m sneaks up on $N... $n thrusts $p\x1B[0;37m into $S back!");
	  if (dam < 20)
	    sprintf (buf2, "You circle and thrust $p\x1B[0m into \x1B[1m$N\x1B[0m's back.");
	  if ((dam > 19) && (dam < 50))
	    sprintf (buf2, "You circle and thrust $p\x1B[0m into \x1B[1m$N\x1B[0m's back, causing cries of agony and pain.");
	  if ((dam > 49) && (dam < 100))
	    sprintf (buf2, "You circle your opponent.... $p\x1B[0m finds its mark in \x1B[1m$N\x1B[0m's back, causing $S body to spasm in pain.");
	  if ((dam > 99) && (dam < 200))
	    sprintf (buf2, "You circle your opponent.... $p\x1B[0m sinks deeply into \x1B[1m$N\x1B[0m's back, and blood runs over your hands.");
	  if ((dam > 199) && (dam < 275))
	    sprintf (buf2, "You circle your opponent.... $p\x1B[0m has struck a pressure point in \x1B[1m$N\x1B[0m's back!\n\rThat's gotta hurt!");
	  if ((dam > 274) && (dam < 350))
	    sprintf (buf2, "You circle around and twist $p\x1B[0m around several times in \x1B[1m$N\x1B[0m's back! That's gotta hurt!");
	  if (dam > 349)
	    sprintf(buf2, "Your $p\x1B[0m penetrates the base of \x1B[1m$N\x1B[0m's neck spraying spinal fluid onto your armor!");
	  sprintf (buf3, "\x1B[1m$n\x1B[0m is behind you before you know it, and slips $p\x1B[0m into your back.\n\r");
	}
    }
  else if (dt == gsn_backstab)
    {
      if ((obj = get_item_held (ch, ITEM_WEAPON)) == NULL)
	return;
      if (dam > 0)
	{ 
	  if (dam <100)  
	     sprintf (buf1, "\x1B[1;37m$n\x1B[0;37m thrusts $p\x1B[0;37m into \x1B[1;37m$N\x1B[0m's back.\n\r");
	  if ((dam > 99) && (dam < 200))
     	     sprintf (buf1, "Blood runs over \x1B[1;37m$n\x1B[0;37m hands as $p\x1B[0;37m\n\ris thrust into \x1B[1;37m$N\x1B[0m's back.\n\r");
	  if ((dam > 199) && (dam < 275))
     	     sprintf (buf1, "\x1B[1;37m$n\x1B[0;37m hits a pressure point as $p\x1B[0;37m\n\ris thrust into \x1B[1;37m$N\x1B[0m's back.\n\r");
	  if ((dam > 274) && (dam < 350))
     	     sprintf (buf1, "\x1B[1;37m$n\x1B[0;37m twists $p\x1B[0;37m around several times\n\rin \x1B[1;37m$N\x1B[0m's back.\n\r");
	  if ((dam > 349) && (dam < 425))
     	     sprintf (buf1, "Spinal fluid sprays as \x1B[1;37m$n\x1B[0;37m thrusts $p\x1B[0;37m\n\rinto \x1B[1;37m$N\x1B[0m's back. That had to HURT!\n\r");
	  if (dam > 424)
     	     sprintf (buf1, "\x1B[1;37m$n\x1B[0;37m uses $p\x1B[0;37m to punch a hole \n\rclean through \x1B[1;37m$N\x1B[0m's neck! Guts spray everywhere!\n\rThat REALLY had to HURT!");
	     
	  if (dam < 20)
	    sprintf (buf2, "You thrust $p\x1B[0m into \x1B[1m$N\x1B[0m's back.");
	  if ((dam > 19) && (dam < 50))
	    sprintf (buf2, "You thrust $p\x1B[0m into \x1B[1m$N\x1B[0m's back, causing cries of agony and pain.");
	  if ((dam > 49) && (dam < 100))
	    sprintf (buf2, "$p\x1B[0m finds its mark in \x1B[1m$N\x1B[0m's back, causing $s body to spasm.");
	  if ((dam > 99) && (dam < 200))
	    sprintf (buf2, "$p\x1B[0m sinks deeply into \x1B[1m$N\x1B[0m's back, and blood runs over your hands.");
	  if ((dam > 199) && (dam < 275))
	    sprintf (buf2, "$p\x1B[0m has struck a pressure point in \x1B[1m$N\x1B[0m's back! \n\rThat's gotta hurt!");
	  if ((dam > 274) && (dam < 350))
	    sprintf (buf2, "You twist $p\x1B[0m around several times in \x1B[1m$N\x1B[0m's back!\n\rThat's gotta hurt!");
	  if ((dam > 349) && (dam < 425))
	    sprintf(buf2, "Your $p\x1B[0m penetrates the base of \x1B[1m$N\x1B[0m's neck spraying spinal fluid onto your armor!\n\rThat REALLY had to HURT!");
	  if (dam > 424)
	    sprintf(buf2, "Your $p\x1B[0m punches a hole clean through \x1B[1m$N\x1B[0m's neck spraying guts all over you!\n\rThat REALLY had to HURT SEVERELY!");

	/* Added Damage Display for backstabee j. ellis (cyric) 2-6-01 */  

	if (dam <100)
	sprintf (buf3, "Before you know what's going on, \x1B[1m$n\x1B[0m\n\ris behind you, and thrusts $p\x1B[0m into your back.\n\r");
	if ((dam > 99) && (dam < 200))
 	   sprintf (buf3, "Blood runs all over \x1B[1m$n\x1B[0m's hands as $p\x1B[0m\n\ris thrust into your back.\n\r");
	if ((dam >199) && (dam < 275))
	   sprintf (buf3, "\x1B[1m$n\x1B[0m strikes a pressure point as $p\x1B[0m\n\ris thrust into your back.\n\r");
	if ((dam >274) && (dam < 350))
	   sprintf (buf3, "\x1B[1m$n\x1B[0m twists $p\x1B[0m around several times\n\rin your back! That HURT!");
	if ((dam >349) && (dam < 425))
	   sprintf (buf3, "\x1B[1m$n\x1B[0m penetrates the base of your neck with $p\x1B[0m\n\rYour spinal fluid sprays everywhere!\n\rThat REALLY HURT!");
	if (dam >424)
	   sprintf (buf3, "\x1B[1m$n\x1B[0m punches a hole clean through your neck with \n\r$p\x1B[0m, That REALLY HURT!");


/*	sprintf (buf3, "Before you know what's going on, \x1B[1m$n\x1B[0m\n\ris behind you, and thrusts $p\x1B[0m\n\r into your back.\n\r");*/
	}
      else
	{
	  sprintf (buf1, "\x1B[1m$n\x1B[0m fails to lunge $p\x1B[0m in \x1B[1m$N\x1B[0m's back.");
	  sprintf (buf2, "You fail to place $p\x1B[0m into \x1B[1m$N\x1B[0m's back.");
	  sprintf (buf3, "\x1B[1m$n\x1B[0m's \x1B[1;30mbackstab\x1B[0m just barely misses you.");
	}
    }

  else if (dt == gsn_fireshield)
  {
    if(dam > 0)
    {
      if( dam > 0 && dam <= 20 )
      {
        sprintf (buf1, "\x1B[1m$n\x1B[0m's shield of fire scorches \x1B[1m$N\x1B[0m!");
        sprintf (buf2, "Your shield of fire \x1B[1mburns\x1B[0m $N!");
        sprintf (buf3, "\x1B[1m$n\x1B[0m's \x1B[1;30mfire shield\x1B[0m chars you!");
      }
      else if( dam > 20 && dam <= 40)
      {
        sprintf (buf1, "\x1B[1m$n\x1B[0m's shield of fire engulfs \x1B[1m$N\x1B[0m!");
        sprintf (buf2, "Your shield of fire \x1B[1minflames\x1B[0m $N!");
        sprintf (buf3, "Ouch!! \x1B[1m$n\x1B[0m's \x1B[1;30mfire shield\x1B[0m engulfs you!");
      }
      else if( dam > 40 && dam < 100)
      {
        sprintf (buf1, "\x1B[1m$n\x1B[0m's shield of fire roasts \x1B[1m$N\x1B[0m!");
        sprintf (buf2, "Your shield of fire \x1B[1mROASTS\x1B[0m $N!");
        sprintf (buf3, "Oof!! \x1B[1m$n\x1B[0m's \x1B[1;30mfire shield\x1B[0m ROASTS you!");
      }
      else if( dam >= 100)
      {
        sprintf (buf1, "\x1B[1m$n\x1B[0m's shield of fire OBLITERATES \x1B[1m$N\x1B[0m!!");
        sprintf (buf2, "Your shield of fire \x1B[1mOBLITERATES\x1B[0m $N!");
        sprintf (buf3, "AARRGGHH!!! \x1B[1m$n\x1B[0m's \x1B[1;30mfire shield\x1B[0m OBLITERATES you!");
      }
      else
      {
        sprintf (buf1, "\x1B[1m$n\x1B[0m's shield of fire OBLITERATES \x1B[1m$N\x1B[0m!! [%d]",dam);
        sprintf (buf2, "Your shield of fire \x1B[1mOBLITERATES\x1B[0m $N! [%d]",dam);
        sprintf (buf3, "AARRGGHH!!! \x1B[1m$n\x1B[0m's \x1B[1;30mfire shield\x1B[0m OBLITERATES you! [%d]",dam);
      }
    }
    else
    {
      sprintf (buf1, "\x1B[1m$n\x1B[0m's fire shield fails to affect $p\x1B[0m in \x1B[1m$N\x1B[0m.");
      sprintf (buf2, "\x1B[1m$N\x1B[0m's attack goes right through your fire shield!.");
      sprintf (buf3, "\x1B[1m$n\x1B[0m's fire shield fails to protect him from your attack.");
    }
  }
  else if (dt == TYPE_HIT || dt < 0)
    {
      if (nocolor)
	{
	  sprintf (buf, "%s", other_hit);
	  sprintf (buf1, buf, bare);
	  sprintf (buf, "%s", you_hit);
	  sprintf (buf2, buf, bare);
	  sprintf (buf, "%s", hit_you);
	  sprintf (buf3, buf, bare);
	  if (RIDING (ch) != NULL)
	    {
	      send_to_char ("ACK! You are having problems punching while riding!\n\r", ch);
	    }
	}
      else
	{
	  sprintf (buf, "\x1B[1;37m%s\x1B[0m", other_hit);
	  sprintf (buf1, buf, bare);
	  sprintf (buf, "\x1B[1;35m%s\x1B[0m", you_hit);
	  sprintf (buf2, buf, bare);
	  sprintf (buf, "\x1B[1;36m%s\x1B[0m", hit_you);
	  sprintf (buf3, buf, bare);
	}
    }
  else
    {
      if (dt >= 0 && dt < SKILL_COUNT)
	{
	  SPELL_DATA *spell;
	  if ((spell = skill_lookup (NULL, dt)) == NULL)
	    return;
	  strcpy (attack, spell->noun_damage);
	}
      else if ((dt - TYPE_HIT) < MAX_ATTACK)
	{
	  strcpy (attack, attack_table[dt - TYPE_HIT].name);
	}
      else
	{
	  bug ("Dam_message: bad dt %d.", dt);
	  dt = TYPE_HIT;
	  strcpy (attack, attack_table[0].name);
	}
      if (nocolor)
	{
	  sprintf (buf, "%s", other_hit);
	  sprintf (buf1, buf, attack);
	  sprintf (buf, "%s", you_hit);
	  sprintf (buf2, buf, attack);
	  sprintf (buf, "%s", hit_you);
	  sprintf (buf3, buf, attack);
	}
      else
	{
	  sprintf (buf, "\x1B[1;37m%s\x1B[0m", other_hit);
	  sprintf (buf1, buf, attack);
	  sprintf (buf, "\x1B[1;35m%s\x1B[0m", you_hit);
	  sprintf (buf2, buf, attack);
	  sprintf (buf, "\x1B[1;36m%s\x1B[0m", hit_you);
	  sprintf (buf3, buf, attack);
	}
    }
  if ((bufptr = strstr (buf1, "hs ")))
    {
      sprintf (subbuf, bufptr + 2);
      *(bufptr + 1) = 'e';
      *(bufptr + 2) = 's';
      *(bufptr + 3) = '\0';
      strcat (buf1, subbuf);
    }
  if ((bufptr = strstr (buf2, "hs ")))
    {
      sprintf (subbuf, bufptr + 2);
      *(bufptr + 1) = 'e';
      *(bufptr + 2) = 's';
      *(bufptr + 3) = '\0';
      strcat (buf2, subbuf);
    }
  if ((bufptr = strstr (buf3, "hs ")))
    {
      sprintf (subbuf, bufptr + 2);
      *(bufptr + 1) = 'e';
      *(bufptr + 2) = 's';
      *(bufptr + 3) = '\0';
      strcat (buf3, subbuf);
    }
  if (dam <= 1)
    {
      act(buf1, ch, obj, victim, TO_NOTVICT_SPAM + 1000);
      act(buf2, ch, obj, victim, TO_CHAR_SPAM + 1000);
      act(buf3, ch, obj, victim, TO_VICT_SPAM + 1000);
    }
  else
    {
      act(buf1, ch, obj, victim, TO_NOTVICT + 1000);
      act(buf2, ch, obj, victim, TO_CHAR + 1000);
      act(buf3, ch, obj, victim, TO_VICT + 1000);
      if (victim->in_room != ch->in_room)
	{
	  ty = 0;
	  for (tt = buf1; *tt != '\0'; tt++)
	    {
	      if (*tt == '$')
		{
		  ty++;
		  tt++;
		  switch(*tt)
		    {
		    case 'N':
		      buf1[ty] = 'n';
		      break;
		    case 'n':
		      buf1[ty] = 'N';
		      break;
		    case 'S':
		      buf1[ty] = 's';
		      break;
		    case 's':
		      buf1[ty] = 'S';
		      break;
		    }
		}
	      ty++;
	    }
	  ty = 0;
	  for (tt = buf3; *tt != '\0'; tt++)
	    {
	      if (*tt == '$')
		{
		  ty++;
		  tt++;
		  switch(*tt)
		    {
		    case 'N':
		      buf3[ty] = 'n';
		      break;
		    case 'n':
		      buf3[ty] = 'N';
		      break;
		    case 'S':
		      buf3[ty] = 's';
		      break;
		    case 's':
		      buf3[ty] = 'S';
		      break;
		    }
		}
	      ty++;
	    }
	   act(buf1, victim, obj, ch, TO_NOTVICT + 1000);
	   act(buf3, victim, obj, ch, TO_CHAR + 1000);
	}
    }
  if (dt == gsn_backstab && dam > 0)
    check_social (victim, "wince", "");
  return;
}
Exemplo n.º 9
0
/*
 * The main entry point for executing commands.
 * Can be recursively called from 'at', 'order', 'force'.
 */
void interpret( CHAR_DATA * ch, const char *argument )
{
   char command[MAX_INPUT_LENGTH];
   char logline[MAX_INPUT_LENGTH];
   char logname[MAX_INPUT_LENGTH];
   TIMER *timer = NULL;
   CMDTYPE *cmd = NULL;
   int trust;
   int loglvl;
   bool found;
   struct timeval time_used;
   long tmptime;


   if( !ch )
   {
      bug( "interpret: null ch!", 0 );
      return;
   }

   found = FALSE;
   if( ch->substate == SUB_REPEATCMD )
   {
      DO_FUN *fun;

      if( ( fun = ch->last_cmd ) == NULL )
      {
         ch->substate = SUB_NONE;
         bug( "interpret: SUB_REPEATCMD with NULL last_cmd", 0 );
         return;
      }
      else
      {
         int x;

         /*
          * yes... we lose out on the hashing speediness here...
          * but the only REPEATCMDS are wizcommands (currently)
          */
         for( x = 0; x < 126; x++ )
         {
            for( cmd = command_hash[x]; cmd; cmd = cmd->next )
               if( cmd->do_fun == fun )
               {
                  found = TRUE;
                  break;
               }
            if( found )
               break;
         }
         if( !found )
         {
            cmd = NULL;
            bug( "interpret: SUB_REPEATCMD: last_cmd invalid", 0 );
            return;
         }
         sprintf( logline, "(%s) %s", cmd->name, argument );
      }
   }

   if( !cmd )
   {
      /*
       * Changed the order of these ifchecks to prevent crashing. 
       */
      if( !argument || !strcmp( argument, "" ) )
      {
         bug( "interpret: null argument!", 0 );
         return;
      }

      /*
       * Strip leading spaces.
       */
      while( isspace( *argument ) )
         argument++;
      if( argument[0] == '\0' )
         return;

      timer = get_timerptr( ch, TIMER_DO_FUN );

      /*
       * REMOVE_BIT( ch->affected_by, AFF_HIDE ); 
       */

      /*
       * Implement freeze command.
       */
      if( !IS_NPC( ch ) && IS_SET( ch->act, PLR_FREEZE ) )
      {
         send_to_char( "You're totally frozen!\r\n", ch );
         return;
      }

      /*
       * Grab the command word.
       * Special parsing so ' can be a command,
       *   also no spaces needed after punctuation.
       */
      strcpy( logline, argument );
      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 );

      /*
       * Look for command in command table.
       * Check for council powers and/or bestowments
       */
      trust = get_trust( ch );
      for( cmd = command_hash[LOWER( command[0] ) % 126]; cmd; cmd = cmd->next )
         if( !str_prefix( command, cmd->name )
             && ( cmd->level <= trust
                  || ( !IS_NPC( ch ) && ch->pcdata->bestowments && ch->pcdata->bestowments[0] != '\0'
                       && is_name( cmd->name, ch->pcdata->bestowments ) && cmd->level <= ( trust + 5 ) ) ) )
         {
            found = TRUE;
            break;
         }

      /*
       * Turn off afk bit when any command performed.
       */
      if( !IS_NPC( ch ) && IS_SET( ch->act, PLR_AFK ) && ( str_cmp( command, "AFK" ) ) )
      {
         REMOVE_BIT( ch->act, PLR_AFK );
         act( AT_GREY, "$n is no longer afk.", ch, NULL, NULL, TO_ROOM );
      }
   }

   /*
    * Log and snoop.
    */
   sprintf( lastplayercmd, "** %s: %s", ch->name, logline );

   if( found && cmd->log == LOG_NEVER )
      strcpy( logline, "XXXXXXXX XXXXXXXX XXXXXXXX" );

   loglvl = found ? cmd->log : LOG_NORMAL;

   if( ( !IS_NPC( ch ) && IS_SET( ch->act, PLR_LOG ) )
       || fLogAll || loglvl == LOG_BUILD || loglvl == LOG_HIGH || loglvl == LOG_ALWAYS )
   {
      /*
       * Added by Narn to show who is switched into a mob that executes
       * a logged command.  Check for descriptor in case force is used. 
       */
      if( ch->desc && ch->desc->original )
         sprintf( log_buf, "Log %s (%s): %s", ch->name, ch->desc->original->name, logline );
      else
         sprintf( log_buf, "Log %s: %s", ch->name, logline );

      /*
       * Make it so a 'log all' will send most output to the log
       * file only, and not spam the log channel to death   -Thoric
       */
      if( fLogAll && loglvl == LOG_NORMAL && ( IS_NPC( ch ) || !IS_SET( ch->act, PLR_LOG ) ) )
         loglvl = LOG_ALL;

      /*
       * This is handled in get_trust already 
       */
/*	if ( ch->desc && ch->desc->original )
	  log_string_plus( log_buf, loglvl,
		ch->desc->original->level );
	else*/
      log_string_plus( log_buf, loglvl, get_trust( ch ) );
   }

   if( ch->desc && ch->desc->snoop_by )
   {
      sprintf( logname, "%s", ch->name );
      write_to_buffer( ch->desc->snoop_by, logname, 0 );
      write_to_buffer( ch->desc->snoop_by, "% ", 2 );
      write_to_buffer( ch->desc->snoop_by, logline, 0 );
      write_to_buffer( ch->desc->snoop_by, "\r\n", 2 );
   }



   if( timer )
   {
      int tempsub;

      tempsub = ch->substate;
      ch->substate = SUB_TIMER_DO_ABORT;
      ( timer->do_fun ) ( ch, "" );
      if( char_died( ch ) )
         return;
      if( ch->substate != SUB_TIMER_CANT_ABORT )
      {
         ch->substate = tempsub;
         extract_timer( ch, timer );
      }
      else
      {
         ch->substate = tempsub;
         return;
      }
   }

   /*
    * Look for command in skill and socials table.
    */
   if( !found )
   {
      if( !check_skill( ch, command, argument ) && !check_social( ch, command, argument )
#ifdef IMC
          && !imc_command_hook( ch, command, argument )
#endif
          )
      {
         EXIT_DATA *pexit;

         /*
          * check for an auto-matic exit command 
          */
         if( ( pexit = find_door( ch, command, TRUE ) ) != NULL && IS_SET( pexit->exit_info, EX_xAUTO ) )
         {
            if( IS_SET( pexit->exit_info, EX_CLOSED )
                && ( !IS_AFFECTED( ch, AFF_PASS_DOOR ) || IS_SET( pexit->exit_info, EX_NOPASSDOOR ) ) )
            {
               if( !IS_SET( pexit->exit_info, EX_SECRET ) )
                  act( AT_PLAIN, "The $d is closed.", ch, NULL, pexit->keyword, TO_CHAR );
               else
                  send_to_char( "You cannot do that here.\r\n", ch );
               return;
            }
            move_char( ch, pexit, 0 );
            return;
         }
         send_to_char( "Huh?\r\n", ch );
      }
      return;
   }

   /*
    * Character not in position for command?
    */
   if( !check_pos( ch, cmd->position ) )
      return;

   /*
    * Berserk check for flee.. maybe add drunk to this?.. but too much
    * hardcoding is annoying.. -- Altrag 
    */
   if( !str_cmp( cmd->name, "flee" ) && IS_AFFECTED( ch, AFF_BERSERK ) )
   {
      send_to_char( "You aren't thinking very clearly..\r\n", ch );
      return;
   }

   /*
    * Dispatch the command.
    */
   ch->prev_cmd = ch->last_cmd;  /* haus, for automapping */
   ch->last_cmd = cmd->do_fun;
   start_timer( &time_used );
   ( *cmd->do_fun ) ( ch, argument );
   end_timer( &time_used );
   /*
    * Update the record of how many times this command has been used (haus)
    */
   update_userec( &time_used, &cmd->userec );
   tmptime = UMIN( time_used.tv_sec, 19 ) * 1000000 + time_used.tv_usec;

   /*
    * laggy command notice: command took longer than 1.5 seconds 
    */
   if( tmptime > 1500000 )
   {
      sprintf( log_buf, "[*****] LAG: %s: %s %s (R:%d S:%d.%06d)", ch->name,
               cmd->name, ( cmd->log == LOG_NEVER ? "XXX" : argument ),
               ch->in_room ? ch->in_room->vnum : 0, ( int )( time_used.tv_sec ), ( int )( time_used.tv_usec ) );
      log_string_plus( log_buf, LOG_NORMAL, get_trust( ch ) );
   }

   tail_chain(  );
}