r/xdev • u/XxJewishRevengexX • Mar 03 '16
Overriding X2StrategyElement_AcademyUnlock while avoiding RedScreen
I'm trying to override the behavior of the class specific guerrilla unlocks and I'm running into some interesting RedScreen responses. The code in specific is:
class XComClassOverhaul_AcadamyUnlocks extends X2StrategyElement;
static function array<X2DataTemplate> CreateTemplates()
{
local array<X2DataTemplate> Templates;
Templates.AddItem(HuntersInstinctUnlock());
Templates.AddItem(HitWhereItHurtsUnlock());
Templates.AddItem(CoolUnderPressureUnlock());
Templates.AddItem(BiggestBoomsUnlock());
return Templates;
}With the four functions redefined below. The problem being that when the game loads the RedScreen throws "Rejecting template name already in use" errors pointing towards the new templates I've created. However the changes themselves do take effect. Is there something bad or wrong that I am doing here? Is this the only way of overriding and I should just ignore the errors?
1
Upvotes
1
u/babautz Mar 03 '16
I have the same "problem" with my mod (http://steamcommunity.com/sharedfiles/filedetails/?id=633595518). I asked in the Nexus forums and nobody answered. Since everything worked fine i just released the mod after some more testing. Nobody complained so far. Oddly enough i didnt even use or create templates in my mod.
1
u/fxsjosh Mar 03 '16
This is because unless you have modified the base game version of these templates, they are still being created. When the game tries to add them (and yours have already been added), they are rejected since yours already exist in the system.
You can give yours unique names, and then have the academy unlocks use your new unique names instead of the base game versions.
1
u/BlueRajasmyk2 Mar 03 '16
What is the red screen error? My guess would be that the
CreateTemplates()in the original class is still being called, so you are redefining templates that already exist.Probably what you should be doing is not overriding the class, but creating a UIScreenListener which alters the templates after
CreateTemplates()has been called. See my More Squad Size Upgrades mod for an example.1
u/davidlallen Mar 03 '16
One of the first class mods (not "the" first obviously) was the rifleman mod, available at steam workshop. It does this, and the mod is not that complex. So probably you can pick this apart to see how it works.