End Battle without killing enemy (+gain full exp)

XthenewB

Villager
Member
Joined
Apr 5, 2020
Messages
7
Reaction score
0
First Language
german
Primarily Uses
RMMV
Hi all. I have searched already a lot and didn´t find anything I can use.

The idea is an enemy that doesnt fight.
•If you give it an item. It say thx, and the fight will be over + you get exp.
•If you hurt it, it just will run away.

What I want to do:
End a battle without killing the enemy but still get the exp. in the victory screen.
- the enemy should not get any damage
- I dont want use the event for gaining the exp. because it needs to be in the victory screen.
- I cant abort the battle, cause thats the same as the enemy escaped = 0 exp.

So is there a way to do this without/with plugins?
btw. if it is possible to gain exp. even if the enemy escaped, it would work too.

THX
 

rainyday

Veteran
Veteran
Joined
Nov 5, 2019
Messages
50
Reaction score
21
First Language
English
Primarily Uses
RMMV
If you don't have Yanfly's Buff and States Core plugin let me know cause I'll need to change the method slightly, but the following should work.

Make a state that resits the death/knockout state, and paste the following in the notebox
Code:
 <Custom React Effect>
//This skill should have an effect that makes the user escape. By default that's skill 6
var skillId = 6;
this.setSkill(skillId);
user.forceAction(skillId, user);
</Custom React Effect>

Your state should look like this.
Untitled2.png

Then, make an item that removes the state you just made. Finally, in the troop for the enemy, make a Turn 0 event that adds the state to the enemy, then reduces its HP to 0.
Troop Event.png
 
Last edited:

XthenewB

Villager
Member
Joined
Apr 5, 2020
Messages
7
Reaction score
0
First Language
german
Primarily Uses
RMMV
thx for your reply @rainyday

I have access to the yanfly addons. I´ve tried it the way you told. But the problem is, the enemy gets
damaged in Turn 0.
In my case the enemy has 2 states:
-1 It is lucky (it gets the item, say thx and end the fight with exp.)
-2 It is angry (it gets hurt, any damage trigger the effect here, and escape without give any exp.)

So it would´t work for this one here :(
 

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
1,700
Reaction score
559
First Language
Dutch
Primarily Uses
RMMV
would be rather something like this in lunatic code.
if "correct" item or items are given
enemy get state "succes" and get killed for exp
else
he escapes and 0 exp.

I dont know how to use lunatic code, but it should be something
like this what you need? (I know I said killed, but its more as
a faking death.
 

XthenewB

Villager
Member
Joined
Apr 5, 2020
Messages
7
Reaction score
0
First Language
german
Primarily Uses
RMMV
would be rather something like this in lunatic code.
if "correct" item or items are given
enemy get state "succes" and get killed for exp
else
he escapes and 0 exp.

I dont know how to use lunatic code, but it should be something
like this what you need? (I know I said killed, but its more as
a faking death.
thx for reply.

If this "faking death" will not damage the enemy, yes.
As I said, any damage would trigger the other state here, that means = 0 exp.
(even if the item was already given first to it.)
 
Last edited:

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
1,700
Reaction score
559
First Language
Dutch
Primarily Uses
RMMV
thats why, give a state if the item is given and fake its death,
if no item is given, it wont get a state and he escapes.

but I dont know or understand hte lunatic codes or I could try something out
before passing it to you.
 

rainyday

Veteran
Veteran
Joined
Nov 5, 2019
Messages
50
Reaction score
21
First Language
English
Primarily Uses
RMMV
Show me your 2 states. Its very likely you could use just 1 to handle this, and save yourself a lot of trouble.
 

XthenewB

Villager
Member
Joined
Apr 5, 2020
Messages
7
Reaction score
0
First Language
german
Primarily Uses
RMMV
Okay, the big problem I got is, that I play with the enemy HP-Bars. So any damage done
to the enemy will be noticed
.

I dont really solved the main problem, but I think I will leave off the HP-Bars. So I can just simmulate
or "fake death" the enemy.

Right now I´m using 3 states. Gonna explain a little.

1. state is needed for the "angry" state. So only if the enemy have the 1. state he can become angry.
This state is given to the enemy in Round 0 automatically. (by Troops event)

2. state is the "angry" state. It appears right after the enemy get damaged (no matter how much).
And like I mentioned before, only if state 1. is on the enemy, state 2. can appear.

3. state is given by the item which I can use on the enemy. (In my case its a healing item) It gives a state
to let the game know which enemy is targeted with the item.
Also the use of that item triggers a switch, which enables a common event. (force the enemy action right after I used the item on it)
In that event I´m gonna end the 1. state (so if the enemy get damaged, it can´t get angry anymore, cause it need state 1 + 2 to get so) and fake death it.
The fight is over and I got the victory screen I needed.

The only problem right now is I have to set the enemy on a variable. Right now its just every enemy in every battle on #1 that get the item will say thx and get killed o_o
I´ve tryed it with a script $gameTroop.members()[ID].name() but it didn´t work.


Sorry if it is a little complicated. I´m trying my best to explain it.

Thanks for your time guys.


Edit:
Okay got it to work now with $gameVariables.setValue(20, $gameTroop._troopId).
Anyway, if someone have an idea how to end a battle like I mentioned at the beginning, would be great.
(So I could use the HP-Bar again)
THX.
 
Last edited:

hinola

Veteran
Veteran
Joined
Jun 27, 2015
Messages
49
Reaction score
67
First Language
Français
Primarily Uses
RMVXA
I did something that doesn't work, but may still help :

One item
target : none
Call a common event

One common event
Do the test to be sure it's the right troop
active switch "object given"

One troop
with to pages :
first with condition "enemy hp <= 99%"
=> message "He's running away !"
=> end battle (command event, tab 3)
second with condition "switch "object given" ON"
=> message "He appreciate it !"
=> script "BattleManager.processVictory()"

This last script I wanted to try ask Game_Troop to calculate xp
But inside it looks into the list of dead members for xp and items

I think workaround is easy, but I don't know how it would react with your actual battle script.

EDIT

Done

JavaScript:
(function() {

    Game_Troop.prototype.fullExpTotal = function() {
        return this.members().reduce(function(r, enemy) {
            return r + enemy.exp();
        }, 0);
    };

    Game_Troop.prototype.fullGoldTotal = function() {
        return this.members().reduce(function(r, enemy) {
            return r + enemy.gold();
        }, 0) * this.goldRate();
    };

    Game_Troop.prototype.fullMakeDropItems = function() {
        return this.members().reduce(function(r, enemy) {
            return r.concat(enemy.makeDropItems());
        }, []);
    };

    BattleManager.processVictoryWithFullRewards = function() {
        $gameParty.removeBattleStates();
        $gameParty.performVictory();
        this.playVictoryMe();
        this.replayBgmAndBgs();
        this.makeFullRewards();
        this.displayVictoryMessage();
        this.displayRewards();
        this.gainRewards();
        this.endBattle(0);
    };

    BattleManager.makeFullRewards = function() {
        this._rewards = {};
        this._rewards.gold = $gameTroop.fullGoldTotal();
        this._rewards.exp = $gameTroop.fullExpTotal();
        this._rewards.items = $gameTroop.fullMakeDropItems();
    };

})();
Place that Somewhere, in a new file BattleManagerFullReward.js in the plugin folder for exemple
Then activate the pluggin in the pluggin manager

The ligne to call in the battle is "BattleManager.processVictoryWithFullRewards()"
I don't know yet how to do pluggin command to make it looks better, but it's a start
 
Last edited:

0zuma

Villager
Member
Joined
Dec 14, 2019
Messages
25
Reaction score
17
First Language
English
Primarily Uses
RMMV
Uhm... This might be a dumb suggestion but why not just call the function that processes victory?

JavaScript:
BattleManager.processVictory()
 

hinola

Veteran
Veteran
Joined
Jun 27, 2015
Messages
49
Reaction score
67
First Language
Français
Primarily Uses
RMVXA
As I said in the post above, it call methods that calculate xp, gold and item gains with the deads members of the troop

JavaScript:
Game_Troop.prototype.goldTotal = function() {
    return this.deadMembers().reduce(function(r, enemy) {
        return r + enemy.gold();
    }, 0) * this.goldRate();
};
SO I made a second processvictory which call new methods which use every members, dead or alive.
And I won't change the base process because it will apply to every fights, and it shouldn't.
Only if XthenewB want it, at least
 

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
1,700
Reaction score
559
First Language
Dutch
Primarily Uses
RMMV
plugin command can be easy probably using something like:

Alias_PluginCommand = Game_Interpreter.prototype.pluginCommand
Game_Interpreter.prototype.pluginCommand = function(command, args) {
Alias_PluginCommand.call(this,command, args);
if (command === "BattleComplete")
return BattleManager.processVictoryWithFullRewards() ;

or around this, I'm struggling with plugin commands as well, but its
only a short example, cant garantee that this one will work though.
 

hinola

Veteran
Veteran
Joined
Jun 27, 2015
Messages
49
Reaction score
67
First Language
Français
Primarily Uses
RMVXA
Thanks.
I checked on other pluggins too, I made a commande with args

Now you just have to use a pluggin command with "Battle full_reward_victory"

JavaScript:
//=============================================================================
// FullRewardVictory.js
//=============================================================================

/*
  * Now use pluggin commands :
  *
  * Battle full_reward_victory
  *
*/

(function() {
   
    var _GIPC_Before_BattleCommand = Game_Interpreter.prototype.pluginCommand;
   
    Game_Interpreter.prototype.pluginCommand = function(command, args) {
        _GIPC_Before_BattleCommand.call(this, command, args);
        if (command === 'Battle') {
            switch (args[0]) {
            case 'full_reward_victory':
                BattleManager.processVictoryWithFullRewards();
                break;
            }
        }
    };

    Game_Troop.prototype.fullExpTotal = function() {
        return this.members().reduce(function(r, enemy) {
            return r + enemy.exp();
        }, 0);
    };

    Game_Troop.prototype.fullGoldTotal = function() {
        return this.members().reduce(function(r, enemy) {
            return r + enemy.gold();
        }, 0) * this.goldRate();
    };

    Game_Troop.prototype.fullMakeDropItems = function() {
        return this.members().reduce(function(r, enemy) {
            return r.concat(enemy.makeDropItems());
        }, []);
    };

    BattleManager.processVictoryWithFullRewards = function() {
        $gameParty.removeBattleStates();
        $gameParty.performVictory();
        this.playVictoryMe();
        this.replayBgmAndBgs();
        this.makeFullRewards();
        this.displayVictoryMessage();
        this.displayRewards();
        this.gainRewards();
        this.endBattle(0);
    };

    BattleManager.makeFullRewards = function() {
        this._rewards = {};
        this._rewards.gold = $gameTroop.fullGoldTotal();
        this._rewards.exp = $gameTroop.fullExpTotal();
        this._rewards.items = $gameTroop.fullMakeDropItems();
    };

})();
 

XthenewB

Villager
Member
Joined
Apr 5, 2020
Messages
7
Reaction score
0
First Language
german
Primarily Uses
RMMV
Hey! Thank you guys for your suggestions.

Uhm... This might be a dumb suggestion but why not just call the function that processes victory?

JavaScript:
BattleManager.processVictory()
Problem here is, that I get no exp. or anything else in the "victory screen". Because I didn´t killed an enemy. So it would´t work out for this one.


@hinola
This plugin you made is really awesome! I think this could be what I´ve looked for.
I have tried it out and I got a few question.

1. I´m using Yanfly´s-VictoryAftermath, is it possible to change the regular victory screen to the Yanfly´s-Victory.. screen?

2. In this fight I´m using "double exp. + double gold" buffs on the party, if the fight is successfull.
The amount of exp. the plugin show in the victory screen, is just the normal that I get for the enemy.
So for example: The enemy give 100 exp. & 100 Gold usually.
The double amount would be 200 exp. & 200 Gold. The plugin shows the double amount of Gold, but not the exp. I get.
But I noticed that its only a display mistake. Because after the fight I compared the exp. I start, with the exp. I get, and it was actual 200 exp.


Anyway I appreciate for your time!
thanks.
 

mlogan

Global Moderators
Global Mod
Joined
Mar 18, 2012
Messages
14,650
Reaction score
8,079
First Language
English
Primarily Uses
RMMV

I've moved this thread to Plugin Support. Please be sure to post your threads in the correct forum next time. Thank you.

 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Please do not buy games from g2a.com. The sellers have total power over you. The website has many scam sellers. It looks cheap, but the key code didn't work.
A while back I was having fun making my own custom tiles, then I hit carpet... why is it so difficult!? Lol.
Weekend is finally here... what would you like to see (?):
1) Pokemon into zelda minish-cap style
or
2) Pokemon into zelda gbc style
or
3) Zelda into pokemon style

#= Choose ===============#
||__[ Full mockup ]_[ Charset ]__||
#=======================#
I know someday I'll start working on this...

I'm so happy that I got Steam achievements to work in my game, thanks in large part to the posts by other RPG Maker devs on this issue!

Forum statistics

Threads
97,943
Messages
948,060
Members
129,193
Latest member
annygma
Top