Skip to content
User Avatar
#4053
Auto-translated
_BlackKnight_, for example, if a player strictly plays as a Knight, and the AI strictly plays as a Demon, then:
-- table of correspondences, only added a couple of creatures, the rest by analogy
creatures_conversion_table =
{
  {CREATURE_PEASANT, CREATURE_FAMILIAR},
  {CREATURE_MILITIAMAN, CREATURE_IMP},
  {CREATURE_LANDLORD, CREATURE_QUASIT},
};

-- checking function, without the wrapper regarding when to call it
-- the names of the player's and AI's heroes are passed as input.
function CheckCreaturesConversion(hero_player, hero_enemy)
  for i, cr in creatures_conversion_table do
    local cr_num = GetHeroCreatures(hero_player, cr[1]);
    if (cr_num > 0) then
      AddHeroCreatures(hero_enemy, cr[2], cr_num);
    end
  end
end
If the castles are random, then, of course, everything will be a little more complicated. I haven't checked the code; I might have made a mistake somewhere.
РПГ-сценарий для HoMM5: Путь героя
ЧаВо по созданию карт для HoMM5: ЧаВо