Auto-translated
No, the scripts still don't work. What's the problem? Could you take a look, if possible?
New here? I'm Roha — want a quick tour?
No, the scripts still don't work. What's the problem? Could you take a look if possible?
function SetPlayerStartResources (player, wood, ore, mercury, crystal, sulfur, gem, gold)
if player == 1
then wood = 20
ore = 20
mercury = 10
crystal = 15
sulfur = 10
gem = 10
gold = 15000
end
endSetPlayerStartResources (1, 20, 20, 10, 15, 10, 10, 15000)
--without any function, etc.Maybe it's simpler this way?function alive()
while IsHeroAlive("Hero9") do
sleep(10)
end
Loose()
-- or --
Loose(1)
endIf it's what I think it is, it can be done much simpler and clearer, without any loops
Well, the main thing is that it works.
function QuestPervii ()
if HasArtefact ("Hero9", "TOME_OF_DESTRUCTION") without quotes, incorrect id
then MessageBox (GetMapDataPath().."QuestPervii.txt")
ChangeHeroStat ("Hero9", STAT_DEFENSE, 7) STAT_DEFENCE
RemoveArtefact ("Hero9", "TOME_OF_DESTRUCTION") without quotes, incorrect id
Trigger(OBJECT_TOUCH_TRIGGER, "Pervii", nil)
else MessageBox (GetMapDataPath().."LoseL.txt")
end;
end;function QuestVtoroi ()
if HasArtefacts ("Hero9", "SKULL_OF_MARKAL") incorrect function name, id without quotes, incorrect id
then MessageBox (GetMapDataPath().."QuestVtoroi.txt")
ChangeHeroStat ("Hero9", STAT_OFFENCE, 7)
RemoveArtefact ("Hero9", "SKULL_OF_MARKAL" ) without quotes, incorrect id
Trigger(OBJECT_TOUCH_TRIGGER, "Vtoroi", nil)
else MessageBox (GetMapDataPath().."LoseLI.txt")
end;
end;function alive()
while IsHeroAlive("Hero9") do
sleep(10)
end
Loose()
-- or --
Loose(1) remove, so as not to confuse anyone
endTrigger(OBJECT__TRIGGER, 'X', 'capture_town') incorrect trigger id, pointer to a non-existent function
function alive()
while IsHeroAlive("Hero9") do
sleep(10)
end
Loose()
-- or --
Loose(1)
end
function alive(heroname)
if heroname=="Hero9" then
Loose()
end
end
Trigger(2, 1, "alive")
To avoid dealing with various constants like REGION_ENTER_AND_STOP_TRIGGER or TOME_OF_DESTRUCTION, it's better to replace them with numbers (all numbers are listed in the document IDs for scripts). This makes the code more compact and helps avoid several errors that are almost unnoticeable during debugging.
For example, the codes
Trigger(REGION_ENTER_AND_STOP_TRIGGER, "Gnom", "gnom")
and
Trigger(6, "Gnom", "gnom")
work the same, but the second entry is much easier to use.
function alive()
while IsHeroAlive("Hero9") do
sleep(10)
end
Loose()
-- or --
Loose(1)
end
function alive(heroname)
if heroname=="Hero9" then
Loose()
end
end
Trigger(2, 1, "alive")
I need a script so that the mission fails after a hero dies. Thanks in advance.
Nargott wouldn't approve.
In Notepad++, where I write scripts, for example, when I type the first letters of a constant, a list of words from the file is suggested, and I just have to choose one. This reduces the chance of making a mistake.
Added 2 minutes later
The second one will trigger with any loss of a hero by the player, the first one - only upon death.