Scripted Gameplay Flow Control

Miscellaneous Forums/General Discussion/Scripted Gameplay Flow Control

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Interesting questions. This is pretty new to me too and I'm trying to figure out the same kind of things at the moment. I'm using my own script `language` and `virtual cpu` rather than LUA but I guess it's the same problems.

For me, each script is multitaskable ie I give tasks timeslices and priorities and all that, so you could say that a character says something to the player and then puts itself into a `waiting for state` condition, and senses the players activities like you would sense things like collision detection, and when the right conditions are met then the guard's script would just kick in with the next part of its sequence. I guess it depends how flexible you want things to be, whether you want the story to proceed along a variety of known lines which all end up at known destinations, or wether you want it so open that anything can happen.

I think of each object as an infinite loop running all the time sensing messages and other conditions and then occasionally doing something to react to it. Each object is fully autonomous and has its own script code. That means that as your player interacts with the guard there are messages being sent back and forth.

Another approach is to think of events as objects. An event, even in real life, is really just a collection of objects arranging themselves in a particular way at the same time, to create the overall impression of significance or meaning. There really are no events, there are only arrangements of objects. So to detect when it's time to do something you basically are detecting what state the objects are in and when it matches up to something that `triggers` an activity then that kicks in some new set of behaviors - which really are just sequences of changes to objects.

You could have a `game object`, a single object which senses game state and is looking for when its the right time to trigger the cut scene based on sequence or pattern matches. Then it can send the appropriate signal/message to the player object to put it into a passive mode and let `control` switch to the king object which then orchestrates what the player object does.

There's probably other approaches I guess. Good luck.