Question about rooms and objects in AGS

Started by xelanoimis, Tue 22/07/2008 09:22:05

Previous topic - Next topic

xelanoimis

Hello,

I'd like to ask a few questions about how AGS handles the game's rooms, objects, and their logic status.

1. Is there only one room accessible in script at a time?
I mean, that you can't access objects from rooms other than the current one.
I saw a trick in the forums, that you can use a global variable to hide an object from another room, but you have to test that variable when the room is entered, and change the object visibility then.

2. Does the status of a room gets preserved by the engine, so the next time you enter it, you find it's objects as you left them last time? So if you hide an object, or change it's view, leave the room and then come back, the object is still hidden? I saw a Reset function in the docs, and it saids it can be used to reset room's objects to their initial state.

3. What about room scripts? Are they loaded when the game starts, and the variables, declared at the beginning of the room script, are preserved during the game?

4. What does the engine loads when a room is changed, and what does it unload when the room is exit from?
Since it has to keep some info about that room (like objects status), does it load only the graphic sprites from that room? Does the engine use to cache them for faster room loading? What happens if you have a game with lots of rooms with lot of graphic content. Will the game have a very long loading time at the beginning, or will it have long loading times when room changes?

5. If ChangeRoom function changes the room after the script returns, how can you implement cutscenes where you get to see what happens in another rooms, then back to the current one for more talking? Do you have to use a global variable to tell the room it's in a cutscene mode, so when it loads to do some specific stuff and then change back to the previous room, where the player was supposed to be?

Well that's it for now. Please drop a few YES or NO to the questions if you know how this stuff works, and if you want to give more details, it would be appreciated.

Thanks!

Gilbert

#1
1. Correct, because when you are in a room, the information for the other rooms may not be in memory.

2. Yes, correct also. But note that as the status of rooms that the player has entered will be saved in memory (and thus also the saved games), to prevent consuming too much space, the engine only saves the status up to room #299. If you create a room with number >= 300 its stauts will not be saved, so these rooms will be reset next time you enter them. This is particularly useful if you don't need to save the status of some of the rooms (say, like those used in cutscenes) or for some reasons you need them to be reset everytime the player enters them. The Reset function is for cases that you either really need a room's status to be reset in some stage of the game, or you know that a room won't be used anymore in the rest of the game, so to reset it to free some memory (I think this is rarely needed).

3. Room scripts are loaded when a room is loaded (hence not game_start), they're considered unloaded when there is a room change, but (see point 2) their status such as variables, object placements would be saved in memory.

4. Sprites aren't room specific, so they're generally loaded when needed. You can set the amount of sprite cache in the advanced settings of an AGS game's setup, which may affect the performance of it, depending on the computers' specs. In general, a room file contains background and its own script, this is what the engine loads or unloads when the player enters or leaves the room. Only the status like variables, etc. are saved in memory when the player changes room.

5. There're numereous way to do it, as your post reflects that you have already invested on the engine in some details and have adequate amount of knowledge about script I'll explain it simple. One way is to set a global variable in the cutsene, so when you return to the original room, you check the value of this variable (in "player enters room", prossibly) and if it reflects that it just returns from the cutscene, execute the codes about the talking.

SSH

Also, look at the OtherRoom module, which hides the complexities of turning on/off stuff in other rooms inside a nicer interface.
12


SMF spam blocked by CleanTalk