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

Posts

Ahh crap, I somehow must have messed with where it defined nextScriptLine. It says "nextScriptLine not defined in this scope." Okay, I think I found it.

...Okay, weird. I did this code:

#include <DynRPG/DynRPG.h>
#include <sstream>

std::string parseText(std::string in);
char* g_pluginName;

bool onStartup(char* pluginName) {
g_pluginName = pluginName;
return true;
}

std::string formatText(std::string s)
{
size_t size = 2;
//std::string d = "]";
while(size < s.size() && s[size++]!=']');
size -= 2;
int n = atoi(parseText(s.substr(2, size)).c_str());
std::string r = s.substr(0,s.size()-1);
//std::string r = "** NOT FOUND **";

switch (s[0])
{
case 'A': case 'a':
if (n < RPG::attributes.count())
return RPG::attributes[n]->name;
else return r;

case 'B': case 'b':
if (n < RPG::battleSettings->battleCommands.count())
return RPG::battleSettings->battleCommands[n]->name;
else return r;

// C,c (Color)

case 'D': case 'd':
if (n < RPG::actors.count())
return RPG::actors[n]->getDegree();
else return r;

case 'I':
return RPG::getItemName(n);

case 'i':
return RPG::getItemDescription(n);

case 'K':
return RPG::getSkillName(n);

case 'k':
return RPG::getSkillDescription(n);

case 'M':
if (n < RPG::dbMonsters.count())
return RPG::dbMonsters[n]->name;
else return r;

case 'm':
{
std::stringstream ss;
ss << RPG::dbMonsters[n]->itemId;
return ss.str();
}

// N,n (Hero Name)

case 'O': case 'o':
return RPG::getConditionName(n);

case 'R': case 'r':
if (n < 88)
return RPG::vocabulary[n];
else return r;

// S,s (Speed)

case 'T': case 't':
if (n < RPG::terrains.count())
return RPG::terrains[n]->name;
else return r;

case 'V': case 'v':
{
std::stringstream ss;
ss << RPG::variables[n];
return ss.str();
}
default:
return r;
}
}

std::string parseText(std::string in)
{
std::string out;
for(size_t i = 0; i < in.size(); i++)
{
char d = in[i+1];
if (in[i] == '\\'
&& (d == 'I' || d == 'i' || d == 'V' || d == 'v' || d == 'D' || d == 'd'
|| d == 'K' || d == 'k' || d == 'O' || d == 'o' || d == 'M' || d == 'm'
|| d == 'A' || d == 'a' || d == 'R' || d == 'r' || d == 'T' || d == 't'
|| d == 'B' || d == 'b' ))
{
out += formatText(in.substr(i+1, in.size()));
while(i < in.size() && in[i++]!=']');
i--;
while(i < in.size() && (in[i+1]==']'))i++;
}
else
out += in[i];
}
return out;
}

/*bool onEventCommand ( RPG::EventScriptLine * scriptLine, RPG::EventScriptData * scriptData,
int eventId, int pageId, int lineId, int *nextLineId)
{*/
bool onEventCommand ( RPG::EventScriptLine * nextScriptLine, RPG::EventScriptData * scriptData,
int eventId, int pageId, int lineId, int *nextLineId)
{
if(nextScriptLine->command == RPG::EVCMD_SHOW_MESSAGE)
{
std::string txt;
txt = parseText(nextScriptLine->stringParameter);
// Parse and replace actual message line
nextScriptLine->stringParameter = txt;// Parse the other 3 lines
for (int i=2;i<=4; i++)
{
if (scriptData->line(lineId+i)->command == RPG::EVCMD_ADD_LINE_TO_MESSAGE)
{
txt = parseText(scriptData->line(lineId+i)->stringParameter);
scriptData->line(lineId+i)->stringParameter = txt;

} else break;

}


}


return true;
}

It works, but in this message:

Each Reaper has a duty. I work closely
with \n[2], the Reaper of \d[2], and
\n[3], the \d[3] Reaper.

I displays as:

Each Reaper has a duty. I work closely
with Seishi, the Reaper of [2], and
Yomi, the Death Reaper.

I think I must have done something wrong while doing the code, but not sure what. It runs the second one but not the first. Can you look and see if there is some glaring problem?

Okay, I did // to if(nextScriptLine->command == RPG::EVCMD_SHOW_MESSAGE) and it ran all code lines, however, it seems like it might be constantly checking (there is lag while running move events. I need to delay checking, but still run all code. Any advice?

Nevermind, I tried this:

if(nextScriptLine->command == RPG::EVCMD_SHOW_MESSAGE)

to

if(RPG::EVCMD_SHOW_MESSAGE)

Removing the nextScriptLine removed the error where it only checked starting with the second, and checked only if you were actually opening a window, meaning the lag while moving/panning etc went away too. It works, yay! ^_^

Urgh... Almost. It crashes in battle. I need a way to skip it if it for some reason cannot run. That, or skip this.

...I think I'll alter Mordant's code instead. His doesn't crash my battles. How do I make his code more stable? I heard that was a concern.

Hola, DYN Geniuses.
Is it possible to change the way the numbers are displayed in battle when damaging an enemy, or being damaged by an enemy?
Like, separate colors, making them appear on screen for a longer amount of time, making them bounce more/shake, yadda yadda?

I believe dragonheartman may have created something similar to this, but I haven't found anything downloadable out there.
There is an easy way to solve this problem (create a text Battle Animation, and do the colors and animation you want) and a hard way of fixing it (DynRPG uses C++ code, so you can do stuff like this but it takes code to do everything from moving it to bouncing it back).

What I think would be good is to add a new callback for if damage has been done. To somehow pause damage before it displays and configure how it displays.
I created a custom damage numbers plugin for someone. The hard part is not displaying numbers. It's tracking what happened and getting the numbers. I did that by reading from the displayed popup graphic. To do that I created a very simple pattern matching that is enough to read the numbers and detect the color.

Currently no public release planned, it's part of a bigger project.
I created a custom damage numbers plugin for someone. The hard part is not displaying numbers. It's tracking what happened and getting the numbers. I did that by reading from the displayed popup graphic. To do that I created a very simple pattern matching that is enough to read the numbers and detect the color.

Currently no public release planned, it's part of a bigger project.


Damn! lol
What about JUST changing the colors of the default DMG popups?
Is that doable?
Should be. But, as I've discovered with trying to do this by changing system, there is glitch potential. I turned the B/W text system to a green system. The numbers suddenly turned to a very strange blue and pink color for damage. Not sure what I did, lol.
It would be cleaner to change:

std::string formatText(std::string s)
to

std::string formatText(const std::string &s)

Actually, in this case you'd probably do best to just use C strings (const char *), you aren't really using any of the features of std::strings.
To whom it may concern, DynBattleDisplay has been updated yet again with bugfixes. Actually there's one other update which took place without me mentioning it in this thread, but I wanted to make sure I announced it here this time if only to give kudos to Corti for his BattleOverlay subsystem. ;) Thanks to that there should no longer be potential cases of monsters overwriting battle displays. The other fixes are that the plugin will now terminate gracefully in cases where the condition icons are not used; the plugin will not crash if you are using another plugin or patch that causes zero-or-less values for maximum HP (in theory anyway, I don't have an easy way to test this); and if a hero is added to the party in mid-battle, their battle display will show up properly.
Hey, Audrey. You worked on the atb_overhaul_upgrade right?

Well, ummm, I've been trying to give Cerberus's code an update. I want it to run under its system, but use the conditionExceptions.


#include <DynRPG/DynRPG.h>
#include <string>
#include <stdio.h>
#include <vector>
#include <sstream>
std::map<std::string, std::string> configuration;

//int confAddValue;
//int confHeroSpeedVarM;
//int confBattlerStartVar;
//int confMonsterSpeedVarM;
//int confDefaultHeroSpeed;
//int confDefaultMonsterSpeed;
//int confAtbModeSwitch;
//int confActiveSpeed;
//int confWaitSpeed;
bool atbWait;
//bool monsterAction = false;
//bool longAction = false; // Added by AubreyTheBard
//bool confAgilMult;
bool condCheckFail;
int confFreezeSwitch;
std::string condExceptionSet;

std::vector<int> exceptionVect;

char monsters, actors, monmoved, actmoved;
char waitBetweenTurns;
bool battle=false, isPartyTurn=true, firstTurn=false;

bool onStartup (char *pluginName) {
configuration = RPG::loadConfiguration(pluginName);
//confAtbModeSwitch = atoi(configuration["ATBmodeSwitch"].c_str());
//confAddValue = atoi(configuration["AddValue"].c_str());
//confAgilMult = configuration["MultiplyAgility"] == "true";
//confHeroSpeedVarM = atoi(configuration["HeroSpeedMasterVar"].c_str()); // Convert String to Int
//confMonsterSpeedVarM = atoi(configuration["MonsterSpeedMasterVar"].c_str());
//confBattlerStartVar = atoi(configuration["BattlerStartVar"].c_str());
// confDefaultHeroSpeed = atoi(configuration["DefaultHeroSpeed"].c_str());
// confDefaultMonsterSpeed = atoi(configuration["DefaultMonsterSpeed"].c_str());
// confActiveSpeed = atoi(configuration["ActiveSpeed"].c_str());
// confWaitSpeed = atoi(configuration["WaitSpeed"].c_str());
// confFreezeSwitch = atoi(configuration["FreezeSwitch"].c_str());
// get the condition exceptions
condExceptionSet = configuration["ConditionExceptions"];
std::string delimiter = ",";
size_t pos = 0;
int token;
while ((pos = condExceptionSet.find(delimiter)) != std::string::npos) {
token = atoi(condExceptionSet.substr(0, pos).c_str());
exceptionVect.push_back(token);
condExceptionSet.erase(0, pos + delimiter.length());
}
token = atoi(condExceptionSet.c_str());
exceptionVect.push_back(token);

return true;
}

void resumeAtb(){
if (atbWait == true) {
RPG::battleSpeed = 100;
atbWait = false;
}
}

void onFrame(RPG::Scene scene)
{
if ((scene==RPG::SCENE_MAP) && (battle))
{
monsters=actors=monmoved=actmoved=0;
RPG::battleSpeed=100;
battle=false;
}
if ((scene==RPG::SCENE_BATTLE) && (!battle))
{
battle=true;
}
for (int i=0; i<8; i++)
{
for (unsigned int j=0; j<exceptionVect.size(); j++)
{
if (RPG::Actor::partyMember(i) != NULL && RPG::Actor::partyMember(i)->conditions[exceptionVect[j]] != 0)
{
RPG::Actor::partyMember(i)->atbValue = 0;
condCheckFail = true;
break;
} else condCheckFail = false;

}
if (firstTurn)
{
if (isPartyTurn)
{
for (int i=0; i<4; i++)
{
//maybe it's not good way, but I don't know how to find the count of actors in party,
//so I check everyone and, if it exist - perform needed
if (RPG::Actor::partyMember(i)!=NULL && condCheckFail == false && (RPG::Actor::partyMember(i)->conditions[1] == 0 && RPG::Actor::partyMember(i)->actionStatus == RPG::AS_IDLE && RPG::Actor::partyMember(i)->animationId != 14))
{
RPG::Actor::partyMember(i)->atbValue=300001;
}
//// The ATB bar shouldn't move in these situations... the hero is there, not dead, not under an excepted condition, idle, and not in victory pose
}
firstTurn=false;

}


}
else
{
for (unsigned int j=0; j<exceptionVect.size(); j++)
{
if (RPG::monsters[i] != NULL
&& RPG::monsters[i]->conditions[exceptionVect[j]] != 0)
{
condCheckFail = true;
break;
} else condCheckFail = false;

}
if (RPG::monsters[i] != NULL && condCheckFail == false && (RPG::monsters[i]->conditions[1] == 0 && RPG::monsters[i]->actionStatus == RPG::AS_IDLE))
{
for (int i=0; i<RPG::monsters.count(); i++)
RPG::monsters[i]->atbValue=300001;
firstTurn=false;

}

}

}


if (waitBetweenTurns>0)
{
waitBetweenTurns--;
if (waitBetweenTurns==0)
{
if (isPartyTurn)
{
for (int i=0; i<4; i++)
{
if (RPG::Actor::partyMember(i)!=NULL)
RPG::Actor::partyMember(i)->atbValue=300001;
}
actmoved=0;
}
else
{
for (int i=0; i<RPG::monsters.count(); i++)
RPG::monsters[i]->atbValue=300001;
monmoved=0;
}
}
}
}

bool onBattleStatusWindowDrawn(int x, int selection, bool selActive, bool isTargetSelection, bool isVisible) {
//if (selActive == true) {
// if (RPG::system->atbMode == RPG::ATBM_WAIT) RPG::battleSpeed = confWaitSpeed; // wait mode should stop the atb bar when heros are selecting actions
// else RPG::battleSpeed = confActiveSpeed; // active mode should still move the atb bar by the % set in confActiveSpeed (100 is the default speed)
// atbWait = true;
// }

// if the party member dies (or has a condition with a status restriction) while the status window was open
for (unsigned int j=0; j<exceptionVect.size(); j++)
{
if ((RPG::Actor::partyMember(selection)->conditions[1]
&& RPG::Actor::partyMember(selection)->conditions[exceptionVect[j]]) != 0) {
RPG::Actor::partyMember(selection)->atbValue = 0;
resumeAtb(); // resume the ATB bar
//MessageBox(NULL, "what happen", "Debug", MB_ICONINFORMATION);
break;
}
}
return true;
}


bool __cdecl onBattlerDrawn (RPG::Battler *battler, bool isMonster, int id)
{
if (isMonster)
{
if (battler->hp>0) monsters|=1<<id;
else monsters&=~(1<<id);
if (RPG::battleSpeed!=0)
{
if (battler->atbValue>=300000)
{
RPG::battleSpeed=0;
monmoved=actmoved=0;
isPartyTurn=false;
firstTurn=true;
}
}
}
else
{
if (battler->hp>0) actors|=1<<(id-1);
else actors&=~(1<<(id-1));
if (RPG::battleSpeed!=0)
{
if (battler->atbValue>=300000)
{
RPG::battleSpeed=0;
monmoved=actmoved=0;
isPartyTurn=true;
firstTurn=true;
}
}
}
return true;
}

bool __cdecl onBattlerActionDone (RPG::Battler *battler, bool success)
{
if (battler->isMonster())
{
monmoved|=1<<(battler->id-1);
if (monmoved==monsters)
{
isPartyTurn=true;
waitBetweenTurns=60;
}
}
else
{
actmoved|=1<<(battler->id-1);
if (actmoved==actors)
{
isPartyTurn=false;
waitBetweenTurns=60;
}
}
return true;
}

void onExit()
{
exceptionVect.clear();
}


I don't understand battle code, and visibly cringe when I encounter it, because the tiniest mistake usually gives me a full-blown crash. I wanted to pawn it off on PepsiOtaku, since he was the original creator, but he was like "I'm busy doing a demo, do it yourself." I think some combination of not having a clue what I'm doing and possibly missing a bracket somewhere, and it doesn't really work right. Basically, I wanted Cerberus's ability to run the thing without needing variables for everything (his code doesn't even use the ini), combined with the ini basically just for the conditionExceptions.

It gives me a runtime error if I forget the ini, and if I include the ini, it loads but does apparently nothing.

I figure since you worked on it, you might be able to tell me where I went wrong. I need the code to stop without the pause switch, because Cerberus's plugin doesn't need it.
Your post is missing information. What is Cerberus's plugin and what does it do? Link it. And what do you want it to do?
Oh, basically that's the turn based. From the thread below this one. I was trying to get it to accept conditions, since on conditions other than death, it doesn't skip them (Cerberus didn't know how) so I tried to use code from ATB Overhaul to get it to resume atb only on these status (since normally this freezes the game). Why not use ATB overhaul? Well, it's concerning the massive amount of speed variables ATB overhaul expects you to put up with. I have a turn based template on utilities, I know how to make it with just rpgmaker code. And without all these speed variables. It technically works, but it wastes three pages of battle event code for every party. I need something easier to use, not harder.
So Cerberus delivers on that, no variables at all, just default turn based behavior. Only thing is, it freezes when you get hit by sleep or paralyze. So I'm trying to figure how to make it not freeze, and having trouble blending the two codes.
So far Pepsi just told me "do it yourself" and I wound up with this mess. Can someone explain where I went wrong?
First things first. That plugin is very simple and will probably not work well with event scripting in battle system. Just waiting some frames is not enough, so sooner or later you might run into problems.

How to solve your problem:
The turns are started on line 51 and 58. The RM2k3 lets "unable to act" monsters reach full atk and they will skip the turn. For players, it freezes atb because it cant deal with "unable to act" players reaching full atb, and thats what happens.

What you need to do now is:
* Check health > 0 for actor before setting the atb value to full+1 in line 51.
* Check conditions for actor before setting the atb value to full+1 in line 51.
* The actor has an array for conditions. The array contains the rounds its been up, so you need to check all conditions with rounds > 0.
* When you find a condition that is applied, you need to find out, if it has the "unable to act" flag.
* RPG::conditions contains all condtions in the database.
* The conditions have a property called "actionRestriction". So you need to check if that is set.
* RPG::ActionRestriction: Here are the values it can take.

Good luck.

PS: You need DynRPG 0.3 for it.
Thanks for your help. I don't know how much it will help me though (not you, I'm pretty much not understanding the battle code at all, since I've only really worked with onComment and onEvent code except for the Condition Icons which is all predone), but I will check over line 51-58.

I don't understand how to use enums. Would if (RPG::Condition::actionRestriction == AR_NO_ACTION_ALLOWED ) work, or do I need to set it for a character, or am I missing something.

I'll try to figure out what I need, and run it by you again? If it's still not, probably will need code help.
Try the enum is part of the RPG-Namespace, so it is RPG::AR_NO_ACTION_ALLOWED ;-)

RPG::Condition::actionRestriction does not exist. RPG::conditions is a list.
RPG::conditions[index]->actionRestriction should work. The index is the database ID. RPG::conditions.count() gets the number of conditions.

Have fun.
@bulmabriefs144,

PepsiOtaku and I were testing his ATB Overhaul plugin some time long ago, since I had found specific bugs with it. Pepsi was able to fix most of them, but at that time, I wasn't able to continue testing the latest update to double check the fixed issues as well as look for any others.

Anyways, the changes we (and by we, I mean Pepsi, but I helped test stuff :)) made to the plugin are on Pepsi's github which I've linked here.

This fixes most, if not all, of the issues we encountered and it might be more helpful as a starting point for whatever extra features you were trying to add to the ATB Overhaul plugin.

Cheers!
I don't actually want to fix the ATB overhaul code. This is Pepsi's code.

This was the code that I want to fix.

author=Cerberus
#define AUTO_DLLMAIN
#include <DynRPG/DynRPG.h>
#include <string>
#include <stdio.h>
char monsters, actors, monmoved, actmoved;
char waitBetweenTurns;
bool battle=false, isPartyTurn=true, firstTurn=false;

void onFrame(RPG::Scene scene)
{
if ((scene==RPG::SCENE_MAP) && (battle))
{
monsters=actors=monmoved=actmoved=0;
RPG::battleSpeed=100;
battle=false;
}
if ((scene==RPG::SCENE_BATTLE) && (!battle))
{
battle=true;
}
if (firstTurn)
{
if (isPartyTurn)
{
for (int i=0; i<4; i++)
{
//maybe it's not good way, but I don't know how to find the count of actors in party,
//so I check everyone and, if it exist - perform needed
if (RPG::Actor::partyMember(i)!=NULL)
RPG::Actor::partyMember(i)->atbValue=300001;
}
firstTurn=false;
}
else
{
for (int i=0; i<RPG::monsters.count(); i++)
RPG::monsters[i]->atbValue=300001;
firstTurn=false;
}
}
if (waitBetweenTurns>0)
{
waitBetweenTurns--;
if (waitBetweenTurns==0)
{
if (isPartyTurn)
{
for (int i=0; i<4; i++)
{
if (RPG::Actor::partyMember(i)!=NULL)
RPG::Actor::partyMember(i)->atbValue=300001;
}
actmoved=0;
}
else
{
for (int i=0; i<RPG::monsters.count(); i++)
RPG::monsters[i]->atbValue=300001;
monmoved=0;
}
}
}
}

bool __cdecl onBattlerDrawn (RPG::Battler *battler, bool isMonster, int id)
{
if (isMonster)
{
if (battler->hp>0) monsters|=1<<id;
else monsters&=~(1<<id);
if (RPG::battleSpeed!=0)
{
if (battler->atbValue>=300000)
{
RPG::battleSpeed=0;
monmoved=actmoved=0;
isPartyTurn=false;
firstTurn=true;
}
}
}
else
{
if (battler->hp>0) actors|=1<<(id-1);
else actors&=~(1<<(id-1));
if (RPG::battleSpeed!=0)
{
if (battler->atbValue>=300000)
{
RPG::battleSpeed=0;
monmoved=actmoved=0;
isPartyTurn=true;
firstTurn=true;
}
}
}
return true;
}

bool __cdecl onBattlerActionDone (RPG::Battler *battler, bool success)
{
if (battler->isMonster())
{
monmoved|=1<<(battler->id-1);
if (monmoved==monsters)
{
isPartyTurn=true;
waitBetweenTurns=60;
}
}
else
{
actmoved|=1<<(battler->id-1);
if (actmoved==actors)
{
isPartyTurn=false;
waitBetweenTurns=60;
}
}
return true;
}

The frustrating thing about all of this is that I'm only seeking to fix one person's code, instead get stuck worrying about ATB Overhaul. I'll look at line 51 (which may not be line 51 on this one). But yea, I have no idea what the hell I'm doing. I mainly want to fix Cerberus's issues, and leave Pepsi to his business. I asked him, he doesn't want to be bothered with it (working on his demo update) and I don't want to bother him.

Where in this code would be the stuff that I need to fix? Obviously, I'm gonna need something to check for conditions, so I would need to come up with something, since frankly I don't think Pepsi's code meshes well with this code.
New plugin available! DynBattlerChange allows you to transform enemies manually instead of having to rely on it being triggered by enemy behaviors. You can do this both whenever you want using a comment command, and automatically at battle start. This means you can determine the makeup of an enemy group at run-time, instead of being restricted to the groups you define in the database. It also means you can do whatever battle event scripting you need to in a single enemy group and transform its monsters as needed instead of copying the scripting to hundreds of other enemy groups (and probably having to do it over and over as you make changes).

As a bonus, you can also reposition both enemies and actors, although for the actors it's a bit more restrictive--you can only change their positions before battle, and once it starts they're stuck where they are for the whole battle. Still, I seem to recall bulmabriefs was wrestling with the actor alignments a while ago, maybe this will come in handy. You'll have to come up with a system for precisely determining where each actor goes, but at least you have complete control in doing so.

author=bulmabriefs144
Hey, Audrey. You worked on the atb_overhaul_upgrade right?


In a very limited sense. X) I attempted to add some hack-y (even for DynRPG) checks to it to make it avoid the infamous skill override bug. As far as I can tell it worked, but only when the combat system is in "wait" mode. PepsiOtaku seems to have made his own improvements to atb_overhaul since then that are probably better than what I did. But yeah, I'll take a look at what you're doing when I have some time. Sorry if I left you wondering for a while, I often don't check the forums on weekends.
There is no rush. My game is essentially done, so it would mainly be to get things to run better. Pepsi or you could work on it, even if it was three weeks later. I could try my hands, but I'm pretty shaky on the stuff Corti mentioned. It's mainly because an update to this plugin has been due.

I can't climb that building, the anti-climbing paint...
author=kaine87
aubrey the link is dead.


Guess that's because the submission is still pending, so only I and staff are allowed to visit the page. Sorry for jumping the gun on announcing it.