Author Topic: Remove Or Disable Weather  (Read 13716 times)

Offline newjack

  • Newbie
  • *
  • Posts: 11
Remove Or Disable Weather
« on: August 11, 2010, 09:04:22 AM »
Hello everyone, I was wondering if there is a way to disable or remove all the natural disasters from the game? I really like doing the population colony games on hard and building massive citys. However after a while it becomes really frustrating when all your doing is repairing structures constantly and have no time for expansion or fighting. Once I hit this point I always just quit the game from anger. Anyways, any info on doing this would be really awesome and would greatly enhance my outpost fun!! Thanks in advance!

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Remove Or Disable Weather
« Reply #1 on: August 11, 2010, 09:20:12 AM »
It's been done, but I dunno where you can find the hacked EXE.
"As usual, colonist opinion is split between those who think the plague is a good idea, and those who are dying from it." - Outpost Evening Star

Outpost 2 Coding 101 Tutorials

Offline Flashy

  • Sr. Member
  • ****
  • Posts: 391
Remove Or Disable Weather
« Reply #2 on: August 11, 2010, 09:46:36 AM »
Outcaster Starship doesn't have disasters
« Last Edit: August 14, 2010, 06:56:08 AM by Flashy »
Praise the mighty light towers!!!

Offline Hidiot

  • Hero Member
  • *****
  • Posts: 1018
Remove Or Disable Weather
« Reply #3 on: August 11, 2010, 12:26:18 PM »
Any colony games that don't involve AI bases can sort of easily be recoded without disasters.
"Nothing from nowhere, I'm no one at all"

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Remove Or Disable Weather
« Reply #4 on: August 11, 2010, 01:02:05 PM »
He's looking for no disasters at all in any game.
"As usual, colonist opinion is split between those who think the plague is a good idea, and those who are dying from it." - Outpost Evening Star

Outpost 2 Coding 101 Tutorials

Offline newjack

  • Newbie
  • *
  • Posts: 11
Remove Or Disable Weather
« Reply #5 on: August 11, 2010, 01:25:00 PM »
Quote
Any colony games that don't involve AI bases can sort of easily be recoded without disasters.
Do you know which files I have to change? I am not great with this coding stuff so I am guessing I would need a program as well to do it. I am willing to do whatever I need. Like I said the disasters kinda ruin the game for me.

Offline Flashy

  • Sr. Member
  • ****
  • Posts: 391
Remove Or Disable Weather
« Reply #6 on: August 11, 2010, 01:30:29 PM »
To delete the disasters from the original colony games you need the source, but no one has it. Hidiot talked about rewriting the whole level
Praise the mighty light towers!!!

Offline Hidiot

  • Hero Member
  • *****
  • Posts: 1018
Remove Or Disable Weather
« Reply #7 on: August 11, 2010, 01:30:42 PM »
Existing maps can be altered, yes, but that is something I don't exactly know how to do. A person named vennom looked into this a while ago. It involves hacking an already compiled file for each map.

I was suggesting a complete re-coding, since without disasters, those maps with no AI bases should be pretty easy.

What Flashy says is not true, you don't necessarily need the source to remove all calls to disaster functions with special tools, including a debugger.
« Last Edit: August 11, 2010, 01:32:49 PM by Hidiot »
"Nothing from nowhere, I'm no one at all"

Offline Flashy

  • Sr. Member
  • ****
  • Posts: 391
Remove Or Disable Weather
« Reply #8 on: August 11, 2010, 02:57:54 PM »
Ok, but having the source makes it MUCH easier. And lowers the chance that you mess something up.
Praise the mighty light towers!!!

Offline newjack

  • Newbie
  • *
  • Posts: 11
Remove Or Disable Weather
« Reply #9 on: August 11, 2010, 04:20:47 PM »
So I am guessing whatever I need to do is way over my head? That kinda sucks. I would not even know where to begin to recode an entire map.

Offline BlackBox

  • Administrator
  • Hero Member
  • *****
  • Posts: 3093
Remove Or Disable Weather
« Reply #10 on: August 11, 2010, 05:23:19 PM »
What you -could- try (I can't remember if these even work correctly or not), is loading the map using the debug menu. There are checkboxes for disasters (however this just sets a flag on or off, the map doesn't have to honor the setting so it might not work... since you can't normally select if there are disasters or not in a colony game the map may create disasters anyway).

To do this, at the main menu press D -> a grey box will pop up. Click "run script" and select the map from the left (it is actually the filename of the DLL that contains the mission. All the colony games start with C and are as follows:
cde1.dll = pre release eden demo
cdp1.dll = pre release plymouth demo
cds1.dll = post release colony demo
cep1.dll = eden population
cersbas.dll = plymouth cold war
ces1.dll = eden starship
cpp1.dll = plymouth population
cps1.dll = plymouth starship
cps2.dll = plymouth starship 2

Make sure the 'disasters' checkbox is off and press OK to start the game. But again, there is a good chance this may not work (like said the disasters checkbox is just a flag that the mission can check; the mission may just create disasters anyway without honoring this setting).

Failing that it would be relatively trivial for someone to modify the existing missions to run without disasters (it does require some programming knowledge however so not necessarily the most simple for the average person playing the game, but it is entirely possible). If I have some free time later this week perhaps I could modify a couple to not have disasters.

Offline Flashy

  • Sr. Member
  • ****
  • Posts: 391
Remove Or Disable Weather
« Reply #11 on: August 11, 2010, 05:29:57 PM »
I tested the debug menu, and it can't disable disasters. It probably just sets the disaster flag off, like you said
Praise the mighty light towers!!!

Offline newjack

  • Newbie
  • *
  • Posts: 11
Remove Or Disable Weather
« Reply #12 on: August 11, 2010, 06:12:51 PM »
Hello guys, I also just tried the debug method and yielded no results :(   Blackbox you don't have to do that for me ( (thumbsup) unless your really bored (thumbsup) ) especially if it is lots of work! :blink:  

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Remove Or Disable Weather
« Reply #13 on: August 12, 2010, 02:01:51 AM »
This isn't actually too hard to do with a debugger, but it may appear a bit intimidating if you don't understand much of it. But no worries, this should be easy to follow if you do it as you read it:


1. Download OllyDbg, (or a similar debugger, but instructions here are for OllyDbg).
2. Start up OllyDbg and open Outpost2.exe with it.
3. Quick check to make sure it loaded correctly. The main area should be populated with assembly code, it'll probably say "Program entry point" in the bottom left, and "paused" in yellow in the bottom right.
4. Click on the main pane titled "CPU - main thread, module Outpost2". Press Ctrl+N to bring up a list of symbol names.

5. Find the function for a disaster you want to disable. They are named something like "SetDisaster". (A lot of functions start with "Set", so you might have to read closely). You can start typing the symbol name, and the selection will jump down to the first entry with a prefix matching what you've typed so far. Try "SetTornado". Double click on the entry to see the code for the function.

6. Disabled the function by overwriting it's first instruction with an appropriate "RET" (return) instruction. Basically, you're going to shortcircuit the function body and turn it into a do nothing function. There is a constant at the end of the RET instruction to say how many bytes to pop off the stack while returning, and this depends on the number and types of arguments passed to the function. It will not be the same for each function, so you'll have to do a quick visual inspection to find the right value from the original RET instruction for that function. If you get it wrong and try running the game, it will most likely crash when that function is called. No worries, just load everything up again and try again. OllyDbg tends to highlight function boundaries quite well, and the RET instruction will be the last instruction in the function.

Here's the first line of "SetTornado":
Code: [Select]
00478350 >/$  SHL EDX,5
Here's the last line of "SetTornado":
Code: [Select]
0047839E  \.  RETN 10
Just replace the first line with the last line.

To replace the line, highlight it and start typing the new instruction "RET 10". A box should open up for you to type into. You can also hit spacebar on the line to open up the box without starting to replace what's in it. Press enter, or click "assemble" to overwrite the instruction. The highlighted line will change and turn red, and the box will stay open (letting you overwrite the next instruction). Press ESC or click "cancel" to close it. You only need to overwrite one line. If you accidentally overwrite two, it really doesn't matter, just as long as you're only trashing the rest of the function which will no longer run. If you overwrite too much and it bothers you, use Alt+Backspace with the line highlighted to undo your changes.

7. Repeat for other disaster functions you want to disable (or stop and test what you have so far). Use Ctrl+N to get back to the symbol names window, and find other disaster functions such as "SetMeteor", doubling clicking on them to go to the function's code. Again, replace the first instruction with the last "RET" instruction for that function.

8. When you're done and ready to play, hit F9 to start the game up and play. It will run under OllyDbg with the modified (gutted) functions.


Note that these changes are only done in memory, and do not actually change the exe file on disk. This means it's fairly safe to do, as you can't screw up and permanently damage the exe file. It also means you'll have to go through the same steps each time you start the game up. (But you'll get pretty fast at it).  B)

Also, if you have a program running under a debugger, such as OllyDbg, and you close the debugger, you will also kill whatever is running under the debugger. This means  you'll need to leave OllyDbg open while you play. If you try to close it, it will kill the game, and you'll have to reapply the patches.


If you're successful with this, we can probably tell you how to save changes to disk as a new exe file. But, try them first to make sure you can get the patches working. :)
 

Offline newjack

  • Newbie
  • *
  • Posts: 11
Remove Or Disable Weather
« Reply #14 on: August 12, 2010, 04:54:14 PM »
Wow!! I will try this tonight and let you know how I make out with it. Hopefully I can do this without any real trouble. Thanks alot for all the info! I am really excited to play Outpost without the disasters!

Offline newjack

  • Newbie
  • *
  • Posts: 11
Remove Or Disable Weather
« Reply #15 on: August 12, 2010, 10:04:31 PM »
:lol: It worked perfectly!! Your instructions were exact, thank you very much Hooman! This is so cool! I am amazed at all the lines of code there is for this game! If a guy knew what he was doing you could probably change anything you wanted with that debugger program. I patched the .exe twice and was successful first try on both attempts (thumbsup)  So does removing the disasters using this method, affect the missions? For example, if I disabled the microbe, could a mission go on until I decide to complete the objective or would there be some other code in place to trigger the blight to flood the map? (Same with eruption for plymouth)

What will I need to do to create a patched .exe? I can see how doing this patch everytime could be a pain if I want to play often. Anyways, thanks again Hooman!

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Remove Or Disable Weather
« Reply #16 on: August 12, 2010, 11:01:55 PM »
The simple and slightly incorrect answer is no, there is no other way for disasters to appear once you gut those functions.

The real answer is, the levels are implemented as DLLs, which are executable code, and they could do whatever they wanted. This include undoing the memory hack that gutted the functions. However, it would be very bad practice for DLLs to simply do "whatever", such as patching the EXE that loaded them. None of the official levels "behave badly". Unless someone here went out of their way to write a custom level that still had disasters in them, despite the hack, this isn't going to happen. So, in theory, yes, you could still create disaster, but in practice, it just isn't going to happen.

Mind you, some of the expansion and mod DLLs we've written do patch the EXE file in memory at run time, but none of them really have anything to do with disasters. More like color mods, or extra VOL file loading, or the NetFix, and things like that.


As for saving the changes to disk, right-click in the CPU window and choose "Copy to executable" -> "All modifications". You may need to choose "Copy All" from a box that pops up. After that, a new copy of the CPU window will open with the modifications in it, not highlighted in red. Right-click on the new window, and choose "Safe to file". A box will pop up prompting you for the file name, with a default of the original executable name. I strongly advise you to change the name slightly, such as "Outpost2-NoDisasters.exe" or similar, rather than overwrite the original.

Note that the name of the INI file matches the name of the EXE file, so it will probably create a new one if you run a renamed EXE file. This will reset the settings to default values when it creates the new file. But, if it bothers you, you can always just copy and paste the contents of the old INI file to the new one.

 

Offline newjack

  • Newbie
  • *
  • Posts: 11
Remove Or Disable Weather
« Reply #17 on: August 13, 2010, 12:36:23 AM »
Ok thanks! Now I can kinda mess around with the code and what not and see if there are other things I can tinker with.. Of course I am not that great with programing in general but it will be fun to try :blink: . Thanks for all the help in getting me all setup with no disasters! Its kinda nice not hearing any of the weather warnings all the time :)  

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Remove Or Disable Weather
« Reply #18 on: August 13, 2010, 12:46:49 AM »
Quote
Its kinda nice not hearing any of the weather warnings all the time :)
Well, if that's all you wanted you could have disabled the warnings but kept the disasters.  ;)  
"As usual, colonist opinion is split between those who think the plague is a good idea, and those who are dying from it." - Outpost Evening Star

Outpost 2 Coding 101 Tutorials

Offline newjack

  • Newbie
  • *
  • Posts: 11
Remove Or Disable Weather
« Reply #19 on: August 14, 2010, 10:10:28 PM »
Just an update for you guys, I have tried many times to create the patched .exe file with no success. Everytime I make one, it crashes and must close when the intro starts up. I tried taking the .ini file from the original .exe, renaming it to match the patched .exe hoping that it would keep my game settings and skip the intro, however that did not work. If your wondering where the intro is coming from I have the original game CD in when playing because the game music is awesome! (thumbsup) (which does not have one scratch on it!) Anyway I have tried this with the version that I own on CD and also with the version I downloaded from OPU. The only changes I am making in the code are the disasters(earthquake,eruption,lightning,meteor and tornado) in the manner explained by Hooman. I have also tried running the .exe with out the CD but both patched .exe files (CD and Downloaded) both require me to have the CD in the drive. So is there another code line that needs to be changed? I thought mabey there is something I can do to make the game run without the CD like the downloadable version from OPU.

Offline Angellus Mortis

  • Full Member
  • ***
  • Posts: 138
Remove Or Disable Weather
« Reply #20 on: August 15, 2010, 12:22:46 AM »
You can download the game music so you do not need the CD. Look for the op2.clm file on outpost2.net under Outpost 2 Downloads.

And learn what an edit button is. =P
« Last Edit: August 15, 2010, 12:23:27 AM by angellus »

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Remove Or Disable Weather
« Reply #21 on: August 15, 2010, 12:29:42 AM »
Or copy the .clm file off the CD, since he has one.


What do you mean by "both require me to have the CD in the drive"? You haven't accidentally mixed files from two installs have you? That might very well cause it to crash. Does the game work normally when unedited? What about after applying the patches to memory and running it? You can still save the exe after it's been run and tested (provided you don't restart it along the way?).

If it's crashing, maybe try posting a crash address. Windows will usually give an address of where things went bad before closing a program on you.
 

Offline newjack

  • Newbie
  • *
  • Posts: 11
Remove Or Disable Weather
« Reply #22 on: August 15, 2010, 01:12:17 AM »
I would NEVER mix two different installs. When I try to run the patched .exe that I made...(I patched the stock game .exe and the downloaded game .exe separately. Basicly I have two versions of Outpost 2 on my computer. Just for trial purposes) ...The game runs perfectly unedited in both versions, and perfectly when I applied the patch in memory to both versions. It only crashes shortly after I try to run the new .exe file on both versions. When I try to run either game without the CD using the patched .exe files they will not run. The not running with the CD is not a factor sinse I like to have it in anyway. It was just a result from my .exe troubleshooting. Also I expected the stock game not to run without the CD but I am surprised the downloaded game won't sinse when you just download it and run it, it runs fine with no CD. I will try patching then play the game from memory to make sure it works then make the .exe after I've tested the patch. I will let you know how I make out with it.

Offline Arklon

  • Administrator
  • Hero Member
  • *****
  • Posts: 1269
Remove Or Disable Weather
« Reply #23 on: August 23, 2010, 07:42:23 PM »
Since someone else also asked about this, I wrote up a mod that disables disasters.
http://arklon.outpost2.net/other/DisasterlessMod.zip Extract to your Outpost2 folder.
Also, you may need http://arklon.outpost2.net/other/op2ext.dll (a fixed version of the DLL included with our version of OP2); that also goes in your OP2 folder.

You can start the mod using the included .bat file (or creating a shortcut with /loadmod Disasterless added to the target field). By default, only eruptions and blight are disabled. If you hold the shift key down during startup, all disasters will be disabled. To ensure the shift key is infact held down right at startup, highlight the .bat or shortcut, hold down shift, and press enter. (You can't press shift and double click as that will highlight a whole bunch of files instead of launching the clicked item.)
You can also load the mod by editing Outpost2.ini to load it. If the mod is loaded this way, you must hold the control key down or it won't patch anything (I did this as ini mods aren't as easily disabled).
The mod changes the internal version number, thereby disabling multiplayer with others who aren't running the mod.

The source has been committed to the SVN.
« Last Edit: August 23, 2010, 08:11:07 PM by Arklon »

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Remove Or Disable Weather
« Reply #24 on: August 24, 2010, 12:45:23 AM »
Hmm, very nice idea. Good job Arklon.