Skip to content

Posts from Scripts

4.8 (8 ratings)
In reply to Dyrman
User Avatar
11 years ago
Auto-translated
Dyrman
It's a pity that the custom script editor complains about the "%" symbol.
This is because it is designed for Lua 5, not Lua 4 (as in Heroes of Might and Magic V), and their syntax differs slightly. In the fifth version, "%" is the remainder operator.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
11 years ago
Auto-translated
By the way, could the value of
while GetLastSavedCombatIndex() == combat_index do
sleep()
end
change during simultaneous turns? For example, if two players are conducting battles at the same time, the hero might still be in combat, but the index has already changed. As a result, he might lose, but the function will return that he is still alive. Therefore, it would be desirable to call the function only at the end of the battle.
Моды для HeroesV:
NHF 0.90 : NHF - группа в VK

Карты для HeroesV:
Путешествие , Условие крови , Рука судьбы.Часть 1: В поход , Рука судьбы.Часть 2: Отчаянье , Рука судьбы.Часть 3: Восхождение , Стойкость
Абсолютная власть , Иду на Вы! , Корона Ургаша , На задворках
Мир надо уничтожить... Чтобы создать свой...
In reply to Dyrman
User Avatar
11 years ago
Auto-translated
Perhaps it can be done like this. I just don't remember exactly what the second argument in GetSavedCombatArmyHero means.
local wrapStartCombat = StartCombat
function StartCombat(hero, enemy, stacks, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18)
	%wrapStartCombat(hero, enemy, stacks, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18)
	local combat_index = GetLastSavedCombatIndex()
	while 1 do
		if GetLastSavedCombatIndex() ~= combat_index then
			if GetSavedCombatArmyHero(combat_index, 0) ~= hero and GetSavedCombatArmyHero(combat_index, 1) ~= hero then
				combat_index = GetLastSavedCombatIndex()
			else
				break
			end
		end
		sleep()
	end
	local result = IsHeroAlive(hero)
	return result
end
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
11 years ago
Auto-translated
Yeah, it looks like it's true.
StartCombat(hero, nil,4,CREATURE_FIRE_ELEMENTAL,5, CREATURE_WATER_ELEMENTAL,5, CREATURE_EARTH_ELEMENTAL,5, CREATURE_AIR_ELEMENTAL,5,nil,'NHF_Touch_hero_treasury_reward_F("'..hero..'","'..MASS.. '","'..NHF_mass_CYCLOPS_STOCKPILE.variant1.treasury.spell[1]..'")',nil,not nil);

Is there a way to pass the MASS array? The console says it's not possible.
Моды для HeroesV:
NHF 0.90 : NHF - группа в VK

Карты для HeroesV:
Путешествие , Условие крови , Рука судьбы.Часть 1: В поход , Рука судьбы.Часть 2: Отчаянье , Рука судьбы.Часть 3: Восхождение , Стойкость
Абсолютная власть , Иду на Вы! , Корона Ургаша , На задворках
Мир надо уничтожить... Чтобы создать свой...
User Avatar
11 years ago
Auto-translated
Manually convert the array to its string representation.

Added 32 seconds ago
Does the method mentioned above work?

Added 38 seconds ago
Simply converting arrays to strings is a complex and slow operation.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
In reply to RedHeavenHero
User Avatar
11 years ago
Auto-translated
RedHeavenHero
Manually convert the array into its string representation.

Added 32 seconds ago
Does the method mentioned above work?

Added 38 seconds ago
Converting arrays to strings is a complex and slow operation.
It's not possible to test the top option simultaneously.
Logically, it should work.
Моды для HeroesV:
NHF 0.90 : NHF - группа в VK

Карты для HeroesV:
Путешествие , Условие крови , Рука судьбы.Часть 1: В поход , Рука судьбы.Часть 2: Отчаянье , Рука судьбы.Часть 3: Восхождение , Стойкость
Абсолютная власть , Иду на Вы! , Корона Ургаша , На задворках
Мир надо уничтожить... Чтобы создать свой...
User Avatar
11 years ago
Auto-translated
Dyrman
Remind me, please, what advantage does using % before a variable give?
You can also put it before the names of global variables and passed parameters so that the function uses the variable as a constant (i.e., subsequently changing the value of the variable will not affect the function's operation).
And is it possible to pass the MASS array somehow? The console complains that it is not allowed.
You can pass it through a global variable.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
In reply to RedHeavenHero
User Avatar
11 years ago
Auto-translated
RedHeavenHero
You can also place it before the names of global variables and passed parameters so that the function uses the variable as a constant (i.e., subsequent changes to the variable's value will not affect the function's operation).

Alternatively, you can pass it through a global variable.
That's what I did.
Each player has their own global variable.
This is also needed to remember visits, rewards, etc.
It will be useful for new features.
I want to make the tool more comprehensive right away so that I don't run into problems and have to redo old functions.
Моды для HeroesV:
NHF 0.90 : NHF - группа в VK

Карты для HeroesV:
Путешествие , Условие крови , Рука судьбы.Часть 1: В поход , Рука судьбы.Часть 2: Отчаянье , Рука судьбы.Часть 3: Восхождение , Стойкость
Абсолютная власть , Иду на Вы! , Корона Ургаша , На задворках
Мир надо уничтожить... Чтобы создать свой...
User Avatar
11 years ago
Auto-translated
Hello everyone. I decided to add a "prestige" parameter to my map, which limits the number of creatures in a hero's army. To implement this, I had to disable the standard creature recruitment in all dwellings and write a script that displays the question: "Do you want to recruit [x] creatures for [y] gold? OK Cancel"
However, the drawback is that the hero can only recruit all the creatures available in the building, or those for which they have enough prestige and gold.
Also, when upgrading creatures or recruiting them from a garrison, the change in available prestige is not taken into account, so the hero can end up with an army larger than their prestige allows.
Is it possible to make it so that the standard creature recruitment window limits the number of creatures not only by gold but also by prestige?
 Создается карта про эльфов: Воссоединение - готовность 71%
User Avatar
11 years ago
Auto-translated
Options: 1) A talkbox that simulates the recruitment window, specifically with + and - buttons. 2) Hide a garrison on the map so that no one can see it. When touching the recruitment building (with its standard property disabled), fill the garrison only with creatures that can be purchased with "gold" or "leadership" (here, authority). It's better to do it one by one (by type), as you'll have to make additional checks. Then, force the hero to visit this garrison using scripts. 3) Reset the dwelling's values at the beginning of the week and after touching it. When touched, determine what type of dwelling it is, and change its growth rate via scripts to the maximum possible based on authority and gold. This only works for dwellings where you can recruit an army of one type.

Added 7 minutes later
Spectral

Options:
Also, when upgrading creatures or taking them from a garrison, the change in available authority is not taken into account, so the hero can gather an army larger than what his authority allows.
1) You can run a constant loop and check the quantity. 2) When touching the garrison, reduce the army in it to the extent that the authority allows. And make the upgrade/no upgrade option with a single authority value.
Моды для HeroesV:
NHF 0.90 : NHF - группа в VK

Карты для HeroesV:
Путешествие , Условие крови , Рука судьбы.Часть 1: В поход , Рука судьбы.Часть 2: Отчаянье , Рука судьбы.Часть 3: Восхождение , Стойкость
Абсолютная власть , Иду на Вы! , Корона Ургаша , На задворках
Мир надо уничтожить... Чтобы создать свой...
User Avatar
11 years ago
Auto-translated
What is florID? I know it's the level number where the artifact should be placed, but I don't understand what it means.
[url=Таверна (фулдилка) - заходите.


User Avatar
11 years ago
Auto-translated
Dungeon/surface. In the first case, the index is 1, and in the second, 0.
 

К А
Стикеры GBF в Telegram
User Avatar
11 years ago
Auto-translated
how to specify the script name of a hero in a quest - the hero must survive.
[url=Таверна (фулдилка) - заходите.


User Avatar
11 years ago
Auto-translated
Please provide the correct script for the dialogue (cutscene). (I've seen one, but the problem is that no matter how hard I try to create the cutscene, I can't seem to make it work).
[url=Таверна (фулдилка) - заходите.


Statistics

Welcome our newest member: recijeb