DynRPG v0.32 Unofficial
Plugin SDK
|
The RPG Maker is written in Delphi (and I didn't have access to the source code of its classes, etc.), while my SDK uses C++. Thus, many things are not working the way you might expect.
There is a set of rules which you must follow under all circumstances when you are developing a DynRPG Plugin:
false
from a callback function. This will "lock out" all plugins which are called after yours. Only return false
if you really want this behavior. vTable
member of a class. This will make the game crash sooner or later (probably sooner). char *
to an RPG::DString pointer. It will appear to work, but it will cause the game to crash with an "Invalid pointer operation" error when the RPG Maker tries to free the string. Also, do not store RPG::DStringPtr objects or RPG::DString pointers inside your plugin, but copy their content to a std::string
instead, since RPG::DString objects may suddenly vanish. There is also a set of guidelines which you are strongly advised to follow, but there might be cases in which there is a better solution.
Comments in event scripts are a great way to let events scripts invoke functions of your plugin. Please follow the following guidelines:
@
sign, immediately followed by the command name. 5.5e+6
for 5.5 million). He said ""hello"" and smiled
) V
character prior to the variable ID. This should also work with multiple levels of dereferencing. N
character prior the the actor ID. This should also work together with V
.false
from onComment when you found a known command, regardless whether the parameters were valid or not. true
from onComment when you didn't find a known command, even though you may have found an @
sign at the beginning of the comment.Use the parsedData
parameter of your onComment handler to get the comment data in an already nicely parsed form!
Example for a "special" comment:
The command name is foobar
.
The first parameter is numerical.
The second parameter is a string.
The third parameter is a numerical value read from variable #55.
The fourth parameter is a numerical value read from the variable whose ID is stored in variable #66.
The fifth parameter is a string, read from the name of actor #7.
The sixth parameter is a string, read from the name of the actor whose ID is stored in variable #8.
The seventh parameter is a token named nothing
.
You might advise users to download RPG Maker 2009 Ultimate if they need to enter comments longer than 4 lines.
Many plugins need some kind of configuration. An important rule is: Make as many things configurable as possible.
If possible, store configuration in a DynRPG.ini
file. Also, you should use your plugin's name which you get as parameter to the onStartup function as section name. If you need several sections, you can append an underscore and an additional identifier to the name and use it as section name. This will prevent conflicts with other plugins while still combining all relevant configuration of a game in one file.
You may use the RPG::loadConfiguration function as a convenient way to load configuration data to a std::map<std::string, std::string>
in the onStartup function.
If you need more or more complex configuration, like XML data, use a filename containing your plugin's name.
Your plugin may also use data which is changed in-game and needs to be preserved. Savestate-independent data (like a highscore) should be stored in the DynRPG.ini
file together with configuration (use the WinAPI function WritePrivateProfileString).
Savestate-related data (data which should be saved when the user saves the game and loaded when the use loads a saved game) should be saved using the function passed as savePluginData
parameter to the onSaveGame function. When the user loads the savestate again, you will get the same data back, in the parameters to the onLoadGame function. Internally, this data is saved in a file called SaveXX.dyn
where XX
is the savestate ID.
An example usage of savestate-related plugin data is shown here:
(Of course, the same result could have been achieved by saving score
and level
in in-game variables which are automatically saved.)
Time is a very important factor. Especially with many plugins, it is important to use as little time as possible in your callback handlers, otherwise the game will eventually start lagging. Thus, try to optimize your code where you can. If possible, always test your plugin with several other plugins in a "real-life situation" to see whether your plugin slows the game down too much. Remember that most of your code will be executed a minimum of 60 times per second (many parts more often than that, for example onCheckEventVisibility will be called 900 times per second if there are 150 events on the map).
Here is a bit of advice how to optimize your plugin code:
maskColor
to RPG::MASK_NONE). The same rule applies for RPG::Canvas::draw, see also RPG::Image::useMaskColor.