Skip to content

Posts from Scripts

4.8 (8 ratings)
User Avatar
Auto-translated
Is there a way to forget spells? Is there a way to keep a spell if you forget a leveled magic school? (for example, keep the "Subjugation" spell even after forgetting the "Dark Magic" skill).
Моды для HeroesV:
NHF 0.90 : NHF - группа в VK

Карты для HeroesV:
Путешествие , Условие крови , Рука судьбы.Часть 1: В поход , Рука судьбы.Часть 2: Отчаянье , Рука судьбы.Часть 3: Восхождение , Стойкость
Абсолютная власть , Иду на Вы! , Корона Ургаша , На задворках
Мир надо уничтожить... Чтобы создать свой...
User Avatar
Auto-translated
Is it possible to create a hero using scripts? And if not, will the game lag if I place a lot of heroes on the map, but they are all disabled?
I just need a random hero to appear in a specific location.

Question 2: Is it possible to determine a monster's level using a script? I don't have the manuals handy right now, and I don't know/remember if there's a function for that...

Whatever
In reply to Heroist
User Avatar
Auto-translated
Heroist
Is it possible to create a hero using scripts? And if not, will the game lag if I place a lot of heroes on the map, but they are all disabled?
I just need a random hero to appear in a specific location.

Question 2: Is it possible to determine the level of a monster using a script? I don't have the manuals handy right now, and I don't know/remember if there's a function for that...
1. Reserve them and then place them. ;)
2. GetGuardsTier(object) returns an array where each element is equal to the level of the object's creature multiplied by 2 and added to 1, if it is upgraded. For example, for a zombie, it will be 12, for a titan - 15, for an obsidian gargoyle - 5.
The only problem is that this function doesn't work with heroes.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
Auto-translated
Yeah, I actually need it for heroes. Well, okay, I guess I'll have to manually enter it by ID... Thanks anyway.

Added 20 hours 17 minutes ago
nn = GetDate(ABSOLUTE_DAY) / 7
---
n = random (179) + 1
AddHeroCreatures(hh[gen] , n , nn * ?)

I have this question: I need a random creature to appear for the hero, but its quantity should depend on the current week * a special coefficient, unique for each monster in the game; I've already defined it. The problem is that I can't fit all of this into one line. Maybe it's possible to create an array of 179 values, for example, c[0] = 1, c[1] = 10, c[179] = 2, etc., and then, instead of ?, substitute c[n] into the above function? But, unfortunately, it doesn't work. What should I do? I hope for help.

Whatever
Auto-translated
Hello. Please help me. I created a Lord (name: Vlas) from a building. I added an animation so he stands still, and everything is fine. Now, the most difficult thing for me (if not to say, impossible) is the script. Please show me how. My idea is this: if the hero is a demon and has at least 50 Archdevils or Archdemons, then he should receive 25% of the experience from level 40 (the Lord is perfect in principle) and 50 Archdevils or Archdemons should be taken from him. It shouldn't be free, after all. And if the hero is not a demon, then 75% of the hero's experience should be taken from him, and all stats should be reduced by 5 units. So, don't bother the Lord. Something like that. If I missed any condition, please let me know.
Please send the answer in a private message. I might not find this page. It's easy to get lost here. I really hope for an answer.
In reply to Heroist
User Avatar
Auto-translated
Heroist
Yeah, I actually need it for heroes. Well, okay, I guess I'll have to manually enter it by ID... Thanks anyway.

Added 20 hours and 17 minutes ago
nn = GetDate(ABSOLUTE_DAY) / 7
---
n = random (179) + 1
AddHeroCreatures(hh[gen] , n , nn * ?)

I have this question: I need a random creature to appear for the hero, but its quantity should depend on the current week * a special coefficient, unique for each monster in the game; I've already defined it. The problem is that I can't fit all of this into one line. Maybe it's possible to create an array of 179 values, for example, c[0] = 1, c[1] = 10, c[179] = 2, etc., and then, instead of ?, substitute into the above function: c[n] ? But, unfortunately, it doesn't work. What should I do? I hope for help.
How do you create arrays? Are there any errors?
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
Auto-translated
The problem is that I have absolutely no idea how to create arrays in general. I tried using GetAllNames (or something like that), but it doesn't work at all. And I couldn't find anything in the manual about creating long arrays or artificially increasing their maximum size.

Whatever
In reply to Heroist
User Avatar
Auto-translated
Heroist
The problem is that I have no idea how to create arrays in general. I tried using GetAllNames (or something like that), but it doesn't work. And I couldn't find anything in the manual about creating long arrays or artificially increasing their maximum number. :(

table = {5,12,4,4,9,0}
table = {["кристаллы"]=4, x=1, y=55; 5, 6, 11, nil, "string", function()end, {"Brem", "Berein"}}
empty = {}
and so on. The first element is index 1. This is a rough example; a better explanation of how to create them can be found on the Lua 4.0 developers' website, as well as here, section 4.4.5.7.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
Auto-translated
Okay, I understand everything now. I had all 179 coefficients recorded as c[0], c[1]... c[179], and then I added c = {} on top, and everything started working as it should. Thank you very much.

Whatever
User Avatar
Auto-translated
Where can I find the map editor manual?
In reply to mapeditor5
User Avatar
Auto-translated
mapeditor5
Where can I find a manual for the map editor?
In the Editor Documentation folder.
If you're lucky, you might find Russian manuals there.
Мои карты:
Town
Готовится:Чума (40%), Сосиска(42%), Война Грааля
User Avatar
Auto-translated
1) How do I raise a number to a power? It seems like n ^ 2 doesn't work...
2) How do I select a hero? In the sense that, for example, a player has 8 heroes, and I need one of them to be selected as if by clicking the left mouse button. Simply deleting 7 of them afterward, and it's impossible to select the last one by default at the start of the game (or make it the first one).
3) Does GetDate(ABSOLUTE_DAY) return any current day in the game? (1, 2,...101, 192)?
4) What does GetDate(WEEK) return? It seems to me that it goes in a circle, increasing to a larger number, and then starts again from 1 (or am I wrong?)
5) What will happen if I try to force a hero to learn a spell that he cannot learn due to a low skill level? (Will he be able to cast it?)
6) Will the map crash due to point 5, or if I try to force a human to learn a spell from another faction/vice versa?

Whatever
In reply to Heroist
User Avatar
Auto-translated
I only know the answer to questions 5 and 6. If you force a hero to learn an ability that they cannot learn, they will learn it and be able to cast it. This can be done either through the ObjectTree (by selecting the hero) or through a script. Any hero can be given any spell. The map will not crash.
Создаётся карта "Забытый Авангард (готовность 80%)
In reply to Heroist
User Avatar
Auto-translated
Heroist
1) How do I raise a number to a power? n ^ 2 doesn't seem to work...
2) How do I select a hero? In the sense that, for example, a player has 8 heroes, and I need one of them to be "clicked" as if with the left mouse button. Simply deleting 7 of them afterwards, and it's impossible to select the last one by default at the start of the game (or make it the first one).
3) Does GetDate(ABSOLUTE_DAY) return any current day of the game? (1, 2,...101, 192)?
4) What does GetDate(WEEK) return? It seemed to me that it goes in a circle, increasing to a larger number, and then starts again from 1 (or am I wrong?)
5) What will happen if I try to force a hero to learn a spell that he cannot learn due to a low skill level? (Will he be able to cast it?)
6) Will there be a map error due to point 5, or if I try to force a human to learn an orcish spell/vice versa?
1) It doesn't work. Use multiplication and sqrt.
2) It's not possible. Make the player not click on a hero, but instead enter some region.
3) Yes.
4) Up to 4. You can find the week from the beginning of the game like this: ceil(GetDate(DAY) / 7)
5) He will learn it and use it.
6) Battle cries are only for orcs, spells are only for the rest.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
Auto-translated
2) That’s exactly what I need – for it to select the 8th hero by default. I don’t know what’s causing this bug; when the first hero is removed, the game automatically switches the screen to the second hero. However, this doesn’t work with the eighth hero, and the camera ends up stopping at an empty space where the seventh hero used to be. That’s not a big deal, as I can adjust the camera, but the real problem is that, until a hero is selected, the horse cursor (which indicates where to move) doesn’t appear, forcing the player to click on a hero again. And that just looks bad. ;)

Thank you very much, AkaR and RedHeavenHero.

Whatever

Statistics