[rgss]
#====================================================================
# ** Item menu addon
#-------------------------------------------------------------------
# by: Silver Wind
#
# - What is this script for ?
# By default, weapons, armors and items with
# scope 'none' are disabled on the item menu.
# This script lets the player select them anyway.
# Once selected, the item menu will close, and the item
# is saved in variables 001 and 002, and also in $game_temp.
# variable 001: number of the item/weapon/armor
# variable 002: type. 0 means item, 1=weapon and 2=armor.
# * if you wish to use other variables,
# change the numbers in lines 26-27.
#====================================================================
class Game_Temp
attr_accessor :select_equip # enable weapon/armor selection?
attr_accessor :item_id
attr_accessor :item_kind
end
class Scene_Item
ID_VAR = 1
KIND_VAR = 2
def update_item
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to menu screen
$scene = Scene_Menu.new(0)
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Get currently selected data on the item window
@item = @item_window.item
# ---------- my edit --------------------------
can_use = @item.is_a?(RPG::Item) and
$game_party.item_can_use?(@item.id)
can_use |= $game_temp.select_equip
# If it can't be used
unless can_use
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# chek if the item has a target
is_weapon = @item.is_a?(RPG::Weapon)
is_armor = @item.is_a?(RPG::Armor)
is_item = @item.is_a?(RPG::Item)
no_target = ( is_weapon or
is_armor or
@item.scope == 0 )
if no_target
# save the item and return
$game_variables[ID_VAR] = @item.id
kind = is_weapon ? 1 : (is_armor ? 2 : 0)
$game_variables[KIND_VAR] = kind
$game_temp.item_id = @item.id
$game_temp.item_kind = kind
$scene = Scene_Map.new
return
end
# ---------- my edit --------------------------
# If effect scope is an ally
if @item.scope >= 3
# Activate target window
@item_window.active = false
@target_window.x = (@item_window.index + 1) % 2 * 304
@target_window.visible = true
@target_window.active = true
# Set cursor position to effect scope (single / all)
if @item.scope == 4 || @item.scope == 6
@target_window.index = -1
else
@target_window.index = 0
end
# If effect scope is other than an ally
else
# If command event ID is valid
if @item.common_event_id > 0
# Command event call reservation
$game_temp.common_event_id = @item.common_event_id
# Play item use SE
$game_system.se_play(@item.menu_se)
# If consumable
if @item.consumable
# Decrease used items by 1
$game_party.lose_item(@item.id, 1)
# Draw item window item
@item_window.draw_item(@item_window.index)
end
# Switch to map screen
$scene = Scene_Map.new
return
end
end
return
end
end
end
[/rgss]
I've seen other people asking 'how to let the player use item on an event'.
So, I made this simple script.
To select weapon/armor, make an event with a script command:
$game_temp.select_equip = true
$scene = Scene_Item.new
variable 001 and 002 save the selected item's number and type.
You can use them in your enchanter NPC event.
Your event will act weird since we're opening the menu, so follow my instructions carefully:
use 2 pages in your NPC event.
page 1 :
- pull self-switch A ON,
- the script command
page 2 :
condition = 'switch A ON'.
- if variable 002 == 1 (the player selected a weapon)
if variable 001 = 1
text: you selected Bronze Sword
enchant the bronze sword.
if variable 001 = 2
text: you selected Iron Sword
enchant the iron sword.
if variable 001 = 3
text: you selected Mythril Sword
enchant the mythril sword.
...
else
text: that is not a weapon !
end