Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

detect image


  • Please log in to reply
9 replies to this topic
SkrillexAkaCraft
  • Members
  • 45 posts
  • Last active: Jan 04 2018 06:02 PM
  • Joined: 04 Feb 2015

sp i'm working on a project wich should be using more than only 1 image

 

 

so lets say it sees a button with Fight on it presses that then when there are 4 buttons it should only be using moves wich cause dammage

 

 

the example moves are:

 

Thunderbolt

Growl

Tailwhip

Strenght

 

 

 

so what i want to mannage is when it sees those buttons it should look for the 3 damage causers wich are Thunderbolt, Strenght

 

 

how do i manage that

 

 

 

what i got is this

 

 

Click_Attack(){
     
ImageSearch profilex, profiley, 50, 50, 1920, 1080, *25 Lib/ScriptsImages/scratch.png
     or
ImageSearch profilex, profiley, 50, 50, 1920, 1080, *25 Lib/ScriptsImages/tackle.png
or 
ImageSearch profilex, profiley, 50, 50, 1920, 1080, *25 Lib/ScriptsImages/watergun.png
or
ImageSearch profilex, profiley, 50, 50, 1920, 1080, *25 Lib/ScriptsImages/rage.png
if (ErrorLevel=0)
 
{      
 
click %profilex%, %profiley%, right
 
          sleep 100
 
}
}
 
;#####################################################################################


Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

Perform each ImageSearch and then check each ErrorLevel to see if you want to click on the profilex and profiley coordinates.

 

Is there any indicator of what type of move this is (Physical, Special, Status/Neither (The gray swirly icon)) in your game that you could search for? Picking out the physical or special attack should then work. I worry because there are hundreds of attacks and compiling images for each of these would take a while (a couple hours of your time) and imagesearching for each of these would take a while (might take several seconds if you're searching your entire screen - I would limit to just the area the attack icons could be.)



SkrillexAkaCraft
  • Members
  • 45 posts
  • Last active: Jan 04 2018 06:02 PM
  • Joined: 04 Feb 2015

Perform each ImageSearch and then check each ErrorLevel to see if you want to click on the profilex and profiley coordinates.

 

Is there any indicator of what type of move this is (Physical, Special, Status/Neither (The gray swirly icon)) in your game that you could search for? Picking out the physical or special attack should then work. I worry because there are hundreds of attacks and compiling images for each of these would take a while (a couple hours of your time) and imagesearching for each of these would take a while (might take several seconds if you're searching your entire screen - I would limit to just the area the attack icons could be.)

nope red plain buttons with text on so that means i have to do a whole list of moves? o_O like this 

 

 

 

if detect_end()=1
{
Click_fight()
sleep 100
Click_scratch()
sleep 400
 
}
else
if detect_end()=0
{
if detect_strenght()=1
{
click...
....
....
...}
}
return


Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

I wouldn't put each imagesearch command in your script.

 

You will need an image of each attack though.

 

What I recommend is using a Loop and running through your files. You can consider doing a LoopFile command and ImageSearch by the %A_LoopField% for the image name. If you do that, you can use a Break once a match is found.

 

If you have a folder of just images, this will work fine.

 

There may be a better approach, but I'm only somewhat familiar with your situation from prior posts and my own history with the official games.



SkrillexAkaCraft
  • Members
  • 45 posts
  • Last active: Jan 04 2018 06:02 PM
  • Joined: 04 Feb 2015

currently i'm making a image of each move i got 

 

after that can you send a part of code wich i can use for that? well i'm also working with a lib so its not each image in the script itself but in the lib :/

 

 

so if i can make a function like what i did post above that would realy help me at all!



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

Click_Attack(){   
Loop, File, ; fill in the parameters
{
ImageSearch profilex, profiley, 50, 50, 1920, 1080, *25 %A_LoopFile%.png ; I think I siad this was A_LoopField earlier. I think it should be A_LoopFile. There is also a variable that includes the .png extension, so be careful not to be redundant.
if (ErrorLevel=0) 
{     
click %profilex%, %profiley%, right
          sleep 100
Break
}
}
}


SkrillexAkaCraft
  • Members
  • 45 posts
  • Last active: Jan 04 2018 06:02 PM
  • Joined: 04 Feb 2015
Click_Attack(){   
Loop, File, ; fill in the parameters
{
ImageSearch profilex, profiley, 50, 50, 1920, 1080, *25 %A_LoopFile%.png ; I think I siad this was A_LoopField earlier. I think it should be A_LoopFile. There is also a variable that includes the .png extension, so be careful not to be redundant.
if (ErrorLevel=0) 
{     
click %profilex%, %profiley%, right
          sleep 100
Break
}
}
}

wich means i have to place them in a different folder than it is now since there are alot of images in the same folder



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

That would be the easiest. If that is absolutely not an option, you have three options I can think of:

 

A) Go the long route and include every single ImageSearch step as a separate set of lines, making your script really long.

B) Defining an array for the attack names corresponding ot the images and looping through that rather than using the LoopFile.

C) Prefixing the name of your images as "Attack_" such as "Attack_Scratch" and "Attack_Thunderbolt" and match the "Attack_" prefix when you do your LoopFile.



SkrillexAkaCraft
  • Members
  • 45 posts
  • Last active: Jan 04 2018 06:02 PM
  • Joined: 04 Feb 2015

so lets say i got 2 image folders one named ScriptsImages and one called AttackMoves i just do this 

 

 

Click_Attack(){   
Loop, File, ; fill in the parameters
{
ImageSearch profilex, profiley, 50, 50, 1920, 1080, *25 Lib/%A_LoopFile%.png ; I think I siad this was A_LoopField earlier. I think it should be A_LoopFile. There is also a variable that includes the .png extension, so be careful not to be redundant.
if (ErrorLevel=0) 
{     
click %profilex%, %profiley%, right
          sleep 100
Break
}
}
}

 

?



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

Look up the Loop, File syntax (I believe I linked it earlier) and specify what folder it should look for files inside of, in this case you'd want the AttackMoves folder. It may also be in your interest to specify a full name for the ImageFile, which is a variable associated with Loop File that you can look at in the documentation.