Xml Calculate question

I was trying to change the BowAttack_ a bid trying to balance it a bid more in favor of trained Archers vs spammed cheap units

so what i wanted to do is scale the damage an arrow does on how "precise" he is shot at the targe. Using the Archers Accuracy and the targets Dodge. so I inserted a GameModifier which looks like this

Code: xml
  1.    
  2. <GameModifier>
  3.   <ModType>Unit</ModType>
  4.       <Attribute>AdjustUnitStat</Attribute>
  5.       <StrVal>UnitStat_Attack_Pierce</StrVal>
  6.       <ApplyToCaster>1</ApplyToCaster>
  7.       <Duration>1</Duration>
  8.       <UpdateDurationAtTurnStart>1</UpdateDurationAtTurnStart>
  9.       <Calculate InternalName="Do" ValueOwner="TargetUnit">
  10.         <Expression><![CDATA[[UnitStat_Dodge]+[UnitStat_DodgeAgainstRanged]]]></Expression>
  11.       </Calculate>
  12.       <Calculate InternalName="AC" ValueOwner="CastingUnit">
  13.         <Expression><![CDATA[[UnitStat_Accuracy]]]></Expression>
  14.       </Calculate>
  15.       <Calculate InternalName="Calc">
  16.         <Expression><![CDATA[[AC]-[Do]]]></Expression>
  17.       </Calculate>
  18.       <Calculate InternalName="Value">
  19.         <Expression><![CDATA[[Calc]*0.1]]></Expression>
  20.       </Calculate>
  21.     </GameModifier>

 

now everything does work fine except... that the variable "Do" is taken from the attacking unit not the targeted one, basically if i equip +Accuracy Items my Damage increases and if i add +Dodge it decreases. Is this me doing something wrong or is this a bug, because i have absolutly no idea how to reference the targeted unit if target refers to my archer

10,788 views 12 replies
Reply #1 Top

I think you will have to define [Do] by [Unit_GetUnitStat_Dodge], taken from "TargetUnit"... try it out.

Reply #2 Top

I tried using [Unit_GetUnitStat_Dodge] and unfortunately it always returned 0, it does not seem to work at all. I couldn't find any instance of it within the CoreSpells.xml as well. However putting

Code: xml
  1.     <GameModifier>
  2.       <ModType>Unit</ModType>
  3.       <Attribute>AdjustUnitStat</Attribute>
  4.       <StrVal>UnitStat_Moves</StrVal>
  5.       <Calculate InternalName="Value" ValueOwner="TargetUnit">
  6.         <Expression><![CDATA[[UnitStat_Dodge]]]></Expression>
  7.       </Calculate>
  8.     </GameModifier>

In the same spell works as exspected  so it seem that using TargetUnit within a GameModifier that uses <ApplyToCaster>1</ApplyToCaster> creates a bug :(

Reply #3 Top

As far as I can tell, you are attempting to pull dodge stat properly.

Did you test if you managed to successfully to pull the dodge number?

If not, it's quite possibly that, like many other stats, it's unpullable (the tag isn't working).

Reply #4 Top

It is pullable however i wanted to pull it from the target im shooting at and it seem that

Code: xml
  1. <span style="color: #0000ff;">&lt;</span><span style="color: #800000;">ApplyToCaster</span><span style="color: #0000ff;">&gt;</span>1<span style="color: #0000ff;">&lt;/</span><span style="color: #800000;">ApplyToCaster</span><span style="color: #0000ff;">&gt;</span>

 

changes the TargetUnit tag to my shooter basically I'm pulling the shooters not the targets dodge

I went ahead and tried that second block I posted within the same spell to see if i can get the correct dodge when the ApplytoCaster is not there and indeed it did work.

The bug is that the two Tags don't work together :(

Reply #5 Top
  1. <ApplyToCaster>1</ApplyToCaster>
  2.       <Duration>1</Duration>
  3.       <UpdateDurationAtTurnStart>1</UpdateDurationAtTurnStart>

Take this stuff out and all should be well.

Reply #6 Top

I agree with piffle- I think it will work without the apply to caster.

Reply #7 Top

Yes i would pull the right dodge value, but how do i change the casters damage without ApplyToCaster? :/

 

Reply #8 Top

Sorry, I thought you were adding this to bows, but that wouldn't work either.

Have you tried making this into a level-up trait?

Reply #9 Top

i cant pull casting or targeted unit from a trait. My main idea was to make archers "dependent" on two Attributes rather then just maxing damage in order to give them some form of balance and making it less viable to just spam glass-cannons.

I have a few new ideas how to achieve that goal but i found the idea of making accuracy an actually important stat form them a nice idea :(

Reply #10 Top

You can do BattleAutoCastSpell from a trait.

Look at the Amarian blood trait.

Reply #11 Top

yes i can, in fact you can even do it from an item albeit with a strange double casting buff, but that would make the buff static, i can already use the Accuracy to increase the damage the part of my code which doesn't work was using the targets dodge, to give it a more dynamic feel vs high dodge targets. :)

Reply #12 Top

While I find it a bit hard to understand the logic behind what you are trying to do, this is your mod ;). Here is an idea on how to solve your problem, in a way:

Instead of damage bonus (or total) of (acc-dodge)*n, use acc as bonus damage and dodge as bonus armor.

This means that the higher accuracy the unit have, the harder and more frequently it will hit, and the more dodge the unit have, the more armor it will have.

The armor against the arrows can be added by 1 of two ways- adding it directly to piercing, and update the other weapons accordingly, or create another attack/defense type, though it might take some work and might be bugged.