Legacy GM Question about "waiting frames"

M

Mantra

Guest
Hello, I'm a new user of Game Maker but I've already being developing games in the RPG Maker engine for about 10 years, my question is about a feature I found in the RPG Maker programs that allows the user to wait a number of frames before the event keeps going, I'm wandering how I could use the GM scripts to do a similiar effect, for example:

Player talks with a NPC:

"Hello, I'm a mad robot who hates robots, let me scan you"
-> Wait 10 frames
"Yeah, you are a real person, you may pass"
*In this example, I made the player wait 10 frames between the dialogues to add 'drama' to the scene, just for aesthetics purpose

Or maybe during a Action Battle System:

> Player conjures a FireBall and changes his sprite to attack mode
wait 15 frames
> Player returns his sprite to standard form
*In this example, the player changed his sprite for a while so the player could see what was happening"
 
Last edited by a moderator:
M

Mantra

Guest
Hey, thanks for the quick reply and help :)

I checked this alarm feature but I'm not sure if it is precisely what I want, 12 alarms sounds not enough, in rpg maker I used to make about 30-40 'waits' during a single big scene of the game, it was a pretty normal thing to do, just like a box dialogue.

Is there a way to use alarms via codes and scripts? I just want to stop the current code to "keep going" for a fraction of seconds, and then it continues where it paused, but never changes, no Ifs, conditions, whiles, loops, it just freezes and keep going where it stopped

But the only thing that stops is the current 'event', for example, if the robot that talks to the npc pauses his dialogue, only him is paused, there may still be birds flying around, they won't be stopped
 
T

Treecase86

Guest
Hey, thanks for the quick reply and help :)

I checked this alarm feature but I'm not sure if it is precisely what I want, 12 alarms sounds not enough, in rpg maker I used to make about 30-40 'waits' during a single big scene of the game, it was a pretty normal thing to do, just like a box dialogue.

Is there a way to use alarms via codes and scripts? I just want to stop de current code to 'keep going' for a fraction of seconds, and then it keep going, but never changes, no Ifs, conditions, whiles, loops, it just freezes and keep going where it stopped
No problem, You may be able to use the same alarm multiple times, but I'll have to double-check.
 

K3fka

Member
You can use the same alarm multiple times, but you'll need some other variable to tell which message to use.
 

acidemic

Member
You can use a variable which sets the current state of an object and use just one alarm for different purposes using state variables.
Code:
// Step Event
if (npc_state == "active")
{
    // perform some code for NPC
}
else if (npc_state == "waiting")
{
     // perform some code or do nothing
}
else if (npc_state == "anything-you-can-think-of")
{
     // perform some code
}
So you can set npc_state variable to "waiting" or anything else other than "active" and in that case the object will not perform the code which it would perform in the "active" state.

Also you can use the similar system for alarms:
Code:
// Use this where you call alarm
alarm0_state = "action1";
alarm[0] = room_speed; // Alarm will perform in 1 sec (Room Speed)
.....
alarm0_state = "action55";
alarm[0] = room_speed * 5; // Alarm will perform in 5 sec (Room Speed)
In alarm[0] event you can use:
Code:
if (alarm0_state = "action1")
{
 // Code for condition 1
}
else if (alarm0_state = "action2")
{
 // Code for condition 2
}
.......
else if (alarm0_state = "action55")
{
 // Code for condition 55
}
This way you can use one single alarm for as many cases as you need.
Also you can use the "Switch" statement instead of if / else if
 
T

Treecase86

Guest
Hello, I'm a new user of Game Maker but I've already being developing games in the RPG Maker engine for about 10 years, my question is about a feature I found in the RPG Maker programs that allows the user to wait a number of frames before the event keeps going, I'm wandering how I could use the GM scripts to do a similiar effect, for example:

Player talks with a NPC:

"Hello, I'm a mad robot who hates robots, let me scan you"
-> Wait 10 frames
"Yeah, you are a real person, you may pass"
*In this example, I made the player wait 10 frames between the dialogues to add 'drama' to the scene, just for aesthetics purpose

Or maybe during a Action Battle System:

> Player conjures a FireBall and changes his sprite to attack mode
wait 15 frames
> Player returns his sprite to standard form
*In this example, the player changed his sprite for a while so the player could see what was happening"
Hope we've helped
 
M

Mantra

Guest
Thanks again, I'm trying here but my only issues seems to be that this 'alarm' thing is activating something outside of the code right? I wish I could activate something in the same code, without calling something external, because if I did this way, every dialogue of the game would have a 'wait' and it would break in 29382329 pieces, you see?

>Dialogue: "You are very special"
>Wait 10 frames
>Dialogue: "I think, maybe..."
>wait 10 friends
>"I..."
>wait 10 frames
>"Love..."
>wait 10 frames
>"You."


Well, I'm going to read more tutorials about this alarm and try figure it out :s




for example, is this piece of code, i wanted to when the player press the key 'A', he would change his graphic according to his position (if he is oriented to right, left, up, down), create a fireball then >wait a few seconds< and come back to the regular sprite, so the player would see the hero conjuring a fireball for a few seconds and then come back to what it was
 
Last edited by a moderator:

TheouAegis

Member
var time = current_time + duration;
while current_time < time continue;

That's about the only way to have it wait within the current code, but that will literally lock up the game for the duration, which is a no-no.
 
M

Mantra

Guest
var time = current_time + duration;
while current_time < time continue;

That's about the only way to have it wait within the current code, but that will literally lock up the game for the duration, which is a no-no.
So I can't block a single object and then return his code? hummm
 
T

Treecase86

Guest
Thanks again, I'm trying here but my only issues seems to be that this 'alarm' thing is activating something outside of the code right? I wish I could activate something in the same code, without calling something external, because if I did this way, every dialogue of the game would have a 'wait' and it would break in 29382329 pieces, you see?

>Dialogue: "You are very special"
>Wait 10 frames
>Dialogue: "I think, maybe..."
>wait 10 friends
>"I..."
>wait 10 frames
>"Love..."
>wait 10 frames
>"You."


Well, I'm going to read more tutorials about this alarm and try figure it out :s




for example, is this piece of code, i wanted to when the player press the key 'A', he would change his graphic according to his position (if he is oriented to right, left, up, down), create a fireball then >wait a few seconds< and come back to the regular sprite, so the player would see the hero conjuring a fireball for a few seconds and then come back to what it was
obj_spiritball?
 
M

Mantra

Guest
Well, I tried something, but I want the opnion of you guys, I'm not sure if this will set my pc to destruction:

>>>nevermind, it pauses the whole game, not just the particular object<<<

obj_spiritball?
I agree with you it is a kind of generic name, but I'm just testing hahaha, are you watching Dragon Ball Super? :eek:
 
Last edited by a moderator:
P

p055ible

Guest
You can probably use a time variable and manually keep it ticking. Use it's value to do frame based action. Additionally, if you are using animated sprites, you can use inbuild image_index variable which automatically keeps ticking locally for each object. You can simply use something like

Code:
while(image_index<14)
{
show_dialog(x,y,"Hello, I'm a mad robot who hates robots, let me scan you")
}
OR
Code:
switch(image_index)
case 0:
show_dialog(x,y,"Hello, I'm a mad robot who hates robots, let me scan you");
break;
case 15:
show_dialog(x,y,"Yeah, you are a real person, you may pass");
break;
 
T

Treecase86

Guest
Well, I tried something, but I want the opnion of you guys, I'm not sure if this will set my pc to destruction:

>>>nevermind, it pauses the whole game, not just the particular object<<<



I agree with you it is a kind of generic name, but I'm just testing hahaha, are you watching Dragon Ball Super? :eek:
No, I just noticed obj_spiritball and my mind went to Yamcha's spiritball attack. I'm waiting for the English dub before I watch Dragon Ball Super.:D
 
A

anomalous

Guest
timelines is what you want to look up in GMS.

While you could use alarms or timer variables, those seem less suited to this cut-scene style orchestration you are doing.

I suspect most people don't use timelines because if you only need a little orchestration, I would just set some flags and timers and be done with it. But doing what you are doing.. a lot of that, yes I agree you should probably see if timelines make this process much more intuitive and easy (once you learn how they work).
 
Top