Skip to content

Posts from Scripts

4.8 (8 ratings)
In reply to JonnyP
User Avatar
#911
Auto-translated
JonnyP
Why not? He tricked the hero, escaped, bought more troops, and attacked again. It's not necessary to make the quest about the 'hero surviving'.
Let the author decide.

Heroist, the xdb and lua files should not be in intermediate folders.
Here are their actual paths (not the ones you need to write in the function)
\Maps\map1.h5m\CombatScript.xdb
\Maps\map1.h5m\CombatScript.lua
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
#912
Auto-translated
No, I'm not that clueless about scripts. Here's the full path to the file: ('/Maps/SingleMissions/NewRandomMap21/CombatScript.xdb#xpointer(/Script)') It's strange, but it seems like the path is specified incorrectly: SetHeroCombatScript(hero1, '/CombatScript.xdb#xpointer(/Script)')

Whatever
In reply to Heroist
User Avatar
#913
Auto-translated
Heroist
No, I'm not that clueless about scripts.
Here's the full file path:
('/Maps/SingleMissions/NewRandomMap21/CombatScript.xdb#xpointer(/Script)')

It's strange, but it seems like the path is incorrect:
SetHeroCombatScript(hero1, '/CombatScript.xdb#xpointer(/Script)')
The problem is that the full path should not be /Maps/SingleMissions/NewRandomMap21/CombatScript.xdb#xpointer(/Script), but rather /CombatScript.xdb#xpointer(/Script), meaning the xdb file should not be in any folder at all.

Here's an example of what the map archive should look like.
Attachments 1
1 file attached • Total size: 422 B
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
#914
Auto-translated
yes, everything finally works as it should! Thank you very much for your help; I wouldn't have figured it out on my own.

Added 3 hours and 59 minutes ago
Here's a new question. With which function can I work with combat creatures? Here's an excerpt of what I forgot again and did wrong:

x11, x22, x33, x44, x55, x66, x77 = GetDefenderCreatures()

if GetHeroName(hero) == 'Isabell_A1' then SetUnitManaPoints(hero, 500) UnitCastAimedSpell(hero, 107, x11)

I know this is wrong, but how else can I find the conditional name of the units on the battlefield and then work with them?

Whatever
In reply to Heroist
User Avatar
#915
Auto-translated
GetDefenderCreatures returns an array, and only one variable should be placed before the "=" sign:
xnn=GetDefenderCreatures()
Accessing the array is done differently: after its name, you should place square brackets with the number of the element you need.
xnn[0]
xnn[length(xnn)-1]
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
#916
Auto-translated
Thanks again. By the way, in mapscript.lua, I was able to determine the hero's army using several variables, and it all worked.

Whatever
User Avatar
#917
Auto-translated
LUA is actually a VERY flexible language; it often allows constructions that any other compiler would strongly object to. But even it has its limits sometimes, so it's best to try to do everything correctly.
 

К А
Стикеры GBF в Telegram
User Avatar
#918
Auto-translated
Ah, so how can I artificially influence the stats of creatures directly in battle? (Well, most likely, this is a combat function).
For example, many heroes have a special ability that gives a bonus to creatures. But I haven't found a similar function in the combat scripts.

Whatever
In reply to Heroist
User Avatar
#919
Auto-translated
Heroist
Thank you again. By the way, in mapscript.lua, I was able to retrieve a hero's army using several variables, and it worked.
If you're referring to GetHeroCreaturesTypes, then yes, it will return multiple values. Other functions return arrays mainly because the number of values can be quite large. Therefore, arrays are more convenient if you know how to handle them. ;)
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
#920
Auto-translated
Yes, I was talking about that one. Arrays are more convenient, and no one would argue with that.

Whatever
User Avatar
#921
Auto-translated
Well, I looked at the developers' scripts (all of them, except for those in the bonus missions, but there didn't seem to be anything like that there), and I didn't find such a function. I would recommend experimenting: come up with your own idea of what such a function would look like if it existed, based on what is known. By the way, regarding what is known: here are some functions I found that are not in the official manual (maybe they are in unofficial ones, I don't know):
SetUnitManaPoints(to whom, how much) {it seems that it was mentioned here}
setATB(to whom, position) {this is really interesting in my opinion; you can implement specializations for creatures using it instead of increasing stats, if you simply give a certain creature initiative in this way}
UnitCastGlobalSpell(to whom, which) {this has definitely been mentioned}
GetRagePoints(creatureName)
GetRageLevel(creatureName)
playAnimation(who, animation name, repetition)
Based on this, I can assume that the function you need, if it exists, looks like this: SetUnitAttack|SetUnitStat|SetAttack|SetStat
Possibly...
 

К А
Стикеры GBF в Telegram
User Avatar
#922
Auto-translated
I would take a look, but the thing is that the Lua mechanics for hero specializations are so deeply embedded that I haven't been able to find them yet... and there's nothing particularly special about them in regular battle scripts. Although, I found a very interesting trick for myself – resurrecting Nicholas, I finally understood how it was done properly in the campaign.

Whatever
User Avatar
#923
Auto-translated
I'm not sure if it's implemented through combat scripts. Otherwise, it would be mentioned somewhere.
Try those four options I listed. Something might work.
 

К А
Стикеры GBF в Telegram
In reply to Ment
User Avatar
#924
Auto-translated
That doesn't make sense. The functions that exist are in the executable file. There are no others. At least, the ones that Ment was talking about aren't there.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
#925
Auto-translated
but how can we then implement the mechanics of hero specializations? if, for example, the get...race function (or something like that), implemented in 3.1, can be replaced using the capabilities of 3.0, then I can't even think of any options here.

Added 2 minutes later
it should be something like changemonsterstat.

Whatever

Statistics

Welcome our newest member: Emil