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

Fix bugs with Revival Protocol and Restoration #1415

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -718,13 +718,21 @@ static function X2AbilityTemplate RevivalProtocol()
local X2AbilityCost_Charges ChargeCost;
local X2AbilityCharges Charges;

// Variable for Issue #1414
local X2Effect_RestoreActionPoints RestoreActionPoints;

`CREATE_X2ABILITY_TEMPLATE(Template, 'RevivalProtocol');

ActionPointCost = new class'X2AbilityCost_ActionPoints';
ActionPointCost.iNumPoints = 1;
Template.AbilityCosts.AddItem(ActionPointCost);

Charges = new class'X2AbilityCharges';
// Start Issue #1414
// Use the correct class for Charges to make the number of charges scale with GREMLIN tier.
//Charges = new class'X2AbilityCharges';
Charges = new class'X2AbilityCharges_RevivalProtocol';
// End Issue #1414

Charges.InitialCharges = default.REVIVAL_PROTOCOL_CHARGES;
Template.AbilityCharges = Charges;

Expand All @@ -741,7 +749,22 @@ static function X2AbilityTemplate RevivalProtocol()
Template.AbilityTargetConditions.AddItem(new class'X2Condition_RevivalProtocol');

Template.AddTargetEffect(RemoveAdditionalEffectsForRevivalProtocolAndRestorativeMist());
Template.AddTargetEffect(new class'X2Effect_RestoreActionPoints'); // put the unit back to full actions

// Start Issue #1414
/// HL-Docs: ref:Bugfixes; issue:1414
/// Fixes the specialist's Revival Protocol and Restoration abilities to make them function as intended.
/// 1. Revival Protocol now can target any allied unit, not just units under player's control.
/// 2. Revival Protocol and Restoration now properly remove Stun, and no longer recover action points for Disoriented units.
/// 3. Revival Protocol now properly gets more Charges with higher GREMLIN tiers.

// Add a new condition to this effect, so it does not restore action points if the unit is only stunned or disoriented.
RestoreActionPoints = new class'X2Effect_RestoreActionPoints';
RestoreActionPoints.TargetConditions.AddItem(new class'X2Condition_RevivalProtocolRestoreAP');
Template.AddTargetEffect(RestoreActionPoints); // put the unit back to full actions

// Use a separate effect to restore action points for a stunned unit.
Template.AddTargetEffect(class'X2StatusEffects'.static.CreateStunRecoverEffect());
// End Issue #1414

Template.AbilityTriggers.AddItem(default.PlayerInputTrigger);

Expand Down Expand Up @@ -1217,11 +1240,20 @@ static function X2AbilityTemplate RestorativeMist()
MedikitHeal.PerUseHP = class'X2Ability_DefaultAbilitySet'.default.MEDIKIT_PERUSEHP;
Template.AddMultiTargetEffect(MedikitHeal);

// Start Issue #1414
// Move this effect to apply before the effects that restore action points
// to ensure the ability's behavior is consistent with Revival Protocol.
Template.AddMultiTargetEffect(RemoveAdditionalEffectsForRevivalProtocolAndRestorativeMist());

// Use a different condition on this effect so it does not grant action points if the unit is only stunned or disoriented.
RestoreEffect = new class'X2Effect_RestoreActionPoints';
RestoreEffect.TargetConditions.AddItem(new class'X2Condition_RevivalProtocol');
//RestoreEffect.TargetConditions.AddItem(new class'X2Condition_RevivalProtocol');
RestoreEffect.TargetConditions.AddItem(new class'X2Condition_RevivalProtocolRestoreAP');
Template.AddMultiTargetEffect(RestoreEffect);

Template.AddMultiTargetEffect(RemoveAdditionalEffectsForRevivalProtocolAndRestorativeMist());
// Add stun recover effect to restore action points for stunned units.
Template.AddMultiTargetEffect(class'X2StatusEffects'.static.CreateStunRecoverEffect());
// End Issue #1414

//Typical path to build gamestate, but a (very crazy) special-case visualization
Template.BuildNewGameStateFn = SendGremlinToOwnerLocation_BuildGameState;
Expand Down Expand Up @@ -2112,6 +2144,9 @@ static function X2Effect_RemoveEffects RemoveAdditionalEffectsForRevivalProtocol
RemoveEffects.EffectNamesToRemove.AddItem(class'X2AbilityTemplateManager'.default.BerserkName);
RemoveEffects.EffectNamesToRemove.AddItem(class'X2AbilityTemplateManager'.default.ShatteredName);

// Single Line for Issue #1414 - make Revival Protocol and Restoration remove Stun.
RemoveEffects.EffectNamesToRemove.AddItem(class'X2AbilityTemplateManager'.default.StunnedName);

foreach class'X2Ability_DefaultAbilitySet'.default.MedikitHealEffectTypes(HealType)
{
RemoveEffects.DamageTypesToRemove.AddItem(HealType);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//---------------------------------------------------------------------------------------
// FILE: X2Condition_RevivalProtocol.uc
// AUTHOR: Joshua Bouscher
//
//---------------------------------------------------------------------------------------
// Copyright (c) 2016 Firaxis Games, Inc. All rights reserved.
//---------------------------------------------------------------------------------------
class X2Condition_RevivalProtocol extends X2Condition;

event name CallMeetsCondition(XComGameState_BaseObject kTarget)
{
local XComGameState_Unit TargetUnit;

TargetUnit = XComGameState_Unit(kTarget);
if (TargetUnit == none)
return 'AA_NotAUnit';

if (!TargetUnit.GetMyTemplate().bCanBeRevived || TargetUnit.IsBeingCarried() )
return 'AA_UnitIsImmune';

// Issue #1235 - add IsStunned() check to allow Revival Protocol to target stunned units.
if (TargetUnit.IsPanicked() || TargetUnit.IsUnconscious() || TargetUnit.IsDisoriented() || TargetUnit.IsDazed() || TargetUnit.IsStunned())
return 'AA_Success';

return 'AA_UnitIsNotImpaired';
}

event name CallMeetsConditionWithSource(XComGameState_BaseObject kTarget, XComGameState_BaseObject kSource)
{
local XComGameState_Unit SourceUnit, TargetUnit;

SourceUnit = XComGameState_Unit(kSource);
TargetUnit = XComGameState_Unit(kTarget);

if (SourceUnit == none || TargetUnit == none)
return 'AA_NotAUnit';

// Start Issue #1235
// Replace the controlling player check with a hostility check,
// allowing Revival Protocol to target all friendly units instead of just player-controlled units.
// if (SourceUnit.ControllingPlayer == TargetUnit.ControllingPlayer)
if (SourceUnit.IsFriendlyUnit(TargetUnit))
return 'AA_Success';
// End Issue #1235

return 'AA_UnitIsHostile';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Start Issue #1235
// This condition determines whether Revival Protocol and Restoration should restore Action Points to the targeted units,
// which is necessarily different from the X2Condition_RevivialProtocol, which determines whether these abilities
// can target these units at all.
// For example, these abilities can be used to remove Disorientation, but doing so should not restore units' Action Points.
class X2Condition_RevivalProtocolRestoreAP extends X2Condition;

event name CallMeetsCondition(XComGameState_BaseObject kTarget)
{
local XComGameState_Unit TargetUnit;

TargetUnit = XComGameState_Unit(kTarget);
if (TargetUnit == none)
return 'AA_NotAUnit';

if (TargetUnit.IsPanicked() || TargetUnit.IsUnconscious() || TargetUnit.IsDazed())
{
return 'AA_Success';
}
return 'AA_UnitIsNotImpaired';
}
// End Issue #1235
6 changes: 6 additions & 0 deletions X2WOTCCommunityHighlander/X2WOTCCommunityHighlander.x2proj
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,12 @@
<Content Include="Src\XComGame\Classes\X2ChosenActionTemplate.uc">
<SubType>Content</SubType>
</Content>
<Content Include="Src\XComGame\Classes\X2Condition_RevivalProtocol.uc">
<SubType>Content</SubType>
</Content>
<Content Include="Src\XComGame\Classes\X2Condition_RevivalProtocolRestoreAP.uc">
<SubType>Content</SubType>
</Content>
<Content Include="Src\XComGame\Classes\X2Condition_StasisLanceTarget.uc">
<SubType>Content</SubType>
</Content>
Expand Down