Jump to content

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

In game countdown timer activated with a key press



  • Please log in to reply
11 replies to this topic
adamkm
  • Members
  • 10 posts
  • Last active: Apr 10 2013 02:48 PM
  • Joined: 29 Jan 2013

Hi Guys

 

I've used AHK for a while but to do simple things, remap keys, sort/filter my clipboard, remove clipboard formatting, multibox in Warcraft and recently i created some image recognition scripts to auto collect gold and production in a one of those browser games (forge of empires). Was alot of learning but i got there.

 

Now im playing Path of Exile and what i need is a script that when i press a key it puts a countdown from 7 seconds onto my screen somewhere and dissapears when it ends. It will need a directX hook or i can run the game in windowed mode with fullscreen if a directX hook isnt possible.

 

I have looked at timer scripts but i dont understand the commands to code 1 myself.

 

If anyone else plays Path of Exile you'll know that potion uses don't stack so on using 1, its difficult to know when the potions effect has expired. A timer would solve this.

 

Can anyone help ? with this ? :)

 

Thanks

 

Adam

 



JadeDragon
  • Members
  • 935 posts
  • Last active: Jun 07 2014 07:40 AM
  • Joined: 18 Jan 2013
✓  Best Answer
There are basically two types of timers -- freerunning timers run constantly and oneshot timers run one time and have to be restarted once they've timed out. Free running timers are useful if you have things that have to run on a schedule like buffs for example. Oneshot timers are useful for things like fight key cooldowns and stuff that needs to be timed for a specific period but are irregular in when they have to be done. If you need a regular 7 second repeating timer a free running timer would probably be your best bet.. maybe something like this...
;this just produces a tooltip when the timer expires
FreeRunTimer1: ;<-- this is just a name you can call it anything you want
Tooltip, FreeRunTimer1 has expired
SoundBeep, 450, 1000
return

;this is how you can cause the timer to start freerunning
SetUp7SecTimer: ;<--a subroutine call to start the timer running
SetTimer, FreeRunTimer1, 7000 ;<-- set the timer named FreeRunTimer1 for 7000 milliseconds (7sec)
Return
and that's pretty much it. You can make a lot of fancy things happen inside the timer code, sound beeps, messages, starting a subroutine, even another timer, or doing skills and stuff. The critical part of knowing about timers is to keep the routine short so the code execution time never exceeds the timer period.

The surprising part about one shot timers is that the only difference between those and the free running kind is the time period. If you wanted to turn FreeRunTimer1 into a oneshot all you need is this...
 SetTimer, FreeRunTimer, -7000 ;<-- notice the minus sign in front of the timer period
The oneshot timer ends at 7 seconds and doesn't automatically restart. They're great for asynchronous event timing. And that's essentially it for timers.

Getting them to work is easy. The hard part is making them do game stuff or display stuff while ingame. Some games are pretty picky about displaying screen messages, or accepting to simulated key strokes especially when in true fullscreen mode. If the game has fullscreen windowed mode you are likely to have more luck with that than true fullscreen. Lot of technical reasons for it that don't really affect the timers tho. Timers can be pretty powerful especially when dealing with mmos for buffing, cooldowns, anti-afk boot routines and other stuff.
 
I find a lot of times you can use sound instead of screen messages to alert you to stuff too. Just a thought.

Never assume evil intent when simple ignorance will suffice. Ignorance is an eventually curable condition with the right education. Evil intent, however, is another matter entirely. Scripts are much like children. Simple to conceive. Difficult, expensive, and time-consuming to raise. Often do the opposite of what you expect them to. Require frequent  "correction". And once they leave home you can't control them anymore. But you love them anyway.


adamkm
  • Members
  • 10 posts
  • Last active: Apr 10 2013 02:48 PM
  • Joined: 29 Jan 2013

Thanks JadeDragon.

 

I'm probably been really thick but i can never get these to actually time any amounts of time.

 

Like your example above, when i run the script i'll get a tooltip popup instantly for 1 second. Nothing seems to change that.

 

I always feel im probably better off just using sleep commands and encompass those with popups.

 

The result im trying to achieve basically is in the game i drink a health potion. It restores 120 health over 7 seconds. If i drink another in that 7 seconds it just resets to 7 seconds, it doesnt stack so i dont want to be using them prematurely. I literally want to use 1 only when the 7 seconds has expired.

 

For that im probably best off initiating a pop up when i press a key, sleep for 7 seconds and remove the pop up so i know i can use it again ? Not knowing many commands, i can code that easily with basic stuff but i was hoping for a better way. Hopefully tooltips can overlay my display when running in windowed mode... hell windows annoying updates and notifications manage it :)



adamkm
  • Members
  • 10 posts
  • Last active: Apr 10 2013 02:48 PM
  • Joined: 29 Jan 2013

Ah i see, i can't use sleep because it effectively pauses the script... of course happy.png

 

So i have come up with this thanks to your code above.

 

I press F1 and i get a tooltip above my red health bar which stays for 7 seconds.

I press F2 and i also get a tooltip above my blue mana bar.

 

For some reason its bugged. The tooltip for drinkmanapotion stays on forever, until the script is ended. But i cannot figure out why that is.

 

the tooltip,,,2 should remove it but it doesnt.

 

any idea ?

 

Ignore me, i had DrinkHealthPotion referred to twice as you can see below. Called under the F2 key and F1 key (figured i wouldnt amend my mistakes)

 

#persistent




F1::
	Tooltip, "Drinking health potion....", 54,560,1	
	SetTimer, DrinkHealthPotion, -7000
	
Return

F2::
	Tooltip, "Dinking mana potion....", 937,560,2	
	SetTimer, DrinkHealthPotion, -7000
	
Return


DrinkHealthPotion:

tooltip,,,1

return

DrinkManaPotion:

tooltip,,,2

return

 

2zxmeiu.jpg



JadeDragon
  • Members
  • 935 posts
  • Last active: Jun 07 2014 07:40 AM
  • Joined: 18 Jan 2013
You were missing a comma in the line that clears the tooltips
DrinkHealthPotion:
tooltip,,,,1
return

DrinkManaPotion:
tooltip,,,,2
return

Never assume evil intent when simple ignorance will suffice. Ignorance is an eventually curable condition with the right education. Evil intent, however, is another matter entirely. Scripts are much like children. Simple to conceive. Difficult, expensive, and time-consuming to raise. Often do the opposite of what you expect them to. Require frequent  "correction". And once they leave home you can't control them anymore. But you love them anyway.


adamkm
  • Members
  • 10 posts
  • Last active: Apr 10 2013 02:48 PM
  • Joined: 29 Jan 2013

Your right of course :) there was 2 mistakes in total.

 

Weird though, the tooltip 1 worked fine.

 

Ok now to remap half my keyboard because of the lack of in game UI modifications you can do and create a script to enable WASD to move my character.

 

Cheers for your help mate.



JadeDragon
  • Members
  • 935 posts
  • Last active: Jun 07 2014 07:40 AM
  • Joined: 18 Jan 2013
I do that a lot when I stay up past my bedtime on an all-nighter. I'm not proud of it but some of my script screw-up have been pretty "epic".

Tooltip one worked because the default for tooltips is tooltip one so even though the comma's were missing the system defaulted to turning off tooltip one

Never assume evil intent when simple ignorance will suffice. Ignorance is an eventually curable condition with the right education. Evil intent, however, is another matter entirely. Scripts are much like children. Simple to conceive. Difficult, expensive, and time-consuming to raise. Often do the opposite of what you expect them to. Require frequent  "correction". And once they leave home you can't control them anymore. But you love them anyway.


aasi888
  • Members
  • 52 posts
  • Last active: Jun 01 2016 08:05 PM
  • Joined: 21 Sep 2012

For my timer I decided to use a sound. This way you can keep your eyes on the game. I got this idea from Gladioatorlos SA  that is a wow addon that tells you what cooldowns opponent used.

 

 

You can use Soundplay or Soundbeep if you  want to use a sound instead of tooltip.



adamkm
  • Members
  • 10 posts
  • Last active: Apr 10 2013 02:48 PM
  • Joined: 29 Jan 2013

For my timer I decided to use a sound. This way you can keep your eyes on the game. I got this idea from Gladioatorlos SA  that is a wow addon that tells you what cooldowns opponent used.

 

 

You can use Soundplay or Soundbeep if you  want to use a sound instead of tooltip.

 

I generally play with no sounds on, that way i can play on the couch in the room and the other half doesn't really class it as a "computer night" because im there with her so its a win win situation :)



Albvar
  • Members
  • 5 posts
  • Last active: Feb 14 2013 11:36 PM
  • Joined: 08 Feb 2013

Couldn't you make it so that you press F1 and F1 becomes disabled for 7 seconds? Not sure if that's possible, just my two cents.



adamkm
  • Members
  • 10 posts
  • Last active: Apr 10 2013 02:48 PM
  • Joined: 29 Jan 2013

Couldn't you make it so that you press F1 and F1 becomes disabled for 7 seconds? Not sure if that's possible, just my two cents.

 

Possibly, but still you would not know if your currently drinking a potion or not in that event.

 

Also, flasks can have "restores 50% instantly" sometimes you might want to spam the button for that.



joekingcool
  • Members
  • 1 posts
  • Last active: Dec 05 2013 10:50 PM
  • Joined: 05 Dec 2013

Hi Adamkm,

 

I was looking at creating something to collect gold in forge of empires, would you be willing to post the script, would be greatly apreicated!