• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Windows How to best handle instanced combat?

T

TheBlindG

Guest
Hello everyone!

I am currently working on a project where I want to have instanced ocmbat when I i.e. make ocntact with an enemy obj, when combat is over, return to my old room, position and delete the instance of the enemy that I defeated. Any thought on how to do this?

I tried using: room_goto(room_last); but all objects and stuff were gone in the "last" room then.

Thanks in advance
 

Yal

🐧 *penguin noises*
GMC Elder
The simplest way to do this - not necessarily the BEST - is to delete the enemy before you change room, then make the room persistent (see room_persistent) before you leave it. When you're back in the room, turn it un-persistent again (use a Room Start event for that, they're triggered every time you enter a room, even if it's persistent... so it's not exactly room start per se).

Note that changing rooms won't happen until the current event (ie, the piece of code that makes you change room) is completed, so you can't do any "return to room" thing in the same script/code you use to change rooms, you need to have a different event for that.
 
T

TheBlindG

Guest
If I use this method, will all monsters respawn when I re-enter the room or will they stay gone? Cus I want respawning mobs also :)
 
B

bojack29

Guest
Simply save the coordinates off the enemy prefight and when you come back delete whatever is at his position. Make all enemy objects persistent, save his position, deactivate all instances, fight, come back, reactive instances, destroy his position
 
A

Aura

Guest
If I use this method, will all monsters respawn when I re-enter the room or will they stay gone? Cus I want respawning mobs also
Yal told about a method that would destroy the enemy instance then make the room persistent, so if you return to the room again, the room would be the same as you left, that is, that particular enemy instance won't exist anymore.

If you want random enemy encounters, I'd suggest spawning new instances instead of relying on the old ones. If you want a new enemy to be respawned in the same position, you'd want it to turn it into an inactive instance which is reactivated after some time. Either by using GM:S's deactivation functions or by using a variable. For instance, instead of destroying the enemy instance, you'd set a variable to true which would force it to act as if doesn't exist, that is, neglecting all the events. After certain time, you can reactivate it or create a new instance in its place (in case you want the attributes like health to be reset -- you can also force the Create event to run for that). ^^'
 

Yal

🐧 *penguin noises*
GMC Elder
If I use this method, will all monsters respawn when I re-enter the room or will they stay gone? Cus I want respawning mobs also :)
As soon as you leave the room while it's not persistent. AKA enemies don't respawn after a battle, but if you go to another map and then back, enemies return. This is normally how you want since mobs that respawn after every battle makes exploration more or less impossible.
 
T

TheBlindG

Guest
I deactivate an enemy when I beat it in battle, and I have the rooms presistant. But I cannot get the instances to activate again with likle instance_activate_all in room end or room start events.
 
A

Aura

Guest
If you are talking about the deactivating the enemy instance that you fight in the combat room, aren't you supposed to do that with the enemy instance in the main room? That's just a guess though due to the lack of information.

But as Yal said, you don't need to keep the room persistent at all times. It is simply for returning you to the state that you left it in while moving to the combat room. Either way, if that kind of respawning is what you want then you can simply move to the next room and you'd find the enemies respawned, as long as you had turned off the persistence after each battle, when you'd return. That's how it works IMO.
 
T

TheBlindG

Guest
I got it to work, I deactivate the enemy which I beat (in the room where i can encounter enemies) and have the room persistent. When I use the "door" to go to another room, I activate all objects, so when I go back to the room, the deactivated objects will be activated again! :) This way I can delete bosses, which will not respawn, and have like chests and stuff be open after I open them for the first time.
 
Top