SRL Archive - RS3 Script Requests

Using Regenerate to heal


warhawk881

2014-03-03 01:05:51

Hello everyone, I found that using Regenerate to heal instead of food lets you stay in a training place for an indefinite amount of time. However, it can only be activated when out of combat. What would be the best way to find out if the player is out of combat and activate Regenerate. I thought TRSActionBar.isSlotActive would be something to look at. Anyone help?

Clarity

2014-03-03 01:27:43

From my Jr. Members+ Barrows script:


{PROCEDURE -- regenerate
Purpose: Regenerates health after a fight.
Comments: None.}
procedure regenerate;
var
regenerateLocation: TPoint;
begin
if not isLoggedIn or areWeFighting then
exit;
regenerateLocation := point(actionbar.x1 + 24 + random( - 3, 3), actionbar.y1 + 17 + random( - 3, 3));
ClarityDebug('Regeneration initiated.');
if (actionBar.getAdrenalinePercent() > 5) then
begin
mouse(regenerateLocation, MOUSE_MOVE, MOUSE_HUMAN);
fastClick(MOUSE_LEFT);
ClarityDebug('Regenerating health with leftover adrenaline. Did so blindly.');
scriptStatus('Regenerating health.');
wait(GaussRangeInt(300, 1000));
end;
end;

To check if you are in or out of combat, you could do a number of things. You could check for the presence of the health bar above your player, restricting the search to a box around your player so other players' health bars are not detected. A DTM would probably work well.

My check for fighting vs. not fighting is this, but it is specific to the script, you would want to search for a different DTM depending on your script.


{FUNCTION -- areWeFighting
Purpose: Checks if we are fighting a brother.
Comments: None.}
function areWeFighting: boolean;
var
x, y, tries: integer;
begin
if not isLoggedIn then
exit;
result := false;
isAkrisae := false;
ClarityDebug('Checking to see if we are in combat.');
while tries < 4 do
begin
if findDTM(earthWeakness, x, y, mainScreen.getBounds()) or
findDTM(airWeakness, x, y, mainScreen.getBounds()) or
findDTM(rangedWeakness, x, y, mainScreen.getBounds()) or
findDTM(rangedWeaknessAlt, x, y, mainScreen.getBounds()) or
findDTM(fireWeakness, x, y, mainScreen.getBounds()) or
findDTM(stabWeakness, x, y, mainScreen.getBounds()) or
findDTM(waterWeakness, x, y, mainScreen.getBounds()) or
findDTM(boltWeakness, x, y, mainScreen.getBounds()) then
begin
if findDTM(boltWeakness, x, y, mainScreen.getBounds()) then
begin
isAkrisae := true;
ClarityDebug('We are fighting Akrisae!');
end;
result := true;
ClarityDebug('Currently in combat with a Barrows brother.');
exit;
end
else
inc(tries);
end;
end;

Actionbar.isSlotActive might lead to misleading results since I don't believe you need to be in combat for a slot to be selected.

warhawk881

2014-03-03 13:48:14

Thanks Clarity for you answer. I was wondering would the Regenerate icon on the actionbar itself be a good indicator of in combat or out of combat? Because the icon lights up when out of combat and if you have greater than 0 adrenaline. It will stay dim during combat.
Meaning if the icon is lit and adrenaline is greater than 0 you just got out of combat.

Clarity

2014-03-03 17:08:33

From: warhawk881
Thanks Clarity for you answer. I was wondering would the Regenerate icon on the actionbar itself be a good indicator of in combat or out of combat? Because the icon lights up when out of combat and if you have greater than 0 adrenaline. It will stay dim during combat.
Meaning if the icon is lit and adrenaline is greater than 0 you just got out of combat.

Oh wow, that sounds like an awesome and easy indicator then. A simple color search in a circular area around the heart icon would work. Nice idea. :)

Edit: I just tested this and I don't see any change at all in the icon when in or out of combat.

lemonfrosting

2014-03-04 07:57:33

I use this for my dragon killing bot. But i use autohotkey for my whole bot and use a library called FindClick which looks for images and clicks them when found. I find it usefull to look for when i have any adrenalin or not full health then click the regen icon if any of those are true. i have no idea if the library can be used within SRL or not though. Also the regen icon is lit up when out of combat if it is on your action bar and darkenend if in combat.

My bot will then look if my character has full health or no adrenaline and continue to kill dragons if any of those are true.

Clarity

2014-03-04 08:16:31

From: lemonfrosting
I use this for my dragon killing bot. But i use autohotkey for my whole bot and use a library called FindClick which looks for images and clicks them when found. I find it usefull to look for when i have any adrenalin or not full health then click the regen icon if any of those are true. i have no idea if the library can be used within SRL or not though. Also the regen icon is lit up when out of combat if it is on your action bar and darkenend if in combat.

My bot will then look if my character has full health or no adrenaline and continue to kill dragons if any of those are true.

Oh…he means the actual regen ability icon, I thought he meant the heart on the action bar. Then that is a good method of determining combat. Good plan.
SRL has the following useful functions for the action bar:

This could be used to determine if a slot is empty or not:

if (actionBar.isSlotEmpty(1)) then
writeln('The first Action Bar slot is empty.');

This could be used to determine whether a slot is active or not:

if (actionBar.isSlotActive(1)) then
writeln('The first Action Bar slot is activated.');

This is what one can use to look at whether adrenaline or hitpoints are high/low, as used in my regenerate function:

actionBar.getHPPercent();
actionBar.getAdrenalinePercent();
actionBar.getPrayerPercent();
actionBar.getSummoningPercent();

A dragon killing bot sounds cool, I might make one :D

lemonfrosting

2014-03-04 08:44:11

Looks like SRL has many useful hooks to check in game variables. I'm using a bot that can be used on the official client and at any res and screen layout.

However hard coding the detection of logout and all around detection of where the player is and such was hard but it seems to work well.

Revolution combat has eliminated half of my script however as i had built a similar bot for combat that used the regen icon to detect if in combat then it would act the exact same as revolution does now however my bot i feel was a little more reliable.

Edit: is there a way to check if an ability is off cooldown within SRL if it isnt bound to the hotbar?

Clarity

2014-03-04 08:49:52

From: lemonfrosting
Looks like SRL has many useful hooks to check in game variables. I'm using a bot that can be used on the official client and at any res and screen layout.

However hard coding the detection of logout and all around detection of where the player is and such was hard but it seems to work well.

Revolution combat has eliminated half of my script however as i had built a similar bot for combat that used the regen icon to detect if in combat then it would act the exact same as revolution does now however my bot i feel was a little more reliable.

Edit: is there a way to check if an ability is off cooldown within SRL?

This was all with AHK? Very nice!
Revolution seems like a good improvement for fighting scripts in that we used to have to keep ability cooldowns in mind manually using TTimeMarkers, but now Jagex is doing all the work for us with automatic ability activation. I'm excited to release an upcoming fighting script I think a lot of people will like :)

lemonfrosting

2014-03-04 09:02:11

Yeah all with AHK, With the FindClick library it made it so simple to detect when spells were off cooldown and loop through detecting them for example.


loop
{
ImageSearch, FoundX, FoundY, 0,0, 1920, 1080, dragonname.png
If ErrorLevel = 0
{
ImageSearch, FoundX, FoundY, 0,0, 1920, 1080, dead.png
If ErrorLevel = 1
{
regen = 1
sleep 100
ImageSearch, FoundX, FoundY, 0,0, 1920, 1080, combat3.png
If ErrorLevel = 0
{
FindClick("combat3.png"," !a")
break
}
ImageSearch, FoundX, FoundY, 0,0, 1920, 1080, combat2.png
If ErrorLevel = 0
{
FindClick("combat2.png"," !a")
break
}
}
}
}

So loops through my abilities and clicks the earliest one off cool down then there is checks in my code for ability cast by using the regen icon when it does the global cool down and the regen image is no longer seen the script will loop back and cycle my abilities again. check is as such.

loop{
ImageSearch, FoundX, FoundY, 0,0, 1920, 1080, regen.png
If ErrorLevel = 1
{
break
}
sleep 200
}

I was in the process of cleaning the code up with functions when revolution came out. I may however continue and use my own system.