Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-add event to allow mods to adjust UFO interception time #1317

Merged

Conversation

Tedster59
Copy link
Contributor

Fixes issue #1316.

This event existed in the LW2 Highlander as well as the non-WOTC X2CommunityHighlander. This pull request re-adds it and documents it so LWoTC can use this event for its original purpose of adjusting the UFO interception time for systems such as Long War that do not use the base game mission calendar.

@Tedster59 Tedster59 force-pushed the 1316-PostInterception-Event branch 2 times, most recently from 783d8d5 to 233b076 Compare March 8, 2024 06:08
Copy link
Contributor

github-actions bot commented Mar 8, 2024

Pull request modifies event listener templates

Difference (click to expand)
diff --git a/target/CHL_Event_Compiletest.uc b/target/CHL_Event_Compiletest.uc
index 03d8f1b..7006534 100644
--- a/target/CHL_Event_Compiletest.uc
+++ b/target/CHL_Event_Compiletest.uc
@@ -1196,6 +1196,13 @@ static function EventListenerReturn OnPostSquaddieLoadoutApplied(Object EventDat
 	return ELR_NoInterrupt;
 }
 
+static function EventListenerReturn OnPostUFOSetInterceptionTime(Object EventData, Object EventSource, XComGameState GameState, Name EventID, Object CallbackObject)
+{
+	// Your code here
+
+	return ELR_NoInterrupt;
+}
+
 static function EventListenerReturn OnPreCompleteStrategyFromTacticalTransfer(Object EventData, Object EventSource, XComGameState GameState, Name EventID, Object CallbackObject)
 {
 	// Your code here
What? (click to expand)

The Highlander documentation tool generates event listener examples from event specifications.
This comment contains the modifications that would be made to the copy-pasteable event listeners in documentation, for PR authors and reviewers to inspect for correctness, and will automatically be kept up-to-date whenever this PR is updated.

/// EventSource: XComGameState_UFO,
/// NewGameState: none
/// ```

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The empty line before the event trigger is unnecessary, and I would add Start / End Issue #### tags before the start of the docs and after the event trigger.

Also the docs could be formulated a bit better, like:

The PostUFOSetInterceptionTime event allows mods to modify the state of a UFO
after it has been created, but before the gamestate is submitted.
To use this event, listen to it with ELD_Immediate deferral and edit the state object received.

There's also this issue to consider: https://www.reddit.com/r/xcom2mods/wiki/index/events#wiki_important_note

In short, when listening to events using ELD_Immediate, the state objects passed as EventSource / EventData are taken from History. To modify the current version of the state object, listeners must explicitly get it from the NewGameState you should be passing with the event, otherwise you would be modifying History.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, this has been refactored and updated to shift the call up the stack and pass in NewGameState to the event.

@Tedster59 Tedster59 force-pushed the 1316-PostInterception-Event branch 2 times, most recently from d511a70 to 1501894 Compare March 9, 2024 01:06
/// To use this event, listen to it with `ELD_Immediate`
/// and edit the state object received in the NewGameState.
///
/// local XComGameState_UFO UFOState;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use unrealscript <code> tags around the example code, for example:

/// ```unrealscript
/// float GetPreDefaultAttackingDamageModifier_CH(
///         XComGameState_Effect EffectState,
///         XComGameState_Unit SourceUnit,
///         Damageable Target,
///         XComGameState_Ability AbilityState,
///         const out EffectAppliedData ApplyEffectParameters,
///         float CurrentDamage,
///         XComGameState NewGameState)
/// ```

Also, nitpicking, but I'd adjust docs a little:

"To use this event, listen to it with the ELD_Immediate deferral, and make sure to get the latest version of the UFO state object from the NewGameState, for example: ".

@Iridar Iridar added this to the 1.28.0 milestone Mar 9, 2024
refactor commit to pass NewGameState

revise docs
@Tedster59 Tedster59 force-pushed the 1316-PostInterception-Event branch from 1501894 to 5b9fea7 Compare March 9, 2024 05:05
@Iridar Iridar merged commit dea97d9 into X2CommunityCore:master Mar 9, 2024
4 checks passed
@Tedster59 Tedster59 deleted the 1316-PostInterception-Event branch July 15, 2024 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants