SRL Archive - OSR Help

Someone take a look at my script and let me know whats wrong with it?


Vowel

2015-03-30 23:21:16

Hi, I've just written up this script. It compiles and everything (using LAPE reflection), however it doesn't perform any of the actions it's supposed to in-game… here's the code:

program combatRing;

{$DEFINE SMART}
{$i Reflection/Reflection.Simba}

var MyPlayer: TReflectLocalPlayer;


function outOfRing(): boolean;
var
outsidePolygon: TPointArray;

begin
outsidePolygon := [[7255, 11604], [7254, 11604], [7253, 11604], [7250, 11604]];

if Reflect.Tiles.InPolygon(outsidePolygon) then
result := true;
end;


function inRing(): boolean;
var
insidePolygon: TPointArray;
begin
insidePolygon := [[7253, 11610], [7252, 11610], [7251, 11610], [7250, 11610];

if Reflect.Tiles.InPolygon(insidePolygon) then
result := true;
end;

procedure enterRing();
var
combatRing: TReflectObject
begin
if combatRing.Find(objGame, 'Combat ring', 40) then
wait(randomrange(43,95));
Reflect.Mouse.Move(combatRing.GetMSPoint, 2, 2);
wait(randomrange(39, 75));
Reflect.Mouse.Click(Mouse_Left);
while MyPlayer.IsMoving do
Wait(randomrange(900,1200));
end;

procedure attackPlayer();
var
Player: TReflectPlayer;
begin
wait(500 + random(1097));
while not MyPlayer.IsUnderAttack do
begin
if Player.Find('luuuke dude') then
Reflect.Mouse.Move(Player.GetMSPoint, 2, 2);
wait(randomrange(50,100));
Reflect.Mouse.Click(Mouse_Left);
wait(randomrange(50,150));
while MyPlayer.IsMoving do
Wait(randomrange(1000,1300));
end;
end;

procedure loop();
begin
if outOfRing() then
begin
enterRing;
end;

if inRing() then
begin
Wait(randomrange (120, 300));
attackPlayer;
end;
end;

begin
Reflect.Setup;
repeat
loop;
until (false);
end.

pija

2015-04-10 16:46:27

When your script compiles it means there are no syntactic errors. These are identifiable just by the code.
However since your code compiles and it still doesn't do what you want, there are semantic errors. Also called bugs. A bug is an error that causes your code to function in a way different to the behaviour you want. There is no way to tell what the bug is unless we know what the script is supposed to be doing in the first place.
We need to know the following.
What is the script supposed to be doing?
What is the script actually doing?
Exactly what did you do when the script misbehaved?

Of course we could guess the answers to the questions ourselves by looking at your uncommented code. But come on. At least help us help you.

Zace

2015-04-10 21:51:23

From: Vowel
Hi, I've just written up this script. It compiles and everything (using LAPE reflection), however it doesn't perform any of the actions it's supposed to in-game… here's the code:

Try to get all those waitrandom ranges out I believe you're using them to wait a random amount of time between actions. If so just use wait(300+random(250)); numbers in ms.
Also try to just use those functions to call in your procedures to find if you're in or out of the ring.

anoobis

2015-04-10 22:40:32

It's hard to tell just looking at coords but make sure you drew the polygons correctly. The tiles that bound the polygon are not included in its area. In general though, you should add writeln('debug reference here') to sections of your code that you expect to be executed. Based on what it outputs you can start pinpointing where exactly where your script is encountering a bug.

Camel

2015-04-10 22:47:15

I don't know anything about reflection but

function outOfRing(): boolean;
var
outsidePolygon: TPointArray;

begin
outsidePolygon := [[7255, 11604], [7254, 11604], [7253, 11604], [7250, 11604]];

if Reflect.Tiles.InPolygon(outsidePolygon) then
result := true;
end;

Is a function to tell if you are out of the ring. But i would return true if you actually in the ring..

function outOfRing(): boolean;
var
outsidePolygon: TPointArray;

begin
outsidePolygon := [[7255, 11604], [7254, 11604], [7253, 11604], [7250, 11604]];

if not Reflect.Tiles.InPolygon(outsidePolygon) then // <--- right here
result := true;
end;

try adding that not, maybe that would fix it.

Threshold

2015-04-10 23:36:19

From: pija
When your script compiles it means there are no syntactic errors. These are identifiable just by the code.
However since your code compiles and it still doesn't do what you want, there are semantic errors. Also called bugs. A bug is an error that causes your code to function in a way different to the behaviour you want. There is no way to tell what the bug is unless we know what the script is supposed to be doing in the first place.
We need to know the following.
What is the script supposed to be doing?
What is the script actually doing?
Exactly what did you do when the script misbehaved?

Of course we could guess the answers to the questions ourselves by looking at your uncommented code. But come on. At least help us help you.


Seems like it's using two accounts to get combat xp in a house combat arena. Of course we do need some sort of follow up by the OP. Could be wrong though.