Victor's Incapacitate States : "Incapacitate State" will not give Money or EXP

Panda_Artist

Humble RPG Fan
Veteran
Joined
Dec 22, 2018
Messages
195
Reaction score
15
First Language
Portuguese
Primarily Uses
RMVXA
Good Morning / Day / Afternoon / Evening everyone.

I have a request for a bit of support regarding a script:


This script is neat as it allows to create states that incapacitate an enemy and can result in battle victory or game over if all enemies are afflicted. It has an option for a "kill state" and an "incapacitate state", like a Stone state.

However:

When enemies are applied an "incapacitate state" they don't grant EXP or money at the end of battle.

Is there a way to fix this? I really would like to have the enemies drop EXP and money with an "incapacitate state".
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,575
Reaction score
542
First Language
English
Primarily Uses
RMVXA
you could change part of the script.
Ruby:
  alias :all_dead_ve_incapacitate_states? :all_dead?
  def all_dead?
        for i in $game_troop.members.each { |e|
            if e.incapacitated?
                e.die
            end }
    end
    all_dead_ve_incapacitate_states? || all_incapacitated?
  end
*scratch that. kills as soon as the enemy is incapacitated.
 

Featherbrain

Veteran
Veteran
Joined
Jan 12, 2020
Messages
50
Reaction score
39
First Language
English
Primarily Uses
RMMV
Following because I eventually need to fix this for Yanfly Group Categories and the category "Group Defeat." It behaves similarly. If a fix is found for this one I may be able to apply it to that plugin or just switch to this plugin for that functionality.
 

Panda_Artist

Humble RPG Fan
Veteran
Joined
Dec 22, 2018
Messages
195
Reaction score
15
First Language
Portuguese
Primarily Uses
RMVXA
Yes I tried it and it does kill the enemy. It's not exactly what I want. is there a way to make sure the enemy graphic stays in the battle screen for incapacitate states and still recieve EXP and money?
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,575
Reaction score
542
First Language
English
Primarily Uses
RMVXA
not exactly what I want
I know, me neither. I could not find a way to add the extra exp to the $game_troop.exp_total it keeps giving an error no matter which way I tried.
But here is a workaround.
Ruby:
module BattleManager
  def self.process_victory
    @expsum = $game_troop.exp_total
    @goldsum = $game_troop.gold_total
        for i in $game_troop.members.each_with_index { |e, enemy|
            if e.incapacitated?
        @expsum += e.exp
        @goldsum += e.gold
                e.die
            end }
    end
    play_battle_end_me
    replay_bgm_and_bgs
    $game_message.add(sprintf(Vocab::Victory, $game_party.name))
    display_exp
    gain_gold
    gain_drop_items
    gain_exp
    SceneManager.return
    battle_end(0)
    return true
  end

  #--------------------------------------------------------------------------
  # * Display EXP Earned
  #--------------------------------------------------------------------------
  def self.display_exp
    if $game_troop.exp_total > 0 || @expsum > 0
      text = sprintf(Vocab::ObtainExp, @expsum)
      $game_message.add('\.' + text)
    end
  end
  #--------------------------------------------------------------------------
  # * Gold Acquisition and Display
  #--------------------------------------------------------------------------
  def self.gain_gold
    if $game_troop.gold_total > 0 || @goldsum > 0
      text = sprintf(Vocab::ObtainGold, @goldsum)
      $game_message.add('\.' + text)
      $game_party.gain_gold(@goldsum)
    end
    wait_for_message
  end
  #--------------------------------------------------------------------------
  # * EXP Acquisition and Level Up Display
  #--------------------------------------------------------------------------
  def self.gain_exp
    $game_party.all_members.each do |actor|
      actor.gain_exp(@expsum)
    end
    wait_for_message
  end
end
 

Panda_Artist

Humble RPG Fan
Veteran
Joined
Dec 22, 2018
Messages
195
Reaction score
15
First Language
Portuguese
Primarily Uses
RMVXA
Do I paste this below the incapacitate states?
 

Featherbrain

Veteran
Veteran
Joined
Jan 12, 2020
Messages
50
Reaction score
39
First Language
English
Primarily Uses
RMMV
Yeah, I realized that after I posted, lol. Living up to my username there. However, the code logic does seem fairly similar. I actually already fixed it for gold and exp last night. I considered changing the battle manager functions but I ended up changing the game troop functions (for ruby it looks like that's $game_troop.exp_total), that worked really seamlessly for MV at least.

ETA: FWIW, here is the code I used for MV. If the Ruby functions are similar this could probably translate. Like I said, it seamlessly adds the extra exp/gold directly to the total earned from the troop at the end of battle so you don't have to edit the additional display functions. I hard-coded my one custom death state (12), you would probably want to reference the "incapacitated" variable from the plugin instead. I'm still working on the item function today, it's a little bit different and I'm not exactly a coding whiz.


JavaScript:
Game_Troop.prototype.expTotal = function() {
    var deadMemberExp = this.deadMembers().reduce(function(r, enemy) {
        return r + enemy.exp();
    }, 0);
    var groupDefeatExp = 0;   
    for (var i = 0; i < this.aliveMembers().length; ++i) {
        var member = this.aliveMembers()[i];
        if (member && member.isStateAffected(12)) {
            groupDefeatExp += member.enemy().exp;
        }
    }
    return deadMemberExp + groupDefeatExp;
};

Game_Troop.prototype.goldTotal = function() {
    var deadMemberGold = this.deadMembers().reduce(function(r, enemy) {
        return r + enemy.gold();
    }, 0);
    var groupDefeatGold = 0;
    for (var i = 0; i < this.aliveMembers().length; ++i) {
        var member = this.aliveMembers()[i];
        if (member && member.isStateAffected(12)) {
            groupDefeatGold += member.enemy().gold;
        }
    }
    return (deadMemberGold + groupDefeatGold) * this.goldRate();
};
 
Last edited:

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

Latest Threads

Latest Posts

Latest Profile Posts

"How dare you!" is probably the most overused reason to start conflict.
Another day of mostly mapping in Make a Game in RPG Maker MZ: Episode 7 starting now! We're making a mansion! Come watch live and join in on the chat!
Game=Forest, Feature=Tree. There's little worth in looking at a tree except in its relation to how it affects the feel of the forest.
Been a while, guys. Despite being in college now, I'm working on Season's Promise as often as I can.
Helping my sister make her game
I hope i can get some freckles for the generator soon

Forum statistics

Threads
104,575
Messages
1,007,282
Members
136,057
Latest member
simonbelmont88
Top