area_trigger
Overview
The area_trigger component provides a mechanism for an entity to dynamically adjust game tuning settings based on the current game area or "story" identifier. It listens for the global "changearea" event and, if configured, applies a set of predefined tuning overrides associated with the new area's story or its depth. This allows for context-sensitive modifications to game mechanics, such as altering spawn rates, damage multipliers, or other game parameters when players enter specific regions or progress through narrative stages.
Dependencies & Tags
Dependencies:
- Relies on the global event system for the
"changearea"event to be pushed. - Requires the
tuning_overrideLua module to perform actual tuning adjustments.
Tags: None identified.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
inst | Entity | (provided in ctor) | A reference to the entity this component is attached to. |
stories | table | {} | A table mapping area story identifiers (strings for area.story or numbers for area.story_depth) to lists of tuning overrides. |
Main Functions
AreaTrigger:DoOverride(overrides)
- Description: Applies a list of tuning overrides. It iterates through the provided
overridestable, where each override is expected to be a table containing a key (corresponding to a function name in thetuning_overridemodule) and a value (the argument for that function). It then calls the correspondingtuning_overridefunction with the specified value. - Parameters:
overrides:table- A list of override definitions. Each element should be a table[key, value]wherekeyis a string matching a function name in thetuning_overridemodule andvalueis the argument for that function.
AreaTrigger:CheckTrigger(area)
- Description: This function is invoked when the game area changes (typically via the
"changearea"event). It inspects the providedareatable forstoryandstory_depthfields. If either of these matches a key registered inself.stories, the associated list of tuning overrides is passed toAreaTrigger:DoOverrideto be applied. - Parameters:
area:table- An object representing the new game area. Expected to contain astory(string) field and optionally astory_depth(number) field.
AreaTrigger:RegisterTriggers(stories)
- Description: Sets the internal table of story-based tuning overrides for this component. This is the primary method used to configure which specific area stories or story depths should trigger particular tuning adjustments. The component will then use this mapping when
"changearea"events occur. - Parameters:
stories:table- A table where keys are story identifiers (strings forarea.storyor numbers forarea.story_depth) and values are tables of tuning override definitions (in the format expected byAreaTrigger:DoOverride).
Events & Listeners
- Listens For:
"changearea": This event is typically pushed when the player or game state transitions to a new distinct game area. When received, it triggers the component'sAreaTrigger:CheckTriggermethod, passing the new area's data.