Page 1 of 2

Resource modification

Posted: 25 Mar 2019, 00:32
by TheLatinGuy
This is something, what bugged me for very long time, In EE 1, you had ferrum (I use Latin names for elements, since their symbols are from Latin) all the way. In EE 2 you have it from epoch 4 (fair enough), but in epoch 10 you don’t. In WW 2, getting enough of it was key. Yet… In EE 2 in that age, there is no mention of it.
And I suppose I just cannot get over this. Sure, having oil, saltpepper and so on is important. I don’t have anything against current resources, I have something against ferrum not being categorized as basic resource from epoch 4 forever.
So, I want to change it. I’ve already changed plenty of configuration files for units, unit upgrades and so on. For example, satellites are actually useful, reveal units similarly to AWACS, nuclear missiles don’t take population points (because they’re the solution to situation, where computer has too many units and you need to get rid of them, because it slows down the game insanely), ships have an actual range worthy of ship weapons, and so on.
There is no need to say that all the modifications I do, I don for myself and myself only. I know nobody is interested in them anyway.
I’ve looked around the files, found some interesting stuff (and then forgot where they are), so I think I could try to do this on my own. I even know, how I rearrange the GUI: I seriously don’t care about territory ownership. Like…yeah, it’s nice to know, I guess, but it’s not a resource like the others. So, I’d have current base resources, after those (epochs 1 to 3) stannum, as now, and then 2 empty fields. Then, in epoch 4, on 5th resource place would be ferrum, under that special ones. In transition from epochs 6 to 7, stannum would change to saltpepper, as now. And in epoch 10, you’d get oil. From then, you’d have 7 types of resources, not only 6.
What I want from you? Advices on which files and how to modify. What I’m doing, when I’m modifying something, is just…reverse engineering of sorts. I’m a programmer, so I know what to look for, but I also know it would be nice to have some manual or something.
What I don’t want to do: push this idea of mine to anyone else. If you couldn’t care less about ferrum, fine. :-) I don’t force it upon anyone. I just want this modification for myself and myself only. So even if you think my idea is stupid, then…OK. It will not affect you.
I just think it’s beyond weird, that when you start building tanks and plains, all of which are from metals, mainly ferrum, you cannot actually…you know…pay it. The resource is just not there. Doesn’t make any sense to me.

I’m modifying in context of, the 1.5 unofficial patch. And I know there is 007 out, I’m too lazy to download it and check if it changes any of the files I’ve changed (which it most certainly does). Meaning mod recommendation would probably not work, since I’d have to implement all my current changes to them.

Re: Resource modification

Posted: 25 Mar 2019, 01:43
by Dr.MonaLisa
Nice post. Always nice to read something creative.

The best modders I know (Iwanicki and RGV1) tried to unlock "different" special resources by modding files. Unfortunately unsuccessful. I believe that it's hardcoded, and would be very hard to change it, especially because they have limited slots in resources UI, etc. I'd risk to say that it would be possible if special resources were defined in 1 place of the .exe, but because of complexity it must be present multiple times. Therefore, even if we find some part of "special resources" by reverse engineering - the game will crash due to incompatibility in other regions. I tried to add more colors to game (and civilization numbers) with this method, and I just couldn't pass it. I would recommend to focus on different things (if there are any remaining) before attempting to modify those special resources. It's really not worth your nerves.

I would recommend to update to (of course after full backup of your folders). There were some important changes: viewtopic.php?p=24679#p24679
First of all a bug where half of the "dbcombat_unittypeadjust" file was not read (original balance issues). Then Snipers rework (they can't longer seriously damage tanks and buildings), Bunkers rework (faster damaged by tanks, less by ICBMS), etc. And of course Loew's Ambient Pack with a lot of new ambient stuff for the Map Editor. Not to mention a new Launcher option where Centering can be disabled for Cycle Select hotkeys (very useful for example for launching ICBMS from siloses with CTRL+SHIFT+N hotkey).
Updating shouldn't be that hard, because not many files have changed. You could open "" (after update) and see modification time of files there. Most likely you didn't even modify those updated files.

Re: Resource modification

Posted: 25 Mar 2019, 12:20
by TheLatinGuy
To be honest, I was kind of expecting and was afraid of it being hard coded. I’ve been looking through all the headers and other files in zips, there was something about order of the resources and so on, but nothing about epochs, where it would be minable.
But don’t you guys have source code or something? Because I’ve noticed (and really appreciated) one thing. The resource capacity is 6 digits long, not only 5. How do you change that? What if I wanted, say, 7, because my economy is too powerful.
Regarding the GUI problem, one of possible solution is to make fonts smaller, the fields for resources as well, so you can fit more of them there.
Yeah, I’ll look into it. :-) Do all the things I need. To successfully update and keep my changes.
But speaking about my nerves (and something creative): it’s more “stressful” not to have it as I desire than try and fail. But to be honest, keeping ferrum is just one idea I have. Because there is plenty more where this one come from. Just in short and numbered: (if you want, I can elaborate on any of those) (disclaimer: those are ideas, not all of them might be possible to implement)
0.0: Adding cuprum, mined from age 2, since that age is named after it, mined up to epoch like 9 or something.
0.1: Or just keeping some resources as mined from certain epoch onwards and discarding some. Because even cuprum is vital to this day. It’s everywhere. In later stages of the game, lithium and hydrogen could be added.
1: Power. Idea borrowed from Command and Conquer Generals Zero Hour (GZH for short). Think about it. You have all the modern tech in epochs 11 onwards, yet no power stations. Huh? How that does make sense?
2: Instead of hotkey cycling, put nuclear missiles to some side bar, again, as it is in GZH. While at it, maybe something else as well (I don’t know what yet).
3: Feeding your population. Each unit will consume some amount of food per some unit of time. Both configurable.
4: If power stations, then also feeding them. Depending on the type, oil or uranium.
5: Concept of mines. You build a building around, say, stone resource, put people there and they produce stone. Just like uranium mines. This parallel to current way.
6: Trading: establishing trade route is done by clicking on territories, no need to look for markets. Obviously only possible if that territory has a market.
7: For love of god, bigger territories. Whatever generates them, needs to make them bigger. So, you can fully develop them.
8: Promotion system, add heroes in the same fashion as veteran and elites are. What is now hero would be Something like super hero.
9: Factories for making parts. What parts? Any. From epoch 11 onwards, making bullets, missiles, engines, cannons, anything. If you have it, then unit producing buildings will build units faster.
10: Ships in epochs 11 to 15: in each epoch, you should get new ships.
11 (drastic one): More epoch, go beyond 15, add atmospheric and planetary ships, railguns, lasers (more) and all of that good futuristic stuff. But don’t add space, that would be too much.
12 (probably just not possible): Units having more weapons. For example, ship having long range missiles, miniguns for incoming anti-ship missiles, laser for air units, railgun for something far away…
13 (system one, I’ve tried but so far failed): If player get’s defeated, EVERYTHING his disappears. Even roads, bridges and farms. Because there is nothing more frustrating than having someone die as your ally, leaving roads and everything behind. If you go to those territories, you can’t get rid of it and build there because of it.
14: Wider rivers, ships being able to go there, under bridges.
15: Ability to build ocean bridges (up to certain distances) and tunnels through mountains.
16: We have roads. What about rails? For transporting units and goods, faster.

If only some subset of these would get implemented, then you’d have pretty big mod.

Re: Resource modification

Posted: 25 Mar 2019, 14:02
by Dr.MonaLisa
But don’t you guys have source code or something? Because I’ve noticed (and really appreciated) one thing. The resource capacity is 6 digits long, not only 5. How do you change that? What if I wanted, say, 7, because my economy is too powerful.
Nope. I changed things like this by the assembly, like in this video:

I think it was changed to 6 digits to fit the text of the amount of resources in all boxes on all screen resolutions (but I'm not sure).
I found this in my notes:

Code: Select all

pop around here:
call: 00789DA4
func: 005E3F30
sets pop here: 005E3FD1 (func 005E3FA0)

Max resources location: 00BD1808
Change: 99 999 to 999 999

change: 0061F494
from: CMP EAX,3E7
to: CMP EAX,270F

change: 0061F49B
from: MOV EAX,3E7
to: MOV EAX,270F

4 after: 007EBD25
3E7 to 270F
Not sure why I'm missing detailed documentation for this one... Maybe I was too lazy that day.
13 (system one, I’ve tried but so far failed): If player get’s defeated, EVERYTHING his disappears. Even roads, bridges and farms. Because there is nothing more frustrating than having someone die as your ally, leaving roads and everything behind. If you go to those territories, you can’t get rid of it and build there because of it.
An annoying, but still workaround can be usage of the ALT key + right mouse button. It allows to kill remaining farms and roads. If you use this combination with SHIFT you can order to destroy road parts one-by-one without wasting too much time. But still, it's just a workaround.

Anyway, the game could be rebalanced and improved a lot witch such little tweaks, however I'm personally not interested in creating mods like this. I like EE2 as it is originally, and I'm aware that any change could be disliked by players who are playing EE2 for a long time. Not to mention that it would affect the Multiplayer community. I know it could be done as a "new" mod, separated from UP1.5, but I personally wouldn't enjoy most of changes, so no pleasure modding it at all. But of course if I can I'm always trying to help and provide information where some thing could be changed, etc.

Re: Resource modification

Posted: 25 Mar 2019, 14:32
by TheLatinGuy
I’m looking how the editing is done, and OMG… This is insane. Wayyy beyond my level. I guess it’s time to level up though.
Well, OK, I guess I’ll become intimate with OllyDbg. Should I do other things, like coding my own programs in C#, where I obviously have the source code? Sure. But that will not help with the feeling about EE2. :-D
Yeah, I know the forced attack (and just btw, I’ve lowered roads health, 10, 20 and 30 per meta-epoch (and corrected when you get new roads, epoch later from what is originally was (and couple other things))), but that doesn’t work on allied ones. Nothing does. As far as I know. This shaped my policy regarding allies. If I detect anyone being weak or in war they cannot win, they go to neutral.
But do you think it’s possible to do this? I mean, there just HAS to be some enumerator somewhere, which tells the game what to remove after player defeat. I’ve tried to categorize roads as buildings, no luck. It would be also nice, if I could at least order my unit to attack all roads automatically, or as a class of enemy units. Together with walls. Yeah, I’m bit OCD on this. I destroy even the pile of rocks, which have the health bar (and now they have just 1 HP) on them.
I wanted to say that those changes would create straight up a new game, but then I’ve remembered how certain mods can change gameplay.
And I just wanted to add, that all of this would be optional addon. I strongly believe in choice, so none of this would be mandatory.
But it doesn’t matter. Now, I’d just like to know, how to mod the best. Before I try it myself, the OllyDbg can work with DLLs as well? Before changing anything, I need to know, where to look for things I need to change and what I can change.

Re: Resource modification

Posted: 25 Mar 2019, 14:59
by Dr.MonaLisa
I mean, there just HAS to be some enumerator somewhere, which tells the game what to remove after player defeat.
I did a quick research now and didn't find anything obvious. I guess it would actually require a few days to find. I thought it depends by "Owner=WorldOnly" (or something like this in DDF files), but can't find it specified for roads. But anyway, it would be worth to try. Another possibility could be changing the mini-map color of roads (or removing that setting at all). In EE2 they used to add several "tweaks" based on totally unrelated ability/setting, so all possibilities need to be checked manually :(
the OllyDbg can work with DLLs as well?
Yes, some DLL could be loaded by assembly and then used. However, I've never done that. I knew nothing about assembly and possibilities when I started it, and just learnt with time, using my "own" methods, not those recommended on forums, etc. Surely, loading a DLL and emulating functions there could be much easier, but still you need to know all memory addresses where things are stored, and still need to manually edit jumps to call your DLL function instead. I think it simply leaves the same amount of work as writing the function itself by assembly. But I'm probably wrong.

To get started, you should copy and rename:
Unofficial Patch Files\EnabledUP15UnitsDX9\EE2.exe
Unofficial Patch Files\EnabledUP15UnitsDX9\EE2X.exe

To the "base" game folder. For example call it: EE2-mymodifications.exe

Then load EE2-mymodifications.exe with Olly (or ). The second one is newer and still updated. I just couldn't get used to it myself, but still looking at it from time to time. I think if you never used Olly it would be better to go for x32dbg.

Re: Resource modification

Posted: 25 Mar 2019, 15:22
by TheLatinGuy
So basically, EE2 creators coded dirty?
One must appreciate open source and documented SW at this point. Really.

I see myself on the similar path, learning on my own as I go.

Yeah, I did that. They’re my test subjects, so they’re named appropriately. :-D
I’ve looked at the second program and it looks much better, to be honest.

And just to be completely sure, with this I can basically edit the exe files, on assembly level, right?
As I’m looking at this, I realize I only thought I knew stuff about computers. :-D
Any advices for someone like me?

Re: Resource modification

Posted: 25 Mar 2019, 15:35
by Dr.MonaLisa
You can edit the exe (saving changes) or add modifications "live" and test how changes work.
Also, make sure to switch EE2 to windowed mode (by UP1.5 Settings) as after adding a breakpoint it might hang and be unable to minimize.

I honestly think assembly knowledge isn't required. If I could select I would never start with it. I only had high ambitions and a lot of UP1.5 users. That's the only thing that motivated me, and that's how most (if not all) of Unhandled Exception crashes were fixed in game. But in general, I wouldn't start it just for myself. Maybe it's hard to believe but for some changes I used to "try" non-stop, for few weeks, everyday for few hours until figured it out.

Re: Resource modification

Posted: 25 Mar 2019, 20:45
by TheLatinGuy
Yeah, the live modification would probably be better than keep loading up my save (14 MB, it takes about 2 minutes from desktop to state when the game actually reacts (on 25% of speed)).
Yes, of course, windowed mode. That will be important, together with backups.
Not only assembly, but the stuff, which I, as C# programmer, didn’t really needed to know: how OS dived up memory, how data are organized there, and so on. Like…I know something, but probably not enough. And yes, assembly would be nice to know, since I just look and know what those instructions are.
Fixing those exceptions must’ve been insane. Do you know, how I’ve mentioned GZH? Yeah, that has a LOT of them. The game engine is just horrible (according to developers working on RotR, pretty big mod (making the game as it should be from the start)). So, if you wanted to just…fix stuff… :-D There is a lot to fix.
I know this, how you just do this one thing and pretty much nothing else.
Anyway, I have here CheatEngine as well. Together with proper hex editor, I’m reasonably set. But one thing is missing. What CSV editor do you use? Because all what I’ve found was either paid (I know, I can find cracks on torrents, but I don’t do that anymore), or useless.
While we have this OT discussion, I wanted to ask about modifying save files. Do you know the structure of that, or is there some unofficial documentation? I don’t want to do miracles, I just wanted to see, what I can do. Especially regarding diplomatic statuses.

Re: Resource modification

Posted: 25 Mar 2019, 21:45
by Dr.MonaLisa
I use Notepad++ to modify EE2 .csv files, and I count commas manually. It's the safest way to not damage the file.
Sometimes I load .csv to Google Docs (by Internet browser), then it's easier to see values in tables.

Any single bit change in .sav, .e2s or .map file damages the file (game is not longer able to load it). So I never managed to edit those files.
The only undocumented change is how UP1.5 stores "no crowns" status information in game saves.
Every .sav file starts with "LChunkFile". You can see it if you open it in Notepad++ or HEX editor (I recommend HXD).
When Crowns are disabled, UP1.5 uses "LChunkFil5" instead of "LChunkFile". Thanks to that it's possible to modify no-crowns status in existing game saves :)