Respawn Array Enemies using real time countdown.

Get help using Construct 2

Post » Thu Sep 17, 2015 10:16 pm

i have an array with a lot of enemies, ordered by "NO_CLICKED", name, type, color, LEVEL (this level never change) and XP LEVEL. ->

Image

Right now this array is in JSON format and is spawing 5 objects at the same time using LEVEL and if the object is NO_CLICKED (0). ->

Image

If you click the enemy and destroy it then the enemy will respawn again because NO_CLICKED will have the value 0 and the enemy didn't level XP up or will level XP down, however if you destroy the enemy without clicking it then the enemy will level XP up. ->

Image

What i want? well i want that my enemies respawn by time and time will be determinated by level XP, something like this: ->

Image

Here i tried to use the plugin rex revive behavior but it didn't work because i need to save my values in the array and i don't need to revive the sprite specifically because the values are in the array, how i can do this with my array? i need to use real time and some enemies need to respawn maybe in 48 hours, for example... the player will save the game progress then if the player open the game after 48 hours then the enemy will appear of course i want to use waves, for example 5 enemies appear at the time otherwise you will have +30 enemies on screen and this is not the idea, each enemy will have his own time countdown, for example you destroy an enemy and the enemy level UP to 5 then this enemy will respawn in 72 hours.

i need the help of this comunity please because i am very sure that i cant do this myself because i spend a lot of time reading tutorials etc and i am not programmer :( ... any advice, tutorial, guide or whatever help will be appreciated, thanks!

MY CAPX ->

http://www.filedropper.com/arrayspawnbylevelandxp
Last edited by Majinboo on Fri Sep 18, 2015 12:36 am, edited 1 time in total.
B
9
S
3
Posts: 142
Reputation: 1,108

Post » Thu Sep 17, 2015 11:15 pm

If you are respawning enemies 48 hrs later, you will need to use WebStorage if you want data to be carried over in between players' closing their browsers. Keep in mind though that WebStorage is inherently tamperable, so people will be able to easily hack your game.
https://www.ravenheart.ca/home
Company name changed to avoid Facebook-type shenanigans

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,414
Reputation: 4,822

Post » Thu Sep 17, 2015 11:36 pm

gumshoe2029 wrote:If you are respawning enemies 48 hrs later, you will need to use WebStorage if you want data to be carried over in between players' closing their browsers. Keep in mind though that WebStorage is inherently tamperable, so people will be able to easily hack your game.


I want to save local and backup it in a hosting because if the player lost his mobile phone or uninstall by mistake the game then he can lost his progress, i want too the players can carry his progress between different versions (mobile/PC), anyways i don't will launch the game for browsers just only for windows 10 store and mobile devices, to think about all this i need first solve the problem of how to respawn enemies 48 hours or later by XP level, however if i cant use arrays using LocalStorage or WebStorage then this will be a concern right now.
B
9
S
3
Posts: 142
Reputation: 1,108

Post » Fri Sep 18, 2015 12:46 am

If you want multi-platform support, you will have to use a server.
https://www.ravenheart.ca/home
Company name changed to avoid Facebook-type shenanigans

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,414
Reputation: 4,822

Post » Fri Sep 18, 2015 1:05 am

Use Local Storage instead. To respawn enemies 48 hours later you can use "rex_time_awayL" plugin which saves the time you are away (game is closed) and you can easily compare how much time have passed between game sessions.

and like @gumshoe2029 said. to save data externally you will need some kind of a server (or service) that can do keep the record of your players and their score, settings etc.
ImageImageImageImage
B
157
S
65
G
41
Posts: 2,594
Reputation: 34,748

Post » Fri Sep 18, 2015 1:25 am

shinkan wrote:Use Local Storage instead. To respawn enemies 48 hours later you can use "rex_time_awayL" plugin which saves the time you are away (game is closed) and you can easily compare how much time have passed between game sessions.

and like @gumshoe2029 said. to save data externally you will need some kind of a server (or service) that can do keep the record of your players and their score, settings etc.


rex_time_awayL will help me but in need to understand how to do this.

The system will look like this----->

Destroy enemy (without clicked) -> +1 level XP UP

Destroy enemy (clicked) -> - 1 Level XP Down

On destroyed = Level XP 1 -> Respawn in 1 hour

On destroyed = Level XP 2 -> Respawn in 2 hour

On destroyed = Level XP 10 -> Respawn in 90 hours

I need each enemy have a countdown, i dont know how to do this or if i need to save the time in the array, when the player close the game then obviously the countdown stop but when open the game again then i need with the rex_time_awayL subtract to the countdown the time away from the game, i don't care cheating etc.. i just want to make this easy because i cant advance in my game without this, when the countdown ends then i will add 1 in the array to the enemy so the with a loop i can spawn new enemies with value 1 in the array, like a queue list.


1. When save the game -> save in the array the time left of the countdown of each enemy, maybe i don't need save this in the array? just subtract the away time to the current countdown.

2. On load complete -> subtract Time Away to all countdown time values in the array, then -> find in the array 0< time values, then -> add string "ready" in the array to all enemies with 0< values (this to make a queue list) then -> loop = spawn enemies of the array that contain the string "ready".

Or more easy, i don't know if this can be done, just save the game, all countdowns are paused, when you open the game again the countdowns are unpaused but subtract the away time to all countdowns, the question is how i can use a countdown for each destroyed enemy? because each enemy will be destroyed and if i have a lot of enemies (more of 100) a lot of countdowns will lag the game?
B
9
S
3
Posts: 142
Reputation: 1,108

Post » Fri Sep 18, 2015 9:38 am

"Or more easy, i don't know if this can be done, just save the game, all countdowns are paused, when you open the game again the countdowns are unpaused but subtract the away time to all countdowns"

That is the way to go. rex_time_awayL don't care about object, array or any other stuff it simply saves the key (you set the name) and value (time)

1. You don't array but you can use if your enemies have some stuff to save (like position, variables, states etc or even respawn time) then Array will help organizing it

2. If you set proper naming convention for Time Away then yeah. It's a matter of simple for each loop

Countdowns don't need to run every tick. You can update them ever 1 second, and don't worry about the lag. I have a mobile game where I have very similar setup
and on my old Samsung Galaxy S3 it checks an array with 900 items every one second and it's perfectly fine.

But just in case I've modify my system a bit. At start array is empty (size 0,4,1) every time enemy is destroyed I'm adding a new index to the array, and when enemy is respawn I'm removing it, It reduced the countdown checks from 900 to max 20-30 a second :)
ImageImageImageImage
B
157
S
65
G
41
Posts: 2,594
Reputation: 34,748

Post » Fri Sep 18, 2015 7:52 pm

shinkan wrote:"Or more easy, i don't know if this can be done, just save the game, all countdowns are paused, when you open the game again the countdowns are unpaused but subtract the away time to all countdowns"

That is the way to go. rex_time_awayL don't care about object, array or any other stuff it simply saves the key (you set the name) and value (time)

1. You don't array but you can use if your enemies have some stuff to save (like position, variables, states etc or even respawn time) then Array will help organizing it

2. If you set proper naming convention for Time Away then yeah. It's a matter of simple for each loop

Countdowns don't need to run every tick. You can update them ever 1 second, and don't worry about the lag. I have a mobile game where I have very similar setup
and on my old Samsung Galaxy S3 it checks an array with 900 items every one second and it's perfectly fine.

But just in case I've modify my system a bit. At start array is empty (size 0,4,1) every time enemy is destroyed I'm adding a new index to the array, and when enemy is respawn I'm removing it, It reduced the countdown checks from 900 to max 20-30 a second :)


how can i countdown objects inside in the array? i am reading about rex time plugins but i cant realize how to do this , i want some enemies even respawn after 2 or 3 months then use every second maybe isn't worth because countdown 3 months takes a lot of time and i need hundred of countdowns.

I am thinking in this:

On destroyed level XP 9 enemy -> save in array 3 months to countdown (how can i countdown a object inside the array?, using a rex plugin?)

i have all my enemies values (level XP, Type, leve, name, etc..) in the json array, after destroyed the sprite didn't exist anymore so how can i countdown? can i countdown the values inside the array? i cant realize how to do this, i am thinking in global variable but you cant save the values of a global variable with localstorage?

Image
B
9
S
3
Posts: 142
Reputation: 1,108

Post » Fri Sep 18, 2015 9:13 pm

To count down values in array every 1 second you simply do

+Every 1 second
+Array: For each X element
+Array: Value at (Array.CurX, Y) > 0 -> Array: Set value at (Array.CurX, Y)-1
ImageImageImageImage
B
157
S
65
G
41
Posts: 2,594
Reputation: 34,748

Post » Fri Sep 18, 2015 9:19 pm

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.
ImageImageImageImage
B
157
S
65
G
41
Posts: 2,594
Reputation: 34,748

Next

Return to How do I....?

Who is online

Users browsing this forum: DarknessGamingDK, webebiz and 4 guests