Posts from Scripts
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?
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога
Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
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
endthe 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...
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)?
randomize - using the random() function, but it doesn't work in combat. Fortunately, there are a couple of custom implementations of this.
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?
The name of the deceased unit is already passed to this function. Therefore, you can also use GetCreatureType().
function DefenderCreatureDeath(unit)
if(GetCreatureType(unit) == CREATURE_PHOENIX) then
fenix = 0
end
endкак то так
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
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