Game Development Community

How to implement a command 'wait until is done

by Diego Santos Leao - GameBlox Studio · in Torque Game Builder · 03/28/2008 (4:54 am) · 7 replies

I want to create a cutscene for my RPG, in which characters will move and talk WITHOUT user interaction. The problem is that every sprite moves at the same time... what I want is that before a sprite can move, it waits for the previous sprite to be "done" with its tasks.

I also want to do the following: when the character clicks on a door, I want to zoom in until the ceiling of the house is very near, and only then call the "sceneWindow2D.loadLevel(...)" function to show its interior.

Thanks!

#1
03/28/2008 (6:06 am)
If you have a script (in the movie sense) and want to do it based on events, have each object do it's thing then call a function on the next object or report that it's done to a director object which then gives directions to the other objects. If you wish to use time-based scheduling, just use the built-in scheduling capabilities.

Also, I think your logic backwards. Rather than having object B wait for object A to finish its tasks, object A should tell object B to go. That would prevent you from having a bunch of objects polling each other to see if it's time for them to take action.
#2
03/28/2008 (6:57 am)
The problem with time-based scheduling is that if a lag occurs, or other situation that would mess the timing of the game arises, the entire cutscene will fail.

I guess I'll have, as you said, to think backwards to accomplish what I want.
When I find a proper solution I'll post here. thanks!
#3
03/28/2008 (9:11 am)
I just gave you two solutions that would work.

How much lag do you expect to happen on a cut-scene (which should be managed locally)? If you do have clock drift, it would affect everything the same and the order wouldn't be disturbed. Although if you do have so much clock drift on your system that it makes the scene unwatchable, you have bigger problems on your hand or you need a new computer.
#4
03/29/2008 (9:27 pm)
This might help but i needed a wait untill this is done then do this type command before, i used a loop

$node = 0; // impliment this in level loaded

if ($node==1)
{

// add dialog and commands

$node++;
}


else if ($node==2)
{

// add 2nd lot of dialog and commands

$node++;
}

this way a script will only run once the previous one has run and added 1 to the node count

maybe way off base but its an idea
#5
03/31/2008 (7:42 am)
Anthony,

In your implementation, are you polling the value of $node periodically?
#6
05/11/2008 (11:16 am)
Not sure wta u mean but the node increases with each if
#7
05/11/2008 (4:42 pm)
I'm also making an RPG :) The solution I came up with for this is to simply use schedule commands with a big switch statement that decides what to do next. Maybe not the most efficient code but it's simple and works good. This is also the same method I use for attacks and spells etc. in my turn based RPG battles. I guess you would call it event based scheduling, and there's no lag or timing issues that I've noticed.