Skip to content

A few questions about scripts.

User Avatar
#2
Auto-translated
1. If the txt file is located in the main map folder (i.e., Maps/SingleMissions/map_name), you can specify the path to it as follows:
GetMapDataPath()..'filename.txt'

2. The simplest way would be to attach the OBJECT_CAPTURE_TRIGGER to all necessary objects and create a variable to store the number of captured objects:
huts = {table_of_script_names_of_objects}
huts_captured = 0 -- number of captured objects

for i, hut in huts do
Trigger(OBJECT_CAPTURE_TRIGGER, hut, 'CaptureHut')
end

-- function that is triggered when an object is captured
function CaptureHut(p_owner, n_owner)
-- is the new owner of the object a player?
if n_owner == PLAYER_1 then
-- increase the number of captured objects
huts_captured = huts_captured + 1
-- if all are captured and the objective is active
if huts_captured = length(huts) and GetObjectiveState('objective_name') == OBJECTIVE_ACTIVE then
-- complete the objective
SetObjectiveState('objective_name', OBJECTIVE_COMPLETED)
end
else -- if the new owner is not a player?
if p_owner == PLAYER_1 then
-- decrease the number of captured objects if the player was the previous owner
huts_captured = huts_captured - 1
end
end
end
3. MoveHeroRealTime() will be helpful.
4. OpenCircleFog() will be helpful.

P.S. I advise you to read the manuals more carefully; the questions are very basic and are covered in any guide
Нет войне.