QuoteThe damage popups are a piece of cake, consider it done (two lines of code
).
It was more than 2 lines -_-'
Anyway, here's the first draft, which works:
#==============================================================================
# ** module FTS
#==============================================================================
module FTS
module_function
def learn_new_skills?(actor_id, skill_id)
case actor_id
#================================
# Config Begin
#================================
# when A then [B, C]
# A - Cast skill ID (eg: 57)
# B - Cast A how many times? (eg: 6)
# C - ID(s) of skill(s) to learn. It can be a number or
# an array of numbers (eg: 13, 21, 9, [2, 3], [1,3,7,35,64])
#================================
when 1 # when actor_id
a = case skill_id
# when skill with ID 57 is used 1 time, actor learns skills 6 and 7
when 57 then [1, [6, 7]]
# when skill with ID 6 is used 1 time, actor learns skill 13
when 6 then [1, 13]
else false
end
#----------------------------------------------------------------
# Actor Seperator
#----------------------------------------------------------------
when 7 # when actor_id
a = case skill_id
when 1 then [1, [8, 9]]
else false
end
#================================
# Config End
#================================
end
a[1] = [a[1]] if a && !a[1].is_a?(Array)
return a
end
end
#==============================================================================
# ** class Game_Actor
#==============================================================================
class Game_Actor
attr_accessor :skill_learns, :skill_uses
alias fts_skill_learning_game_actor_setup setup
def setup(actor_id)
fts_skill_learning_game_actor_setup(actor_id)
skill_list = load_data('Data/Skills.rxdata')
@skill_uses = Array.new(skill_list.size + 1, 0)
@skill_uses[0], @skill_learns, skill_list = id, [], nil
end
def skill_use_count(skill_id)
return @skill_uses[skill_id]
end
end
#==============================================================================
# ** class Scene_Battle
#==============================================================================
class Scene_Battle
alias fts_skill_learning_scene_battle_skill_action_result make_skill_action_result
def make_skill_action_result
battler = @active_battler
@skill = $data_skills[battler.current_action.skill_id]
if battler.is_a?(Game_Actor) && battler.skill_can_use?(@skill.id)
battler.skill_learns = [] if battler.skill_learns == nil
battler.skill_uses[@skill.id] += 1
s = FTS::learn_new_skills?(battler.id, @skill.id)
if s && battler.skill_use_count(@skill.id) == s[0]
s[1].each {|i| battler.skill_learns.push(i)}
end
end
fts_skill_learning_scene_battle_skill_action_result
end
alias fts_skill_learning_scene_battle_init5 start_phase5
def start_phase5
fts_skill_learning_scene_battle_init5
@phase5_wait_count, @new_skills = 0, []
$game_party.actors.each_with_index {|actor, i| actor.skill_learns.each {|id|
@new_skills.push([i, id])}}
@learn_skill_count = @new_skills.size
end
alias fts_skill_learning_scene_battle_upd5 update_phase5
def update_phase5
if @learn_skill_count > 0
if @learn_skill_count == @new_skills.size
a = @new_skills.shift
actor = $game_party.actors[a[0]]
actor.learn_skill(a[1])
actor.damage = "+ #{$data_skills[a[1]].name}!"
actor.damage_pop = true
end
@learn_skill_count -= 1
@phase5_wait_count = 1 if @new_skills.size == 0
end
fts_skill_learning_scene_battle_upd5
end
end
I hope you can understand that easily, because if you REALLY want that Hilda example, it'll be very confusing.
And also, here's a scene where you can check the details of learning. It's not much, it's a draft:
#==============================================================================
# ** Window_Skill
#==============================================================================
class Window_SkillList < Window_Selectable
def initialize(actor)
super(0, 64, 240, 416)
@actor = actor
@column_max = 1
refresh
self.index = 0
end
def skill
return @data[self.index]
p @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
@data.push(skill)
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]
self.contents.font.color = normal_color
x = 4
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(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_SkillInfo < Window_Base
def initialize(actor)
@actor = actor
super(240, 64, 400, 416)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.size = 28
contents.draw_text(0, 0, contents.width, 64, @actor.name, 1)
self.contents.font.size = 22
refresh
end
def refresh(skill=nil)
return unless skill
self.contents.fill_rect(0, 64, contents.width, contents.height - 64, Color.new(0, 0, 0, 0))
contents.draw_text(4, 64, contents.width - 8, 32, "Times used: #{@actor.skill_use_count(skill.id)}")
a = FTS::learn_new_skills?(@actor.id, skill.id)
return unless a
contents.draw_text(4, 96, contents.width - 8, 32, "When used #{a[0]} time(s), learns:")
list = a[1]
list.size.times {|i| skill_id = list[i]
rect = Rect.new(4, 128 + i * 32 + 4, 24, 24)
contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon($data_skills[skill_id].icon_name)
contents.blt(rect.x, rect.y, bitmap, Rect.new(0, 0, 24, 24))
contents.draw_text(32, 128 + i * 32, contents.width - 36, 32, "#{$data_skills[skill_id].name}")}
end
end
class Scene_SkillLearnInfo
def initialize(actor_index=0)
@actor_index = actor_index
$data_skills = load_data('Data/Skills.rxdata') unless $data_skills
end
def main
@actor = $game_party.actors[@actor_index]
@help_win = Window_Help.new
@list_win = Window_SkillList.new(@actor)
@list_win.help_window = @help_win
@info_win = Window_SkillInfo.new(@actor)
@info_win.refresh(@list_win.skill)
Graphics.transition
loop do
Graphics.update
Input.update
update
break if $scene != self
end
Graphics.freeze
@help_win.dispose
@list_win.dispose
@info_win.dispose
end
def update
@help_win.update
@list_win.update
@info_win.update
if Input.trigger?(Input::B)
$scene = Scene_Map.new
elsif Input.trigger?(Input::L)
new_index = (@actor_index - 1) % $game_party.actors.size
$scene = Scene_SkillLearnInfo.new(new_index)
elsif Input.trigger?(Input::R)
new_index = (@actor_index + 1) % $game_party.actors.size
$scene = Scene_SkillLearnInfo.new(new_index)
elsif Input.repeat?(Input::UP) || Input.repeat?(Input::DOWN)
@info_win.refresh(@list_win.skill)
end
end
end
For calling the scene, you can use this call script command:
$scene = Scene_SkillLearnInfo.new