Logo Platform
logo amplifiers simplified

[Solved]Population Bonuses Issue

Reply
Copied to clipboard!
7 years ago
Jul 10, 2017, 5:58:04 PM

I'm trying to make my own population bonuses but something is missing/wrong and i can't guess what.

I'm able to see the new trait and choose it, when I click create it returns to "None".


Maybe it's some other thing, I've made the following files:


  1. Gui/GuiElements[MorePopulationBonuses].xml
  2. Localization/english/ES2_Localization_Locales.xml
  3. Simulation/PopulationModifiersTraits[MorePopulationBonuses].xml
  4. Simulation/SimulationDescriptors[MorePopulationBonuses].xml


It would be a plus if I wouldn't need to make it a Conversion instead of an extension.



        <!-- XML files to load -->
        <Plugins>
            <DatabasePlugin DataType="PopulationModifiersTrait, Assembly-CSharp">
                <FilePath>Simulation/PopulationModifiersTraits[MorePopulationBonuses].xml</FilePath>
            </DatabasePlugin>

            <DatabasePlugin DataType="Amplitude.Unity.Simulation.SimulationDescriptor, Assembly-CSharp-firstpass">
                <FilePath>Simulation/SimulationDescriptors[MorePopulationBonuses].xml</FilePath>
            </DatabasePlugin>

            <DatabasePlugin DataType="Amplitude.Unity.Gui.GuiElement, Assembly-CSharp-firstpass">
                <ExtraTypes>
                    <ExtraType DataType="Amplitude.Unity.Gui.ExtendedGuiElement, Assembly-CSharp-firstpass" />
                </ExtraTypes>
                <FilePath>Gui/GuiElements[MorePopulationBonuses].xml</FilePath>
            </DatabasePlugin>

            <LocalizationPlugin DefaultLanguage="english">
                <Directory>Localization</Directory>
            </LocalizationPlugin>
        </Plugins>




Here goes the file contents in order:

1.

<?xml version="1.0" encoding="utf-8" ?>
<Datatable xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:noNamespaceSchemaLocation="../Schemas/Amplitude.Unity.Gui.GuiElement.xsd">
<!--This File stops the traits from being in pink, Delete it and find out for yourself if you want-->
    <!-- It also is what give objects there names and descriptions -->
    <GuiElement Name="PopulationModifiersTraitMoreBonusesIndustry01">
        <!-- the %Words are references to the localization file -->
        <Title>%PopulationModifiersTraitMoreBonusesIndustry01Title</Title>
    </GuiElement>
        <GuiElement Name="ClassPopulationPlanetModifiersTraitMoreBonusesIndustry01">
        <Title>%PopulationModifiersTraitMoreBonusesIndustry01Title</Title>
    </GuiElement>

</Datatable>


2.

<?xml version="1.0" encoding="utf-8"?>
<Datatable xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!-- xsi:noNamespaceSchemaLocation="../../Documentation/Schemas/Amplitude.Unity.Localization.LocalizationDatatableElement.xsd"> -->

  <!--Contains the new texts for the mod. If there is just English language, it will be used for all localisations -->
 
  <LocalizationPair Name="%PopulationModifiersTraitMoreBonusesIndustry01Title">Tireless Workers</LocalizationPair>

</Datatable>


3.
<?xml version="1.0" encoding="utf-8"?>
<Datatable xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:noNamespaceSchemaLocation="../Schemas/PopulationModifiersTrait.xsd">

    <PopulationModifiersTrait Name="PopulationModifiersTraitMoreBonusesIndustry01" SubCategory="Primary" ShowInCustom="true" Cost="10"><!--Local Bonus: Tireless workers-->
        <Modifiers>
            <Modifier Class="ClassPopulationEmpire">
                <SimulationDescriptorReference Name="WithPopulationPlanetModifiersTraitMoreBonusesIndustry01"/>
            </Modifier>
            <Modifier Class="ClassPopulationPlanet">
                <SimulationDescriptorReference Name="ClassPopulationPlanetModifiersTraitMoreBonusesIndustry01"/>
            </Modifier>
        </Modifiers>
        <AssimilatedModifiers>
            <Modifier Class="ClassPopulationPlanet"><!--Bonus given to the Population that assimilates them-->
                <SimulationDescriptorReference Name="ClassPopulationAssimilatedMoreBonusesIndustry01"/>
            </Modifier>
        </AssimilatedModifiers>
    </PopulationModifiersTrait>

</Datatable>

4.

<?xml version="1.0" encoding="utf-8" ?>
<Datatable xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:noNamespaceSchemaLocation="../Schemas/Amplitude.Unity.Simulation.SimulationDescriptor.xsd">

    <!--<SimulationDescriptor Name="PopulationGrowthScoreBoosted" Type="PopulationGrowthScoreBoosted">

        <Modifier TargetProperty="BonusPopulation_MoreBonusesIndustry01" Operation="Addition" Value="5"            Path="WithPopulationPlanetModifiersTrait_MoreBonusesIndustry01/./ClassEmpire/ClassColonizedStarSystem/ClassPlanet/ClassPopulationPlanetModifiersTraitPrimaryIndustry" TooltipHiddenIfPathInvalid="true" />

    -->

    <SimulationDescriptor Name="PopulationGrowthScoreBoostedMorePopulationBonuses" Type="PopulationGrowthScoreBoosted">
        <Modifier TargetProperty="BonusPopulationIndustry" Operation="Addition" Value="3"            Path="WithPopulationPlanetModifiersTraitMoreBonusesIndustry01/./ClassEmpire/ClassColonizedStarSystem/ClassPlanet/ClassPopulationPlanetModifiersTraitMoreBonusesIndustry01"  />
    </SimulationDescriptor>
    <!--TooltipHiddenIfPathInvalid="true"-->


<!-- Local bonus trackers -->
     <SimulationDescriptor Name="WithPopulationPlanetModifiersTraitMoreBonusesIndustry01" Type="WithPopulationPlanet"/>

    <SimulationDescriptor Name="ClassPopulationPlanetModifiersTraitMoreBonusesIndustry01" Type="ClassPopulationPlanet">
        <Modifier TargetProperty="BonusPopulationIndustry" Operation="Addition" Value="3" />
    </SimulationDescriptor>

    <SimulationDescriptor Name="ClassPopulationAssimilatedMoreBonusesIndustry01" Type="ClassPopulationAssimilated">
        <Modifier       TargetProperty="BonusPopulationIndustry"  Operation="Addition"    Value="3"      />
    </SimulationDescriptor>

</Datatable>






Updated 7 years ago.
0Send private message
7 years ago
Jul 13, 2017, 12:26:27 AM

I tried modifying the bonus "Meritocratic Cosmopolites" from 2fisdsi to 1fidsi, still having the same issue when the mod's on "Extension", tried switching to "Conversion" then it worked but only for Meritocratic Cosmopolites, but it takes like a couple of refreshes or retries to switch the population bonuses(really weird) its kinda non-consistent, when I click the create button, any insight?

0Send private message
7 years ago
Jul 13, 2017, 11:53:42 AM

A thing that I can currently spot is that lack of a priority set in the modifier and the tooltip being always shown, but I would expect the game to be fine with it.


<SimulationDescriptor Name="PopulationGrowthScoreBoostedMorePopulationBonuses" Type="PopulationGrowthScoreBoosted">
<Modifier
TargetProperty="BonusPopulationIndustry" Operation="Addition" Value="3"            Path="WithPopulationPlanetModifiersTraitMoreBonusesIndustry01/./ClassEmpire/ClassColonizedStarSystem/ClassPlanet/ClassPopulationPlanetModifiersTraitMoreBonusesIndustry01"  />
</SimulationDescriptor>

So I assume it might have something to do with having this modifier is under your new simulation Descriptor "PopulationGrowthScoreBoostedMorePopulationBonuses"

I do not know how the game reacts to having population trait modifiers under different simulation descriptors (it looks like you tried having them under that same one before due to it being commented out, how did that go?) The original has a non-trait specific modifier so you can try add that to the simulation descriptor (see below)


Try Change it to (Additions in bold and underlined)

<SimulationDescriptor Name="PopulationGrowthScoreBoostedMorePopulationBonuses" Type="PopulationGrowthScoreBoosted">

<Modifier TargetProperty="PopulationGrowthScoreModifier" Operation="Percent" Value="1"/>
<Modifier
TargetProperty="BonusPopulationIndustry" Operation="Addition" Value="3"  Priority="-2"     Path="WithPopulationPlanetModifiersTraitMoreBonusesIndustry01/./ClassEmpire/ClassColonizedStarSystem/ClassPlanet/ClassPopulationPlanetModifiersTraitMoreBonusesIndustry01"  TooltipHiddenIfPathInvalid="true"/>
</SimulationDescriptor>

If this does not work I would suggest getting the original simulation descriptor "PopulationGrowthScoreBoosted" and adding your modifier to that

(So copy lines 1654 to 1770 in \Simulation\SimulationDescriptors[Population].xml into SimulationDescriptors[MorePopulationBonuses].xml and then insert your modifier "BonusPopulationIndustry" into it shouldn’t matter where, at the end just before </SimulationDescriptor> should be fine.

0Send private message
7 years ago
Jul 13, 2017, 9:49:32 PM

Thanks for the reply! yeah I've tried adding "PopulationGrowthScoreModifier" in my PopulationGrowthScoreBoostedMorePopulationBonuses, I removed the "TooltipHiddenIfPathInvalid="true"" to see if it was some pathing problem but it seems fine, so i kept it in other tests, tried with different values for the Priority attribute, from -3 to 1, without results, still same behavior, my new bonus never gets recognized, and after a retry it loads any other bonus (also the modified meritocratic cosmopolites), I also tried copypasting lines 1654 to 1770, and changing the mod to conversion, adding my own bonus at the end.

I tried doing the same operation without mods and its the same for any bonus here, they get added at the "modifiers" section after a retry, for example if I create a faction using analysts.

I validated my gamefiles to see if it was my issue alone.


Made a custom population "test" I checked the file Documents/Endless Space 2/Custom Factions/Custom Populations/test.xml and i have the

<Trait Name="PopulationModifiersTraitMoreBonusesIndustry01" />

Then I Run the game with the mod and it never finishes loading.


Next steps? Should I report a bug? want my Mod folder for testing Rob?

Updated 7 years ago.
0Send private message
7 years ago
Jul 14, 2017, 9:07:13 AM

If you put your mod folder in a zip I could have a look at it, also if you could add your diagnostics file (in %Documents%\Endless Space 2\Temporary Files It's a .html with the time and date of when the game launched in its name) I could look into the infinite loading.


This might be a bug with the modding system (there are a few) one way to check would be to take you code and edit it directly into the original game files, if you have an issue after that then its probably an issue with your code if you don't then its probably an issue with the modding system (or your mods main xml)

0Send private message
7 years ago
Jul 14, 2017, 4:34:50 PM

Diagnostics - 2017'07'14 @1318'38''.html


The custom trait did work when I modified the base game files, it still doesn't when I try using my mod, in the diagnostics html there's a couple of null reference exceptions by the end, then I waited for eight minutes trying to load a tiny map and exited ES2.


Here goes the mod.

MorePopulationBonusesv0.1.zip

0Send private message
7 years ago
Jul 14, 2017, 5:04:39 PM

Well This is what looks to be the issue:

13:19:50:338 Can't find the element 'PopulationModifiersTraitMoreBonusesIndustry01' in database of 'PopulationTrait'.


Amplitude.Unity.Xml.XmlNamedReference:GetInstancesFromXmlReferences(System.Reflection.ParameterInfo, System.Reflection.ParameterInfo) Amplitude.Unity.Xml.XmlNamedReference:GetInstancesFromXmlReferences(System.Reflection.ParameterInfo, System.Reflection.ParameterInfo) PopulationDefinition:get_Traits() PopulationDefinition+c__Iterator0:MoveNext() PopulationDefinition:WouldBeValidCustomPopulation(System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo) PopulationDefinition:IsValidCustomPopulation(System.Reflection.ParameterInfo) PopulationDefinition:IsFullyValidCustomPopulation() Faction:IsFullyValidCustomFaction() GuiFaction+Comparer:Compare(System.Reflection.ParameterInfo, System.Reflection.ParameterInfo) System.Array:compare(System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo) System.Array:qsort(System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo) System.Array:qsort(System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo) System.Array:qsort(System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo) System.Array:Sort(System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo) System.Array:Sort(System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo) System.Collections.Generic.List`1[GuiFaction]:Sort(System.Reflection.ParameterInfo) FactionChoiceModalWindow:BindCards() FactionChoiceModalWindow:OnBeginShow(System.Reflection.ParameterInfo) Amplitude.Unity.Gui.GuiPanel:Show(System.Reflection.ParameterInfo) Amplitude.Unity.Gui.GuiWindow:InternalShow(System.Reflection.ParameterInfo) Amplitude.Unity.Gui.GuiWindowsStack:ShowWindow(System.Reflection.ParameterInfo, System.Reflection.ParameterInfo) Amplitude.Unity.Gui.GuiWindowsStackModal:ShowWindow(System.Reflection.ParameterInfo, System.Reflection.ParameterInfo) Amplitude.Unity.Gui.GuiManager:ShowWindow(System.Reflection.ParameterInfo, System.Reflection.ParameterInfo) PlayerCompetitorSlot:OnSelectFactionCb(System.Reflection.ParameterInfo) UnityEngine.GameObject:SendMessage(System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo) AgeControlButton:HandleMouseUpOrDown(System.Reflection.ParameterInfo) AgeControlButton:MouseUp(System.Reflection.ParameterInfo) UnityEngine.Component:SendMessage(System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo) UnityEngine.Component:SendMessage(System.Reflection.ParameterInfo, System.Reflection.ParameterInfo) AgeManager:UpdateInteractivity() AgeManager:LateUpdate()

13:19:50:338 Could not retrieve 42e01958-7b26-449a-939f-f0f15718471b's traits in the PopulationTrait database. Skipping the trait.


PopulationDefinition+c__Iterator0:MoveNext() PopulationDefinition:WouldBeValidCustomPopulation(System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo) PopulationDefinition:IsValidCustomPopulation(System.Reflection.ParameterInfo) PopulationDefinition:IsFullyValidCustomPopulation() Faction:IsFullyValidCustomFaction() GuiFaction+Comparer:Compare(System.Reflection.ParameterInfo, System.Reflection.ParameterInfo) System.Array:compare(System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo) System.Array:qsort(System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo) System.Array:qsort(System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo) System.Array:qsort(System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo) System.Array:Sort(System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo) System.Array:Sort(System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo) System.Collections.Generic.List`1[GuiFaction]:Sort(System.Reflection.ParameterInfo) FactionChoiceModalWindow:BindCards() FactionChoiceModalWindow:OnBeginShow(System.Reflection.ParameterInfo) Amplitude.Unity.Gui.GuiPanel:Show(System.Reflection.ParameterInfo) Amplitude.Unity.Gui.GuiWindow:InternalShow(System.Reflection.ParameterInfo) Amplitude.Unity.Gui.GuiWindowsStack:ShowWindow(System.Reflection.ParameterInfo, System.Reflection.ParameterInfo) Amplitude.Unity.Gui.GuiWindowsStackModal:ShowWindow(System.Reflection.ParameterInfo, System.Reflection.ParameterInfo) Amplitude.Unity.Gui.GuiManager:ShowWindow(System.Reflection.ParameterInfo, System.Reflection.ParameterInfo) PlayerCompetitorSlot:OnSelectFactionCb(System.Reflection.ParameterInfo) UnityEngine.GameObject:SendMessage(System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo) AgeControlButton:HandleMouseUpOrDown(System.Reflection.ParameterInfo) AgeControlButton:MouseUp(System.Reflection.ParameterInfo) UnityEngine.Component:SendMessage(System.Reflection.ParameterInfo, System.Reflection.ParameterInfo, System.Reflection.ParameterInfo) UnityEngine.Component:SendMessage(System.Reflection.ParameterInfo, System.Reflection.ParameterInfo) AgeManager:UpdateInteractivity() AgeManager:LateUpdate()

(42e01958-7b26-449a-939f-f0f15718471b is your custom faction population's name that the game uses behind the scenes)


The Game does not seem to add the element/trait to the 'populationtrait' database correctly when its added as a mod. 

Strange, guess its a bug. You should probably submit a bug report so that the devs can have a look at this.

But its the start of a weekend so don't expect an anwser from them for a while.



0Send private message
0Send private message0Send private message
7 years ago
Jul 18, 2017, 1:44:41 PM

Hey folks!


After inspecting the XML of the mod, it appears that the following part is required for it to work properly:


<DatabasePlugin DataType="PopulationTrait, Assembly-CSharp">
  <ExtraTypes>
    <ExtraType DataType="PopulationModifiersTrait, Assembly-CSharp"/>
  </ExtraTypes>
  <FilePath>Simulation/PopulationModifiersTraits.xml</FilePath>
</DatabasePlugin>

Add this to the file MorePopulationBonuses.xml and the mod should run fine.


The issue is that we build a list of each PopulationModifiersTrait individually AND add it to the list of PopulationTraits (its 'base' type).

So it is required to have the declaration of both lists in your DatabasePlugin declarations.


Hope this helps!

0Send private message
7 years ago
Jul 18, 2017, 3:30:10 PM

Hi Admiral! I Tried two things out: added the Database Plugin (1.)  deleting the previous (2.) and on a second attempt (reloading the mod) tried keeping both of them, and the trait was still missing when I accessed the custom faction screen. Nevermind, it worked! made a retry restarting the game, good to know that the data of the plugins is loaded at ES2 startup. Thanks! :) I'll be publishing the mod on the weekend :D

1.

<DatabasePlugin DataType="PopulationTrait, Assembly-CSharp">
  <ExtraTypes>
    <ExtraType DataType="PopulationModifiersTrait, Assembly-CSharp"/>
  </ExtraTypes>
  <FilePath>Simulation/PopulationModifiersTraits.xml</FilePath>
</DatabasePlugin>

2.

<DatabasePlugin DataType="PopulationModifiersTrait, Assembly-CSharp">
   <FilePath>Simulation/PopulationModifiersTraits.xml</FilePath>
</DatabasePlugin>



Updated 7 years ago.
0Send private message
?

Click here to login

Reply
Comment