I just did the exact opposite, so i think it can work for you as well.
When my Cirdan stay near a Port he gives to the structure the ability to build a great personal Vessel.
This is the power i gave to Cirda so that at level 3 it can trigger to the port the AttributeModifier ShipwrightKingKnowledge:
;-----------------------------------------------------------------------------
; Shipwright King
;-----------------------------------------------------------------------------
Behavior = AttributeModifierAuraUpdate ModuleTag_Shipwright
StartsActive = No
BonusName = ShipwrightKingKnowledge
TriggeredBy = Upgrade_ObjectLevel3
RefreshDelay = 2000
Range = 300
AntiCategory = BUFF
ObjectFilter = NONE +PORT
End
Behavior = UnpauseSpecialPowerUpgrade ModuleTag_ShipwrightLeadership
SpecialPowerTemplate = SpecialAbilityFakeLeadership2
TriggeredBy = Upgrade_ObjectLevel3
End
Behavior = SpecialPowerModule ModuleTag_ShipwrightLeadershipUpdate
SpecialPowerTemplate = SpecialAbilityFakeLeadership2
UpdateModuleStartsAttack = No
StartsPaused = Yes
End
Then into the AttributeModifier.ini i defined it:
ModifierList ShipwrightKingKnowledge
Category = LEADERSHIP
Upgrade = Upgrade_ShipwrightKing Delay:500
Modifier = PRODUCTION 200%
Duration = 3000
FX = FX_GenericLeadership
ReplaceInCategoryIfLongest = Yes
IgnoreIfAnticategoryActive = Yes
End
So as you can see there is the 2nd line of the Modifier that state "Upgrade = Upgrade_ShipwrightKing Delay:500 ".
It means that this attribute gives the Upgrade_ShipWrightKing to the filtered objects and the duration set the expire time in 3 seconds (If Cirdan go away from it).
So basically you just need to add a condition of NeededUpgrade into the object SpecialPower's code or in the relative Button, like:
;------------------------------------------------------------------------------
CommandButton Command_ConstructCirdanVessel
Command = UNIT_BUILD
Object = ElvenCirdanVessel
Options = CANCELABLE NEED_UPGRADE
NeededUpgrade = Upgrade_ShipwrightKing
TextLabel = CONTROLBAR:ConstructCirdanVessel
ButtonImage = BCShipwright_GoodBattleship
ButtonBorderType = BUILD
DescriptLabel = CONTROLBAR:ToolTipBuildConstructCirdanVessel
Radial = Yes
InPalantir = Yes
ShowProductionCount = Yes
End
I hope this could help you
Edited by Symonius, 22 April 2020 - 11:19 PM.