+++ DYNRPG - THE RM2K3 PLUGIN SDK +++

Posts

Mkay, it's been awhile since I tried C++ but I'll give it a shot.

...So far, so good, it compiled. Now let's run a test with some program.

It didn't run in time. I'll try something else.

// Save Load Switches
// by bulmabriefs144

#define AUTO_DLLMAIN
#include <DynRPG/DynRPG.h>
#include <sstream> // For std::stringstream

std::map<std::string, std::string> configuration;

int LoadSwitch;
int SaveSwitch;
//I wanna have it run using config

bool onStartup(char *pluginName) {
// Store configuration
//std::map<std::string, std::string> configuration;
// Load configuration on startup
configuration = RPG::loadConfiguration(pluginName);
LoadSwitch = atoi(configuration["LoadSwitch"].c_str()); // atoi is the easiest way here to get an integer
SaveSwitch = atoi(configuration["SaveSwitch"].c_str());
return true;
}

void onLoadGame() {

RPG::switches[LoadSwitch] = true;

}

void onSaveGame() {
RPG::switches[SaveSwitch] = true;

}
Update: Latest Code.

It compiles, but doesn't seem to spit out anything. Lemme retry. Btw, I have BetterAEP on the test program. I think I'll experiment with the callbacks.

There may be something wrong with my compiler? Since I added the new DynRPG patch (the one with quick_patches), lately I've had trouble having new plugins work. They work on compile but not on the actual test part.

Update (again): I tried straight numbers, and stripping this down to the onLoadGame callbacks. No dice.
Your onLoadGame and onSaveGame callbacks have the wrong signature. See documentation.
Ah. Nothing inside the parentheses.

So onLoadGame gets id, data, length, and onSaveGame gets...

It's just me, but it looks like there are two different signature sets you can use, is this correct? Which do I use, SavePluginData, or the one with void __cdecl(*)(char *data, int length (i don't even know how to write that, it sounds like you're declaring another callback or function inside the first).

Oh, good thing for In-Game Data.

void onLoadGame(int id, char *data, int length) {

void onSaveGame(int id, void __cdecl (*savePluginData)(char *data, int length)) {

This will work?
Hey Cherry, how exactly can you play a system sound or bgm file. I'm trying to write a plugin that lets you do this on onComment, but I'm not having any luck. Here's what I've tried:

if!cmd.compare("bgm_battle")){
RPG::system->battleBGM->play();
}

When I added @bgm_battle comment, this just seemed to stop the currently playing music. I then tried to piggy-back a Play BGM command by doing this:

if(!cmd.compare("bgm_battle") && nextScriptLine->command == RPG::EVCMD_PLAY_BGM) {
nextScriptLine->stringParameter = RPG::system->battleBGM->filename;
nextScriptLine->parameters[0] = RPG::system->battleBGM->fadeInTime;
nextScriptLine->parameters[1] = RPG::system->battleBGM->volume;
nextScriptLine->parameters[2] = RPG::system->battleBGM->speed;
nextScriptLine->parameters[3] = RPG::system->battleBGM->pan;
}

So then in the event, I would have a @bgm_battle comment followed by a Play BGM (setting the BGM to a random file knowing it would be overwritten anyway), it did the same thing the previous code did.

The former code would be ideal assuming it's being used correctly, so what am I missing exactly? Do I need to create an RPG::Sound (or RPG::Music) constructor for this somehow?
Documentation
Many things are only stored in this class if they were changed and are now different from the default in the database, thus you should use the getter methods to access these things.
Therefore, you better use RPG::system->getBattleBGM()->play() because battleBGM is empty if it means "use the default from the Database".

@bulmabriefs144: void onSaveGame(int id, void __cdecl (*savePluginData)(char *data, int length)) is correct. It means it gets two parameters: id and savePluginData. id is an integer and savePluginData is a pointer to a function (this function can be called to store your own data, it gets the parameters data and length).
Yea, I did it that way, and after finding it works, submitted as a Utility.
My program demo isn't great but it has the essentials. I managed to get it so one character would appear if you saved, a sign would appear if you loaded, and on any given load, there's a 20% chance of a treasure appearing (I had to use clunky code, and keep LoadSwitch ON, because the aforementioned sign would otherwise disappear).
author=Cherry
Documentation
Many things are only stored in this class if they were changed and are now different from the default in the database, thus you should use the getter methods to access these things.
Therefore, you better use RPG::system->getBattleBGM()->play() because battleBGM is empty if it means "use the default from the Database".


Ah, thanks! I somehow missed those.
Just as a btw, is there a way to have a plugin attuned to the current map's panorama? For instance, you have color A (let's say pink) be transparent, and color B (let's say black) where the color is using the sword animation, or maybe some line picture.

You have some attack where it slashes a mountain, and instead of the color black, it shows the panorama behind the mountain showing through. Sort of an anti-layer effect.

Currently the only way to do this is meticulously copy paste portions of the BG on top of the mountain in question, and you'd need to align this perfectly.
Currently there is no access to the panorama.

About the switch problem - just a guess: You have the treasure chest use a switch start condition at an event page? In this case take a look at the updateEvents method here: http://rpg-maker.cherrytree.at/dynrpg/class_r_p_g_1_1_map.html#ab0b8f845f99beb32cd99364b60d980a5

Essentially, you would need to call RPG::map->updateEvents(); to have the RPG Maker re-check all event start conditions after you changed the switch.
Why would you need that? There's already a comment command which you can use to handle pretty much any plugin code.
for example you put in a comment:
Switch 50: ON
and in other page you put in that comment of the image Switch 50: ON
and the page is activated using directly a switch that no exist in the
rpgmaker2k3, instead a switch of an dynrpg plugin.

I wanna have some way for have some categories for use switchs,
no all the switches mixed (for events, chests, custom menus switches). u_u
Well, I dunno about having comments for switches. I guess he meant because some plugin codes would be better as preconditions.

But I would like to see more options for menu boxes, particularly expanding the 4th page of the command box which only has like 2 options. Possibly adding battle options, since some people prefer to do all battle formats using common events, for easier editing.

Cherry, it's not a real problem. It's just something that an actual user is unlikely to have both a switch activated object, and a random variable object in the same screen. I suppose I could have a switch and a random number both activate on load. But that's for another day of programming.
author=gadesx
for example you put in a comment:
Switch 50: ON
and in other page you put in that comment of the image Switch 50: ON
and the page is activated using directly a switch that no exist in the
rpgmaker2k3, instead a switch of an dynrpg plugin.

I wanna have some way for have some categories for use switchs,
no all the switches mixed (for events, chests, custom menus switches). u_u
Well, I just wrote an auto-switch plugin. That's basically what you want. It's a lot easier to use than what you described though. You just set it to a single switch, throw in a couple comment commands and use a conditional branch to check if that switch was turned on (which the plugin will handle based on the map id, event id, and page id). This also means you can setup an auto-switch for each page in an event (along with any number of pages). I'll have a sample project and stuff when I release it in a couple days.
Sounds cool.

...Remember the SaveGamePatch (the one that lets you make custom Save menus and save to variable numbers, and has that character 99 that dummies your lead party character)?

Is there a way to add in the map name you are in? For example, map 276 is Hotaru, so the screen displays:

Ambrosia ----- Hotaru
Level 24
1235 HP

It'd have to be callable, since I have the screen switch to a menu screen, so I'd want it able to store it just before changing screens.
And now, the ramblings of a confused programmer.

Open question to anyone who has a definitive answer. So I'm attempting to make a counter-attack plugin. It's in the early stages at the moment, where I'm just trying to get a hero to attack the monster that just attacked them, and it kinda works. You'd have to see it in action.

bool onBattlerActionDone(RPG::Battler* battler, bool success) {
if (battler->isMonster() == true) {
//RPG::updateBattle();
RPG::Battler* battlerTarget;
int temp = (battler->id)-1; // save the monster's id
battlerTarget = RPG::Actor::partyMember(battler->action->targetId); // set new battler
// create a new counter-attack action
battlerTarget->action->kind = RPG::AK_BASIC;
battlerTarget->action->basicActionId = RPG::BA_ATTACK;
battlerTarget->action->target = RPG::TARGET_MONSTER;
battlerTarget->action->targetId = temp;
battlerTarget->executeAction(true);
}
return true;
}

As the documentation suggests, executeAction is very unpredictable. Two issues. This code only works when the monster uses a skill (noting happens with a basic attack). The second issue being that it only works maybe 5% of the time, while the other 95% it crashes out with "Event script referenced a battle command that does not exist."

On the one hand, I'm mainly just experimenting at this point, but on the other, it would be nice to understand how this should work.


Another open question: I've actually had some success with executeAction. I'm also working on a replacement for the reflect functionality since in rm2k3 1.08, the battle animation for the reflected spell shows up 3 times (target, caster, then back to target). It's wicked annoying, and was the main reason I was using 1.09 (power mode) for so long before switching to DynRPG. It should just show the battle animation on the target, and then the actual spell is cast onto the caster.

At any rate, here's the code I have for the replacement. So far, this is just for monster to hero behavior (where hero has a reflect condition).

bool __cdecl onDoBattlerAction (RPG::Battler* battler){
if ((battler->action->kind == RPG::AK_SKILL) && (battler->isMonster() == true) // monster to hero version
&& RPG::Actor::partyMember(battler->action->targetId)->conditions[9] != 0){
int temp = battler->action->skillId;
battler->action->skillId = 69;
battler->executeAction(true);
battler->action->skillId = temp;
battler->action->target = RPG::TARGET_MONSTER;
battler->action->targetId = (battler->id)-1;

//battler->action->kind = RPG::AK_NONE;
}


return true;
}

However, instead of showing the battle animation twice, I have it cast a dummy skill (id of 69) to the target, and then cast the original spell onto the monster itself. Ideally, I'd like to see the animation twice (just like the built in reflect condition) without having the hero take damage. Is there a way to force play a battle animation from within DynRPG? It looks like it has to be in a battle event script, but even then, I don't know how to force that.
Getting a weird bug here. I hadn't touched my project folder for a while, but when I came back to it recently and opened the project in engine, I'm finding that I can't test battles anymore. Nor can I load old save files that worked previously.

Attempting to test battles gives me this error.



That's not even spelled correctly!




And then attempting to load old save files just leads to a black screen and what I assume is a freeze.

But the interesting part to this is that I can start up the title screen normally and start a new game. Everything works as intended when starting a new game and playing through as far as I can tell. I just can't load old save files or test battles. The save files don't matter that much to me, but not being able to test battles is a huge problem. What with all the debugging and testing I need to do.

I tried moving the plugins in and out of the folder to no avail. I tried to test without plugins as well. Still get the same error.

Any ideas?

EDIT: I changed the party starting position to my debugging map in order to work around the test battle issue and now I get the error when attempting to start up the game. But placing the starting position back to the title screen map, the game still works that way.

What the hell is going on?
No idea why you're getting that test battle error. Isn't that normally caused by an image file that's not 256 colors?

And then attempting to load old save files just leads to a black screen and what I assume is a freeze.
This is a bug in the current DynRPG version. Delete all of your Save##.dyn files.

Although Cherry disapproves, I made a plugin that does this automatically after you've quit the game: http://rpgmaker.net/engines/rm2k3/utilities/30/

You obviously wouldn't want to use this if you use any plugins that save data to the .dyn files (The DynText plugin supposedly does, but I haven't seen any evidence/issues)
author=PepsiOtaku
No idea why you're getting that test battle error. Isn't that normally caused by an image file that's not 256 colors?

And then attempting to load old save files just leads to a black screen and what I assume is a freeze.
This is a bug in the current DynRPG version. Delete all of your Save##.dyn files.

Although Cherry disapproves, I made a plugin that does this automatically after you've quit the game: http://rpgmaker.net/engines/rm2k3/utilities/30/

You obviously wouldn't want to use this if you use any plugins that save data to the .dyn files (The DynText plugin supposedly does, but I haven't seen any evidence/issues)

Well the image thing doesn't make any sense since it's been working for a good, long time before this. Why would 2k3 suddenly start doing that now?

Either way, I'll take a look at my image files...which is a ton, and see if that can be fixed.

...Guh.

As for the save files, that's good to know. I'll keep it in mind, but I think I'll hold out for Cherry's official update. Whenever that is.

EDIT: Okay, so I think I solved the image error. Finding a single 24bpp image in a mountain of 8bpp files is like trying to find a needle in a haystack. :|
I wanna make a question,
there is possible make a way of use teleports without re-start all the events position?
when you use a teleport from map A to B, all the events position and other values
are set as default,
if you teleport from map A to A there is no "reset position" of all the events.

I don't know if there is a cache or something,