Janilabo

Janilabo | Shadow Worlds Map.scar

Aug 5th, 2012
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 4.69 KB | None | 0 0
  1. procedure MapSetup;
  2. var
  3.   TSA: TStrArray;
  4.   h, i, id: Integer;
  5.   str: string;
  6. begin
  7.   SetLength(SW.map.info, MAPS_COUNT);
  8.   if not FileExists(IncludesPath + 'MSSL\[' + MSSL_ShortBuiltString + ']\Library\Games\Shadow_Worlds\Configuration\maps\map_info.cfg') then
  9.     Exit;                            
  10.   str := GrabFileData(IncludesPath + 'MSSL\[' + MSSL_ShortBuiltString + ']\Library\Games\Shadow_Worlds\Configuration\maps\map_info.cfg');
  11.   if (str <> '') then
  12.   begin                          
  13.     TSA := Explode(#13#10, str);
  14.     h := High(TSA);
  15.     str := '';
  16.     for i := 0 to h do
  17.     begin  
  18.       id := StrToIntDef(Between('ID="', '", ', TSA[i]), -1);
  19.       if InRange(id, 0, (MAPS_COUNT - 1)) then
  20.       begin
  21.         SW.map.info[id].name := Between('Name="', '", ', TSA[i]);
  22.         SW.map.info[id].width := StrToIntDef(Between('Width="', '", ', TSA[i]), -1);
  23.         SW.map.info[id].height := StrToIntDef(Between('Height="', '", ', TSA[i]), -1);
  24.         SW.map.info[id].pvp := StrToBoolDef(Between('PVP="', '";', TSA[i]), True);
  25.       end;
  26.     end;
  27.     SetLength(TSA, 0);  
  28.   end;
  29. end;
  30.  
  31. procedure MapUnsetup;
  32. begin
  33.   SetLength(SW.map.info, 0);
  34. end;
  35.  
  36. function GetPlayerPositionInMap(mapID: Integer; var playerPos: TPoint): Boolean;
  37. var
  38.   minimap, map: TSCARBitmap;
  39.   client: TSCARClient;
  40.   pX, pY, x, y: Integer;
  41.   cPt: TPoint;
  42. begin
  43.   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
  44.     Exit;
  45.   minimap := GetClient.CaptureEx(490, 112, 569, 191);
  46.   try
  47.     ReplaceColorMulti(minimap, [16777215, 3289855, 10198015], 0);
  48.     minimap.TranspColor := 0;
  49.     cPt := AreaCenter(490, 112, 569, 191);
  50.     map.LoadFromBMP(IncludesPath + 'MSSL\[' + MSSL_ShortBuiltString + ']\Library\Games\Shadow_Worlds\Configuration\maps\' + IntToStr(mapID) + '.bmp');
  51.     try  
  52.       client := SetClient(TSCARBitmapClient.Create(map));                                            
  53.       try      
  54.         Result := FindBitmap(x, y, minimap, 0, 0, (map.Width - 1), (map.Height - 1));
  55.         if Result then
  56.           playerPos := Point(((pX - 490) + x), ((pY - 112) + y));
  57.       finally
  58.         SetClient(client).Free;
  59.       end;  
  60.     finally
  61.       map.Free;
  62.     end;
  63.   finally              
  64.     minimap.Free;
  65.   end;
  66. end;
  67.  
  68. function GetMap: Integer;
  69. var
  70.   minimap, map: TSCARBitmap;
  71.   client: TSCARClient;
  72.   x, y, i: Integer;
  73. begin
  74.   Result := -1;
  75.   minimap := GetClient.CaptureEx(490, 112, 569, 191);
  76.   try        
  77.     ReplaceColorMulti(minimap, [16777215, 3289855, 10198015], 0);
  78.     minimap.TranspColor := 0;
  79.     for i := 0 to (MAPS_COUNT - 1) do
  80.       if FileExists(IncludesPath + 'MSSL\[' + MSSL_ShortBuiltString + ']\Library\Games\Shadow_Worlds\Configuration\maps\' + IntToStr(i) + '.bmp') then
  81.       begin
  82.         map.LoadFromBMP(IncludesPath + 'MSSL\[' + MSSL_ShortBuiltString + ']\Library\Games\Shadow_Worlds\Configuration\maps\' + IntToStr(i) + '.bmp');
  83.         try    
  84.           client := SetClient(TSCARBitmapClient.Create(map));
  85.           try  
  86.             if FindBitmap(x, y, minimap, 0, 0, (map.Width - 1), (map.Height - 1)) then
  87.             begin
  88.               Result := i;
  89.               Break;
  90.             end;
  91.           finally      
  92.             SetClient(client).Free;  
  93.           end;
  94.         finally
  95.           map.Free;    
  96.         end;
  97.       end;        
  98.     SetClientWindowHandle(SW_Client.wHandle);
  99.   finally
  100.     minimap.Free;        
  101.   end;
  102. end;
  103.  
  104. function GetMatchedMaps: TIntArray;
  105. var
  106.   minimap, map: TSCARBitmap;
  107.   client: TSCARClient;
  108.   x, y, i, r: Integer;
  109. begin
  110.   minimap := GetClient.CaptureEx(490, 112, 569, 191);
  111.   try
  112.     ReplaceColorMulti(minimap, [16777215, 3289855, 10198015], 0);
  113.     minimap.TranspColor := 0;
  114.     SetLength(Result, MAPS_COUNT);
  115.     for i := 0 to (MAPS_COUNT - 1) do
  116.       if FileExists(IncludesPath + 'MSSL\[' + MSSL_ShortBuiltString + ']\Library\Games\Shadow_Worlds\Configuration\maps\' + IntToStr(i) + '.bmp') then
  117.       begin
  118.         map.LoadFromBMP(IncludesPath + 'MSSL\[' + MSSL_ShortBuiltString + ']\Library\Games\Shadow_Worlds\Configuration\maps\' + IntToStr(i) + '.bmp');
  119.         try  
  120.           client := SetClient(TSCARBitmapClient.Create(map));
  121.           try
  122.             if FindBitmap(minimap, x, y, 0, 0, (map.Width - 1), (map.Height - 1)) then
  123.             begin
  124.               Result[r] := i;
  125.               Inc(r);
  126.             end;
  127.           finally
  128.             SetClient(client).Free;    
  129.           end;
  130.         finally
  131.           map.Free;
  132.         end;    
  133.       end;        
  134.     SetLength(Result, r);  
  135.   finally
  136.     minimap.Free;  
  137.   end;
  138. end;
Advertisement
Add Comment
Please, Sign In to add comment