Thank you.
Another question:
How can I correctly (and, if possible, compactly) replace creature "A" with creature "B" in a hero's army? (For example, let's say the hero's specialization is to transform all their banshees into death knights in battle).
Specific example:
if (hero == "replacer") and (GetHeroCreatures ('replacer', CREATURE_A) > 0 ) then
local replace = GetHeroCreatures ('replacer', CREATURE_A);
RemoveHeroCreatures ('replacer', CREATURE_A, replace);
AddHeroCreatures ('replacer', CREATURE_B, replace);
end;
This script has several drawbacks:
1. If the creatures to be replaced are placed in multiple slots, the replacement will result in them being merged into one.
2. If there is only one slot with the creatures to be replaced in the army (and no other army), the replacement will add another creature.
----------------DAEDRA-------------------
function error_NHF_Nemor_F()
print("error:NHF_Nemor_F");
end;
function NHF_HERO_F.Nemor()
errorHook(error_NHF_Nemor_F);
local prirost = 0;
local creatures = "";
local temp_name = NHF_tempName_F("Nemor");
local count_umertvie = GetHeroCreatures("Nemor", CREATURE_WIGHT);
if count_umertvie > 0 then
RemoveHeroCreatures("Nemor", CREATURE_WIGHT, count_umertvie);
AddHeroCreatures("Nemor", CREATURE_BANSHEE, count_umertvie);
end;
end;
This script only has the second drawback, as the first one won't have time to occur – all creatures will already be replaced.
Thank you for pointing out this flaw.