-
I'm not sure if this is the right place for this but..
Where do I edit the default script to be able to use the item menu when there are no actors in party? I'm trying to make a key item usable that has 'no scope' so it doesn't need to be used on an actor.
-
I'm not exactly sure what question you're asking.
But if you want to access the item menu without accessing it through the main menu itself
(i.e no actors required).
In your event files on the third page, select script and input this code
$scene = Scene_Item.new
and that will open the item menu for you.
-
I'm not sure if this is the right place for this but..
Where do I edit the default script to be able to use the item menu when there are no actors in party? I'm trying to make a key item usable that has 'no scope' so it doesn't need to be used on an actor.
Wouldn't you set the scope to none then?
-
Sorry for being unspecific.
Basically I'm making an event-based party system that works like this:
*a common event that removes the entire party (Using a key item)
*a common event that keeps me in menu as long as there are no party members
*common events that add actors to party (using key items)
Basically, I have a 'card' that removes all party members and other 'cards' for each actor to be added to party. The problem being that if I have no actors, it won't let me access the item menu to activate the 'actor cards'.
I have that 'menu if no actors' event so that someone can't just walk around with an empty party. The reason I did this instead of 'remove all party members except main character' is because I want to be able to have a party of anyone.
-
Create a backup of 'Scene_Menu' (Just in case).
And then replace all of it with this
#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
# This class performs the menu screen processing.
#==============================================================================
class Scene_Menu < Scene_Base
#--------------------------------------------------------------------------
# * Object Initialization
# menu_index : command cursor's initial position
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#--------------------------------------------------------------------------
# * Start processing
#--------------------------------------------------------------------------
def start
super
create_menu_background
create_command_window
@gold_window = Window_Gold.new(0, 360)
@status_window = Window_MenuStatus.new(160, 0)
end
#--------------------------------------------------------------------------
# * Termination Processing
#--------------------------------------------------------------------------
def terminate
super
dispose_menu_background
@command_window.dispose
@gold_window.dispose
@status_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
update_menu_background
@command_window.update
@gold_window.update
@status_window.update
if @command_window.active
update_command_selection
elsif @status_window.active
update_actor_selection
end
end
#--------------------------------------------------------------------------
# * Create Command Window
#--------------------------------------------------------------------------
def create_command_window
s1 = Vocab::item
s2 = Vocab::skill
s3 = Vocab::equip
s4 = Vocab::status
s5 = Vocab::save
s6 = Vocab::game_end
@command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])
@command_window.index = @menu_index
if $game_party.members.size == 0 # If number of party members is 0
@command_window.draw_item(1, false) # Disable skill
@command_window.draw_item(2, false) # Disable equipment
@command_window.draw_item(3, false) # Disable status
end
if $game_system.save_disabled # If save is forbidden
@command_window.draw_item(4, false) # Disable save
end
end
#--------------------------------------------------------------------------
# * Update Command Selection
#--------------------------------------------------------------------------
def update_command_selection
if Input.trigger?(Input::B)
Sound.play_cancel
$scene = Scene_Map.new
elsif Input.trigger?(Input::C)
if $game_party.members.size == 0 and @command_window.index >= 1 and @command_window.index < 4
Sound.play_buzzer
return
elsif $game_system.save_disabled and @command_window.index == 4
Sound.play_buzzer
return
end
Sound.play_decision
case @command_window.index
when 0 # Item
$scene = Scene_Item.new
when 1,2,3 # Skill, equipment, status
start_actor_selection
when 4 # Save
$scene = Scene_File.new(true, false, false)
when 5 # End Game
$scene = Scene_End.new
end
end
end
#--------------------------------------------------------------------------
# * Start Actor Selection
#--------------------------------------------------------------------------
def start_actor_selection
@command_window.active = false
@status_window.active = true
if $game_party.last_actor_index < @status_window.item_max
@status_window.index = $game_party.last_actor_index
else
@status_window.index = 0
end
end
#--------------------------------------------------------------------------
# * End Actor Selection
#--------------------------------------------------------------------------
def end_actor_selection
@command_window.active = true
@status_window.active = false
@status_window.index = -1
end
#--------------------------------------------------------------------------
# * Update Actor Selection
#--------------------------------------------------------------------------
def update_actor_selection
if Input.trigger?(Input::B)
Sound.play_cancel
end_actor_selection
elsif Input.trigger?(Input::C)
$game_party.last_actor_index = @status_window.index
Sound.play_decision
case @command_window.index
when 1 # skill
$scene = Scene_Skill.new(@status_window.index)
when 2 # equipment
$scene = Scene_Equip.new(@status_window.index)
when 3 # status
$scene = Scene_Status.new(@status_window.index)
end
end
end
end
-
It didn't work. Is that the menu code from vx? I'm using vxa if that makes any difference, cuz it seems to be a little different.
-
Yes it was the code for VX. :P
Alright create a backup of 'Window_MenuCommand' (Just In Case)
and replace all of it with this.
#==============================================================================
# ** Window_MenuCommand
#------------------------------------------------------------------------------
# This command window appears on the menu screen.
#==============================================================================
class Window_MenuCommand < Window_Command
#--------------------------------------------------------------------------
# * Initialize Command Selection Position (Class Method)
#--------------------------------------------------------------------------
def self.init_command_position
@@last_command_symbol = nil
end
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0)
select_last
end
#--------------------------------------------------------------------------
# * Get Window Width
#--------------------------------------------------------------------------
def window_width
return 160
end
#--------------------------------------------------------------------------
# * Get Number of Lines to Show
#--------------------------------------------------------------------------
def visible_line_number
item_max
end
#--------------------------------------------------------------------------
# * Create Command List
#--------------------------------------------------------------------------
def make_command_list
add_main_commands
add_formation_command
add_original_commands
add_save_command
add_game_end_command
end
#--------------------------------------------------------------------------
# * Add Main Commands to List
#--------------------------------------------------------------------------
def add_main_commands
add_command(Vocab::item, :item,)# main_commands_enabled)
add_command(Vocab::skill, :skill, main_commands_enabled)
add_command(Vocab::equip, :equip, main_commands_enabled)
add_command(Vocab::status, :status, main_commands_enabled)
end
#--------------------------------------------------------------------------
# * Add Formation to Command List
#--------------------------------------------------------------------------
def add_formation_command
add_command(Vocab::formation, :formation, formation_enabled)
end
#--------------------------------------------------------------------------
# * For Adding Original Commands
#--------------------------------------------------------------------------
def add_original_commands
end
#--------------------------------------------------------------------------
# * Add Save to Command List
#--------------------------------------------------------------------------
def add_save_command
add_command(Vocab::save, :save, save_enabled)
end
#--------------------------------------------------------------------------
# * Add Exit Game to Command List
#--------------------------------------------------------------------------
def add_game_end_command
add_command(Vocab::game_end, :game_end)
end
#--------------------------------------------------------------------------
# * Get Activation State of Main Commands
#--------------------------------------------------------------------------
def main_commands_enabled
$game_party.exists
end
#--------------------------------------------------------------------------
# * Get Activation State of Formation
#--------------------------------------------------------------------------
def formation_enabled
$game_party.members.size >= 2 && !$game_system.formation_disabled
end
#--------------------------------------------------------------------------
# * Get Activation State of Save
#--------------------------------------------------------------------------
def save_enabled
!$game_system.save_disabled
end
#--------------------------------------------------------------------------
# * Processing When OK Button Is Pressed
#--------------------------------------------------------------------------
def process_ok
@@last_command_symbol = current_symbol
super
end
#--------------------------------------------------------------------------
# * Restore Previous Selection Position
#--------------------------------------------------------------------------
def select_last
select_symbol(@@last_command_symbol)
end
end
-
That actually worked!
But now it won't let me use the items themselves... :P
Edit: It seems as though (scope: none) items still require some kind of actor check before use.
-
Alright create a backup of 'Window_MenuCommand' (Just In Case)
You don't need to replace the default classes and, in my opinion, it is generally best not to advise people to do so since it makes it difficult for them to remove the script if they later decide not to use it.
You can reopen the class in a new slot and just alias or overwrite (if necessary) the methods you want changed.
In your case, leaving the default class in and simply adding the following code into a new slot between Materials and Main would do the same thing:
class Window_MenuCommand
#--------------------------------------------------------------------------
# * Add Main Commands to List
#--------------------------------------------------------------------------
def add_main_commands
add_command(Vocab::item, :item)# main_commands_enabled)
add_command(Vocab::skill, :skill, main_commands_enabled)
add_command(Vocab::equip, :equip, main_commands_enabled)
add_command(Vocab::status, :status, main_commands_enabled)
end
end
To make the script more compatible through aliasing, the following code would have the same effect:
class Window_MenuCommand
#--------------------------------------------------------------------------
# * Add Main Commands to List
#--------------------------------------------------------------------------
alias dp3_zaiu_addmncmmnds_2jh6 add_main_commands
def add_main_commands(*args, &block)
dp3_zaiu_addmncmmnds_2jh6(*args, &block)
@list.find({}) {|cmnd| cmnd[:symbol] == :item }[:enabled] = true
end
end
-
Yeah, the problem of opening the item menu with no actors is solved, but I still can't use items that have no scope(items that don't need to be used on allies/enemies but still have a common event attached that I want to use).
-
It has to do with the usable? method of the Game_Party class, but I don't want to swoop in and take the opportunity to answer the question away from D&P3. I only posted to let him know that there is an easier way to modify a class than replacing it.
-
I changed it from:
def usable?(item)
members.any? {|actor| actor.usable?(item)
end
to: def usable?(item)
if
$game_party.members.size <= 0
if :item
item.is_a?(RPG::Item) && item.key_item?
end
else
members.any? {|actor| actor.usable?(item) }
end
end
It keeps regular items+key items usable before empty party, then after empty party the regular items are disabled(which is good) and the key items are highlighted. Only problem is, I get this error when I use my key item to summon a party member:
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi.imgur.com%2Fx0NWX.png&hash=b3447bf9f048b940569d23cdd9c5f859e4f67d45) (http://imgur.com/x0NWX)
-
I went into Scene_ItemBase and changed line132 to this:
def use_item
play_se_for_item
if :item
if item.is_a?(RPG::Item) && !item.key_item?
user.use_item(item)
end
end
use_item_to_actors
check_common_event
check_gameover
@actor_window.refresh
end
It doesn't give me an error anymore, but the actor still doesn't get added to party.
-
Reverse those changes please. They are wrong, although I do appreciate that you are taking the effort to try and resolve errors by yourself. That is a step most RM users wouldn't take, and I respect you for it.
Also, don't directly change the default scripts at all.
Anyway, I will tell you what to do if D&P3 doesn't get to it tomorrow.
-
Darn, and I thought I was close too. Ok, I'll wait til tomorrow. ^-^
-
I've been taking a crack at it :)
So far I've been unsuccessful in getting it to work correctly, but that won't stop me from continuing to try.
I managed to learn quite a bit about how the item menu works, so that's a good thing. Especially since I've never looked into VXA scripting before, looks much easier ^-^
Anyway, I'm afraid this may take me awhile, and the code would definitely be more efficient if you did it MA, so please answer the question in my place :D
Here's what I managed to do so far, though I already know what the bugs are with it.
Got any suggestions on how I can improve this?
#============================================================================
# Code by Modern Algebra
#----------------------------------------------------------------------------
class Window_MenuCommand #/////////////////////////////////////////////////
#//////////////////////////////////////////////////////////////////////////
#--------------------------------------------------------------------------
# * Add Main Commands to List
#--------------------------------------------------------------------------
alias dp3_zaiu_addmncmmnds_2jh6 add_main_commands #//////////////////////
def add_main_commands(*args, &block) #///////////////////////////////////
dp3_zaiu_addmncmmnds_2jh6(*args, &block) #/////////////////////////////
@list.find({}) {|cmnd| cmnd[:symbol] == :item }[:enabled] = true #/////
end #////////////////////////////////////////////////////////////////////
end #/////////////////////////////////////////////////////////////////////
#=============================================================================
class Game_Party < Game_Unit
#--------------------------------------------------------------------------
# * Display in Enabled State?
#--------------------------------------------------------------------------
alias dp3_zaiu_enblkeyitem_2jh6 usable?
def usable?(item)
if $game_party.members.size == 0
@actors.empty? {|actor| actor.usable(item.key_item) }
else
members.any? {|actor| actor.usable?(item) }
end
end
end
class Window_MenuActor < Window_MenuStatus
#--------------------------------------------------------------------------
# * Restore Previous Selection Position
#--------------------------------------------------------------------------
alias dp3_zaiu_actrselect_2jh6 select_last
def select_last
if $game_party.members.size > 0
select($game_party.target_actor.index || 0)
else
Sound.play_buzzer
@category_window = Window_ItemCategory.new #exits the actor selection
#if there are no actors to display.
end
end
end
class Scene_ItemBase < Scene_MenuBase
alias dp3_zaiu_useitem_2jh6 use_item
def use_item
if $game_party.members.size == 0
play_se_for_item
user.use_item(item) #This is the main part that I am stuck at. It returns an error when
#using an item at this line when no party members are available.
check_common_event
check_gameover
@actor_window.refresh
else
play_se_for_item
user.use_item(item)
use_item_to_actors
check_common_event
check_gameover
@actor_window.refresh
end
end
end
-
I've been taking a crack at it :)
Here's what I managed to do so far, though I already know what the bugs are with it.
Got any suggestions on how I can improve this?
#============================================================================
# Code by Modern Algebra
#----------------------------------------------------------------------------
class Window_MenuCommand #/////////////////////////////////////////////////
#//////////////////////////////////////////////////////////////////////////
#--------------------------------------------------------------------------
# * Add Main Commands to List
#--------------------------------------------------------------------------
alias dp3_zaiu_addmncmmnds_2jh6 add_main_commands #//////////////////////
def add_main_commands(*args, &block) #///////////////////////////////////
dp3_zaiu_addmncmmnds_2jh6(*args, &block) #/////////////////////////////
@list.find({}) {|cmnd| cmnd[:symbol] == :item }[:enabled] = true #/////
end #////////////////////////////////////////////////////////////////////
end #/////////////////////////////////////////////////////////////////////
#=============================================================================
class Game_Party < Game_Unit
#--------------------------------------------------------------------------
# * Display in Enabled State?
#--------------------------------------------------------------------------
alias dp3_zaiu_enblkeyitem_2jh6 usable?
def usable?(item)
if $game_party.members.size == 0
@actors.empty? {|actor| actor.usable(item.key_item) }
else
members.any? {|actor| actor.usable?(item) }
end
end
end
class Window_MenuActor < Window_MenuStatus
#--------------------------------------------------------------------------
# * Restore Previous Selection Position
#--------------------------------------------------------------------------
alias dp3_zaiu_actrselect_2jh6 select_last
def select_last
if $game_party.members.size > 0
select($game_party.target_actor.index || 0)
else
Sound.play_buzzer
@category_window = Window_ItemCategory.new #exits the actor selection
#if there are no actors to display.
end
end
end
class Scene_ItemBase < Scene_MenuBase
alias dp3_zaiu_useitem_2jh6 use_item
def use_item
if $game_party.members.size == 0
play_se_for_item
user.use_item(item) #This is the main part that I am stuck at. It returns an error when
#using an item at this line when no party members are available.
check_common_event
check_gameover
@actor_window.refresh
else
play_se_for_item
user.use_item(item)
use_item_to_actors
check_common_event
check_gameover
@actor_window.refresh
end
end
end
Yeah, that error is satanic. At least you got very close and made a good framework for most of it.
-
*bump*
Can anyone help us with the last error?
-
Alright, try this:
#==============================================================================
# Zero Actor Item Use
# Version: 1.0
# Author: modern algebra (rmrk.net)
# Date: April 21, 2012
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Description:
#
# This script allows you to access the Items menu even when there are no
# actors in the party. Additionally, you can use any items that do not target
# actors so long as all other conditions for its use are satisfied.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Instructions:
#
# Paste this script into its own slot in the Script Editor, above Main but
# below Materials.
#
# This script will operate to permit opening the Item scene from the menu
# at all times, even when there are no actors in the party. Additionally, any
# items with a scope that doesn't target any actors will be usable so long
# as any other requirements are satisfied. You can override that and make
# even items with non-actor scope unusable without actors in the party by
# placing the following code in its notebox:
#
# \nonzero
#
# Finally, as this script, by default, makes it so that the Item scene is
# always available, I have added a switch which you can use to control access
# to the Item scene. You set the ID of the in-game switch at line 42. When
# you turn that switch ON, the player will not be able to access the Item
# menu under any conditions, but as long as that switch is off the Items
# scene can always be accessed.
#==============================================================================
$imported ||= {}
$imported[:MA_ZeroActorItemUse] = true
# Set this value to the ID of the switch which you want to control whether
# access to the Item scene should be disabled. See line 27 for more details.
# Ex: if you set this to 201, then that means the switch with ID 201 will
# control access to the Items scene.
MAZAIU_DISABLE_ITEMS_SWITCH_ID = 201
#==============================================================================
# ** Game_Party
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased method - usable?
# new method - zaiu_zero_actor_usable?
#==============================================================================
class Game_Party
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Determine Skill/Item Usability
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias madp3_zaiu_usble_3hv7 usable?
def usable?(item, *args, &block)
return true if members.empty? && zaiu_zero_actor_usable?(item)
madp3_zaiu_usble_3hv7(item, *args, &block) # Call Original Method
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Determine if usable without a party
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def zaiu_zero_actor_usable?(item)
item.is_a?(RPG::Item) && $game_actors[1].item_conditions_met?(item) &&
item.scope < 7 && !item.note[/\\NONZERO/i]
end
end
#==============================================================================
# ** Window_MenuCommand
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased method - add_main_commands
# new method - zaiu_item_enabled
#==============================================================================
class Window_MenuCommand
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Add Main Commands to List
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias madp3_zaiu_addmncmmnds_2jh6 add_main_commands
def add_main_commands(*args, &block)
madp3_zaiu_addmncmmnds_2jh6(*args, &block) # Call Original Method
@list.find({}) {|cmnd| cmnd[:symbol] == :item }[:enabled] = zaiu_item_enabled
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Item Enabled
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def zaiu_item_enabled
!$game_switches[MAZAIU_DISABLE_ITEMS_SWITCH_ID]
end
end
#==============================================================================
# ** Scene_ItemBase
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased method - user
#==============================================================================
class Scene_ItemBase
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Get Item's User
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias madp3_zaiu_usr_5kd9 user
def user(*args, &block)
member = madp3_zaiu_usr_5kd9(*args, &block)
# Actor 1 set to use item if no actors in party
member ? member : $game_actors[1]
end
end
-
Thanks!
I tested it out and it seems as though it does call in the actor, but they disappear immediately after.
I duplicated the problem here:
http://dl.dropbox.com/u/33252047/Test.zip
I made 3 cards, 1 to call rain(as a common event test), 1 to call the first character and 1 to call the second character(to test if adding actors works beforehand) [item 18,19,20]
I made switch 199 to keep you in menu if there are no actors(menu lock), switch 200 to remove all party members(remove party) and kept switch 201 the 'disable item menu' from the script. Variable 97-100 are to check the actor ID for the menu lock. I made the character above the player give the items and the dog to the right activate menu lock+remove party. So the common events are: Menu Lock, Remove Party, Rain, Eric, Natalie.
Before activating menu lock+remove party, if I use the 'natalie card', it calls up that character. If I use the rain card, that works too.
After activating menu lock+remove party, if I use the rain card(if I previously didn't) that still works. If I use either actor card, they appear for a quick second then disappear and cause the menu to pop back up again, from menu lock, showing that there are no actors.
-
Well, your Remove Actors common event is set as a parallel process, meaning that it runs every frame as long as switch 200 is on. So you are adding the actor with the item and then immediately removing him or her with the parallel process common event. So just make that not a parallel process event and you should be fine.
-
Wow, silly me. I set it to auto run and had it turn the switch off at the end of the common event and it works fine now. :lol:
-
I'm glad everything is working.
Just so you are aware, you can directly call a common event from within an event; it doesn't need to have a trigger and a condition switch. It's the "Call Common Event" option and it's located in the first column of the first event page, 4th from the bottom. It's more efficient then what you just described and it's just as easy to do as turning a switch ON.
-
I'm doing it to where I can change party anywhere. I'll have a party remove item and then the actor cards. If I change my mind, I could have a call common event remove party at only the Inn's or something.
Edit: Just realized that someone could change party whenever a lot of their members die.