(Coding) Clear Terrain Definitions

Joined
Jan 10, 2019
Messages
1,850
What are 'Clear Terrains' as defined in UnitAbilites.xml, and Modifiers.xml ?

So far there's no clear definitions of 'Clear terrain' beyond the in game effects that add +1 movements to TWO chariot class units. Even with @raen 's tools I still se nothing fruitful to exploit in codings. (I'm about to modify Heavycav class abilities to grant combat stenght bonus attacking enemy in open terrain (or alternatively to deal less damage when attacking enemy units stationed in a closed terrains (woods, jungles, marshes, districts). So far no codes beyond the followings.

- UnitsAbilites.xml
Code:
...
<UnitAbilityModifiers>
...
       <Row>
           <UnitAbilityType>ABILITY_HEAVY_CHARIOT</UnitAbilityType>
           <ModifierId>HEAVYCHARIOT_FASTER_CLEAR_TERRAIN</ModifierId>
       </Row>
...
       <Row>
           <UnitAbilityType>ABILITY_LIGHT_CHARIOT</UnitAbilityType>
           <ModifierId>LIGHTCHARIOT_FASTER_CLEAR_TERRAIN</ModifierId>
       </Row>
</UnitAbilityModifiers>
<Modifiers>
...
      <Row>
           <ModifierId>HEAVYCHARIOT_FASTER_CLEAR_TERRAIN</ModifierId>
          <ModifierType>MODIFIER_PLAYER_UNIT_ADJUST_CLEAR_TERRAIN_START_MOVEMENT</ModifierType>     
       </Row>
...
       <Row>
           <ModifierId>LIGHTCHARIOT_FASTER_CLEAR_TERRAIN</ModifierId>
           <ModifierType>MODIFIER_PLAYER_UNIT_ADJUST_CLEAR_TERRAIN_START_MOVEMENT</ModifierType>
       </Row>
</Modifiers>
<ModifierArguments>
...
       <Row>
           <ModifierId>HEAVYCHARIOT_FASTER_CLEAR_TERRAIN</ModifierId>
           <Name>Amount</Name>
           <Value>1</Value>
       </Row>
...
       <Row>
           <ModifierId>LIGHTCHARIOT_FASTER_CLEAR_TERRAIN</ModifierId>
           <Name>Amount</Name>
           <Value>2</Value>
       </Row>
...
</ModifierArguments>

- Modifiers.xml
Code:
...
<DynamicModifiers>
...
       <Row>
           <ModifierType>MODIFIER_PLAYER_UNIT_ADJUST_CLEAR_TERRAIN_START_MOVEMENT</ModifierType>
           <CollectionType>COLLECTION_OWNER</CollectionType>
           <EffectType>EFFECT_ADJUST_UNIT_CLEAR_TERRAIN_START_MOVEMENT</EffectType>
       </Row>
...
</DynamicModifiers>

Where 'Clear terrain' referred in two files actually is? Or any other codings that will grant an ability to do extra damage against target standing on a said clear terrain plot (with neither 'features' nor 'districts' and not with defesible improvements (Forts, Chateau and Alcazar) and wonders so Heavycav class can use this ability?
 
I'm fairly certain that the EffectType "EFFECT_ADJUST_UNIT_CLEAR_TERRAIN_START_MOVEMENT" is hard-coded to recognise the plot that the owner's unit (well, coupled with the COLLECTION_OWNER CollectionType) is currently occupying and, what's more, before their movement has started. I am not sure you will have any luck exploiting that EffectType to achieve a unit ability that is intended to analyse the plot the opponent is on.

I would've thought the logic required, here, is to use an appropriate Requirement to determine the plot that the opposing unit is occupying. Something like REQUIREMENT_PLOT_TERRAIN_TYPE_MATCHES. This is used extensively to provide units (e.g. the Rough Rider) with combat strength bonuses dependent on the terrain type they occupy. In the case of the Rough Rider, it is used in conjunction with the ModifierType MODIFIER_UNIT_ADJUST_COMBAT_STRENGTH.

I think you could coupled it with a second requirement of type REQUIREMENT_PLAYER_IS_ATTACKING to only grant the bonus when your unit is attacking - this will ensure that if it is attacked in open terrain, it does not get the CS bonus.
 
I am fairly certain that the plot being evaluated to grant a combat bonus is the one the defender is occupying. So I do think that using a combination of the below requirements:

REQUIREMENT_PLOT_TERRAIN_TYPE_MATCHES
REQUIREMENT_PLAYER_IS_ATTACKING

...should result in the correct plot being evaluated (i.e. the one the defender is on). That would get you as far as the attacker getting a Combat Strength bonus when the defender is in open terrain.

If the defender occupies the wrong terrain, the test will fail and therefore the attacker will not get a bonus. If the unit in question is not the attacker, the test will fail and the unit will not get a bonus.

Now, that is not the full requirement - I do understand that - but I have not had a chance to think/look into how you would add a requirement to evaluate the plot from which the attacker moves in. If it is possible, it'll be another (third) requirement - which will need to be evaluated and part of a REQUIREMENT_TEST_ALL evaluation.

As I understand it, you want to grant a Combat Strength bonus if the attacking unit is in open terrain and the defending unit is in open terrain (adjacent). Genuinely, I am not sure if it is possible - as it feels as though that kind of dynamic, multi-plot evaluation is beyond what is available. As I indicated above, you may be able to do it by stringing together multiple, individual requirements: one for the plot the attacker occupies, one for the plot the defender occupies and one for establishing the attacker as, well, the attacker.

Even without the final attacker's-starting-plot evaluation, I think the approach I've suggested above should get you close to what you are after. Not exactly, but perhaps it'll be a serviceable starting point for your request. At least, I don't think it is as far away as you perhaps think it was - unless I have misunderstood.
 
Top Bottom