Skip to content

Scripts for beginners.

User Avatar
#393
Auto-translated
AngryTapok1337

I wanted to ask for help with a script again, but somehow I managed to get it working. smile

 

The script gives the player a town and a hero when they complete a quest (in my case, the quest is initially hidden, so I couldn't just use OBJECTIVE_STATE_CHANGE_TRIGGER). It's probably possible to write it more simply, and if so, I'll be corrected. But anyway, I'll leave it here, just in case it's useful to someone.

 

function InfernoF()
 if ( GetObjectiveState("KillDruid") == OBJECTIVE_COMPLETED ) then
         MessageBox ("/Maps/SingleMissions/ZimaMap1v2NoScriptsNoQuests/Succubus2.txt")
         sleep(1)
         SetObjectOwner( "InfTown", 1 )
         DeployReserveHero( "Biara", 28, 21, UNDERGROUND )
         end
end

Trigger(OBJECTIVE_STATE_CHANGE_TRIGGER, "KillDruid", "InfernoF")

 



Added 4 minutes ago

And again, I'm asking for help.

The problem is this: I had working scripts for a hero to enter a region and a battle to begin. Everything worked perfectly. But suddenly, something went wrong, and I 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 clear it with one hero, but that's not the point). So I added a second hero to the player, and immediately everything went wrong - the script works as it should, and the battle begins, but... only the first hero fights (let's call him hero1). That is, when hero2 enters the scripted region, the battle is still fought by hero1, regardless of where he is now.

The question is: how can I change 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.

function Region1F ()
         MessageBox ("/Maps/SingleMissions/ZimaMap1v2NoScriptsNoQuests/Spasenie1.txt")
         StartCombat("RedHeavenHero04", 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
Trigger(REGION_ENTER_AND_STOP_TRIGGER,"Region1","Region1F")

 

Thank you in advance!

I'll just write the script, because I'm too lazy to explain.
function Region1F (hero)
MessageBox ("/Maps/SingleMissions/ZimaMap1v2NoScriptsNoQuests/Spasenie1.txt")
StartCombat(hero, 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
Trigger(REGION_ENTER_AND_STOP_TRIGGER,"Region1","Region1F")

Мои карты:
Падший рыцарь
Сердце Хаоса

Мои моды:
Визуальные:
Изменение внешнего вида героев-некромантов
Существа-жители и кое-что по мелочи в городах Ордена Порядка, Некрополиса и Инферно

NCF-существа:
Странствующие рыцари
Наемники