Respawn Array Enemies using real time countdown.

0 favourites
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • i have an array with a lot of enemies, ordered by "NO_CLICKED", name, type, color, LEVEL (this level never change) and XP LEVEL. ->

    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). ->

    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. ->

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

    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 <img src="{SMILIES_PATH}/icon_e_sad.gif" alt=":(" title="Sad"> ... any advice, tutorial, guide or whatever help will be appreciated, thanks!

    MY CAPX ->

    http://www.filedropper.com/arrayspawnbylevelandxp

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • If you want multi-platform support, you will have to use a server.

  • 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.

  • 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?

  • "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

  • "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?

  • 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

  • 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 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:

    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.

  • 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.

  • 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

  • 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.

  • 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..

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