Ah ben oui ! d'accord, je comprends mieux maintenant... J'avais tout simplement mit ton script et celui de Lettuce sans pour autant mettre celui que tu me proposes dans le lien. merci beaucoup, ça fonctionne. Continue de faire de si beaux scripts !
class Scene_File def initialize(sauver,titre,event) @sauver,@titre,@event,@donnees=sauver,titre,event,[] Dir.mkdir(P_Save,777)rescue nil end
def start super create_menu_background @help=Window_Help.new @fichiers=Dir.glob("#{P_Save}/*.rvdata").sort! @fichiers.each{|k|preload(File.open(k,'rb'))} if @sauver @help.set_text(Vocab::SaveMessage,1) @obj,d=(@index_max=@fichiers.size+1),(@donnees< else @help.set_text(Vocab::LoadMessage,1) @obj,d=(@index_max=@fichiers.size),@donnees.reverse! end @fenetre=Window_File.new(@sauver,0,56,544*@index_max,360) @fenetre.create_planes(@obj,d,@fichiers,@sauver) end
def terminate @fenetre.dispose @help.dispose end
def update super @help.update next_scene if Input.trigger?(Input::B) confirm if Input.trigger?(Input::C) @index=(@fenetre.x/544).to_i.abs case Input.dir4 when 4;move(false)if @index>0 when 6;move if @index<@index_max-1 end end
def preload(file) h=(a=[:scr,:inf,:cha,:fra,:bgm,:bgs,:sys,:msg,:swi,:var,:ssw,:act,:par,:tro,:map,:pla]).to_hash a.size.times{|i|h[a[i]]=Marshal.load(file)} @donnees.insert(0,h) file.close end
def confirm Sound.play_decision path=P_Save+"/#{fi=@fichiers[@index]}" if @sauver if fi.nil? path=P_Save+"/#{P_Fichier+@index.to_s}.rvdata" else f=Window_Temp.new(SF_Ecraser[Berka::Lang])if FileTest.exist?(path) (return if !f.refresh)rescue nil end sauver(File.open(path,"wb")) avert(SF_Avert[Berka::Lang]) $scene=Scene_Menu.new else charger(File.open(path,"rb")) $scene=Scene_Map.new RPG::BGM.fade(1500) Graphics.fadeout(60) Graphics.wait(40) @last_bgm.play @last_bgs.play end end
def avert(msg) h=Window_Help.new h.width=344;h.x,h.y=(544-h.width)/2,(416-h.height)/2 h.contents=Bitmap.new(308,h.height-32) h.set_text(msg) (SF_Latence*Graphics.frame_rate).times{Graphics.update} h.dispose Sound.play_decision end
def move(right=true,i=68,ok=false) Sound.play_cursor i.times{|n|@n=n Input.update Graphics.update @fenetre.update (ok=true;break)if Input.trigger?(right ? Input::LEFT : Input::RIGHT) right ? @fenetre.x-=8 : @fenetre.x+=8} move(!right,68-i+@n)if ok end
def next_scene Sound.play_cancel if @titre;$scene=Scene_Title.new elsif @event;$scene=Scene_Map.new else;$scene=Scene_Menu.new(4) end end end
class Window_File def initialize(bool,x,y,w,h) super(x,y,w,h) @fondb=Sprite.new @fondb.x,@fondb.y,@fondb.z=23,396,1000 @fondb.bitmap=Bitmap.new(501,8) @fondb.bitmap.fill_rect(0,0,501,8,Color.new(255,255,255)) @fondb.bitmap.coins @fondb.bitmap.fill_rect(1,1,499,6,Color.new(0,0,0,0)) @bar=Sprite.new @bar.x,@bar.y,@bar.z=23,396,1000 @bar.bitmap=Bitmap.new(501,8) update end
def create_planes(i,d,fs,sauve) @i=i update fs.collect!{|f|f=f.split('/')[-1]} @i.times{|n|create_cursor(8+(x=544*n),8,492,300) if sauve&&d[n].nil? self.contents.font.size=96 self.contents.draw_text(x,40,544,132,"?",1) self.contents.font.size=20 self.contents.draw_text(x,256,544,WLH,SF_Nouv[Berka::Lang],1) next end (cadre(x);self.contents.blt(16+x,16,d[n][:scr].coins,d[n][:scr].rect)rescue next) d[n][:cha].each_with_index{|nm,i| create_cursor(278+x,28+48*i,214,32) draw_character(nm[0],nm[1],288+x,56+48*i) draw_actor_name(a=d[n][:par].members[i],302+x,48*(i+1)-29) draw_actor_hp(a,368+x,48*(i+1)-30,120) draw_actor_level(a,308+x,48*(i+1)-8) draw_actor_class(a,388+x,48*(i+1)-8)} create_cursor(15+x,220,477,80) self.contents.font.color=system_color self.contents.draw_text(20+x,224,272,WLH,SF_Strings[Berka::Lang][3]) self.contents.draw_text(20+x,248,272,WLH,sprintf(SF_Strings[Berka::Lang][1],Vocab::gold)) self.contents.draw_text(20+x,272,272,WLH,SF_Strings[Berka::Lang][2]) self.contents.draw_text(272+x,224,272,WLH,SF_Fichier[Berka::Lang]) self.contents.draw_text(272+x,248,272,WLH,SF_Date[Berka::Lang]) self.contents.font.color=normal_color self.contents.draw_text(x,224,264,WLH,lieu(d[n][:map].map_id),2) self.contents.draw_text(x,248,264,WLH,d[n][:par].gold,2) h=sprintf("%02d:%02d:%02d",(ts=d[n][:fra]/Graphics.frame_rate)/60/60,ts/60%60,ts%60) self.contents.draw_text(x,272,264,WLH,h.to_s,2) self.contents.fill_rect(268+x,225,1,82,normal_color) self.contents.fill_rect(269+x,226,1,80,system_color) self.contents.draw_text(274+x,224,224,WLH,fs[n],2) self.contents.draw_text(274+x,248,224,WLH,d[n][:inf][-1],2)} end
def lieu(id) load_data("Data/MapInfos.rvdata")[id].name end
def cadre(n) self.contents.fill_rect(15+544*n,15,274,210,Color.new(255,255,255)) [[15+n,15],[288+n,15],[288+n,224],[15+n,224]].each{|x,y| self.contents.set_pixel(x,y,Color.new(0,0,0,0))} end
def update @bar.bitmap.clear x=1+(502.0)*(self.x.abs.to_f/self.width.to_f) @bar.bitmap.fill_rect(x-1,1,(503.0/(@i)),6,Color.new(255,255,255,50))rescue nil @fondb.update @bar.update end
def dispose @bar.dispose @fondb.dispose super end
def create_cursor(x,y,w,h) wsk=self.windowskin [[0]*4,[w,0,24,0],[w,h,24,24],[0,h,0,24]].each{|a,b,c,d| self.contents.blt(x+a,y+b,wsk,Rect.new(64+c,64+d,8,8))} [[8,0,w-8,8,8,0],[w,8,8,h-8,24,8],[8,h,w-8,8,8,24],[0,8,8,h-8,0,8],[8,8,w-8,h-8,8,8]].each{|a,b,c,d,e,f| self.contents.stretch_blt(Rect.new(x+a,y+b,c,d),wsk,Rect.new(64+e,64+f,8,8))} end end
class Window_Temp def initialize(texte) super(100,160,344,84) @sprite,@texte=Sprite.new,texte @sprite.z=self.z-1 (@sprite.bitmap=Graphics.snap_to_bitmap).blur @sprite.color.set(16,16,16,128) @confirm=Window_Command.new(344,SF_Confirm[Berka::Lang],2) @confirm.x,@confirm.y,@confirm.opacity=self.x,self.y+self.height-48,0 end
def refresh loop{ Graphics.update Input.update @sprite.update @confirm.update self.contents.clear self.contents.draw_text(0,0,300,WLH,@texte,1) @ok=@confirm.index==0 if Input.trigger?(Input::C) (dispose;return @ok)if !@ok.nil?} end
def dispose @sprite.dispose @confirm.dispose super end end
class Scene_Menu alias :capt_init :initialize def initialize(menu_index=0) capt_init(menu_index) $capture.dispose if !$capture.nil?&&!$capture.disposed? $capture=Graphics.snap_to_bitmap.resize(0.5) end end
class Bitmap def resize(z) (b=Bitmap.new(self.width*z,self.height*z)).stretch_blt(b.rect,self,self.rect);b end
def coins(c=Color.new(0,0,0,0)) [[0,0],[self.width-1,0],[self.width-1,self.height-1],[0,self.height-1]].each{|x,y| self.set_pixel(x,y,c)} self end
#! Par Yeyinde (http://hbgames.org) RtlMoveMemory_pi=Win32API.new('kernel32','RtlMoveMemory','pii','i') RtlMoveMemory_ip=Win32API.new('kernel32','RtlMoveMemory','ipi','i')
def _dump(limit) data="rgba"*width*height RtlMoveMemory_pi.call(data,address,data.length) [width,height,Zlib::Deflate.deflate(data)].pack("LLa*") end
def self._load(str) w,h,zdata=str.unpack("LLa*");b=new(w,h) RtlMoveMemory_ip.call(b.address,Zlib::Inflate.inflate(zdata),w*h*4);b end
def address buffer,ad="xxxx",object_id*2+16 RtlMoveMemory_pi.call(buffer,ad,4);ad=buffer.unpack("L")[0]+8 RtlMoveMemory_pi.call(buffer,ad,4);ad=buffer.unpack("L")[0]+16 RtlMoveMemory_pi.call(buffer,ad,4);buffer.unpack("L")[0] end end
=begin #=============================================================================== Disgaea Scene Shop #===============================================================================
By GB Production http://gbproduction.wordpress.com/
Last date updated : 20/10/2010
Version 1.0
This script is inspired from the game Disgaea. At the begining, I create this script for my script Item World, but I decide to do a compatibility for everyone who want to use it.
Features : - New desygn for scene shop - 3 differents categories in buy shop (Item, weapon and armor) - Now shop display the number of equiped item - This shop comparate 4 importants stats Atk & Spi for weapons, Def & Magic def for armors - New system of gauge bonus who gain xp each time you perform actions in the shop (buy or sell) - Gauge Exp depend of the Item price - For each level of the gauge, you can take a reward in a new bonus section
I accept request. Report bugs please ! Credit to GB Production if you use this script., Thanks.
#=============================================================================== Version history #=============================================================================== 20/10/2010 Version 1.0 done 19/10/2010 Begin this script
#=============================================================================== Instruction and compatibility #=============================================================================== - Place this under all added script - If you use RES stat of YEM new battle stats, the armor magic defense comparison will be made with RES stat if you don't use RES stat, the comparaison will be made with the spi stat. - If you use Disgaea Item World, the shop desygn change a little and the shop generate randomized and separated items and equipements. (Available for Item World V4.0 and more)
=end
$imported = {} if $imported == nil $imported["GB_PROD_SHOP"] = true
module GB_PROD_SHOP #BEGIN CONFIGURATION
#Icon ID of category item ICON_CATEGORY_ITEM = 64 #Icon ID of category weapon ICON_CATEGORY_WEAPON = 1 #Icon ID of category armor ICON_CATEGORY_ARMOR = 41
#Icon ID to display atk difference ICON_ATK = 1 #Icon ID to display def difference ICON_DEF = 41 #Icon ID to display spi difference ICON_SPI = 21 #Icon ID to display res difference ICON_RES = 133
#Vocab for item in possession TEXT_POSSESSION = "Possession:" #Vocab for item equiped TEXT_EQUIPED = "Equiped:"
#Set this to true if you want to use the item gauge bonus system USE_ITEM_EXP_GAUGE = true #Vocab for the category Bonus of the shop TEXT_SHOP_CATEGORY_BONUS = "Bonus" #Text choice of the window bonus TEXT_ACCEPT_ITEM = "Accept reward" #Text of the gauge level TEXT_GAUGE_LEVEL = "Rank:" #Text of the exp total of the gauge TEXT_GAUGE_TOTAL_EXP = "Total:"
#The max level the gauge can reach. There is no limit. GAUGE_MAX_LEVEL = 10 #Base exp of the gauge. This is used to create the experience table of the gauge GAUGE_BASE_EXP = 500
#In this array, you can choose witch item you will gain at each level of the bonus gauge # Template is: "TYPE ID" TYPE can be ITEM, WEAPON or ARMOR # ID is the ID of the item in database # Each line correspond to one level of the bonus gauge. The first Item in at gauge lvl0 so it's a free item. ITEM_BONUS_TABLE = [ "ITEM 1", #Free item, gauge level 0 "ARMOR 4", #Gauge level 1 "WEAPON 2", # gauge level 2 "ARMOR 8", #gauge level 3 "ITEM 11", #.....I hope you have anderstand ! "WEAPON 13", "ARMOR 18", "ITEM 17", "ITEM 19", "WEAPON 17", "WEAPON 19", "ARMOR 21", "WEAPON 24", "ARMOR 28", ] #don't delete this
#Here you can edit the exp formula at your own risk ! def self.gauge_exp_formula(base_exp, level) return base_exp + (level - 1) * base_exp / 2 #This line can be edited to change the exp formula end
@exp_list[0] = @exp_list[GB_PROD_SHOP::GAUGE_MAX_LEVEL] = 0 for i in 1..GB_PROD_SHOP::GAUGE_MAX_LEVEL @exp_list[i - 1] = GB_PROD_SHOP.gauge_exp_formula(@base_exp, i) end
for bonus in GB_PROD_SHOP::ITEM_BONUS_TABLE bonus.scan(/(.*)[ ](\d+)/i) case $1 when "ITEM" @bonus_table.push($data_items[$2.to_i]) when "ARMOR" @bonus_table.push($data_armors[$2.to_i]) when "WEAPON" @bonus_table.push($data_weapons[$2.to_i]) end #case end #for
end #def
def gain_exp(amount) max_level = GB_PROD_SHOP::GAUGE_MAX_LEVEL @exp += amount @total_exp += amount while @exp >= @exp_list[@level] and @exp_list[@level] > 0 level_up end end #def
if $imported["ItemWorld"] def get_reward item = @bonus_table[@bonus_index] unless @bonus_table[@bonus_index].nil? if item.is_a?(RPG::Item) if GB_Prod::SEPARATE_ITEM_ENABLE has_prefix, has_suffix = false, false index = Separation.create(item) item = $data_items[index] item = Item_World_Randomization.randomize(item) end else has_prefix, has_suffix = false, false index = Separation.create(item) item = $data_weapons[index] if item.is_a?(RPG::Weapon) item = $data_armors[index] if item.is_a?(RPG::Armor)
item = Item_World_Randomization.randomize(item) end
$game_party.gain_item(item, 1) @bonus_index += 1 end else #imported def get_reward item = @bonus_table[@bonus_index] unless @bonus_table[@bonus_index].nil? $game_party.gain_item(item, 1) @bonus_index += 1 end end #imported
end #class
#=============================================================================== # Game_party #=============================================================================== class Game_Party < Game_Unit
if $imported["ItemWorld"] #-------------------------------------------------------------------------- # * overwrite: item_number #-------------------------------------------------------------------------- def item_number(item) number = 0 case item when RPG::Item if GB_Prod::SEPARATE_ITEM_ENABLE for itemp in items number += 1 if itemp.name == $data_items[item.id].name end else number = @items[item.id] number = 0 if number.nil? end when RPG::Weapon for itemp in items number += 1 if itemp.name == $data_weapons[item.id].name end when RPG::Armor for itemp in items number += 1 if itemp.name == $data_armors[item.id].name end end return number end end #imported
#-------------------------------------------------------------------------- # * New mothod: item_number_equip #-------------------------------------------------------------------------- def item_number_equip(item) number = 0 case item when RPG::Weapon for actor in members for equip in actor.equips.compact number += 1 if item.name == equip.name end #for end #for when RPG::Armor for actor in members for equip in actor.equips.compact number += 1 if item.name == equip.name end #for end #for end return number end
class Window_ShopBuy < Window_Selectable attr_accessor :shop_type_index #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize(x, y) super(x, y, 304, 304) @shop_goods = $game_temp.shop_goods @shop_type_index = 0 refresh self.index = 0 end #-------------------------------------------------------------------------- # * Get Item #-------------------------------------------------------------------------- def item return @data[self.index] end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh @data = [] for goods_item in @shop_goods case goods_item[0] when 0 next if @shop_type_index == 1 || @shop_type_index == 2 item = $data_items[goods_item[1]] when 1 next if @shop_type_index == 0 || @shop_type_index == 2 item = $data_weapons[goods_item[1]] when 2 next if @shop_type_index == 0 || @shop_type_index == 1 item = $data_armors[goods_item[1]] end if item != nil @data.push(item) end end @item_max = @data.size create_contents for i in 0...@item_max draw_item(i) end end #-------------------------------------------------------------------------- # * Draw Item # index : item number #-------------------------------------------------------------------------- def draw_item(index) item = @data[index] number = $game_party.item_number(item) enabled = (item.price <= $game_party.gold and number < 99) rect = item_rect(index) self.contents.clear_rect(rect) draw_item_name(item, rect.x, rect.y, enabled) rect.width -= 4 self.contents.draw_text(rect, item.price, 2) end #-------------------------------------------------------------------------- # * Help Text Update #-------------------------------------------------------------------------- def update_help @help_window.set_text(item == nil ? "" : item.description) end end #class
if @item.is_a?(RPG::Weapon) || @item.is_a?(RPG::Armor) $game_party.gain_gold(@item.price/2) $game_party.lose_item(@item, $game_party.item_number(@item)) if GB_PROD_SHOP::USE_ITEM_EXP_GAUGE $item_gauge.gain_exp(@item.price/2) @exp_gauge_window.refresh end elsif @item.is_a?(RPG::Item) if GB_Prod::SEPARATE_ITEM_ENABLE $game_party.gain_gold(@item.price/2) $game_party.lose_item(@item, $game_party.item_number(@item)) if GB_PROD_SHOP::USE_ITEM_EXP_GAUGE $item_gauge.gain_exp(@item.price/2) @exp_gauge_window.refresh end else $game_party.gain_gold(@number_window.number * (@item.price / 2)) $game_party.lose_item(@item, @number_window.number) if GB_PROD_SHOP::USE_ITEM_EXP_GAUGE $item_gauge.gain_exp(@number_window.number * (@item.price / 2)) @exp_gauge_window.refresh end end end
@gold_window.refresh @sell_window.refresh @status_window.refresh @sell_window.active = true @sell_window.visible = true @status_window.visible = false @iw_status_window.visible = true @iw_status_window.refresh(@sell_window.item) end end else #imported #-------------------------------------------------------------------------- # * Confirm Number Input #-------------------------------------------------------------------------- def decide_number_input Sound.play_shop @number_window.active = false @number_window.visible = false case @command_window.index when 0 # Buy
if GB_PROD_SHOP::USE_ITEM_EXP_GAUGE $item_gauge.gain_exp(@number_window.number * @item.price) @exp_gauge_window.refresh end
class Scene_Title < Scene_Base #-------------------------------------------------------------------------- # * Create Game Objects #-------------------------------------------------------------------------- alias gbp_shop_cgo create_game_objects def create_game_objects gbp_shop_cgo $item_gauge = Item_Gauge.new end #def end
class Scene_File #-------------------------------------------------------------------------- # * Alias List #-------------------------------------------------------------------------- alias gbp_shop_wsd write_save_data alias gbp_shop_rsd read_save_data #-------------------------------------------------------------------------- # * Write Save Data # file : write file object (opened) #-------------------------------------------------------------------------- def write_save_data(file) gbp_shop_wsd(file) Marshal.dump($item_gauge, file) end #-------------------------------------------------------------------------- # * Read Save Data # file : file object for reading (opened) #-------------------------------------------------------------------------- def read_save_data(file) gbp_shop_rsd(file) $item_gauge = Marshal.load(file) end end