class Game_Actor < Game_Battler
attr_accessor :elem_xp
attr_accessor :elem_points
attr_accessor :elem_fire
attr_accessor :elem_water
attr_accessor :elem_wind
attr_accessor :elem_earth
alias old_setup setup
def setup(actor_id)
old_setup(actor_id)
@elem_xp = 0
@elem_points = 0
@elem_fire = 0
@elem_water = 0
@elem_wind = 0
@elem_earth = 0
end
end
class Scene_Battle
alias old_start_phase5 start_phase5
def start_phase5
old_start_phase5
elem_xp = 0
for enemy in $game_troop.enemies
unless enemy.hidden
elem_xp += 1
end
end
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
if actor.cant_get_exp? == false
actor.elem_xp += elem_xp
if actor.elem_xp >= 100
actor.elem_points += 1
actor.elem_xp -= 100
actor.damage = 'Element Point Gained'
actor.damage_pop = true
end
end
end
end
end
class Window_Elem_Levels < Window_Base
def initialize(actor_pos)
super(0, 64, 640, 416)
self.contents = Bitmap.new(width - 32, height - 32)
@actor_pos = actor_pos
@actor = $game_party.actors[actor_pos]
@window_elem_levels_adjust = Window_Elem_Levels_Adjust.new(actor_pos)
@window_elem_levels_adjust.active = true
@window_elem_levels_adjust.opacity = 0
refresh
end
def refresh
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(0, 0, 640, 32, "Please edit your mastery of elements here:")
self.contents.draw_text(0, 32, 90, 32, "You have ")
self.contents.draw_text(90, 32, 40, 32,@actor.elem_points.to_s)
self.contents.draw_text(130, 32, 300, 32, "elemental points to distribute.")
self.contents.draw_text(0, 64, 90, 32, "You have ")
x = @actor.elem_points
x -= (@actor.elem_fire + @actor.elem_water + @actor.elem_wind + @actor.elem_earth)
self.contents.draw_text(90, 64, 40, 32, x.to_s)
self.contents.draw_text(130, 64, 400, 32, "elemental points remaining to distribute.")
x = 100 - @actor.elem_xp
x = x.to_s
x = x + ' elemental experience to next element point'
self.contents.draw_text(200, 106, 440, 32, x)
for i in 0...4
string = ''
case i
when 0
string = string + @actor.elem_fire.to_s
when 1
string = string + @actor.elem_water.to_s
when 2
string = string + @actor.elem_wind.to_s
when 3
string = string + @actor.elem_earth.to_s
end
string = string + '/50'
self.contents.draw_text(120, (106 + 32 * i) , 150, 32, string)
end
end
def update
super
@window_elem_levels_adjust.update
end
def help_window_text
return @window_elem_levels_adjust.help_window_text
end
def index
return @window_elem_levels_adjust.index
end
def dispose
@window_elem_levels_adjust.dispose
super
end
end
class Window_Elem_Levels_Adjust < Window_Selectable
def initialize(actor_pos)
super(15, 170, 100, 314)
self.contents = Bitmap.new(width - 32, height - 32)
@actor_pos = actor_pos
@actor = $game_party.actors[actor_pos]
@item_max = 5
@column_max = 1
@commands = ['Fire', 'Water', 'Wind', 'Earth', 'Exit']
@index = 0
for i in 0...5
rect = Rect.new(4, 32 * i, self.contents.width - 8, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[i])
end
end
def help_window_text
case @index
when 0
return 'Press Left/Right to fine tune your mastery of Fire'
when 1
return 'Press Left/Right to fine tune your mastery of Water'
when 2
return 'Press Left/Right to fine tune your mastery of Wind'
when 3
return 'Press Left/Right to fine tune your mastery of Earth'
when 4
return 'Exit'
end
end
end
class Scene_Elem_Levels
def initialize(actor_index = 0)
@actor_index = actor_index
end
def main
# Get actor
@actor = $game_party.actors[@actor_index]
@help_window = Window_Help.new
@elem_window = Window_Elem_Levels.new(@actor_index)
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@help_window.dispose
@elem_window.dispose
end
def update
@elem_window.update
@help_window.set_text(@elem_window.help_window_text)
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to map screen
exit_element_mastery
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Play decision SE
$game_system.se_play($data_system.decision_se)
if @elem_window.index == 4
# Switch to map screen
exit_element_mastery
return
end
end
if Input.trigger?(Input::LEFT)
case @elem_window.index
when 0
@actor.elem_fire -= 1
if @actor.elem_fire < 0
@actor.elem_fire = 0
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.decision_se)
end
when 1
@actor.elem_water -= 1
if @actor.elem_water < 0
@actor.elem_water = 0
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.decision_se)
end
when 2
@actor.elem_wind -= 1
if @actor.elem_wind < 0
@actor.elem_wind = 0
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.decision_se)
end
when 3
@actor.elem_earth -= 1
if @actor.elem_earth < 0
@actor.elem_earth = 0
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.decision_se)
end
end
@elem_window.refresh
end
if Input.trigger?(Input::RIGHT)
if @actor.elem_points > (@actor.elem_fire + @actor.elem_water +
@actor.elem_wind + @actor.elem_earth)
case @elem_window.index
when 0
@actor.elem_fire += 1
if @actor.elem_fire > 50
@actor.elem_fire = 50
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.decision_se)
end
when 1
@actor.elem_water += 1
if @actor.elem_water > 50
@actor.elem_water = 50
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.decision_se)
end
when 2
@actor.elem_wind += 1
if @actor.elem_wind > 50
@actor.elem_wind = 50
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.decision_se)
end
when 3
@actor.elem_earth += 1
if @actor.elem_earth > 50
@actor.elem_earth = 50
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.decision_se)
end
end
@elem_window.refresh
else
$game_system.se_play($data_system.buzzer_se)
return
end
end
# If R button was pressed
if Input.trigger?(Input::R)
exit_element_mastery(false)
# Play cursor SE
$game_system.se_play($data_system.cursor_se)
# To next actor
@actor_index += 1
@actor_index %= $game_party.actors.size
# Switch to different status screen
$scene = Scene_Elem_Levels.new(@actor_index)
return
end
# If L button was pressed
if Input.trigger?(Input::L)
exit_element_mastery(false)
# Play cursor SE
$game_system.se_play($data_system.cursor_se)
# To previous actor
@actor_index += $game_party.actors.size - 1
@actor_index %= $game_party.actors.size
# Switch to different status screen
$scene = Scene_Elem_Levels.new(@actor_index)
return
end
end
def exit_element_mastery(exit = true)
for i in 0...4
x = []
for j in 0...50
x.push(0)
end
case i
when 0 # Fire
mastery = @actor.elem_fire
x[0] = 7 # Means 1 point in fire mastery lets you learn fire
x[20] = 8 # Means 21 point in fire mastery lets you learn greater fire
x[49] = 9 # Means 50 point in fire mastery lets you learn mass fire
when 1 # Water
mastery = @actor.elem_water
x[0] = 16
x[14] = 17
x[29] = 18
when 2 # Wind
mastery = @actor.elem_wind
x[0] = 22
x[14] = 23
x[29] = 24
when 3 # Earth
mastery = @actor.elem_earth
x[0] = 19
x[14] = 20
x[29] = 21
end
if mastery > 0
for k in 0...mastery
@actor.learn_skill(x[k])
end
end
if mastery < 50
for k in mastery...50
@actor.forget_skill(x[k])
end
end
end
if exit == true
$scene = Scene_Menu.new
end
end
end