Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure MapSetup;
- var
- TSA: TStrArray;
- h, i, id: Integer;
- str: string;
- begin
- SetLength(SW.map.info, MAPS_COUNT);
- if not FileExists(IncludesPath + 'MSSL\[' + MSSL_ShortBuiltString + ']\Library\Games\Shadow_Worlds\Configuration\maps\map_info.cfg') then
- Exit;
- str := GrabFileData(IncludesPath + 'MSSL\[' + MSSL_ShortBuiltString + ']\Library\Games\Shadow_Worlds\Configuration\maps\map_info.cfg');
- if (str <> '') then
- begin
- TSA := Explode(#13#10, str);
- h := High(TSA);
- str := '';
- for i := 0 to h do
- begin
- id := StrToIntDef(Between('ID="', '", ', TSA[i]), -1);
- if InRange(id, 0, (MAPS_COUNT - 1)) then
- begin
- SW.map.info[id].name := Between('Name="', '", ', TSA[i]);
- SW.map.info[id].width := StrToIntDef(Between('Width="', '", ', TSA[i]), -1);
- SW.map.info[id].height := StrToIntDef(Between('Height="', '", ', TSA[i]), -1);
- SW.map.info[id].pvp := StrToBoolDef(Between('PVP="', '";', TSA[i]), True);
- end;
- end;
- SetLength(TSA, 0);
- end;
- end;
- procedure MapUnsetup;
- begin
- SetLength(SW.map.info, 0);
- end;
- function GetPlayerPositionInMap(mapID: Integer; var playerPos: TPoint): Boolean;
- var
- minimap, map: TSCARBitmap;
- client: TSCARClient;
- pX, pY, x, y: Integer;
- cPt: TPoint;
- begin
- if (not InRange(mapID, 0, (MAPS_COUNT - 1)) or not FileExists(IncludesPath + 'MSSL\[' + MSSL_ShortBuiltString + ']\Library\Games\Shadow_Worlds\Configuration\maps\' + IntToStr(mapID) + '.bmp')) then
- Exit;
- minimap := GetClient.CaptureEx(490, 112, 569, 191);
- try
- ReplaceColorMulti(minimap, [16777215, 3289855, 10198015], 0);
- minimap.TranspColor := 0;
- cPt := AreaCenter(490, 112, 569, 191);
- map.LoadFromBMP(IncludesPath + 'MSSL\[' + MSSL_ShortBuiltString + ']\Library\Games\Shadow_Worlds\Configuration\maps\' + IntToStr(mapID) + '.bmp');
- try
- client := SetClient(TSCARBitmapClient.Create(map));
- try
- Result := FindBitmap(x, y, minimap, 0, 0, (map.Width - 1), (map.Height - 1));
- if Result then
- playerPos := Point(((pX - 490) + x), ((pY - 112) + y));
- finally
- SetClient(client).Free;
- end;
- finally
- map.Free;
- end;
- finally
- minimap.Free;
- end;
- end;
- function GetMap: Integer;
- var
- minimap, map: TSCARBitmap;
- client: TSCARClient;
- x, y, i: Integer;
- begin
- Result := -1;
- minimap := GetClient.CaptureEx(490, 112, 569, 191);
- try
- ReplaceColorMulti(minimap, [16777215, 3289855, 10198015], 0);
- minimap.TranspColor := 0;
- for i := 0 to (MAPS_COUNT - 1) do
- if FileExists(IncludesPath + 'MSSL\[' + MSSL_ShortBuiltString + ']\Library\Games\Shadow_Worlds\Configuration\maps\' + IntToStr(i) + '.bmp') then
- begin
- map.LoadFromBMP(IncludesPath + 'MSSL\[' + MSSL_ShortBuiltString + ']\Library\Games\Shadow_Worlds\Configuration\maps\' + IntToStr(i) + '.bmp');
- try
- client := SetClient(TSCARBitmapClient.Create(map));
- try
- if FindBitmap(x, y, minimap, 0, 0, (map.Width - 1), (map.Height - 1)) then
- begin
- Result := i;
- Break;
- end;
- finally
- SetClient(client).Free;
- end;
- finally
- map.Free;
- end;
- end;
- SetClientWindowHandle(SW_Client.wHandle);
- finally
- minimap.Free;
- end;
- end;
- function GetMatchedMaps: TIntArray;
- var
- minimap, map: TSCARBitmap;
- client: TSCARClient;
- x, y, i, r: Integer;
- begin
- minimap := GetClient.CaptureEx(490, 112, 569, 191);
- try
- ReplaceColorMulti(minimap, [16777215, 3289855, 10198015], 0);
- minimap.TranspColor := 0;
- SetLength(Result, MAPS_COUNT);
- for i := 0 to (MAPS_COUNT - 1) do
- if FileExists(IncludesPath + 'MSSL\[' + MSSL_ShortBuiltString + ']\Library\Games\Shadow_Worlds\Configuration\maps\' + IntToStr(i) + '.bmp') then
- begin
- map.LoadFromBMP(IncludesPath + 'MSSL\[' + MSSL_ShortBuiltString + ']\Library\Games\Shadow_Worlds\Configuration\maps\' + IntToStr(i) + '.bmp');
- try
- client := SetClient(TSCARBitmapClient.Create(map));
- try
- if FindBitmap(minimap, x, y, 0, 0, (map.Width - 1), (map.Height - 1)) then
- begin
- Result[r] := i;
- Inc(r);
- end;
- finally
- SetClient(client).Free;
- end;
- finally
- map.Free;
- end;
- end;
- SetLength(Result, r);
- finally
- minimap.Free;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment