SRL Archive - SRL Archives

SetSpell


Richard

2009-06-06 02:03:00

I noticed that the previous one only supported the strike spells, so here's a version that supports all F2P spells, and, unlike the old one, checks if you're actually wielding a staff:

{*******************************************************************************
procedure SetSpell(Spell: String; Defensive: Boolean);
By: Richard
Description: Sets the autospell for staves
*******************************************************************************}

procedure SetSpell(Spell: String; Defensive: Boolean);
var
xc, yc, x, y, xx, yy, i: integer;
TSA: TStringArray;
TIA: TIntegerArray;
begin
if not GameTab(1) then Exit;
if not(GetColor(670, 273) = 16711422) then Exit;
if Defensive then
Mouse(655, 253, 50, 25, True)
else
Mouse(665, 320, 50, 25, True);
Wait(500 + random(300));
TSA := srl_Explode(Spell, ' ');
Case lowercase(TSA[0]) of
'wind' : xc := 1;
'water' : xc := 2;
'earth' : xc := 3;
'fire' : xc := 4;
else
srl_Warn('SetSpell', Spell+' is not a valid spell', warn_AllVersions);
end;
Case lowercase(TSA[1]) of
'strike': yc := 1;
'bolt' : yc := 2;
'blast' : yc := 3;
else
srl_Warn('SetSpell', Spell+' is not a valid spell', warn_AllVersions);
end;
x := (xc * 40) + 543;
y := (yc * 61) + 185;
TIA := [1250066, 1576205, 4352, 2841, 131074, 1574150, 20]
For i := 0 to High(TIA) do
Begin
if FindColorTolerance(TIA[i], xx, yy, x - 15, y - 15, x + 15, y + 15, 2) then
Begin
Mouse(x, y, 3, 3, true);
Break;
end;
end;
MouseBox(684, 447, 722, 458, 1);
end;

Shuttleu

2009-06-06 02:17:45

    if FindColorTolerance(TIA[i], xx, yy, x - 15, y - 15, x + 15, y + 15, 2) then
Begin
Mouse(x, y, 3, 3, true);
Exit;
end;
should it be a break; ?
    if FindColorTolerance(TIA[i], xx, yy, x - 15, y - 15, x + 15, y + 15, 2) then
Begin
Mouse(x, y, 3, 3, true);
break;
end;
?

~shut

Richard

2009-06-06 02:24:36

From: Shuttleu
    if FindColorTolerance(TIA[i], xx, yy, x - 15, y - 15, x + 15, y + 15, 2) then
Begin
Mouse(x, y, 3, 3, true);
Exit;
end;
should it be a break; ?
    if FindColorTolerance(TIA[i], xx, yy, x - 15, y - 15, x + 15, y + 15, 2) then
Begin
Mouse(x, y, 3, 3, true);
break;
end;
?

~shut


Yes, well caught.

Narcle

2009-06-06 02:58:06

Had a new one made… idk where it is tho. Couple things I did different. Instead of using colors I just used a Luminance check on the area - so it doesn't have to be update for a long time. I also included fire - might as well have all of em…

Oh instead of using cases - you could use a location finder in TString arrays, will make the script a bit shorter.

['wind', 'water', 'earth', 'fire']

Forgot what the finder is called, but I know there is one.

Richard

2009-06-06 03:00:17

From: Narcle
Had a new one made… idk where it is tho. Couple things I did different. Instead of using colors I just used a Luminance check on the area - so it doesn't have to be update for a long time. I also included fire - might as well have all of em…


This includes fire, just not wave spells, as I don't have P2P.

Could I look at this luminance checker? It could come on handing for other things.

P1nky

2009-06-06 06:45:43

Suggestion:
Mouse(655, 253, 50, 25, True)
replace with MouseBox :) just to be extra safe :P

well yeah dude looks good and if I ever do update my Curser i'll pretty sure to use thiiis

senrath

2009-06-06 06:56:01

From: ~~Joker~~
Suggestion:
Mouse(655, 253, 50, 25, True)
replace with MouseBox :) just to be extra safe :P

well yeah dude looks good and if I ever do update my Curser i'll pretty sure to use thiiis


Why? MouseBox uses Mouse for the clicking.

P1nky

2009-06-06 08:09:07

From: senrath
Why? MouseBox uses Mouse for the clicking.


adds the randomness?

senrath

2009-06-06 08:11:01

From: ~~Joker~~
adds the randomness?


Add what randomness? Seriously, take a look at what MouseBox is:
{*******************************************************************************
procedure MouseBox(x1, y1, x2, y2: Integer; ClickType: Integer);
By: SKy Scripter and Nielsie95
Description: Moves mouse into a random position in the box. Clicks if told to.
*******************************************************************************}

procedure MouseBox(x1, y1, x2, y2: Integer; ClickType: Integer);
begin
case ClickType of
1 : Mouse(RandomRange(x1, x2), RandomRange(y1, y2), 0, 0, True);
2 : Mouse(RandomRange(x1, x2), RandomRange(y1, y2), 0, 0, False);
3 : MMouse(RandomRange(x1, x2), RandomRange(y1, y2), 0, 0);
else
srl_Warn('MouseBox', 'ClickType is NOT a valid number!', warn_AllVersions);
end;
end;

P1nky

2009-06-06 08:18:21

From: senrath
Add what randomness? Seriously, take a look at what MouseBox is:
{*******************************************************************************
procedure MouseBox(x1, y1, x2, y2: Integer; ClickType: Integer);
By: SKy Scripter and Nielsie95
Description: Moves mouse into a random position in the box. Clicks if told to.
*******************************************************************************}

procedure MouseBox(x1, y1, x2, y2: Integer; ClickType: Integer);
begin
case ClickType of
1 : Mouse(RandomRange(x1, x2), RandomRange(y1, y2), 0, 0, True);
2 : Mouse(RandomRange(x1, x2), RandomRange(y1, y2), 0, 0, False);
3 : MMouse(RandomRange(x1, x2), RandomRange(y1, y2), 0, 0);
else
srl_Warn('MouseBox', 'ClickType is NOT a valid number!', warn_AllVersions);
end;
end;

I know it'll click anything inside the BOX, and wont be exactly 1 coord spot…

senrath

2009-06-06 08:25:47

From: ~~Joker~~
I know it'll click anything inside the BOX, and wont be exactly 1 coord spot…


:duh:
Mouse(655, 253, 50, 25, True);
Will click in a box that is 50px by 25 px. It is functionally identical to this:
MouseBox(655, 253, 705, 278, 1);