Jump to content
Rpg²S Forum

*Trance System


Valentino
 Share

Recommended Posts

Trance System



Descrizione



Questo script emula la Trance di FF9, cioè subiti abbastanza colpi ci si trasforma automaticamente in Trance con lo sblocco di nuove abilità.


Autore


Avon Valentino (Io)



Allegati

Script:

 

#----------------------------Trance System------------------------------
#Script creato da Valentino Avon
#Se usate questo script, creditatemi ;)
#Questo script emula la trance di FF9: Subiti abbastanza danni dal nemico, ci
#si trasforma in modalità trance sbloccando abilità più potenti e potenziando
#di un po' la forza, l'agilità, la destrezza e l'intelligenza.
#il sistema offre solo una base di quella che è veramente la trance di ff9, in
#quanto si limita a sbloccare nuove abilità.
#La grafica non è delle migliori ma può essere migliorata.
module Trance
	#nomi che verranno sostituiti al comando "skill" nell elenco dei comandi quando
	#in trance.
	ACTOR_COMMAND = {1 => "Segreto", 2 => "Caccia", 7=> "Soccorso", 8 => "Distruzione"}
	DEFAULT_COMMAND = "P. Celato" #nome default
end
#abilità utilizzabili dalle trance
TRANCE_SKILL = [2,11,58,62]
#animazione visualizzata alla trasformazione
ANIMAZIONE_TRANCE = 101
class Game_Actor < Game_Battler
	attr_accessor :trance
	attr_accessor :barra_trance
	attr_accessor :trance_command
	alias vale_setup setup
	def setup(actor_id)
		@trance = false
		@barra_trance = 0
		if Trance::ACTOR_COMMAND[actor_id] != nil
			@trance_command = Trance::ACTOR_COMMAND[actor_id]
		else
			@trance_command = Trance::DEFAULT_COMMAND
		end
		vale_setup(actor_id)
	end
	alias vale_base_str base_str
	def base_str
		n = $data_actors[@actor_id].parameters[2, @level]
		n += n/5 if self.trance
		vale_base_str
		return [[n, 1].max, 999].min
	end
	alias vale_base_dex base_dex
	def base_dex
		n = $data_actors[@actor_id].parameters[3, @level]
		n += n/5 if self.trance
		vale_base_dex
		return [[n, 1].max, 999].min
	end
	alias vale_base_agi base_agi
	def base_agi
		n = $data_actors[@actor_id].parameters[4, @level]
		n += n/5 if self.trance
		vale_base_agi
		return [[n, 1].max, 999].min
	end
	alias vale_base_int base_int
	def base_int
		n = $data_actors[@actor_id].parameters[5, @level]
		n += n/5 if self.trance
		vale_base_int
		return [[n, 1].max, 999].min
	end
end
class Window_Base < Window
	def draw_actor_trance(actor, x, y)
		self.contents.font.color = normal_color
		unless actor.trance
			self.contents.draw_text(x,y,120, 32,"Trance: " + actor.barra_trance.to_s + "%")
		else
			self.contents.draw_text(x,y,170, 32,"Trance: Attiva!")
		end
	end
end
class Scene_Battle
	alias vale_p3_setup_command_window phase3_setup_command_window
	def phase3_setup_command_window
		if @active_battler != nil and @active_battler.trance == true and @active_battler.barra_trance != 0
			s1 = $data_system.words.attack
			s2 = @active_battler.trance_command
			s3 = $data_system.words.guard
			s4 = $data_system.words.item
			@actor_command_window.dispose unless @actor_index == $game_party.actors.size
			@actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
			@actor_command_window.draw_item(1,Color.new(255, 255, 64, 255))
			@actor_command_window.y = 160
			@actor_command_window.back_opacity = 160
		else
			s1 = $data_system.words.attack
			s2 = $data_system.words.skill
			s3 = $data_system.words.guard
			s4 = $data_system.words.item
			@actor_command_window.dispose unless @actor_index == $game_party.actors.size
			@actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
			@actor_command_window.y = 160
			@actor_command_window.back_opacity = 160
			@actor_command_window.active = true
			@actor_command_window.visible = true
		end
		vale_p3_setup_command_window
	end
	alias vale_update_phase4_step5 update_phase4_step5
	def update_phase4_step5
		for target in @target_battlers
			if @active_battler.is_a?(Game_Actor)
				if @active_battler.trance == true
					@active_battler.barra_trance -= 50
				end
				if @active_battler.barra_trance <= 0
					@active_battler.trance = false
					@active_battler.barra_trance = 0
				end
			end
			if target.is_a?(Game_Actor)
				if target.damage.is_a?(Numeric) and target.damage > 0 and target.hp > 0
					barra = (target.damage*2) / (target.maxhp/30)
					target.barra_trance += barra unless target.trance
					if barra <= 0
						target.barra_trance += 1 unless target.trance
					end
				end
				if target.barra_trance > 100 and target.hp > 0
					target.barra_trance = 100
					target.animation_id = ANIMAZIONE_TRANCE
					target.trance = true
				end
				if target.hp == 0
					target.barra_trance = 0
				end
			end
		end
		@status_window.refresh
		@phase4_step = 6
		vale_update_phase4_step5
	end
	alias valentino_update_phase3_basic_command update_phase3_basic_command
	def update_phase3_basic_command
		if Input.trigger?(Input::C)
			case @actor_command_window.index
			when 0 # attack
				$game_system.se_play($data_system.decision_se)
				# Set action
				@active_battler.current_action.kind = 0
				@active_battler.current_action.basic = 0
				start_enemy_select
			when 1 # skill
				$game_system.se_play($data_system.decision_se)
				@active_battler.current_action.kind = 1
				start_skill_select unless @active_battler.trance
				start_trance_select if @active_battler.trance
			when 2
				$game_system.se_play($data_system.decision_se)
				@active_battler.current_action.kind = 0
				@active_battler.current_action.basic = 1
				phase3_next_actor
			when 3 # item
				$game_system.se_play($data_system.decision_se)
				@active_battler.current_action.kind = 2
				start_item_select
			end
			return
		end
		valentino_update_phase3_basic_command
	end
	def start_trance_select
		@skill_window = Window_Trance.new(@active_battler)
		@skill_window.help_window = @help_window
		@actor_command_window.active = false
		@actor_command_window.visible = false
	end
	alias valentino_make_basic_action_result make_basic_action_result
	def make_basic_action_result
		if @active_battler.current_action.basic == 1
			@help_window.set_text($data_system.words.guard, 1)
			if @active_battler.is_a?(Game_Actor)
				if @active_battler.trance == true
					@active_battler.barra_trance -= 50
					if @active_battler.barra_trance <= 0
						@active_battler.trance = false
						@active_battler.barra_trance = 0
					end
				end
			end
			return
		end
		valentino_make_basic_action_result
	end
	alias vale_battle_end battle_end
	def battle_end(result)
		for actor in $game_party.actors
			if actor.trance
				actor.trance = false
				actor.barra_trance = 0
			end
		end
		vale_battle_end(result)
	end
end
class Window_Skill < Window_Selectable
	alias vale_refresh refresh
	def refresh
		vale_refresh
		@data = []
		for i in 0...@actor.skills.size
			skill = $data_skills[@actor.skills[i]]
			if skill != nil
				unless TRANCE_SKILL.include?(skill.id)
					@data.push(skill)
				end
			end
		end
		@item_max = @data.size
		if @item_max > 0
			self.contents = Bitmap.new(width - 32, row_max * 32)
			for i in 0...@item_max
				draw_item(i)
			end
		end
	end
end
class Window_Trance < Window_Selectable
	def initialize(actor)
		super(0, 128, 640, 352)
		@actor = actor
		@column_max = 2
		refresh
		self.index = 0
		if $game_temp.in_battle
			self.y = 64
			self.height = 256
			self.back_opacity = 160
		end
	end
	def skill
		return @data[self.index]
	end
	def refresh
		if self.contents != nil
			self.contents.dispose
			self.contents = nil
		end
		@data = []
		for i in 0...@actor.skills.size
			skill = $data_skills[@actor.skills[i]]
			if skill != nil
				if TRANCE_SKILL.include?(skill.id)
					@data.push(skill)
				end
			end
		end
		@item_max = @data.size
		if @item_max > 0
			self.contents = Bitmap.new(width - 32, row_max * 32)
			for i in 0...@item_max
				draw_item(i)
			end
		end
	end
	def draw_item(index)
		skill = @data[index]
		if @actor.skill_can_use?(skill.id)
			self.contents.font.color = normal_color
		else
			self.contents.font.color = disabled_color
		end
		x = 4 + index % 2 * (288 + 32)
		y = index / 2 * 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(skill.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, 204, 32, skill.name, 0)
		self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
	end
	def update_help
		@help_window.set_text(self.skill == nil ? "" : self.skill.description)
	end
end
class Window_MenuStatus < Window_Selectable
	alias vale_refresh refresh
	def refresh
		self.contents.clear
		vale_refresh
		@item_max = $game_party.actors.size
		for i in 0...$game_party.actors.size
			x = 64
			y = i * 116
			actor = $game_party.actors[i]
			draw_actor_trance(actor, x + 236,y)
		end
	end
end
class Window_BattleStatus < Window_Base
	alias vale_refresh refresh
	def refresh
		self.contents.clear
		@item_max = $game_party.actors.size
		for i in 0...$game_party.actors.size
			actor = $game_party.actors[i]
			actor_x = i * 160 + 4
			draw_actor_hp(actor, actor_x, 32, 120)
			draw_actor_sp(actor, actor_x, 48, 120)
			draw_actor_trance(actor, actor_x, 72)
		end
		vale_refresh
	end
end

 

 



EDIT Reso più leggero e compatibile lo script.
Demo Link:
http://www.mediafire.com/download.php?b5z91nygxnk9ikc

Istruzioni per l'uso

Trovate tutto all'interno dello script, se lo usate creditatemi per favore :wink:


Bugs e Conflitti Noti


N/A


Altri Dettagli


La grafica non è il massimo, ma il concetto è quello :)

Edited by Flame
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...