[LW2] Is it possible to add/remove a soldier ability during tactical play?

Dev Help

The context here are the 3 PurePassive abilities that LW2 adds that control when a overwatch shot can trigger:

  • FireControl25
  • FireControl50
  • FireControl75

Those are checked on X2Condition_RequiredToHitChance using the following code:

	if (AttackingUnit.HasSoldierAbility('FireControl25'))
		FinalMinimumRequiredHitChance = LowAbilityMinimumRequiredHitChance;
	if (AttackingUnit.HasSoldierAbility('FireControl50'))
		FinalMinimumRequiredHitChance = MidAbilityMinimumRequiredHitChance;
	if (AttackingUnit.HasSoldierAbility('FireControl75'))
		FinalMinimumRequiredHitChance = HighAbilityMinimumRequiredHitChance;

Now, if that was an effect, it would be possible to deliver on the request that's so commonly made about being able to control which one is used during tactical play. As they are abilities, I don't think it's possible to add/remove them on the tactical layer, but I thought I would ask anyway, maybe someone smarter than me has an idea.

To deliver on the original request of just moving them out of PCS, I think it should be possible to create weapon upgrades that add those abilities, but what I really want to add is a free ability that allows the player to switch between the 3 options on the fly. On that note, is it possible to modify the ability text/icon after tactical play has begun? or is it fixed?

Posted Feb 14, 2017, 1:37 PM UTC

22
SockPunk•

It's most likely possible with a screenlistener. Here's a snippet from a console command that adds abilities at tactics time. Best I can offer, I don't know a whole lot of scripting.

	ItemRef = NewUnit.GetItemInSlot(Slot).GetReference();

	AbilityTemplate = AbilityTemplateMan.FindAbilityTemplate(AbilityName);
	AbilityRef = `TACTICALRULES.InitAbilityForUnit(AbilityTemplate, NewUnit, NewGameState, ItemRef);
	NewAbility = XComGameState_Ability(NewGameState.GetGameStateForObjectID(AbilityRef.ObjectID));
	NewAbility.CheckForPostBeginPlayActivation();
1
SentenryuOP•

Since posting this, I noticed that a suggestion from robojumper on another question of mine might be used to produce something like this: https://www.reddit.com/r/xcom2mods/comments/5tu4ud/is_there_any_actual_reason_secondary_weapons_dont/

Your example made me think about how hack rewards can grant you run'n'gun, I'll take a look on that too.

1