Jump to content

EXE editing & programming issues


MrFlibble
 Share

Recommended Posts

Thanks Nyerguds, I actually have some extremely basic knowledge of assembly and managed it myself. I also successfully removed the code that turned squads into single soldiers at 50% hp (I replaced the single soldiers with the Fremen&Sardaukar troopers :) ), keeping the retreat check. I was quite proud of that one. :D

But trying to answer Flibble's post I realize I actually don't have a clear idea of what changes I'd like to do yet. For now I wanted to make the Sardaukar light factory start upgraded just like the Harkonnen (and also keep the harkonnen upgraded light factory). With or without trike doesn't matter. But the other tech tree stuff in that post seems to be aimed at not displaying the upgrade button if certain conditions are met (that's just a guess, I really can't make much of assembly code)

I'll probably have to replace one of the other exceptions but I'm sure I'll find one suitable for that.

I am very interested in this. I should *really* learn how to do ASM...

Link to comment
Share on other sites

I can also find no plausible reason for this. No other unit is handled like that in the game. Perhaps it allows to avoid some side-effects we're still unaware of?

Anyway, would be nice if you posted this code exception here (I think it's not mentioned in Segra's posts, unless I'm missing something) :)

Luckily Segra also found this exception, it's in the StructureBuildListCreate function


seg010:1D5D                   loc_1C18D:                                                  ; CODE XREF: structureBuildListCreate:loc_1C188j
seg010:1D5D 83 7E EE 0D                       cmp     word ptr [bp+buildingDataPtr2+2], 0Dh ; constructOptN
seg010:1D61 75 0F                             jnz     short loc_1C1A2                     ; Jump if Not Zero (ZF=0)
seg010:1D63
seg010:1D63                   loc_1C193:                                                  ; Load Full Pointer to ES:xx
seg010:1D63 C4 5E 06                          les     bx, [bp+buildingGamePtr]
seg010:1D66 26 83 7F 47 02                    cmp     word ptr es:[bx+47h], 2             ; Compare Two Operands
seg010:1D6B 75 05                             jnz     short loc_1C1A2                     ; if(constructOpt == trike)
seg010:1D6B                                                                               ;  constructOpt = raidertrike;
seg010:1D6D C7 46 EE 0E 00                    mov     word ptr [bp+buildingDataPtr2+2], 0Eh

If the item is a trike (0D) and house is ordos (02) then use the raider trike (0E) instead. I'm going to replace this one with a sardaukar quad, and use nyer's editor to add the raider trike for house ordos instead. Will let you know if anything weird happens when playing house ordos.

edit: well guess I'm doing something wrong. I change the 2 (house ID) to 3 and 0E (unit ID) to 0F, but nothing happens against an AI sardaukar and if I set the sardaukar as Human instead of CPU in the scenario the game crashes.

Link to comment
Share on other sites

It probably doesn't help that the alignment is messy even inside the code tags :)

edit: Ok, I've looked into the problem with the sardaukar quad (it was late when I posted yesterday), looks like the problem is that it still checks the tech prerequisite after replacing the unit in the build list. So an unupgraded light factory with a trike replaced by a quad will just get that unbuildable carryal instead. I'll have to find another solution for the sardaukar quad :(

Anyway, I found no problems using the settings in nyer's program to give the raider trike to house ordos, so if you have another idea for this exception, here is the hex string you need to search for:

0D 75 0F C4 5E 06 26 83 7F 47 02 75 05 C7 46 EE 0E

0D: the trike unit ID. I suppose you could change it to 0F to replace the quad instead. Edit2: or any unit really, looks like there is no 'factory check' beforehand!

02: house id, 0=harkonnen, 1= atreides, 2=ordos, 3=fremen, 4=sardaukar, 5 = mercenary (not sure about those last three)

0E: unit ID to replace it with (to get the number, count the unit list in nyer's editor, thopter is 0, carryall is 1 etc etc... Then convert to hex). Just make sure the unit 'upgrades needed' setting matches the unit you're replacing.

Link to comment
Share on other sites

Thanks for posting the code, Jordos :)

0D: the trike unit ID. I suppose you could change it to 0F to replace the quad instead. Edit2: or any unit really, looks like there is no 'factory check' beforehand!

True. Actually, any unit can be produced from any factory/barracks if assigned to it via settings editable by Nyerguds' editor. The only condition is that the factory has been upgraded as many times as specified by the "number of required upgrades" variable in the unit's profile. This is how I found out that the Raiders were a code exception in the first place, when I made a single Vehicle Factory in a release of Dune 2 eXtended: the game refused to allow production of Trikes for the Ordos even if they were switched to a Heavy Factory, and the unit itself was enabled for the House (I made the Sardaukar Trooper unit from the Raider).

Link to comment
Share on other sites

Recently I've been browsing through my old Dune II savegames from v1.0, and noticed that sometimes one of my buildings would explode several seconds after the game was loaded, for no particular reason. Even though this might be a side effect caused by Minniatian's patch (I remember I used it with my v1.0, while now I tested the saved games on a "clean" version), this passage from the Dune II manual came to my mind:

Beware, for some Houses booby-trap their own structures in case they fall into enemy hands. These structures may self-destruct right away or they might wait awhile.

As far as I remember, I've never witnessed this in action. I wonder if the code for this is present in the game... Judging by what Segra uncovered about the "special" blooms, and the fact that there are no parameters to define booby-trapped structures in the scenario files, maybe this feature would depend on the map seed number and the position of each structure (and perhaps by some House characteristic)?

Link to comment
Share on other sites

Hmm, doesn't this mean that the wall placement bug still exists in the new SD2?

Possible; but it is hard to exploit, so I think not many people will notice :) In the worst case, when the A/O/H/S builds a wall, the owner becomes F/M. so it has less impact than the concrete bug.

Link to comment
Share on other sites

Possible; but it is hard to exploit, so I think not many people will notice :) In the worst case, when the A/O/H/S builds a wall, the owner becomes F/M. so it has less impact than the concrete bug.

Ehh, the point is, you play with the extra sides in SD2. Won't that affect them when trying to build walls?

Link to comment
Share on other sites

Hmm, doesn't this mean that the wall placement bug still exists in the new SD2?

I haven't noticed anything like that: with the fix, walls are built and placed down normally for the new sides.

More stuff at the OpenDUNE Development Blog:

[blog 2009-11-24] GameLoops

[blog 2009-11-22] GameLoop_House

[blog 2009-11-22] Scripting

Link to comment
Share on other sites

It is interesting to note that the Light Factory tech level is 3, yet this is only true for House Harkonnen. Every other house and side, including the unplayable ones, get to build the Light Factory starting with mission 2. I wonder how they did that, with 5 code exceptions for each House or what? ;D

Link to comment
Share on other sites

Actually I think a comparison with Harkonnen followed by a JNE (jump not equal) instruction is performed.

Probably equivalent in C is something like

if (house!=Harkonnen)

    //allow build Light-Factory

[obviously only for level 2]

-Daelin

Link to comment
Share on other sites

Here you go :) (in the structurebuildlistcreate function)


seg010:1C74                   loc_1C0A4:                                                  ; Check House
seg010:1C74 26 80 7F 08 00                    cmp     es:[bx+_buildingGame.houseID], 0
seg010:1C79 74 08                             jz      short loc_1C0B3                     ; Jump if house=harkonnen
seg010:1C7B
seg010:1C7B                   loc_1C0AB:                                                  ; Check building type
seg010:1C7B 83 FE 03                          cmp     si, 3
seg010:1C7E 75 03                             jnz     short loc_1C0B3                     ; Jump if building is not light factory
seg010:1C80
seg010:1C80                   loc_1C0B0:
seg010:1C80 BF 02 00                          mov     di, 2                               ; Change tech level to 2

Pretty much exactly what Daelin suggested.

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

I wonder about two things, one of you might be able to help out with.

First, the CY, Heavy Factory, ... have an icon you can click, which allows you to select something to build. In Dune2 there is also code for units, where that icon becomes clickable. Is there any unit which allows this? The unit can't build something, it only allows clicking the image which brings it to something (no idea what, as I can't find a unit which does that ;)).

Second, the repair facility now shows this weird ugly icon of the unit it is repairing. There is lots of code to make it behave the same as CY and stuff, where you can even put the repair on hold. This code of course is never really called, but all of it is still in Dune2. Is there any version which has this? Or maybe it is some switch?

Well, I hope any of you ever encountered either of the above. Any feedback would be appreciated.

Link to comment
Share on other sites

First, the CY, Heavy Factory, ... have an icon you can click, which allows you to select something to build. In Dune2 there is also code for units, where that icon becomes clickable. Is there any unit which allows this? The unit can't build something, it only allows clicking the image which brings it to something (no idea what, as I can't find a unit which does that ;)).

No, there are no such units, unto my knowledge. Maybe some value modifiable by Nyerguds' editor can switch this on for a unit, but to behave like a production facility (and not only have an icon on the sidebar you can click with a mouse), there has to be a separate chunk of code:

Kinda doesn't surprise me, all throughout the game code exists segments such as this

seg007:05B6 C4 1E C0 84                      les    bx, buildingGamePtrCurrent

seg007:05BA 26 80 7F 02 0A                    cmp    es:[bx+_buildingGame.TypeIndex], 0Ah ; Barracks

seg007:05BF 74 72                            jz      short BarracksWOR

seg007:05C1 C4 1E C0 84                      les    bx, buildingGamePtrCurrent

seg007:05C5 26 80 7F 02 07                    cmp    es:[bx+_buildingGame.TypeIndex], 7 ; WOR

seg007:05CA 74 67                            jz      short BarracksWOR

seg007:05CC

The "TypeIndex" field is actually the index into the data table (this code jumps to a location if its in the WOR/BARRACKS data position)... alot of code is like this

Second, the repair facility now shows this weird ugly icon of the unit it is repairing. There is lots of code to make it behave the same as CY and stuff, where you can even put the repair on hold. This code of course is never really called, but all of it is still in Dune2. Is there any version which has this? Or maybe it is some switch?

That's a very interesting find, indeed. However, none of the versions known to us so far allow to pause unit repairs. Maybe Segra documented this feature in his database?

Link to comment
Share on other sites

I doubt that is actually possible. The "clickable icon" thingy is building-related. If by messing with a certain byte you actually got the mentioned behavior it would be awsome to actually mention it. :)

And as for "repair hold".... I wonder if this can't be achieved by some sort of scripting in an EMC file or something (if I'm not mistaken that's how the "always return to repaired units to previous position on the map" and the "turret increased range" thingies were solved).

-Daelin

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...