Skip to content

Posts from Scripts

4.8 (8 ratings)
Auto-translated
Hello. Could you please tell me how to enable scripts on multiplayer maps?
User Avatar
Auto-translated
Scripts for adventure maps work on multiplayer maps! To enable combat scripts and town scripts, you need to patch the game's executable with a special patch (I'm not 100% sure if this is necessary), and I can send it to you privately.
С уважением, }{0TT@6bI4
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________
User Avatar
Auto-translated

Hello everyone!

Using the Manuals, I decided to try creating a combat script.
I encountered a couple of problems with it:
1) The function GetDefenderCreatures() gives an error: "Wrong type of argument 1 when calling function GetUnits", regardless of where I call it in the script file. I tried a similar function for the attacker - GetAttackerCreatures(). It worked the first time, but the second time, the same problem occurred as with Defender.
2) The DefenderHeroMove(heroName) and AttackerHeroMove(heroName) hooks do not trigger during hero turns - there is not even a message in the console that the script entered the function body, and no error is displayed either. Once, the AttackerHeroMove(heroName) hook even got stuck in a loop. Only the Prepare() and Start() hooks work consistently.
Could you please advise on how to resolve these issues?

Script content (for now, just logs to understand what works and what doesn't):

print("inside combat file");

DEFENDER = GetDefenderHero();
print(DEFENDER);
ATTACKER = GetAttackerHero();
print(ATTACKER);
defenderCreatures = {0};
attackerCreatures = {0};


function Prepare()
  print("inside Prepare function");
  print("Prepare function has ended");
end;

function Start()
  print("inside Start function");
  ShowFlyingSign(GetMapDataPath().."CombatMessage.txt", DEFENDER, 200);
  defenderCreatures = GetDefenderCreatures();
  attackerCreatures = GetAttackerCreatures();
  print(1);
  for key, creature in defenderCreatures do
    print("key=", key, ", creature=", creature);
  end;
  print(attackerCreatures);
  print("Start function has ended");
end;

function DefenderHeroMove(heroName)
  print("inside DefenderHeroMove function");
  ShowFlyingSign(GetMapDataPath().."CombatMessage.txt", DEFENDER, 200);
  print("DefenderHeroMove function has ended");
end;

function AttackerHeroMove(heroName)
  print("inside AttackerHeroMove function");
  ShowFlyingSign(GetMapDataPath().."CombatMessage.txt", DEFENDER, 200);
  print("AttackerHeroMove function has ended");
end;

In reply to }{0TT@6bI4
Auto-translated
}{0TT@6bI4
The scripts for adventure maps work on multiplayer maps! To enable combat scripts and town scripts, you need to patch the game's executable with a special patch (not 100% sure if this is necessary), I can send it to you privately.
Thank you, I must have made a mistake somewhere earlier. I would be grateful for the patch; I have a patcher if needed.
In reply to IchGViji
User Avatar
Auto-translated
IchGViji

Good day to all!

I decided to try making a combat script using the Manuals.
A couple of issues came up with it
1) The GetDefenderCreatures() function throws an error: "Wrong type of argument 1 when calling function GetUnits" regardless of where I call it in the script file. I tried a similar function for the attacker - GetAttackerCreatures(). It worked the first time, but the second time I got the same problem as with the Defender.
2) The DefenderHeroMove(heroName) and AttackerHeroMove(heroName) hooks do not trigger when heroes move - there's not even a console message indicating the script entered the function body, and it doesn't output any errors at all. Once, the AttackerHeroMove(heroName) hook actually got stuck in a loop. Only the Prepare() and Start() hooks work reliably.
Could you please advise on how to fix these issues?

Script contents (for now just logs to see what works and what doesn't):

print("inside combat file");

DEFENDER = GetDefenderHero();
print(DEFENDER);
ATTACKER = GetAttackerHero();
print(ATTACKER);


function Prepare()
print("inside Prepare function");
print("Prepare function has ended");
end;

function Start()
print("inside Start function");
ShowFlyingSign(GetMapDataPath().."CombatMessage.txt", DEFENDER, 200);
defenderCreatures = GetDefenderCreatures();
attackerCreatures = GetAttackerCreatures();
print(1);
for key, creature in defenderCreatures do
print("key=", key, ", creature=", creature);
end;
print(attackerCreatures);
print("Start function has ended");
end;

function DefenderHeroMove(heroName)
print("inside DefenderHeroMove function");
ShowFlyingSign(GetMapDataPath().."CombatMessage.txt", DEFENDER, 200);
print("DefenderHeroMove function has ended");
end;

function AttackerHeroMove(heroName)
print("inside AttackerHeroMove function");
ShowFlyingSign(GetMapDataPath().."CombatMessage.txt", DEFENDER, 200);
print("AttackerHeroMove function has ended");
end;


you probably have an issue with these two lines:
DEFENDER = GetDefenderHero();
print(DEFENDER);
ATTACKER = GetAttackerHero();
print(ATTACKER);

here's the thing: the game defines two constants, ATTACKER and DEFENDER, which respectively specify the attacking and defending sides of the combat. By using these lines, you are essentially overwriting these constants, assigning them the names of the hero units instead of the standard sides. The subsequent errors are obvious: GetAttackerCreatures() and GetDefenderCreatures() are just wrappers around a lower-level function - inside them, GetCreatures(ATTACKER) and GetCreatures(DEFENDER) are called, respectively. Because of the overwritten constants, these functions cannot work correctly, which causes the error. The rest of the script simply fails to execute due to these errors. Accordingly, the solution is simple: use different names for your hero unit constants.
Нет войне.
In reply to Gerter
User Avatar
Auto-translated

Gerter

most likely, the problem lies in these two lines:
DEFENDER = GetDefenderHero();
print(DEFENDER);
ATTACKER = GetAttackerHero();
print(ATTACKER);

the point is that the game defines two constants, ATTACKER and DEFENDER, which determine the attacking and defending sides of the battle, respectively. With these lines, you are essentially overwriting these constants, assigning the names of the hero units to them instead of the standard sides. The subsequent errors are obvious - GetAttackerCreatures() and GetDefenderCreatures() are simply wrappers around a lower-level function - they internally call GetCreatures(ATTACKER) and GetCreatures(DEFENDER), respectively. Due to the redefined constants, these functions cannot work correctly, which causes the error. The rest of the script simply does not execute due to these errors. Therefore, the solution is simple - use different names for your hero name constants.

Gerter, thank you for your help!

Indeed, giving these constants different names made the script work like a charm! At least, until I break it with something else:)
It turns out that ATTACKER and DEFENDER are reserved words, just like CREATURE_VAMPIRE.

In reply to IchGViji
User Avatar
Auto-translated

IchGViji
It turns out that ATTACKER and DEFENDER are reserved words, just like CREATURE_VAMPIRE.
Excerpt from the combat-startup.lua file:
ATTACKER = 0
DEFENDER = 1

function IsAttacker(unit) return GetUnitSide(unit) == ATTACKER end
function IsDefender(unit) return GetUnitSide(unit) == DEFENDER end

function GetAttackerHero() local temp = GetHero(ATTACKER) return temp end
function GetDefenderHero() local temp = GetHero(DEFENDER) return temp end
function GetAttackerCreatures() local temp = GetCreatures(ATTACKER) return temp end
function GetDefenderCreatures() local temp = GetCreatures(DEFENDER) return temp end
function GetAttackerWarMachines() local temp = GetWarMachines(ATTACKER) return temp end
function GetDefenderWarMachines() local temp = GetWarMachines(DEFENDER) return temp end
function GetAttackerBuildings() local temp = GetBuildings(ATTACKER) return temp end
function GetDefenderBuildings() local temp = GetBuildings(DEFENDER) return temp end
function GetAttackerSpellSpawns() local temp = GetSpellSpawns(ATTACKER) return temp end
function GetDefenderSpellSpawns() local temp = GetSpellSpawns(DEFENDER) return temp end

and so on.

So yes, you shouldn't modify these two constants, otherwise the entire combat script will break.

Auto-translated
Hello.

Could someone please tell me how to add a shimmer and reflections to a custom effect with a large, flat water surface?
I have a model extracted from a town using the effect method, as described in Khottabych's guide "Extracting Models from a Town."
So, it's not a model, but rather an effect.
I've significantly increased the size of some of its parts, and it looks more or less okay, but by default, it doesn't shimmer or reflect, so what's supposed to be hidden beneath this "water" (and there's a lot that should be hidden) doesn't look very good.
(It looks especially bad at the transition between land and water tiles; the difference between them is very noticeable, but it shouldn't be).

I really need to add this shimmer to the water. I've been trying to create this water effect for about five years, and it's finally starting to work, but this is a major setback.

And here's my second question.
Why do some particles copy without any problems within the town, while others don't?
For example,
Particle:Effects\_(Particle)\Towns\Rampart\MysticPound\Fountain01
copies and saves without any problems.
But the splashes from the waterfall in the same model,
Particle:Effects\_(Effect)\Towns\Rampart\MysticPound:item_7772e68f-fed1-40e5-b9e9-0d216e051b90:Particle
although they save, disappear on the map.
I've tried it about four times.

What should I do about this? How can I attach these splashes to the waterfall, or create a separate effect with the desired splashes?
Help, if anyone can.
Especially Khottabych).

I apologize for posting in the wrong section; I just noticed that I'm in the scripts section again.
User Avatar
Auto-translated
There's a nuance: some particles don't need offset adjustments. For example, if the model's offset is -300, -280, -20, the particle retains its original values – 3, 1.4, 0. Try it out.

Regarding the reflections on the water – were they present in the city? In general, this is configured using additional materials for the model, and as I understand it, new materials cannot be added without modifying the model itself.
С уважением, }{0TT@6bI4
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________
In reply to }{0TT@6bI4
Auto-translated
Hello, Khottabych. I'm very glad to be reading you again. I ended up in the hospital for six months, and unfortunately, I don't have a laptop.

These particles didn't need to be moved much, but they definitely don't transfer.
Here, take a look, I copied it:

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Light    L_NORMAL    Is the particle illuminated by the sun and ambient light?
Particle    null    
Position        
Position.x    -0.25    
Position.y    0.3    
Position.z    1.6    
Rotation        
Rotation.x    0    
Rotation.y    0    
Rotation.z    0    
Rotation.w    1    
Scale    1    Scaling factor
Speed    0.8    Playback speed factor
Offset    0    (seconds) Pause before playback
EndCycle    3    (seconds) Length of one cycle (do not repeat = 0)
CycleCount    0    Number of repetitions during particle playback, 0 = infinite
Pivot        Texture attachment point to the particle
Pivot.x    0    
Pivot.y    0    
Textures        
Textures.[0]    Texture:Textures\Effects\Water\Water00    
Textures.[1]    Texture:Textures\Effects\Water\Water01    
Textures.[2]    Texture:Textures\Effects\Water\Water02    
Textures.[3]    Texture:Textures\Effects\Water\Water03    
Textures.[4]    Texture:Textures\Effects\Water\Water04    
Textures.[5]    null    
Textures.[6]    null    
Textures.[7]    null    
Textures.[8]    null    
Textures.[9]    null    
Textures.[10]    null    
Textures.[11]    null    
Textures.[12]    null    
Textures.[13]    null    
Textures.[14]    null    
Textures.[15]    null    
LeaveParticlesWhereStarted    false    Do we need particles to be attached to their source or left at their starting point?
Priority    0  
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Particle    null, they write. But when you save in the city, it's not null at all, everything is fine.
I redid it four times, but it doesn't transfer, damn it. And I can't add them to the model on the map, I add them, but when I reload, it's null again.
.
Maybe I'll try to make a separate foam model, but it's also unclear how, if this thing doesn't transfer.
But is there definitely no way to transfer it?

Regarding the highlights, there weren't any in the city, but I found a way to make them.
You just need to put it in the Data folder, in separate folders _(Model)\Effects\Towns, the file Rampart_MysticPound-lambert3.(Material), and manually write M_REFLECT_WATER instead of M_GENERIC, and the water immediately looks natural.
It's a pity that it doesn't work with the waterfall, because if you change M_CLOUDS_H5 there, the water stops flowing.
You can do a lot of things in these manually added files. I wonder if you can add a second effect there...

Added 2 hours 19 minutes ago
And here's another question. Can you extract a model from a Castle without effects?
For example, that huge elven tree is just begging to be used. But it has no effects.
User Avatar
Auto-translated
Built-in elements cannot be simply copied; select all particle properties by holding Shift, then press Ctrl+C. Next, in the effect, create a new empty particle with any name, add the same number of elements to its Textures, and press Ctrl+V.

All properties should be transferred to the new particle and should not be reset.
С уважением, }{0TT@6bI4
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________
In reply to }{0TT@6bI4
Auto-translated
Hmm, thank you very much, I'll give it a try. There are many interesting models without effects. Sorry, but I didn't understand. How do I get to the Effects section from there? There are only models and materials, and access to the Effects folder is only possible through an open window, but it seems you can't save anything there. Or am I misunderstanding, and is this supposed to be done from the map editor, not from the city window? To avoid cluttering the script topic further, I'll rewrite my questions in the Map Editor Questions section.
Auto-translated
Good evening. I'm trying to figure out combat scripts, but so far without success. I saw someone mention that there's a guide to combat scripts; could someone provide a link to it? I haven't been able to find it. Is it possible for someone to help me create a necessary script? If it's feasible, of course. The idea is this: when a battle starts, and if the hero has the "Ashih's Blessing" skill, three archangels will appear on the battlefield.
In reply to Shiroyasha2910
User Avatar
Auto-translated
Shiroyasha2910
Good evening. I'm trying to figure out combat scripts, but so far without success. I saw someone here mention that there's a guide to combat scripts; maybe someone could give me a link to it? Because I couldn't find it.
Is it possible that someone could also help me create the necessary script? If it's possible to implement, of course. The idea is this: when a battle starts, if the hero has the "Ashe's Blessing" skill, then 3 archangels will appear on the battlefield.


Shiroyasha2910, there's an excellent guide on combat scripts by the respected }{0TT@6bI4: combat scripts - guide
As for your idea, I haven't done anything like that myself yet, but as I see it, you should try using the HasHeroSkill() function, and save the result in a variable using the SetGameVar() function, and then retrieve it in the combat script file using GetGameVar(). There might be another way, but this seems like the most obvious one.


Сценарии:
"Холм мертвецов"
"Священное древо"

Statistics