Skip to content

Commit 4195a76

Browse files
committed
Fix X2AllowSelectAll
1 parent 350754a commit 4195a76

File tree

7 files changed

+71
-13
lines changed

7 files changed

+71
-13
lines changed

X2WOTCCommunityHighlander/Config/XComGame.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,3 +321,10 @@ InterruptionsUpdateTurnStartLocation = false ; Should interruptions update tur
321321
InterruptionsResetPanicTestsPerformedThisTurn = false ; Should interruptions reset the tracker for the amount of panic tests performed this turn, just like a normal turn? Default is false, because the unit isn't taking a typical turn.
322322
InterruptionsTriggerGroupTurnBegunEvent = true ; Should interruptions trigger the GroupTurnBegunEvent, just like what happens in a normal turn. Default is true, because interruptions work closely with "groups" (XComGameState_AIGroup) in the code side of things.
323323
; End Issue #1325
324+
325+
; Start Issue #1486
326+
;Uncomment to exclude civilians from being selected in the X2AllowSelectAll Console Command
327+
;ExcludeCiviliansFromX2AllowSelectAll = true
328+
;Uncomment to alert & scamper all aliens when using X2AllowSelectAll - allows all alien units to move normally
329+
;UseImprovedX2AllowSelectAllBehavior = true
330+
; End Issue #1486

X2WOTCCommunityHighlander/Src/XComGame/Classes/CHHelpers.uc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,19 @@ var config bool bDisableAutomaticPromotionPhoto;
286286
var config bool bDisableAutomaticBondPhoto;
287287
// End Issue #1453
288288

289+
// Start Issue #1486
290+
/// HL-Docs: ref:Bugfixes; issue:1486
291+
/// This set of changes fixes seveal issues with the behavior of the debugging console command X2AllowSelectAll - in particular:
292+
/// 1. With the command active, when selecting units non on the XCom team, the camera would not pan to those units
293+
/// 2. When carrying out other debug commands on non-XCom units (e.g. grantactionpoints), the camera would pan back to the first active unit on the player team
294+
/// 3. Turns which were ended while the command was active would not be processed properly
295+
/// 4. Non-XCom units would not move correctly when the command was issued due to XCom not being considered visible (game resorts to AI-like patrol behavior)
296+
/// All of these are now fixed in a minimally invasive way by gating small setions of basegame code when the command is active and will have no effect otherwise
297+
/// Disabling selection of civilians & 'Improved Behavior' (scamper & alert all aliens) are also provided as optional flags to improve the overall experience.
298+
var config bool ExcludeCiviliansFromX2AllowSelectAll;
299+
var config bool UseImprovedX2AllowSelectAllBehavior;
300+
// End Issue #1486
301+
289302
// Start Issue #885
290303
enum EHLDelegateReturn
291304
{

X2WOTCCommunityHighlander/Src/XComGame/Classes/X2Camera_FollowMouseCursor.uc

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,12 @@ function Activated(TPOV CurrentPOV, X2Camera PreviousActiveCamera, X2Camera_Look
6565
{
6666
History = `XCOMHISTORY;
6767
ActiveUnit = XComGameState_Unit(History.GetGameStateForObjectID(LocalController.GetActiveUnitStateRef().ObjectID));
68+
// Begin Issue #1486 - Allow the default camera to pan to units owned by the AI when the X2AllowSelectAll command is used
6869
if(ActiveUnit != none
69-
&& !ActiveUnit.ControllingPlayerIsAI()
70-
&& ActiveUnit.ControllingPlayer == GetActivePlayer())
70+
&& ((!ActiveUnit.ControllingPlayerIsAI()
71+
&& ActiveUnit.ControllingPlayer == GetActivePlayer())
72+
|| (`CHEATMGR != None && `CHEATMGR.bAllowSelectAll)))
73+
// End Issue #1486
7174
{
7275
CenterOnUnitIfOffscreen(ActiveUnit);
7376
}
@@ -113,9 +116,12 @@ function EventListenerReturn OnCameraFocusUnit(Object EventData, Object EventSou
113116
{
114117
History = `XCOMHISTORY;
115118
ActiveUnit = XComGameState_Unit(History.GetGameStateForObjectID(LocalController.GetActiveUnitStateRef().ObjectID));
119+
// Begin Issue #1486 - Allow the default camera to pan to units owned by the AI when the X2AllowSelectAll command is used
116120
if(ActiveUnit != none
117-
&& !ActiveUnit.ControllingPlayerIsAI()
118-
&& ActiveUnit.ControllingPlayer == GetActivePlayer())
121+
&& ((!ActiveUnit.ControllingPlayerIsAI()
122+
&& ActiveUnit.ControllingPlayer == GetActivePlayer())
123+
|| (`CHEATMGR != None && `CHEATMGR.bAllowSelectAll)))
124+
// End Issue #1486
119125
{
120126
CenterOnUnitIfOffscreen(ActiveUnit);
121127
}
@@ -310,8 +316,8 @@ event OnActiveUnitChanged(XComGameState_Unit NewActiveUnit)
310316
super.OnActiveUnitChanged(NewActiveUnit);
311317

312318
MoveAbilitySubmitted = false;
313-
314-
if( NewActiveUnit.IsPlayerControlled() )
319+
// Single Line for Issue #1486 - Allow the camera to focus on non-player controlled units when X2AllowSelectAll is used
320+
if( NewActiveUnit.IsPlayerControlled() || (`CHEATMGR != None && `CHEATMGR.bAllowSelectAll))
315321
{
316322
CenterOnUnitIfOffscreen(NewActiveUnit);
317323
LastPlayerControlledUnit = NewActiveUnit;
@@ -429,7 +435,12 @@ function EventListenerReturn OnAbilityActivated(Object EventData, Object EventSo
429435
if (AbilityContext.InputContext.AbilityTemplateName == 'StandardMove')
430436
{
431437
UnitState = XComGameState_Unit(`XCOMHISTORY.GetGameStateForObjectID(AbilityContext.InputContext.SourceObject.ObjectID));
432-
if (UnitState != none && !UnitState.ControllingPlayerIsAI() && UnitState.ControllingPlayer == GetActivePlayer())
438+
// Begin Issue #1486 - Allow the default camera to pan to units owned by the AI when the X2AllowSelectAll command is used
439+
if (UnitState != none
440+
&& ((!UnitState.ControllingPlayerIsAI()
441+
&& UnitState.ControllingPlayer == GetActivePlayer())
442+
|| (`CHEATMGR != None && `CHEATMGR.bAllowSelectAll)))
443+
// End Issue #1486
433444
{
434445
// A move action was just submitted, will cause disabling of focuspointexpiry so building vis doesnt fluctuate
435446
//while we are waiting for the camera to switch to the follow moving unit camera

X2WOTCCommunityHighlander/Src/XComGame/Classes/X2TacticalGameRuleset.uc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5059,8 +5059,11 @@ simulated state TurnPhase_UnitActions
50595059
if( bActionsAvailable )
50605060
{
50615061
bWaitingForNewStates = true; //If there are actions available, indicate that we are waiting for a decision on which one to take
5062-
5063-
if( !UnitActionPlayerIsRemote() )
5062+
// Single Line for Issue #1486 - When using X2AllowSelectAll, we need to bypass the reselection of the player visualizer when
5063+
// a new gamestate is submitted but the unit we're controlling (which may not belong to us) still has actions left -
5064+
// this prevents the game from 'tabbing away' from units which are not on our team but which we may still may be controlling.
5065+
// This is most obvious when issuing debug commands such as ttc / giveactionpoints
5066+
if( !UnitActionPlayerIsRemote() && (`CHEATMGR == none || !`CHEATMGR.bAllowSelectAll))
50645067
{
50655068
PlayerState = XComGameState_Player(CachedHistory.GetGameStateForObjectID(UnitState.ControllingPlayer.ObjectID));
50665069
`assert(PlayerState != none);

X2WOTCCommunityHighlander/Src/XComGame/Classes/XComTacticalCheatManager.uc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3949,10 +3949,22 @@ exec function X2AllowSelectAll(bool bSetting)
39493949
if( bSetting && `XWORLD.bDebugEnableFOW )
39503950
{
39513951
ToggleFOW();
3952+
// Begin Issue #1486 - Force visibility to allow proper pathing of alien units
3953+
// (They will still walk if not activated / alerted)
3954+
ForceAllUnitsVisible = true;
3955+
// Improved functionality alerts and scampers, breaking the default patrol mechanics and allowing the units to move normally
3956+
if(class'CHHelpers'.default.UseImprovedX2AllowSelectAllBehavior == true)
3957+
{
3958+
ToggleIndividualConcealment();
3959+
X2DebugPodReveals();
3960+
}
3961+
// End Issue #1486
39523962
}
39533963
else if ( bSetting && !`XWORLD.bDebugEnableFOW )
39543964
{
39553965
ToggleFOW();
3966+
// Single Line for Isuee #1486 - Turn off forced visibility if we're also turning the FOW back on
3967+
ForceAllUnitsVisible = false;
39563968
}
39573969

39583970
//Force all units to be visible

X2WOTCCommunityHighlander/Src/XComGame/Classes/XComTacticalController.uc

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -574,9 +574,15 @@ simulated function bool Visualizer_CycleToNextAvailableUnit(int Direction)
574574
// Force all units to be selectable regardless of action points, if AllowSelectAll is on.
575575
if ((`CHEATMGR != None && `CHEATMGR.bAllowSelectAll))
576576
{
577-
bActionsAvailable = true;
577+
if(class'CHHelpers'.default.ExcludeCiviliansFromX2AllowSelectall && SelectNewUnit.GetTeam() == eTeam_Neutral)
578+
{
579+
bActionsAvailable = false;
580+
}
581+
else
582+
{
583+
bActionsAvailable = true;
584+
}
578585
}
579-
580586
if( bActionsAvailable && Visualizer_SelectUnit(SelectNewUnit) )
581587
{
582588
return true;
@@ -1373,7 +1379,12 @@ function bool GameStateMoveUnit(XGUnit kUnit,
13731379
// ---------------------------------------------------------------------
13741380
simulated function bool PerformEndTurn(EPlayerEndTurnType eEndTurnType)
13751381
{
1376-
// Aural feedback for player input
1382+
// Single Line for Issue #1486 - When ending the turn, switch off bAllowSelectAll to allow the AI to process the alien turn normally
1383+
// This maintains the previous FOW and Unit Visibility selections from X2AllowSelectAll
1384+
`CHEATMGR.bAllowSelectAll = false;
1385+
1386+
// Aural feedback for player input
1387+
13771388
if(eEndTurnType == ePlayerEndTurnType_PlayerInput)
13781389
{
13791390
PlaySound(SoundCue'SoundUI.PositiveUISelctionCue', true, true);

X2WOTCCommunityHighlander/Src/XComGame/Classes/XComTacticalInput.uc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2884,7 +2884,8 @@ state ActiveUnit_Moving
28842884

28852885
bChangeUnitSuccess = false;
28862886
bHandled = false;
2887-
if( XComTacticalController(Outer).m_XGPlayer.m_eTeam == kTargetedUnit.m_eTeam )
2887+
// Single Line for Issue #1486 - Left click now allows selection of units that don't belong to the player when X2AllowSelectAll is used
2888+
if( XComTacticalController(Outer).m_XGPlayer.m_eTeam == kTargetedUnit.m_eTeam || (`CHEATMGR != none && `CHEATMGR.bAllowSelectAll))
28882889
{
28892890
//`log("Want to target: " $ kTargetedUnit.GetHumanReadableName(),,'uixcom');
28902891

0 commit comments

Comments
 (0)