Wait action for auto attacking

Get help using Construct 2

Post » Wed May 11, 2016 10:44 pm

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:

Image

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.
In development: Avalon Isle
B
12
S
4
G
1
Posts: 44
Reputation: 1,496

Post » Wed May 11, 2016 10:59 pm

Its wait, then do.
Not, do, then wait.
Image ImageImage
B
170
S
50
G
179
Posts: 8,378
Reputation: 113,425

Post » Wed May 11, 2016 11:51 pm

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.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Thu May 12, 2016 12:00 am

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


That's actually what happened using:

Image

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
In development: Avalon Isle
B
12
S
4
G
1
Posts: 44
Reputation: 1,496

Post » Thu May 12, 2016 12:28 pm

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.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Thu May 12, 2016 10:17 pm

99Instances2Go wrote: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.
In development: Avalon Isle
B
12
S
4
G
1
Posts: 44
Reputation: 1,496

Post » Fri May 13, 2016 10:51 am

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.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Fri May 13, 2016 11:35 am

99Instances2Go wrote: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.
In development: Avalon Isle
B
12
S
4
G
1
Posts: 44
Reputation: 1,496


Return to How do I....?

Who is online

Users browsing this forum: 25games, brunopalermo and 11 guests