It would be great if you could answer! We have tried many things, and we are not sure if it just not possible or if there is some obscure way of doing it. We have created a Player tech that is only meant to be given when you have a certain spell or city improvement.
This is the code I have created, and modified around a certain theme, but no luck yet:
<Spells><SpellDef InternalName="GetAmulet"> <DisplayName>Get Amulet</DisplayName> <Description>Turns on AmuletOfFlames 2 for Unit Design</Description> <Cooldown>1</Cooldown> <AutoUnlock>1</AutoUnlock> <SpellBookSortCategory>World</SpellBookSortCategory> <SpellType>Strategic</SpellType> <SpellClass>Other</SpellClass> <SpellSubClass>Other</SpellSubClass> <SpellTargetType>Self</SpellTargetType> <CasterMustBeSov>1</CasterMustBeSov> <GameModifier> <ModType>Player</ModType> <Attribute>AbilityBonusOption</Attribute> <StrVal>AOF_RARE_UD</StrVal> <BoolVal1>1</BoolVal1> <Duration>-1</Duration> </GameModifier></SpellDef></Spells> <AbilityBonuses> <AbilityBonus InternalName="AOF_RARE_UDAbility"> <AbilityBonusType>Player</AbilityBonusType> <AbilityBonusOption InternalName="AOF_RARE_UD"> <AbilityBonusType>Player</AbilityBonusType> <Type>Army</Type> <DisplayName>Amulet Of Flames II</DisplayName> <Cost>10</Cost> </AbilityBonusOption> </AbilityBonus> </AbilityBonuses><GameItemTypes> <GameItemType InternalName="AmuletOfFlames_RARE2"> <DisplayName>Amulet of Flames II</DisplayName> <Description>When it is worn even the wearer's caress burns those he or she touches. Although some see this as a weapon, the Quendar are known to use it for pleasure.</Description> <Type>Accessory</Type> <CanBeEquipped>1</CanBeEquipped> <ShopValue>300</ShopValue> <AdditionalTrainingTurns>24</AdditionalTrainingTurns> <Prereq> <Type>AbilityBonusOption</Type> <Attribute>AOF_RARE_UD</Attribute> <Target>Player</Target> </Prereq> <GameModifier> <ModType>Unit</ModType> <Attribute>AdjustUnitStat</Attribute> <StrVal>UnitStat_Attack_Fire</StrVal> <Value>3</Value> </GameModifier> <IsAvailableForSovereignCustomization>0</IsAvailableForSovereignCustomization> <Likelihood>100</Likelihood> <RarityDisplay>Rare</RarityDisplay> <IsUsable>0</IsUsable> <Prereq> <Type>UnitStat_Level</Type> <Attribute>7</Attribute> </Prereq> <ArtDef>AmuletOfFlames_ArtDef2</ArtDef> <GameItemTypeArtDef InternalName="AmuletOfFlames_ArtDef2"> <GameItemTypeModelPack InternalName="AmuletOfFlames_Default2"> <IconFile>Gfx//Xtra//Icons//AmuletofFlame_Item2.png</IconFile> </GameItemTypeModelPack> </GameItemTypeArtDef> </GameItemType>
So, is there currently any game capability to add a trait, especially a Player trait, by a Spell or Improvement?
I look forward to your reply!
From a spell, or an item that you use:
<GameModifier> <ModType>Unit</ModType> <Attribute>UnlockUnitAbility</Attribute> <StrVal>your_abilitybonusoption_here</StrVal> <ApplyToCaster>1</ApplyToCaster> <Provides>adds the above trait</Provides> </GameModifier>
Is there any way to add a Player trait?
If the trait in question is bound to a unit ability (vs. a race ability) then Heavenfall's recommendation above should work fine. Alternatively, you could have the spell summon a champion unit that has the trait in question. This is similar to when you obtain surrender of an AI sovereign with Warlord, the Player trait affecting unit wages now applies to your empire.
For Player traits applied to the Race instead of the Sovereign, you'd need to create a new trait that's unit applicable.
N/A
It's to unlock a unit design item, but only if the player has a building that also sells the item to champions. There are similar improvements that sell a different range of items, so it can't just all unlock after researching a certain tech.
I don't have the XMLs in front of me but if I understand that you want to unlock an item by having a tech requirement + building requirement then the code for growth potion should look like the one you are looking for.
You'll have to do a work-around where the improvement produces a local resource and the item requires the local resource. This will make the unit design always available but only trainable if the resource is available as well.
The thing is the Vaults don't sell all the items, they sell a certain number out of the ones available. We only want to unlock an item for unit design if it's also available for purchase.
There are many great features available to you once you register, including:
Sign in or Create Account