Page 1 of 1

Re-enabling same-class AWC perks

Posted: Mon Jul 17, 2017 6:13 pm
by Artigo
Hi everyone.

Question is pretty straightforward. In previous versions you could get perks from your same class causing the ability to double up in perks, however that has been fixed as of 1.4.

However, I'm wanting to re-enable this option for certain classes. Editing config/text markup files is easy to do, but I'm unfamiliar with XCOM's logic file format. I'm assuming that is where class restrictions are handled and would need to be unpacked in order to make a change of this type.

Is this possible? If so could someone point me in the right direction?

Thank you all

Re: Re-enabling same-class AWC perks

Posted: Thu Jul 20, 2017 12:46 am
by tracktwo
This isn't something that's exposed by the .ini, unfortunately, it's encoded in the the sources. See GetValidAWCAbilitiesForUnit in LWAWCUtilities.uc:

Code: Select all

		if(HasClassAbility(UnitState, PossibleAbility.AbilityName))
			continue;
You could potentially mod this by providing a class override for XComGameState_Unit_AWC_LW and overriding ChooseSoldierAWCOption.

Re: Re-enabling same-class AWC perks

Posted: Thu Jul 20, 2017 1:25 pm
by Artigo
tracktwo wrote:This isn't something that's exposed by the .ini, unfortunately, it's encoded in the the sources. See GetValidAWCAbilitiesForUnit in LWAWCUtilities.uc:

Code: Select all

		if(HasClassAbility(UnitState, PossibleAbility.AbilityName))
			continue;
You could potentially mod this by providing a class override for XComGameState_Unit_AWC_LW and overriding ChooseSoldierAWCOption.
Tracktwo, thank you very much for the reply.

I will give this a try when I get home from work.

Re: Re-enabling same-class AWC perks

Posted: Thu Jul 27, 2017 4:55 pm
by Artigo
tracktwo wrote:This isn't something that's exposed by the .ini, unfortunately, it's encoded in the the sources. See

Code: Select all

		if(HasClassAbility(UnitState, PossibleAbility.AbilityName))
			continue;
Tracktwo,

heres the solution I've come up with

LWAWCUtilities_Revamp

Code: Select all

class LWAWCUtilities_Revamp extends LWAWCUtilities config(LW_AWCPack_Revamp);

function static array<ClassAgnosticAbility> GetValidAWCAbilitiesForUnitNew(XComGameState_Unit UnitState, array<AWCAbilityConfig> SourceAbilities, int AWCLevel, optional XComGameState_Unit_AWC_LW AWCComponent)
{
	local array<ClassAgnosticAbility> Abilities;
	local ClassAgnosticAbility NewAbility;
	local AWCAbilityConfig PossibleAbility;
    local X2AbilityTemplateManager AbilityTemplateManager;
	local X2AbilityTemplate AbilityTemplate;
    
	if (AWCComponent == none)
	{
		AWCComponent = GetAWCComponent(UnitState); // retrieve from history if it wasn't passed
	}

	AbilityTemplateManager = class'X2AbilityTemplateManager'.static.GetAbilityTemplateManager();

	foreach SourceAbilities(PossibleAbility)
	{
		AbilityTemplate = AbilityTemplateManager.FindAbilityTemplate(PossibleAbility.AbilityName);
		if (AbilityTemplate == none)
			continue;

		if(PossibleAbility.Level != AWCLevel)
			continue;

		if(RestrictedAbility(UnitState, AWCComponent, PossibleAbility.AbilityName))
			continue;

		//if(HasClassAbility(UnitState, PossibleAbility.AbilityName))
			//continue;

        if (HasEarnedAbility(UnitState, PossibleAbility.AbilityName))
            continue;

		if(AWCComponent != none && AWCComponent.HasAWCAbility(UnitState, PossibleAbility.AbilityName))
			continue;

		NewAbility.iRank = PossibleAbility.Level;
		NewAbility.bUnlocked = false;
		NewAbility.AbilityType.AbilityName = PossibleAbility.AbilityName;
		NewAbility.AbilityType.ApplyToWeaponSlot = PossibleAbility.ApplyToWeaponSlot;
		NewAbility.AbilityType.UtilityCat = PossibleAbility.UtilityCat;
		Abilities.AddItem(NewAbility);
	}
	return Abilities;
} 

Code: Select all


function ClassAgnosticAbility ChooseSoldierAWCOption(XComGameState_Unit UnitState, const int idx, const AWCTrainingType Option)
{
	local ClassAgnosticAbility EmptyAbility, NewAbility;
	local array<ClassAgnosticAbility> PossibleAbilities;

	switch (Option)
	{
		case AWCTT_Offense:
			PossibleAbilities = GetValidAWCAbilitiesNew(class'LWAWCUtilities'.default.AWCAbilityTree_Offense, idx + 1);
			NewAbility = PossibleAbilities[`SYNC_RAND(PossibleAbilities.Length)];
			break;
		case AWCTT_Defense:
			PossibleAbilities = GetValidAWCAbilitiesNew(class'LWAWCUtilities'.default.AWCAbilityTree_Defense, idx + 1);
			NewAbility = PossibleAbilities[`SYNC_RAND(PossibleAbilities.Length)];
			break;
		case AWCTT_Pistol:
			PossibleAbilities = WeightedSort(class'LWAWCUtilities'.default.AWCAbilityTree_Pistol);
			NewAbility = PossibleAbilities[Min(idx, PossibleAbilities.Length)];
			break;
		default:
			NewAbility = EmptyAbility;
			break;
	}
	return NewAbility;
}

function array<ClassAgnosticAbility> GetValidAWCAbilitiesNew(array<AWCAbilityConfig> SourceAbilities, int AWCLevel)
{
    return class'LWAWCUtilities_Revamp'.static.GetValidAWCAbilitiesForUnitNew(GetUnit(), SourceAbilities, AWCLevel, self);
}

My thought process was essentially just override the ChooseSoldierAWCOption and the GetValidAWCAbilities functions. Additionally, commenting out that line in LWAWCUtilities.