SRL Archive - Research & Development Lounge

Music Functions


Naum

2009-07-21 19:19:06

Hey, I made some music functions for RuneScape, it would be appreciated if anyone could advise/test them:

Procedure Loop(State : (TurnOn, TurnOff));
Begin
If (GetColor(643, 226) = 716552) xOr (State = TurnOn) Then
Mouse(633, 212, 20, 20, True);
End;

Function NumberOfUnlockedSongs: Integer;
Var TmpStr : String;
Begin
If FindColor(x, y, 39423, 671, 220, 673, 223) Then
TmpStr := GetTextAtEx(x - 4, y - 1, 10, StatChars, False, False, -1, 6, 39423, 9, False, tr_AllChars);
If Pos(' ', TmpStr) > 0 Then Delete(TmpStr, Pos(' ', TmpStr), Length(TmpStr));
Result := StrToIntDef(Trim(TmpStr), -1);
End;

Function SelectMusic(Name : String) : Boolean;
Var I, x, y, Time : Integer;
Arr : TStringArray;
CordY : Extended;
Result2 : Boolean;

Begin
Result := (Capitalize(Trim(LowerCase(Name))) = GetMusic);
If Result Then Exit;
If Random(4) = 1 Then Loop(TurnOn);
If Random(3) = 0 Then Loop(TurnOff);
If NumberOfUnlockedSongs <= 30 Then Exit Else

Arr := ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
If Pos('the ', Trim(LowerCase(Name))) = 0 Then Delete(Name, 1, 4);

For I := 0 to High(Arr) Do
If LowerCase(Name) = 'random' Then
Begin
I := Random(23);
Name := Capitalize(Arr[I]);
Break;
End Else
If LowerCase(Trim(Left(Name, 1))) = Arr[I] Then
Break;

CordY := ((5.058 * I) + I Mod 3);

If LowerCase(Trim(Left(Name, 1))) = 's' Then
DecEx(CordY, 5);

Mouse(719, 287 + Round(CordY - (0.03)), 6, 1, True);
Wait(200 + Random(200));
Time := GetSystemTime + 20000;

MMouse(718, 440, 7, 7);
GetMousePos(x, y);
HoldMouse(x, y, True);
Repeat
Result := FindTextTpaEx(ClGreen, 10, MIX1, MIY1, MIX2, MIY2, x, y, Capitalize(Name), StatChars, Nothing);
Result2 := FindTextTpaEx(ClRed, 10, MIX1, MIY1, MIX2, MIY2, x, y, Capitalize(Name), StatChars, Nothing);
Until(Result2) Or (Result) Or (GetSystemTime >= Time);
ReleaseMouse(x, y, True);
Wait(200 + Random(200));

If Result Then
ClickText(Capitalize(Name), StatChars, MIX1, MIY1, MIX2, MIY2, True);
If Result2 Then
If Random(5) = 0 Then
ClickText(Capitalize(Name), StatChars, MIX1, MIY1, MIX2, MIY2, True);

If Result Then WriteLn('Found The Song (Unlocked)');
If Result2 Then WriteLn('Found The Song (Locked)');
If (Not (Result)) And (Not (Result2)) Then WriteLn('Could NOT Find The Song :(');
End;

Thanks :)