Skip to content

Combat scripts and battle management.

User Avatar
#2
Auto-translated
MasteR
Here are just a few questions that I remember and have wanted to ask for a long time:

1) Is it possible to temporarily increase the stats of creatures/heroes during combat using combat scripts? (e.g., give +1 to the speed of friendly creatures).
2) Is it possible to give a creature an ability during combat that it doesn't normally have? (unlikely, but who knows...)
3) How can I make it so that when a hero casts a spell using a script, they don't move back on the ATB scale? (of course, you can move the hero on the scale using the appropriate function, but I haven't found a function that returns the CURRENT position of the unit/hero)
4) Situation: a friendly creature starts its turn and attacks an enemy. At this time, the hero casts a conditional magic arrow using a script, and the target creature dies before the attacker reaches it. How can I avoid this collision?
5) Can creatures cast spells using a combat script that they normally cannot cast? Or those that don't have that spell in their spellbook? Can siege weapons cast spells? :D
6) Is it possible to give extra shots to a ballista or catapult in combat? Increase damage/healing power?
7) Is there a try-catch structure that allows you to ignore errors that occur during script execution?
1-3) Most likely, it is not possible.
4) You can use the following structure:
repeat sleep() until combatReadyPerson()
, which will wait until someone's turn comes.
5) Creatures can cast spells that they don't know, including those that cannot cast spells at all. However, there must be enough mana for this spell.
6) Most likely, no. But the ballista still has infinite shots: after reaching 0, it will continue to fire, and the shots will become negative.
7) You can emulate try using startThread and catch using errorHook. In the lualib library, I implemented a function called pcall, which does approximately this.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

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