Skip to content

Posts from Scripts for beginners.

4.5 (2 ratings)
User Avatar
Auto-translated
The simplest (and the only sensible) thing that comes to mind is to make your map replace all the campaigns of the original Heroes, and your videos replace the corresponding videos about the wedding and the one that plays at the end of the game.
 

К А
Стикеры GBF в Telegram
In reply to Ment
User Avatar
Auto-translated
Thanks for the advice, but unfortunately, that's not an option. Firstly, it would only allow for one video to be displayed, and secondly, I don't want to replace anything; I want to add something. Okay, we'll think about it. Maybe we can create some kind of video texture, or something similar. And then set up a cutscene where the video texture plays on a static object – a plane or a wall – and the camera is fixed on that object. But, as far as I know, in Heroes, you can't set a texture as a sequence of frames. In that case, the only option left is to arrange the sequence of frames on a plane as separate objects and set the camera to switch to each frame in the cutscene. That is, for each new frame, the camera in the cutscene would be fixed on a new object with a new frame of the video. It's clear that this is a somewhat crazy solution, and there might be issues with syncing the audio. But, I think there aren't many other options.
Группа в вк посвящённая моим модам

Страничка моего последнего мода на ModDB

Моя страничка на Artstation,
где можно посмотреть и повертеть внутри браузера мои 3d модели.
Auto-translated
Hello, I have a question: how can I limit the number of heroes a player can control simultaneously, for example, so that they cannot have more than 3 heroes?
User Avatar
Auto-translated
SetPlayerHeroesCountNotForHire(player_id, number_to_reduce_the_standard_number_of_heroes_by), something like that.
Нет войне.
In reply to Gerter
Auto-translated
Gerter
SetPlayerHeroesCountNotForHire(player_id, number_to_reduce_the_standard_number_of_heroes_by)
, something like that.

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?
Auto-translated
Who can help? A friend got me hooked on Heroes 5 3.1, and I decided to create a huge map for 8 players. It's completely hand-drawn, and each race will have its own unique features and secrets. Right now, I'm working on one of the races and I've run into the need for scripts. I need a couple of basic scripts. I'll be able to modify them later. The main thing is to have examples, because I'm trying to figure it out myself, but it's not going very well. As a thank you, I'll post my map here later so that everyone can play it. Specifically, I'm interested in these scripts: 1. There's a prophet's hut where a quest is given. There's a condition for completing the quest. When the quest is completed, as a reward, obstacles should be removed in a specific location on the map at the specified coordinates, opening a passage. Or, the hero who completed the quest should be teleported to a specific point on the map. Moreover, this won't always be a player; it could also be an AI playing for that race. 2. I need a script that, when visiting the prophet's hut and completing the quest, transforms a specific town captured by the player who visited the prophet into a town of a different type. And in general, is it possible to do such things through the prophet's hut? Thank you in advance.
User Avatar
Auto-translated
Check out the FAQs for this section: one and two; they should provide sufficient guidance. Regarding conversion, I'll say right away that it won't be possible to convert a town into another while preserving its buildings. However, with Necropolis, it is definitely possible; I am less certain about the others, but most likely yes. Nevertheless, the task is not entirely trivial.
 

К А
Стикеры GBF в Telegram
In reply to Ment
Auto-translated
Check out the FAQs for this section: one and two; they should provide enough information for learning purposes.

I'm saying that I couldn't find how to do it. I already looked and tried to figure it out. I need help from a professional.
User Avatar
Auto-translated
Deleting an object

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.
 

К А
Стикеры GBF в Telegram
In reply to Ment
Auto-translated
Ment
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.
User Avatar
Auto-translated
Could you tell me what exactly it writes? I'm running a bit short on ideas. Just now, I realized that the player number is passed to the a1 function, but ideally, this shouldn't affect anything. Novik, in his manual, describes how to create hooks; you can use it.
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.
 

К А
Стикеры GBF в Telegram
In reply to Ment
Auto-translated
I changed it to your name. It's the same. It specifically says the following about the first line in the built-in script editor. The external script editor doesn't complain.

Function gogo not defined, line 1.
User Avatar
Auto-translated
Is this what the editor displays during map validation? It's irrelevant and doesn't indicate incorrect code. You need to enable the console in the game and check for errors there.
 

К А
Стикеры GBF в Telegram
In reply to Ment
Auto-translated
On the very first day, even before the turn begins, it displays in red:

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.
Attachments 2
2 files attached • Total size: 383.3 KB

Statistics

Welcome our newest member: Emil