SRL Archive - OSR Help

Monster in combat detection?


Ryutoh

2013-05-23 20:30:43

How would it be done? I was thinking of having the script check if there's an hp bar above the monster but not entirely sure on how to get it working.

This is where I'd want to implement it.

begin
if not FindObjEx(X, Y, ['ttak', 'iant', 'rypt', 'at'], [8358276, 6975078, 8358271, 6058844, 7244398, 6190685, 7371120, 9278344, 5136973, 4738632], 3, 50, MSX1, MSY1, MSX2, MSY2) then
begin
findMonster;
end
end;

rj

2013-05-23 21:05:55

I suggest looking into TPAs and ATPAs, with them it can pretty much find the monster in a little box, and within that box you could look for a HP bar.


http://villavu.com/forum/showthread.php?t=92301

http://villavu.com/forum/showthread.php?t=49067

Ryutoh

2013-05-23 21:14:34

From: Officer Barbrady
I suggest looking into TPAs and ATPAs, with them it can pretty much find the monster in a little box, and within that box you could look for a HP bar.


http://villavu.com/forum/showthread.php?t=92301

http://villavu.com/forum/showthread.php?t=49067

Thank you very much, just want I need!

samerdl

2013-05-24 07:47:27

Once you grasp TPA'S, look at this topic, many solutions have been offered:

http://villavu.com/forum/showthread.php?t=102670

my favorite is getting the bound of the ATPA then increasing its size just a bit so it, and if it doesn't find the HP bar Red/Green Color and Blue/Red splat hit colors inside the box, it will attack, else it will search again for another monster, you make the bounds over the monster :-).

Works quiet well on large monsters, but really hard for a monster like Tz-Kih.

Also you can do a timer command fail safe, setup a Timer:integer var and have it reset every-time the script does a red click (attack) then the loop cant repeat the attack procedure if the time running for the script is shorter than the time to re-attack (like say your running to a monster and need it to click only once not 5 times while your running towards it, this way it clicks once and you dont need to put any wait time/sleep time after click, your script continues to cycle through the mainloop and fail safes and random detection :-).

Something like this:


program TestTimers;

{$I SRL-OSR/SRL.Simba}


var
AttackTimer:integer;

const
AttackTime1 = 5000;
AttackTime2 = 7000;


procedure Attacktiming;
begin
AttackTimer := GetTimeRunning + RandomRange(AttackTime1,AttackTime2);
end;



Function killit:boolean;
begin
{script here
{and here...
{ and so on...
{ at the end:}

if didclick(true,2000) then
begin
Attacktiming; // this resets your Timer, adds up 5 seconds or whatever time

result := true; // you want it to add and won't repeat attack till 5 seconds
exit; // have passed.. Above this you should have a Tbox as ATPA
end; // or TPA Bounds and increase about 12-17 pixels above it
// So if it finds Hp Bar colors or Splat Colors it will not
// attack the monster again nor reset the timer. I suggest
// ATPA Bounds or look into what ShatterHand posted.



procedure AttackMonster;
begin

if (not(loggedin)) then exit;

if (GetTimeRunning >= AttackTimer) then
begin
Killit;
end;
end;


begin
setupsrl;
AttackMonster;
end.


So that way it starts with your timer as Zero, once it attacks it will add 5 seconds (or whatever you decide) onto the timer, so that way it won't repeat attacks for at least 5 seconds (or whatever time you need).
I think its better this way than adding Sleep/Wait times after click, at least its working for me :).

I recommend you start with something simple as TPA bounds then increase box size around it to include hp bar/splat hits colors

I.E these colors:

Color: 255, Tol: 3.
Color: 192, Tol 3.
Color: 65280, tol: 3.
Color: 16777215, tol 3.


You can also use DTM'S or merging some TPA's and excluding others (look at shatterhand post, but only do so once you fully grasp tpa's), debug all the stuff while you do it ;0

Good luck!