H&DD and Hex Editing!

Discuss modding & editing for H&D Deluxe using the Insanity 2 editor and 3d Studio Max here.
zanzibar
Private
Posts: 22
Joined: Sat Oct 06, 2012 3:17 pm

H&DD and Hex Editing!

Unread post by zanzibar » Sat Oct 06, 2012 5:20 pm

Hi everyone, thanks for having me here.

Recently I've picked up H&D Deluxe again, after having played its original release through hell and back and this version some time later in order to try the expansion pack. I've been replaying it this week, but after all these years only today did I took to tinkering with the Editor. Almost immediately after reading the first two pages of the tutorial, I felt ready to conquer the world. Haha, how little did I know!

One of the things that I did find annoying (other than Stealth being apparently useless in-game) was that I couldn't modify a mission's predefined objects. Sure, I can move a truck far away, or reduce the scale of something until it becomes near invisible, but unlike actors or models extracted from the main folders, I can't seem to, for instance, duplicate buildings (even if I can affect position and scale). I was feeling kinda miffed about this, in particular because all attempts to get 3DSM 3/3.1 have been met with utter defeat. So I tried something else.

While I have never really made any mods, I have spent some time messing around with editors, doing stuff ranging from texture work to game translations. For this, I used several programs, but one that I stuck with was Hex Workshop. HW is pretty fast and useful for all sorts of things, and while I'm not claiming to have made great strides in H&DD modding, I did come up with something useful (here's hoping this wasn't covered in the tutorial, otherwise I'll look like a fool :lol: ).

C6M1, the first level in Prague, has several destroyed buildings. There's the one almost at the start, with a blockade of cars and trucks, the one with the tank at the square and the other one with the streetcars. I had a small quibble trying to mod the one at the plaza. Other editors would allow me to, say, delete one portion of a model, then duplicate (or copy and paste) some other part. No matter what I did, I found myself stuck with the shop interior exposed. Remove the tank, yes, but not the debris. I could scale down the debris or move them under the ground but had no way to cover it up other than pilling models in front of it. Unless...

I decided to test something. With the hex editor, I searched the Scene.bin and Scene.i3d files for any references to the model in question. You'll note there are two shop facades - one in perfect condition to the right (vyklad17), and the other one destroyed on the left (vyklad14). I thought simply replacing all references to vyklad14 with vyklad17 in both files would be so simple and stupid that it wouldn't work.

But work it did:

Before:
Image

After:
Image

You can still see the debris because I haven't yet modified their presence. Apparently, outright deleting references to a model in the files makes it so the Editor does not recognize the mission, effectively corrupting the file and laying waste to any and all progress done. I tried doing this with some debries along the roads, like Line56, etc., and the Editor simply wouldn't recognize the changes - everything was pitch black, and a loading file error mentioned at the bottom of the screen, even if I didn't change anything else.

But it is interesting to note that, potentially, while this does not replace Studio Max as a better alternative to terrain editing and creation, it might mean that more specialized/specific editing can be achieved. In theory, this suggests I could place something like the train terminal from C1M3 in any other level through simple reference editing/switching, provided there is at least a model with similar characteristic (place in the map) and/or same amount of individual parts.

Next, I'll try doing this with buildings. The destroyed ones, I feel, are dangerous: they have more individual parts than a standard building, so it can't just be a case of replacing everything. My next goal goal is to have a duplicate of the outlined building in the following picture in place of the ruined one. They're actually almost the same size, so it wouldn't seem out of place.

Image

I'll try my best and see what else I can pull off with hex editing. Hoping to return with more and better news!

EDIT: A quick note. After changing that particular part of the map, loading up the editor made the original vyklad17 blink in red. IIRC, the Editor pointed out the model no longer had a lightmap but so far there doesn't seem to be any problem whatsover.

User avatar
Jason
Administrator
Posts: 1881
Joined: Thu Sep 02, 2004 7:26 pm
Location: Perth, Australia
Contact:

Re: H&DD and Hex Editing!

Unread post by Jason » Sat Oct 06, 2012 8:27 pm

Hi and welcome to the forums thup01

That's an interesting way of doing it! It's great that you could actually figure out how to do it without 3d Studio Max. Perhaps I can help you get 3d studio max running? what operating system are you trying it on? What problems did you run into specifically?

zanzibar
Private
Posts: 22
Joined: Sat Oct 06, 2012 3:17 pm

Re: H&DD and Hex Editing!

Unread post by zanzibar » Sat Oct 06, 2012 9:38 pm

Hi Jason!

Actually, the problem was getting 3DMax itself, not running it. Sorry if I didn't made it clear.

I've yet to touch the building, but I noticed something else. I got into this hex editing thing with H&DD after replaying it, true, but as I did ideas for missions kept popping up, some based on actual WW2 operations, others less so. One of them involved using Prague as a location, and I wanted to give the idea of the city as being less ruined, almost pristine. A couple of minutes ago I tried to "reconstruct" the tram lines on the street and came upon the bombed out "square" near the last ruined building. What I wanted was to change the "hole in the ground" model to the box that has the tram line intersection.

I tried the previous workaround - replace all references to box236 (the ground hole) with box131 (the intersection model) - but this time, it didn't work. So I went stupid again and decided to make it so every 131 reference would point to 236 instead.

I achieved this:

Image

Of course, my celebration was short because this particular model and texture doesn't line up (you'll note that rotating it isn't enough, it would still need to be moved along the ground axis to line up, but a piece of road would be missing). But the curious thing about this wasn't so much that the reverse method worked. It's that the original 131 remained intact :shock:

So I guess this means there's some manner of logic at work in these files that I haven't quite understood. But suddenly new things seem possible.

zanzibar
Private
Posts: 22
Joined: Sat Oct 06, 2012 3:17 pm

Re: H&DD and Hex Editing!

Unread post by zanzibar » Sat Oct 06, 2012 10:02 pm

Quick update on how it looks so far:

This is the original intersection model:
Image

This is the same model overriding the hole on the ground (I'll have to figure out a way to cover that space there, though):
Image

This is what I had to do with the debris:
Image

Curiously, one of the debries (the rocky ones) is permanently attached to the intersection model. Not overlapping it, merely it moves in the same directions (if I wanted to flip the model so the bottom was up, the rock would come out on top, floating above it). I've yet to test if this happens simply because I'm hex editing, or because I have models selected when I save the scene (which might cause some weird connections between models).

zanzibar
Private
Posts: 22
Joined: Sat Oct 06, 2012 3:17 pm

Re: H&DD and Hex Editing!

Unread post by zanzibar » Sat Oct 06, 2012 11:59 pm

And I guess I can call it a night! :grin:

Image

So, how to do this? It's the same replacement method, with caveats. Since these premade buildings cannot be safely deleted from the table files (or if they can, I have not discovered yet how to), the workaround is somewhat simple. I did the same thing; in this case, I replaced the box320 reference (the lower front part of the ruined building) with box170 (an intact building very similar in architectural style as the other one). What happens is:

The ruined building is made of 9 parts. The roof, the front ruined wall, two corners, one back wall (at the top, where the shooter is), two supports (one assumes ruined walls), and two side walls for the upper floor. I simply replaced the front wall, as reused the roof, scaling it to fit with the new facade. Now, there are two possibilities here:

1) Assuming the premade models cannot be deleted, they have to be taken away from sight. As with the tram intersection, I placed them below the ground level.

2) Assuming they can't be deleted, *but* can be reappropriated (by "simply" having them point to other references in the map), it might be possible to turn them into other assets for a map without having to add new ones. An example, still untested, would be to convert the remaining unused house parts to something like crates, and place them anywhere else on the map, instead of having to insert models from the database and bloat the map memory.

I'll try that last one tomorrow. For now, I think I earned the right to go get some sleep :lol:

EDIT: Oh, before I go, one last note for today. I've only replaced references with the same amount of words/letters in their names. Because there's something else operating in the code, replacing box320 with, say, box12 wouldn't work, as it mangled the file. Until I discover a way to fix this, it's the best workaround I can manage. It's limiting, no doubt, but at least it makes sense.

User avatar
Jason
Administrator
Posts: 1881
Joined: Thu Sep 02, 2004 7:26 pm
Location: Perth, Australia
Contact:

Re: H&DD and Hex Editing!

Unread post by Jason » Sun Oct 07, 2012 3:35 pm

Pretty good progress considering your limitations, well done thup01 very interesting to see how you progress through.

I'm going to try and get 3d studio max running on Windows 7 some time today. I've had it running on Windows XP SP3.

zanzibar
Private
Posts: 22
Joined: Sat Oct 06, 2012 3:17 pm

Re: H&DD and Hex Editing!

Unread post by zanzibar » Mon Oct 08, 2012 9:36 am

Well, it seems things didn't go as planned :/

I noticed today that the Editor actually does not save the models. To be precise, it doesn't seem to register the position/orientation of a duplicate box, if the one being swapped is a multi-part object. For instance, the shop facade with the tank in Prague (vyklad14) is still working, because it's a full model. Even if it inherits the base properties of the other model (vyklad17), it works.

Today, loading the editor, I realized that I had forgotten to reload the mission, to check if things worked (apparently, the Scene Validity Check doesn't report any issues). So what is the problem? Not sure yet, but the results are:

1) Original building (box170) is removed from its place.

2) Modified building part (box320) is successfully replaced with a copy of box170, *but* is still forever linked to the remaining building pieces. Even linking them to other models (using Shift+Ctrl) doesn't do anything, and any change I perform is not saved (even rebuilding the BSP tree does not work).

Only thing I did notice, but have yet to fully test, is that after editing, it is possible to change the building's coordinates in the hex editor. All other buildings can be changed, but with my method, this specific building can't. So far, editing the coordinates in HW is a very blunt thing; minor changes result in large displacements.

I haven't tested this thoroughly because the Editor seems to have also decided any file I placed in mymap\missions\addon\1 was corrupted. I just uninstalled and reinstalled everything, and it's now working again, so I'm off to check if the corruption problem was due to me changing the file or something else.

Foiled again :(

After some browsing, I also noticed that the intro to the Prague missions (with the general throwing the cup of coffee at the painting) uses some of the same assets used in the mission. A quick inspection revealed that in this map, box170 is not editable - but it is in the mission itself. I'd love to know what, if anything, toggles the ability to do this.

But I'm not giving up just yet!

zanzibar
Private
Posts: 22
Joined: Sat Oct 06, 2012 3:17 pm

Re: H&DD and Hex Editing!

Unread post by zanzibar » Thu Oct 11, 2012 5:11 pm

Ok. Yesterday I had a terrible night. Two straight hours of H&DD editing down the toilet, though I can't tell if it was related to tampering with the files or simply a bug in the editor.

This is just an update to explain a small development. So far I've managed to replace four different objects, by duplicating existing ones via "hexing". I've already discussed "vyklad" and the intersection. If you'll note, replacing the bombed out ground with a duplicate of the original intersection works, but visually, it's still missing the tram cables. Not anymore:

Image

As I said, yesterday things didn't go so well. The above pic was what I was trying to do, and did, but after 2 hours straight of not having any problems (and spending huge amounts of time making things look as consistent as possible), the editor decided to remove the lines. Today, it didn't. Why? While I'm still not an expert on the file format, here's what seems to work.

When hex editing the scene.i3D, look for the text string of both the items you want to replace and the ones you want to duplicate. In my case, I wanted to duplicate line124 and line108, the diagonal tram lines above the first intersection. I decided to replace line324 and 325, which are tram lines heading towards the back of the level, up the hill near the houses (behind the hill with the cannon). What I did yesterday, I'm not entirely sure. What I did today, however, was:

*Backup, obviously.
*Open the scene.i3d, and *only* scene.i3d, with the hex editor.
*Search for the text of the models you want to replace (line 324 and 325 in my case).
*Virtually every model will be listed twice on the *.i3d file. The reference will be listed twice. Ignore their first instance of each, and focus on the second only.
*Replace the original names with the ones you want to change (line324 into line124 and line325 into line108 in my case).
*Save and exit the editor.
*Load the HD&D Editor, and...

Calm your nerves. The editor will burp up an error (unable to load frames, more than likely). You'll note that it's quite possible, depending on what models you've changed, that both the original and duplicates are out of place. This wasn't my case, though, because I didn't edit anything else in the files. For me, the original diagonal lines were still there, but the other two were slightly out of place (a bit to the front of theire original place), but looking exactly like the original tram lines. From here it's "simply" a case of modifying them as you wish... But there is one major caveat I've yet to solve.

You cannot apply Undo/Redo commands on them. For some reason, you might make 30 edits on the entire map, and the models you've changed will retain their last position and orientation, while everything else will successfully revert. This also carries another issue (though not a very problematic one), in that it's actually best to save the scene.i3d file, manipulate the models into the position you want them, write down (preferably copy+pasting with Notepad) their X,Y and Z values along with any other change in them, and *only* change them this way. It's quite possible to still manipulate their states via Shift+Alt and toggling different axis, but these should only be made towards the end when you're doing the finishing touches.

In order to keep the integrity of the map and models, I've not changed their links. By this I mean I have not used Shift+Ctrl to link the changed models to any other model. This can cause further issues like displacement. Retaining their original links is advised.

Regardless, this is so far the only "safe" way I found of duplicating models that I found. More tests will follow in time, but if you're short of a 3DMax 3, this might be a good second option :)

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests