Coder Social home page Coder Social logo

thereddaemon / littlecrusaderasi Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 2.43 MB

LittleCrusaderAsi is a modification for Stronghold Crusader 1 that applies changes during runtime.

License: MIT License

C++ 99.96% C 0.04%
stronghold-crusader stronghold crusader mod modification overlay

littlecrusaderasi's Introduction

LittleCrusaderAsi

Table of contents

Summary

LittleCrusaderAsi is a modification for Stronghold Crusader 1 inspired by the awesome work on the UnofficialCrusaderPatch. The later provides a ton of features and is quite flexible when it comes to version compatibility. However, the patcher modifies the executable, which requires restarts if something needs changes.

The LittleCrusaderAsi tries to tackle this issue by using a very common technique when it comes to modding. The modification uses an AsiLoader (see Installation) to load a Dynamic Link Library (dll, just named asi in this approach) into the address space of a program. That allows to execute additional code and modify the software during runtime.

The implementation tries to grant individual features a lot of freedom how to handle issues like missing addresses, so version compatibility is provided on a per feature basis.
That being said, as long as no one with other versions then 1.41 and 1.41.1-E digs through the addresses, the mods will mostly be limited to the later. Additionally, the restriction is further defined by the mod being so far created using a German crusader version. As a result:

Full compatibility so far is only guaranteed for Crusader versions 1.41 and 1.41.1-E and only if they are codewise identical to the german version. (A guess would be that this includes all using the latin alphabet, like the english version.) Other "versions" of 1.41 and 1.41.1-E might even create crashes at the moment, since the current system might not know how to handle them. (There are reports of problems with the Russian version and the UnofficialCrusaderPatch, so this might be a candidate.) In all other cases (for example version 1.2), the feature should simply not work and the issue will be written to a log file.

For more information on the implementation approach and structure, please take a look at the README inside the src-folder. I hope it is a good read for everyone who wants to contribute. ^^

Installation

Getting LittleCrusaderAsi

Go HERE to get the latest release.

The project can also be build from source. It is written in C++17 and the repository contains a Visual Studio 2019 project. One must make sure to use the Win32 mode and (for DEBUG mode) redefine Properties->General->Output Directory and Properties->Debugging->Command, since both are currently configured to allow debugging the dll and point therefore in the file structure of the latest who edited the project file.

Getting an AsiLoader

LittleCrusaderAsi relies on a third party tool that loads it into the process. Basically only one tool was tested, but more or less two variants are possible:

  • Using Ultimate-ASI-Loader directly. The release will contain a 'dinput8.dll' which needs to be placed in the game root directory. However, it needs to be renamed into a dll the game loads. One that works is 'ddraw.dll'. Other names might be possible, but were not tested. Now the game will load ASI files placed in the game root directory or the folders 'scripts' or 'plugins', if they are created inside the game directory.

  • Using DxWrapper, which uses code of the Ultimate-ASI-Loader to provide the same feature alongside a ton more, like Dd7to9. The later allows stuff like running the game in window mode (with a few issues, like the cursor not being bound to the window). For the installation, please refer to the DxWrapper documentation. In short, it is required that the provided 'ddraw.dll' is placed in the game root folder alongside 'dxwrapper.dll' and 'dxwrapper.ini'. The asi-loading needs to be activated in the 'dxwrapper.ini'. It also supports the folders 'scripts' and 'plugins'.

Both have also additional features, but if interested, please refer to their documentations. Furthermore, loading LittleCrusaderAsi into the process by other means may also work, but there are no guarantees.

Location of files and configuration

First, all now mentioned files need to be placed in the same directory. This might either be the game root, or one of the supported folders 'scripts'/'plugins' (recommended).

Currently three files are needed:

  1. The 'LittleCrusaderAsi.asi' of course.
  2. The 'logger.config', which is the configuration for the logger. Simply using the file HERE is enough. For customisation please refer to the easylogging++ documentation (see Dependencies). Omitting it will result in the use of a default configuration.
  3. The actual 'modConfig.json'. This file contains the mod configuration. THIS non valid json-file will contain examples for every possible adjustments and features.

If the asi-file is missing, it will not work. If the modConfig is missing or invalid the mod will crash with a log. Log output is written to a file named 'crusaderAsi.log', which will be overwritten on every start and generated in the same folder as the other files. In case of a noticed exception or if requested by a feature, the log will be copied and renamed on exit. Hard crashes (in case of corrupted memory for example) will likely not show up in the log.

At the moment, configuring the modification is kinda clunky. The focus for now is on functionality instead of usability. However, if anyone wants to provide a GUI for generating the configuration json, feel free. ^^
In the future it might also be possible to define the configuration in the overlay menu and save it at the end, but this is currently not possible.

Current Features

A list of the features currently provided by the LittleCrusaderAsi. The short summery will not contain in-depth details regarding the configuration. Please search in the Example Json after the feature name to get information about the configuration.

KeyboardInterceptor
Supported versions: All (in theory)
The keyboard interceptor has two features. First, implementation utility. It allows other mods to register key functions and to receive text input. Second, it allows to redefine keypresses. The later is directly handled through the configuration of this mod. It is therefore possible to tranform a press on the 'a'-key to a press on 'b'. However, this is only possible for single keys and is done by catching the actual key and telling the game another was pressed. As a result, combinations like 'shift+a' are carried over (for example would become 'shift+b') and text inputs are unreliable. To circumvent this issue the interceptor as a whole has a configurable on/off-key.

BltOverlay
Supported versions: V1.41.1-E | V1.41
Not directly a feature that changes the game, but the most noticeable utility. Mods are now able to provide menus that can be accessed by using an overlay menu. It also provides a console window that can display some log messages. For more informations on the current sub-menus, please refer to THIS file.

BuildRangeChanger
Supported versions: V1.41.1-E | V1.41
A simple modification that allows to change the castle build range. Can be configured to be active at start, can register a key function used for activation (with activated KeyboardInterceptor) or be configured in more detail by using the BltOverlay menu. Ranges are defined by map size. Key function allows toggle between vanilla and custom values. The AI will build walls regardless, but no towers if they fall out of range.

AICLoad
Supported versions: V1.41.1-E | V1.41
AIC loader of the LittleCrusaderAsi. The mod was created to support the file format defined by the UCP (2.14) (Example with vanilla AIC). This mod posseses a lot of features, among them the ablilty to load new AIC files, define their load order, a live editor and the possiblity to save the current custom values. Please check out the Example Json and the Menu Description for more details.
Note that all AIC values are currently applied per value, so it is possible to carelessly create AI-amalgamations if one does only define half of the Rats values, while having an AIC with another Rat in line.

One last note. Not all log messages are displayed in the text console and there is also currently no way to scroll back. So if in doubt, check the log-file created in the mod directory.

FAQ

A place for questions some might have.

  1. Is LittleCrusaderAsi compatible with the UCP?
    A test with version 0.1 of LittleCrusaderAsi and version 2.14 of the UCP (with not all but multiple features enabled) yielded no obvious errors. Version 0.2 was not tested so far, but the only changes to processes are to some of the main DirectDraw functions, which seem to be untouched by the UCP so far? I am rather sure there should be no issues. That being said, using AIC modifications in both the UCP and LittleCrusaderAsi might lead to unwanted overwrites. For example, the "default values" in the editor menu will be the values installed by the UCP.

Credits

  • TheRedDaemon - Maintainer and Developer
  • The people of the UCP - Indirect supporters, by finding knowledge that can be taken. :-)

Additional Information

License

This repository is licensed using the MIT License.

Dependencies

LittleStrongholdAsi uses third party tools/code.
You will find them together with a copy of their licenses under THIS folder.

Dependency Used Version Notes
Easylogging++ 9.96.7
JSON for Modern C++ 3.9.1
DDFontEngine - Old Tutorial for DirectDraw fonts. Classes themselves unused, but kept for reference.

Other Crusader projects

There are a handful of projects on GitHub for Stronghold (Crusader) 1. So take a look. After all, every development might be helpful for other projects.
(Note: Without any claim to comprehensiveness.)

  • Was the UnofficialCrusaderPatch already mentioned? ^^
  • The Gm1KonverterCrossPlatform is a tool developed for easier editing of all kinds of Crusader textures and sprites.
  • While the Sourcehold main project seems to laying dormant at the moment (October 2020), it might still be worth a look.
    • As an interesting subproject, sourcehold-maps tries do analyze how the map files are structured and is still active (October 2020). Who knows what might be possible by only messing with the map files?
  • Any more suggestions? Feel free to add them (as long as they are related to Stronghold at least)!

Special Thanks

Basically everyone involved with and thanked by the UnofficialCrusaderPatch. So pass the thanks down the thanks tree. ^^

And especially Firefly Studios for the creation of the Stronghold series. There can not be a mod without a game in the first place...

littlecrusaderasi's People

Contributors

thereddaemon avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

littlecrusaderasi's Issues

TheRedDaemon / LittleCrusaderAsi/

2021-10-05 16:09:12,280343 INFO Logger loaded.
2021-10-05 16:09:12,281341 INFO Configuration loaded.
2021-10-05 16:09:12,281341 WARNING AICLoad: 'keyConfig': No 'applyAICFiles' found. The file AICs can not be applied using only this mod and the keyboard. However, should BltOverlay not exist, 'reloadMain' and 'reloadAll' will also do this.
2021-10-05 16:09:12,281341 INFO Mods loaded.
2021-10-05 16:09:12,281341 INFO AddressBase initialized.
2021-10-05 16:09:12,281341 INFO Detected Stronghold 1.41.
2021-10-05 16:09:12,281341 INFO VersionGetter initialized.
2021-10-05 16:09:12,281341 INFO AddressResolver initialized.
2021-10-05 16:09:12,281341 INFO KeyboardInterceptor initialized.
2021-10-05 16:09:12,288322 INFO BltOverlay initialized.
2021-10-05 16:09:12,288322 WARNING AICLoad: Unable to load file 'ratWolf.json'. Is the name or the aic folder wrong?
2021-10-05 16:09:12,288322 WARNING AICLoad: Unable to load file 'wolfRat.json'. Is the name or the aic folder wrong?
2021-10-05 16:09:12,288322 WARNING AICLoad: Unable to load file 'vanilla.json'. Is the name or the aic folder wrong?
2021-10-05 16:09:12,288322 INFO AICLoad initialized.
2021-10-05 16:09:12,288322 INFO BuildRangeChanger initialized.
2021-10-05 16:09:12,288322 INFO 7 of 7 mods initialized.

i didn't have mod button Please help there can i fix it
directionarystronghold crusader
files

Thinking about the possibility of an in-game overlay menu.

An in-game overlay menu (and may it be independent of the current game situation) would be a game changer, and would allow interactive control over the features. However, there are some problems.

Stronghold Crusader uses some version of DirectDraw for rendering (at least, that is what i assume).
While there are several overlays for DirectX 9 and beyond, I was not able to find a complete solution for DirectDraw so far.

It is clear, that some part of Crusaders Rendering pipeline needs to be hijacked, but I am unsure where, what and how.
Another later part would be to figure out how to get DirectDraw to draw some boxes and text. That would actually be enough for such a menu.
The KeyboardInterceptor could provide the controls, that should not be a problem.

One additional restriction would be the interception of the DirectDraw calls.
Many tutorials for DirectX 9... overlays use the method that currently loads the LittleCrusaderAsi. They create a surrogate DirectX dll and place it in the folder. Windows will now load that instead and one can now execute their own code. While likely also possible for DirectDraw, I would prefer if LittleCrusaderAsi can be kept independend of the actual loader.
Additionally, it would be awsome if the functionality of features like Dd7to9 could be sustained, further narrowing the possible options.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.