Thread: Red Skill Caps
View Single Post
  #11  
Old 10-01-2009, 11:31 AM
Pyre
Fire Beetle
 
Join Date: Nov 2006
Posts: 3
Default

Sorry for the thread necro, but I'm getting strange results and am having trouble following this.

I found Client::MaxSkill, and it eventually inherits from the GetSkillCap function in common/database.cpp.

Code:
int8 Database::GetSkillCap(int8 skillid, int8 in_race, int8 in_class, int16 in_level)
{
	int8 skill_level = 0, skill_formula = 0;
	int16 base_cap = 0, skill_cap = 0, skill_cap2 = 0, skill_cap3 = 0;
	char errbuf[MYSQL_ERRMSG_SIZE];
	char *query = 0;
	int32	affected_rows = 0;
	MYSQL_RES *result;
	MYSQL_ROW row;
	//Fetch the data from DB.
	if (RunQuery(query, MakeAnyLenString(&query, "SELECT level, formula, pre50cap, post50cap, post60cap from skillcaps where skill = %i && class = %i", skillid, in_class), errbuf, &result, &affected_rows))
	{
		if (affected_rows != 0)
		{
			row = mysql_fetch_row(result);
			skill_level = atoi(row[0]);
			skill_formula = atoi(row[1]);
			skill_cap = atoi(row[2]);
			if (atoi(row[3]) > skill_cap)
				skill_cap2 = (atoi(row[3])-skill_cap)/10; //Split the post-50 skill cap into difference between pre-50 cap and post-50 cap / 10 to determine amount of points per level.
			skill_cap3 = atoi(row[4]);
		}
		delete[] query;
		mysql_free_result(result);
	}

	int race_skill = GetRaceSkill(skillid,in_race);

	if (race_skill > 0 && (race_skill > skill_cap || skill_cap == 0 || in_level < skill_level))
		return race_skill;

	if (skill_cap == 0) //Can't train this skill at all.
		return 255; //Untrainable

	if (in_level < skill_level)
		return 254; //Untrained

	//Determine pre-51 level-based cap
	if (skill_formula > 0)
		base_cap = in_level*skill_formula+skill_formula;
	if (base_cap > skill_cap || skill_formula == 0)
		base_cap = skill_cap;
	//If post 50, add post 50 cap to base cap.
	if (in_level > 50 && skill_cap2 > 0)
		base_cap += skill_cap2*(in_level-50);
	//No cap should ever go above its post50cap
	if (skill_cap3 > 0 && base_cap > skill_cap3)
		base_cap = skill_cap3;
	//Base cap is now the max value at the person's level, return it!
	return base_cap;
}
The first thing I noticed is that the number of arguments is wrong. Is this overloaded somewhere else that I didn't find?

On the assumption that this is the actual function being used, this code shouldn't work. At least in the peq database I'm running (rev974), there is no skillcaps table. I see a skill_caps table, but it has a different field structure.

I have a bot in PoK doing testing on this, and the script code fragment looks like this:

Code:
if($text=~/skills/i) {
    quest::say("Very well, feel your skills increase!" );
    my $count;
    for ($count = 0; $count <= 74; $count++) {
      if($client->CanHaveSkill($count)) {
        quest::setskill($count,$client->MaxSkill($count));
      }
    }
  }
Am I looking at the wrong implementation of this function?
Reply With Quote