Promotion that gives bonus unit strength when in territory of a civilisation you have a DoF with

cake_zero

Chieftain
Joined
Aug 11, 2017
Messages
3
I don't have an amazing grasp on lua yet, and I don't know how to create a new modifier "DOFTerritoryBonusModifier", that gives +20% combat strength if you are inside the territory of a civilisation you have a Declaration of Friendship with.

This is what I have for the promotion so far, it's using the modifier that I haven't made yet

<GameData>
<UnitPromotions>
<Row>
<Type>PROMOTION_DOF_TERRITORY_BONUS</Type>
<Description>TXT_KEY_DOF_TERRITORY_BONUS</Description>
<Help>TXT_KEY_DOF_TERRITORY_BONUS_HELP</Help>
<Sound>AS2D_IF_LEVELUP</Sound>
<DOFTerritoryBonusModifier>20</DOFTerritoryBonusModifier>
<IconAtlas>ABILITY_ATLAS</IconAtlas>
<PediaType>PEDIA_ATTRIBUTES</PediaType>
<PediaEntry>TXT_KEY_PEDIA_DOF_TERRITORY_BONUS</PediaEntry>
</Row>
</UnitPromotions>
<Gamedata>

Basically, how do I create a modifier with this purpose, or is there a better way to do this that I am missing? And how do I give this promotion a name?
thanks :)
 
Are you creating a new promotion that it doesn't exsit in the BNW?I searched in the table "UnitPromotions".I don't find the "DOFTerritoryBonusModifier".XML can rearrange and combine existing promotion effects,but it can't CREAT a NEW effect.
What's more,you forget the <PortraitIndex>Number</PortraitIndex>.This sentence determins the which icon of ABILITY_ATLAS is used to the promotion.Usually if the promotion is positive,we use <PortraitIndex>59</PortraitIndex>.

I am not familar with lua or MOD( or English:lol:.I am not sure if I understand your meaning correctly.)This is a promotion can contain:

Code:
<Row>
            <Type>PROMOTION_DRILL_2</Type>
            <Description>TXT_KEY_PROMOTION_DRILL_2</Description>
            <Help>TXT_KEY_PROMOTION_DRILL_2_HELP</Help>
            <PortraitIndex>20</PortraitIndex>
            <IconAtlas>PROMOTION_ATLAS</IconAtlas>
            <HotKeyPriority>0</HotKeyPriority>
            <HotKeyPriorityAlt>0</HotKeyPriorityAlt>
            <OrderPriority>2</OrderPriority>
            <AltDown>false</AltDown>
            <AltDownAlt>false</AltDownAlt>
            <ShiftDown>false</ShiftDown>
            <ShiftDownAlt>false</ShiftDownAlt>
            <CtrlDown>false</CtrlDown>
            <CtrlDownAlt>false</CtrlDownAlt>
            <Sound>AS2D_IF_LEVELUP</Sound>
            <CannotBeChosen>false</CannotBeChosen>
            <LostWithUpgrade>false</LostWithUpgrade>
            <NotWithUpgrade>false</NotWithUpgrade>
            <InstaHeal>false</InstaHeal>
            <Leader>false</Leader>
            <Blitz>false</Blitz>
            <Amphib>false</Amphib>
            <River>false</River>
            <EnemyRoute>false</EnemyRoute>
            <RivalTerritory>false</RivalTerritory>
            <MustSetUpToRangedAttack>false</MustSetUpToRangedAttack>
            <RangedSupportFire>false</RangedSupportFire>
            <CanMoveAfterAttacking>false</CanMoveAfterAttacking>
            <AlwaysHeal>false</AlwaysHeal>
            <HealOutsideFriendly>false</HealOutsideFriendly>
            <HillsDoubleMove>false</HillsDoubleMove>
            <RoughTerrainEndsTurn>false</RoughTerrainEndsTurn>
            <IgnoreTerrainCost>false</IgnoreTerrainCost>
            <HoveringUnit>false</HoveringUnit>
            <FlatMovementCost>false</FlatMovementCost>
            <CanMoveImpassable>false</CanMoveImpassable>
            <NoCapture>false</NoCapture>
            <OnlyDefensive>false</OnlyDefensive>
            <NoDefensiveBonus>false</NoDefensiveBonus>
            <NukeImmune>false</NukeImmune>
            <HiddenNationality>false</HiddenNationality>
            <AlwaysHostile>false</AlwaysHostile>
            <NoRevealMap>false</NoRevealMap>
            <Recon>false</Recon>
            <CanMoveAllTerrain>false</CanMoveAllTerrain>
            <FreePillageMoves>false</FreePillageMoves>
            <AirSweepCapable>false</AirSweepCapable>
            <AllowsEmbarkation>false</AllowsEmbarkation>
            <EmbarkedAllWater>false</EmbarkedAllWater>
            <HealIfDestroyExcludesBarbarians>false</HealIfDestroyExcludesBarbarians>
            <RangeAttackIgnoreLOS>false</RangeAttackIgnoreLOS>
            <CityAttackOnly>false</CityAttackOnly>
            <CaptureDefeatedEnemy>false</CaptureDefeatedEnemy>
            <HealOnPillage>false</HealOnPillage>
            <IgnoreGreatGeneralBenefit>false</IgnoreGreatGeneralBenefit>
            <IgnoreZOC>false</IgnoreZOC>
            <HasPostCombatPromotions>false</HasPostCombatPromotions>
            <PostCombatPromotionsExclusive>false</PostCombatPromotionsExclusive>
            <RangedAttackModifier>0</RangedAttackModifier>
            <InterceptionCombatModifier>0</InterceptionCombatModifier>
            <InterceptionDefenseDamageModifier>0</InterceptionDefenseDamageModifier>
            <AirSweepCombatModifier>0</AirSweepCombatModifier>
            <ExtraAttacks>0</ExtraAttacks>
            <ExtraNavalMovement>0</ExtraNavalMovement>
            <VisibilityChange>0</VisibilityChange>
            <MovesChange>0</MovesChange>
            <MoveDiscountChange>0</MoveDiscountChange>
            <RangeChange>0</RangeChange>
            <InterceptChanceChange>0</InterceptChanceChange>
            <NumInterceptionChange>0</NumInterceptionChange>
            <EvasionChange>0</EvasionChange>
            <CargoChange>0</CargoChange>
            <EnemyHealChange>0</EnemyHealChange>
            <NeutralHealChange>0</NeutralHealChange>
            <FriendlyHealChange>0</FriendlyHealChange>
            <SameTileHealChange>0</SameTileHealChange>
            <AdjacentTileHealChange>0</AdjacentTileHealChange>
            <EnemyDamageChance>0</EnemyDamageChance>
            <NeutralDamageChance>0</NeutralDamageChance>
            <EnemyDamage>0</EnemyDamage>
            <NeutralDamage>0</NeutralDamage>
            <CombatPercent>0</CombatPercent>
            <CityAttack>0</CityAttack>
            <CityDefense>0</CityDefense>
            <RangedDefenseMod>0</RangedDefenseMod>
            <HillsAttack>0</HillsAttack>
            <HillsDefense>0</HillsDefense>
            <OpenAttack>0</OpenAttack>
            <OpenRangedAttackMod>0</OpenRangedAttackMod>
            <OpenDefense>0</OpenDefense>
            <RoughAttack>15</RoughAttack>
            <RoughRangedAttackMod>0</RoughRangedAttackMod>
            <RoughDefense>15</RoughDefense>
            <AttackFortifiedMod>0</AttackFortifiedMod>
            <AttackWoundedMod>0</AttackWoundedMod>
            <FlankAttackModifier>0</FlankAttackModifier>
            <NearbyEnemyCombatMod>0</NearbyEnemyCombatMod>
            <NearbyEnemyCombatRange>0</NearbyEnemyCombatRange>
            <UpgradeDiscount>0</UpgradeDiscount>
            <ExperiencePercent>0</ExperiencePercent>
            <AdjacentMod>0</AdjacentMod>
            <AttackMod>0</AttackMod>
            <DefenseMod>0</DefenseMod>
            <DropRange>0</DropRange>
            <GreatGeneral>false</GreatGeneral>
            <GreatAdmiral>false</GreatAdmiral>
            <GreatGeneralModifier>0</GreatGeneralModifier>
            <GreatGeneralReceivesMovement>false</GreatGeneralReceivesMovement>
            <GreatGeneralCombatModifier>0</GreatGeneralCombatModifier>
            <FriendlyLandsModifier>0</FriendlyLandsModifier>
            <FriendlyLandsAttackModifier>0</FriendlyLandsAttackModifier>
            <OutsideFriendlyLandsModifier>0</OutsideFriendlyLandsModifier>
            <HPHealedIfDestroyEnemy>0</HPHealedIfDestroyEnemy>
            <ExtraWithdrawal>0</ExtraWithdrawal>
            <EmbarkExtraVisibility>0</EmbarkExtraVisibility>
            <EmbarkDefenseModifier>0</EmbarkDefenseModifier>
            <CapitalDefenseModifier>0</CapitalDefenseModifier>
            <CapitalDefenseFalloff>0</CapitalDefenseFalloff>
            <CityAttackPlunderModifier>0</CityAttackPlunderModifier>
            <ReligiousStrengthLossRivalTerritory>0</ReligiousStrengthLossRivalTerritory>
            <TradeMissionInfluenceModifier>0</TradeMissionInfluenceModifier>
            <TradeMissionGoldModifier>0</TradeMissionGoldModifier>
            <GoldenAgeValueFromKills>0</GoldenAgeValueFromKills>
            <Sapper>false</Sapper>
            <HeavyCharge>false</HeavyCharge>
            <PromotionPrereqOr1>PROMOTION_DRILL_1</PromotionPrereqOr1>
            <PediaType>PEDIA_MELEE</PediaType>
            <PediaEntry>TXT_KEY_PROMOTION_DRILL_2</PediaEntry>
        </Row>
The "
<Description>TXT_KEY_PROMOTION_DRILL_2</Description><Help>TXT_KEY_PROMOTION_DRILL_2_HELP</Help>
<PortraitIndex>20</PortraitIndex>
<IconAtlas>PROMOTION_ATLAS</IconAtlas>
<PediaType>PEDIA_MELEE</PediaType><PediaEntry>TXT_KEY_PROMOTION_DRILL_2</PediaEntry>
<Sound>AS2D_IF_LEVELUP</Sound>
"I think is necessary,and the
"<CannotBeChosen>false</CannotBeChosen>"
is worth to pay attention.If you give the promotion to a kind of unit for free,and hope others never have it.You should make the <CannotBeChosen>true</CannotBeChosen> and so you dont need <OrderPriority>.Rest every sentence makes an effect,If you don't need it,just delete it.Thers are also some sentence not included.They are written at other place.
My suggestion is you can creat another promotion that give combat bonus.Then use a lua function to give / remove the
combat bonus promotion from the units ,who have the DOFTerritoryBonusModifier promotion,according the plot they stand.That's what I did in my case.
You can creat promotion like this:

Code:
<GameData>
<UnitPromotions>
  <Row>
           <Type>PROMOTION_DOF_TERRITORY_BONUS</Type>
            <Description>TXT_KEY_DOF_TERRITORY_BONUS</Description>
            <Help>TXT_KEY_DOF_TERRITORY_BONUS_HELP</Help>
            <PortraitIndex>59</PortraitIndex>
            <IconAtlas>PROMOTION_ATLAS</IconAtlas>
            <PediaType>PEDIA_SHARED</PediaType>
            <PediaEntry>TXT_KEY_DOF_TERRITORY_BONUS</PediaEntry>
            <Sound>AS2D_IF_LEVELUP</Sound>
       </Row>
<Row>
           <Type>PROMOTION_DOF_TERRITORY_TRUE_BONUS</Type>
            <Description>TXT_KEY_PROMOTION_DOF_TERRITORY_BONUS</Description>
            <Help>TXT_KEY_PROMOTION_DOF_TERRITORY_BONUS_HELP</Help>
            <PortraitIndex>59</PortraitIndex>
            <IconAtlas>PROMOTION_ATLAS</IconAtlas>
            <PediaType>PEDIA_SHARED</PediaType>
           <CombatPercent>20</CombatPercent><PediaEntry>TXT_KEY_PROMOTION_DOF_TERRITORY_TRUE_BONUS</PediaEntry>
            <Sound>AS2D_IF_LEVELUP</Sound>
  </Row>
</UnitPromotions>
<Language_en_US>
<Row Tag="TXT_KEY_DOF_TERRITORY_BONUS"/>
<Text>........(I am not good at English.So ....You write it yourself.)</Text>
</Row>
<Row Tag="TXT_KEY_PROMOTION_DOF_TERRITORY_BONUS_HELP"/>
<Text>........(Hep info.)</Text>
</Row>
<Row Tag="TXT_KEY_PROMOTION_DOF_TERRITORY_TRUE_BONUS"/>
<Text>........(This also show in Civ clopedias.)</Text>
</Row>[/COLOR]
</Language_en_US>
<Language_zh_CN>
...........
</Language_en_US>
<Gamedata>
The two promotion has the same Description,Help,and icon.Player won't find it if I change one to another.But only the latter will give unit combat bonus,the former has not effect at all.
Now you need a lua function to convert the two promotion at every turn.Fill this in your lua.

Code:
local BonusID = GameInfo.UnitPromotions["PROMOTION_DOF_TERRITORY_BONUS"].ID
local BonusTrueID = GameInfo.UnitPromotions["PROMOTION_DOF_TERRITORY_TRUE_BONUS"].ID
function ConvertPromotion(PlayerID)
local player=Players[PlayerID]
for unit in player:Units() do
if unit:IsHasPromotion(BonusID) or unit:IsHasPromotion(BonusTrueID) then
local plot=unit:GetPlot()
local plotOwner=plot:GetOwner()
if (player:IsDoF(plotOwner)) then
unit:SetHasPromotion(BonusTrueID,true)
unit:SetHasPromotion(BonusID,false)
end
end
end
end
GameEvents.PlayerDoTurn.Add(ConvertPromotion)
Remember giving the lua InGameUIAddin entry. See in Kael's guide.
 
Last edited:
I think I understand it for the most part. Very extensive and helpful, thank you very much :D
I am going to try implement it now and see if it works, I will get back to you soon on whether or not I have any success :P

Your English is fully understandable by the way, no problems there. :)
 
Last edited:
I think I understand it for the most part. Very extensive and helpful, thank you very much :D

Your English is fully understandable by the way, no problems there. :)
Thank you.It thanks to the translation software.I really suggest you should add the <PortraitIndex>59</PortraitIndex> to your XML first.Try in the game.If it works,that's all OK.If it still works wrong,you might as well try my method then.

Edited:My function have a disadvantage that it only runs when a turn start.
It means if your Unit stands in friends territory when turn start,then its combat bonus will last the whole turn.
That says,It still enjoy the combat bonus even if it walk out of the friend's territory to attack enemy in current turn.
The similar case happens when a Unit walk into friend's territory and attack.
To solve it,you need find more GameEvent to hook up the function.
I used a GameEvent called CombatEnded.
But you want a GameEvent that take place before every combat start.
Unfortunately I don't know if such a GameEvent exists.
But I think someone will know better code.

Edit:
<FriendlyLandsModifier>20<FriendlyLandsModifier/>
You don't need creat the modifier.CIV5 has the modifier alreday.So you don't need the lua.
http://modiki.civfanatics.com/index.php?title=Main_Page
This page you can find many reference in "XML/SQL reference".
 
Last edited:
Oh, so I just create a promotion like any other one with
<FriendlyLandsModifier>20<FriendlyLandsModifier/>
instead of making a whole new code for a new modifier?
I'll try that out, thanks for letting me know
 
Back
Top Bottom