-
Notifications
You must be signed in to change notification settings - Fork 0
Mod Creation: The Project Environment
This guide will go over how to start a new mod for Wizard of Legend from scratch:
- Creating visual studio class library
- Adding the necessary project references
- Writing a BepInEx Plugin
- If you haven't already, download Visual Studio Community.
- Start Visual Studio, and create a C# Class Library (.NET Framework)
- Choose the
Project name
you wish, theLocation
you wish - For
Framework
, choose.NET Framework 3.5
. - You're well on your way! Optionally, if you plan to upload this to a git repo, download a .gitignore for visual studio and place it in your solution folder
You can simply download the lib folder here and use those. All the necessary references should be ready to go. If you do, skip to step 4
If you want (or, for any reason, need) to grab the references yourself:
- Create a folder in your project directory called
lib
. - Assuming you've installed BepInEx and have run the game modded (if not, download BepInEx Here)
Navigate to the folderBepInEx/core
, and copy all the files in there to yourlib
folder. - Assuming you've run the game with HookGenPatcher (if not, download Here, install, and run the game once)
Navigate toBepInEx/plugins/MMHOOK
folder and copy theMMHOOK_Assembly-CSharp.dll
to yourlib
folder. - Navigate to your game's executable folder. Go to
Wizard of Legend\WizardOfLegend_Data\Managed
and copy overUnityEngine.dll
andUnityEngine.UI.dll
to yourlib
folder.
You only need one more dll to reference, but for that you're going to need to publicize
The reason we do this is to access the game code's private fields in our mods. This opens many doors for our mods without the need of something like reflection.
- Download NStrip.
- Download latest release and unzip.
- Open console command in the folder where you unzipped.
- Run the command
.\NStrip.exe -p -cg -cg-exclude-events -remove-readonly <FULL_PATH_TO_WOL_FOLDER\WizardOfLegend_Data\Managed\Assembly-CSharp.dll>
. - This should spit out a new .dll with all the method bodies stripped, and fields publicized.
- Finally, add this new .dll to your
lib
folder.
If you plan on adding relics, robes, and/or arcana you'll be using LegendAPI.
For this, or any other mod you want to use the code of, you need to add those as references as well
(Again, if you're using the template, a LegendAPI.dll should already be there)
- Find the mod on wizard-of-legend.thunderstore.io.
- Manually download the latest version.
- Unzip the downloaded mod, find the .dll file and add it to your
lib
folder.
With all the assemblies gathered, you can now add them all to your project's references:
- Back in Visual Studio, find the solution explorer on the right. Under your CSharp project, right click
References
and chooseAdd Reference...
- Navigate to your
lib
folder, and add all .dll files
In order to use the publicized Assembly-CSharp.dll
, you need to have these lines anywhere in your codebase:
using System.Security;
using System.Security.Permissions;
[assembly: SecurityPermission( SecurityAction.RequestMinimum, SkipVerification = true )]
For organization, I usually create a new file called ModAccess.cs
with only these lines.
This is where basic knowledge of classes, functions, and attributes in C# will come into play. If you do not have that, it should be quite easy to get online.
- Your CSharp Project in Visual Studio usually starts with a base class called
Class1.cs
. - Rename this class and file to whatever you like, conventionally ending in
Plugin
(For exampleMyCoolModPlugin
) - Make this class inherit from
BaseUnityPlugin
and add theBepInPlugin
attribute like this:
[BepInPlugin("CoolAuthorName.CoolModName", "Cool Mod Name", "0.1.0")]
public class MyCoolModPlugin: BaseUnityPlugin
{
void Awake()
{
}
}
This is the basis of every mod. Your mod should now work! It won't do anything, but you can build this project and Bepin should load it.
(if it doesn't, ping thetimesweeper
on discord and tell him he FUCKED UP)
Your project environment is set up to start modding.
Continue to the First Mod guide to learn more about the BaseUnityPlugin
you've just created, and how to take your mod further.
After you've understood that, if you'd like to create Relics (Items), Robes (Outfits) or Arcana (Skills), refer to the Custom Content
pages on this wiki.
Good luck and have fun!