There is a mistake in the function UndergroundTriggerCarrier::SpawnTrigger, which causes double rotation of underground darkness triggers with custom orientation set.
Description
Description
Details
Details
- Severity
- Major
- Resolution
- Open
- Reproducibility
- Always
- Operating System
- Windows 11 x64
- Category
- Scripting
Steps To Reproduce
Rotate an underground trigger using CfgUndergroundTriggers.json, and check the appearance/behavior of the trigger in game.
Additional Information
The problem in question is caused by setting orientation of the trigger *before* adding it as a child of the trigger carrier in the original code.
void SpawnTrigger() { if (!CanSpawnTrigger()) { RequestDelayedTriggerSpawn(); return; } if (UndergroundAreaLoader.m_JsonData.Triggers && UndergroundAreaLoader.m_JsonData.Triggers.IsValidIndex(m_TriggerIndex)) { JsonUndergroundAreaTriggerData data = UndergroundAreaLoader.m_JsonData.Triggers[m_TriggerIndex]; UndergroundTrigger trigger = UndergroundTrigger.Cast(GetGame().CreateObjectEx( "UndergroundTrigger", GetPosition(), ECE_LOCAL )); if (trigger) { #ifdef DEVELOPER trigger.m_Local = true; #endif trigger.SetPosition(vector.Zero); if (GetOrientation() != vector.Zero) trigger.SetOrientation(GetOrientation()); AddChild(trigger,-1); trigger.Init(data); m_Trigger = trigger; } } }
Additionally, #ifdef DEVELOPER should be #ifdef DIAG_DEVELOPER, as DEVELOPER is only present on internal builds.
The fixed code is as follows:
void SpawnTrigger() { if (!CanSpawnTrigger()) { RequestDelayedTriggerSpawn(); return; } if (UndergroundAreaLoader.m_JsonData.Triggers && UndergroundAreaLoader.m_JsonData.Triggers.IsValidIndex(m_TriggerIndex)) { JsonUndergroundAreaTriggerData data = UndergroundAreaLoader.m_JsonData.Triggers[m_TriggerIndex]; UndergroundTrigger trigger = UndergroundTrigger.Cast(GetGame().CreateObjectEx( "UndergroundTrigger", GetPosition(), ECE_LOCAL )); if (trigger) { #ifdef DIAG_DEVELOPER trigger.m_Local = true; #endif trigger.SetPosition(vector.Zero); AddChild(trigger,-1); trigger.Init(data); m_Trigger = trigger; } } }
Event Timeline
Comment Actions
Where can I find the code file?
Also how come preprocessor directives are necessary since it is a script?