Skip to content

Scripts for beginners.

User Avatar
#394
Auto-translated

AngryTapok1337
I need help again. The problem is this: I had working scripts that triggered a battle when a hero entered a region. Everything worked perfectly. But suddenly, I had an idea and wanted to give the player two heroes at the start (partly because the map is large, and it would take until the second coming to explore it with just one hero, but that's not the main point). So, I added a second hero for the player, and immediately everything went wrong – the script works as it should, and the battle starts, but... only the first hero fights (let's call him Hero1). That is, when Hero2 enters the scripted region, Hero1 still fights the battle, regardless of where he is currently located. The question is: how can I modify the script so that the battle is fought not by a specific hero, but by the one who enters the region? The script is attached. Thank you in advance!
Here's the script, but let's add that it should only work for our heroes; otherwise, an enemy bot might (just in case?) run in and activate the script, which is not what we want (or is it?).
function Region1F( heroName )
      if ( heroName == "scripted name of the first main hero" ) or ( heroName == "scripted name of the second main hero" ) then --if more main heroes are planned, you can add more checks in the same way as for the second hero
            MessageBox ("/Maps/SingleMissions/ZimaMap1v2NoScriptsNoQuests/Spasenie1.txt")
            StartCombat( heroName, nil, 4, 93, 100, 93, 100, 95, 75, 101, 15, nil)
            RemoveObject('g1')
            RemoveObject('g2')
            RemoveObject('g3')
            RemoveObject('g4')
            RemoveObject('g5')
            RemoveObject('g6')
            sleep(1)
            Trigger(REGION_ENTER_AND_STOP_TRIGGER,"Region1",nil)
      end
end
Trigger(REGION_ENTER_AND_STOP_TRIGGER,"Region1","Region1F")

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

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