RMMV Using Yanfly Buff/States Core for "events" on death?

woootbm

Super Sand Legend
Veteran
Joined
Apr 26, 2014
Messages
233
Reaction score
161
First Language
English
Primarily Uses
RMMV
I might be going about this in a very roundabout way, so feel free to suggest alternative methods (ideally ways that don't require non-compatible plugins or great amounts of coding).

Basically my plan is to create a state using Buff/States Core (that is applied to all enemies automatically using another Yanfly plugin) that has a Custom Respond Effect. I think I know how to use this to respond when an enemy is hit with a specific element, but I need it to play specifically when that element kills an enemy (or maybe there's another way to categorize attacks since I will have much more elements than relevant methods of defeating an enemy).

The respond effect is that it adds XP to a specific party member. What I'm trying to do is make a system that keeps track of the player's combat methods. Using a "lethal" skill will give XP to a dummy PC that can level up. When it levels up, the player can access new things via events that check the level of that PC. There would also be "non-lethal" and "diplomacy" types of skills.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
3,168
Reaction score
1,870
First Language
English
Primarily Uses
RMMV
Sure. There's even a Yanfly Tips & Tricks for Auto-Life, so you can look at how to check for an attack that will defeat the battler.
 

woootbm

Super Sand Legend
Veteran
Joined
Apr 26, 2014
Messages
233
Reaction score
161
First Language
English
Primarily Uses
RMMV
Ah, that was a good starting point. Thanks! Piecing a few things together, I have this:

Code:
<Custom Deselect Effect>
var lethal = 1;
var nonlethal = 2;
var diplomacy = 3;
var violence = $gameActors.actor(4);
if (this.isHpEffect() && (target.hp <= 0 || target.isDead()) && this.item().damage.elementId === lethal) {
  target.startAnimation(49);
  var xp = target.mat;
  violence.gainExp(xp);
}
</Custom Deselect Effect>

I'm using the enemy's MAT since I think I'll not have to use every stat for my enemies. If I need extra variables, I'll figure that out later. The animation is just there so I can visually confirm this thing is triggering. I think I can manage the limiting of elements by using yanfly's multi-element mod (but the main element needs to be what's called in the code here).

The problem now is that this only seems to work if this actor is active in the party. Is there a way to affect actors who are not active in the fight here?

EDIT:
So I changed it a bit and went with variables.
Code:
<Custom Deselect Effect>
var lethal = 1;
var nonlethal = 2;
var diplomacy = 3;
var xp = target.mat;
var basexpa = $gameVariables.value(1);
var basexpb = $gameVariables.value(2);
var basexpc = $gameVariables.value(3);
if (this.isHpEffect() && (target.hp <= 0 || target.isDead()) && this.item().damage.elementId === lethal) {
  target.startAnimation(56);
  $gameVariables.setValue(1, basexpa +xp);
}
if (this.isHpEffect() && (target.hp <= 0 || target.isDead()) && this.item().damage.elementId === nonlethal) {
  target.startAnimation(54);
  $gameVariables.setValue(2, basexpb +xp);
}
if (this.isHpEffect() && (target.hp <= 0 || target.isDead()) && this.item().damage.elementId === diplomacy) {
  target.startAnimation(63);
  $gameVariables.setValue(3, basexpc +xp);
}
</Custom Deselect Effect>

And then I have my battles via events that look like this:
1639012365385.png
The variable change at the beginning wipes the slate clean, and after the battle is over I grant XP using the stored variable increases from the battle (since events can apply XP this way for some reason). This works for me because I don't use random encounters, but someone interested in those will need some kind of control over variables. Maybe a common event or something. Troop events?
 
Last edited:

Latest Threads

Latest Profile Posts

You thought kids rooms were messy. Look at this.
Back in the house and I'm hungry
Yoshi!
DNPwhy.gif

You're using that item wrong... TwT

Trying to get the mechanics down for a cute, story-driven board game! I think I've accomplished dice movement, item effects, and activating a space's event when you land on it. Art is WIP. Hope to open a thread about the game soon!
My entire family and I have Covid... If it's this bad with the vaccine, without must be terrible. Stay safe, everyone. This thing is a doozy.

Forum statistics

Threads
118,527
Messages
1,116,651
Members
155,544
Latest member
Merodu
Top