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.

Party Changer

I think I'm going about this the worng way. I'm making a Party Switcher to match the interface of pokemon. I've got the interface down but when I switch Party Member #1 with #2 it works, But when you try to switch it back its horrible. It's even worse if you have more than 2 party members. So what I need help on is the Switching part. I tried to make my variables good for you guys helping.

It WAS designed for FOUR PARTY MEMBERS.

If you find any errors I can post any scripts that might fix them(Like Fomar's Creature Scripts.)

If you need more information, just post saying you do...

I really... want?... no... umm... I REALLY DESIRE THIS.

Code:
class Scene_Pokemon
  attr_accessor :pokemon_window
  def main
    @pokemon_window = Window_Pokemonswitching.new
    s1 = "Switch"
    s2 = "Abilities"
    s3 = "Stats"
    @command_window = Window_Command.new(192, [s1, s2, s3])
    @command_window.opacity = 255
    @command_window.active = false
    @command_window.visible = false
    @command_window.x = 130 + (4 + @pokemon_window.index % 2 * (320 + 0))
    @command_window.y = (@pokemon_window.index / 2 * 160)
    @creature = Hash.new("")
    if $game_party.actors[0] != nil
      index = 0
      @creature[index] = (Window_Creature.new($game_party.actors[index]))
      @creature[index].x = (4 + index % 2 * (305 + 0))# - 5
      @creature[index].y = (index / 2 * 160)
    end
    if $game_party.actors[1] != nil
      index = 1
      @creature[index] = (Window_Creature.new($game_party.actors[index]))
      @creature[index].x = (4 + index % 2 * (305 + 0))# - 5
      @creature[index].y = (index / 2 * 160)
    end
    if $game_party.actors[2] != nil
      index = 2
      @creature[index] = (Window_Creature.new($game_party.actors[index]))
      @creature[index].x = (4 + index % 2 * (305 + 0))# - 5
      @creature[index].y = (index / 2 * 160)
    end
    if $game_party.actors[3] != nil
      index = 3
      @creature[index] = (Window_Creature.new($game_party.actors[index]))
      @creature[index].x = (4 + index % 2 * (305 + 0))# - 5
      @creature[index].y = (index / 2 * 160)
    end
    @stats_window = []
    for i in 0..$game_party.actors.size - 1
      @stats_window.push(Window_Status.new($game_party.actors[i]))
      @stats_window[i].visible = false
      @stats_window[i].z = 9011
    end
    # Transition run
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    if $game_party.actors[0] != nil
      @creature[0].dispose
    end
    if $game_party.actors[1] != nil
      @creature[1].dispose
    end
    if $game_party.actors[2] != nil
      @creature[2].dispose
    end
    if $game_party.actors[3] != nil
      @creature[3].dispose
    end
    for i in 0..$game_party.actors.size - 1
      @stats_window[i].dispose
    end
    @command_window.dispose
    @pokemon_window.dispose
  end
  def update
    @command_window.update
    @pokemon_window.update
    if $game_party.actors[0] != nil
      @creature[0].update
      @creature[0].refresh
    end
    if $game_party.actors[1] != nil
      @creature[1].update
      @creature[1].refresh
    end
    if $game_party.actors[2] != nil
      @creature[2].update
      @creature[2].refresh
    end
    if $game_party.actors[3] != nil
      @creature[3].update
      @creature[3].refresh
    end
    for i in 0..$game_party.actors.size - 1
      @stats_window[i].update
    end
    creature_refresh
    for i in 0..$game_party.actors.size - 1
      if @pokemon_window.active and @beforepokemon == nil
        update_pokemon
      elsif @pokemon_window.active and  @beforepokemon != nil
        update_pokeswitch
      elsif @command_window.active
        update_activity
      elsif @stats_window[i].visible
        update_stat
      end
    end
  end
  def creature_refresh
    if $game_party.actors[0] != nil
      @creature[0].dispose
    end
    if $game_party.actors[1] != nil
      @creature[1].dispose
    end
    if $game_party.actors[2] != nil
      @creature[2].dispose
    end
    if $game_party.actors[3] != nil
      @creature[3].dispose
    end
    if $game_party.actors[0] != nil
      index = 0
      @creature[index] = (Window_Creature.new($game_party.actors[index]))
      @creature[index].x = (4 + index % 2 * (305 + 0))# - 5
      @creature[index].y = (index / 2 * 160)
    end
    if $game_party.actors[1] != nil
      index = 1
      @creature[index] = (Window_Creature.new($game_party.actors[index]))
      @creature[index].x = (4 + index % 2 * (305 + 0))# - 5
      @creature[index].y = (index / 2 * 160)
    end
    if $game_party.actors[2] != nil
      index = 2
      @creature[index] = (Window_Creature.new($game_party.actors[index]))
      @creature[index].x = (4 + index % 2 * (305 + 0))# - 5
      @creature[index].y = (index / 2 * 160)
    end
    if $game_party.actors[3] != nil
      index = 3
      @creature[index] = (Window_Creature.new($game_party.actors[index]))
      @creature[index].x = (4 + index % 2 * (305 + 0))# - 5
      @creature[index].y = (index / 2 * 160)
    end
  end
  def update_pokemon
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
      return
    end
    if Input.trigger?(Input::C)
      @command_window.x = 130 + (4 + @pokemon_window.index % 2 * (320 + 0))
      @command_window.y = (@pokemon_window.index / 2 * 160)
      @actor = $game_actors[@pokemon_window.index + 1]
      @command_window.visible = true
      @command_window.active = true
      #@pokemon_window.visible = false
      @pokemon_window.active = false
      return
    end
  end
  def update_activity
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @pokemon_window.active = true
      @command_window.visible = false
      @command_window.active = false
      #@pokemon_window.visible = false
      return
    end
    if Input.trigger?(Input::C)
      case @command_window.index
      when 0
        @beforepokemon = @pokemon_window.index
        if $game_party.actors[@beforepokemon] != nil
          $game_system.se_play($data_system.decision_se)
          @pokemon_window.active = true
          @command_window.visible = false
          @command_window.active = false
          #@pokemon_window.visible = false
          #update_pokeswitch
        else
          $game_system.se_play($data_system.buzzer_se)
        end
      when 1
        if $pokeability == true
          @a = $data_armors[$game_party.actors[@pokemon_window.index].armor1_id]
          #if @a.guard_element_set.include?(1)
            $scene = Scene_Map.new
            $game_temp.common_event_id = @a.guard_element_set[0] + 1
            common_event = $data_common_events[$game_temp.common_event_id]
            $game_system.battle_interpreter.setup(common_event.list, 0)
            #return
          #end
        end
      when 2
        @beforepokemon = @pokemon_window.index
        $game_system.se_play($data_system.decision_se)
        @stats_window[@beforepokemon].visible = true
        @pokemon_window.active = false
        @command_window.visible = false
        @command_window.active = false
      end
      return
    end
  end
  def update_pokeswitch
    @afterpokemon = @pokemon_window.index
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @beforepokemon = nil
      @command_window.visible = true
      @command_window.active = true
      #@pokemon_window.visible = false
      @pokemon_window.active = false
      return
    end
    if Input.trigger?(Input::C)
      if $game_party.actors[@afterpokemon] != nil
        $game_system.se_play($data_system.decision_se)
        if $data_actors[@beforepokemon].id < $data_actors[@afterpokemon].id
          $game_party.actors[@afterpokemon] = $game_actors[@beforepokemon + 1]
          $game_party.actors[@beforepokemon] = $game_actors[@afterpokemon + 1]
        elsif $data_actors[@beforepokemon].id == $data_actors[@afterpokemon].id
          $game_party.actors[@beforepokemon] = $game_actors[@afterpokemon + 1]
          $game_party.actors[@afterpokemon] = $game_actors[@beforepokemon + 1]
        elsif $data_actors[@beforepokemon].id > $data_actors[@afterpokemon].id
          $game_party.actors[@beforepokemon] = $game_actors[@afterpokemon + 1]
          $game_party.actors[@afterpokemon] = $game_actors[@beforepokemon + 1]
        end
        $game_party.refresh
        @pokemon_window.refresh
        @beforepokemon = nil
        @command_window.visible = true
        @command_window.active = true
        #@pokemon_window.visible = false
        @pokemon_window.active = false
        @pokemon_window.active = true
        @command_window.visible = false
        @command_window.active = false
        #@pokemon_window.visible = false
        return
      else
        $game_system.se_play($data_system.buzzer_se)
      end
    end
  end
  def update_stat
    if Input.trigger?(Input::B)
      @beforepokemon = nil
      for i in 0..$game_party.actors.size - 1
        @stats_window[i].visible = false
      end
      $game_system.se_play($data_system.cancel_se)
      @command_window.visible = true
      @command_window.active = true
      #@pokemon_window.visible = false
      @pokemon_window.active = false
      @pokemon_window.active = true
      @command_window.visible = false
      @command_window.active = false
      return
    end
  end
end
class Window_Creature < Window_Base
  def initialize(actor)
    super(0, 0, 100, 100)
    @actor = actor
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 0
    self.back_opacity = 0
    self.z = 7011
    refresh
  end
  def refresh
    self.contents.clear
    draw_actor_graphic(@actor, 20, 50)
  end
end
class Window_Pokemonswitching < Window_Selectable
  attr_accessor :commands
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 640, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.back_opacity = 160
    #pokemon = draw_actor_name(0)
    @column_max = 2
    @row_max = 3
    #self.active = false
    #self.visible = false
    refresh
  end
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
      self.contents = Bitmap.new(width - 32, height - 32)
      self.back_opacity = 160
    end
    self.index = 0
    # If item count is not 0, make a bit map and draw all items
    @item_max = 4
    @po = $game_party.actors
    if @po[0] == nil
      @commands = ["-","-","-","-","-","-"]
    elsif @po[1] == nil
      @commands = [@po[0].name,"-","-","-","-","-"]
    elsif @po[2] == nil
      @commands = [@po[0].name,@po[1].name,"-","-","-","-"]
    elsif @po[3] == nil
      @commands = [@po[0].name,@po[1].name,@po[2].name,"-","-","-"]
    elsif @po[4] == nil
      @commands = [@po[0].name,@po[1].name,@po[2].name,@po[3].name,"-","-"]
    elsif @po[5] == nil
      @commands = [@po[0].name,@po[1].name,@po[2].name,@po[3].name,@po[4].name,"-"]
    else
      @commands = [@po[0].name,@po[1].name,@po[2].name,@po[3].name,@po[4].name,@po[5].name]
    end
    draw_item(0, normal_color)
    draw_item(1, normal_color)
    draw_item(2, normal_color)
    draw_item(3, normal_color)
    #draw_item(4, normal_color)
    #draw_item(5, normal_color)
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #     color : text character color
  #--------------------------------------------------------------------------
  def draw_item(index, color)
    #x = index
    self.contents.font.color = color
    rect = Rect.new((4 + index % 2 * (320 + 0)), (index / 2 * 160), 128 - 10, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[index], 1)
  end
  #--------------------------------------------------------------------------
  # * Cursor Rectangle Update
  #--------------------------------------------------------------------------
  def update_cursor_rect
    x = index
    self.cursor_rect.set((4 + index % 2 * (320 + 0)), (index / 2 * 160), 128, 32)
  end
end
 

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