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

Faction Heroes are created without an origin country #1140

Closed
Iridar opened this issue Apr 3, 2022 · 1 comment · Fixed by #1141 or #1186
Closed

Faction Heroes are created without an origin country #1140

Iridar opened this issue Apr 3, 2022 · 1 comment · Fixed by #1141 or #1186
Assignees

Comments

@Iridar
Copy link
Contributor

Iridar commented Apr 3, 2022

The Problem

Without Highlander, Reapers and Templars roll a random country for the purposes of name and biography, just like for regular soldiers, and then their country gets overridden to their faction countries for the sake of country flag.

With Highlander, Reapers and Templars are generated with their faction countries right away, so their names default to USA names, and their biography is missing a country name entirely, presumably because their faction countries do not have a localized name.

The Suspect

#783 added faction hero XGCharacterGenerator classes into Highlander, and adjusted their logic slightly so that the new DLC hook, ModifyGeneratedUnitAppearance, can work more consistently.

For example, for Reapers, the following code:

function TSoldier CreateTSoldier(optional name CharacterTemplateName, optional EGender eForceGender, optional name nmCountry = '', optional int iRace = -1, optional name ArmorName)
{
	local X2SoldierClassTemplateManager ClassMgr;
	local X2SoldierClassTemplate ClassTemplate;

	kSoldier = super.CreateTSoldier('ReaperSoldier', eForceGender, nmCountry, iRace, ArmorName);
	SetCountry('Country_Reaper');
	ClassMgr = class'X2SoldierClassTemplateManager'.static.GetSoldierClassTemplateManager();
	ClassTemplate = ClassMgr.FindSoldierClassTemplate('Reaper');
	kSoldier.strNickName = GenerateNickname(ClassTemplate, kSoldier.kAppearance.iGender);

	return kSoldier;
}

was replaced with

function TSoldier CreateTSoldier(optional name CharacterTemplateName, optional EGender eForceGender, optional name nmCountry = '', optional int iRace = -1, optional name ArmorName)
{
	kSoldier = super.CreateTSoldier('ReaperSoldier', eForceGender, nmCountry, iRace, ArmorName);
	return kSoldier;
}

The overall idea of the refactor was to move calling super.CreateTSoldier() to the very end of the function, so that ModifyGeneratedUnitAppearance, which is called at the very end of XGCharacterGenerator::CreateTSoldier(), has the final say on the properties of the generated soldier.

This had the assumption that super.CreateTSoldier() would call SetCountry(), which in the case of Reaper character generator was changed to:

function SetCountry(name nmCountry)
{
	kSoldier.nmCountry = 'Country_Reaper';
	kSoldier.kAppearance.nmFlag = kSoldier.nmCountry; // needs to be copied here for pawns -- jboswell
}

This assumption has missed the fact that XGCharacterGenerator::CreateTSoldier() sets BioCountryName = kSoldier.nmCountry;, which at that time and place would be the randomly generated country.

The original XGCharacterGenerator_Reaper::CreateTSoldier() would override kSoldier.nmCountry later, but it would not affect the BioCountryName.

With the Highlander changes, the BioCountryName is set to faction country, creating the problem.

@Iridar Iridar self-assigned this Apr 3, 2022
Iridar added a commit to Iridar/X2WOTCCommunityHighlander that referenced this issue Apr 3, 2022
Iridar added a commit that referenced this issue May 21, 2023
Iridar pushed a commit that referenced this issue May 21, 2023
…n heroes default to USA names"

This reverts commit 025aa11.
@Iridar
Copy link
Contributor Author

Iridar commented May 21, 2023

The merged PR turned out to be buggy, reopening.

@Iridar Iridar reopened this May 21, 2023
Iridar added a commit to Iridar/X2WOTCCommunityHighlander that referenced this issue May 21, 2023
Iridar pushed a commit to Iridar/X2WOTCCommunityHighlander that referenced this issue May 21, 2023
Iridar pushed a commit to Iridar/X2WOTCCommunityHighlander that referenced this issue May 21, 2023
Iridar pushed a commit to Iridar/X2WOTCCommunityHighlander that referenced this issue May 21, 2023
Iridar pushed a commit to Iridar/X2WOTCCommunityHighlander that referenced this issue May 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant