Heroes of Might and Magic Community
visiting hero! Register | Today's Posts | Games | Search! | FAQ/Rules | AvatarList | MemberList | Profile


Age of Heroes Headlines:  
5 Oct 2016: Heroes VII development comes to an end.. - read more
6 Aug 2016: Troubled Heroes VII Expansion Release - read more
26 Apr 2016: Heroes VII XPack - Trial by Fire - Coming out in June! - read more
17 Apr 2016: Global Alternative Creatures MOD for H7 after 1.8 Patch! - read more
7 Mar 2016: Romero launches a Piano Sonata Album Kickstarter! - read more
19 Feb 2016: Heroes 5.5 RC6, Heroes VII patch 1.7 are out! - read more
13 Jan 2016: Horn of the Abyss 1.4 Available for Download! - read more
17 Dec 2015: Heroes 5.5 update, 1.6 out for H7 - read more
23 Nov 2015: H7 1.4 & 1.5 patches Released - read more
31 Oct 2015: First H7 patches are out, End of DoC development - read more
5 Oct 2016: Heroes VII development comes to an end.. - read more
[X] Remove Ads
LOGIN:     Username:     Password:         [ Register ]
New Server | HOMM1: info forum | HOMM2: info forum | HOMM3: info forum | HOMM4: info forum | HOMM5: info forum | MMH6: wiki forum | MMH7: wiki forum
Heroes Community > Heroes 4 - Lands of Axeoth > Thread: H4ResourceEditor
Thread: H4ResourceEditor This thread is 5 pages long: 1 2 3 4 5 · NEXT»
iliveinabox05
iliveinabox05


Adventuring Hero
posted February 13, 2018 09:14 PM
Edited by iliveinabox05 at 02:50, 13 Apr 2018.

H4ResourceEditor

Unless / Until Namerutan returns, I will be working on a tool similar to the one he put out for testing to help with modding.

What will this tool be used for? It will be for viewing and editing Heroes 4 resource and def files.

In no particular order:

1) Ability to view and edit passability and Entrance information (currently working).

2) Modify and / or replace images for objects.

3) Export individual objects, including the campaign maps (Currently working).

4) Create objects from scratch.

5) Pack h4r files.

6) Enable easy editing of the flag location for flaggable objects and various other fields.

If you have additional thoughts, please let me know!

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Baronus
Baronus


Supreme Hero
posted February 13, 2018 11:43 PM

Great news! Go ahead! Nothnig cant stop you!

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
iliveinabox05
iliveinabox05


Adventuring Hero
posted February 18, 2018 08:29 AM
Edited by iliveinabox05 at 17:58, 18 Feb 2018.

As I was typing this out it became apparent that the following procedure to look through hex files to aid me with parsing the image info by hand is not really feasible, but I'll go ahead and post it here anyway. I'll do my best to see about printing the offsets of each of the data below with my resource editor to make it so others can actually take a look and try to help out.


In the image below, the 1a 00 indicates that there are 26 images to follow. Each image starts with its color palette, which starts out with a Short (2 bytes) which indicates the number of colors to follow. This is usually 00 01, which is 256 in decimal. Next is another Short (2 bytes) giving the location of the first non-transparent color index. After that come the colors, 3 bytes each for blue, green, and red values.

To skip the color palette, simply jump ahead by 772 bytes (4 bytes + 768 for the colors) from the start of the color palette.



That will get you to the next screen shot below.



Now you have a Short (2 bytes) telling you the length of the image name to follow, and then that many bytes for the image name. After the image name is 1 byte for the blending mode. Next are 4 Ints (4 bytes each for a total of 16 bytes). The first is for the starting x value, then the starting y value, then the end x value, and finally the end y value of the image.

Now we are getting to the data portion. Next are the line offsets, which are 8 bytes each. To figure out how many there are, you need the height of the image, which can be found by taking endY - startY from above. The first 2 bytes indicate the starting x value for the line, and the next 2 bytes indicate the ending x value for the line. The next 4 bytes represent the offset into the data.

Move forward that number of bytes and you are at the pixel data values. As was the case with the line offsets, there will be image height entries, but each entry is variable and depends on the corresponding line offset. For example, lets say the first line offset above had a starting x of 10, and an ending x of 20. Then the first pixel data entry line would be 20 - 10 = 10 bytes long. For the second pixel data line, you look at the second line offset starting and ending x values and so on.

Now, if the blending mode byte above is 4, then there is an alpha channel. To determine the length of the alpha channel, it is half of the length of the pixel data. So, if you added up the bytes for all of the pixel data lines above, divide that number by 2. According to Namerutan, the way the game does it is: (pixel data length + 1) / 2

This is integer division, so the result is rounded down.

Finally, we are at the acceleration mask. If the color palette's first non transparent index is not equal to 0, then there is an acceleration mask. The data length here is calculated by: (pixel data length + 131) / 128

Still integer division, and the 131 is likely a bug in the game engine, but that's apparently how it is calculated.

Somewhere there is a bad calculation that is putting my program off by 1 to 2 bytes, which means reading the next image will fail.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Baronus
Baronus


Supreme Hero
posted February 19, 2018 07:53 AM
Edited by Baronus at 07:54, 19 Feb 2018.

Baronus

Those columns are line by line picture pixel index.
One is lenght eg
12 means that first line is 12
25 menans that second line is 13 and total 25
Etc  to end of picture.
Second line is info where line starts one can start 5 from border second 10.
So all image is only cutted shape from rectangle.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
iliveinabox05
iliveinabox05


Adventuring Hero
posted March 16, 2018 05:06 PM

I've put handling of the image data aside for the moment.

Currently I'm looking at editing the passability and interactivity information. With Namerutan's documentation, I understand how these are parsed from the file, and I am working on creating a visual of the passability info, which will be editable.

After that I will work on being able to view and edit the interactivity data.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Baronus
Baronus


Supreme Hero
posted March 17, 2018 05:13 PM

Yes with help old tools docs will be faster. Do it in mode which be easier.
It mustnt be one tool. If will be easier may be 5 for various kinds of defs.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Karmakeld
Karmakeld


Famous Hero
posted March 18, 2018 04:21 PM

Are you so far in reading the passability info, that you will be able to display how changing any passability info will affect the object??
More specifically I'm asking about 'unused' passability which isn't already found within any of the original objects - it's possible to edit the passability in ways none of game objects appears in, but knowing how each byte and number effects it would be priceless.
____________

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
iliveinabox05
iliveinabox05


Adventuring Hero
posted March 18, 2018 06:53 PM
Edited by iliveinabox05 at 18:58, 18 Mar 2018.

I can display passability right now. I'm just working on getting the footprint centered on the panel.

Soon I'll be able to completely test Namerutan's documentation on how to read passability, but I did check against a sawmill (2 rows by 3 columns) and I do get the correct passability of 6 not passable tiles.

After that I'll test actually modifying the passability. Should allow us to make some nifty objects that you can pass through Also, we should be able to create landscape objects like grass that's not passable so we don't have to hide non-passable objects to get the effect we're looking for

Edit. Sorry, forgot to specifically answer your question Michael: yes I can actually display the passability in a grid format and will post an image soon of what that looks like. I haven't yet tested against an object that doesn't have the entire footprint as not passable, but it shouldn't be any different than what I'm already doing.

The footprint width and height should encompass a full rectangle, including areas that are passable, and the bits I'm reading in will reflect that.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
iliveinabox05
iliveinabox05


Adventuring Hero
posted March 18, 2018 07:25 PM
Edited by iliveinabox05 at 23:32, 18 Mar 2018.

Got it centered. Now time to actually apply the passability data to select the correct color to display



Apparently I have to edit my last post, rather than making a new post for the new info I'm going to share.

Anyway, the passability bits are actually read down each column, rather than row. For example, read row 0 column 0, then row 1 column 0, and so on.

After fixing that, here are a couple images of adv-object.mountains.Grass04.h4d





So it looks like I'm correctly parsing the passability data.

Next up, editing the passability data

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
kkfkkkfk
kkfkkkfk


Hired Hero
Nothing is impossible
posted March 19, 2018 05:47 AM

Good idea.Look forward to your work.
Hope that the final tools can support Chinese language.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
iliveinabox05
iliveinabox05


Adventuring Hero
posted March 19, 2018 04:40 PM

While I have not used it, Java does seem to have support for different languages, including Chinese. Once this tool is in a releasable state, I'll look into how to use Java's language support

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
kkfkkkfk
kkfkkkfk


Hired Hero
Nothing is impossible
posted March 19, 2018 05:08 PM

iliveinabox05 said:
While I have not used it, Java does seem to have support for different languages, including Chinese. Once this tool is in a releasable state, I'll look into how to use Java's language support


I have a little understanding of JAVA
It does support,But need to pay attention to the font.
Many fonts can't represent Chinese,such as Arial.
Tahoma will be a good choice at this time.
I suggest setting up a separate resource package for text.(utf-8)
Rather than  mixing with instructions.
So it will be a better application.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
iliveinabox05
iliveinabox05


Adventuring Hero
posted March 19, 2018 05:29 PM

Right, I'll get to that once things are working and relatively bug free.

Looks like Java has some notes on Internationalization, so I'll go there and read up on the approaches they recommend and the type of support they already have when the time comes

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Karmakeld
Karmakeld


Famous Hero
posted March 19, 2018 06:26 PM

iliveinabox05 said:

After that I'll test actually modifying the passability. Should allow us to make some nifty objects that you can pass through Also, we should be able to create landscape objects like grass that's not passable so we don't have to hide non-passable objects to get the effect we're looking for



Just want to add that Equilibris did in fact modify the event object to a blocked 1x1 tile objects that isn't visible on the map in their 3.55 version. But it's great to visually see your progress

A question came to mind, as Radmutant and I have occasionally encountered some off centered issues when making new objects - you could say there are 2 categories of uncentered, 1 where the image is not centered on the grid, the other where passability info isn't centered on the object.
Is this issue something you recon your tool would be able to handle/solve? I guess it would mean editing image positions/knowing how they match up.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
iliveinabox05
iliveinabox05


Adventuring Hero
posted March 19, 2018 07:03 PM

Karmakeld said:
Just want to add that Equilibris did in fact modify the event object to a blocked 1x1 tile objects that isn't visible on the map in their 3.55 version. But it's great to visually see your progress

A question came to mind, as Radmutant and I have occasionally encountered some off centered issues when making new objects - you could say there are 2 categories of uncentered, 1 where the image is not centered on the grid, the other where passability info isn't centered on the object.
Is this issue something you recon your tool would be able to handle/solve? I guess it would mean editing image positions/knowing how they match up.


I recall seeing something about that, but now no one will have to wait for a release and we can create our own

As far as being uncentered and what this tool should be able to do, it's all up to being able to figure out what I have wrong with my calculation of the image data length.

Each image layer in an object has an x and y offset, so it would be a pretty simple thing to make those offsets editable and show you on screen what it looks like after you move the image layer.

Like I said though, that is all dependent on first getting my program to correctly parse each of the image layers in an object and then get them into a Java construct for viewing.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
iliveinabox05
iliveinabox05


Adventuring Hero
posted March 20, 2018 05:18 PM
Edited by iliveinabox05 at 17:20, 21 Mar 2018.

So I'm currently thinking about what the process should be for editing the passability info.

One way would be to have an "Edit" button to enable editing, then you could just click a grid square to flip its passability (passable to not passable or not passable to passable).

A second way would be to have context menus, so if you right click on a grid square, a drop down menu with options would display with an option like "Change Passability". Selecting the option would flip the passability.

This would remove the necessity of an "Edit" button.

Either way there will need to be an "Update" or "Save" button once you are finished editing. Maybe "Update" would be better since you would still need to save the entire object.

Interactivity would be similar to whatever I go with for passability.

Thoughts and suggestions are welcome

Edit: Got editing of passability info working. I went ahead with the first option, minus an "edit" button. Currently no "Update" or "Cancel" button and the passability is updated as the user left clicks on a grid. You still have to remember to actually save the object after any edits.

Now I need to recall how to get one of these "new" objects into a map so that I can have a look in the editor / game to verify the updates!

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Karmakeld
Karmakeld


Famous Hero
posted March 21, 2018 09:12 PM

Make sure it's saved as/renamed to .h4d file.
Place it in the Data folder.
Open editor, select Tools -> Customize (ctrl +T, ctrl + C).
Locate the objects name (just search for it, starting with type name etc). Double click or drag it. If editor crashes you know it can't be read.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
iliveinabox05
iliveinabox05


Adventuring Hero
posted March 21, 2018 09:32 PM

Karmakeld said:
Make sure it's saved as/renamed to .h4d file.
Place it in the Data folder.
Open editor, select Tools -> Customize (ctrl +T, ctrl + C).
Locate the objects name (just search for it, starting with type name etc). Double click or drag it. If editor crashes you know it can't be read.


Cool! Do I need to save it as a unique name? Meaning, something different than the name of the object I edited?

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Karmakeld
Karmakeld


Famous Hero
posted March 21, 2018 09:42 PM
Edited by Karmakeld at 21:44, 21 Mar 2018.

Not really, but in any case just add an e.g. '2' or similar so you don't have 2 objects with the exact same name, not sure how the editor will handle that. They're all listed in alphabetically, 2nd's last.
So if it's eg. adv_object.mountains.grass.25 you just add an extra number or letter.
Don't worry about additional space, dots or underscore etc. just add/name as you please. What matters is 'adv_object.' and '.h4d'
Or you could simply name it adv_object.Derricks test object.h4d

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
iliveinabox05
iliveinabox05


Adventuring Hero
posted March 21, 2018 09:57 PM

Nice, I'll start testing that when I get home

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Jump To: « Prev Thread . . . Next Thread » This thread is 5 pages long: 1 2 3 4 5 · NEXT»
Post New Poll    Post New Topic    Post New Reply

Page compiled in 0.0470 seconds