A few questions about the Heroes V map editor...

Maps and the art of mapmaking.
User avatar
Mace the Councillor
Peasant
Peasant
Posts: 57
Joined: 06 Jan 2006
Location: Sweden

A few questions about the Heroes V map editor...

Unread postby Mace the Councillor » 20 Nov 2006, 13:57

I have checked this out a bit, and most of it seems fairly straightforward. However, there are a few aspects I am a bit unsure about.

1. Is there a quick way to learn the scripting language syntax? This would be of great help. I am no newbie to programming (in fact, I study computer science at university, and I have made a heavily scripted map for Heroes IV), but this language hardly seems well-documented. While there is an Acrobat file documenting various functions, it seems unclear how to place them in a syntax. It also seems unclear how to arrange a script in such a way that a triggering event on the map (town changing owner, hero entering region, hero/monster defeated etc.) causes other things to happen.

2. Are object scripts handled on the objects themselves or in the map script.

3. How are victory and defeat conditions (such as whether a player who has no town for a consecutive 7 days will automatically lose) managed? Is there a way to deactivate the standard victory conditions? I suspect this may somehow be done via scripting, but how.

4. Can campaigns with carryover hero(es) be made in this game? If so, how?

Any help would be greatly appreciated.

User avatar
Pitsu
Round Table Hero
Round Table Hero
Posts: 1830
Joined: 22 Nov 2005

Unread postby Pitsu » 20 Nov 2006, 14:21

Mace the Councillor wrote: 1. Is there a quick way to learn the scripting language syntax?
As far as I know there is no manual for that.
2. Are object scripts handled on the objects themselves or in the map script.
Which "object scripts" you mean? Most of them can be defined in main map script. But combat, for example, goes into a separate file.
3. How are victory and defeat conditions (such as whether a player who has no town for a consecutive 7 days will automatically lose) managed? Is there a way to deactivate the standard victory conditions? I suspect this may somehow be done via scripting, but how.
You can deactivate the standart win and lose (Game properties tree, under objectives). With scripts you can make any conditions to give a victory or loss.
4. Can campaigns with carryover hero(es) be made in this game? If so, how?
Campaign editor is officially not there (if not with HoF). Some once showed a screen of map linking tool (re-enabled by a editor modification) but dunno its functionality.

And finally, scripts only work on singleplayer maps.
Avatar image credit: N Lüdimois

User avatar
Grumpy Old Wizard
Round Table Knight
Round Table Knight
Posts: 2205
Joined: 06 Jan 2006
Location: Tower Grump

Re: A few questions about the Heroes V map editor...

Unread postby Grumpy Old Wizard » 20 Nov 2006, 14:29

Mace the Councillor wrote:I have checked this out a bit, and most of it seems fairly straightforward. However, there are a few aspects I am a bit unsure about.

1. Is there a quick way to learn the scripting language syntax? This would be of great help. I am no newbie to programming (in fact, I study computer science at university, and I have made a heavily scripted map for Heroes IV), but this language hardly seems well-documented. While there is an Acrobat file documenting various functions, it seems unclear how to place them in a syntax. It also seems unclear how to arrange a script in such a way that a triggering event on the map (town changing owner, hero entering region, hero/monster defeated etc.) causes other things to happen.
Go through the mapmaker guide--the practical guide (tutorial) and the theoretical guide.

Look here for LUA scripting:

http://www.lua.org/manual/5.1/manual.html#2.4.5

http://lua-users.org/wiki/

http://www.wowwiki.com/Lua_functions

Look at maps that have a lot of scripting. My map "Seize The Throne" has over 1100 lines of script. It is heavily commented. Find it here
Mace the Councillor wrote:2. Are object scripts handled on the objects themselves or in the map script.
Most scripts will be handled in the map script. Some things like a simple quest hut can be handled on the object.

viewtopic.php?t=4058

See "Seize The Throne" scripting for examples of scripting in the map script that deals with objects being touched (like dwellings, fairy rings, and a statue.)
Mace the Councillor wrote:3. How are victory and defeat conditions (such as whether a player who has no town for a consecutive 7 days will automatically lose) managed? Is there a way to deactivate the standard victory conditions? I suspect this may somehow be done via scripting, but how.
Under the map properties tree you will find "objectives." I believe that you can alter the win/loss conditions there. You can also do it throught scripting. In "Seize The Throne" the player loses if he loses his starting heroe. I used scripting to program that.
Mace the Councillor wrote:4. Can campaigns with carryover hero(es) be made in this game? If so, how?
It was not possible to make campaigns with the editor in version 1.3 I have not yet played around with the editor since HOF was released, so I don't know if it is possible now.

GOW

Mod note: please make sure to place long URL:s in URL tags, so as to not disrupt the layout of the forums and cause them to stretch beyond all limits. Thank you. GC
Frodo: "I wish the ring had never come to me. I wish none of this had happened."
Gandalf: "So do all who live to see such times but that is not for them to decide. All we have to decide is what to do with the time that is given to us."

User avatar
Mace the Councillor
Peasant
Peasant
Posts: 57
Joined: 06 Jan 2006
Location: Sweden

Unread postby Mace the Councillor » 20 Nov 2006, 14:49

Thanks for the reply!
Pitsu wrote:Which "object scripts" you mean? Most of them can be defined in main map script. But combat, for example, goes into a separate file.
Towns, garrisons, heroes, monsters, dwellings and mines, I meant. Checking again, I can see that all except for heroes and mines have their own separate script tabs, but can objects without script tabs be scripted?
3. How are victory and defeat conditions (such as whether a player who has no town for a consecutive 7 days will automatically lose) managed? Is there a way to deactivate the standard victory conditions? I suspect this may somehow be done via scripting, but how.
Pitsu wrote:You can deactivate the standart win and lose (Game properties tree, under objectives). With scripts you can make any conditions to give a victory or loss.
Thanks, I found it!
Pitsu wrote:Campaign editor is officially not there (if not with HoF). Some once showed a screen of map linking tool (re-enabled by a editor modification) but dunno its functionality.
Is this a feature that can be downloaded, and if so, where?
Pitsu wrote:And finally, scripts only work on singleplayer maps.
Thanks! I didn't know that.

GOW, thanks for your reply, too!
I have downloaded your map and will check its scripts. I may have to play it first though, as maps get kind of spoiled if one looks at them in the editor, and besides, it is easier to understand scripts after one sees what they do in the game.

User avatar
Vitirr
Scout
Scout
Posts: 157
Joined: 06 Jan 2006
Contact:

Unread postby Vitirr » 20 Nov 2006, 18:55

My advice to learn with the scripts is to start making a map, a test map, and start using some basic scripts. To start adding them just open the map properties window, go to the script tab and start editing. This is some basic knowledge about how scripts work:

- Every line of code you add is executed inmediately when the map begins, except for functions (they have to be called).

- Triggers allow you to execute code when some conditions are met. The conditions are automatically checked by the script system, (I guess every trigger has a thread asociated with it that makes that work for you). That's one of the first things you have to look at the list of script functions in the editor manual.

- You can use more than one thread, (there is a specific script for that). With another thread you can do things like repetitive checks (is it the computer turn?, if not sleep(1) and ask again), whithout interfering with your main execution thread. As far as I know, triggers affect all the threads, (you can't set a new day trigger for a thread, and one different for another).

- As far as I know, variables don't have to be declared and are global by default. Just like var1 = 6;

- .. is used to concatenate strings. == is the equals check, ~= is not equal, (the relational are the ussual <, >, >=...), = is used to asign values to variables.

- A string use " or ', ("string1", 'string2').

If you have problems with the basic language, take a look at this reference manual.
Mace the Councillor wrote:Checking again, I can see that all except for heroes and mines have their own separate script tabs, but can objects without script tabs be scripted?
Every object has a name field in the object properties tree. You can use that name in your scripts, so yes, every object is subject to be used by a script.
Mace the Councillor wrote:Is this a feature that can be downloaded, and if so, where?
No, you can't download any campaign editor but I guess it will be enabled in next patches.

User avatar
Mace the Councillor
Peasant
Peasant
Posts: 57
Joined: 06 Jan 2006
Location: Sweden

Unread postby Mace the Councillor » 21 Nov 2006, 14:53

Thanks to you too, Vitirr!

After taking a look at the scripts GOW's Seize the Throne map (I gave up playing it first because, unfortunately, it lagged too much on my computer), I figured most of this out myself. However, I tried to make a script for an ambush, where a hero gets attacked for entering a region. It didn't work. "Ambush" is a region, and a function that is supposed to start a fight. It says "Function Ambush not defined, line 3." (line 3 is the one "function Ambush(heroname)") when I click the Check-button. If anyone can help me tell what I did wrong, I'd very strongly appreciate it.

Code: Select all

function Ambush(heroname)
     StartCombat(heroname, 1, 2, 10)
end;

Trigger(REGION_ENTER_WITHOUT_STOP_TRIGGER,"Ambush","Ambush");
Neither does the line (which is not inside a function, by the way)...

Code: Select all

StartCombat("Oddrema",1,2,10)
...start the fight I was hoping it would when the map opened in the game. "Oddrema" is the "Script name" found under the Settings tab in the hero's properties window.

User avatar
Vitirr
Scout
Scout
Posts: 157
Joined: 06 Jan 2006
Contact:

Unread postby Vitirr » 21 Nov 2006, 15:56

I haven't still used the start combat script so I don't know if you have used it properly, (don't you have to use nil for enemy hero if you want fight only neutrals for example?). The function not defined error is normal. It will say that for all your defined functions.

So if it doesn't work it must be something you did wrong with the start combat script.

User avatar
Pitsu
Round Table Hero
Round Table Hero
Posts: 1830
Joined: 22 Nov 2005

Unread postby Pitsu » 21 Nov 2006, 16:34

See this page of the Editor troubleshooting thread for combat scripts (makrise's post).
Avatar image credit: N Lüdimois

User avatar
Mace the Councillor
Peasant
Peasant
Posts: 57
Joined: 06 Jan 2006
Location: Sweden

Unread postby Mace the Councillor » 24 Nov 2006, 15:58

I managed to make the combat script work. "nil" had to be placed in the unused fields of the StartCombat() parameters. I should have thought about that myself. I know Java, and I shouldn't have counted on them overloading the function.

User avatar
Mace the Councillor
Peasant
Peasant
Posts: 57
Joined: 06 Jan 2006
Location: Sweden

Unread postby Mace the Councillor » 05 Dec 2006, 14:43

Does anyone know how to create abyss in the Heroes V editor? I have seen it in the game, in underground levels, and it is just a black nothingness that one cannot walk over, but I have never managed to figure out how to make it myself.

Can anybody help??

meows
Peasant
Peasant
Posts: 75
Joined: 11 Oct 2006

Unread postby meows » 15 Dec 2006, 20:34

Mace the Councillor wrote:Thanks to you too, Vitirr!

After taking a look at the scripts GOW's Seize the Throne map (I gave up playing it first because, unfortunately, it lagged too much on my computer), I figured most of this out myself. However, I tried to make a script for an ambush, where a hero gets attacked for entering a region. It didn't work. "Ambush" is a region, and a function that is supposed to start a fight. It says "Function Ambush not defined, line 3." (line 3 is the one "function Ambush(heroname)") when I click the Check-button. If anyone can help me tell what I did wrong, I'd very strongly appreciate it.

Code: Select all

function Ambush(heroname)
     StartCombat(heroname, 1, 2, 10)
end;

Trigger(REGION_ENTER_WITHOUT_STOP_TRIGGER,"Ambush","Ambush");
Neither does the line (which is not inside a function, by the way)...

Code: Select all

StartCombat("Oddrema",1,2,10)
...start the fight I was hoping it would when the map opened in the game. "Oddrema" is the "Script name" found under the Settings tab in the hero's properties window.
use this code for what you want to do.
at the top put

Code: Select all

name=GetPlayerHeroes(1); 
check_assassins=0 
check_ambush=0 
function s_2() -- further down in your code put this function
  while 1 do 
        if  IsPlayerHeroesInRegion(PLAYER_1,"assassins") and check_assassins==0 then
           BlockGame(); 
StartCombat( name[0], nil, 2, 113, 43 , 113, 55, nil, nil); -- here we have mob type 113 and there are 43 of them and mob type 113 and 55 of them
        check_assassins=1 
         LevelUpHero("Ingvar"); -- from here you can give hero stats creatures etc..
         --ChangeHeroStat("Ingvar", 0, 6000); -- decided he was not worthy of more experence
         ChangeHeroStat("Ingvar", 1, 6); -- upgraded attack to help next fight
         ChangeHeroStat("Ingvar", 2, 7); -- upgraded defence to prevent loseing next fight
         UnblockGame(); 
MessageBox ("Maps/SingleMissions/Ashers World one/training3.txt"); this code from my Ashers World series..
           break; 
    else sleep(1) need this incase the code breaks for any reason.

     end;      
   end; 
end; 
GOW's Seize the Throne map has helped me immensely as have Pitsu's and others


Return to “Mapmaking Guild”

Who is online

Users browsing this forum: No registered users and 9 guests