[XP] Display A Specific Item in Battle Screen

Started by lonely_cubone, January 14, 2012, 02:00:08 am

Previous topic - Next topic

lonely_cubone

Hi everyone. I know I haven't been very active recently, but I'm working on a game that I'll post here pretty soon, and I was hoping someone could help me with a tiny little script. :^_^':

I'm using Ryex's Asan'Tear battle system (http://forum.chaos-project.com/index.php/topic,3872.0.html), and I want to have a small window in the top right-hand corner of the screen displaying the number of a specific item that the player has (item ID 1). If possible, it would be best if it only appeared when the player is viewing a character's list of skills, but it would also work if it was always there. All I want in the window is the icon of the item, and how many of that item the player has. I'm looking for this because several skills that the characters can learn consume that item when they're used, and it would be nice if the player could see how many they have left.

Thanks in advance to anyone who can help!

ForeverZer0

I think this is what you are looking for, I assumed you meant for only in battle. I included window movement and opacity to match the skill CBS.


class Icon_Window < Window_Base
 
 def initialize
   super(640, 96, 96, 64)
   self.contents = Bitmap.new(width - 32, height - 32)
   refresh
 end
 
 def refresh
   self.contents.clear
   @quantity = $game_party.item_number(1)
   bitmap = RPG::Cache.icon($data_items[1].icon_name)
   self.contents.blt(4, 4, bitmap, Rect.new(0, 0, 24, 24))
   self.contents.draw_text(32, 0, 32, 32, @quantity.to_s, 1)
 end
end

class Scene_Battle
 
 alias icon_window_update update_phase3_skill_select
 def update_phase3_skill_select
   @icon_window.update
   icon_window_update
 end
 
 alias icon_window_start_skill_select start_skill_select
 def start_skill_select
   @icon_window = Icon_Window.new
   @icon_window.move(544, 96)
   icon_window_start_skill_select
   @icon_window.back_opacity = @skill_window.back_opacity
 end
 
 alias icon_window_end_skill_select end_skill_select
 def end_skill_select
   @icon_window = @icon_window.dispose
   icon_window_end_skill_select
 end
end
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

lonely_cubone

January 14, 2012, 09:32:10 am #2 Last Edit: January 15, 2012, 02:03:24 pm by lonely_cubone
That's perfect! Thank you! :D

EDIT: Actually, I have a request for one more little feature. Could someone please make it so the window only appears when a certain switch (#3) is on?

ForeverZer0

Add this line to the beginning of the "refresh" method of the Window class from above:

self.visible = $game_switches[3]
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.