Blue Eye Logo

Blue Eye Macro

Automation is freedom
It is currently Thu Nov 21, 2024 3:24 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Timeouts
Thanked: 0 time(s)  Unread post Posted: Sun Sep 25, 2011 1:31 am 
New User
New User



Joined: Sun Sep 25, 2011 1:17 am
Posts: 9
Been thanked: 0 time(s)
Has thanked: 0 time(s)
Contribution Points: 64
I dont know nothing yet how to create a macro so don't laught :p
i want to it select the mob then attack and when it die select another mob. but sometimes it stuck in walls,tree etc.. so i want to add timeouts. (15 segs) then select another mob.
also if someone can improve it i would be happy,thank you.


Code:

begin
     if  Color.At coordinate is within (RGB range)("113", "129", "44", "0", "529", "663")
          begin loop("1024")
               Keyboard.Press key("{<tab>}")
               Macro.Pause("300")
               Keyboard.Press key("{<f1>}")
               Macro.Pause("320")
               if  Color.At coordinate is not within (RGB range)("113", "129", "44", "0", "530", "660")
                    begin
                         Keyboard.Press key("{<f1>}")
                         Macro.Pause("310")
                    end
          end
 end




Top
 Profile  
Reply with quote  
 Post subject: Re: Timeouts
Thanked: 0 time(s)  Unread post Posted: Sun Sep 25, 2011 3:54 am 
VIP Contributor
VIP Contributor
User avatar



Joined: Mon Sep 12, 2011 8:36 pm
Posts: 1307
Location: Steins;Gate
Been thanked: 91 time(s)
Has thanked: 0 time(s)
Contribution Points: 15369
Nice first attempt, it's just sometimes knowledge is power and the more you know about certain functions, the better. And that knowledge will be brought now~ (Ah, a little note: you can use the [.code][/code] feature (without the period) to wrap your code around.)

Concerning time, there's a command called Macro.Start stopwatch() that essentially lets you create a timer. Then we'll 'Read the stopwatch' and compare it to an if statement to see if the time exceeds 15 seconds (This function uses the unit 'ms' miliseconds, so 1 second = 1000 ms). The important part is that we need the timer to stop and reset itself so that way it'll only count for those 15 seconds the moment it finds another enemy to target on.

Here's a small example:

Code:
 Macro.Start stopwatch("Switch Enemies")
 begin loop()
     Macro.Read stopwatch("Switch Enemies", "time")
     if  Variable.Is greater than (Math)("time", "14999")
          begin
               Macro.Reset stopwatch("Switch Enemies")
               Macro.Stop stopwatch("Switch Enemies")
               Macro.Break from loop("no")
          end
 end


The Macro.Break from loop "no" signifies to break the loop immediately. If you want this to loop infinity until you want it to stop, there's a tickmark you can check called 'Infinite' under loops. You can click on that and your entire macro will loop regardless. Make sure under 'Trigger' that you actually set up a hotkey to stop your macro (I recommend Ctrl+A).

I'll go under the assumption that 'tab' is to switch enemies, and to make this macro efficient, you already got one pixel detection that essentially activates the whole macro, so we'll leave the beginning part alone, and get rid of the second pixel detection. Here's a revised code I came up with on the fly, let me know what you think and report back. You may edit this particular line if you choose to edit the amount of seconds:

Code:
if  Variable.Is greater than (Math)("Switch Enemies", "14999") //Edit the "14999" of your liking, keep in mind that 1 second = 1000 ms.


Modified code for you (with a bit of Gigus on the side):

Code:
begin
     if  Color.At coordinate is within (RGB range)("113", "129", "44", "0", "529", "663")
          begin
               Keyboard.Press key("{<tab>}")
               Macro.Pause("300")
               Macro.Start stopwatch("Switch Enemies")
               begin loop()
                    Keyboard.Press key("{<f1>}")
                    Macro.Pause("320")
                    Macro.Read stopwatch("Switch Enemies", "time")
                    if  Variable.Is greater than (Math)("time", "14999")
                         begin
                              Macro.Reset stopwatch("Switch Enemies")
                              Macro.Stop stopwatch("Switch Enemies")
                              Macro.Break from loop("no")
                         end
               end
          end
end


Edit: Reflects on Gigus's post. I must of been on a sugar rush typing this out~

_________________
Image
Code:
> Meanwhile at Blue Eye Macro...
> BEM Video Games Department - Moderator, Coder, Debugger, Math/Physics & Algorithm Enthusiast - USA
Current Project: Mod Duty


Last edited by Critical on Sun Sep 25, 2011 9:52 am, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Timeouts
Thanked: 0 time(s)  Unread post Posted: Sun Sep 25, 2011 9:24 am 
Partner / Developer
Partner / Developer
User avatar



Joined: Mon Jan 18, 2010 11:51 am
Posts: 4525
Been thanked: 1346 time(s)
Has thanked: 133 time(s)
Contribution Points: 33209
A small correction, to see how long has passed since the stop watch was started, you first need to read the stopwatch value using Macro.Read stopwatch, like this:

Code:
 begin
     if  Color.At coordinate is within (RGB range)("113", "129", "44", "0", "529", "663")
          begin
               Keyboard.Press key("{<tab>}")
               Macro.Pause("300")
               Macro.Start stopwatch("Switch Enemies")
               begin loop()
                    Keyboard.Press key("{<f1>}")
                    Macro.Pause("320")
                    Macro.Read stopwatch("Switch Enemies", "time")
                    if  Variable.Is greater than (Math)("time", "14999")
                         begin
                              Macro.Reset stopwatch("Switch Enemies")
                              Macro.Stop stopwatch("Switch Enemies")
                              Macro.Break from loop("no")
                         end
               end
          end
 end

_________________
Blue Eye - Developer / Moderator
Code:
Gigus


Please read the rules about contribution points - click here

Do you know everything about BE, the forum, licenses and contribution points?
Please take a minute to read this introduction & guidelines.


Top
 Profile  
Reply with quote  
 Post subject: Re: Timeouts
Thanked: 0 time(s)  Unread post Posted: Tue Sep 27, 2011 1:10 pm 
New User
New User



Joined: Sun Sep 25, 2011 1:17 am
Posts: 9
Been thanked: 0 time(s)
Has thanked: 0 time(s)
Contribution Points: 64
Thank you.
but it is waiting 15 sec to switch enemies even when it is already dead.


Top
 Profile  
Reply with quote  
 Post subject: Re: Timeouts
Thanked: 0 time(s)  Unread post Posted: Tue Sep 27, 2011 1:14 pm 
VIP Contributor
VIP Contributor
User avatar



Joined: Mon Sep 12, 2011 8:36 pm
Posts: 1307
Location: Steins;Gate
Been thanked: 91 time(s)
Has thanked: 0 time(s)
Contribution Points: 15369
Remember, you can edit this line:

Code:
if  Variable.Is greater than (Math)("Switch Enemies", "14999") //Edit the "14999" of your liking, keep in mind that 1 second = 1000 ms.


You can try to type '5000' instead if your character can kill a lot faster. If that works fine with no problems, you can perhaps notch it down to '4500'.

_________________
Image
Code:
> Meanwhile at Blue Eye Macro...
> BEM Video Games Department - Moderator, Coder, Debugger, Math/Physics & Algorithm Enthusiast - USA
Current Project: Mod Duty


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


You cannot post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group