Game Development Community

Scripted Sequences

by Jemand den es nicht gibt · in Torque Game Builder · 04/16/2006 (8:08 am) · 1 replies

Hiya!

I am thinking of working on a little Zelda-style game in my spare
time and I am trying to come up with a nice system to handle
scripted story sequences. Has anybody given that any thought
thus far? I would be interested in anything you might have
tried / found out thus far. :)

I thought about creating an entity system in TorqueScript that
allows un-/locking of entities and giving them a simple command
queue when any event is triggered.

#1
04/16/2006 (2:55 pm)
I thought of a scripted sequences system in torque script a while ago but never came to try it out.
Something like this:

function ScriptedSequence::onAdd(%this)
{
   %this.actionSet = new SimSet();
   %this.currentAction = 0;
}

function ScriptedSequence::onRemove(%this)
{
    %this.actionSet.delete();
}

function ScriptedSequence::addAction(%this,%actionObject)
{
   %this.actionSet.add(%actionObject);
}

function ScriptedSequence::process(%this)
{
   if( %this.actionSet.getCount() == %this.currentAction )
   {
      %this.schedule(0,"delete");   
      return;
   }

   %actionCompleted = %this.actionSet.getObject(%this.currentAction).process();
   if( %actionCompleted )
      %this.currentAction++;
}

You could then create a scriptObject with class "ScriptedSequence" and add actions to it like "walk to point X" where every action is another scriptObject with a process method that returns whether the action was completed. You would then just have to call the sequence's process method repeatedly until the sequence is finished. This still seems like a pretty versatile approach to me.

-Michael