How do games implement their triggers and events that make up the plot of the story. For example, to be concrete how would one implement the story of a game such as The Legend of Zelda: A Link to the Past. I'm assuming there is some kind of scripting that somehow hooks into the game world state? I know absolutely nothing about scripting and game development. And have no clue how the underlying code would be architected in terms of classes, data structures, design patterns, etc.

  • \$\begingroup\$ Based on what seems like cluelessness, I suggest you download something like RPG Maker and see how they do it. That'll give you an idea (in one genre) how they use scripts and events. \$\endgroup\$
    – ashes999
    Sep 28, 2013 at 14:09

2 Answers 2


In the simplest terms i can put it.

  • There will be some kind of "trigger" volume in most cases. When the player steps into this volume it will trigger the "event".
  • Volumes will be a cube, or a sphere, or some other 3D primitive.
  • The script will either be a pre-animated cutscene, in which case an animation will be played, or the gameplay script will be some kind of finite state machine (FSM).
  • Different "states" will be triggered upon in game events, such as retrieving an item, or beating a boss.
  • The mission will be "over" when the final state is run, this will usually update the players profile to say that a particular mission has been complete. And most likely cause the next FSM to be loaded.

The FSM may be defined like

  1. Get Object A
  2. Get Object B
  3. Get Object C
  4. Play cutscene putting triforce together
  5. Boss defeated
  6. Play cutscene
  7. Load next "mission".

Each "state" within a FSM may contain its own FSM. All of this can be defined with data, and doesnt necessarily require its own scripting language.

  • 1
    \$\begingroup\$ Are there maybe any indepth tutorials or articles written out there about this stuff? \$\endgroup\$
    – user782220
    Sep 28, 2013 at 23:33
  • \$\begingroup\$ In link to the past there isn't much of world states going on though. It's mostly pretty straightforward. Grab mastersword > Got all 3 pendants > Release Mastersword. Hit barrier > Is sword mastersword or higher > remove barrier. Most of these "triggers" have a simple checkup. You need certain items to get from place to the other. But the way they are triggered is not as much by an event, just by using the item you normally would. \$\endgroup\$
    – Sidar
    Sep 29, 2013 at 0:39

I want to add some more information to what Matt already mentioned by explaining how the RPG Maker does specific story progression and states. Though one can implement a more complex system the simplified way how the RPG Maker does it should be a good start.

In maps we can find certain triggers or entities. That can be an invisible tile which executes some code when the player steps on it or just a NPC you can talk to. Each one has different properties and provides different ways to interact with. Assume we have a NPC who would send you give you a quest - the first time you talk to him he would say something different than later on. Using pages for entities one can write code for different situations which is only executed under certain conditions. The RPG Maker uses so called switches - just boolean variables which are either on or off. At the beginning of the game a switch HasAcquiredQuestX might be off and the NPCs page 1 (giving the player the quest and turning on HasAcquiredQuestX) would be executed. Speaking to him now would maybe execute page 2 with some text like "Oh did you finish your quest yet?". Once you finish the quest another trigger might turn on a switch HasFinishedQuestX which lets our aforementioned NPC execute page 3 which will reward you with glory, gold and items.

This is a very easy way to work with story progression, however the more content the game has the more switches you will have and at a certain point it is definitely better to consider using finite state machines!


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .