Skip to content

Posts from Scripts

4.8 (8 ratings)
In reply to Gerter
Auto-translated
Gerter
I tested the necessary part of the code – this is 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

Thank you very much. It helped.
Карты: Экспедиция ГрувераНаследие ШантириВременной парадоксПоиски рунной сферыПуть возвращения
User Avatar
Auto-translated
Question regarding combat scripts. I want to create a boss battle, but not a simple one. The battle starts against a succubus and a devil. After the succubus is killed, the devil disappears and an archdemon spawns. If the devil is killed first, the succubus disappears and a temptress is summoned. The question is, what commands are used to do this, and is it even possible (will the battle end after killing only one unit, or are there other pitfalls)?
Автор карт:
Долина расхитителей
Выбор мира
In reply to OrnsteinDragonslayer
Auto-translated
OrnsteinDragonslayer
Question about combat scripts. I want to create a boss battle, but not a simple one. The battle starts against a succubus and a devil. After the succubus is killed, the devil disappears and an archdemon spawns. If the devil dies first, the succubus disappears and a temptress is summoned. The question is, what commands are used to do this, and is it even possible (will the battle end after only one unit is killed, and are there any other pitfalls)?
EnableAutoFinish(nil)

function DefenderCreatureDeath(unit)
if(GetCreatureType(unit) == 21) then
removeUnit("devil's name")
SummonCreature(DEFENDER,28,10,-1,-1)
end
if(GetCreatureType(unit) == 27) then
removeUnit("succubus's name")
SummonCreature(DEFENDER,134,10,-1,-1)
end
end

I don't know how to remove units that are present at the beginning of the battle (you need their scripted name).
But for those that are summoned, the name is written at the end:
SummonCreature(DEFENDER, CREATURE_DEVIL, 1, 11, -1, 1, 'Devil')
Карты: Экспедиция ГрувераНаследие ШантириВременной парадоксПоиски рунной сферыПуть возвращения
User Avatar
Auto-translated
I don't know how to remove units that have been present since the beginning of the battle (you need their scripted name).
You can get a list of enemy creatures using GetCreatures(DEFENDER). For example, for a devil:
local units = GetCreatures(DEFENDER);
for i, unit in units do
local unit_id = GetCreatureType(unit);
if(unit_id == DEVIL_ID) then
removeUnit(unit)
end
end
РПГ-сценарий для HoMM5: Путь героя
ЧаВо по созданию карт для HoMM5: ЧаВо
User Avatar
Auto-translated
The battle with the code above will continue indefinitely because there is no termination condition specified when automatic mode is disabled.
Нет войне.
User Avatar
Auto-translated
Here is the code:
function DefenderCreatureDeath(unit)
	if(GetCreatureType(unit) == 21) then
		removeUnit("CREATURE_DEVIL")
		SummonCreature(DEFENDER,137,10,-1,-1)
	end
	if(GetCreatureType(unit) == 27) then
		removeUnit("CREATURE_SUCCUBUS")
		SummonCreature(DEFENDER,134,10,-1,-1)
	end
end

local units = GetCreatures(DEFENDER);
for i, unit in units do
  local unit_id = GetCreatureType(unit);
  if(unit_id == 27) then
    removeUnit(unit)
  end
end

local units = GetCreatures(DEFENDER);
for i, unit in units do
  local unit_id = GetCreatureType(unit);
  if(unit_id == 21) then
    removeUnit(unit)
  end
end
Here is the error: And this is not just in this battle. And yes, nothing happens as intended. Apparently, I need to somehow get the hero's name...
Автор карт:
Долина расхитителей
Выбор мира
User Avatar
Auto-translated
^The heroname argument with which GetHeroName() is called is not defined. It should be called like this - GetHeroName(GetHero(faction)), for example. I also have a small question. I encountered a problem where it is impossible to make creatures cast certain abilities, for example, the banshee's ability, because there is simply no ID for it. I tried to specify the ability name from the creature file as an argument - ABILITY_DEATH_WAIL, but this value is also not defined. Does this mean that these abilities cannot be cast at all, or is there a way to do it?
Нет войне.
User Avatar
Auto-translated
OrnsteinDragonslayer, the code is so incorrect that it's unclear where to even begin explaining. You should start by noting that the game directly indicates in which function the error occurred and which variable it didn't like. In the provided code, these are absent, which means the error occurred in another part of the combat script. For the rest, I recommend reviewing Novik's manual, especially the section on combat hooks. Gerter, the combat script knows everything that is in common.lua. If there is no corresponding macro there, you can also look in types.xml, and if there is something needed there, insert it into the script as a number. For example, in common.lua, spells end with: SPELL_BLADE_BARRIER = 284; and in types.xml, after it, there are: SPELL_UBER_METEOR_SHOWER 285 and many others, far beyond 300. In particular, ABILITY_DEATH_WAIL is 316.
РПГ-сценарий для HoMM5: Путь героя
ЧаВо по созданию карт для HoMM5: ЧаВо
User Avatar
Auto-translated
Thank you, I didn't even know about types.xml, to be honest; I always limited myself to the standard list of IDs from the manual. Now I'll use the extended one, thanks.
Нет войне.
In reply to Jack_of_shadows
User Avatar
Auto-translated
Jack_of_shadows
OrnsteinDragonslayer, the code is so incorrect that it's unclear where to even begin explaining. You should start by noting that the game directly indicates in which function the error occurred and which variable it didn't like. There are none of those in the provided code, which means the error occurred in another part of the combat script. As for the rest, I recommend looking at Novik's manual, especially regarding combat hooks.

Well, I'm not very familiar with combat scripts, so I just copied everything from above and added creature identifiers. A manual would be helpful, but where can I find it? Google is silent, and there's no one with the nickname Novik on the forum (or is it spelled that way? I only found that in Google). There's nothing about it in the general Heroes manuals. I would be grateful if you could share it for everyone to see.
Автор карт:
Долина расхитителей
Выбор мира
User Avatar
Auto-translated
Here's another small question regarding the game mechanics. All spells are divided into targeted, area-of-effect, and global types, but there are exceptions like teleportation, which require both a target and an area to be specified. As I understand it, are such spells completely unusable in combat? Attempting to cast teleportation always results in an error, and while enchanted arrow can be used, it has no effect. Is there a way to resolve this issue (I'm 99% sure there isn't, but just in case)?
Нет войне.
In reply to Gerter
User Avatar
Auto-translated
Regarding teleportation, I know that there is such a function: teleporting a unit to a specific cell.
User Avatar
Auto-translated
I understand, but I'm interested in the teleport as a spell.
Нет войне.
In reply to Gerter
User Avatar
Auto-translated
Has anyone tried using runes on other factions in a Heroes of Might and Magic script? If so, please tell me how to use them via commandDoSpell or CommandDoSpecial?:p (since they are basically spells).

Statistics

Welcome our newest member: Emil