How to make an item only usable if character has ability ?

Hi all,

I'd like to be able to restrict a particular item (could be any item but it's a horse i'm trying it with currently) so it is only usable by a character that has a particular ability/trait.

Basically the scenario might be something like:

- create a new item which happens to be a mount called "Wild Horse"

- create a unit level ability "Ride Wild Horse" that when selected allows the character to ride a "Wild Horse"

- although it would be possible to trade the item to another character... they should not be able to "equip" the horse (unless they too have the "Ride Wild Horse" ability

Problem I have is getting the prereq on the item to work, starting to think it's not possible :-(  I have tried all these prereqs...

<Prereq>
   <Type>AbilityBonusOption</Type>
   <Attribute>RideWildHorse</Attribute>
</Prereq>

<Prereq>
   <Type>AbilityBonusOption</Type>
   <Attribute>RideWildHorse</Attribute>
   <Target>Unit</Target>
</Prereq>

And have also tried giving the ability a unique unitstat and then doing this...

<Prereq>
   <Type>UnitStat_CanRideWildHorse</Type>
   <Attribute>1</Attribute>
</Prereq>

 

None of these seem to work, I can give the WildHorse item to any character and they can equip it just fine.  Any ideas?

5,747 views 12 replies
Reply #1 Top

Indeed, you cannot limit equipment in this way. The only allowed prereqs for equipment are techs, races (blocks unit design and shop) and unit level. Besides unit level, there is no good way to block a unit from equipping an item once it is in the inventory. There is one bad way, but that means the item is destroyed if placed in the inventory of a unit that can't equip it.

A work-around is to give the equipment a modifier that requires a unitstat on the wearer. For example, a mount can be equipped by anyone but if ridden by a UnitStat_Dragonlord = 1 then the unit will also unlock a firebreath attack, or deal extra melee damage.

Reply #2 Top

Dammit.  Thanks for confirming though.

Re. your workaround, not a bad option... in fact I might even be able to cancel out the bonuses... so if you don't have the unitstat the opposite effects are applied.. 

Hmmm that look like something like this maybe...

<GameModifier>
   <ModType>Unit</ModType>
   <Attribute>AdjustUnitStat</Attribute>
   <StrVal>UnitStat_WeightCapacity</StrVal>
   <StrVal2>UnitStat_CanRideWildHorse</StrVal2>
   <Value>-40</Value>
   <vsLower>1</vsLower>
   <Provides>blah</Provides>
</GameModifier>

??

Reply #3 Top

Actually now that i'm trying to do it i'm starting to think that modifying weightcapcity like this won't work because these unitstat comparion this will only when when comparing values.... so like when attacking a unit.

HF - reading your reply above though you mentioned unlocking a firebreath attack with a unitstat... can you alaborate on what you meant?  Or is there an item in the Reliquary that does something similar that you could point me at as an example?

Cheers

Reply #4 Top

Require 2 unitstat for unlock. Put +1 on item and +1 on trait.

Reply #5 Top

(I think) I get what you mean now, but I can't seem to get the unitstat prereq's to work...

I have this spell/ability:

 

<SpellDef InternalName="JB_AwakenDemonSteed">
   <DisplayName>Awaken Demon Steed</DisplayName>
   <Description>Awakens a Demon Steed.</Description>
   <Image>T_Confusion_Painting.png</Image>
   <IconFG>T_Confusion_Icon.png</IconFG>
   <IconColor>32,45,243</IconColor>
   <AutoUnlock>1</AutoUnlock>
   <CanStack>0</CanStack>
   <SpellBookSortCategory>Unit</SpellBookSortCategory>
   <SpellBookSortSubCategory>UnitEnchantment</SpellBookSortSubCategory>
   <SpellType>Strategic</SpellType>
   <SpellClass>Defensive</SpellClass>
   <SpellSubClass>Buff</SpellSubClass>
   <SpellTargetType>Self</SpellTargetType>
   <Range>0</Range>
   <Prereq>
      <Type>UnitStat</Type>
      <Attribute>UnitStat_CallDemonSteed</Attribute>
      <Value>1</Value>
   </Prereq>

...etc
</SpellDef>

Note the prereq.

Then I have an ability trait with this in there as one of the game modifiers....

<GameModifier>
   <ModType>Unit</ModType>
   <Attribute>AdjustUnitStat</Attribute>
   <StrVal>UnitStat_CallDemonSteed</StrVal>
   <Value>1</Value>
   <Provides>Unit can call and ride a Demon Steed</Provides>
</GameModifier>

 

So I would have expected as a start point, that giving a character this ability would unlock the spell above.  Doesn't seem to work, been testing a heap of stuff and not sure what i'm missing (probably something simple).

Can you see anything obvious?

Reply #6 Top

Make sure the unitstat is defined.

Reply #7 Top

I thought of that.... but i've been checking out the UnitStat_Reliquary_HatchedDragon and that doesn't seem to be defined anywhere?

(still working on it)

Reply #8 Top

Oh wow, that works.    :D    :D

Edit -> HF, thanks for the assistance, would never have gotten something like this to work without your help.  I have a new appreciation for (background) unitstats, opens up quite a few sneaky tricks.  You've done some really clever stuff with them.

 

 

Bloody hell though, i've spent the last 3 hours trawling through the reliquary trying to understand the dragonrider stuff.... I thought I got it... however the one thing is that I can't for the life of me see anywhere that you have defined the unitstat UnitStat_Reliquary_HatchedDragon... so then how the heck does that work without it?  Or is it defined somewhere and i'm just not finding it in my search?

 

Reply #9 Top

<UnitStatType InternalName="UnitStat_Reliquary_Dragonrider">
        <DisplayName>dfas</DisplayName>
        <DisplayNameShort>adfs</DisplayNameShort>
        <Description>afdsasdf</Description>
        <Icon>Stat_Dodge_Icon.png</Icon>
        <Hidden>1</Hidden>
    <UnitStatGrouping>CombatStat</UnitStatGrouping>
    <UnitStatGrouping>UnitDetailsCombatStat</UnitStatGrouping>
</UnitStatType>

<UnitStatType InternalName="UnitStat_Reliquary_HatchedDragon">
        <DisplayName>dfas</DisplayName>
        <DisplayNameShort>adfs</DisplayNameShort>
        <Description>afdsasdf</Description>
        <Icon>Stat_Dodge_Icon.png</Icon>
        <Hidden>1</Hidden>
    <UnitStatGrouping>CombatStat</UnitStatGrouping>
    <UnitStatGrouping>UnitDetailsCombatStat</UnitStatGrouping>
</UnitStatType>

 

in nevertouchunitstat.xml

Reply #10 Top

Stupid windows search, dunno why that file didn't come up when I was searching.

Thanks.

Reply #11 Top

Use Notepad++ search in files function.

Reply #12 Top

Good suggestion thanks, i'm using it (notepad++) for editing anyways so yep good suggestion cheers.   :thumbsup: