Skip to content

Posts from Scripts

4.8 (8 ratings)
In reply to DevoRevo
User Avatar
Auto-translated
DevoRevo

Hello. I've already broken my head trying to figure out how SetHeroLootable and IsHeroLootable work.

I tried IsHeroLootable(“heroname”, nil)
I tried SetHeroLootable(“heroname”,nil)
SetHeroLootable(“heroname”, disable)
No matter what I do, the hero's artifacts are still being taken.

Can you tell me what I'm doing wrong?

Does the console report any errors?

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

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

In reply to Азгалор
User Avatar
Auto-translated
Azgalor
Is the console not complaining about anything?

Not at all.
In reply to DevoRevo
Auto-translated
I have a question.
Could someone tell me if there's a way to use a script to move a static object on the map from one point to another, so that its z-coordinate is higher or lower than zero in the new location?
I really need to do this, and I've been trying for a while.
I know how to teleport to zero, but I haven't found a way to do it higher or lower.
In reply to DevoRevo
User Avatar
Auto-translated
DevoRevo

Hello. I've already broken my head trying to figure out how SetHeroLootable and IsHeroLootable work.

I tried IsHeroLootable(“heroname”, nil)
I tried SetHeroLootable(“heroname”,nil)
SetHeroLootable(“heroname”, disable)
No matter what I do, the hero's artifacts are still being taken.

Can you tell me what I'm doing wrong?

In general, I solved this problem myself.
I wrote the following in the general code:
SetHeroLootable("Berein", nil);

Auto-translated
Could someone who knows about scripts please help me?
I have a prophet's hut on my map. It gives a repeatable quest. I've configured the hut correctly. I've specified what's needed to complete the quest, the reward, and that the quest is repeatable.
The problem is this: I've chosen to give a creature as a reward. But I also need to take away certain resources from the hero who completes the quest. And it should be a bit of a trick). For example, if a player brings 20 wood, they get a Dryad, but as a trick, all the resources the hero has at that moment are taken away, and their luck and morale are reduced by 20.
I think I'll have to use a script because I've already tried everything else. It's important that the script runs at the right moment and for the hero who completes the quest in the hut. And, of course, the script should be repeatable since the quest is repeatable. Please send me a private message if you can help. Thank you in advance.
User Avatar
Auto-translated

Hello!

Is there a way to add a workaround to the game/map to make requests to a web server? I was thinking about trying to do this through Lua scripts in the map... I honestly don't know where to start with this. It seems to me that it's hardly possible without modifying the game's executable file. Still, I'm interested in the opinions of experienced map/mod creators.

User Avatar
Auto-translated
In the game, there is a "connect to ubi.com" button in the multiplayer section. Through this button, you can link any URL (most likely an IP address). Theoretically, it can be replicated on the adventure map screen, and so on. Additionally, if you are a skilled programmer with plenty of free time, you can write a program that processes game data in the background and, based on certain events (most easily triggered by key combinations), overlays a window with a link or directly opens the link in a browser.
С уважением, }{0TT@6bI4
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________
Auto-translated
Hello, is it possible to set a specific week using scripts? For example, if a condition is met, then it will be the "week of the dove".
User Avatar
Auto-translated
no.
Нет войне.
User Avatar
Auto-translated
Hello, is it possible to write a script that can pass the name of an object to a text? Specifically, I want to create a quest to find a random artifact, i.e., a random artifact ID will be selected, but I don't know if it's possible to pass the name of the selected artifact ID as an argument to the text (not in the quest texts, but in the Msg box), or will I have to create a table for all artifact IDs?

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

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

In reply to Азгалор
User Avatar
Auto-translated
Azgalor
Hello, is it possible to write a script that can pass the name of an object to the text? Specifically, I want to create a quest to find a random artifact, i.e., an artifact ID will be selected using a random function, but I don't know if it's possible to pass the name of the selected artifact ID as an argument to the text (not in the quest texts, but in a Msg box), or will I have to create a table for all artifact IDs?
You can create an array where the position is the artifact ID, and it stores the name. For example:

artefactArray = {}

artefactArray[4] = "Unicorn Horn Bow" -- where 4 is the artifact ID

rndArt = random(your number)

MessageBox({"Link_to_text"; artefact = artefactArray[rndArt]}) -- where artefact is in your text file

Added after 12 hours 23 minutes
I couldn't find any function that would return the text name of an object. If a large list of possible artifacts is needed, then you will have to write a table
Мои карты: Белый Храм, Поменяться местами, Судьба королевства, Стихийные острова.
User Avatar
Auto-translated
Azgalor, here's the table. Taken from my map "Hero's Path", so it's not completely universal, but the artifact's name and description are available by id using the functions GetArtefactName(id) / GetArtefactDesc(id). If needed, you can find the const.lua file in the map — it has similar tables for spells, creatures, skills, and other things.
-- типы артефактов. распределял по логике, а не по слотам, в которые они ставятся
ART_TYPE_WEAPON = 1; -- оружие
ART_TYPE_SHIELD = 2; -- щиты
ART_TYPE_BOOTS = 3; -- сапоги и поножи
ART_TYPE_HELMET = 4; -- шлемы и шапки
ART_TYPE_ARMOR = 5; -- кирасы
ART_TYPE_CLOAK = 6; -- плащи
ART_TYPE_RING = 7; -- кольца
ART_TYPE_NECKLACE = 8; -- ожерелья
ART_TYPE_MISC = 9; -- прочее

-- список артефактов
ARTEFACT_TABLE_NAME = 1; -- файл с названием артефакта
ARTEFACT_TABLE_TYPE = 2; -- тип артефакта
ARTEFACT_TABLE_COST = 3; -- номинальная цена артефакта (не равна внутрегеройской)
artefact_table =
{
[ARTIFACT_SWORD_OF_RUINS] = {'SwordOfRuin', ART_TYPE_WEAPON, 2000}, -- Меч Мощи
[ARTIFACT_GREAT_AXE_OF_GIANT_SLAYING] = {'Great_Axe_of_giant_slaying', ART_TYPE_WEAPON, 8000}, -- Секира горного короля
[ARTIFACT_WAND_OF_X] = {'Wand_of_x', ART_TYPE_WEAPON, 4000}, -- Палочка с заклинанием
[ARTIFACT_UNICORN_HORN_BOW] = {'UnicornHornBow', ART_TYPE_WEAPON, 10000}, -- Лук из рога Единорога
[ARTIFACT_TITANS_TRIDENT] = {'Titan`s_trident', ART_TYPE_WEAPON, 4000}, -- Трезубец Титанов
[ARTIFACT_STAFF_OF_VEXINGS] = {'Staff_of_vexing', ART_TYPE_WEAPON, 16000}, -- Посох Преисподней
[ARTIFACT_SHACKLES_OF_WAR] = {'ShacklesOfWar', ART_TYPE_MISC, 20000}, -- Кандалы неизбежности
[ARTIFACT_FOUR_LEAF_CLOVER] = {'Four_leaf_clover', ART_TYPE_MISC, 2000}, -- Четырехлистный клевер
[ARTIFACT_ICEBERG_SHIELD] = {'Iceberg_shield', ART_TYPE_SHIELD, 5000}, -- Ледяной щит
[ARTIFACT_GOLDEN_SEXTANT] = {'Golden_sextant', ART_TYPE_MISC, 3000}, -- Секстант морских эльфов
[ARTIFACT_CROWN_OF_COURAGE] = {'Crown_of_courage', ART_TYPE_HELMET, 15000}, -- Корона льва
[ARTIFACT_CROWN_OF_MANY_EYES] = {'Crown_of_many_eyes', ART_TYPE_HELMET, 1000}, -- Корона всевидящего
[ARTIFACT_PLATE_MAIL_OF_STABILITY] = {'PlateMailOfStability', ART_TYPE_ARMOR, 20000}, -- Доспехи Забытого Героя
[ARTIFACT_BREASTPLATE_OF_PETRIFIED_WOOD] = {'Breastplate_of_petrified_wood', ART_TYPE_ARMOR, 2000}, -- Нагрудник огромной мощи
[ARTIFACT_PEDANT_OF_MASTERY] = {'Pedant_of_mastery', ART_TYPE_NECKLACE, 15000}, -- Кулон Мастерства
[ARTIFACT_NECKLACE_OF_BRAVERY] = {'Necklace_of_bravery', ART_TYPE_NECKLACE, 2000}, -- Ошейник льва
[ARTIFACT_WEREWOLF_CLAW_NECKLACE] = {'Werewolf_claw_necklace', ART_TYPE_NECKLACE, 6000}, -- Ожерелье Кровавого Когтя
[ARTIFACT_EVERCOLD_ICICLE] = {'Evercold_icicle', ART_TYPE_NECKLACE, 4000}, -- Кулон ледяных объятий
[ARTIFACT_NECKLACE_OF_POWER] = {'Necklace_of_power', ART_TYPE_NECKLACE, 8000}, -- Ожерелье победы
[ARTIFACT_RING_OF_LIGHTING_PROTECTION] = {'Ring_of_lightning_protection', ART_TYPE_RING, 3000}, -- Кольцо защиты от молний
[ARTIFACT_RING_OF_LIFE] = {'RingOfLife', ART_TYPE_RING, 7000}, -- Кольцо жизненной силы
[ARTIFACT_RING_OF_HASTE] = {'Ring_of_haste', ART_TYPE_RING, 18000}, -- Кольцо скорости
[ARTIFACT_NIGHTMARISH_RING] = {'Nightmarish_ring', ART_TYPE_RING, 7000}, -- Кольцо сломленного духа
[ARTIFACT_BOOTS_OF_SPEED] = {'BootsOfSpeed', ART_TYPE_BOOTS, 8000}, -- Сапоги путешественника
[ARTIFACT_GOLDEN_HORSESHOE] = {'Golden_horseshoe', ART_TYPE_MISC, 6000}, -- Золотая подкова
[ARTIFACT_WAYFARER_BOOTS] = {'Wayfarer_boots', ART_TYPE_BOOTS, 5000}, -- Сапоги открытого пути
[ARTIFACT_BOOTS_OF_INTERFERENCE] = {'Boots_of_interference', ART_TYPE_BOOTS, 1000}, -- Сапоги магической защиты
[ARTIFACT_ENDLESS_SACK_OF_GOLD] = {'EndlessSackOfGold', ART_TYPE_MISC, 40000}, -- Сума бесконечного золота
[ARTIFACT_ENDLESS_BAG_OF_GOLD] = {'Endless_bag_of_gold', ART_TYPE_MISC, 10000}, -- Мешочек бесконечного золота
[ARTIFACT_ANGEL_WINGS] = {'Angel_wings', ART_TYPE_CLOAK, 40000}, -- Крылья ангела
[ARTIFACT_LION_HIDE_CAPE] = {'Lion_hide_cape', ART_TYPE_CLOAK, 6000}, -- Накидка с гривой льва
[ARTIFACT_PHOENIX_FEATHER_CAPE] = {'Phoenix_feather_cape', ART_TYPE_CLOAK, 4000}, -- Накидка из перьев феникса
[ARTIFACT_CLOAK_OF_MOURNING] = {'Cloak_of_mourning', ART_TYPE_CLOAK, 12000}, -- Плащ Смертоносной Тени
[ARTIFACT_HELM_OF_ENLIGHTMENT] = {'Helm_of_enlightenment', ART_TYPE_HELMET, 4000}, -- Тюрбан просвещенности
[ARTIFACT_CHAIN_MAIL_OF_ENLIGHTMENT] = {'Chain_mail_of_enlightenment', ART_TYPE_ARMOR, 6000}, -- Кольчуга просвещенности
[ARTIFACT_DRAGON_SCALE_ARMOR] = {'Dragon_scale_armor', ART_TYPE_ARMOR, 10000}, -- Доспехи из чешуи дракона
[ARTIFACT_DRAGON_SCALE_SHIELD] = {'DragonscaleShield', ART_TYPE_SHIELD, 10000}, -- Щит из чешуи дракона
[ARTIFACT_DRAGON_BONE_GRAVES] = {'Dragon_bone_greaves', ART_TYPE_BOOTS, 10000}, -- Поножи из кости дракона
[ARTIFACT_DRAGON_WING_MANTLE] = {'Dragon_wing_mantle', ART_TYPE_CLOAK, 10000}, -- Мантия из крыльев дракона
[ARTIFACT_DRAGON_TEETH_NECKLACE] = {'Dragon_teeth_necklace', ART_TYPE_NECKLACE, 10000}, -- Ожерелье из зубов дракона
[ARTIFACT_DRAGON_TALON_CROWN] = {'Dragon_talon_crown', ART_TYPE_HELMET, 10000}, -- Корона из когтей дракона
[ARTIFACT_DRAGON_EYE_RING] = {'Dragon_eye_ring', ART_TYPE_RING, 10000}, -- Кольцо Глаз дракона
[ARTIFACT_DRAGON_FLAME_TONGUE] = {'Dragon_flame_tongue', ART_TYPE_WEAPON, 10000}, -- Пламенный язык дракона
[ARTIFACT_ROBE_OF_MAGI] = {'Robe_of_magi', ART_TYPE_ARMOR, 20000}, -- Халат Сар-Иссы
[ARTIFACT_STAFF_OF_MAGI] = {'Staff_of_magi', ART_TYPE_WEAPON, 20000}, -- Посох Сар-Иссы
[ARTIFACT_CROWN_OF_MAGI] = {'Crown_of_magi', ART_TYPE_HELMET, 20000}, -- Корона Сар-Иссы
[ARTIFACT_RING_OF_MAGI] = {'Ring_of_magi', ART_TYPE_RING, 20000}, -- Кольцо Сар-Иссы
[ARTIFACT_DWARVEN_MITHRAL_CUIRASS] = {'Dwarven_mithral_cuirass', ART_TYPE_ARMOR, 15000}, -- Кираса короля гномов
[ARTIFACT_DWARVEN_MITHRAL_GREAVES] = {'Dwarven_mithral_greaves', ART_TYPE_BOOTS, 15000}, -- Поножи короля гномов
[ARTIFACT_DWARVEN_MITHRAL_HELMET] = {'Dwarven_mithral_helmet', ART_TYPE_HELMET, 15000}, -- Шлем короля гномов
[ARTIFACT_DWARVEN_MITHRAL_SHIELD] = {'Dwarven_mithral_shield', ART_TYPE_SHIELD, 15000}, -- Щит короля гномов
[ARTIFACT_SCROLL_OF_SPELL_X] = {'ScrollOfSpell', ART_TYPE_MISC, 7000}, -- Магический свиток с заклинанием
[ARTIFACT_GRAAL] = {'Graal', ART_TYPE_MISC, 100000}, -- Слеза Асхи
[ARTIFACT_BOOTS_OF_LEVITATION] = {'Boots_of_levitation', ART_TYPE_BOOTS, 12000}, -- Сапоги левитации
[ARTIFACT_SKULL_HELMET] = {'Skull_Helmet', ART_TYPE_HELMET, 2000}, -- Шлем некроманта
[ARTIFACT_VALORIOUS_ARMOR] = {'Valorious_Armor', ART_TYPE_ARMOR, 3000}, -- Доспехи бесстрашия
[ARTIFACT_BOOTS_OF_SWIFTNESS] = {'Boots_of_Swiftness', ART_TYPE_BOOTS, 5000}, -- Сапоги странника
[ARTIFACT_MOONBLADE] = {'Moonblade', ART_TYPE_WEAPON, 4000}, -- Лунный клинок
[ARTIFACT_RING_OF_CELERITY] = {'Ring_of_Celerity', ART_TYPE_RING, 8000}, -- Кольцо стремительности
[ARTIFACT_BAND_OF_CONJURER] = {'Band_of_Conjurer', ART_TYPE_RING, 7000}, -- Пояс элементалей
[ARTIFACT_EARTHSLIDERS] = {'Earthsliders', ART_TYPE_BOOTS, 4000}, -- Изумрудные туфли
[ARTIFACT_RIGID_MANTLE] = {'Rigid_Mantle', ART_TYPE_CLOAK, 3000}, -- Плащ Силанны
[ARTIFACT_JINXING_BAND] = {'Jinxing_Band', ART_TYPE_RING, 6000}, -- Проклятое кольцо
[ARTIFACT_BONESTUDDED_LEATHER] = {'Bonestudded_Leather', ART_TYPE_ARMOR, 3000}, -- Туника из плоти
[ARTIFACT_WISPERING_RING] = {'Wispering_Ring', ART_TYPE_RING, 4000}, -- Кольцо предостережения
[ARTIFACT_HELM_OF_CHAOS] = {'Helm_of_Chaos', ART_TYPE_HELMET, 4000}, -- Шлем Хаоса
[ARTIFACT_TWISTING_NEITHER] = {'Twisting_neither', ART_TYPE_NECKLACE, 8000}, -- Кулон Поглощения
[ARTIFACT_SANDALS_OF_THE_SAINT] = {'Sandals_of_the_Saint', ART_TYPE_BOOTS, 12000}, -- Сандалии Святого
[ARTIFACT_SHAWL_OF_GREAT_LICH] = {'Shawl_of_the_great_lich', ART_TYPE_CLOAK, 14000}, -- Плащ Сандро
[ARTIFACT_RING_OF_DEATH] = {'Ring_of_Death', ART_TYPE_RING, 4000}, -- Кольцо Грешников
[ARTIFACT_NECROMANCER_PENDANT] = {'Necromancer_Pendant', ART_TYPE_NECKLACE, 7000}, -- Амулет некроманта
[ARTIFACT_FREIDA] = {'Freida', ART_TYPE_MISC, 1000}, -- Фрида (fake)
[ARTIFACT_RING_OF_THE_SHADOWBRAND] = {'Ring_of_the_Shadowbrand', ART_TYPE_RING, 1000}, -- Кольцо Заклейменных Тенью (fake)
[ARTIFACT_OGRE_CLUB] = {'Ogre_Club', ART_TYPE_WEAPON, 15000}, -- Дубина людоеда
[ARTIFACT_OGRE_SHIELD] = {'Ogre_Shield', ART_TYPE_SHIELD, 15000}, -- Щит людоеда
[ARTIFACT_TOME_OF_DESTRUCTION] = {'Tome_of_Destruction', ART_TYPE_MISC, 20000}, -- Том магии Хаоса
[ARTIFACT_TOME_OF_LIGHT_MAGIC] = {'Tome_of_Light_Magic', ART_TYPE_MISC, 20000}, -- Том магии Света
[ARTIFACT_TOME_OF_DARK_MAGIC] = {'Tome_of_Dark_Magic', ART_TYPE_MISC, 20000}, -- Том магии Тьмы
[ARTIFACT_TOME_OF_SUMMONING_MAGIC] = {'Tome_of_Summoning_Magic', ART_TYPE_MISC, 20000}, -- Том магии Призыва
[ARTIFACT_BEGINNER_MAGIC_STICK] = {'Beginer_Magic_Stick', ART_TYPE_WEAPON, 2000}, -- Волшебная палочка новичка
[ARTIFACT_RUNIC_WAR_AXE] = {'Runic_War_Axe', ART_TYPE_WEAPON, 10000}, -- Рунный боевой топор
[ARTIFACT_RUNIC_WAR_HARNESS] = {'Runic_War_Harness', ART_TYPE_ARMOR, 10000}, -- Рунная боевая упряжь
[ARTIFACT_SKULL_OF_MARKAL] = {'Skull_of_Markal', ART_TYPE_MISC, 18000}, -- Череп Маркела
[ARTIFACT_BEARHIDE_WRAPS] = {'Bearhide_Wraps', ART_TYPE_CLOAK, 3000}, -- Тайные защитные покровы
[ARTIFACT_DWARVEN_SMITHY_HUMMER] = {'Dwarven_Smithy_Hammer', ART_TYPE_WEAPON, 5000}, -- Гномий кузнечный молот
[ARTIFACT_RUNE_OF_FLAME] = {'Rune_of_Flame', ART_TYPE_MISC, 4000}, -- Руна пламени
[ARTIFACT_TAROT_DECK] = {'Tarot_Deck', ART_TYPE_MISC, 3000}, -- Колода Таро
[ARTIFACT_CROWN_OF_LEADER] = {'Crown_Of_Leader', ART_TYPE_HELMET, 5000}, -- Корона лидерства
[ARTIFACT_MASK_OF_DOPPELGANGER] = {'Mask_Of_Doppelganger', ART_TYPE_HELMET, 16000}, -- Маска справедливости
[ARTIFACT_EDGE_OF_BALANCE] = {'Edge_Of_Balance', ART_TYPE_WEAPON, 2000}, -- На грани равновесия
[ARTIFACT_RING_OF_MACHINE_AFFINITY] = {'Ring_Of_Machine_Affinity', ART_TYPE_RING, 18000}, -- Кольцо родства с машинами
[ARTIFACT_HORN_OF_PLENTY] = {'Horn_Of_Plenty', ART_TYPE_MISC, 20000}, -- Рог изобилия
[ARTIFACT_RING_OF_UNSUMMONING] = {'Ring_Of_Unsummoning', ART_TYPE_RING, 3000}, -- Кольцо изгнания
[ARTIFACT_BOOK_OF_POWER] = {'Book_Of_Power', ART_TYPE_MISC, 9000}, -- Том Силы
[ARTIFACT_TREEBORN_QUIVER] = {'Treeborn_Quiver', ART_TYPE_MISC, 10000}, -- Изумительный колчан
[ARTIFACT_PRINCESS] = {'Princess_Aelina', ART_TYPE_MISC, 1000}, -- Принцесса Аэлина (fake)
};

function GetArtefactName(id)
if(id == ARTIFACT_BEARHIDE_WRAPS) then
return '/Text/Game/Artifacts/'..artefact_table[id][ARTEFACT_TABLE_NAME]..'/name.txt'
else
return '/Text/Game/Artifacts/'..artefact_table[id][ARTEFACT_TABLE_NAME]..'/Name.txt'
end
end

function GetArtefactDesc(id)
return '/Text/Game/Artifacts/'..artefact_table[id][ARTEFACT_TABLE_NAME]..'/Description.txt'
end

function GetArtefactType(id)
return artefact_table[id][ARTEFACT_TABLE_TYPE]
end

function GetArtefactCost(id)
return artefact_table[id][ARTEFACT_TABLE_COST]
end
РПГ-сценарий для HoMM5: Путь героя
ЧаВо по созданию карт для HoMM5: ЧаВо
Auto-translated

Hello. Could you please tell me how to wait for a playing animation to finish in a combat script?

Is it necessary to run the animation in a separate thread, or can it be run in the main thread?

The idea for the battle is that when a unit takes its turn, it applies blindness to a random stack of the player's units. The necessary checks for applicability are performed before calling this function. The problem is that the following happens: the unit moves, then the movement animation is interrupted, it starts the casting animation, and the casting animation is interrupted before it finishes, followed by the attack animation, if the unit initially planned to attack the player's stack.

Here is the code for the functions used:

function Cast(unit, target)
combatSetPause(not nil);
CastBlindForFree(unit, target);
playAnimation(target, 'hit', ONESHOT_STILL);
table.insert(blind_array, target);
combatSetPause(nil);
return not nil
end

function CastBlindForFree(caster, target)
SetUnitManaPoints(caster, 100);
local mana_before_cast = GetUnitManaPoints(caster);
repeat sleep(1) until(GetUnitManaPoints(caster) == 100);
UnitCastAimedSpell(caster, SPELL_BLIND, target);
sleep(4);
SetUnitManaPoints(caster, mana_before_cast);
repeat sleep(1) until(GetUnitManaPoints(caster) == mana_before_cast);
end

In other words, the logic works correctly, but how can I synchronize the animations so that they play sequentially, and the main game animations do not interrupt the casting animation?

Thank you very much for your time and attention to reading the question; I would be grateful for any information.

In reply to MaiorPain
User Avatar
Auto-translated
MaiorPain

Hello. Please tell me: how do I wait for the end of a playing animation in a combat script?

Is it necessary to run the animation in a separate thread, or can it be run in the main thread?

The idea of the battle is that when a unit takes its turn, it applies blindness to a random stack of the player. The necessary checks for applicability are performed before calling this function. The problem is that the following happens: the unit moves, then the movement animation is interrupted, it starts the casting animation, and the casting animation is interrupted before the attack animation finishes, if the unit initially planned to attack the player's stack.

Here is the code for the functions used:

function Cast(unit, target)
combatSetPause(not nil);
CastBlindForFree(unit, target);
playAnimation(target, 'hit', ONESHOT_STILL);
table.insert(blind_array, target);
combatSetPause(nil);
return not nil
end

function CastBlindForFree(caster, target)
SetUnitManaPoints(caster, 100);
local mana_before_cast = GetUnitManaPoints(caster);
repeat sleep(1) until(GetUnitManaPoints(caster) == 100);
UnitCastAimedSpell(caster, SPELL_BLIND, target);
sleep(4);
SetUnitManaPoints(caster, mana_before_cast);
repeat sleep(1) until(GetUnitManaPoints(caster) == mana_before_cast);
end

In other words, the logic works correctly, but how do I synchronize the animations so that they play sequentially, and the main game animations do not interrupt the casting animation?

Thank you very much for your time and attention to reading the question; I will be grateful for any information.

while combatReadyPerson() == nil do sleep(1) end
This code "sleeps" until it is no one's turn: at the start of the battle or during the animation. If this doesn't help, then you can only use waiting, but keep in mind that sleep() in a combat script is different from its counterpart on the adventure map. The argument for sleep() should be in the hundreds to provide any visible delay in the combat script
Мои карты: Белый Храм, Поменяться местами, Судьба королевства, Стихийные острова.
User Avatar
Auto-translated
MaiorPain, I think using a separate thread is better; if you mess something up, it will only result in an unsuccessful cast, whereas without a thread, the function will crash and not execute the code.

And as I understand it, you're casting a unit during its turn in the UnitMove(unit) hook, right? Then, if the cast is successful, you just need this function to return not nil, and the game won't control that creature during that turn.
РПГ-сценарий для HoMM5: Путь героя
ЧаВо по созданию карт для HoMM5: ЧаВо

Statistics