[GS] Creating a Building that Prevents Damage from Disasters

ReggieB

Chieftain
Joined
Mar 28, 2018
Messages
36
Hi all, I'm working on a mod to create a building that will prevent damage from disasters for the city in the same way that the Governor Liang's "Reinforced Materials" promotion does. However I haven't been able to get the effect to work so far, and I'm hoping you can offer some advice.

It was easy enough to create a building called "BUILDING_STRUCTURAL_REINFORCEMENTS", but so far I haven't found any way to apply the damage prevention modifier correctly. The first thing I tried was simply copying the modifier from Liang. Note that the spelling "PREVENET" instead of "PREVENT" is consistent with the game code:
Code:
<BuildingModifiers>
    <Row ModifierId="REINFORCED_INFRASTRUCTURE_PREVENET_STRUCTURAL_DAMAGE" BuildingType="BUILDING_STRUCTURAL_REINFORCEMENTS"/>
</BuildingModifiers>

My best guess as to why that doesn't work is because that modifier applies to "COLLECTION_OWNER", where owner refers to the governor herself and not the city where she resides. So to try to get around that, I made a dynamic modifier that has the same effect "EFFECT_ADJUST_PREVENT_STRUCTURAL_DAMAGE", but that applies to "COLLECTION_PLAYER_CITIES" instead:
Code:
<Types>
    <Row Type="MODTYPE_STRUCTURAL_REINFORCEMENTS_PLAYER_CITIES_ADJUST_PREVENT_STRUCTURAL_DAMAGE" Kind="KIND_MODIFIER"/>
</Types>
<DynamicModifiers>
    <Row ModifierType="MODTYPE_STRUCTURAL_REINFORCEMENTS_PLAYER_CITIES_ADJUST_PREVENT_STRUCTURAL_DAMAGE" CollectionType="COLLECTION_PLAYER_CITIES" EffectType="EFFECT_ADJUST_PREVENT_STRUCTURAL_DAMAGE"/>
</DynamicModifiers>
<Modifiers>
    <Row ModifierId="STRUCTURAL_REINFORCEMENTS_PREVENTION" ModifierType="MODTYPE_STRUCTURAL_REINFORCEMENTS_PLAYER_CITIES_ADJUST_PREVENT_STRUCTURAL_DAMAGE"/>
</Modifiers>
<ModifierArguments>
    <Row ModifierId="STRUCTURAL_REINFORCEMENTS_PREVENTION" Name="Prevent" Type="ARGTYPE_IDENTITY" Value="1"/>
</ModifierArguments>
<BuildingModifiers>
    <Row ModifierId="STRUCTURAL_REINFORCEMENTS_PREVENTION" BuildingType="BUILDING_STRUCTURAL_REINFORCEMENTS"/>
</BuildingModifiers>

However that modifier also doesn't seem to do anything. In theory there should be some way to apply that effect to a city using a building instead of a governor. But I'm at a loss as to how I would forumalte a dynamic modifier to do that. Any help would be appreciated, thanks!
 
Collection_Owner should work fine, the "governor" in the original ModifierId has no functional value, it's jut part of the name. Modifiers assigned to Owner seem to follow all the owner's connections. For example a district is associated with a city, a plot, and a player. So if you assign an effect relating to any of these classes to the district via "owner", it will automatically "jump over" to the correct class.

Collection_Player_Cities would mean that the modifier i applied to all your cities if you build one building.

Maybe replace the Value="1" with Value="True"? SQL only understands 0 and 1 for Boolean variables while XML can use True and False (I don't know whether XML can ONLY use True and False or whether both are necessary, but "True" and "False" definitely work for XML).
 
xml should be able to use 'true' or 'false' or 1 or 0. You should avoid capitalizing these booleans in XML because there are cases where 'true' and 'false' are used as "Value" arguments in non-boolean columns, and text-strings 'True' and 'False' are not the same as text-strings 'true' and 'false' and the DLL may not properly "recognize" such a capitalized text-string.

'true' and 'false' are still better in xml for boolean columns only because at one point in civ5, 1 and 0 were not properly implemented as boolean values from xml files, as were 'True' and 'False' as I recall, so safe is better than head-bashing only to find there was nothing really wrong with the code, just that an oops in the xml parser crept in as a result of an expansion or patch.
 
old case, but I wonder...was anyone able to attach EFFECT_ADJUST_PREVENT_STRUCTURAL_DAMAGE to anything other than governor?

EDIT:
I've created a dynamic modifier with this effect and tried to attach it to building or district or policy but nothing works (no errors in logs just doesn't work) only attachment to governor works.

It seems that CityLights mod also uses this attachment with one of the buildings - Civil Engineering? - but doesn't create a new dynamic modifier just uses ModifierType: MODIFIER_GOVERNOR_ADJUST_PREVENET_STRUCTURAL_DAMAGE and within that mod this also doesn't seem to work (at least it doesn't for me - please correct me if I'm wrong).

Also tried to change the CollectionType and failed even when attached to governor when used anything other than COLLECTION_OWNER.

I did create a copies of governors - created a new governors with same icons/promotions trees and my dynamic modifier - works but You can only gain a maximum of 64 Governor Points (sic! xD ). I know u can change the number of MAX_GOVERNOR_APPOINTMENTS in GlobalParameters but I could not find the number for points. So yeah....Am I disabled? xP

With Love for CivFanatics
 
Last edited:
Back
Top Bottom