Skip to content
User Avatar
#3216
Auto-translated
Loli Nikita
How do I create a script so that when interacting with an object, a battle starts with specific enemies (in my case, 3 groups of 5 infantry units each), but the number of creatures depends on the difficulty level (for example, 5 infantry units on Warrior difficulty, and 7 on Hero difficulty)? Thanks in advance to whoever answers.
First, assign a script name to the object by clicking on it on the map and entering this name in the object's Name property. Let's say it's nObject. And MyHeroScriptName is the script name of the main hero; you can find it by selecting the hero and pressing the spacebar, in the Settings tab.
In the script:

diff=GetDifficulty();
--diff == 1 on Recruit, 2 on Warrior, 3 on Veteran, 4 on Hero

function MyCombat(heroname, objectname)
if heroname == "MyHeroScriptName" then--Check if the correct hero touched the object
StartCombat(heroname, nil, 3, 6, 5+2*diff, 6, 5+2*diff, 6, 5+2*diff, nil, "resultsf"--Function that runs after the battle, needed if something should happen after the battle);
Trigger(OBJECT_TOUCH_TRIGGER, "nObject", nil); --Resets the function
end;
end;

Trigger(OBJECT_TOUCH_TRIGGER, "nObject", "MyCombat");

function results(hero, result)
if result == not nil then
--Script that runs after victory...
else --Script that runs in case of defeat...
end;
end;
6 is the ID of the infantry unit; there will be 3 stacks of 5 plus 2 for each difficulty level.
С уважением, }{0TT@6bI4
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________

Statistics

Welcome our newest member: artem