My Func List!
Hey all, I was roaming through the includes and picked up some code which would either not work or could be made shorter (in my view).
SRL/SRL/Skill/Magic.Scar
SetUpAutoCast(AutoSpell: string; Defensive: Boolean):
SCAR Code:
function SetUpAutoCast(AutoSpell: string; Defensive: Boolean): Boolean;
var
X, Y, Col, Row, Msk: Integer;
TB : TBox;
Spells, ColArray : TVariantArray;
begin
if not GameTab(1) then exit;
if Defensive then
Mouse(655, 253, 50, 25, True)
else Mouse(665, 320, 50, 25, True);
Spells := ['', 'wind strike', 'water strike', 'earth strike', 'fire strike',
'wind bolt', 'water bolt', 'earth bolt', 'fire bolt',
'wind blast', 'water blast', 'earth blast', 'fire blast',
'wind wave', 'water wave', 'earth wave', 'fire wave'];
ColArray := [835570, 16579836, 16563743, 3003805, 835570];
While (GetColor(587, 363) = 8621205) Do Wait(100 + Random(100));
Try Msk := StrToIntDef(AutoSpell, -1) Except end;
If Msk <> -1 Then
Row := Trunc(Msk Div 4) + 1
Else
For Msk := 0 to High(Spells) Do
If AutoSpell = Spells[Msk] Then
Row := Trunc(Msk Div 4) + 1;
If (Msk Mod 4) = 0 Then Dec(Row);
Col := Msk Mod 4;
If Col = 0 Then Col := 4;
TB.x1 := 571 + 40 * (Col - 1);
TB.y1 := 229 + 60 * (Row - 1);
For Msk := 0 to High(Spells) Do
If (LowerCase(AutoSpell) = Spells[Msk]) or (LowerCase(AutoSpell) = IntToStr(Msk)) Then
Result := FindColor(X, Y, ColArray[Msk Mod 4], TB.x1, TB.y1, TB.x1 + 40, TB.y1 + 60);
If Result <> True Then
Begin
srl_Warn('SetUpAutoCast', '"' + AutoSpell + '" is not a valid autocasting spell.', -2);
Mouse(687, 448, 9, 4, True); // Exits the autocasting Spells setup 'popup'.
End Else
Mouse(x, y, 2, 2, True);
End;
Replaces the current one, I edited it a lot from the first release and it now works! Horaay! However, the last one would not exit the menu as there was a wrong co-ord, this now does.
SRL/SRL/Core/MapWalk.Scar
GetMiniMapDotsIn(WhatDot: String; x1, y1, x2, y2: Integer): TPointArray;
SCAR Code:
function GetMiniMapDotsIn(WhatDot: String; x1, y1, x2, y2: Integer): TPointArray;
var
Color, I: Integer;
Arr : TVariantArray;
begin
WhatDot := LowerCase(WhatDot);
Arr := [0, 'npc', 'yellow', 60909, 'cape', 'blue', 12742980, 'item', 'red',
789758, 'player', 'white', 16711422, 'friend', 'green', 61440];
For I := 0 to (High(Arr) Div 3)- 1 Do
If (WhatDot = Arr[I*3+1]) Or (WhatDot = Arr[I*3+2]) Then
Color := Arr[I*3+3];
FindColorsSpiralTolerance(MMCX, MMCY, Result, Color, x1, y1, x2, y2, 0);
RAaSTPA(Result, 4);
if (WhatDot = 'player') or (WhatDot = 'white') then
begin
Swap(Result[0], Result[High(Result)]);
SetLength(Result, High(Result));
end;
end;
Hopefully that fixes the access violation error, and hopefully it is shorter.
SRL/SRL/Skill/Cooking.Scar
FindRange(Var X, Y : Integer) : Boolean;
SCAR Code:
Function FindRange(Var X, Y : Integer) : Boolean;
Begin
X := MSCX;
Y := MSCY;
Result := FindObjTPA(X, Y, 6579308, 10, 2, 10, 10, 20, ['ange']);
If Result <> False Then GetMousePos(x, y);
End;
The last one had an error, I didn't do much here.
SRL/SRL/Skill/Crafting.Scar
FindOven(Var XX, YY : Integer) : Boolean;
SCAR Code:
Function FindOven(Var XX, YY : Integer) : Boolean;
Begin
XX := MSCX;
YY := MSCY;
Result := FindObjTPA(XX, YY, 3754068, 13, 2, 10, 10, 30, ['ven']);
If Result <> False Then GetMousePos(xx, yy);
End;
Current one will keep on hovering and will not click. Again, I did not do much here.
SRL/SRL/Core/Login.Scar
Function LogOut : Boolean;
SCAR Code:
Function LogOut : Boolean;
Var I : Integer;
Begin
Result := (LoggedIn <> True);
If Result Then Exit;
If SRL_Procs[srl_OnLogOut] <> nil Then
SRL_Procs[srl_OnLogOut]();
GameTab(14);
Wait(200 + Random(100));
While LoggedIn And (I <= 10) Do
Begin
Inc(I);
If I Mod 2 = 0 Then
If ClickText('here', UpChars, MIX1, MIY1, MIX2, MIY2, True) Then
Begin
Wait(600 + Random(300));
If LoggedIn <> True Then Break;
End;
End;
Result := True;
End;
^ My shot
^
SRL/SRL/Core/GameTab.Scar
DoEmote(EmoteNumber : Integer)
SCAR Code:
Procedure DoEmote(EmoteNumber : Integer);
Var Ex, Ey, Row, Col : Integer;
Begin
If (EmoteNumber / 46 > 1) Or (EmoteNumber * 34729237 = 0) Then
Begin
srl_Warn('DoEmote', 'Invalid EmoteNumber: ' + IntToStr(EmoteNumber) + ', Valid Emotes: 1..46', warn_AllVersions);
Exit;
End;
GameTab(12);
If EmoteNumber <= 20 Then
If GetColor(724, 222) = 1975337 Then
Mouse(724, 233, 5, 5, True);
If InRange(EmoteNumber, 21, 40) Then
Begin
If GetColor(727, 360) = 2106924 Then
Mouse(727, 360, 5, 5, True);
EmoteNumber := EmoteNumber - 20;
End;
If InRange(EmoteNumber, 41, 46) Then
Begin
If GetColor(723, 443) = 1975337 Then
Mouse(723, 443, 3, 3, True);
EmoteNumber := EmoteNumber - 28;
End;
Row := (Trunc(EmoteNumber / 4) + 1);
If EmoteNumber Mod 4 = 0 Then Dec(Row);
Col := EmoteNumber Mod 4;
If Col = 0 Then Col := 4;
Ex := 562 + 37 * (Col - 1);
Ey := 231 + 44 * (Row - 1);
If CountColor(65536, Ex, Ey, Ex + 37, Ey + 44) >= 5 Then
Begin
Mouse(Ex, Ey, 23, 25, True);
Wait(1200 + Random(700));
End;
End;
DoEmote wasn't working and 9 new emotes have been added.
Hopefully people can give me tips to improve
.
Thanks