Skip to content

Posts from The intricacies of game mechanics

No ratings yet — be the first to rate!
13 years ago
Auto-translated
I have been analyzing the exe file of Heroes 3 (SoD 3.2) for quite some time now, and I am finding many interesting gameplay nuances that seem to be unknown to others. Previously, I posted some things in the FizMiG thread on the df2 forum, but it later became clear that FizMiG is not going to be updated anyway, and few players visit it. I think this information will be more in demand here.

To start, I will gradually (not all at once) go through FizMiG and write about the errors and inaccuracies in it that I am aware of, as well as clarify descriptions (I will only paraphrase what is already there if it is necessary for the clarity of the text). Perhaps some of this information is already known to some (including things I have posted elsewhere), but a sufficient condition for its inclusion here will be the absence, incorrectness, or insufficient accuracy of its description in FizMiG.

If anyone has specific questions, feel free to ask — I can find answers to many of them.
If something seems wrong, we can discuss it; I could certainly be mistaken.

1. Starting armies and hero movement points.

A hero's starting army consists of 3 stacks: first, second, and third in the order they are listed in FizMiG. The war machine is always considered the second stack and appears according to the same rules as it does, except that it does not disappear when the army is zeroed or replaced by a single unit.
The first stack is always given to the hero.
The second stack is given to the hero with an 88% probability.
The third stack is given to the hero with a 25% probability.

At the start of the game, all heroes are assigned a starting army in the specified form, and movement points are calculated based on it. An army is set to a single unit only after placing the hero in the tavern, during which movement points are not recalculated. Because of this, for example, a Barbarian hero bought with a single unit will have 1630 movement points with a 75% probability (Orcs did not arrive at map start, minimum speed 5), and 1560 movement points with a 25% probability (Orcs arrived at map start, minimum speed 4), while the tavern will show that he has one goblin in either case.

When a hero is lost in battle, first their army is zeroed, then their movement points are recalculated, and then they are given a standard starting army. As a result, when calculating movement points, the minimum speed of the hero's creatures is considered to be 20, and the hero is given 2000 movement points (excluding other modifiers).
Upon retreat, the army is immediately set to 1 creature, and movement points are not recalculated.

At the start of a new day, movement points are recalculated only for heroes belonging to players, as well as heroes in the tavern. As a result, if, for example, a Ranger hero was given Dwarves at map start and arrived in the tavern with one Centaur — then if you buy him on the same day he arrives, he will have 1500 movement points, but if you make him spend the night in the tavern and buy him the next day — he will have 1700. If this hero arrived, spent the night in the tavern, was not bought, and was overwritten — he will still have 1700 movement points by the time he arrives next.

In online play, information that a hero has been bought is transmitted to inactive players immediately, but changes to heroes' armies are only transmitted during turn handover. This includes the fact that information about replacing a starting army (or one given after a hero's death) with a single unit upon arriving in the tavern is not transmitted. Because of this, inactive players see what army was generated at start for the active player's bought heroes before it was replaced by a single unit. This is also taken into account in the tavern information (where the hero with the strongest value of this number is always shown: sqrt((1.0 + 0.05*(hero attack))*(1.0 + 0.05*(hero defense)))*(sum of AI Value of all creatures in the hero's army) ): for example, if Galtran arrives in the tavern on the first day with 1 Skeleton and the player buys him, other players will see his starting army before it was replaced by a single unit, and since it is likely to be stronger than the starting armies of other heroes, other players may see him in the tavern.

At map start, heroes are given a random amount of experience ranging from 40 to 90.


2. Hero specializations.

Generally, almost everything in the specializations section of FizMiG is described well and accurately; I will only clarify some points more precisely.

No secondary skill specializations work if the hero lacks the corresponding secondary skill (while a first aid specialization is considered a skill specialization and does not work without it, a ballista specialization is considered a creature specialization and works without the artillery skill). If a necromancy specialist hero does not have necromancy but has the Cloak of the Undead King, which still allows raising skeletons, the specialization effect will also not be taken into account.

The Luck spell specialization (for both Melody and Daremif) is simple: the Luck spell always gives +3 luck to target stacks, without the possibility of exceeding the maximum (3).

Eagle Eye specialization still adds +5% of the skill effect per hero level to the skill effect.

Navigation specialization adds +5% to the hero's base water walking reserve (1500) per level. That is, the specialization effect does not depend on the navigation skill level (except for the fact that if the hero has no navigation skill at all, the specialization does not work) and always equals +75*(hero level) movement points. In FizMiG, they apparently only checked for expert navigation, which is why they wrote 2%.


3. Impossibility of learning certain secondary skills in the University.

FizMiG lists a table, but it is not entirely correct. In reality, it is simpler: a hero cannot learn those and only those secondary skills in the University for which the drop chance for their class is 0. However, in the Witch's Hut and from the Scholar, a hero can learn any offered skills.


4. Spells.

- Bloodlust.
Bloodlust increases attack only for melee combat: although the spell is cast on shooters, its bonus is not taken into account when shooting. In the original, the attack plus for shooters was always displayed in the stack information window; in HD+, it is only shown when it is active, i.e., if the shooter can only hit in close combat.

- Minefield.
The player always sees their own mines. If the hero had creatures at the start of battle for whom the battlefield is native land, the player also sees enemy mines. If a player sees a mine, their creatures will not take damage when passing through it.

- Fire Shield.
Fire shield damage is calculated after all attack bonuses are calculated, but before all penalties.
That is, fire shield damage will correspond to the required percentage of damage taking into account attack and defense bonuses (if attack exceeds defense), luck, cavalry bonus, hatreds, offense secondary skill (and specialization), Blessing specialization, and Death Knight double damage.
But fire shield damage is calculated without considering attack and defense penalties (if defense exceeds attack), Psychic or Magic Elemental hits on creatures with corresponding magic defenses, melee penalty, counter-attack penalty after removing Blindness or Paralysis, hits on petrified creatures, the Shield spell penalty, and the hero's armor secondary skill (and specialization).

After taking the required percentage of damage, it is processed by a function that modifies magic damage. That is, fire shield damage is affected by: the hero having the Sphere of Raging Fire, wizardry secondary skill and specialization, partial damage ignore by Stone, Steel, Gold, and Diamond Golems, and the presence of the Fire Protection spell on the stack receiving fire shield damage.
At the same time, everything that affects the chance to cast a spell: resistances, immunities, cursed ground, anti-magic garrison, artifacts that forbid casting — does not affect receiving fire shield damage. The only exception is that fire shield does not work on creatures with immunity to fire (Ifrits, Fire Elementals, Fire Birds, and upgraded versions of these entities).

Fire shield damage is calculated and produced identically for a creature on which the corresponding spell has been cast and for Ifrit Sultans. If the Fire Shield spell is cast on Ifrit Sultans (for example, via the Medal of Vulnerability), then the modifier — the percentage of damage corresponding to the spell (20% - 20% - 25% - 30%) — is used; otherwise, it is always 20%.

- Clone.
The order of hex checking when summoning a clone (hexes are checked in increasing order of numbers; the clone is placed on the first free one).
For single-cell:
https://www.dropbox.com/s/45dxj8e8geudsm2/clone1.jpg
For 2-cell (cells with numbers are the rear part of the summoned clone):
https://www.dropbox.com/s/dl8cxnvm3xl9427/clone2.jpg

If the stack is turned in a different direction than the arrow, the scheme is mirrored horizontally.

If the clone cannot be placed on any of the marked hexes, it is not summoned at all (and a corresponding message is shown).

At the same time, 2-cell clones have features that are game bugs (fixed in HD+):
If hex 11 on the scheme is free, then during check 11, as well as intermediate checks between 21 and 22; 31 and 32; 41 and 42; 51 and 52; 61 and 62; 71 and 72; 81 and 82; 91 and 92, the checks pass and the clone is "summoned" to cell 11 (partially overlapping the cloned stack). In this case, the clone itself is invisible and non-interactive, does not participate in battle, and the cloned stack becomes invisible until its first action.
Regardless of occupied hexes, if the check reaches 28, 38, 48, 58, 68, 78, 88 or 98, the clone immediately tries to be summoned on the cell of the cloned stack; it is not summoned, but the cloned stack will disappear after the spell duration expires or after battle.

- Quicksand.
Quicksand does not affect flying creatures.
After a non-flying creature steps on quicksand, its turn ends immediately and it cannot move further or attack.
The player always sees their own quicksand. If the hero had creatures at the start of battle for whom the battlefield is native land, the player also sees enemy quicksand. If a player's non-flying creature steps on quicksand that was previously invisible to them — this quicksand becomes visible. If a player sees quicksand, their creatures will always plan a route to avoid it when moving (meaning you don't have to worry about a creature passing through visible quicksand — if the hex is marked as available by the movement shadow, the stack will reach there, avoiding all visible quicksand).
During a castle siege, the AI evaluates quicksand the same way as a moat (even if the castle has no moat): if the AI believes the moat would deal too much damage to the stack, it will also be afraid of stepping on quicksand.

- Hypnosis.
In many battle calculations, a hypnotized creature is considered one's own: for example, offense, shooting, and armor secondary skills from the controlling player apply to it, not the owner. I won't compile a full list of modifiers yet as it is tedious and not certain that anyone needs it.

- Magic Mirror.
Magic Mirror only works with spells cast by human heroes. Spells cast by stacks or AI heroes are not subject to redirection by Magic Mirror. However, when calculating the value of casting by a hero (but not by stacks), the AI takes into account the Magic Mirror on the target, and its desire to cast on a stack protected by Magic Mirror drops significantly (specifically, if the chance of reflecting the spell is 50%, the AI equates the value of casting on such a stack to 0), despite the fact that when an AI hero casts, the mirror never works.

The stack to which the spell will be reflected is chosen randomly from all non-killed stacks of the caster's side that are not shooting towers. If casting this spell on this stack is impossible, it will have no effect.

Fabled Dragons have a Magic Mirror effect identical to a spell cast without an element skill (i.e., 20%). If Magic Mirror is cast on a Fabled Dragon, the maximum of the effects is taken (meaning the spell effect will effectively always override the innate mirror, which in this case stops providing any effect). If no external Magic Mirror is cast on Fabled Dragons, the AI does not consider their innate mirror when calculating casting value by a hero.


5. Creatures.

- Pegasus, Silver Pegasus.
If the hero had Pegasi or Silver Pegasi in their army at the start of battle — enemy spells will cost 2 more until the end of battle.

- Unicorn, War Unicorn.
The magic resistance aura does not add 20% to the chance to reflect a spell, but multiplies the chance of casting the spell by 0.8. The number of unicorn stacks nearby does not matter — the aura is either present or it isn't.

- Mage, Archmage.
Has no penalty for shooting through fortress walls.
If the hero had mages or archmages in their army at the start of battle — their spells will cost 2 less until the end of battle.

- Master Djinn, Sorcerer.
The Master Djinn chooses a spell from all existing long-term spells intended for casting on a friendly stack + healing (flag 0x00000008). Spells that cannot be cast (at all or due to stack immunity), those already cast on the stack, and those the djinn does not consider correct to cast (see below) are not considered. From all eligible spells, one is chosen randomly with equal chances for each. The AI calculates average utility across all possible spells when casting. Casts at advanced level with 6 spell power.

The Sorcerer chooses a spell from the following list with specified chances, first excluding those that cannot be cast on each stack, are already cast, or in the opinion of the Sorcerer (same as Master Djinn) are useless to cast.
Haste: 15
Air Shield: 10
Slow: 10
Stone Skin: 15
Bloodlust: 5
Blessing: 15
Healing: 10
Weakness: 4
The specified chance values are not percentages, but indicators. Calculate the chance as: (spell indicator)/(sum of indicators of all possible spells for casting). For example, the chance of Haste when all spells are available will be 15/84.
Casts with spell power 3 at expert level.

Now regarding the determination of casting appropriateness:
Elemental Protections, Anti-Magic and Magic Mirror: only if the enemy has a hero and that hero has a Spellbook.
Healing: only if the target has lost health.
Prayer: only if the target hasn't acted yet in this round (waiting is not considered an action).
Executioner: only if the enemy has creatures susceptible to basic Executioner (including already dead ones) — this is a game bug, as Master Djinn casting occurs at advanced level (Sorcerers do not cast Executioner).
Shield and Fire Shield: only if the enemy has stacks that are not killed, blinded, petrified, paralyzed and currently cannot shoot (blocked shooters etc. are also counted).
Air Shield: only if the enemy has stacks that are not killed, blinded, petrified, paralyzed and currently can shoot (blocked shooters etc. are not counted).
Precision: only if the target stack can currently shoot (a blocked shooter etc. is not counted).
Bloodlust: only if the target stack cannot currently shoot (a blocked shooter etc. is also counted).
Other spells (including all spells cast on opponents for Sorcerers) are considered by magic creatures to always make sense to cast, provided they aren't already on the stack and can be cast on it at all.

- Black Knight, Death Knight, Mummy.
Upon hitting, they cast basic Curse on the attacked with a 25% chance.

- Troglodyte, Hell Troglodyte.
Immune not only to Blindness, but also to Petrify (from Medusas and Basilisks).

- Scorpikora.
Scorpikora's Paralysis works like advanced Blindness: the counter-attack damage of a paralyzed creature is reduced 4 times. If the creature is also blinded, the effects are multiplied.

- Ifrit Sultan.
Fire shield damage for Ifrit Sultans is calculated and produced the same as for a creature on which the corresponding spell has been cast. See details in the Fire Shield spell description.

- Ogre Mage.
Casts advanced Bloodlust for 6 rounds.

- Mighty Gorgon.
After hitting, deadly gaze triggers: each creature from the attacking squad has a 10% chance to kill a creature in the attacked squad, but the total number of killed creatures cannot be more than (number of creatures in attacking squad)/10 (rounded up).

- Monarch Wyvern.
After hitting, there is a 30% probability that poison is cast on the attacked stack for 3 rounds if it is a living creature. Immediately upon casting, as well as at the start of each round, the poison takes 10% of maximum health from the stack until the end of battle, but total poison damage per battle cannot exceed 50%. If poison is cast on a creature that already has poison, its duration is extended, but no additional health reduction occurs upon casting. Poison and old age effects are multiplied.

- Phoenix.
Resurrects once per battle immediately after death. Number of resurrected Phoenixes in a stack: (number of creatures at start of battle)/5 + X, where X is calculated as follows: take the number of phoenixes equal to the remainder of dividing the number of creatures in the stack at map start by 5, and each has a 20% chance to resurrect. For example, if there were 19 phoenixes, then 3 phoenixes will definitely resurrect, and among the other 4 phoenixes, each has a 20% chance to resurrect. With great luck, all 7 can resurrect.

- Sorcerer.
Regarding cast spells — see the section on Master Djinn and Sorcerer.
Has no penalty for shooting through fortress walls.

- Fabled Dragon.
Upon receiving a turn (at start of round or after waiting), a spell is generated that the Fabled Dragon can cast.

Drop chances for various spells for fabled dragon in original:
  • Ice Bolt: 16/153
  • Lightning Bolt: 17/153
  • Fireball: 21/153
  • Magic Arrow: 15/153
  • Ring of Frost: 20/153
  • Chain Lightning: 19/153
  • Meteor Shower: 23/153
  • Inferno: 22/153

It is easy to notice that spell IDs are used as chances. This is a game bug — correct chances are written in the code, but not used. The bug is fixed in HD+.

Drop chances for various spells for fabled dragon in HD+:
  • Ice Bolt: 22%
  • Lightning Bolt: 22%
  • Fireball: 21%
  • Magic Arrow: 10%
  • Ring of Frost: 10%
  • Chain Lightning: 5%
  • Meteor Shower: 5%
  • Inferno: 5%

Fabled Dragons have a Magic Mirror effect identical to a spell cast without an element skill (i.e., 20%). See details in the Magic Mirror spell description.

- Rust Dragon.
Acid breath consists of 2 parts: the first is cast on the attacked stack with non-zero defense upon any hit and reduces its defense by 3. The second part is cast after the first with a 20% probability and deals damage equal to (number of attacking creatures)*(random number from creature's minimum damage to maximum)/2. Since Rust Dragon damage is 50, the second part of acid breath always deals 25*(number of attacking creatures) damage. This damage affects all creatures, and no modifiers affect it.

- Azure Dragon.
Fear: every creature, except those immune to morale as well as Azure Dragons, has a 10% chance to skip its turn (chance is calculated separately from negative morale), if there is at least 1 Azure Dragon in the enemy army. If all Azure Dragons in the army are destroyed — the fear effect stops.
Azure Dragon is actually subject to morale — FizMiG contains an error.

6. Weeks and months of creatures and plagues.

When generating a new week, in 25% of cases +5 units of monster occur and 75% — nothing (anteaters etc. are not equal to monsters and are generated separately when these 75% occur).
Only monsters belonging to the town can appear.

When generating a new month, in 50% of cases nothing happens (earthworms etc.), in 40% a monster is generated and in 10% — a plague.
Difficulty level has no effect. The only thing is that in tutorials, same-month monsters and plagues cannot occur at all.

Monsters are indeed taken from the 12 specified in FizMiG. Drop chances for each are equal.
Number of monsters = (random number from minimum monster count on map at start to maximum monster count on map at start) * 2; if it is greater than 4095, it is set to 4095.
Minimum and maximum counts can be seen in crtraits.txt. They are common for all town creatures of the same level. For example, 1st degrade: 20-50, 1st grade: 20-30, 7th grade: 3-8.
Aggressiveness of appearing monsters is random — from 1 to 10 with equal chances; these monsters can always increase in number and retreat.

The number of monsters appearing on the map is not fixed; every available (without water etc.) cell of the map has a 0.5% chance that a monster will appear on it. That is, theoretically, monsters could appear on all cells at once or none at all.
User Avatar
13 years ago
Auto-translated
On ХВ, the topic of PhysMig is discussed here.

And generally, thanks for the information; I learned something new.
In reply to Dirty_Player
13 years ago
Auto-translated
Dirty_Player
On ХВ, the FizMiG topic is discussed here.
Writing posts on the FizMiG topic does not lead to an update of FizMiG, unfortunately, so I don't think it's worth tying all the discussion to it – after all, I write primarily about the game mechanics, and not about FizMiG. It just happens that it’s convenient for me to use it right now to see what information is currently unknown or little known regarding some of the topics. After a while, I will finish clarifying the topics that are there, and I will no longer rely on it.
User Avatar
13 years ago
Auto-translated
Awesome, thanks! I found the information about the Bloodlust skill on archers and the trolls' immunity to petrification particularly interesting – I didn't know that. This is a very useful topic, and the presentation is enjoyable. We're looking forward to the continuation. :smile20:
13 years ago
Auto-translated
Sav
The Wizard chooses a spell from the following list with the indicated chances, excluding those that cannot be cast or, in his opinion (the same as that of the Master Genie), are useless for any stack.
Haste: 15
Air Shield: 10
Slow: 10
Stone Skin: 15
Bloodlust: 5
Bless: 15
Heal: 10
Weakness: 4
The indicated chance values are not percentages, but indicators. Calculate the chance as follows: (spell indicator) / (sum of indicators of all possible spells to cast). For example, the chance of Haste with all spells available will be 15/84.
Casts with a spell power of 3 at the expert level.

Now, regarding the determination of the appropriateness of casting:
Elemental Protection, Anti-Magic, and Magic Mirror: only if the enemy has a hero, and he has a Spell Book.
Heal: only if the target has lost health.
Prayer: only if the target has not acted in this round yet (waiting does not count as an action).
Executioner: only if the enemy has creatures susceptible to the basic Executioner spell (including already dead ones) - this is a bug in the game, because the Master Genie's spell is cast at an advanced level (Wizards do not cast Executioner).
Shield and Fire Shield: only if the enemy has stacks that are not killed, blinded, petrified, paralyzed, and cannot shoot at the moment (blocked and similar shooters are also considered).
Air Shield: only if the enemy has stacks that are not killed, blinded, petrified, paralyzed, and can shoot at the moment (blocked and similar shooters are not considered).
Accuracy: only if the target stack can shoot at the moment (a blocked or similar shooter is not considered).
Bloodlust: only if the target stack cannot shoot at the moment (a blocked or similar shooter is also considered).
The remaining spells (including all spells cast on the enemy, for Wizards) are, in the opinion of the mage creatures, always worth casting if they have not yet been cast on the stack and can be cast on it at all.
Very interesting.
I have a question about Wizards. I think if I dig around, I can find a save where I took a tier 3 can (for 3 angels).
So, it was in offline mode. The Wizard behaved strangely. With a certain tactic, he always cast Mass Slow!!!
But what is especially interesting is that sometimes he cast it 3-5 times and then completely stopped casting. Could you comment on such behavior of the Wizard?
I don't remember the army exactly, but there were approximately 20-40 snipers, 1 Wizard, and 30-40 "pokemons".

Personally, I have the impression that the Wizard "thinks" that if my army is in a position where it can reach the enemy's strike stacks, and casting Mass Slow puts it out of reach, then the chances of this cast increase.
That is, I always put the Wizard in a vulnerable position so that he would save his own life with Mass Slow. :)
13 years ago
Auto-translated
I just looked at the code again, and it seems like I described the mechanism correctly. I just forgot to mention that the Wizard won't cast spells that are already applied to all stacks they affect, and the Wizard sees a reason to cast them. It seems like there's no evaluation of the usefulness of specific spells, other than the points already mentioned.

For now, I can only assume that the constant casting of Slow is just a lucky random occurrence (possibly in combination with the fact that other frequently cast spells are already applied to all stacks). Although, in theory, the random element shouldn't repeat in offline mode.
The Wizard might also not cast any spells if all possible spells are already applied. In theory, there shouldn't be any other reasons.

If the save file can be found (along with the necessary sequence of actions), or if the situation can be recreated, I will definitely take a look and try to figure it out.
User Avatar
13 years ago
Auto-translated
Since we're already talking about Wizards, I'll add something that some might not know. If a Wizard casts a spell, for example, Slow, it lasts for 3 rounds. But if a hero has a basic Slow skill and applies it on top of the Wizard's Slow, the unit will only have the effect of the expert Slow, but the duration will be extended by the hero's spell power. The same applies to any spell.
User Avatar
13 years ago
Auto-translated
By the way, regarding the mythical dragon. Just now, I cast Blindness on it, it resisted on my Archdevil, it was blinded, but it could still move!
13 years ago
Auto-translated
Apparently, the Archdevil's spell was cast just as its turn ended, and casting Blind doesn't immediately cause it to skip its turn. This should generally be considered a bug, as is, for example, the fact that a Phoenix resurrects after some time has passed since it was sacrificed.

I also noticed another small detail while looking into the Blind spell: casting Hypnotize on a creature removes its Berserk status, and casting Berserk on a creature removes its Hypnotize status. In particular, since Berserk can be cast on your own units, you can use it to cure them of Hypnotize.

And regarding poison – it is completely cured by healing (the spell itself is removed, and the entire health penalty is removed), but it is not removed by dispelling spells (neither the spell itself nor the health penalty is removed, although if the spell is active, you can attempt to dispel it, but it will be ineffective).
User Avatar
13 years ago
Auto-translated
Sav is not aware. There is a command called gosolo, which allows the computer to play for you, but is it possible to remove the reminder "Press ESC to cancel solo mode"?
13 years ago
Auto-translated
It seems like you can’t disable it using the in-game settings, but you can create a patch that either disables it or reduces the waiting time.
In reply to Sav
User Avatar
12 years ago
Auto-translated
I recently heard that when calculating stats, even with all the artifacts and skills equipped, morale and luck will only be considered up to a value of 3. So, if there's no anti-morale effect, is there any point in equipping extra artifacts and raising troop morale above 3?
12 years ago
Auto-translated
Yes, there's no point. Unless, perhaps, you're counting on your opponent casting a spell that will cause them grief. :)
In reply to Sav
User Avatar
12 years ago
Auto-translated
Thank you for the prompt response!
User Avatar
12 years ago
Auto-translated
Maybe I'll let you in on a secret, but negative luck doesn't work either. :)

Statistics

Welcome our newest member: recijeb