SRL Archive - OSR Help

OSR Fighter script ideas help


Haxz

2013-04-25 11:08:49

I've started to think what my next project should be after failing on having a reliable walking method for runecrafting. Color changes and minimap shifting are doing its job to stop color bots. It seems to be that back then at 2007, Runescape focus more on killing color bots lol.

My membership is going to run out, and I need to get some cash before it does to buy another membership. I was thinking combat might get me quite some cash. And I started to make a fighter script with functions that could fight anything, so I can use it in future to fight other NPC too. Then I come to another problem. On OSR mainscreen, your character position will shift too.

WTFBBQDAFUQLOLOL!@#%$^&%^&*(&(&*%$#$@#@#$@#@#!!

Other than that, MMtoMS doesn't work well in OSR. I was still thinking of a function that doesn't use only colors to find NPC, instead, using MMtoMS for npc dots, and make a box in mainscreen with the tpoint, then find the color of npc. But now, naaawwww! Character position changes, so it is hard to get the area of hp bar, or the character for pixelshift. Using a wider area might count another player's hp bar or pixelshift and end up with false result.

TL DR.
I need some ideas on how to exactly get your character position, character hp bar position, target hp bar position, and how to get position of your target's loot.

I personally had some ideas in mind. I might get the character's hair/cloth/pants (most probably hair) color, then create a box from there so I can get my character's position and hp bar position. As for target's position, I had some ideas too but its not really efficient.

I think scripting with Simba is all about creative and innovative. You need to be creative with the functions to make an efficient script.

Hope I'll get to see some creative ideas from the community while I script. Thanks :D

Ian

2013-04-25 11:19:38

Your character position should be (MSCX, MSCY)
Your HP bar position will be in a box a certain distance above that, and it rotates with your screen so as long as you're at High angle it should be pretty much in the same box always.

Haxz

2013-04-25 11:21:07

From: BMWxi
Your character position should be (MSCX, MSCY)
Your HP bar position will be in a box a certain distance above that, and it rotates with your screen so as long as you're at High angle it should be pretty much in the same box always.


Nope, I've tested. Character will not be in the middle of the main screen most of the time sometimes. That's what I meant by character position shifts too.

EDIT: After reloading OSR after update, character position didn't change that much anymore for me :eek:

EDIT2: I'm wrong, it still do.

Flight

2013-04-25 12:01:02

You'll probably want to check out this utility by Shatterhand; it's the most accurate way of determining our player's HP percent based on our HP bar while in combat. I changed up the bounds a bit to be more accurate (atleast for me) as such:

X1 := 236;
Y1 := 134;
X2 := 287;
Y2 := 156;

Next, what I did to determine if our player was in combat, was make a function that returns all the HP bars found on the MS. I do this with simple DTMs, by making 3 different DTMs of HP bars: a fully healthy bar, a damaged health bar and a fully damaged (dead) health bar.

//Full health bar
HB_1 := DTMFromString('mWAAAAHicY2FgYPgLxO+hNA8jA8MMID0VCTP8R8UgipUBQTOiYRAAAHPNC1o=');
//Damaged health bar
HB_2 := DTMFromString('mQwAAAHicY2ZgYPgHxO+BmIeRgWEPkN4JxQz/IRhKMbBCMSMSBgIAYmsINQ==');
//Dead health bar
HB_3 := DTMFromString('mQwAAAHicY2ZgYGBkZGD4DKQFgPQOIL0Viv+jYVYoZkTCQAAAJfgHNQ==');

I search for all 3 DTMs, split the TPAs so none are over-lapped, return the middle of each [TPA] and the result is a TPA of the middle of every HP bar on the screen. Next, I count the health bars within a specific box region around my player (this region depends on the size of the NPC you're fighting) and if there's atleast 2 points inside (our player's health & our target's health) then the script registers us as "in combat".

You're probably wondering why I made a DTM of a dead NPC health bar. The answer is because my target-finding function is meant to exclude NPCs who are already in combat as well as dead, so we don't attack someone else's target. This is done by finding all target NPC's on the screen and then searching above the top of each of them for any 3 of the health bars. Now if we're fighting an NPC and do that finishing blow that changes their health bar to all red then we're ready to search and find another NPC. With my function I explained earlier that finds all the health bars, I can set it to include or ignore dead NPCs. I simply include it for this step, so when we kill an NPC and start looking for another we don't click on the same NPC we just killed. It makes for a much faster performance.


I hope I didn't lose you in that explanation, ha. I was only meaning to explain one of the possible ways to go about making a combat script for OSR. The best advice I can give you is think of how you yourself actually determine if you're fighting or not, which NPC is the one you're fighting. There's always a way to detect things like that, it's just up to you if you're willing to spend the time to replicate human detection in a script. Just stop and think how you, with your own eyes, determine this stuff.

Haxz

2013-04-25 12:26:55

From: Flight
You'll probably want to check out this utility by Shatterhand; it's the most accurate way of determining our player's HP percent based on our HP bar while in combat. I changed up the bounds a bit to be more accurate (atleast for me) as such:

X1 := 236;
Y1 := 134;
X2 := 287;
Y2 := 156;

Next, what I did to determine if our player was in combat, was make a function that returns all the HP bars found on the MS. I do this with simple DTMs, by making 3 different DTMs of HP bars: a fully healthy bar, a damaged health bar and a fully damaged (dead) health bar.

//Full health bar
HB_1 := DTMFromString('mWAAAAHicY2FgYPgLxO+hNA8jA8MMID0VCTP8R8UgipUBQTOiYRAAAHPNC1o=');
//Damaged health bar
HB_2 := DTMFromString('mQwAAAHicY2ZgYPgHxO+BmIeRgWEPkN4JxQz/IRhKMbBCMSMSBgIAYmsINQ==');
//Dead health bar
HB_3 := DTMFromString('mQwAAAHicY2ZgYGBkZGD4DKQFgPQOIL0Viv+jYVYoZkTCQAAAJfgHNQ==');

I search for all 3 DTMs, split the TPAs so none are over-lapped, return the middle of each [TPA] and the result is a TPA of the middle of every HP bar on the screen. Next, I count the health bars within a specific box region around my player (this region depends on the size of the NPC you're fighting) and if there's atleast 2 points inside (our player's health & our target's health) then the script registers us as "in combat".

You're probably wondering why I made a DTM of a dead NPC health bar. The answer is because my target-finding function is meant to exclude NPCs who are already in combat as well as dead, so we don't attack someone else's target. This is done by finding all target NPC's on the screen and then searching above the top of each of them for any 3 of the health bars. Now if we're fighting an NPC and do that finishing blow that changes their health bar to all red then we're ready to search and find another NPC. With my function I explained earlier that finds all the health bars, I can set it to include or ignore dead NPCs. I simply include it for this step, so when we kill an NPC and start looking for another we don't click on the same NPC we just killed. It makes for a much faster performance.


I hope I didn't lose you in that explanation, ha. I was only meaning to explain one of the possible ways to go about making a combat script for OSR. The best advice I can give you is think of how you yourself actually determine if you're fighting or not, which NPC is the one you're fighting. There's always a way to detect things like that, it's just up to you if you're willing to spend the time to replicate human detection in a script. Just stop and think how you, with your own eyes, determine this stuff.


I'll try to look into Shatterhand's functions later. He made the best fighter script IMO, learnt a lot by reading his script before I start making mine.

Checking for dead health bar totally makes sense, how did I not think about using it to check for targets lol. I've only used the dead health bar DTM for searching loots. I am now checking and observing from different angles to find if there is anything that can differentiate my own target and another player's target. Still no good result though, hope I can discover or think of something creative soon.

If you don't mind, can you show me how you made DTMs into TPAs? What Shatterhand did was combine 2 TPAs together, but not DTM.

EngageTheRage

2013-04-25 12:56:24

hey there :)just thought i'd share with you how my fighter script works :)

firstly i check if i am in combat, to do this i have spent quite a lot of time testing what area my character stays within, i have found that searching for the green of hp bar (red isnt needed because if there is no green you're dead!) within a certain box the most effective:


if(FindColor(cx, cy, 65280, 220, 110, 300, 190)) then
begin
MyDeBug('In Combat');
Eat;
AntiBan;
numberOfLoops := 0;
lastTimeCombat := True;
away := True;
end;

obviously this isnt 100% accurate, as if someone else is near/ontop of you and they are in combat, you'll get a false positive, but my script is supposed to be run with no one else around so i dont really mind that. but if you are in combat, it detects it 99% of the time (hasnt had any noticeably fails in my tests).

with finding monsters, i search for a certain color, obtain TPA's of all location of that color and store that in an ATPA using the SplitTPAEx function. next i search the given boxes for the monsters secondary color, this have preoven very accurate so far with locations i have added!

after obtaining an array of TPA's each giving a box around each monster, i check if they are in combat. to do this i iterate through the ATPA, and for each box around a monster i create a new box that the monsters hp bar should be in.


if(FindColor(cx, cy, 255, bounds.X1, bounds.y1-10, bounds.X2, bounds.Y1 + 30)) then
begin
MyDeBug('that monster is in combat');
AreNoobsTalking;
wait(randomrange(200,500));
inc(i);
continue;
end else

////// this is where i attack as its not in combat!

i then use a custom getUpText method and check if it is infact the monster in question and bobs your uncle!


i hope that this was useful, obviously im new here and new to pascal so my code may not be excellent, but i hope that the ideas behind it help you!

Good Luck on your fighter script!

EDIT: forgot to mention, in that last piece of code there is a check beforehand to make sure that the first y co-ord is >10, otherwise the bounds.y1-10 throws an error :D

Haxz

2013-04-25 13:23:09

From: EngageTheRage
hey there :)just thought i'd share with you how my fighter script works :)

firstly i check if i am in combat, to do this i have spent quite a lot of time testing what area my character stays within, i have found that searching for the green of hp bar (red isnt needed because if there is no green you're dead!) within a certain box the most effective:


if(FindColor(cx, cy, 65280, 220, 110, 300, 190)) then
begin
MyDeBug('In Combat');
Eat;
AntiBan;
numberOfLoops := 0;
lastTimeCombat := True;
away := True;
end;

obviously this isnt 100% accurate, as if someone else is near/ontop of you and they are in combat, you'll get a false positive, but my script is supposed to be run with no one else around so i dont really mind that. but if you are in combat, it detects it 99% of the time (hasnt had any noticeably fails in my tests).

with finding monsters, i search for a certain color, obtain TPA's of all location of that color and store that in an ATPA using the SplitTPAEx function. next i search the given boxes for the monsters secondary color, this have preoven very accurate so far with locations i have added!

after obtaining an array of TPA's each giving a box around each monster, i check if they are in combat. to do this i iterate through the ATPA, and for each box around a monster i create a new box that the monsters hp bar should be in.


if(FindColor(cx, cy, 255, bounds.X1, bounds.y1-10, bounds.X2, bounds.Y1 + 30)) then
begin
MyDeBug('that monster is in combat');
AreNoobsTalking;
wait(randomrange(200,500));
inc(i);
continue;
end else

////// this is where i attack as its not in combat!

i then use a custom getUpText method and check if it is infact the monster in question and bobs your uncle!


i hope that this was useful, obviously im new here and new to pascal so my code may not be excellent, but i hope that the ideas behind it help you!

Good Luck on your fighter script!

EDIT: forgot to mention, in that last piece of code there is a check beforehand to make sure that the first y co-ord is >10, otherwise the bounds.y1-10 throws an error :D


That certainly helped! Thanks!

But the problem with this is, like you said, it won't be accurate if there's another player nearby you since the box you used for finding hp bar is quite big.

Would like to see how your fighter script loots. Does it use colors to find loot's colors after finishing a npc? Or you might have some cooler ways of finding it?

EngageTheRage

2013-04-25 13:32:05

i have 2 methods depending on the monster so far.

1 - a monster who drops an item every kill (like big bones). i search the entire MainScreen immediately after leaving combat (you can see in the earlier code the variable lastTimeCombat that i use), then it is a simple case of checking up text and either left clicking if it is wanted loot or right clicking if there is an npc over it or other loot covering it. i also have a mode to collect and bury bones/big bones which speeds this up as there is usually only the previous monsters bones to check (if you are on your own)!

2- if there are no big bones or everytime drop then i use the box that has previously been created around the monster and instead of moving it up as i did when looking for the hp bar i move it slightly further down and check that area for loot, on the first iteration after being in combat.

this method i am still working on as for agressive monsters i need to find which monster i am in combat in if they attacked me, im currently searching the box i created for my hp bar to find any monsters in it (works as long are you are meleeing). again though, with lots of people in the same area this becomes messy as 2 or 3 monsters and people can all be very close!

Haxz

2013-04-25 14:24:05

I don't really like the first method, which is commonly used in fighter scripts. Because I wanted to make a loot function that loots multiple items. If it finds a big bone that is not dropped by the monster you killed, it would missed out the other loots under it.

As for the second method, if the monster is maybe 4 tiles distance from your character and you made a box around the monster, after you clicked it, character will move to the monster and monster will not be in the box anymore, right? Maybe I misunderstood the method :p

EngageTheRage

2013-04-25 14:30:25

From: Haxz
I don't really like the first method, which is commonly used in fighter scripts. Because I wanted to make a loot function that loots multiple items. If it finds a big bone that is not dropped by the monster you killed, it would missed out the other loots under it.

As for the second method, if the monster is maybe 4 tiles distance from your character and you made a box around the monster, after you clicked it, character will move to the monster and monster will not be in the box anymore, right? Maybe I misunderstood the method :p


to clarify - the first one searches the top of the pile for your loot list, if the uptext is in your loot array it left clicks and moves on (my assumption is only one drop per monster but that could easily be changed) if there is nothing on the top, then it right clicks and checks the option list against your loot array (if you wanted you could skip the first part and just have the right click) then after those checks, it picks up the bones and buries when your inventory is full.

yeah the second one is a work in progress, im looking at tracking the monster you click on so that i can expand the script to accommodate range training, but the same thing applies for this method of looting. at the moment i have been using the idea that the monster is next to you so get that monster and check under him.

i think that makes sense now? lol