Jump to content

Recommended Posts

Posted (edited)

So, as you would probably note from my code and such, I'm new to AutoIt coding, so there is probably a better way to code it, or a simple solution that I'm not seeing, so I'm trying to get better at it, and I appologize in advance. I made an example of what I'm trying to do, with my code and an image to better exemplify what I'm trying to achieve

 

I have a character that is performing an action (example here is the stickman attacking those green things)

Everytime he is engaged in that action, he moves to where the green enemy is. So I'm trying to make a script that keeps engaged in the action while the enemy is in front of him, and keeps on repeating this action of searching and clicking on them, while there are still green enemies to his left and right.

 

Simply, that is what I'm trying to achieve:

1. Searchs if the green enemy is in front of him

  -if it is, stay in the same position, untill it's not there anymore

    -if it's not, search for the green enemy to it's right and left, and click on it

 

For the sake of searching if it is in front of him and staying in there untill it disappears, I made a "MouseMove" that I thought was going to keep the mouse on top of this green enemy, while it was there. But it only moves over it once or twice, and then it clicks on the green enemies that are from it's left/right, even if the green enemy that is in front of him has not been killed, and that is not what I'm trying to achieve.

I know it is clicking away because the MouseClick function that is being triggered later in the other part the of the code, but I can't think of a way to not trigger it, while the green is still in front of the stickman.

So, here's the code I have and the image to ilustrate it better:

#include <AutoItConstants.au3>

HotKeySet("{esc}", "quit")

While(1)

for $count = 1 to 20

   ;search for the green color on the central piece - under the stickman
   $pixels1 = PixelSearch(390, 310, 430, 353, 0x31ff31, 1)
   if NOT(@error) Then
      MouseMove($pixels1[0], $pixels1[1])
      sleep (350)
   EndIf


     ;search for the green color to the left of the stickman
     $pixels2 = PixelSearch(120, 310, 375, 353, 0x31ff31, 1)
     
     if NOT(@error) Then
        MouseClick($MOUSE_CLICK_LEFT, $pixels2[0], $pixels2[1])
        sleep (1* 2500)
     EndIf


       ;search for the green color to the right of the stickman
       $pixels3 = PixelSearch(445, 310, 698, 353, 0x31ff31, 1)
       
       if NOT(@error) Then
          MouseClick($MOUSE_CLICK_LEFT, $pixels3[0], $pixels3[1])
          sleep (1* 3500)
       EndIf

Next
WEnd

Func quit()
    Exit
EndFunc   ;==>quit

If anyone could help me here, I would be very thankful!

a1.png

Edited by iTzSublime
  • Moderators
Posted

Welcome to the AutoIt forum.

Unfortunately you appear to have missed the Forum rules on your way in. Please read them now - particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked.

See you soon with a legitimate question I hope.

The Moderation team

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...