Skip to content

Posts from Scripts

4.8 (8 ratings)
In reply to Warrior777
User Avatar
Auto-translated
Warrior777
It displays perfectly for me. This is a bug report.

Added after 2 hours 13 minutes


Then, tell me how to reduce the amount of resource in 1.6.
I only see a picture with an editor error. And there isn't one in message #1322.

local gold=GetPlayerResource(1,6)-10000
gold=gold>0 and gold or 0
SetPlayerResource(1,6,gold)

Added after 2 minutes
It's generally better to check for resource availability in advance.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
Auto-translated
And why doesn't it work in 1.6? I didn't read the entire thread, so maybe I don't understand the last question: (What is 1.6, is it a game version?)

If GetPlayerResource(1, 6) >= 0 then
SetPlayerResource(1, 6, GetPlayerResource(1, 6) - 10000)
else
--no gold--
end

Whatever
In reply to Heroist
User Avatar
Auto-translated
Heroist
Doesn't this work in 1.6? I didn't read through the entire thread, so maybe I don't understand the last question: (What is 1.6, is it a game version?)

If GetPlayerResource(1, 6) >= 0 then
SetPlayerResource(1, 6, GetPlayerResource(1, 6) - 10000)
else
--no gold--
end
1.6 refers to the heavily patched original Heroes of Might and Magic V.
Yes, and you need to use a different check.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
Auto-translated
Here's an example of code that should definitely not be written this way (it's very poor handwriting, resembling machine code):
gold=gold>0 and gold or 0

And here's how it should be written, making it both functional and readable:
TAX_GOLD = 10000
...
local playerGold = GetPlayerResource(PLAYER_1, GOLD)
if (playerGold > TAX_GOLD) then
local newPlayerGold = playerGold - TAX_GOLD
SetPlayerResource(PLAYER_1, GOLD, newPlayerGold)
else
SetPlayerResource(PLAYER_1, GOLD, 0)
end
Разработчик Heroes 5.5 WarGame Edition.
Сайт проекта - пока неактивен
Автор Асимметричных шахмат
User Avatar
Auto-translated
Wouldn't it be better to include ">=" in the definition of the gold amount? That way, we'd cover both scenarios at once. And the "else" statement would then mean that there's not enough gold at all... Or, in this case, does Lua interpret ">" as greater than or equal to?

Whatever
In reply to Heroist
User Avatar
Auto-translated
It's slightly different there: in my case, the amount of gold was checked after the sum was already deducted, while in your case, you need to compare it not to 0, but to 10000, and in that case, you need to use >=.

Added 5 minutes later
It's better to perform the check in function b and immediately display a message about the lack of resources.

Added 7 minutes later
function b()
    if GetPlayerResource(1, 6) >= 10000 then
        QuestionBox("золото есть.txt", "yes")
    else
        MessageBox("золота нет.txt")
    end
end

function yes()
    SetPlayerResource(1, 6, GetPlayerResource(1, 6) - 10000)
    obs = obs + 10
end
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
Auto-translated
obs - what is this variable? I couldn't find it...
And, by the way, it seems like we could do without the function yes(). Or, alternatively, we could improve the question box, just for fun, with 2 options, so the player can cancel the deal themselves...

Whatever
In reply to Heroist
User Avatar
Auto-translated
Heroist
obs - what is this variable? I couldn't find it...
And, by the way, it seems like you can do without the function yes(). Or, you could improve the question box as a fun feature, with 2 options, so the player can cancel the deal themselves...
Obs is some kind of scripted element in the Warrior777 mission, where they offer to increase it by 10 for ten thousand. My suggestion is this: when the function b is called, the player is offered a gold coin for 10,000 gold, if they have that much, and they can agree or refuse. And if they don't have the money, they are sent a message box with one answer option.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
Auto-translated
function b() if GetPlayerResource(1, 6) >= 10000 then --money ok-- QuestionBox("согласен_ли_ты.txt", "yes" , "no") else --money no-- MessageBox("золота нет.txt") end end function yes() --da soglasen-- SetPlayerResource(1, 6, GetPlayerResource(1, 6) - 10000) obs = obs + 10 end function no() --net ne hochu-- end

Whatever
In reply to Heroist
User Avatar
Auto-translated
Heroist
function b()
if GetPlayerResource(1, 6) >= 10000 then
--money ok--
QuestionBox("согласен_ли_ты.txt", "yes" , "no")
else
--money no--
MessageBox("золота нет.txt")
end
end

function yes()
--da soglasen--
SetPlayerResource(1, 6, GetPlayerResource(1, 6) - 10000)
obs = obs + 10
end

function no()
--net ne hochu--
end
The "no" function and its reference in the QuestionBox are unnecessary because it doesn't do anything and isn't even required.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
In reply to RedHeavenHero
User Avatar
Auto-translated
RedHeavenHero
The 'no' function and its mention in the QuestionBox are unnecessary because it doesn't do anything and isn't even required.

I didn't know, sorry. In any case, it can be left as a draft, just in case it needs to be used later to record some actions...

Whatever
User Avatar
Auto-translated
Is there a way to reduce a hero's experience or lower their level? For example, I need a function that is the opposite of the LevelUpHero function.
Кампании для Heroes V 3.1 (Трилогия):

Пробуждение зла
Нашествие из Преисподней
Смена эпох

Скачать все кампании одним архивом: Яндекс.Диск Google.Диск

You can download the set of 3 Campaigns (English version) here


Одиночные сценарии Heroes V 3.1:


Незваные гости
Красный кристалл
Синий кристалл
Закат тьмы

Мультиплеерные карты для Heroes V 3.1:

Легендарная война
Сердце вулкана
Передел мира
In reply to MasteR
Auto-translated
Juss456
Is there a way to reduce a hero's experience or lower their level? For example, I need a function that is the opposite of the LevelUpHero function.


As far as I remember, there is a function called ChangeHeroStat - with its help, you can not only manipulate experience but also other hero characteristics (including removing or adding movement points).
In reply to antonag07
User Avatar
Auto-translated
antonag07
As far as I remember, there is a function called ChangeHeroStat - it can be used not only to manipulate experience but also other hero stats (including removing or adding movement points).
You can't actually manipulate experience with it. I initially tried to do that.

Added 4 minutes later
void ChangeHeroStat(sHeroName, nStatID, nDelta)

This function retrieves or modifies a specific hero stat. The corresponding constants for nStatID are defined in /scripts/advmap-startup.lua and are as follows:
STAT_EXPERIENCE = 0
STAT_ATTACK = 1
STAT_DEFENCE = 2
STAT_SPELL_POWER = 3
STAT_KNOWLEDGE = 4
STAT_LUCK = 5
STAT_MORALE = 6
STAT_MOVE_POINTS = 7
STAT_MANA_POINTS = 8
Please note that the ChangeHeroStat function does not set a stat, but modifies it. That is, the third parameter is not the new value of the stat, but the difference from the old one (which can also be negative). Unlike others, STAT_EXPERIENCE cannot be decreased. STAT_MOVE_POINTS and STAT_MANA_POINTS represent the current values of the corresponding parameters, and you cannot set them higher than the maximum.
Кампании для Heroes V 3.1 (Трилогия):

Пробуждение зла
Нашествие из Преисподней
Смена эпох

Скачать все кампании одним архивом: Яндекс.Диск Google.Диск

You can download the set of 3 Campaigns (English version) here


Одиночные сценарии Heroes V 3.1:


Незваные гости
Красный кристалл
Синий кристалл
Закат тьмы

Мультиплеерные карты для Heroes V 3.1:

Легендарная война
Сердце вулкана
Передел мира
User Avatar
Auto-translated
TakeAwayHeroExp(heroName, exp)
The LockMinHeroSkillsAndAttributes(heroName) function can be useful with it, if you need to lock certain skills so they won't be reduced.
 

К А
Стикеры GBF в Telegram

Statistics

Welcome our newest member: Emil