SRL Archive - SRL Archives

* Fighting.scar


Richard

2009-05-18 21:52:11

I was thinking that people may like making an autofighter, and these are just a few procedure/functions that could make it easier.

IsAutoRetaliateOn

Pretty simple, checks if auto retaliate is on:

{*******************************************************************************
Function IsAutoRetaliateOn: Boolean;
By: Richard
Description: Returns true if auto retaliate is on
*******************************************************************************}

Function IsAutoRetaliateOn: Boolean;
Begin
GameTab(1);
Result := (GetColor(692, 391) = 1711220);
end;


SetAutoRetaliate

Set the auto retaliate button to either on or off:

{*******************************************************************************
Function SetAutoRetaliate(On : Boolean): Boolean;
By: Richard
Description: Set auto retaliate to on if true, off if false. Returns the result
false if it is unable to execute the function.
*******************************************************************************}

Function SetAutoRetaliate(SetOn : Boolean): Boolean;
Var
c: Integer;
Begin
If (IsAutoRetaliateOn = SetOn) then
Begin
Result := True;
Exit;
end;
c := (GetColor(692, 391));
MouseBox(571, 361, 713, 396, 1);
If (GetColor(692, 391) <> c) then
Result := True;
end;


SpecialAttack

Now this I'm not entirely sure that it'll work, due to the varying colour of green across the bar, but all testers found it successful. It clicks the attack bar if it is above of equal to the percent defined:

{*******************************************************************************
Procedure SpecialAttack(MinPercent: Integer);
By: Richard
Description: Use the special attack button if it is present, and presses it if
the percent of the bar filled is >= MinPercent
*******************************************************************************}

Procedure SpecialAttack(MinPercent: Integer);
Begin
GameTab(1);
If (GetColor(623,424) = 65535) then
Begin
WriteLN('Special attack is already active');
Exit;
end;
If (GetColor(623,424) <> 1048576) then
Begin
WriteLN('Current weapon doesn'#39't have a special attack');
Exit;
end;
If (MinPercent <= Round((((CountColorTolerance(3700023, 572, 417, 713, 428, 120))/1634)*100))) then
MouseBox(570, 413, 714, 431, 1);
end;


SetAttackStyle

Sets the attack styles, the number you enter is worked out as you go across for normal attack styles, and down for the staff attack styles.

Note: This doesn't set the spells, there is a function in Magic.scar for that:

{*******************************************************************************
Function SetAttackStyle(Style: Integer, Staff: Boolean): Boolean;
By: Richard
Description: Sets the attack style (1 = top left, 2 = top right, 3 = bottom left
4 = bottom right)(for staffs its vertically down). Also has support for staffs
if Staff is set to true.
*******************************************************************************}

Function SetAttackStyle(Style: Integer; Staff: Boolean): Boolean;
Var
Info: TIntegerArray;
x, y: Integer;
Begin
GameTab(1);
If not(Staff) then
Begin
Case Style of
1: Info := [571, 254, 632, 290];
2: Info := [655, 254, 717, 290];
3: Info := [571, 306, 632, 343];
4: Info := [655, 306, 717, 343];
else
srl_Warn('SetAttackStyle', IntToStr(Style) + 'is not a valid attack style', warn_AllVersions);
end;
end else
Begin
Case Style of
1: Info := [571, 255, 633, 280];
2: Info := [571, 290, 633, 315];
3: Info := [571, 326, 633, 349];
else
srl_Warn('SetAttackStyle', IntToStr(Style) + 'is not a valid attack style', warn_AllVersions);
end;
end;
If FindColorTolerance(x, y, 2106256, Info[0], Info[1], Info[2], Info[3], 50) then
Begin
Result := True;
Exit;
end;
MouseBox(Info[0], Info[1], Info[2], Info[3], 1);
Result := True;
end;



And the whole fighting.scar:

//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- Fighting routines --//
//-----------------------------------------------------------------//
// * Function Damage:Integer; // * By WT-Fakawi
// * function FightNPC(Colors : TIntegerArray, tol, TimeOut: Integer): Boolean;; // *By WT-Fakawi
// * function InFight: Boolean; // *By XxKanexX
// * function IsFightAt(x, y: Integer): Boolean; // *By RealRune
// * Function FindAllHPBars(Sx, Sy, x1, y1, x2, y2: Integer): Array of TPointArray; // By n3ss3s
// * Function GetHitsIn(Sx, Sy, x1, y1, x2, y2: Integer): TIntegerArray; // By n3ss3s
// * Function FindMainScreenHits(Bar: Integer): Integer; // by n3ss3s
// * Function IsAutoRetaliateOn: Boolean; // By Richard
// * Function SetAutoRetaliate(On: Boolean): Boolean; // By Richard
// * Procedure SpecialAttack(MinPercent: Integer); // By Richard
// * Function SetAttackStyle(Style: Integer, Staff: Boolean): Boolean; // By Richard


{*******************************************************************************
Function Damage:Integer;
By: WT-Fakawi
Description: Returns the amount of damage.
*******************************************************************************}

Function Damage:Integer;
begin
Result := (GetSkillInfo('hitpoints',False) - GetSkillInfo('hitpoints',True));
end;


{*******************************************************************************
function FightNPC(Colors : TIntegerArray, tol, TimeOut:
Integer): Boolean;
By: WT-Fakawi & Cazax
Description: Fights NPC. Input an array of colors. (May be the same colors),
tol = tolerance, TimeOut = amount of time before clicking on next NPC
*******************************************************************************}

function FightNPC(Colors : TIntegerArray; tol, TimeOut:
Integer): Boolean;
var
Mark, x, y: Integer;
begin
if (not LoggedIn) then Exit;
if (FindObjCustom(x, y, ['ttack'], Colors, tol)) then
begin
Result := True;
GetMousePos(x, y);
if (not (LoggedIn)) or (FindDead) then
begin
Result := False;
Exit;
end;
Mouse(x, y, 0, 0, True);
Wait(1000 + Random(500));
FFlag(10);
MarkTime(Mark);
repeat
if (not (LoggedIn) or (FindDead) or (FindNormalRandoms)) then Break;
Wait(1000 + Random(500));
if (TimeFromMark(Mark) > TimeOut) then Break;
until ((not FindColorSpiral(x, y, 65280, 240, 140, 290, 175))
or (FindDead)
or (TimeFromMark(Mark) > TimeOut));
end;
end;

{*****************************************************************************
function InFight: Boolean;
By: WT-Fakawi
Description: Returns as True if in fight.
*****************************************************************************}

function InFight: Boolean;
var
x, y : Integer;
begin
Result := (FindColor(x, y, 65280, 230, 130, 280, 180) or
FindColor(x, y, 255, 230, 130, 280, 180));
end;

{*****************************************************************************
function IsFightAt(x, y: Integer): Boolean;
By: realrune
Description: results true if it finds a fight near x,y.
*****************************************************************************}

function IsFightAt(x, y: Integer): Boolean;
var
xx, yy: Integer;
begin
Result := FindColor(xx, yy, 65280, x - 20, y - 20, x + 20, y + 20);
end;


{*******************************************************************************
Function FindAllHPBars(Sx, Sy, x1, y1, x2, y2: Integer): Array of TPointArray;
By: n3ss3s
Description: Finds all the HP bars (the TPAs of them) in the box formed by
x1, y1, x2, y2. Recommended to set Sx and Sy to MSCX and MSCY, so Result[0]
is your own Bar or the closest one to you.
*******************************************************************************}

Function FindAllHPBars(Sx, Sy, x1, y1, x2, y2: Integer): Array of TPointArray;

Var
g, r: TPointArray;
Begin
FindColorsSpiralTolerance(Sx, Sy, g, 65280, x1, y1, x2, y2, 0);
FindColorsSpiralTolerance(Sx, Sy, r, 255, x1, y1, x2, y2, 0);
Result := TPAToATPAEx(CombineTPA(g, r), 31, 5);
End;


{*******************************************************************************
Function GetHits(Sx, Sy, x1, y1, x2, y2: Integer): TIntegerArray;
By: n3ss3s
Description: Finds all HP percents of the HP bars in x1, y1, x2, y2.
READ THE DESCRIPTION OF FindAllHPBars!
*******************************************************************************}

Function GetHitsIn(Sx, Sy, x1, y1, x2, y2: Integer): TIntegerArray;

Var
E: Extended;
TB: TBox;
I: Integer;
TPAA: T2DPointArray;
Begin
TPAA := FindAllHPBars(Sx, Sy, x1, y1, x2, y2);
SetArrayLength(Result, GetArrayLength(TPAA));
For I := 0 To High(TPAA) Do
Begin
TB := GetTPABounds(TPAA[i]);
E := CountColor(65280, TB.x1, TB.y1, TB.x2, TB.y2) / 150;
Result[i] := Round(100 * E);
End;
End;


{*******************************************************************************
Function FindMainScreenHits(Bar: Integer): Integer;
By: n3ss3s
Description: Returns the rounded HP percent of the hp bar Bar counting out from
main screen centre, if Bar is 0, it's your own bar or the closest one to you.
If could not find the bar Bar, returns -1 so you can't confuse it to 0 HP%.
*******************************************************************************}

Function FindMainScreenHits(Bar: Integer): Integer;

Var
TIA: TIntegerArray;
Begin
TIA := GetHitsIn(MSCX, MSCY, MSX1, MSY1, MSX2, MSY2);
Try
Result := TIA[bar];
Except
Result := -1;
End;
End;

{*******************************************************************************
Function IsAutoRetaliateOn: Boolean;
By: Richard
Description: Returns true if auto retaliate is on
*******************************************************************************}

Function IsAutoRetaliateOn: Boolean;
Begin
GameTab(1);
Result := (GetColor(692, 391) = 1711220);
end;

{*******************************************************************************
Function SetAutoRetaliate(On : Boolean): Boolean;
By: Richard
Description: Set auto retaliate to on if true, off if false. Returns the result
false if it is unable to execute the function.
*******************************************************************************}

Function SetAutoRetaliate(SetOn : Boolean): Boolean;
Var
c: Integer;
Begin
If (IsAutoRetaliateOn = SetOn) then
Begin
Result := True;
Exit;
end;
c := (GetColor(692, 391));
MouseBox(571, 361, 713, 396, 1);
If (GetColor(692, 391) <> c) then
Result := True;
end;


{*******************************************************************************
Procedure SpecialAttack(MinPercent: Integer);
By: Richard
Description: Use the special attack button if it is present, and presses it if
the percent of the bar filled is >= MinPercent
*******************************************************************************}

Procedure SpecialAttack(MinPercent: Integer);
Begin
GameTab(1);
If (GetColor(623,424) = 65535) then
Begin
WriteLN('Special attack is already active');
Exit;
end;
If (GetColor(623,424) <> 1048576) then
Begin
WriteLN('Current weapon doesn'#39't have a special attack');
Exit;
end;
If (MinPercent <= Round((((CountColorTolerance(3700023, 572, 417, 713, 428, 120))/1634)*100))) then
MouseBox(570, 413, 714, 431, 1);
end;

{*******************************************************************************
Function SetAttackStyle(Style: Integer, Staff: Boolean): Boolean;
By: Richard
Description: Sets the attack style (1 = top left, 2 = top right, 3 = bottom left
4 = bottom right)(for staffs its vertically down). Also has support for staffs
if Staff is set to true.
*******************************************************************************}

Function SetAttackStyle(Style: Integer; Staff: Boolean): Boolean;
Var
Info: TIntegerArray;
x, y: Integer;
Begin
GameTab(1);
If not(Staff) then
Begin
Case Style of
1: Info := [571, 254, 632, 290];
2: Info := [655, 254, 717, 290];
3: Info := [571, 306, 632, 343];
4: Info := [655, 306, 717, 343];
else
srl_Warn('SetAttackStyle', IntToStr(Style) + 'is not a valid attack style', warn_AllVersions);
end;
end else
Begin
Case Style of
1: Info := [571, 255, 633, 280];
2: Info := [571, 290, 633, 315];
3: Info := [571, 326, 633, 349];
else
srl_Warn('SetAttackStyle', IntToStr(Style) + 'is not a valid attack style', warn_AllVersions);
end;
end;
If FindColorTolerance(x, y, 2106256, Info[0], Info[1], Info[2], Info[3], 50) then
Begin
Result := True;
Exit;
end;
MouseBox(Info[0], Info[1], Info[2], Info[3], 1);
Result := True;
end;


Please post any amendments you may have to these.

Thanks

Naike

2009-05-18 21:59:54

Naice.

You should post the updated Fighting.scar aswell(Makes it easier for people).

Richard

2009-05-18 22:00:46

Ok, changing now.

Just noticed that FightNPC uses 6 colours, TIntegerArray anyone? I'll be updating that now.

EDIT: Don't worry, its just the list at the top is incorrect.

Naum

2009-05-18 23:08:27

AFAIK this will not work:

Function SetAutoRetaliate(On : Boolean): Boolean;
Var
c: Integer;
Begin
If (IsAutoRetaliateOn = On) then
Begin
Result := True;
Exit;
end;

Shouldn't there be a True in there? Im pretty sure there is no record that you made called On.

Function SetAutoRetaliate(On : Boolean): Boolean;
Var
c: Integer;
Begin
If (IsAutoRetaliateOn = True) then
Begin
Result := True;
Exit;
end;

Sorry if I'm wrong.


Also why is Info a TV array? Shouldn't a TI array suffice?

Nice for these functions I'll look into ways of shortening them later,
Good work man!

Richard

2009-05-18 23:12:46

From: NaumanAkhlaQ
AFAIK this will not work:

Function SetAutoRetaliate(On : Boolean): Boolean;
Var
c: Integer;
Begin
If (IsAutoRetaliateOn = On) then
Begin
Result := True;
Exit;
end;

Shouldn't there be a True in there? Im pretty sure there is no record that you made called On.

Function SetAutoRetaliate(On : Boolean): Boolean;
Var
c: Integer;
Begin
If (IsAutoRetaliateOn = True) then
Begin
Result := True;
Exit;
end;

Sorry if I'm wrong.


No, that is meant to be like that, so if the 2 equal each other it will exit, otherwise if the user is trying to turn off the auto retaliate it will exit before it gets the chance. If the IsAutoRetaliateOn and On are different, its needs to continue the function.

I have tested my method a lot and it never fails, but I briefly tried that way and it will only work if its trying to turn it on.

Also why is Info a TV array? Shouldn't a TI array suffice?

Nice for these functions I'll look into ways of shortening them later,
Good work man!


I was thinking I made need more info, but it turns out I didn't, will change that now.

Thanks

Naum

2009-05-18 23:16:12

But 'On' is already in SCAR, no?

Richard

2009-05-18 23:17:54

Only as a local as far as I'm aware.

ShowerThoughts

2009-05-18 23:50:10

I don't get it!
You don't use any variable called on in that procedure how do you use it?

Richard

2009-05-18 23:54:05

From: Hermen
I don't get it!
You don't use any variable called on in that procedure how do you use it?


Look at the params for that function ;)

ShowerThoughts

2009-05-19 00:06:13


Function SetAutoRetaliate(On : Boolean): Boolean;
Var
c: Integer;
Begin//I MEAN WHERE IS THE ON in this function?! You don't even var the ON.
If (IsAutoRetaliateOn = True) then //<-- should be here?!?
Begin
Result := True;
Exit;
end;
Btw, it's pretty lame if you just changed it and say like it wasn't never wrong.(Just saying if you didn't you're fine ;)).

Richard

2009-05-19 00:13:57

From: Hermen

Function SetAutoRetaliate(On : Boolean): Boolean;
Var
c: Integer;
Begin//I MEAN WHERE IS THE ON in this function?! You don't even var the ON.
If (IsAutoRetaliateOn = True) then //<-- should be here?!?
Begin
Result := True;
Exit;
end;
Btw, it's pretty lame if you just changed it and say like it wasn't never wrong.(Just saying if you didn't you're fine ;)).


Have you never made functions/procedures with parameters in it, look:

Function SetAutoRetaliate(On : Boolean): Boolean;

"On : Boolean", its not a var, its effectively a const, so when you call

If (IsAutoRetaliateOn = On) then

its referring to the "On" that the user defined.


And what you're looking at it the one nauman made, which wouldn't work, the original has "On" instead of that "True".


If thats not what you're talking about, then I'm completely lost what you mean.

Sir R. M8gic1an

2009-05-19 00:57:17

lol.
Function SetAutoRetaliate(On : Boolean): Boolean;

notice the bolded bit, hermen, nauman?

anyway, good work richard, although i thought these had already been done by narcle.
I'll have a better look later.

~RM

ShowerThoughts

2009-05-19 00:59:27

Now I am getting pissed the function in the first post is different than in the post of naum, I probably know params better than you(Richard) and if you would have read my post correctly you would have seen it!

wisard 93596

2009-05-19 02:14:49

why i hit play…this pops up

Line 26: [Error] (26:12): Unknown identifier 'GetSkillInfo' in script
Failed when compiling
Line 26: [Error] (26:12): Unknown identifier 'GetSkillInfo' in script

Richard

2009-05-19 02:21:27

This is for an include, you're not supposed to run the file itself.

Instead save this in the fighting.scar file (C:/Program Files/SCAR/Includes/SRL/SRL/skill/Fighting.scar), then make a script which has that include in it:

Program Fighting;
{.include SRL/SRL.scar}
{.include SRL/SRL/skill/fighting.scar}

Begin
/*Insert fighting
stuff here*/
end.

EDIT: Whoever made the scar tags forgot that 3rd method of commenting :p

Shuttleu

2009-05-19 02:22:55

{*******************************************************************************
procedure SetAutoRetaliate(On : Boolean);
By: Shuttleu
Description: Set auto retaliate to on if true, off if false. Returns the result
false if it is unable to execute the function.
*******************************************************************************}
procedure SetAutoRetaliate(SwitchOn : Boolean);
begin
GameTab(1);
if (SwitchOn) xor (GetColor(702, 391)= 1777020) then
MouseBox(571, 361, 713, 396, 1);
end;
:)

~shut

Richard

2009-05-19 02:28:12

From: Shuttleu
{*******************************************************************************
Function SetAutoRetaliate(On : Boolean): Boolean;
By: Richard
Description: Set auto retaliate to on if true, off if false. Returns the result
false if it is unable to execute the function.
*******************************************************************************}
procedure SetAutoRetaliate(SwitchOn : Boolean);
begin
GameTab(1);
if (SwitchOn) xor (GetColor(702, 391)= 1777020) then
MouseBox(571, 361, 713, 396, 1);
end;
:)

~shut


{*******************************************************************************
Function SetAutoRetaliate(On : Boolean): Boolean;
By: Richard
Description: Set auto retaliate to on if true, off if false. Returns the result
false if it is unable to execute the function.
*******************************************************************************}
Function SetAutoRetaliate(On : Boolean): Boolean;
begin
GameTab(1);
if (SwitchOn) xor (IsAutoRetaliateOn) then
Begin
MouseBox(571, 361, 713, 396, 1);
Result := True;
end;
end;

Still like it as a result :)

Thanks though

Shuttleu

2009-05-19 02:33:12


{*******************************************************************************
function SetAutoRetaliate(SwitchOn : Boolean): Boolean;
By: Shuttleu
Description: Set auto retaliate to on if true, off if false. Returns the result
false if it doesnt change the state.
*******************************************************************************}
function SetAutoRetaliate(SwitchOn : Boolean): Boolean;
begin
GameTab(1);
if (SwitchOn) xor (GetColor(702, 391)= 1777020) then
begin
MouseBox(571, 361, 713, 396, 1);
result:= True;
end;
end;
use that then
its faster

~shut

wisard 93596

2009-05-19 02:35:44

ok i took the include u gave me
and inserted the fighting program where u told me to put it…i clicked run
and this poped up
Include file C:\Program Files\SCAR 3.20\includes\SRL\SRL.scar does not exist.
Include file C:\Program Files\SCAR 3.20\includes\SRL\SRL\skill\fighting.scar does not exist.
Failed when compiling

wisard 93596

2009-05-19 02:37:36

do u think u could just put everything u need to make it run perfectly and hassle free in one script…because im no scar master and all i can do is move the crosshairs onto he page and click run..
sorry i know noobs cause u extra work

Richard

2009-05-19 02:37:55

From: Shuttleu

{*******************************************************************************
function SetAutoRetaliate(SwitchOn : Boolean): Boolean;
By: Shuttleu
Description: Set auto retaliate to on if true, off if false. Returns the result
false if it doesnt change the state.
*******************************************************************************}
function SetAutoRetaliate(SwitchOn : Boolean): Boolean;
begin
GameTab(1);
if (SwitchOn) xor (GetColor(702, 391)= 1777020) then
begin
MouseBox(571, 361, 713, 396, 1);
result:= True;
end;
end;
use that then
its faster

~shut


Well, 5-10 msecs :p

Nice job on shortening it, I'd forgotten about xor (x mean exclusive I guess).

What do you think about the others?

EDIT: wisard sounds like you haven't downloaded SRL, look up a guide on how to install, or use the wiki (villavu.com/wiki) it on the main page. And avoid double posting ;)

Shuttleu

2009-05-19 02:40:25

From: Richard
Well, 5-10 msecs :p

Nice job on shortening it, I'd forgotten about xor (x mean exclusive I guess).

What do you think about the others?

EDIT: wisard sounds like you haven't downloaded SRL, look up a guide on how to install, or use the wiki (villavu.com/wiki) it on the main page. And avoid double posting ;)


i shall have a look at them

~shut

EDIT: not really shorter but it is neater
{*******************************************************************************
Procedure SpecialAttack(MinPercent: Integer);
By: Richard edited by Shuttleu
Description: Use the special attack button if it is present, and presses it if
the percent of the bar filled is >= MinPercent
*******************************************************************************}
procedure SpecialAttack(MinPercent: Integer);
begin
GameTab(1);
case GetColor(623,424) of
65535: Begin
WriteLN('Special attack is already active');
Exit;
end;
1048576: begin
WriteLN('Current weapon doesn'#39't have a special attack');
Exit;
end;
end;
If (MinPercent <= Round((((CountColorTolerance(3700023, 572, 417, 713, 428, 120))/1634)*100))) then
MouseBox(570, 413, 714, 431, 1);
end;

wisard 93596

2009-05-19 02:45:15

no…ive downloaded srl..i got it off freddy1990.com ..or somthing like that
at the top of the program it says SCAR Divi 3.20d by Freddy1990
do i have a bad version of it…or does my version not work with ur script?

Richard

2009-05-19 02:51:44

From: wisard 93596
no…ive downloaded srl..i got it off freddy1990.com ..or somthing like that
at the top of the program it says SCAR Divi 3.20d by Freddy1990
do i have a bad version of it…or does my version not work with ur script?


First of all, I'd use 3.15b over 3.20d, and secondly, that's SCAR you've downloaded, not SRL. SRL is the include thats designed for runescape, click here.

Shuttleu

2009-05-19 02:51:53

From: wisard 93596
no…ive downloaded srl..i got it off freddy1990.com ..or somthing like that
at the top of the program it says SCAR Divi 3.20d by Freddy1990
do i have a bad version of it…or does my version not work with ur script?

you my dear friend have only done half of what you need to do
you have downloaded and installed scar but you havent downloaded srl

~shut

wisard 93596

2009-05-19 03:00:00

oh ok sorry i should of listen to what u said the first time
ive downloaded srl…and will your script work smothly with 3.20 or should i try and find the 3.15 version?
also i tryed running your script with srl and this messaged poped up
Line 29: [Error] (16941:1): Identifier expected in script

Richard

2009-05-19 03:30:42

From: wisard 93596
oh ok sorry i should of listen to what u said the first time
ive downloaded srl…and will your script work smothly with 3.20 or should i try and find the 3.15 version?
also i tryed running your script with srl and this messaged poped up
Line 29: [Error] (16941:1): Identifier expected in script


Are you just copying and pasting the code into SCAR and pressing play? If so, that won't work, as theres no main loop.

wisard 93596

2009-05-19 03:39:06

ok last question…i have my scar program full working and my script seems like it will work smoothly…but for it to find monsters it needs 3 colors…i know its some sort of code or number…where would i find these codes?

Naum

2009-05-19 10:53:52

From: Rasta Magician
lol.
Function SetAutoRetaliate(On : Boolean): Boolean;

notice the bolded bit, hermen, nauman?

anyway, good work richard, although i thought these had already been done by narcle.
I'll have a better look later.

~RM


I noticed it man, just thought it would clash with the bold 'On' command in SCAR,

http://www.delphibasics.co.uk/RTL.asp?Name=On

;)

Although it's pretty cool to use your own local variable as a result, didn't know you could do that :)

More Over, Shut your shortened version would still not work:

From: Shuttleu
i shall have a look at them

~shut

EDIT: not really shorter but it is neater
{*******************************************************************************
Procedure SpecialAttack(MinPercent: Integer);
By: Richard edited by Shuttleu
Description: Use the special attack button if it is present, and presses it if
the percent of the bar filled is >= MinPercent
*******************************************************************************}
procedure SpecialAttack(MinPercent: Integer);
begin
GameTab(1);
case GetColor(623,424) of
65535: Begin
WriteLN('Special attack is already active');
Exit;
end;
1048576: begin
WriteLN('Current weapon doesn'#39't have a special attack');
Exit;
end;
end;
If (MinPercent <= Round((((CountColorTolerance(3700023, 572, 417, 713, 428, 120))/1634)*100))) then
MouseBox(570, 413, 714, 431, 1);
end;


Should work with this:

  If (GetColor(623,424) = 65535) then
Begin
WriteLN('Special attack is already active');
Exit;
end;
If (GetColor(623,424) {}<>{} 1048576) then

there is an <> in there so if it is not Equal to, what your doing in your other procedure is making it equal to :)

Home

2009-05-19 13:50:04

From: Rasta Magician
lol.
Function SetAutoRetaliate(On : Boolean): Boolean;

notice the bolded bit, hermen, nauman?

anyway, good work richard, although i thought these had already been done by narcle.
I'll have a better look later.

~RM


I'm sorry that was so funny :) 2 very good scripters didin't notice Boolean?

Well anyways, this was kinda off topic (:

~HOme

Naum

2009-05-19 14:14:23

But I did notice it.

Thanks for the good scripter compliment :)

ZephyrsFury

2009-05-19 14:36:56

From: Hermen

Function SetAutoRetaliate(On : Boolean): Boolean;
Var
c: Integer;
Begin//I MEAN WHERE IS THE ON in this function?! You don't even var the ON.
If (IsAutoRetaliateOn = True) then //<-- should be here?!?
Begin
Result := True;
Exit;
end;
Btw, it's pretty lame if you just changed it and say like it wasn't never wrong.(Just saying if you didn't you're fine ;)).


From: Hermen
Now I am getting pissed the function in the first post is different than in the post of naum, I probably know params better than you(Richard) and if you would have read my post correctly you would have seen it!

Chill, mate. Richard's original function is the one in the first post atm. He hasn't changed anything with it so don't get angry…

Anyway Richard, nice functions. I'm pretty sure, however, that SetAutoRetaliate and SetAttackStyle are already in SRL:


procedure Retaliate(RetTrue: Boolean); //GameTab.scar

function SetFightMode(oFightMode: Integer): Boolean; //GameTab.scar

I'm not sure about the magic staffs though.

Richard

2009-05-19 20:40:33

From: ZephyrsFury
Chill, mate. Richard's original function is the one in the first post atm. He hasn't changed anything with it so don't get angry…

Anyway Richard, nice functions. I'm pretty sure, however, that SetAutoRetaliate and SetAttackStyle are already in SRL:


procedure Retaliate(RetTrue: Boolean); //GameTab.scar

function SetFightMode(oFightMode: Integer): Boolean; //GameTab.scar

I'm not sure about the magic staffs though.


Didn't think of looking in GameTab.scar, I guess its more relevant as there could also be magic/range weapons.

Thanks.

ShowerThoughts

2009-05-19 22:13:01

Wtf, lol I did notice it just some person had a edited qoute of the real function and I was like Fuck The What, and I tried to help Richard :(.

That you didn't know that, that you can pass var's thru a parameter like:


function FindEdgeBank(var TempX, TempY:integer; MaxTime :integer):boolean;

if FindEdgeBank(A, B, 5000) then

;)
It's very handy especially for this^

Naum

2009-05-19 23:00:24

No hermpie he used his own local variable to use as a result ;)

Nava2

2009-05-20 05:50:34

You should change the On variable, On is a part of pascal script afaik.

Richard

2009-05-26 00:12:43

Is this planning to be added?

Also, changing the "on" to "setOn" to prevent problems with SCARs inbuilt variable.

May I ask what the asterisk next to this thread means?

ZephyrsFury

2009-05-26 09:22:30

I'll have a look in a bit. I think a couple could be useful (like SpecialAttack).

Da 0wner

2009-05-26 11:49:10

Alright, nevermind then. I deleted the post. Edit it out from your quote :D.