Jump to content
MrHbbq

Need help finding cords to store for vars

Recommended Posts

To start off im new to programing, and this scar script is the first one ive ever wrote. My code is not be sound proof, but she works up until this part, and I cant find out HOW to code it, im lost.

imgur: the simple image sharer

 

above is what it looks at right from where I want it to start. The middle blue hi lighted unit doesn’t matter he has aleady attack. What im stuck as HOW can I FINDCOLOR or FINDBITMAP or just find the 4 other purple units and store them as different vars so I can use them when I want to. I can find out how to find all of them, it keeps storing the same one for more than one vars. I cant find a way to make sure each var gets a different unit. I think I can take it from here if I can get help storing the cords of the units without repeating any of the, also the bottom unit is a different color only because he was just hit it resets back to the purple the rest are, I just took it before it changed back. Also I need more Is and run-on sentences in this post.

Link to comment
Share on other sites

thank you for wanted to help "startrepeatattacks" is where i wanted to put the attacks, but i dont know how to make the code logic work. SO, i made "stompattack" which for now will replace it. the problem with this is IF the 1st stomp attack(firstattack), then first roar attack(roarattack), then 2nd stomp attack(stompattack), does not kill all the units, which 50:50 chance, it stops and thinks the battle is over so it looks for the end battle ok buttons.

 

what my code does below..

 

**before clicking start have screen in bigfoot area* then start bot.. and the bot does the following..

 

clicks green attack icon

click orange select

click green fight

wait till map is done loading and your in the pre-battle/ pick units

click slider/ move the slider left

click units while you see them (wood and purple units), then stop moving slider

click green fight button **now you in battle***

use stomp attack one

wait till its my turn

click and use roar attack

wait till its my turn

click stomp button and use stomp *** battle should be over over*** //// replace this

click orange "OK" button

click blue "OKay" button

wait till map is done loading and you back in the bigfoo area

repeat everything

 

 

 

the step i said "click stomp button and use stomp" which is coded as "stompattack" i want to replace with the code i wanted help with and put it in "startrepeatattacks". the way i have it now only runs if stompattack kills the last of the units if not she stops working.

 

 

 

 

 

 

program BattleNations;  

var

 select, fight, slider, slider2, loadingscreen: TSCARBitmap;
 x, y, sag, x2, y2, p, w, punitc, wunitc, gfight, mturn, greenshot, yellowshot, orangeshot, redshot, roar, punitbattle, stomp, abok, tok, e, q, r, over: Integer;
 Box1: TBox;
 Desktop: TSCARWindowClient;


procedure setcolors;          
begin
 Sag := 977791;
 select := TSCARBitmap.Create('deNotyU8vw3AYwPHvjhzdvQcnB2/AW1gkDs' +
   'JmSWf/UlarjrAIN3GUiKMQJxESIYtZRpwciGlUa1NNt18lemkkjDY8+Ry+z/P0' +
   '0U8zzX0CPc9jhofUv6YUecpg5NDTGNmo/9awdYkXJWYVY1YBM5THChUiZhZ7Aa' +
   'dEK8ebih1GgbaMXeRVpjHNpcRFktuZ6OjM4RRxZnE19tIj1a3yyVqqNjnYknEV' +
   'OipdDbHM6Wbuw20/X58fJoeP4xgyXQWxhFDRa0efvt8xzav9nY34UH0CbxFRwt' +
   'MIguAnnF6v9/21q47VE4h5hIZX5mx73RfCvLs5qIyvjg40pniv4K1Er18JN4iM');
 fight := 37376;
 slider := TSCARBitmap.Create('deNpTYeBgiPTS725KW7uoa0JLXmmy76YV/cf' +
   '3L82Kc+usTVk1t33R7EZvG5nlcxuBgnDkY6OxemEHnL12cTeQ4W2jMLWnYN3C7' +
   'p6GrOIE753rpwEFPSzEN63s27puWqSHYXdLdpSPzqIZNUDxAzvmx/lZLJ/TcmD' +
   'nAhBjbgvEtGAXFWLs8rGVWbekE8jYv31ekKMOxM0Qu4CM1GDrRTOb4XYBUaib0' +
   'eKZjXu3zk0JsV01v408u4DI3Vx5/bJeYuw6smdRvL/lwmn1R/cu3rRqsq+9PKZ' +
   'di2c1Hd27ZOXiHldTJWLsyo12mj25FtMuIGNSZ3FSqENWtEtVcaSzqQiaXT1Nu' +
   'fkJXnnxHn01WU6GcsTYNbW7JCHIdtWC1r1bZ0HUrJzftm/rbEiYL5vTsmRm47z' +
   'pdf4OGivmtSDbtW/7vFUL2pfNbtq2ajJQzYEd84CCy+YAGXMhCpbObjq4Yz6YU' +
   'X9wJ4ixb9vcpbObkQ2Bow0rJy2eXL+wrzo/zrMqLXjH2ilYlVEFHdg5f+6Uhsm' +
   'd5UDf7Vw39eieRVQxFgBIZAIP');
 slider2 := TSCARBitmap.Create('deNqTZ2BlOL5/KRAtmlyXG+lSmxmSFeY0u' +
   'T3v2L4lpemBHmaKttriSZF2a5d1LZvfFetvPbO3dNu66XEBRrP6i5fM7Qhw0gc' +
   'q6G/NP7BjPtCQVYt7/RwUF82ogZgZ7KICYQBRZXaoqbJAQWrg9vUz1q+YmBzmO' +
   'LE1d9v66YnBZpPas5bO64zysZjeU7J13bRoX/2ZfYWL57T72unM6i+Hm4DH8CV' +
   'TGmI9zXsbMkEemVRXFOexYErV8X1LsmLsOuuTF85qJdLwhdOrgWyg35ENXz27L' +
   'SvMcVJbLpC9Y+PMpFDHjtrURZNqw12MJrUXAL0TH2g8oTVjwayWIBd1rIYDUbS' +
   'vXkV+5JY1UyY35LmbKsHF187tKIjxmNpZCOH2tud422taaohWFcTs2jQLKNJVn' +
   'ehloZyZ4BrkpjpnYikwoELcjedOqkI2fNHstkhvMzs9fmcjqel9FQAMwvAF');
  loadingscreen := TSCARBitmap.Create('deNqNlvtbGlcexmWYKwy3YbjInWF' +
   'gEBhGBhFFqYqXoFlNamObNs0+brK2adIaU6OixphNWnef7P60f/G+h1GcoE2X5' +
   '3WcB4bv57zfyzmoI9mRp3HHToIIN9b9s6Tjp7Tj+ZV+zjh+yZDrrkq9zBPta0Q' +
   'HY87DkvOo7OzpzqOKs1ch12OdPqnSpwb9Zpx+a17qXYP50CRC8B8RP3UtC/TCo' +
   'iiO3RwFCgHZWKAclomOqyQsgoMC4eas9gnlH1cgyAI9T38igHYVhz2+pVeFK9Y' +
   'VaBAWiM9QoN9bLFj2dIGCjP2SJay9AvVrgdorXIOs7A1MwcUguF2DpCE+rhct9' +
   'qLFXcxyVsYQ3NKLjOOlZUe9Dj4QoQyyd1Way/gT9PtJxtIAhPgXM4RiyULs9vW' +
   'yXxc4gou9W0Hl6zKdGENeaHu67AhL/2xzMHUJstUFoNfFy6IcjFEHdkrfzslVp' +
   'c7r9FBRhhCW/r3AQxbLDhpiDen4NtB7IvbDNPf7bF8zffXvP87zHxd4XC/a3K2' +
   'mriboEtfrexmMz2XSmu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Yij4TX23Pf3r8fJNFkAlGel3AoR/6axcHk+MV' +
   'eOwQEaeY0IhD8lYIz3oQLtu+iLWturP9xYwbnbc+cXanBKwQF4Pj5iV8SRw6D0' +
   '0hs/vUvJhpBElm2yrKxvVW13cinv0t+n9kxU76+T9qiILqBFAk7M5OJKDIulzg' +
   'UWDlQzSGHAEmVNZ1Mge344YwqEbO93y5reNx09bG1/X20tap1ua/kLNR0lwn1f' +
   'Q62mvyDspB2pE2riRBshiWdeZjvb5Yi3/RW/M5tRiNBIJeLDzchzabMT2ult0u' +
   '8iwkDajaSqekAZehoQ0du8NscZBR9tPtBRMMXKO1kKWsHjK6WCx8wucxyNKfpc' +
   'k+WTZ36txeiqIT/EY8mY3MiSzeZ1GILCNYAPJ5EIugcWGDAsMS6MW2ACxX6FpS' +
   'Qnqn0ToKJKLx0ZDQLfasQtpBG7hTkmvp9CoyAZWiOIGJE8sEUT20FpW5m9dLYf' +
   'dzMX9KQjfLSOOmdIqsYDfjWzjBPT6hERKLuqxP/rK0DsYUszszY/sa0M2UA4Yw' +
   'RkkCIzo5WNxP1zg/f+TYqnRUozJzK3P970kFC0iR7xuNy96BCwsnQthV/nTbEN' +
   'obMwmHi7qcU2PYdNeXNNrOIBuPmmm1OJoFAmTRJwdKAcetub6c/HNFOYlV4ims' +
   'qHRRACpwKHgl9yQxyssr1fBskfAPbb3eDIoy1457EMpsTC9/rlSYg2oY1YN9U9' +
   'ht8tFfu3ghStPOp/3+ARJclusQZIREzu8HPIClM6FCcX8QwQsoI6xRCAY8qBPB' +
   'PJLgcwUvKQUcq6VDdJO9WYOv0zMyQyOBkziIAOJpITjHgexVo4NzN5sG1WLxGJ' +
   '+rJYn8Z3483oFnMv4vWQ2ldmO1umfa5bIPN4zlFz4f+LTkYM=');
 wunitc := 7179425;  //wood unit
 punitc := 757968;  //purple unit
 gfight := 100867;    // green circle fight button
 mturn := 11712012; // its my turn yaaaaaaa      
 greenshot := 370691; // E's units are green
 yellowshot := 371111; // E's units are yellow
 orangeshot := 350119; // E's units are orange
 redshot := 0; // E's units are orange
 roar := 4817545; // roar icon
 punitbattle := 5593988; // p unit in battle
 stomp := 7163976; // stomp attack
 abok := 9350579;
 tok := 12574224;
 q := 0;
 e := 0;
 r := 0;


 Desktop := TSCARWindowClient.Create(GetDesktopWindow);
 SetClient(Desktop);
 Box1 := GetWindowBox(GetDesktopWindow);
 WriteLn('Vars are Loaded');  
end;  

procedure makebuglog;
begin
 writeLn('Capt My Capt, She Done Broked');
 TerminateScript;
end;

procedure startbot;
begin
 Writeln('You Clicked Start');
 Wait(250);
 Writeln('Bot Has Started');
end;

procedure setstartattack;
begin  
 begin
    if 
   Findcolor(x, y, sag, 0, 0, Box1.X2 - 1, Box1.Y2 - 1)   
 then
   begin
     ClickMouseEx(x, y, mbLeft, 150);
     WriteLn(IntToStr(x) + ', ' + IntToStr(y) + ' Clicked Attack Icon');      
   end
 else
   begin
     Writeln('CANT FIND GREEN ATTACK BUTTON');
     makebuglog;
   end;
 end;


   wait(1000);

 begin
 if 
   FindBitmap(x, y, select, 0, 0, Box1.X2 - 1, Box1.Y2 - 1)   
 then
   begin
     ClickMouseEx(x, y, mbLeft, 150);
     WriteLn(IntToStr(x) + ', ' + IntToStr(y) + ' Clicked Select');      
   end
 else
   begin
     Writeln('CANT FIND SELECT BUTTON');
     makebuglog;
   end;  
 end;         

 select.Free;
 wait(1000);   

 begin    
 if 
   Findcolor(x, y, fight, 0, 0, Box1.X2 - 1, Box1.Y2 - 1)   
 then
   begin
     ClickMouseEx(x, y, mbLeft, 150);
     WriteLn(IntToStr(x) + ', ' + IntToStr(y) + ' Clicked Fight');      
   end
 else
   begin
     Writeln('CANT FIND FIGHT BUTTON');
     makebuglog;
   end; 
 end;  

end;

procedure scroll;
begin
 if 
 FindBitmap(x, y, slider, 0, 0, Box1.X2 - 1, Box1.Y2 - 1)
 and
 FindBitmap(x2, y2, slider2, 0, 0, Box1.X2 - 1, Box1.Y2 - 1)    
 then
   begin
     wait(250)
     MouseBtnDown(x, y+25, mbleft)
     Wait(250)
     WriteLn(IntToStr(x) + ', ' + IntToStr(y) + ' Found Slider...Moving')
     MouseBtnUp(x2, y2+25, mbleft)
     WriteLn(IntToStr(x2) + ', ' + IntToStr(y2) + ' Found Slider2...Moved') 
     wait(1000)   
   end
 else
   begin
   Writeln('CANT FIND SLIDER');
   makebuglog;
   end; 
end;

procedure clickpunit;
begin
 if Findcolor(x, y, punitc, 0, 0, Box1.X2 - 1, Box1.Y2 - 1) then
   begin
     if p=0 then
       begin
         Findcolor(x, y, punitc, 0, 0, Box1.X2 - 1, Box1.Y2 - 1)
         wait(250)
         writeln('clicked purple unit')
         ClickMouseEx(x, y, mbLeft, 150)
         wait(250)
         writeln('clicked purple unit')
         ClickMouseEx(x, y, mbLeft, 150)
         wait(250)
         writeln('clicked purple unit')
         ClickMouseEx(x, y, mbLeft, 150)
         wait(250)
         writeln('clicked purple unit')  
         ClickMouseEx(x, y, mbLeft, 150)
         wait(250)
         writeln('clicked purple unit')
         ClickMouseEx(x, y, mbLeft, 150)
         writeln('clicked purple unit')
         P := 1
         scroll;         
       end
     else
   end
 else
   begin
     scroll; //too many punits

   end;                      
end;

procedure clickwunit;
begin
 writeln('looking for wunit...')
 if w=0 then
   begin
     wait(250)
     Findcolor(x, y, wunitc, 0, 0, Box1.X2 - 1, Box1.Y2 - 1)
     ClickMouseEx(x, y, mbLeft, 150)
     writeln('Clicked Wood Unit')
     wait(500)     
     w := 1;
   end         
 else
   begin
     clickpunit;
   end;            
end;

procedure lookingforunits;
begin
 if Findcolor(x, y, wunitc, 0, 0, Box1.X2 - 1, Box1.Y2 - 1) then
   begin
     clickwunit; 
   end
 else
   begin
     clickpunit;
   end;
end;

procedure lookingforfightbutton;
begin
 if Findcolor(x, y, gfight, 0, 0, Box1.X2 - 1, Box1.Y2 - 1) then
   begin
     writeln('Clicked Fight');
     begin
       ClickMouseEx(x, y, mbLeft, 150);
     end;
   end
 else
   begin
     makebuglog;  
   end;
end;


procedure Setupbattle;
begin
w := 0
P := 0
repeat
 begin
   lookingforunits;  
 end;  
until (w=1) and (p=1);
 writeln('Done Picking Units');
 begin
   lookingforfightbutton;  
 end;
end;


procedure lscreen;
begin
 writeLn('Loading screen...'); 
 wait(1500);
 while FindBitmap(x, y, loadingscreen, 0, 0, Box1.X2 - 1, Box1.Y2 - 1) = true do
 begin
   wait(1500);
 end;
 WriteLn('Loading Done.');
end;


procedure doihaveashot;
begin
 if Findcolor(x, y, greenshot, 0, 0, Box1.X2 - 1, Box1.Y2 - 1) then
   ClickMouseEx(x, y, mbLeft, 150)
 else
   if Findcolor(x, y, yellowshot, 0, 0, Box1.X2 - 1, Box1.Y2 - 1) then
     ClickMouseEx(x, y, mbLeft, 150)
   else
     if Findcolor(x, y, orangeshot, 0, 0, Box1.X2 - 1, Box1.Y2 - 1) then
       ClickMouseEx(x, y, mbLeft, 150)
     else                             
       if Findcolor(x, y, redshot, 0, 0, Box1.X2 - 1, Box1.Y2 - 1) then
         ClickMouseEx(x, y, mbLeft, 150)
       else
         writeln('No Shot To Fire');       
end;

procedure roaricon;
begin
 Findcolor(x, y, roar, 0, 0, Box1.X2 - 1, Box1.Y2 - 1);
 ClickMouseEx(x, y, mbLeft, 150)
 WriteLn(IntToStr(x) + ', ' + IntToStr(y) + ' Click Roar Icon');
 wait(250);
end;

procedure firstattack; // 1st stomp attack
begin  
wait(1000);
 if Findcolor(x, y, mturn, 0, 0, Box1.X2 - 1, Box1.Y2 - 1) then
   begin
     writeln('My First Attack...');
       begin
         doihaveashot;
       end;
   end
 else
   begin
    writeln('not my turn')
    firstattack;
   end;  
end;



procedure myturn;    // seeing if my turn yet
begin
 wait(2000);
 if Findcolor(x, y, mturn, 0, 0, Box1.X2 - 1, Box1.Y2 - 1) then
   writeln('My Turn')
 else
   begin
     writeln('Not My Turn')
     myturn;
   end;
end;

procedure roarattack;       // main center unit's roar attack, ran onces per battle
begin
myturn;
 begin
   begin
     roaricon;      
   end;
   wait(100);
   doihaveashot;
 end; 
end;



procedure startrepeatattacks;        // new code here this will replace stompattck
begin

end;    


procedure stompicon;
begin
 Findcolor(x, y, stomp, 0, 0, Box1.X2 - 1, Box1.Y2 - 1);
 ClickMouseEx(x, y, mbLeft, 150)
 WriteLn(IntToStr(x) + ', ' + IntToStr(y) + ' Click Stomp Icon');
 wait(250);
end;


procedure stompattack; ///replace with startrepeatattacks when its working
begin
myturn;
 begin
   begin
     stompicon;      
   end;
   wait(100);
   Findcolor(x, y, greenshot, 0, 0, Box1.X2 - 1, Box1.Y2 - 1);
   ClickMouseEx(x, y, mbLeft, 150);
 end; 
end;



procedure battleover;
begin
wait(1000);
 if Findcolor(x, y, abok, 0, 0, Box1.X2 - 1, Box1.Y2 - 1) then
   begin
     if  q=0 then
       begin
         ClickMouseEx(x, y, mbLeft, 150);
         writeln(IntToStr(x) + ', ' + IntToStr(y) + ' clicked after battle ok');
         q := (q + 1);
         wait(2000);
       end
     else battleover;
   end
 else 
   begin
     if Findcolor(x, y, tok, 0, 0, Box1.X2 - 1, Box1.Y2 - 1) then
       begin
         if e=0 then
           begin
             ClickMouseEx(x, y, mbLeft, 150);
             writeln(IntToStr(x) + ', ' + IntToStr(y) + ' clicked after battle okya...');
             e := (e + 1);
             wait(2000);
           end
         else
         battleover;
       end
     else
      begin
       begin
         writeln('Starting battle over again...');  
         begin
           battleover;
         end;
       end;   
      end;
  end;
end;




begin
ClearDebug;
over := 0
 repeat
 setcolors;
 startbot;
 Setstartattack;
 lscreen;
 Setupbattle;
 firstattack;
 roarattack;
 stompattack;  // look into later startrepeatattacks places this
 battleover;
 lscreen; 
 until over = 1;
end.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...