Experience only to character that lands killing blow

liberusanima

Warper
Member
Joined
Feb 18, 2020
Messages
4
Reaction score
1
First Language
english
Primarily Uses
N/A
I'm making a game where player competes in a party with ai-controlled members, so the player will have to compete and plan to get the killing blow and get "credit" for the kill by getting the exp (and also items if possible).

Also it would be great to be able to have a comment event where if the player gets the kill he says something like "I did it!" while if someone else gets the kill he says something like "Aw, that sucks".

Any help would be appreciated.
 

oooNUKEooo

Veteran
Veteran
Joined
Sep 22, 2020
Messages
159
Reaction score
42
First Language
br portuguese
Primarily Uses
RMMV
i dont know a full method for this but maybe if you disable xp (giving 0xp per enemy) and with every skill, check if the target is dead and then reward the xp there, midbattle. i dont know. maybe theres a native way of doing this.
 

liberusanima

Warper
Member
Joined
Feb 18, 2020
Messages
4
Reaction score
1
First Language
english
Primarily Uses
N/A
i dont know a full method for this but maybe if you disable xp (giving 0xp per enemy) and with every skill, check if the target is dead and then reward the xp there, midbattle. i dont know. maybe theres a native way of doing this.
Thanks for the reply :). So I would use skill -> effects: run common event -> conditional branch: enemy "x" is dead -> rewards / items / comment. Sounds like it may work, I'll try it out!
 

Frostorm

[]D[][]V[][]D
Veteran
Joined
Feb 22, 2016
Messages
2,788
Reaction score
2,224
First Language
English
Primarily Uses
RMMV
It's easy! Just make the XP gain into state notetags. This is what I did:
JavaScript:
<Custom React Effect>
target._HP = target.hp;
</Custom React Effect>
<Custom Establish Effect>
if (user.isActor() && target.result()) {
  if (target.isEnemy() && target.result().hpDamage > 0) {
    var XP = Math.round(target.exp() * Math.min(target.result().hpDamage, target._HP) / target.mhp);
    user.gainExp(XP);
    BattleManagerTBS.activeEntity().addTextPopup("+" + XP + "xp", 28, "#fd5ca8");
  } else if (target.isActor() && target.result().hpDamage < 0) {
    var XP = (target.result().hpDamage + target._HP - target.mhp) * target.level;
    user.gainExp(XP);
    BattleManagerTBS.activeEntity().addTextPopup("+" + XP + "xp", 28, "#fd5ca8");
  }
}
</Custom Establish Effect>
Of course, mine is for XP gain on damage/healing dealt, but you can adapt it for your own uses. Some of that code, such as addTextPopup(), is for LeTBS only, so you can ignore that. And then just disable XP gain anywhere else.
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
5,042
Reaction score
3,202
First Language
English
Primarily Uses
RMMV
The solution Frostorm posted relies on you using Yanfly's Buffs and States Core plugin, just because the information wasn't given to you.

I would not do it in a common event attached to the skill like you describe in post 4. You could do it in troop events that are checking for a given enemy to have 0% HP, but that would need HimeWorks' End Phase Triggers plugin to make sure they function properly.

I think a state is the easiest way to go. You'd use Yanfly's Buffs and States Core and Auto-Passive States. Make a state with this in the notetag:
Code:
<Custom React Effect>
if (target.hp<=0)
    user.gainExp(target.exp());
</Custom React Effect>

You can then add stuff like turn on a switch which will trigger a troop event and make the party members say things.
 

Frostorm

[]D[][]V[][]D
Veteran
Joined
Feb 22, 2016
Messages
2,788
Reaction score
2,224
First Language
English
Primarily Uses
RMMV
Doh, I keep forgetting YEP stuff isn't there by default. Good catch. But shouldn't it be <Custom Establish Effect>?
Code:
<Custom Establish Effect>
if (target.hp<=0)
    user.gainExp(target.exp());
</Custom Establish Effect>
 

liberusanima

Warper
Member
Joined
Feb 18, 2020
Messages
4
Reaction score
1
First Language
english
Primarily Uses
N/A
Okay, I got it to work using passive states and custom establish effect note tags on enemies. But now
how do I add a switch to make people talk? Is there a way to add info about which character killed which enemy?
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
5,042
Reaction score
3,202
First Language
English
Primarily Uses
RMMV
Doh, I keep forgetting YEP stuff isn't there by default. Good catch. But shouldn't it be <Custom Establish Effect>?
No. Custom Establish runs when the battler with the state connects a hit, and we're putting this on the enemies.

Custom Respond is when the battler takes the hit. (but you're correct that I typed the wrong R word, it should be Respond not React).

But now how do I add a switch to make people talk?
There's a pinned thread in the JavaScript forum that has a list of script calls for RPG Maker MV. (you can also find a lot of things by just Googling. e.g. "RPG Maker MV script switch").

But basically you'd change the middle to look like:
Code:
if (target.hp<=0)
{
    user.gainExp(target.exp());
    $gameSwitches.setValue(ID, true);
}
where ID is the ID of a switch.

Is there a way to add info about which character killed which enemy?

You'd add the command to turn the switch on, and the rest is basic eventing logic. You could say which switch is flipped indicates the person that killed the monster. Or set both a switch and a variable, and the variable indicates who killed it and you use conditionals inside the troop event.
 

Frostorm

[]D[][]V[][]D
Veteran
Joined
Feb 22, 2016
Messages
2,788
Reaction score
2,224
First Language
English
Primarily Uses
RMMV
No. Custom Establish runs when the battler with the state connects a hit, and we're putting this on the enemies.
But, I thought we're putting this on the attacking unit because we want the user (player) to gain XP. Hence the if (target.hp<=0) user.gainExp(target.exp()); part.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
5,042
Reaction score
3,202
First Language
English
Primarily Uses
RMMV
But, I thought we're putting this on the attacking unit because we want the user (player) to gain XP. Hence the if (target.hp<=0) user.gainExp(target.exp()); part.
The target and user variables will refer to the same battlers regardless of which battle-process notetags you use.

My presumption was to put it on the enemies, but it can also be done by putting it on all the actors - it really doesn't matter. Either way you have to put the same passive state on each battler involved in the battle, of whichever side you choose.

If you only put it on the player's actor, then it won't be able to do anything (boastful comments, etc.) when the AI teammates defeat enemies.
 

Latest Threads

Latest Posts

Latest Profile Posts

I wonder if anyone would be interested in free character art from me...
I remade/fixed my Elf XP Mack Templates. The Ears are looking better now.
Male Update.pngFemale Update.png
You can check them out, they are in 12 recolours, both Human and Elf Versions!
I'M BACK BABEY!!!
College is hitting me a lil' softer than I expected, so I'm back on MV!
And to kick things off, here's a lil' test of a tileset edit I made today! (Took me, like, 5 hours, considering this was the first time I've EVER used GraphicsGale...)Edit test SUCCESS.PNG

Forum statistics

Threads
124,608
Messages
1,164,704
Members
163,428
Latest member
rialr
Top