Respawn Array Enemies using real time countdown.

Get help using Construct 2

Post » Fri Sep 18, 2015 9:56 pm

shinkan wrote:I don't want to sound like a dick but I'm not entirely sure you know what you are doing.
I'm trying to understand everything you wrote and show in images and honestly I think you trying to overcomplicate this by a lot.

Do you really need to countdown hundreds of objects?? What is the purpose in that? I'm just trying to understand your logic so I can help you better.


I am trying to do this:

Image

its very simple, you kill an enemy then the enemy will level UP +1 , you cheating clicking the enemy with the mouse then the enemy will Level Down -1 and will respawn again so you can have another chance to kill it but without level up because you fail the first time, each enemy have a level and each level means that the enemy will respawn in a future, i need countdown to all my enemies by level (hundred of enemies even maybe thousands of different enemies).

Obviously this is a template, for example you can use a specific combination of magic to kill an enemy, if you use the wrong magic combination then you can kill the enemy but the enemy didn't level up instead this enemy will level down and the countdown will be short of course because low level enemies will have low countdown times, yes i need to countdown thousand of enemies because i have a big list of enemies with names, type, etc... maybe you cant see the purpose of this but i want to make something different, step by step, i cant think in the next stage of my game without solve this, i need at least 8,000 countdowns and maybe countdowns even of 6 months.
B
9
S
3
Posts: 142
Reputation: 1,108

Post » Fri Sep 18, 2015 10:12 pm

Ok, got it. From what I see I think you should approach this from other side.
Don't add enemies to the Array when they are spawned, but rather add them when they are destroyed. In short it means that you don't need to count down for 100 spawned enemies but for 100 killed enemies. If enemy is still alive we don't really need any values in the array for it.

It's just part of the code and I can't see rest of it, but also You don't need countdown global variable here, just type in values (30,60,90...) right to the array.

also to make it easier for you, so you don't need to make events for every LevelXP to set array. if you take that each next level is always 30 more than previous one you could do just one event to control all enemies LevelXP

for example

enemies: On destroyed - > Array: Set value at (enemies.loopindex, 6 ) to enemies.LevelXP*30 - or any other math expression to describe your leveling system.


Tell me what is happening on the screen in the game. Are there only a few enemies that you kills and then they are recycled, or enemies spawn every X second, so you can end up with for example 100 of them on the screen at once?


EDIT: Ok it's not nice to edit the post while someone is writing a replay ;) let me reread what you have edited to see if what I wrote still make sense.
ImageImageImageImage
B
157
S
66
G
41
Posts: 2,599
Reputation: 34,825

Post » Fri Sep 18, 2015 10:19 pm

shinkan wrote:Ok, got it. From what I see I think you should approach this from other side.
Don't add enemies to the Array when they are spawned, but rather add them when they are destroyed. In short it means that you don't need to ....


level up will be simple, destroy 1 enemy without clicking then enemy +1

Check your PM's
Last edited by Majinboo on Sat Sep 19, 2015 4:38 am, edited 2 times in total.
B
9
S
3
Posts: 142
Reputation: 1,108

Post » Fri Sep 18, 2015 10:42 pm

shinkan wrote:Ok, got it. From what I see I think you should approach this from other side.
Don't add enemies to the Array when they are spawned, but rather add them when they are destroyed. In short it means that you don't need to ....


5 Unseen enemies spawn each time , after you destroy these 5 enemies without clicking then they level up +1 so the countdown start, after the 5 unseen enemies are destroyed then the old enemies spawn 5 each time too of course when the countdown ends, so i will have a queue list of time out enemies, after you don't have old enemies to spawn then more unseen enemies will spawn 5 each time.
Last edited by Majinboo on Fri Sep 18, 2015 11:16 pm, edited 1 time in total.
B
9
S
3
Posts: 142
Reputation: 1,108

Post » Fri Sep 18, 2015 11:03 pm

shinkan wrote:Ok, got it. From what I see I think you should approach this from other side.
Don't add enemies to the Array when they are spawned, but rather add them when they are destroyed. In short it means that you don't need to ....


I need the values of the array because of what i explain you in the PM, level time countdown in the capx was an example, i will set countdowns even of 6 months, 43 hours etc..
B
9
S
3
Posts: 142
Reputation: 1,108

Post » Sat Sep 19, 2015 4:38 am

Finally i make this work, please give me a hand to subtract the time away to the countdowns,

http://www.filedropper.com/countdownandspawnarray

I used localstorage to save the countdowns, the capx makes exactly what i want.

Now i just need to fix a 3 issues:

1. When i refresh the browser new objects disappears because the value 2 is saved in the array before i destroy the enemies. (i tried to fix this but i cant find the logic to do it)

2. Respawn each enemy with interval of time between each spawn to looks more natural (right now sometimes spawn 4 or 5 enemies all at the same time) , and spawn in order, like a queue list.

3. Subtract the away time to all countdowns, i used the rex_time_awayL then right now i can see the away time in a text object to debug but i need to subtract it to all countdowns when you reopen the game, i tried on start of layout:

Image

UPDATE: now didn't work, i don't understand why :(

Maybe i am doing unnecessary things with this loops but if you see with the debugger visor and you see what the capx makes then you will understand perfectly what i want to do, thank you so much for your help!!! i cant believe that i progressed so much xD
B
9
S
3
Posts: 142
Reputation: 1,108

Post » Sat Sep 19, 2015 11:04 pm

Hey, sorry man was away all day. Had a brief look at your capx and try this.

When all enemies are destroyed (all 5 of them) maybe then make a loop to subtract countdown time for all saved enemies in the array. And when that loop is done spawn new wave of enemies. Loop through huge array will take some time, but if nothing currently will happen on the screen it should be fine.

As of the subtracting TimeAway from countdowns. You don't need to check them all the time in game. There is no need for that. What you want to do is a quick check only at the Start of layout.

In short something like that.

+On start of layout
++For Each value > 0 - > set value to value - time away.

This works as a "game initialization" you only need to run in once, when player starts the game.
ImageImageImageImage
B
157
S
66
G
41
Posts: 2,599
Reputation: 34,825

Post » Sat Sep 19, 2015 11:21 pm

shinkan wrote:Hey, sorry man was away all day. Had a brief look at your capx and try this.

When all enemies are destroyed (all 5 of them) maybe then make a loop to subtract countdown time for all saved enemies in the array. And when that loop is done spawn new wave of enemies. Loop through huge array will take some time, but if nothing currently will happen on the screen it should be fine.

As of the subtracting TimeAway from countdowns. You don't need to check them all the time in game. There is no need for that. What you want to do is a quick check only at the Start of layout.

In short something like that.

+On start of layout
++For Each value > 0 - > set value to value - time away.

This works as a "game initialization" you only need to run in once, when player starts the game.


i optimized a lot the events, right now my main issue is subtract the away time, i tried on start of layout but didn't work, i tried a lot of things but for some reason this didn't work.

Image

http://www.filedropper.com/v2_3
B
9
S
3
Posts: 142
Reputation: 1,108

Post » Sat Sep 19, 2015 11:54 pm

In even 3 where you have System: Set elapsedTime to TimeAwayL.ElapsedTime you need to put a (tag) at the end so it should look like

System: Set elapsedTime to TimeAwayL.ElapsedTime("t") in your case
ImageImageImageImage
B
157
S
66
G
41
Posts: 2,599
Reputation: 34,825

Post » Sun Sep 20, 2015 12:06 am

shinkan wrote:In even 3 where you have System: Set elapsedTime to TimeAwayL.ElapsedTime you need to put a (tag) at the end so it should look like

System: Set elapsedTime to TimeAwayL.ElapsedTime("t") in your case


Didn't worked :(, i don't why this don't subtract the elapsed time to all array countdowns.
B
9
S
3
Posts: 142
Reputation: 1,108

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: Lancifer, MPPlantOfficial, Sup with that? and 60 guests