Skip to content

Scripts for beginners.

#248
Auto-translated
preserve_heroes={"Elleshar", "Linaas", "Gillion", "Diraya", "Itil", "Ossir", "Nadaur"}
function Def( heroName )
local PreserveHero
for key, name in preserve_heroes do
if name == heroName then
PreserveHero=1
end;
end;
if not PreserveHero then
StartCombat(heroName, "Metlirn",7,44,24,146,80,148,16,147,48,50,16,48,48,44,24)
end;
end;
Trigger( REGION_ENTER_AND_STOP_TRIGGER, "def", "Def" );


In this form, all heroes enter the battle.

preserve_heroes={"Elleshar", "Linaas", "Gillion", "Diraya", "Itil", "Ossir", "Nadaur"}
function Def( heroName )
if not contains(preserve_heroes, heroName) then
StartCombat(heroName, "Metlirn",7,44,24,146,80,148,16,147,48,50,16,48,48,44,24)
end;
end;
Trigger( REGION_ENTER_AND_STOP_TRIGGER, "def", "Def" );

 

And this version works as intended: it lets Rangers pass through, and initiates a battle with the rest. Thank you!
Another related question: how can I add a condition so that the trigger resets after a specific player loses?