SRL Archive - OSR Help

What would be a good method to...


ownedlikenoob

2010-06-11 16:41:53

Tell when a monster has died?

I want the script to be like this

attack monster,
when monster is dead
attack new monster

I can do the attack monster without any problem. just how would I get it to know when the monster you are attacking is dead?

Thanks

Frement

2010-06-11 16:50:57

Check when hp bar is gone for example.

InFight(); in SRL.

EDIT: Something I used in my script.
function F_InFight: Boolean;
var GTPA, RTPA: TPointArray;
begin
FindColorsTolerance( GTPA, 49499, MSCX - 15, MSCY - 40, MSCX + 15, MSCY, 20 );
FindColorsTolerance( RTPA, 590010, MSCX - 15, MSCY - 40, MSCX + 15, MSCY, 20 );
Result := ( ( GetArrayLength( GTPA ) + GetArrayLength( RTPA ) ) >= 20 );
end;

Blumblebee

2010-06-11 17:23:33

or you could always find the HP bar and look for when there is no green in the HP bar (all red).

Frement

2010-06-11 17:40:33

From: Blumblebee
or you could always find the HP bar and look for when there is no green in the HP bar (all red).


But the monster can be on the left, right, top, bottom. And your HP bar is allways in the center :)

TRiLeZ

2010-06-11 18:50:35

You could also wait for your hp bar to disappear.

Frement

2010-06-11 18:53:40

From: TRiLeZ
You could also wait for your hp bar to disappear.


From: Frement
Check when hp bar is gone for example.


Said that :(

TRiLeZ

2010-06-11 19:02:56

From: Frement
Said that :(


Oh, sorry, I thought that you were meaning the npc's hp bar.

Ogre

2010-06-11 19:03:49

It's faster to wait until the enemy's hp bar is red than to wait for yours to disappear (only slightly though). Also, your hp bar doesn't appear unless the enemy hits you back, and you might one hit it if it's a chicken or something like that.

Frement

2010-06-11 19:47:15

From: Ogre
It's faster to wait until the enemy's hp bar is red than to wait for yours to disappear (only slightly though). Also, your hp bar doesn't appear unless the enemy hits you back, and you might one hit it if it's a chicken or something like that.


Well, I had:
Flag;
Wait(2000+Random(500));
WhileInFight;

Capricorn

2010-06-11 20:57:40

What I did was check for the colour pure white in the middle of the screen, for the text inside the splashes. Problem is if someone is being hit under you, but it worked for unpopular places.

ownedlikenoob

2010-06-12 00:36:51

From: Frement
Check when hp bar is gone for example.

InFight(); in SRL.

EDIT: Something I used in my script.
function F_InFight: Boolean;
var GTPA, RTPA: TPointArray;
begin
FindColorsTolerance( GTPA, 49499, MSCX - 15, MSCY - 40, MSCX + 15, MSCY, 20 );
FindColorsTolerance( RTPA, 590010, MSCX - 15, MSCY - 40, MSCX + 15, MSCY, 20 );
Result := ( ( GetArrayLength( GTPA ) + GetArrayLength( RTPA ) ) >= 20 );
end;


Ok so could I do something like this

If(findcolor(x,y,0,0,600,600,Monster)) then
begin
Mouse(x,y,true)
Wait Untill(Not(inFight());

Something like that. I kind of just made up the wait until thing. lol So like how would I do that?

Frement

2010-06-12 07:51:50

Heres fast example:
program new;
{$IFDEF SIMBA}
{$I SRL/SRL.scar}
{$ELSE}
{.Include SRL/SRL.scar}
{$ENDIF}

function F_InFight: Boolean;
var GTPA, RTPA: TPointArray;
begin
FindColorsTolerance(GTPA, 49499, MSCX - 15, MSCY - 40, MSCX + 15, MSCY, 20);
FindColorsTolerance(RTPA, 590010, MSCX - 15, MSCY - 40, MSCX + 15, MSCY, 20);
Result := ((GetArrayLength(GTPA) + GetArrayLength(RTPA)) >= 20);
end;

function WhileInFight: Boolean;
begin
while F_InFight do
begin
FindNormalRandoms;
//AntiBan; <-- Your AntiBan procedures here for example.
FindNormalRandoms;
Wait(200 + Random (500));
FindNormalRandoms;
end;
Result := True;
end;

procedure Fight;
var x, y: Integer;
begin
if (FindColorTolerance(x, y, 15125125, MSX1, MSY1, MSX2, MSY2, 15)) then begin
Mouse(x, y, 5, 5, True);
Flag;
Wait(800+Random(100));
WhileInFight;
end;
end;

begin
SetupSRL;
repeat
Fight;
until(False);
end.

masterBB

2010-06-12 07:59:47

procedure CharIsDoingSomething;
var
fails:Integer;
begin
repeat
wait(200);
if(GetAnimation = -1) then
fails := fails +1;
until(fails > 4);
end;

An example of a reflection solution.

ownedlikenoob

2010-06-12 23:39:58

From: Frement
Heres fast example:
program new;
{$IFDEF SIMBA}
{$I SRL/SRL.scar}
{$ELSE}
{.Include SRL/SRL.scar}
{$ENDIF}

function F_InFight: Boolean;
var GTPA, RTPA: TPointArray;
begin
FindColorsTolerance(GTPA, 49499, MSCX - 15, MSCY - 40, MSCX + 15, MSCY, 20);
FindColorsTolerance(RTPA, 590010, MSCX - 15, MSCY - 40, MSCX + 15, MSCY, 20);
Result := ((GetArrayLength(GTPA) + GetArrayLength(RTPA)) >= 20);
end;

function WhileInFight: Boolean;
begin
while F_InFight do
begin
FindNormalRandoms;
//AntiBan; <-- Your AntiBan procedures here for example.
FindNormalRandoms;
Wait(200 + Random (500));
FindNormalRandoms;
end;
Result := True;
end;

procedure Fight;
var x, y: Integer;
begin
if (FindColorTolerance(x, y, 15125125, MSX1, MSY1, MSX2, MSY2, 15)) then begin
Mouse(x, y, 5, 5, True);
Flag;
Wait(800+Random(100));
WhileInFight;
end;
end;

begin
SetupSRL;
repeat
Fight;
until(False);
end.


Thanks, :D can you explain this to me though,

function F_InFight: Boolean;
var GTPA, RTPA: TPointArray;
begin
FindColorsTolerance(GTPA, 49499, MSCX - 15, MSCY - 40, MSCX + 15, MSCY, 20);
FindColorsTolerance(RTPA, 590010, MSCX - 15, MSCY - 40, MSCX + 15, MSCY, 20);
Result := ((GetArrayLength(GTPA) + GetArrayLength(RTPA)) >= 20);
end;

Danizho

2010-06-13 00:54:32

From: masterBB
procedure CharIsDoingSomething;
var
fails:Integer;
begin
repeat
wait(200);
if(GetAnimation = -1) then
fails := fails +1;
until(fails > 4);
end;

An example of a reflection solution.


Can you explain me this?

i luffs yeww

2010-06-13 01:07:01

From: Danizho
Can you explain me this?


Well, no offense to masterBB, he did it kind of silly. It could've been done easier/better. But basically it's just to check if the character is animating or not. And it checks every 200ms, which he should change to 600, as the game runs on ticks, which happen every 0.6 seconds (600ms). There is already an IsAnimating function in reflection to check for that, though.

^ http://goo.gl/pnqj if you want to read more about it. :) I think it's pretty interesting.

From: ownedlikenoob
Thanks, :D can you explain this to me though,

function F_InFight: Boolean;
var GTPA, RTPA: TPointArray;
begin
FindColorsTolerance(GTPA, 49499, MSCX - 15, MSCY - 40, MSCX + 15, MSCY, 20);
FindColorsTolerance(RTPA, 590010, MSCX - 15, MSCY - 40, MSCX + 15, MSCY, 20);
Result := ((GetArrayLength(GTPA) + GetArrayLength(RTPA)) >= 20);
end;


It checks to find the color 49499 where one's HP bar would be, which is the green color, if I inferred that 'G' stands for 'green' and 'R' stands for 'red' correctly, and then checks for 590010, the red color. It stores those two in two different TPAs (GTPA and RTPA, respectively), and then gets the length of them (how many pixels are that color), adds them, and checks to see if those together are greater than 20 (otherwise, the HP bar wouldn't be there, because if it is there, there will always be either 20 pixels of 49499, 20 of 590010, or 20 of the sum of the colors.

Hope that helps.

Danizho

2010-06-13 01:09:13

again, more "findcolor" (and a good explanation too) makes my pc very slow…