Skip to content

Posts from Scripts

4.8 (8 ratings)
In reply to Jack_of_shadows
8 years ago
Auto-translated
Crypt, meaning a tomb, but thank you very much, I will try to implement it tomorrow. In the best-case scenario, I want to create a campaign about Cyrus in his youth.

Added 46 minutes later
-- disable highlighting and set a peaceful icon on hover
SetObjectEnabled(npc, nil);
SetDisabledObjectMode(npc, DISABLED_INTERACT);
sleep(1)
SetMonsterSelectionType(npc, 0);

-- function-handler for poking - optional parameter
if(func ~= nil) then
Trigger(OBJECT_TOUCH_TRIGGER, npc, func);
end

-- NPC name - optional parameter
if(name ~= nil) then
SetMonsterNames(npc, MONSTER_NAME_SINGLE, name);
end

end

And can I, for the less intelligent, change what is in the parentheses? If so, what does nil, DISABLED_INTERACT mean, does npc need a name that I invent and enter into the name string and then here, or not, OBJECT_TOUCH_TRIGGER, npc, func, and what does this mean: name ~= nil) then
SetMonsterNames(npc, MONSTER_NAME_SINGLE, name);?:confused:
User Avatar
8 years ago
Auto-translated
Godric's Hollow, you've taken a phrase out of context, meaning you've extracted code from a function. npc, func, and name were its parameters, and a description with an example of how to use them was provided in the link. nil is one of the keywords in Lua; it has many different uses in code, and it's impossible to describe them all at once. DISABLED_INTERACT, OBJECT_TOUCH_TRIGGER are named constants; their definitions can always be found near the function for which they are intended. If the code of my function seems too complex, the point is not in it, but in the fact that all the necessary names of standard functions are given, both for disabling an object and for attaching its own handler to it. And this knowledge is already 90% of the solution to your problem.
In reply to Jack_of_shadows
8 years ago
Auto-translated
How do you build a dock or pier? I've been searching, but I can't find any information.
In reply to Годрикова впадина
User Avatar
8 years ago
Auto-translated
Godric's Hollow
How do you make a dock or pier? I've been searching, but I can't find it.
1. Create the body of water yourself. 2. In the Terraforming tab, you need the ramp button; click it. 3. At the border between the water and the land, click and hold for about 5 seconds, then drag the mouse towards the water, and a transition between the land and water should be created. 4. Place a shipyard nearby, and there you can buy ships, and that's your pier.

Added 24 minutes later
Godric's Hollow, and if you want a pier near a Castle (so that the shipyard is in the Castle), do everything up to step 4. You need to build a shipyard in the Castle, and you can buy ships there. BUT, I don't recommend trying to build piers using Castles, as Castles often cause problems and don't recognize the water or the space for placing ships (I speak from my own experience).
8 years ago
Auto-translated
Hello. I'm creating a map for multiplayer, and the idea is that after 2.5 months, the player's hero will be teleported to a portal leading to the center of the map, where a battle with the other players will take place. And I don't know anything about scripting :с. I need help. Is there a script that can create this scenario?
In reply to Sarcastrophe.
User Avatar
8 years ago
Auto-translated
Sarcastrophe.
Hello. I'm creating a map for multiplayer, and the idea is that after 2.5 months, the player's hero will be teleported to a portal leading to the center of the map, where a battle with the other players will take place. And I don't know any scripting at all :с. I need help. Is there a script that can create this scenario?
In general, it looks like this. The only problem is choosing the player's hero to teleport.
function NewDay()
if GetDate() == 71 then
SetObjectPosition('hero_name_1', coord_x, coord_y, floor_0_or_1)
SetObjectPosition('hero_name_2', coord_x, coord_y, floor_0_or_1)
-- ... and so on
end
end

Trigger(NEW_DAY_TRIGGER, 'NewDay')
In reply to RedHeavenHero
8 years ago
Auto-translated
RedHeavenHero
Overall, this is what it looks like. The only problem is choosing which player hero to teleport.
function NewDay()
if GetDate() == 71 then
SetObjectPosition('hero_name_1', coord_x, coord_y, floor_0_or_1)
SetObjectPosition('hero_name_2', coord_x, coord_y, floor_0_or_1)
-- ... and so on
end
end

Trigger(NEW_DAY_TRIGGER, 'NewDay')

RedHeavenHero, thank you very much. And one more question, if possible. Are the heroes on the map chosen by the player or randomly? If so, how would that work? As I understand it, I need to choose a starting block for the hero, right?
User Avatar
8 years ago
Auto-translated
Hey, does anyone know how to open the built-in script editor (Map Properties > Script > Edit Script)? When I click "Edit Script," the game crashes. I'm using the HoMM5 Map Scripts Editor, but I haven't found a proper solution to these crashes online, and I suspect I'm not the only one facing this issue. I'd appreciate any help in resolving this.
In reply to Sarcastrophe.
User Avatar
8 years ago
Auto-translated
Sarcastrophe.
RedHeavenHero, thank you very much. And one more question, if possible. Are the heroes on the map chosen by the player or randomly? How does it work in that case? As I understand it, you need to choose a starting block for the hero, right?
In general, you can get an array with the names of all the player's heroes by calling the GetPlayerHeroes(player_number) function. The question here is more about which of the heroes you want to teleport.
User Avatar
8 years ago
Auto-translated
Question regarding bouncing messages. Is it necessary for them to bounce away from the object? In some cases, I'm not sure I can correctly select the object within the player's field of view at the time of the script. The point is to have a message "main quest updated" float across the screen. Currently, it bounces off the main hero, but this is extremely inefficient. After all, it might not be Markel who takes the garrison. And how do I make the battle script update? I noticed that it works in a very one-time way... How do I make it run from the beginning at the start of the battle, and not from the point where it stopped in the previous battle? That is, how do I reset the script's variables to 0 at the end of the battle, regardless of the outcome?
User Avatar
8 years ago
Auto-translated
The point is that a message should appear on the screen saying "main quest updated." Right now, it bounces away from the main hero, but that's very inconvenient. After all, it might not be Markel who takes the garrison.
I think that's the whole point of the floating message – that it's tied to an object. In most cases, you can track which hero performed the event; it's passed along through trigger touches, after battles, and in many other places.
How can I make it go to a specific starting point at the beginning of a battle, instead of starting from where it stopped in the previous battle?
It already calls the Start() function at the beginning of each battle, and then other functions are called based on various events. By overriding your own Start() function, you can reset anything you want in it. If you're wrapping the script in a separate thread, you probably need to track the end-of-battle event and exit from it.
User Avatar
8 years ago
Auto-translated
Here's how a script of the following type would look: as soon as the hero "hero" finishes any battle, the "battle" script is removed from him and reapplied.

Added 4 minutes later
As far as I remember, the esteemed RedHeavenHero had an elemental amulet in the Unicorn Empire campaign that allowed Varen to summon elementals at the beginning of the battle. And this script worked flawlessly. At the beginning of each battle, always.
User Avatar
8 years ago
Auto-translated
And how can I make the battle script update? I noticed that it works in a very one-time way... How can I make it start from the beginning at the start of the battle, and not from the point where it stopped in the previous battle? That is, how can I reset the script's variables to 0 at the end of the battle, no matter what?
That's strange, I've never noticed that. The usual SetHeroCombatScript worked correctly, starting the script from the beginning.
In reply to орлан-1
User Avatar
8 years ago
Auto-translated
orlan-1
Hey, does anyone know how to open the built-in script editor (Map Properties > Script > Edit Script)? When I click "Edit Script," the game crashes. I'm using the HoMM5 Map Scripts Editor, but I haven't found a proper solution to these crashes online, and I suspect I'm not the only one facing this issue. I'd appreciate any help in resolving this.
Please don't ignore:smile35:
User Avatar
8 years ago
Auto-translated
This is a persistent issue, and I haven't been able to resolve it on my end. I use Notepad.

Statistics

Welcome our newest member: recijeb