[NFP] Helicopter Attack while Embarked

wobusaya

Chieftain
Joined
Aug 21, 2021
Messages
4
Hi guys :)

Wondering if you can help with this. I have made simple mods before but with this one I'm kind of stumped, I am not sure where to start.

I would like to give Helicopters (CLASS_HELICOPTER or UNIT_HELICOPTER) the ABILITY_UNIT_FIGHT_WHILE_EMBARKED ability that GDRs have. I'm already using the no Embark graphic mod so that Helicopters don't transform into a ship while on water. Helicopters in Humankind can attack on water tiles, I figured, why not in Civ6? GDRs can already do this...

But creating a new UnitAbilityType ABILITY_UNIT_FIGHT_WHILE_EMBARKED_HELI and tagging it to CLASS_HELICOPTER only links it to the Helicopter unit's abilities panel in game, but it has no practical effect -- still can't attack.

Do you know what I might be doing wrong or point me in the general direction please?

Thanks in advance.

EDIT: I have the following rows linked (basically copied the XML code from the GDR ability):

<Row UnitAbilityType="ABILITY_UNIT_FIGHT_WHILE_EMBARKED_HELI" Name="LOC_ABILITY_UNIT_FIGHT_WHILE_EMBARKED_NAME" Description="LOC_ABILITY_UNIT_FIGHT_WHILE_EMBARKED_DESCRIPTION"/>

<Row>
<UnitAbilityType>ABILITY_UNIT_FIGHT_WHILE_EMBARKED_HELI</UnitAbilityType>
<ModifierId>HELI_FIGHT_WHILE_EMBARKED</ModifierId>
</Row>

<Row>
<ModifierId>HELI_FIGHT_WHILE_EMBARKED</ModifierId>
<ModifierType>MODIFIER_SINGLE_UNIT_ADJUST_FIGHT_WHILE_EMBARKED</ModifierType>
</Row>

This ModifierType is the exact same as the GDR's existing one. How come the ability and its modifiers work perfectly on GDR but does nothing for Helicopters?
 
Code:
<GameInfo>
	<Types>
		<Row Type="ABILITY_UNIT_FIGHT_WHILE_EMBARKED" Kind="KIND_ABILITY"/>
	</Types>
	<TypeTags>
		<Row Type="ABILITY_UNIT_FIGHT_WHILE_EMBARKED" Tag="CLASS_GIANT_DEATH_ROBOT"/>
	</TypeTags>
	<UnitAbilities>
		<Row UnitAbilityType="ABILITY_UNIT_FIGHT_WHILE_EMBARKED" Name="LOC_ABILITY_UNIT_FIGHT_WHILE_EMBARKED_NAME" Description="LOC_ABILITY_UNIT_FIGHT_WHILE_EMBARKED_DESCRIPTION"/>
	</UnitAbilities>
	<UnitAbilityModifiers>
		<Row>
			<UnitAbilityType>ABILITY_UNIT_FIGHT_WHILE_EMBARKED</UnitAbilityType>
			<ModifierId>GDR_FIGHT_WHILE_EMBARKED</ModifierId>
		</Row>
	</UnitAbilityModifiers>
	<Modifiers>
		<Row>
			<ModifierId>GDR_FIGHT_WHILE_EMBARKED</ModifierId>
			<ModifierType>MODIFIER_SINGLE_UNIT_ADJUST_FIGHT_WHILE_EMBARKED</ModifierType>
		</Row>
	</Modifiers>
	<ModifierArguments>
		<Row>
			<ModifierId>GDR_FIGHT_WHILE_EMBARKED</ModifierId>
			<Name>CanFight</Name>
			<Value>true</Value>
		</Row>
	</ModifierArguments>
</GameInfo>
 
Thanks for that, LeeS!

However, it seems there are some unintended consequences of giving this ability to the Helicopter class. It turns out that there was nothing wrong with my code, but that Helicopters just could not melee attack an enemy in water. When I tested, I only tested attacking with Helicopters, not defending (so I thought my mod wasn't working!).

Here is the result when I tested properly, this time giving Helicopters to an enemy player and using my Destroyers to test engagements.

Vanilla behavior:
- When embarked, combat strength goes from 86 down to 55.
- When embarked, cannot attack enemy units.
- When embarked, cannot defend against enemy attacks (do no counterdamage).

Modded behavior:
- When embarked, combat strength stays at 86.
- When embarked, still cannot attack enemy units.
- When embarked, can defend against enemy attacks (animation plays, and enemy destroyer takes similar damage to Helicopter as they have similar strength).

However, GDRs in GS obviously can initiate attacks even when in water. I just tested again, and it turns out that GDRs also cannot melee attack while in water -- only the Ranged attack works!

So, it seems to me that, only by giving Helicopters a ranged attack, would they be able to attack in water. This is of course not a desirable fix as it would make Helicopters much stronger.

The behavior seems hardcoded, unless anyone knows better?

EDIT: Tested, and Helicopters, with the modded ability, are only able to attack in water once given a ranged strength. Lol.
 
Last edited:
Back
Top Bottom