Help with RPG rooms

This forum is currently in read-only mode.
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • Here is what I want to do:

    1- The player breaks some "Bricks" in a room.

    2- The player leaves the room/layout.

    3- The player returns to the room/layout.

    4- The rooms does not re-create the bricks the player destroyed, but remains as the player left it.

    I tried doing this by creating a brick spawner that only creates one brick when it's private variable 'destroyed' equals 0.

    So when I destroy a Brick, the brick get's destroyed but the brick spawner stays there, and I change it's private variable 'destroyed' to 1.

    When I leave the room, I save each brick spawner UID as keys, and the value of their 'destroyed' variable as their corresponding value.

    When I re-enter the room, I load the hash table, I compare the keys to find the corresponding instance with their matching UID (with the "brick spawner Pick by UID equals to Hashtable.CurrentKey" sub-event, inside a "(HashTable) For each key" event), then put the HashTable.CurrentValue in its 'destroyed' variable.

    Makes sense?. This doesn't seem to work.

    I checked the debugger and it seems that each time I leave the room and go back to it, the bricks get a brand new/different UID, so how can I keep track of each individual brick and it's state?. Am I missing a feature that would make all this much easier?. Thanks in advance.

  • Ok, since half the users say save/load is bugged, and the other half say it's fine to use except with certain third party plugins that are bugged. Why not a compromise?

    Setup an event that saves a version of the undamaged level, in this case where none of the bricks have been destroyed, using the save to ONLY save the undamaged bricks (and other things you want to persist like that, depends on what else you have in mind but we'll stick with just bricks for this example). Then when the player starts the game, upon entering that level, he/she automatically loads that saved file. Because it's only loading certain things and not expected to load everything, then badly behaved plugins shouldn't have an issue with it.

    When the player leaves the level as per your example. Those bricks are once again saved in their new state, to the same file. So when the player returns, bingo, the level is how they left it, and previously destroyed bricks, remain destroyed.

    Then use a value inside an ini file or registry key (you'll need an installer such as Inno or Nullsoft to create the registry key, but then construct can edit it afterwards) to tell it if it's supposed to be a new game or not, or alternatively, a profile type setup. In which case a new undamaged version of a save file is saved prior to the player getting their grubby hands on the level (like during a "loading level 1" message, so they don't notice it's saving/loading anything). Then in the case of a new game, all the bricks will be untouched, ready to be destroyed again.

    That make sense?

  • yep, you can't guarantee that UIDs will ever be the same when an object is recreated. If fact, that would be very surprising.

    Setup an event that saves a version of the undamaged level, in this case where none of the bricks have been destroyed, using the save to ONLY save the undamaged bricks (and other things you want to persist like that, depends on what else you have in mind but we'll stick with just bricks for this example).

    This is a good idea.

    I did something something less sophisticated in my games. I save the x and y location along with the room name in a global array and then when I returned to rooms I redestroyed all of those objects that matched. p.s. Part4 of the adventure tutorial specifically addresses these issues of changing layouts so it might help you to take a look.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for the replies. I got the saving thing working, for now, maybe I'll come back asking more questions when I get in trouble again.

    Thanks

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