RMXP - died person is still receiving exp

Started by babcia11, November 23, 2014, 03:27:47 pm

Previous topic - Next topic

babcia11

Hello i need help someone who know rmxp scripts code
When i use this script if any party member die in battle he still can get exp like all other alive member in party :/
without this script everything work fine - died member dont get any exp
but i rly need this in my project :(

This script is mix of 2 other - "battle result" and "moore drop from mob" I no have contact to person who made it anymoore thats why i need help :(

can anyone check why i got problem in this script? why died member can get exp after battle?

(sry for my bad english and this is my 1st post here im total newbie in rmxp)


#=================================================================
# ■ Battle Result by A3D Ver. 1.02
# Useful : show battle result in a different way
# Effect to default script : this code will replace methode "start_phase5" & "update_phase5" in Scene_Battle
# How to install : in script editor, insert all the code above main
# Note : this script is for non-commercial use only, give credit if use
# Contact : A3D (hyper_s@hotmail.com)
#=================================================================

module A3D
  WAIT_WINDOW_APPEAR = 90
  WAIT_RUNNING_NUMBER = 50
  STEP_EXP = 50
  STEP_GOLD = 50
  SE_LEVELUP = ["lvl up", 70, 100]
  SE_NEWSKILL = ["new skill", 70, 100]
  FONT_NAME = "Rum Raisin"
  FONT_SIZE = 22
end

module Ayene
  ITEM = {# ID potwora => [%, id przedmiotu],[%, id przedmiotu], itd.]
1 => [[30, 22],[20, 23],],
  4 => [[35, 22],[25, 23],],
  4 => [[25, 22],[15, 23],],
  4 => [[20, 22],[10, 23],],
  5 => [[50, 18],],
  6 => [[75, 18],],
  7 => [[40, 19],],
  8 => [[60, 20],],
  9 => [[50, 21],],
  10 => [[70, 22],],
  13 => [[50, 18],],
  14 => [[40, 24],],
  17 => [[60, 18],],
  31 => [[60, 25],],
  32 => [[40, 26],],
  33 => [[80, 25],],
  34 => [[80, 27],[50, 28],[20, 29],],
  35 => [[80, 20],],
  36 => [[35, 30],],
  37 => [[15, 31],],
  39 => [[20, 8],],
  }
  WEAPON = {# ID potwora => [%, id broni],[%, id broni], itd.]
 
  10 => [[15, 2],[15,12],],
  11 => [[25, 3],[25,13],[25, 23],], #
  15 => [[15, 2],[15, 12],[15, 22],[15, 32],],
  17 => [[10, 3],[10, 13],[10, 23],[10,33],],
  18 => [[25, 3],[25, 13],[25, 23],], #
  20 => [[15, 3],[15, 13],[15, 23],[15, 33],],
  23 => [[20, 4],[20, 14],[20, 24],[20, 34],], #
  30 => [[100,201],],
  31 => [[15, 3],[15, 13],[15, 23],[15, 33],],
  33 => [[8, 3],[8, 13],[8, 23],[8, 33],],
  35 => [[15, 3],[15, 13],[15, 23],[15, 33],],
  40 => [[3, 3],[3, 13],[3, 23],[3, 33],],
  41 => [[5, 3],[5, 13],[5, 23],[5, 33],],
  42 => [[10, 4],[10, 14],[10, 24],[10, 34],],
  }
  ARMOR = {# ID potwora => [%, id pancerza],[%, id pancerza], itd.] 
 
    8 => [[15,52],[15,62],[15,72],],
    9 => [[15, 2],[15,12],[15,32],[15,42],],
  12 => [[15, 2],[15, 12],[15, 22],],
  13 => [[15,52],[15,62],[15,72],],
  14 => [[15,32],[15,42],],
  16 => [[15,3],[15,13],[15,23],],
  18 => [[25,3],[25,13],[25,23],],
  19 => [[15, 33],[15, 43],],
  21 => [[15, 3],[15, 13],[15, 23],],
  22 => [[15, 53],[15, 63],[15, 73],],
  24 => [[5, 81],[5, 84],[5, 87],[3, 90],],
  32 => [[10,33],[10,43],],
  36 => [[10,4],[10,14],[10,24],],
  }
 
end

#==============================================================================
# Scene_Battle
#==============================================================================
class Scene_Battle
  #--------------------------------------------------------------------------
  # After battle phase start
  #--------------------------------------------------------------------------
  def start_phase5
    @phase = 5
    $game_system.me_play($game_system.battle_end_me)
    $game_system.bgm_play($game_temp.map_bgm)
    exp = 0
    gold = 0
    treasures = []
    for enemy in $game_troop.enemies
      unless enemy.hidden
        exp += enemy.exp
        gold += enemy.gold
        if rand(100) < enemy.treasure_prob
          if enemy.item_id > 0
            treasures.push($data_items[enemy.item_id])           
          end
          if enemy.weapon_id > 0
            treasures.push($data_weapons[enemy.weapon_id])
          end
          if enemy.armor_id > 0
            treasures.push($data_armors[enemy.armor_id])
          end
        end   
        if Ayene::ITEM.include?(enemy.id)
          for i in 0..Ayene::ITEM[enemy.id].size-1
            if rand(100) < Ayene::ITEM[enemy.id][i][0]
              treasures.push($data_items[Ayene::ITEM[enemy.id][i][1]])
            end
          end
        end
        if Ayene::WEAPON.include?(enemy.id)
          for i in 0..Ayene::WEAPON[enemy.id].size-1
            if rand(100) < Ayene::WEAPON[enemy.id][i][0]
              treasures.push($data_weapons[Ayene::WEAPON[enemy.id][i][1]])
            end
          end
        end
        if Ayene::ARMOR.include?(enemy.id)
          for i in 0..Ayene::ARMOR[enemy.id].size-1
            if rand(100) < Ayene::ARMOR[enemy.id][i][0]
              treasures.push($data_armors[Ayene::ARMOR[enemy.id][i][1]])
            end
          end
        end
      end     
    end
    treasures = treasures[0..7]
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      if actor.cant_get_exp? == true
        last_level = actor.level
        actor.exp += exp
        if actor.level > last_level
          @status_window.level_up(i)
        end
      end
    end
    $game_party.gain_gold(gold)
    for item in treasures
      case item
      when RPG::Item
        $game_party.gain_item(item.id, 1)
      when RPG::Weapon
        $game_party.gain_weapon(item.id, 1)
      when RPG::Armor
        $game_party.gain_armor(item.id, 1)
      end
    end   
    # Create Variable & Window
    @phase5_step = 1
    @wait_window_appear = A3D::WAIT_WINDOW_APPEAR
    @wait_running_number = A3D::WAIT_RUNNING_NUMBER
    @resultreceive_window = Window_ResultReceive.new(exp, gold, treasures)
    @resultgold_window = Window_ResultGold.new
    @resultparty_window = Window_ResultParty.new
    @actor_level_before = []
    @resultlevel_window = []
    @resultskill_window = []
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      @actor_level_before[i] = actor.level
      @resultlevel_window[i] = Window_ResultLevel.new(i)
      @resultskill_window[i] = Window_ResultSkill.new(i)
    end
  end
  #--------------------------------------------------------------------------
  # ● Update Phase 5
  #--------------------------------------------------------------------------
  def update_phase5
    case @phase5_step
    when 1 # EXP & Gold Phase
      update_phase5_step1
    when 2 # Skill Phase
      update_phase5_step2
    when 3 # Delete Window Phase
      update_phase5_step3
    end
  end
  #--------------------------------------------------------------------------
  # ● Update Phase 5 Step 1
  #--------------------------------------------------------------------------
  def update_phase5_step1
    # Wait Count Before Window Appear
    if @wait_window_appear > 0
      @wait_window_appear -= 1
      if @wait_window_appear == 0
        @resultreceive_window.visible = true
        @resultgold_window.visible = true
        @resultparty_window.visible = true
        $game_temp.battle_main_phase = false
      end
      return
    end
    # Wait Count Before Running Number
    if @wait_running_number > 0
      @wait_running_number -= 1
      return
    end
    # Change Item Page
    if Input.trigger?(Input::RIGHT)
      if @resultreceive_window.max_page != 1
        $game_system.se_play($data_system.cursor_se)
        @resultreceive_window.page = @resultreceive_window.page == 1 ? 2 : 1
        @resultreceive_window.refresh
      end
    end
    # EXP & Gold Rolling
    if (@resultreceive_window.exp != 0 || @resultreceive_window.gold != 0)
      # Input C to Shortcut Calculation
      if Input.trigger?(Input::C)
        for i in 0...$game_party.actors.size
          actor = $game_party.actors[i]
          level_before = actor.level
          actor.exp += @resultreceive_window.exp
          if actor.level > level_before
            @resultlevel_window[i].visible = true
            Audio.se_play("Audio/SE/" + A3D::SE_LEVELUP[0], A3D::SE_LEVELUP[1], A3D::SE_LEVELUP[2])
          end
        end
        $game_party.gain_gold(@resultreceive_window.gold)
        @resultreceive_window.exp = 0
        @resultreceive_window.gold = 0
        @resultreceive_window.refresh
        @resultgold_window.refresh
        @resultparty_window.refresh
      end
    # EXP
      if @resultreceive_window.exp != 0
        step_exp = @resultreceive_window.exp >= A3D::STEP_EXP.abs ? A3D::STEP_EXP.abs : @resultreceive_window.exp
        for i in 0...$game_party.actors.size
          actor = $game_party.actors[i]
          if actor.next_rest_exp <= step_exp && actor.next_rest_exp != 0
            @resultlevel_window[i].visible = true
            Audio.se_play("Audio/SE/" + A3D::SE_LEVELUP[0], A3D::SE_LEVELUP[1], A3D::SE_LEVELUP[2])
          end
          actor.exp += step_exp
        end
        @resultreceive_window.exp -= step_exp
        @resultreceive_window.refresh
        @resultparty_window.refresh
      end
      # Gold
      if @resultreceive_window.gold != 0
        step_gold = @resultreceive_window.gold >= A3D::STEP_GOLD.abs ? A3D::STEP_GOLD.abs : @resultreceive_window.gold
        $game_party.gain_gold(step_gold)
        @resultreceive_window.gold -= step_gold
        @resultreceive_window.refresh
        @resultgold_window.refresh
      end
      return
    end
    # Input C to Bypass Step
    if Input.trigger?(Input::C)
      @phase5_step = 2
      return
    end
  end
  #--------------------------------------------------------------------------
  # ● Update Phase 5 Step 2
  #--------------------------------------------------------------------------
  def update_phase5_step2
    # Change Item Page
    if Input.trigger?(Input::RIGHT)
      if @resultreceive_window.max_page != 1
      $game_system.se_play($data_system.cursor_se)
      @resultreceive_window.page = @resultreceive_window.page == 1 ? 2 : 1
      @resultreceive_window.refresh
      end
    end
    # Initialize Skill Phase
    if @initialized_skill_phase == nil
      for i in 0...$game_party.actors.size
        actor = $game_party.actors[i]
        for skill in $data_classes[actor.class_id].learnings
          if skill.level > @actor_level_before[i] && skill.level <= actor.level
            Audio.se_play("Audio/SE/" + A3D::SE_NEWSKILL[0], A3D::SE_NEWSKILL[1], A3D::SE_NEWSKILL[2])
            @resultskill_window[i].skill_id = skill.skill_id
            @resultskill_window[i].visible = true
            @resultskill_window[i].refresh
            @skill_phase_active = true
          end
        end
      end
      @initialized_skill_phase = true
    end
    # If Skill Phase Active, Show Window
    if @skill_phase_active != nil
      if @resultskill_window[0].x != 456
        for i in 0...$game_party.actors.size
          @resultskill_window[i].x -= 23
        end
        return
      end
    else
      @phase5_step = 3
      return
    end
    # Input C to Bypass Step
    if Input.trigger?(Input::C)
      @phase5_step = 3
      return
    end
  end
  #--------------------------------------------------------------------------
  # ● Update Phase 5 Step 3
  #--------------------------------------------------------------------------
  def update_phase5_step3
    # Delete All Result-Window
    @resultreceive_window.dispose
    @resultgold_window.dispose
    @resultparty_window.dispose
    for i in 0...$game_party.actors.size
      @resultlevel_window[i].dispose
      @resultskill_window[i].dispose
    end
    battle_end(0)
  end 
end

#==============================================================================
# ■ Game_Actor
#==============================================================================
class Game_Actor
  def next_rest_exp
    return @exp_list[@level+1] > 0 ? (@exp_list[@level+1] - @exp) : 0
  end
end

#==============================================================================
# ■ Window_ResultReceive
#==============================================================================

class Window_ResultReceive < Window_Base
  #--------------------------------------------------------------------------
  # ● Attr
  #--------------------------------------------------------------------------
  attr_accessor :exp
  attr_accessor :gold
  attr_accessor :page
  attr_reader :max_page
  #--------------------------------------------------------------------------
  # ● Initialize
  #--------------------------------------------------------------------------
  def initialize(exp, gold, treasures)
    super(40, 28, 224, 212)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = A3D::FONT_NAME
    self.contents.font.size = A3D::FONT_SIZE
    self.back_opacity = 160
    self.visible = false
    @exp = exp
    @gold = gold
    @treasures = treasures
    @page = 1
    @max_page = treasures.size > 4 ? 2 : 1
    refresh
  end
  #--------------------------------------------------------------------------
  # ● Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_outline_text(0, -8, self.width - 32, 32, "Exp")
    self.contents.draw_outline_text(0, 16, self.width - 32, 32, $data_system.words.gold)
    self.contents.draw_outline_text(0, 40, self.width - 32, 32, $data_system.words.item + " :")
    self.contents.font.color = normal_color
    self.contents.draw_outline_text(0, -8, self.width - 32, 32, @exp.to_s, 2)
    self.contents.draw_outline_text(0, 16, self.width - 32, 32, @gold.to_s, 2)
    if @treasures.size == 0
      self.contents.draw_outline_text(0, 68, self.width - 32, 32, "Nic nie znaleziono")
      elsif @treasures.size > 4
      bitmap = RPG::Cache.windowskin($game_system.windowskin_name)
      self.contents.blt(184, 116, bitmap, Rect.new(168, 24, 16, 16), 255)
    end
    y = 68
    item_start_index = @page == 1 ? 0 : 4
    for i in item_start_index...@treasures.size
      item = @treasures[i]
      draw_item_name(item, 0, y)
      y += 28
    end
  end 
end

#==============================================================================
# ■ Window_ResultGold
#==============================================================================

class Window_ResultGold < Window_Base
  #--------------------------------------------------------------------------
  # ● Initialize
  #--------------------------------------------------------------------------
  def initialize
    super(40, 240, 224, 52)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = A3D::FONT_NAME
    self.contents.font.size = A3D::FONT_SIZE
    self.back_opacity = 160
    self.visible = false
    refresh
  end
  #--------------------------------------------------------------------------
  # ● Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_outline_text(0, -8, self.width - 32, 32, "W sumie " + $data_system.words.gold)
    self.contents.font.color = normal_color
    self.contents.draw_outline_text(0, -8, self.width - 32, 32, $game_party.gold.to_s, 2)
  end 
end

#==============================================================================
# ■ Window_ResultParty
#==============================================================================

class Window_ResultParty < Window_Base
  #--------------------------------------------------------------------------
  # ● Initialize
  #--------------------------------------------------------------------------
  def initialize
    super(264, 28, 336, 264)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = A3D::FONT_NAME
    self.contents.font.size = A3D::FONT_SIZE
    self.back_opacity = 160
    self.visible = false
    refresh
  end
  #--------------------------------------------------------------------------
  # ● Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      y = 60 * i + 22
      draw_actor_graphic(actor, 24, y + 28 )
      draw_actor_name(actor, 64, y - 28)
      self.contents.font.color = system_color
      self.contents.draw_outline_text(116, y, (self.width - 32), 32, "LVL")
      self.contents.draw_outline_text(188, y, (self.width - 32), 32, "Nast.")
      self.contents.font.color = normal_color
      self.contents.draw_outline_text(-140, y, (self.width - 32), 32, actor.level.to_s ,2)
      self.contents.draw_outline_text(0 , y, (self.width - 32), 32, actor.next_rest_exp_s ,2)
    end
  end
end

#==============================================================================
# ■ Window_ResultLevel
#==============================================================================

class Window_ResultLevel < Window_Base
  #--------------------------------------------------------------------------
  # ● Initialize
  #--------------------------------------------------------------------------
  def initialize(id)
    super(332, 60 * id + 40, 124, 60)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = A3D::FONT_NAME
    self.contents.font.size = A3D::FONT_SIZE
    self.back_opacity = 160
    self.visible = false
    self.z = 200
    refresh
  end
  #--------------------------------------------------------------------------
  # ● Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.draw_outline_text(0, -2, self.width - 32, 32, "Lvl up", 1)
  end 
end

#==============================================================================
# ■ Window_ResultSkill
#==============================================================================

class Window_ResultSkill < Window_Base
  #--------------------------------------------------------------------------
  # ● Attr
  #--------------------------------------------------------------------------
  attr_accessor :skill_id
  #--------------------------------------------------------------------------
  # ● Initialize
  #--------------------------------------------------------------------------
  def initialize(id)
    super(640, 60 * id + 40, 200, 60)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = A3D::FONT_NAME
    self.contents.font.size = A3D::FONT_SIZE
    self.back_opacity = 160
    self.visible = false
    self.z = 200
    @skill_id = nil
  end
  #--------------------------------------------------------------------------
  # ● Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    if @skill_id == nil
      return
    end
    skill = $data_skills[@skill_id]
    bitmap = RPG::Cache.icon(skill.icon_name)
    self.contents.blt(0, 2, bitmap, Rect.new(0, 0, 24, 24), 255)
    self.contents.font.color = normal_color
    self.contents.draw_outline_text(32, -2, self.width - 64, 32, skill.name)
  end
end

KK20

*moved to Script Troubleshooting*

It just needed a check if the actor was currently applied with a state that would prevent it from gaining EXP just before the actual EXP is added.

next if actor.cant_get_exp?

Also, this script is pretty poorly written. Did you notice you were gaining twice as much gold? I removed that for you as well. Replace entire script with this.

#=================================================================
# ■ Battle Result by A3D Ver. 1.02
# Useful : show battle result in a different way
# Effect to default script : this code will replace methode "start_phase5" & "update_phase5" in Scene_Battle
# How to install : in script editor, insert all the code above main
# Note : this script is for non-commercial use only, give credit if use
# Contact : A3D (hyper_s@hotmail.com)
#=================================================================

module A3D
  WAIT_WINDOW_APPEAR = 90
  WAIT_RUNNING_NUMBER = 50
  STEP_EXP = 50
  STEP_GOLD = 50
  SE_LEVELUP = ["lvl up", 70, 100]
  SE_NEWSKILL = ["new skill", 70, 100]
  FONT_NAME = "Rum Raisin"
  FONT_SIZE = 22
end

module Ayene
  ITEM = {# ID potwora => [%, id przedmiotu],[%, id przedmiotu], itd.]
1 => [[30, 22],[20, 23],],
  4 => [[35, 22],[25, 23],],
  4 => [[25, 22],[15, 23],],
  4 => [[20, 22],[10, 23],],
  5 => [[50, 18],],
  6 => [[75, 18],],
  7 => [[40, 19],],
  8 => [[60, 20],],
  9 => [[50, 21],],
  10 => [[70, 22],],
  13 => [[50, 18],],
  14 => [[40, 24],],
  17 => [[60, 18],],
  31 => [[60, 25],],
  32 => [[40, 26],],
  33 => [[80, 25],],
  34 => [[80, 27],[50, 28],[20, 29],],
  35 => [[80, 20],],
  36 => [[35, 30],],
  37 => [[15, 31],],
  39 => [[20, 8],],
  }
  WEAPON = {# ID potwora => [%, id broni],[%, id broni], itd.]
 
  10 => [[15, 2],[15,12],],
  11 => [[25, 3],[25,13],[25, 23],], #
  15 => [[15, 2],[15, 12],[15, 22],[15, 32],],
  17 => [[10, 3],[10, 13],[10, 23],[10,33],],
  18 => [[25, 3],[25, 13],[25, 23],], #
  20 => [[15, 3],[15, 13],[15, 23],[15, 33],],
  23 => [[20, 4],[20, 14],[20, 24],[20, 34],], #
  30 => [[100,201],],
  31 => [[15, 3],[15, 13],[15, 23],[15, 33],],
  33 => [[8, 3],[8, 13],[8, 23],[8, 33],],
  35 => [[15, 3],[15, 13],[15, 23],[15, 33],],
  40 => [[3, 3],[3, 13],[3, 23],[3, 33],],
  41 => [[5, 3],[5, 13],[5, 23],[5, 33],],
  42 => [[10, 4],[10, 14],[10, 24],[10, 34],],
  }
  ARMOR = {# ID potwora => [%, id pancerza],[%, id pancerza], itd.] 
 
    8 => [[15,52],[15,62],[15,72],],
    9 => [[15, 2],[15,12],[15,32],[15,42],],
  12 => [[15, 2],[15, 12],[15, 22],],
  13 => [[15,52],[15,62],[15,72],],
  14 => [[15,32],[15,42],],
  16 => [[15,3],[15,13],[15,23],],
  18 => [[25,3],[25,13],[25,23],],
  19 => [[15, 33],[15, 43],],
  21 => [[15, 3],[15, 13],[15, 23],],
  22 => [[15, 53],[15, 63],[15, 73],],
  24 => [[5, 81],[5, 84],[5, 87],[3, 90],],
  32 => [[10,33],[10,43],],
  36 => [[10,4],[10,14],[10,24],],
  }
 
end

#==============================================================================
# Scene_Battle
#==============================================================================
class Scene_Battle
  #--------------------------------------------------------------------------
  # After battle phase start
  #--------------------------------------------------------------------------
  def start_phase5
    @phase = 5
    $game_system.me_play($game_system.battle_end_me)
    $game_system.bgm_play($game_temp.map_bgm)
    exp = 0
    gold = 0
    treasures = []
    for enemy in $game_troop.enemies
      unless enemy.hidden
        exp += enemy.exp
        gold += enemy.gold
        if rand(100) < enemy.treasure_prob
          if enemy.item_id > 0
            treasures.push($data_items[enemy.item_id])           
          end
          if enemy.weapon_id > 0
            treasures.push($data_weapons[enemy.weapon_id])
          end
          if enemy.armor_id > 0
            treasures.push($data_armors[enemy.armor_id])
          end
        end   
        if Ayene::ITEM.include?(enemy.id)
          for i in 0..Ayene::ITEM[enemy.id].size-1
            if rand(100) < Ayene::ITEM[enemy.id][i][0]
              treasures.push($data_items[Ayene::ITEM[enemy.id][i][1]])
            end
          end
        end
        if Ayene::WEAPON.include?(enemy.id)
          for i in 0..Ayene::WEAPON[enemy.id].size-1
            if rand(100) < Ayene::WEAPON[enemy.id][i][0]
              treasures.push($data_weapons[Ayene::WEAPON[enemy.id][i][1]])
            end
          end
        end
        if Ayene::ARMOR.include?(enemy.id)
          for i in 0..Ayene::ARMOR[enemy.id].size-1
            if rand(100) < Ayene::ARMOR[enemy.id][i][0]
              treasures.push($data_armors[Ayene::ARMOR[enemy.id][i][1]])
            end
          end
        end
      end     
    end
    treasures = treasures[0..7]

    for item in treasures
      case item
      when RPG::Item
        $game_party.gain_item(item.id, 1)
      when RPG::Weapon
        $game_party.gain_weapon(item.id, 1)
      when RPG::Armor
        $game_party.gain_armor(item.id, 1)
      end
    end   
    # Create Variable & Window
    @phase5_step = 1
    @wait_window_appear = A3D::WAIT_WINDOW_APPEAR
    @wait_running_number = A3D::WAIT_RUNNING_NUMBER
    @resultreceive_window = Window_ResultReceive.new(exp, gold, treasures)
    @resultgold_window = Window_ResultGold.new
    @resultparty_window = Window_ResultParty.new
    @actor_level_before = []
    @resultlevel_window = []
    @resultskill_window = []
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      @actor_level_before[i] = actor.level
      @resultlevel_window[i] = Window_ResultLevel.new(i)
      @resultskill_window[i] = Window_ResultSkill.new(i)
    end
  end
  #--------------------------------------------------------------------------
  # ● Update Phase 5
  #--------------------------------------------------------------------------
  def update_phase5
    case @phase5_step
    when 1 # EXP & Gold Phase
      update_phase5_step1
    when 2 # Skill Phase
      update_phase5_step2
    when 3 # Delete Window Phase
      update_phase5_step3
    end
  end
  #--------------------------------------------------------------------------
  # ● Update Phase 5 Step 1
  #--------------------------------------------------------------------------
  def update_phase5_step1
    # Wait Count Before Window Appear
    if @wait_window_appear > 0
      @wait_window_appear -= 1
      if @wait_window_appear == 0
        @resultreceive_window.visible = true
        @resultgold_window.visible = true
        @resultparty_window.visible = true
        $game_temp.battle_main_phase = false
      end
      return
    end
    # Wait Count Before Running Number
    if @wait_running_number > 0
      @wait_running_number -= 1
      return
    end
    # Change Item Page
    if Input.trigger?(Input::RIGHT)
      if @resultreceive_window.max_page != 1
        $game_system.se_play($data_system.cursor_se)
        @resultreceive_window.page = @resultreceive_window.page == 1 ? 2 : 1
        @resultreceive_window.refresh
      end
    end
    # EXP & Gold Rolling
    if (@resultreceive_window.exp != 0 || @resultreceive_window.gold != 0)
      # Input C to Shortcut Calculation
      if Input.trigger?(Input::C)
        for i in 0...$game_party.actors.size
          actor = $game_party.actors[i]
          next if actor.cant_get_exp?
          level_before = actor.level
          actor.exp += @resultreceive_window.exp
          if actor.level > level_before
            @resultlevel_window[i].visible = true
            Audio.se_play("Audio/SE/" + A3D::SE_LEVELUP[0], A3D::SE_LEVELUP[1], A3D::SE_LEVELUP[2])
          end
        end
        $game_party.gain_gold(@resultreceive_window.gold)
        @resultreceive_window.exp = 0
        @resultreceive_window.gold = 0
        @resultreceive_window.refresh
        @resultgold_window.refresh
        @resultparty_window.refresh
      end
    # EXP
      if @resultreceive_window.exp != 0
        step_exp = @resultreceive_window.exp >= A3D::STEP_EXP.abs ? A3D::STEP_EXP.abs : @resultreceive_window.exp
        for i in 0...$game_party.actors.size
          actor = $game_party.actors[i]
          next if actor.cant_get_exp?
          if actor.next_rest_exp <= step_exp && actor.next_rest_exp != 0
            @resultlevel_window[i].visible = true
            Audio.se_play("Audio/SE/" + A3D::SE_LEVELUP[0], A3D::SE_LEVELUP[1], A3D::SE_LEVELUP[2])
          end
          actor.exp += step_exp
        end
        @resultreceive_window.exp -= step_exp
        @resultreceive_window.refresh
        @resultparty_window.refresh
      end
      # Gold
      if @resultreceive_window.gold != 0
        step_gold = @resultreceive_window.gold >= A3D::STEP_GOLD.abs ? A3D::STEP_GOLD.abs : @resultreceive_window.gold
        $game_party.gain_gold(step_gold)
        @resultreceive_window.gold -= step_gold
        @resultreceive_window.refresh
        @resultgold_window.refresh
      end
      return
    end
    # Input C to Bypass Step
    if Input.trigger?(Input::C)
      @phase5_step = 2
      return
    end
  end
  #--------------------------------------------------------------------------
  # ● Update Phase 5 Step 2
  #--------------------------------------------------------------------------
  def update_phase5_step2
    # Change Item Page
    if Input.trigger?(Input::RIGHT)
      if @resultreceive_window.max_page != 1
      $game_system.se_play($data_system.cursor_se)
      @resultreceive_window.page = @resultreceive_window.page == 1 ? 2 : 1
      @resultreceive_window.refresh
      end
    end
    # Initialize Skill Phase
    if @initialized_skill_phase == nil
      for i in 0...$game_party.actors.size
        actor = $game_party.actors[i]
        for skill in $data_classes[actor.class_id].learnings
          if skill.level > @actor_level_before[i] && skill.level <= actor.level
            Audio.se_play("Audio/SE/" + A3D::SE_NEWSKILL[0], A3D::SE_NEWSKILL[1], A3D::SE_NEWSKILL[2])
            @resultskill_window[i].skill_id = skill.skill_id
            @resultskill_window[i].visible = true
            @resultskill_window[i].refresh
            @skill_phase_active = true
          end
        end
      end
      @initialized_skill_phase = true
    end
    # If Skill Phase Active, Show Window
    if @skill_phase_active != nil
      if @resultskill_window[0].x != 456
        for i in 0...$game_party.actors.size
          @resultskill_window[i].x -= 23
        end
        return
      end
    else
      @phase5_step = 3
      return
    end
    # Input C to Bypass Step
    if Input.trigger?(Input::C)
      @phase5_step = 3
      return
    end
  end
  #--------------------------------------------------------------------------
  # ● Update Phase 5 Step 3
  #--------------------------------------------------------------------------
  def update_phase5_step3
    # Delete All Result-Window
    @resultreceive_window.dispose
    @resultgold_window.dispose
    @resultparty_window.dispose
    for i in 0...$game_party.actors.size
      @resultlevel_window[i].dispose
      @resultskill_window[i].dispose
    end
    battle_end(0)
  end 
end

#==============================================================================
# ■ Game_Actor
#==============================================================================
class Game_Actor
  def next_rest_exp
    return @exp_list[@level+1] > 0 ? (@exp_list[@level+1] - @exp) : 0
  end
end

#==============================================================================
# ■ Window_ResultReceive
#==============================================================================

class Window_ResultReceive < Window_Base
  #--------------------------------------------------------------------------
  # ● Attr
  #--------------------------------------------------------------------------
  attr_accessor :exp
  attr_accessor :gold
  attr_accessor :page
  attr_reader :max_page
  #--------------------------------------------------------------------------
  # ● Initialize
  #--------------------------------------------------------------------------
  def initialize(exp, gold, treasures)
    super(40, 28, 224, 212)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = A3D::FONT_NAME
    self.contents.font.size = A3D::FONT_SIZE
    self.back_opacity = 160
    self.visible = false
    @exp = exp
    @gold = gold
    @treasures = treasures
    @page = 1
    @max_page = treasures.size > 4 ? 2 : 1
    refresh
  end
  #--------------------------------------------------------------------------
  # ● Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_outline_text(0, -8, self.width - 32, 32, "Exp")
    self.contents.draw_outline_text(0, 16, self.width - 32, 32, $data_system.words.gold)
    self.contents.draw_outline_text(0, 40, self.width - 32, 32, $data_system.words.item + " :")
    self.contents.font.color = normal_color
    self.contents.draw_outline_text(0, -8, self.width - 32, 32, @exp.to_s, 2)
    self.contents.draw_outline_text(0, 16, self.width - 32, 32, @gold.to_s, 2)
    if @treasures.size == 0
      self.contents.draw_outline_text(0, 68, self.width - 32, 32, "Nic nie znaleziono")
      elsif @treasures.size > 4
      bitmap = RPG::Cache.windowskin($game_system.windowskin_name)
      self.contents.blt(184, 116, bitmap, Rect.new(168, 24, 16, 16), 255)
    end
    y = 68
    item_start_index = @page == 1 ? 0 : 4
    for i in item_start_index...@treasures.size
      item = @treasures[i]
      draw_item_name(item, 0, y)
      y += 28
    end
  end 
end

#==============================================================================
# ■ Window_ResultGold
#==============================================================================

class Window_ResultGold < Window_Base
  #--------------------------------------------------------------------------
  # ● Initialize
  #--------------------------------------------------------------------------
  def initialize
    super(40, 240, 224, 52)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = A3D::FONT_NAME
    self.contents.font.size = A3D::FONT_SIZE
    self.back_opacity = 160
    self.visible = false
    refresh
  end
  #--------------------------------------------------------------------------
  # ● Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_outline_text(0, -8, self.width - 32, 32, "W sumie " + $data_system.words.gold)
    self.contents.font.color = normal_color
    self.contents.draw_outline_text(0, -8, self.width - 32, 32, $game_party.gold.to_s, 2)
  end 
end

#==============================================================================
# ■ Window_ResultParty
#==============================================================================

class Window_ResultParty < Window_Base
  #--------------------------------------------------------------------------
  # ● Initialize
  #--------------------------------------------------------------------------
  def initialize
    super(264, 28, 336, 264)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = A3D::FONT_NAME
    self.contents.font.size = A3D::FONT_SIZE
    self.back_opacity = 160
    self.visible = false
    refresh
  end
  #--------------------------------------------------------------------------
  # ● Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      y = 60 * i + 22
      draw_actor_graphic(actor, 24, y + 28 )
      draw_actor_name(actor, 64, y - 28)
      self.contents.font.color = system_color
      self.contents.draw_outline_text(116, y, (self.width - 32), 32, "LVL")
      self.contents.draw_outline_text(188, y, (self.width - 32), 32, "Nast.")
      self.contents.font.color = normal_color
      self.contents.draw_outline_text(-140, y, (self.width - 32), 32, actor.level.to_s ,2)
      self.contents.draw_outline_text(0 , y, (self.width - 32), 32, actor.next_rest_exp_s ,2)
    end
  end
end

#==============================================================================
# ■ Window_ResultLevel
#==============================================================================

class Window_ResultLevel < Window_Base
  #--------------------------------------------------------------------------
  # ● Initialize
  #--------------------------------------------------------------------------
  def initialize(id)
    super(332, 60 * id + 40, 124, 60)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = A3D::FONT_NAME
    self.contents.font.size = A3D::FONT_SIZE
    self.back_opacity = 160
    self.visible = false
    self.z = 200
    refresh
  end
  #--------------------------------------------------------------------------
  # ● Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.draw_outline_text(0, -2, self.width - 32, 32, "Lvl up", 1)
  end 
end

#==============================================================================
# ■ Window_ResultSkill
#==============================================================================

class Window_ResultSkill < Window_Base
  #--------------------------------------------------------------------------
  # ● Attr
  #--------------------------------------------------------------------------
  attr_accessor :skill_id
  #--------------------------------------------------------------------------
  # ● Initialize
  #--------------------------------------------------------------------------
  def initialize(id)
    super(640, 60 * id + 40, 200, 60)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = A3D::FONT_NAME
    self.contents.font.size = A3D::FONT_SIZE
    self.back_opacity = 160
    self.visible = false
    self.z = 200
    @skill_id = nil
  end
  #--------------------------------------------------------------------------
  # ● Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    if @skill_id == nil
      return
    end
    skill = $data_skills[@skill_id]
    bitmap = RPG::Cache.icon(skill.icon_name)
    self.contents.blt(0, 2, bitmap, Rect.new(0, 0, 24, 24), 255)
    self.contents.font.color = normal_color
    self.contents.draw_outline_text(32, -2, self.width - 64, 32, skill.name)
  end
end

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

babcia11

Thank you very much for fix all this bugs in script, now everything works perfectly!! :)