draw_item(item_id, type, i , j)
if type == "i" and
$game_party.item_can_use?($data_items[item_id].id)
opacity = 255
else
opacity = 128
end
if item_id != 0
case type
when "i"
x = 4 + (j * 32)
y = i * 32
bitmap = RPG::Cache.icon($data_items[item_id].icon_name)
@grid_color.bitmap.fill_rect(j*32+1, i*32+1, 31, 31, Color.new(0,0,200))
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
when "w"
x = 4 + (j * 32)
y = i * 32
bitmap = RPG::Cache.icon($data_weapons[item_id].icon_name)
@grid_color.bitmap.fill_rect(j*32+1, i*32+1, 31, 95, Color.new(200,0,0))
self.contents.blt(x, y + 4 + 32, bitmap, Rect.new(0, 0, 24, 24), opacity)
when "a"
x = 4 + (j * 32)
y = i * 32
bitmap = RPG::Cache.icon($data_armors[item_id].icon_name)
@grid_color.bitmap.fill_rect(j*32+1, i*32+1, 63, 95, Color.new(0,200,0))
self.contents.blt(x + 18, y + 4 + 32, bitmap, Rect.new(0, 0, 24, 24), opacity)
end
end
end
end
class Mini_Help < Window_Base
alias old_initialize initialize
def initialize
super(0, 0, 180, 40)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.size = 14
self.back_opacity = 170
self.z = 102
self.visible = false
end
def set_text(text, align = 1)
# If at least one part of text and alignment differ from last time
if text != @text or align != @align
# Redraw text
self.contents.clear
#self.contents.font.color = normal_color
self.contents.draw_text(4, -12, self.width - 40, 32, text, align)
#self.width = self.contents.text_size(text).width
@text = text
@align = align
@actor = nil
end
self.visible = true
end
end
class Game_Actor < Game_Battler
attr_accessor :item_grid
alias old_initialize initialize
def initialize(actor_id)
old_initialize(actor_id)
@item_grid = Array.new(12)
for i in
0..@item_grid.size - 1
@item_grid[i] = Array.new(13)
for k in 0..@item_grid[i].size - 1
@item_grid[i][k] = Array.new(2)
@item_grid[i][k][0] = 0
@item_grid[i][k][1] = ""
end
end
end
end
class Game_Party
def gain_item(item_id, n)
if item_id > 0
for k in 1..n
for i in 0..self.actors.size - 1
break if set_item(item_id, "i", i) == nil
end
end
end
end
def gain_weapon(weapon_id, n)
if weapon_id > 0
for k in 1..n
for i in 0..self.actors.size - 1
break if set_item(weapon_id, "w", i) == nil
end
end
end
end
def gain_armor(armor_id, n)
if armor_id > 0
for k in 1..n
for i in 0..self.actors.size - 1
break if set_item(armor_id, "a", i) == nil
end
end
end
end
def lose_item(item_id, n, random = true)
if random == true
if item_id > 0
for k in 1..n
del_item(item_id, "i")
end
end
end
@items[item_id] = [[item_number(item_id) + -n, 0].max, 99].min
end
def lose_weapon(weapon_id, n, random = true)
if random == true
if weapon_id > 0
for k in 1..n
del_item(weapon_id, "w")
end
end
end
@weapons[weapon_id] = [[weapon_number(weapon_id) + -n, 0].max, 99].min
end
def lose_armor(armor_id, n, random = true)
if random == true
if armor_id > 0
for k in 1..n
del_item(armor_id, "a")
end
end
end
@armors[armor_id] = [[armor_number(armor_id) + -n, 0].max, 99].min
end
def set_item(item_id, type, i)
for a in 0..self.actors[i].item_grid.size - 1
for b in 0..self.actors[i].item_grid[a].size - 1
if self.actors[i].item_grid[a][b][0] == 0
case type
when "i"
self.actors[i].item_grid[a][b][0] = item_id
self.actors[i].item_grid[a][b][1] = type
@items[item_id] = [[item_number(item_id) + 1, 0].max, 99].min
return
when "w"
if a < self.actors[i].item_grid.size - 2
if self.actors[i].item_grid[a + 1][b][0] == 0 and
self.actors[i].item_grid[a + 2][b][0] == 0
self.actors[i].item_grid[a][b][0] = item_id
self.actors[i].item_grid[a][b][1] = type
self.actors[i].item_grid[a + 1][b][0] = item_id
self.actors[i].item_grid[a + 1][b][1] = "e"
self.actors[i].item_grid[a + 2][b][0] = item_id
self.actors[i].item_grid[a + 2][b][1] = "e"
@weapons[item_id] = [[weapon_number(item_id) + 1, 0].max, 99].min
return
end
end
when "a"
if b < self.actors[i].item_grid[a].size - 1 and a < self.actors[i].item_grid.size - 2
if self.actors[i].item_grid[a + 1][b][0] == 0 and self.actors[i].item_grid[a + 2][b][0] == 0 and
self.actors[i].item_grid[a][b + 1][0] == 0 and
self.actors[i].item_grid[a + 1][b + 1][0] == 0 and self.actors[i].item_grid[a + 2][b + 1][0] == 0
self.actors[i].item_grid[a][b][0] = item_id
self.actors[i].item_grid[a][b][1] = type
self.actors[i].item_grid[a + 1][b][0] = item_id
self.actors[i].item_grid[a + 1][b][1] = "r"
self.actors[i].item_grid[a + 2][b][0] = item_id
self.actors[i].item_grid[a + 2][b][1] = "r"
self.actors[i].item_grid[a][b + 1][0] = item_id
self.actors[i].item_grid[a][b + 1][1] = "r"
self.actors[i].item_grid[a + 1][b + 1][0] = item_id
self.actors[i].item_grid[a + 1][b + 1][1] = "r"
self.actors[i].item_grid[a + 2][b + 1][0] = item_id
self.actors[i].item_grid[a + 2][b + 1][1] = "r"
@armors[item_id] = [[armor_number(item_id) + 1, 0].max, 99].min
return
end
end
end
end
end
end
end
def del_item(item_id, type)
for i in 0..self.actors.size - 1
for a in 0..self.actors[i].item_grid.size - 1
for b in 0..self.actors[i].item_grid[a].size - 1
if self.actors[i].item_grid[a][b][0] == item_id and
self.actors[i].item_grid[a][b][1] == type
case type
when "i"
self.actors[i].item_grid[a][b][0] = 0
self.actors[i].item_grid[a][b][1] = ""
return
when "w"
self.actors[i].item_grid[a][b][0] = 0
self.actors[i].item_grid[a][b][1] = ""
self.actors[i].item_grid[a + 1][b][0] = 0
self.actors[i].item_grid[a + 1][b][1] = ""
self.actors[i].item_grid[a + 2][b][0] = 0
self.actors[i].item_grid[a + 2][b][1] = ""
return
when "a"
self.actors[i].item_grid[a][b][0] = 0
self.actors[i].item_grid[a][b][1] = ""
self.actors[i].item_grid[a + 1][b][0] = 0
self.actors[i].item_grid[a + 1][b][1] = ""
self.actors[i].item_grid[a + 2][b][0] = 0
self.actors[i].item_grid[a + 2][b][1] = ""
self.actors[i].item_grid[a][b + 1][0] = 0
self.actors[i].item_grid[a][b + 1][1] = ""
self.actors[i].item_grid[a + 1][b + 1][0] = 0
self.actors[i].item_grid[a + 1][b + 1][1] = ""
self.actors[i].item_grid[a + 2][b + 1][0] = 0
self.actors[i].item_grid[a + 2][b + 1][1] = ""
return
end
end
end
end
end
end
end
class Cursor_Icon < RPG::Sprite
def initialize
super
@color = Color.new(255,255,0,150)
@rect = Rect.new(0, 0, 24, 24)
end
def refresh(bitmap, item)
case item
when "i"
x = 4
y = 4
width = 32
height = 32
when "w"
x = 4
y = 36
width = 32
height = 96
when "a"
x = 22
y = 36
width = 64
height = 96
end
if self.bitmap == nil or (self.bitmap.width != width or self.bitmap.height != height)
self.bitmap = Bitmap.new(width, height)
else
self.bitmap.clear
end
self.bitmap.fill_rect(0,0,width,height, @color)
self.bitmap.blt(x, y , bitmap, @rect)
self.z = 9999
end
end
class Window_Base
def draw_actor_picture(actor, x, y)
bitmap = RPG::Cache.battler(actor.character_name, actor.character_hue)
cw = bitmap.width
ch = bitmap.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
end
end
class Scene_Menu
def update_command
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to map screen
$scene = Scene_Map.new
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# If command other than save or end game, and party members = 0
if $game_party.actors.size == 0 and @command_window.index < 4
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Branch by command window cursor position
case @command_window.index
when 0 # item
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to item screen
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 1 # skill
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 2 # equipment
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 3 # status
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 4 # save
# If saving is forbidden
if $game_system.save_disabled
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to save screen
$scene = Scene_Save.new
when 5 # end game
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to end game screen
$scene = Scene_End.new
end
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when status window is active)
#--------------------------------------------------------------------------
def update_status
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Make command window active
@command_window.active = true
@status_window.active = false
@status_window.index = -1
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @command_window.index
when 0
$game_system.se_play($data_system.decision_se)
$scene = Scene_Item2.new(@status_window.index)
when 1 # skill
# If this actor's action limit is 2 or more
if $game_party.actors[@status_window.index].restriction >= 2
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to skill screen
$scene = Scene_Skill.new(@status_window.index)
when 2 # equipment
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to equipment screen
$scene = Scene_Equip.new(@status_window.index)
when 3 # status
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to status screen
$scene = Scene_Status.new(@status_window.index)
end
return
end
end
end