HOW-TO: Set traps
Setting traps, activating them and adding a trigger.
Table of contents:
Â
Traps class and properties
All traps inherit from W3Trap class, which inherits from W3MonsterClue and share the following properties:
activeByDefault: Should the trap be activated by default. Activated means it's been triggered and it's trying to do damage right now.
canBeArmed: This trap can be armed using interaction 'Arm'
interactibleAfterSprung: After this trap has been activated, it will be possible to interact with it, using Disarm / Arm.
willActivateWhenHit: If this is set to true, as soon as the trap receives any kind of hit it will set off.
Traps will only be able to Activate if they are Armed. Traps are armed by default. To activate a trap, either set its activeByDefault value to true, use a trap trigger (W3TrapTrigger), or use a tripwire.
Some traps (W3TrapSpawnEntity) might only activate when an Actor enters their trigger.
You can also use the quest function: SwitchTrapActivation (activate: True, trapTag: name, optional targetTag:name).
Facts can be added at various points of the life cycle of a trap. The parameters use a specific structure:
Â
Because traps inherit from W3MonsterClue, they show up in Focus mode.
Adding both 'Arm' and 'Disarm' InteractionComponents to them, makes it possible for Geralt to perform these actions on the traps. Disarmed traps cannot be activated. The animation used for Arming / Disarming a trap is taken from W3MonsterClue.
Trap Trigger
Entity class: W3TrapTrigger.
When an entity with the trigger activator component enters the trigger (which is an area, and can be found in the context menu under Gameplay → Traps→ Add Trap Trigger ), it will activate all the traps with the tag set in m_TrapsToActivateTag.
It is also possible to set the trigger to deactivate the traps when there is no more entity inside it.
A trap trigger needs to be enabled to work. It can be enabled by default with m_Enabled set on true, or enabled from the quest function EnableTrapTrigger (triggerTag: name, enable: True)
A TrapTrigger cannot be seen in Focus mode, cannot be Disarmed or Armed. Existing example: gameplay\traps\trap_trigger.w2ent (but then again, it is used as an area).
Â
Trap: Projectile Statue
Entity class: W3TrapProjectileStatue
These traps will shoot projectiles at a target. They can rotate towards the target or be static. Projectile can go from normal arrow to meteorite.
m_FireRate: Projectile shot per second.
m_MaxShots: Maximum number of projectiles shot before the trap is useless.
m_MinimumAngleToStartShooting: The minimum Angle before the statue starts shooting. To avoid shooting when the target is in the back for example. If you really want this, set the angle to 360.
m_MaxAimingPitchCorrection: How much up or down can the trap correct the direction of its projectile to reach the target. If the target is above this limit, the trap will shoot at the maximum value of this pitch. Example: you set the value at 45, the target is 60 degree above the trap -> projectile is shoot at 45 degrees.
m_TargetPositionPrediction: Projectile traps can predict the position of the target when rotating towards it. The default value is set to 0.5 seconds. The time value you will want to set will depend on the speed of the trap's rotation, speed of the projectile and distance from the target.
A Projectile Statue can be seen in Focus mode and be Disarmed or Armed. Existing example: gameplay\traps\trap_arrow_statue.w2ent
Trap: Alarm
Entity class: W3TrapAlarm
These traps will play a sound when triggered. Use it in combination with facts added on activation to have the quest adapt when the alarm is triggered. Existing example: gameplay\traps\trap_alarm_statue.w2ent.
Trap: Projectile Area (a.k.a Rain of Death)
Entity Class: W3TrapProjectileArea
This trap allow you to create an area where projectiles fall from the sky at random positions.
projectile: Projectile to fire.
density: Projectiles by square meter.
maxShots: Negative means infinite - Stop shooting after that much has been fired.
reloadAtActivation: Will shoot maxShots quantity everytime it is activated.
projAtOnce: How many projectile can be shot simultaneously every 'delay'.
delay: Period of time between each shoot.
height: Height of projectile origin from root of the trap entity.
velocity: Velocity of each projectile.
Â
projectileOriginOffsetX: X offset of orgin position from landing position.
projectileOriginOffsetY: Y offset of orgin position from landing position.
shootOnlyWhenTargetInside: When active, the trap will only shoot when a target is inside the trigger.
deactivateAutomatically: Should the trap deactivate automatically when there is no more target in the area.
useAdvancedDistribution: [More Costly] Cycle throught all the possible position to make sure everywhere is hit.
useGridPositioning: Using the grid is cheaper - but the result may look unnatural with big projectiles at low density.
excludedEntityTags: Entities with this tag will not trigger the trap.
Magnetisation: If a projectile is suppose to land at a position close (<magnetRange) to a GameplayEntity with one of the tag listed, it will snap its landing position to this entity position. The offset allows you to not land exactly at the entity position (in the case of player, you may want to go a bit higher than its feet if you're shooting arrows for
example).
The area itself can be found in the context menu under Gameplay → Traps→ Add ProjectileArea
A Projectile Area cannot be seen in Focus mode, cannot be Disarmed or Armed. Existing example: gameplay\traps\trap_projectile_area.w2ent.
Trap: Spawn Entity
Entity Class: W3TrapSpawnEntity
When activated, this trap will spawn the specified entity. Can be found in the context menu under Gameplay → Traps→ Add Trap Spawn Entity.
spawnOnlyOnAreaEnter: Even if the trap is active, only spawn entity when an actor enters the area trigger.
maxSpawns: Maximum time the entity that can be spawn during trap lifetime. (-1 means infinite).
offsetVector: spawn position offest.
excludedActorsTags: Actors with this tag will not trigger the trap when entering the trigger.
appearanceAfterFirstSpawn: appearance to switch to after the first spawn on the entity.
A Spawn Entity can be seen in Focus mode and be Disarmed or Armed.
Trap: Tripwire
Entity Class: W3TrapTripwire
eventOnTripped: Events that will be fired when the tripwire is walked into
excludedActorTags: Like W3TrapSpawnEntity, can be set to ignore CActor entities with these tags.
Can be used to fire the following actions (using eventOnTripped):
A Tripwire can be seen in Focus mode and be Disarmed or Armed. Existing example: gameplay\traps\tripwires\tripwire_outdoors\.
Â
Â
______________________________________
The Witcher 3: Wild Hunt Complete Edition © 2024 CD PROJEKT S.A. Published by CD PROJEKT S.A. Developed by CD PROJEKT RED. CD PROJEKT®, The Witcher®, REDengine® are registered trademarks of CD PROJEKT Capital Group. All rights reserved. The Witcher game is set in the universe created by Andrzej Sapkowski in his series of books. All rights reserved.