Skip to content

Posts from A few questions about scripts.

No ratings yet — be the first to rate!
User Avatar
7 years ago
Auto-translated
In general, I decided to create a few scripts, and I have some questions, even though I studied the manuals for a long time. 1. A simple MessageBox. I created a txt file, but what path should I specify in the script to access it? What is the initial folder, and do I need to include the file extension? 2. This isn't exactly about scripts, but it's related. How can I create a quest where the goal is to capture multiple identical peasant huts (like in the first map of the Hammers of Fate)? 3. How can I make it so that when an enemy hero crosses a region, they run from one place to another, while the camera follows them, preventing the player from controlling them? 4. How can I make certain areas on the map initially visible?
User Avatar
7 years ago
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
In reply to Gerter
User Avatar
6 years ago
Auto-translated
Thank you. I've managed to resolve most of the issues, but this darn MessageBox keeps popping up, and I can't get rid of it. I've tried all possible paths. Nothing works. For example, I call MessageBox like this: What's my mistake?
MessageBox("Maps/SingleMissions/Revolution vol2/exroadmsg.txt");
User Avatar
6 years ago
Auto-translated
well, if the file is located correctly, you also need to add a slash:
MessageBox("/Maps/SingleMissions/Revolution vol2/exroadmsg.txt");
but the best way, as I wrote before, is:
MessageBox(GetMapDataPath().."exroadmsg.txt");
In reply to Gerter
User Avatar
6 years ago
Auto-translated
Even with the slash, it still gives the same error: Empty message text!
I didn't quite understand about GetMapDataPath.

And also, sorry for being persistent, could you please tell me how to do this: if a hero completes a quest, they can go to the key keeper, but if they haven't completed it, a message is displayed when entering the region, and the hero is teleported back.

Statistics

Welcome our newest member: recijeb

Users Online 4 users 1371 guests