Skip to content
User Avatar
#3280
Auto-translated
Loli Nikita
Please help me with a script. I need peasants to join my hero, a quest to appear, and the goal is to lead them to a specific point and complete the quest there, after which they should disappear from the hero's party. If the peasants die in battle, the quest should fail. (I can more or less write the initial stages, but I don't know how to make the quest fail after the peasants die.)
First, place the peasants on the map.
Then, use this command:
SetObjectEnabled ('Peasant', nil);

On the map, draw a region to which the peasants must be led, and let's call it 'Region'.

---script for joining peasants---

function peasants()
---your code---
AddHeroCreatures ('hero_name', 1, 4);
SetObjectiveState ('quest_name', OBJECTIVE_ACTIVE, PLAYER_1);
RemoveObject ('Peasant');
end;

Trigger(OBJECT_TOUCH_TRIGGER, 'Peasant','peasants');

Now, the script for when you need to say goodbye to the peasants:

function RegionF()
---your code---
if GetObjectiveState ('quest_name', 1) == OBJECTIVE_ACTIVE then GetHeroCreatures('hero_name', 1)==4 then
RemoveHeroCreatures('hero_name', 1, 4);
SetObjectiveState ('quest_name',OBJECTIVE_COMPLETED, PLAYER_1);
Trigger (REGION_ENTER_AND_STOP_TRIGGER, 'Region', nil);
end;
end;

Trigger (REGION_ENTER_AND_STOP_TRIGGER, 'Region', 'RegionF');

Regarding the peasants dying in battle and the subsequent quest failure, I think combat scripts are needed, but unfortunately, I don't know them.

Above, }{0TT@6bI4 suggested a better version;)