Trap system

From Dragon Age Toolset Wiki
Revision as of 17:58, 2 July 2009 by BryanDerksen (Talk | contribs) (category)

Jump to: navigation, search
  • Trap - A placeable object with the Trap Type setting (see below) set to a value != 0.
  • Trap Type - A trap's type defines the effect(s) and/or scripted actions the object will apply to its surrounding when triggered. Trap Type is defined in the integer variable 'PLC_TRAP_TYPE' on the placeable's ?Vartable .
  • Armed - A trap placeable that is flagged as 'inactive' is considered 'not armed' and will not react to creatures entering or leaving its trigger volume. This is to allow the user to leave the area of effect of the trap after setting it without being damaged. Arming a placeable automatically sets it to 'active'.
  • Detected - Traps that have the integer variable 'PLC_TRAP_DETECTED' set to 0 (default) when they are armed are considered 'not detected' and are automatically set to be invisible to the player and his party. Traps dynamically created by the player are always set to 'detected' after they are created.
  • Trap Owner - Traps dynamically spawned by a creature in the game world have the object variable 'PLC_TRAP_OWNER' on them pointing to the creature that created them. Any hostility checks performed or effects applied by the trap will be attributed to owner of the trap, ensuring that proper experience rewards are given to the trap creator for objects killed by a trap.
  • Rearming Delay - Traps that have the float variable 'PLC_TRAP_REARM' set to a positive value will not be automatically destroyed when triggered but instead deactivate themselves and rearm after the number of seconds defined in the variable.
  • Signal Target - Traps can optionally define a signal target object by defining the string variable 'PLC_SIGNAL_TAG' on the template. If set to a valid object tag, the trap will send EVENT_TYPE_TRAP_TRIGGER_ENTER to this object to allow designers to script custom actions. This is mostly interesting for pre placed designer traps

Trap Placeables

There are two possible ways for Trap objects to enter the world:

  • Being pre-placed by a designer in the toolset.
  • Being dynamically spawned by a player controlled creature that has the Traps Skill.

When a pre placed object is initially loaded, it will receive an EVENT_SPAWN, during which the default placeable event script (placeable_core.nss) will automatically 'arm' the trap if the object is 'active' at that time. If the object is not active, it needs to be activated and armed manually by the designer. This can be done by calling the function TrapArm() in sys_traps_h.

Dynamically spawned traps are created when a player controlled character uses one of the trap kit item abilities from their quickbar, causing the character to play a kneeling 'conjure' animation. The object will spawn in as initially inactive at the players location and will arm through a delayed itself after a short grace period to allow the player to exit the danger area around the trap. The player will also automatically be set as the traps owner:

Once a trap placeable is armed, it will automatically spawn an EFFECT_AREA_OF_EFFECT onto itself that provides the trigger mechanism for the trap. The type of the area of effect object are defined for each trap type in traps.xls, pointing to an entry in aoe.xls defining the dimensions of the trigger volume. Aftwards, if a Signal Target was defined on the placeable, the target object will receive EVENT_TYPE_TRAP_TRIGGER_ARMED .

Logic path:

Preplaced:

object spawns --> object has trap type set -- Yes --> object active? -- Yes --> object arms itself --> object spawns AoE trigger on itself

                                              \ -- No --> do nothing    \
                                                                         \ -- No --> do nothing.

Dynamic:

Trap Item Ability Use --> Placeable object is created (inactive) --> object is armed/activated after delay --> object spawns AoE trigger on itself

Triggering a Trap

Any creature object entering the area of effect object trigger around an armed trap object will cause an EVENT_ENTER to fire into placeable_core.nss, which will call the function Trap_HandleEventEnter() in sys_traps_h.

Here, a number of conditions are checked to validate if the entering object will to set the trap off:

If the trap object is currently set inactive, the function will exit immediately without applying any effects.

If the trap has a valid owner associated with it, a hostility check between the owner and the entering creature is performed. If they are found non hostile. the function exits immediately without applying any effects.

If the trap does not have an owner set, it is considered an environmental trap and only hostile to the player's group. If the entering creature is not a member of the player's group, the function exists immediately without applying any effects.

Logic Tree:

object enters -- Trap Active? -- Yes --> Have Owner -- Yes --> object hostile to owner -- Yes --> Trigger Trap!

                             \-- No --> do nothing.     \ 
                                                        \ --> IsPartyMember(object) -- Yes --> Trigger Trap!
                                                                                       \-- No --> do nothing.

If all conditions are satisifed and the entering object has been found valid for triggering the trap, the function Trap_TriggerTrap() is called from sys_traps_h, causing the effects defined in traps.xls to be applied to the entering object. In addition, if a Signal Target was defined on the trap placeable, EVENT_TYPE_TRAP_TRIGGER_ENTER will be fired to the closes object matching the 'PLC_SIGNAL_TAG' string variable on the placeable, allowing triggering of designer defined events (such as running environmental traps).

After running, the trap disables itself, preventing any further triggering from entering objects. Traps that have a 'Rearming Delay' specified will automatically reactivate after the specified amount of time - all other traps will self destruct after 1000ms.

Trap Detection

The presence of the trap skill on member of the player's party will automatically spawn an EFFECT_TYPE_HEARTBEAT on that creature, which runs the function Trap_RunDetectionPulse from sys_traps_h at predefined intervals that shorten based on skill level.

The detection pulse function scans the area around the party member to a range based on the character's skill level for active placeable objects and inspects the found objects for their Trap Type and Detected state. Each pulse, the 10 closes placeable objects to the players current location are inspected.

For object to be found to be an undetected trap, a skill check (defined in sys_traps_h.TrapTryDetect()) determines whether or not the player detects the trap. This check is based partially on the players traps rank.

On successful detection, the object is flagged as detected and thereby made visible to the player and his party. An additional visual effect is spawned to provide a visual cue to the player about the detection. We are still considering whether the game will auto pause in the event of a detected trap.

Trap Disarming

Disarming a trap will be handled through the placeable objects interaction menu.

!!need more recent documentation on this!!

Creating a trap trigger placeable

A trap trigger placeable is a placeable object that acts as the trigger for a trap, which can be either VFX based (e.g. explosion) or based on a complex trap placeable.

Setting up the traps

Every placeable object in the game can act as a trap trigger, but only some of them actually make sense.

In order to set a placeable object up as a trap trigger, the PLC_TRAP_TYPE integer variable in its vartable has to be set to a valid row index in traps.xls.

Additional variables can be used to tweak the behavior of an object, such as whether or not it signals its triggering event to another object (e.g. a complex trap placeable) and whether or not the trap will rearm itself after triggering once.

Variable summary:

PLC_TRAP_AOE int
PLC_TRAP_DEACTIVATE int
PLC_TRAP_DETECTED int
PLC_TRAP_REARM_DELAY float If this is set to anything other than 0, the trap will rearm after triggering in so many seconds.
PLC_TRAP_SIGNAL_HEIGHT float
PLC_TRAP_SIGNAL_TAG string Tag of the object that will be notified of enter events.
PLC_TRAP_TEAM int
PLC_TRAP_TYPE int a row in traps.xls indicating what type of trap this is. An object automatically becomes a trap trigger if this is not 0.

Setting detection and disarm difficulty

Detection and disarm properties are set on the placeable properties and pick from a 2da. The granularity for these difficulties ranges from 'Auto Success' to 'Nearly Impossible'. The default value is currently 'Auto Success'.

The actual difficulty for the player will depend on his skill level, attributes and a number of other factors.

traps xls

Traps.xls contains three 2da worksheets. lock_difficulty and trap_difficulty define difficulty categories for locks and traps respectively, and are unlikely to need changing.

the "traps" worksheet is what defines the details of each type of trap, and has the following columns:

  • ID
  • Label
  • TrapPlaceable
  • PlayerCreated
  • aoe_index - index into aoe.xls
  • AoEVFX
  • HideWhenUndetected
  • AnimImpact
  • ResetDelay
  • Projectile
  • ProjectileCount
  • ProjectileCrust
  • LocationVfx - If negative, this will be played at the location of the placeable, if positive this will be applied on the target object.
  • Effect1
  • Effect1_Float1
  • Effect1_Float2
  • Effect1_Int1
  • Effect1_Int2
  • Effect1_Duration
  • Effect2
  • Effect2_Float1
  • Effect2_Float2
  • Effect2_Int1
  • Effect2_Int2
  • Effect2_Duration
  • Effect3
  • Effect3_Float1
  • Effect3_Float2
  • Effect3_Int1
  • Effect3_Int2
  • Effect3_Duration
  • Effect4
  • Effect4_Float1
  • Effect4_Float2
  • Effect4_Int1
  • Effect4_Int2
  • Effect4_Duration

A reference worksheet is also included that gives the meaning of the trap effects and their associated parameters.