UnitStat_IsBow for skills based on units stats - how does it work?

also racial class skill?

Hello,

 

I'm trying to make some skills based on the weapon unit is using. There are supposed to be some, for example Master Archer skill:

    <AbilityBonus InternalName="MasterArcherAbility">
        <AbilityBonusOption InternalName="MasterArcher">
            <DisplayName>Master Archer</DisplayName>
            <Description>+25 Critical Hit Chance when using a Bow</Description>
            <Icon>Ability_MasterArcher_Icon.png</Icon>
            <GameModifier>
                <ModType>Unit</ModType>
                <Attribute>AdjustUnitStat</Attribute>
                <BoolVal1>1</BoolVal1>
                <StrVal>UnitStat_ChanceToCrit</StrVal>
                <StrVal2>UnitStat_IsBow</StrVal2>
                <Value>25</Value>
                <BonusValue>0.5</BonusValue>
                <Provides>+25 Critical Hit Chance when using a Bow</Provides>
                <vsHigher>1</vsHigher>
            </GameModifier>
            <IsCombatAbility>1</IsCombatAbility>
            <Type>Ability</Type>
            <AIData AIPersonality="AI_General">
                <AIPriority>5</AIPriority>
            </AIData>
        </AbilityBonusOption>
    </AbilityBonus>

I have copied it and tried to make a skill based on it. However when I choose it in Unit Design, it simply adds bonuses even when the unit does not use bows:

    <AbilityBonus InternalName="ArcheryAbility">
        <AbilityBonusType>Unit_Design</AbilityBonusType>
        <AbilityBonusOption InternalName="Archery">
            <DisplayName>Archery Training</DisplayName>
            <Description>+10 Attack and +10 Accuracy when using Bow. +10 Critical Hit Chance when using a Bow.</Description>
            <Icon>Ability_Archery_Icon.png</Icon>
        <ProductionRequirement>
            <Type>Resource</Type>
            <Attribute>Gold</Attribute>
            <Value>2</Value>
        </ProductionRequirement>
           <GameModifier>
                <ModType>Unit</ModType>
                <Attribute>AdjustUnitStat</Attribute>
                <BoolVal1>1</BoolVal1>
                <StrVal>UnitStat_Attack_Boost</StrVal>
                <StrVal2>UnitStat_IsBow</StrVal2>
                <Value>10</Value>
                <BonusValue>0.5</BonusValue>
<!--                 <PerLevel>1</PerLevel> -->
                <Provides>+10 Attack per level when using Bow.</Provides>
            </GameModifier>
            <GameModifier>
                <ModType>Unit</ModType>
                <Attribute>AdjustUnitStat</Attribute>
                <BoolVal1>1</BoolVal1>
                <StrVal>UnitStat_Accuracy</StrVal>
                <StrVal2>UnitStat_IsBow</StrVal2>
                <Value>1</Value>
                <BonusValue>0.5</BonusValue>
<!--                 <PerLevel>1</PerLevel> -->
                <Provides>+10 Accuracy per level when using Bow.</Provides>
            </GameModifier>
            <GameModifier>
                <ModType>Unit</ModType>
                <Attribute>AdjustUnitStat</Attribute>
                <BoolVal1>1</BoolVal1>
                <StrVal>UnitStat_ChanceToCrit</StrVal>
                <StrVal2>UnitStat_IsBow</StrVal2>
                <Value>10</Value>
                <BonusValue>0.5</BonusValue>
                <Provides>+10 Critical Hit Chance when using a Bow</Provides>
<!--                 <vsHigher>1</vsHigher>
                <vsLower>1</vsLower> -->
            </GameModifier>
            <AdditionalTrainingTurns>10</AdditionalTrainingTurns>
            <Type>Army</Type>
            <AIData AIPersonality="AI_General">
                <AIPriority>5</AIPriority>
            </AIData>
        </AbilityBonusOption>
    </AbilityBonus>

Any ideas how to make it right? Does it have to be "Ability" type? What is the tag BonusValue doing?

 

Also I have tried to make some racial class skills and have failed miserably. Apparently only one Prereq is required, if two are present game checks for only one. I have tried different things, making the ability as Spell type didn't really helped (one skill worked others didn't). Restricting ability didn't worked either (added all the bloods except the one that was supposed to have it, all but the first restrictedability got ignored).

Any idea how to make it right? If this is even possible?

 

Help. Anyone who knows how to do it or has seen any mod achieved those, please let me know.

12,358 views 1 replies
Reply #1 Top

Thanks to Primal_Savage, here is how it works:

 

IF StrVal2 (UnitStat_IsBow: 0 or 1) is higher (vsHigher=1) than BonusValue (0.5), then (BoolVal1=1, true) StrVal (UnitStat_ChanceToCrit) gets +25% (Value).

BonusValue is just a number you compare your UnitStat w/. I usually input 0.99 instead of 0.5.

 

Those skills will use PerLevel tag for scaling, as well as Multiplier tag.

An example of working skills:

    <AbilityBonus InternalName="ArcheryTraining_Warrior">
        <AbilityBonusType>Unit_Level</AbilityBonusType>
        <AbilityBonusOption InternalName="ArcheryTraining_Warrior">
            <DisplayName>Archery Training</DisplayName>
            <Description>+20 Accuracy and +6 Initiative when using a Bow.</Description>
            <Icon>Ability_ArcheryWarrior_Icon.png</Icon>
            <PerkTreePosX>6</PerkTreePosX>
            <PerkTreePosY>2</PerkTreePosY>
            <GameModifier>
                <ModType>Unit</ModType>
                <Attribute>AdjustUnitStat</Attribute>
                <BoolVal1>1</BoolVal1>
                <StrVal>UnitStat_Dodge</StrVal>
                <StrVal2>UnitStat_IsBow</StrVal2>
                <Value>5</Value>
                <BonusValue>0.5</BonusValue>
                <vsHigher>1</vsHigher>
<!--                 <PerLevel>1</PerLevel> -->
                <Provides>+5 Dodge when using Bow.</Provides>
            </GameModifier>
             <GameModifier>
                <ModType>Unit</ModType>
                <Attribute>BattleAutoCastSpell</Attribute>
                <BoolVal1>1</BoolVal1>
                <StrVal>Archery_Self</StrVal>
                <StrVal2>UnitStat_IsBow</StrVal2>
                <Value>100</Value>
                <BonusValue>0.5</BonusValue>
                <vsHigher>1</vsHigher>
                <Provides>Casts Archery Training Spell</Provides>
            </GameModifier>
            <IsCombatAbility>1</IsCombatAbility>
            <Type>Ability</Type>
            <Prereq>
                <Type>AbilityBonusOption</Type>
                <Target>Unit</Target>
                <Attribute>PathOfTheWarrior</Attribute>
            </Prereq>
            <AIData AIPersonality="AI_General">
                <AIPriority>5</AIPriority>
            </AIData>
        </AbilityBonusOption>
    </AbilityBonus>
    <AbilityBonus InternalName="SniperTraining_Warrior">
        <AbilityBonusType>Unit_Level</AbilityBonusType>
        <AbilityBonusOption InternalName="SniperTraining_Warrior">
            <DisplayName>Sniper Training</DisplayName>
            <Description>+25% Attack per Level , +20 Critical Hit Chance and +100% Critical Hit Damage when using a Bow.</Description>
            <Icon>Ability_SniperWarrior_Icon.png</Icon>
            <PerkTreePosX>7</PerkTreePosX>
            <PerkTreePosY>2</PerkTreePosY>
           <GameModifier>
                <ModType>Unit</ModType>
                <Attribute>AdjustUnitStat</Attribute>
                <BoolVal1>1</BoolVal1>
                <StrVal>UnitStat_Attack_Boost</StrVal>
                <StrVal2>UnitStat_IsBow</StrVal2>
                <Multiplier>1.25</Multiplier>
                <BonusValue>0.5</BonusValue>
                 <vsHigher>1</vsHigher>
                <PerLevel>1</PerLevel>
                <Provides>+10 Attack when using Bow.</Provides>
            </GameModifier>
            <GameModifier>
                <ModType>Unit</ModType>
                <Attribute>AdjustUnitStat</Attribute>
                <BoolVal1>1</BoolVal1>
                <StrVal>UnitStat_ChanceToCrit</StrVal>
                <StrVal2>UnitStat_IsBow</StrVal2>
                <Value>20</Value>
                <BonusValue>0.5</BonusValue>
                 <vsHigher>1</vsHigher>
                <Provides>+20 Critical Hit Chance when using a Bow</Provides>
            </GameModifier>
            <GameModifier>
                <ModType>Unit</ModType>
                <Attribute>AdjustUnitStat</Attribute>
                <BoolVal1>1</BoolVal1>
                <StrVal>UnitStat_CritDamageMultiplier</StrVal>
                <StrVal2>UnitStat_IsBow</StrVal2>
                <Value>1</Value>
                <BonusValue>0.5</BonusValue>
                 <vsHigher>1</vsHigher>
<!--                 <PerLevel>1</PerLevel> -->
                <Provides>+100% to Critical Hit damage</Provides>
            </GameModifier>
            <IsCombatAbility>1</IsCombatAbility>
            <Type>Ability</Type>
            <Prereq>
                <Type>AbilityBonusOption</Type>
                <Target>Unit</Target>
                <Attribute>ArcheryTraining_Warrior</Attribute>
            </Prereq>
            <AIData AIPersonality="AI_General">
                <AIPriority>5</AIPriority>
            </AIData>
        </AbilityBonusOption>
    </AbilityBonus>

 

Because some bonuses do not work - Initiative does nothing, Accuracy shows higher chance to hit but in reality it isn't, those need to be applied by a spell cast at the start of combat. Those that have effect based on IsBow will require extra wizardry in order to have them applied desired effect and only under desired conditions.

Here is working example for the skill above:

    <SpellDef InternalName="Archery_Self">
        <DisplayName>Archery Training</DisplayName>
        <Description>Archery training allows archers to fire their weapons much faster and more accurate than soldiers without training.</Description>
        <Image>T_Berzerk_Painting.png</Image>
        <IconFG>Ability_ArcheryWarrior_Icon.png</IconFG>
        <CanStack>0</CanStack>
        <SpellBookSortCategory>Unit</SpellBookSortCategory>
        <SpellBookSortSubCategory>UnitEnchantment</SpellBookSortSubCategory>
        <SpellType>Tactical</SpellType>
        <SpellClass>Defensive</SpellClass>
        <SpellSubClass>Buff</SpellSubClass>
        <SpellTargetType>Self</SpellTargetType>
        <IsCastable>0</IsCastable>
        <IsSpecialAbility>1</IsSpecialAbility>
        <PreventStackingWith>Archery_Self</PreventStackingWith>
        <IgnoreCastAnim>1</IgnoreCastAnim>
        <GameModifier>
            <ModType>Unit</ModType>
            <Attribute>AdjustUnitStat</Attribute>
            <StrVal>UnitStat_Accuracy</StrVal>
            <DisplayName>Archery Training</DisplayName>
            <Duration>-1</Duration>
            <Calculate InternalName="Value" ValueOwner="TargetUnit">
        <Expression><![CDATA[[UnitStat_IsBow] *20]]></Expression>
      </Calculate>
    </GameModifier>
        <GameModifier>
            <ModType>Unit</ModType>
            <Attribute>AdjustUnitStat</Attribute>
            <StrVal>UnitStat_CombatSpeed</StrVal>
            <Duration>-1</Duration>
            <Calculate InternalName="Value" ValueOwner="TargetUnit">
        <Expression><![CDATA[[UnitStat_IsBow] *4]]></Expression>
      </Calculate>
    </GameModifier>
        <GameModifier>
            <ModType>Unit</ModType>
            <Attribute>AdjustUnitStat</Attribute>
            <StrVal>UnitStat_CombatSpeed</StrVal>
            <Duration>1</Duration>
            <UpdateDurationAtTurnStart>1</UpdateDurationAtTurnStart>
            <Value>100</Value>
        </GameModifier>
        <AIData AIPersonality="AI_General">
            <AIPriority>10</AIPriority>
        </AIData>
    </SpellDef>