Skip to content

"Замена" startcombat

User Avatar
#2
Auto-translated

There is a much simpler way if you don't want to use a reserve — the function MakeHeroInteractWithObject( heroName, objectName ). You enter the script names of your own and the desired enemy hero, and then your hero effectively "touches" the enemy one, thereby triggering combat. If the target enemy hero is stationed in a town, you need to specify the script name of the town they are in for objectName (or alternatively use SiegeTown(heroName, townName, arenaName = "")). If the town doesn't have a script name, then you'll need to "kick" the hero out of the town using SetObjectPosition(). Now, if you need a specific Combat Script to run during all of this, you should put the path to the script in the Shared properties of the main (your own) hero so that it runs during every skirmish; then, write conditions so that the script only executes its code if we encounter a specific hero, for example (I took this code from my own map, which handles encounters between required heroes, such as when my hero attacks/is attacked by certain heroes):

function CheckHero()
if (GetDefenderHero() and GetHeroName(GetDefenderHero()) == "Duncan") or (GetAttackerHero() and GetHeroName(GetAttackerHero()) == "Duncan") then
if (GetDefenderHero() and GetHeroName(GetDefenderHero()) == "Freyda") or (GetAttackerHero() and GetHeroName(GetAttackerHero()) == "Freyda") then
print("Рубль будет? Мне на яхту не хватает")
end
end

That's how it works :)

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

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