Skip to content
User Avatar
#3985
Auto-translated
green belly
Madara X, Azgalor, thank you for your answers. I figured out how to check multiple perks in one script. But I still can't figure out how to grant bonuses using givebattlebonus.
I need an example of the code. Maybe some forum users have maps or examples where this code is used.
I'm looking for the following examples:
1) If a hero has skill A, grant THAT HERO a bonus for one battle (e.g., +1 to creature speed, +defense, +stats, or +1% to creature HP).
2) If a hero has skill B, grant the OPPONENT'S HERO a bonus for one battle (e.g., -1 to creature speed, -1 defense, luck, etc.).
3) If a hero has skill C, this hero casts spell D at the beginning of all subsequent battles.
Thank you for any examples and help!
Here are the stats you can change for heroes in GiveHeroBattleBonus(heroName, bonusType/bonusID, +-(if you need to add, don't put a + (otherwise the script will give an error)) amount). These are the IDs and names of the bonuses that can be increased or decreased (except for Hitpoints, which can only be increased):
HERO_BATTLE_BONUS_LUCK = 0
HERO_BATTLE_BONUS_MORALE = 1
HERO_BATTLE_BONUS_ATTACK = 2
HERO_BATTLE_BONUS_DEFENCE = 3
HERO_BATTLE_BONUS_HITPOINTS = 4
HERO_BATTLE_BONUS_INITIATIVE = 5
HERO_BATTLE_BONUS_SPEED = 6

Accordingly:
function buffsForbattle()
if HasHeroSkill("Duncan", SKILL_LUCK ) then
GiveHeroBattleBonus("Duncan", HERO_BATTLE_BONUS_SPEED, 1)
elseif...... and so on.
end
end

Regarding spells: you need to use SetGameVar and GetGameVar to pass the information so that the game knows what you want to pass from the adventure script to the battle script.

Всякое/карты:

Добавление недостающей музыки гномам