SRL Archive - Jr. Member General Help and Discussion

RS3 Combat script help (OGL)


Thomas

2015-05-15 09:51:45

Hey,

How would I prevent my basic combat script to attack a NPC that is currently in its death animation?
Perhaps I should start sorting the various TPoints of the models and then start right clicking each of them to select option that isn't 'Attack *Troll' but 'Attack Troll'.


function isCombat(): boolean;
begin
if length(ogl.getTextures(7750, mainScreen.getBounds())) or length(ogl.getModels(1452224228, mainScreen.getBounds())) then //either the target reticule or the monster info
exit(true);
end;

procedure attack();
begin
if length(ogl.getModels(403123861, mainScreen.getBounds())) then
begin
wait(gaussRangeInt(500, 1500)); //this currently works semi well (just wait till the one in front of you (closest) is dead
mouse(ogl.getModels(403123861, mainScreen.getBounds()).closest(mainScreen.playerPoint).rand(5), MOUSE_MOVE);
if isMouseOverText(['Attack']) then
fastClick(MOUSE_RIGHT);
if chooseOption.isOpen(500) then
chooseOption.select(['Attack'], 200);
wait(gaussRangeInt(200, 600)); //could replace this with a timer later on, but I like how waits actually pauze my mainloop and save resources
end
else if random(2) then
minimap.setAngle(random(350));
end;


procedure mainloop();
begin
..........
FailTimer.start();
while (not isCombat()) do //have not decided if I would just use; if...then or while...do --> suggestions welcome!
begin
if (FailTimer.getTime() > (randomRange(1000, 1200) * 20)) or (not isLoggedIn()) then
exit();
attack();
end;
..........
end;

Thomas

2015-05-15 10:06:18

I suppose I could tweak the method Ross uses in his slayer script :)
He makes sure the next target is a certain amount of pixels away from his current target.

I suppose I could draw a TBox around the target reticule, move it up slightly, and look for a TPoint oglmodel that isn't inside the TBox?
Or turn all NPC's into ATPA's and sort them by distance and select second closest as next.
Problem with both those methods might be moving models?

*edit*

Maybe putting a TBox around the target (based on target reticule) and attack next target that isn't in the TBox is the best solution?

*edit*

Current solution, still need help with the TP X,Y coordinates?
function isCombat(): boolean;
begin
if length(ogl.getModels(1452224228, mainScreen.getBounds())) then //check for target reticule
begin
CurrentFight := ogl.getModels(1452224228, mainScreen.getBounds()).closest(mainScreen.playerPoint).offset([0, 20]); //Offsets the target reticule
exit(true); //no need to check for fight info
end;
result := length(ogl.getTextures(7750, mainScreen.getBounds())); //incase there isn't a reticule but still in combat, might not be needed
end;

procedure attack();
var
TPA: TPointArray;
i: Integer
begin
if length(ogl.getModels(403123861, mainScreen.getBounds())) then //only if troll brutes visible
begin
TPA := FilterPointsDist(ogl.getModels(403123861, mainScreen.getBounds()).toTPA(), 20, 500, CurrentFightX, CurrentFightY); //currentfight TPA X,Y ---> HOW!!
TPA.sortFromPoint(mainScreen.playerPoint);
for i := 0 to high(TPA) do
begin
mouse(TPA[i].rand(5), MOUSE_MOVE);
if isMouseOverText(['Attack']) then
Begin
fastClick(MOUSE_RIGHT);
if chooseOption.isOpen(500) then
If chooseOption.select(['Attack'], 200) then
break;
end;
end;
end
else if random(2) then
minimap.setAngle(random(350));
end;

Suppose I dont need to for I to highATPA since they'll probably be moving

Obscurity

2015-05-15 15:34:10

On my phone, so excuse the bad reply.

Procedure Loop:
Begin
If Combat.HasTarget() Then
TargetPoint:=Combat.GetTarget().ToPoint()
Else If Length(MonsterModels:=OGL.GetModels(MonsterID)) Then
Begin
If Not MonsterModels[0].ToPoint().Equals(TargetPoint)
Mouse.Click(MinsterModels[0].ToPoint())
Else If Length(MonsterModels)>1 Then
Mouse.Click(MonsterModels[1].ToPoint());
End;
End;

You get the idea.

Thomas

2015-05-15 15:49:20

From: Obscurity
On my phone, so excuse the bad reply.

Procedure Loop:
Begin
If Combat.HasTarget() Then
TargetPoint:=Combat.GetTarget().ToPoint()
Else If Length(MonsterModels:=OGL.GetModels(MonsterID)) Then
Begin
If Not MonsterModels[0].ToPoint().Equals(TargetPoint)
Mouse.Click(MinsterModels[0].ToPoint())
Else If Length(MonsterModels)>1 Then
Mouse.Click(MonsterModels[1].ToPoint());
End;
End;

You get the idea.


Thanks! But I'm not using oglib. I'm using srl-6.
I was just looking for other ideas. But indeed the most obvious method is the one Ross uses in his Slayer and the one you suggested (like I somewhat implemented myself).

But I'm gonna try to use this part you suggested:
If Not MonsterModels[0].ToPoint().Equals(TargetPoint)

Clarity

2015-05-15 19:05:05

You're using SRL-6? I see ogLib code in your initial examples. Currently the two libraries aren't compatible unless you've made your own custom include files.

Obscurity

2015-05-15 20:28:47

I am equally as confused.

ogl.getTextures(7750, mainScreen.getBounds())

ogl.getModels(1452224228, mainScreen.getBounds())

ogl.getModels(403123861, mainScreen.getBounds())

ogl.getModels(403123861, mainScreen.getBounds()).closest(mainScreen.playerPoint)

minimap.setAngle(random(350))

Are all from ogLib. If you need help, you're going to have to explain yourself a bit better - because you've lost me. :P.

Thomas

2015-05-16 02:17:14

The mayor has made some edits to srl-6.
He linked me his version.

For example it has no combat.hastarget AFAIK.
Or combat.getTarget.topoint.

Minimap.setangle has been in srl-6 for ages I think.

I am only using his version of srl-6. No oglib included.
Basicly it allowed me to keep login functions/breaking systems etc from my other scripts.

Clarity

2015-05-16 13:28:13

Maybe @The Mayor can explain. Did he make a hybrid include?
I don't understand why you insist you aren't using ogLib when there is direct code from that library (ogl.getModels, etc).

I'd like to help you with your issue so a better picture of the code you're using would be great!

If a portion of SRLCompatibility has already been made then I'd love for it to be shared :) Would save me lots of time!

Thomas

2015-05-16 13:39:31

From: Clarity
Maybe @The Mayor can explain. Did he make a hybrid include?
I don't understand why you insist you aren't using ogLib when there is direct code from that library (ogl.getModels, etc).

I'd like to help you with your issue so a better picture of the code you're using would be great!


He made a hybrid with the ogl plug-in AFAIK.
I have not included the oglib in this script.

I currently have solved the problem, with something very similar to what I posted before.
Just nerds some more tweaking.

For your edit:
I'm pretty sure he only made some basic changes to srl and made a seperate include with minor ogl functions.

I think smart.simba, ogl.simba and core.simba have been added. Either way it are only 3 files.
The ogl.simba includes some basic getmodel/texture functions, I suppose others are just tweaked to support ogl.

Clarity

2015-05-16 14:01:29

Oh, alright. I'll keep working on ogLib's SRLCompatibility then :)

The Mayor

2015-05-16 14:02:21

I more or less used Brandon's original methods to see how integration with srl-6 would look on a simple level. Basically a 10 minute copy paste job https://github.com/SRLTheMayor/SRL-6/commit/1978e639a885079a4d6be4832548275c20c68cc2

This won't be official or anything because of the fps issues which basically made ogl a dead end 2 years ago. The only thing I can see working in directX.

Ross

2015-05-24 08:51:28

@lovebotter if you're having trouble with this, take a look at either my color slayer in jr mems+ (outdated but the combat stuff should work) or my OGL basic slayer in public. They both have a solution to this.

Thomas

2015-05-24 09:42:12

Thanks Ross :) I have resolved it a while ago in both oglib, srl-6 and srl/ogl lib :)
I might post my solutions later, but got exams soon..