Alchemy Pot
Descrizione
Questo script simula il pentolone alchemico di Dragon Quest VIII.
Per chi non lo conoscesse il pentolone alchemico permette di "buttare" nel pentolone oggetti per crearne uno nuovo.
Script
Spoiler
#============================================================================== # ** Alchemy Pot #------------------------------------------------------------------------------ # Autore: The Sleeping Leonhart # Versione: 1.4 # Data di rilascio: 10/07/2010 #------------------------------------------------------------------------------ # Descrzione: # Questo script simula il pentolone alchemico di Dragon Quest VIII. # Per chi non lo conoscesse il pentolone alchemico permette di "buttare" # nel pentolone oggetti per crearne uno nuovo. #------------------------------------------------------------------------------ # Versione: # 1.0 (06/12/2008): Versione Base. # 1.1 (06/12/2008): Aggiunta la possibilità di ottenere oggetti da formule errate. # 1.2 (08/12/2008): Fixato un Bug bug nella item window. # Ora si possono visualizzare immediatamente i risultati. # 1.3 (09/12/2008): Aggiunto un indicatore del tempo residuo. # Aggiunto filtro per gli ingredienti inutilizzabili # 1.4 (10/07/2010): Bugfix. #------------------------------------------------------------------------------ # Istruzioni: # Per chiamare il pentolone usate il comando script degli eventi ed inserite: # $scene = Scene_AlchemyPot.new # Premere A per passare dalla finestra di conferma a quella degli oggetti e viceversa. # Per personalizzare lo script andate nella sezione Configurazione e Vocabolario. #============================================================================== #============================================================================== # Configurazione #============================================================================= module AlchemyPot #=====Non Toccare========================================================= i = load_data("Data/Items.rxdata") w = load_data("Data/Weapons.rxdata") a = load_data("Data/Armors.rxdata") #========================================================================= #========================================================================= # Formula: Imposta le formule del pentolone. #------------------------------------------------------------------------- # Sintassi: # Formula[iId1, ...] = [iId2, time] # Parametri: # iId1: id degli ingredienti, usate i[id] per gli oggetti, w[id] per le armi, # a[id] per le armature. id è il numero dell'oggetto nel database. # iId2: id dell'oggetto ottenuto, usate i[id] per gli oggetti, w[id] per le armi, # a[id] per le armature. id è il numero dell'oggetto nel database. # time: numero di minuti richiesti per la ricetta. #========================================================================= Formula = {} Formula[[i[1], i[1]]] = [i[2], 0.02] Formula[[i[1], w[1]]] = [w[2], 0] Formula[[a[1], w[2]]] = [a[2], 4] Formula[[i[1], i[1], i[1]]] = [i[3], 1] Formula[[i[1], i[1], i[1], i[1], i[1]]] = [i[8], 1] #========================================================================= # UnusableItem: Definisce gli ingredienti non usabili nel pentolone #------------------------------------------------------------------------- # Sintassi: # UnusableItem = [iId, ...] # Parametri: # iId: id degli ingredienti, usate i[id] per gli oggetti, w[id] per le armi, # a[id] per le armature. id è il numero dell'oggetto nel database. #========================================================================= UnusableItem = [i[3], w[5], a[4]] #========================================================================= # MaxItem: Numero massimo di oggetti inserbili nel pentolone. #------------------------------------------------------------------------- # Sintassi: # MaxItem = n # Parametri: # n: Numero massimo di oggetti inserbili nel pentolone. #========================================================================= MaxItem = 5 #========================================================================= # FailureItem: Imposta gli oggetti ricevuti con formule sbagliate #------------------------------------------------------------------------- # Sintax: # FailureItem = [iId, ...] # Parameter: # iId: id dell'oggetto ottenuto, usate i[id] per gli oggetti, w[id] per le armi, # a[id] per le armature. id è il numero dell'oggetto nel database. #========================================================================= FailureItem = [i[1], w[4], a[5]] #========================================================================= # FailureTime: Imposta il tempo per ottenere l'oggetto sbagliato #------------------------------------------------------------------------- # Sintax: # FailureItem = time # Parameter: # time: numero di minuti richiesti per la ricetta. #========================================================================= FailureTime = 1 #========================================================================= # MapBG: Imposta la mappa come background #------------------------------------------------------------------------- # Sintassi: # MapBG = b # Parametri: # b: true per impostare la mappa come background, false per il background nero. #========================================================================= MapBG = true #========================================================================= # TimeMeter: Imposta le immagini della barra del tempo #------------------------------------------------------------------------- # Sintassi: # TimeMeter = [emptymeter, fullmeter] o nil # Parametri: # emptymeter = picture che rappresenta la barra del tempo vuota # fullmeter = picture che rappresenta la barra del tempo piena # nil = mettere nil per non visualizzare la barra del tempo #========================================================================= TimeMeter = ["MeterEmpty", "MeterFull"] end #============================================================================== # Vocabolario #============================================================================= module Vocab #Pulsante di Conferma AlchemyPotGo = "Avvia" #Pulsante di uscita AlchemyPotExit = "Esci" #Formula Corretta AlchemyPotRightFormula = "Credo che possa funzionare!" #Formula Inesistente AlchemyPotWrongFormula = "Non credo che possa funzionare!" #Ricetta Terminata AlchemyPotFormulaFinished = "La ricetta è pronta!" #Ricetta non Terminata AlchemyPotFormulaNotFinished = "La ricetta non è ancora pronta!" #Oggetto ottenuto AlchemyPotObtained = "Hai ottenuto:" end class Game_Party attr_accessor :alchemy_pot alias tslalchemypot_gameparty_initialize initialize def initialize tslalchemypot_gameparty_initialize @alchemy_pot = [] end end class Window_Base def draw_graphical_bar(x, y, barravuota, barrapiena, corrente, max) barra_vuota = Bitmap.new("Graphics/Pictures/"+barravuota) barra_piena = Bitmap.new("Graphics/Pictures/"+barrapiena) taglio = corrente.to_f / max.to_f cwp = barra_piena.width cwv = barra_vuota.width chp = barra_piena.height chv = barra_vuota.height taglio = taglio*cwp src_rect = Rect.new(0, 0, taglio, chp) self.contents.blt(32+x-cwp/4, 18+y-chp/2, barra_piena, src_rect) src_rect = Rect.new(taglio, 0, cwv-taglio, chv) self.contents.blt(32+x-cwv/4+taglio, 18+y-chv/2, barra_vuota, src_rect) end end class Window_AlchemyPotItem < Window_Selectable def initialize super(32, 96, 312, 312) @column_max = 10 self.index = 0 refresh end def item return @data[self.index] end def enable?(item) return $game_party.item_can_use?(item) end def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] for item in $data_items if $game_party.item_number(item.id) > 0 and item != nil @data.push(item) if check(item) end end for item in $data_weapons if $game_party.weapon_number(item.id) > 0 and item != nil @data.push(item) if check(item) end end for item in $data_armors if $game_party.armor_number(item.id) > 0 and item != nil @data.push(item) if check(item) end end @item_max = @data.size @row_max = @data.size / 10 if @item_max > 0 self.contents = Bitmap.new(width - 32, row_max * 28) for i in 0...@item_max draw_item(i) end end end def draw_item(index) item = @data[index] case item when RPG::Item number = $game_party.item_number(item.id) when RPG::Weapon number = $game_party.weapon_number(item.id) when RPG::Armor number = $game_party.armor_number(item.id) end x = index % @column_max * 28 y = index / @column_max * 28 rect = Rect.new(x, y, 32, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(item.icon_name) self.contents.blt(x, y, bitmap, Rect.new(0, 0, 24, 24)) self.contents.font.size = 12 self.contents.draw_text(12 + x, 8 + y, 24, 24, number.to_s) end def update_help @help_window.set_text(item == nil ? "" : item.name) end def page_row_max return (self.height - 32) / 28 end def top_row return self.oy / 28 end def top_row=(row) super self.oy = row * 28 end def update_cursor_rect super x = @index % @column_max * 28 y = @index / @column_max * 28 - self.oy self.cursor_rect.set(x, y, 24, 24) end def check(item) for i in AlchemyPot::UnusableItem if i.id == item.id and i.class == item.class return false end end return true end end class Window_AlchemyPotPot < Window_Base def initialize super(454, 96, 28 + 32, 28 * AlchemyPot::MaxItem + 32) self.contents = Bitmap.new(width - 32, height - 32) refresh end def refresh(pot = []) self.contents.clear @data = pot.clone @data.push(nil) if @data == [] @item_max = @data.size for i in 0...@item_max draw_item(i) end end def draw_item(index) item = @data[index] if item != nil y = index * 28 bitmap = RPG::Cache.icon(item.icon_name) self.contents.blt(0, y, bitmap, Rect.new(0, 0, 24, 24)) end end end class Window_AlchemyPotResult < Window_Base def initialize super(0, 192, 320, 64) self.contents = Bitmap.new(width - 32, height - 32) self.width = [self.contents.text_size(Vocab::AlchemyPotObtained).width + 240, 640].min self.contents = Bitmap.new(width - 32, height - 32) self.x = 272 - self.width / 2 refresh end def refresh(item = nil) self.contents.clear self.contents.font.color = normal_color self.contents.draw_text(0, 4, self.width - 64, 24, Vocab::AlchemyPotObtained) draw_item_name(item, self.contents.text_size(Vocab::AlchemyPotObtained).width + 2, 0) end end class Window_PotTimeMeter < Window_Base def initialize(a = 0) super(420, 400, 192, 64) self.contents = Bitmap.new(width - 32, height - 32) self.opacity = 0 refresh(a) end def refresh(a) if AlchemyPot::TimeMeter != nil self.contents.clear a = 0 if a == nil b = $game_party.alchemy_pot[2] b = (Graphics.frame_count - a) * 100 if b == nil b += 1 if b == 0 draw_graphical_bar(0, 0, AlchemyPot::TimeMeter[0], AlchemyPot::TimeMeter[1], Graphics.frame_count-a, b) end end end class Scene_AlchemyPot def main @map = Spriteset_Map.new if AlchemyPot::MapBG create_command_window @help_window = Window_Help.new @item_window = Window_AlchemyPotItem.new @item_window.help_window = @help_window @pot_window = Window_AlchemyPotPot.new @result_window = Window_AlchemyPotResult.new @result_window.visible = false @meter = Window_PotTimeMeter.new($game_party.alchemy_pot[1]) @ready = false if $game_party.alchemy_pot != [] if $game_party.alchemy_pot[0][0] == "Wrong" @ingredients = $game_party.alchemy_pot[0][1].clone item = AlchemyPot::FailureItem[rand(AlchemyPot::FailureItem.size)] else @ingredients = $game_party.alchemy_pot[0].clone item = AlchemyPot::Formula[find_recipe(@ingredients)][0] end @pot_window.refresh(@ingredients) @item_window.active = false if Graphics.frame_count - $game_party.alchemy_pot[1] >= $game_party.alchemy_pot[2] @help_window.set_text(Vocab::AlchemyPotFormulaFinished) case item when RPG::Item $game_party.gain_item(item.id, 1) when RPG::Weapon $game_party.gain_weapon(item.id, 1) when RPG::Armor $game_party.gain_armor(item.id, 1) end @result_window.refresh(item) $game_party.alchemy_pot = [] @ready = true else @help_window.set_text(Vocab::AlchemyPotFormulaNotFinished) end else @ingredients = [] end Graphics.transition loop do Graphics.update Input.update update if $scene != self break end end Graphics.freeze @map.dispose if AlchemyPot::MapBG @command_window.dispose @help_window.dispose @item_window.dispose @pot_window.dispose @result_window.dispose @meter.dispose end def update @help_window.update @command_window.update @item_window.update @pot_window.update @result_window.update @meter.update if @command_window.active update_command_selection elsif @item_window.active update_item_selection elsif @ready and @result_window.visible == false if Input.trigger?(Input::C) $game_system.se_play($data_system.decision_se) @result_window.visible = true @result_window.z = 105 return end elsif @result_window.visible if Input.trigger?(Input::C) $game_system.se_play($data_system.decision_se) @ingredients = [] @ready = false @result_window.visible = false @item_window.active = true @item_window.refresh @pot_window.refresh return end else if Input.trigger?(Input::C) $game_system.se_play($data_system.decision_se) $scene = Scene_Map.new end end if $game_party.alchemy_pot[1] != nil @meter.refresh($game_party.alchemy_pot[1]) if Graphics.frame_count - $game_party.alchemy_pot[1] >= $game_party.alchemy_pot[2] $scene = Scene_AlchemyPot.new end end end def create_command_window s1 = Vocab::AlchemyPotGo s2 = Vocab::AlchemyPotExit @command_window = Window_Command.new(96, [s1, s2]) @command_window.active = false @command_window.x = 430 @command_window.y = 304 end def update_item_selection if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) if @ingredients == [] $scene = Scene_Map.new else pop = @ingredients.pop case pop when RPG::Item $game_party.gain_item(pop.id, 1) when RPG::Weapon $game_party.gain_weapon(pop.id, 1) when RPG::Armor $game_party.gain_armor(pop.id, 1) end @item_window.refresh @pot_window.refresh(@ingredients) end elsif Input.trigger?(Input::C) if @ingredients.size < AlchemyPot::MaxItem and @item_window.item != nil $game_system.se_play($data_system.decision_se) item = @item_window.item @ingredients.push(item) case item when RPG::Item $game_party.gain_item(item.id, -1) when RPG::Weapon $game_party.gain_weapon(item.id, -1) when RPG::Armor $game_party.gain_armor(item.id, -1) end @item_window.refresh @pot_window.refresh(@ingredients) else $game_system.se_play($data_system.buzzer_se) end elsif Input.trigger?(Input::A) $game_system.se_play($data_system.decision_se) @item_window.active = false @command_window.active = true end end def update_command_selection if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) exit elsif Input.trigger?(Input::C) case @command_window.index when 0 if @ingredients.size > 1 $game_system.se_play($data_system.decision_se) start_alchemy else $game_system.se_play($data_system.buzzer_se) end when 1 $game_system.se_play($data_system.decision_se) exit end elsif Input.trigger?(Input::A) $game_system.se_play($data_system.decision_se) @item_window.active = true @command_window.active = false end end def exit for item in @ingredients case item when RPG::Item $game_party.gain_item(item.id, 1) when RPG::Weapon $game_party.gain_weapon(item.id, 1) when RPG::Armor $game_party.gain_armor(item.id, 1) end end $scene = Scene_Map.new end def start_alchemy rec = find_recipe(@ingredients) if rec != nil && AlchemyPot::Formula[rec] != nil @help_window.set_text(Vocab::AlchemyPotRightFormula) $game_party.alchemy_pot[0] = rec.clone $game_party.alchemy_pot[1] = Graphics.frame_count $game_party.alchemy_pot[2] = AlchemyPot::Formula[rec][1] * Graphics.frame_rate * 60 @command_window.active = false return end @help_window.set_text(Vocab::AlchemyPotWrongFormula) if AlchemyPot::FailureItem.size > 0 $game_party.alchemy_pot[0] = ["Wrong", @ingredients.clone] $game_party.alchemy_pot[1] = Graphics.frame_count $game_party.alchemy_pot[2] = AlchemyPot::FailureTime * Graphics.frame_rate * 60 @command_window.active = false return else for item in @ingredients case item when RPG::Item $game_party.gain_item(item.id, 1) when RPG::Weapon $game_party.gain_weapon(item.id, 1) when RPG::Armor $game_party.gain_armor(item.id, 1) end end @ingredients = [] @item_window.refresh @pot_window.refresh(@ingredients) end end def find_recipe(items) for i in AlchemyPot::Formula.keys formula = item_sort(i) ingredients = item_sort(items) if formula == ingredients return i end end end def item_sort(formula) i = []; w = []; a = [] for item in 0...formula.size i.push(formula[item].id) if formula[item].is_a?(RPG::Item) w.push(formula[item].id) if formula[item].is_a?(RPG::Weapon) a.push(formula[item].id) if formula[item].is_a?(RPG::Armor) end a.sort!; i.sort!; w.sort! formula = [] for type in [i, w, a] for item in type formula.push($data_items[item]) if type == i formula.push($data_weapons[item]) if type == w formula.push($data_armors[item]) if type == a end end end end
Istruzioni per l'uso
Per chiamare il pentolone usate il comando script degli eventi ed inserite:
$scene = Scene_AlchemyPot.new
Premere A per passare dalla finestra di conferma a quella degli oggetti e viceversa.(A inteso come tasto di RpgMaker non la lettera della tastiera!)
Bugs e Conflitti Noti
N/A
Altri Dettagli
Non bisogna mettere necessariamente gli oggetti nello stesso ordine della formula.
Modificato da Apo, 14 March 2013 - 21:53 PM.
applicato il tag code