Defense vs. City Center Attacks? (was: defense for naval units)

sp00n

Prince
Joined
Jan 4, 2007
Messages
371
I'm trying to give all naval units an on defense buff. The log files show no errors, however the modifier is not applied (testing this in Hotseat).

Can anybody point out what's wrong here?

MOD_UnitAbilities.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<GameInfo>
   <Types>
       <Row Type="ABILITY_NAVAL_DEFENSE" Kind="KIND_ABILITY"/>
   </Types>

   <TypeTags>
       <Row Type="ABILITY_NAVAL_DEFENSE" Tag="CLASS_NAVAL_DEFENSE_BONUS"/>
   </TypeTags>

   <UnitAbilities>
       <Row UnitAbilityType="ABILITY_NAVAL_DEFENSE" Name="LOC_ABILITY_NAVAL_DEFENSE_NAME" Description="LOC_ABILITY_NAVAL_DEFENSE_DESCRIPTION"/>
   </UnitAbilities>

   <UnitAbilityModifiers>
       <Row>
           <UnitAbilityType>ABILITY_NAVAL_DEFENSE</UnitAbilityType>
           <ModifierId>PLUS_X_WHEN_DEFENDING_COMBAT_NAVAL_BONUS</ModifierId>
       </Row>
   </UnitAbilityModifiers>

   <Modifiers>
       <Row>
           <ModifierId>PLUS_X_WHEN_DEFENDING_COMBAT_NAVAL_BONUS</ModifierId>
           <ModifierType>MODIFIER_UNIT_ADJUST_COMBAT_STRENGTH</ModifierType>
           <SubjectRequirementSetId>PLAYER_IS_NAVAL_DEFENDER_REQUIREMENTS_SET</SubjectRequirementSetId>
       </Row>
   </Modifiers>

   <ModifierStrings>
       <Row ModifierId="PLUS_X_WHEN_DEFENDING_COMBAT_NAVAL_BONUS" Context="Preview" Text="PLUS_X_WHEN_DEFENDING_COMBAT_NAVAL_BONUS_DESC"/>
   </ModifierStrings>

   <ModifierArguments>
       <Row>
           <ModifierId>PLUS_X_WHEN_DEFENDING_COMBAT_NAVAL_BONUS</ModifierId>
           <Name>Amount</Name>
           <Value>20</Value>
       </Row>
   </ModifierArguments>

   <RequirementSets>
       <Row>
           <RequirementSetId>PLAYER_IS_NAVAL_DEFENDER_REQUIREMENTS_SET</RequirementSetId>
           <RequirementSetType>REQUIREMENTSET_TEST_ALL</RequirementSetType>
       </Row>
   </RequirementSets>

   <RequirementSetRequirements>
       <Row>
           <RequirementSetId>PLAYER_IS_NAVAL_DEFENDER_REQUIREMENTS_SET</RequirementSetId>
           <RequirementId>PLAYER_IS_DEFENDER_REQUIREMENTS</RequirementId>
       </Row>
   </RequirementSetRequirements>
   
</GameInfo>


MOD_Units.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<GameInfo>
   <Tags>
       <Row Tag="CLASS_NAVAL_DEFENSE_BONUS" Vocabulary="ABILITY_CLASS"/>
   </Tags>

   <!-- Enter all the naval units here -->
   <TypeTags>
       <Row Type="UNIT_GALLEY"                 Tag="CLASS_NAVAL_DEFENSE_BONUS"/>
       <Row Type="UNIT_NORWEGIAN_LONGSHIP"     Tag="CLASS_NAVAL_DEFENSE_BONUS"/>
       <Row Type="UNIT_CARAVEL"                Tag="CLASS_NAVAL_DEFENSE_BONUS"/>
       <Row Type="UNIT_IRONCLAD"               Tag="CLASS_NAVAL_DEFENSE_BONUS"/>
       <Row Type="UNIT_DESTROYER"              Tag="CLASS_NAVAL_DEFENSE_BONUS"/>
       <Row Type="UNIT_QUADRIREME"             Tag="CLASS_NAVAL_DEFENSE_BONUS"/>
       <Row Type="UNIT_FRIGATE"                Tag="CLASS_NAVAL_DEFENSE_BONUS"/>
       <Row Type="UNIT_BATTLESHIP"             Tag="CLASS_NAVAL_DEFENSE_BONUS"/>
       <Row Type="UNIT_BRAZILIAN_MINAS_GERAES" Tag="CLASS_NAVAL_DEFENSE_BONUS"/>
       <Row Type="UNIT_BARBARIAN_RAIDER"       Tag="CLASS_NAVAL_DEFENSE_BONUS"/>
       <Row Type="UNIT_PRIVATEER"              Tag="CLASS_NAVAL_DEFENSE_BONUS"/>
       <Row Type="UNIT_ENGLISH_SEADOG"         Tag="CLASS_NAVAL_DEFENSE_BONUS"/>
       <Row Type="UNIT_SUBMARINE"              Tag="CLASS_NAVAL_DEFENSE_BONUS"/>
       <Row Type="UNIT_GERMAN_UBOAT"           Tag="CLASS_NAVAL_DEFENSE_BONUS"/>
       <Row Type="UNIT_NUCLEAR_SUBMARINE"      Tag="CLASS_NAVAL_DEFENSE_BONUS"/>
       <Row Type="UNIT_AIRCRAFT_CARRIER"       Tag="CLASS_NAVAL_DEFENSE_BONUS"/>
   </TypeTags>
</GameInfo>


Ultimately I would like this mod to allow embarked land units to be destroyed more easily. My first approach was to give the ocean and coast tiles a -20 defense modifier, and giving it back to true naval units with the above code.
Giving embarked units a direct negative defense modifier would be the more direct approach. I have identified a couple of potential requirements for this (REQUIREMENT_OPPONENT_UNIT_DOMAIN_MATCHES, OPPONENT_IS_LAND_UNIT_REQUIREMENTS, REQUIRES_TERRAIN_OCEAN, REQUIRES_TERRAIN_COAST), but if I don't even get the above to work, progressing to defining new custom requirements doesn't make much sense.
 
Well, now I'm struggling to apply a defense modifer against city center attacks. The embarkment promotion already does the same thing (+10 defense versus city center attacks), however even when I copy the whole tree it doesn't work as an unit ability.

MOD_UnitAbilities.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<GameInfo>
   <!-- Define the unit ability -->
   <Types>
       <Row Type="ABILITY_DEFENSE_VS_CITY_ATTACK" Kind="KIND_ABILITY"/>
   </Types>

   <!-- Make class out of this unit ability -->
   <TypeTags>
       <Row Type="ABILITY_DEFENSE_VS_CITY_ATTACK" Tag="CLASS_DEFENSE_VS_CITY_ATTACKS"/>
   </TypeTags>


   <!-- Localization for the ability? -->
   <UnitAbilities>
       <Row UnitAbilityType="ABILITY_DEFENSE_VS_CITY_ATTACK" Name="LOC_ABILITY_DEFENSE_VS_CITY_ATTACK_NAME" Description="LOC_ABILITY_DEFENSE_VS_CITY_ATTACK_DESCRIPTION"/>
   </UnitAbilities>


   <!-- Define the unit ability, which refers to a modifier -->
   <UnitAbilityModifiers>
       <Row>
           <UnitAbilityType>ABILITY_DEFENSE_VS_CITY_ATTACK</UnitAbilityType>
           <ModifierId>DEFENSE_VS_CITY_ATTACK</ModifierId>
       </Row>
   </UnitAbilityModifiers>


   <!-- Define the modifier -->
   <Modifiers>
       <Row>
           <ModifierId>DEFENSE_VS_CITY_ATTACK</ModifierId>
           <ModifierType>MODIFIER_UNIT_ADJUST_COMBAT_STRENGTH</ModifierType>
           <SubjectRequirementSetId>DEFENSE_VS_CITY_ATTACK_REQUIREMENT_SET</SubjectRequirementSetId>
       </Row>
   </Modifiers>


   <!-- Define the localization string for the modifier -->
   <ModifierStrings>
       <Row ModifierId="DEFENSE_VS_CITY_ATTACK" Context="Preview" Text="DEFENSE_VS_CITY_ATTACK_DESC"/>
   </ModifierStrings>


   <!-- The modifier effects -->
   <ModifierArguments>
       <Row>
           <ModifierId>DEFENSE_VS_CITY_ATTACK</ModifierId>
           <Name>Amount</Name>
           <Value>20</Value>
       </Row>
   </ModifierArguments>


   <!-- Define the requirement set -->
   <RequirementSets>
       <Row>
           <RequirementSetId>DEFENSE_VS_CITY_ATTACK_REQUIREMENT_SET</RequirementSetId>
           <RequirementSetType>REQUIREMENTSET_TEST_ALL</RequirementSetType>
       </Row>
   </RequirementSets>


   <!-- Which requirements must be met for the modifier to become active -->
   <RequirementSetRequirements>
       <Row>
           <RequirementSetId>DEFENSE_VS_CITY_ATTACK_REQUIREMENT_SET</RequirementSetId>
           <RequirementId>PLAYER_IS_DEFENDER_REQUIREMENTS</RequirementId>
       </Row>
       <Row>
           <RequirementSetId>DEFENSE_VS_CITY_ATTACK_REQUIREMENT_SET</RequirementSetId>
           <RequirementId>OPPONENT_IS_DISTRICT</RequirementId>
       </Row>
       <Row>
           <RequirementSetId>DEFENSE_VS_CITY_ATTACK_REQUIREMENT_SET</RequirementSetId>
           <RequirementId>OPPONENT_PLOT_IS_CITY_CENTER_REQUIREMENT</RequirementId>
       </Row>
       <!-- <Row>
           <RequirementSetId>DEFENSE_VS_CITY_ATTACK_REQUIREMENT_SET</RequirementSetId>
           <RequirementId>REQUIRES_TERRAIN_COAST</RequirementId>
       </Row> -->


       <!-- Original Embarkment promotion entries from UnitPromotions.xml -->
       <!--
       <Row>
           <RequirementSetId>EMPLACEMENT_REQUIREMENTS</RequirementSetId>
           <RequirementId>PLAYER_IS_DEFENDER_REQUIREMENTS</RequirementId>
       </Row>
       <Row>
           <RequirementSetId>EMPLACEMENT_REQUIREMENTS</RequirementSetId>
           <RequirementId>OPPONENT_IS_DISTRICT</RequirementId>
       </Row>
       <Row>
           <RequirementSetId>EMPLACEMENT_REQUIREMENTS</RequirementSetId>
           <RequirementId>OPPONENT_PLOT_IS_CITY_CENTER_REQUIREMENT</RequirementId>
       </Row>
       -->
      
   </RequirementSetRequirements>
</GameInfo>


MOD_Units.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<GameInfo>
   <!-- Not sure -->
   <Tags>
       <Row Tag="CLASS_DEFENSE_VS_CITY_ATTACKS" Vocabulary="ABILITY_CLASS"/>
   </Tags>

   <!-- Add the unit classes to which the ability should apply to -->
   <TypeTags>
       <Row Type="ABILITY_DEFENSE_VS_CITY_ATTACK" Tag="CLASS_RECON"/>
       <Row Type="ABILITY_DEFENSE_VS_CITY_ATTACK" Tag="CLASS_MELEE"/>
       <Row Type="ABILITY_DEFENSE_VS_CITY_ATTACK" Tag="CLASS_RANGED"/>
       <Row Type="ABILITY_DEFENSE_VS_CITY_ATTACK" Tag="CLASS_SIEGE"/>
       <Row Type="ABILITY_DEFENSE_VS_CITY_ATTACK" Tag="CLASS_HEAVY_CAVALRY"/>
       <Row Type="ABILITY_DEFENSE_VS_CITY_ATTACK" Tag="CLASS_LIGHT_CAVALRY"/>
       <Row Type="ABILITY_DEFENSE_VS_CITY_ATTACK" Tag="CLASS_RANGED_CAVALRY"/>
       <Row Type="ABILITY_DEFENSE_VS_CITY_ATTACK" Tag="CLASS_ANTI_CAVALRY"/>
       <Row Type="ABILITY_DEFENSE_VS_CITY_ATTACK" Tag="CLASS_HEAVY_CHARIOT"/>
       <Row Type="ABILITY_DEFENSE_VS_CITY_ATTACK" Tag="CLASS_LIGHT_CHARIOT"/>
       <Row Type="ABILITY_DEFENSE_VS_CITY_ATTACK" Tag="CLASS_RELIGIOUS"/>
   </TypeTags>
</GameInfo>

MOD_Text.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<GameInfo>
   <LocalizedText>
       <Row Tag="DEFENSE_VS_CITY_ATTACK_DESC" Language="en_US">
           <Text>Modified defense vs. city attacks</Text>
       </Row>
   </LocalizedText>
</GameInfo>


Testing with the same hotseat game where the original modifiers eventually worked (and where none of the newly added localization text works, which however work fine on normal single player games).
 
Hm.
Code:
[3222007.159] [Turn: 1] Created Requirement <259:OPPONENT_IS_DISTRICT> with Owner <Unit: 1245202, Owner: 64, Type: 18 Position: -9999x-9999> and Subject <ProposedCombat>.
[3222007.159] [Turn: 1] Warning: Object <ProposedCombat> does not support interface <{3572089E-A269-461E-BD1B-803EF6CD044B}>.
[3222007.159] [Turn: 1] Created Requirement <260:OPPONENT_PLOT_IS_CITY_CENTER_REQUIREMENT> with Owner <Unit: 1245202, Owner: 64, Type: 18 Position: -9999x-9999> and Subject <ProposedCombat>.
[3222007.159] [Turn: 1] Created Requirement <261:PLAYER_IS_DEFENDER_REQUIREMENTS> with Owner <Unit: 1245202, Owner: 64, Type: 18 Position: -9999x-9999> and Subject <ProposedCombat>.
[3222007.159] [Turn: 1] Created Requirement Set <262:DEFENSE_VS_CITY_ATTACK_REQUIREMENT_SET> with Owner <Unit: 1245202, Owner: 64, Type: 18 Position: -9999x-9999> and Subject <ProposedCombat>.
[3222007.159] [Turn: 1] Modifier <11:DEFENSE_VS_CITY_ATTACK> Collection Count (met/total): 0/1.

Is there any way to find out what this warning message actually means? I have a gut feeling that the internal requirement is only valid for the embarkment promotion...
If I remove the OPPONENT_PLOT_IS_CITY_CENTER_REQUIREMENT requirement, and only leave in the OPPONENT_IS_DISTRICT requirement, the warning message goes away, but the ability is still not applied. If I remove both the city plot requirements, the defense debuff works fine.
 
Back
Top Bottom