Log in

View Full Version : Skill Experience Related Functions



TOB
11-29-2006, 08:21 AM
Well, talk about free time, I made a couple functions and I made a list of experience values. I thought this may be useful, not so much on the magic part because you would need to have a function check if the attack was successful.

I'll attach SkillExperience.scar, it should go in your srl\srl\skill\ folder. I got lazy and didn't add smithing experiences or thieving, the list for other skills isn't complete but eh I think I added enough to get the point across. :P

The Task parameter is the prefix you see on the values for case statements minus the underscore.

First for these to work temporarily(until SRL is updated) you will need to take the function CurrentSkillXp2 from http://www.villu-reborn.com/showthread.php?p=42399#post42399. Next go into SRL's srl\srl\core\GameTab.scar file and find CurrentSkillXp and add this function under it, now go into XpTilNextLevel and change occurances of CurrentSkillXp to CurrentSkillXp2 inside that function.

Now here are some functions you should add to your srl\srl\skills\SkillCalculators.scar

{************************************************* ******************************
function TimesNeededToLvl(Skill, Item, Task: string): Integer;
By: TOB
Description: Returns number of times needed to perform Task on Item to level up Skill
************************************************** *****************************}
function TimesNeededToLvl(Skill, Item, Task: string): Integer;
var
tmpResult: Extended;
begin
tmpResult:= XpTilNextLevel(Skill, False) / GetExp(Item, Task);
if(tmpResult > Round(tmpResult)) then
Result:= Round(tmpResult) + 1
else
Result:= Round(tmpResult);
end;

{************************************************* ******************************
function TimesNeededToExp(Skill, Item, Task: string; ToExp: Integer): Integer;
By: TOB
Description: Returns number of times needed to perform Task on Item to ToExp
************************************************** *****************************}
function TimesNeededToExp(Skill, Item, Task: string; ToExp: Integer): Integer;
var
tmpResult: Extended;
begin
if(ToExp < CurrentSkillXp2(Skill)) then
begin
Result:= 0;
Exit;
end else
begin
tmpResult:= XpTilNextLevel(Skill, False) / GetExp(Item, Task);
if(tmpResult > Round(tmpResult)) then
Result:= Round(tmpResult) + 1
else
Result:= Round(tmpResult);
end;
end;

{************************************************* ******************************
function TimesNeededToExpEx(Item, Task: string; FromExp, ToExp: Integer): Integer;
By: TOB
Description: Returns number of times needed to perform Task on Item to ToExp from FromExp
************************************************** *****************************}
function TimesNeededToExpEx(Item, Task: string; FromExp, ToExp: Integer): Integer;
var
tmpResult: Extended;
begin
if(ToExp < FromExp) then
begin
Result:= 0;
Exit;
end else
begin
tmpResult:= (ToExp - FromExp) / GetExp(Item, Task);
if(tmpResult > Round(tmpResult)) then
Result:= Round(tmpResult) + 1
else
Result:= Round(tmpResult);
end;
end;

Now go into srl\SRL.scar an add these includes somewhere in there:

{.include srl\srl\skill\SkillExperience.scar}
{.include srl\srl\skill\SkillCalculators.scar}

Here is a quick little test script for it:
{.include srl\SRL.scar}
var
timesNeeded: Integer;
begin
ActivateClient;
SetupSRL;
ClearDebug;

timesNeeded:= TimesNeededToLvl('fletching', 'long oak', 'bow');
WriteLn(IntToStr(timesNeeded));
Wait(500);
timesNeeded:= TimesNeededToExp('mining', 'coal', 'mine', 36264);
WriteLn(IntToStr(timesNeeded));
Wait(500);
timesNeeded:= TimesNeededToExpEx('magic', 'burn', 445, 1023);
WriteLn(IntToStr(timesNeeded));
end.

_____

Let me know what problems there is because I threw this together rather quick.

TOB
11-30-2006, 09:43 PM
Not even one view on experience list and no responses :/

WT-Fakawi
11-30-2006, 10:12 PM
I am sorry. Thats just awful. I will take a look at it right now. Everyone just seems to be so pre-occupied these days.

Ron
08-01-2007, 05:23 AM
Wow those are some nice functions Nate! I think they were added in SRL. Good job! :)

itSchRis917
08-01-2007, 06:02 AM
Wow, very nice! This is sweet! Thanks for making these, and better yet, releasing them. ;)