New account registration is temporarily disabled.

[RM2K3] ACCESSING STATS IN BATTLE

Posts

Pages: 1
So, I realized working on my secondary project that there's something I've come to take for granted in RGSS-based scripting - the ability to lookup and alter battler stats on the fly.

While working on A Fatal Hope, I've been trying to find a way to accomplish a certain task, and, coming down to it, it requires me to be able to alter statistics of actors and monsters while the battle is running (monster statistics being the required portion for this). I need more than just the doubling/halving conditions give (my patchwork temporary solution, which will become the permanent solution if I can't solve this uses a condition), but I need to be able to alter statistics without having a monster/actor waste their turn (ie. statistics automatically change).

I can't seem to find a way to do this in default RM2k3, and while looking at DynRPG, there appears to be existing functions to get the statistics, but no existing functions to set the statistics.

So, to the point:

1) Is there an existing way to automatically alter statistics in battle, whether with a plug-in or whatever?
2) If there isn't, would it be possible to do it in DynRPG (or another RM2k3 scripting setup)?
Technically you can get the monster Hp & Mp, erase the monster and put another one in its place, with the statistics you want... What do you want to do, exactly?
I'm looking to slowly raise the stats of certain monsters over time - I considered using the method of replacing monsters, but it would require a lot of extra monster slots to pull off with the frequency of stat increases I'm considering (plus, each monster that does it would need all that slots). The current solution of just having the monster 'enrage' after a number of turns works for the time being, but doesn't quite get the effect I'm looking for - I'm just trying to figure if I can get a solution closer to what I want.
Hm, can't you have a drone sort of (invincible) monster cast Empower on the enemy party every turn? Alternately, I'm not sure if you can diectly cast skills in monsters from events, but if you can, bingo!
The issue I've come across with the drone monster is that the ability doesn't stack - it'll come into affect the monster once, but not after that. I can't use it to continually raise stats every X turns. Right now, the Enrage effect I have essentially does the same thing without the need for another monster.

I don't see a way to cast spells/skills on monsters in the Battle Events, just to change a Monster's HP, MP, and Condition. Even if I did find a way to do it, as is, I think I'd run into the same problem as using a drone - the skill won't stack with multiple castings.
Here, I had this conversation with Cherry a year ago or so:

author=Large
So sorry to keep bothering you, you must be super busy, and deep in tits and asses after all the work you did with the SDK.

Say, I have a question: I see that you can get the attributes of Battlers with RPG::Battler::getDefense(), for example, but... can you SET it?

My idea is to have the defense attrib for one boss be modified (Doubled, tripled, halved, w/e) when a certain spell is cast (by him). After 2-3 turns, the Defense goes back to normal.

I couldn't find a setter method, so I was wondering... how can I accomplish that?

Thanks in advance!

author=Cherry
That's because the actual attribute value is calculated based on various factors: Basic settings (per level), equipment, conditions, adjustments one by "Change Ability" event commands...

Because of that, there is no actual DEF value, for example, only a method getDefense which calculates it. You can hover use the defenseDiff member (same for the other attributes). That's the difference from the default (default = basic stats + equipment + conditions). Please do not use "=" to change it (since this will override changes done by event commands like "Change Ability"), but only "+=" and "-=" to in-/decrease the attribute.

=== Is it okay if I publish this conversation? Others might have the same question. Next time, please ask in the thread!

Best regards,
Cherry

author=Large
You can use the question, no problem.

So I can just use RPG::Actor::defenseDiff += 30; and that will increase the defense of the actor?

author=Cherry
Exactly. Of course not the way you wrote it now (RPG::Actor::defenseDiff += 30) but by actually using a particular actor, like

RPG::actors(3)->defenseDiff += 30; <-- Brackets changed to parenthesis

Hope it helps.
... and that was exactly what I was wondering, if there was a way to do it, and of course DynRPG presents a way to do exactly what I need. <3 Now, I'll just have to patch it in and do a little bit of coding work to see if it plays nicely on the bosses (and maybe, just maybe, do it on some of the random encounters as well, so you can't just Auto your way into beating them).
But if I were to use RPG::Actor::defenseDiff += 30 (if I wanted the entire party to get a nice bonus), this would be the right format? That is, it wouldn't crash?

...I can't tell you how long I've spent wondering when to use Actor instead of actors. The latter is given examples,
(
int zackHp = RPG::actors[1]->hp;
)
but not the former.

By the way, this is more or less how you access in battle, if not to increase stats (to check them). Don't reassign the actor (RPG::Actor, RPG::actors to the left), reassign an int/string/whatever storing the value in a temporary (placing RPG::actors to the right). Then do something like this.

RPG::variable[(paramParse commenting, or specific variable, or config system)] = zackhp;

Btw, you can also use Common Events, to do exactly the same things with no C++ coding. Make a common event called CheckStats or ChangeStats (depending on what you wanna do), and use the variable system->Hero and possibly the Change Character Base Statistics. Even though it's not in battle (well, the variable system is), common events allow you to do quite a bit that isn't in the battle menu. I just tested it, common events, if it can call rain (trust me, it can), it can definitely give you stat access/change (the only two things it doesn't seem to do through CE is Pictures, you have to patch for it to even show pictures, and strangely, Battle Animations because out of battle animations use Hero).
author=bulmabriefs144
But if I were to use RPG::Actor::defenseDiff += 30 (if I wanted the entire party to get a nice bonus), this would be the right format? That is, it wouldn't crash?
No, this would crash. There is no format for this outside of looping over all the actors

...I can't tell you how long I've spent wondering when to use Actor instead of actors. The latter is given examples,
(
int zackHp = RPG::actors[1]->hp;
)
but not the former.

You use the Actor class if you want to keep track of a particular Actor without having to look up it's index all the time.

example:
RPG::Actor* alex = RPG::actors[5]

This is convenient, but not neccessary. You can totally disregard using the Actor class and just use actors instead for it to work, which is already an array of Actor.

By the way, this is more or less how you access in battle, if not to increase stats (to check them). Don't reassign the actor (RPG::Actor, RPG::actors to the left), reassign an int/string/whatever storing the value in a temporary (placing RPG::actors to the right). Then do something like this.

RPG::variable[(paramParse commenting, or specific variable, or config system)] = zackhp;


it's hard to understand what advice you're trying to give here. There's no reason to take a detour of storing the value into a temporary variable when
RPG::variable[number] = RPG::hero[1]->hp
is just as valid and hardly causing any problems. Wouldn't this go against your "use as few variables as possible" paradigm?

author=Travio
... and that was exactly what I was wondering, if there was a way to do it, and of course DynRPG presents a way to do exactly what I need. <3 Now, I'll just have to patch it in and do a little bit of coding work to see if it plays nicely on the bosses (and maybe, just maybe, do it on some of the random encounters as well, so you can't just Auto your way into beating them).

Just to make sure you've noticed this: From what I can see in the documentation, the stat diff only applies to the heroes, i.e. not monsters. So what you'll have to do is decrease the stat of the party members to give the illusion of the monsters growing stronger. I also assume that the changes you do there are of the permanent kind, so you'll have to keep track of how much you've changed it during a battle such to reset it to the original stats afterwards
The only way to change monster stats is using conditions. The RPG Maker doesn't provide an attackDiff, defenseDiff, etc. feature for monsters, it's just reading the stats from the database and applying the conditions to it.

Maybe I should add an onGetMonsterATK, etc. hook in the future...
author=Kazesui
Just to make sure you've noticed this: From what I can see in the documentation, the stat diff only applies to the heroes, i.e. not monsters. So what you'll have to do is decrease the stat of the party members to give the illusion of the monsters growing stronger. I also assume that the changes you do there are of the permanent kind, so you'll have to keep track of how much you've changed it during a battle such to reset it to the original stats afterwards

I've looked it up in the documentation - it does currently exist only in the Actor class, which poses a bit of a problem - but I think I see a way that I might be able to temporarily trick the system into accepting them for monsters (this might require more work than it'd pay off), I need to play around with it once I get a compiler going. I also wonder if I couldn't just entirely redefine the Monster class to include calls referring specifically to getting their four stats - surely there's a reference in RM2k3 directly to those stats, it's just a matter of finding a way to map them to the C++ to call them. Work has just kept me away from wanting to touch the C++ though.

author=bulmabriefs144
Btw, you can also use Common Events, to do exactly the same things with no C++ coding. Make a common event called CheckStats or ChangeStats (depending on what you wanna do), and use the variable system->Hero and possibly the Change Character Base Statistics. Even though it's not in battle (well, the variable system is), common events allow you to do quite a bit that isn't in the battle menu. I just tested it, common events, if it can call rain (trust me, it can), it can definitely give you stat access/change (the only two things it doesn't seem to do through CE is Pictures, you have to patch for it to even show pictures, and strangely, Battle Animations because out of battle animations use Hero).

This only works for characters, not for monsters. The only apparent way to alter monsters stats, at the moment, appears to be through skills (which don't stack), through conditions (which don't stack), or by replacing the monster (which takes a lot of space in the database). If it comes down to it and I can't smoothly pull off the effect I want, I'm most likely going to be going with a combination of the first two to accomplish something close (as it is, an 'Enrage' effect makes the battle much harder).


author=Cherry
The only way to change monster stats is using conditions. The RPG Maker doesn't provide an attackDiff, defenseDiff, etc. feature for monsters, it's just reading the stats from the database and applying the conditions to it.

Maybe I should add an onGetMonsterATK, etc. hook in the future...

So, surely there's someway to at least read their stats that could be manually written on top of what you already have, and that, in theory, could be used to directly alter the stats in the database? For that matter, being able to alter information in the database would be just as effective for what I'm trying to do.

Anyways, if this whole idea doesn't work out right, I might just have to put off using the version of strengthening I was envision for an RGSS-compatible project and go with the conditions method ('enraging' during the fight) for this project.
Untested code, just made out of my notes:

class DBMonster {
public:
void **vTable;
int id;
RPG::DStringPtr name;
int _unknown_C;
int _unknown_10;
int maxHp;
int maxMp;
int attack;
int defense;
int intelligence;
int agility;
// Other members not known yet
}

static RPG::NamedCatalogPtr<DBMonster *> &dbMonsters = (**reinterpret_cast<RPG::NamedCatalogPtr<DBMonster *> **>(0x4CDE0C));

Please keep in mind that (same as with DBActor and DBSystem), changes persist for the whole session, until the game is closed, and are not reset on "New Game", nor saved or loaded to/from savestates.

If you put some logic to restore the original value after battle, please keep in mind that the player might also press F12 during the battle.
Thanks, Cherry - I'll play around with that and be extremely careful with it.

Possible solution to the changes persisting through the entire session - at the beginning of any battle involving monsters whom are affected by these stat changes (as opposed to afterwards, where it might be gotten around using F12), use the same type of code you'd be using to alter their stats in battle to ensure their stats are set to default before the battle starts.
author=Kazesui
RPG::variable[number] = RPG::hero[1]->hp

is just as valid and hardly causing any problems. Wouldn't this go against your "use as few variables as possible" paradigm?

Oh yea...

This paradigm exists because of personal experience. When I am getting used to a code (hint: C++, but previously rpgmaker code), I tend to not know what I'm doing and create a ton of code cruft (like the following I did just now). Later, when I get better, I look over this code and having to edit some part of it to do something, end up spending 10+ hours removing extra crap (don't get me started on battle events). I'm having to do this now with much of my old common events.

It is better policy to start simple from the onset, and then when editing, you only have to change one line.

And yes, I know what you mean about monsters. DynRPG itself could use a dbMonster (much like I just noticed by reading above from Cherry) thing, because every time I've tried to mess with monsters, I've found to my horror that rather than being able to easily access the monsterID itself from the database, it seems to do it from in battle selection which is not much good for any purpose I'd have for it. There are variable options for seeing monster stats, and skills for changing them, but no commands for changing them.
Pages: 1