I've experimented a bit with modding of Confusion spell (used both as troll ability and combat school spell).
This is original calculation code from the spell:
Code: xml
- <Calculate InternalName="TargetAttack" ValueOwner="TargetUnit">
- <Expression><![CDATA[[UnitStat_Attack] * -0.5]]></Expression>
- </Calculate>
- <Calculate InternalName="Value">
- <Expression><![CDATA[[TargetUnitAttack]]]></Expression>
- </Calculate>
If modified to this:
Code: xml
- <Calculate InternalName="TargetAttack" ValueOwner="TargetUnit">
- <Expression><![CDATA[[UnitStat_Attack] * -0.5]]></Expression>
- </Calculate>
- <Calculate InternalName="TargetPerUnitAttack" ValueOwner="TargetUnit">
- <Expression><![CDATA[[TargetAttack] / [TroopCount]]]></Expression>
- </Calculate>
- <Calculate InternalName="Value">
- <Expression><![CDATA[[TargetPerUnitAttack]]]></Expression>
- </Calculate>
Confusion will work properly for single units (as before) as well as for full groups. Additional code reduces penalty by number of people in group, so that penalty per person gets properly calculated.
Unfortunately, it only works good this way, if stack is fully healed, since [TroopCount] counts current number of troops in unit, while attack rating of the group never drops when soldiers start dying. This bug/feature messes up calculations.
So if there are 2 people in 4 unit group, spell will decrease attack rating for each unit in group by A*0.5/2=A/4, where A is attack rating of whole group (4 times higher then single solider attack regardless of losses). And since A/4 is also attack rating of single unit, in this particular scenario confusion will reduce attack rating of whole group to 0.
And in case of only one solider remaining in 4 unit group, it would lead to negative attack value (decrease per unit: A*0.5/1=A/2, so new attack of single solider is A/4-A/2= -A/4, and of full troop -A).