Skip to content
User Avatar
#2655
Auto-translated
You're approaching the task from the wrong angle. Combat functions are well-described in Novik's scripting guide, if needed.
- when the only stack of the defending side moves, it does something.
It's simple here:
function DefenderUnitMove(unit)
  -- for example, cast a spell:
  UnitCastGlobalSpell(unit, 'SPELL_NAME');
  return not nil
end
- when any stack of the attacking side dies, ghosts appear on the defending side.
There might be some nuances:
function AttackerUnitDeath(unit)
  -- haven't checked, it might work like this:
  local x, y = GetUnitPosition(unit);
  AddCreature(side, type, quantity, x, y);
end
You just need to place these functions in the combat script; they will be automatically called when the corresponding event occurs.