[RESOLVED][RMXP] 8-Actor Party script interferes with Add-ons pack

Started by Fatih, January 11, 2019, 10:34:22 am

Previous topic - Next topic

Fatih

Hello there. New to this community though I've known about it for a long time, and recently I've been trying to do a sort of side project in RPGXP.
Basically, I've been trying to make use of this script found here. It allows a maximum of eight actors into your game. Though, the attachment is gone/corrupted and the creator of the script has been gone for years. Luckily, at the bottom, someone else seems to have reuploaded the script on pastebin. It seems to work on a fresh project, but on my actual project, I run head-on into an issue when going into battle.



One thing that I should note is that I have the Tons of Add-ons Pack, and I believe that the SP/HP bars in Part 1 might have to do with it because of how both scripts write to HP and SP display. I decided that I would take a look at the order of my scripts, and I decided to see what would happen if I moved the party script below the trio as I had it above earlier. It seems to override the bars, and testing reveals that the battle works, except that there's an issue with disposals from the death image addon (during the end of battle in any way), so I can tell this is going to take quite a bit of work.

I want to firstly find out if I can retain the bars in the Add-on collection while having the effects of the new script underway. I have been tinkering the past while trying to find out if I can do this myself but it's easier said than done with my limited Ruby knowledge.
I know for sure is that the 8 Party script defines draw_actor_hp/sp again and also re-applies the default states and even adds some ugly shadow to the text, so if I can find a way to disable whatever causes those to come about again then I'll be set. But I've been trying to go at it with no success and lots of syntax errors so I've been wondering if anyone here who is more versed in Ruby could assist me with this.
It's partially a request to have the script work with the add-ons without rewriting anything, but is it possible at this point? Am I better off requesting the same sort of script in Requests?
Thanks in advance.

KK20

First off, the formatting of that script is god awful. Even though that last poster said they "fixed" it, I can't imagine what the script possibly looked like originally. I've cleaned it up: https://pastebin.com/raw/QncGr1QG

So the problem is as you said due to overloading the parameters. The reason for the parameters is because of the shadow text, which is something you don't even want. That makes things easy.

Keep the 8 actor script above Tons. Locate within it for the Window_BattleStatus class and replace the refresh method with this one

  def refresh
    self.contents.clear
    @item_max = $game_party.actors.size
    if @item_max > 7
      self.contents.font.size = 16
      self.contents.font.bold = true
    elsif @item_max > 6
      self.contents.font.size = 18
      self.contents.font.bold = true
    elsif @item_max > 4
      self.contents.font.size = 20
      self.contents.font.bold = true
    else
      self.contents.font.size = 22
    end
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      if @item_max > 6
        actor_x = i * 610 / @item_max + 0
        text_x = 75
      elsif @item_max > 4
        actor_x = i * 612 / @item_max + 4
        text_x = 95
      else
        actor_x = i * 160 + 4
        text_x = 120
      end
      draw_actor_name(actor, actor_x, 0)
      draw_actor_hp(actor, actor_x, 32, text_x)
      draw_actor_sp(actor, actor_x, 64, text_x)
      if @level_up_flags[i]
        self.contents.font.color = normal_color
        self.contents.draw_text(actor_x, 96, 120, 32, "LEVEL UP!")
      else
        draw_actor_state(actor, actor_x, 96)
      end
    end
  end

I did not test it.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

Fatih

It works! Thank you very much!

The final script comes out as

Spoiler: ShowHide
#==============================================================================
# ** 8_Hero_Party - by cockroach
#------------------------------------------------------------------------------
#  This script is meant to permit 8 heroes in the party.
#  The heroes will appear in every instance of the game and show up properly,
#  but in many cases it may look crowded. (Specially in the default Battle System)
#  This is why this goes best with another type of battle system.
#  If anyone wants to use even more than 8 heroes, all necessary changes are in
#  this script, and it is a very easy thing to alter.
#
#  All you need to do is adding heroes to the party normally, no custom script
#  call is necessary.
#
#  (This very simple script is free for usage and edition, in any type of game.)
#==============================================================================
#==============================================================================
# Alterations in Game_Actor
#==============================================================================
class Game_Actor
  def screen_x
    return 0 if self.index.nil?
    # Return after calculating x-coordinate by order of members in party
    p_size = [$game_party.actors.size, 4].max
    self.index * (640 / p_size) + (320 / p_size) 
  end
end
#==============================================================================
# Alterations in Game_Party
#==============================================================================
class Game_Party 
  #-------------------------------------------------------------------------- 
  # * Add an Actor 
  # actor_id : actor ID 
  #--------------------------------------------------------------------------
  def add_actor(actor_id)
    # Get actor
    actor = $game_actors[actor_id]
    # If the party has less than 8 members and this actor is not in the party
    if @actors.size < 8 && !@actors.include?(actor)
      # Add actor
      @actors.push(actor)
      # Refresh player
      $game_player.refresh
    end
  end
  #-------------------------------------------------------------------------- 
  # * Random Selection of Target Actor 
  # hp0 : limited to actors with 0 HP 
  #--------------------------------------------------------------------------
  def random_target_actor(hp0 = false)
    # Initialize roulette
    roulette = []
    # Loop
    for actor in @actors
      # If it fits the conditions
      if (!hp0 && actor.exist?) || (hp0 && actor.hp0?)
        # Get actor class [position]
        position = $data_classes[actor.class_id].position / 2
        # Front guard: n = 4; Mid guard: n = 3; Rear guard: n = 2
        n = 4 - position
        n = 1 if n == 0
        # Add actor to roulette n times
        n.times { roulette.push(actor) }
      end
    end
    # If roulette size is 0
    return nil if roulette.size == 0
    # Spin the roulette, choose an actor
    roulette[rand(roulette.size)] 
  end
end
#==============================================================================
# Alterations in Window_MenuStatus
#==============================================================================
class Window_MenuStatus < Window_Selectable 
  #-------------------------------------------------------------------------- 
  # * Refresh 
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    @item_max = $game_party.actors.size
    for i in 0...$game_party.actors.size
      x = 64
      if @item_max > 5
        y = i * (455 / @item_max)
      else
        y = i * 76.5
      end
      actor = $game_party.actors[i]
      draw_actor_graphic(actor, x - 40, y + 47)
      draw_actor_name(actor, x, y - 9)
      draw_actor_class(actor, x + 144, y - 9)
      draw_actor_level(actor, x, y + 7)
      draw_actor_state(actor, x + 90, y + 7)
      draw_actor_exp(actor, x, y + 23)
      draw_actor_hp(actor, x + 236, y + 7)
      draw_actor_sp(actor, x + 236, y + 23)
    end 
  end 
  #-------------------------------------------------------------------------- 
  # * Cursor Rectangle Update 
  #--------------------------------------------------------------------------
  def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
    else
      if @item_max > 5
        y = @index * (455 / @item_max) - 3
      else
        y = @index * 76.5 - 3
      end
      self.cursor_rect.set(0, y, self.width - 32, 52)
    end 
  end
end
#==============================================================================
# Alterations in Window_Target
#==============================================================================
class Window_Target < Window_Selectable 
  #-------------------------------------------------------------------------- 
  # * Refresh 
  #-------------------------------------------------------------------------- 
  def refresh
    self.contents.clear
    for i in 0...$game_party.actors.size
      x = 4
      y = i * 55
      actor = $game_party.actors[i]
      draw_actor_name(actor, x, y)
      draw_actor_class(actor, x + 144, y)
      draw_actor_level(actor, x + 8, y + 16)
      draw_actor_state(actor, x + 8, y + 32)
      draw_actor_hp(actor, x + 152, y + 16)
      draw_actor_sp(actor, x + 152, y + 32)
    end
  end 
  #-------------------------------------------------------------------------- 
  # * Cursor Rectangle Update 
  #-------------------------------------------------------------------------- 
  def update_cursor_rect
    # Cursor position -1 = all choices, -2 or lower = independent choice
    # (meaning the user's own choice)
    if @index <= -2
      self.cursor_rect.set(0, (@index + 10) * 55 + 6, self.width - 32, 48)
    elsif @index == -1
      self.cursor_rect.set(0, 0, self.width - 32 + 6, @item_max * 58 - 20)
    else
      self.cursor_rect.set(0, @index * 55 + 6, self.width - 32, 52)
    end 
  end
end
#==============================================================================
# Alterations in Window_SaveFile
#==============================================================================
class Window_SaveFile < Window_Base 
  #-------------------------------------------------------------------------- 
  # * Refresh 
  #-------------------------------------------------------------------------- 
  def refresh
    self.contents.clear
    # Draw file number
    self.contents.font.color = normal_color
    name = "File#{@file_index + 1}"
    self.contents.draw_text(4, 0, 600, 32, name)
    @name_width = contents.text_size(name).width
    # If save file exists
    if @file_exist
      # Draw character
      for i in 0...@characters.size
        bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1])
        cw = bitmap.rect.width / 4
        ch = bitmap.rect.height / 4
        src_rect = Rect.new(0, 0, cw, ch)
        x = 275 - @characters.size * 24 + i * 48 - cw / 2
        self.contents.blt(x, 68 - ch, bitmap, src_rect)
      end
      # Draw play time
      hour = @total_sec / 60 / 60
      min = @total_sec / 60 % 60
      sec = @total_sec % 60
      time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
      self.contents.font.color = normal_color
      self.contents.draw_text(4, 8, 600, 32, time_string, 2)
      # Draw timestamp
      self.contents.font.color = normal_color
      time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
      self.contents.draw_text(4, 40, 600, 32, time_string, 2)
    end
  end
end
#==============================================================================
# Alterations in Window_ShopStatus
#==============================================================================
class Window_ShopStatus < Window_Base 
  #-------------------------------------------------------------------------- 
  # * Refresh 
  #-------------------------------------------------------------------------- 
  def refresh
    self.contents.clear
    return if @item.nil?
    number = case @item
      when RPG::Item then $game_party.item_number(@item.id)
      when RPG::Weapon then $game_party.weapon_number(@item.id)
      when RPG::Armor then $game_party.armor_number(@item.id)
    end
    self.contents.font.color = system_color
    self.contents.draw_text(4, 0, 200, 24, "number in possession")
    self.contents.font.color = normal_color
    self.contents.draw_text(204, 0, 32, 24, number.to_s, 2)
    return if @item.is_a?(RPG::Item)
    # Equipment adding information
    for i in 0...$game_party.actors.size
      # Get actor
      actor = $game_party.actors[i]
      p_size = $game_party.actors.size
      # If equippable, then set to normal text color. If not, set to
      # invalid text color.
      if actor.equippable?(@item)
        self.contents.font.color = normal_color
      else
        self.contents.font.color = disabled_color
      end
      # Draw actor's name
      if p_size > 5
        y1 = i * (288 / p_size)
      else
        y1 = i * 48
      end
      self.contents.draw_text(4, 24 + y1, 120, 24, actor.name)
      # Get current equipment
      if @item.is_a?(RPG::Weapon)
        item1 = $data_weapons[actor.weapon_id]
      elsif @item.kind == 0
        item1 = $data_armors[actor.armor1_id]
      elsif @item.kind == 1
        item1 = $data_armors[actor.armor2_id]
      elsif @item.kind == 2
        item1 = $data_armors[actor.armor3_id]
      else
        item1 = $data_armors[actor.armor4_id]
      end
      # If equippable
      if actor.equippable?(@item)
        # If weapon
        if @item.is_a?(RPG::Weapon)
          atk1 = item1 != nil ? item1.atk : 0
          atk2 = @item != nil ? @item.atk : 0
          change = atk2 - atk1
        end
        # If armor
        if @item.is_a?(RPG::Armor)
          pdef1 = item1 != nil ? item1.pdef : 0
          mdef1 = item1 != nil ? item1.mdef : 0
          pdef2 = @item != nil ? @item.pdef : 0
          mdef2 = @item != nil ? @item.mdef : 0
          change = pdef2 - pdef1 + mdef2 - mdef1
        end
        # Draw parameter change values
        self.contents.draw_text(124, 24 + y1, 112, 24, sprintf("%+d", change), 2)
      end
      # Draw item
      if item1.nil?
        x = 4
        y = 8 + y1 + 32
        bitmap = RPG::Cache.icon(item1.icon_name)
        opacity = self.contents.font.color == normal_color ? 255 : 128
        self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
        self.contents.draw_text(x + 28, y, 212, 24, item1.name)
      end
    end
  end
end
class Spriteset_Battle 
  #-------------------------------------------------------------------------- 
  # * Object Initialization 
  #-------------------------------------------------------------------------- 
  def initialize
    # Make viewports
    @viewport1 = Viewport.new(0, 0, 640, 320)
    @viewport2 = Viewport.new(0, 0, 640, 480)
    @viewport3 = Viewport.new(0, 0, 640, 480)
    @viewport4 = Viewport.new(0, 0, 640, 480)
    @viewport2.z = 101
    @viewport3.z = 200
    @viewport4.z = 5000
    # Make battleback sprite
    @battleback_sprite = Sprite.new(@viewport1)
    # Make enemy sprites
    @enemy_sprites = []
    for enemy in $game_troop.enemies.reverse
      @enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
    end
    # Make actor sprites
    @actor_sprites = []
    8.times { @actor_sprites.push(Sprite_Battler.new(@viewport2)) }
    # Make weather
    @weather = RPG::Weather.new(@viewport1)
    # Make picture sprites
    @picture_sprites = []
    for i in 51..100
      @picture_sprites.push(Sprite_Picture.new(@viewport3, $game_screen.pictures[i]))
    end
    # Make timer sprite
    @timer_sprite = Sprite_Timer.new
    # Frame update
    update
  end

  def update
    # Update actor sprite contents (corresponds with actor switching)
    8.times do |i|
      @actor_sprites[i].battler = $game_party.actors[i]
    end
    # If battleback file name is different from current one
    if @battleback_name != $game_temp.battleback_name
      @battleback_name = $game_temp.battleback_name
      @battleback_sprite.bitmap.dispose unless @battleback_sprite.bitmap.nil?
      @battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
      @battleback_sprite.src_rect.set(0, 0, 640, 320)
    end
    # Update battler sprites
    for sprite in @enemy_sprites + @actor_sprites
      sprite.update
    end
    # Update weather graphic
    @weather.type = $game_screen.weather_type
    @weather.max = $game_screen.weather_max
    @weather.update
    # Update picture sprites
    for sprite in @picture_sprites
      sprite.update
    end
    # Update timer sprite
    @timer_sprite.update
    # Set screen color tone and shake position
    @viewport1.tone = $game_screen.tone
    @viewport1.ox = $game_screen.shake
    # Set screen flash color
    @viewport4.color = $game_screen.flash_color
    # Update viewports
    @viewport1.update
    @viewport2.update
    @viewport4.update
  end
end
#==============================================================================
# ** Window_BattleStatus
#------------------------------------------------------------------------------
#  This window displays the status of all party members on the battle screen.
#==============================================================================
class Window_Base < Window
  def shadow_color
    Color.new(0, 0, 0)
  end 
  #-------------------------------------------------------------------------- 
  # * Draw Name 
  #actor : actor 
  #x: draw spot x-coordinate 
  #y: draw spot y-coordinate 
  #-------------------------------------------------------------------------- 
  def draw_actor_name(actor, x, y, shadow = false)
    self.contents.font.color = shadow ? shadow_color : normal_color
    self.contents.draw_text(x, y, 120, 32, actor.name)
  end 
  #-------------------------------------------------------------------------- 
  # * Draw State 
  #actor : actor 
  #x: draw spot x-coordinate 
  #y: draw spot y-coordinate 
  #width : draw spot width 
  #-------------------------------------------------------------------------- 
  def draw_actor_state(actor, x, y, width = 120, shadow = false)
    text = make_battler_state_text(actor, width, true)
    self.contents.font.color = shadow ? shadow_color : (actor.hp == 0 ? knockout_color : normal_color)
    self.contents.draw_text(x, y, width, 32, text)
  end 
  #-------------------------------------------------------------------------- 
  # * Draw HP 
  #actor : actor 
  #x: draw spot x-coordinate 
  # y : draw spot y-coordinate 
  # width : draw spot width 
  #-------------------------------------------------------------------------- 
  def draw_actor_hp(actor, x, y, width = 144, height = 32, shadow = false)
    # Draw "HP" text string
    self.contents.font.color = shadow ? shadow_color : system_color
    self.contents.draw_text(x, y, 32, height, $data_system.words.hp)
    # Calculate if there is draw space for MaxHP
    if width - 32 >= 108
      hp_x = x + width - 108
      flag = true
    elsif width - 32 >= 28
      hp_x = x + width - 48
      flag = false
    end
    # Draw HP
    self.contents.font.color = shadow ? shadow_color : (actor.hp == 0 ? knockout_color : (actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color))
    self.contents.draw_text(hp_x, y, 48, height, actor.hp.to_s, 2)
    # Draw MaxHP
    if flag
      self.contents.font.color = shadow ? shadow_color : normal_color
      self.contents.draw_text(hp_x + 48, y, 12, height, "/", 1)
      self.contents.draw_text(hp_x + 60, y, 48, height, actor.maxhp.to_s)
    end
  end 
  #-------------------------------------------------------------------------- 
  # * Draw SP 
  # actor : actor 
  # x : draw spot x-coordinate 
  # y : draw spot y-coordinate 
  # width : draw spot width 
  #-------------------------------------------------------------------------- 
  def draw_actor_sp(actor, x, y, width = 144, height = 32, shadow = false)
    # Draw "SP" text string
    self.contents.font.color = shadow ? shadow_color : system_color
    self.contents.draw_text(x, y, 32, height, $data_system.words.sp)
    # Calculate if there is draw space for MaxHP
    if width - 32 >= 108
      sp_x = x + width - 108
      flag = true
    elsif width - 32 >= 28
      sp_x = x + width - 48
      flag = false
    end
    # Draw SP
    self.contents.font.color = shadow ? shadow_color : (actor.sp == 0 ? knockout_color : (actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color))
    self.contents.draw_text(sp_x, y, 48, height, actor.sp.to_s, 2)
    # Draw MaxSP
    if flag
      self.contents.font.color = shadow ? shadow_color : normal_color
      self.contents.draw_text(sp_x + 48, y, 12, height, "/", 1)
      self.contents.draw_text(sp_x + 60, y, 48, height, actor.maxsp.to_s)
    end 
  end
end

class Window_BattleStatus < Window_Base 
  #-------------------------------------------------------------------------- 
  # * Refresh 
  #-------------------------------------------------------------------------- 
  def refresh
    self.contents.clear
    @item_max = $game_party.actors.size
    if @item_max > 7
      self.contents.font.size = 16
      self.contents.font.bold = true
    elsif @item_max > 6
      self.contents.font.size = 18
      self.contents.font.bold = true
    elsif @item_max > 4
      self.contents.font.size = 20
      self.contents.font.bold = true
    else
      self.contents.font.size = 22
    end
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      if @item_max > 6
        actor_x = i * 610 / @item_max + 0
        text_x = 75
      elsif @item_max > 4
        actor_x = i * 612 / @item_max + 4
        text_x = 95
      else
        actor_x = i * 160 + 4
        text_x = 120
      end
      draw_actor_name(actor, actor_x, 0)
      draw_actor_hp(actor, actor_x, 32, text_x)
      draw_actor_sp(actor, actor_x, 64, text_x)
      if @level_up_flags[i]
        self.contents.font.color = normal_color
        self.contents.draw_text(actor_x, 96, 120, 32, "LEVEL UP!")
      else
        draw_actor_state(actor, actor_x, 96)
      end
    end
  end
end

class Scene_Battle
  def phase3_setup_command_window
    # Disable party command window
    @party_command_window.active = false
    @party_command_window.visible = false
    # Enable actor command window
    @actor_command_window.active = true
    @actor_command_window.visible = true
    p_size = $game_party.actors.size - 1
    step_x = 480 / p_size
    step = 160 if step_x > 160
    window_x = @actor_index * step_x
    if @actor_index == $game_party.actors.size - 1
      window_x = 480
    end
    # Set actor command window position
    @actor_command_window.x = window_x
    # Set index to 0
    @actor_command_window.index = 0 
  end
end


for any future lurkers, and it becomes compatible. There's bold text on the battle UI for stats and all, but I actually prefer that. Thanks again!