Exemplo n.º 1
0
//===========================================================================
//
// Parameter:           -
// Returns:             -
// Changes Globals:     -
//===========================================================================
int BotLoadCharacter( char *charfile, int skill )
{
    int skill1, skill4, handle;

    //make sure the skill is in the valid range
    if ( skill < 1 )
    {
        skill = 1;
    }
    else if ( skill > 5 )
    {
        skill = 5;
    }

    //skill 1, 4 and 5 should be available in the character files
    if ( skill == 1 || skill == 4 || skill == 5 )
    {
        return BotLoadCharacterSkill( charfile, skill );
    } //end if

    //check if there's a cached skill 2 or 3
    handle = BotFindCachedCharacter( charfile, skill );

    if ( handle )
    {
        //botimport.Print(PRT_MESSAGE, "loaded cached skill %d from %s\n", skill, charfile);
        return handle;
    } //end if

    //load skill 1 and 4
    skill1 = BotLoadCharacterSkill( charfile, 1 );

    if ( !skill1 )
    {
        return 0;
    }

    skill4 = BotLoadCharacterSkill( charfile, 4 );

    if ( !skill4 )
    {
        return skill1;
    }

    //interpolate between 1 and 4 to create skill 2 or 3
    handle = BotInterpolateCharacters( skill1, skill4, skill );

    if ( !handle )
    {
        return 0;
    }

    //write the character to the log file
    BotDumpCharacter( botcharacters[ handle ] );
    //
    return handle;
} //end of the function BotLoadCharacter
Exemplo n.º 2
0
//===========================================================================
//
// Parameter:			-
// Returns:				-
// Changes Globals:		-
//===========================================================================
int BotLoadCharacter(char *charfile, float skill)
{
	int firstskill, secondskill, handle;

	//make sure the skill is in the valid range
	if (skill < 1.0) skill = 1.0;
	else if (skill > 5.0) skill = 5.0;
	//skill 1, 4 and 5 should be available in the character files
	if (skill == 1.0 || skill == 4.0 || skill == 5.0)
	{
		return BotLoadCharacterSkill(charfile, skill);
	} //end if
	//check if there's a cached skill
	handle = BotFindCachedCharacter(charfile, skill);
	if (handle)
	{
		BotAI_Print(PRT_DEVELOPER, "loaded cached skill %f from %s\n", skill, charfile);
		return handle;
	} //end if
	if (skill < 4.0)
	{
		//load skill 1 and 4
		firstskill = BotLoadCharacterSkill(charfile, 1);
		if (!firstskill) return 0;
		secondskill = BotLoadCharacterSkill(charfile, 4);
		if (!secondskill) return firstskill;
	} //end if
	else
	{
		//load skill 4 and 5
		firstskill = BotLoadCharacterSkill(charfile, 4);
		if (!firstskill) return 0;
		secondskill = BotLoadCharacterSkill(charfile, 5);
		if (!secondskill) return firstskill;
	} //end else
	//interpolate between the two skills
	handle = BotInterpolateCharacters(firstskill, secondskill, skill);
	if (!handle) return 0;
#if 0 // ZTM: FIXME: add new bot logfile for game to write to?
	//write the character to the log file
	BotDumpCharacter(&botcharacters[handle]);
#endif
	//
	return handle;
} //end of the function BotLoadCharacter
Exemplo n.º 3
0
int
BotLoadCharacter(char *charfile, float skill)
{
	int firstskill, secondskill, handle;

	/* make sure the skill is in the valid range */
	if(skill < 1.0) skill = 1.0;
	else if(skill > 5.0) skill = 5.0;
	/* skill 1, 4 and 5 should be available in the character files */
	if(skill == 1.0 || skill == 4.0 || skill == 5.0)
		return BotLoadCharacterSkill(charfile, skill);
	/* check if there's a cached skill */
	handle = BotFindCachedCharacter(charfile, skill);
	if(handle){
		botimport.Print(PRT_MESSAGE, "loaded cached skill %f from %s\n",
			skill,
			charfile);
		return handle;
	}
	if(skill < 4.0){
		/* load skill 1 and 4 */
		firstskill = BotLoadCharacterSkill(charfile, 1);
		if(!firstskill) return 0;
		secondskill = BotLoadCharacterSkill(charfile, 4);
		if(!secondskill) return firstskill;
	}else{
		/* load skill 4 and 5 */
		firstskill = BotLoadCharacterSkill(charfile, 4);
		if(!firstskill) return 0;
		secondskill = BotLoadCharacterSkill(charfile, 5);
		if(!secondskill) return firstskill;
	}
	/* interpolate between the two skills */
	handle = BotInterpolateCharacters(firstskill, secondskill, skill);
	if(!handle) return 0;
	/* write the character to the log file */
	BotDumpCharacter(botcharacters[handle]);
	return handle;
}