Skip to content

Posts from Scripts

4.8 (8 ratings)
User Avatar
#2811
Auto-translated
I encountered a problem where the setATB function doesn't work on combat units. It might be related to the catapult/ballista's triple shot, but nonetheless. Maybe someone knows how to solve this?
Нет войне.
In reply to Gerter
User Avatar
#2812
Auto-translated
Gerter
I encountered a problem where the setATB function doesn't work on combat units. It might be related to the catapult/ballista's triple shot, but regardless. Maybe someone knows how to fix this?
I just checked on a ballista with a triple shot - it worked fine. The error is in something else.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
In reply to RedHeavenHero
User Avatar
#2814
Auto-translated
RedHeavenHero
I just checked it on a ballista with a triple shot – it was working. The error is something else.

although, no, it still doesn't work. Can you show me your code, maybe I'm doing something wrong in principle...
I'm writing something like this:

function DefenderMachineMove(machine)
local n = GetWarMachineType(machine)
if n == 1 or n == 2 then
setATB(machine, 0.5)
end
end
the code works, but there's no shift on the scale.

Okay, I moved the shift function to DefenderCreatureMove – now it works. It's strange that I could shift heroes and units within their turns...
Нет войне.
User Avatar
#2816
Auto-translated
Does anyone know how to check a hero's spellcasting ability in a combat script?
User Avatar
#2817
Auto-translated
it is impossible to find out exactly which spell the hero cast. However, you can determine whether a spell was cast, for example, by observing the change in mana during the HeroMove event.
Нет войне.
In reply to Gerter
User Avatar
#2818
Auto-translated
Does anyone know how to activate a specific skill on a creature using a combat script? For example:
function AttackerCreatureMove()
The creature roots itself or does something else.
end
(I don't remember the exact syntax of this function)

Also, does anyone know how to randomize values (I looked something up online about Lua, but I couldn't find it)?
User Avatar
#2819
Auto-translated
commandDoSpecial(unit name, ability ID, coordinates to use the ability on)

randomize - using the random() function, but it doesn't work in combat. Fortunately, there are a couple of custom implementations of this.
Нет войне.
In reply to Gerter
User Avatar
#2820
Auto-translated
Gerter
commandDoSpecial(unit name, ability ID, coordinates to use the ability on)

randomize - using the random() function, but it doesn't work in combat. Luckily, there are a couple of custom implementations of this.

Which ones specifically?
Карты для героев 5

"Плата за любовь"
"Путь некроманта"
"Темные грани"
"Рок Гримхейма"
User Avatar
#2821
Auto-translated
The Echo of the Void map has a great random map script; I use it.
Нет войне.
User Avatar
#2823
Auto-translated
the name of the deceased unit is already passed to this function, so you can also use GetCreatureType().
Нет войне.
In reply to Gerter
#2824
Auto-translated
Gerter
The name of the deceased unit is already passed to this function. Therefore, you can also use GetCreatureType().
I know, I just need a variable (fenix) to be set to 0 after the phoenix dies.
Карты: Экспедиция ГрувераНаследие ШантириВременной парадоксПоиски рунной сферыПуть возвращения
User Avatar
#2825
function DefenderCreatureDeath(unit)
if(GetCreatureType(unit) == CREATURE_PHOENIX) then
fenix = 0
end
end

как то так
Нет войне.
In reply to Gerter
#2826
Auto-translated
Gerter
function DefenderCreatureDeath(unit)
if(GetCreatureType(unit) == CREATURE_PHOENIX) then
fenix = 0
end
end

something like that

That's strange... nothing happens. Here's the script, just in case. (It also doesn't work with elementals)

diff = GetDifficulty() + 1
defender = GetDefenderHero()
attacker = GetAttackerHero()
defender_turn = 0
death = 0
elemental= 0
fenix = 0

function Start()
SummonCreature(DEFENDER,103, 12 * diff,8,9)
SummonCreature(DEFENDER,105, 9* diff,8,2)
end

function DefenderHeroMove()
if elemental == 0 then
elemental = 1
UnitCastGlobalSpell(defender,SPELL_SUMMON_ELEMENTALS )
end
defender_turn = defender_turn + 1
if defender_turn == 1 then
combatSetPause(1)
UnitCastGlobalSpell(defender,SPELL_ARMAGEDDON)
sleep(200)
combatSetPause(nil)
end
if defender_turn == 2 then
SummonCreature(DEFENDER,104, 10 * diff)
if fenix == 0 then
fenix = 1
UnitCastGlobalSpell(defender,SPELL_CONJURE_PHOENIX)
end
end
end

function DefenderCreatureDeath(unit)
if(GetCreatureType(unit) == CREATURE_FIRE_ELEMENTAL ) then
elemental = 0
end
end
death = death + 1
if death == 1 then
print("bbb")
end
Карты: Экспедиция ГрувераНаследие ШантириВременной парадоксПоиски рунной сферыПуть возвращения
User Avatar
#2827
Auto-translated
I tested the necessary part of the code – here’s how it works. Each time after the phoenix/elementals die, the hero summons them again.
elemental = 0
fenix = 0

function DefenderHeroMove(hero)
if elemental == 0 then
elemental = 1
startThread(UnitCastGlobalSpell, hero, SPELL_SUMMON_ELEMENTALS)
end
if fenix == 0 then
fenix = 1
startThread(UnitCastGlobalSpell, hero, SPELL_CONJURE_PHOENIX)
end
return not nil
end

function DefenderCreatureDeath(unit)
if(GetCreatureType(unit) == 85) then
print('fire elem dead')
elemental = 0
end

if(GetCreatureType(unit) == 91) then
print('phoenix dead')
fenix = 0
end
end
Нет войне.

Statistics

Welcome our newest member: Emil