Posts from Scripts for beginners.
SetPlayerHeroesCountNotForHire(player_id, number_to_reduce_the_standard_number_of_heroes_by), something like that.
, something like that.SetPlayerHeroesCountNotForHire(player_id, number_to_reduce_the_standard_number_of_heroes_by)
I tried this function, but I don't understand how it works: it's not clear where the standard number of heroes comes from; I even set it to 1000, and I could still hire as many heroes as I wanted.
Added after 15 hours and 31 minutes
Could someone explain or provide an example of how the SetPlayerHeroesCountNotForHire function works?
function gogo()
if GetObjectiveState("quest name at the prophet") == OBJECTIVE_COMPLETED then
RemoveObject("Name of the object to be deleted")
end
end
Trigger(OBJECTIVE_STATE_TRIGGER, "quest name at the prophet", "gogo")
Some immediate comments:
1) The object to be deleted must be of type Static, and the IsRemovable property must be set to true (check in the objectPropretiesTree).
The name is, of course, given there as well – in the name field.
2) If the quest is the same for multiple players and for the same object, we insert a check for IsObjectExists. Then we delete it.
3) Strictly speaking, I haven't tested this trigger for prophet quests. But it most likely works.
Removing an object
function gogo()
if GetObjectiveState("quest name at the prophet") == OBJECTIVE_COMPLETED then
RemoveObject("Name of the object to be removed")
end
end
Trigger(OBJECTIVE_STATE_TRIGGER, "quest name at the prophet", "gogo")
Some immediate comments:
1) The object to be removed must be of type Static, and the IsRemovable property must be set to true (check in the objectPropretiesTree).
The name is also given there – in the name field.
2) If the quest is the same for multiple players and for the same object, add a check for IsObjectExists. Then remove it.
3) Strictly speaking, I haven't tested this trigger for prophet quests. But it will probably work.
function a1()
if GetObjectiveState ("q1") == OBJECTIVE_COMPLETED then
RemoveObject ("qq1");
end;
end;
Trigger(OBJECTIVE_STATE_CHANGE_TRIGGER, "q1", "a1" )
I did it like this. You had a couple of inaccuracies, but it still doesn't work. I even set a quest to remove monsters, and it still doesn't help. Is it necessary to specify that it's for all players, or is that understood by default?
By the way, it complains about the first line of the script. Specifically, about - function a1(), and it's not about the number of characters in the name; I tried 5 letters, and it still complains. Maybe the function itself is somehow wrong; I don't know. My brain is about to explode.
void errorHook( fCallback ) Allows you to set an error handler. By default, when a script error occurs, the current thread terminates. Thanks to this function, you have the opportunity to adjust this behavior – before stopping, control will be passed to the fCallback function. Example: function onError() print("Error occured ") end function SetArtefactUntrans(nArtefactName) errorHook(onError) RemoveArtefact("Berein",nArtefactName) GiveArtefact("Berein",nArtefactName,1) end If an error occurs in the SetArtefactUntrans function (for example, if the hero does not have the required artifact), the string "Error occured " will be displayed in the console. Note that this very informative string will not save you from the thread stopping (nor from displaying diagnostics in the console). The hook will work in all script threads (and not just in the one that called it) until errorHook is called with the parameter nil. I also recommend paying attention to the fact that the hook only works on runtime errors; it does not affect interpretation errors. Regarding the example provided, it is much more reasonable to check the hero for the presence of the required artifact instead of using a hook.
Function gogo not defined, line 1.
Objective with name "gaz" does not exist
I'm attaching screenshots of the Seer's Hut and the tree that should supposedly be removed by the script.
It seems like it doesn't recognize the quest in the Seer's Hut, even though it works and can be completed in the game.