Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Swaps lead when lead is dead

Does anyone knows how to swap the lead when the lead is dead?
I am currently using the caterpillar system. I want to know how to edit it so
that when a character in my team dies, the lead is switched to the next character in the team and the dead character's graphic is changed to show a
dead pose. So when we move around with a dead character in the caterpillar system, how do I make it so that it seems that we are dragging around an unconscious character instead of the unrealistic "I am knocked out but yet I am still walking around"? Please help me. I am sure it is quite simple to tweak.

If Actor's HP is 0, swap actor with the next actor in line.
If Actor's HP is 0, change graphic

But I don't know where and how to implement such codes. Please help me. Thanks.
 
I have made this.
I strongly suggest that you take time to check the code.

Code:
#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
#  This class handles the player. Its functions include event starting
#  determinants and map scrolling. Refer to "$game_player" for the one
#  instance of this class.
#------------------------------------------------------------------------------
# *  Edited by Dargor
#    Effect: Change the player's graphic if the leading actor is dead
#    Edited on: 21/01/07
#==============================================================================

class Game_Player
  #--------------------------------------------------------------------------
  # * Alias listing
  #--------------------------------------------------------------------------
  alias character_hp0_refresh refresh
  alias character_hp0_update update
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    # Call the original refresh method
    character_hp0_refresh
    # Get lead actor
    $game_party.actors.each do |actor|
      # Check if actor is dead
      unless actor.dead?
        # Set character file name and hue
        @character_name = actor.character_name
        @character_hue = actor.character_hue
        # Initialize opacity level and blending method
        @opacity = 255
        @blend_type = 0
        return
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Call the original update method
    character_hp0_update
    # Refresh player
    refresh
  end
end

Just copy and past it above main.
 
Thanks. The swapping works. But in the caterpillar system, it doesn't work because when my lead is dead, it changes to the next alive hero but the alive hero's graphic in the caterpillar system doesn't changes. So it would seem like there are two same alive hero at the same time.

How do I link the swap script to the caterpillar system?

Or maybe how do I swap the character's position in the party and not just the image?
 
I was using a caterpillar system called train actor by Fukuyama. I am not sure... I know it was edited by Blizzard. Here's the script


Code:
# train_actor 

=begin
Caterpillar walking script 

Copyright © 2005 fukuyama 

This library is free software; you can redistribute it and/or 
modify it under the terms of the GNU Lesser General Public 
License as published by the Free Software Foundation; either 
version 2.1 of the License, or (at your option) any later version. 

This library is distributed in the hope that it will be useful, 
but WITHOUT ANY WARRANTY; without even the implied warranty of 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
Lesser General Public License for more details. 

You should have received a copy of the GNU Lesser General Public 
License along with this library; if not, write to the Free Software 
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA 

[url]http://www.gnu.org/licenses/lgpl.html[/url] 
[url]http://www.opensource.gr.jp/lesser/lgpl.ja.html[/url] 

=end 

# Config.rb 
#============================================================================== 
# â–  Train_Actor::Config 
#------------------------------------------------------------------------------ 
# Caterpillar movement of actor is carried out on map 
#============================================================================== 

module Train_Actor 

# ●Switch setup for transparent status 
# When true, switch control is used 
# TRANSPARENT_SWITCH = true 
TRANSPARENT_SWITCH = true 

# ●Switch number for transparent status 
# When TRANSPARENT_SWITCH is true, transparency will be activated when the switch of this number is on 
TRANSPARENT_SWITCHES_INDEX = 1 

# ●Maximum number of actors 
# There will be support for a large number of people in a party in the future... 
TRAIN_ACTOR_SIZE_MAX = 4

# Constants 
DOWN_LEFT  = 1 
DOWN_RIGHT = 3 
UP_LEFT    = 7 
UP_RIGHT   = 9 
JUMP       = 5 

# Put any actor IDs who should have a "stopped animation" if in the caterpillar
# i.e. if a party member "is floating" it will look stupid if he suddenly stops
# moving in the air.
# - added by Blizzard
ACTOR_IDS = [2, 3, 4]

end 

# rgss 

# Spriteset_Map_Module.rb 
#============================================================================== 
# â–  Spriteset_Map_Module 
#------------------------------------------------------------------------------ 
# Caterpillar movement of actor is carried out on map 
#============================================================================== 

module Train_Actor 

module Spriteset_Map_Module 
  def setup_actor_character_sprites? 
    return @setup_actor_character_sprites_flag != nil 
  end 
  def setup_actor_character_sprites(characters) 
    if !setup_actor_character_sprites? 
      for character in characters.reverse 
        @character_sprites.unshift( 
          Sprite_Character.new(@viewport1, character) 
        ) 
      end 
      @setup_actor_character_sprites_flag = true 
    end 
  end 
end 

end 

class Spriteset_Map 
  include Train_Actor::Spriteset_Map_Module 
end 

# Scene_Map_Module.rb 
#============================================================================== 
# â–  Scene_Map_Module 
#------------------------------------------------------------------------------ 
# Caterpillar movement of actor is carried out on map 
#============================================================================== 

module Train_Actor 

module Scene_Map_Module 
  def setup_actor_character_sprites(characters) 
    @spriteset.setup_actor_character_sprites(characters) 
  end 
end 

end 

class Scene_Map 
  include Train_Actor::Scene_Map_Module 
end

# Game_Party_Module.rb 
#============================================================================== 
# â–  Game_Party_Module 
#------------------------------------------------------------------------------ 
# Caterpillar movement of actor is carried out on map 
#============================================================================== 

module Train_Actor 

module Game_Party_Module
  
  attr_reader :characters
  
  def update_party_order() return actors end
  
  def setup_actor_character_sprites 
    if @characters.nil? 
      @characters = [] 
      for i in 1 ... TRAIN_ACTOR_SIZE_MAX 
        @characters.push(Game_Party_Actor.new) 
      end 
    end 
    setup_actors = update_party_order 
    for i in 1 ... TRAIN_ACTOR_SIZE_MAX 
      @characters[i - 1].setup(setup_actors[i]) 
    end
    if $scene.class.method_defined?('setup_actor_character_sprites') 
      $scene.setup_actor_character_sprites(@characters) 
    end
  end
  
  def update_party_actors
     update_party_order
    setup_actor_character_sprites 
    transparent = $game_player.transparent 
    if transparent == false and TRANSPARENT_SWITCH 
      transparent = $game_switches[TRANSPARENT_SWITCHES_INDEX] 
    end
    for character in @characters 
      character.transparent = transparent 
      character.move_speed = $game_player.move_speed 
      if ACTOR_IDS.include?(character.cp_id) # Blizzard's support for stopped animation
        character.step_anime = true # Blizzard's support for stopped animation
      else # Blizzard's support for stopped animation
        character.step_anime = $game_player.step_anime
      end # Blizzard's support for stopped animation
      character.update 
    end 
  end 
  
  def moveto_party_actors( x, y ) 
    setup_actor_character_sprites 
    for character in @characters 
      character.moveto( x, y ) 
    end 
    @move_list = [] if @move_list == nil 
    move_list_setup 
  end 
  
  def move_party_actors 
    if @move_list == nil 
      @move_list = [] 
      move_list_setup 
    end 
    @move_list.each_index do |i| 
    if @characters[i] != nil 
      case @move_list[i].type 
        when Input::DOWN 
          @characters[i].move_down(@move_list[i].args[0]) 
        when Input::LEFT 
          @characters[i].move_left(@move_list[i].args[0]) 
        when Input::RIGHT 
          @characters[i].move_right(@move_list[i].args[0]) 
        when Input::UP 
          @characters[i].move_up(@move_list[i].args[0]) 
        when DOWN_LEFT 
          @characters[i].move_lower_left 
        when DOWN_RIGHT 
          @characters[i].move_lower_right 
        when UP_LEFT 
          @characters[i].move_upper_left 
        when UP_RIGHT 
          @characters[i].move_upper_right 
        when JUMP 
          @characters[i].jump(@move_list[i].args[0],@move_list[i].args[1]) 
        end 
      end
    end 
  end

  class Move_List_Element
    
    def initialize(type,args) 
      @type = type 
      @args = args 
    end
    
    def type() return @type end 
    
    def args() return @args end 
    
    end
    
    def move_list_setup 
      for i in 0 .. TRAIN_ACTOR_SIZE_MAX 
        @move_list[i] = nil 
      end
    end 
    
    def add_move_list(type,*args) 
      @move_list.unshift(Move_List_Element.new(type,args)).pop 
    end
    
    def move_down_party_actors(turn_enabled = true) 
      move_party_actors 
      add_move_list(Input::DOWN,turn_enabled) 
    end
    
    def move_left_party_actors(turn_enabled = true) 
      move_party_actors 
      add_move_list(Input::LEFT,turn_enabled) 
    end
    
    def move_right_party_actors(turn_enabled = true) 
      move_party_actors 
      add_move_list(Input::RIGHT,turn_enabled) 
    end
    
    def move_up_party_actors(turn_enabled = true) 
      move_party_actors 
      add_move_list(Input::UP,turn_enabled) 
    end
    
    def move_lower_left_party_actors 
      move_party_actors 
      add_move_list(DOWN_LEFT) 
    end
    
    def move_lower_right_party_actors 
      move_party_actors 
      add_move_list(DOWN_RIGHT) 
    end
    
    def move_upper_left_party_actors 
      move_party_actors 
      add_move_list(UP_LEFT) 
    end
    
    def move_upper_right_party_actors 
      move_party_actors 
      add_move_list(UP_RIGHT) 
    end
    
    def jump_party_actors(x_plus, y_plus) 
      move_party_actors 
      add_move_list(JUMP,x_plus, y_plus) 
    end
    
  end  

end 

class Game_Party 
  include Train_Actor::Game_Party_Module 
end 

# Game_Player_Module.rb 
#============================================================================== 
# â–  Game_Player_Module 
#------------------------------------------------------------------------------ 
# Caterpillar movement of actor is carried out on map 
#============================================================================== 

module Train_Actor 

module Game_Player_Module
  
  attr_reader :move_speed
  attr_reader :step_anime
  
  def update_party_actors 
    $game_party.update_party_actors 
    $game_party.actors.each do |actor| 
      @character_name = actor.character_name 
      @character_hue = actor.character_hue 
      break 
    end 
  end
   
  def update 
    update_party_actors 
    super 
  end
  
  def moveto( x, y ) 
    $game_party.moveto_party_actors( x, y ) 
    super( x, y ) 
  end
  
  def move_down(turn_enabled = true) 
    if passable?(@x, @y, Input::DOWN) 
      $game_party.move_down_party_actors(turn_enabled) 
    end 
    super(turn_enabled) 
  end
  
  def move_left(turn_enabled = true) 
    if passable?(@x, @y, Input::LEFT) 
      $game_party.move_left_party_actors(turn_enabled) 
    end 
    super(turn_enabled) 
  end
  
  def move_right(turn_enabled = true) 
    if passable?(@x, @y, Input::RIGHT) 
      $game_party.move_right_party_actors(turn_enabled) 
    end 
    super(turn_enabled) 
  end
  
  def move_up(turn_enabled = true) 
    if passable?(@x, @y, Input::UP) 
      $game_party.move_up_party_actors(turn_enabled) 
    end 
    super(turn_enabled) 
  end
  
  def move_lower_left 
    # When possible to move from down→left or from left→down 
    if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or 
       (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN)) 
      $game_party.move_lower_left_party_actors 
    end 
    super 
  end
  
  def move_lower_right 
    # When possible to move from down→right or from right→down 
    if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or 
       (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN)) 
      $game_party.move_lower_right_party_actors 
    end 
    super 
  end
  
  def move_upper_left 
    # When possible to move from up→left or from left→up 
    if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or 
       (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP)) 
      $game_party.move_upper_left_party_actors 
    end 
    super 
  end
  
  def move_upper_right 
    # When possible to move from up→right or from right→up 
    if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or 
       (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP)) 
      $game_party.move_upper_right_party_actors 
    end 
    super 
  end
  
  def jump(x_plus, y_plus) 
    # New coordinates are calculated 
    new_x = @x + x_plus 
    new_y = @y + y_plus 
    # When addition values are (0,0), it is possible to jump to the destination 
    if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0) 
      $game_party.jump_party_actors(x_plus, y_plus) 
    end 
    super(x_plus, y_plus) 
  end
  
end  

end 

class Game_Player 
 include Train_Actor::Game_Player_Module 
end 

# Game_Event_Module.rb 
#============================================================================== 
# â–  Game_Event_Module 
#------------------------------------------------------------------------------ 
# Caterpillar movement of actor is carried out on map 
#============================================================================== 

module Train_Actor 

module Game_Event_Module 
  #-------------------------------------------------------------------------- 
  # ● Judgement determined 
  #     x  : X coordinates 
  #     y  : Y coordinates 
  #     d  : Direction (0,2,4,6,8)  ※ 0 = Checks if all directions are not able to be passed (for a jump) 
  # return : Passing is impossible (false), possible (true) 
  #-------------------------------------------------------------------------- 
  def passable?(x, y, d)
    result = super(x, y, d) 
    if result 
      # New coordinates are searched for 
      new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0) 
      new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0) 
      # Loops for actor in train 
      for actor in $game_party.characters 
        # When displayed 
        if not actor.character_name.empty? 
          # When actor's coordinates correspond to the destination 
          if actor.x == new_x and actor.y == new_y 
          # When event 
            return false if self != $game_player
          end 
        end 
      end 
    end 
    return result 
  end
  
end 

end 

class Game_Event 
  include Train_Actor::Game_Event_Module 
end 
  
# Game_Party_Actor.rb 
#============================================================================== 
# â–  Game_Party_Actor 
#------------------------------------------------------------------------------ 
# Caterpillar movement of actor is carried out on map 
#============================================================================== 

module Train_Actor 

class Game_Party_Actor < Game_Character
  
  attr_reader :cp_id
  attr_writer :move_speed 
  attr_writer :step_anime 

  def initialize 
    super() 
    @through = true 
  end
  
  def setup(actor) 
    # The file name and hue of the character are set 
    @cp_id = $data_actors[actor.id].id
    if actor != nil
      @character_name = actor.character_name 
      @character_hue = actor.character_hue
    # Opacity and blending method are initialized 
    @opacity = 255 
    @blend_type = 0
      
      
# YBM edited this to show character dead graphic


          if actor.dead?
            case @cp_id
            when 1
              @opacity = 100
            when 2
              @character_name = '192-down04'
            when 3
              @character_name = '192-down04'
              @opacity = 150
            else
              @character_name = '192-down04'
             end
          end
# YBM


    else 
      @character_name = "" 
      @character_hue = 0
    # Opacity and blending method are initialized 
    @opacity = 255 
    @blend_type = 0
  end 
  
    # Opacity and blending method are initialized 
#YBM    @opacity = 255 
#YBM    @blend_type = 0 
  end
  
  def screen_z(height = 0) 
    if $game_player.x == @x and $game_player.y == @y 
      return $game_player.screen_z(height) - 1 
    end 
    super(height) 
  end 
  #-------------------------------------------------------------------------- 
  # ● Move down 
  #     turn_enabled : Flag that permits direction change on the spot 
  #-------------------------------------------------------------------------- 
  def move_down(turn_enabled = true) 
    # Face down 
    turn_down if turn_enabled
    # When possible to pass 
    if passable?(@x, @y, Input::DOWN) 
      # Face down 
      turn_down 
      # Update coordinates 
      @y += 1 
    end 
  end 
  #-------------------------------------------------------------------------- 
  # ● Move left 
  #     turn_enabled : Flag that permits direction change on the spot 
  #-------------------------------------------------------------------------- 
  def move_left(turn_enabled = true) 
    # Face left 
    turn_left if turn_enabled 
    # When possible to pass 
    if passable?(@x, @y, Input::LEFT) 
      # Face left 
      turn_left 
      # Update coordinates 
      @x -= 1 
    end 
  end 
  #-------------------------------------------------------------------------- 
  # ● Move right 
  #     turn_enabled : Flag that permits direction change on the spot 
  #-------------------------------------------------------------------------- 
  def move_right(turn_enabled = true) 
    # Face right 
    turn_right if turn_enabled
    # When possible to pass 
    if passable?(@x, @y, Input::RIGHT) 
      # Face right 
      turn_right 
      # Update coordinates 
      @x += 1 
    end 
  end 
  #-------------------------------------------------------------------------- 
  # ● Move up 
  #     turn_enabled : Flag that permits direction change on the spot 
  #-------------------------------------------------------------------------- 
  def move_up(turn_enabled = true) 
    # Face up 
    turn_up if turn_enabled
    # When possible to pass 
    if passable?(@x, @y, Input::UP) 
      # Face up 
      turn_up 
      # Update coordinates 
      @y -= 1 
    end 
  end 
  #-------------------------------------------------------------------------- 
  # ● Move lower left 
  #-------------------------------------------------------------------------- 
  def move_lower_left 
    # When no direction fixation 
    unless @direction_fix 
      # Turn left when facing right, turn down when facing up 
      @direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::UP ? Input::DOWN : @direction) 
    end 
    # When possible to move from down→left or from left→down 
    if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or 
       (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN)) 
      # Update coordinates 
      @x -= 1 
      @y += 1 
    end 
  end 
  #-------------------------------------------------------------------------- 
  # ● Move lower right 
  #-------------------------------------------------------------------------- 
  def move_lower_right 
    # When no direction fixation 
    unless @direction_fix 
      # Turn right when facing left, turn down when facing up 
      @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::UP ? Input::DOWN : @direction) 
    end 
    # When possible to move from down→right or from right→down 
    if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or 
       (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN)) 
      # Update coordinates 
      @x += 1 
      @y += 1 
    end 
  end 
  #-------------------------------------------------------------------------- 
  # ● move upper left 
  #-------------------------------------------------------------------------- 
  def move_upper_left 
    # When no direction fixation 
    unless @direction_fix 
      # Turn left when facing right, turn up when facing down 
      @direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::DOWN ? Input::UP : @direction) 
    end 
    # When possible to move from up→left or from left→up 
    if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or 
       (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP)) 
      # Update coordinates 
      @x -= 1 
      @y -= 1 
    end 
  end 
  #-------------------------------------------------------------------------- 
  # ● move upper right 
  #-------------------------------------------------------------------------- 
  def move_upper_right 
    # When no direction fixation 
    unless @direction_fix 
      # Turn right when facing left, turn up when facing down 
      @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::DOWN ? Input::UP : @direction) 
    end 
    # When possible to move from up→right or from right→up 
    if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or 
       (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP)) 
      # Update coordinates 
      @x += 1 
      @y -= 1 
    end 
  end
  
end

end



And it works except what I mentioned earlier, the swapping. Can you help me with the "If actor X is dead, show his dead graphic. If lead is dead, show next live member's image and swap the original member's image with lead's dead graphic." Basically what you did earlier except with the caterpillar system. Thanks.

Edit: Also How do I change the opacity and blend type in Seph's script? And is it possible to use this caterpillar system but keep Seph's Event following function?
 
I have added a method which rearrange the party depending on who's dead.

Here's an example of the method:
Actors 1,4,2 and 5 are in the party. Actors 1 and 2 got killed. The party will now look like this: 4,5,1,2.

Take a look at my topic in the submitted script section. You'll find the updated version there.
 
Thanks a lot! It works. Um, Dargor do you by any chance know how to edit a party reposition menu? I have a script which repositions characters. I think this might be a problem since your script is only meant to push characters down so that they do not take the lead. How do I disable that party changer slot when my character is dead?

Code:
class Scene_Menu
# --------------------------------
  def initialize(menu_index = 0)
    @menu_index = menu_index
    @changer = 0
    @where = 0
    @checker = 0
  end
# --------------------------------
  def main
    s1 = $data_system.words.item
    s2 = $data_system.words.skill
    s3 = $data_system.words.equip
    s4 = "Stats"
    s5 = "Save"
    s6 = "Exit"
    s7 = "Party"
    @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7])
    @command_window.index = @menu_index
    if $game_party.actors.size == 0
      @command_window.disable_item(0)
      @command_window.disable_item(1)
      @command_window.disable_item(2)
      @command_window.disable_item(3)
    end
    if $game_system.save_disabled
      @command_window.disable_item(4)
    end
    if $game_party.actors.size == 1
      @command_window.disable_item(6)
    end
    @playtime_window = Window_PlayTime.new
    @playtime_window.x = 0
    @playtime_window.y = 256
    @gold_window = Window_Gold.new
    @gold_window.x = 0
    @gold_window.y = 416
    @status_window = Window_MenuStatus.new
    @status_window.x = 160
    @status_window.y = 0
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @command_window.dispose
    @playtime_window.dispose
    @gold_window.dispose
    @status_window.dispose
  end
# --------------------------------
  def update
    @command_window.update
    @playtime_window.update
    @gold_window.update
    @status_window.update
    if @command_window.active
      update_command
      return
    end
    if @status_window.active
      update_status
      return
    end
  end
# --------------------------------
  def update_command
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
      return
    end
    if Input.trigger?(Input::C)
      if $game_party.actors.size == 0 and @command_window.index < 4
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      if $game_party.actors.size == 1 and @command_window.index ==6
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      case @command_window.index
      when 0
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Item.new
      when 1
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 2
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 3
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 4
        if $game_system.save_disabled
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Save.new
      when 5
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_End.new
      when 6
        $game_system.se_play($data_system.decision_se)
        @checker = 0
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      end
      return
    end
  end
# --------------------------------
  def update_status
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @command_window.active = true
      @status_window.active = false
      @status_window.index = -1
      return
    end
    if Input.trigger?(Input::C)
      case @command_window.index
      when 1
        if $game_party.actors[@status_window.index].restriction >= 2
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Skill.new(@status_window.index)
      when 2
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Equip.new(@status_window.index)
      when 3
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Status.new(@status_window.index)
      when 6
        $game_system.se_play($data_system.decision_se)
        if @checker == 0
          @changer = $game_party.actors[@status_window.index]
          @where = @status_window.index
          @checker = 1
        else
          $game_party.actors[@where] = $game_party.actors[@status_window.index]
          $game_party.actors[@status_window.index] = @changer
          @checker = 0
          @status_window.refresh
        end
      end
      return
    end
  end
end

And I was wondering... do you know how to make that selected box? You know when you select the first party member, a dark selection box remains on the first member while you move your cursor to select the second member to switch places with. Thanks again.
 
That's easy. At the end of your script you have those lines.
Code:
  when 6
        $game_system.se_play($data_system.decision_se)
        if @checker == 0
          @changer = $game_party.actors[@status_window.index]
          @where = @status_window.index
          @checker = 1
        else
          $game_party.actors[@where] = $game_party.actors[@status_window.index]
          $game_party.actors[@status_window.index] = @changer
          @checker = 0
          @status_window.refresh
        end
...

Just replace it with this:
Code:
  when 6
        $game_system.se_play($data_system.decision_se)
        if @checker == 0
          unless $game_party.actors[@status_window.index].dead?
            @changer = $game_party.actors[@status_window.index]
            @where = @status_window.index
            @checker = 1
          else
            $game_system.se_play($data_system.buzzer_se)
            return
          end
        else
          unless $game_party.actors[@status_window.index].dead?
            $game_party.actors[@where] = $game_party.actors[@status_window.index]
            $game_party.actors[@status_window.index] = @changer
            @checker = 0
            @status_window.refresh
          else
            $game_system.se_play($data_system.buzzer_se)
            return
          end
        end

Let me a few minutes for the selection box
 
Thanks. I got it working. But also I want to know how to create the dark selected box over a selected character. Do you know how?

EDIT: Sorry, didn't see your "Let me a few minutes for the selection box".

You are really good at this scripting stuff.
 
Ok, here's your script. Replace your old one with this one.

Code:
class Window_MenuStatus
  def refresh(where=nil)
    self.contents.clear
    if where != nil
      y = where*116
      color = Color.new(65,65,65,200)
      self.contents.fill_rect(0,y,480,96,color)
    end
    @item_max = $game_party.actors.size
    for i in 0...$game_party.actors.size
      x = 64
      y = i * 116
      actor = $game_party.actors[i]
      draw_actor_graphic(actor, x - 40, y + 80)
      draw_actor_name(actor, x, y)
      draw_actor_class(actor, x + 144, y)
      draw_actor_level(actor, x, y + 32)
      draw_actor_state(actor, x + 90, y + 32)
      draw_actor_exp(actor, x, y + 64)
      draw_actor_hp(actor, x + 236, y + 32)
      draw_actor_sp(actor, x + 236, y + 64)
    end
  end
end

class Scene_Menu
# --------------------------------
  def initialize(menu_index = 0)
    @menu_index = menu_index
    @changer = 0
    @where = 0
    @checker = 0
  end
# --------------------------------
  def main
    s1 = $data_system.words.item
    s2 = $data_system.words.skill
    s3 = $data_system.words.equip
    s4 = "Stats"
    s5 = "Save"
    s6 = "Exit"
    s7 = "Party"
    @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7])
    @command_window.index = @menu_index
    if $game_party.actors.size == 0
      @command_window.disable_item(0)
      @command_window.disable_item(1)
      @command_window.disable_item(2)
      @command_window.disable_item(3)
    end
    if $game_system.save_disabled
      @command_window.disable_item(4)
    end
    if $game_party.actors.size == 1
      @command_window.disable_item(6)
    end
    @playtime_window = Window_PlayTime.new
    @playtime_window.x = 0
    @playtime_window.y = 256
    @gold_window = Window_Gold.new
    @gold_window.x = 0
    @gold_window.y = 416
    @status_window = Window_MenuStatus.new
    @status_window.x = 160
    @status_window.y = 0
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @command_window.dispose
    @playtime_window.dispose
    @gold_window.dispose
    @status_window.dispose
  end
# --------------------------------
  def update
    @command_window.update
    @playtime_window.update
    @gold_window.update
    @status_window.update
    if @command_window.active
      update_command
      return
    end
    if @status_window.active
      update_status
      return
    end
  end
# --------------------------------
  def update_command
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
      return
    end
    if Input.trigger?(Input::C)
      if $game_party.actors.size == 0 and @command_window.index < 4
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      if $game_party.actors.size == 1 and @command_window.index ==6
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      case @command_window.index
      when 0
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Item.new
      when 1
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 2
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 3
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 4
        if $game_system.save_disabled
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Save.new
      when 5
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_End.new
      when 6
        $game_system.se_play($data_system.decision_se)
        @checker = 0
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      end
      return
    end
  end
# --------------------------------
  def update_status
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @command_window.active = true
      @status_window.active = false
      @status_window.index = -1
      return
    end
    if Input.trigger?(Input::C)
      case @command_window.index
      when 1
        if $game_party.actors[@status_window.index].restriction >= 2
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Skill.new(@status_window.index)
      when 2
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Equip.new(@status_window.index)
      when 3
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Status.new(@status_window.index)
      when 6
        $game_system.se_play($data_system.decision_se)
        if @checker == 0
          unless $game_party.actors[@status_window.index].dead?
            @changer = $game_party.actors[@status_window.index]
            @where = @status_window.index
            @status_window.refresh(@where)
            @checker = 1
          else
            $game_system.se_play($data_system.buzzer_se)
            return
          end
        else
          unless $game_party.actors[@status_window.index].dead?
            $game_party.actors[@where] = $game_party.actors[@status_window.index]
            $game_party.actors[@status_window.index] = @changer
            @checker = 0
            @status_window.refresh
          else
            $game_system.se_play($data_system.buzzer_se)
            return
          end
        end
      end
      return
    end
  end
end

EDIT: Your script isn't well written. It isn't pleasant to read lol
If you want i can make it a look bit better.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top