Good afternoon, I have a simple task: to create a script in the map editor that, for example, when a neutral creature is killed, any hero who does it receives X experience.
But I can't seem to implement it. What's the error here?
GetPlayerHeroes(0);
SetGameVar(whotoup, 0);
whotoup = GetPlayerHeroes(0);
ChangeHeroStat(whotoup[0], 0, 999999999)
You can achieve a simpler result with workarounds, but if you need precise logic, so that ANY hero receives experience for defeating a SPECIFIC stack, and not a total number of creatures, here's my idea:
Give a name to the unit on the map. For example, UnitExp
function FightUnitExp(hero, unit)
while isObjectExists(hero) == not nil and isObjectExists(unit) == not nil do
sleep(5)
end
if isObjectExists(unit) == nil then
ChangeHeroStat(hero, 0, 999999999)
end
end
Trigger(OBJECT_TOUCH_TRIGGER, "UnitExp", "FightUnitExp")