SRL Archive - OSR Help

How to check if the monster was clicked on?


rj

2012-11-23 16:14:54

Hi, I have managed to write a script that attacks a skeleton, waits to get out of combat, look for the bone color and picks up the gold charm. Now I am having a couple problems:
1) The bot spam clicks the hell out of the skeleton until my charactor attacks it
2) the bot keeps doing the looting procedure over and over instead of looting, then attacking another skeleton

Here is my script:
// fill out const's
const
NPC = 1121869;
loot = 14079706;
tolerence = 12;
time = 1; // in seconds
rwait = 100;
tleft = 41;
tright = 44;
bleft = 426;
bright = 280;

var
charm: Integer;

procedure PickUp;
var
X, Y: Integer;
begin
WriteLn('Looking for bones...');
if FindColorTolerance(X, Y, loot, 223, 114, 388, 290, 15) then
begin
WriteLn('Found bones!');
Movemouse(x, y);
Wait(120 + Random(80));
ClickMouse(x, y, mouse_Right);
end;
WriteLn('Looking for charm...');
Wait(1100);
if FindBitmapToleranceIn(charm, X, Y,161, 86, 420, 252, 85) then
begin
Movemouse(X, Y);
WriteLn('Found charm!');
Wait(500);
ClickMouse(X, Y, mouse_Left);
Wait(1820 + Random(80));
end;
end;
procedure CheckCombat;
var
X, Y: Integer;
Begin
if FindColorTolerance(X, Y, 49499, 244, 150, 283, 219, 15) then
begin
ClearDebug;
Wait((time+500) + Random(rwait));
WriteLn('Waiting to get out of combat . . .');
CheckCombat;
PickUp;
End;
End;

procedure ClickNPC;
var
X, Y: Integer;
begin // kill npc
WriteLn('Attacking skeleton...');
if FindColorTolerance(X, Y, NPC, tleft, tright, bleft, bright, tolerence) then
begin
MoveMouse(X, Y);
Wait(20 + Random(50));
ClickMouse(X, Y, Mouse_Left);
WriteLn('Attacked skeleton!');
CheckCombat;
end;
end;

begin
charm := BitmapFromString(31, 12, 'meJyTUdeWIQU5TPgPRyRpJNJkBj' +
'CgrvnIJkNEkNnUMpwMvVN3HIMj/IZjDXOscQFxCcRMiDdxmY/scrQ' +
'wxx8XcMPR2HiCBZmLi40ZJnAvUNdwBiSAJ9iJNxwevGiOx59mMJMl' +
'VnHMdIvf8WjKiBGnEQIAUtQGXA==');
repeat
ClearDebug;
ClickNPC;
until False;
FreeBitmap(charm);
end.

procedure CheckCombat;
begin
Wait((time * 500) + Random(rwait));
WriteLn('Waiting for loot...');
Wait((time * 500) + Random(rwait));
PickUp;
end;

procedure ClickNPC;
var
X, Y,cx,cy: Integer;
begin // kill npc
WriteLn('Attacking skeleton...');
if FindColorTolerance(X, Y, NPC, tleft, tright, bleft, bright, tolerence) then
begin
MoveMouse(X, Y);
Wait(2000 + Random(50));
ClickMouse(X, Y, Mouse_Left);
getmousepos(cx,cy)
if findcolortolerance(x, y, 65535, cx -25, cy -25, cx+ 25, cy +25, tolerence)then
ClickNPC;
else
WriteLn('Attacked skeleton!');
CheckCombat;
end;
end;

begin
charm := BitmapFromString(31, 12, 'meJyTUdeWIQU5TPgPRyRpJNJkBj' +
'CgrvnIJkNEkNnUMpwMvVN3HIMj/IZjDXOscQFxCcRMiDdxmY/scrQ' +
'wxx8XcMPR2HiCBZmLi40ZJnAvUNdwBiSAJ9iJNxwevGiOx59mMJMl' +
'VnHMdIvf8WjKiBGnEQIAUtQGXA==');
repeat
ClearDebug;
ClickNPC;
until False;
FreeBitmap(charm);
end.

Rezozo

2012-11-23 16:24:05

This is your fighting script right? Please use one of the many threads you have already made about the script, to post errors and questions.

Also, please display the errors exactly in Code tags.

rj

2012-11-23 16:25:12

[Error] (60:40): Unknown identifier 'mouse' at line 59
Compiling failed.

Footy

2012-11-23 16:28:20

Add
{$i srl/srl.simba}
To the line after program (Programname);

rj

2012-11-23 16:35:11

From: Footy
Add
{$i srl/srl.simba}
To the line after program (Programname);


[Error] (62:45): Invalid number of parameters at line 61
Compiling failed.

Footy

2012-11-23 16:40:27

Can you show us which line is 61?

rj

2012-11-23 16:42:11

From: Footy
Can you show us which line is 61?


Sorry.

first one is line 61
 if FindColorTolerance(X, Y, 65535, mouse.x, mouse.y, mouse.x-25, mouse.y+25, tolerence) then
ClickNPC;

I knew it was wrong but I did not know how to correctly program it

Footy

2012-11-23 16:43:51

I'm not sure what you are trying to do with the mouse.x, mouse.y. Use MSX1, MSY1, MSX2, and MSY2 as your boundaries, that will search the entire screen.

rj

2012-11-23 16:48:04

From: Footy
I'm not sure what you are trying to do with the mouse.x, mouse.y. Use MSX1, MSY1, MSX2, and MSY2 as your boundaries, that will search the entire screen.


I want it to search were my like a box were my mouse is:


KingKong

2012-11-23 17:32:12

use


var
cx, cy:integer;
begin
getmousepos(cx,cy)
findcolortolerance(x, y, 65535, cx -25, cy -25, cx+ 25, cy +25, tol)
end;


h4x_

2012-11-23 17:51:32

im 90% sure that he is trying to script a script for a RSPS (SoulSplit) this is why he is getting so many errors (using SRL functions that only work with RS) and problems with this script which is made worse by his lack of programming/pascal knowledge,

Sorry guys, i hope he learns to keep to one thread or read previous threads about the same matter (scripting in simba for a rsps) - thats how i learnt that using simba was an ineffective way to script for a RSPS because most functions SRL gives wont work :(

J J

2012-11-23 17:51:57

if FindColorTolerance(X, Y, 65535, mouse.x, mouse.y, mouse.x-25, mouse.y+25, tolerence) then
ClickNPC;
WriteLn('Attacked skeleton!');
CheckCombat;
You only want to check if you are in combat if you actually clicked so:
if FindColorTolerance(X, Y, 65535, mouse.x, mouse.y, mouse.x-25, mouse.y+25, tolerence) then
begin
ClickNPC;
WriteLn('Attacked skeleton!');
CheckCombat;
end;

We also have some functions like DidRedClick and DidYellowClick.

rj

2012-11-23 17:55:00

From: J J
if FindColorTolerance(X, Y, 65535, mouse.x, mouse.y, mouse.x-25, mouse.y+25, tolerence) then
ClickNPC;
WriteLn('Attacked skeleton!');
CheckCombat;
You only want to check if you are in combat if you actually clicked so:
if FindColorTolerance(X, Y, 65535, mouse.x, mouse.y, mouse.x-25, mouse.y+25, tolerence) then
begin
ClickNPC;
WriteLn('Attacked skeleton!');
CheckCombat;
end;

We also have some functions like DidRedClick and DidYellowClick.


Check combat procedure is misnamed lol it actually just a wait for the loot to appear until i can figure out how to wait for the monster to die

J J

2012-11-23 18:07:58

From: rjj95
Check combat procedure is misnamed lol it actually just a wait for the loot to appear until i can figure out how to wait for the monster to die

If this is for a RS script now with the EOC you can read which monster you are fighting from the Combat tab. If it reads none then you are out of combat. Double check by testing if you are moving towards a monster (IsMoving).

If this is for a RSPS try making a bitmap or color search for the health bar/hit splat.

rj

2012-11-23 18:22:02

From: J J
If this is for a RS script now with the EOC you can read which monster you are fighting from the Combat tab. If it reads none then you are out of combat. Double check by testing if you are moving towards a monster (IsMoving).

If this is for a RSPS try making a bitmap or color search for the health bar/hit splat.


will do

rj

2012-11-23 22:25:25

new problem, just going to bump this to avoid spam