KItemDesc XP Zilsel Version - kyonides - 11-22-2019
KItemDesc XP
Zilsel Version
version 1.0.2
by Kyonides
Introduction
This scriptlet just pretends to implement zlsl's need of a different item description menu by adding an extra window to display an icon or picture plus the hero's comment.
You may also want to activate a global switch to show skills as if they were simple items! Don't worry! You can deactivate that at any given time!
Warning: The player cannot change this on his own so you would need to let them use an event as a trigger.
Just paste it in a script section above Main but below Scene_Debug.
Screenshot
The Script
XP Version
Code: # * KItemDesc XP Zilsel Version
# Scripter : Kyonides Arkanthes
# v1.0.2 - 2019-11-24
# This scriptlet allows you to show custom icons and comments in the Inventory
# Menu scene. It will show the party leader's opinion on a given item.
# Place large icons in the Graphics/Pictures directory if you ever use them!
# You may also allow the player to check out his or her skills on the same menu
# by activating a global switch via an event command. It can be deactivated at
# any given time!
module KItemDesc
INCLUDE_SKILLS_SWITCH_ID = 1
PICTURE_X = 12
PICTURE_Y = 12
PICTURE_CENTER_X = true # true - Ignores X coordinate, false - uses X
PICTURE_CENTER_Y = true # true - Ignores Y coordinate, false - uses Y
COMMENTS_Y = 180
ACTOR_OPINION_LABEL = "%s's Opinion"
# Comments may include newlines alias \n if needed.
DEFAULT_COMMENT = "The hero has nothing to say\nabout this"
@comments = {} # There's no need to edit this line.
# [[Kind, ID]] = { ActorID => "Hero's comment on current item", etc. }
# Kind Options - :item, :weapon, :armor, :skill - Check the following example.
@comments[[:item, 1]] = {
1 => "You know, I'll never need potions\nfor I'm invincible!"
}
@comments.default = {} # Do not touch this! It will eat you alive!
def self.comments() @comments end
end
class Game_Party
def leader() @actors[0] end
end
class ItemDescWindow < Window_Base
include KItemDesc
def initialize
super(320, 64, 320, 416)
self.contents = Bitmap.new(width - 32, height - 32)
end
def refresh(new_item)
return if @item == new_item
@item = new_item
c = self.contents
c.clear
return if @item.nil?
lid = $game_party.leader.id
name = $game_party.leader.name
key = [@item.type, @item.id]
comments = KItemDesc.comments[key][lid] || DEFAULT_COMMENT
comments = comments.split("\n")
text = sprintf(ACTOR_OPINION_LABEL, name)
icon_name = @item.icon_name
begin
bit = RPG::Cache.picture(icon_name)
rescue
bit = RPG::Cache.icon(icon_name)
end
rect = Rect.new(0, 0, bit.width, bit.height)
icon_x = PICTURE_CENTER_X ? 288 / 2 - bit.width / 2 : PICTURE_X
icon_y = PICTURE_CENTER_Y ? COMMENTS_Y / 2 - bit.height / 2 : PICTURE_Y
c.blt(icon_x, icon_y, bit, rect)
c.draw_text(0, COMMENTS_Y, 288, 24, text)
comments.size.times do |n|
c.draw_text(0, COMMENTS_Y + 28 + n * 24, 288, 24, comments[n])
end
end
end
module RPG
class Item
def type() :item end
end
class Weapon
def type() :weapon end
end
class Armor
def type() :armor end
end
class Skill
def type() :skill end
end
end
class Game_Party
def item_keys() @items.keys.sort end
def weapon_keys() @weapons.keys.sort end
def armor_keys() @armors.keys.sort end
def skills() @actors.map{|a| a.skills } end
def skill_number(item_id) skills.select{|n| n == item_id}.size end
end
class Window_Item
alias :kyon_itemdesc_win_item_up_help :update_help
def initialize
battle = $game_temp.in_battle
w = battle ? 640 : 320
super(0, 64, w, 416)
refresh
self.index = 0
return unless battle
@column_max = 2
self.y = 64
self.height = 256
self.back_opacity = 160
end
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
$game_party.item_keys.each{|i| @data << $data_items[i] }
unless $game_temp.in_battle
$game_party.weapon_keys.each{|i| @data << $data_weapons[i] }
$game_party.armor_keys.each{|i| @data << $data_armors[i] }
if $game_switches[KItemDesc::INCLUDE_SKILLS_SWITCH_ID]
$game_party.skills.each{|i| @data << $data_skills[i] }
end
end
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
@item_max.times{|i| draw_item(i) }
end
@desc_window.refresh(@data[@index]) if @desc_window
end
def draw_item(index)
item = @data[index]
number = current_item_number(item.type, item.id)
usable = (item.type == :item and $game_party.item_can_use?(item.id))
self.contents.font.color = usable ? normal_color : disabled_color
x = 4 + index % @column_max * (288 + 32)
y = index / @column_max * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
end
def current_item_number(item_type, item_id)
case item_type
when :item
$game_party.item_number(item_id)
when :weapon
$game_party.weapon_number(item_id)
when :armor
$game_party.armor_number(item_id)
when :skill
$game_party.skill_number(item_id)
end
end
def desc_window=(new_window)
@desc_window = new_window
@desc_window.refresh(@data[@index])
end
def update_help
kyon_itemdesc_win_item_up_help
@desc_window.refresh(@data[@index]) if @desc_window
end
end
class Scene_Item
def main
@item_desc = ItemDescWindow.new
@help_window = Window_Help.new
@item_window = Window_Item.new
@item_window.help_window = @help_window
@item_window.desc_window = @item_desc
@target_window = Window_Target.new
@target_window.visible = false
@target_window.active = false
Graphics.transition
main_loop until $scene != self
Graphics.freeze
@item_desc.dispose
@help_window.dispose
@item_window.dispose
@target_window.dispose
end
def main_loop
Graphics.update
Input.update
update
end
end
Terms & Conditions
Free for use in any kind of videogame.
You must include my nickname in your game credits.
Give me a free copy of your completed game if you include at least 2 of my scripts!
RE: KItemDesc XP Zilsel Version - DerVVulfman - 11-24-2019
There is a flaw with the system. You use the ITEM ID to distinguish between one item and another. That's fine insofar as the ITEM database. But you also have ITEM IDs for Weapons and Armor. Using an ITEM ID of #2, I would have the same description for a high potion as I would an Iron Sword.
And you didn't add the '< Window_Selectable' to the Window_Item class, separating it from its Selectable parent class.
RE: KItemDesc XP Zilsel Version - kyonides - 11-24-2019
Bug Fix + Improvement
Yes, guys! I have come back to let you know I smashed Wulfo's flea and implemented a new feature, listing skills as if they were simple items!
So yes, you will be able to check on items, weapons, armors and skills, though you will only find items there if you're already fighting for survival...
Regarding Wulfo's Final Comment
I gotta say that his statement makes no sense. Nobody can separate an existing Ruby class from its predefined parent class. If it has been defined ONCE, there is NO NEED to keep repeating yourself over and over again.
What happened there was that back in 2019 nobody had figured out that the only time you need to ever establish a parent class is just when you are creating a given child class. And this is an one time event, my dear friends. From that moment onward, you only need to reopen that class as many times as needed. Actually, this last statement is the default mode for all Ruby modules, especially because they have no parent class. Modules can only have nested classes or modules and that's all.
RE: KItemDesc XP Zilsel Version - kyonides - 11-25-2019
It Turned Out This Spell Implementation Needed a Spell Troubleshooting
Nope, I'm not talking about my stories here! It just happens that after staying awake till late and waking up a few hours later, I did a few things to improve the script like including a list of skills... Yeah, that was what I thought at first. Don't look at me! I did my best taking in consideration I'm not being paid for this. Plus, I had to prepare for a long trip to the Caribbean!
But yeah, now skills should be listed as well this time.
Don't forget to activate the switch!
RE: KItemDesc XP & VX Zilsel Version - kyonides - 12-01-2019
Something Had Been VeXing Me Lately...
I guess it was the lack of a VX port, guys! Don't worry! I've brought you one just in case you ever felt as if you had been left behind. Now you can enjoy the convenience of showing actor's comments as well.
Yes! I've included screenshots on the first post and for both ports!
|