Skip to content

Posts from Scripts

4.8 (8 ratings)
In reply to Долгий
Auto-translated
Long

Should the path to the text file not contain a "/" before "Maps"?

But in general, always check what the console says.

The console isn't complaining. I asked a friend who knows a lot about this, and he says that I wrote and did everything correctly, and it should work, but it just doesn't work. And how am I supposed to understand that? What the hell is wrong?
In reply to Shiroyasha2910
User Avatar
Auto-translated
Shiroyasha2910

The console isn't showing any errors. I asked a friend who knows a lot about this, and he says that everything I wrote and did is correct, and it should work, but it just doesn't work. And how am I supposed to understand that? What the hell is wrong?

Did you remove the slash before Maps?
User Avatar
Auto-translated
In what text editor did you create the file? It should be encoded in Unicode. Not UTF-8, although that's also a Unicode encoding.
С уважением, }{0TT@6bI4
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________
In reply to }{0TT@6bI4
User Avatar
Auto-translated
}{0TT@6bI4
What program did you use to create the text file? It should be encoded in Unicode, not UTF-8, although that works too.

Exactly.
In reply to }{0TT@6bI4
Auto-translated
}{0TT@6bI4
Where did you create the text file? It should be in Unicode encoding, not UTF-8, although that's also a Unicode encoding.

I did it, but it didn't work. I even removed the slash, as "Dolgy" recommended, but it still doesn't work. The funny thing is that even this command doesn't work, even though, as I wrote earlier, even a friend said that I did everything correctly:

SetObjectEnabled("dolmen1", false);

The only command that worked for me is:

SetPlayerStartResources(1, 0, 0, 0, 0, 0, 0, 5000);

But this is the first script I wrote for the map, and after that, it seems that none of the scripts I add work anymore.

I decided to try something, and I went into the editor -> my map -> Map Properties -> Script -> I clicked the Script button, and the editor immediately crashed. But as I understand it, this is a common occurrence for the regular editor.

In reply to Shiroyasha2910
User Avatar
Auto-translated
Shiroyasha2910

I tried it, but it didn't work. I even removed the slash, as "Dolgy" recommended, but it still doesn't work. The funny thing is that even this command doesn't work, even though, as I mentioned earlier, even a friend said that I did everything correctly:

SetObjectEnabled("dolmen1", false);

The only command that worked for me is:

SetPlayerStartResources(1, 0, 0, 0, 0, 0, 0, 5000);

This is the first script I wrote, and after that, it seems like none of the other scripts I add work.

Okay, let's try again. Open your text file, copy what's in it. Then, open the map files and delete it. Restart the map. Then, place a Signpost object, in the MessageFile on the left, click New, enter the same name as your file, and click Ok. This will open an empty window for that file. Paste your text into it, click Ok, close the map, and test in the game to see if the text appears.

 

If it doesn't work, send me your map ("mapname.h5m" file in the Maps folder).



Added 6 minutes later
Shiroyasha2910
I decided to try something, I went into the editor -> my map -> Map Properties -> Script -> I click the Script button and the editor crashes immediately. But as I understand it, this is a common occurrence for the regular editor.
Don't use that button; pretend it doesn't exist. Write/edit scripts either in a text file in the root of the map files (like I and many others do), or use HoMM5MapScriptsEditor. In general, I recommend writing scripts in it and then transferring them to the text file. However, I don't recommend making notes in Russian in it, because when transferring to the Lua file, the Russian text may be corrupted and become "broken Arabic" The same thing can happen if you copy Russian text from a Lua file of the map and transfer it to ScriptsEditor).

In reply to Азгалор
Auto-translated
Azgalor

Okay, let's try again. Open your text file, copy what's written there. Then, open the map files, delete it. Restart the map. Then, place a Signpost object, on the left in MessageFile, click New, enter the same name as your file, and click Ok. An empty window for that file will open. Paste your text there, click Ok, close the map, and test in the game to see if the text appears.

 

If it doesn't work, send me your map ("mapname.h5m" file in the Maps folder).


No, this works. Quests or texts from signposts that are already added to the map work. Maybe it just doesn't work on the dolmen? It worked, I changed it to a Sylvan tree, and it worked, but now after reading the text, I can't enter the hero, and other in-game text (e.g., "your hero can no longer move this turn," "spell learned") starts displaying 5-10 seconds after the initial text. Anyway, I guess I'm a true genius if such simple commands cause bugs in the game -_-.

 

I know about the editor) That's why I initially use ScriptsEditor).

User Avatar
Auto-translated
Shiroyasha2910, does the function from OBJECT_TOUCH_TRIGGER still not work for you?

Added 38 minutes later
Shiroyasha2910
No, it works. The tasks already added to the map or the texts from the markers work. Maybe it just doesn't work on the dolmen? It started working; I changed it to a Sylvan tree, and it worked, but now, after reading the text, I can't access the hero, and another in-game text (for example: your hero can no longer move this turn, the spell has been learned) starts displaying 5-10 seconds after the initial text. In short, I'm truly a genius if such simple commands cause bugs in the game -_-
The delays are most likely caused by some loop (or loops, if there are several), which is why I asked you to upload the map. As for the dolmen, the error is probably due to the fact that you wrote the script name differently in the dolmen than in Trigger(OBJECT_TOUCH_TRIGGER, "", "")
In reply to Азгалор
Auto-translated
Azgalor
Shiroyasha2910, doesn't the function from OBJECT_TOUCH_TRIGGER still not work for you?

Added 38 minutes later
The delays are most likely caused by some loop (or loops, if there are several), that's why I asked you to upload the map. As for the dolmen, the error is probably due to the fact that you wrote the script name differently in the dolmen, not as in Trigger(OBJECT_TOUCH_TRIGGER, "", "").
I understand. Is it possible for me to send you the map in a private message?
In reply to Shiroyasha2910
User Avatar
Auto-translated
Shiroyasha2910

I understand. Is it possible for me to send you the map via private message?
Yes, click on my nickname, and you'll see "Send a private message."
User Avatar
Auto-translated
Hello. Is there a way to track garrisons without names? `GetObjectNamesByType` doesn't display them. Perhaps there's another function for that?
User Avatar
Auto-translated
It definitely doesn't find anything using "BUILDING_GARRISON"?
If not, then there's only one way: parse the map.xdb file with your own program, assigning a script name to all objects of the garrison type.
С уважением, }{0TT@6bI4
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________
In reply to }{0TT@6bI4
User Avatar
Auto-translated
}{0TT@6bI4
It definitely doesn't find anything using "BUILDING_GARRISON"?

Yes, unfortunately... Neither BUILDING_GARRISON nor BUILDING in general. I decided to test this on one of the maps where the bot owns mines, houses, and garrisons. I used BUILDING to get an array of the bot's possessions and then used SetObjectOwner, and the owner of all the bot's buildings, except for the garrisons, changed. Even the garrisons that have names are not tracked.



Added 8 hours 26 minutes ago
I wrote a small script for myself:
function NoFlee( n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17, n18, n19, n20 )
heroeslist = { n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17, n18, n19, n20 }
for key, heroes in heroeslist do
if IsObjectExists( heroes ) ~= nil then
DenyAIHeroFlee( heroes, 1 )
print("Hero ", heroes, " will no longer leave battles until he dies")
end
end
end

It all works, but the console constantly complains about an incorrect first argument in IsObjectExists, which occurs because of the unfilled arguments. Is it possible to rewrite the script or add something so that the array is filled only with filled arguments? Or rewrite it so that the console doesn't complain about empty arguments.

User Avatar
Auto-translated
Azgalor, you can immediately pass a table to the function: ```lua function NoFlee(heroeslist) for key, heroes in heroeslist do if IsObjectExists(heroes) ~= nil then DenyAIHeroFlee(heroes, 1) print("Hero ", heroes, " will no longer leave battles until he dies") end end end -- Example of usage NoFlee({n1, n2, n3});
РПГ-сценарий для HoMM5: Путь героя
ЧаВо по созданию карт для HoMM5: ЧаВо
User Avatar
Auto-translated

Hello. I'm encountering a strange problem with spellcasting in a combat script.

function DefenderCreatureDeath (unit)
  if exist ('Priest') then
  sleep (2)
  SetUnitManaPoints(Osillian, GetUnitManaPoints(Osillian)+50)
  sleep (1)
  UnitCastAimedSpell (Osillian, SPELL_RESURRECT, unit)
  sleep (5)
  UnitCastAimedSpell (Osillian, SPELL_CELESTIAL_SHIELD, unit)
  end
end

In this script snippet, I need the hero to resurrect the fallen defenders after their death and then cast Celestial Shield on them. The resurrection works fine, but the Celestial Shield simply won't cast. The console displays a generic "Unit can't cast aimed spell..." message. I've been struggling with this for two days, and I would be very grateful if someone could offer some advice.

And another question: I need the enemy hero's archer, let's call him 'Hunter', to target one of the player's hero's creatures during his turn, but not a specific one. However, I can't figure out how to do this. I think I need to create a table of creatures that the archer can choose from, but I'm not sure how to create it, and I also know that the regular commandShot won't work here, so how can I make the archer actually shoot?

Statistics

Welcome our newest member: Emil