Skip to content

Fundamentals of Plugin Writing

Fexty edited this page Sep 29, 2021 · 5 revisions

Making a plugin

Table of contents

A frequently asked question is, "how do I create a plugin". But the truth is, that there is no one way to "make a plugin". All a plugin is, is a dll, which is injected into the game by strackers plugin loader.

Plugins are not something that Capcom implemented to allow easy extension of game functions. In fact, they didn't implement them at all, they are completely custom.

Now to actually "making" one. Plugins are generally written in either C or C++ but there is the possibility of making one in C# (however that won't be covered in this guide).

Setting up the environment

First and foremost you should install an IDE to assist you. For windows development I recommend using Visual Studio. This entire guide will be based on VS2019, so if you prefer to use a different IDE, you will have to figure it out on your own.

Go ahead and download the Visual Studio 2019 Community Edition, the community edition is free. After downloading, install the software like any other. After it is done installing, the Visual Studio Installer should open, this is the package manager for the IDE. You're gonna want to install Desktop Development with C++.

Creating a project

Once you have Visual Studio open, click on File > New > Project. Select Dynamic Link Library (DLL) from the project template selection window. This will create a new project for you with everything you need.

The usual main.cpp file will be called dllmain.cpp. Inside it you will find a function called DllMain, this is the entrypoint for your plugin.

From here you can either make any changes you need, or create a new thread in which your plugin will run.

BOOL APIENTRY DllMain(HMODULE hDll, DWORD dwReason, LPVOID lpReserved)
{
  if (dwReason == DLL_PROCESS_ATTACH)
  {
    // your code here
  }
}

If you prefer to create a new thread, you need a thread function. That could look something like this

DWORD WINAPI DllThread(LPVOID hDll)
{
  // your main loop here

  FreeLibraryAndExitThread((HMODULE)hDll, 0);
  return 0;
}

And to actually create the thread, call the CreateThread WinAPI function:

CreateThread(nullptr, 0, DllThread, hDll, 0, nullptr);

Logging to the loader console

Stracker's loader initially starts a console and displays certain logs there based on the users LogLevel. Any plugin loaded by Strackers loader can make use of that console and log to it as well.

This is really useful for both debugging purposes, and for communicating information to the user, such as warnings, possible errors, or even simple status messages.

First head over to the Loaders GitHub page and grab the loader.h and loader.lib.

Drag both of those files into your project directory. Following that you need to open your project properties in Visual Studio, to do so, simply right click your project in the Solution Explorer and click Properties.

Go to Linker > Input > Additional Dependencies and add loader.lib to it.

Then save and close the project properties, right-click the Header Files filter in the Solution Explorer and click Add > Existing Item. From the file explorer window, select the loader.h file.

Now in your dllmain.cpp include the file:

#include "loader.h"

And to make things easier, use the namespace:

using namespace loader;

Now you can make log statements from anywhere in your code.

LOG(loglevel) << "text";

Example:

LOG(DEBUG) << "This is a DEBUG log";
LOG(INFO) << "This is a log with loglevel INFO";
LOG(WARN) << "This is a WARNING";
LOG(ERR) << "This is an ERROR";

The log class is a stream object and works just like any other stream in C++, such as std::cout or std::stringstream.

Compiling and loading

To compile your dll, make sure you have x64 selected as architecture and Release as configuration. Then simply hit Ctrl+B or Ctrl+Shift+B to build.

Your dll will be in ${SolutionDir}/x64/Release/<project-name>.dll. Now just go ahead and copy this dll to nativePC/plugins and launch the game.

You have successfully created a plugin!

General Tutorials

General Tutorials

Animation Tutorials

Animation Tutorials

Audio Tutorials:

Audio Tutorials

IDs:

File & In Game IDs

Model Tutorials:

Model Tutorials

Effects Tutorials:

EFX Tutorials

FSM Tutorials

FSM Editing

MRL3 Tutorials:

MRL3 Tutorials

NPC Editing:

NPC Editing

Map Editing:

Map Editing

Plugins and Memory Editing:

Plugins and Memory Editing

Quest Editing:

Quest Editing

Monster AI Editing:

Monster AI Editing

Texture Tutorials:

General Texture Tutorials
Specific Texture Tutorials

TIML Editing

TIML Editing

Asterisk's Plugin Notes:

Asterisk's Plugin Notes

Miscellaneous Tutorials:

Miscellaneous Tutorials

Outdated Tutorials:

Outdated Tutorials
Clone this wiki locally