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 » 23 Apr 2016, 03:31

Okay, so before I can easily try to put a hero on a combat script, I need to actually be able to view scripts in the H4MG, so that's currently what I'm working on. I'm probably going to use a Tree View to show the scripts (like a file system where you can expand and collapse nodes) and eventually add options to copy and paste individual scripts, as well as the ability to move scripts in and out of conditionals / ask.

Are there any suggestions on a better way to show / add scripts than what is currently in the editor? Meaning, if you could change the editor where scripting is concerned, what would you like to see, if anything?

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

Re: Heroes 4 Map Generator / Utility

Unread postby Karmakeld » 23 Apr 2016, 11:40

I think it would be a good and reasonable solution to display scripts similar to the editor, as it might make it easier to maneuver around, if the RMG and the editor look alike with a similar setup/display. So no better suggestion from my side. I still gotta test it, though before I can give you proper feedback.
But I actually intended to ask if you'd make an option to copy/paste individual scripts within a script aswell, but you just gave that away :)
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 » 23 Apr 2016, 20:24

I think a tree view of the scripts will be a lot better than what is in the H4 editor. I'm thinking the tree will start completely expanded so that you can see all scripts, and then you can click the minus to hide scripts under conditionals and other scripts that contain scripts.

It looks like I'm going to have to create my own custom behavior, with some help from google, for dragging and moving scripts around inside of the tree.

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

Re: Heroes 4 Map Generator / Utility

Unread postby iLiVeInAbOx05 » 24 Apr 2016, 20:50

Got scripts displayed in tree form, with some minor things I still need to fix as far as what is displayed on some script nodes.

The tree view has the following advantages over the H4 editor way: 1) If you have a lot of nested scripts (scripts inside of scripts), you don't have to open a million windows to finally reach the script you're looking for, you can scroll right to it. 2) The H4 Editor bug that doesn't allow you to see all nested scripts is fixed by default.

I also added buttons to show or hide all scripts.

And now the sad news: I was able to put a hero on a triggered combat script, BUT, the game doesn't recognize the hero and only the creature will show up in the actual combat :( I tried removing the creature so only the hero was present, but that just resulted in a battle against no enemies :( No crash, but no workie either :(

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

Re: Heroes 4 Map Generator / Utility

Unread postby Baronus » 25 Apr 2016, 08:02

I think the best is a pack of typical scripts to choice and people who cant write scripts will change only numbers. Eg. give AI 1000 gold a day. They can change to 2000.

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

Re: Heroes 4 Map Generator / Utility

Unread postby iLiVeInAbOx05 » 25 Apr 2016, 14:10

Well, as far as the AI scripting is concerned, the user will probably be able to set custom values, such as the amount of gold to give the AI per turn (or per week), or they can just use the default values. There should be no need, at least in this particular case, for someone to actually have to go into a script and edit it :)

As far as other types of scripts, I agree. I'll be including a lot of the scripts that I use, most of which don't require any editing, but some will require the name of the hero to be changed to the hero it will apply to. In that case, I'm going to add functionality to the H4MG that will simply let the user change the name, and then the H4MG will change the name everywhere needed in the script.

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

Re: Heroes 4 Map Generator / Utility

Unread postby Karmakeld » 26 Apr 2016, 16:47

Perhaps the Equilibris team might be able to find a way to include a hero in a triggered Battle?
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 » 26 Apr 2016, 18:19

That would certainly be nice :)

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 []


Return to “Heroes I-IV”

Who is online

Users browsing this forum: No registered users and 21 guests