(I need help, this is no longer a request.... Unless you want it to be and can fix this! :P)
Script RequestThis is a request for a combination of 2 existing scripts.
Script Title:Separate Item Bags
RMXP or RMVX:This is for XP
Detailed Description:Let me explain. Right now, the script I am using is set up to go to the item menu. You assign items with the 1, 2, 3 and 4 keys. You press shift to enter the item bags of the actors. In this scene, you can see who has what and unassign items.
What I want is the party's item menu underneath it. I want everything to be done in 1 scene. If you are in the actors selection items then you have to press b or escape to get back to the party items menu (which would be on the bottom of that), you do all of the assigning in the party items menu and you will see it updating as you are doing it. I would also like to be able to assign a max items for each actor if possible which would show under their picture. I hope I am clear with my explanation.
Screen shots:Right now the item script I am using looks like this
(http://img.photobucket.com/albums/v312/Yinyamina/ItemAssignment.jpg)
I want it to look like this
(http://img.photobucket.com/albums/v312/Yinyamina/ItemAssignment2.jpg)
(I did this with paint)
The script Here is the script I need combined with the regular item menu.
#==============================================================================
# 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.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
#==============================================================================
# ** Scene_Battle
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :active_battler
end
#==============================================================================
# ** Window_Item
#==============================================================================
class Window_Item < Window_Selectable
#--------------------------------------------------------------------------
# * 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.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
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, 256)
@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_ItemCache
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
@help_window = Window_Help.new
@help_window.set_text('Select Item To Unassign', 1)
@scene_objects = [@help_window]
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"
end
@actor_0_cache.active = true
@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
# 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
# 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)
# 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
# If A button is pressed
if Input.trigger?(Input::A)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to Item Cache screen
$scene = Scene_Item.new
return
end
end
end
#==============================================================================
# ** Scene_Item
#==============================================================================
class Scene_Item
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias seph_individualactorcache_sceneitem_update update
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Updates Near's Keyboard Module
Keyboard.update
# Assign To Player 1
if Keyboard.trigger?(Keyboard::Numberkeys[1])
# If Actor is nil
if $game_party.actors[0].nil?
$game_system.se_play($data_system.buzzer_se)
return
end
# Plays Decison SE
$game_system.se_play($data_system.decision_se)
# Assigns Item
$game_party.actors[0].assign_item(@item_window.item.id)
# Refreshs Window
@item_window.refresh
end
# Assign To Player 2
if Keyboard.trigger?(Keyboard::Numberkeys[2])
# If Actor is nil
if $game_party.actors[1].nil?
$game_system.se_play($data_system.buzzer_se)
return
end
# Plays Decison SE
$game_system.se_play($data_system.decision_se)
# Assigns Item
$game_party.actors[1].assign_item(@item_window.item.id)
# Refreshs Window
@item_window.refresh
end
# Assign To Player 3
if Keyboard.trigger?(Keyboard::Numberkeys[3])
# If Actor is nil
if $game_party.actors[2].nil?
$game_system.se_play($data_system.buzzer_se)
return
end
# Plays Decison SE
$game_system.se_play($data_system.decision_se)
# Assigns Item
$game_party.actors[2].assign_item(@item_window.item.id)
# Refreshs Window
@item_window.refresh
end
# Assign To Player 4
if Keyboard.trigger?(Keyboard::Numberkeys[4])
# If Actor is nil
if $game_party.actors[3].nil?
$game_system.se_play($data_system.buzzer_se)
return
end
# Plays Decison SE
$game_system.se_play($data_system.decision_se)
# Assigns Item
$game_party.actors[3].assign_item(@item_window.item.id)
# Refreshs Window
@item_window.refresh
end
# If A button is pressed
if Input.trigger?(Input::A)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to item screen
$scene = Scene_ItemCache.new
end
# Orginal Update Method
seph_individualactorcache_sceneitem_update
end
end
#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end
It is made by SephirothSpawn
If you have any specific questions, please don't hesitate to ask me. Thank you to anyone who is able and willing to complete this task.
Just to let you know this script is bugged. You can assign items you dont even have and it also keeps items in there display 0....this script is messed up and should be fixed before anything.
Really? :( I liked the 0 display, but only if it's assigned to someone and not when it's completely not even in the party's inventory. I will try to see what's up with this, thanks for pointing these things out, but I'm no scripter, if anyone is willing to try to fix these thing, then I would appreciate that. Or if anyone can direct me to something like it that maybe has the features requested? Thank you to anyone who is willing and able to help.
Yea press 1 on the 0 display thing and it'll keep adding the item to hero 1.
Yeah I didn't try "over adding" until you mentioned it and I noticed it. Don't I just need to put somewhere add item unless it equals 0 or something like that?
bump?
I fixed it a little! I only need it to show up correctly and be consumed in battle.
#==============================================================================
# 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.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
#==============================================================================
# ** Scene_Battle
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :active_battler
end
#==============================================================================
# ** Window_Item
#==============================================================================
class Window_Item < Window_Selectable
#--------------------------------------------------------------------------
# * 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.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
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, 256)
@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_ItemCache
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
@help_window = Window_Help.new
@help_window.set_text('Select Item To Unassign', 1)
@scene_objects = [@help_window]
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"
end
@actor_0_cache.active = true
@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
# 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
# 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)
# 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
# If A button is pressed
if Input.trigger?(Input::A)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to Item Cache screen
$scene = Scene_Item.new
return
end
end
end
#==============================================================================
# ** Scene_Item
#==============================================================================
class Scene_Item
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias seph_individualactorcache_sceneitem_update update
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Updates Near's Keyboard Module
Keyboard.update
# Assign To Player 1
if Keyboard.trigger?(Keyboard::Numberkeys[1])
# If Actor is nil
if $game_party.actors[0].nil?
$game_system.se_play($data_system.buzzer_se)
return
end
if $game_party.item_number(@item_window.item.id) < 1
$game_system.se_play($data_system.buzzer_se)
@item_window.refresh
return
end
# Plays Decison SE
$game_system.se_play($data_system.decision_se)
# Assigns Item
$game_party.actors[0].assign_item(@item_window.item.id)
# Refreshs Window
@item_window.refresh
end
# Assign To Player 2
if Keyboard.trigger?(Keyboard::Numberkeys[2])
# If Actor is nil
if $game_party.actors[1].nil?
$game_system.se_play($data_system.buzzer_se)
return
end
if $game_party.item_number(@item_window.item.id) < 1
$game_system.se_play($data_system.buzzer_se)
@item_window.refresh
return
end
# Plays Decison SE
$game_system.se_play($data_system.decision_se)
# Assigns Item
$game_party.actors[1].assign_item(@item_window.item.id)
# Refreshs Window
@item_window.refresh
end
# Assign To Player 3
if Keyboard.trigger?(Keyboard::Numberkeys[3])
# If Actor is nil
if $game_party.actors[2].nil?
$game_system.se_play($data_system.buzzer_se)
return
end
if $game_party.item_number(@item_window.item.id) < 1
$game_system.se_play($data_system.buzzer_se)
@item_window.refresh
return
end
# Plays Decison SE
$game_system.se_play($data_system.decision_se)
# Assigns Item
$game_party.actors[2].assign_item(@item_window.item.id)
# Refreshs Window
@item_window.refresh
end
# Assign To Player 4
if Keyboard.trigger?(Keyboard::Numberkeys[4])
# If Actor is nil
if $game_party.actors[3].nil?
$game_system.se_play($data_system.buzzer_se)
return
end
if $game_party.item_number(@item_window.item.id) < 1
$game_system.se_play($data_system.buzzer_se)
@item_window.refresh
return
end
# Plays Decison SE
$game_system.se_play($data_system.decision_se)
# Assigns Item
$game_party.actors[3].assign_item(@item_window.item.id)
# Refreshs Window
@item_window.refresh
end
# If A button is pressed
if Input.trigger?(Input::A)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to item screen
$scene = Scene_ItemCache.new
end
# Orginal Update Method
seph_individualactorcache_sceneitem_update
end
end
#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
#end
I fixed the fact that when you are adding items, it won't over add in the menu. But in battle something is wrong and I don't know what to edit. I guess this is more of support than a request now. If anyone can help, thank you.
This is what I mean.
(http://img.photobucket.com/albums/v312/Yinyamina/SameItemsshowup.jpg)
Why do the items show up like that? Notice I have 2 Potions and it's there twice. And when I use them they are never consumed.
bump?
Do you need SDK to make this work?
Let me know and I'll try. I'm almost positive that I can figure this out. It'll just take me some time.
EDIT: Messing with it. I'm pretty sure that I can fix this. Just give me some time.
Also, how do you select which item to add to the actor's inventory? I place the cursor over the item, then go into the cache and press the button, but it always adds the first item.
I just commented the sdk because I'm not using it. If you can figure this out, that would be great.
Quote from: Yin on June 16, 2009, 06:46:22 pm
I just commented the sdk because I'm not using it. If you can figure this out, that would be great.
Ok, I figured out adding items.
Don't worry, Yin. I'll fix it. That's a definite.
So you want me to combine the two scenes, and fix the items's showing up in battle and consumption?
I have NO LIFE, XD, and I am pretty much working on scripting ALL DAY. I LOOOOVE this stuff, and I'm trying my best to learn it to the greatest of my ability. I've come pretty far. Point being, I can work on this all day for the next several days. With any luck, should be done anytime between today and the next two or three. Sorry for the wait ><
^_^
EDIT:
Ok Yin, I think I just figured out why it's drawing multiple entries of the same item. Very simple mistake, really. Just trying to come up with a solution. I tried some different numbers of items, and if you'll notice, it draws the item the amount of times that the item exists in that actors cache.
Meaning, in your screenie, you have two potions. Potion shows up twice. If you had twelve, it would show up twelve times.
EDIT AGAIN:
I was right. I've also just fixed that problem. That was fairly easy. I only had to add five letters, too, XD.
Next up is item consumption, which is still occurring. Then, I have to combine the scenes, which'll take a little while.
ANOTHER EDIT (XD):
Think I just figured out why items aren't being consumed. It's because they're not being consumed.
Seriously, I don't think that the script tells the game to take the item from the user's cache, OR the inventory. After the battle, both numbers remain unchanged. Point being, the number display works fine. It's just not using them. Working on it now.
EDIT:
Ok, that part took WAAAAAY longer, but I fixed it (as far as I know.) I've been testing as I go along, and haven't hit any bumps.
Editing the scene now. It's gonna take a while. That picture REALLY helps, though. ^_^
EDIT:
Very nearly done, just have to make the item window display changes to itself as they happen in the new scene, then test the whole system for bugs.
If you can, please let me know whether you want to be able to assign items the old way as well. That's how it's configured atm. You can still go in and "speed assign."
You can still use items like normal. Just push shift, or the A button (configured for A. Shift is default.), just like normal, and 'Q' to toggle between the item menu and the actor's menu. Again, nearly done.
EDIT:
Ok, Yin. I MAY be wrong, but I think that this is what you're wanting:
#==============================================================================
# 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.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
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
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_ItemCache
#--------------------------------------------------------------------------
# * 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 = false
@scene_objects = [@help_window, @item_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 = true
@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
# 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 A button is pressed
if Input.trigger?(Input::A)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to Item Cache screen
$scene = Scene_Item.new
return
end
# if the L button is pressed
if Input.trigger?(Input::L)
# 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"
end
end
# Only accept these commands if the active window is the item window
if @item_window.active == true
# Updates Near's Keyboard Module
Keyboard.update
# Assign To Player 1
if Keyboard.trigger?(Keyboard::Numberkeys[1])
# If Actor is nil
if $game_party.actors[0].nil?
$game_system.se_play($data_system.buzzer_se)
return
end
if $game_party.item_number(@item_window.item.id) < 1
$game_system.se_play($data_system.buzzer_se)
@item_window.refresh
return
end
# Plays Decison SE
$game_system.se_play($data_system.decision_se)
# Assigns Item
$game_party.actors[0].assign_item(@item_window.item.id)
@actor_0_cache.refresh
# Refreshs Window
@item_window.refresh
end
# Assign To Player 2
if Keyboard.trigger?(Keyboard::Numberkeys[2])
# If Actor is nil
if $game_party.actors[1].nil?
$game_system.se_play($data_system.buzzer_se)
return
end
if $game_party.item_number(@item_window.item.id) < 1
$game_system.se_play($data_system.buzzer_se)
@item_window.refresh
return
end
# Plays Decison SE
$game_system.se_play($data_system.decision_se)
# Assigns Item
$game_party.actors[1].assign_item(@item_window.item.id)
@actor_1_cache.refresh
# Refreshs Window
@item_window.refresh
end
# Assign To Player 3
if Keyboard.trigger?(Keyboard::Numberkeys[3])
# If Actor is nil
if $game_party.actors[2].nil?
$game_system.se_play($data_system.buzzer_se)
return
end
if $game_party.item_number(@item_window.item.id) < 1
$game_system.se_play($data_system.buzzer_se)
@item_window.refresh
return
end
# Plays Decison SE
$game_system.se_play($data_system.decision_se)
# Assigns Item
$game_party.actors[2].assign_item(@item_window.item.id)
@actor_2_cache.refresh
# Refreshs Window
@item_window.refresh
end
# Assign To Player 4
if Keyboard.trigger?(Keyboard::Numberkeys[4])
# If Actor is nil
if $game_party.actors[3].nil?
$game_system.se_play($data_system.buzzer_se)
return
end
if $game_party.item_number(@item_window.item.id) < 1
$game_system.se_play($data_system.buzzer_se)
@item_window.refresh
return
end
# Plays Decison SE
$game_system.se_play($data_system.decision_se)
# Assigns Item
$game_party.actors[3].assign_item(@item_window.item.id)
@actor_3_cache.refresh
# Refreshs Window
@item_window.refresh
end
end
end
end
#==============================================================================
# ** Scene_Item
#==============================================================================
class Scene_Item
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias seph_individualactorcache_sceneitem_update update
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Updates Near's Keyboard Module
Keyboard.update
# Assign To Player 1
if Keyboard.trigger?(Keyboard::Numberkeys[1])
# If Actor is nil
if $game_party.actors[0].nil?
$game_system.se_play($data_system.buzzer_se)
return
end
if $game_party.item_number(@item_window.item.id) < 1
$game_system.se_play($data_system.buzzer_se)
@item_window.refresh
return
end
# Plays Decison SE
$game_system.se_play($data_system.decision_se)
# Assigns Item
$game_party.actors[0].assign_item(@item_window.item.id)
# Refreshs Window
@item_window.refresh
end
# Assign To Player 2
if Keyboard.trigger?(Keyboard::Numberkeys[2])
# If Actor is nil
if $game_party.actors[1].nil?
$game_system.se_play($data_system.buzzer_se)
return
end
if $game_party.item_number(@item_window.item.id) < 1
$game_system.se_play($data_system.buzzer_se)
@item_window.refresh
return
end
# Plays Decison SE
$game_system.se_play($data_system.decision_se)
# Assigns Item
$game_party.actors[1].assign_item(@item_window.item.id)
# Refreshs Window
@item_window.refresh
end
# Assign To Player 3
if Keyboard.trigger?(Keyboard::Numberkeys[3])
# If Actor is nil
if $game_party.actors[2].nil?
$game_system.se_play($data_system.buzzer_se)
return
end
if $game_party.item_number(@item_window.item.id) < 1
$game_system.se_play($data_system.buzzer_se)
@item_window.refresh
return
end
# Plays Decison SE
$game_system.se_play($data_system.decision_se)
# Assigns Item
$game_party.actors[2].assign_item(@item_window.item.id)
# Refreshs Window
@item_window.refresh
end
# Assign To Player 4
if Keyboard.trigger?(Keyboard::Numberkeys[4])
# If Actor is nil
if $game_party.actors[3].nil?
$game_system.se_play($data_system.buzzer_se)
return
end
if $game_party.item_number(@item_window.item.id) < 1
$game_system.se_play($data_system.buzzer_se)
@item_window.refresh
return
end
# Plays Decison SE
$game_system.se_play($data_system.decision_se)
# Assigns Item
$game_party.actors[3].assign_item(@item_window.item.id)
# Refreshs Window
@item_window.refresh
end
# If A button is pressed
if Input.trigger?(Input::A)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to item screen
$scene = Scene_ItemCache.new
end
# Orginal Update Method
seph_individualactorcache_sceneitem_update
end
end
#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
#end
Just replace what you had SAVE A COPY OF THE OLD VERSION, just in case you want me to make any changes, so that I have a "backup".
Well, wait....there's already one in your earlier post.
Ok then, just replace what you had. That should work just fine. I tested it myself.
When you are in the Scene that lets you assign items to the characters, press Q to toggle between the item window and the character window. Once you're on the item window, you can press the numbers to assign. You can still assign things the old way, as a "speed method", just in case you need/want the option.
Please tell me if you have any problems, or want anything else. That was actually really fun, and I learned a lot. Thanks, Yin ^_^.
And, btw, you're officially my first script help-ee.
^_^
OK, I've been trying to say thank you since this.
-
ANOTHER EDIT (XD):
Think I just figured out why items aren't being consumed. It's because they're not being consumed.
Seriously, I don't think that the script tells the game to take the item from the user's cache, OR the inventory. After the battle, both numbers remain unchanged. Point being, the number display works fine. It's just not using them. Working on it now.
-
My internet has been acting like a bitch. So hopefully this post goes through.
Thank YOU! You are getting done in a few seconds what I couldn't even figure out in weeks.
Quote from: Yin on June 16, 2009, 10:08:29 pm
OK, I've been trying to say thank you since this.
-
ANOTHER EDIT (XD):
Think I just figured out why items aren't being consumed. It's because they're not being consumed.
Seriously, I don't think that the script tells the game to take the item from the user's cache, OR the inventory. After the battle, both numbers remain unchanged. Point being, the number display works fine. It's just not using them. Working on it now.
-
My internet has been acting like a bitch. So hopefully this post goes through.
Thank YOU! You are getting done in a few seconds what I couldn't even figure out in weeks.
Yes, that got through. It's ABOSLUTELY no problem at all. It gave me something to do, taught me a good bit, and allowed me to help someone out ^_^.
If you have anything else, just drop me a line.
Please remember to test it and see if it works to your specifications. If not, tell me, and I'll fix it. Now that I know my way around the script, and have layed framework, it shouldn't take long to fix any potential problems.
I'll test it out now, and I'm glad to have helped you and get help at the same time lol.
Works perfectly when in a new project, but in mine, I get a no method error for nil class on line 571. Line 571 is
@actor.item_cache.sort! {|a, b| a.id<=>b.id}
Maybe it's just not compatible with my setup. :'(
I'll see what I can do to fix it.
Quote from: Yin on June 16, 2009, 10:29:05 pm
I'll test it out now, and I'm glad to have helped you and get help at the same time lol.
^_^
Just lemme know when you're done. Again, if you need anything fixed, or would like anything added, lemme know. It's no trouble at all ^_^
Lol, I editted my post while you was writing that.
Quote from: Yin on June 16, 2009, 10:55:10 pm
Lol, I editted my post while you was writing that.
XD
Ok, I'm not entirely sure on this one, so I'll need one of two things:
1. Is there any way that you can PM me a link to your project? That would be optimal.
If you don't want to do that, then I need several questions answered, which STILL may not be enough. One is Sure-Fire.
2. How many actors are in the party? Which scripts do you have included in your game, and what are they? (IE CMS, CBS, Fishing system, etc). When are you receiving the error? Instantly? When you try to add items? When you add 1,337 items?
The more info the better ^_^
Not sure how much you know about scripting, but your game is pretty much saying that the method sort! (or id), which works on arrays, doesn't work on nil. What that means is that either item_cache, @actor, a, or b is nil, for some reason.
Curious.
Especially since I didn't add that line. Meaning it was already there. Meaning, if that worked BEFORE my edit, something that I did is returning nil.
Again, if you can send me your project, then I can probably fix it within 10 mins-1 hr.
Beyond that, how was it in the new project? Was it what you needed/wanted?
In the new project it was perfect! Do you mind if I have that demo tomorrow, I took nyquil and it's starting to kick in. :>.<:
Quote from: Yin on June 16, 2009, 11:20:23 pm
In the new project it was perfect! Do you mind if I have that demo tomorrow, I took nyquil and it's starting to kick in. :>.<:
XD, if anyone should have to ask about putting it off, it should be me. (You're the one having it done, so you don't have to ask.)
Sure, upload it at your leisure, and I'll check it. ^_^
G'night.
OK! I'm up! It's 7:43 lol. That nyquil had me out cold. I'll put the demo up in a bit.
I've been doing process of elimination, and I know it is not the battle system that is causing the problem. When I get to the source, I'll post it because if I put it in a demo, it's gonna be like 400 mb lol. So, yeah... I'll send it when I find out what's causing this.
Quote from: Yin on June 17, 2009, 07:43:53 pm
OK! I'm up! It's 7:43 lol. That nyquil had me out cold. I'll put the demo up in a bit.
I've been doing process of elimination, and I know it is not the battle system that is causing the problem. When I get to the source, I'll post it because if I put it in a demo, it's gonna be like 400 mb lol. So, yeah... I'll send it when I find out what's causing this.
Thank you, and thank you for doing that part for me.
7:43?!?!?!
AM?!?!?
It's 8ish PM over here.
7:43 PM lol
OK, as I was playing with it some more, I realized that I can assign items even when in the item cache it won't update until you press q though. And I'm trying to make this my item screen so, I removed the other scene item, but now I can't figure out how to make them use the item from the menu.
Ok, Let me go back and fix it then. Didn't know that you ONLY wanted that item menu.
I know how to let you use items from that screen, easy. Just wait up. The update thing is strange....it updated automatically for me.
WAIT! When you push shift to go to the cache, you have to press Q, which will switch your control to the item menu at the bottom. I can make that a different key, if you want (I'll set it to shift, since the normal item scene won't exist.) THEN you push the number keys over whatever item you want, and it SHOULD instantly fill up the cache.
Ok, getting to work now.
Still getting that error?
Yeah, I'm still eliminating things from the list going by most probable to least probable to be causing the problem.
And I mean as soon as you go into the cache menu nobody has any items, but there's items in the party's item section. I can press 1,2,3,4 while still in the cache section and it will add the first item on the list until it can't add anymore then the next until there's no more. I can do that while I'm not even in the party item section and it doesn't update until you press q to switch windows.
Quote from: Yin on June 17, 2009, 10:40:05 pm
Yeah, I'm still eliminating things from the list going by most probable to least probable to be causing the problem.
And I mean as soon as you go into the cache menu nobody has any items, but there's items in the party's item section. I can press 1,2,3,4 while still in the cache section and it will add the first item on the list until it can't add anymore then the next until there's no more. I can do that while I'm not even in the party item section and it doesn't update until you press q to switch windows.
Gotta be a conflicting script problem. On a new project, it works fine. Is there any way that you can make a copy of your project, and then delete ALL music and pictures on that project to "slim it down", then send it to me? I can guarantee you that there's a really good chance of my succeeding if you can do that.
EDIT: So I take it you want to select "items" on the menu and go straight to this?
I'd send my scripts.rxdata, but then if you tried to play it, you'd get all types of missing graphics errors. if you want to work on it JUST by looking at the scripts that I have and not playing at all, then I can just send that, but then how would you know if it works? lol
Quote from: Yin on June 17, 2009, 10:47:37 pm
I'd send my scripts.rxdata, but then if you tried to play it, you'd get all types of missing graphics errors. if you want to work on it JUST by looking at the scripts that I have and not playing at all, then I can just send that, but then how would you know if it works? lol
Gotta be a way....
Try to figure out which one it is. I guess that the best/only way is to find the conflicting script. And also, try to figure out which one is preventing you from adding items from the item window at the bottom.
Thanks ^_^
EDIT: Are you SURE that when you open the cache, you're pressing Q FIRST, THEN pushing numbers to assign items? I tried assigning, then Q, and it did exactly what you say is the problem. You know, I just went into it and pressed 11111, then Q, and the first actor got 5 potions. Try reversing it.
I can add items perfectly fine, but I am able to do it even when I am not in the item window (the one on the bottom).
Well, that's odd, I just removed all the scripts and put them back in 1 by 1 and no more error... :???:
Same order and everything. I'm puzzled. :wacko:
EDIT: Just read your edit. Yeah that's what is happening. I can go in and just press 1111 and it will add items. It just won't update until you press q. I should not be able to add items from there. Only unassign.
Oh, and OOOOOne more thing! :^_^': I know, I know, I'm probably just bugging you now. When the item window is active, can you make it display the description in the help window instead of unassign item?
Just read your other edit.
Yeah, I already got it to go straight to the item cache screen. I just renamed it scene_item.
Quote from: Yin on June 17, 2009, 11:15:04 pm
I can add items perfectly fine, but I am able to do it even when I am not in the item window (the one on the bottom).
Well, that's odd, I just removed all the scripts and put them back in 1 by 1 and no more error... :???:
Same order and everything. I'm puzzled. :wacko:
EDIT: Just read your edit. Yeah that's what is happening. I can go in and just press 1111 and it will add items. It just won't update until you press q. I should not be able to add items from there. Only unassign.
But, if you push Q
first, then push numbers, will it AUTOMATICALLY cache them?
I just overwrote Scene_Item. Working on it, no worries ^_^.
I'm glad that there's no error anymore...makes it MUCH easier to deal with.
Go ahead and tell me, in AS MUCH detail as possible, the problems you are having, and what you want me to do as far as fixes (like making it the only item menu)
Oh yeah, and I fixed it so that you can use items in the menu now.
Would you like for you to start where you are in the item menu, or the cache menu?
EDIT:
You think you're bugging me? LOLOLOLOLOLOLOL
Seriously, You're not. I'm having fun trying to solve this problem.
Yeah, about the help window/item description thing. I already did that around 15 mins ago, because it looks WAY better. right now, some unexpected glitches came up. One of em is the unconsumability problem, and the other is the fact that when you get out of battle after having (tried) to use an item, ALL of that item is gone. It keeps EATING 80 something of them. It's ridiculous. I'm working on it now.
But yeah,
DO NOT WORRY - just tell me if you need/want ANYTHING else. I'd rather you get EXACTLY what you want, then "preten", just to be polite, especially when I'm actually enjoying working on it. No worries ^_^
No, if I press q it switches to the item window and everything works well. I'd like for it to start in the item window first. Right now, since I got rid of the error (somehow), the only problem is the adding items while the cache is active. Everything else you are either working on, or are done with.
EDIT:
LOL, you LOL'd a lot and that made me LOL. But yeah, I won't "pretend." And I wonder why that stuff is happening. :???: That's weird, it just suddenly happened. Maybe you took something out that you shouldn't have?
Quote from: Yin on June 17, 2009, 11:33:01 pm
I'd like for it to start in the item window first.
Easily done - less than two minutes, once I finish with these glitches.
Quote from: Yin on June 17, 2009, 11:33:01 pm
Right now, since I got rid of the error (somehow), the only problem is the adding items while the cache is active. Everything else you are either working on, or are done with.
A little harder, but I'll figure it out.
^_^
No, but I just figured out EXACTLY why it happened >.>
I just made a REALLY dumb mistake.
Script placement is VERY important.
EDIT: Oh, but it's fixed, I believe, so I'm starting on those last few edits.
EDIT AGAIN: Yeah, that fixed it.
EDIT AGAIN: Ok, like I said, I fixed the starting in the item menu thing in around twenty seconds. Literally. Easy edit ^_^.
Working on the problem of adding items while able to remove them in the cache
EDIT: Yeah, this problem is/was EVIL. I THINK I found a workaround....GOD, I'm a genius, XD. Be done soon.
HOPEFULLY, LAST EDIT:
Ok, Yin. I think this is it:
#==============================================================================
# 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
Put it below all of the other Scene_(insert name here) scripts, but above everything else, or you'll get that error that I MAGICALLY got. I tested it A LITTLE, and it seems to be working fine. Items are being consumed, drawing right, not taking extra. Help window shows item description in the item window, and "blah blah unassign" in the cache window. You can't add items FROM the cache, only unassign. The normal item menu has been replaced with this one. I think that's all, but there may well be a stupid little bug hiding somewhere. If that's the case, tell me, and I'll gladly jump on it. I would test it more (and I will, tomorrow), but I'm dead tired. Sorry, Yin >.<
Good luck with it ^_^. Tell me if it's what you need. Again, don't feel bad. You're only hurting yourself to do that, because you don't get the script which you originally wanted. Don't be afraid to ask for a fix or addition - it's my pleasure.
Nighty night ^_^.
Thanks! Good Night. I'll be sure to test it again. and thoroughly. I'll post my results tomorrow because I'm a bit tired too.
Again, thanks!
EDIT: So far, no problems! I think I can handle the rest of the little tweaks. Like having the status window for target select only appear on the right side. I fixed that already.
Quote from: Yin on June 18, 2009, 12:45:12 am
Thanks! Good Night. I'll be sure to test it again. and thoroughly. I'll post my results tomorrow because I'm a bit tired too.
Again, thanks!
Crap! Sorry, Yin. I was dead tired last night. Remember to DELETE THE OLD SCENE_ITEM, or you'll probably get some crazy errors. However, DO NOT put this script in the same spot, or, again, crazy errors. It needs to go at the bottom of all of the Scenes. Specifically, it needs to go UNDER scene_battle. That's what threw those crazy errors for me.
That should work, and it's no problem at all ^_^. If you ever need any additions to this, or help with edit-ing another script, don't hesitate to ask me. I had fun - you're not a jerk, like some people who
"request" demand.
Besides, I checked the dates on this. I wanted to help someone who had waited a decent length of time. You fit the bill ^_^. Thank you for your patience!
No, thank YOU! I don't know how I can repay you! I'm not really good at anything lol. Well, I can probably whip you up a game over screen or something. If you need anything like that, I'll be willing to help. Some examples of my work are here: http://punkid89.b1.jcink.com/index.php?showtopic=896
Quote from: Yin on June 18, 2009, 12:22:30 pm
No, thank YOU! I don't know how I can repay you! I'm not really good at anything lol. Well, I can probably whip you up a game over screen or something. If you need anything like that, I'll be willing to help. Some examples of my work are here: http://punkid89.b1.jcink.com/index.php?showtopic=896
Actually, I COULD use something like that. Graphically, I suck!
I'll check it out, and thanks for the offer ^_^.
Really though, what you just said is exactly what I did this for. All I wanted was to use my newfound talents to help someone in need, and that you appreciate it is all the payment that I could EVER ask for. I really did enjoy working with you - you're very gracious, and not at all bothersome. Thank you for giving me work, and being very friendly during it. Next time you get a request, PM me a link. I really did have fun!
^_^
-Seox
EDIT:
If you don't mind, I could REALLY use a title screen.
http://images.google.com/images?hl=en&q=huguenot%20cross&um=1&ie=UTF-8&sa=N&tab=wi (http://images.google.com/images?hl=en&q=huguenot%20cross&um=1&ie=UTF-8&sa=N&tab=wi)
Those are pictures of the huguenot cross. In my game, it's a medal known as The Valor Dove. It's worth WAY more than the medal of honor, and signifies the valor of a soldier, but the docile nature of a dove, in that they fought like they should have, but kept their humanity and did not BUTCHER. In short, they displayed AMAZING honor and will.
The name of the game is also The Valor Dove. I'd just like the huguenot cross, and the title, with maybe a really cool background or something. I dunno. Point being, the words and the picture, and, other than that, surprise me.
If you don't like titles, I still don't have a good game over screen. My game is a post-modern military RPG. I was thinking maybe a DARK gray metallic looking screen, that maybe slightly gradients. It says in cold, hard, (stenciled, maybe?) letters, "GAME OVER", with, possibly, some bullet holes in the metal surface.
That's if you don't mind ^_^. Don't at all feel obligated!
Thank you for the offer, at any rate ^_^/