SRL Archive - SRL Archives

[Gametab.Scar] Special attack!


Naike

2008-11-18 16:49:24

program New;
{.include SRL/SRL.scar}


{*******************************************************************************
Function CountSpecial: Integer;
By: N1ke!
Description: Counts special attack power, results in 25, 50, 75 or 100.
*******************************************************************************}
Function CountSpecial: Integer;
var
Spec : array [1..2] of TPoint;
i, x, y : Integer;
begin
If Not GameTab(1)Then Exit;
Spec[1] := Point(602, 417);
Spec[2] := Point(619, 426);
For i:=1 to 4 do
begin
If FindColorTolerance(x, y, 4294720, Spec[1].X, Spec[1].Y, Spec[2].X, Spec[2].Y, 10)then
begin
Result := Result + 25;
Spec[1] := Point(Spec[1].X + 28, Spec[1].Y);
Spec[2] := Point(Spec[2].X + 28, Spec[2].Y);
end else Exit;
end;
end;


{*******************************************************************************
Function UseSpecial(PowerNeed: Integer):Boolean;
By: N1ke!
Description: Uses special. Powerneed = How much power you need to
perform a special attack ( 25/50/75/100% ).
*******************************************************************************}
Function UseSpecial(PowerNeed: Integer):Boolean;
begin
If CountSpecial >= PowerNeed then
begin
MouseBox(574, 417, 710, 426, 1);
Result := True;
end;
end;

begin
SetupSRL;
Wait(5000);
UseSpecial(100);
end.


Made a little more advanced special attack function, not just clicking it.

Why? Becuase SRL doesnt have any.

EvilChicken!

2008-11-18 16:54:58

Good job, N1ke.

This is actually a somewhat "smart" function, if you know what I mean.
I like it :)

But, are you sure that color always will be found with 10 tolerance?
And also, at the start of the function(s), you might want to add "Result := -1" followed by "if not LoggedIn then exit;".


E: Bah, didn't really see the GameTab failsafe >_>
I just quickly skimmed over it ..

Naike

2008-11-18 17:03:46

No to both actully ^^

If GameTab Fails, which it will if your not logged in! then it exits…

CountSpecial will count your special, so -1 will not be very accurate xD

and about the color, I'm not sure but it be suprised if it didnt work! otherwise just add a extra 5 tol ;)
<3

Naum

2008-11-19 02:53:27

Maybe use a CountColor for the bar, but nevertheless good job!

Btw. Is this what you asked me about on Msn?

HyperSecret

2008-11-19 09:34:13

I don't really think it will effect the function but doesn't different weapons use different amounts of special attack? I could be wrong, but I thought my maul used more special attack then the ddp++

Naike

2008-11-19 09:36:29

NaumanAkhlaQ :
Yes it is..
CountColor? Never worked with it, Teach me on msn later?

HyperSecret :
{*******************************************************************************
Function UseSpecial(PowerNeed: Integer):Boolean;
By: N1ke!
Description: Uses special. Powerneed = How much power you need to
perform a special attack ( 25/50/75/100% ).
*******************************************************************************}
Function UseSpecial(PowerNeed: Integer):Boolean;
begin
If CountSpecial >= PowerNeed then
begin
MouseBox(574, 417, 710, 426, 1);
Result := True;
end;
end;

PowerNeed will be how much the weapons special will drain, etc Dragon dagger would train 25 while granite maul would do 50 :)

ZephyrsFury

2008-11-19 09:40:49

Perhaps you could use FindColorsTolerance on the colours of the special attack bar then use that to work out accurately the percentage left. I made similar to that once… lemme see if I can find it.

Also CountColor is pretty simple. Just define a colour and a search area and it will return the number of points in that area with that colour. CountColorTolerance does the same thing except with a tolerance.

EDIT:

function SpecialAttackPercent: Integer;
var
CTS: Integer;
Pts: TPointArray;
TB: TBox;
begin
GameTab(1);
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.04, 0.50);
if (FindColorsTolerance(Pts, 1921307, MIX1, MIY1, MIX2, MIY2, 17)) then
begin
TB := GetTPABounds(Pts);
Result := Round(((TB.x2 - TB.x1) / 141) * 100);
end;
if (Result = 0) then Result := -1;
Status('SAP: ' + IntToStr(Result) + '%');
SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(CTS);
end;

Not sure if the colours have changed (I haven't had a members acc for a couple of months now).

Narcle

2008-11-19 09:50:20

I made one for my Nautilus script… Just haven't perfected the actually usage/recording yet.

function SpecialPercent: integer;
var
z: Integer;
TPA: TPointArray;
begin
GameTab(1);
z := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
FindColorsTolerance(TPA, 2985515, 572, 427, 712, 428, 80);
ColorToleranceSpeed(z);
result := Round(GetArrayLength(TPA) / 283.0 * 100.0);
end;

Btw returns 0-100 percent and its always increments of 10. so 0, 10, 20, etc.

n3ss3s

2008-11-19 09:56:33

Couldn't you just do a vertical for loop on the top of the special bar, then break when not at green color anymore. If X div oneblockswidth > needed Then clicky…

PvH

2008-11-19 11:14:47

What about the 55% ranged things?
And good job on this:)

PvH

Naum

2008-11-19 12:34:36

Also you can find out the percentage by Merging the TPA's together.