Dawn of Man
十分な評価がありません
How to create your own mod with MelonLoader
作者: radomiej
A modding guide for DoM. Not related to scenario modding, but on internals of game itself.
   
アワード
お気に入り
お気に入り
お気に入りから削除
Installing MelonLoader
Required if you want to use mod made for this game.

Download MelonLoader installer from: https://github.com/LavaGang/MelonLoader.Installer/releases/latest/download/MelonLoader.Installer.exe

Launch the installer and you should see that :




Now click on "Select" button and open your DoM exe file.
If you don't known the installation path, you can obtain this information through steam, in your library click right mouse button on the DoM -> Manage -> Open local files (or something like this)

Unselect latest and choose version 0.5.7

Click on "Install".

You should see now a bunch of new folders/files into your main folder :



Congrats ! You installed the loader for mods !
Install MelonLoaderPreferences mod
This plugin allow you to customize some of mod properties, if they are exposed. Otherwise you can edit them only by editing config files in mods.

Guide on how to install MelonLoaderPreferences for MelonLoader:
https://github.com/sinai-dev/MelonPreferencesManager

Download: https://github.com/sinai-dev/MelonPreferencesManager/releases/latest/download/MelonPrefManager.Mono.zip
How to make first mod in MelonLoader
Requirements:

You should have installed MonoLoader for DoM.
You need to known some basic of C# and have installed any IDE for this e.g: Visual Studio, Rider.

Some useful information
Target platform: Mono
Target .NET: 3.5
Unity version: 2017.4.40f1

Create new C# library project



Add core dependencies
To make mod operational you need to add some essential dependencies. In Rider you can add dependency by clicking:



And then Add From...



Core MelonLoader dependency: you can find it in your game installation folder in [DoM]/MelonLoader/MelonLoader.dll

0Harmony dependency: add support to replace/override existing game function and change value they return. To found in {DoM}/MelonLoader/0Harmony.dll

Assembly-CSharp: is the all your modding game logic, here happens the magic :) To found in: {DoM}/DawnOfMan_Data/Managed/Assembly-CSharp.dll

Unity core modules: allow for essential operations on unity api. E.g adding new stuff, spawning, modify the UI requires access to this api. Here their list:

  • DawnOfMan\DawnOfMan_Data\Managed\UnityEngine.CoreModule.dll
  • DawnOfMan\DawnOfMan_Data\Managed\UnityEngine.InputModule.dll
  • DawnOfMan\DawnOfMan_Data\Managed\UnityEngine.UI.dll

The Unity modules you wish to use can vary based on what you try to achieve. But for most general stuff it should be enough.

Finally you should have following list of dependencies:



Make entry mod class
Now we can prepare your entry for mod. Let's change the name of our placeholder Class1.cs to for example MyFirstMod.cs and add basic stuff:



Update AssemblyInfo.cs
You should update the AssemblyInfo and provide your main class to allow ML run your mod(also you can add some additional information's).


Setting the entry class in MelonInfo is essential.

After this we are ready to GO!

Write our own mod logic
Here is the part for you to brilliant :)
On this guide purpose I've make mod that will print in MelonLoader console the current temperature, because why not :D


Build your mod
In Rider IDE it's named Build your solution, and have icon of green hammer. What is important, it should make dll with your mod somewhere in your project directory:


Grab this dll and put into {DoM}/Mods folder. Here we go!


Run your game
At this point you can add additional options for your lunching params in steam for DoM:
--melonloader.consoleontop
it make console to popup when you lunch the game. It's not necessary but helpfully.

After looking at your melon console you should see that your mod was loaded successfully:

and after a while you should start getting errors every one second (we don't make null safeguard - as for first exercise you can try to fix it) but after we start new game or load one it start showing current world temperature.




And that it! We make and run our own mod.
For more information I'll send you to:

In the feature there could be also new section how to work with current DoM internal code... we will see.
How to import DoM into UnityEngine for MAX modding power
Thanks to MelonLoader you can make great mod that change logic. But loading DoM into Unity add you super power and unleashed your limit :D This is what make DoM best moddable game every in their type. You got great modding tool for free. And it allow you to add new models, shaders, materials and plugins as AssetBundle.

Download AssetsRipper
https://github.com/AssetRipper/AssetRipper/releases


Open Game and Export Stuff
Extract AssetsRipper somewhere and Launch it.
Then File -> Open Folder -> Select DoM installation folder
Wait some time
Then Export -> Export All -> Select any place when you want to store your ripped game assets
Wait some time or go to next section.

Download Unity 2017.4.40f1

Download and install
https://unity.com/releases/editor/whats-new/2017.4.40

Run Unity and open your project
It's may be required to make unity account or something like this. Assume that you make it on your own.

You can find your ripped project folder in your {ripper folder}/DawnOfMan/ExportedProject
Note: if you wish you can move it somewhere else or change name to be more clearer show project name e.g.: "DoMRipped"

If you got monit about API Update Required just click "I Made a Backup, Go Ahead!"

Fix some things
To make run the project in editor, you need to fix some missing parts.

1. Fix steam api error:
Replace initGameApi() in Platform.cs:

To:

private void initGameApi()
{
GameApi gameApi = null;
string[] registeredFolders = new string[3] { "Profile", "Settings", "Saves" };
gameApi = new GameApiGeneric(new GameApiGeneric.ParamsGeneric(registeredFolders));
gameApi.init();
}



2. Fix Graphics.Blit
At this moment only ad-hoc fix. You need to iterate over all error messages in Unity, each time click play and double-click error, then change pass argument to 3

3. Download my toolset
link: https://www.dropbox.com/s/tfpis39v39r9sxk/DoM-ModdingTools.zip?dl=0
extract content to Asset folder. Now you should see new menu item on top bar: Modding
It's not necessary but help you a lot

4. Fix Textures types
Run: Modding -> Convert PNG to Texture2D
Wait some time

5. Fix bad extansion of some files
Scenario and languages files are wrong ripped, so we need to fix it.
Run: Modding -> File Extension Converter -> Convert DawnOfMan

6. Add camera fix
Open scene DawnOfMan and add to GameBehavior object component: FixBlackCamera

7. Fix EditorUtil.cs
Replace getAssetPath with follwoing code:

public static string getAssetPath(UnityEngine.Object obj)
{
#if UNITY_EDITOR
return AssetDatabase.GetAssetPath(obj);
#else
throw new Exception("Can not call AssetDatabase.GetAssetPath in game");
#endif
}


add missing imports

8. Fix animation system
Replace method loadInternalAnimations in the file PhysicalEntityType.cs with following code:
private void loadInternalAnimations()
{
Dictionary<string, AnimationInfo> internalAnimations = getInternalAnimations();
if (internalAnimations == null)
{
return;
}
mAnimations = new AnimationVariants[88];
foreach (KeyValuePair<string, AnimationInfo> item in internalAnimations)
{
string key = item.Key.Replace(mAnimationId + "_", string.Empty);
string cleanName = RemoveNumericSuffixAndUnderscore(key);
string value = Util.lowerCaseToCamelCase(cleanName);
AnimationType animationType = (AnimationType)Enum.Parse(typeof(AnimationType), value);
mAnimations[(int)animationType] = new AnimationVariants(new AnimationInfo[1] { item.Value }, null, null);
}
}

public static string RemoveNumericSuffixAndUnderscore(string str)
{
for (int i = str.Length - 1; i >= 0; i--)
{
if (!char.IsDigit(str))
{
string numericSuffixRemoved = str.Substring(0, i + 1);

for (int j = numericSuffixRemoved.Length - 1; j >= 0; j--)
{
if (numericSuffixRemoved[j] == '_')
{
numericSuffixRemoved = numericSuffixRemoved.Substring(0, j);
}
else
{
break;
}
}

return numericSuffixRemoved;
}
}
return "";
}


9. Run the game



How to make AssetBundle and load it in game
Thanks to AssetBundle you can add new models and assets to your game.
In this section, I'll describe how to do it.
//TODO fill content
4 件のコメント
radomiej  [作成者] 2024年8月4日 6時35分 
Unfortunately(for this modding guide) game developers updated version of unity and not many people want to have this kind of mods so I've abandoned this modding section, but you can find information about it somewhere at internet and try it on your own. Thanks
Tyrannohotep 2024年7月11日 17時44分 
When will the info on AssetBundle be added?
bytelab 2024年2月28日 10時13分 
Only one comment?! You put so much work into this and it turned out really good. Not many short tutorials with references included. Thank you :)
Edztえどぜて 2023年7月28日 12時38分 
it's troublesome for me to install it, is there an advanced way like to simply press subscribe, let Steam put the beloved package into our game, we go in-game, activating it, easy to use mod