Ejemplo n.º 1
0
void start_tag( void )
{
    DESCRIPTOR_DATA        *d,
                           *d_next;
    ROOM_INDEX_DATA        *loc;
    char                    buf[MAX_INPUT_LENGTH];
    int                     count = 0;

    tag_game.status = TAG_ISPLAY;
    tag_game.timer = 2 * tag_game.playing;

    for ( d = first_descriptor; d; d = d_next ) {
        d_next = d->next;

        if ( d->connected != CON_PLAYING || !d->character || IS_NPC( d->character ) )
            continue;

        if ( xIS_SET( d->character->act, PLR_WAITING ) ) {
            count++;
            loc = get_room_index( number_range( FTAG_MIN_VNUM, FTAG_MAX_VNUM ) );
            xREMOVE_BIT( d->character->act, PLR_FROZEN );
            xREMOVE_BIT( d->character->act, PLR_WAITING );
            xSET_BIT( d->character->act, PLR_PLAYING );
            char_from_room( d->character );
            char_to_room( d->character, loc );
            do_look( d->character, ( char * ) "auto" );
        }
    }
    sprintf( buf, "&R[&WEvento de congelación&R] &C¡El evento va a comenzar! hay &Y%d&C personas jugando.", count );
    tag_channel( NULL, buf );
}
Ejemplo n.º 2
0
void end_tag( void )
{
    DESCRIPTOR_DATA        *d,
                           *d_next;

    tag_game.status = TAG_OFF;
    tag_game.timer = -1;
    tag_game.next = number_range( 30, 50 );
    tag_game.playing = 0;

    for ( d = first_descriptor; d; d = d_next ) {
        d_next = d->next;

        if ( d->connected != CON_PLAYING || !d->character || !d->character->in_room )
            continue;
        if ( d->character->in_room->vnum < FTAG_MIN_VNUM - 1
             || d->character->in_room->vnum > FTAG_MAX_VNUM )
            continue;
        xREMOVE_BIT( d->character->act, PLR_RED );
        xREMOVE_BIT( d->character->act, PLR_BLUE );
        xREMOVE_BIT( d->character->act, PLR_FROZEN );
        xREMOVE_BIT( d->character->act, PLR_PLAYING );
        xREMOVE_BIT( d->character->act, PLR_WAITING );
        xREMOVE_BIT( d->character->act, PLR_PKSAFE );
        char_from_room( d->character );
        char_to_room( d->character, get_room_index( ROOM_VNUM_TEMPLE ) );
        do_look( d->character, ( char * ) "auto" );
        act( AT_TELL, "¡$n cae del cielo!\r\n", d->character, NULL, NULL, TO_ROOM );
        d->character->quest_curr += 10;
        d->character->quest_accum += 10;
        ch_printf( d->character,
                   "¡Ganas 10 puntos de gloria por participar en el evento de congelación!\r\n" );
    }
}
Ejemplo 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];
   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(  );
}
Ejemplo n.º 4
0
void do_tag( CHAR_DATA *ch, char *argument )
{
    CHAR_DATA              *victim;
    DESCRIPTOR_DATA        *d;
    char                    buf[MAX_STRING_LENGTH];
    char                    arg[MAX_INPUT_LENGTH];

    if ( IS_NPC( ch ) || ch->fighting != NULL ) {
        send_to_char( "Deja de pelear primero.\r\n", ch );
        return;
    }

    if ( tag_game.status == TAG_OFF ) {
        send_to_char( "No hay evento de congelación activo.\r\n", ch );
        return;
    }

    argument = one_argument( argument, arg );

    if ( !xIS_SET( ch->act, PLR_PLAYING ) ) {
        send_to_char( "No estás jugando ningún evento de congelación.\r\n", ch );
        return;
    }

    if ( !arg || arg[0] == '\0' ) {
        send_to_char( "¡congelar a quién?\r\n", ch );
        return;
    }

    if ( !( victim = get_char_room( ch, arg ) ) ) {
        send_to_char( "No está aquí.\r\n", ch );
        return;
    }

    if ( victim == ch ) {
        send_to_char( "Claro, claaaro...\r\n", ch );
        return;
    }

    if ( IS_NPC( victim ) ) {
        send_to_char( "Eso es un bicho.\r\n", ch );
        return;
    }

    if ( !xIS_SET( victim->act, PLR_PLAYING ) ) {
        send_to_char( "No está jugando el evento de congelación.\r\n", ch );
        return;
    }

    if ( xIS_SET( ch->act, PLR_FROZEN ) ) {
        send_to_char( "¡No puedes tocar, necesitas descongelarte!\r\n", ch );
        return;
    }

    act( AT_GREEN, "$n te toca.", ch, NULL, victim, TO_VICT );
    act( AT_GREEN, "$n toca a $N.", ch, NULL, victim, TO_NOTVICT );
    act( AT_GREEN, "Tocas a $N.", ch, NULL, victim, TO_CHAR );

    if ( ( xIS_SET( ch->act, PLR_RED ) && xIS_SET( victim->act, PLR_RED ) )
         || ( xIS_SET( ch->act, PLR_BLUE ) && xIS_SET( victim->act, PLR_BLUE ) ) ) {
        if ( xIS_SET( victim->act, PLR_FROZEN ) ) {
            xREMOVE_BIT( victim->act, PLR_FROZEN );
            act( AT_YELLOW, "¡Te descongelas!", ch, NULL, victim, TO_VICT );
            act( AT_YELLOW, "¡$N se descongela!", ch, NULL, victim, TO_ROOM );
            act( AT_YELLOW, "¡$N se descongela!", ch, NULL, victim, TO_CHAR );
            snprintf( buf, MIL, "[&WEvento&R] %s &Cacaba de  &Ydescongelar &Ra %s&C!!!\r\n", ch->name,
                      victim->name );
            arena_chan( buf );
        }
        else
            act( AT_YELLOW, "¡$N se congela!", ch, NULL, victim, TO_CHAR );
    }
    else {
        if ( xIS_SET( victim->act, PLR_FROZEN ) )
            act( AT_YELLOW, "¡$N ya está!", ch, NULL, victim, TO_CHAR );
        else {
            xSET_BIT( victim->act, PLR_FROZEN );
            act( AT_YELLOW, "¡Te han congelado!", ch, NULL, victim, TO_VICT );
            act( AT_YELLOW, "¡$N se congela!", ch, NULL, victim, TO_NOTVICT );
            act( AT_YELLOW, "¡$N ha sido congelado!", ch, NULL, victim, TO_CHAR );
            snprintf( buf, MIL, "[&WEvento&R] %s &Cacaba de &Ccongelar &Ra %s&C!!!\r\n", ch->name,
                      victim->name );
            arena_chan( buf );
            check_team_frozen( victim );
        }
    }
}
Ejemplo n.º 5
0
void do_ftag( CHAR_DATA *ch, char *argument )
{
    CHAR_DATA              *victim;
    ROOM_INDEX_DATA        *loc;
    char                    arg1[MAX_INPUT_LENGTH];
    char                    arg2[MAX_INPUT_LENGTH];
    char                    buf[MAX_STRING_LENGTH];

    if ( IS_NPC( ch ) )
        return;

    argument = one_argument( argument, arg1 );
    if ( !arg1 || arg1[0] == '\0' ) {
        send_to_char( "sintaxis: congelacion entrar\r\n", ch );
        send_to_char( "para comunicarte usa los canales rojo o azul.\r\n", ch );
        send_to_char( "para congelar o descongelar a alguien una vez haya empezado el evento usa el comando tocar.\r\n", ch );
        if ( IS_IMMORTAL( ch ) ) {
            send_to_char( "\r\nSintaxis: congelacion reset\r\n", ch );
            send_to_char( " congelacion next\r\n", ch );
            send_to_char( " congelacion start\r\n", ch );
            send_to_char( " congelacion rojo <player>\r\n", ch );
            send_to_char( " congelacion azul <player>\r\n", ch );
        }
        return;
    }

    if ( arena_prep || challenge || arena_underway ) {
        send_to_char( "Espera a que termine el evento actual de arena.\r\n", ch );
        return;
    }

    if ( !str_cmp( arg1, "entrar" ) ) {
        if ( tag_game.status != TAG_ISWAIT ) {
            send_to_char( "no hay ningún evento de congelación activo.\r\n", ch );
            return;
        }
        if ( xIS_SET( ch->act, PLR_PLAYING ) || xIS_SET( ch->act, PLR_WAITING ) ) {
            send_to_char( "ya estás jugando.\r\n", ch );
            return;
        }
        if ( !( loc = get_room_index( FTAG_WAIT_ROOM ) ) ) {
            send_to_char( "Espera a que termine el que ya hay empezado.\r\n", ch );
            return;
        }
        send_to_char( "Entras al evento de congelación.\r\n", ch );
        char_from_room( ch );
        char_to_room( ch, loc );
        tag_game.playing += 1;
        do_look( ch, ( char * ) "auto" );
        xSET_BIT( ch->act, PLR_WAITING );
        xREMOVE_BIT( ch->act, PLR_FROZEN );
        xSET_BIT( ch->act, PLR_PKSAFE );
        ch->quest_curr += 5;
        ch->quest_accum += 5;
        ch_printf( ch, "¡Ganas 5 puntos de gloria por participar en el evento!\r\n" );
        if ( ( fRed = !fRed ) ) {
            xSET_BIT( ch->act, PLR_RED );
            xREMOVE_BIT( ch->act, PLR_BLUE );
            send_to_char( "&W¡formas parte del equipo &RROJO&W!\r\n", ch );
            tag_channel( ch, "&R[&WEvento de congelación&R] &W¡$n forma parte del equipo &RROJO&W!" );
        }
        else {
            xSET_BIT( ch->act, PLR_BLUE );
            xREMOVE_BIT( ch->act, PLR_RED );
            send_to_char( "&W¡formas parte del equipo &CAZUL&W!\r\n", ch );
            tag_channel( ch, "&R[&WEvento de congelación&R] &W¡$n forma parte del equipo &CAZUL&W!" );
        }
        return;
    }

    if ( !str_cmp( arg1, "start" ) ) {
        if ( GET_MONEY( ch, CURR_SILVER ) < 10 ) {
            send_to_char
                ( "necesitas 10 monedas de plata para comenzar el evento.\r\n", ch );
            return;
        }
        if ( tag_game.status != TAG_OFF ) {
            send_to_char( "ya hay un juego en progreso.\r\n", ch );
            return;
        }
        GET_MONEY( ch, CURR_SILVER ) -= 10;

        tag_channel( NULL,
                     "&R[&WEvento&R] &C¡Ha comenzado un evento de congelación! ¡Teclea '&Wcongelacion entrar&C' para unirte!" );
        tag_game.status = TAG_ISWAIT;
        tag_game.timer = 3;
        tag_game.playing = 0;
        tag_game.next = -1;

        if ( !IS_IMMORTAL( ch ) ) {
            GET_MONEY( ch, CURR_SILVER ) -= 10;
            return;
        }
        return;
    }

    if ( !IS_IMMORTAL( ch ) ) {
        do_ftag( ch, ( char * ) "" );
        return;
    }

    if ( !str_cmp( arg1, "next" ) ) {
        tag_game.next = atoi( argument );
        ch_printf( ch, "El próximo juego comenzará en %d ticks.\r\n", tag_game.next );
        return;
    }

    if ( !str_cmp( arg1, "reset" ) ) {
        end_tag(  );
        send_to_char( "Jugadores reseteados.\r\n", ch );
        return;
    }

    argument = one_argument( argument, arg2 );
    if ( arg2[0] == '\0' || ( str_cmp( arg1, "rojo" ) && str_cmp( arg1, "azul" ) ) ) {
        send_to_char( "sintaxis: congelacion rojo  <player>\r\n", ch );
        send_to_char( "        Congelacion azul <player>\r\n", ch );
        return;
    }

    if ( tag_game.status == TAG_ISPLAY ) {
        send_to_char( "El juego ya ha comenzado.\r\n", ch );
        return;
    }

    if ( !( victim = get_char_world( ch, arg2 ) ) ) {
        send_to_char( "No está aquí.\r\n", ch );
        return;
    }

    if ( IS_NPC( victim ) ) {
        send_to_char( "No puede jugar.\r\n", ch );
        return;
    }

    if ( !( loc = get_room_index( FTAG_WAIT_ROOM ) ) ) {
        send_to_char( "El evento de congelación todavía no ha finalizado.\r\n", ch );
        return;
    }

    send_to_char( "Alguien te une al evento de congelación.\r\n", victim );
    char_from_room( victim );
    char_to_room( victim, loc );
    tag_game.playing += 1;
    do_look( victim, ( char * ) "auto" );

    xSET_BIT( victim->act, PLR_WAITING );
    xREMOVE_BIT( victim->act, PLR_FROZEN );
    xSET_BIT( victim->act, PLR_PKSAFE );

    if ( !str_cmp( arg1, "rojo" ) ) {
        xSET_BIT( victim->act, PLR_RED );
        xREMOVE_BIT( victim->act, PLR_BLUE );
        act( AT_WHITE, "¡Formas parte del equipo &RROJO&W!", ch, NULL, victim, TO_VICT );
        act( AT_WHITE, "¡$N forma parte del equipo &RROJO&W!", ch, NULL, victim, TO_NOTVICT );
        act( AT_WHITE, "¡$N forma parte del equipo &RROJO&W!", ch, NULL, victim, TO_CHAR );
    }
    else if ( !str_cmp( arg1, "blue" ) ) {
        xSET_BIT( victim->act, PLR_BLUE );
        xREMOVE_BIT( victim->act, PLR_RED );
        act( AT_WHITE, "¡Formas parte del equipo &Cazul&W!", ch, NULL, victim, TO_VICT );
        act( AT_WHITE, "¡$N forma parte del equipo &CAZUL&W!", ch, NULL, victim, TO_NOTVICT );
        act( AT_WHITE, "¡$N forma parte del equipo &CAZUL&W!", ch, NULL, victim, TO_CHAR );
    }
}
Ejemplo n.º 6
0
//Command Status: Installed, fairly well tested, near completetion.
void do_prayer( CHAR_DATA *ch, char *argument )
{
    char                    arg[MIL];
    AFFECT_DATA             af;

    one_argument( argument, arg );

    if ( IS_NPC( ch ) )
        return;

    if ( IS_AFFECTED( ch, AFF_CHARM ) )
        return;

    if ( !arg || arg[0] == '\0' ) {
        send_to_char( "Syntax: Prayer start\r\nSyntax: Prayer stop\r\n", ch );
        return;
    }

    if ( !IS_AWAKE( ch ) ) {
        send_to_char( "You cant pray while asleep.", ch );
        return;
    }

    if ( ch->position == POS_MEDITATING ) {
        send_to_char( "You are already meditating!\r\n", ch );
        return;
    }

    if ( IS_AFFECTED( ch, AFF_PRAYER ) && !str_cmp( arg, "start" ) ) {
        send_to_char( "But you're already praying.\r\n", ch );
        return;
    }

    if ( !str_cmp( arg, "start" ) ) {
        if ( can_use_skill( ch, number_percent(  ), gsn_prayer ) ) {
            if ( ch->fighting ) {
                send_to_char( "You cannot start a prayer during combat.\r\n", ch );
                return;
            }
            send_to_char( "You close your eyes and begin to pray.\r\n", ch );
            af.type = gsn_prayer;
            af.location = APPLY_NONE;
            af.modifier = 0;
            af.level = ch->level;
            af.duration = -1;
            af.bitvector = meb( AFF_PRAYER );
            affect_to_char( ch, &af );
            learn_from_success( ch, gsn_prayer );
        }
        else {
            send_to_char( "You can't seem to concentrate enough to properly pray.\r\n", ch );
            learn_from_failure( ch, gsn_prayer );
        }
        return;
    }

    if ( !str_cmp( arg, "stop" ) ) {
        if ( !IS_AFFECTED( ch, AFF_PRAYER ) ) {
            send_to_char( "But you're not praying.\r\n", ch );
            return;
        }

        if ( ch->position != POS_STANDING )
            set_position( ch, POS_STANDING );

        send_to_char( "You come to an end in your prayer and slowly open your eyes.\r\n", ch );
        affect_strip( ch, gsn_prayer );
        xREMOVE_BIT( ch->affected_by, AFF_PRAYER );
        return;
    }
}