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

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".
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.
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.
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?
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.
Spoiler: Add incapacitated state exp
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
Do I paste this below the incapacitate states?
yes
apply it to that plugin
You would have to convert it to Javascript.
This fix is for VX Ace.
If you don't know, Ace uses ruby, MV uses Java
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();
};

Original thread: https://forums.rpgmakerweb.com/threads/victors-incapacitate-states-incapacitate-state-will-not-give-money-or-exp.127599/