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