Adding the 'Type Mastery' perks from Master of Magic

I asked in the topic about adding a new sovereign ability, but my question was answered and I felt it was more relevant and useful to others to create a new topic.

For example, say a Sovereign has Earth Mastery as one of their talents. I want to give them a 20% boost  to essence, rather than just a 10% boost. But I'm not quite sure how to do this. I've tried looking around, but I don't think I'm using <Calculate> properly.

Here's what I've got so far. Forgive how scabby it is.

Code: xml
  1. &lt;AbilityBonuses&gt;
  2.     
  3.     &lt;AbilityBonus InternalName = "MoM_ShardMaster"&gt;
  4.         
  5.         &lt;AbilityBonusType&gt;Champion_Talent&lt;/AbilityBonusType&gt;
  6.         
  7.         &lt;AbilityBonusOption InternalName = "Sovereign_Ability_ShardMaster"&gt;
  8.             &lt;DisplayName&gt;Shard Master&lt;/DisplayName&gt;
  9.             &lt;Description&gt;An extra 100% essence for all units for each shard controlled.&lt;/Description&gt;
  10.             &lt;Icon&gt;Talent_Brilliant.png&lt;/Icon&gt;
  11.             &lt;Cost&gt;5&lt;/Cost&gt;
  12.             
  13.             &lt;GameModifier&gt;
  14.                 &lt;ModType&gt;Player&lt;/ModType&gt;
  15.                 &lt;Attribute&gt;AbilityBonus&lt;/Attribute&gt;
  16.                 &lt;StrVal&gt;A_UnitStat_Essence&lt;/StrVal&gt;
  17.                 &lt;Calculate InternalName = "ShardBonus" ValueOwner = "PlayerSovereign"&gt;
  18.                 &lt;Expression&gt;&lt;![CDATA[[UnitStat_NumAllShards] * 100]]&gt;&lt;/Expression&gt;
  19.                 &lt;/Calculate&gt;
  20.                 &lt;Calculate InternalName = "Value" ValueOwner = "PlayerSovereign"&gt;
  21.                 &lt;Expression&gt;&lt;![CDATA[[100 + ShardBonus]]]&gt;&lt;/Expression&gt;
  22.                 &lt;/Calculate&gt;
  23.                 &lt;Provides&gt;An extra 100% essence for all units for each shard controlled.&lt;/Provides&gt;
  24.             &lt;/GameModifier&gt;
  25.             
  26.         &lt;/AbilityBonusOption&gt;
  27.         
  28.     &lt;/AbilityBonus&gt;
  29.     
  30. &lt;/AbilityBonuses&gt;

I'm not sure how to use <Calculate> properly, I know that much. I most certainly have no idea how to use ValueOwner.

Also, please ignore the 100% bonus, as it's just to make sure it's making a massive and very visible difference.

Any help is greatly appreciated!

5,253 views 7 replies
Reply #1 Top

Do you have an example of any abilitybonus that uses calculate tags like that?

Reply #2 Top

I... do not, unfortunately. I see it used in SpellDef quite a lot, but was hoping it could be used in AbilityBonus/GameModifier, but it looks like it's not possible, as the end "Value" assignment seems to need a target, which is either none, TargetUnit or CastingUnit, and considering it needs UnitStat_NumEarthShards (or the like) it would need a target, I'd assume.

EDIT: Stupidly, I think I overlooked the fact that only SpellDef uses targets, as I've seen different ValueOwners used in treaties. I have no idea what the ValueOwner should be for the AbilityBonus.

Reply #3 Top

You are using calculate correctly. However, you don't really need value owner here (this is mainly used to look up a certain stat for a particular unit - mostly with spells to designate the caster and the target). I'm also not sure you actually need the + 100. I think the game always assumes one shard and adds on to it with every shard after. So basically you should be able to do it with just:


        <Calculate InternalName = "Value">
              <Expression><![CDATA[[UnitStat_NumAllShards] * 100]]></Expression>
        </Calculate>

Reply #4 Top

Ah, ok. Didn't know if it always assumed 100% of essence.

I was mostly doing the +100 to make sure that it was actually working. If the sovereign had double essence, it meant that the calculations were completing properly.

This is my current Calculate code;

Code: xml
  1.                 &lt;Calculate InternalName = "ShardMultiplier"&gt;
  2.                     &lt;Expression&gt;&lt;![CDATA[[UnitStat_NumFireShards] * 100]]&gt;&lt;/Expression&gt;
  3.                 &lt;/Calculate&gt;
  4.                 &lt;Calculate InternalName = "Value"&gt;
  5.                     &lt;Expression&gt;&lt;![CDATA[[ShardMultiplier] + 100]]&gt;&lt;/Expression&gt;
  6.                 &lt;/Calculate&gt;

I'm pretty certain ShardMultiplier will need a ValueOwner, as it uses a UnitStat_ variable. But it sounds like you know what you're doing here, so I'll take your advice and use no ValueOwner.

And just went to test it, but the sovereign has normal essence. What am I doing wrong?

Reply #5 Top

Um, shouldn't he have normal essence? You'd only get more if you actually own a shard right?

 

Edit: Oh, wait, I see what you mean. Try adding 200 instead, maybe it doesn't assume 1 shard anymore (there were a lot of talk about this back and forth and I've never actually tried it).

Reply #6 Top

No, if I have <Value>100</Value> then the sovereign has double mana. Presumably, if it's 100 + (100 * Shards) where Shards is 0 then they'll start with double. I'm using this as a test at the moment, so that if the Sovereign has double mana, the mod presumably works. In the end, I'll take that out so that it only affects them if they have shards.

Reply #7 Top

Nice, looking forward for this being completed! :D

 

Actually the bonus in MoM was 100% benefit, up to 200% (so a total of x3 normal spellpower from nodes) if you also had node mastery, IIRC. Maybe it was 4x, but I don't think so.

 

You may want to wait for the mana system to be implemented though.