PDA

View Full Version : Function which reacts to xp increases



xujnea
05-16-2015, 11:02 PM
Hello, I'm trying to create function which would do things,based on xp increases. Here some code :

program new;
//{$DEFINE SMART}
//{$DEFINE WALKER}
{$i AeroLib/AeroLib.Simba}
{$i Reflection/Reflection.Simba}

var
xpB, xpA, runs : Integer; // xpB - xp before, xpA - xp after

function XpBefore : Integer;
begin
xpB := TReflectLocalPlayer.GetSkillExp(12); // This function to mark xp
Result := xpB;
end;

function XpAfter : Integer;
begin
xpA := TReflectLocalPlayer.GetSkillExp(12); // This function for comparison
Result := xpA;
end;

function XpCompare : Boolean;
begin
if (xpB < xpA) then // Function to check if xp increased
Result := true;
end;

procedure run1
begin
XpBefore; // Marking xp
//do stuff;
end;

procedure run2
begin
XpAfter; // Trying to find xp for comparison
if not XpCompare then
Sleep(RandomRange(800, 2500));
if XpCompare then
//do stuff;
end;

begin
ClearDebug;
InitAL;
Reflect.Setup;
repeat
begin
Inc(runs);
run1;
run2; // <---- here I got stuck
end;
until(runs > 20);
end;


I get stuck at " run2 ". Maybe someone has ideas,how can I fix it?

Richard
05-16-2015, 11:10 PM
Code in Simba tags for you:

program new;
//{$DEFINE SMART}
//{$DEFINE WALKER}
{$i AeroLib/AeroLib.Simba}
{$i Reflection/Reflection.Simba}

var
xpB, xpA, runs : Integer;

function XpBefore : Integer;
begin
xpB := TReflectLocalPlayer.GetSkillExp(12);
Result := xpB;
end;

function XpAfter : Integer;
begin
xpA := TReflectLocalPlayer.GetSkillExp(12);
Result := xpA;
end;

function XpCompare : Boolean;
begin
if (xpB < xpA) then
Result := true;
end;

procedure run1
begin
XpBefore;
//do stuff;
end;

procedure run2
begin
XpAfter;
if not XpCompare then
Sleep(RandomRange(800, 2500));
if XpCompare then
//do stuff;
end;

begin
ClearDebug;
InitAL;
Reflect.Setup;
repeat
begin
Inc(runs);
run1;
run2; // I get Stuck here...
end;
until(runs > 20);
end;


EDIT: apologies, I was wrong about runs > 20 never being satisfied, I can't read code.

woo hoo
05-16-2015, 11:29 PM
xpbefore
while xpbefore = xpafter do
begin
wait(200);
xpafter;
end;


I think something like this would work if you are trying to idle while waiting for an xp drop. Records your xp with xpbefore then enters a 200 millisecond loop, checking your at the beginning or end of each of your loops until your xp changes.


program new;
//{$DEFINE SMART}
//{$DEFINE WALKER}
{$i AeroLib/AeroLib.Simba}
{$i Reflection/Reflection.Simba}

var
xpB, xpA, runs : Integer; // xpB - xp before, xpA - xp after

function XpBefore : Integer;
begin
xpB := TReflectLocalPlayer.GetSkillExp(12); // This function to mark xp
Result := xpB;
end;

function XpAfter : Integer;
begin
xpA := TReflectLocalPlayer.GetSkillExp(12); // This function for comparison
Result := xpA;
end;

procedure run1
begin
XpBefore; // Marking xp
//do stuff;
while xpbefore = xpafter do
begin
Xpafter;
wait(200);
end;
end;

begin
ClearDebug;
InitAL;
Reflect.Setup;
repeat
begin
Inc(runs);
run1;
end;
until(runs > 20);
end;

xujnea
05-18-2015, 08:35 PM
That would work with "Run1",but I got 2 Runs and each of them has 2 different cases. I was trying this :


program PatsGeriausiasScriptas;
//{$DEFINE SMART}
//{$DEFINE WALKER}
{$i AeroLib/AeroLib.Simba}
{$i Reflection/Reflection.Simba}

function Run1 : Boolean
begin
GoToBank;
TakeStuff;
If (xpA > xpB) then
begin
result := false;
GoToArmorShop;
end else
begin
result := true;
GoToSwordShop;
end;
end;

procedure Run2
begin
GoToBank;
TakeDifferentStuff;
if (run1) then // SCRIPT SKIPS FROM HERE TO
begin
Action1;
Action2;
end else
begin
TotalyDifferentAction;
TotalyDifferentAction2;
end; // TO HERE , AND STARTS "RUN1".
end;


begin
ClearDebug;
InitAL;
Reflect.Setup;
repeat
begin
Run1;
Run2;
end;
until(false);
end;
[/QUOTE]

But it seems script do not get result from " Run1 ", and "Run2", skips all part after "if (run1) then" and starts Run1 again. Maybe you,guys,got some ideas how can I fix this ? :/ Thank you

woo hoo
05-18-2015, 08:53 PM
Run2 goes back to run1 because the "if run1 then" statement does run1 until it gets to a boolean result. You'll need to sneak the first 2 lines of run1 into one of those if statements. Something like this:

function Run1 : Boolean
begin
If (xpA > xpB) then
begin
GoToBank;
TakeStuff;
result := false;
GoToArmorShop;
end else
begin
result := true;
GoToSwordShop;
end;
end;

Run2 also needs to be arranged so that it doesn't take out stuff until the result from run1 is returned.

xujnea
05-18-2015, 09:00 PM
Run2 also needs to be arranged so that it doesn't take out stuff until the result from run1 is returned.

So everytime I call "if (Run1) then" it starts doing all other procedures too? I'll try it now. ****Still same problem,runs all procedures if asked for result. :/ I need to mark somehow, what script chooses at "Run1",so I will be able check at "Run2". I hope you understand me :D and thanks for time.**** Lol I just stored Boolean var into my function and made it equal to result. I think that will work. Yeah it worked.