Skip to content

Posts from Scripts

4.8 (8 ratings)
User Avatar
10 years ago
Auto-translated
It is necessary to block a region (passage) for a specific computer-controlled hero. Using SetRegionBlocked with a condition did not work – the computer-controlled hero still passes through the block. Besides, this all works with triggers that are activated by both the player and the computer-controlled hero (which looks terrible – empty stops). I did the following: ``` SetRegionAutoObjectEnable ("kendal00", REGION_AUTOACTION_ON_ENTER, -1, -1, "Deleb", "kendal0", 0); SetRegionAutoObjectEnable ("kendal00", REGION_AUTOACTION_ON_EXIT, -1, -1, "Deleb", "kendal0", 1); ``` It worked. But a problem arose: the computer-controlled hero now constantly tries to pass through the block (which is understandable, because after the hero exits the region, the passage becomes "open" again). Is there a better way to block a passage for a specific hero?
User Avatar
10 years ago
Auto-translated
Using SetRegionBlocked with a condition didn't work – the computer-controlled hero still passes through the blocked area.
That's quite strange; I haven't encountered this error before. How did you write the code? The SetRegionBlocked function has a parameter that specifies the player number for which the function applies. So, for the second player (whether it's the computer or not):
SetRegionBlocked("region name", true, 2)
If the numbering starts from one, I thought that's how it should be. If it starts from zero, then accordingly:
SetRegionBlocked("region name", true, 1)
User Avatar
10 years ago
Auto-translated
The AI doesn't pass if the region is initially blocked. However, if it moves to an adjacent region that activates the blocking region, the hero passes through the block. But if I modify the script for my own purposes, I can't pass through. Moreover, in this case, I need to limit the area of one AI hero without affecting other heroes of that player.
User Avatar
10 years ago
Auto-translated
If he tries to move to an adjacent region (nearby) that activates a blocking region, the hero will pass through the block. However, if I modify the script for my own purposes, I can't pass through.
It should be easy to prevent this. There doesn't seem to be a parameter in REGION_ENTER_AND_STOP_TRIGGER that specifies the player number, but you can easily check the hero's affiliation when he enters the region.
Moreover, in this case, I need to limit the area of one computer-controlled hero without affecting other heroes belonging to the same player.
Oh, if that's the case... Hmm, yes, that's a problem. I need to think about it.
User Avatar
10 years ago
Auto-translated
And you can’t make this hero a new player-ally, right?
User Avatar
10 years ago
Auto-translated
You can’t make this hero a new player-ally, right?
No. This contradicts the design.
User Avatar
10 years ago
Auto-translated
Unfortunately, I have no ideas.
User Avatar
10 years ago
Auto-translated
Okay, I'll leave it as is. Next question.
The first 3 bonuses in a campaign. Construct a building in a town.
If I understand correctly, the choice is limited to the editor's list, and it won't be possible to use building IDs?
TB_BLACKSMITH
TB_DWELLING_1
TB_DWELLING_2
TB_DWELLING_3
TB_DWELLING_4
TB_DWELLING_5
TB_DWELLING_6
TB_DWELLING_7
TB_FORT
TB_GRAIL
TB_MAGIC_GUILD
TB_MARKETPLACE
TB_SHIPYARD
TB_SPECIAL_0
TB_SPECIAL_1
TB_SPECIAL_2
TB_SPECIAL_3
TB_SPECIAL_4
TB_SPECIAL_5
TB_SPECIAL_6
TB_TAVERN
TB_TOWN_HALL

Buildings for which the construction requirements are not met also cannot be built. Is that correct?

What is "TB_SPECIAL"?
User Avatar
10 years ago
Auto-translated
Buildings that do not meet the construction requirements will not be built.
They should be built, in theory. Although, I'm not very familiar with this, as I haven't created any campaigns.
User Avatar
10 years ago
Auto-translated
Regarding the hero's area of activity

You could try using SetAIHeroAttractor.
However, it's not entirely clear how far it will allow the object to move away...
User Avatar
10 years ago
Auto-translated
You could try using SetAIHeroAttractor.
However, it's not entirely clear how far it will allow the object to move away...
Yeah, you could create some kind of portal or something similar... But this script works very unpredictably, if it works at all. And it's not certain that the AI's pathfinding will work correctly with it.
User Avatar
10 years ago
Auto-translated
I looked at SetAIHeroAttractor. With a value of 2, it literally sticks to the object. With a value of 1, it almost doesn't care about the object anymore. But I'll make it with a value of 2. It suits me better; it eliminates the hero's pointless standing near a "wall" and reduces the computer's turn time.
User Avatar
10 years ago
Auto-translated
Could you please advise: how can I access a hero's parameter within one function and use that data when another function is executed?
User Avatar
10 years ago
Auto-translated
Quantum, save it in a global variable, if I understand the task correctly.
User Avatar
10 years ago
Auto-translated
Could you please provide some guidance on how to do this? GetGameVar and SetGameVar? Something like this? GetGameVar ("X") = GetHeroLevel ("Anabel") SetGameVar ("X", 12)

Statistics

Welcome our newest member: recijeb