Skip to content

Posts from Scripts

4.8 (8 ratings)
#2844
Auto-translated
Hello. I'm new to scripting.
Could you suggest a script for attacking a monster on the global map (playing the attack animation)?
In reply to Barboriska
User Avatar
#2845
Auto-translated
PlayObjectAnimation, see the manual.
User Avatar
#2846
Auto-translated
I encountered such a problem... There is an enemy hero (mobile). His death leads to victory in the scenario... but if this hero dies during the AI's turn (he runs into the player), then after the video and other things are played, instead of victory, the game displays a console error "No player!", and the turn change freezes. If the player attacks the hero himself, then everything works correctly. Does anyone know how to fix this? Please help! Here is the function itself: Trigger(PLAYER_REMOVE_HERO_TRIGGER, 2, "TheEnd") function TheEnd(hero) if hero == "RedHeavenHero05" then StartDialogScene(path.."DialogScenes/DialogFinal/DialogScene.xdb#xpointer(/DialogScene)") sleep(5) SetObjectiveState("Final", OBJECTIVE_COMPLETED) SetObjectiveState("NecroTown", OBJECTIVE_COMPLETED) SetObjectiveState("ArantirLive", OBJECTIVE_COMPLETED) sleep(10) Win() end end
Карты для героев 5

"Плата за любовь"
"Путь некроманта"
"Темные грани"
"Рок Гримхейма"
User Avatar
#2847
Auto-translated
Is this the only hero of the opponent?
 

К А
Стикеры GBF в Telegram
In reply to AstralLein
User Avatar
#2849
Auto-translated
AstralLein
I encountered such a problem...

There is an enemy hero (mobile). His death leads to victory in the scenario... but if this hero dies during the AI's turn (he crashes into the player), then after the cutscene and everything else, instead of victory, the game displays a console error "No player!", and the turn change freezes. If the player attacks the hero himself, then everything works correctly.

Does anyone know how to fix this? Please!)))

Here is the function itself:

Trigger(PLAYER_REMOVE_HERO_TRIGGER, 2, "TheEnd")

function TheEnd(hero)
if hero == "RedHeavenHero05" then
StartDialogScene(path.."DialogScenes/DialogFinal/DialogScene.xdb#xpointer(/DialogScene)")
sleep(5)
SetObjectiveState("Final", OBJECTIVE_COMPLETED)
SetObjectiveState("NecroTown", OBJECTIVE_COMPLETED)
SetObjectiveState("ArantirLive", OBJECTIVE_COMPLETED)
sleep(10)
Win()
end
end

I had a similar problem; if the enemy hero crashed into the player, the game would freeze (BlockGame). I solved it by making my event, which occurred when this hero died, happen during the turn of the third, leftmost player, and everything became okay. But if you only have 2 active players, then I don't know how this could help.
Автор карт:
Долина расхитителей
Выбор мира
In reply to AstralLein
#2850
Auto-translated
AstralLein
I encountered the following problem...

There is an enemy hero (mobile). His death leads to victory in the scenario... but if this hero dies during the AI's turn (he crashes into the player), then after the video and other things play, instead of victory, the game displays a console error "No player!", and the turn change freezes. If the player attacks the hero himself, then everything works correctly.

Does anyone know how to fix this? Please!)))

Here is the function itself:

Trigger(PLAYER_REMOVE_HERO_TRIGGER, 2, "TheEnd")

function TheEnd(hero)
if hero == "RedHeavenHero05" then
StartDialogScene(path.."DialogScenes/DialogFinal/DialogScene.xdb#xpointer(/DialogScene)")
sleep(5)
SetObjectiveState("Final", OBJECTIVE_COMPLETED)
SetObjectiveState("NecroTown", OBJECTIVE_COMPLETED)
SetObjectiveState("ArantirLive", OBJECTIVE_COMPLETED)
sleep(10)
Win()
end
end

Record it as I suggested, using startThread.

function TheEnd()
while IsHeroAlive( "RedHeavenHero05" ) == true do sleep(5) end
sleep(1)
StartDialogScene(path.."DialogScenes/DialogFinal/DialogScene.xdb#xpointer(/DialogScene)")
sleep(5)
SetObjectiveState("Final", OBJECTIVE_COMPLETED)
SetObjectiveState("NecroTown", OBJECTIVE_COMPLETED)
SetObjectiveState("ArantirLive", OBJECTIVE_COMPLETED)
sleep(10)
Win()
end
(I might have missed something)
The function itself needs to be launched after defeating Vessel.
Карты: Экспедиция ГрувераНаследие ШантириВременной парадоксПоиски рунной сферыПуть возвращения
In reply to OrnsteinDragonslayer
User Avatar
#2851
Auto-translated
OrnsteinDragonslayer
I had a similar problem; if an enemy hero collided with a player, the game would freeze (BlockGame). I solved it by making my event, which occurred when that hero died, happen during the third player's turn, and everything was fine. But if you only have 2 active players, I don't know how that could help.

Three players.
Карты для героев 5

"Плата за любовь"
"Путь некроманта"
"Темные грани"
"Рок Гримхейма"
#2852
Auto-translated
Hey guys, can you suggest a script that would make creatures attack and show some kind of "happy" animation on the map? It's really important for the map, so please help.
In reply to JackBrainPredtech
User Avatar
#2853
Auto-translated
JackBrainPredtech
Hey guys, can you suggest a script so that a creature attacks and then shows a "happy" animation on the map? It's very important for the map, please help.

PlayObjectAnimation("scripted unit name", "happy", ONESHOT_STILL);

ONESHOT_STILL - if the animation should only play once;
if you want the animation to be continuous, you need a different command; refer to the manual to find out which one.
Автор карт:
Долина расхитителей
Выбор мира
In reply to OrnsteinDragonslayer
#2854
Auto-translated
OrnsteinDragonslayer
PlayObjectAnimation("scripted unit name", "happy", ONESHOT_STILL);

ONESHOT_STILL - if the animation should be played only once;
if you want the animation to be continuous, you need a different command; refer to the manual for the specific command.

I read it, and I didn't understand anything, help me

Added after 35 minutes
OrnsteinDragonslayer
PlayObjectAnimation("scripted unit name", "happy", ONESHOT_STILL);

ONESHOT_STILL - if the animation should be played only once;
if you want the animation to be continuous, you need a different command; refer to the manual for the specific command.

It's all in English. Please write the commands I asked for, if it's not too much trouble...

Added after 8 minutes
OrnsteinDragonslayer
PlayObjectAnimation("scripted unit name", "happy", ONESHOT_STILL);

ONESHOT_STILL - if the animation should be played only once;
if you want the animation to be continuous, you need a different command; refer to the manual for the specific command.
please help
User Avatar
#2855
Auto-translated
OrnsteinDragonslayer explained everything in detail.

In the editor, you assign a script name to the creature that should play the animation. Then, you copy this line into the script for each of these creatures.

PlayObjectAnimation("enter the creature's script name here", "happy", IDLE) - for a looping "happy" animation
PlayObjectAnimation("enter the creature's script name here", "attack00", IDLE) - for a looping "attack" animation
Карты для героев 5

"Плата за любовь"
"Путь некроманта"
"Темные грани"
"Рок Гримхейма"
In reply to AstralLein
#2856
Auto-translated
AstralLein
OrnsteinDragonslayer explained everything in detail.

In the editor, you assign a script name to the creature that should play the animation. Then, you copy this line into the script for each of these creatures.

PlayObjectAnimation("enter the creature's script name here", "happy", IDLE) - for a looping "happy" animation
PlayObjectAnimation("enter the creature's script name here", "attack00", IDLE) - for a looping "attack" animation

Unfortunately, they are still doing nothing.
In reply to JackBrainPredtech
User Avatar
#2857
Auto-translated
Which script did you use: for creatures or for maps?
In reply to JackBrainPredtech
User Avatar
#2858
Auto-translated
JackBrainPredtech
Unfortunately, they are still just standing around doing nothing.

A fragment from my map, where 2 elementals are fighting.
function BattleThread()
while (true) do
if (IsObjectExists("elemF")) then
PlayObjectAnimation("elemF", "attack00", ONESHOT);
end
sleep(random(10)+5);
if (IsObjectExists("elemW")) then
PlayObjectAnimation("elemW", "attack00", ONESHOT);
end
sleep(random(10)+5);
end
end

startThread (BattleThread);

Where elemF and elemW are the script names of the creatures. If you don't know, click on the desired unit in the editor, and in the menu on the left, in the Name line (or something similar), give it a name; use this name in the function above.
Автор карт:
Долина расхитителей
Выбор мира

Statistics

Welcome our newest member: Emil