#==============================================================================
# Seperate Items For Actors
#==============================================================================
# SephirothSpawn
# Version 1
# 2.2.05
# Thanks to Near Fantastica for his Keyboard Module, and Katzbalger for requesting it
#==============================================================================
#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
#SDK.log("Seperate Items For Actors", "SephirothSpawn", 1, "2.2.05")
#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
#if SDK.state("Seperate Items For Actors") == true
#==============================================================================
# ** Keyboard Input Module
#==============================================================================
# Near Fantastica
# Version 5
# 29.11.05
#==============================================================================
# The Keyboard Input Module is designed to function as the default Input module
# dose. It is better then other methods keyboard input because as a key is
# tested it is not removed form the list. so you can test the same key multiple
# times the same loop.
#==============================================================================
module Keyboard
#--------------------------------------------------------------------------
@keys = []
@pressed = []
Mouse_Left = 1
Mouse_Right = 2
Back= 8
Tab = 9
Enter = 13
Shift = 16
Ctrl = 17
Alt = 18
Esc = 27
Space = 32
Numberkeys = {}
Numberkeys[0] = 48
Numberkeys[1] = 49
Numberkeys[2] = 50
Numberkeys[3] = 51
Numberkeys[4] = 52
Numberkeys[5] = 53
Numberkeys[6] = 54
Numberkeys[7] = 55
Numberkeys[8] = 56
Numberkeys[9] = 57
Numberpad = {}
Numberpad[0] = 45
Numberpad[1] = 35
Numberpad[2] = 40
Numberpad[3] = 34
Numberpad[4] = 37
Numberpad[5] = 12
Numberpad[6] = 39
Numberpad[7] = 36
Numberpad[8] = 38
Numberpad[9] = 33
Letters = {}
Letters["A"] = 65
Letters["B"] = 66
Letters["C"] = 67
Letters["D"] = 68
Letters["E"] = 69
Letters["F"] = 70
Letters["G"] = 71
Letters["H"] = 72
Letters["I"] = 73
Letters["J"] = 74
Letters["K"] = 75
Letters["L"] = 76
Letters["M"] = 77
Letters["N"] = 78
Letters["O"] = 79
Letters["P"] = 80
Letters["Q"] = 81
Letters["R"] = 82
Letters["S"] = 83
Letters["T"] = 84
Letters["U"] = 85
Letters["V"] = 86
Letters["W"] = 87
Letters["X"] = 88
Letters["Y"] = 89
Letters["Z"] = 90
Fkeys = {}
Fkeys[1] = 112
Fkeys[2] = 113
Fkeys[3] = 114
Fkeys[4] = 115
Fkeys[5] = 116
Fkeys[6] = 117
Fkeys[7] = 118
Fkeys[8] = 119
Fkeys[9] = 120
Fkeys[10] = 121
Fkeys[11] = 122
Fkeys[12] = 123
Collon = 186
Equal = 187
Comma = 188
Underscore = 189
Dot = 190
Backslash = 191
Lb = 219
Rb = 221
Quote = 222
State = Win32API.new("user32","GetKeyState",['i'],'i')
Key = Win32API.new("user32","GetAsyncKeyState",['i'],'i')
#--------------------------------------------------------------------------
def Keyboard.clear
@pressed.clear
end
def Keyboard.getstate(key)
return true unless State.call(key).between?(0, 1)
return false
end
#--------------------------------------------------------------------------
def Keyboard.testkey(key)
Key.call(key) & 0x01 == 1
end
#--------------------------------------------------------------------------
def Keyboard.update
@keys = []
@keys.push(Keyboard::Mouse_Left) if Keyboard.testkey(Keyboard::Mouse_Left)
@keys.push(Keyboard::Mouse_Right) if Keyboard.testkey(Keyboard::Mouse_Right)
@keys.push(Keyboard::Back) if Keyboard.testkey(Keyboard::Back)
@keys.push(Keyboard::Tab) if Keyboard.testkey(Keyboard::Tab)
@keys.push(Keyboard::Enter) if Keyboard.testkey(Keyboard::Enter)
@keys.push(Keyboard::Shift) if Keyboard.testkey(Keyboard::Shift)
@keys.push(Keyboard::Ctrl) if Keyboard.testkey(Keyboard::Ctrl)
@keys.push(Keyboard::Alt) if Keyboard.testkey(Keyboard::Alt)
@keys.push(Keyboard::Esc) if Keyboard.testkey(Keyboard::Esc)
@keys.push(Keyboard::Space) if Keyboard.testkey(Keyboard::Space)
for key in Keyboard::Numberkeys.values
@keys.push(key) if Keyboard.testkey(key)
end
for key in Keyboard::Numberpad.values
@keys.push(key) if Keyboard.testkey(key)
end
for key in Keyboard::Letters.values
@keys.push(key) if Keyboard.testkey(key)
end
for key in Keyboard::Fkeys.values
@keys.push(key) if Keyboard.testkey(key)
end
@keys.push(Keyboard::Collon) if Keyboard.testkey(Keyboard::Collon)
@keys.push(Keyboard::Equal) if Keyboard.testkey(Keyboard::Equal)
@keys.push(Keyboard::Comma) if Keyboard.testkey(Keyboard::Comma)
@keys.push(Keyboard::Underscore) if Keyboard.testkey(Keyboard::Underscore)
@keys.push(Keyboard::Dot) if Keyboard.testkey(Keyboard::Dot)
@keys.push(Keyboard::Backslash) if Keyboard.testkey(Keyboard::Backslash)
@keys.push(Keyboard::Lb) if Keyboard.testkey(Keyboard::Lb)
@keys.push(Keyboard::Rb) if Keyboard.testkey(Keyboard::Rb)
@keys.push(Keyboard::Quote) if Keyboard.testkey(Keyboard::Quote)
@pressed = []
@pressed.push(Keyboard::Mouse_Left) if Keyboard.getstate(Keyboard::Mouse_Left)
@pressed.push(Keyboard::Mouse_Right) if Keyboard.getstate(Keyboard::Mouse_Right)
@pressed.push(Keyboard::Back) if Keyboard.getstate(Keyboard::Back)
@pressed.push(Keyboard::Tab) if Keyboard.getstate(Keyboard::Tab)
@pressed.push(Keyboard::Enter) if Keyboard.getstate(Keyboard::Enter)
@pressed.push(Keyboard::Shift) if Keyboard.getstate(Keyboard::Shift)
@pressed.push(Keyboard::Ctrl) if Keyboard.getstate(Keyboard::Ctrl)
@pressed.push(Keyboard::Alt) if Keyboard.getstate(Keyboard::Alt)
@pressed.push(Keyboard::Esc) if Keyboard.getstate(Keyboard::Esc)
@pressed.push(Keyboard::Space) if Keyboard.getstate(Keyboard::Space)
for key in Keyboard::Numberkeys.values
@pressed.push(key) if Keyboard.getstate(key)
end
for key in Keyboard::Numberpad.values
@pressed.push(key) if Keyboard.getstate(key)
end
for key in Keyboard::Letters.values
@pressed.push(key) if Keyboard.getstate(key)
end
for key in Keyboard::Fkeys.values
@pressed.push(key) if Keyboard.getstate(key)
end
@pressed.push(Keyboard::Collon) if Keyboard.getstate(Keyboard::Collon)
@pressed.push(Keyboard::Equal) if Keyboard.getstate(Keyboard::Equal)
@pressed.push(Keyboard::Comma) if Keyboard.getstate(Keyboard::Comma)
@pressed.push(Keyboard::Underscore) if Keyboard.getstate(Keyboard::Underscore)
@pressed.push(Keyboard::Dot) if Keyboard.getstate(Keyboard::Dot)
@pressed.push(Keyboard::Backslash) if Keyboard.getstate(Keyboard::Backslash)
@pressed.push(Keyboard::Lb) if Keyboard.getstate(Keyboard::Lb)
@pressed.push(Keyboard::Rb) if Keyboard.getstate(Keyboard::Rb)
@pressed.push(Keyboard::Quote) if Keyboard.getstate(Keyboard::Quote)
end
#--------------------------------------------------------------------------
def Keyboard.trigger?(key)
return true if @keys.include?(key)
return false
end
#--------------------------------------------------------------------------
def Keyboard.pressed?(key)
return true if @pressed.include?(key)
return false
end
end
#==============================================================================
# ** Bitmap
#==============================================================================
class Bitmap
#--------------------------------------------------------------------------
# * Scale Blt
#--------------------------------------------------------------------------
def scale_blt(dest_rect, src_bitmap,
src_rect = Rect.new(0, 0, src_bitmap.width, src_bitmap.height), opacity = 255)
w, h = src_rect.width, src_rect.height
scale = [w / dest_rect.width.to_f, h / dest_rect.height.to_f].max
ow, oh = (w / scale).to_i, (h / scale).to_i
ox, oy = (dest_rect.width - ow) / 2, (dest_rect.height - oh) / 2
stretch_blt(Rect.new(ox + dest_rect.x, oy + dest_rect.y, ow, oh),
src_bitmap, src_rect )
end
end
#==============================================================================
# ** Game_Party
#==============================================================================
class Game_Party
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :items
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias seph_individualactorcache_gameparty_item_number item_number
#--------------------------------------------------------------------------
# * Get Number of Items Possessed
# item_id : item ID
#--------------------------------------------------------------------------
def item_number(item_id)
# If In Battle, loads Active Battler Numbers
if $game_temp.in_battle
n = 0
for item in $scene.active_battler.item_cache
if item.id == item_id
n += 1
end
end
return n
else
# If quantity data is in the hash, use it. If not, return 0
return @items.include?(item_id) ? @items[item_id] : 0
end
end
end
#==============================================================================
# ** Game_Actor
#==============================================================================
class Game_Actor
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :item_cache
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias seph_individualactorcache_gameactor_setup setup
#--------------------------------------------------------------------------
# * Setup
#--------------------------------------------------------------------------
def setup(actor_id)
# Sets Item Cache
@item_cache = []
# Original Actor Setup Method
seph_individualactorcache_gameactor_setup(actor_id)
end
#--------------------------------------------------------------------------
# * Assign Item
# item_id : Items ID #
#--------------------------------------------------------------------------
def assign_item(item_id)
item = $data_items[item_id]
unless item.nil?
@item_cache << item
@item_cache.sort! {|a, b| a.id<=>b.id}
item_number = $game_party.items.include?(item_id) ? $game_party.items[item_id] : 0
$game_party.items[item_id] = [[item_number - 1, 0].max, 99].min
end
end
#--------------------------------------------------------------------------
# * Unassign Item
# item_id : Items ID #
#--------------------------------------------------------------------------
def unassign_item(item_id)
item = $data_items[item_id]
unless item.nil?
if @item_cache.include?(item)
use_item(item_id)
$game_party.gain_item(item_id, 1)
end
end
end
#--------------------------------------------------------------------------
# * Use Item
# item_id : Items ID #
#--------------------------------------------------------------------------
def use_item(item_id)
item = $data_items[item_id]
unless item.nil?
for i in 0...@item_cache.size
if item == @item_cache[i]
@item_cache.delete_at(i)
break
end
end
end
end
end
=begin
#==============================================================================
# ** Game_Actors
#==============================================================================
class Game_Actor
def item_can_use?(item_id)
for index in 0...actor.item_cache.size
if actor.item_cache[index].id == item_id then item_cache_id = index
else next
end
end
if item_cache_id = nil then return false ; end
# If item quantity is 0
if actor.item_cache.values_at(item_cache_id).to_s == 0
# Unusable
return false
end
# Get usable time
occasion = $data_items[item_id].occasion
# If in battle
if $game_temp.in_battle
# If useable time is 0 (normal) or 1 (only battle) it's usable
return (occasion == 0 or occasion == 1)
end
# If useable time is 0 (normal) or 2 (only menu) it's usable
return (occasion == 0 or occasion == 2)
end
end
=end
#==============================================================================
# ** Scene_Battle
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :active_battler
# Redefines the method that consumes items, instead taking from the actor.
def make_item_action_result
# Get item
@item = $data_items[@active_battler.current_action.item_id]
# If unable to use due to items running out
unless $game_party.item_can_use?(@item.id)
# Shift to step 1
@phase4_step = 1
return
end
# If consumable
if @item.consumable
# Stores ONE of the indices of the item being used.
index = @active_battler.item_cache.index(@item)
# Turns that item into nil...
@active_battler.item_cache[index] = nil
# Cuts the nil out of the inventory. This way, you only lose one item
# And not the whole stack.
@active_battler.item_cache.compact!
end
# Display item name on help window
@help_window.set_text(@item.name, 1)
# Set animation ID
@animation1_id = @item.animation1_id
@animation2_id = @item.animation2_id
# Set common event ID
@common_event_id = @item.common_event_id
# Decide on target
index = @active_battler.current_action.target_index
target = $game_party.smooth_target_actor(index)
# Set targeted battlers
set_target_battlers(@item.scope)
# Apply item effect
for target in @target_battlers
target.item_effect(@item)
end
end
end
#==============================================================================
# ** Window_Item
#==============================================================================
class Window_Item < Window_Selectable
# Redefines initialize, allowing specification of the window size and position
def initialize(x=0, y=64, wid=640, hei=416)
super(x, y, wid, hei)
@column_max = 2
refresh
self.index = 0
# If in battle, move window to center of screen
# and make it semi-transparent
if $game_temp.in_battle
self.y = 64
self.height = 256
self.back_opacity = 160
end
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# For Out Of Battle Use
unless $game_temp.in_battle
# Add item
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
@data.push($data_items[i])
end
end
# Adds In Actor Item Cache
for actor in $game_party.actors
for item in actor.item_cache
@data << item unless @data.include?(item)
end
end
# Also add weapons and items if outside of battle
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0
@data.push($data_weapons[i])
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0
@data.push($data_armors[i])
end
end
# For In Battle Use
else
for item in $scene.active_battler.item_cache
@data << item
end
end
# If item count is not 0, make a bit map and draw all items
@item_max = @data.uniq.size
@data.uniq!
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
end
#==============================================================================
# ** Window_ItemCacheHeading
#==============================================================================
class Window_ItemCacheHeading < Window_Base
#--------------------------------------------------------------------------
# * Constant
#--------------------------------------------------------------------------
DRAW_CHARACTER = true
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(actor_index)
super(actor_index * 160, 64, 160, 160)
self.contents = Bitmap.new(width - 32, height - 32)
@frame = 0
refresh(@actor = $game_party.actors[actor_index])
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh(actor = @actor)
self.contents.clear
@actor = actor
return if @actor.nil?
# Draws Actors Name
self.contents.draw_text(4, 0, contents.width - 8, 32, @actor.name, 1)
# Draws Actors Sprite
if DRAW_CHARACTER
draw_sprite(0, 32, 128, 96, @actor.character_name, @actor.character_hue, 0, @frame)
else
bitmap = RPG::Cache.battler(@actor.battler_name, @actor.battler_hue)
self.contents.scale_blt(Rect.new(0, 32, 128, 96), bitmap)
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
# If Character Sprite
if DRAW_CHARACTER
if Graphics.frame_count % 10 == 0
@frame == 3 ? @frame = 0 : @frame += 1
refresh
end
end
end
#--------------------------------------------------------------------------
# * Draw Sprite
#--------------------------------------------------------------------------
def draw_sprite(x, y, w, h, name, hue, stance, frame)
# Gets Bitmap
bitmap = RPG::Cache.character(name, hue)
# Bitmap Division
cw, ch = bitmap.width / 4, bitmap.height / 4
# Gets Animation Offsets
x_off, y_off = cw * frame, ch * stance
# Draws Bitmap
self.contents.scale_blt(Rect.new(x, y, w, h), bitmap, Rect.new(x_off, y_off, cw, ch))
end
end
#==============================================================================
# ** Window_ItemCache
#==============================================================================
class Window_ItemCache < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(actor_index)
super(actor_index * 160, 224, 160, 5 * 32)
@actor = $game_party.actors[actor_index]
refresh
self.index = 0
self.active = false
end
#--------------------------------------------------------------------------
# * Get Item
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# Adds In Actor Item Cache
@actor.item_cache.sort! {|a, b| a.id<=>b.id}
for item in @actor.item_cache
@data << item
end
# If item count is not 0, make a bit map and draw all items
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
item, y = @data[index], index * 32
bitmap = RPG::Cache.icon(item.icon_name)
self.contents.blt(0, y + 4, bitmap, Rect.new(0, 0, 24, 24))
self.contents.draw_text(32, y, 212, 32, item.name)
end
end
#==============================================================================
# ** Scene_ActorCache
#==============================================================================
class Scene_Item
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
@help_window = Window_Help.new
@help_window.set_text('Select Item To Unassign', 1)
# Create the item window, and fit it to the remaining portion of the screen
@item_window = Window_Item.new(0, 224 + 5*32, 640, 480 - 64 - 160 - (5*32))
@item_window.active = true
@item_window.help_window = @help_window
# Make target window (set to invisible / inactive)
@target_window = Window_Target.new
@target_window.visible = false
@target_window.active = false
@scene_objects = [@help_window, @item_window, @target_window]
# Creates a new array to store the actor inventories in
@cache_objects = []
for i in 0..3
eval "@actor_#{i}_heading = Window_ItemCacheHeading.new(#{i})"
eval "@scene_objects << @actor_#{i}_heading"
eval "@actor_#{i}_cache = Window_ItemCache.new(#{i})"
eval "@scene_objects << @actor_#{i}_cache"
eval "@cache_objects << @actor_#{i}_cache"
end
@actor_0_cache.active = false
@actor_index = 0
# Execute transition
Graphics.transition
# Main loop
while $scene == self
# Update game screen
Graphics.update
# Update input information
Input.update
# Updates Scene Objects
@scene_objects.each {|x| x.update}
# Frame update
update
end
# Prepare for transition
Graphics.freeze
# Dispose Scene Objects
@scene_objects.each {|x| x.dispose}
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
active_cache = @cache_objects.collect {|ob| ob.active == true}
if active_cache.include?(true) then @help_window.set_text('Select Item To Unassign', 1) ; end
keyboard
# If target window is active: call update_target
if @target_window.active
update_target
return
end
# If B button is 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
end
# Only carry out these commands if the item window is NOT active,
unless @item_window.active == true
# If C button is pressed
if Input.trigger?(Input::C)
item = eval "@actor_#{@actor_index}_cache.item"
if item.nil?
# Plays Buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Plays Decision SE
$game_system.se_play($data_system.decision_se)
# Usassins Item
$game_party.actors[@actor_index].unassign_item(item.id)
@item_window.refresh
# Refreshes Window
eval "@actor_#{@actor_index}_cache.refresh"
end
# If Left or Right Buttons Are Pressed
if Input.trigger?(Input::LEFT)
# Plays Cursor SE
$game_system.se_play($data_system.cursor_se)
# Deativates Current Window
eval "@actor_#{@actor_index}_cache.active = false"
# Changes Window Index
@actor_index == 0 ? @actor_index = 3 : @actor_index -= 1
# Actives New Window
eval "@actor_#{@actor_index}_cache.active = true"
elsif Input.trigger?(Input::RIGHT)
# Plays Cursor SE
$game_system.se_play($data_system.cursor_se)
# Deativates Current Window
eval "@actor_#{@actor_index}_cache.active = false"
# Changes Window Index
@actor_index == 3 ? @actor_index = 0 : @actor_index += 1
# Actives New Window
eval "@actor_#{@actor_index}_cache.active = true"
end
end
# if the L button is pressed
if Input.trigger?(Input::A)
# determine whether any of the actor item windows are active
active = @cache_objects.collect do |object|
eval "object.active == true"
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Swap the control of the windows
if @item_window.active == true then @item_window.active = false
elsif @item_window.active == false then @item_window.active = true
end
# If the active window is any of the caches, make it inactive. Swap the activity.
if active.include?(true) then @cache_objects.each {|obj| obj.active = false}
elsif !active.include?(true) then eval "@actor_#{@actor_index}_cache.active = true"
if active.include?(true) then @transfers = nil ; end
end
end
# Only accept these commands if the active window is the item window
if @item_window.active == true
@transfers = true
# 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
# If not a use item
unless @item.is_a?(RPG::Item)
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# If it can't be used
unless $game_party.item_can_use?(@item.id)
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# 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
def keyboard
# Updates Near's Keyboard Module
Keyboard.update
# Assign To Player 1
if Keyboard.trigger?(Keyboard::Numberkeys[1])
window = @item_window.active == true
# If Actor is nil
if $game_party.actors[0].nil?
$game_system.se_play($data_system.buzzer_se) if window
return
end
if $game_party.item_number(@item_window.item.id) < 1
$game_system.se_play($data_system.buzzer_se) if window
@item_window.refresh
return
end
# Plays Decison SE
$game_system.se_play($data_system.decision_se) if window
# Assigns Item
$game_party.actors[0].assign_item(@item_window.item.id) if window
@actor_0_cache.refresh
# Refreshs Window
@item_window.refresh
end
# Assign To Player 2
if Keyboard.trigger?(Keyboard::Numberkeys[2])
window = @item_window.active == true
# If Actor is nil
if $game_party.actors[1].nil?
$game_system.se_play($data_system.buzzer_se) if window
return
end
if $game_party.item_number(@item_window.item.id) < 1
$game_system.se_play($data_system.buzzer_se) if window
@item_window.refresh
return
end
# Plays Decison SE
$game_system.se_play($data_system.decision_se) if window
# Assigns Item
$game_party.actors[1].assign_item(@item_window.item.id) if window
@actor_1_cache.refresh
# Refreshs Window
@item_window.refresh
end
# Assign To Player 3
if Keyboard.trigger?(Keyboard::Numberkeys[3])
window = @item_window.active == true
# If Actor is nil
if $game_party.actors[2].nil?
$game_system.se_play($data_system.buzzer_se) if window
return
end
if $game_party.item_number(@item_window.item.id) < 1
$game_system.se_play($data_system.buzzer_se) if window
@item_window.refresh
return
end
# Plays Decison SE
$game_system.se_play($data_system.decision_se) if window
# Assigns Item
$game_party.actors[2].assign_item(@item_window.item.id) if window
@actor_2_cache.refresh
# Refreshs Window
@item_window.refresh
end
# Assign To Player 4
if Keyboard.trigger?(Keyboard::Numberkeys[4])
window = @item_window.active == true
# If Actor is nil
if $game_party.actors[3].nil?
$game_system.se_play($data_system.buzzer_se) if window
return
end
if $game_party.item_number(@item_window.item.id) < 1
$game_system.se_play($data_system.buzzer_se) if window
@item_window.refresh
return
end
# Plays Decison SE
$game_system.se_play($data_system.decision_se) if window
# Assigns Item
$game_party.actors[3].assign_item(@item_window.item.id) if window
@actor_3_cache.refresh
# Refreshs Window
@item_window.refresh
end
end
#--------------------------------------------------------------------------
# * Frame Update (when target window is active)
#--------------------------------------------------------------------------
def update_target
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# If unable to use because items ran out
unless $game_party.item_can_use?(@item.id)
# Remake item window contents
@item_window.refresh
end
# Erase target window
@item_window.active = true
@target_window.visible = false
@target_window.active = false
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# If items are used up
if $game_party.item_number(@item.id) == 0
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# If target is all
if @target_window.index == -1
# Apply item effects to entire party
used = false
for i in $game_party.actors
used |= i.item_effect(@item)
end
end
# If single target
if @target_window.index >= 0
# Apply item use effects to target actor
target = $game_party.actors[@target_window.index]
used = target.item_effect(@item)
end
# If an item was used
if used
# 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)
# Redraw item window item
@item_window.draw_item(@item_window.index)
end
# Remake target window contents
@target_window.refresh
# If all party members are dead
if $game_party.all_dead?
# Switch to game over screen
$scene = Scene_Gameover.new
return
end
# If common event ID is valid
if @item.common_event_id > 0
# Common event call reservation
$game_temp.common_event_id = @item.common_event_id
# Switch to map screen
$scene = Scene_Map.new
return
end
end
# If item wasn't used
unless used
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
end
#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
#end