• Benvenuto in Making Videogames!
  • Dai sfogo alla tua fantasia!
  • Crea il tuo Videogioco!
Benvenuto ospite! Login Registrati




Valutazione discussione:
  • 0 voto(i) - 0 media
  • 1
  • 2
  • 3
  • 4
  • 5
[SCRIPT] Pentolone Alchemico
#1
DESCRIZIONE:
Lo script serve a creare un pentolone alchemico, dove "buttando" alcuni oggetti, se ne possono creare altri... Come fare le pozioni in Harry Potter xD

AUTORE/I:
The Sleeping Leonhart.

ISTRUZIONI:
Mettere lo script sopra Main.

Per chiamare il pentolone usate il comando script degli eventi ed inserite:
Codice:
$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!)

SCRIPT:
[SPOILER]
Codice:
#==============================================================================
# ** Alchemy Pot
#------------------------------------------------------------------------------
#  Autore: The Sleeping Leonhart
#  Versione: 1.4
#  Data di rilascio: 10/07/2001
#------------------------------------------------------------------------------
#  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.
#------------------------------------------------------------------------------
#  Version:
#    1.0 (07/10/2008): Versione Base.
#    1.1 (06/12/2008): Aggiunta l'opzione Failure Item.
#    1.2 (08/12/2008): Ora si possono vedere immediatamente i risultati.
#    1.3 (09/12/2008): Aggiunto un time meter.
#                      Aggiunto un filtro per gli oggetti inusabili.
#    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.
#==============================================================================
 
#==============================================================================
#  Configuration
#=============================================================================
module AlchemyPot
  #=====NON TOCCARE=========================================================
  i = load_data("Data/Items.rvdata")
  w = load_data("Data/Weapons.rvdata")
  a = load_data("Data/Armors.rvdata")
  #=========================================================================
 
  #=========================================================================
  #  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], 1]
  Formula[[i[1], w[1]]] = [w[2], 2]
  Formula[[a[1], w[2]]] = [a[2], 4]
  #=========================================================================
  #  UnusableItem: Definisce gli oggetti che non possono essere messi nel pentolone
  #-------------------------------------------------------------------------
  #  Sintax:
  #    UnusableItem  = [iId, ...]
  #  Parameter:
  #    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 ogetti ottenuti se si sbaglia formula
  #-------------------------------------------------------------------------
  #  Sintassi:
  #    FailureItem = [iId, ...]
  #  Parametri:
  #    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 creare l'oggetto sbagliato
  #-------------------------------------------------------------------------
  #  Sintassi:
  #    FailureItem = time
  #  Parametri:
  #    time: numero di minuti richiesti per la ricetta.
  #=========================================================================
  FailureTime = 1
  #=========================================================================
  #  TimeMeter: Imposta le immagini per la 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 = nil
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, 80, 292, 292)
    @column_max = 10
    self.index = 0
    refresh
  end
  def item
    return @data[self.index]
  end
  def include?(item)
    return false if item == nil
    if $game_temp.in_battle
      return false unless item.is_a?(RPG::Item)
    end
    return true
  end
  def item_rect(index)
    rect = Rect.new(0, 0, 0, 0)
    rect.width = 24
    rect.height = 24
    rect.x = index % @column_max * 26
    rect.y = index / @column_max * 26
    return rect
  end
  def enable?(item)
    return $game_party.item_can_use?(item)
  end
  def refresh
    @data = []
    for item in $game_party.items
      next unless include?(item)
      @data.push(item) if check(item)
    end
    @data.push(nil) if include?(nil)
    @item_max = @data.size
    create_contents
    for i in 0...@item_max
      draw_item(i)
    end
  end
  def draw_item(index)
    rect = item_rect(index)
    self.contents.clear_rect(rect)
    item = @data[index]
    if item != nil
      number = $game_party.item_number(item)
      x = index % @column_max * 26
      y = index / @column_max * 26
      draw_icon(item.icon_index, x, y)
      self.contents.font.size = 12
      self.contents.draw_text(10 + x, 6 + y, 24, 24, number.to_s)
    end
  end
  def update_help
    @help_window.set_text(item == nil ? "" : item.name)
  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, 80, 26 + 32, 26 * AlchemyPot::MaxItem + 32)
    refresh
  end
  def refresh(pot = [])  
    self.contents.clear
    @data = pot.clone
    @data.push(nil) if @data == []
    @item_max = @data.size
    create_contents
    for i in 0...@item_max
      draw_item(i)
    end
  end
  def draw_item(index)
    item = @data[index]
    if item != nil
      y = index * 26
      draw_icon(item.icon_index, 0, y)
    end
  end
end
 
class Window_AlchemyPotResult < Window_Base
  def initialize
    super(0, 180, 272, WLH + 32)
    self.width = [self.contents.text_size(Vocab::AlchemyPotObtained).width + 192, 544].min
    self.x = 272 - self.width / 2
    create_contents
    refresh
  end
  def refresh(item = nil)
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.draw_text(0, 0, self.width - 40, WLH, 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(180, 360, 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
      draw_graphical_bar(0, 0, AlchemyPot::TimeMeter[0], AlchemyPot::TimeMeter[1], Graphics.frame_count-a, b)
    end
  end
end
 
class Scene_AlchemyPot < Scene_Base
  def start
    super
    create_menu_background
    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)
        $game_party.gain_item(item, 1)
        @result_window.refresh(item)
        $game_party.alchemy_pot = []
        @ready = true
      else
        @help_window.set_text(Vocab::AlchemyPotFormulaNotFinished)
      end
    else
      @ingredients = []
    end
  end
 
  def terminate
    super
    dispose_menu_background
    dispose_command_window
    @help_window.dispose
    @item_window.dispose
    @pot_window.dispose
    @meter.dispose
  end
 
  def update
    super
    update_menu_background
    @help_window.update
    @command_window.update
    @item_window.update
    @pot_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)
        Sound.play_decision
        @result_window.visible = true
        return
      end
    elsif @result_window.visible
      if Input.trigger?(Input::C)      
        Sound.play_decision
        @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)      
        Sound.play_decision
        $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 dispose_command_window
    @command_window.dispose
  end
 
  def update_item_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      if @ingredients == []
        $scene = Scene_Map.new
      else
        $game_party.gain_item(@ingredients.pop, 1)
        @item_window.refresh
        @pot_window.refresh(@ingredients)
      end
    elsif Input.trigger?(Input::C)
      if @ingredients.size < AlchemyPot::MaxItem and @item_window.item != nil
        Sound.play_decision
        item = @item_window.item
        @ingredients.push(item)
        $game_party.gain_item(item, -1)
        @item_window.refresh
        @pot_window.refresh(@ingredients)
      else
        Sound.play_buzzer
      end
    elsif Input.trigger?(Input::A)
      Sound.play_decision
      @item_window.active = false
      @command_window.active = true
    end
  end
 
  def update_command_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      exit
    elsif Input.trigger?(Input::C)
      case @command_window.index
      when 0
        if @ingredients.size > 1
          Sound.play_decision
          start_alchemy
        else
          Sound.play_buzzer
        end
      when 1
        Sound.play_decision
        exit
      end
    elsif Input.trigger?(Input::A)
      Sound.play_decision
      @item_window.active = true
      @command_window.active = false
    end
  end
 
  def exit
    for item in @ingredients
      $game_party.gain_item(item, 1)
    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
        $game_party.gain_item(item, 1)
      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
      case formula[item]
      when RPG::Item
        i.push(formula[item].id)
        i.sort!
      when RPG::Weapon
        w.push(formula[item].id)
        w.sort!
      when RPG::Armor
        a.push(formula[item].id)
        a.sort!
      end
    end
    formula = []
    for item in i
      formula.push($data_items[item])
    end
    for item in w
      formula.push($data_weapons[item])
    end
    for item in a
      formula.push($data_armors[item])
    end
    return formula
  end
end
[/SPOILER]


BUG E CONFLITTI NOTI:
Nessuno.
 
Rispondi
#2
Avrei 3 domande:
1) E' compatibile con VX ace?
2) Dove si deve inserire " $scene = Scene_AlchemyPot.new " ?
3) Come devo fare affinché il menù si apra quando il personaggio interagisce con un oggetto (vorrei che il menù si aprisse quando il personaggio interagisce con un tavolo).
 
Rispondi
#3
1) Non saprei (forse Vx e Vx Ace hanno linguaggio scripting leggermente diverso);
2) devi realizzare un evento con comando "call script";
3) stessa cosa del 2, ti basta realizzare un evento con il comando "call script", la grafica di un tavolo e come trigger di attivazione "Action key".
 
Rispondi
#4
Riesco solo a trovare il comando "Chiama evento comune" e all'interno di questo non c'è il comando chiama evento ma sempre "chiama evento comune
 
Rispondi
#5
Mmm non so (io uso rmxp), nelle pagine dei comandi eventi ci dovrebbe essere... hai versione eng o ita? Prova a cercare chiama script o cose del genere.
 
Rispondi
  


Vai al forum:


Browsing: 1 Ospite(i)