Fangames > Programming Questions

What's the fastest way to remove the kid object and stuff related from a room...

(1/1)

l3agu32:
I wanna make this using the yoyoyo engine in game maker studio. I actually succesfully did this, but I have to change all scripts and objects related to the kid considering each room, so I'm curious if advanced game maker users know a faster way.I think some fangames already made something like this (for instance, pokemon area in "I wanna run the marathon"). In only some rooms, I want the normal kid object not to exist, eliminate all sounds related to the kid like shooting and jump and not let the player use "Q" to suicide. Thank you!

patrickgh3:
How I would do something like this is find all the behaviors I want to disable, and wrap each of them in a conditional (if statement) that checks a script to see if the effect is currently active.

So for example, in the pokemon area in run the marathon, I had a script called roomIsPokemon which looked something like this:

--- Code: ---return argument0 == rPokemonOverworld
or argument0 == rPokemonGym
or argument0 == rPokemonHouse
or argument0 == rPokemonHouse2
or argument0 == rPokemonCenter

--- End code ---

And then to disable pressing R, I found where that logic was and did an additional check with that script:


--- Code: ---if (scrButtonCheckPressed(global.restartButton)
and !roomIsPokemon(room)) // added this check
{
    /* ...
       restart game
       ...
    */
}

--- End code ---

I also called that script in many other places. And you can imagine changing that script to just check a global variable instead of a room, or whatever other logic.

l3agu32:
Patrick, just so I can understand better, how did you eliminate the normal kid in case that different kid wasn't the normal kid object?

patrickgh3:
To remove the normal player when entering the room, I would first destroy the player object since it's persistent. And also be sure there's no player start object in that room, obviously. So,


--- Code: ---example warp object or something:

if place_meeting(x, y, objPlayer) {
    with objPlayer instance_destroy()
    room_goto(rPokemonHome)
}

--- End code ---

I guess another thing is how to deal with saving and loading with an alternate player. In my save and load scripts, I added a check for the effect (the roomIsPokemon script above). If it returns false, then proceed as normal. If it returns true, then save and load the alternate player's position. For example:


--- Code: ---in scrSaveGame:

if roomIsPokemon(room) {
    global.savePlayerX = objPokemonPlayer.x
    global.savePlayerY = objPokemonPlayer.y
}
else {
    // normal kid
    global.savePlayerX = objPlayer.x
    global.savePlayerY = objPlayer.y
}

--- End code ---

--- Code: ---in scrLoadGame:

if roomIsPokemon(global.saveRoom) {
    instance_create(global.savePlayerX, global.savePlayerY, objPokemonPlayer)
}
else {
    // normal kid
    instance_create(global.savePlayerX,global.savePlayerY,objPlayer)
}

--- End code ---

And you can imagine having multiple else-ifs if you have multiple alternate players, like run the marathon does. Hope that helps.

Navigation

[0] Message Index

Go to full version