Is there a way to: Disallow Unit Promotion(s) to Avoid Promotion Tree plus Reduce Number of Promotion Icons?

pqsc_programmer

Chieftain
Joined
Dec 26, 2022
Messages
3
Civ IV intermediate modder ... Civ 5 novice modder.

Think I understand difference between Unit Promotions vs. Unit Attributes.
Unit Promotions are actually Attributes which follow a Tree Hierarchy, whereas Unit Attributes are stand-alone.

I would like a Unique Unit Promotion which contains various Unit Attributes.
This Unique Promotion would disallow Unit Promotion(s) that gives/have that/those same Unit Attribute(s).

Example:
PROMOTION_SCOUTING_1 gives +1 visibility. There's also an Attribute which gives +1 visibility: PROMOTION_EXTRA_SIGHT_I.
PROMOTION_SCOUTING_2 adds +1 to that visibility. However, there's also an Attribute PROMOTION_EXTRA_SIGHT_II which gives +2 visibility, at one stroke.
PROMOTION_MEDIC gives AdjacentTileHealChange, yet this Requires, amongst other undesirable Promotions, PROMOTION_SCOUTING_2.
PROMOTION_MEDIC_II gives AdjacentTileHealChange, EnemyHealChange, and NeutralHealChange, Obviously, this Requires PROMOTION_MEDIC.

Goal:
I want a so-called Master Scout and a Combat Medic.
I only want the Unit Attribute of PROMOTION_EXTRA_SIGHT_II and the Attributes of PROMOTION_MEDIC_II.
Via the Promotion Tree this would Require 6 Promotions.
My Unique Promotion would disallow Five Promotions for any given Unique Unit.

I've searched and searched, and read and read Threads for "days".
The only quasi viable solutions I've found are:
- provide a ToolTip of a Units Promotions.
- reduce the icon size of Promotions in the UnitPanel.
- totally re-vamp the Promotion Tree.
- snippet GameEvents potential: How to trap/transfer INSTA_HEAL.

Certainly my Goal will need Lua.
Became comfortable with Civ IV Python, kinda getting grasp on Lua.

I see there is a CanHavePromotion hook.
Haven't researched because seems to me I'm looking for some kinda of OfferUnitPromotion or GiveUnitPromotion hook.

I think I'm in the correct Forum.
Wanted to address my Q directly to WHoward69, amongst others, whom seem quite knowledgeable.

Is there anyone who can point me in the Right Direction?
 
I don't understand what this distinction between unit promotions and unit "attributes" is even supposed to be. Most unit abilities are implemented via promotions anyway.

Every solution you've come up with is about a million times harder than it needs to be. Just make a new promotion and add it to the database, and then give it to the unit for free. Promotions given directly to the unit, either via Lua or by default, don't need to meet the promotion prerequisite requirements.

Spoiler :
Code:
<GameData>
    <UnitPromotions>
        <Row>
            <Type>PROMOTION_PQSC_MASTER_SCOUT</Type>
            <Description>TXT_KEY_PROMOTION_PQSC_MASTER_SCOUT</Description>
            <Help>TXT_KEY_PROMOTION_PQSC_MASTER_SCOUT_HELP</Help>
            <!-- see IconAtlas default -->
            <PortraitIndex>33</PortraitIndex>
            <Sound>AS2D_IF_LEVELUP</Sound>
            <CannotBeChosen>true</CannotBeChosen>
            <LostWithUpgrade>false</LostWithUpgrade>
            <!-- These 3 lines taken from PROMOTION_MEDIC_II -->
            <AdjacentTileHealChange>5</AdjacentTileHealChange>
            <EnemyHealChange>5</EnemyHealChange>
            <NeutralHealChange>5</NeutralHealChange>
            <PediaType>PEDIA_ATTRIBUTES</PediaType>
            <PediaEntry>TXT_KEY_PROMOTION_PQSC_MASTER_SCOUT</PediaEntry>
        </Row>
        <Row>
            <Type>PROMOTION_PQSC_COMBAT_MEDIC</Type>
            <Description>TXT_KEY_PROMOTION_PQSC_COMBAT_MEDIC</Description>
            <Help>TXT_KEY_PROMOTION_PQSC_COMBAT_MEDIC_HELP</Help>
            <!-- see IconAtlas default -->
            <PortraitIndex>33</PortraitIndex>
            <Sound>AS2D_IF_LEVELUP</Sound>
            <CannotBeChosen>true</CannotBeChosen>
            <LostWithUpgrade>false</LostWithUpgrade>
            <!-- These 3 lines taken from PROMOTION_MEDIC_II -->
            <AdjacentTileHealChange>5</AdjacentTileHealChange>
            <EnemyHealChange>5</EnemyHealChange>
            <NeutralHealChange>5</NeutralHealChange>
            <PediaType>PEDIA_ATTRIBUTES</PediaType>
            <PediaEntry>PROMOTION_PQSC_COMBAT_MEDIC</PediaEntry>
        </Row>
    </UnitPromotions>
    <Unit_FreePromotions>
        <Row>
            <UnitType>UNIT_PQSC_MASTER_SCOUT</UnitType>
            <PromotionType>PROMOTION_PQSC_MASTER_SCOUT</PromotionType>
        </Row>
        <Row>
            <UnitType>UNIT_PQSC_MASTER_SCOUT</UnitType>
            <PromotionType>PROMOTION_PQSC_MASTER_SCOUT</PromotionType>
        </Row>
    </Unit_FreePromotions>
</GameData>
 
If you are using modded DLL based on whoward's work, you can use Lua to override promotion availability, without redesigning the entire tree.

I am not sure which versions of the DLL have this, it's in VP DLL for sure, you will have to check the Lua API for something like GameEvents.UnitCanHavePromotion(promotion A) -- I'm not sure this is exactly the name and parameters of the function but it's very close to this. I've used it in the past with VP, works as expected:. Eg. Unit is eligible for promotion A as far as database definitions go, each time a list of eligible promotions is accessed, game runs the canhavepromotion function, which returns either true or false or nothing; if false is returned then the promotion won't be available for selection.

Afaik it does not work in the other direction ie if unit is not eligible in database, you cannot override to make it available by returning true -- can only be turned off via Lua, not turned on
 
I don't understand what this distinction between unit promotions and unit "attributes" is even supposed to be. Most unit abilities are implemented via promotions anyway.

Every solution you've come up with is about a million times harder than it needs to be. Just make a new promotion and add it to the database, and then give it to the unit for free. Promotions given directly to the unit, either via Lua or by default, don't need to meet the promotion prerequisite requirements.

Spoiler :
Code:
<GameData>
    <UnitPromotions>
        <Row>
            <Type>PROMOTION_PQSC_MASTER_SCOUT</Type>
            <Description>TXT_KEY_PROMOTION_PQSC_MASTER_SCOUT</Description>
            <Help>TXT_KEY_PROMOTION_PQSC_MASTER_SCOUT_HELP</Help>
            <!-- see IconAtlas default -->
            <PortraitIndex>33</PortraitIndex>
            <Sound>AS2D_IF_LEVELUP</Sound>
            <CannotBeChosen>true</CannotBeChosen>
            <LostWithUpgrade>false</LostWithUpgrade>
            <!-- These 3 lines taken from PROMOTION_MEDIC_II -->
            <AdjacentTileHealChange>5</AdjacentTileHealChange>
            <EnemyHealChange>5</EnemyHealChange>
            <NeutralHealChange>5</NeutralHealChange>
            <PediaType>PEDIA_ATTRIBUTES</PediaType>
            <PediaEntry>TXT_KEY_PROMOTION_PQSC_MASTER_SCOUT</PediaEntry>
        </Row>
        <Row>
            <Type>PROMOTION_PQSC_COMBAT_MEDIC</Type>
            <Description>TXT_KEY_PROMOTION_PQSC_COMBAT_MEDIC</Description>
            <Help>TXT_KEY_PROMOTION_PQSC_COMBAT_MEDIC_HELP</Help>
            <!-- see IconAtlas default -->
            <PortraitIndex>33</PortraitIndex>
            <Sound>AS2D_IF_LEVELUP</Sound>
            <CannotBeChosen>true</CannotBeChosen>
            <LostWithUpgrade>false</LostWithUpgrade>
            <!-- These 3 lines taken from PROMOTION_MEDIC_II -->
            <AdjacentTileHealChange>5</AdjacentTileHealChange>
            <EnemyHealChange>5</EnemyHealChange>
            <NeutralHealChange>5</NeutralHealChange>
            <PediaType>PEDIA_ATTRIBUTES</PediaType>
            <PediaEntry>PROMOTION_PQSC_COMBAT_MEDIC</PediaEntry>
        </Row>
    </UnitPromotions>
    <Unit_FreePromotions>
        <Row>
            <UnitType>UNIT_PQSC_MASTER_SCOUT</UnitType>
            <PromotionType>PROMOTION_PQSC_MASTER_SCOUT</PromotionType>
        </Row>
        <Row>
            <UnitType>UNIT_PQSC_MASTER_SCOUT</UnitType>
            <PromotionType>PROMOTION_PQSC_MASTER_SCOUT</PromotionType>
        </Row>
    </Unit_FreePromotions>
</GameData>
Thank You. I probably wasn't clear.

If I want a Unique Unit with an Initial +2 Sight and +1 Movement then I can set Moves for the Unit and create a Unique Promotion with VisibilityChange (an Attribute) of 2.
The same goal can also be accomplished via SCOUT 1 thru 3 Promotions (in the Tree) -or- Promotion Extra Sight 2 and Promotion Extra Moves 1 (standalone Attribute changes -- not in Tree -- yet still called Promotion).

All of those Promotions change Attributes (VisibilityChange and MovesChange) and appear in the Unit Panel (I'll forego discussion on generic Icons).

SCOUT... (as noted) is in the Promotion Tree, whereas Promotion Extra... (as noted) just change Attributes and are not in the Tree.

The problem occurs, for me, in the Scout -- other Attributes also present a problem, but using Scout as an example -- when Unit becomes eligible for the Scout 1 Promotion.
Recalling that my UU does not have Scout 1, but rather a Unique Promotion which changes several attributes, including what Scout 1 changes.

If I have a Unique Promotion which increases via VisibilityChange and MovesChange, then when Unit becomes eligible for Scout 1 Promotion, and Player chooses Promotion, they now have more visibility than wanted for the Unit (+3 from base of 2).
Furthermore, should Unit somehow become eligible for Scout 3, they definitely have more moves than ever intended. For me, they simply should not be able to move that far in one turn.

So, I was just inquiring whether there was a way to prevent such a thing from happening.
Apologies for being unclear. Hope this was clearer.
 
If you are using modded DLL based on whoward's work, you can use Lua to override promotion availability, without redesigning the entire tree.

I am not sure which versions of the DLL have this, it's in VP DLL for sure, you will have to check the Lua API for something like GameEvents.UnitCanHavePromotion(promotion A) -- I'm not sure this is exactly the name and parameters of the function but it's very close to this. I've used it in the past with VP, works as expected:. Eg. Unit is eligible for promotion A as far as database definitions go, each time a list of eligible promotions is accessed, game runs the canhavepromotion function, which returns either true or false or nothing; if false is returned then the promotion won't be available for selection.

Afaik it does not work in the other direction ie if unit is not eligible in database, you cannot override to make it available by returning true -- can only be turned off via Lua, not turned on
Much appreciated.

I did see Post about when CanHavePromotion was included in official DLL patch release.
Also saw WHoward's comment about being in his DLL prior to official release (was funny, could relate from professional experience).

By VP DLL, I'm pretty sure you're referring to Vox Populi DLL.
Saw numerous Posts about, but was hesitant to take detour as it seemingly imployed some kind of complete Game Install.
I have a little experience with Dynamic Linked Libraries (DLL's) and do realize that they can Override/Redefine routines in an Original/Core Library.

Thanks for CanHavePromotion should return False, if goal.

Which leads me to another question, if I can further impose on your time.
I have BNW expansion. However, with Civ V I've noticed -- not intending to be critical -- that contents of DLC folders for critical Lua files oftentimes have differences (occasionally significant) from non-DLC.
I attribute this to lack of Project Management -- again, not to be critical. Nevertheless, with an adequate Text File Compare utility, a Modder can overcome differences from Vanilla.

If I may, here's my questions:
Let's say I can yank-out of latest VP DLL its GameEvents.CanHavePromotion declaration and definition (Lua D&D).

#1 Did you have to include the entire VP DLL into you ModBuddy solution?
#2 If so, did you also have to modify other Lua files to accomodate this?
#3 if not, what other VP DLL Lua files were needed to incorporate VP DLL's Unique CanHavePromotion Lua D&D?

Please, forgive my overreach of your time.
I probably missed it, but I've yet to find a download of just the VP DLL, its Source Code, and Link Instructions.

I'm not an advanced Civ Modder, but I do understand Programming.
 
Top Bottom