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

Add 'OverrideMetaHitEffect' event #1117

Merged
merged 3 commits into from
Feb 5, 2022

Conversation

Iridar
Copy link
Contributor

@Iridar Iridar commented Dec 31, 2021

Closes #1116

@Iridar Iridar added the ready-to-review A pull request is ready to be reviewed label Dec 31, 2021
@Iridar Iridar added this to the 1.24.0 milestone Dec 31, 2021
@Iridar Iridar self-assigned this Dec 31, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Dec 31, 2021

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 62b936b..3d07a78 100644
--- a/target/CHL_Event_Compiletest.uc
+++ b/target/CHL_Event_Compiletest.uc
@@ -659,6 +659,39 @@ static function EventListenerReturn OnOverrideKillXp(Object EventData, Object Ev
 	return ELR_NoInterrupt;
 }
 
+static function EventListenerReturn OnOverrideMetaHitEffect(Object EventData, Object EventSource, XComGameState GameState, Name EventID, Object CallbackObject)
+{
+	local XComUnitPawn Pawn;
+	local XComLWTuple Tuple;
+	local bool OverrideMetaHitEffect;
+	local vector HitLocation;
+	local name DamageTypeName;
+	local vector Momentum;
+	local bool bIsUnitRuptured;
+	local EAbilityHitResult HitResult;
+
+	Pawn = XComUnitPawn(EventSource);
+	Tuple = XComLWTuple(EventData);
+
+	OverrideMetaHitEffect = Tuple.Data[0].b;
+	HitLocation = Tuple.Data[1].v;
+	DamageTypeName = Tuple.Data[2].n;
+	Momentum = Tuple.Data[3].v;
+	bIsUnitRuptured = Tuple.Data[4].b;
+	HitResult = EAbilityHitResult(Tuple.Data[5].i);
+
+	// Your code here
+
+	Tuple.Data[0].b = OverrideMetaHitEffect;
+	Tuple.Data[1].v = HitLocation;
+	Tuple.Data[2].n = DamageTypeName;
+	Tuple.Data[3].v = Momentum;
+	Tuple.Data[4].b = bIsUnitRuptured;
+	Tuple.Data[5].i = HitResult;
+
+	return ELR_NoInterrupt;
+}
+
 static function EventListenerReturn OnOverrideMissionImage(Object EventData, Object EventSource, XComGameState GameState, Name EventID, Object CallbackObject)
 {
 	local XComGameState_MissionSite MissionState;
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.

/// ```event
/// EventID: OverrideMetaHitEffect,
/// EventData: [
/// out bool OverrideMetaHitEffect,
Copy link
Member

Choose a reason for hiding this comment

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

Technically this is inout

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I will adjust.

Comment on lines 524 to 528
/// inout vector HitLocation,
/// inout name DamageTypeName,
/// inout vector Momentum,
/// in bool bIsUnitRuptured,
/// inout enum[EAbilityHitResult] HitResult,
Copy link
Member

Choose a reason for hiding this comment

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

Why are these inout with the exception of bIsUnitRuptured? Are listeners meant to be able to override these values while keeping the vanilla logic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are listeners meant to be able to override these values while keeping the vanilla logic?

Yeah, why not? This would be consistent with changes I did for the other similar event nearby.

with the exception of bIsUnitRuptured?

It's a bool and I'm lazy about converting it to int and back and explaining it in docs, and I'm not sure it even makes a difference anyway. If there's a use case for it later, it can be added into the Tuple.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure it even makes a difference anyway

if (bIsUnitRuptured)
{
if (DamageContainer != none)
{
RuptureEffectTemplate = DamageContainer.GetMetaRuptureHitEffectTemplateForDamageType(DamageTypeName);
}
if (HitEffectTemplate != none)
{
Spawn(class'XComPawnHitEffect', , , HitLocation, Rotator(HitNormal), RuptureEffectTemplate);
}
}

/// Meta Hit Effects are intended to communicate the overall effect of the attack,
/// and include things like blood gushing out of the unit.
/// If `OverrideMetaHitEffect` is set to `true`, the default behavior is omitted,
/// and no meta hit effect is played.
Copy link
Member

Choose a reason for hiding this comment

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

Add something like

... Keeping it set to false will allow the original logic to run, but you can also modify the parameters passed to it

@Iridar
Copy link
Contributor Author

Iridar commented Jan 28, 2022

@Xymanek implemented changes you requested. I'll do the same for OverrideHitEffects.

@Xymanek Xymanek merged commit d414289 into X2CommunityCore:master Feb 5, 2022
@Iridar Iridar deleted the 1116-OverrideMetaHitEffect branch October 29, 2023 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-review A pull request is ready to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add 'OverrideMetaHitEffect' event
2 participants