Exemplo n.º 1
0
void do_quest( CHAR_DATA *ch, char *argument )
{
   extern bool quest;
   extern bool auto_quest;
   extern CHAR_DATA *quest_mob;
   extern CHAR_DATA *quest_target;
   extern OBJ_DATA *quest_object;
   extern int quest_timer;
   extern int quest_wait;
  
   char buf[MAX_STRING_LENGTH];
   char new_long_desc[MAX_STRING_LENGTH];
   
   if ( argument[0] == '\0' )	/* Display status */
   {
      if ( !quest )
      {
         send_to_char( "There is no quest currently running.\n\r", ch );
         if ( auto_quest )
            send_to_char( "Quests are currently running automatically.\n\r", ch );
         if ( quest_wait > 0 )
         {
            sprintf( buf, "The next quest may occur in %d minutes.\n\r", (quest_wait * 2) );
            send_to_char( buf, ch );
         }
         return;
      }
      else
         send_to_char( "There is currently a quest running ", ch );
      
      if ( auto_quest )
         send_to_char( "(Automatically)", ch );
      
      send_to_char( "\n\rQuest Details:\n\r\n\r", ch );
      if ( quest_mob )
      {

        sprintf( buf, "The questing mobile is: {x%s{x [In Room %d]\n\r", 
           quest_mob->short_descr, quest_mob->in_room->vnum );
        send_to_char( buf, ch );
      }
      else
      {
        send_to_char( "The questing mobile is dead!\n\r", ch );
      }
      if ( quest_target )
      {
        sprintf( buf, "Target Mobile is: {x%s{x [In Room %d]\n\r",
           quest_target->short_descr, quest_target->in_room->vnum );
        send_to_char( buf, ch );
      }
      else
        send_to_char( "The target mobile is dead!\n\r", ch );

      sprintf( buf, "Target Object is: {x%s{x.\n\r", quest_object->short_descr );
      send_to_char( buf, ch );

      sprintf( buf, "Quest Object is worth: %d QP, %d XP, %d raise points and %d GP\n\r",
         quest_object->value[0], (ch->level < LVL_MOBXPCAP) ? quest_object->value[1] : 0,
         quest_object->value[4], quest_object->value[2]);
      send_to_char( buf, ch );

      
      sprintf( buf, "The Quest has been running for %d/30 minutes.\n\r", (quest_timer * 2) );
      send_to_char( buf, ch );
      
      return;
   }
   if ( !strcmp( argument, "stop" ) )
   {
     if ( quest )
     {
		 /*
       sprintf( buf, "@@NThe quest has been stopped by an {mImmortal@@N. Please speak up if you have already gotten the item.\n\r" );
       do_gecho( ch, buf );
	     */
       clear_quest();
     }
     return;
   }

   if ( !strcmp( argument, "start" ) )
   {
      DESCRIPTOR_DATA *d;
      int a = 80;
      int b = 0;
      sh_int player_count = 0, average_level= 0, total_levels = 0;
      
      /* generate a new quest! */
      if ( quest )
      {
         send_to_char( "There is already a quest running...\n\r", ch );
         return;
      }
      
      if ( auto_quest )
      {
         auto_quest = FALSE;
         send_to_char( "Automatic Quests now OFF.\n\r", ch );
      }
      
      /* Work out levels of currently playing folks */
      for ( d = descriptor_list; d; d = d->next )
      {
         if (  ( d->connected != CON_PLAYING )
            || ( IS_IMMORTAL( d->character )  ) )
            continue;
         player_count += 1;
         total_levels += d->character->level;
      }
      average_level = ( ( ( total_levels == 0 ) ? 30 : total_levels ) /
                        ( ( player_count == 0 ) ? 1 : player_count ) );
      a = average_level - 20;
      b = average_level + 20;

	  sprintf(buf, "Mob lLevel: %d hLevel: %d\n\r", a, b);
	  stc(buf,ch);
      quest_mob    = get_quest_giver(a, b);
      if ( quest_mob == NULL )
      {
         send_to_char( "Failed to find a quest mob\n\r", ch );
         return;
      }
      b = UMIN( b, 110 );
      a = UMAX( 20, a );

      quest_target = get_quest_target( a, b );
      if (  ( quest_target == NULL )
         || ( quest_target == quest_mob )  )
      {
         send_to_char( "Failed to find a quest target\n\r", ch );
         return;
      }
      quest_object = load_quest_object( quest_target );
      if ( quest_object == NULL )
      {
         send_to_char( "An invalid quest object was encountered.  Check log files.\n\r", ch );
         quest = FALSE;
         return;
      }
      /* Set values on quest item for Qp, Pracs, Exp, Gold */
      quest_object->value[0] = UMAX( 1, ( quest_target->level / 3) );
      quest_object->value[1] = number_range(1, 60);
      quest_object->value[2] = ( quest_target->level * 100 );
      quest_object->value[4] = 2;

      if ( number_percent() < 10 )
      {
         quest_object->value[0] += 2;
         quest_object->value[1] += 3;
         quest_object->value[2] *= 2;
         quest_object->value[4] *= 3;
      }
      
      quest_timer = 0;
      quest = TRUE;
      new_long_desc[0] = '\0';
      if ( quest_mob->pIndexData->long_descr_orig != NULL )
        free_string( quest_mob->pIndexData->long_descr_orig );
      quest_mob->pIndexData->long_descr_orig = str_dup(quest_mob->long_descr );
      sprintf( new_long_desc, "%s {xsays have you found %s?\n\r",
         quest_mob->pIndexData->short_descr, quest_object->short_descr );
      if ( quest_mob->long_descr != NULL )      
        free_string( quest_mob->long_descr );    
      quest_mob->long_descr = str_dup( new_long_desc );
      SET_BIT( quest_mob->act, PLR_NOSUMMON );
      REMOVE_BIT(quest_mob->act, ACT_AGGRESSIVE);
     /* T!!! */
      new_long_desc[0] = '\0';
      if ( quest_target->pIndexData->long_descr_orig != NULL )
        free_string( quest_target->pIndexData->long_descr_orig );
      quest_target->pIndexData->long_descr_orig = str_dup( quest_target->long_descr );
      sprintf( new_long_desc, "%s {xsays I stole the {x%s{x!\n\r",
        quest_target->pIndexData->short_descr, quest_object->short_descr );
      if ( quest_target->long_descr != NULL )     
        free_string( quest_target->long_descr );   
      quest_target->long_descr = str_dup( new_long_desc );

      SET_BIT( quest_target->act, PLR_NOSUMMON );

      send_to_char( "QUEST STARTED!\n\r\n\r", ch );
            
      sprintf( buf, "The questing mobile is: {x%s{x [In Room %d]\n\r", 
         quest_mob->pIndexData->short_descr, quest_mob->in_room->vnum );
      send_to_char( buf, ch );
      
      sprintf( buf, "Target Mobile is: {x%s{x [In Room %d]\n\r",
         quest_target->pIndexData->short_descr, quest_target->in_room->vnum );
      send_to_char( buf, ch );
      
      sprintf( buf, "Target Object is: {x%s{x.\n\r", quest_object->short_descr );
      send_to_char( buf, ch );
      
      sprintf( buf, "Quest Object is worth: %d QP, %d XP, %d raise points and %d GP\n\r",
         quest_object->value[0], quest_object->value[1],
         quest_object->value[4], quest_object->value[2] );
      send_to_char( buf, ch );
      
      return;
   }
   if ( !str_cmp( argument, "auto" ) )
   {
      send_to_char( "AutoQuest now initiated!\n\r", ch );
      auto_quest = TRUE;
	  quest_wait = 360;
      return;
   }
   
   
   return;
}      
Exemplo n.º 2
0
void generate_auto_quest()
{

  extern bool quest;
   
  extern CHAR_DATA *quest_mob;
  extern CHAR_DATA *quest_target;
  extern OBJ_DATA *quest_object;
  extern int quest_timer;
  extern int quest_wait;
  extern sh_int quest_personality;
 // int  hunt_flags = 0;
  char new_long_desc[MAX_STRING_LENGTH];
  sh_int       loop_counter = 0; 

  int a = 140;
  int b = 0;
  sh_int  average_level= 0;
      
  /* generate a new quest! */
  if ( quest )
  {
    return;
  }
      
#if 0
      /* Work out levels of currently playing folks */
  if ( descriptor_list && descriptor_list->connected == CON_PLAYING )
  {
  for ( d = descriptor_list; d; d = d->next )
  {
    if (    d->connected != CON_PLAYING )
      continue;
	if (IS_IMMORTAL(d->character))
		continue;
      player_count += 1;
      total_levels += d->character->level;
  }
  player_count = UMAX( 1, player_count );
  average_level = ( total_levels / player_count );
#endif

  quest_mob = NULL;
  quest_target = NULL;

  average_level = number_range( 0, 65 );
  if ( average_level < 20 )
  {
    a = number_range( 5, 25 );
    b = number_range( 30, 45 );
//    hunt_flags = HUNT_WORLD | HUNT_OPENDOOR ;
    quest_personality = 1;
  }
  else   if ( average_level < 40 )
  {
    a = number_range( 30, 40 );
    b = number_range( 40, 55 );
//    hunt_flags = HUNT_WORLD | HUNT_OPENDOOR | HUNT_PICKDOOR;
    quest_personality = 2;
  }
  else
  {
    a = number_range( 50, 55 );
    b = number_range( 56, 99 );
//    hunt_flags = HUNT_WORLD | HUNT_OPENDOOR | HUNT_PICKDOOR | HUNT_UNLOCKDOOR;
    quest_personality = 3;
  }
  if (quest_personality == 0 )
	  quest_personality = 1;

  while (  ( quest_mob == NULL )
        && ( loop_counter < 500 )  )
  {
    loop_counter++;
    quest_mob    = get_quest_giver(a, b);
  }

  if ( quest_mob == NULL )
  {
    quest = FALSE;
    quest_wait = number_range( 1, 3 );
    return;
  }
  loop_counter = 0;
  while (  ( quest_target == NULL )
        && ( loop_counter < 500 )  )
  {
    loop_counter++;
    quest_target = get_quest_target( a, b );
	
    if (  ( quest_target == NULL )
       || ( quest_target == quest_mob )  ) 
      quest_target = NULL;
	  
  }



  if ( quest_target == NULL )
  {
    quest = FALSE;
    quest_wait = number_range( 1, 3 );
    return;
  }
  quest_object = load_quest_object( quest_target );
  if ( quest_object == NULL )
  {
    quest = FALSE;
    quest_wait = number_range( 1, 3 );
    return;
  }
      /* Set values on quest item for Qp, Pracs, Exp, Gold */
  quest_object->value[0] = UMAX( 1, ( quest_target->level / 3 ) );
  quest_object->value[1] = number_range(1, 60);
  quest_object->value[2] = ( quest_target->level * 100 );
  quest_object->value[3] = average_level;
  quest_object->value[4] = 2;

  if ( number_percent() < 10 )
  {
    quest_object->value[0] += 2;
    quest_object->value[1] += 3;
    quest_object->value[2] *= 2;
    quest_object->value[4] *= 3;
  }
      
  quest_timer = 0;
  quest = TRUE;
  new_long_desc[0] = '\0';
  if ( quest_mob->pIndexData->long_descr_orig != NULL )
    free_string( quest_mob->pIndexData->long_descr_orig );
  quest_mob->pIndexData->long_descr_orig = str_dup(quest_mob->long_descr );
  sprintf( new_long_desc, "{x%s{x says have you found {x%s{x?\n\r",
         quest_mob->short_descr, quest_object->short_descr );
  if ( quest_mob->long_descr != NULL )      
    free_string( quest_mob->long_descr );    
  quest_mob->long_descr = str_dup( new_long_desc );
  SET_BIT( quest_mob->act, PLR_NOSUMMON );
  REMOVE_BIT(quest_mob->act, ACT_AGGRESSIVE);

  new_long_desc[0] = '\0';
  if ( quest_target->pIndexData->long_descr_orig != NULL )
    free_string( quest_target->pIndexData->long_descr_orig );
  quest_target->pIndexData->long_descr_orig = str_dup( quest_target->long_descr );
  sprintf( new_long_desc, "{x%s{x says I stole {x%s{x!\n\r",
        quest_target->pIndexData->short_descr, quest_object->short_descr );
  if ( quest_target->long_descr != NULL )     
        free_string( quest_target->long_descr );   
  quest_target->long_descr = str_dup( new_long_desc );

  SET_BIT( quest_target->act, PLR_NOSUMMON );  
  return;

}
Exemplo n.º 3
0
void generate_auto_quest(  )
{
    DESCRIPTOR_DATA *d;
    int hunt_flags = 0;
    char new_long_desc[MAX_STRING_LENGTH];
    short loop_counter = 0;

    int a = 140;
    int b = 0;
    short player_count = 0, average_level = 0, total_levels = 0;

    /*
     * generate a new quest!
     */
    if ( quest )
    {
        return;
    }

    /*
     * Work out levels of currently playing folks
     */
    if ( first_desc && first_desc->connected == CON_PLAYING )
    {
        for ( d = first_desc; d; d = d->next )
        {
            if ( d->connected != CON_PLAYING )
                continue;
            if ( IS_IMMORTAL(d->character) ) /* Imms shouldn't count against the quest level. --Kline */
                continue;
            player_count++;
            total_levels += d->character->level;
        }
        player_count = UMAX( 1, player_count );
        if ( total_levels > 0 ) /* If we don't have any players on, don't want a div by 0 error. --Kline */
            average_level = ( total_levels / player_count );
        else
            average_level = 1;

        quest_mob = NULL;
        quest_target = NULL;

        if ( average_level < 20 )
        {
            a = number_range( 5, 25 );
            b = number_range( 30, 45 );
            hunt_flags = HUNT_WORLD | HUNT_OPENDOOR;
            quest_personality = 1;
        }
        else if ( average_level < 65 )
        {
            a = number_range( 40, 55 );
            b = number_range( 60, 84 );
            hunt_flags = HUNT_WORLD | HUNT_OPENDOOR | HUNT_PICKDOOR;
            quest_personality = 2;
        }
        else
        {
            a = number_range( 100, 110 );
            b = number_range( 115, 140 );
            hunt_flags = HUNT_WORLD | HUNT_OPENDOOR | HUNT_PICKDOOR | HUNT_UNLOCKDOOR;
            quest_personality = 3;
        }

        while ( ( quest_mob == NULL ) && ( loop_counter < 500 ) )
        {
            loop_counter++;
            quest_mob = get_quest_giver( a, b );
            if ( ( quest_mob == NULL )
                    || ( ( h_find_dir( get_room_index( ROOM_VNUM_TEMPLE ), quest_mob->in_room, hunt_flags ) < 0 ) ) )
                quest_mob = NULL;
        }

        if ( quest_mob == NULL )
        {
            quest = FALSE;
            quest_wait = number_range( 1, 3 );
            return;
        }
        loop_counter = 0;
        while ( ( quest_target == NULL ) && ( loop_counter < 500 ) )
        {
            loop_counter++;
            quest_target = get_quest_target( a, b );
            if ( ( quest_target == NULL )
                    || ( ( h_find_dir( get_room_index( ROOM_VNUM_TEMPLE ), quest_target->in_room, hunt_flags ) < 0 ) )
                    || ( quest_target == quest_mob ) )
                quest_target = NULL;
        }



        if ( quest_target == NULL )
        {
            quest = FALSE;
            quest_wait = number_range( 1, 3 );
            return;
        }
        quest_object = load_quest_object( quest_target );
        if ( quest_object == NULL )
        {
            quest = FALSE;
            quest_wait = number_range( 1, 3 );
            return;
        }
        /*
         * Set values on quest item for Qp, Pracs, Exp, Gold
         */
        quest_object->value[0] = UMAX( 1, ( quest_target->level / 20 ) );
        quest_object->value[1] = UMAX( 1, ( quest_target->level / 18 ) );
        quest_object->value[2] = ( quest_target->level * 20 );
        quest_object->value[3] = average_level;

        if ( number_percent() < 10 )
            quest_object->value[0] *= 2;
        if ( number_percent() < 10 )
            quest_object->value[1] *= 2;
        if ( number_percent() < 10 )
            quest_object->value[2] *= 2;

        quest_timer = 0;
        quest = TRUE;
        new_long_desc[0] = '\0';

        quest_mob->long_descr_orig = quest_mob->long_descr;
        snprintf( new_long_desc, MSL, "%s @@Nsays have you found my %s ?", quest_mob->get_name(), quest_object->short_descr );
        quest_mob->long_descr = new_long_desc;
        quest_mob->act.set(ACT_NO_SUMMON );
        quest_mob->act.set(ACT_NO_VISIT );
        quest_mob->act.set(ACT_NO_BLOOD );


        new_long_desc[0] = '\0';

        quest_target->long_descr_orig = quest_target->long_descr;
        snprintf( new_long_desc, MSL, "%s @@Nsays I stole the %s !!!", quest_target->get_name(), quest_object->short_descr );
        quest_target->long_descr = new_long_desc;

        quest_target->act.set(ACT_NO_SUMMON );
        quest_target->act.set(ACT_NO_VISIT );
        quest_target->act.set(ACT_NO_BLOOD );

        return;
    }
}