Skip to content

Posts from Scripts

4.8 (8 ratings)
User Avatar
#3504
Auto-translated
Hello. I tested your script and made a few changes. It now works. However, I recommend using a more convenient way to iterate through the array: ```lua for key, id in enemy_creatures do if GetHeroCreatures(hero, id)>=1 then counter = counter - 1 end end
С уважением, }{0TT@6bI4
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________
In reply to Азгалор
User Avatar
#3505
Auto-translated
Azgalor writes in the console: ERROR: Empty message text!
In reply to Alinksolo
User Avatar
#3506
Auto-translated

}{0TT@6bI4, thank you very much, I'll test it out. :)

Alinksolo
Azgalor writes in the console: ERROR: Empty message text!
This means that the path to the text file is incorrect. Are you sure that the required text is actually in that file/at that path?
In reply to Азгалор
User Avatar
#3507
Auto-translated
Well, I don't know if there are any more folders with that path:
Maps/SetingMission/MY_MAP_NAME/TEXT

If so, it might not be correct.
User Avatar
#3508
Auto-translated
Alinksolo, then do the following: Copy your text, place the Signpost object (this is a signpost) on your map. You can find it almost at the very bottom among the Objects, select it, and on the left in the window, in the MessageFileRef line, click New, enter a name, for example, Reg0Message. After that, a window will open for entering text, paste/enter your text there, confirm, close the window, and delete the signpost. In the files of your map, a text file Reg0Message will appear; enter its path into your MessageBox in the script, i.e., MessageBox("Maps/SingleMissions/greet/Reg0Message.txt"), save the map, and then check the result in the game.
In reply to Alinksolo
User Avatar
#3509
Auto-translated
Alinksolo
Well, I don't know if there are any more folders with that path:
Maps/SetingMission/MY_MAP_NAME/TEXT

then it might be incorrect.
Try this: /Maps/SingleMissions/MapName/filename.txt
With a mandatory slash before Maps.
С уважением, }{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
#3510
Auto-translated
I already tried, it doesn't work.

Added 13 minutes later
Azgalor, your method helped, thank you!
User Avatar
#3511
Auto-translated
Alinksolo, by the way, I think I understand what your likely mistake was. You were creating the file on your desktop, for example, or in the file explorer, and therefore it had the wrong encoding (most likely ASCII), but it should be strictly Unicode. I recommend getting a script editor and creating text files through it; it's convenient.
С уважением, }{0TT@6bI4
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________
#3512
Auto-translated
Sir }{0TT@6bI4, I apologize for such a lengthy question, but it's been on my mind. How do you even write combat scripts? What can I read about this, and what exactly do I need to do?
How do I create the CombatScript.lua and CombatScript.xdb files? If I simply put modified files from another source into the unpacked map, ScriptsEditor throws errors and refuses to open the map when I repack it. Although, maybe it's just that I've made so many changes that it's complaining.
On the internet, there are only scattered pieces of information, and I haven't found a comprehensive guide.
User Avatar
#3513
Auto-translated
https://vk.com/h5mmmapeditors?w=wall-197578149_356
I made such a guide a long time ago. There are many other interesting things in my group! biggrin They say that even two-horned unicorns can be found there smile04
С уважением, }{0TT@6bI4
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________
In reply to }{0TT@6bI4
#3515
Auto-translated
}{0TT@6bI4
https://vk.com/h5mmmapeditors?w=wall-197578149_356
I made this guide a long time ago. There's a lot of interesting stuff in my group! biggrin They say that even two-horned unicorns can be found there smile04
-----

Oh, come on, so to read it, I need to register on VKontakte? I don't even have social media accounts, and I really don't want to get into it.
Can't I just download it somewhere?

P.S. Okay, for such a thing, I registered and even subscribed. I'm going to read it.

Added 1 hour 2 minutes ago

Sorry, }{0TT@6bI4, but I read it and didn't understand anything.

"To create an xdb file for the script, you need to go to Map Properties Tree => Map Script and create a new one instead of the map script. In it, in ScriptFile, select the Lua script file from Game/Editor/H5MMods/Map Name. Save, then return (by selecting or entering the path manually)."

I open Map Properties Tree => Map Script, create a new script, and name it Kot.
And I see: (I would insert a screenshot of what I see, but they tell me that they don't support uploading files in png or jpg format, and what format can I use to insert screenshots here, and how do I do it?)
In short, I don't see any Lua file for my map because it doesn't exist.
I didn't create it - I don't know how.

Your guide is good for advanced users, but I'm a beginner in this.
Can you just write what to click to create CombatScript.lua?
You write about hooks in your guide, but you don't write where to write them - apparently, in this file?
User Avatar
#3516
Auto-translated
Martha, select any creature/hero on the map; in the window on the left, you will see the CombatScript line. Hover the cursor over null and click on it, then click on New, and give a name to the future xdb file, which will lead to the lua file. For example, Combat_1. Next, a window will open (if it doesn't open, click on the ellipsis where you previously selected New); there, you will already see the path to the created xdb file. On the right, you will see two lines: FileName and ScriptText. Perform exactly the same operation in FileName as you did when creating the xdb file; name it the same as the xdb file (so that you should have two files: Combat_1). In the filled-in FileName, you will see the path to the lua file. By selecting the path and clicking Edit instead of the ellipsis, you can edit this lua file. Also, the lua file can be edited by clicking on the ellipsis in the ScriptText line.
In reply to Азгалор
#3517
Auto-translated
Azgalor, thank you very much. I will try.
In reply to }{0TT@6bI4
User Avatar
#3518
Auto-translated
}{0TT@6bI4
Hello. I tested your script variant, making a few changes. It works. But I recommend using a more convenient way to iterate through the array:

for key, id in enemy_creatures do
if GetHeroCreatures(hero, id)>=1 then
counter = counter - 1
end
end

 

Hello! I tested it, and for some reason, the more convenient version works correctly for me, while the first one gives an incorrect number. By the way, I tested it in the "extended" version of my script, that is...
reputation = 0;
player_heroes = { "RedHeavenHero03", "RedHeavenHero02" }
enemy_creatures = { 106, 107, 108, 109, 110, 111, 112, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28 }
friend_creatures = { 600, 601, 602, 603, 604, 605, 606, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }

function conditions()
print("reputation = ", reputation );
for h, heroes in player_heroes do
for e, enemy in enemy_creatures do
for f, friend in friend_creatures do
if GetHeroCreatures(heroes, enemy) > 0 and GetHeroCreatures(heroes, enemy) <= 99 then
reputation = reputation - 1
sleep(1)
elseif GetHeroCreatures(heroes, enemy) >= 100 then
reputation = reputation - 2
sleep(1)
elseif GetHeroCreatures(heroes, friend) > 0 then
reputation = reputation + 1
end
end
end
end
end

And here's what's strange. I have Valeria and Lorenzo (Knights from the array) on the map, and Valeria is also in reserve (this is kind of a bug, because for the reserve, she shouldn't be on the map initially. So I don't know if her presence in the reserve affects the script that checks the heroes' armies), and I test it like this: I give Valeria in reserve a green archangel and a paladin (which are in the array as "friends" for which +1 reputation per unit is added), and the one on the map only has a green archangel (+1 reputation), and Lorenzo has 40 land lords, 50 archers, 20 zealots, 10 combat griffins, 6 adepts, 4 knight isabelles, and 2 fallen angels. In total, Lorenzo should give -7 reputation, because each red creature is -1 and none of them are more than 100, but for some reason, the counter goes crazy, giving me -126 points. And it also starts to go crazy if I dismiss all creatures from Lorenzo except, for example, 40 land lords. Then it will gradually decrease the counter to a small negative number (16-36), and then completely reset it.

 

In general, my idea is this: the player will have a counter called reputation, which: decreases for "bad" creatures and increases for "good" ones, and I plan to add some more factors in the future, such as capturing treasure vaults owned by a certain player, a battle with "good" creatures (which I already asked about before, but haven't implemented yet). In general, I would like to put all this system with the counter into one function, but I don't know if this is a good idea. So, I need help  

User Avatar
#3519
Auto-translated
Martha, Reply => Advanced Mode => Attachments (visual button), this is how you can attach images.

Here is an excerpt from one of the guides:
First, create a new lua and xdb file for the script, which will contain the combat script, and
link it to the hero. This action is performed for all heroes whose specialization
works in combat.
To create a new xdb file, open the map and find Map Properties Tree => MapScript.
Click on this line, select the current content, and copy it to the clipboard (Ctrl+C).
Then, click New => Enter the name CombatScript => OK. You can, of course, simply re-enter Map
Properties Window => Script => Edit Script and continue editing the combat script
from there, but it often crashes, so I strongly recommend using the script editor. Save and close the map, open it in the script editor. In any folder, create a new lua file (File=>New *.lua) and save it, then close it.
Now, open the map in the editor again, MapScript => … => FileName => … => In the file explorer, go to
Editor/H5Mods/Map Name/Maps/SingleMissions/MapName/=> Select your lua file from here.
Or from wherever you put it. Save and close the editor and return to the script editor. So, the general preparations for creating the combat script are complete.
Now, in the main script of the map, write
SetHeroCombatScript('Hero',
'/Maps/SingleMissions/MapName/CombatScript.xdb#xpointer(/Script)').
This action attaches the script that will be executed each time the hero Hero
enters combat. Also, before creating combat scripts, I recommend that you familiarize yourself with
the combat script guide.

I think this is a fairly complete answer!
С уважением, }{0TT@6bI4
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________

Statistics

Welcome our newest member: den