Jump to content
AC Tool Forums
Sign in to follow this  
ArcherRojas

Time condition

Recommended Posts

// This command adjusts how quickly, or slowly, AC Tool
// presses a key. The lower the number the quicker the
// key is pressed. The higher the number the slower the
// key is pressed.
//
// Adjust the number up to slow down the
// pressing of the keys until your game recognizes
// that the key has been pressed.
//
// NOTE: No matter what game you are playing.
// KeyRate show not be higher than 50, and
// even then that is way to slow.
KeyRate 10

// Set the game window as the active window
SetActiveWindow Granado Espada// Andromida
//
Delay 4 sec


while 1=1
Call scout_principal
ProcessMessages
end



///procesos

procedure scout_principal
Constants
TIMER =  0 MIN
End

If TIMER = 0 MIN
  // Do these commands if true 
  skeys z
  delay 3 sec
  skeys h
Else
  // Do these commands if false 
End

So hi, its been a while since I last entered the forum, I'm here with a new dilema , is it possible to make a condition with a certain time.

 

I mean lets just say I have a skill with a certain duration let's say 3 minutes, how can I make my code to check if the 3 minutes have passed and then recast the skill or if the 3 minutes haven't passed then continue with the other processes until the time set finish, so far this is what i got its just an example but what i need is to set a timer to cast the skill every 4 minutes , while in the loop if the code detects the process timer havent finish then keep doing the other procedures 

 

 

Edited by ArcherRojas

Share this post


Link to post
Share on other sites

@ArcherRojas Well, If I understand you correctly. You have two options to do this.

Option 1: Look in the Help file General Information > Special Variables. You should see 8 special variables that you could use to help you. I would recommend that you use the Millisecond one if you go this route. You would then create three constants, One for when you are setting the start time of your event. One for when the next time the event should trigger. And last another for the current time. You would use these three constants to create when the next time you want your event to be triggered. And then to compare when it is time to trigger that event. If you plan to have multiple events to be executed. Then you will have to create addition constants to keep track of each events next execution time.

Option 2: Use the Procedure ... Every ... End procedure and the ProcessMessages to create a event(s) that will be executed every millisecond/second/minute/hour/etc. Look in the Help file > AC Tool Commands > Procedure ... End & AC Tool Commands > ProcessMessages to learn more. A couple of things I need to mention. If you use this Option, place the ProcessMessages command where you would like your event to take place. Like someplace where it would not enter-fear with what you are doing with your script. Also, note that if you create more than one Procedure ... Every ... End procedure. Then keep in mind that the Process messages will check all such procedures at that time. And if more then one of them is able to be executed. Then it will execute them, in order that it finds them, at that time. So, keep this in mind as it could cause problems with what you are doing.

 

Share this post


Link to post
Share on other sites
6 hours ago, The WABBIT said:

@ArcherRojas Well, If I understand you correctly. You have two options to do this.

Option 1: Look in the Help file General Information > Special Variables. You should see 8 special variables that you could use to help you. I would recommend that you use the Millisecond one if you go this route. You would then create three constants, One for when you are setting the start time of your event. One for when the next time the event should trigger. And last another for the current time. You would use these three constants to create when the next time you want your event to be triggered. And then to compare when it is time to trigger that event. If you plan to have multiple events to be executed. Then you will have to create addition constants to keep track of each events next execution time.

Option 2: Use the Procedure ... Every ... End procedure and the ProcessMessages to create a event(s) that will be executed every millisecond/second/minute/hour/etc. Look in the Help file > AC Tool Commands > Procedure ... End & AC Tool Commands > ProcessMessages to learn more. A couple of things I need to mention. If you use this Option, place the ProcessMessages command where you would like your event to take place. Like someplace where it would not enter-fear with what you are doing with your script. Also, note that if you create more than one Procedure ... Every ... End procedure. Then keep in mind that the Process messages will check all such procedures at that time. And if more then one of them is able to be executed. Then it will execute them, in order that it finds them, at that time. So, keep this in mind as it could cause problems with what you are doing.

 

Thanks sir I will look into it and then report back

Share this post


Link to post
Share on other sites

This is what I am interested in as well. Will be watching this thread for the code. I tried a few things and came across the problems The WABBIT typed under Option 2. My placement interfered with the code so I stopped and put it out of my head until now. Thanks a lot... lol

Share this post


Link to post
Share on other sites

@Ego The only way that I can think of to work around the problem I mention for Option 2 is this.

Create a Constant that will be a flag for when the event can/should be executed. Then sometime in your script, you would need to set the flag to (dis)allow the event to execute as needed based on where at in your script you are.

Example:

Example:

  Contants
    Attack
    MPLvl
    (* The following constants are flags
       for the Procedure..Every event(s).
       Their value can be set to 1/0 or
       True/False or Yes/No or On/Off. Just
       so long as you have the starting
       value set to "Turn OFF" then event.

       Then later within your script
       code you can then "Turn ON" the
       event, and/or "Turn OFF" other
       event(s), when the various Event(s)
      can be, and should be, allowed to
      executed. *)
      
   RechargeMP = False
   Heal = False
 end
    
  procedure DrinkMPPotion Every 1 min
    if RechargeMP = True
      // code to get the character's
      // MP level.
      
      // Set the MPLvl constant with
      // the current MP level
      Set MPLvl = 0
      
      // Do we need to replenish MP?
      if MPLvl < 20
        //to drink a MP potion if necessary.
      end
    end
  end
    
  procedure HealToon Every 1.5 min
  	// Code to get the current MP level
  	
  	// Set the MPLvl constant with the
  	// current MP level
  	Set MP Lvl = 
  	
    if Heal = True
      // code to get the character's
      // HP level
      
      // Set the HPLvl constant with the
      // current HP level.
      Set HPLvl = 
      
      // Do we need to heal the character?
      if HPLvl < 20
        if MPLvl > 19
      	  // code to cast a Heal spell
      	  // on the character if necessary.
        else
      	  // code to drink a HP potion
      	  // if necessary.
        end
      end
    end
  end
    
  procedure AttackMOB
    Set Attack = False
    
    // Turn On/Off events as needed
    Set RechargeMP = True // Turn On the Event
    Set Heal = True // Torn on the event
    
    // Check to see if there is a MOB to attack

    // If there is a MOB to attack then set
    // Attack flag to True
    Set Attack = True
    
    // if the Attack flag is turned "ON"
    // attack the MOB
    While Attack = True
      // Code to attack the MOB
      
      // Code to 
      ProcessMessages
      
      // Code to check to see if the MOB
      // still needs to be attacked
      
      // If the MOB is DEAD, then set the
      // Attack flag False to exit the
      // attack routine
      Set Attack = False
    end
    
    // Turn On/Off events as needed
    Set RechargeMP = False // Turn Off the Event
    Set Heal = False // Turn Off the Event
  end
  

As you can see from the Example, it is quite simple to work around the issue of the multiple of Events being triggered at the same time.

But, still be careful.

Even with doing this you may still have an issue with a Procedure..Every event executing at just the wrong time. For which you may need to use additional flags to check to make sure the Procedure..Every event does not execute at the wrong time.

 

Now there addition problem with using Procedure..Every event(s). If you set the Procedure..Every event's every parameter for the event to only execute the event when you are able to re-cast a spell. (Like I did with the HealToon Procedure..Every event.) Then the only time that event will be triggered is when the character is able to re-cast the spell. 

At which you have to options.

  1. Change the time of the Procedure..Every event to execute the event more often. Which may, or may not, impact the performance of your script.
  2. Change the Procedure..Every event to a Procedure..When event. Then use the Flag as the When parameter. That way the Procedure..When event will only be executed when the flag has been "Turned ON". And you can use multiple flags as part of the When parameter, just like in a If..end statement.

The following Example  uses Options 1 & 2 from my first post, as well as the Procedure..When event.

  • The script uses the Procedure..Every event (As mentioned in my previous post) to drink a MP potion.
  • It uses a Procedure..When event to Heal the character.
  • And yet, within the Procedure..When event, it uses the Time Constants (as mentioned in my previous post) to decide if we can cast a spell to heal the character or to drink a potion.

Example:

Example:

  Contants
    Attack
    MPLvl
    (* The following constants are flags
       for the Procedure..Every event(s).
       Their value can be set to 1/0 or
       True/False or Yes/No or On/Off. Just
       so long as you have the starting
       value set to "Turn OFF" then event.

       Then later within your script
       code you can then "Turn ON" the
       event, and/or "Turn OFF" other
       event(s), when the various Event(s)
      can be, and should be, allowed to
      executed. *)
      
   RechargeMP = False
   Heal = False
   
   (* Constants to check to see if a spell
      can be re-cast. *)
   CurrentTime
   RecastHealSpell = 0
   RecastHealTime = 1500 // how long, in milliseconds, be you can re-cast the spell
 end
    
  procedure DrinkMPPotion Every 30 sec
    // code to get the character's
    // MP level.
     
    // Set the MPLvl constant with the current MP level
    Set MPLvl = 
      
    // Do we need to replenish MP?
    if MPLvl < 20
      // to drink a MP potion.
    end
  end
    
  procedure HealToon When Heal = True
    // Code to get the current MP level
  	
    // Set the MPLvl constant with the current MP level
    Set MP Lvl = 
  	
    // Do we have enough MP to cast a spell?
    if MPLvl > 19
      // Get the current current time
      Set CurrentTime = {ElapsedMSec}
      // Can we re-cast the heal spell yet?
      if CurrentTime >= RecastHealSpell
  	    // code to cast a Heal spell on the character.
       
        (* Set the time the spell can be re-cast.
           At thie time we are taking the currenttime
           (which is in milliseconds) and adding the value in
           the RecastHealTime (also in milliseconds) constant to it *)
        Compute RecastHealSpell = CurrentTime + RecastHealTime
      else
  	    // code to drink a HP potion if necessary.
  	    Set RechargeMP = True
      end      
    end
    Set Heal = False
  end
    
  procedure AttackMOB
    Set Attack = False

    // Turn On/Off events as needed
    Set RechargeMP = True // Turn On the Event
    
    // Check to see if there is a MOB to attack

    // If there is a MOB to attack then set Attack flag to True
    Set Attack = True
    
    // if the Attack flag is turned "ON" enter the
    //attact routine to attack the MOB
    While Attack = True
      // Code to attack the MOB
      
      // Code to get the charater's current HP level.
      
      // Set the HPLvl constant with the
      // current HP level
      Set HPLvl =
      
      // Check to see if you need to replenish
      // the character's HP
      if HPLvl < 19
      	Set Heal = True // Turn On the event
      end
      
      // Hopefully this is a safe place to execute
      // the Event(s).
      ProcessMessages
      
      // Code to check to see if the MOB
      // still needs to be attacked
      
      // If the MOB is DEAD, then set the
      // Attack flag to False to exit the
      // attack routine
      Set Attack = False
    end

    // Turn On/Off events as needed
    Set RechargeMP = False // Turn On the Event
  end
  

 

 

The examples shown above was created off the top of my head as I typed this post. The logic in them should be fine. If not, then it should only take a few minor changes/corrections to make the examples work as intended.

There you have it. Code to use without code being given. Learn from it.

 

Share this post


Link to post
Share on other sites

Sorry for the late reply so i found and old thread about an old code i wrote like a year ago so what i did was taking the advice of mr wabbit and the code looks like this 

// This command adjusts how quickly, or slowly, AC Tool
// presses a key. The lower the number the quicker the
// key is pressed. The higher the number the slower the
// key is pressed.
//
// Adjust the number up to slow down the
// pressing of the keys until your game recognizes
// that the key has been pressed.
//
// NOTE: No matter what game you are playing.
// KeyRate show not be higher than 50, and
// even then that is way to slow.
KeyRate 15

// Set the game window as the active window
SetActiveWindow Granado Espada Andromida// Andromida
//
Delay 5 sec

///procesos

procedure scout_principal every 4 min
skeys y
//delay 3 sec
//skeys h
//delay 10 sec 
//skeys a
end

procedure autobullet every 30 min

skeys m
delay 1 sec
skeys m
delay 1 sec
skeys j
delay 1 sec
skeys j
end

while 1=1
ProcessMessages
end

 

Share this post


Link to post
Share on other sites

@ArcherRojas Well, you added your post just as I had added mine.

One thing I should mention, for the SetActiveWindow make sure to put a space between the Window name and your first / for your comment after it. Otherwise, AC Tool will think the comment is part of the window name.

But, from what I can see. The code that you have there should work fine.

But, remember what I mentioned about what can happen if you are using multiple Procedure..Every events. So, look at my newest post and see if any of that may help.

Share this post


Link to post
Share on other sites

Yes it does work as expected as it checks the time and cast the skill every 4 minutes , so now I have another question how can I make s counter and program an alarm to sound when my inventory is full? 🤔

Share this post


Link to post
Share on other sites

The code that you posted above does not have anything that checks the time. But, it does execute the skill every 4 minutes, as coded with the Procedure..Every event.

 

What do you mean by counters? Are you talking about keeping track of how much of something you have? How many of something that you are creating/getting? Please explain more.

 

As for sounding a sound, as if for an alarm, you would use the Bell Command. Look at Help file > AC Tool Commands > Bell to learn more.

Share this post


Link to post
Share on other sites

I mean I used the procedure .... Every as you kindly told me on one of my post like a year ago, so the script a it is right now does what's needed.

 

As for the other part of the code I'm looking to create an alarm when my inventory is full. I will look into the bell command

Share this post


Link to post
Share on other sites

Thanks WABBIT, will have a look over the next few days, got a lot on atm with foster child, taking up a lot of my old free time. Very rewarding.

 

 

Oooo, read up on when event, now that could be what I am looking for, going to have a play with that.

 

Share this post


Link to post
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.

Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and to our Privacy Policy.