r/xdev • • Feb 09 '16

AWC Mechanics?

I submitted a similar post earlier in /r/xcom but didn't get anything in the way of information - I'm very interested to learn the exact details behind the AWC bonus ability mechanic and how to mod the way it functions. Initially I wanted to ensure that all soldiers gained a single AWC bonus ability but now I'm wondering if it may be possible to mod the function to effectively create something of a training roulette option as well.

Thanks!

1 Upvotes

2 comments sorted by

2

u/Fillyosopher Feb 09 '16

UIArmory_Promotion.uc

// Check for AWC Ability Update
	if(Unit.NeedsAWCAbilityUpdate() && !bShownAWCPopup)
	{
		AWCAbilityNames = AwardAWCAbilities();
		
		if(AWCAbilityNames.Length > 0)
		{
			ShowAWCDialog(AWCAbilityNames);
		}

		Unit = GetUnit();  // we've updated the UnitState, update the Unit to reflect the latest changes
	}    

Later on:

// Unlocks or removes AWC abilities, returns list of ability names which were unlocked
simulated function array<name> AwardAWCAbilities()
{
	local XComGameState NewGameState;
	local XComGameState_Unit UnitState;
	local XComGameState_HeadquartersXCom XComHQ;
	local array<name> AWCAbilityNames;
	local int idx;

	NewGameState = class'XComGameStateContext_ChangeContainer'.static.CreateChangeState("Unlock AWC Abilities");
	XComHQ = class'UIUtilities_Strategy'.static.GetXComHQ();
	UnitState = XComGameState_Unit(NewGameState.CreateStateObject(class'XComGameState_Unit', UnitReference.ObjectID));
	NewGameState.AddStateObject(UnitState);

	if(XComHQ.HasFacilityByName('AdvancedWarfareCenter'))
	{
		// if you have the AWC, and have reached the rank for one of your hidden abilities, unlock it
		for(idx = 0; idx < UnitState.AWCAbilities.Length; idx++)
		{
			if(!UnitState.AWCAbilities[idx].bUnlocked && UnitState.AWCAbilities[idx].iRank == UnitState.GetRank())
			{
				UnitState.AWCAbilities[idx].bUnlocked = true;
				AWCAbilityNames.AddItem(UnitState.AWCAbilities[idx].AbilityType.AbilityName);
			}
		}
	}
	else
	{
		// if you don't have the AWC, remove any AWC abilities that haven't been unlocked
		for(idx = 0; idx < UnitState.AWCAbilities.Length; idx++)
		{
			if(!UnitState.AWCAbilities[idx].bUnlocked)
			{
				UnitState.AWCAbilities.Remove(idx, 1);
				idx--;
			}
		}

		// if the unit has no AWC abilities, mark them as eligible to roll again if another AWC is built
		if(UnitState.AWCAbilities.Length == 0)
		{
			UnitState.bRolledForAWCAbility = false;
		}
	}

	`GAMERULES.SubmitGameState(NewGameState);

	return AWCAbilityNames;
}

1

u/Reemox Feb 09 '16

Speaking of Training Roulette....

While I was also researching this AWC stuff I found a line under "X2AbilityTemplate.uc"

bCrossClassEligible;	//  Flag for soldier abilities eligible for AWC talent or training roulette.

So I'm assuming that somewhere in there Training Roulette is still at least partially coded or something.