Nightmare Omnizohar
Member
Hi I'm using one of exseiken's old party switcher version. I need help on how to fix this window bug. Here's the current script:
I did everything that the script wanted me to do.
Heres a pic of the window bug:
http://img487.imageshack.us/img487/6063/bug1tb5.png
http://img487.imageshack.us/img487/1404/bug2it9.png
Anyway the first picture shows the window not scrolling with the cursor and the second picture shows the cursor missing. Thanks to those for helping me.
Code:
#==============================================================================
# Scene_Switch class definition
#------------------------------------------------------------------------------
#
# *** P L E A S E R E A D T H I S F I R S T ***
#
# Indeed, this is one huge comment block, but hopefully, everything you need
# to know will be included.
#
# This is currently a 4-page script, but I might eventually make them all in
# one single script, but it will work the same.
#
# This is version 1.04 of this script. I will not change the version number if
# the only changes I have made are in this instruction header. (In other words,
# if it does not change the actual workings of the script, I will not change
# the version number.)
#
# First of all, read the instructions provided in this header. You will find
# them not far below. If you have questions, please read the Mini-FAQ which is
# also in this huge comment header. If (and only if) the question is not
# answered there, please ask it on the "official" topic in the RMXP.net forums
# at the following URL:
# http://www.rmxp.net/forums/index.php?showtopic=20169
# (If RMXP.net is offline, please go to RMXP.org instead and make a topic if
# there is not one already.)
#
# Once again, please read the FAQ and instructions before posting on the forum.
# I will not bother answering a question if the one who asked did not bother to
# read the instructions beforehand. I apologize if I sounded harsh, but it is
# quite unpleasant to be asked to repeat yourself over and over.
#
# On that, happy RPG Making. :)
#
# About the script provided in this file, it is the scene object, which
# provides the basic functionnality to implement a screen for switching
# characters in and out of the party. It works with three (3) other scripts,
# named Window_SwitchParty, Window_SwitchReserve and Window_SwitchStatus.
#------------------------------------------------------------------------------
# VERSION HISTORY
# ---------------
# 1.04: Fixed the incompatilibity with the legal version. Also updated the FAQ
# with a few more common questions, and added a link to the "official"
# topic at RMXP.net in the introduction.
#
# 1.03: Fixed the problem where characters that were subject to any of the
# listed event commands were automatically added to the reserve window.
# Commands: Enter Hero Name, Change HP, Change SP, Change Status
# Complete Healing, Change Experience Points, Change Level
# Change Basic Statistics, Change Skill, Change Equipped Items,
# Change Hero Name, Change Hero Class and Change Hero Graphic.
#
# No more need for setting Game_Party::actors writable, and
# Actor::actor_id readable.
#
# 1.02: Added "Known Issues" section, listing various problems you may
# encounter.
#
# 1.01: Now, the reserve window allows to have as many characters as it can
# fit. The default size is still 10, but if it is greater, it will scroll
# correctly.
#
# Removed a lot of useless/erroneous code.
#
# 1.00: Original version.
#------------------------------------------------------------------------------
# INSTRUCTIONS
# ------------
# 1- Open RPG Maker XP and go to the Script Editor.
# 2- Select script "Game_Actor"
# 3- Find the line "attr_reader :skills", and
# right below, add those two lines:
# attr_accessor :mandatory # if actor can be switched out [R/W]
# attr_accessor :unavailable # if actor appears in reserve [R/W]
# 4- Find the line "actor = $data_actors[actor_id]", which is right under
# "def setup(actor_id)", and add those two lines below:
# @mandatory = false
# @unavailable = true
# 5- Select script "Game_Actors"
# 6- Find the line "class Game_Actors", and right below, add this line:
# attr_reader :data # all initialized actors [R-O]
# 7- Select script "Game_Party"
# 8- Find the line "def setup_starting_members", and between the 4th and the
# 5th line below (between the two "end"), add those lines:
# for actor in @actors
# actor.unavailable = false
# end
# 9- Find the line "actor = $game_actors[actor_id]", and add those two lines
# right below:
# # newly-added characters are made "available" by default
# actor.unavailable = false
# 10- You are done with manual editing. :)
# 11- Create three new scripts. Put them preferably with the others "Window_"
# scripts for quicker reference. Call them "Window_SwitchParty",
# "Window_SwitchReserve", and "Window_SwitchStatus"
# 12- Copy the other three scripts in them.
# 13- Create a fourth script called "Scene_Switch" (Put this one in the Scene_
# scripts) and paste this file into it.
# 14- Click OK, then click File/Save.
#------------------------------------------------------------------------------
# HOW TO USE
# ----------
# To display this screen, just make an event, insert a Call RGSS Script command
# and paste the following code:
# $scene = Scene_Switch.new
#
# I suggest you put this code into a common event, so you do not have to
# remember the code everytime. The screen works very similarily to the party
# switching screens of other (commercial) RPGs. The left window lists the
# selected characters and the right window lists unselected characters that are
# available to be picked. Once you are satisfied with your new party, press B to
# return to the main screen.
#
# This is all there is to know if you simply want to use this screen. However,
# this provides two additional features. One allows to force a character in the
# party, the other make the character unpickable from the right (reserve)
# window.
#
# In most games, you absolutely need to have the main character in your party.
# Using a special feature of this script, it is possible to make a character
# unremovable. (Except by manually removing it.) To do this, create an event,
# add a Call RGSS Script command and paste the following code:
# $game_actors[12345].mandatory = true
# Similarily, if you want to make a character removable again, use this code:
# $game_actors[12345].mandatory = false
# return true # **SEE BUGS AND KNOWN ISSUES FOR THIS**
# In both examples, change 12345 for the number of the character you want to
# affect. For example, the first hero in the database is number 1, the second
# is number 2, etc... (Same numbers you use for the \n[12345] commands in
# Show Message.
#
# Also, while the script makes automatically available a characters as soon as
# she/he joins the party, it cannot guess when you want them to leave your
# party. Just like above, there is a simple RGSS line that will do the work for
# us. To make a character unpickable in the switch screen, use this:
# $game_actors[12345].unavailable = true
# And to make it available again:
# $game_actors[12345].unavailable = false
# return true # **SEE BUGS AND KNOWN ISSUES FOR THIS**
#
# Since those two last features require you to modify the script, you cannot
# really put them in a common event like for showing the scene. BUT if you
# really hate having to put scripts manually and prefer using common events,
# you could do this:
# 1- Make a variable called "Switch Param" or something among those lines
# 2- Remember the number of the variable.
# 3- Make a common event called "Set Mandatory" and paste this line, replacing
# 12345 with the number of the variable "Switch Param":
# $game_actors[$game_variables[12345]].mandatory = true
# 4- Repeat for "Reset Mandatory", "Set Unavailable" and "Reset Unavailable"
# 5- When you want to do one of those operations, store the number of the
# character with Change Variable (i.e. 1 for the first hero in the
# database, 2 for the next, etc...) and use Call Common Event to execute
# the operation.
#
# Sometimes, you want the player to have a fixed amount of party members. By
# default, it allows the player to have one, two, three or four characters, but
# you can change this if you want. When you call the switching screen, either
# in an event or in a common event, you can pass parameters to limit the size
# of the party. Like this:
# $scene = Scene_Switch.new(false, 2, 4)
# The first parameters, "false" in this case, must always be "false" and is
# there only for those who intent to implement it in their menu. (Requires
# knowledge in Ruby.) The second parameter, "2", is the minimum amount of
# characters the player is allowed to select. The third, as you can guess, is
# the maximum amount allowed. So in this example, the new party can comprise
# only two, three or four characters, in other words, solos are not accepted.
#------------------------------------------------------------------------------
# BUGS / KNOWN ISSUES
# -------------------
# "This is not a bug, this is a feature." -- Bill Gates, Microsoft Corporation
#
# 1- Calling "$game_actors[12345].mandatory = false" freezes the game.
# This is supposed to be the normal behavior. If you evaluate an
# expression that returns false, the game is supposed to hang and call
# this script again and again until it returns true. Hence why I wrote a
# "return true" line below.
#
# HOWEVER, there is a bug in the default scripts of RPG Maker XP
# affecting this command, that make that special behavior happen ONLY
# when there the script contains only one line. If an expression that
# returns false has several lines, even if all other lines are comments,
# it will not hang the game like it is supposed to do. Of course, this
# bug has nothing to do with my script. You can try a random expression
# that returns false (i.e. "x = false") and you will get the same result,
# as long as the script has only one line.
#
# I have written a topic about it. The way that I wrote it is a little
# confusing, but if you are interested, you may consult it here:
# http://www.rmxp.net/forums/index.php?showtopic=20182
#------------------------------------------------------------------------------
# MINI-FAQ (Frequently Asked Questions)
# -------------------------------------
# Those are questions asked a lot on the old deleted topics, and also questions
# I got by email/PM. I do this from memory, since the deleted topic is...
# deleted! If I get other frequent questions I will add them here without
# increasing the version number.
#
# 1- I am getting "??? Syntax_Error ?" or "??? NoMethod_Error
# ?" errors!
# Unless you modified a part of this script, (in that case double-check
# your code) that is most probably because you made an error while
# editing the scripts (Game_Actors and Game_Party must be modified a
# little for this script to work) or you did not use a Call RGSS Script
# correctly.
#
# 2- Does this work mid-battle?
# No. That is because this screen is a "scene", just like the battle
# screen, and only one scene can be active at once. In other words, if
# you open this scene, you will have to close the battle screen. To make
# it work mid-battle, you will have to make this a sub-screen instead.
# This is not impossible to do, but you have no template or example in
# the default scripts.
#
# 3- How do I incorporate it in my menu?
# Assuming you know have a minimum RGSS knowledge... First prepare your
# menu. (Add a menu command, icon, whatever it takes.) Then call the
# screen like this:
# $scene = Scene_Switch.new(true)
# Set the party size limit if you need. Now, if you are using a modified
# default menu, find the line "$scene = Scene_Menu.new(0)" in
# update_party and set the parameter to the index of the switch command
# in the menu.
#
# 4- How do I allow more places in the reserve window?
# The reserve window will present 10 places by default, and will resize
# itself if you have more characters. But if you want even more places
# even though you do not have that amount of characters, when you call
# the screen, pass the amount of characters you want as a fourth
# parameter. Note that it will always be an even number though. If you
# request an odd number you will have one more place.
#
# 5- Is there a demo? Are there screenshots?
# I no longer use RPGXP, nor do I have it on my harddrive. I cannot do
# this. I would really appreciate if someone could do this though.
#
# 6- Is this script SDK-compatible?
# No. I do not support the SDK at all. I believe that it is not required,
# complicates the work of the coders, and is not even what a real SDK
# should be. I, however, am not trying to force my opinion upon you, so
# if someone were to adapt my work for the SDK, I would have no problem
# in adding a link to the SDK-ed version. Of course, if you have trouble
# with it, I would not be able to help, but at least, you will be given
# the choice.
#
# 7- Help! I do not see the fonts!
# That is because you are using a pirated version. The previous version
# of this script, which was written well before the legal English version
# came on the market, was adapted for the Postiality Knights edition. Now
# that a legal alternative is out, I adapted the script for it. That
# being said, the lines that supports the Postiality Knights edition are
# still in the scripts. I have simply put them in comment. Find them. I
# will keep those lines, unless someone with authority (a moderator or an
# administrator) insists that I delete those lines.
#------------------------------------------------------------------------------
# Version 1.04, by exseiken. March 16th, 2006
#==============================================================================
class Scene_Switch
#----------------------------------------------------------------------------
# Initialize the sub-screen.
#
# Parameters:
# from_menu: Determines whether or not the scene was called from
# the menu or not. Note that although it can return
# to the menu, it will not reposition the menu cursor
# to the right position. It will reposition it to the
# first position, which is usually "Items". You will
# have to edit this script.
# [true|false; default=false]
# min_party_size: The minimum amount of battlers you want to allow
# the player to select. [1-4; default=1]
# max_party_size: The maximum amount of battlers you want to allow
# the player to select. [1-4; default=4]
# reserve_size: How many places there are in the reserve window.
# [default=10]
#----------------------------------------------------------------------------
def initialize(from_menu = false, min_party_size = 1, max_party_size = 4, reserve_size = 10)
# store the data telling whether or not the scene was called from the menu
@from_menu = from_menu
# store the array founds for the max_party_size and the min_party_size
@min_party_size = [[min_party_size, 1].max, 4].min
@max_party_size = [[max_party_size, @min_party_size].max, 4].min
# store the desired reserve size
@reserve_size = reserve_size
end
#----------------------------------------------------------------------------
# The main routine, which controls the switching screen.
#----------------------------------------------------------------------------
def main
# create the window containing the current party members
@party_window = Window_SwitchParty.new
# create the window containing all available party members
@reserve_window = Window_SwitchReserve.new(@reserve_size)
# create the window showing information about the selected character, be it
# from the party window or from the reserve window
@status_window = Window_SwitchStatus.new
# unactivate the reserve_window
@reserve_window.active = false
# set this status window as the two other windows' help window
@party_window.help_window = @status_window
@reserve_window.help_window = @status_window
# display the transition
Graphics.transition
# enter the main loop
loop do
# flip the screen
Graphics.update
# get the keyboard/joypad status
Input.update
# update the sub-screen
update
# if the scene has changed, break out of the main loop
if $scene != self
break
end
end
# stop graphics updating
Graphics.freeze
# destroy the sub-windows
@status_window.dispose
@reserve_window.dispose
@party_window.dispose
end
#----------------------------------------------------------------------------
# Method called on every frame to update the screen's state.
#----------------------------------------------------------------------------
def update
# update all sub-windows
@party_window.update
@reserve_window.update
@status_window.update
# if the active screen is party_window, update it, else update the reserve
# window
if @party_window.active
update_party
else
update_reserve
end
end
#----------------------------------------------------------------------------
# Called when the focus is on the party window. Read on the keyboard and
# update the state of the scene according to the buttons pressed. If the
# played pressed B while this mode is on, the new party will be set and the
# scene will close.
#----------------------------------------------------------------------------
def update_party
# if the B (back) button was pressed, return to the preceeding screen
if Input.trigger?(Input::B)
# remove all holes in the party
new_party = @party_window.new_party.compact
# ensure that the number of party members is within the allowed range
unless (@min_party_size..@max_party_size).include?(new_party.size)
# play the buzzer and exit
$game_system.se_play($data_system.buzzer_se)
return
end
# play the confirm sound
$game_system.se_play($data_system.decision_se)
# set the new party
until $game_party.actors.size == 0
# empty the party
$game_party.remove_actor($game_party.actors[0].id)
end
for actor in new_party
# add the character to the party
$game_party.add_actor(actor.id)
end
# return to the screen who called
if @from_menu
$scene = Scene_Menu.new(0)
else
$scene = Scene_Map.new
end
# refresh the player's sprite
$game_player.refresh
# if the C (confirm) button was pressed, switch the control to the reserve
# window
elsif Input.trigger?(Input::C)
# if the selected character is not nil or is unavailable, play the buzzer
if @party_window.actor != nil and @party_window.actor.mandatory
# play the buzzer
$game_system.se_play($data_system.buzzer_se)
else
# play the decision sound
$game_system.se_play($data_system.decision_se)
# unactivate the party window
@party_window.active = false
# activate the reserve window
@reserve_window.active = true
end
end
end
#----------------------------------------------------------------------------
# Called when the focus is on the reserve window. Read on the keyboard and
# update the state of the scene according to the buttons pressed.
#----------------------------------------------------------------------------
def update_reserve
# if the B (back) button was pressed, give back the focus to the party
# window
if Input.trigger?(Input::B)
# play the cancel sound
$game_system.se_play($data_system.decision_se)
# unactivate the reserve window and activate the party window
@reserve_window.active = false
@party_window.active = true
# if the C (confirm) button was pressed, switch the party member in reserve
# with the one selected in the party
elsif Input.trigger?(Input::C)
# play the confirm sound
$game_system.se_play($data_system.decision_se)
# swap the 2 party members
@party_window.change_selection(@reserve_window.swap_characters(@party_window.actor))
# unactivate the reserve window and activate the party window
@reserve_window.active = false
@party_window.active = true
end
end
end
I did everything that the script wanted me to do.
Heres a pic of the window bug:
http://img487.imageshack.us/img487/6063/bug1tb5.png
http://img487.imageshack.us/img487/1404/bug2it9.png
Anyway the first picture shows the window not scrolling with the cursor and the second picture shows the cursor missing. Thanks to those for helping me.