[DYNRPG] STORE ITEM, SKILL & CONDITION ID IN BATTLE

Track Items, Skills & Conditions more easily!

========================================================================
Store Item, Skill & Condition ID in Battle v1.1
For RPG Maker 2003 with DynRPG v0.20 or higher
By PepsiOtaku
========================================================================

This plugin will store the Skill or Item ID that's used during a battle's action to a variable, and turn on a switch saying it was done. This allows for additional battle trigger conditions.

Using a comment command, it can also check all of the battlers for a specific condition. The Id will be
stored in 1 of 12 variables, depending on the battler. It also turns on one of two switches (Monster/hero) if either one of the heroes or one of the monsters has that condition.

To check for a condition every turn, use "Turns Elapsed (0)" for the first turn, "Turns Elapsed (1x+1)" for all subsequent turns, and Place a "@check_condition #" comment in either of those.

IMPORTANT: It is the maker's responsibility to turn off the switches and reset the variables after the action has been made (or at the start of battle). I recommend adding a Trigger condition for Turns Elapsed (0) and calls a common event that does this.



Installation

To install the plugin, make sure that you have patched your project with cherry's DynRPG patch which
can be found here:
http://share.cherrytree.at/showfile-12494/dynrpg.rar (Link for v0.20)
http://cherrytree.at/dynrpg

1. Copy the "battle_store_itemskill.dll" into the DynPlugins folder of your own project.

2. Add the following (between the asterisks) to your DynRPG.ini

**********************************************


[battle_store_itemskill]
SkillIdSwitch=4037
SkillIdVar=4016
ItemIdSwitch=4038
ItemIdVar=4017
ConditionSwitch=4049
MonSkillIdSwitch=4042
MonSkillIdVar=4023
MonConditionSwitch=4050
ConditionIdStartVar=4081

**********************************************


3. Set the "SkillIdSwitch" value to the switch of your choice for when a hero uses a skill.

4. Set the "SkillIdVar" value to the variable of your choice for when a hero uses a skill.

5. Set the "ItemIdSwitch" value to the switch of your choice for when a hero uses an item.

6. Set the "ItemIdVar" value to the variable of your choice for when a hero uses an item.

7. Set the "ConditionSwitch" value to the switch of your choice for when any hero has the condition specified.

8. Set the "MonSkillIdSwitch" value to the switch of your choice for when a monster uses a skill.

9. Set the "MonSkillIdVar" value to the variable of your choice for when a monster uses a skill.

10. Set the "MonConditionSwitch" value to the switch of your choice for when any monster has the condition specified.

11. Set the "ConditionIdStartVar" to the value of the first variable in a range of 12 to identify each battler.
When a battler has the specified condition, the variable will equal that condition ID, otherwise it will
automatically be set to 0.
Only heroes and monsters that exist in the battle arena are tracked.
Var+0 through Var+3: The 4 heroes
Var+4 through var+11: the 8 monsters
Example: If ConditionIdStarVar was set to 4081, Hero 3's variable would be 4083, and Monster 5's variable would
be 4089


NOTE: Monsters can't use items, therefor, a "MonItemIdSwitch/Var" is not needed.


Instructions

In your battles, add a Trigger condition for Turns Elapsed (0) and calls a common event that turns off the three switches, and sets the 3 variables to 0. This will ensure they're initialized at the start of every battle. Next, follow these steps:

Step 1: Add a trigger condition for the switch of your choice
Step 2: Add a conditional check for the variable used
Step 3: Turn the switch off and reset the variable at the end of the event
Step 4: ????
Step 5: Profit!

Condtion checking is a little more involved. You must use the command "@check_condition #" to check for a specific condition, where # is the database ID of the condition to check for. As mentioned above, it will set the appropriate variable to the condition ID when the check is true.

If one of the heroes has the condition, ConditionSwitch will be true, and if one of the monsters has the condition, MonConditionSwitch will be true. You will need to turn these off before/after use if you need to check them.

Details

  • 142.3 KB
  • 225
  • 12/23/2023 04:31 PM

Actions

Posts

Pages: 1
This is exactly what I've been hoping for, once I learned that DynRPG existed. I was too proud to ask for it directly, mind you.

If there was literally only one plugin I could use over all of the other DynRPG goodness, this would be it.

Thanks dude.
Is there a way to have this so that it doesn't require another battler/monster to perform an action before the engine realizes the switch is on?

It seems like the update to turn the switch and set the variables when an action is done does not happen immediately after performing an action, as a trigger condition for "hero used 'skill' command" goes off before the switch is on or variable set.
While on the other hand, a trigger condition for the switch being on doesn't happen until the next turn (monster or player) has gone by, despite verifying that the switch and variable are set almost immediately after the attack was made.
This is causing a problem where if hero 1 uses a skill, and then the next turn is hero2 using a skill, the value of the first skill is lost completely, resulting in hero1 not having recorded a use of his skill. This is because the value is recorded almost immediately after the skill is used, but the game doesn't update the turn number until after the NEXT turn, and the engine doesn't seem to do a check to see if switches are on until a turn has elapsed.

turn 0 -> hero1 -> skillA -> TURN 1 -> switch on/variable set -> hero2 -> skillB -> switch on/variable set -> TURN 2 -> CHECK FOR SWITCH -> run common event

I assume there is a turn update after hero1 uses his skill, but before the switch and variable are set, I think this is causing the issue. Any advice?
The switch/variable get set immediately after the command is executed (check using F9). The problem is the way 2k3 handles turns (surprise, it sucks!) Basically, a skill's switch condition won't trigger right after you cast it, but an item's switch will. This obviously doesn't make sense. I don't get why rm2k3 works this way, but you have to work around it.

Ignore the fact that the plugin turns on a switch for skills and make 2 battle pages, using a different switch ID:

Page 1: [Hero] uses the [Combat] command
<>Switch Operation: [XXXX: HeroCombat] ON

Page 2: Switch [XXXX: HeroCombat] ON
<>Branch if SkillVar is 452 etc etc

Use Branches in the 2nd page to determine which skill was used, and add your event code there. Be sure to turn the switch off at the end of the event page. You might need to make a skill subset too.

In the item scenario, you just need 1 page:
Page 2: Switch [XXXX: ItemSwitch] ON
<>Branch if ItemVar is 452 etc etc
Hmm. Even after doing that I still observe that an enemy or another player needs to act before the second page takes effect.

I'm trying to use this to keep track of numbers of times a hero uses a skill, and levels up the skill based on repeated usage. So far, it won't catch the last skill used if it kills the final enemy because the battle ends immediately.
The fix by using the multiple pages in the monster screen doesn't solve that problem, and it also introduces a second problem, depending on how I work the second page:

Either A - Multiple heroes would use multiple second pages, which would cause two heroes using skills with no monsters or non-skill using heroes in between to have a skill cancelling problem

or B - Multiple heroes would use the same page which would cause the skill variable to change to whatever the latest hero used, making the first guy's skill use not be recorded.

This is a longshot, but I was looking at some of the classes while trying to flop around on a quick fix for this problem and I found the following in the documentation:

enum RPG::BattleEventUpdateMode
Possible values of the mode parameter of RPG::updateBattleEvents.
Warning:I am not completely sure about the effects these modes have. Enumerator:
BEUM_BEFORE_ACTION
Used before a battler executes its action.

BEUM_AFTER_ACTION
Used after a battler executes its action.

BEUM_SWITCH_ACTIVATED
Used when a skill or an item activates a switch.

BEUM_BATTLE_START
Used to call events with start condition "Turns elapsed [0x+0]".

Is there a way using this to force the engine to look for a switch update using the BEUM_AFTER_ACTION enumerator instead of the BEUM_SWITCH_ACTIVATED one? Wouldn't this cause a switch based event page to happen instantly the same way an action based one works?

edit: or some way to change this plugin so that it updates those switches before the turn counter is incremented, to allow for the switch update check to happen right after the turn instead of right after the following turn.
Alright, now that I've muddled my way around your ATB plugin enough to get it working, it seems like I can definitively say that attack used by hero1 is not lost when hero2 uses a skill on the very next turn. It just seems to delay processing that use of the skill until the following turn.

This means no lost skill uses, except if a skill is used to finish the last enemy as the last turn in the battle. The thing about this is that the last ability is still saved, even though the common event has no chance to play, meaning that a common event can still be called after the battle to commit that last value to memory.

It's still a bit iffy on how it decides to work though. I've tracked it where two heroes get their turns at the same time, and instead of each skill getting one use point, the second hero to move gets 2 use points. For the most part, this is good enough to use though.

Thanks for hearing me out. And for making awesome plugins. I apologize for asking a bunch of questions and basically begging you for stuff. What you're doing is probably a lot more awesome than you think it is :)
Ugh let's see. I've toyed around with updateBattleEvents & its enums before, and have had 0 success in getting them to do anything. They like to make RM2k3 crash, but I can try again. You might be on to something with using BEUM_SWITCH_ACTIVATED. It might exclusively be for an item/skill that is set to Type "Switch" though, so if I try to call it on one that is of another type, it might crash.

Are you trying to trigger a common event with the skill switch? If not, don't do that.

Do exactly what I mentioned before with the 2 page method (not sure why that wouldn't work for you), make sure you have a skill subset and your skill is set to it, and then in your second battle event page (which is set to trigger when a switch is turned on). In the event script, simply call the common event you want to call. This should prevent any outside-of-battle interaction.

Another solution you can do is make a simple common event that is set to parallel process, trigger switch: skillswitch, and simply turns the skillswitch off. Common events that are set to parallel process & autostart don't run in battle, so it will take effect as soon as you leave battle.
author=Ramza
Is there a way to have this so that it doesn't require another battler/monster to perform an action before the engine realizes the switch is on?


Yes, that's what I was thinking/hoping for too. Battle events can detect whether a Hero uses the Attack/Skill/Item/etc command before their actual action occurs; it would be fantastic if there was somehow a way to make it detect these switches and variables that are set with the plugin before the Hero action occurs. That said, even without it, it's still pretty sweet and opens up some nice possibilities.
Updated to version 1.1: Track specific conditions now! See the readme for more details.
Sweet, condition tracker should be very useful.
I don't know if I've been doing something wrong, but I can't get the condition variable check to work. Here's a screenshot of what I have: http://oi62.tinypic.com/20uocra.jpg

Upper left corner is my .ini file that decides which variable condition checks will be set to (864 through 875).
Upper right corner shows my Hero1 afflicted by MP Regen, which is set to 106 in my database.
At the bottom it shows the variables that are supposed to track the conditions all to 0 while my character has MP Regen on him.

Something I'm missing?
I'm assuming you're missing this:

Condtion checking is a little more involved. You must use the command @condition_check # to check for a specific condition, where # is the database ID of the condition to check for. As mentioned above, it will set the appropriate variable to the condition ID when the check is true.


So if you're checking for condition 14, you would add a comment of "@condition_check 14" in your event code. It doesn't update automatically.

I tried this in my battle events, but the variable remains at 0 when I check it in the console, and the branch doesn't trigger.
http://oi59.tinypic.com/19h5c.jpg
What's the start condition of that event page, and is the condition being changed before the check?
The page activates every time a character moves. I made a video showing everything I have and how it's not activating: https://www.youtube.com/watch?v=y7F3b24nqzM
Try changing "Turns Elapsed 1x" to "Turns Elapsed 1x+1" and make that page 2. Then, for page 1, add the same comment command with "Turns Elapsed 0"

Page 1 would be the very first turn, while page 2 would be all subsequent turns. Don't ask me why "1x+1" gets called every turn... because I don't know. :)
That didn't seem to help. Could you upload a project file with a test battle that successfully pulls off this check?
Oh shit, I know why. I had it documented wrong. It's "check_condition #" instead of "condition_check"

Sorry about that!

Edit: Updated
Yes, that made it work. Now to start getting **** done with this thing.
Erroneously, if a battle animation for a skill is too short, another actor will be required to take an action in order to activate the battle event page with the SkillIDSwitch ON trigger. An example of this: I had a battle animation of length 20 frames and another actor had to act to activate the page, while the same exact setup but changing the battle animation to 30 frames caused the battle event page to immediately trigger.

I am, however, still having trouble getting the ItemIDSwitch triggered page to activate immediately (without actually setting the Item to the Switch type (but doing this would disallow targeting with a specific item)).
Pages: 1