-
Notifications
You must be signed in to change notification settings - Fork 3
FormulaEngine Concepts Events
An event is simply a signal of some kind from one part of the game simulation to another. For example, the C++ code might signal the FormulaEngine script that a physics collision occurred. Or the script for an AI RTS unit might send an event to a player's unit notifying the unit that it has been attacked.
Events are a powerful tool for communication. They can be given attached parameters which are used to inform the recipient of the event about the event's finer details. A collision event might contain details of the colliding object's mass and velocity, for example. An event notifying an RTS unit that it has been attacked would probably carry parameters about the type and quantity of damage carried by the attack, and so on.
There are two philosophical "flavors" of event: something happened, and something failed to happen. Dealing with events that talk about successful simulation interactions is pretty straightforward. However, failure events are much more subtle, and in fact also much more important.
Failure events are an immensely useful ingredient in the creation of a robust simulation. They allow script authors to decide what to do when things do not go according to plan. For example, consider the case where a unit is pathfinding a long distance to reach an enemy base and attack it. What happens if the unit is ambushed halfway there? What happens if the base is destroyed by a third team before the unit arrives? These sorts of occurrences are tremendously common in nontrivial game simulations, and yet we often don't think of them as first-class events to deal with.
Generally a good FormulaEngine setup will use some goal states to set up desired outcomes, and then handle the success and failure events generated when those goal states are either reached or become unreachable, respectively.