Jump to content

Can anyone tell where I'm going wrong?


Yzaxtol

Recommended Posts

I've tried to create a new Officer/Shieldbearer that leads squads of up to 8 troopers.

 

But whenever he/she spawns he appears like this, doesn't do anything, has no stats and can't be targeted.

 

 

 

 

Does anyone know where I'm going wrong?

 

I've coped the ShieldbearerM2 Create Character Template function from X2Character_DefaultCharacters (and renamed all relevant references to AdvCommanderM2 and added the simulated Matinee function.

 

Their stats are declared in XComGameData_CharacterStats

 

I've linked code below, it easily compiles but as you can see it's not working as inteded :S

 

Any help would be greatly appreciated as I have spent nearly my entire Saturday trying to figure out where I've been going wrong :S

 

 

 

[AdvCommanderM2 X2CharacterTemplate] ; Advent Shield Bearer M2 template used
+CharacterBaseStats[eStat_AlertLevel]=2
+CharacterBaseStats[eStat_ArmorChance]=100
+CharacterBaseStats[eStat_ArmorMitigation]=3 ;+2 Armor
+CharacterBaseStats[eStat_ArmorPiercing]=0
+CharacterBaseStats[eStat_CritChance]=0
+CharacterBaseStats[eStat_Defense]=10
+CharacterBaseStats[eStat_Dodge]=0
+CharacterBaseStats[eStat_HP]=15 ;+9 Health
+CharacterBaseStats[eStat_Mobility]=12
+CharacterBaseStats[eStat_Offense]=75
+CharacterBaseStats[eStat_PsiOffense]=0
+CharacterBaseStats[eStat_ReserveActionPoints]=0
+CharacterBaseStats[eStat_SightRadius]=27
+CharacterBaseStats[eStat_DetectionRadius]=16
+CharacterBaseStats[eStat_UtilityItems]=1
+CharacterBaseStats[eStat_Will]=50
+CharacterBaseStats[eStat_HackDefense]=125
+CharacterBaseStats[eStat_FlankingCritChance]=33
+CharacterBaseStats[eStat_FlankingAimBonus]=0
+CharacterBaseStats[eStat_Strength]=50
+XpKillscore=32
+DirectXpAmount=10
+MaxCharactersPerGroup=1
+LeaderLevelSpawnWeights=(MinForceLevel=1, MaxForceLevel=20, SpawnWeight=15, MaxAlertSpawnWeight=12)
+FollowerLevelSpawnWeights=(MinForceLevel=1, MaxForceLevel=20, SpawnWeight=15, MaxAlertSpawnWeight=12)
+UntetheredLeaderLevelSpawnWeights=(MinForceLevel=1, MaxForceLevel=20, SpawnWeight=15, MaxAlertSpawnWeight=12)
+SupportedFollowers=AdvTrooperM1
+SupportedFollowers=AdvTrooperM2
+SupportedFollowers=AdvTrooperM3
+HackRewards=SKULLFeedback
+HackRewards=ALittleIntel
+HackRewards=FacilityLead
+HackRewards=ALotOfIntel

[AdvCommanderM2_Diff_1 X2CharacterTemplate]
+CharacterBaseStats[eStat_ArmorMitigation]=3

[AdvCommanderM2_Diff_2 X2CharacterTemplate]
+CharacterBaseStats[eStat_ArmorMitigation]=3

[AdvCommanderM2_Diff_3 X2CharacterTemplate]
+CharacterBaseStats[eStat_ArmorMitigation]=4 ; +1 Armour
+CharacterBaseStats[eStat_HP]=20 ;+5 Health

 

 

 

 

 

class Characters_Enemy extends X2Character config(GameData_CharacterStats);

static function array<X2DataTemplate> CreateTemplates()
{
	local array<X2DataTemplate> Templates;

	Templates.AddItem(CreateTemplate_AdvCommanderM2());
	
	return Templates;
}


static function X2CharacterTemplate CreateTemplate_AdvCommanderM2()
{
	local X2CharacterTemplate CharTemplate;
	local LootReference Loot;

	`CREATE_X2CHARACTER_TEMPLATE(CharTemplate, 'AdvCommanderM2');
	CharTemplate.CharacterGroupName = 'AdventShieldBearer';
	CharTemplate.DefaultLoadout='AdvShieldBearerM2_Loadout';
	CharTemplate.BehaviorClass=class'XGAIBehavior';
	CharTemplate.strPawnArchetypes.AddItem("GameUnit_AdvShieldBearer.ARC_GameUnit_AdvShieldBearerM2_M");
	CharTemplate.strPawnArchetypes.AddItem("GameUnit_AdvShieldBearer.ARC_GameUnit_AdvShieldBearerM2_F");
	Loot.ForceLevel=0;
	Loot.LootTableName='AdvShieldBearerM2_BaseLoot';
	CharTemplate.Loot.LootReferences.AddItem(Loot);

	// Timed Loot
	Loot.ForceLevel = 0;
	Loot.LootTableName = 'AdvShieldBearerM2_TimedLoot';
	CharTemplate.TimedLoot.LootReferences.AddItem(Loot);
	Loot.LootTableName = 'AdvShieldBearerM2_VultureLoot';
	CharTemplate.VultureLoot.LootReferences.AddItem(Loot);

	CharTemplate.strMatineePackages.AddItem("CIN_Advent");
	CharTemplate.RevealMatineePrefix = "CIN_Advent_ShieldBearer";
	CharTemplate.GetRevealMatineePrefixFn = GetAdventMatineePrefix;

	CharTemplate.UnitSize = 1;

	// Traversal Rules
	CharTemplate.bCanUse_eTraversal_Normal = true;
	CharTemplate.bCanUse_eTraversal_ClimbOver = true;
	CharTemplate.bCanUse_eTraversal_ClimbOnto = true;
	CharTemplate.bCanUse_eTraversal_ClimbLadder = true;
	CharTemplate.bCanUse_eTraversal_DropDown = true;
	CharTemplate.bCanUse_eTraversal_Grapple = false;
	CharTemplate.bCanUse_eTraversal_Landing = true;
	CharTemplate.bCanUse_eTraversal_BreakWindow = true;
	CharTemplate.bCanUse_eTraversal_KickDoor = true;
	CharTemplate.bCanUse_eTraversal_JumpUp = false;
	CharTemplate.bCanUse_eTraversal_WallClimb = false;
	CharTemplate.bCanUse_eTraversal_BreakWall = false;
	CharTemplate.bAppearanceDefinesPawn = false;    
	CharTemplate.bSetGenderAlways = true;
	CharTemplate.bCanTakeCover = true;

	CharTemplate.bIsAlien = false;
	CharTemplate.bIsAdvent = true;
	CharTemplate.bIsCivilian = false;
	CharTemplate.bIsPsionic = false;
	CharTemplate.bIsRobotic = false;
	CharTemplate.bIsSoldier = false;

	CharTemplate.bCanBeTerrorist = false;
	CharTemplate.bCanBeCriticallyWounded = false;
	CharTemplate.bIsAfraidOfFire = true;

	CharTemplate.Abilities.AddItem('EnergyShield');

	CharTemplate.SightedNarrativeMoments.AddItem(XComNarrativeMoment'X2NarrativeMoments.TACTICAL.AlienSitings.T_Central_AlienSightings_AdvShieldBearerM2');

	CharTemplate.AddTemplateAvailablility(CharTemplate.BITFIELD_GAMEAREA_Multiplayer); // Allow in MP!
	CharTemplate.MPPointValue = CharTemplate.XpKillscore * 10;

	CharTemplate.strHackIconImage = "UILibrary_Common.TargetIcons.Hack_captain_icon";
	CharTemplate.strTargetIconImage = class'UIUtilities_Image'.const.TargetIcon_Advent;

	return CharTemplate;
}


simulated function string GetAdventMatineePrefix(XComGameState_Unit UnitState)
{
	if(UnitState.kAppearance.iGender == eGender_Male)
	{
		return UnitState.GetMyTemplate().RevealMatineePrefix $ "_Male";
	}
	else
	{
		return UnitState.GetMyTemplate().RevealMatineePrefix $ "_Female";
	}
}

 

 

 

Link to comment
Share on other sites

I don't know the answer, but slightly offtopic ...

 

AFAIK this forum has a bigger audience than r/xcom2mods. I am certain it has a larger audience than the 2k forum based on post+thread count.

 

At reddit, how can you see new posts in old threads? When you use /new, it sorts by thread start date, but you cannot tell if older threads have new posts.

 

At reddit, is there a way to see the total number of posts (threads plus comments) in a subreddit? Nexus modding has 410 threads and 1520 posts as of just now, for example.

Link to comment
Share on other sites

Finally got it working, it was all due to the Difficulty modifiers having the exact same stat as the default unit. :S

 

Once those removed it all started working.

 

2 DAYS i've spent trying to figure which advanced piece of code I was missing or what i've mispelt :S *cries in mixture of anguish and happiness*

Link to comment
Share on other sites

Here's a very important lesson to remember (anyone) -- never give up...

 

But please do it in a logical way, patiently, after a good mighty night sleep, pick your poison--i prefer coffee.. and then, Let's GO!!! :D

 

95% of ANY success is the result of frontal lobe plus occipital sweat and tears & at times, plain elbow grease -- 5% is pure talent or/and/if/else/then coincidental brainy skills.

Link to comment
Share on other sites

OK scratch that,

 

 

APPARENTLY the problem has come from the fact that EVERY stat has to be declared in each difficulty variation for some reason with new characters, and the reason originally why my new Advent Commander was standing around like a scarecrow was that his health wasn't declared. I'm assuming I've either done something wrong to require declaring each difficulty or the other mods that have done that have only tested it on the basic difficulties (or not at all).

 

My money is on that i've done something wrong because there's like 8 mods out there with new enemies (and Amineri is like a programmer god)

 

And I'm halfway through a full overhaul mod so, there's that too.

Link to comment
Share on other sites

Yes, I've had that problem, too. Not only HP, but maximum action points per turn are configured stats. So if you don't set the difficulty variant stats, you end up with a unit with 0 HP, 0 Action points, and 0 visibility range. :smile:

 

The "trick" is that the game automatically creates three new templates, appended with the difficulty. So for the Muton Centurion (which I used the name 'MutonM2'), the difficulty variant code automatically creates 4 difficulty variant templates called 'MutonM2_Diff_0', 'MutonM2_Diff_1', 'MutonM2_Diff_2', 'MutonM2_Diff_3'. This happens in X2DataSet.CreateDifficultyVariantsForTemplate :

for( DifficultyIndex = `MIN_DIFFICULTY_INDEX; DifficultyIndex <= `MAX_DIFFICULTY_INDEX; ++DifficultyIndex )
{
    NewTemplateName = BaseTemplate.DataName $ "_Diff_" $ DifficultyIndex;
    NewTemplate = new(None, NewTemplateName) BaseTemplate.Class (BaseTemplate);
    NewTemplate.SetDifficulty(DifficultyIndex);
    NewTemplates.AddItem(NewTemplate);
} 

What's really fun is that you can't actually directly access these difficulty variants -- instead, the native code looks up the current difficulty and retrieves the one for the current difficulty. So when you request 'MutonM2' template, you get one of the difficulty variants, based on the difficulty setting in the CampaignSettings.

 

However, to configure the difficulty variants isn't too tough :

 

 

;;; DIFFICULTY VARIATIONS
 
[MutonM2_Diff_1 X2CharacterTemplate]
+CharacterBaseStats[eStat_ArmorChance]=100
+CharacterBaseStats[eStat_ArmorMitigation]=0
+CharacterBaseStats[eStat_HP]=8
+CharacterBaseStats[eStat_Mobility]=12
+CharacterBaseStats[eStat_Offense]=80
+CharacterBaseStats[eStat_CritChance]=10
+CharacterBaseStats[eStat_Defense]=0
+CharacterBaseStats[eStat_DetectionRadius]=12
+CharacterBaseStats[eStat_FlankingCritChance]=33
+CharacterBaseStats[eStat_FlankingAimBonus]=0
 
[MutonM2_Diff_2 X2CharacterTemplate]
+CharacterBaseStats[eStat_ArmorChance]=100
+CharacterBaseStats[eStat_ArmorMitigation]=0
+CharacterBaseStats[eStat_HP]=10 
+CharacterBaseStats[eStat_Defense]=10
+CharacterBaseStats[eStat_Mobility]=12
+CharacterBaseStats[eStat_Offense]=85
+CharacterBaseStats[eStat_CritChance]=10
+CharacterBaseStats[eStat_DetectionRadius]=12
+CharacterBaseStats[eStat_Will]=50
+CharacterBaseStats[eStat_FlankingCritChance]=40
+CharacterBaseStats[eStat_FlankingAimBonus]=0
 
[MutonM2_Diff_3 X2CharacterTemplate]
+CharacterBaseStats[eStat_ArmorChance]=100
+CharacterBaseStats[eStat_ArmorMitigation]=0
+CharacterBaseStats[eStat_HP]=10
+CharacterBaseStats[eStat_Defense]=10
+CharacterBaseStats[eStat_Mobility]=12
+CharacterBaseStats[eStat_Offense]=85
+CharacterBaseStats[eStat_CritChance]=10
+CharacterBaseStats[eStat_DetectionRadius]=12
+CharacterBaseStats[eStat_Will]=50
+CharacterBaseStats[eStat_FlankingCritChance]=40
+CharacterBaseStats[eStat_FlankingAimBonus]=0

Note that you don't have to fully specify every change from the base, only what's different. Each variant should be starting off based on the default stats. Note that the above doesn't change anything for Diff_0 (Rookie/Easy).
The base stats have to be specified in the "base" template name, that is in :

[MutonM2 X2CharacterTemplate]
+CharacterBaseStats[eStat_ActionPoints]=2
+CharacterBaseStats[eStat_AlertLevel]=2
+CharacterBaseStats[eStat_ArmorChance]=100
+CharacterBaseStats[eStat_ArmorMitigation]=2 ; +1 compared to muton
+CharacterBaseStats[eStat_ArmorPiercing]=1 ; +1 compared to muton
+CharacterBaseStats[eStat_CritChance]=0
+CharacterBaseStats[eStat_Defense]=10
+CharacterBaseStats[eStat_Dodge]=0
+CharacterBaseStats[eStat_HP]=12 ; + 4 compared to muton
+CharacterBaseStats[eStat_Mobility]=12
+CharacterBaseStats[eStat_Offense]=75
+CharacterBaseStats[eStat_PsiOffense]=0
+CharacterBaseStats[eStat_ReserveActionPoints]=0
+CharacterBaseStats[eStat_SightRadius]=27
+CharacterBaseStats[eStat_DetectionRadius]=12
+CharacterBaseStats[eStat_UtilityItems]=1
+CharacterBaseStats[eStat_Will]=50
+CharacterBaseStats[eStat_HackDefense]=0
+CharacterBaseStats[eStat_FlankingCritChance]=33
+CharacterBaseStats[eStat_Strength]=100
...
...

 

Link to comment
Share on other sites

Bear in mind I did 95% of my testing by Forcing the Gatecrasher mission to spawn a commander in the first patrol on Commander Difficulty

 

[AdvCommanderM2_Diff_2 X2CharacterTemplate]
+CharacterBaseStats[eStat_ArmorMitigation]=3

 

This was where I started for 2 days of spawning scarecrows, I then swapped to +CharacterBaseStats[eStat_HP]=20 that spawned the unit with no armour.

 

I then proceeded to add the HP and armour to each difficulty (with different value) which then spawned a unit that had HP and Armour but did nothing. After checking the AI configs extensively using 3 different re-writes I then tested the unit with +50 defense in the core base stats and tried again. It wasn't there on the mission. I then copied the entire stat file over all difficulty and BLAMMO I now had a Commander with 8 Troopers that was Shielding and Marking Targets.

 

Edit: Yup that is exactly what I've called the file, I had been using it to add extra armour to all advent previously before trying to create a new unit, and then after experiencing difficulties removed all the code to a safe place as I proceeded to test the config file, over and over and over and over and over....

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...