Stronghold 2

Stronghold 2

View Stats:
Daerandin Jul 16, 2022 @ 10:07am
2
3
3
2
2
5
Multiplayer AI fix
UPDATED: Version 0.3: Does not require constant running as it overwrites game instructions in memory that disable AI.

UPDATED: Version 0.2: Automatic PID detection. No interaction is required anymore. Simply run this tool, then run Stronghold 2 Steam Edition.

I made a little tool that should let you enable AI for multiplayer. Current version should work very well. The tool works for both Windows and Linux.

I have prepared both 32-bit and 64-bit windows executables. The download page is probably a bit shoddy at the moment, and I might never make it look better. What I might do is improve a bit on the instructions, possibly add pictures as well. Especially for the compilation instructions, I want to encourage people to compile stuff on their own.

Windows download: https://www.questforgaming.com/stronghold2/

AUR package for Arch Linux: https://aur.archlinux.org/packages/sh2_mp_ai_enabler

The source is available on gitlab: https://gitlab.com/Daerandin/sh2_mp_ai_enabler
Last edited by Daerandin; Jun 22, 2024 @ 5:06am
< >
Showing 31-45 of 121 comments
Boybou Jul 21, 2022 @ 10:31am 
amazing!
Daerandin Jul 26, 2022 @ 10:45am 
I have updated the source code so it will now find the PID automatically. I have ran tests both on Linux and virtualized Windows. I'm always suspicious that something is not working 100% virtualized so if anyone is up for compiling on their windows machine to test I'd be happy.

Just to be clear: You can now launch the AI enabler, then you launch Stronghold 2. No more interaction is needed.

If you use MSYS2, then there is also a makefile now, so you can simply compile with "make windows"

If you use Visual Studio then the makefile is probably useless. But I do hope it will compile without warnings and errors. If you get any warnings or errors with Visual Studio, please let me know, ideally by opening an issue on the gitlab repo.

Should things work as expected for those who want to test, please let me know here. Once I'm confident there are no issues, then I'll provide updated precompiled Windows executables on the page I set up.
Last edited by Daerandin; Jul 26, 2022 @ 10:45am
Loaf Cat Jul 27, 2022 @ 3:15pm 
Originally posted by Daerandin:
I have updated the source code so it will now find the PID automatically. I have ran tests both on Linux and virtualized Windows. I'm always suspicious that something is not working 100% virtualized so if anyone is up for compiling on their windows machine to test I'd be happy.

Just to be clear: You can now launch the AI enabler, then you launch Stronghold 2. No more interaction is needed.

If you use MSYS2, then there is also a makefile now, so you can simply compile with "make windows"

If you use Visual Studio then the makefile is probably useless. But I do hope it will compile without warnings and errors. If you get any warnings or errors with Visual Studio, please let me know, ideally by opening an issue on the gitlab repo.

Should things work as expected for those who want to test, please let me know here. Once I'm confident there are no issues, then I'll provide updated precompiled Windows executables on the page I set up.

Just compiled it myself using VS' developer command prompt with the "cl" function. Compiled without issues. Followed the application instructions. AI loaded into multiplayer without any manual PID input. Seems to work just fine.
wobbli Jul 27, 2022 @ 4:03pm 
It compiled cleanly using Visual Studio and on a full Windows install as opposed to a VM - works as expected.
Last edited by wobbli; Jul 27, 2022 @ 4:04pm
wobbli Jul 27, 2022 @ 7:55pm 
Originally posted by Daerandin:
I might revisit this at a later point if I get a better idea.
Perhaps similar to the NOP approach developed by JPNock that does not appear to be actively under development any more? I have suggested the opcode signature for that on his GitHub.
Daerandin Jul 28, 2022 @ 4:04am 
New version is out with automatic PID detection. No more interaction is required. Main post is updated to reflect a new version.

Thanks for the testing, in particular the compilation testing on VS. That helps a lot!
Daerandin Jul 28, 2022 @ 4:51am 
Originally posted by wobbli:
Originally posted by Daerandin:
I might revisit this at a later point if I get a better idea.
Perhaps similar to the NOP approach developed by JPNock that does not appear to be actively under development any more? I have suggested the opcode signature for that on his GitHub.

Yes I have thought of this, but modifying the text segment of process memory requires admin/root rights. I think I prefer having the program being able to run with just your regular user and no elevated privileges.
EaglePrince Jul 29, 2022 @ 10:44am 
Hey! We spoke at Stronghold Nation forum, now I'm here, so we can discuss it at one place.

Anyway, this is a great tool, although I haven't tested it yet. I agree with others who noted that it might be better to make the tool so that it doesn't collide with any of the Steam rules. I don't know much about that, I have to admit.

Also, I have yet to test the tool, and I will let everybody else know how it works. What I'm interested to know the most is how it works compared to the old Stronghold 2 AI Manager. For start, the old AI Manager was getting detected by antivirus as a troyan. It was a false positive, but still, it was an inconvenience. From what I heard here, this one doesn't have that issue, so that's a promising start for me! :)
Daerandin Jul 29, 2022 @ 12:09pm 
Originally posted by EaglePrince:
Hey! We spoke at Stronghold Nation forum, now I'm here, so we can discuss it at one place.

Anyway, this is a great tool, although I haven't tested it yet. I agree with others who noted that it might be better to make the tool so that it doesn't collide with any of the Steam rules. I don't know much about that, I have to admit.

Also, I have yet to test the tool, and I will let everybody else know how it works. What I'm interested to know the most is how it works compared to the old Stronghold 2 AI Manager. For start, the old AI Manager was getting detected by antivirus as a troyan. It was a false positive, but still, it was an inconvenience. From what I heard here, this one doesn't have that issue, so that's a promising start for me! :)

Hello, glad you found your way here.

I'm not that familiar with how different antivirus software work, but when it comes to unknown software I suspect they analyze the binary file for typical opcodes. I most certainly hope no software will detect my tool as malware, but considering that it specifically modifies the memory of another process, I suppose there is always the chance.

If the Stronghold Manager was detected as malware, that might be related to the fact that it modifies the 'text' segment of process memory. The 'text' segment is protected memory as it contains opcodes, which is essentially cpu instructions. Modifying these will require the software to be run as admin (root on Linux). I would not be surprised if this was more likely to trigger a false positive in antivirus software.
wobbli Jul 29, 2022 @ 4:06pm 
My understanding is that the "Stronghold Manager" was an exe of unknown origin from years back and it was this one that caused the virus alert concerns. Without any knowledge of the source and the fact that it seemingly can't be found now to download, it can be dismissed.

The utility developed by @jpnock that NOPs the opcode to stop the disablement of the AI in MP does not cause any such concern and appears to run without elevation. Obviously @Daerandin's works just as well by toggling the 'enable/disable' byte in memory on an ongoing basis whilst the game is running and has the benefit of not having to find the process ID yourself.

Two ways to achieve the same result - seems we are now spoiled for choice...
Last edited by wobbli; Jul 29, 2022 @ 4:18pm
Daerandin Jul 30, 2022 @ 3:30am 
Originally posted by wobbli:
My understanding is that the "Stronghold Manager" was an exe of unknown origin from years back and it was this one that caused the virus alert concerns. Without any knowledge of the source and the fact that it seemingly can't be found now to download, it can be dismissed.

The utility developed by @jpnock that NOPs the opcode to stop the disablement of the AI in MP does not cause any such concern and appears to run without elevation. Obviously @Daerandin's works just as well by toggling the 'enable/disable' byte in memory on an ongoing basis whilst the game is running and has the benefit of not having to find the process ID yourself.

Two ways to achieve the same result - seems we are now spoiled for choice...

Your post made me perform a little test, and you are correct! Seems I was mistaken about needing elevated privileges. I just assumed since that region of memory is marked as read-only. My code needs slight modification for Linux, since Linux does not permit writing to that region without first attaching to the process as a debugger but it can still be done as a regular user. As for Windows, no changes were needed.

I can update my program to do it in this way instead. The difference is this:

Now my program needs to constantly run. If you stop my program, and then host a multiplayer game, then you can't add AI.

With the changes, my program would perform the operation once, then shut down on its own since there is no need for it to keep running. The changes will remain in effect as long as the game itself is running. If you restart the game, then my changes will no longer be present and you would need to run my tool again to apply the changes.
Daerandin Jul 30, 2022 @ 4:26am 
I went ahead and updated the tool, main post also updated to reflect this. The new version will overwrite the instruction that disables AI, and then simply shut down as it does not need to run after that.

As an added bonus, the new version also lets you add randomized AI opponents in multiplayer, just like Kingmaker.

The older versions are also available on the download page, just in case someone would prefer how that worked.
Loaf Cat Jul 30, 2022 @ 5:45am 
Originally posted by Daerandin:
I went ahead and updated the tool, main post also updated to reflect this. The new version will overwrite the instruction that disables AI, and then simply shut down as it does not need to run after that.

As an added bonus, the new version also lets you add randomized AI opponents in multiplayer, just like Kingmaker.

The older versions are also available on the download page, just in case someone would prefer how that worked.

Nice little tweak. I was wondering why the random option wasn't enabled in prior patches! Thanks for the update :)
EaglePrince Jul 31, 2022 @ 12:40am 
Originally posted by wobbli:
Without any knowledge of the source and the fact that it seemingly can't be found now to download, it can be dismissed.
I have it on a CD.😁 Because an antivirus cannot delete anything from a CD.😆 If somebody would like to have a look, I could share it, though I expect the reason for its false detection doesn't matter much at this point.
wobbli Jul 31, 2022 @ 9:29am 
Originally posted by EaglePrince:
If somebody would like to have a look

I wouldn't use that old one - you don't know what else it might be doing unless you can review source.

The one here by Daerandin is safe to use
Last edited by wobbli; Aug 3, 2022 @ 7:52pm
< >
Showing 31-45 of 121 comments
Per page: 1530 50