Jump to content
Rpg²S Forum

*Dinamic Gardening


SIMO696
 Share

Recommended Posts

Dinamic Gardening

Descrizione

 

Lo script permete di piantare dei semi che germoglieranno e cresceranno fino a diventare piante adulte che daranno un prodotto diverso ogni volta...

Autore

 

ForeverZer0, con mia relativa traduzione

Allegati


http://www.mediafire.com/?ijqlqjdnnj3

SCRIPT

 

 

 

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
# Dynamic Gardening
# Autore: ForeverZer0
# Data: 4.14.2010
# Versione : v.1.1
# Traduzione: SIMO696
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
# VERSION HISTORY
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
# -> v.1.1 (4.15.2010)
# - Migliorato il codice
# - Aggiunta la possibilità di creare grafiche diverse per ogni pianta, senza
# dover utilizzare piu' le pagine evento.
# - Molto meno noioso del metodo a eventi: non bisogna piu' cambiare la variabile
# a ogni condizione.
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#
# Spiegazione:
#
# Si tratta di un sistema che permetterà al giocatore di piantare semi di piante
# che cresceranno nel corso del tempo, ogni pianta darà al giocatore un elemento
# quando saranno cresciute. In linea di principio, è quasi esattamente lo stesso
# sistema di Legend of Mana.Le combinazioni di diversi semi si tradurranno in
# prodotti diversi.Ogni pianta avrà la sua crescita timer propria che non mancherà
# di tenere traccia del suo progresso.
#
# Caratteristiche:
#
# - Sono completamente configurabili i tassi di crescita, i risultati e grafici
# per ogni pianta.
# - Può usare un array di oggetti per ogni risultato, in modo che il frutto non
# sia necessariamente lo stesso ogni volta.Ogni timer di sviluppo per la pianta
# è indipendente, e il suo progresso è salvato con il gioco. Setup facile, che
# richiede soltanto un evento: basta utilizzare una chiamata di script di avvio
# evento.
#
# Istruzioni:
#
# - Inserire lo script sotto main
# - Hai bisogno di un evento dotato di 5 pagine. La prima pagina deve essere
# vuota, e ogni pagina a seguire deve avere la condizione di essere switch
# locale = A, B, C e D in ordine. , e ogni pagina deve avere come condizione
# di avvio azione
#
# - Nella prima pagina ci deve essere solo lo script di chiamata:
#
# $scene = Scene_Garden(*THIS_EVENTS_ID*)
#
# - Ogni altra pagina deve avere questo script di chiamata:
#
# $scene = Scene_Harvest(*THIS_EVENTS_ID*)
#
# - Pagine 2-4 dovrebbero avere il loro set di caratteri grafici per aumentare le fasi
# di crescita delle piante.
# - Per la grafica cambia lavoro, devi mettere un commento in cima a pagina 5
# che recita semplicemente "final stage"(senza virgolette)
# - Una volta fatto questo, è possibile copiare e incollare questo evento per
# altrettanti distinti eventi di cui hai bisogno. Devi solo cambiare l'ID
# evento utilizzati nelle chiamate script.
# - Le piante possono essere raccolte velocemente, ma non produrranno nulla
# finché non sono mature
# - Se non vuoi ogni volta, dopo aver raccolto qualcosa avviare la Garden
# scene, usa questo chiama script nella prima pagina:
#
# if !$game_temp.message_window_showing
# $scene = Scene_Garden(*THIS_EVENTS_ID*)
# end
#
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Inizio configurazione
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

SEED_IDS = [33, 34, 35, 36, 37, 38, 39, 40]
# ID degli oggetti del database che sono i semi. Aggiungili nella lista nell'
# ordine di valore /rarità nel vostro gioco

FINAL_ITEM_GRAPHICS = true
# Se è vero, utilizzerà diverse grafiche per la final stage. È necessario mettere
# il commento 'Final stage' nell'ultima pagina, e configurare la grafica delle
# altre pagine.
HARVEST_SE = '056-Right02'
# Questo è il SE che verrà riprodotto quando il giocatore raccoglie la pianta e
# riceve l'oggetto.

module Zer0_CFG
	
	# Definire i tassi di crescita qui. (La media di entrambi i semi da utilizzare)
	
	def self.growth_rates(seed)
		case seed
			# sostituite i numeri con l'ID dei semi che avete inserito nel vostro database
			# e sostituite i numeri per definire il tempo da aspettare prima che la pianta
			# vi possa dare il suo frutto
		when 33 then return 10
		when 34 then return 12
		when 35 then return 15
		when 36 then return 20
		when 37 then return 23
		when 38 then return 25
		when 39 then return 30
		when 40 then return 35
		end
	end
	
	#-------------------------------------------------------------------------------
	# Definisce il risultato finale dei semi. Un elemento casuale dell' array dara'
	# il risultato finale.
	#
	# Ogni seme è assegnato un valore da 0 al numero totale di semi nella lista (SEED_IDS)
	# ed entrambi i valori sono sommati per determinare quale 'produrrà' l'array
	# per il risultato finale.
	# Per questo motivo è importante avera la lista SEED_IDS in ordine di valore/rarità.
	# È possibile trovare il numero totale di casi: per farlo e' necessario sottrarre
	# 1 dal numero totale di semi diversi in SEED_IDS, e moltiplicando questo numero per 2.
	#
	# Es. Se il giocatore usa il primo e l'ultimo seme della lista (SEED_IDS) e ci sono 8 semi in totale
	# nella matrice ...
	
	# FIRST_SEED = 0
	# LAST_SEED = 7 0 + 7 = RESULT
	#
	# Mettendo più copie dello stesso valore in un array, è possibile aumentare le probabilità
	# di ricevere tale elemento rispetto ad un altro nello stesso array.
	#-------------------------------------------------------------------------------
	
	def self.produce(seed)
		case seed
		when 0 then return [41, 42] # Only if both seed are the lowest seeds
		when 1 then return [42, 43]
		when 2 then return [43, 44]
		when 3 then return [44, 45]
		when 4 then return [45, 46]
		when 5 then return [46, 47]
		when 6 then return [47, 48] # Every combination in between
		when 7 then return [48, 49]
		when 8 then return [49, 50]
		when 9 then return [50, 51]
		when 10 then return [51, 52]
		when 11 then return [52, 53]
		when 12 then return [53, 54]
		when 13 then return [54, 55]
		when 14 then return [56] # Only if both seeds are the highest seeds
		end
	end
	
	#-------------------------------------------------------------------------------
	# Definite il grafico utilizzato per ogni possibile risultato dato dalla pianta.
	# Se non si usa questa funzione , non avete bisogno di configurarla, e la grafica
	# del frutto verranno utilizzati in base all'ultima pagina.
	#
	# when ITEM_ID then ['FILENAME', X, Y]
	#
	# ITEM_ID = L' ID dell'oggeto nella voce nel database
	# FILENAME = The name of the character file the needed graphic is on
	# X = La coordinata x dell'immagine corretta sul charset(1 - 4)
	# Y = La coordinata y dell'immagine corretta sul charset(1 - 4)
	#
	# ? X ? Ex. Se l'immagine è stata necessaria in basso
	# 1 2 3 4 a sinistra: X = 1 Y = 4
	# +-----------+
	# 1 ¦ ¦ ¦ ¦ ¦
	# +--+--+--+--¦
	# ? 2 ¦ ¦ ¦ ¦ ¦
	# Y +--+--+--+--¦
	# ? 3 ¦ ¦ ¦ ¦ ¦
	# +--+--+--+--¦
	# 4 ¦ ¦ ¦ ¦ ¦
	# +-----------+
	#-------------------------------------------------------------------------------
	
	def self.final_graphic(item)
		case item
		when 41 then return ['Garden Plants', 1, 4]
		when 42 then return ['Garden Plants', 2, 4]
		when 43 then return ['Garden Plants', 3, 4]
		when 44 then return ['Garden Plants', 4, 4]
		when 45 then return ['Garden Plants', 1, 2]
		when 46 then return ['Garden Plants', 2, 2]
		when 47 then return ['Garden Plants', 3, 2]
		when 48 then return ['Garden Plants', 4, 2]
		when 49 then return ['Garden Plants', 1, 3]
		when 50 then return ['Garden Plants', 2, 3]
		when 51 then return ['Garden Plants', 3, 3]
		when 52 then return ['Garden Plants', 4, 3]
		when 53 then return ['Garden Plants', 1, 1]
		when 54 then return ['Garden Plants', 2, 1]
		when 55 then return ['Garden Plants', 3, 1]
		when 56 then return ['Garden Plants', 4, 1]
		end
	end
	
	#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
	# END CONFIGURATION
	#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
	
	def self.start_growing(seed1, seed2, event)
		s1 = self.growth_rates(seed1)
		s2 = self.growth_rates(seed2)
		rate = ((s1 + s2) / 2) * 40
		p1 = SEED_IDS.index(seed1)
		p2 = SEED_IDS.index(seed2)
		stage1 = (rate / 10) * 2
		stage2 = (rate / 10) * 3
		stage3 = (rate / 10) * 5
		items = self.produce(p1 + p2)
		result = items[rand(items.size)]
		map = $game_map.map_id
		data = [0, stage1, stage2, stage3, result, map, event]
		$game_system.plant_growth.push(data)
	end
end

#-------------------------------------------------------------------------------
# * Game_System
#-------------------------------------------------------------------------------

class Game_System
	
	attr_accessor :plant_growth
	
	alias zer0_plant_timers_init initialize
	def initialize
		zer0_plant_timers_init
		@plant_growth = []
	end
	
	alias zer0_plant_timers_upd update
	def update
		zer0_plant_timers_upd
		unless @plant_growth.empty?
			if $scene.is_a?(Scene_Map) || $scene.is_a?(Scene_Battle)
				update_plant_timers
			end
		end
	end
	
	def update_plant_timers
		@plant_growth.compact!
		@plant_growth.each_index {|i|
		if @plant_growth[i][0] == 0
			if @plant_growth[i][1] > 0
				@plant_growth[i][1] = @plant_growth[i][1] - 1
				if @plant_growth[i][1] == 0
					key = [@plant_growth[i][5], @plant_growth[i][6], 'B']
					$game_self_switches[key] = true
					$game_map.refresh
				end
			end
			if @plant_growth[i][1] == 0 && @plant_growth[i][2] > 0
				@plant_growth[i][2] = @plant_growth[i][2] - 1
				if @plant_growth[i][2] == 0
					key = [@plant_growth[i][5], @plant_growth[i][6], 'C']
					$game_self_switches[key] = true
					$game_map.refresh
				end
			end
			if @plant_growth[i][2] == 0 && @plant_growth[i][3] > 0
				@plant_growth[i][3] = @plant_growth[i][3] - 1
				if @plant_growth[i][3] == 0
					key = [@plant_growth[i][5], @plant_growth[i][6], 'D']
					$game_self_switches[key] = true
					@plant_growth[i][0] = @plant_growth[i][4]
					$game_map.refresh
				end
			end
		end
		}
	end
end

#-------------------------------------------------------------------------------
# * Window_Seed
#-------------------------------------------------------------------------------

class Window_Seed < Window_Selectable
	
	def initialize
		super(160, 304, 320, 160)
		@column_max, self.index = 1, 0
		refresh
	end
	
	def item
		return @seeds[self.index]
	end
	
	def refresh
		if self.contents != nil
			self.contents.dispose
			self.contents = nil
		end
		@seeds = []
		SEED_IDS.each_index {|i|
		if $game_party.item_number(SEED_IDS[i]) > 0
			@seeds.push($data_items[sEED_IDS[i]])
		end
		}
		@item_max = @seeds.size
		if @item_max > 0
			self.contents = Bitmap.new(width - 32, row_max * 32)
			(0...@item_max).each {|i| draw_item(i)}
		end
	end
	
	def draw_item(index)
		item = @seeds[index]
		number = $game_party.item_number(item.id)
		x = 4 + index % 1 * (288 + 32)
		y = index * 32
		rect = Rect.new(x, y, self.width / @column_max - 32, 32)
		self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
		bitmap = RPG::Cache.icon(item.icon_name)
		opacity = self.contents.font.color == normal_color ? 255 : 128
		self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
		self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
		self.contents.draw_text(x + 240, y, 16, 32, ':', 1)
		self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
	end
end

#-------------------------------------------------------------------------------
# * Scene_Garden
#-------------------------------------------------------------------------------

class Scene_Garden
	
	def initialize(event_id)
		@event_id = event_id
		@seed1 = @seed2 = nil
	end
	
	def main
		$game_system.se_play($data_system.decision_se)
		@map = Spriteset_Map.new
		@seed_window = Window_Seed.new
		@confirm_window = Window_Command.new(128, ['Si', 'No'])
		@confirm_window.x, @confirm_window.y = 496, 336
		@confirm_window.active = @confirm_window.visible = false
		@help_window = Window_Help.new
		Graphics.transition
		loop {Graphics.update; Input.update; update; break if $scene != self}
		[@map, @seed_window, @confirm_window, @help_window].each {|w| w.dispose}
	end
	
	def update
		@seed_window.active == true ? update_seed : update_confirm
		update_help
		[@map, @seed_window, @confirm_window, @help_window].each {|w| w.update}
	end
	
	def update_seed
		if Input.trigger?(Input::B)
			$game_system.se_play($data_system.cancel_se)
			$scene = Scene_Map.new if @seed1 == nil
			if @seed1 != nil
				$game_party.gain_item(@seed1.id, 1)
				@seed_window.refresh
				@seed1 = nil
			end
		end
		if Input.trigger?(Input::C)
			if @seed1 == nil
				$game_system.se_play($data_system.decision_se)
				@seed1 = @seed_window.item
				$game_party.lose_item(@seed1.id, 1)
			else
				$game_system.se_play($data_system.decision_se)
				@seed2 = @seed_window.item
				$game_party.lose_item(@seed2.id, 1)
				@seed_window.active = false
				@confirm_window.active = @confirm_window.visible = true
			end
			@seed_window.refresh
		end
	end
	
	def update_confirm
		if Input.trigger?(Input::C)
			if @confirm_window.index == 0
				$game_system.se_play($data_system.decision_se)
				$game_self_switches[[$game_map.map_id, @event_id, 'A']] = true
				$game_map.refresh
				Zer0_CFG.start_growing(@seed1.id, @seed2.id, @event_id)
				$scene = Scene_Map.new
			else
				$game_system.se_play($data_system.cancel_se)
				$game_party.gain_item(@seed1.id, 1)
				$game_party.gain_item(@seed2.id, 1)
				@seed_window.refresh
				@seed1 = @seed2 = nil
				@confirm_window.active = @confirm_window.visible = false
				@seed_window.active = true
			end
		end
		if Input.trigger?(Input::B)
			$game_system.se_play($data_system.cancel_se)
			$game_party.gain_item(@seed1.id, 1)
			$game_party.gain_item(@seed2.id, 1)
			@seed_window.refresh
			@seed1 = @seed2 = nil
			@confirm_window.active = @confirm_window.visible = false
			@seed_window.active = true
		end
	end
	
	def update_help
		if @seed1 == nil && @seed2 == nil
			@help_window.set_text('Scegli quale di questi semi vuoi piantare')
		elsif @seed2 == nil
			@help_window.set_text(@seed1.name + ' + ')
		else
			text = ('vuoi usare questo seme? (' + @seed1.name + ' + ' + @seed2.name + ')')
			@help_window.set_text(text)
		end
	end
end

#-------------------------------------------------------------------------------
# * Scene_Harvest
#-------------------------------------------------------------------------------

class Scene_Harvest
	
	def initialize(event_id)
		@event_id = event_id
	end
	
	def main
		$game_system.se_play($data_system.decision_se)
		@map = Spriteset_Map.new
		@pick_window = Window_Command.new(128, ['Si', 'No'])
		@pick_window.x, @pick_window.y = 256, 336
		@help_window = Window_Help.new
		@value = 0
		$game_system.plant_growth.each_index {|i|
		if $game_system.plant_growth[i][5] == $game_map.map_id &&
			$game_system.plant_growth[i][6] == @event_id
			@value = $game_system.plant_growth[i][0]
		end
		}
		if @value > 0
			@help_window.set_text('Vuoi raccogliere questa pianta?')
		else
			text = 'Niente e cresciuto ancora su questa pianta. Vuoi sradicarla?'
			@help_window.set_text(text)
		end
		Graphics.transition
		loop {Graphics.update; Input.update; update; break if $scene != self}
		[@map, @help_window, @pick_window].each {|w| w.dispose}
	end
	
	def update
		[@map, @help_window, @pick_window].each {|w| w.update}
		if Input.trigger?(Input::C)
			if @pick_window.index == 0
				if @value > 0
					$game_party.gain_item(@value, 1)
					item = $data_items[@value].name
					Audio.se_play('Audio/SE/' + HARVEST_SE, 80, 100)
					$game_temp.message_text = ('Hai ricevuto ' + item + '!')
				else
					$game_system.se_play($data_system.buzzer_se)
				end
				$game_system.plant_growth.each_index {|i|
				if $game_system.plant_growth[i][5] == $game_map.map_id &&
					$game_system.plant_growth[i][6] == @event_id
					$game_system.plant_growth[i] = nil
				end
				}
				['A', 'B', 'C', 'D'].each {|self_sw|
				$game_self_switches[[$game_map.map_id, @event_id, self_sw]] = false}
				$game_map.refresh
			else
				$game_system.se_play($data_system.cancel_se)
				$scene = Scene_Map.new
			end
			$scene = Scene_Map.new
		elsif Input.trigger?(Input::B)
			$game_system.se_play($data_system.cancel_se)
			$scene = Scene_Map.new
		end
	end
end

#-------------------------------------------------------------------------------
# * Sprite_Character
#-------------------------------------------------------------------------------

class Sprite_Character < RPG::Sprite
	
	# This uses a little more coding than needed just to work, but it ensures that
	# this update method will only run if it is absolutely neccessary.
	
	alias zer0_gardening_plant_graphic_upd update
	def update
		if FINAL_ITEM_GRAPHICS
			self.bitmap = RPG::Cache.character(@character.character_name,
			@character.character_hue)
			zer0_gardening_plant_graphic_upd
			if final_stage?(character.id)
				@data = []
				id = character.id
				$game_system.plant_growth.each_index {|i|
				if $game_system.plant_growth[i] != nil &&
					$game_system.plant_growth[i][6] == character.id
					@data[id] = Zer0_CFG.final_graphic($game_system.plant_growth[i][0])
				end
				}
				if @data[character.id] != nil
					self.bitmap = RPG::Cache.character(@data[id][0],
					@character.character_hue)
					width = self.bitmap.width / 4
					height = self.bitmap.height / 4
					x_index = width * (@data[id][1] - 1)
					y_index = height * (@data[id][2] - 1)
					self.src_rect.set(x_index, y_index, width, height)
					self.ox = width / 2
					self.oy = height
				end
			end
		end
	end
	
	def final_stage?(id)
		return false unless @character.is_a?(Game_Event)
		return false unless $game_self_switches[[$game_map.map_id, id, 'D']]
		return false if $game_system.plant_growth.empty?
		return false if @character.list == nil
		return false if character.list[0].code != 108
		return false if character.list[0].parameters != ['Final Stage']
		return true
	end
end

 



Istruzioni per l'uso

 

Tutto all'interno dello script

Bugs e Conflitti Noti


N/A

 

Altri Dettagli

 

Io ho incontrato parecchie difficolta' a farlo funzionare per cui postate qua sotto nel caso non riusciste a capire qualcosa

Edited by Dilos
Script monoriga sistemato.
I'm working for a new project
Link to comment
Share on other sites

Semplicemente stupendo,a me va che una meraviglia e non è molto difficile da configurare.^_^

Complimenti a ForeverZer0 e ovviamente complimenti anche a te SIMO696 per averlo postato e tradotto.XD

PROGETTI IN CORSO:

 

http://img88.imageshack.us/img88/8484/bannerfirmabetatester.jpg

 

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

In chat il mio nickname sarà Aleks o Al, mi pento ancora di essermi messo il nick tamarro di Aliuzz.ç_ç

 

http://img571.imageshack.us/img571/6659/alicei.png

membro ufficiale fondatore n4 di mrfruffolobatuffolo

http://img717.imageshack.us/img717/4789/mrfruffolobanner.jpg

 

 

Rudo:

Ti ringrazio. Ci misi tutto me stesso diversi anni fa per realizzare CrystalQuest. Sebbene la mia visione sia cambiata con il passare del tempo, ci sono molti aspetti che manterrei se dovessi (per assurdo) realizzare una nuova avventura oggi.

 

Questo non accade tutti i giorni,sono commosso.ç_ç

 

 

Orgoglioso membro del trio *o*

Link to comment
Share on other sites

uuh!! :o

giustamente gli si possono cambiare anche le cose... invece della pianta ci metti altra roba... mmm... tipo puoi metterci in cinta una NPC co sto script!! e alla fine ti nasce il figlio!!!! XD XD XD XD XD

 

 

Membro # 8-8-8 [Hachi] della:

http://img3.imageshack.us/img3/9636/bannergm.png

Link to comment
Share on other sites

lol...

Uh dimenticavo di dirvi che nella demo nella cartella della grafica su icone si trovano le immagini dei semi...

quindi e' consigliatissimo scaricarla...

comunque tornando a quello che si puo' fare con questo script si puo' applicare ad alberi...

magari quando nevica si puo' fare in modo che le mappe si coprano sempre piu' di neve e cosi' via...

I'm working for a new project
Link to comment
Share on other sites

  • 6 months later...

ecco una nuova versione dello script domani poi lo aggiungo anche alla prima pagina...

il codice e' stato totalmente riscritto... la cosa che apprezerete di piu' probabilmente e' l'uso di un solo commento invece che 4 appena ho un po' di tempo cmq tradurro' tutte le nuove features

 

 

 

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
=:=:=:=:=:=:=:=:=:
# Dynamic Gardening
# Author: ForeverZer0
# Date: 10.10.2010
# Version: v.2.0
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#                            VERSION HISTORY
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#  v.1.1  (4.15.2010)
#   - Improved coding 
#   - No longer uses game variables, events use self-switches instead
#   - Added ability to create different graphics for every plant, without
#     having to use more event pages
#   - Much less tedious setting up multiple events and changing the every 
#     condition variable.
#  v.2.0  (10.10.2010)
#   - Total re-write. Code has been vastly improved and is much more efficient.
#   - Event setup has been simplified. Now requires only a single comment, and 
#     does not require multiple pages.
#   - Added configurability for the number of stages each item requires.
#   - The timers no longer use Game_System to constantly update, but simply
#     compare themselves with the Graphics.frame_count when the event exists
#     on the current map, which also allows the plants to grow during scenes
#     other than Scene_Map and Scene_Battle.
#   - Got rid of Scene_Harvest. Scene_Garden now handles both aspects, and has
#     been improved.
#   - Added item icons to the help window display.
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#
# Explanation:
#
#   This system allows the player to plant seeds, which will eventually grow 
#   into plants that can be harvested for items. The system is very similar in
#   nature to that found in Legend of Mana. Seed's can be combined in different
#   ways, which will effect the total growth duration, the number of stages the
#   plant passes through, the graphics used, and of course the final result.
#
# Features:
#
#  - Totally configurable growth rates, results, and graphics for every plant.
#  - Can use arrays of items for each result, so the final item is not
#    neccessarily the same every time.
#  - Each plant timer is independent, and its progress is saved with the game.
#  - Easy setup. Need only a single comment in one of the event's pages.
#
# Instructions:
#   
#  - Place script below Debug and above Main
#  - Configure the options below (instructions are with each setting)
#  - Create an event, setting the graphic to whatever you want. This will be the
#    graphics used when nothing is growing on the plant.
#  - At the very top event's page, place a comment that reads "Garden Event", 
#    omitting the quotation marks.
#  - As long as the page's conditions are met, this event can be clicked on to
#    initiate the Garden scene, and can grow plants.
#  - Note that plants can be harvested early, but they will yield nothing until 
#    they are ripe.
#
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#  BEGIN CONFIGURATION
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
#===============================================================================
# ** Garden
#===============================================================================

module Garden
 
 SEED_IDS = [1, 2, 3, 4, 5, 6, 7, 8]
 # IDs of the items in the database that are seeds. Add them into the array in
 # the order of value/rarity in your game
 
 HARVEST_SE = '056-Right02'
 # This is the SE that will be played when the player harvests the plant.
 
 SEED_DISPLAY = true
 # If true, all seeds will be displayed in the seed window, including those 
 # that the player does not have, though they will be disabled. If false, only
 # seeds that that the player currently has will be displayed.
 
 # Define the growth rates here. (the average of both seeds will be used)
 def self.growth_rate(seed)
   case seed
   # when SEED_ID then SECONDS
   when 1 then return 10
   when 2 then return 12
   when 3 then return 15
   when 4 then return 20
   when 5 then return 23
   when 6 then return 25 
   when 7 then return 30
   when 8 then return 35
   end
 end
 
#-------------------------------------------------------------------------------
# Define the number of stages that each item uses. The stages will still cycle
# in the same order, but only use up to the defined number of them before going
# to the final graphic. This will not effect the duration that the seed takes to 
# grow, only how many times the graphic changes.
# 
# You do not have to define anything that uses a three stage configuration.
#-------------------------------------------------------------------------------
 def self.number_stages(result)
   case result
   when 8..16
     return 4
   when 17..24
     return 5
   else
     return 3
   end
 end
 
#-------------------------------------------------------------------------------
# Define the final result of the seeds. A random item from the array will be
# given as the final result.
#  
# Each seed is given a value from 0 to the total number of seeds in the SEED_IDS
# array, and both values are added together to determine which 'produce' array
# will be used for the final result. This is why it is important that you have 
# the SEED_IDS array in order of value/rarity. You can find the total number of 
# cases you will need by subtracting 1 from the total number of different seeds 
# in SEED_IDS, and multiplying that number by 2.
#
#   EX. Player uses one each of the first and last seed in the SEED_IDS array,
#       and there are 8 total seeds in the array...
#
#       FIRST_SEED = 0
#       LAST_SEED = 7         0 + 7 = RESULT
#
# By placing multiple copies of the same value in an array, you can increase
# the odds of receiving that item over another in the same array.
#-------------------------------------------------------------------------------

 def self.produce(seed)
   case seed
   when 0 then return [9, 10]      # Only if both seed are the lowest seeds
   when 1 then return [10, 11]
   when 2 then return [12, 13]
   when 3 then return [13, 14]
   when 4 then return [14, 15]
   when 5 then return [15, 16]
   when 6 then return [16, 17]      # Every combination in between
   when 7 then return [17, 18]
   when 8 then return [18, 19]
   when 9 then return [19, 20]
   when 10 then return [20, 21]
   when 11 then return [21, 22]
   when 12 then return [22, 23]
   when 13 then return [23, 24]
   when 14 then return [24]         # Only if both seeds are the highest seeds
   end
 end
 
#------------------------------------------------------------------------------- 
#  Define graphics for the final results, and each stage. Follow the below 
#  template to set it up.
#
#   when ITEM_ID/STAGE then ['FILENAME', X, Y]
#
#   ITEM_ID = The ID number of the item in your database
#   STAGE = The stage during which to display the graphic
#
#   FILENAME = The name of the character file the needed graphic is on
#   X = The x-coordinate of the correct picture on the charset (1 - 4)
#   Y = The y-coordinate of the correct picture on the charset (1 - 4)
#
#           ? X ?             Ex.   If the needed graphic was in the bottom
#         1  2  3  4                left corner:   X = 1    Y = 4 
#       +-----------+                    
#     1 ¦  ¦  ¦  ¦  ¦
#       +--+--+--+--¦
#  ?  2 ¦  ¦  ¦  ¦  ¦
#  Y    +--+--+--+--¦
#  ?  3 ¦  ¦  ¦  ¦  ¦
#       +--+--+--+--¦
#     4 ¦  ¦  ¦  ¦  ¦
#       +-----------+
#-------------------------------------------------------------------------------

 def self.stage_graphics(stage)
   return case stage
   when 0 then ['Plants1', 1, 1]
   when 1 then ['Plants1', 2, 3]
   when 2 then ['Plants1', 2, 1]
   when 3 then ['Plants1', 4, 2]
   when 4 then ['Plants1', 2, 4]
   end
 end

 def self.final_graphic(item)
   return case item   
   when 9 then  ['Garden Plants', 1, 4]
   when 10 then ['Garden Plants', 1, 4]
   when 11 then ['Garden Plants', 2, 4]
   when 12 then ['Garden Plants', 3, 4]
   when 13 then ['Garden Plants', 4, 4]
   when 14 then ['Garden Plants', 1, 2]
   when 15 then ['Garden Plants', 2, 2]   
   when 16 then ['Garden Plants', 3, 2]
   when 17 then ['Garden Plants', 4, 2]
   when 18 then ['Garden Plants', 1, 3]
   when 19 then ['Garden Plants', 2, 3]
   when 20 then ['Garden Plants', 3, 3]
   when 21 then ['Garden Plants', 4, 3]
   when 22 then ['Garden Plants', 1, 1]
   when 23 then ['Garden Plants', 2, 1]
   when 24 then ['Garden Plants', 3, 1]
   end
 end
 
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#  END CONFIGURATION
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

 def self.plant_seeds(seed1, seed2, event_id)
   # Calculate the total duration and final result of the seed combination.
   duration = ((self.growth_rate(seed1) + self.growth_rate(seed2)) / 2) * 40
   items = self.produce(SEED_IDS.index(seed1) + SEED_IDS.index(seed2))
   # Selects a random item from the possible results.
   result = items[rand(items.size)]
   # Calculate number of stages and break total duration up into them. 
   number = self.number_stages(result)
   stage_duration, stages = duration / number, []
   (1..number).each {|i| stages.push(i*stage_duration + Graphics.frame_count) }
   # Add the data at the proper key and index of the garden hash.
   $game_system.garden[$game_map.map_id][event_id] = [0, stages, result]
 end
 
 def self.harvest(event_id)
   # Returns result item ID of event's plant, then resets.
   data = $game_system.garden[$game_map.map_id][event_id]
   # Returns nil if plant is not done growing.
   result = data[0] == data[1].size ? data[2] : nil
   $game_system.garden[$game_map.map_id][event_id] = [-1, [0], nil]
   return result
 end
end

#===============================================================================
# ** Game_Event
#===============================================================================

class Game_Event
 
 alias zer0_garden_event_refresh refresh
 def refresh
   # Normal refresh method.
   zer0_garden_event_refresh
   return if @page == nil
   # Setup the Garden Data for this event if comment code is found.
   if @page.list[0].code == 108 && @page.list[0].parameters[0] == 'Garden Event'
     setup_garden_event
   # Apply changes to events graphic, direction, and pattern.  
     if @data[0] != -1
       if @data[0] == @data[1].size
         graphic = Garden.final_graphic(@data[2])
       else
         graphic = Garden.stage_graphics(@data[0])
       end
       # Set the graphic simply by changing the character name, direction, and
       # pattern. Sprite_Character will change the image in the next update. 
       @character_name = graphic[0]
       @pattern, @direction = graphic[1] - 1, graphic[2] * 2
     else
       # Reset graphic to original image.
       @direction, @pattern = @original_direction, @original_pattern
       @character_name = @page.graphic.character_name
     end
   end
 end
 
 def setup_garden_event
   # Create a key in the garden hash for current map ID if it does not exist.
   unless $game_system.garden.has_key?(@map_id)
     $game_system.garden[@map_id] = []
   end
   # Add the event to the array for this map if it does not exist.
   if $game_system.garden[@map_id][@id] == nil
     $game_system.garden[@map_id][@id] = [-1, [0], nil]
   end
   # Create instance of this events growth data.
   @data = $game_system.garden[@map_id][@id]
   # Find current growth stage of this event.
   stages = @data[1]
   if stages.all? {|stage| stage == 0 }
     @data[0] = -1
   elsif stages.all? {|stage| Graphics.frame_count > stage }
     @data[0] = stages.size
   else
     value = stages.find {|stage| Graphics.frame_count < stage }
     @data[0] = stages.index(value)
   end
   # Set Garden Event flag.
   @garden_event = true
 end
 
 alias zer0_garden_event_start start
 def start
   # Redefine the 'start' method if Garden Event flag is present.
   if @garden_event
     $scene = Scene_Garden.new(@id, @data[0] != -1)
     return
   end
   zer0_garden_event_start
 end
 
 alias zer0_garden_event_upd update
 def update
   if @garden_event && ![-1, @data[1].size].include?(@data[0])
     # Check to see if plant is ready for next stage.
     if Graphics.frame_count > @data[1][@data[0]]
       # Increase growth stage and change graphic.
       @data[0] += 1
       refresh
     end
     return
   end      
   zer0_garden_event_upd
 end
end

#===============================================================================
# ** Game_System
#===============================================================================

class Game_System
 
 attr_accessor :garden
 
 alias zer0_garden_system_init initialize
 def initialize
   zer0_garden_system_init
   # Initialize garden hash, which holds garden event data for each map.
   @garden = {}
 end
end

#===============================================================================
# * Window_Seed
#===============================================================================

class Window_Seed < Window_Selectable
 
 def initialize
   super(160, 304, 320, 160)
   self.index = 0
   refresh
 end
 
 def refresh
   # Clear the bitmap.
   self.contents = self.contents.dispose if self.contents != nil
   # Determine what seeds to display.
   @seeds = Garden::SEED_IDS.collect {|id| $data_items[id] }
   unless Garden::SEED_DISPLAY
     @seeds.reject! {|seed| $game_party.item_number(seed.id) < 1 }
   end
   @item_max = @seeds.size
   # Draw the items on the bitmap.
   if @item_max > 0
     self.contents = Bitmap.new(width - 32, @item_max * 32)
     @seeds.each_index {|i|
       item = @seeds[i]
       number = $game_party.item_number(item.id)
       self.contents.font.color = number > 0 ? normal_color : disabled_color
       opacity = number > 0 ? 255 : 128
       # Find icon bitmap and set it to window, and draw the text.
       bitmap = RPG::Cache.icon(item.icon_name)
       self.contents.blt(4, i*32+4, bitmap, Rect.new(0, 0, 24, 24), opacity)
       self.contents.draw_text(32, i*32, 288, 32, item.name)
       self.contents.draw_text(-32, i*32, 288, 32, ':', 2)
       self.contents.draw_text(-4, i*32, 288, 32, number.to_s, 2)
     }
   end
 end
 
 def seed
   # Returns currently highlighted seed item.
   return @seeds[self.index]
 end
end

#===============================================================================
# * Scene_Garden
#===============================================================================

class Scene_Garden
 
 def initialize(event_id, harvest)
   @event_id, @harvest = event_id, harvest
   # Play SE to give impression that scene never changed.
   $game_system.se_play($data_system.decision_se)
   $game_player.straighten
 end
 
 def main 
   # Create map sprite and required windows.
   @map, @help_window = Spriteset_Map.new, Window_Help.new
   # Create Confirmation window.
   @confirm_window = Window_Command.new(128, ['Yes', 'No'])
   @confirm_window.x, @confirm_window.y = 496, 336
   # Initialize sprites array. Used to handle all the sprites together.
   @sprites = [@map, @help_window, @confirm_window]
   # Create seed window if plant is not being harvested.
   unless @harvest
     @seed_window = Window_Seed.new
     @sprites.push(@seed_window)
     @seed_window.active = @seed_window.visible = false
     @help_window.set_text('Plant seeds here?')
   else
     @data = $game_system.garden[$game_map.map_id][@event_id]
     if @data[0] == @data[1].size
       text = 'This plant is ripe. Would you like to harvest it?'
     else
       text = 'Nothing is growing yet on this plant. Harvest it anyway?'
     end
     @help_window.set_text(text)
   end
   # Transition instantly then start main loop.
   Graphics.transition(0)
   loop { Graphics.update; Input.update; update; break if $scene != self }
   # Dispose of all the sprites.
   @sprites.each {|sprite| sprite.dispose }
   # Have map refresh to update any changes made.
   $game_map.need_refresh = true
 end
 
 def update
   @sprites.each {|sprite| sprite.update }
   # Branch update method depending on what window is active.
   if @confirm_window.active
     update_confirm
   elsif @seed_window != nil && @seed_window.active
     update_seed_select
   end
 end
 
 def update_confirm
   if Input.trigger?(Input::B)
     # Branch by what action is being canceled.
     if @harvest
       back_to_map
     else
       @seed1 == nil ? back_to_map : cancel_seed_selection
     end
   elsif Input.trigger?(Input::C)
     # Branch by what action is being confirmed.
     if @harvest
       if @confirm_window.index == 0
         item_id = Garden.harvest(@event_id)
         if item_id != nil
           @confirm_window.active = @confirm_window.visible = false
           # Gain item, play the harvest SE, then return to the map.
           $game_party.gain_item(item_id, 1)
           $game_system.se_play(RPG::AudioFile.new(Garden::HARVEST_SE, 80, 100))
           show_results($data_items[item_id])
           $scene = Scene_Map.new
         else
           back_to_map
         end
       else
         back_to_map
       end
     else
       # If asking if player would like to plant seeds at this location.
       if @seed1 == nil
         if @confirm_window.index == 0
           @seed_window.active = @seed_window.visible = true
           @confirm_window.active = @confirm_window.visible = false
           @help_window.set_text('Which seeds would you like to plant?')
         else
           back_to_map
           return
         end
       else # If confirming seed selection.
         if @confirm_window.index == 0
           # Plant seeds and return to map.
           Garden.plant_seeds(@seed1.id, @seed2.id, @event_id)
           $scene = Scene_Map.new
         else # If canceling seed selection
           cancel_seed_selection
           return
         end
       end
       $game_system.se_play($data_system.decision_se)
     end
   end
 end
 
 def show_results(result)
   @help_window.contents.clear
   # Display the message in the help window.
   @help_window.draw_item_name(result, 0, 0)
   cw = @help_window.contents.text_size(result.name).width + 32
   @help_window.contents.draw_text(cw, 0, 608, 32, ' received!')
   # Call Input.update to the clear key press.
   Input.update
   # Loop until it is pressed again.
   until Input.trigger?(Input::C)
     Graphics.update; Input.update; update
   end
 end
 
 def cancel_seed_selection
   # Play cancel SE, reset seeds, and activate/deactivate windows.
   $game_system.se_play($data_system.cancel_se)
   @seed_window.active = @seed_window.visible = true
   @confirm_window.active = @confirm_window.visible = false
   @help_window.set_text('Which seeds would you like to plant?')
   @seed1 = @seed2 = nil
 end
 
 def back_to_map
   # Play cancel SE and return to map.
   $game_system.se_play($data_system.cancel_se)
   $scene = Scene_Map.new
 end
 
 def update_seed_select
   if Input.trigger?(Input::B)
     # If first seed is selected, go back to re-select, else return to map.
     if @seed1 != nil
       $game_party.gain_item(@seed1.id, 1)
       @seed1 = nil
       @seed_window.refresh
       $game_system.se_play($data_system.cancel_se)
     else
       back_to_map
     end
   elsif Input.trigger?(Input::C)
     # Play Cancle SE if displayed and party has none.
     if $game_party.item_number(@seed_window.seed.id) < 1
       $game_system.se_play($data_system.buzzer_se)
       return
     end
     $game_system.se_play($data_system.decision_se)
     # Set first seed if not defined, else set the second seed and continue.
     if @seed1 == nil
       @seed1 = @seed_window.seed
       $game_party.lose_item(@seed1.id, 1)
     else
       @seed2, @seed_window.active = @seed_window.seed, false
       $game_party.lose_item(@seed2.id, 1)
       @confirm_window.active = @confirm_window.visible = true
     end
     # Refresh seed window to show changes in inventory.
     set_help
     @seed_window.refresh
   end
 end
 
 def set_help
   # Clear help window.
   @help_window.contents.clear
   # Draw items
   text = @seed2 != nil ? 'Plant these two seeds?' : 'Select second seed...'
   @help_window.set_text(text)
   @help_window.draw_item_name(@seed1, 224, 0)
   if @seed2 != nil
     cw = @help_window.contents.text_size(@seed1.name).width + 320
     @help_window.draw_item_name(@seed2, cw, 0)
   end
 end
end

 

 

qui trovate la nuova demo

http://www.mediafire.com/?t2apb5hdh43u524

I'm working for a new project
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...