Heroes 4 Advanced Options Map Editor

The old Heroes games developed by New World Computing. Please specify which game you are referring to in your post.
User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 773
Joined: 21 Jul 2014

Re: Heroes 4 Map Generator / Utility

Unread postby iLiVeInAbOx05 » 29 Apr 2016, 02:07

Okay, so here are a couple screens showing the event and script displays. I've added an "Edit" option to the event tables like so:

Image

Navigate to the script tab and voila, we have the scripts in a tree view. We can collapse or expand as needed (all scripts are expanded by default).

Image

By clicking the "Hide All" button, we can collapse all scripts down to open only the path that we wish to see. This can be helpful for a script with lots of conditionals and conditionals within conditionals.

Image

To manually expand a node, simply click the little expand icon next to the script info.

Image

As I said before, with the tree view, there's no more need to open several scripts before you finally get to the one you want to edit, you simply go right to it :)

All for now :)

User avatar
Baronus
Assassin
Assassin
Posts: 288
Joined: 06 Jun 2015

Re: Heroes 4 Map Generator / Utility

Unread postby Baronus » 30 Apr 2016, 09:50

Script tree? Good idea! Now all looks cleary. Thats it what we need.

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 773
Joined: 21 Jul 2014

Re: Heroes 4 Map Generator / Utility

Unread postby iLiVeInAbOx05 » 07 May 2016, 05:39

Glad you like it Baronus :)

Update:
I've added the ability to view castle objects and their scripts, and the triggered / completion scripts for quest objects.

I've also done some work with editing heroes: Can change the class, gender, portrait, name, and bio. That took some work, since I had to record the code for each hero. I want to get the skills setup so we don't have to use the H4 editor "trick" to give any hero type any starting skill.

I think I want to finish getting viewers setup for the other garrison objects (garrisons and mines), and then I'll get started on an area selection tool (select and copy/paste parts of a map)

User avatar
Duzeom_
Conscript
Conscript
Posts: 235
Joined: 07 Mar 2011

Re: Heroes 4 Map Generator / Utility

Unread postby Duzeom_ » 07 May 2016, 10:41

The scripting tree is something which everyone wanted, I presume. When will be a release?

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 773
Joined: 21 Jul 2014

Re: Heroes 4 Map Generator / Utility

Unread postby iLiVeInAbOx05 » 07 May 2016, 17:41

Hi Duzeom.

The scripting tree is something I decided to do because, as you said in the Megom thread, clicking around is such a waste of time. Hopefully others will find this feature useful as well :)

What kind of ideas were you thinking as far as editing scripts? For some of the simple ones I was thinking about keeping them as they are in the editor (such as increase / decrease), but for the more complicated ones, such as the conditional, I'm not sure how I want them to be edited.

For conditionals, it's annoying to have to plan out the logic before you start scripting it. Make one mistake in the ordering and you have to back out and redo it, so I'm trying to think of a way to make that easier and not require things to be scripted in order. I was thinking about making it kind of code oriented, but that might take some time to design and implement. Maybe it wouldn't be too bad though..

Unfortunately the scripting feature is not very far along. Right now I can only edit combat scripts (since I wanted to try putting a hero on it), so there is a lot more work to be done (setting up viewers for different script types).

Right now you can open an existing .h4c map or create a new one, copy / paste events between maps and objects, save / load events and quest huts to / from file (which you can copy to your map and objects), paint terrain with various brush sizes (including a really large size good for high level map design), paint "void" terrain anywhere, and edit some properties on objects (army, hero, castle, etc.).

If you would find any of that useful right now, I can send you the current version of the H4MG, but an actual release is still a little ways away. I guess I could remove the things that currently aren't implemented and release that, and then just release more features as things progress :)

User avatar
Duzeom_
Conscript
Conscript
Posts: 235
Joined: 07 Mar 2011

Re: Heroes 4 Map Generator / Utility

Unread postby Duzeom_ » 08 May 2016, 20:17

iLiVeInAbOx05 wrote: For conditionals, it's annoying to have to plan out the logic before you start scripting it. Make one mistake in the ordering and you have to back out and redo it, so I'm trying to think of a way to make that easier and not require things to be scripted in order. I was thinking about making it kind of code oriented, but that might take some time to design and implement. Maybe it wouldn't be too bad though..

Unfortunately the scripting feature is not very far along. Right now I can only edit combat scripts (since I wanted to try putting a hero on it), so there is a lot more work to be done (setting up viewers for different script types).

Right now you can open an existing .h4c map or create a new one, copy / paste events between maps and objects, save / load events and quest huts to / from file (which you can copy to your map and objects), paint terrain with various brush sizes (including a really large size good for high level map design), paint "void" terrain anywhere, and edit some properties on objects (army, hero, castle, etc.).
It is pain in the ass if you want to change the conditional. So maybe some drag and drop? If you have implemented copying piece of script somewhere else, which is great functionality and I could just use it immediately, this shouldn't be very difficult, does it? I think all scripts should be implicitly in sequence script and they should draggable in that way:

conditional {
conditional clause
} then {
sequence { <-- drag it from here
...
}
} else {
... <-- to here for example
}

I used to make lot of event inside custom heroes as triggerable events because of lack of ability to copy placed events through different maps. I also had to make a first map of my last campaign a not part of the story because I made all scripts in carryover hero and I needed a dummy map in the beginning to have a carryover hero in the second ;p.

What is void terrain?

I could use a functionality which paints whole land with given terrain eg. dirt.

Are you implementing it in java? If yes, then maybe I could help a bit.

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 773
Joined: 21 Jul 2014

Re: Heroes 4 Map Generator / Utility

Unread postby iLiVeInAbOx05 » 08 May 2016, 21:10

Duzeom_ wrote:It is pain in the ass if you want to change the conditional. So maybe some drag and drop? If you have implemented copying piece of script somewhere else, which is great functionality and I could just use it immediately, this shouldn't be very difficult, does it? I think all scripts should be implicitly in sequence script and they should draggable in that way:

conditional {
conditional clause
} then {
sequence { <-- drag it from here
...
}
} else {
... <-- to here for example
}
Ah, I meant when scripting the conditional requirement, such as: If count == 0 AND (total number of creatures in army < 1 OR hero is dead)

If the requirements were entered in the wrong order (the parentheses above), then you have to pretty much redo the logic. I was thinking about coming up with some way to make entering and adjusting this logic in a better way, but so far I haven't come up with anything.

As far as dragging and dropping scripts within an event, that will definitely be a feature as you described. Being able to drag a script into or out of a conditional (or sequence or any other nested script) would be extremely useful.

The only problem is that java's JTree doesn't have any native support for drag and drop, so I'm going to have to create that from scratch :)
Duzeom_ wrote:I used to make lot of event inside custom heroes as triggerable events because of lack of ability to copy placed events through different maps. I also had to make a first map of my last campaign a not part of the story because I made all scripts in carryover hero and I needed a dummy map in the beginning to have a carryover hero in the second ;p.
Haha I ran into that when going from my second to third map and had to recreate all of my scripting on a carryover hero. I didn't even think about hiding a carryover hero on my first map, that would have certainly saved me some time.

Fortunately, with this tool we won't have to do things like that anymore, since we can copy / paste events between heroes :)
Duzeom_ wrote:What is void terrain?
Void terrain is the pure black terrain that you get when you paint cave or stone. With this tool we can put that black terrain wherever we want, and without the stone / cave boundaries.
Duzeom_ wrote:I could use a functionality which paints whole land with given terrain eg. dirt.
You can easily do that with this tool :) Just set the "brush size" to ludicrous, select your terrain type, and you can paint an XL map in a of couple seconds :)
Duzeom_ wrote:Are you implementing it in java? If yes, then maybe I could help a bit.
I sure am. I'll take a look and see what I could use some help with. Right now I'm still creating the various viewers. I still have garrisons and mines to replicate, and then the various script viewers, along with editing abilities.

After I get through those, I could probably use some help with some of the random generation algorithms, mostly the design, such as zones and what can potentially go where, etc.

Right now, I could use some non-java help coming up with ideas for editing the conditional logic requirements (AND, OR, NOT, etc.). The way the H4 editor handles editing conditional requirements is time consuming and can be unforgiving if you make any mistakes, so I'd like to create an alternative that's more user friendly :)

Just to be completely clear, here are a couple screen shots of what I'm talking about.

Image

And then if I select the top edit button to edit the If condition.

Image

If you have any amount of AND's, OR's, or NOT's, it can be extremely annoying if you have to change the logic, not to mention that you have to enter it in the correct order, which can sometimes be difficult if you have somewhat complex logic to deal with.

User avatar
Duzeom_
Conscript
Conscript
Posts: 235
Joined: 07 Mar 2011

Re: Heroes 4 Map Generator / Utility

Unread postby Duzeom_ » 08 May 2016, 21:26

You could write a parser for a user scripting:
AND, OR, NOT, FALSE, TRUE, () <- function
then user could write a conditional like that:
IF ( (func1) AND (func2 OR NOT (func3)) )

func1: hero level >= 4
func2 hero colour == blue
func3: day >= 10

I could write a random map generator engine. I was doing some research about it. You can find my topic about rmg long time ago. The main problem with it that I don't have a lot of spare time, so I could tweak something or write a little functionality. If I had a lot of time I would started writing rmg myself... but life's brutal ;)

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 773
Joined: 21 Jul 2014

Re: Heroes 4 Map Generator / Utility

Unread postby iLiVeInAbOx05 » 08 May 2016, 23:07

Duzeom_ wrote:You could write a parser for a user scripting:
AND, OR, NOT, FALSE, TRUE, () <- function
then user could write a conditional like that:
IF ( (func1) AND (func2 OR NOT (func3)) )

func1: hero level >= 4
func2 hero colour == blue
func3: day >= 10
I do have a conditional script parser, but right now it parses by number of scripts, rather than by logical operator (AND, OR, NOT) which would be a better solution. The way the logical scripts are coded in the .h4c files is a little different than you would expect (I think it's in a stack form, and I can't remember the name of this method of encoding, but it's an older well known method).

So, how do you propose the user actually be able to enter scripts in this manner? Do they select from the normal list of scripts, and if they choose a logical operator (AND for example) we put the AND in and put two placeholders for the user to fill in?

What about some sort of add / remove button functionality for the conditional logic?
Duzeom_ wrote:I could write a random map generator engine. I was doing some research about it. You can find my topic about rmg long time ago. The main problem with it that I don't have a lot of spare time, so I could tweak something or write a little functionality. If I had a lot of time I would started writing rmg myself... but life's brutal ;)
I read through it and a lot of what I'm working on currently came from suggestions in that thread :) So that made this project more of a mix between utility (advanced options editor) and RMG.

As far as knowing how to read .h4c files, I've documented almost everything in detail in a google doc, which is linked on the first page of this thread. The only thing I have left out is how to read each of the scripts and a few objects (it's documented in the code itself, but I haven't gone back and put it into words).

Life always gets in the way! I've been lucky that I don't have too many things getting in the way outside of work :)

User avatar
Duzeom_
Conscript
Conscript
Posts: 235
Joined: 07 Mar 2011

Re: Heroes 4 Map Generator / Utility

Unread postby Duzeom_ » 09 May 2016, 19:04

If you have a sort of library which reads data from h4c files I could use it to make rmg simultaneously with your code. And as I can see you have a way to display the map. I think you done a tremendous work :)

The conditional could be written as separate tree where every node is operation and every leaf is a clause:

AND
/ \
OR c3
/ \
c1 c2

Probably it is the way it is written in h4c file because every operation is binary operation - takes two arguments (from the tree you can create other notation like polish notations etc.).
It is nice to represent a conditional but it is not pragmatic because you probably will want to write something like that:
c1 AND c2 AND c3 AND c4 AND c5 AND ...

So my proposition is that:
You can specify a operand (AND/OR/"("/NOT) and clause alternately:
c1 OP c2 OP c3 OP c4
The issue is that how to define a clause outside of a conditional.
I don't know how the clauses are written in h4 files.

Then such a chain of operands and clause you can represent as a tree, and then write to h4c file.

I don't know if anything helps you from this, but if you could write something how scripts are written in h4c file maybe I could think something more useful.

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 773
Joined: 21 Jul 2014

Re: Heroes 4 Map Generator / Utility

Unread postby iLiVeInAbOx05 » 10 May 2016, 05:01

Duzeom_ wrote:If you have a sort of library which reads data from h4c files I could use it to make rmg simultaneously with your code. And as I can see you have a way to display the map. I think you done a tremendous work :)
Thank you :)

I do have reusable libraries for reading in .h4c files, but they're not quite complete yet, and there are still some bugs lurking (found one when trying to open Megom Chronicles: MC that I haven't looked into fixing just yet). And the elevation just reads in the bytes and doesn't have an interface yet to manipulate it. Oh, and I haven't figured out what specifies passability. There's no passable specific stuff, so it's probably buried where each adventure / landscape object is encoded and I'll need to figure out some sort of interface for that.

I would prefer if the RMG stuff would be part of the H4MG (specifically I'm thinking about removing the "Map" tab and including those options in a separate frame which is triggered when the user selects File -> New Random Map (or possibly just under the frame that pops up when the user selects File -> New).

If you're alright with that, I'd be happy to discuss the RMG stuff in detail and get the ideas for options, etc. hashed out and send you the code. If you'd prefer to create your own thing, I'll still send you the source code, but I'll still work on getting RMG functionality built into the H4MG.
Duzeom_ wrote:The conditional could be written as separate tree where every node is operation and every leaf is a clause:

AND
/ \
OR c3
/ \
c1 c2

Probably it is the way it is written in h4c file because every operation is binary operation - takes two arguments (from the tree you can create other notation like polish notations etc.).
It is nice to represent a conditional but it is not pragmatic because you probably will want to write something like that:
c1 AND c2 AND c3 AND c4 AND c5 AND ...

So my proposition is that:
You can specify a operand (AND/OR/"("/NOT) and clause alternately:
c1 OP c2 OP c3 OP c4
The issue is that how to define a clause outside of a conditional.
I don't know how the clauses are written in h4 files.

Then such a chain of operands and clause you can represent as a tree, and then write to h4c file.

I don't know if anything helps you from this, but if you could write something how scripts are written in h4c file maybe I could think something more useful.
Polish Notation! That's what it was called! It appears that the logical operators, as well as the mathematical operators, are encoded using Polish Notation, which I believe is stack like in nature (unless I've forgotten), so shouldn't be difficult to parse / encode. Just have to code the algorithm :) I'll have to play around with some hex editing again with various AND's, OR's, and EQUALS with various conditions to verify, but I'm pretty sure that's what they're using.

I thought about the tree as well, but then as you said, it would be difficult to write several AND's. Maybe the tree is still okay, and the user could add another AND at the same level as another, and could be prompted to use another logical operator to connect them? For example:

Code: Select all

-AND
    -c1
    -OR
        -c2
        -c3
Then, the user selects another AND to add at the top level, and is prompted to choose a connecting logical operator (AND, OR) and the tree is updated to the following:

Code: Select all

-AND (connector)
    -AND
        -c1
        -OR
            -c2
            -c3
    -AND (selected AND)
        -c4
        -c5
That way might be a little complicated, and we still can't do c1 AND c2 AND c3 AND c4..

Maybe (going back to my last post), we can allow the user to select a script like normal. If they choose an AND, they get FALSE AND FALSE, where the user can select either FALSE and choose either a script, or logical operator, or they can select another script and be prompted for a connector? So if they choose an OR connector, we get the following:

FALSE AND FALSE OR FALSE

We would need an easy way to add parentheses to correctly group the logic, but that might be a reasonable way to do things. I think the above is kind of what you were saying at the end of your post. Of course, Java doesn't have a nice built-in construct that I know of for this example, haha :)

What do you think? I like the idea of prompting the user for a connector so that they aren't limited in adding conditional requirements, and it would solve the issue of creating a condition outside of the current logical operators.

How it's represented in the file isn't too important because we can write an interface that knows how to convert between our way of viewing / editing the condition to the way that the editor and game understand, so don't worry about ideas of how to view / edit the conditional requirement not fitting the way the game does things. I think we're getting close to a nice and user-friendly way to view / edit the condition :)

User avatar
Duzeom_
Conscript
Conscript
Posts: 235
Joined: 07 Mar 2011

Re: Heroes 4 Map Generator / Utility

Unread postby Duzeom_ » 12 May 2016, 18:21

For what H4MG stands for? I'm just curious ;)

RMG tool can be developed separately without GUI. Someone could do a "View" from MVC model afterwards and merge to H4MG.

You can create a tree with n children so that:

Code: Select all

AND:
	-c1
	-c2
	-c3
	OR
		-c4
		-c5
Which translates to c1 AND c2 AND c3 AND (c4 OR c5).
Such a tree you can easily parse with recursive algorithm.
I think the editor gives the most power because you can copy part of the script somewhere else. The representation could be different, but the most flexible notation is just code-like. I am used to coding so it is easy for me. I'm wondering if no-programmers could use that, and I think that yes indeed.
The other problem is to how to specify clauses? Maybe just a sequence of clauses and then just indexes - eg c4 means a 4th clause from the given sequence.

The other way, which can be simpler but less flexible is to have a window in which on the start you have nothing and there is two buttons: let's call it "divide" and "add".
So "divide" will split every clause into two clauses with choosable (from a chooser or other UI element) operation.
"Add" button adds new clause with also choosable operation. For example:
1. We have nothing so we can only divide with operation eg AND:
[] -divide-> [[] AND []]
2. we can divide further the first clause:
[[] AND []] -divide-> [[[] OR []] AND []]
3. we can add statements to the selected clauses:
[[[] OR []] AND []] -add-> [[[] OR [] OR []] AND []] -add-> [[[] OR [] OR []] AND []] AND []

There are also NOT statements but should be easily incorporated by the third button "negation"
4. negate all ORs:
[[[] OR [] OR []] AND []] AND [] -negate-> [NOT[[] OR [] OR []] AND []] AND []

User avatar
Karmakeld
CH Staff
CH Staff
Posts: 1126
Joined: 12 Nov 2011

Re: Heroes 4 Map Generator / Utility

Unread postby Karmakeld » 12 May 2016, 21:31

Leave it to us 'common' people to test and comment on the user-friendliness for non programmers ;) of course this would require an actual setup and not just the theory of it. You start loosing me on those parts.
I'm silent in seven languages - and I got all my familys fear.
Everytime you throw dirt, you loose a little ground

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 773
Joined: 21 Jul 2014

Re: Heroes 4 Map Generator / Utility

Unread postby iLiVeInAbOx05 » 13 May 2016, 16:13

Fear not, there won't be any actual typing involved (there would be too much event handling and too many cases to check). You will still need to select the script type you want to add.

I'm leaning toward my description at the end of my last post. Putting the requirements in a java Tree might be slightly confusing due to the orientation, so I'll probably try to stick to something that's visually linear (left to right).

Oh, and H4MG just stands for Heroes 4 Map Generator. It was going to be H4RMG, but it's already more than just a random map generator. Probably still needs a better name :)

Some good things to think about from your post Duzeom.

User avatar
Karmakeld
CH Staff
CH Staff
Posts: 1126
Joined: 12 Nov 2011

Re: Heroes 4 Map Generator / Utility

Unread postby Karmakeld » 14 May 2016, 20:07

Just a quick note, from my short test of it, you should add the Rock Terrain Tool. Minor detail, but that seems to be lacking atm.
I successfully created a new map using the H4MG, and got no problems loading and saving new edits between the MG and the editor. The colums also fits nicely, although the small brush paints Tetris blocks instead of a single 1x1 tile, and as you mentioned, it completely square. So perhaps add an 'extra small' 1x1 brush? Creating a new map, it reads in the editable objects I've placed, as well as a quest hut name perfectly.
I'm silent in seven languages - and I got all my familys fear.
Everytime you throw dirt, you loose a little ground

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 773
Joined: 21 Jul 2014

Re: Heroes 4 Map Generator / Utility

Unread postby iLiVeInAbOx05 » 15 May 2016, 05:35

The rock terrain tool might be a little tough (or might just take some time) because I have to also place the rock / cave objects on the boundaries. I can certainly come up with an algorithm to go around the rock / terrain boundary and place the rock / cave object, I'll just have to map the boundary faces to the correct object faces.

As far as the brushes and sizes of the brushes, I plan to add a square brush that is oriented the way the terrain brush in the editor is :)

Also, I fixed a couple more bugs causing me to be unable to load certain maps in the H4MG. I happened to have missed a couple scripts and had another bug where I was using an incorrect index.

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 773
Joined: 21 Jul 2014

Re: Heroes 4 Map Generator / Utility

Unread postby iLiVeInAbOx05 » 22 May 2016, 06:47

Update: I believe I have viewers for all objects with events, as well as the ability to copy events between them. I also have support for editing some of the other major fields for the objects (such as name fields).

I do kind of want to redo the way I handled copying and pasting events, since I implemented my own way, rather than using the Clipboard (forgot to check for java support of the Clipboard, and they do have support for it). It would clean up quite a bit of code, but I may wait until later to switch it up.

As far as scripting features Something else I thought of that would be quite nice has to do with calling a custom triggered event from another event. It would be really convenient if we could open up that custom event to view / edit from the event we are currently looking at, rather than having to go back into the events to find it and open it. I'm thinking I'll probably add an edit button to the "Trigger Custom Event" panel which will open up an event edit frame for the custom triggered event which defaults to the script panel.

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 773
Joined: 21 Jul 2014

Re: Heroes 4 Map Generator / Utility

Unread postby iLiVeInAbOx05 » 31 May 2016, 21:12

Update: I have implemented the ability to view and edit most scripts. I have also implemented the ability to "step into" and view / edit custom events from a separate event. Here are some screen shots to illustrate what I'm talking about.

First, open up a map that has event scripting which calls a custom event via the "Trigger custom event" script. Then navigate to an event which has one of these scripts in it.

Image

View the event (by double clicking it) and select the "Trigger custom event" script.

Image

Open it (by double clicking) and you will see the following:

Image

I've added a button "Edit Event". Clicking it will open up an Event Properties dialogue for the selected custom event and default to the "Script" tab.

Image

No more hunting around to find a custom event when you're trying to trace your events to debug or see how another map maker did his/her scripting, simply open it from the event you are looking at :)

I'm likely going to add a context menu so that right clicking on a "Trigger custom event" script in the script viewer will give you the option to go to the custom event so that we don't have to open the script dialogue first (fewer clicks).

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 773
Joined: 21 Jul 2014

Re: Heroes 4 Map Generator / Utility

Unread postby iLiVeInAbOx05 » 01 Jun 2016, 00:57

Another update: I've begun copying and pasting scripts between events! We can also copy and paste scripts to the same event. I'll probably work on adding new scripts and changing the type of other scripts next. Then I'll look at moving scripts by dragging them (and allow scripts to be moved into or out of other scripts, such as a conditional).

Then the area selection tool, although I think before that I may update my old copy / paste implementation to use the system clipboard, which is significantly easier and better than what I initially implemented. In fact, I may do that first..

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 773
Joined: 21 Jul 2014

Re: Heroes 4 Map Generator / Utility

Unread postby iLiVeInAbOx05 » 01 Jun 2016, 05:00

Okay, I fixed the copy / paste implementation to use the system clipboard, which cleaned up a LOT of code, besides being the correct way to do things. It will be a simple thing to implement copying / pasting of pretty much anything else useful now that I know how to use the clipboard :)


Return to “Heroes I-IV”

Who is online

Users browsing this forum: No registered users and 15 guests