mirror of
https://github.com/moparisthebest/Simba
synced 2024-12-22 23:38:50 -05:00
Added ColorToHSL, so I can run my old neopets script. ^_^
git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@217 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
parent
7ff6765f73
commit
270394a397
@ -7,7 +7,7 @@
|
||||
<TargetFileExt Value=""/>
|
||||
<Title Value="Mufasa Stand Alone"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<ActiveEditorIndexAtStart Value="4"/>
|
||||
<ActiveEditorIndexAtStart Value="6"/>
|
||||
</General>
|
||||
<VersionInfo>
|
||||
<ProjectVersion Value=""/>
|
||||
@ -305,8 +305,8 @@
|
||||
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="mmlpsthread"/>
|
||||
<CursorPos X="44" Y="167"/>
|
||||
<TopLine Value="142"/>
|
||||
<CursorPos X="15" Y="96"/>
|
||||
<TopLine Value="71"/>
|
||||
<EditorIndex Value="5"/>
|
||||
<UsageCount Value="202"/>
|
||||
<Loaded Value="True"/>
|
||||
@ -374,9 +374,11 @@
|
||||
</Unit45>
|
||||
<Unit46>
|
||||
<Filename Value="../../Units/MMLAddon/PSInc/pscompile.inc"/>
|
||||
<CursorPos X="67" Y="97"/>
|
||||
<TopLine Value="87"/>
|
||||
<CursorPos X="88" Y="96"/>
|
||||
<TopLine Value="71"/>
|
||||
<EditorIndex Value="6"/>
|
||||
<UsageCount Value="94"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit46>
|
||||
<Unit47>
|
||||
<Filename Value="../../../FPC/FPCCheckout/rtl/win/tthread.inc"/>
|
||||
@ -407,9 +409,11 @@
|
||||
</Unit50>
|
||||
<Unit51>
|
||||
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/colour.inc"/>
|
||||
<CursorPos X="30" Y="28"/>
|
||||
<TopLine Value="16"/>
|
||||
<CursorPos X="1" Y="1"/>
|
||||
<TopLine Value="33"/>
|
||||
<EditorIndex Value="7"/>
|
||||
<UsageCount Value="38"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit51>
|
||||
<Unit52>
|
||||
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/bitmap.inc"/>
|
||||
@ -1178,7 +1182,7 @@
|
||||
<UnitName Value="framescript"/>
|
||||
<CursorPos X="13" Y="98"/>
|
||||
<TopLine Value="87"/>
|
||||
<EditorIndex Value="6"/>
|
||||
<EditorIndex Value="8"/>
|
||||
<UsageCount Value="106"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit161>
|
||||
@ -1492,8 +1496,8 @@
|
||||
<ComponentName Value="ColourHistoryForm"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="colourhistory"/>
|
||||
<CursorPos X="75" Y="121"/>
|
||||
<TopLine Value="115"/>
|
||||
<CursorPos X="39" Y="117"/>
|
||||
<TopLine Value="113"/>
|
||||
<EditorIndex Value="4"/>
|
||||
<UsageCount Value="43"/>
|
||||
<Loaded Value="True"/>
|
||||
@ -1665,7 +1669,7 @@
|
||||
<UsageCount Value="10"/>
|
||||
</Unit232>
|
||||
</Units>
|
||||
<JumpHistory Count="6" HistoryIndex="5">
|
||||
<JumpHistory Count="8" HistoryIndex="7">
|
||||
<Position1>
|
||||
<Filename Value="testunit.pas"/>
|
||||
<Caret Line="837" Column="30" TopLine="831"/>
|
||||
@ -1690,6 +1694,14 @@
|
||||
<Filename Value="../../Units/MMLCore/input.pas"/>
|
||||
<Caret Line="78" Column="47" TopLine="67"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
|
||||
<Caret Line="195" Column="24" TopLine="177"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
|
||||
<Caret Line="242" Column="18" TopLine="227"/>
|
||||
</Position8>
|
||||
</JumpHistory>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
|
148
Tests/PS/Neopets_old.mufa
Normal file
148
Tests/PS/Neopets_old.mufa
Normal file
@ -0,0 +1,148 @@
|
||||
program BankProblems;
|
||||
|
||||
// http://www.neopets.com/games/play.phtml?game_id=371
|
||||
|
||||
Const
|
||||
KeyDownUpSpeed = 1; // The Higher the "KeyDownUpSpeed", the slower the script is.
|
||||
|
||||
Type
|
||||
Door = record
|
||||
X: Integer;
|
||||
Y: Integer;
|
||||
DoorChar: Byte;
|
||||
IsOpen: Boolean;
|
||||
IsMonster: Boolean;
|
||||
WhatMonster: String;
|
||||
End;
|
||||
|
||||
Var
|
||||
Doors: Array [0..5] Of Door;
|
||||
|
||||
Procedure DeclareStuff;
|
||||
|
||||
Var
|
||||
I: Integer;
|
||||
Begin
|
||||
For I := 0 To 5 Do
|
||||
Begin
|
||||
Doors[I].X := 45 + I * 96;
|
||||
Doors[I].Y := 210;
|
||||
End;
|
||||
|
||||
Doors[0].DoorChar := 83;
|
||||
Doors[1].DoorChar := 68;
|
||||
Doors[2].DoorChar := 70;
|
||||
Doors[3].DoorChar := 74;
|
||||
Doors[4].DoorChar := 75;
|
||||
Doors[5].DoorChar := 76;
|
||||
End;
|
||||
|
||||
Function IsBadGuy(DN: Integer): Boolean;
|
||||
|
||||
Var
|
||||
TempColor: Array [0..11] Of Integer;
|
||||
I, x, y: Integer;
|
||||
H, S, L: Extended;
|
||||
Begin
|
||||
TempColor[0] := GetColor(Doors[DN].X, Doors[DN].Y);
|
||||
TempColor[1] := GetColor(Doors[DN].X, Doors[DN].Y-1);
|
||||
TempColor[2] := GetColor(Doors[DN].X-1, Doors[DN].Y);
|
||||
TempColor[3] := GetColor(Doors[DN].X, Doors[DN].Y+1);
|
||||
TempColor[4] := GetColor(Doors[DN].X+1, Doors[DN].Y);
|
||||
TempColor[5] := GetColor(Doors[DN].X, Doors[DN].Y-2);
|
||||
TempColor[5] := GetColor(Doors[DN].X-2, Doors[DN].Y);
|
||||
TempColor[6] := GetColor(Doors[DN].X+1, Doors[DN].Y+2);
|
||||
TempColor[7] := GetColor(Doors[DN].X+2, Doors[DN].Y);
|
||||
TempColor[8] := GetColor(Doors[DN].X, Doors[DN].Y-3);
|
||||
TempColor[9] := GetColor(Doors[DN].X-3, Doors[DN].Y);
|
||||
TempColor[10] := GetColor(Doors[DN].X+1, Doors[DN].Y+3);
|
||||
TempColor[11] := GetColor(Doors[DN].X+3, Doors[DN].Y);
|
||||
|
||||
For I := 0 To 11 Do
|
||||
Begin
|
||||
If SimilarColors(TempColor[I], 3055, 30) Then // Red Devil
|
||||
Begin
|
||||
Result := True;
|
||||
Doors[DN].WhatMonster := 'Devil';
|
||||
Exit;
|
||||
End;
|
||||
End;
|
||||
|
||||
For I := 0 To 11 Do
|
||||
Begin
|
||||
If SimilarColors(TempColor[I], 12841714, 40) Then // Squirrle
|
||||
Begin
|
||||
ColorToHSL(TempColor[I], H, S, L);
|
||||
If (L > 60) And (L < 95) Then
|
||||
If (H > 5 ) And (H < 30) Then
|
||||
If FindColorTolerance(x, y, 4092580, Doors[DN].X, Doors[DN].Y-1,
|
||||
Doors[DN].X + 20, Doors[DN].Y + 1, 40)
|
||||
Then
|
||||
Begin
|
||||
Result := True;
|
||||
Doors[DN].WhatMonster := 'Squirrle';
|
||||
Exit;
|
||||
End;
|
||||
End;
|
||||
End;
|
||||
|
||||
For I := 0 To 11 Do
|
||||
Begin
|
||||
If SimilarColors(TempColor[I], 28756, 30) Then // Green Monster
|
||||
Begin
|
||||
Result := True;
|
||||
Doors[DN].WhatMonster := 'Green Monster';
|
||||
Exit;
|
||||
End;
|
||||
End;
|
||||
|
||||
For I := 0 To 11 Do
|
||||
Begin
|
||||
If SimilarColors(TempColor[I], 794793, 30) Then // Mysterious Man
|
||||
Begin
|
||||
Result := True;
|
||||
Doors[DN].WhatMonster := 'Mysterious Man';
|
||||
Exit;
|
||||
End;
|
||||
End;
|
||||
|
||||
End;
|
||||
|
||||
Procedure HandleMonsters;
|
||||
|
||||
Var
|
||||
I, iX, iY, Time: Integer;
|
||||
|
||||
Begin
|
||||
For I := 0 To 5 Do
|
||||
Begin
|
||||
If IsBadGuy(I) Then
|
||||
Begin
|
||||
KeyDown(Doors[I].DoorChar);
|
||||
Wait(10 * KeyDownUpSpeed);
|
||||
KeyUp(Doors[I].DoorChar);
|
||||
End;
|
||||
End;
|
||||
End;
|
||||
|
||||
Procedure AddToGold;
|
||||
|
||||
Begin
|
||||
If GetColor(388, 25) = 0 Then
|
||||
Begin
|
||||
Wait(100);
|
||||
KeyDown(32);
|
||||
Wait(10 * KeyDownUpSpeed);
|
||||
KeyUp(32);
|
||||
End;
|
||||
End;
|
||||
|
||||
begin
|
||||
//ClearDebug;
|
||||
DeclareStuff;
|
||||
Repeat
|
||||
AddToGold;
|
||||
HandleMonsters;
|
||||
Wait(10);
|
||||
Until False;
|
||||
end.
|
@ -93,6 +93,8 @@ Sender.AddFunction(@FindColorSpiral,'function FindColorSpiral(var x, y: Integer;
|
||||
Sender.AddFunction(@FindColorsSpiralTolerance,'function FindColorsSpiralTolerance(x, y: Integer; var Points: TPointArray; color, xs, ys, xe, ye: Integer; Tolerance: Integer) : boolean;');
|
||||
Sender.AddFunction(@SetColorToleranceSpeed, 'procedure SetColorToleranceSpeed(cts: integer);');
|
||||
|
||||
Sender.AddFunction(@ColorToHSL, 'procedure ColorToHSL(c: integer; var r,g,b: extended);');
|
||||
|
||||
{Mouse etc.}
|
||||
Sender.AddFunction(@MoveMouse, 'procedure MoveMouse(x, y: integer);');
|
||||
Sender.AddFunction(@GetMousePos, 'procedure GetMousePos(var x, y: integer);');
|
||||
|
@ -93,6 +93,7 @@ uses
|
||||
Graphics, //For Graphics types
|
||||
math, //Maths!
|
||||
bitmaps,
|
||||
colour_conv,
|
||||
forms,//Forms
|
||||
lclintf; // for GetTickCount and others.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user