#==============================================================================
# Rozdawanie punktów co poziom [VXAce]
#==============================================================================
# Autor: Ayene
# www.ultimateam.pl
#==============================================================================
# Skrypt umożliwia rozwój postaci poprzez zwiększanie jej statystyk dzięki
# dodatkowym punktom, które otrzymuje po uzyskaniu poziomu.
# Instalacja: Umieść skrypt nad Main.
#==============================================================================
# By wywołać okno rozdawania punktów użyj polecenia 'Script' i wpisz:
# SceneManager.call(Scene_Upgrade)
#==============================================================================
module Ayene
POINTS_PER_LEVEL = 5 # liczba punktów co poziom
IN_MENU = true # widoczne w menu
COMMAND_UPGRADE = 'Rozdaj' # nazwa komendy w menu
end
#==============================================================================
# ** Window_Points
#==============================================================================
class Window_Points < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
def initialize(actor)
super(97, 33, 350, 350)
@actor = actor
refresh
activate
end
#--------------------------------------------------------------------------
# * Actor
#--------------------------------------------------------------------------
def actor=(actor)
return if @actor == actor
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_block1 (line_height * 0)
draw_horz_line(line_height * 4)
draw_block2 (line_height * 5)
end
#--------------------------------------------------------------------------
# * Draw Block 1
#--------------------------------------------------------------------------
def draw_block1(y)
draw_actor_face(@actor, 8, y)
draw_actor_name(@actor, 150, y + line_height * 0 + 12)
draw_actor_level(@actor, 150, y + line_height * 1 + 12)
draw_actor_points(@actor, 150, y + line_height * 2 + 12)
draw_actor_graphic(@actor, 270, y + line_height * 3)
end
#--------------------------------------------------------------------------
# * Draw Block 2
#--------------------------------------------------------------------------
def draw_block2(y)
draw_parameters(32, y)
end
#--------------------------------------------------------------------------
# * Draw Horizontal Line
#--------------------------------------------------------------------------
def draw_horz_line(y)
line_y = y + line_height / 2 - 1
contents.fill_rect(0, line_y, contents_width, 2, line_color)
end
#--------------------------------------------------------------------------
# * Line Color
#--------------------------------------------------------------------------
def line_color
color = normal_color
color.alpha = 48
color
end
#--------------------------------------------------------------------------
# * Draw Parameters
# x : draw spot x-coordinate
# y : draw spot y-coordinate
#--------------------------------------------------------------------------
def draw_parameters(x, y)
8.times {|i| draw_actor_param(@actor, x, y + line_height * i, i) }
end
#--------------------------------------------------------------------------
# * Draw Level
# actor : actor
# x : draw spot x-coordinate
# y : draw spot y-coordinate
#--------------------------------------------------------------------------
def draw_actor_level(actor, x, y)
change_color(system_color)
draw_text(x, y, 64, line_height, Vocab::level)
change_color(normal_color)
draw_text(x + 64, y, 24, line_height, actor.level, 2)
end
#--------------------------------------------------------------------------
# * Draw Points
# actor : actor
# x : draw spot x-coordinate
# y : draw spot y-coordinate
#--------------------------------------------------------------------------
def draw_actor_points(actor, x, y)
change_color(system_color)
draw_text(x, y, 64, line_height, "Punkty")
change_color(normal_color)
draw_text(x + 64, y, 24, line_height, actor.points, 2)
end
end
#==============================================================================
# ** Window_PointsCommand
#==============================================================================
class Window_PointsCommand < Window_Command
#--------------------------------------------------------------------------
# * Object Initialization
# x : window X coordinate
# y : window Y coordinate
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y)
@actor = nil
self.opacity = 0
end
#--------------------------------------------------------------------------
# * Actor
#--------------------------------------------------------------------------
def actor=(actor)
return if @actor == actor
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# * Make Command List
#--------------------------------------------------------------------------
def make_command_list
8.times {|i| add_command('+', :addpoint, commands_enabled)}
end
#--------------------------------------------------------------------------
# * Commands Enabled
#--------------------------------------------------------------------------
def commands_enabled
return unless @actor
@actor.points > 0
end
#--------------------------------------------------------------------------
# * Window Width
#--------------------------------------------------------------------------
def window_width
return 48
end
#--------------------------------------------------------------------------
# * Alignment
#--------------------------------------------------------------------------
def alignment
return 1
end
end
#==============================================================================
# ** Scene_Upgrade
#==============================================================================
class Scene_Upgrade < Scene_MenuBase
#--------------------------------------------------------------------------
# * Start processing
#--------------------------------------------------------------------------
def start
super
create_status_window
create_command_window
end
#--------------------------------------------------------------------------
# * Create Status Window
#--------------------------------------------------------------------------
def create_status_window
@status_window = Window_Points.new(@actor)
@status_window.viewport = @viewport
@status_window.actor = @actor
end
#--------------------------------------------------------------------------
# * Create Command Window
#--------------------------------------------------------------------------
def create_command_window
@command_window = Window_PointsCommand.new(300, 153)
@command_window.viewport = @viewport
@command_window.actor = @actor
@command_window.set_handler(:addpoint, method(:command_add))
@command_window.set_handler(:cancel, method(:return_scene))
@command_window.set_handler(:pagedown, method(:next_actor))
@command_window.set_handler(:pageup, method(:prev_actor))
end
#--------------------------------------------------------------------------
# * Command Add Points
#--------------------------------------------------------------------------
def command_add
index = @command_window.index
value = index == 0 || index == 1 ? 10 : 1
@actor.add_param(index, value)
@actor.points -= 1
@status_window.refresh
@command_window.refresh
@command_window.activate
end
#--------------------------------------------------------------------------
# * On Actor Change
#--------------------------------------------------------------------------
def on_actor_change
@status_window.actor = @actor
@command_window.actor = @actor
@command_window.activate
end
end
#==============================================================================
# ** Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
include Ayene
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :points
#--------------------------------------------------------------------------
# * Setup (alias)
#--------------------------------------------------------------------------
alias aye_gamac_setup setup
def setup(*args)
@points = 0
aye_gamac_setup(*args)
end
#--------------------------------------------------------------------------
# * Level Up (alias)
#--------------------------------------------------------------------------
alias aye_gamac_level_up level_up
def level_up
aye_gamac_level_up
@points += POINTS_PER_LEVEL
end
#--------------------------------------------------------------------------
# * Level Down (alias)
#--------------------------------------------------------------------------
alias aye_gamac_level_down level_down
def level_down
aye_gamac_level_down
@points -= [POINTS_PER_LEVEL, @points].min
end
end
if Ayene::IN_MENU
#==============================================================================
# ** Window_MenuCommand
#==============================================================================
class Window_MenuCommand < Window_Command
#--------------------------------------------------------------------------
# * Add Main Commands (alias)
#--------------------------------------------------------------------------
alias aye_wincom_addmaincom add_main_commands
def add_main_commands
aye_wincom_addmaincom
add_command(Ayene::COMMAND_UPGRADE, :upgrade, main_commands_enabled)
end
end
#==============================================================================
# ** Scene_Menu
#==============================================================================
class Scene_Menu < Scene_MenuBase
#--------------------------------------------------------------------------
# * Create Command Window (alias)
#--------------------------------------------------------------------------
alias aye_scmen_crcommwin create_command_window
def create_command_window
aye_scmen_crcommwin
@command_window.set_handler(:upgrade, method(:command_personal))
end
#--------------------------------------------------------------------------
# * On Personal OK (alias)
#--------------------------------------------------------------------------
alias aye_scmen_conperok on_personal_ok
def on_personal_ok
aye_scmen_conperok
case @command_window.current_symbol
when :upgrade
SceneManager.call(Scene_Upgrade)
end
end
end
end