Skip to content

Posts from Scripts

4.8 (8 ratings)
User Avatar
7 years ago
Auto-translated
Good day!

The PlayObjectAnimation function doesn't work for heroes, or am I doing something wrong?
In the properties, I set the correct AnimSet and HeroCharacterAdventure. Under the same conditions, a regular creature plays the animation, but there is no reaction from the hero.
User Avatar
7 years ago
Auto-translated
doesn't work
7 years ago
Auto-translated
Hello everyone:)

I have a question: is it possible to use combat scripts (for heroes) in multiplayer maps, or do they only work for single-player games? And if it is possible, are there any maps on the site where I can see how they are implemented?
7 years ago
Auto-translated
Okay, thank you.
User Avatar
7 years ago
Auto-translated
Hello everyone :)
The questions are: Is it possible to call a function without using standard triggers?
And is there a more or less detailed description of how while do and for work?
In reply to Jewily
User Avatar
7 years ago
Auto-translated
Is it possible to call a function without using standard triggers?
To call it at the start of the map, simply write the function call anywhere in the script. You can also call it from another function/thread.
And is there a more or less detailed description of how while do and for work?

Google Novik's guide – it contains general information about how scripts work, plus a good description of most functions in Russian. In general, these are standard Lua 4.0 loops.
In reply to Gerter
User Avatar
7 years ago
Auto-translated
Thank you. I'll try to figure out the streams, although, to be honest, Novik's language is quite complex, especially for someone who isn't familiar with programming languages.
User Avatar
7 years ago
Auto-translated
Hello forum. Maybe someone can tell me how to add one to a variable? I'm running a loop with a check to see if my variable has changed by "+1" (in my case, it's GetHeroLevel). However, the game doesn't react at all, as if there's a syntax error.
In reply to Jewily
User Avatar
7 years ago
Auto-translated
Jewill
Hello forum again. Maybe someone can tell me how to add one to a variable? I mean, I'm running a loop with a check to see if my variable has changed by "+1" (in my case, this is GetHeroLevel). However, the game doesn't react at all, as if there's a syntax error.

In general, to add one:
a = a + 1

In the case of a loop checking the level, I would do it like this:

a = 1;
while 1 do
sleep(2);
if GetHeroLevel(hero) - a == 1 then
...
end
sleep(2);
a = GetHeroLevel(hero);
end

And for this purpose, there is:
Trigger(HERO_LEVELUP_TRIGGER, hero, function)
In reply to 32MeTpa
User Avatar
7 years ago
Auto-translated
32MeTpa
In general, to add one:
a = a + 1

In the case of a loop to check the level, I would do it like this:

a = 1;
while 1 do
sleep(2);
if GetHeroLevel(hero) - a == 1 then
...
end
sleep(2);
a = GetHeroLevel(hero);
end

And for this purpose, there is:
Trigger(HERO_LEVELUP_TRIGGER, hero, function)

Thank you :) The function works perfectly in a single case. But what if I need the action to be performed with Each
level up? I apologize for the silly questions, but manipulating comparison signs didn't help.
User Avatar
7 years ago
Auto-translated
Trigger(HERO_LEVELUP_TRIGGER, hero, function) - the function `function` will be called each time the hero `hero` levels up.
In reply to Gerter
User Avatar
7 years ago
Auto-translated
Well, thank you both for your answers; indeed, everything works properly through a trigger. I tried to delve deeper into the maps of the esteemed 32MeTpa; everything is described there, albeit concisely, but my knowledge is insufficient. :smile15: UPD: It stopped working altogether. It's simple and straightforward, but creatures are given only upon the first level-up, and nothing happens on subsequent level-ups. What's the mistake? function a() AddHeroCreatures("Sarge",CREATURE_ARCHER,20); Trigger(HERO_LEVELUP_TRIGGER,"Sarge",nil) end; Trigger(HERO_LEVELUP_TRIGGER,"Sarge","a")
In reply to Jewily
User Avatar
7 years ago
Auto-translated
Jewill

UPD: It stopped working completely. It's simple, but the creatures are given only upon the first level up, and nothing happens on subsequent level ups. What's the mistake?
function a()
AddHeroCreatures("Sarge",CREATURE_ARCHER,20);
Trigger(HERO_LEVELUP_TRIGGER,"Sarge",nil)
end;
Trigger(HERO_LEVELUP_TRIGGER,"Sarge","a")
Trigger(HERO_LEVELUP_TRIGGER,"Sarge",nil)
This line resets the trigger, which is why it only runs once and then disables itself. Just remove it, and it will work every time the hero levels up.
In reply to 32MeTpa
User Avatar
7 years ago
Auto-translated
32MeTpa
Trigger(HERO_LEVELUP_TRIGGER,"Sarge",nil)
This line resets the trigger, which is why it only executes once and then disables itself. Simply remove it, and it will work every time the hero levels up.
Thank you. By the way, do you know if it's possible to give a hero of one class perks from another class using scripts? (GiveHeroSkill can grant a skill of the first level, but it refuses to grant abilities). Or do I need to change something in GameMechanics within the hero's structure? Thank you again for your quick responses and for taking the time.

Statistics

Welcome our newest member: recijeb