Author Topic: What's the fastest way to remove the kid object and stuff related from a room...  (Read 1334 times)

l3agu32

  • Wannabe
  • Posts: 22
  • OS:
  • Windows 10 Windows 10
  • Browser:
  • Chrome 51.0.2704.103 Chrome 51.0.2704.103
    • View Profile
  • Playstyle: Keyboard
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

  • Spike Dodger
  • Posts: 169
  • stay optimistic! :D
  • OS:
  • Windows 10 Windows 10
  • Browser:
  • Chrome 51.0.2704.103 Chrome 51.0.2704.103
    • View Profile
    • Github
  • Playstyle: Keyboard
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: [Select]
return argument0 == rPokemonOverworld
or argument0 == rPokemonGym
or argument0 == rPokemonHouse
or argument0 == rPokemonHouse2
or argument0 == rPokemonCenter

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

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

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

  • Wannabe
  • Posts: 22
  • OS:
  • Windows 10 Windows 10
  • Browser:
  • Chrome 51.0.2704.103 Chrome 51.0.2704.103
    • View Profile
  • Playstyle: Keyboard
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

  • Spike Dodger
  • Posts: 169
  • stay optimistic! :D
  • OS:
  • Windows 10 Windows 10
  • Browser:
  • Chrome 51.0.2704.103 Chrome 51.0.2704.103
    • View Profile
    • Github
  • Playstyle: Keyboard
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: [Select]
example warp object or something:

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

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: [Select]
in scrSaveGame:

if roomIsPokemon(room) {
    global.savePlayerX = objPokemonPlayer.x
    global.savePlayerY = objPokemonPlayer.y
}
else {
    // normal kid
    global.savePlayerX = objPlayer.x
    global.savePlayerY = objPlayer.y
}
Code: [Select]
in scrLoadGame:

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

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