Yes, indeed, with the expert call, the Celestial Shield began to be cast. And the random function also started generating numbers. But now, this problem has arisen: the script is complaining about the second argument of your function, i.e., the variable chosen_target (screenshot attached). Maybe I misunderstood it somehow and, accordingly, I'm writing it incorrectly?
P.S. Everything was resolved; I just needed to add a sleep command so that everything would work correctly. Thank you very much.
The function itself:
Title
function DefenderHeroMove (unit)InitRandom()
for n, creature in GetDefenderCreatures() do
local id = GetCreatureType(creature)
if id == CREATURE_ARCHER then
local targets = GetAttackerCreatures()
local chosen_target = targets[random(length(targets)+1)]
commandShot (creature, chosen_target, nil)
end
end
In the randomizer from RedHeavenHero, the random function is created only after the randomizer is initialized, i.e., after calling the InitRandom() function. You need to add this line to the beginning of the script.
Perhaps, a summoning skill is required to cast the Celestial Shield?
I have encountered the issue where I cannot cast Masscare without Light Magic.