Skip to content
This repository has been archived by the owner on Jan 22, 2023. It is now read-only.

TheRedDaemon/LittleCrusaderAsi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

96 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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...