Advertisement
Vlue

Skill Trees or Something

Nov 17th, 2014
1,531
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 22.01 KB | None | 0 0
  1. # Skill Trees or Something v1.0a
  2. #----------#
  3. #Features: Basic skill trees! Earn skill points, spend skill points,
  4. #           get abilities! Enjoy.
  5. #
  6. #Usage:   Set up your skill trees, knock yourself out.
  7. #          Script calls:
  8. #           SceneManager.call(Scene_SkillTree)
  9. #           $game_actors[actor_id].add_skill_tree(tree_id)
  10. #
  11. #          Notetags (Actors):
  12. #       <SP_PER #>  - sets the amount of sp earned per gain (overrides default)
  13. #       <SP_LEVEL #> - Overrides how many levels between each sp gain
  14. #       <SKILL_TREE #> - Sets the actors default skill tree
  15. #
  16. #          Notetags (Classes):
  17. #       <SKILL_TREES [#,#..]> - An array of trees for a class
  18. #         Example: <SKILL_TREES [0,1,24]>
  19. #
  20. #          Notetags (Items):
  21. #       <SKILL_BOOK> - Will add value of grow feature in skill points instead.
  22. #      Example: Set an item with the feature grow MHP 5 and gain 5 skill points.
  23. #
  24. #
  25. #~ #----------#
  26. #-- Script by: V.M of D.T
  27. #
  28. #- Questions or comments can be:
  29. #    given by email: sumptuaryspade@live.ca
  30. #    provided on facebook: http://www.facebook.com/DaimoniousTailsGames
  31. #   All my other scripts and projects can be found here: http://daimonioustails.weebly.com/
  32. #
  33. #--- Free to use in any project, commercial or non-commercial, with credit given
  34. # - - Though a donation's always a nice way to say thank you~ (I also accept actual thank you's)
  35.  
  36. #Default SP earned every gain
  37. DEFAULT_POINTS_GAINED = 5
  38. #Default levels between each SP gain (2 means every two levels, 3 means 3, etc.)
  39. DEFAULT_LEVEL_MOD = 2
  40. #The Skill Trees!
  41. # id# => { :name => "Tree name",
  42. #   :desc => "Description of tree",
  43. #   :icon => id,
  44. #   :background => "image_name",
  45. #   :skills => {
  46. #     :skillname => { :name => "Skill Name",
  47. #       :skillids => [skill1,skill2,...],
  48. #       :replace => true/false
  49. #       :spcost => #,
  50. #       :splock => #, :prevlock => [:skill1,:skill2,...],
  51. #       :row => #, :col => #
  52. #     },
  53. #   },
  54. #  },
  55. #
  56. # Look at how confusing that can be! I either hate you all or this is the easiest
  57. #  setup for me! I'll let you decide later. Anywho, on to the explanation:
  58. # id# is the the number of the skill tree, just a number
  59. # :name is just the name of the skill tree
  60. # :skills is where you set up each branch of the tree
  61. #   :skillname is just a simple identifier, can be anything
  62. #   :name is the name of the branch that appears in the menu
  63. #   :icon is the id of the icon to be displayed in the tree selection
  64. #   :background is the image to be displayed behind the tree (Graphics/System)
  65. ###   :background can also be set to :simple for a simple rowed background
  66. #   :skillids is the list of skills learned, more skills = more ranks
  67. #   :replace - skill from next rank will replace skill from previous rank
  68. #   :spcost is the cost in SP it takes to learn one rank of a branch
  69. #   :splock means you have to have spent that much SP to learn that branch
  70. #   :prevlock is a list of :skillnames that have to be learnt to learn that branch
  71. #   :row is the vertical position of the branch (it's # * 24)
  72. #   :col is the horizontal position of the branch (also # * 24)
  73. #
  74. # I'll have to explain this better at some point, but I can't get around it right
  75. #  now. The example below should be able to provide a lot of answers!
  76.  
  77. SKILL_TREES = {
  78.  
  79.   0 => {
  80.     :name => "Paladin",
  81.     :desc => "The mighty Paladin, master of sword and holy magic.",
  82.     :icon => 15,
  83.     :background => "GameOver",
  84.     :skills => {
  85.       :hpboost => { :name => "HP Boost [Passive]",
  86.         :skillids => [76,77,78],
  87.         :replace => true,
  88.         :row => 0, :col => 3
  89.       },
  90.       :combostrike => { :name => "Combo Strike [Ability]",
  91.         :skillids => [80], :spcost => 2,
  92.         :row => 0, :col => 6
  93.       },
  94.       :cover => { :name => "Cover [Ability]",
  95.         :skillids => [90], :spcost => 2,
  96.         :splock => 3, :statlock => [[:hp,750],[:def, 25]],
  97.         :row => 2, :col => 2
  98.       },
  99.       :cure1 => { :name => "Minor Cure [Spell]",
  100.         :skillids => [31], :spcost => 3,
  101.         :splock => 3, :statlock => [[:int, 25]],
  102.         :row => 2, :col => 5
  103.       },
  104.       :cleave => { :name => "Cleave [Ability]",
  105.         :skillids => [81], :spcost => 2,
  106.         :splock => 3, :lvllock => 10,
  107.         :row => 2, :col => 8
  108.       },
  109.       :provoke => { :name => "Provoke [Ability]",
  110.         :skillids => [91], :spcost => 2,
  111.         :splock => 10, :prevlock => [:cover,:cleave],
  112.         :row => 4, :col => 3
  113.       },
  114.       :defup => { :name => "Def Boost [Passive]",
  115.         :skillids => [72,73,74],
  116.         :splock => 10, :lvllock => 15,
  117.         :row => 4, :col => 6
  118.       },
  119.       :cure2 => { :name => "Super Cure [Spell]",
  120.         :skillids => [32], :spcost => 4,
  121.         :splock => 17, :prevlock => [:cure1],
  122.         :row => 6, :col => 5
  123.       }
  124.     },
  125.   },
  126.  
  127. }
  128.  
  129. class Game_Actor
  130.   attr_accessor :active_skill_tree
  131.   attr_accessor :skill_points
  132.   attr_accessor :spent_skill_points
  133.   alias sktree_init initialize
  134.   def initialize(*args)
  135.     sktree_init(*args)
  136.     @active_skill_tree = {}
  137.     @skill_points = 0
  138.     @spent_skill_points = {}
  139.     $data_classes[@class_id].skill_trees.each do |id|
  140.       add_skill_tree(id)
  141.     end
  142.     add_skill_tree(actor.skill_tree) if actor.skill_tree
  143.   end
  144.   def add_skill_tree(id)
  145.     skill_tree = SKILL_TREES[id].clone
  146.     skill_tree[:skills].each do |key,hash|
  147.       hash[:rank] = 0
  148.     end
  149.     @active_skill_tree[id] = skill_tree
  150.     @spent_skill_points[id] = 0
  151.   end
  152.   def remove_skill_tree(id)
  153.     reset_skill_tree(id)
  154.     @active_skill_tree.delete(id)
  155.     @spent_skill_points.delete(id)
  156.   end
  157.   def skill_upgrade_valid?(tree_id, skill_id)
  158.     if skill_id.is_a?(Integer)
  159.       skill_id = @active_skill_tree[tree_id][:skills].keys[skill_id]
  160.     end
  161.     sktree = @active_skill_tree[tree_id][:skills][skill_id]
  162.     return false if @skill_points < (sktree[:spcost] ? sktree[:spcost] : 1)
  163.     return false if sktree[:rank] >= sktree[:skillids].size
  164.     if sktree[:lvllock]
  165.       return false if @level < sktree[:lvllock]
  166.     end
  167.     if sktree[:statlock]
  168.       id = [:hp,:mp,:atk,:def,:int,:wis,:agi,:luk]
  169.       sktree[:statlock].each do |array|
  170.         return false if param(id.index(array[0])) < array[1]
  171.       end
  172.     end
  173.     if sktree[:splock]
  174.       return false if @spent_skill_points[tree_id] < sktree[:splock]
  175.     end
  176.     if sktree[:prevlock]
  177.       sktree[:prevlock].each do |key|
  178.         nextskill = @active_skill_tree[tree_id][:skills][key]
  179.         return false if nextskill[:rank] < nextskill[:skillids].size
  180.       end
  181.     end
  182.     return true
  183.   end
  184.   def increase_rank(tree_id, skill_id)
  185.     if skill_id.is_a?(Integer)
  186.       skill_id = @active_skill_tree[tree_id][:skills].keys[skill_id]
  187.     end
  188.     sktree = @active_skill_tree[tree_id][:skills][skill_id]
  189.     if sktree[:replace] && sktree[:rank] > 0
  190.       forget_skill(sktree[:skillids][sktree[:rank]-1])
  191.     end
  192.     learn_skill(sktree[:skillids][sktree[:rank]])
  193.     sktree[:rank] += 1
  194.     @skill_points -= (sktree[:spcost] ? sktree[:spcost] : 1)
  195.     @spent_skill_points[tree_id] += (sktree[:spcost] ? sktree[:spcost] : 1)
  196.   end
  197.   def reset_skill_tree(id)
  198.     @active_skill_tree[id][:skills].keys.each do |key|
  199.       sktree = @active_skill_tree[id][:skills][key]
  200.       while sktree[:rank] > 0
  201.         sktree[:rank] -= 1
  202.         forget_skill(sktree[:skillids][sktree[:rank]])
  203.         @skill_points += (sktree[:spcost] ? sktree[:spcost] : 1)
  204.         @spent_skill_points[id] -= (sktree[:spcost] ? sktree[:spcost] : 1)
  205.       end
  206.     end
  207.   end
  208.   def increase_skill_points(amount)
  209.     @skill_points += amount
  210.   end
  211.   alias sktree_level_up level_up
  212.   def level_up
  213.     sktree_level_up
  214.     if @level % actor.spoint_level == 0
  215.       increase_skill_points(actor.spoint_gain)
  216.     end
  217.   end
  218.   alias skill_change_class change_class
  219.   def change_class(class_id, keep_exp = false)
  220.     old_trees = $data_classes[@class_id].skill_trees
  221.     new_trees = $data_classes[class_id].skill_trees
  222.     old_level = @level
  223.     skill_change_class(class_id, keep_exp)
  224.     (new_trees - old_trees).each do |id|
  225.       add_skill_tree(id)
  226.     end
  227.     (old_trees - new_trees).each do |id|
  228.       remove_skill_tree(id)
  229.     end
  230.     if old_level < @level
  231.       (@level - old_level).times do |i|
  232.         if (old_level + i) % actor.spoint_level == 0
  233.           increase_skill_points(-actor.spoint_gain)
  234.         end
  235.       end
  236.     end
  237.   end
  238.   def item_effect_grow(user, item, effect)
  239.     if item.skill_book
  240.       increase_skill_points(effect.value1.to_i)
  241.     else
  242.       add_param(effect.data_id, effect.value1.to_i)
  243.     end
  244.     @result.success = true
  245.   end
  246. end
  247.  
  248. class RPG::Item
  249.   def skill_book
  250.     self.note =~ /<SKILL_BOOK>/ ? true : false
  251.   end
  252. end
  253.  
  254. class RPG::Class
  255.   def skill_trees
  256.     self.note =~ /<SKILL_TREES (.+)>/ ? eval($1) : []
  257.   end
  258. end
  259.  
  260.  
  261. class RPG::Actor
  262.   def spoint_gain
  263.     self.note =~ /<SP_PER (\d+)>/ ? $1.to_i : DEFAULT_POINTS_GAINED
  264.   end
  265.   def spoint_level
  266.     self.note =~ /<SP_LEVEL (\d+)>/ ? $1.to_i : DEFAULT_LEVEL_MOD
  267.   end
  268.   def skill_tree
  269.     self.note =~ /<SKILL_TREE (\d+)>/ ? $1.to_i : false
  270.   end
  271. end
  272.  
  273. class Scene_SkillTree < Scene_MenuBase
  274.   def start
  275.     super
  276.     @actor = $game_party.menu_actor
  277.     @help_window = Window_Help.new(1)
  278.     @category_window = Window_STCat.new
  279.     @category_window.set_handler(:ok, method(:cat_ok))
  280.     @category_window.set_handler(:cancel, method(:cat_cancel))
  281.     @tree_window = Window_STTree.new(cur_item)
  282.     @tree_window.set_handler(:ok, method(:on_tree_ok))
  283.     @tree_window.set_handler(:cancel, method(:on_tree_cancel))
  284.     @actor_window = Window_STActor.new
  285.     @skill_window = Window_STSkill.new(cur_item)
  286.     @text = ""
  287.   end
  288.   def cat_ok
  289.     @tree_window.activate
  290.     @tree_window.select(0)
  291.   end
  292.   def on_tree_ok
  293.     @tree_window.activate
  294.     return Sound.play_buzzer unless @actor.skill_upgrade_valid?(cur_item,@tree_window.index)
  295.     @actor.increase_rank(cur_item,@tree_window.index)
  296.     Sound.play_ok
  297.     @tree_window.refresh
  298.     @skill_window.refresh
  299.     @actor_window.refresh
  300.     Sound.play_buzzer
  301.   end
  302.   def cur_item
  303.     @category_window.cur_item
  304.   end
  305.   def cat_cancel
  306.     SceneManager.return
  307.   end
  308.   def on_tree_cancel
  309.     @category_window.activate
  310.     @tree_window.select(-1)
  311.   end
  312.   def update
  313.     super
  314.     if @tree_window.current_tree != cur_item
  315.       @tree_window.current_tree = cur_item
  316.       @skill_window.current_tree = cur_item
  317.       @tree_window.refresh
  318.       @skill_window.refresh
  319.     end
  320.     @skill_window.set_skill(@tree_window.current_item)
  321.     return unless @actor.active_skill_tree[cur_item]
  322.     sym = @actor.active_skill_tree[cur_item][:skills].keys[@tree_window.index]
  323.     if @actor.active_skill_tree[cur_item][:desc]
  324.       text = @actor.active_skill_tree[cur_item][:desc]
  325.     else
  326.       text = ""
  327.     end
  328.     if @text != text
  329.       @text = text
  330.       @help_window.set_text(@text)
  331.     end
  332.   end
  333.   def terminate
  334.     super
  335.   end
  336. end
  337.  
  338. class Window_STCat < Window_HorzCommand
  339.   def initialize
  340.     super(0,48) #,Graphics.width/2,48)
  341.     @actor = $game_party.menu_actor
  342.     @index = 0
  343.     activate
  344.     refresh
  345.   end
  346.   def col_max; 3; end
  347.   def ensure_cursor_visible2
  348.     self.top_col = index - 1 if index < top_col
  349.     self.bottom_col = index + 1 if index > bottom_col
  350.   end
  351.   def window_width; Graphics.width/2; end
  352.   def window_height; 48; end
  353.   def item_max
  354.     @actor ? @actor.active_skill_tree.keys.size : 0
  355.   end
  356.   def current_item
  357.     @actor.active_skill_tree[cur_item][:name]
  358.   end
  359.   def cur_item
  360.     @actor.active_skill_tree.keys[index]
  361.   end
  362.   def item(id)
  363.     @actor.active_skill_tree[@actor.active_skill_tree.keys[id]]
  364.   end
  365.   def spacing; 12; end
  366.   def draw_item(index)
  367.     rect = item_rect(index)
  368.     item = item(index)
  369.     draw_icon(item[:icon],rect.x,rect.y) if item[:icon]
  370.     rect.x += 24;rect.width -= 24
  371.     draw_text(rect,item[:name])
  372.   end
  373.   def current_item_enabled?
  374.     !cur_item.nil?
  375.   end
  376. end
  377.  
  378. class Window_STTree < Window_Selectable
  379.   attr_accessor :current_tree
  380.   def initialize(tree)
  381.     super(0,48*2,Graphics.width/2,Graphics.height-48*2)
  382.     @actor = $game_party.menu_actor
  383.     @index = -1
  384.     @current_tree = tree
  385.     refresh
  386.   end
  387.   def ensure_cursor_visible
  388.   end
  389.   def item_width; 48; end
  390.   def item_height; 24; end
  391.   def item_rect(index)
  392.     Rect.new(current_item[:col]*24,current_item[:row]*24,48,24)
  393.   end
  394.   def item_max
  395.     return 0 unless @actor
  396.     @actor.active_skill_tree[@current_tree][:skills].values.size
  397.   end
  398.   def current_item
  399.     return nil unless @actor
  400.     return nil if @index == -1
  401.     @actor.active_skill_tree[@current_tree][:skills].values[@index]
  402.   end
  403.   def refresh
  404.     contents.clear
  405.     return unless @actor
  406.     skilltree = @actor.active_skill_tree[@current_tree]
  407.     return unless skilltree
  408.     if skilltree[:background]
  409.       if skilltree[:background] == :simple
  410.         (contents.height/24).times do |i|
  411.           i % 2 == 0 ? color = Color.new(150,150,150,75) : color = Color.new(150,150,150,30)
  412.           contents.fill_rect(0,24*i,contents.width,24,color)
  413.         end
  414.       else
  415.         bitmap = Cache.system(skilltree[:background])
  416.         contents.blt(0,0,bitmap,bitmap.rect,175)
  417.       end
  418.     end
  419.     skilltree[:skills].each do |key, skillhash|
  420.       change_color(normal_color, @actor.skill_upgrade_valid?(@current_tree,key))
  421.       skill = $data_skills[skillhash[:skillids][0]]
  422.       x, y = skillhash[:col] * 24, skillhash[:row] * 24
  423.       draw_icon(skill.icon_index,x,y,@actor.skill_upgrade_valid?(@current_tree,key))
  424.       draw_text(x+24,y,24,24,skillhash[:rank].to_s + "/" + skillhash[:skillids].size.to_s)
  425.     end
  426.     contents.font.size = 20
  427.     change_color(system_color)
  428.     draw_text(0,contents.height-20,contents.width,20,"SP Spent: ")
  429.     change_color(normal_color)
  430.     draw_text(0,contents.height-20,contents.width/2,20,@actor.spent_skill_points[@current_tree],2)
  431.     reset_font_settings
  432.   end
  433.   def process_ok
  434.     if current_item_enabled?
  435.       Input.update
  436.       deactivate
  437.       call_ok_handler
  438.     else
  439.       Sound.play_buzzer
  440.     end
  441.   end
  442.   def cursor_up(wrap = false)
  443.     next_skill = nil
  444.     next_key = nil
  445.     tree = @actor.active_skill_tree[@current_tree][:skills]
  446.     curr_skill = tree[@actor.active_skill_tree[@current_tree][:skills].keys[@index]]
  447.     tree.each do |key, hash|
  448.       next if hash[:row] >= curr_skill[:row]
  449.       if next_skill == nil
  450.         next_skill = tree[key]
  451.         next_key = key
  452.         next
  453.       else
  454.         if next_skill[:row] == hash[:row]
  455.           if (curr_skill[:col] - hash[:col]).abs < (curr_skill[:col] - next_skill[:col]).abs
  456.             next_skill = tree[key]
  457.             next_key = key
  458.           end
  459.         end
  460.         if hash[:row] > next_skill[:row] && hash[:row] < curr_skill[:row]
  461.           next_skill = tree[key]
  462.           next_key = key
  463.         end
  464.         next
  465.       end
  466.     end
  467.     if next_key
  468.       select(@actor.active_skill_tree[@current_tree][:skills].keys.index(next_key))
  469.     end
  470.   end
  471.   def cursor_down(wrap = false)
  472.     next_skill = nil
  473.     next_key = nil
  474.     tree = @actor.active_skill_tree[@current_tree][:skills]
  475.     curr_skill = tree[@actor.active_skill_tree[@current_tree][:skills].keys[@index]]
  476.     tree.each do |key, hash|
  477.       next if hash[:row] <= curr_skill[:row]
  478.       if next_skill == nil
  479.         next_skill = tree[key]
  480.         next_key = key
  481.         next
  482.       else
  483.         if next_skill[:row] == hash[:row]
  484.           if (curr_skill[:col] - hash[:col]).abs < (curr_skill[:col] - next_skill[:col]).abs
  485.             next_skill = tree[key]
  486.             next_key = key
  487.           end
  488.         end
  489.         if hash[:row] < next_skill[:row] && hash[:row] > curr_skill[:row]
  490.           next_skill = tree[key]
  491.           next_key = key
  492.         end
  493.         next
  494.       end
  495.     end
  496.     if next_key
  497.       select(@actor.active_skill_tree[@current_tree][:skills].keys.index(next_key))
  498.     end
  499.   end
  500.   def cursor_left(wrap = false)
  501.     next_skill = nil
  502.     next_key = nil
  503.     tree = @actor.active_skill_tree[@current_tree][:skills]
  504.     curr_skill = tree[@actor.active_skill_tree[@current_tree][:skills].keys[@index]]
  505.     tree.each do |key, hash|
  506.       next if hash[:col] >= curr_skill[:col]
  507.       next if hash[:row] != curr_skill[:row]
  508.       if next_skill == nil
  509.         next_skill = tree[key]
  510.         next_key = key
  511.         next
  512.       else
  513.         if hash[:col] > next_skill[:col]
  514.           next_skill = tree[key]
  515.           next_key = key
  516.         end
  517.         next
  518.       end
  519.     end
  520.     if next_key
  521.       select(@actor.active_skill_tree[@current_tree][:skills].keys.index(next_key))
  522.     end
  523.   end
  524.   def cursor_right(wrap = false)
  525.     next_skill = nil
  526.     next_key = nil
  527.     tree = @actor.active_skill_tree[@current_tree][:skills]
  528.     curr_skill = tree[@actor.active_skill_tree[@current_tree][:skills].keys[@index]]
  529.     tree.each do |key, hash|
  530.       next if hash[:col] <= curr_skill[:col]
  531.       next if hash[:row] != curr_skill[:row]
  532.       if next_skill == nil
  533.         next_skill = tree[key]
  534.         next_key = key
  535.         next
  536.       else
  537.         if hash[:col] < next_skill[:col]
  538.           next_skill = tree[key]
  539.           next_key = key
  540.         end
  541.         next
  542.       end
  543.     end
  544.     if next_key
  545.       select(@actor.active_skill_tree[@current_tree][:skills].keys.index(next_key))
  546.     end
  547.   end
  548. end
  549.  
  550. class Window_STActor < Window_Base
  551.   def initialize
  552.     super(Graphics.width/2,48,Graphics.width/2,96+24)
  553.     @actor = $game_party.menu_actor
  554.     refresh
  555.   end
  556.   def set_actor(actor)
  557.     return if actor == @actor
  558.     @actor = actor
  559.     refresh
  560.   end
  561.   def refresh
  562.     contents.clear
  563.     return unless @actor
  564.     draw_actor_face(@actor,0,0)
  565.     draw_actor_name(@actor,96+12,0)
  566.     draw_actor_level(@actor,96+12,24)
  567.     draw_text(96+12,24*2,contents.width,24,"SP: " + @actor.skill_points.to_s)
  568.   end
  569. end
  570.  
  571. class Window_STSkill < Window_Base
  572.   attr_accessor :current_tree
  573.   def initialize(tree)
  574.     super(Graphics.width/2,48+96+24,Graphics.width/2,Graphics.height-48-96-24)
  575.     @skill = nil
  576.     @current_tree = tree
  577.     @actor = $game_party.menu_actor
  578.     contents.font.size = line_height
  579.     refresh
  580.   end
  581.   def set_actor(actor)
  582.     return if actor == @actor
  583.     @actor = actor
  584.   end
  585.   def set_skill(skill)
  586.     return if @skill == skill
  587.     @skill = skill
  588.     refresh
  589.   end
  590.   def line_height
  591.     20
  592.   end
  593.   def refresh
  594.     contents.clear
  595.     return unless @skill
  596.     change_color(system_color)
  597.     draw_text(0,0,contents.width,24,"SP Cost:")
  598.     draw_text(0,line_height,contents.width,line_height,"Current:")
  599.     draw_text(0,line_height*4,contents.width,line_height,"Next:")
  600.     draw_text(0,line_height*7,contents.width,line_height,"Requirements:")
  601.     change_color(normal_color)
  602.     draw_text(0,0,contents.width,line_height,(@skill[:spcost] ? @skill[:spcost] : 1).to_s,2)
  603.     if @skill[:rank] > 0
  604.       skill = $data_skills[@skill[:skillids][@skill[:rank]-1]]
  605.       draw_icon(skill.icon_index,contents.width-text_size(skill.name).width-24,line_height)
  606.       draw_text(0,line_height,contents.width,line_height,skill.name,2)
  607.       draw_text_ex(0,line_height*2,skill.description)
  608.     else
  609.       draw_text_ex(0,line_height*2,"   -----")
  610.     end
  611.     if @skill[:rank] < @skill[:skillids].size
  612.       skill = $data_skills[@skill[:skillids][@skill[:rank]]]
  613.       draw_icon(skill.icon_index,contents.width-text_size(skill.name).width-24,line_height*4)
  614.       draw_text(0,line_height*4,contents.width,line_height,skill.name,2)
  615.       draw_text_ex(0,line_height*5,skill.description)
  616.     else
  617.       draw_text_ex(0,line_height*5,"   -----")
  618.     end
  619.     if @skill[:splock] || @skill[:prevlock] || @skill[:lvllock] || @skill[:statlock]
  620.       yy = line_height * 8
  621.       if @skill[:splock]
  622.         change_color(normal_color, @actor.spent_skill_points[@current_tree] >= @skill[:splock])
  623.         draw_text(12,yy,contents.width-12,line_height,"SP Spent: " + @skill[:splock].to_s)
  624.         yy += line_height
  625.       end
  626.       if @skill[:lvllock]
  627.         change_color(normal_color, @actor.level >= @skill[:lvllock])
  628.         draw_text(12,yy,contents.width-12,line_height,"Level: " + @skill[:lvllock].to_s)
  629.         yy += line_height
  630.       end
  631.       if @skill[:statlock]
  632.         xx = 12
  633.         id = [:hp,:mp,:atk,:def,:int,:wis,:agi,:luk]
  634.         @skill[:statlock].each do |array|
  635.           param_id = id.index(array[0])
  636.           change_color(normal_color,@actor.param(param_id) >= array[1])
  637.           text = Vocab::param(param_id) + ":" + array[1].to_s
  638.           width = text_size(text).width
  639.           if xx + width > contents.width
  640.             xx = 12; yy += line_height
  641.           end
  642.           draw_text(xx,yy,contents.width,line_height,text)
  643.           xx += width + 6
  644.         end
  645.       end
  646.       if @skill[:prevlock]
  647.         xx = 12
  648.         @skill[:prevlock].each do |sym|
  649.           olskill = @actor.active_skill_tree[@current_tree][:skills][sym]
  650.           text = "["+olskill[:name]+"]"
  651.           width = text_size(text).width
  652.           if xx + width > contents.width
  653.             xx = 12
  654.             yy += line_height
  655.           end
  656.           change_color(normal_color, olskill[:rank] >= olskill[:skillids].size)
  657.           draw_text(xx,yy,contents.width,line_height,text)
  658.           xx += width
  659.         end
  660.       end
  661.     else
  662.       draw_text(0,line_height*8,contents.width,line_height,"None")
  663.     end
  664.   end
  665.   def draw_text_ex(x, y, text)
  666.     text = convert_escape_characters(text)
  667.     pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
  668.     process_character(text.slice!(0, 1), text, pos) until text.empty?
  669.   end
  670. end
  671.  
  672. class Window_MenuCommand < Window_Command
  673.   alias sktree_aoc add_original_commands
  674.   def add_original_commands
  675.     sktree_aoc
  676.     add_command("Skill Tree", :skilltree)
  677.   end
  678. end
  679.  
  680. class Scene_Menu
  681.   alias sktree_ccw create_command_window
  682.   def create_command_window
  683.     sktree_ccw
  684.     @command_window.set_handler(:skilltree,    method(:command_personal))
  685.   end
  686.   alias sktree_opo on_personal_ok
  687.   def on_personal_ok
  688.     sktree_opo
  689.     SceneManager.call(Scene_SkillTree) if @command_window.current_symbol == :skilltree
  690.   end
  691. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement