SRL Archive - OSR Help

Hitpoints Bar?


koryperson

2013-11-21 22:52:22

Hey guys, so I've always just made scripts for skilling but now I wanna move up a notch and make some basic auto fighters. I just can't seem to figure out a way to check when a monster dies. I've tried bitmaps which worked pretty well, but it goes crazy in a crowded combat zone, help pl0x?

sahibjs

2013-11-22 01:18:29

Well, I haven't touched runescape or simba in a long time, but I remember a certain function in the SRL library that was something along the lines of incombat() or isincombat() and using that would check if you were in combat. Not sure how SRL 6 has changed things, but just check out the library

Tickyy

2013-11-22 03:10:45

Hi there!

sahibjs is right, there is a function that already does that

function InFight: Boolean;

While InFight do
// Eat, antiban, Antirandoms, etc

bonsai

2013-11-22 07:37:00

From: Tickyy
Hi there!

sahibjs is right, there is a function that already does that

function InFight: Boolean;


That's an SRL5 function and not avaiable on SRL6. I'm not sure the colors/counts are still valid with the updated game.

It uses the health bar above your head which is unreliable. Sometimes that bar stays over your head long after a fight has ended.

I've been using a combination of two ways of detecting the popup box (target info?) that comes up when you start a fight. I use a DTM that matches some of the black boxing on the right hand side and a secondary color method (getting the blackish color to define a box and looking in that box for the white and green colors).

Even this is not fully reliable. When another NPC wanders under your mouse you can get a second popup showing and if you are ranging or using magic your fight may not even be on screen.

I'm looking to add some pixel shift / animation detection. Also looking at the target rings that appear under the NPC you are fighting. Or catching the increase in XP, that's a true indicator the fight is done.

DTM:
'mrAAAAHichcqxCkAAAEXRJyllUharMiCDMjIpm29mNCkmROJL3JSVV2d4dW1JkyltGLHiwI4TF1qaDjMWbDgxoEdaNXJc7+GHkYIkU5wXz4/KWhbNF+PHuxuG4xEk'

Colors:

Popup Blackish color - 2960658 tol 8 hue 6.25 sat 3.35
White NPC name - 15658990 tol 7 hue 4.77 sat 0.44
Green health bar - 3114537 tol 13 hue 0.03 sat 0.31

Ashaman88

2013-11-22 08:40:56

If there is still that "target" tab which shows the target w/ weaknesses or w/e - just use that. There was even a function or two related to "hastarget" or something like that. The target in the tab goes away as soon as the monster dies, so if you just wait to see when that goes away - boom means target is dead

Hoodz

2013-11-22 08:57:25

rs3 or osr?

bonsai

2013-11-22 09:05:11

I'm talking RS3, not sure about OP. And I think that combat tab disappeared from the interface, someone please correct me if I just never found it!

koryperson

2013-11-22 10:49:42

That awkward moment when you're scripting for an RSPS haha

I'm trying to script combat scripts for an RSPS but the functions aren't compatible with most of them. I'm pretty new at this whole scripting scene, but is there any way to repeatedly check the hp bar until it can't find one? I'm trying to make my combat script just 2 procedures, one for clicking on the monster, and the other for waiting until it's dead without a constant wait time between clicks.

bonsai

2013-11-22 12:28:33

searchBox := intToBox(430, 275, 490, 283);
findColorsTolerance(tpa, 46410, searchBox, 8, colorSetting(2, 0.79, 0.0));

This is working for me on rs3. Typically returns 74 points when 100% healthy.

koryperson

2013-11-22 19:24:11

Basically all I need to know is how to run a procedure until the procedure is true, I tried just inputting true but that didn't work. What I'm attempting is to continue searching for the HP bar bitmap I created, then move on to ClickMonster then repeat the process of searching for the bitmap, then clicking again. I just can't seem to get this to work.

procedure HPbitmap;
begin
repeat
FindBitmapIn(hpbar, X, Y, 1, 4, 515, 338)
until(true)
Wait(3000)
ClickMonster;
End;

bonsai

2013-11-23 05:18:08

From: koryperson
Basically all I need to know is how to run a procedure until the procedure is true, I tried just inputting true but that didn't work. What I'm attempting is to continue searching for the HP bar bitmap I created, then move on to ClickMonster then repeat the process of searching for the bitmap, then clicking again. I just can't seem to get this to work.

procedure HPbitmap;
begin
repeat
FindBitmapIn(hpbar, X, Y, 1, 4, 515, 338)
until(true)
Wait(3000)
ClickMonster;
End;


They way you have it the program is throwing away the true/false returned by FindBitmapIn.

You either need to save it in a variable or use it directly in the test.

procedure HPbitmap;
var found: boolean;
begin
repeat
found := FindBitmapIn(hpbar, X, Y, 1, 4, 515, 338)
until(found)
Wait(3000)
ClickMonster;
End;

procedure HPbitmap;
begin
repeat
until(FindBitmapIn(hpbar, X, Y, 1, 4, 515, 338))
Wait(3000)
ClickMonster;
End;

koryperson

2013-11-23 19:41:18

From: bonsai
They way you have it the program is throwing away the true/false returned by FindBitmapIn.

You either need to save it in a variable or use it directly in the test.

procedure HPbitmap;
var found: boolean;
begin
repeat
found := FindBitmapIn(hpbar, X, Y, 1, 4, 515, 338)
until(found)
Wait(3000)
ClickMonster;
End;

procedure HPbitmap;
begin
repeat
until(FindBitmapIn(hpbar, X, Y, 1, 4, 515, 338))
Wait(3000)
ClickMonster;
End;


Oh my gosh, this is EXACTLY the answer I was looking for, thanks much!