Need to know if something like this is possible to code (experienced modders please take a look)

I am trying to come up with some creative way of making the larger units for my mod idea (100 and 300) to work in a balanced way. 100 and 300 man groups do a lot of damage and lowering weapon damage breaks other things. So I was thinking if something, like what I suggest below, is possible then maybe I can make it work better:

 

 

Somehow make it so that units do less damage based on unit size. Maybe I could add some code to the CoreUnitGroupingTypes to make them do less damage.

 

Somehow make it so that units do less damage (maybe by percent) to champions and monsters. 

 

 

Or if anyone has a better idea on how I could balance it then I would appreciate ideas.

61,390 views 43 replies
Reply #1 Top

I have tried to come up with ways to do this, but the best I can do is have a meleeappliesspell that deals X damage based on your troopcount against the enemy troopcount. Unfortunately that kind of system is bad as hell.

Reply #2 Top


Another way of doing this (although it will take a long time) is to create identical weapons (different tags) that are only for designed units. Thus you can set the weapon damage for these really low and shouldn't break things between champions and units.

But other than that I cannot think of a good way of doing the system you propose.

Reply #3 Top

I already thought of that of course Parrot, but that does not work. Even if you set weapon damage to 1, it could still potentially do 300 damage. Will you set every weapon to one> I tried setting weapons either dmg 1,2,3, or 4 depending on tier, but even at 2 damage, it is just plain too much. Heroes and monsters will be basically one shotted. Also, it breaks the auto update system for designing units. If you try to design units and click the button that automatically chooses best weapon and armor it won't work correctly.

 

Also, setting numbers below 1 doesn't work. .2 will default to 1 and so will all other numbers below 1. They just default to 1. I have been struggling with this with the mod I am working on, which is what is holding it up. Yeah, I can just go with the system I have now but then auto updating and also the upgrade unit feature will not work. Every unit will need to be designed individually. This is a pain because I was basing my units off of the affliction mod because I am using his abilities and stuff. That means you need to start up each faction and individually design units for them. This wouldn't be too big of a deal if you could use the auto update feature but you can't with this. It keeps just making them wear leather and use lower tier weapons.

Reply #4 Top

Then it looks like you will have to multiply the base hitpoints of everything by a very large factor if you are going to accomplish what you are trying to do....

Otherwise it is going to be like heavenfall suggested a spell that does what he suggests. Then you would have to edit the range attacks as well to do the same thing... Not looking like you can do what you want to do.

Reply #5 Top

Well, I can do it, it will just break the auto update and upgrade features. There might be another way that we just haven't thought of yet. 

Reply #6 Top

Are there any spells that do percentage damage and code to do dmg times amount of soldiers as a percentage. Meaning maybe I could add code into CoreUnitGroupingTypes (or to each weapon) that makes it do minus % dmg per soldier in group. 

 

Maybe if there is a spell that does this or something I can copy the effect.

Reply #7 Top

Well you can add a bloodtrait that activates a spell at the start of battle... that will raise hitpoints depending on the number of units in the army. Say if you have 300 units, then +1 hitpoint per unit.. but if there is 1 unit then +300 hitpoints or something like that. Add it to all the blood traits and that might do what you want.

Reply #8 Top

Okay I found this code:

 

<GameModifier>
<ModType>Unit</ModType>
<Attribute>CurHealth</Attribute>
<Duration>-1</Duration>
<PerTurn>1</PerTurn>
<Calculate InternalName="TgTpCt" ValueOwner="TargetUnit">
<Expression><![CDATA[[UnitOwner_GetTroopCount]]]></Expression>
</Calculate>
<Calculate InternalName="Value">
<Expression><![CDATA[[TgTpCt] * -1]]></Expression>
</Calculate>
</GameModifier>

 

This does:  "take 1 damage per turn per soldier in the unit"

 

This has one of the elements I am looking for, a way to get troop count and have it affect something. Let me look at something that affects dmg by percentage.

Reply #9 Top

Quoting parrottmath, reply 8
Well you can add a bloodtrait that activates a spell at the start of battle... that will raise hitpoints depending on the number of units in the army. Say if you have 300 units, then +1 hitpoint per unit.. but if there is 1 unit then +300 hitpoints or something like that. Add it to all the blood traits and that might do what you want.

 

Hmm, the HP for heroes would have to go up considerably. A couple of thousand probably but I wouldn't want regular army units to go up in hp. However, that would make any level up or ability changes to HP irrelevant.

Reply #10 Top

Not true if you get the spell to take level into account. It is a horrible rebalance in the tatical battle that you are doing. This blood trait would have to magnify and nerf a lot of things depending on unit sizes... I don't envy the job you've taken on.

Reply #11 Top

Maybe something like this:

 

<GameModifier>
<ModType>Unit</ModType>

<Attribute>AdjustUnitStat</Attribute>

<AttackStat>UnitStat_Attack_Blunt</AttackStat>

<Calculate InternalName="TgTpCt" ValueOwner="TargetUnit">
<Expression><![CDATA[[UnitOwner_GetTroopCount]]]></Expression>
</Calculate>

<Calculate InternalName="Calc" ValueOwner="TargetUnit">
<Expression><![CDATA[[UnitStat_Attack_Blunt]]></Expression>
</Calculate>

<Calculate InternalName="Calc1" ValueOwner="TargetUnit">
<Expression><![CDATA[[TgTpCt]*[Calc]]></Expression>
</Calculate>

<Calculate InternalName="Value" ValueOwner="TargetUnit">
<Expression><![CDATA[[Calc1] * -0.75]]></Expression>
</Calculate>

</GameModifier>

 

 

I am not sure if this is 100% right, but maybe like this

 

Now maybe this could be applied to a blood trait and just give it to all races or perhaps this could be put directly into coreunitgroupingtypes, not sure if that is possible though.

Reply #12 Top

Quoting parrottmath, reply 11
Not true if you get the spell to take level into account. It is a horrible rebalance in the tatical battle that you are doing. This blood trait would have to magnify and nerf a lot of things depending on unit sizes... I don't envy the job you've taken on.

 

It isn't that I am trying to rebalance. I just want to make larger unit sizes for immersion purposes. Yes, it has been frustrating but that doesn't mean it can't be done. If anything, I am trying to do it to see if it can be done.

Reply #13 Top

I really think you are going about this the wrong way.   Why not add some champion weapons that do damage  based on the number of units in a squad?   Then all you have to do is beef their hit points per level at an exponential rate (if you want the size of units to scale from where they are now, to the hundreds).  The other issue I think you're going to run into, is rendering hundreds of figures, and what happens when things like blizzard go off.

Reply #14 Top

I have been working on this for weeks. I already have them doing dmg based on the number of units in a squad. I do not want to beef up their hit points per level at an exponential rate because I think it will look stupid for heroes to have thousands of HP, although this is one route I may have to take if there is no other way. The game is not going to be rendering hundreds of units either.

 

Look, if I sound frustrated, I am sorry because I have been working on this for weeks now and have tried many things. I have a thread already, which is stickied at the top which has basically been explaining what I have been doing or what I have tried, etc. First of all, it is impossible to have hundreds of soldiers show up on screen per unit because it is hardcoded, which is something which has already been discussed. Only 20 soldiers can show up on screen for one unit at any given time. The number will not decrease from 20 until the army reaches 19 soldiers remaining. 

Reply #15 Top

Also, again, adding just a ton of HP to champions is going to kill other things. For example, it will make any spells that buff HP be useless for champions  because these spells also need to affect units and you do not want that to happen. Also items or abilities that also affect health which are used by both champions and units would be useless for champions. 

Reply #16 Top

Would it be possible to give all champions a massive percent hp boost? Like a trait that gives them +10000% hp (i.e. +100x), similar to the Yithril trait that gives all units +10% hp or whatever but much stronger and champion-only. Then hp boosting spells/equipment would be balanced; +3 to a champion's base hp would be like +300 hp after the percent modifier, comparable to what a 100-soldier trained unit gets. Same trait might add a percent damage multiplier so that champions and trained units can use the same weapons, and so on for other stats.

Reply #17 Top

The percentage would have to be based off the total hitpoints of the unit in order for that to work. But it is still a result of a melee applies spell on all the weapons.

Reply #18 Top

Another option would perhaps be to allow units to upgrade their size? This is doable from ElementalDefs.xml. Would fit well in an immersion mod, as famous units often accrued their fame over several wars.

Reply #19 Top

<GameModifier>
<ModType>Unit</ModType>

<Attribute>AdjustUnitStat</Attribute>

<AttackStat>UnitStat_Attack_Blunt</AttackStat>

<Calculate InternalName="TgTpCt" ValueOwner="TargetUnit">
<Expression><![CDATA[[UnitOwner_GetTroopCount]]]></Expression>
</Calculate>

<Calculate InternalName="Calc" ValueOwner="TargetUnit">
<Expression><![CDATA[[UnitStat_Attack_Boost]]></Expression>
</Calculate>

<Calculate InternalName="Calc1" ValueOwner="TargetUnit">
<Expression><![CDATA[[TgTpCt]*[Calc]]></Expression>
</Calculate>

<Calculate InternalName="Value" ValueOwner="TargetUnit">
<Expression><![CDATA[[Calc1] * -0.75]]></Expression>
</Calculate>

</GameModifier>

 

Maybe if I took this code and made it into a battle trait that all units have by default and can't be removed then it will lower the attack of units in battle but not affect monsters or heroes.

Reply #20 Top

Actually, look at this. Can this be done as an ability:

 

<AbilityBonus InternalName="DecreaseDmgAbility">
<AbilityBonusOption InternalName="DecreaseDmg">
<DisplayName>Decreases Damage</DisplayName>
<Description>Decreases Damage relative to size of unit</Description>
<Icon>Ability_ImmuneToPoison_Icon.png</Icon>
<GameModifier>
<ModType>Unit</ModType>
<Attribute>AdjustUnitStat</Attribute>
<AttackStat>UnitStat_Attack_Boost</AttackStat>
<Calculate InternalName="TgTpCt" ValueOwner="TargetUnit">
<Expression><![CDATA[[UnitOwner_GetTroopCount]]]></Expression>
</Calculate>
<Calculate InternalName="Calc" ValueOwner="TargetUnit">
<Expression><![CDATA[[UnitStat_Attack_Boost]]></Expression>
</Calculate>
<Calculate InternalName="Calc1" ValueOwner="TargetUnit">
<Expression><![CDATA[[TgTpCt]*[Calc]]></Expression>
</Calculate>
<Calculate InternalName="Value" ValueOwner="TargetUnit">
<Expression><![CDATA[[Calc1] * -0.75]]></Expression>
</Calculate>
</GameModifier>
<CombatRating>10</CombatRating>
<HideWhenUpgraded>0</HideWhenUpgraded>
<IsCombatAbility>1</IsCombatAbility>
<Type>Weakness</Type>
<AIData AIPersonality="AI_General">
<AIPriority>5</AIPriority>
</AIData>
</AbilityBonusOption> 

 

 

Or does Calculate only function with spells?

Reply #21 Top

if coreabilities can't calculate, maybe I can just do it as a spell like the amarian blood trait and have it auto cast

Reply #22 Top

Ah now I see what you are trying to do. Yes, this should work if you put it in an autocast.

Reply #23 Top

I will test, if it works then it will solve all my problems and I wont even have to do much work. I wasted so much time already though heh.

Reply #24 Top

Okay, either I did something wrong or it isn't working. The ability does show up on the unit as it should but it isn't decreasing dmg. Please take a look at the code:

 

I created a new ability:

 

<AbilityBonus InternalName="DecreaseDmgAbility">
<AbilityBonusOption InternalName="DecreaseDmgAll">
<DisplayName>Decreases Damage</DisplayName>
<Description>Decreases Damage relative to size of unit</Description>
<Icon>Ability_Large_Icon.png</Icon>
<GameModifier>
<ModType>Unit</ModType>
<Attribute>BattleAutoCastSpell</Attribute>
<StrVal>DecreaseDmg</StrVal>
<Value>100</Value>
<Provides>Decreased Dmg for all</Provides>
</GameModifier>
<HideWhenUpgraded>0</HideWhenUpgraded>
<AIData AIPersonality="AI_General">
<AIPriority>5</AIPriority>
</AIData>
</AbilityBonusOption>
</AbilityBonus>

 

 

and a new spell:

 

<SpellDef InternalName="DecreaseDmg">
<DisplayName>Decrease Damage</DisplayName>
<Description>Decreases damage relevant to unit size</Description>
<FormattedDescription>This spell is automatically cast on all soldiers at the start of battle.</FormattedDescription>
<Image>S_BlessingOfRestoration_Painting.png</Image>
<IconFG>S_BlessingOfRestoration_Icon.png</IconFG>
<IconColor>245,236,46</IconColor>
<CanStack>0</CanStack>
<SpellBookSortCategory>Unit</SpellBookSortCategory>
<SpellBookSortSubCategory>UnitEnchantment</SpellBookSortSubCategory>
<SpellType>Tactical</SpellType>
<SpellClass>Defensive</SpellClass>
<SpellSubClass>Buff</SpellSubClass>
<SpellTargetType>Self</SpellTargetType>
<HideInHiergamenon>1</HideInHiergamenon>
<IgnoreCastAnim>1</IgnoreCastAnim>
<IsCastable>0</IsCastable>
<GameModifier>
<ModType>Unit</ModType>
<Attribute>AdjustUnitStat</Attribute>
<AttackStat>UnitStat_Attack_Boost</AttackStat>
<IsForFormattedDescription>1</IsForFormattedDescription>
<Duration>-1</Duration>
<Calculate InternalName="TgTpCt" ValueOwner="TargetUnit">
<Expression><![CDATA[[UnitOwner_GetTroopCount]]]></Expression>
</Calculate>
<Calculate InternalName="Calc" ValueOwner="TargetUnit">
<Expression><![CDATA[[UnitStat_Attack_Boost]]></Expression>
</Calculate>
<Calculate InternalName="Calc1" ValueOwner="TargetUnit">
<Expression><![CDATA[[TgTpCt]*[Calc]]></Expression>
</Calculate>
<Calculate InternalName="Value" ValueOwner="TargetUnit">
<Expression><![CDATA[[Calc1] * -0.90]]></Expression>
</Calculate>
</GameModifier>
<AIData AIPersonality="AI_General">
<AIPriority>5</AIPriority>
</AIData>
<HitSoundFX>AirShard_SFX_01</HitSoundFX>
</SpellDef>

Reply #25 Top

<Calculate InternalName="Calc" ValueOwner="TargetUnit">
<Expression><![CDATA[[UnitStat_Attack_Boost]]></Expression>
</Calculate>

if the unit has 0 Attack_Boost this modifier will do nothing.