Skip to content

Commit 562dbda

Browse files
committed
Add Tuple & OnGetPawnArchetypeString Event
1 parent b83a787 commit 562dbda

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

X2WOTCCommunityHighlander/Src/XComGame/Classes/X2CharacterTemplate.uc

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,10 @@ private function bool FilterPawnWithGenderAndGhost(X2BodyPartTemplate Template)
276276
simulated function string GetPawnArchetypeString(XComGameState_Unit kUnit, optional const XComGameState_Unit ReanimatedFromUnit = None)
277277
{
278278
local string SelectedArchetype;
279-
local X2BodyPartTemplate ArmorPartTemplate;
279+
local X2BodyPartTemplate ArmorPartTemplate;
280+
281+
// Single line for Issue #1521
282+
local XComLWTuple Tuple;
280283

281284
//If bAppearanceDefinesPawn is set to TRUE, then the pawn's base mesh is the head, and the rest of the parts of the body are customizable
282285
if (bAppearanceDefinesPawn)
@@ -315,6 +318,26 @@ simulated function string GetPawnArchetypeString(XComGameState_Unit kUnit, optio
315318
{
316319
SelectedArchetype = strPawnArchetypes[`SYNC_RAND(strPawnArchetypes.Length)];
317320
}
321+
322+
// Start Issue #1521, Allow runtime override of SelectedArchetype (kUnit is NOT none for ELD_Immediate)
323+
Tuple = new class'XComLWTuple';
324+
Tuple.Id = 'OnGetPawnArchetypeString';
325+
Tuple.Data.Add(3);
326+
Tuple.Data[0].kind = XComLWTVString;
327+
Tuple.Data[0].s = ""; // [0] the override: listeners may supply a custom archetype string (leave empty to abstain).
328+
Tuple.Data[1].kind = XComLWTVString;
329+
Tuple.Data[1].s = SelectedArchetype; // [1] read-only reference: the pre-hook SelectedArchetype (reference only; do not modify).
330+
Tuple.Data[2].kind = XComLWTVInt;
331+
Tuple.Data[2].i = -1; // [2] arbitration hint: integer priority for listeners to read/set (higher wins by convention).
332+
333+
`XEVENTMGR.TriggerEvent(Tuple.Id, Tuple, kUnit, none); // Listeners may set [0].s (and optionally [2].i).
334+
335+
// Adopt listener-supplied result only if provided (non-empty); otherwise, keep the original.
336+
if (Tuple.Data[0].s != "")
337+
{
338+
SelectedArchetype = Tuple.Data[0].s;
339+
}
340+
// End Issue #1521
318341

319342
return SelectedArchetype;
320343
}

0 commit comments

Comments
 (0)