Salve, allora, si lo so, devo fare la domanda sul topic dello script, ma siccome la non ho avuto risposta la faccio qui.
La mia domanda è se è possibile creare una ricetta che possa essere fatta solo se una SPECIFICA persona nel party ha raggiunto quel livello. Per esempio, se voglio che il mio personaggio numero 8 sia di un certo livello e che solo lui possa creare un certo oggetto come l' arma numero 54. si può fare ?
Questo è lo script:
#===============================================================================
# Autore : kingartur2(3)
# Versione : 1.6
# Nome : Alchemy Qualcosa
#===============================================================================
# --- Istruzioni ---
# Apporre nelle note di un oggetto, arma o armatura
# ricetta[INGREDIENTI](PREZZO*opzionale)(LIVELLO*opzionale)
# INGREDIENTI :
# per gli ingredienti è sufficiente apporre in seguenza tutto ciò che serve
# per fare l'oggetto seguendo questa legenda :
# NUMEROtipo_oggettoID_OGGETTO
# dove:
# NUMERO = il numero di oggetti di quell'id necessari a creare l'oggetto
# tipo_oggetto - "i" se è un oggetto
# - "w" se è un arma
# - "a" se è un armatura
# ID_OGGETTO = id di quell'oggetto nel database
# esempio : 2a4 + 3w1 + 5i2
#---------------- ---------------- ----------------
# PREZZO
# scrivere un numero al posto di prezzo, si può anche non metterlo proprio per
# specificare che l'oggetto non ha costo in denaro
#---------------- ---------------- ----------------
# LIVELLO
# se almeno un personaggio del party ha raggiunto il livello specificato allora
# l'oggetto apparirà nella lista, altrimenti pur avendo gli ingredienti non
# apparirà, come per il prezzo si può anche omettere
#---------------- ---------------- ----------------
# ESEMPI GENERALI :
# ricetta[2a6+5w4+1i1] --- una ricetta dove sono richiesti solo oggetti
# ricetta[2a6+5w4+1i1](200) ---- una ricetta dove oltre agli oggetti bisogna pagare
# ricetta[2a6+5w4+1i1](lv:10) --- una ricetta che compare solo se almeno uno nel party è livello 10
# ricetta[2a6+5w4+1i1](200)(lv:10) --- una ricetta che compare solo se almeno uno nel party è livello 10 e che bisgona anche pagare
#===============================================================================
# --- Come verranno visualizzate le ricette ---
# Una volta richiamata la scena del processo alchemico verranno visualizzate nel
# menu tutte le ricette di cui si ha almeno un oggetto elencato negli ingredienti
# Cioè se per fare una spada ho bisgono di acciaio e legno e non ho nessuno dei
# due allora quella ricetta non mi verrà proprio visualizzata. Se invece ho un
# unità di legno o un unità di acciao allora potrò visualizzarla nelle scelte.
#===============================================================================
# --- Richiamare la scena per l'Alchimia ---
# Nulla di più facile :D
# call script
# SceneManager.call(Scene_Alchemy)
#===============================================================================
# --- Configurazione ---
# Seguire le istruzioni sopra a ogni variabile :D
#===============================================================================
module Alchemy
#-----------------------------------------------------------------------------
# PREPARAZIONE = "stringa"
# Seleziona il messaggio di default e di benvenuto della schermata
#-----------------------------------------------------------------------------
PREPARAZIONE = "Scegli una ricetta e controlla se hai tutto"
#-----------------------------------------------------------------------------
# NO_INGREDIENTI = "stringa"
# Seleziona il messaggio che sarà visualizzato quando si cerca di sintetizzare
# qualcosa di cui non se ne hanno tutti gli ingredienti
#-----------------------------------------------------------------------------
NO_INGREDIENTI = "Non hai tutti gli ingredienti!!"
#-----------------------------------------------------------------------------
# NO_DENARO = "stringa"
# Seleziona il messaggio che sarà visualizzato quando si cerca di sintetizzare
# qualcosa di cui si hanno tutti gli ingredienti ma non abbastanza soldi
#-----------------------------------------------------------------------------
NO_DENARO = "Non hai abbastanza soldi!! Pezzente >_<!!"
#-----------------------------------------------------------------------------
# NO_SELEZIONATO = "stringa"
# Nella malaugurata ipotesi che per qualche bug viene selezionato un quadratino
# vuoto avremo già pronto il nostro messaggio di errore :D
#-----------------------------------------------------------------------------
NO_SELEZIONATO = "Non hai selezionato nulla!!"
#-----------------------------------------------------------------------------
# TUTTO_FATTO = "stringa"
# Quando finalmente il nostro player riuscirà a sintetizzare qualcosa gli uscirà
# questo messaggio accompagnato dal nome dell'oggetto
#-----------------------------------------------------------------------------
TUTTO_FATTO = "Bravo!!Hai realizzato"
end
#-------------------------------------------------------------------------------
# FINE CONFIGURAZIONE(se tocchi qualcosa dopo questo il mondo imploderà, attento
#-------------------------------------------------------------------------------
module RPG
class BaseItem
def ricette
if not @ricette.nil?
return @ricette
end
@ricette = {}
scritto = @note.clone
line = scritto.scan(/(.+)$/)
for string in line
string = string[0]
if string[/ricetta\[(.+)\](\((\d+)\)|)(\(lv:(\d+)\)|)/]
result = $1.to_s
if $3.nil?
gold = 0
else
gold = $3.to_i
end
if $5.nil?
level = 0
else
level = $5.to_i
end
result = result.scan(/(\d+[iwa]\d+)/)
tluser = []
for i in result
i[0][/(\d+)([iwa])(\d+)/]
case $2
when "i"
tluser.push([$1.to_i, $data_items[$3.to_i]])
when "w"
tluser.push([$1.to_i, $data_weapons[$3.to_i]])
when "a"
tluser.push([$1.to_i, $data_armors[$3.to_i]])
end
end
@ricette[@ricette.length] = {}
@ricette[@ricette.length - 1]["ingredienti"] = tluser
@ricette[@ricette.length - 1]["gold"] = gold
@ricette[@ricette.length - 1]["level"] = level
end
end
return @ricette
end
end
end
class Alche_Item_Window < Window_ItemList
attr_reader :data2
attr_reader :data
attr_accessor :info_window
attr_accessor :price_window
def col_max
return 1
end
def include?(item)
return true
end
def update_help
super
@info_window.refresh(item, @data2[self.index])
@price_window.refresh(item, @data2[self.index])
end
def current_item
return @data[index]
end
def enable?(item, index = index)
return false if item.nil?
return false if item.ricette[@data2[index]]["gold"] > $game_party.gold
ingredienti = item.ricette[@data2[index]]["ingredienti"]
for i in ingredienti
if not $game_party.item_number(i[1]) >= i[0]
return false
end
end
return true
end
def draw_item(index)
item = @data[index]
if item
rect = item_rect(index)
rect.width -= 4
draw_item_name(item, rect.x, rect.y, enable?(item, index))
end
end
def make_item_list
@data = []
@data2 = []
for i in ($data_items + $data_weapons + $data_armors)
id2 = -1
next if not i.is_a?(RPG::BaseItem)
for id in i.ricette.keys
id2 += 1
for ingredienti in i.ricette[id]["ingredienti"]
if $game_party.item_number(ingredienti[1]) >= 1 and
$game_party.highest_level >= i.ricette[id]["level"]
@data.push(i)
@data2.push(id2)
break
end
end
end
end
end
end
class Window_AlchePrice < Window_Base
def initialize
super(0, 0, window_width, fitting_height(1))
@recorded = []
refresh
end
def window_width
return 160
end
def draw_currency_value(value, unit, x, y, width)
cx = text_size(unit).width
change_color(normal_color)
draw_text(x, y, width - cx - 2, line_height, value, 2)
change_color(system_color)
draw_text(x, y, width, line_height, unit, 2)
end
def refresh(item = @recorded[0], id_ricetta = @recorded[1])
@recorded[0] = item
@recorded[1] = id_ricetta
contents.clear
if not item.nil?
prezzo = item.ricette[id_ricetta]["gold"]
draw_currency_value("Prezzo :", prezzo, 4, 0, contents.width - 8)
end
end
def open
refresh
super
end
end
class Window_Info < Window_Base
def initialize(x, y, w, h)
super(x, y, w, h)
@recorded = []
end
def refresh(item = @recorded[0], id_ricetta = @recorded[1])
@recorded[0] = item
@recorded[1] = id_ricetta
contents.clear
change_color(system_color)
contents.font.bold = true
draw_text(0, 0, contents.width, line_height, "Materiali")
draw_text(0, 0, contents.width, line_height, " Req.", 1)
draw_text(0, 0, contents.width, line_height, "Poss.", 2)
contents.font.bold = false
y = line_height
if not item.nil?
ingredienti = item.ricette[id_ricetta]["ingredienti"]
for oggetto in ingredienti
enabled = ($game_party.item_number(oggetto[1]) >= oggetto[0].to_i)
change_color(normal_color, enabled)
draw_icon(oggetto[1].icon_index, 0, y, enabled)
draw_text(20, y, contents.width / 3 * 2, line_height, oggetto[1].name)
draw_text(0, y, contents.width, line_height, " " + oggetto[0].to_s, 1)
draw_text(0, y, contents.width, line_height, $game_party.item_number(oggetto[1]).to_s, 2)
y += line_height
end
end
end
end
class Scene_Alchemy < Scene_Base
def start
super
create_background
create_help_window
create_note_window
create_info_window
create_alche_gold_window
create_alche_price_window
create_alche_item_window
@timer_note = 0
end
def update
super
update_note_window
if @alche_item_window.active and Input.trigger?(Input::B)
Sound.play_cancel
SceneManager.return
end
if @alche_item_window.active and Input.trigger?(Input::C)
item = @alche_item_window.current_item
if item.nil?
Sound.play_buzzer
return
end
ricetta = item.ricette[@alche_item_window.data2[@alche_item_window.index]]
if @alche_item_window.current_item_enabled?
for ingredienti in ricetta["ingredienti"]
$game_party.lose_item(ingredienti[1], ingredienti[0])
end
$game_party.lose_gold(ricetta["gold"])
$game_party.gain_item(item, 1)
@alche_gold_window.refresh
@alche_item_window.refresh
@alche_item_window.update_help
if @alche_item_window.index >= (@alche_item_window.data.size - 1)
@alche_item_window.index = @alche_item_window.data.size - 1
end
@note_window.set_text(Alchemy::TUTTO_FATTO + " #{item.name}")
@timer_note = 150
Sound.play_use_item
else
if @alche_item_window.current_item.nil?
@note_window.set_text(Alchemy::NO_SELEZIONATO)
else
if check_all_item(ricetta)
@note_window.set_text(Alchemy::NO_DENARO)
else
@note_window.set_text(Alchemy::NO_INGREDIENTI)
end
end
@timer_note = 150
Sound.play_buzzer
end
end
end
def terminate
super
dispose_background
end
def create_background
@background_sprite = Sprite.new
@background_sprite.bitmap = SceneManager.background_bitmap
@background_sprite.color.set(16, 16, 16, 128)
end
def create_help_window
@help_window = Window_Help.new
@help_window.viewport = @viewport
end
def create_note_window
@note_window = Window_Help.new(1.5)
@note_window.viewport = @viewport
@note_window.width = @note_window.width
@note_window.y = Graphics.height - @note_window.height
@note_window.set_text(Alchemy::PREPARAZIONE)
end
def create_info_window
@info_window = Window_Info.new(0, 0, 100, 100)
@info_window.x = Graphics.width / 5 * 2
@info_window.y = @help_window.height
@info_window.height = Graphics.height - @help_window.height - @note_window.height
@info_window.width = Graphics.width / 5 * 3
@info_window.create_contents
end
def create_alche_gold_window
@alche_gold_window = Window_Gold.new
@alche_gold_window.x = @info_window.width + @info_window.x - @alche_gold_window.width
@alche_gold_window.y = @info_window.y + @info_window.height - @alche_gold_window.height
end
def create_alche_price_window
@alche_price_window = Window_AlchePrice.new
@alche_price_window.x = @info_window.x
@alche_price_window.y = @info_window.y + @info_window.height - @alche_price_window.height
end
def create_alche_item_window
@alche_item_window = Alche_Item_Window.new(0, 0, 100, 100)
@alche_item_window.y = @help_window.height + @help_window.y
@alche_item_window.height = Graphics.height - @help_window.height - @note_window.height
@alche_item_window.width = Graphics.width / 5 * 2
@alche_item_window.create_contents
@alche_item_window.help_window = @help_window
@alche_item_window.info_window = @info_window
@alche_item_window.price_window = @alche_price_window
@alche_item_window.index = 0
@alche_item_window.refresh
@alche_item_window.activate
end
def update_note_window
if @timer_note > 0
@timer_note -= 1
if @timer_note == 0
@note_window.set_text(Alchemy::PREPARAZIONE)
end
end
end
def check_all_item(ricetta)
for oggetto in ricetta["ingredienti"]
if not $game_party.item_number(oggetto[1]) >= oggetto[0]
return false
end
end
return true
end
def dispose_background
@background_sprite.dispose
end
end