Jump to content
WCouillard

Trying to smash a bug in one of my old scripts...

Recommended Posts

OK, so I made a script a long time ago, to only show the members of your battle party in the menu. By default, RPG Maker VX Ace shows every single member of your party in the menu, and simply grays out the ones who are not in the battle party. The issue here is that players can still use those characters' abilities, etc. while they aren't in the party, which is sort of stupid. So, the script I wrote was to limit that, only give the player access to the members of their party who were active in battle, and generally work more like a traditional JRPG. Clearly, an external party swap system was necessary when using this script. YEA Party System is the one I (and I'm sure many others) am using.

 

So here's the bug: when you use the Abilities/Equip/Status command in the menu, and select a party member, then change your party to remove that member, the cursor will still try to select the party member you removed, even if they aren't in the battle party. Confirming on this empty space leads to a game crash. So, pretty serious bug.

 

Here is the script, if anyone can tell me what to add to prevent this issue from occurring (ideally, choosing Abilities/Equip/Status from the main menu would always reset to selecting the first actor in the party), I'd be eternally grateful. Not being able to figure out this issue is actually holding up an imminent release of my project, lol.

 

# ╔══════════════════════════════════════════════════════╤═══════╤════════════╗
# ║ Menu Battle Members Restriction                      │ v1.01 │ (03/11/15) ║
# ╠══════════════════════════════════════════════════════╧═══════╧════════════╣
# ║ Author  : William Couillard                                               ║
# ║ Thanks  : Traverse                                                        ║
# ║ E-Mail  : cooliebk18@yahoo.com                                            ║
# ║ Website : ???                                                             ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ ABOUT                                                                     ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ This script forces the default menus to only allow the player access to   ║
# ║ party members who are in the current battle party. By default, all party  ║
# ║ members are accessible, so even party members who aren't in battle can    ║
# ║ use their skills or change their equipment. This script is intended to be ║
# ║ used alongside a Party Change script, such as Yanfly's Party System.      ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ TERMS OF USE                                                              ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ ► Do not edit the script's header or comments.                            ║
# ║ ► Free to use in commercial projects as long as proper credit is given to ║
# ║   ALL the names in the above header.                                      ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ FEATURES                                                                  ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ ► Restricts default menus to only allow access to party members who are   ║
# ║   in the active battle party. Custom menus for other scenes are not       ║
# ║   affected.                                                               ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ KNOWN ISSUES                                                              ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ ► None.                                                                   ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ CHANGE LOG                                                                ║
# ╠═════════════════════════════════════════════════════════════════╤═════════╣
# ║ ■ March 11, 2015    : Bugfixes.                                 │ (v1.01) ║
# ╟─────────────────────────────────────────────────────────────────┼─────────╢
# ║ ■ December 04, 2014 : Initial release.                          │ (v1.00) ║
# ╠═════════════════════════════════════════════════════════════════╧═════════╣
# ║ OVERWRITTEN METHODS                                                       ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║   This script overwrites a few methods in various default scripts.        ║
# ╟───────────────────────────────────────────────────────────────────────────╢
# ║ ■ class Game_Party < Game_Unit                                            ║
# ║    ► def menu_actor_next                                                  ║
# ║    ► def menu_actor_prev                                                  ║
# ╟───────────────────────────────────────────────────────────────────────────╢
# ║ ■ class Window_MenuStatus < Window_Selectable                             ║
# ║    ► def item_max                                                         ║
# ║    ► def draw_item                                                        ║
# ║    ► def process_ok                                                       ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ INSTRUCTIONS                                                              ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ Simply paste this script anywhere BELOW Window_MenuStatus. If you are     ║
# ║ using this script alongside Yanfly's Party System, place this script      ║
# ║ below it.                                                                 ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ IMPORT SETTING                                                            ║
# ╚═══════════════════════════════════════════════════════════════════════════╝
$imported = {} if $imported.nil?                    # Do not edit
$imported["WC-BattleMemberRestriction_1.01"] = true # Do not edit
# ╔═══════════════════════════════════════════════════════════════════════════╗
# ║ ** Game_Party                                                             ║
# ╟───────────────────────────────────────────────────────────────────────────╢
# ║  This class handles parties. Information such as gold and items is        ║
# ║ included. Instances of this class are referenced by $game_party.          ║
# ╚═══════════════════════════════════════════════════════════════════════════╝
class Game_Party < Game_Unit
# ╔═══════════════════════════════════════════════════════════════════════════╗
# ║ SELECT NEXT ACTOR ON MENU SCREEN                                          ║
# ╚═══════════════════════════════════════════════════════════════════════════╝
  def menu_actor_next
    index = battle_members.index(menu_actor) || -1
    index = (index + 1) % battle_members.size
    self.menu_actor = battle_members[index]
  end
# ╔═══════════════════════════════════════════════════════════════════════════╗
# ║ SELECT PREVIOUS ACTOR ON MENU SCREEN                                      ║
# ╚═══════════════════════════════════════════════════════════════════════════╝
  def menu_actor_prev
    index = battle_members.index(menu_actor) || 1
    index = (index + battle_members.size - 1) % battle_members.size
    self.menu_actor = battle_members[index]
  end
# ╔═══════════════════════════════════════════════════════════════════════════╗
# ║ ** End of Game_Party                                                      ║
# ╚═══════════════════════════════════════════════════════════════════════════╝
end
# ╔═══════════════════════════════════════════════════════════════════════════╗
# ║ ** Window_MenuStatus                                                      ║
# ╟───────────────────────────────────────────────────────────────────────────╢
# ║  This window displays party member status on the menu screen.             ║
# ╚═══════════════════════════════════════════════════════════════════════════╝
class Window_MenuStatus < Window_Selectable
# ╔═══════════════════════════════════════════════════════════════════════════╗
# ║ GET NUMBER OF ITEMS                                                       ║
# ╚═══════════════════════════════════════════════════════════════════════════╝
  def item_max
    $game_party.battle_members.size
  end
# ╔═══════════════════════════════════════════════════════════════════════════╗
# ║ DRAW ITEM                                                                 ║
# ╚═══════════════════════════════════════════════════════════════════════════╝
  def draw_item(index)
    actor = $game_party.battle_members[index]
    enabled = $game_party.battle_members.include?(actor)
    rect = item_rect(index)
    draw_item_background(index)
    draw_actor_face(actor, rect.x + 1, rect.y + 1, enabled)
    draw_actor_simple_status(actor, rect.x + 108, rect.y + line_height / 2)
  end
# ╔═══════════════════════════════════════════════════════════════════════════╗
# ║ PROCESSING WHEN OK BUTTON IS PRESSED                                      ║
# ╚═══════════════════════════════════════════════════════════════════════════╝
  def process_ok
    super
    $game_party.menu_actor = $game_party.battle_members[index]
  end
# ╔═══════════════════════════════════════════════════════════════════════════╗
# ║ ** End of Window_MenuStatus                                               ║
# ╚═══════════════════════════════════════════════════════════════════════════╝
end
# ╔═══════════════════════════════════════════════════════════════════════════╗
# ║ END OF SCRIPT                                                             ║
# ╚═══════════════════════════════════════════════════════════════════════════╝

 

Thanks for taking the time!

Share this post


Link to post
Share on other sites

With the fix, I think this is the correct layout:
 

Spoiler

# ╔══════════════════════════════════════════════════════╤═══════╤════════════╗
# ║ Menu Battle Members Restriction                      │ v1.01 │ (03/11/15) ║
# ╠══════════════════════════════════════════════════════╧═══════╧════════════╣
# ║ Author  : William Couillard                                               ║
# ║ Thanks  : Traverse                                                        ║
# ║ E-Mail  : cooliebk18@yahoo.com                                            ║
# ║ Website : ???                                                             ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ ABOUT                                                                     ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ This script forces the default menus to only allow the player access to   ║
# ║ party members who are in the current battle party. By default, all party  ║
# ║ members are accessible, so even party members who aren't in battle can    ║
# ║ use their skills or change their equipment. This script is intended to be ║
# ║ used alongside a Party Change script, such as Yanfly's Party System.      ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ TERMS OF USE                                                              ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ ► Do not edit the script's header or comments.                            ║
# ║ ► Free to use in commercial projects as long as proper credit is given to ║
# ║   ALL the names in the above header.                                      ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ FEATURES                                                                  ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ ► Restricts default menus to only allow access to party members who are   ║
# ║   in the active battle party. Custom menus for other scenes are not       ║
# ║   affected.                                                               ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ KNOWN ISSUES                                                              ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ ► None.                                                                   ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ CHANGE LOG                                                                ║
# ╠═════════════════════════════════════════════════════════════════╤═════════╣
# ║ ■ March 11, 2015    : Bugfixes.                                 │ (v1.01) ║
# ╟─────────────────────────────────────────────────────────────────┼─────────╢
# ║ ■ December 04, 2014 : Initial release.                          │ (v1.00) ║
# ╠═════════════════════════════════════════════════════════════════╧═════════╣
# ║ OVERWRITTEN METHODS                                                       ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║   This script overwrites a few methods in various default scripts.        ║
# ╟───────────────────────────────────────────────────────────────────────────╢
# ║ ■ class Game_Party < Game_Unit                                            ║
# ║    ► def menu_actor_next                                                  ║
# ║    ► def menu_actor_prev                                                  ║
# ╟───────────────────────────────────────────────────────────────────────────╢
# ║ ■ class Window_MenuStatus < Window_Selectable                             ║
# ║    ► def item_max                                                         ║
# ║    ► def draw_item                                                        ║
# ║    ► def process_ok                                                       ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ INSTRUCTIONS                                                              ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ Simply paste this script anywhere BELOW Window_MenuStatus. If you are     ║
# ║ using this script alongside Yanfly's Party System, place this script      ║
# ║ below it.                                                                 ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ IMPORT SETTING                                                            ║
# ╚═══════════════════════════════════════════════════════════════════════════╝
$imported = {} if $imported.nil?                    # Do not edit
$imported["WC-BattleMemberRestriction_1.01"] = true # Do not edit
# ╔═══════════════════════════════════════════════════════════════════════════╗
# ║ ** Game_Party                                                             ║
# ╟───────────────────────────────────────────────────────────────────────────╢
# ║  This class handles parties. Information such as gold and items is        ║
# ║ included. Instances of this class are referenced by $game_party.          ║
# ╚═══════════════════════════════════════════════════════════════════════════╝
class Game_Party < Game_Unit
# ╔═══════════════════════════════════════════════════════════════════════════╗
# ║ SELECT NEXT ACTOR ON MENU SCREEN                                          ║
# ╚═══════════════════════════════════════════════════════════════════════════╝
  def menu_actor_next
    index = battle_members.index(menu_actor) || -1
    index = (index + 1) % battle_members.size
    self.menu_actor = battle_members[index]
  end
# ╔═══════════════════════════════════════════════════════════════════════════╗
# ║ SELECT PREVIOUS ACTOR ON MENU SCREEN                                      ║
# ╚═══════════════════════════════════════════════════════════════════════════╝
  def menu_actor_prev
    index = battle_members.index(menu_actor) || 1
    index = (index + battle_members.size - 1) % battle_members.size
    self.menu_actor = battle_members[index]
  end
# ╔═══════════════════════════════════════════════════════════════════════════╗
# ║ ** End of Game_Party                                                      ║
# ╚═══════════════════════════════════════════════════════════════════════════╝
end
# ╔═══════════════════════════════════════════════════════════════════════════╗
# ║ ** Window_MenuStatus                                                      ║
# ╟───────────────────────────────────────────────────────────────────────────╢
# ║  This window displays party member status on the menu screen.             ║
# ╚═══════════════════════════════════════════════════════════════════════════╝
class Window_MenuStatus < Window_Selectable
# ╔═══════════════════════════════════════════════════════════════════════════╗
# ║ GET NUMBER OF ITEMS                                                       ║
# ╚═══════════════════════════════════════════════════════════════════════════╝
  def item_max
    $game_party.battle_members.size
  end
# ╔═══════════════════════════════════════════════════════════════════════════╗
# ║ DRAW ITEM                                                                 ║
# ╚═══════════════════════════════════════════════════════════════════════════╝
  def draw_item(index)
    actor = $game_party.battle_members[index]
    enabled = $game_party.battle_members.include?(actor)
    rect = item_rect(index)
  # draw_item_background(index)
    draw_actor_face(actor, rect.x + 1, rect.y + 1, enabled)
    draw_actor_simple_status(actor, rect.x + 108, rect.y + line_height / 2)
  end
# ╔═══════════════════════════════════════════════════════════════════════════╗
# ║ PROCESSING WHEN OK BUTTON IS PRESSED                                      ║
# ╚═══════════════════════════════════════════════════════════════════════════╝
  def process_ok
    super
    $game_party.menu_actor = $game_party.battle_members[index]
  end
# ╔═══════════════════════════════════════════════════════════════════════════╗
# ║ MAKE SURE THE FIRST MEMBER IS SELECTED UPON RE-ENTRY                      ║
# ╚═══════════════════════════════════════════════════════════════════════════╝
  def select_last
    select(0)
  end
# ╔═══════════════════════════════════════════════════════════════════════════╗
# ║ ** End of Window_MenuStatus                                               ║
# ╚═══════════════════════════════════════════════════════════════════════════╝
end
# ╔═══════════════════════════════════════════════════════════════════════════╗
# ║ END OF SCRIPT                                                             ║
# ╚═══════════════════════════════════════════════════════════════════════════╝

 


Looks like a very useful script, and to be honest, I had no idea VX Ace did that. How silly, lol

Edited by PhoenixSoul
Made changes to reflect error correction

Share this post


Link to post
Share on other sites

There is a misplaced "end" in def_select_last and you might want to comment out the "draw_item_background" line, as I think that is something specific to my own project, and would likely return errors. Just a heads up!

 

EDIT: Here, to avoid potential issues...

 

# ╔══════════════════════════════════════════════════════╤═══════╤════════════╗
# ║ Menu Battle Members Restriction                      │ v1.02 │ (06/03/19) ║
# ╠══════════════════════════════════════════════════════╧═══════╧════════════╣
# ║ Author  : William Couillard                                               ║
# ║ Thanks  : Traverse, Black Mage                                            ║
# ║ E-Mail  : cooliebk18@yahoo.com                                            ║
# ║ Website : ???                                                             ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ ABOUT                                                                     ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ This script forces the default menus to only allow the player access to   ║
# ║ party members who are in the current battle party. By default, all party  ║
# ║ members are accessible, so even party members who aren't in battle can    ║
# ║ use their skills or change their equipment. This script is intended to be ║
# ║ used alongside a Party Change script, such as Yanfly's Party System.      ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ TERMS OF USE                                                              ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ ► Do not edit the script's header or comments.                            ║
# ║ ► Free to use in commercial projects as long as proper credit is given to ║
# ║   ALL the names in the above header.                                      ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ FEATURES                                                                  ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ ► Restricts default menus to only allow access to party members who are   ║
# ║   in the active battle party. Custom menus for other scenes are not       ║
# ║   affected.                                                               ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ KNOWN ISSUES                                                              ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ ► None.                                                                   ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ CHANGE LOG                                                                ║
# ╠═════════════════════════════════════════════════════════════════╤═════════╣
# ║ ■ June 03, 2019     : Bugfixes/Compatibility.                   │ (v1.02) ║
# ╟─────────────────────────────────────────────────────────────────┼─────────╢
# ║ ■ March 11, 2015    : Bugfixes.                                 │ (v1.01) ║
# ╟─────────────────────────────────────────────────────────────────┼─────────╢
# ║ ■ December 04, 2014 : Initial release.                          │ (v1.00) ║
# ╠═════════════════════════════════════════════════════════════════╧═════════╣
# ║ OVERWRITTEN METHODS                                                       ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║   This script overwrites a few methods in various default scripts.        ║
# ╟───────────────────────────────────────────────────────────────────────────╢
# ║ ■ class Game_Party < Game_Unit                                            ║
# ║    ► def menu_actor_next                                                  ║
# ║    ► def menu_actor_prev                                                  ║
# ╟───────────────────────────────────────────────────────────────────────────╢
# ║ ■ class Window_MenuStatus < Window_Selectable                             ║
# ║    ► def draw_item                                                        ║
# ║    ► def process_ok                                                       ║
# ║    ► def item_max                                                         ║
# ║    ► def select_last                                                      ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ INSTRUCTIONS                                                              ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ Simply paste this script anywhere BELOW Window_MenuStatus. If you are     ║
# ║ using this script alongside Yanfly's Party System, place this script      ║
# ║ above it.                                                                 ║
# ╠═══════════════════════════════════════════════════════════════════════════╣
# ║ IMPORT SETTING                                                            ║
# ╚═══════════════════════════════════════════════════════════════════════════╝
$imported = {} if $imported.nil?                    # Do not edit
$imported["WC-BattleMemberRestriction_1.01"] = true # Do not edit
# ╔═══════════════════════════════════════════════════════════════════════════╗
# ║ ** Game_Party                                                             ║
# ╟───────────────────────────────────────────────────────────────────────────╢
# ║  This class handles parties. Information such as gold and items is        ║
# ║ included. Instances of this class are referenced by $game_party.          ║
# ╚═══════════════════════════════════════════════════════════════════════════╝
class Game_Party < Game_Unit
# ╔═══════════════════════════════════════════════════════════════════════════╗
# ║ SELECT NEXT ACTOR ON MENU SCREEN (Alias)                                  ║
# ╚═══════════════════════════════════════════════════════════════════════════╝
  def menu_actor_next
    index = battle_members.index(menu_actor) || -1
    index = (index + 1) % battle_members.size
    self.menu_actor = battle_members[index]
  end
# ╔═══════════════════════════════════════════════════════════════════════════╗
# ║ SELECT PREVIOUS ACTOR ON MENU SCREEN (Alias)                              ║
# ╚═══════════════════════════════════════════════════════════════════════════╝
  def menu_actor_prev
    index = battle_members.index(menu_actor) || 1
    index = (index + battle_members.size - 1) % battle_members.size
    self.menu_actor = battle_members[index]
  end
# ╔═══════════════════════════════════════════════════════════════════════════╗
# ║ ** End of Game_Party                                                      ║
# ╚═══════════════════════════════════════════════════════════════════════════╝
end
# ╔═══════════════════════════════════════════════════════════════════════════╗
# ║ ** Window_MenuStatus                                                      ║
# ╟───────────────────────────────────────────────────────────────────────────╢
# ║  This window displays party member status on the menu screen.             ║
# ╚═══════════════════════════════════════════════════════════════════════════╝
class Window_MenuStatus < Window_Selectable
# ╔═══════════════════════════════════════════════════════════════════════════╗
# ║ GET NUMBER OF ITEMS (Overwrite)                                           ║
# ╚═══════════════════════════════════════════════════════════════════════════╝
  def item_max
    $game_party.battle_members.size
  end
# ╔═══════════════════════════════════════════════════════════════════════════╗
# ║ DRAW ITEM (Alias)                                                         ║
# ╚═══════════════════════════════════════════════════════════════════════════╝
  def draw_item(index)
    coolie_bmr_draw_item(index)
    actor = $game_party.battle_members[index]
    enabled = $game_party.battle_members.include?(actor)
    rect = item_rect(index)
    draw_actor_face(actor, rect.x + 1, rect.y + 1, enabled)
    draw_actor_simple_status(actor, rect.x + 108, rect.y + line_height / 2)
  end
# ╔═══════════════════════════════════════════════════════════════════════════╗
# ║ PROCESSING WHEN OK BUTTON IS PRESSED (Alias)                              ║
# ╚═══════════════════════════════════════════════════════════════════════════╝
  def process_ok
    super
    $game_party.menu_actor = $game_party.battle_members[index]
  end
# ╔═══════════════════════════════════════════════════════════════════════════╗
# ║ SELECT LAST (Overwrite)                                                   ║
# ╚═══════════════════════════════════════════════════════════════════════════╝
  def select_last
    select(0)
  end  
# ╔═══════════════════════════════════════════════════════════════════════════╗
# ║ ** End of Window_MenuStatus                                               ║
# ╚═══════════════════════════════════════════════════════════════════════════╝
end
# ╔═══════════════════════════════════════════════════════════════════════════╗
# ║ END OF SCRIPT                                                             ║
# ╚═══════════════════════════════════════════════════════════════════════════╝

 

Edited by WCouillard

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×