Skip to content

Posts from Scripts

4.8 (8 ratings)
User Avatar
10 years ago
Auto-translated
By default, the console does not display the return value of functions; you need to wrap it in a print statement. Here's how it works for me:
@print(GetPlayerHeroes(PLAYER_1))
10 years ago
Auto-translated
Heh, I completely forgot about the print command. I've used it myself many times to find out the MP. Thanks! And can I ask another question? Where in the game files are the properties of skills and artifacts defined? I've searched through the entire data folder and couldn't find them.
In reply to RedHeavenHero
User Avatar
10 years ago
Auto-translated
RedHeavenHero

local threads = {}

local startExec = function(func)
local threads = threads
errorHook(function()
%threads[%func] = nil
end)
threads[func] = 1
func()
threads[func] = nil
end

function startThreadOnce(func)
if not %threads[func] then
startThread(%startExec, func)
end
end

function isFunctionRunning(func)
return %threads[func]
end
In this example, startThreadOnce starts the function only if it is not already running. isFunctionRunning checks if the function is currently running.
Thank you. If the function throws an error, will it transition to a completed status?
Моды для HeroesV:
NHF 0.90 : NHF - группа в VK

Карты для HeroesV:
Путешествие , Условие крови , Рука судьбы.Часть 1: В поход , Рука судьбы.Часть 2: Отчаянье , Рука судьбы.Часть 3: Восхождение , Стойкость
Абсолютная власть , Иду на Вы! , Корона Ургаша , На задворках
Мир надо уничтожить... Чтобы создать свой...
In reply to Dyrman
User Avatar
10 years ago
Auto-translated
Dyrman
Thank you. If the function returns an error, will it change its status to completed?
Yes:
errorHook(function()
%threads[%func] = nil
end)
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
10 years ago
Auto-translated
serovoy
Where in the game files are the properties of skills and artifacts defined?
GameMechanics/RefTables/ and then the files Skills.xdb/Artifacts.xdb. Only the basic properties are described there; all the most interesting things are hardcoded in the game.
10 years ago
Auto-translated
So, if I, for example, want to change the diplomacy settings (reduce the percentage, but also reduce the cost), would I have to modify the game's code itself? :eek:
User Avatar
10 years ago
Auto-translated
Not everything can be described using the concise language of XML markup. For example, diplomacy has numerous conditions that alter the chances of success, and it's impossible to represent them in a key-value table format. You won't be able to delve into the game's code, as everything has already been compiled into an executable file, and further modifications would be a rather complex task.
10 years ago
Auto-translated
Yes, I am aware of this and have read the manual, remembering this passage:
1) +5% if the hero and neutral creatures have the same alignment (good/evil – as in the calculation of Battle Spirit)
2) +5% if the hero and neutral creatures belong to the same castle
3) +5% if the hero's army contains the exact same creatures as the neutral army (regular and upgraded creatures are considered different)
4) +5% if the neutral creatures are regular creatures, and the hero's army contains their upgraded version (e.g., neutral creatures are peasants, and the hero's army contains militia)
5) +10% if the hero has the "Diplomacy" skill.
6) +20% if the hero has a specialization in creatures from the neutral army
I am specifically interested in the second-to-last point (point 5). Where can I change these infamous 10%, and is it possible?
And one more question (I hope I'm not being annoying): where can I edit the starting armies of heroes? (Not on a specific map, but generally in the game.)
User Avatar
10 years ago
Auto-translated
There's a strange quirk: if you replace a creature using scripts in the animation mode, it immediately becomes visible in the hero's army interface. However, in single-player mode, you have to exit and re-enter the interface for it to appear...
Is there a way to implement a similar update or refresh function for single-player mode?
Моды для HeroesV:
NHF 0.90 : NHF - группа в VK

Карты для HeroesV:
Путешествие , Условие крови , Рука судьбы.Часть 1: В поход , Рука судьбы.Часть 2: Отчаянье , Рука судьбы.Часть 3: Восхождение , Стойкость
Абсолютная власть , Иду на Вы! , Корона Ургаша , На задворках
Мир надо уничтожить... Чтобы создать свой...
User Avatar
10 years ago
Auto-translated
Hello everyone!
A question for those who know scripting.
Is it possible to temporarily (until the first battle, including it) increase/decrease morale/luck? So that afterwards they return to their original values.
Всё, что сейчас происходит во мне, тоже является частью Вселенной. (с) Иванов Александр.
Цикл кампаний "Дыхание Смерти" из трёшки в четвёртом исполнении
Учебная карта
Астралия
За Королеву!
Подземелья и Дьяволы
Отголоски войны
Освобождение
User Avatar
10 years ago
Auto-translated
GiveHeroBattleBonus('hero_name', BONUS_TYPE, MODIFICATION)
BONUS_TYPE. Luck - HERO_BATTLE_BONUS_LUCK, morale - HERO_BATTLE_BONUS_MORALE.
MODIFICATION - a number, which can be positive or negative.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
10 years ago
Auto-translated
RedHeavenHero
Thank you very much! :beer:

Do you know if there is a "libhomm3" for version 3.1?
Because the description for this script collection said that "version 3.1 will fix the output of these values."
So, I had to fix it myself with your help).
Всё, что сейчас происходит во мне, тоже является частью Вселенной. (с) Иванов Александр.
Цикл кампаний "Дыхание Смерти" из трёшки в четвёртом исполнении
Учебная карта
Астралия
За Королеву!
Подземелья и Дьяволы
Отголоски войны
Освобождение
User Avatar
10 years ago
Auto-translated
I completely forgot which script determines a hero's allegiance to a player. Basically, I need it so that when any hero belonging to the first player enters a region, a message box opens, but the trigger doesn't react to all other heroes. Could you please tell me how to do this?
In reply to Рыцарь Бездны
User Avatar
10 years ago
Auto-translated
You can check if a player owns an object like this: `
if GetObjectOwner(hero) == 1 then
.....
end
` The hero must be the first parameter of the function called by the trigger. For example: `
function message(hero, region)
`
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4

Statistics

Welcome our newest member: recijeb