You are on page 1of 12

class scene_item

# ------------------------------------
def main
@help_window = window_help.new
@item_window = window_item.new
# <item detail view script> #
# creates the window and hides it until user input.
@itemdetail_window = window_itemdetailview.new
@itemdetail_window.visible = false
@itemdetail_window.active = false
# </item detail view script> #
@item_window.help_window = @help_window
@target_window = window_target.new
@target_window.visible = false
@target_window.active = false
graphics.transition
loop do
graphics.update
input.update
update
if $scene != self
break
end
end
graphics.freeze
@help_window.dispose
@item_window.dispose
# <item detail view> below line required for disposal when needed.
@itemdetail_window.dispose
@target_window.dispose
end
# ------------------------------------
def update
# <item detail view>
# below line sets highlighted item into global variable.
$currenthighlighteditem = @item_window.item
@help_window.update
@item_window.update
@target_window.update
if @item_window.active
update_item
return
end
if @target_window.active
update_target
return
end
# <item detail view> #
# tells window to update when active.
if @itemdetail_window.active
update_detail
return
end
# </item detail view> #
end
# ------------------------------------
def update_detail
if input.trigger?(input::b)
$game_system.se_play($data_system.cancel_se)
unless $game_party.item_can_use?(@item.id)
@item_window.refresh
end
@item_window.active = true
@itemdetail_window.visible = false
@itemdetail_window.active = false
@itemdetail_window.refresh2
return
end
end
# ------------------------------------
def update_item
# <item detail view> #
# below if-then statement is to check user's input.
# if user presses button a (shift), then item detail window
# is turned active and visible.
if input.trigger?(input::a)
# below if-then statement checks for blank item, and cancels
# input effect is true.
if $currenthighlighteditem == nil
return
end
$game_system.se_play($data_system.decision_se)
@itemdetail_window.refresh
@item_window.active = false
@itemdetail_window.visible = true
@itemdetail_window.active = true
end
# </item detail view> #
if input.trigger?(input::b)
$game_system.se_play($data_system.cancel_se)
$scene = scene_menu.new(0)
return
end
if input.trigger?(input::c)
@item = @item_window.item
unless @item.is_a?(rpg::item)
$game_system.se_play($data_system.buzzer_se)
return
end
unless $game_party.item_can_use?(@item.id)
$game_system.se_play($data_system.buzzer_se)
return
end
# code below is suspected to be use command
$game_system.se_play($data_system.decision_se)
if @item.scope >= 3
@item_window.active = false
@target_window.x = (@item_window.index + 1) % 2 * 304
@target_window.visible = true
@target_window.active = true
if @item.scope == 4 || @item.scope == 6
@target_window.index = -1
else
@target_window.index = 0
end
else
if @item.common_event_id > 0
$game_temp.common_event_id = @item.common_event_id
$game_system.se_play(@item.menu_se)
if @item.consumable
$game_party.lose_item(@item.id, 1)
@item_window.draw_item(@item_window.index)
end
$scene = scene_map.new
return
end
end
return
# code above
end
end
# ------------------------------------
def update_target
if input.trigger?(input::b)
$game_system.se_play($data_system.cancel_se)
unless $game_party.item_can_use?(@item.id)
@item_window.refresh
end
@item_window.active = true
@target_window.visible = false
@target_window.active = false
return
end
if input.trigger?(input::c)
if $game_party.item_number(@item.id) == 0
$game_system.se_play($data_system.buzzer_se)
return
end
if @target_window.index == -1
used = false
for i in $game_party.actors
used |= i.item_effect(@item)
end
end
if @target_window.index >= 0
target = $game_party.actors[@target_window.index]
used = target.item_effect(@item)
end
if used
$game_system.se_play(@item.menu_se)
if @item.consumable
$game_party.lose_item(@item.id, 1)
@item_window.draw_item(@item_window.index)
end
@target_window.refresh
if @item.common_event_id > 0
$game_temp.common_event_id = @item.common_event_id
$scene = scene_map.new
return
end
end
unless used
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
end

__________________________________despues:

nuevo script arriba de main:

class window_itemdetailview < window_base

# ---------------------------------------------------------
# script v1.1
# by jackatrades
#
# find me at http://www.dubealex.com/creation_asylum/forum/
# if you have questions/comments.
# ---------------------------------------------------------

# creates the window for usage.


def initialize
super(0, 40, 640, 400)
self.contents = bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
self.contents.font.color = normal_color
# z acts as "layer order."
self.z += 10
@itemdetail = []
# ------------------------------
# @leadingcharacters is set for the script to delete (x+1) amount of
# characters in each line of the .rxdata
# in this case, the first 6 characters will be deleted in each line.
# ------------------------------
@leadingcharacters = 5
# clears and resets the window everytime it is requested by scene_item.
refresh2
end

def refresh2
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
self.contents.font.color = normal_color
self.contents.clear
end

def refresh
item_id = $currenthighlighteditem.id
# the three huge if-then statements check the current highlighted
# item and its property, and executes the appropriate script
# when it is true.
# <-----------------------------------item---------------------------->
if $currenthighlighteditem.is_a?(rpg::item)
item_name = $data_items[item_id].name
item_icon = $data_items[item_id].icon_name
item_amount = ($game_party.item_number(item_id)).to_s
item_price = ($data_items[item_id].price).to_s
getitem_scope = $data_items[item_id].scope
# the item scope descriptions can be edited if needed.
if getitem_scope == 0
getitem_scope = "no use"
end
if getitem_scope == 1
getitem_scope = "one enemy"
end
if getitem_scope == 2
getitem_scope = "all enemies"
end
if getitem_scope == 3
getitem_scope = "one ally"
end
if getitem_scope == 4
getitem_scope = "party"
end
if getitem_scope == 5
getitem_scope = "down ally (hp = 0)"
end
if getitem_scope == 6
getitem_scope = "down allies (hp = 0)"
end
if getitem_scope == 7
getitem_scope = "user"
end
# </> #
self.contents.font.color = system_color
self.contents.draw_text(310, 44, 100, 24, "usage:", 2)
self.contents.font.color = normal_color
self.contents.draw_text(426, 44, 250, 24, getitem_scope, 0)
end
# <-------------------------------------------------------------------->

# <-----------------------------------weapon---------------------------->
if $currenthighlighteditem.is_a?(rpg::weapon)
item_name = $data_weapons[item_id].name
item_icon = $data_weapons[item_id].icon_name
item_amount = ($game_party.weapon_number(item_id)).to_s
item_price = ($data_weapons[item_id].price).to_s
# initialize p# variables.
# these are used to display either plus sign or no sign depending on
# the weapon's attribute bonus.
# negative sign originates from the value itself, so no need to check
# them with if-then statements.
p1 = ""
p2 = ""
p3 = ""
p4 = ""
p5 = ""
p6 = ""
# ---------------------------------------------------
# start inserting appropriate variables from database.
# ---------------------------------------------------
item_atk = $data_weapons[item_id].atk.to_s
item_pdef = $data_weapons[item_id].pdef
if item_pdef > 0
p5 = "+"
end
item_pdef = item_pdef.to_s
item_mdef = $data_weapons[item_id].mdef
if item_mdef > 0
p6 = "+"
end
item_mdef = item_mdef.to_s
item_str = $data_weapons[item_id].str_plus
if item_str > 0
p1 = "+"
end
item_str = item_str.to_s
item_dex = $data_weapons[item_id].dex_plus
if item_dex > 0
p2 = "+"
end
item_dex = item_dex.to_s
item_agi = $data_weapons[item_id].agi_plus
if item_agi > 0
p3 = "+"
end
item_agi = item_agi.to_s
item_int = $data_weapons[item_id].int_plus
if item_int > 0
p4 = "+"
end
item_int = item_int.to_s
# sets elemental and status attributes of weapon string along with
# suffix slashes when there are two or more attributes.
item_element = ""
flag = false
for i in $data_weapons[item_id].element_set
if flag
item_element += "/"
end
item_element += $data_system.elements[i]
flag = true
end
# checks whether item_element is blank. if it is, then sets it
# to "none".
if item_element == ""
item_element = "none"
end
item_status = ""
flag = false
for i in $data_weapons[item_id].plus_state_set
if flag
item_status += "/"
end
item_status += $data_states[i].name
flag = true
end
if item_status == ""
item_status = "none"
end
# ------------------------------
# start drawing attribute names.
# ------------------------------
# x and y can be changed to easily affect other attributes.
x = 33
y = 66
self.contents.font.color = system_color
self.contents.font.size = $fontsize - 4
self.contents.font.color = color.new(255, 255, 0, 255)
self.contents.draw_text(x, y, 256, 24, $data_system.words.atk)
self.contents.font.color = system_color
self.contents.draw_text(x, y + 28, 256, 24, $data_system.words.str)
self.contents.draw_text(x, y + 42, 256, 24, $data_system.words.dex)
self.contents.draw_text(x, y + 56, 256, 24, $data_system.words.agi)
self.contents.draw_text(x, y + 70, 256, 24, $data_system.words.int)
self.contents.draw_text(x, y + 84, 256, 24, $data_system.words.pdef)
self.contents.draw_text(x, y + 98, 256, 24, $data_system.words.mdef)
self.contents.draw_text(x + 170, y, 256, 24, "elemental attack:")
self.contents.draw_text(x + 170, y + 42, 256, 24, "status attack:")
# ------------------------------
# start drawing attribute values.
# ------------------------------
self.contents.font.color = normal_color
self.contents.draw_text(x + 74, y, 64, 24, item_atk, 2)
self.contents.draw_text(x + 74, y + 28, 64, 24, p1 + item_str, 2)
self.contents.draw_text(x + 74, y + 42, 64, 24, p2 + item_dex, 2)
self.contents.draw_text(x + 74, y + 56, 64, 24, p3 + item_agi, 2)
self.contents.draw_text(x + 74, y + 70, 64, 24, p4 + item_int, 2)
self.contents.draw_text(x + 74, y + 84, 64, 24, p5 + item_pdef, 2)
self.contents.draw_text(x + 74, y + 98, 64, 24, p6 + item_mdef, 2)
self.contents.draw_text(x + 170, y + 14, 420, 24, " " + item_element, 0)
self.contents.draw_text(x + 170, y + 56, 420, 24, " " + item_status, 0)
# resets font size.
self.contents.font.size = $fontsize
end
# <-------------------------------------------------------------------->

# <-----------------------------------armor---------------------------->
if $currenthighlighteditem.is_a?(rpg::armor)
item_name = $data_armors[item_id].name
item_icon = $data_armors[item_id].icon_name
item_amount = ($game_party.armor_number(item_id)).to_s
item_price = ($data_armors[item_id].price).to_s
# set variables
p1 = ""
p2 = ""
p3 = ""
p4 = ""
p5 = ""
p6 = ""
# checks armor's type and inserts appropriate string.
type = $data_armors[item_id].kind
if type == 0
type = "shield"
end
if type == 1
type = "helmet"
end
if type == 2
type = "armor"
end
if type == 3
type = "accessory"
end
item_pdef = $data_armors[item_id].pdef
if item_pdef > 0
p5 = "+"
end
item_pdef = item_pdef.to_s
item_mdef = $data_armors[item_id].mdef
if item_mdef > 0
p6 = "+"
end
item_mdef = item_mdef.to_s
item_str = $data_armors[item_id].str_plus
if item_str > 0
p1 = "+"
end
item_str = item_str.to_s
item_dex = $data_armors[item_id].dex_plus
if item_dex > 0
p2 = "+"
end
item_dex = item_dex.to_s
item_agi = $data_armors[item_id].agi_plus
if item_agi > 0
p3 = "+"
end
item_agi = item_agi.to_s
item_int = $data_armors[item_id].int_plus
if item_int > 0
p4 = "+"
end
item_int = item_int.to_s
item_element = ""
flag = false
for i in $data_armors[item_id].guard_element_set
if flag
item_element += "/"
end
item_element += $data_system.elements[i]
flag = true
end
if item_element == ""
item_element = "none"
end
item_status = ""
flag = false
for i in $data_armors[item_id].guard_state_set
if flag
item_status += "/"
end
item_status += $data_states[i].name
flag = true
end
if item_status == ""
item_status = "none"
end
#draw attribute names
self.contents.font.color = system_color
self.contents.font.size = $fontsize - 4
x = 33
y = 66
self.contents.font.color = color.new(255, 255, 0, 255)
self.contents.draw_text(x, y, 256, 24, "type")
self.contents.draw_text(x, y + 14, 256, 24, $data_system.words.pdef)
self.contents.draw_text(x, y + 28, 256, 24, $data_system.words.mdef)
self.contents.font.color = system_color
self.contents.draw_text(x, y + 56, 256, 24, $data_system.words.str)
self.contents.draw_text(x, y + 70, 256, 24, $data_system.words.dex)
self.contents.draw_text(x, y + 84, 256, 24, $data_system.words.agi)
self.contents.draw_text(x, y + 98, 256, 24, $data_system.words.int)
self.contents.draw_text(x + 170, y, 256, 24, "elemental guard:")
self.contents.draw_text(x + 170, y + 42, 256, 24, "status guard:")

#draw attributes
self.contents.font.color = normal_color
self.contents.draw_text(x + 74, y, 64, 24, type, 2)
self.contents.draw_text(x + 74, y + 14, 64, 24, p5 + item_pdef, 2)
self.contents.draw_text(x + 74, y + 28, 64, 24, p6 + item_mdef, 2)
self.contents.draw_text(x + 74, y + 56, 64, 24, p1 + item_str, 2)
self.contents.draw_text(x + 74, y + 70, 64, 24, p2 + item_dex, 2)
self.contents.draw_text(x + 74, y + 84, 64, 24, p3 + item_agi, 2)
self.contents.draw_text(x + 74, y + 98, 64, 24, p4 + item_int, 2)
self.contents.draw_text(x + 170, y + 14, 420, 24, " " + item_element, 0)
self.contents.draw_text(x + 170, y + 56, 420, 24, " " + item_status, 0)
self.contents.font.size = $fontsize

end
# <-------------------------------------------------------------------->

# stores item price's string width.


item_price_width = item_price.size * 10
# stores item's icon graphic.
bitmap = rpg::cache.icon(item_icon + ".png")
# draws item's icon.
self.contents.blt(5, 8, bitmap, rect.new(0, 0, 24, 24), 255)
self.contents.font.color = normal_color
self.contents.draw_text(33, 8, 256, 24, item_name)
self.contents.font.color = system_color
self.contents.draw_text(310, 8, 100, 24, "owned no.:", 2)
self.contents.draw_text(310, 26, 100, 24, "value:", 2)
self.contents.font.color = normal_color
self.contents.draw_text(426, 8, 160, 24, item_amount, 0)
self.contents.draw_text(426, 26, 160, 24, item_price, 0)
# this if-then statement is pretty much unnecessary unless
# you're using the same idea: if user's party does not
# know the item's value and had not appraised the item,
# then don't draw text.
if item_price != "unknown"
self.contents.font.color = system_color
self.contents.draw_text(432 + item_price_width, 26, 160, 24,
$data_system.words.gold, 0)
end
self.contents.font.color = normal_color
# two lines below calls the two definitions to write the item's
# detailed description.
get_item_detail(item_id)
write_item_detail(5, 223)
end

def get_item_detail(item_id)
# descarray stores the line numbers needed to call the right
# detail description into an array.
descarray =
[
item_id * 7,
item_id * 7 + 1,
item_id * 7 + 2,
item_id * 7 + 3,
item_id * 7 + 4,
item_id * 7 + 5,
item_id * 7 + 6
]
# the if-then statements below checks the highlighted item and use
# the right .rxdata.
if $currenthighlighteditem.is_a?(rpg::item)
f = file.open("data/item_detail.rxdata")
end
if $currenthighlighteditem.is_a?(rpg::weapon)
f = file.open("data/weapon_detail.rxdata")
end
if $currenthighlighteditem.is_a?(rpg::armor)
f = file.open("data/armor_detail.rxdata")
end
# stores _every_ line of the file into @itemdetail as an array.
@itemdetail = f.readlines
# clears first seven lines for lines 1-7 (0..6), as it will never be used.
for i in 0..6
@itemdetail[i] = ""
end
# crops the first 6 characters in each line.
for i in 0..6
cropheadcharacters(descarray[i])
end
# stores the cropped lines into description array.
@description = []
for i in 0..6
@description[i] = @itemdetail[descarray[i]]
end
return
end

def cropheadcharacters(descarray)
# checks to see if any lines are nil. if so, then sets them
# as blank lines after cropping.
if @itemdetail[descarray] == nil
@itemdetail[descarray] = "123456 "
end
# crops the first (@leadingcharacters) characters in each line.
# default: 5.
@itemdetail[descarray].slice!(0..@leadingcharacters)
return
end

def write_item_detail(x, y)
self.contents.font.color = system_color
self.contents.draw_text(x, y - 20, 640, 32, "description:")
self.contents.font.color = normal_color
self.contents.font.size = $fontsize - 2
# draws the first six lines in normal color.
for i in 0..5
self.contents.draw_text(x, y, 640, 32, @description[i])
y += 18
end
# draws the seventh line in another color.
self.contents.font.color = color.new(255, 255, 0, 255)
self.contents.draw_text(x, y, 640, 32, @description[6])
end
end

despues creas los archivos "weapon_detail.txt", "armor_detail.txt", y


"item_detail.txt" (despues cambia su extensi�nes en *.rxdata)

importante:

######description 1
######description 2
######description 3
######description 4
######description 5
######description 6
######description 7

para el idtem1:

#0

#1 description 1
description 2
description 3
description 4
description 5
description 6
description 7

para el iditem2:

#0

#1
#2 description 1
description 2
description 3
description 4
description 5
description 6
description 7

las lineas blancas les da mejor apecto ok.

You might also like