PDA

View Full Version : FIX: Skills not capping properly.


Toriad
02-01-2008, 10:49 PM
For me the skills were not capping properly and I found out that the DB query was off at least for PEQ? Maybe I just jumped blindly, if so let me know....

Replace GetSkillCap in database.cpp with this

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 cap from skill_caps where skillID = %i && class = %i && level = %i", skillid, in_class, in_level), errbuf, &result, &affected_rows)) //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);
LogFile->write(EQEMuLog::Debug, "row[0] = %i", atoi(row[0]));
skill_cap = atoi(row[0]);
/*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 skill_cap;
}

KLS
02-02-2008, 10:59 AM
I don't think this code is actually still being used in the server, at least I looked at the unmodified code and it seems old.. is uses skillcaps table for instance and we use skill_caps now...

Can you explain what exactly is wrong with skill caps, what were you trying to fix?

Toriad
02-02-2008, 11:05 AM
When I was level one, as long as I used offeense it kept going up, it never stopped at 10, like the skillcaps table said it should. I was trying to make it so it would. On a side note where is this skills_caps table? I didn't see any tables...

cavedude
02-02-2008, 12:00 PM
On a side note where is this skills_caps table? I didn't see any tables...

Then that's your problem ;) The table is in the newest PEQ release as well as our CVS, and I am sure Angelox's newest db has it as well.

Toriad
02-02-2008, 12:10 PM
I have that table, but it still wasn't working... SELECT * FROM peq.skill_caps s;

The old DB query in the code was

//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))

That was the old query however, I dont have a skillcaps table i did have skill_caps but it didn't have any of those fields which is why i changed it to

if (RunQuery(query, MakeAnyLenString(&query, "SELECT cap from skill_caps where skillID = %i && class = %i && level = %i", skillid, in_class, in_level), errbuf, &result, &affected_rows))

That is what I changed it to... Which seemed to fix the problem, maybe the latest source code already had this change? but when I downloaded the source from latest emu it was like the old.

Knightly
02-02-2008, 06:57 PM
I think that what KLS is saying is that the code you pasted above isn't the code that loads skill caps any more. Pretty sure the current code for skill caps is in shareddb.cpp in the DBLoadSkillCaps function, which does have the correct query:
"SELECT skillID,class,level,cap FROM skill_caps ORDER BY skillID,class,level"
That's not to say that the issue didn't occur, just that more information needs to be provided in order to reproduce the problem.

Toriad
02-02-2008, 07:23 PM
I didn't mean to say he was incorrect and if thats how it came out I sincerely apologize.

I cannot give more information that that...

I was at level 1 using a 1hslash weapon, i got 11 offense at level 1 which according to my database said was incorrect.. When I modified the code to what I put in the posts above I was capped at 10 offense at elvel 1.

cavedude
02-03-2008, 02:12 AM
That's very bizarre, I wasn't able to reproduce this, either on my test server or TGC. Both are running the same code more or less and are the newest.

Toriad
02-03-2008, 11:16 AM
Hmm, Ok maybe I'm just retarded somehow -shrugs- sorry for all the trobule, feel free to delete this topic.