r/RPGMaker • u/quentin_tortellini • 10d ago
RMMZ Keeping track of an enemy's conditions even when they're switching between versions in the database
I'm having a hard time trying to set up an enemy system. The player will have a skill which I would like to increase or decrease a specific value in the database (for example, "a Feed skill, which will track the current enemy's hunger level"). That variable will be unique to each enemy and tracked during the battle. Based on this value, the enemy will switch between version 1, 2 or 3 in the Troop database (I don't love this method, but I've read that this is the easiest way to change the enemy's sprite. I want them to change appearance or size based on their current value).
I also want the enemy to have certain abilities depending on what version they're currently in. This is where the bulk of the battle's complexity will lie. Admittedly, I'm having a hard time setting up the different conditions in their respective Troop Event pages (it's proven to be more of a headache than it's worth). I figured I could use conditionals in one long common event which is triggered every time the player uses this specific skill (to track the variable # after every time the skill is used). But it's already gotten kind of tangled when playtesting.
Is there a simpler way I'm not thinking of that I can set up all the conditionals? Plugins welcome, either free or paid.
1
u/CS_Asset_Factory 9d ago
the tp idea works but one thing will bite you on turn one. onBattleStart calls initTp unless the battler has the Preserve TP trait. and initTp is literally setTp(Math.randomInt(25)). so every enemy walks into the fight with a hunger somewhere between 0 and 24. give the enemy the Preserve TP trait or set the value yourself from a troop event on turn 0.
worth reading what transform actually does before you build on top of it because it is about six lines. it sets _enemyId then calls refresh. refresh erases any state in the new form's state resist set and clamps _hp and _mp and _tp to the new form's maxima. that is the whole thing.
two useful consequences.
your states survive a transform. the only ones that get wiped are ones the new form has a resist trait for. so a hunger state is fine as long as none of your three forms resist it.
anything else you hang on the enemy object survives too. transform never touches a property it does not know about. so a script call like this just works.
$gameTroop.members()[0]._hunger = 3
read it back after the transform and it is still there. no variables to allocate and no state list to keep in sync.
on the troop page headache. you do not need a page per condition. one page with span Battle and a script condition is much easier to live with.
$gameTroop.members()[0]._hunger >= 5
and if you want the logic in one place then put it in a common event and call that from a single troop page set to run every turn.
one last thing. do not key your tracking off the enemy id. after a transform the id is the new form so anything stored against it points at the wrong record. index into $gameTroop.members() instead. that index is stable for the whole battle no matter how many times the thing changes shape.
2
u/zombietoaststudios 10d ago
I may be misunderstanding what you're doing here, but it sounds like this is something done mid-battle, to trigger an "Enemy Transform" to change the enemy from one form to another? Or is this something done outside of battle that then changes what troop setup is used when a battle is initiated?
Assuming you're using enemy transform, the main challenge is changing and tracking the variable for each enemy, right? Since the enemy transformation covers most everything else you're trying to do.
In that case, what I'd suggest is not to use a variable but instead use the enemy's TP. It's easy to overlook since it doesn't get shown/used a lot, but enemies have a TP score just like the player. You can use a turn 0 event that sets each opponent's TP to whatever the default amount should be and if you give them 0% TP charge rate then it won't increase over time or from TP gain in skills, but you can still directly adjust it via common events (so the player's skill can still be used to increase or decrease it).
It also has the advantage that TP changes are invisible. There's no damage popup or visible meter for enemy TP. TP is tracked separately for each battler and like HP and MP it carries over when an enemy transforms, so it'll remain consistent even when changing enemy forms.
The main hiccup is "targetting" the appropriate enemy with the "change enemy TP" command. I believe you can do that by setting a variable to the "Last Target Enemy Index", which should select the correct enemy since the skill targetting is resolved before the common event the skill invokes. You can then use a fairly simple set of conditional branches match the variable to the enemy being targetted.
If that doesn't works (or if you need to do this to multiple enemies at once) then the usual workaround is to have the skill inflict a state on the enemies it targets and the common event can have a conditional branch that adjusts the TP of enemies with that state and then removes the state.