Heroes of Might and Magic II Mod

The old Heroes games developed by New World Computing. Please specify which game you are referring to in your post.
User avatar
Pitsu
Round Table Hero
Round Table Hero
Posts: 1848
Joined: 22 Nov 2005

Unread postby Pitsu » 19 Sep 2010, 16:00

Anyone happens to have the palette used in HoMM2? I'd like to know which 3 byte RGB combination corresponds to which single byte HoMM2 color code. There is a RGBlookup file in agg, but i did not manage to extract anything sensible out from there.
Avatar image credit: N Lüdimois

User avatar
Soronarr
Pixie
Pixie
Posts: 117
Joined: 25 Aug 2010
Location: Croatia

Unread postby Soronarr » 21 Sep 2010, 13:25

I got the changed price to work :)

Final stats for the crusader:
growth halved
ATT 14
DEF 14
HP 120
DMG 25 (max and min)
price: 2000 gold

Speaking of which, any idea how fight Value is calculated? HPxDamage?

User avatar
Pitsu
Round Table Hero
Round Table Hero
Posts: 1848
Joined: 22 Nov 2005

Unread postby Pitsu » 01 Oct 2010, 17:15

Had some fun with hex editor and vb net. Lot more to debug, but a test:


Image
Avatar image credit: N Lüdimois

Dave_Jame
Pixie
Pixie
Posts: 119
Joined: 06 Jan 2006

Ghost and Ginies

Unread postby Dave_Jame » 07 Nov 2010, 16:34

Greetings Moders.

I'm not a moder, but I like what you are doing here and would like to give you some of my proposals.

As you all know, the number of genies on the map, is sat randomly at the beginning of the game.
In PoL the ghosts have been added as recruitable unites.

I personally think that the Heroes 2 ghosts are overpowered with their Kill one gain one ability.

So, my question is:
Could it be changed that the Genies would have a weekly growth of 1-2 instedof 2-4 pernament recruitable number from the beginning of the game.
And on the other hand the ghosts would switch to the lamp style at-the-beginning-of-the-map sate population of let say 5-7(6-8)

As I said, I'm no moder, but I would love to see this change.
Could anybody tell mi if it is even possible?

dudejo
Leprechaun
Leprechaun
Posts: 45
Joined: 18 Jul 2010

Unread postby dudejo » 09 Nov 2010, 21:36

most of the unit stats have been found in the game EXE.

so we could change not only the weekly growth but HP, Attack or Defense for example.

i could see Ghosts sacrificing either offense or defense. that would compensate for their easy numbers boost. i would say speed but flying units can do whatever the **** they want in Heroes 2.

Genies, imo, are fine. yeah, they have great offense but they can't take a lot of damage and are hard to get.

and afaik, the unit's weekly growth decides how many there are on the first week.

Dave_Jame
Pixie
Pixie
Posts: 119
Joined: 06 Jan 2006

Unread postby Dave_Jame » 09 Nov 2010, 22:40

dudejo wrote:most of the unit stats have been found in the game EXE.

so we could change not only the weekly growth but HP, Attack or Defense for example.

i could see Ghosts sacrificing either offense or defense. that would compensate for their easy numbers boost. i would say speed but flying units can do whatever the **** they want in Heroes 2.

Genies, imo, are fine. yeah, they have great offense but they can't take a lot of damage and are hard to get.

and afaik, the unit's weekly growth decides how many there are on the first week.
I think you misunderstand me.
I don't want to balance them. I Want to know, if it is possible to switch their breeding system.
For example
1: Fined the Lamp and the Barrow in the Exe file
2: Fined out what part says which unit is produced there.
3: Switch this property of the Lamp and Barrow (Than Genies would by produced in the Barrow and Ghosts in the Lamp)
4: Adjust production rate (Genie to 1-2 ghost to 4-7)
(other details)
5: change the names (ex. Barrow-Altar of wishes, Lamp-Soul Jar)
6: change graphic so it is suitable.

Has anybody the skill to make this Happen?

dudejo
Leprechaun
Leprechaun
Posts: 45
Joined: 18 Jul 2010

Unread postby dudejo » 10 Nov 2010, 02:21

i don't think that particular data was found yet.

however, i can't help but wonder if doing this will change the main strategy into a race for the Ghost Recruitment.

the main issue with Ghosts is how easy it is to get more. send them after a weak monster stack and watch your power increase exponentially.

if there are limited recruitment chances, first dibs means you get a lot of exclusive power.

User avatar
Kristo
Round Table Knight
Round Table Knight
Posts: 1548
Joined: 23 Nov 2005
Location: Chicago, IL

Unread postby Kristo » 10 Nov 2010, 05:12

Ghosts are supposed to be overpowered. They're designed to grow to ridiculous numbers if you try to attack them with low level troops. You can't really balance that ability for multiplayer purposes. I think you're better off just banning Barrow Mounds from any multiplayer map than trying to mess with them. As for Genies, you can achieve the same effect by playing a map with lots of Lamps.

I make these suggestions only because we haven't really found a way to mod anything beyond basic stats and costs. Barrow Mounds and Lamps likely have some hard-coded logic that would be difficult to even locate, much less change.
Peace. Love. Penguin.

User avatar
Darmani
Blood Fury
Blood Fury
Posts: 479
Joined: 06 Jan 2006
Location: Cambridge, MA

Unread postby Darmani » 10 Nov 2010, 06:47

That won't be the most straightforward thing to locate, but it's well within the realm of doability.

A quick search in IDA for the word "barrow" in the data section of the EXE found the string "Barrow Mounds", which is only referenced in the function beginning at address 004BAD0. Judging by the repeated uses of the strings "(visited)" and "(not visited)", this is a function used to help render tooltips. With a bit of playing around in the debugger, I could quickly figure out which of the arguments are used to determine that the mouse is over a Barrow Mounds, then from that find the structure in memory used to represent a particular Barrrow Mounds, and then set breakpoints on it being updated, and thereby find the code that updates it.

It's really tempting to attempt to do that right now, but I need to finish the homework for my graduate statistics class.

*sigh* Thanksgiving break can't come soon enough.

Dave_Jame
Pixie
Pixie
Posts: 119
Joined: 06 Jan 2006

Unread postby Dave_Jame » 10 Nov 2010, 07:37

Darmani wrote:That won't be the most straightforward thing to locate, but it's well within the realm of doability.

A quick search in IDA for the word "barrow" in the data section of the EXE found the string "Barrow Mounds", which is only referenced in the function beginning at address 004BAD0. Judging by the repeated uses of the strings "(visited)" and "(not visited)", this is a function used to help render tooltips. With a bit of playing around in the debugger, I could quickly figure out which of the arguments are used to determine that the mouse is over a Barrow Mounds, then from that find the structure in memory used to represent a particular Barrrow Mounds, and then set breakpoints on it being updated, and thereby find the code that updates it.

It's really tempting to attempt to do that right now, but I need to finish the homework for my graduate statistics class.

*sigh* Thanksgiving break can't come soon enough.
If you actually managed this somhaw, that would be great.
Darmani wrote: Ghosts are supposed to be overpowered. They're designed to grow to ridiculous numbers if you try to attack them with low level troops. You can't really balance that ability for multiplayer purposes. I think you're better off just banning Barrow Mounds from any multiplayer map than trying to mess with them. As for Genies, you can achieve the same effect by playing a map with lots of Lamps.

I make these suggestions only because we haven't really found a way to mod anything beyond basic stats and costs. Barrow Mounds and Lamps likely have some hard-coded logic that would be difficult to even locate, much less change.
Well you sort of said why i thought of this idea.
The ghosts can gain large numbers from weaker units. So you don't need them to constantly grow in barrows. A simple 5 at the beginning of the Game would be enough.
The Genies on the other side are standard units (with a very good abilitei) but haw low health and limited numbers. Making them useful only to the end of 1st month (at best) Giving them a constant growth would make them useful even in later game situation.

User avatar
Darmani
Blood Fury
Blood Fury
Posts: 479
Joined: 06 Jan 2006
Location: Cambridge, MA

Unread postby Darmani » 26 Nov 2010, 00:21

Looks like Fireball, Cold Ray, and Fireblast share the same damage-computing code. Here's a patch to change the damage to 13*spellpower:

Code: Select all

This difference file is created by The Interactive Disassembler

HEROES2W.EXE
0009FDA9: 8D BA
0009FDAA: 04 0D
0009FDAB: 80 00
0009FDAC: 03 00
0009FDAD: C0 00
0009FDAE: 89 F7
0009FDAF: 45 E2
0009FDB0: F0 89
0009FDB1: 8B 45
0009FDB2: 4D F0
0009FDB3: AC 90
We got lucky -- there was a redundant instruction nearby, so I had enough space to insert an arbitrary multiplication.

I've tested this with a bunch of different combinations of artifacts that affect fire/cold damage (Hot Magma Rock, Evercold Icicle, Heart of Fire, Heart of Ice). It seems to work. And now I have an idea what that call to "ftol" is doing a bit later in the function. :)

For those wondering how to change this do a different value, the bytes "BA 0D 00 00 00" correspond to the assembly "mov edx, 13". Changing the "0D 00 00 00" to the little-endian integer of your choice should do the trick :)

User avatar
Kristo
Round Table Knight
Round Table Knight
Posts: 1548
Joined: 23 Nov 2005
Location: Chicago, IL

Unread postby Kristo » 26 Nov 2010, 03:01

Awesome work Darmani! Care to elaborate on how you found it?
Peace. Love. Penguin.

User avatar
Darmani
Blood Fury
Blood Fury
Posts: 479
Joined: 06 Jan 2006
Location: Cambridge, MA

Unread postby Darmani » 26 Nov 2010, 05:39

Sure!

I started with my earlier work on Lightning Bolt. I found the format string for "The Lighting bolt does %d damage", and found the references to it. It quickly became apparent that this was in the "CastCombatSpell" function, which I marked as such.

Through similar methods, I found that the CastCombatSpell function called a separate function when a Cold Ring, Fireball, or Fireblast was cast. I found where it formatted the "Fireball does %d damage" message, and from that found the stack variable where the damage was being stored. I then put a break point at the beginning of that method, cast a Fireball while running in the debugger, and then put a write trace on that variable, thus finding the damage calculation.

I then changed the Fireball damage, and began looking for the Cold Ring damage, when I realized it had already been changed.

IDA is very much not designed to patch executables, but Atli Mar Gundmonsson's PE Utilities were a huge help.

User avatar
Darmani
Blood Fury
Blood Fury
Posts: 479
Joined: 06 Jan 2006
Location: Cambridge, MA

Unread postby Darmani » 01 Dec 2010, 04:22

I thought I should probably mention this blog post on reverse-engineering some of the file formats in HoMM II that I found a few months ago: http://www.terrybutler.co.uk/misc/heroe ... -magic-ii/

I've contacted the author asking for more details; he says he hasn't had the time to post.

I'm still wondering what the .bin files are. They seem to be the central stores of information about screens, creatures, and other things, judging both from the high density of file names in their hex view, and from their frequent usage in the code. I found the function which reads in the .bin files a few days ago, but I have yet to seriously investigate it -- it's hardly a piece of low-hanging fruit.

User avatar
UndeadHalfOrc
Titan
Titan
Posts: 1363
Joined: 13 Mar 2007

Unread postby UndeadHalfOrc » 02 Dec 2010, 13:51

Darmani wrote:Looks like Fireball, Cold Ray, and Fireblast share the same damage-computing code. Here's a patch to change the damage to 13*spellpower:

:-D :-D :-D :-D :-D :-D

By Cold Ray, you meant Cold Ring , right? Cold Ray is already 20 spell power. ( Looking at your later posts it seems it's the case, and only a typo on that one particular sentence)

That is wicked awesome, Darmani. Can't wait to fire up Heroes 2 again when I have the time.

User avatar
UndeadHalfOrc
Titan
Titan
Posts: 1363
Joined: 13 Mar 2007

Unread postby UndeadHalfOrc » 03 Dec 2010, 13:29

Many thanks again Darmani, it works perfectly!

If I find the time, I'll try to find the same offsets for the Heroes 2 vanilla version (succesion wars)

User avatar
Darmani
Blood Fury
Blood Fury
Posts: 479
Joined: 06 Jan 2006
Location: Cambridge, MA

Unread postby Darmani » 18 Dec 2010, 04:38

I thought I'd share something fun I found.

At address 3409D, change the byte "84" to "85." (This effectively swaps the "then" part of an if-statement with the "else" part.)

This enables a "debug mode." A "Debug" menu will appear in both the adventure and town screens (when playing in windowed mode, at least), offering things such as a Build All Buildings button, a Free Creatures Button, and similar things.

There is a debug_mode flag which is set at a couple points in the program. There may be a bit more to the debug_mode, as it does other things when setting this flag -- I haven't looked at that yet.

User avatar
Darmani
Blood Fury
Blood Fury
Posts: 479
Joined: 06 Jan 2006
Location: Cambridge, MA

Unread postby Darmani » 18 Dec 2010, 09:05

Forget my previous post.

To activate debug mode,open the Command Prompt, navigate to the directory containing HoMM II, and run the following:

Code: Select all

HEROES2W.EXE /NWC

User avatar
Darmani
Blood Fury
Blood Fury
Posts: 479
Joined: 06 Jan 2006
Location: Cambridge, MA

Unread postby Darmani » 02 Feb 2011, 05:32

After a lot of work, I have successfully managed to massage a disassembly of H2 into something that reassembles into a somewhat-playable version, despite having a lot of addresses changed.

It's still not that playable, and is wrought with bugs, some of them hilarious. For example, attempting to pick up a scroll brought me into combat with a Gray, Level 1 Necromancer, and, upon ending turn, I got this:

Image

It also crashes upon loading any map I've tried other than "Dungeon Below." I believe it somewhat likely that all bugs are instances of the same problem -- the infamous "code versus data" problem, where segments of data in the middle of the code are misinterpreted. It originally crashed in Dungeon Below as well, but I traced the problem to a table with a few consecutive 0s, which had been disassembled into "align 4," which had been reassembled into garbage (since no-one cares about alignments). If true, a single sufficiently-clever script could potentially fix them all.
Last edited by Darmani on 02 Feb 2011, 06:53, edited 1 time in total.

User avatar
Darmani
Blood Fury
Blood Fury
Posts: 479
Joined: 06 Jan 2006
Location: Cambridge, MA

Unread postby Darmani » 02 Feb 2011, 06:52

In other news, I have finally gotten around to releasing a couple tools I wrote a month ago for dealing with the AGG files which contain H2 data.

One of these is an AGG extractor. These have already existed, and are nothing new.

Another is a AGG creator, which is something new. Also included is a complete description of AGG files.

AGG Util


This is made possible by a larger effort to reverse-engineer the ResourceManager class. I had some fun changing stpnewgm.bin (BIN files, by the way, encode information on GUI screens) to move the buttons in the New and Load Game menus around, and make the "Cancel" button act like the "Standard Game" button.

If you play around with this, I recommend writing a couple BAT files to merge changed files into a new AGG and copy it into the H2 directory -- beats moving them around by hand.


Return to “Heroes I-IV”

Who is online

Users browsing this forum: No registered users and 1 guest