0 Favourites

Wait action for auto attacking

  • Hi all,

    Having a Wait action in a Function called by another Function is not going to provide a delay is it? I've been trying to add a delay in a Function calling with it to simulate auto attack speed, but I think i've come to the realisation it's not used for what I thought it would be.

    I thought this:

    Would dump out to the textbox (aCharH.At(13) is 2, which is the character attack speed in seconds):

    You hit x for x damage.

    Wait for 2 seconds

    You hit x for x damage.

    Wait for 2 seconds

    etc until tempMob.At(0) =<0, then it stops.

    What it does do instead, is instantly gut the spawned mob for all it's health and dumps every line to the textbox instantly:

    You hit x for x damage.

    You hit x for x damage.

    You hit x for x damage.

    You hit x for x damage.

    with 0 delay until death

    I don't think i'm using the wrong loop. I've read the manual on the others but they don't seem to fit what i'm after. I tried repeat also but again, it just instakilled the poor bastard. I've searched all posts referencing auto attacking and looked through them all. 1 might have helped but it's a good few years old and the capx for reference is not available. I also went through 38 pages of tutorials, and whilst finding a few awesome bits and bobs, nothing referencing my current plight! Even went out for a walk to clear my head but just ended up getting soaked from the rain!

    Any idea on what I could use in it's place?

    Thanks.

  • Its wait, then do.

    Not, do, then wait.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • That aint gonna work anyway if the function gets called multiple times in a short time. What will happen is this ....

    Lets assume the wait is 1 sec, and the function gets called each tick.

    at zero time :Call 1 ... thing waits 1 second

    one tick later : Call 2 .. thing waits one tick + 1 second

    one tick later : call 3 .. thing waits two ticks + 1 second.

    Or, it will wait 1 second, and then fire them all with a wait of 1 thiCK.

    Much easyer to use a timer.

  • Or, it will wait 1 second, and then fire them all with a wait of 1 thiCK.

    That's actually what happened using:

    Or well, I hit AutoAtkTest, it posted "hit x for x" in the textbox, waited 2 seconds, then gutted the rest of the HP instantly.

    I'll redo this section then when i've looked in to timers. Hadn't thought i'd need it for this in particular before. Thanks for the suggestion!

    Cheers

  • You can do it with a 'wait' action. (I would never).

    Make a local variable 'TimeToFight'.

    Add aCharH to 'TimeToFight'.

    Wait 'TimeToFight' seconds.

    I did't test this, but it works in my head.

  • You can do it with a 'wait' action. (I would never).

    Make a local variable 'TimeToFight'.

    Add aCharH to 'TimeToFight'.

    Wait 'TimeToFight' seconds.

    I did't test this, but it works in my head.

    Works in my head as well in practice, but not in testing! Plus if you would never use it, i'd rather not try any further if it's bad practice. I'm just about to start on the timer to see what I can get working.

    Cheers.

  • This is not meant to solve you problem. Mainly because i dont understand the full problem based on a little snapshot of your code.

    This is purely meant as a small-little-teeny-weeny showcase to promote the use of timers. To show how easy they are to manage, they never miss, they are a personal clock for each instance. They are allready a 'once while true', so animations are so easy to start. They are basecaly just functions that you call when ever you need to. They are easaly set up to call/stop each other, therefor easy to make a full and automatic running circle.

    https://

    drive.google.com/open?id=0B1SSuCVV8v74WmpvMEhXdTJNN2s

    Hope this helps you some.

  • This is not meant to solve you problem. Mainly because i dont understand the full problem based on a little snapshot of your code.

    This is purely meant as a small-little-teeny-weeny showcase to promote the use of timers. To show how easy they are to manage, they never miss, they are a personal clock for each instance. They are allready a 'once while true', so animations are so easy to start. They are basecaly just functions that you call when ever you need to. They are easaly set up to call/stop each other, therefor easy to make a full and automatic running circle.

    https://

    drive.google.com/open?id=0B1SSuCVV8v74WmpvMEhXdTJNN2s

    Hope this helps you some.

    I get that, I just never thought of the use of timers before to be used in this way, probably as i'd not had much exposure to it. It does seem to do what I want though.

    Thanks for the example too, cool little capx

    Cheers for your advice.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)