Advertisement
Dekita

skill levels 1.3

Apr 22nd, 2013
405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.89 KB | None | 0 0
  1. if true # << Make true to use this script, false to disable.
  2. #===============================================================================
  3. #
  4. # ☆ $D13x - Skill Levels
  5. # -- Author : Dekita
  6. # -- Version : 1.3
  7. # -- Level : Easy / Normal
  8. # -- Requires : $D13x - Statistic Control
  9. # -- Engine : RPG Maker VX Ace.
  10. #
  11. #===============================================================================
  12. # ☆ Import
  13. #-------------------------------------------------------------------------------
  14. $D13x={}if$D13x==nil
  15. $D13x[:Skill_Lv]=true
  16. #===============================================================================
  17. # ☆ Updates
  18. #-------------------------------------------------------------------------------
  19. # D /M /Y
  20. # 22/o4/2o13 - Fixed Bug, (forget skill error)
  21. # 23/o3/2o13 - Fixed Bug, (guard skill leveling)
  22. # - Added Guard && Attack Skill Lv Options,
  23. # - Added New Script Calls,
  24. # 21/o3/2o13 - Fixed Bug, (enemy damage)
  25. # - Fixed Bug, (Mp/Tp cost)
  26. # 2o/o3/2o13 - Finished,
  27. # 1o/o3/2o13 - Started
  28. #
  29. #===============================================================================
  30. # ☆ Introduction
  31. #-------------------------------------------------------------------------------
  32. # This script gives skills - levels.
  33. # You can have different growth types, exp requirements, max level,
  34. # level name and damage multiplier for each skill.
  35. # Simple notetag usage.
  36. # Plug-N-Play.
  37. #
  38. #===============================================================================
  39. # ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
  40. #===============================================================================
  41. # 1. You MUST give credit to "Dekita" !!
  42. # 2. You are NOT allowed to repost this script.(or modified versions)
  43. # 3. You are NOT allowed to convert this script.
  44. # 4. You are NOT allowed to use this script for Commercial games.
  45. # 5. ENJOY!
  46. #
  47. # "FINE PRINT"
  48. # By using this script you hereby agree to the above terms and conditions,
  49. # if any violation of the above terms occurs "legal action" may be taken.
  50. # Not understanding the above terms and conditions does NOT mean that
  51. # they do not apply to you.
  52. # If you wish to discuss the terms and conditions in further detail you can
  53. # contact me at http://dekitarpg.wordpress.com/
  54. #
  55. #===============================================================================
  56. # ☆ Instructions
  57. #-------------------------------------------------------------------------------
  58. # Place Below " ▼ Materials " and Above " ▼ Main " in your script editor.
  59. # Place Under My $D13x - Statistic Control Script.
  60. #
  61. #===============================================================================
  62. # ☆ Script Calls
  63. #-------------------------------------------------------------------------------
  64. # level_skill(actor_id, skill_id)
  65. # gain_skill_exp(actor_id, skill_id, value)
  66. #
  67. # actor_id = the id of the actor from the database.
  68. # skill_id = the id of the skill from the database.
  69. # value = the amount you wish to increase the exp.
  70. #
  71. #===============================================================================
  72. # ☆ Notetags ( default )
  73. # For use with Class Skill Learn noteboxes only !
  74. #-------------------------------------------------------------------------------
  75. # <exp set: id>
  76. # replace id with the id of the Exp_Set (defined below) that you wish to use.
  77. #
  78. # <growth type: id>
  79. # replace id with the id of the Growth_Type (defined below) that you wish to use.
  80. #
  81. # <max level: value>
  82. # replace value with the maximum level for that skill
  83. # (cannot be higher than the Exp_Set hash size)
  84. #
  85. #===============================================================================
  86. # ☆ HELP
  87. #-------------------------------------------------------------------------------
  88. # The default max level is the size of its Exp_Set[id] hash.
  89. #
  90. #===============================================================================
  91. module Skill_Levels
  92. #===============================================================================
  93. Exp_Set=[]# << Keep
  94. Growth_Type=[]# << Keep
  95.  
  96. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  97. # ☆ General Settings
  98. #--------------------------------------------------------------------------
  99. # Reset Exp to 0 after level up ?
  100. Exp_Reset_On_Lv_Up = false # true
  101.  
  102. # Reset Level && Exp after forgetting skill ?
  103. Reset_On_Forget = true
  104.  
  105. # If these are true, skill costs will be multiplied by the DMG Multi
  106. Dmg_Multi_Skill_Cost = { :mp => true , :tp => false }
  107.  
  108. # Default Exp Set given to skills (unless notetagged)
  109. Default_Exp_Set_ID = 0
  110.  
  111. # Default Growth Type given to skills (unless notetagged)
  112. Default_GrowthT_ID = 0
  113.  
  114. # Make this true to allow the default Attack skill to level up
  115. Default_Attack_Can_Lv = false
  116.  
  117. # Make this true to allow the default Guard skill to level up
  118. Default_Guard__Can_Lv = false
  119.  
  120. # Default Notetags
  121. Notes={
  122. :exp_set => /<exp set:(.*)>/i ,
  123. :max_lev => /<max level:(.*)>/i ,
  124. :gro_typ => /<growth type:(.*)>/i ,
  125. }# << end Notes={}
  126.  
  127. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  128. # ☆ Exp Setup - Settings
  129. #--------------------------------------------------------------------------
  130. # here is where you define the required exp for each level
  131. # as well as the level name and damage multiplier.
  132. # DMG Multi will also increase any statistics gained by
  133. # using the Statistic Control scripts notetags
  134. # you can add to this array as you please.
  135. Exp_Set[0]={#<< Exp Settings : 0 Begin
  136. # Level => [Exp Req, "Name", DMG Multi] ,
  137. 1 => [ 0, "Lv 1", 1.0 ] , # << Default level
  138. 2 => [ 25, "Lv 2", 1.1 ] ,
  139. 3 => [ 50, "Lv 3", 1.2 ] ,
  140. 4 => [ 100, "Lv 4", 1.4 ] ,
  141. 5 => [ 200, "Lv 5", 1.6 ] ,
  142. 6 => [ 400, "Lv 6", 1.8 ] ,
  143. 7 => [ 800, "Lv 7", 2.0 ] ,
  144. 8 => [ 1600, "Lv 8", 2.4 ] ,
  145. 9 => [ 3200, "Lv 9", 3.0 ] ,
  146. }# << Keep
  147.  
  148. Exp_Set[1]={#<< Exp Settings : 1 Begin
  149. # Level => [Exp Req, "Name", DMG Multi] ,
  150. 1 => [ 0, "Lv 1", 1.0 ] , # << Default level
  151. 2 => [ 50, "Lv 2", 1.1 ] ,
  152. 3 => [ 100, "Lv 3", 1.2 ] ,
  153. 4 => [ 200, "Lv 4", 1.4 ] ,
  154. 5 => [ 400, "Lv 5", 1.6 ] ,
  155. 6 => [ 800, "Lv 6", 1.8 ] ,
  156. 7 => [ 1600, "Lv 7", 2.0 ] ,
  157. 8 => [ 3200, "Lv 8", 2.4 ] ,
  158. 9 => [ 6400, "Lv 9", 3.0 ] ,
  159. }# << Keep
  160.  
  161. Exp_Set[2]={#<< Exp Settings : 2 Begin
  162. # Level => [Exp Req, "Name", DMG Multi] ,
  163. 1 => [ 0, "Lv 1", 1.0 ] , # << Default level
  164. 2 => [ 15, "Lv 2", 1.1 ] ,
  165. 3 => [ 45, "Lv 3", 1.2 ] ,
  166. 4 => [ 135, "Lv 4", 1.4 ] ,
  167. 5 => [ 405, "Lv 5", 1.6 ] ,
  168. 6 => [ 1215, "Lv 6", 1.8 ] ,
  169. 7 => [ 3645, "Lv 7", 2.0 ] ,
  170. 8 => [ 10935, "Lv 8", 2.4 ] ,
  171. 9 => [ 32805, "Lv 9", 3.0 ] ,
  172. }# << Keep
  173.  
  174. # << You can add more Exp_Set[ id ] here, simply copy the code from
  175. # above and change the id number and values to suit your needs.
  176.  
  177. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  178. # ☆ Growth Type - Settings
  179. #--------------------------------------------------------------------------
  180. # Here is where you can define the exp gained for various conditions
  181. # you can add to this array as you please.
  182. # :per_use = exp gained per use of the skill
  183. # :per_dmg = per (100 * skill level) damage dealt
  184. # :per_bat = exp gained per battle (while you know the skill)
  185. # :per_die = exp gained when actor dies ( for the skill )
  186. # :per_esc = exp gained when actor escapes battle (for the skill)
  187. Growth_Type[0]={
  188. :per_use => 1,
  189. :per_dmg => 0,
  190. :per_bat => 1,
  191. :per_die => 0,
  192. :per_esc => 0,
  193. } # << Keep
  194.  
  195. Growth_Type[1]={
  196. :per_use => 0,
  197. :per_dmg => 1,
  198. :per_bat => 0,
  199. :per_die => 0,
  200. :per_esc => 0,
  201. } # << Keep
  202.  
  203. Growth_Type[2]={
  204. :per_use => 1,
  205. :per_dmg => 0,
  206. :per_bat => 0,
  207. :per_die => 0,
  208. :per_esc => 0,
  209. } # << Keep
  210.  
  211. # << You can add more Growth_Type[ id ] here, simply copy the code from
  212. # above and change the id number and values to suit your needs.
  213.  
  214. #####################
  215. # CUSTOMISATION END #
  216. end #####################
  217. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
  218. # #
  219. # http://dekitarpg.wordpress.com/ #
  220. # #
  221. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
  222. #===============================================================================#
  223. # ARE YOU MODIFYING BEYOND THIS POINT? \.\. #
  224. # YES?\.\. #
  225. # OMG, REALLY? \| #
  226. # WELL SLAP MY FACE AND CALL ME A DRAGONITE.\..\.. #
  227. # I REALLY DIDN'T THINK YOU HAD IT IN YOU.\..\.. #
  228. #===============================================================================#
  229. module BattleManager
  230. #===============================================================================
  231. #--------------------------------------------------------------------------
  232. # Alias List
  233. #--------------------------------------------------------------------------
  234. class << self
  235. alias :gain_skill_exp :gain_exp
  236. end
  237. #--------------------------------------------------------------------------
  238. # EXP Acquisition and Level Up Display
  239. #--------------------------------------------------------------------------
  240. def self.gain_exp
  241. gain_skill_exp
  242. skills_gain_exp
  243. end
  244. #--------------------------------------------------------------------------
  245. # EXP Acquisition and Level Up Display (Skills)
  246. #--------------------------------------------------------------------------
  247. def self.skills_gain_exp
  248. $game_party.battle_members.each do |actor|
  249. actor.skills.each do |skill|
  250. next if skill == nil
  251. value = Skill_Levels::Growth_Type[skill.growth_type][:per_bat]
  252. actor.increase_skill_exp(skill, value)
  253. end
  254. end
  255. wait_for_message
  256. end
  257.  
  258. end
  259.  
  260. #===============================================================================
  261. class RPG::Skill < RPG::UsableItem
  262. #===============================================================================
  263. #---------------------------------------------------------------------------
  264. # Alias List
  265. #---------------------------------------------------------------------------
  266. alias :deki_skill_levz :load_stat_control
  267. #---------------------------------------------------------------------------
  268. # Pi Variables
  269. #---------------------------------------------------------------------------
  270. attr_accessor :exp_set
  271. attr_accessor :growth_type
  272. attr_accessor :max_lv
  273. #---------------------------------------------------------------------------
  274. # Load Stat Control
  275. #---------------------------------------------------------------------------
  276. def load_stat_control
  277. deki_skill_levz
  278. @exp_set = Skill_Levels::Default_Exp_Set_ID
  279. @growth_type = Skill_Levels::Default_GrowthT_ID
  280. @max_lv = Skill_Levels::Exp_Set[@exp_set].size
  281. self.note.split(/[\r\n]+/).each do |line|
  282. case line
  283. when Skill_Levels::Notes[:max_lev] then @max_lv = $1.to_i
  284. when Skill_Levels::Notes[:exp_set] then @exp_set = $1.to_i
  285. when Skill_Levels::Notes[:gro_typ] then @growth_type = $1.to_i
  286. end
  287. end
  288. end
  289.  
  290. end
  291.  
  292. #===============================================================================
  293. class Game_Battler < Game_BattlerBase
  294. #===============================================================================
  295. #--------------------------------------------------------------------------
  296. # Alias List
  297. #--------------------------------------------------------------------------
  298. alias :_MDV__skillev :make_damage_value
  299. alias :_APV__skillev :apply_variance
  300. #--------------------------------------------------------------------------
  301. # M.D.V
  302. #--------------------------------------------------------------------------
  303. def make_damage_value(user, item)
  304. @skillev_user = user
  305. @skillev_item = item
  306. _MDV__skillev(user, item)
  307. end
  308. #--------------------------------------------------------------------------
  309. # Apply Variance Mod ( HEAVY ALIAS )
  310. #--------------------------------------------------------------------------
  311. def apply_variance(damage, variance)
  312. user = @skillev_user
  313. item = @skillev_item
  314. orii = _APV__skillev(damage, variance)
  315. orig = apply_skill_variance(user,item,orii)
  316. orig
  317. end
  318. #--------------------------------------------------------------------------
  319. # Apply Skill Variance
  320. #--------------------------------------------------------------------------
  321. def apply_skill_variance(user,item,orig)
  322. return orig if user.is_a?(Game_Enemy)
  323. return orig if item.id == (attack_skill_id || guard_skill_id)
  324. lvdmgmul = Skill_Levels::Exp_Set[item.exp_set][user.skills_lv(item.id)][2]
  325. valu = orig * lvdmgmul
  326. ex = ((valu/100)*user.skills_lv(item.id)*
  327. Skill_Levels::Growth_Type[item.growth_type][:per_dmg]).to_i
  328. user.increase_skill_exp(item, ex)
  329. valu
  330. end
  331.  
  332. end
  333.  
  334. #===============================================================================
  335. class Game_Actor < Game_Battler
  336. #===============================================================================
  337. #--------------------------------------------------------------------------
  338. # Alias List
  339. #--------------------------------------------------------------------------
  340. alias :ls_alias_SD13x :learn_skill
  341. alias :fs_alias_SD13x :forget_skill
  342. alias :from_suparr_pscc :pay_skill_cost
  343. alias :init_de_skeel :init_skills
  344. alias :die_exp_skill :die
  345. alias :escape_exp_skill :escape
  346. alias :skill_lv_mp_st :skill_mp_cost
  347. alias :skill_lv_tp_st :skill_tp_cost
  348. #--------------------------------------------------------------------------
  349. # Learn Skill
  350. #--------------------------------------------------------------------------
  351. def learn_skill(skill_id)
  352. old_skills = skills.clone
  353. ls_alias_SD13x(skill_id)
  354. if skills != old_skills
  355. @skills_lv[skill_id] = 1
  356. @skills_exp[skill_id] = 0
  357. @skills_list.push(skill_id)
  358. @skills_list.sort!
  359. end
  360. end
  361. #--------------------------------------------------------------------------
  362. # Initialize Skills
  363. #--------------------------------------------------------------------------
  364. def init_skills
  365. ds = $data_skills.size
  366. @skills_lv = [1] * ds
  367. @skills_exp = [0] * ds
  368. init_de_skeel
  369. end
  370. #--------------------------------------------------------------------------
  371. # Get Skill Level
  372. #--------------------------------------------------------------------------
  373. def skills_lv(id)
  374. @skills_lv[id]
  375. end
  376. #--------------------------------------------------------------------------
  377. # Get Skill Exp
  378. #--------------------------------------------------------------------------
  379. def skills_exp(id)
  380. @skills_exp[id] == nil ? 0 : @skills_exp[id]
  381. end
  382. #--------------------------------------------------------------------------
  383. # Increase Skill Exp
  384. #--------------------------------------------------------------------------
  385. def increase_skill_exp(skill, value = nil)
  386. mod = Skill_Levels
  387. return if skill.id == attack_skill_id unless mod::Default_Attack_Can_Lv
  388. return if skill.id == guard_skill_id unless mod::Default_Guard__Can_Lv
  389. value = mod::Growth_Type[skill.growth_type][:per_use] if value == nil
  390. return if value == nil || value <= 0
  391. return if @skills_lv[skill.id] >= skill.max_lv
  392. set_id = skill.exp_set
  393. value.times do
  394. break if @skills_lv[skill.id] >= skill.max_lv
  395. @skills_exp[skill.id] += 1
  396. need = mod::Exp_Set[set_id][(@skills_lv[skill.id]+1)][0]
  397. if @skills_exp[skill.id] >= need
  398. increase_skill_proficiency(skill.id)
  399. end
  400. end
  401. end
  402. #--------------------------------------------------------------------------
  403. # Increase Skill Level
  404. #--------------------------------------------------------------------------
  405. def increase_skill_proficiency(skill_id)
  406. return if @skills_lv[skill_id] >= $data_skills[skill_id].max_lv
  407. @skills_lv[skill_id] += 1
  408. if Skill_Levels::Exp_Reset_On_Lv_Up
  409. @skills_exp[skill_id] = 0
  410. end
  411. ltex = Skill_Levels::Exp_Set[$data_skills[skill_id].exp_set][@skills_lv[skill_id]][1]
  412. text = "#{self.name}'s #{$data_skills[skill_id].name} is now #{ltex}"
  413. $game_message.add(text)
  414. end
  415. #--------------------------------------------------------------------------
  416. # Forget Skill
  417. #--------------------------------------------------------------------------
  418. def forget_skill(skill_id)
  419. fs_alias_SD13x(skill_id)
  420. @skills_list.delete(skill_id)
  421. if Skill_Levels::Reset_On_Forget
  422. @skills_lv[skill_id] = 1
  423. @skills_exp[skill_id] = 0
  424. end
  425. end
  426. #--------------------------------------------------------------------------
  427. # Die
  428. #--------------------------------------------------------------------------
  429. def die
  430. die_exp_skill
  431. do_obscure_skill_exp(:per_die)
  432. end
  433. #--------------------------------------------------------------------------
  434. # Escape
  435. #--------------------------------------------------------------------------
  436. def escape
  437. escape_exp_skill
  438. do_obscure_skill_exp(:per_esc)
  439. end
  440. #--------------------------------------------------------------------------
  441. # Do Obscure Skill Exp Gain
  442. #--------------------------------------------------------------------------
  443. def do_obscure_skill_exp(type = :nil)
  444. return if type == :nil
  445. skills.each do |skill|
  446. next if skill == nil
  447. value = Skill_Levels::Growth_Type[skill.growth_type][type]
  448. next if value <= 0
  449. actor.increase_skill_exp(skill, value)
  450. end
  451. end
  452. #--------------------------------------------------------------------------
  453. # Pay Cost of Using Skill
  454. #--------------------------------------------------------------------------
  455. def pay_skill_cost(skill)
  456. from_suparr_pscc(skill)
  457. increase_skill_exp(skill)
  458. end
  459. #--------------------------------------------------------------------------
  460. # Calculate Skill's MP Cost
  461. #--------------------------------------------------------------------------
  462. def skill_mp_cost(skill)
  463. old = skill_lv_mp_st(skill)
  464. if Skill_Levels::Dmg_Multi_Skill_Cost[:mp]
  465. old *= Skill_Levels::Exp_Set[skill.exp_set][@skills_lv[skill.id]][2]
  466. end
  467. old.to_i
  468. end
  469. #--------------------------------------------------------------------------
  470. # Calculate Skill's TP Cost
  471. #--------------------------------------------------------------------------
  472. def skill_tp_cost(skill)
  473. old = skill_lv_tp_st(skill)
  474. if Skill_Levels::Dmg_Multi_Skill_Cost[:tp]
  475. old *= Skill_Levels::Exp_Set[skill.exp_set][@skills_lv[skill.id]][2]
  476. end
  477. old.to_i
  478. end
  479.  
  480. end # << Game_Actor
  481.  
  482. #===============================================================================
  483. class Window_SkillList < Window_Selectable
  484. #===============================================================================
  485. #--------------------------------------------------------------------------
  486. # Draw Item Name
  487. #--------------------------------------------------------------------------
  488. def draw_item_name(item, x, y, enabled = true, width = (Graphics.width/2))
  489. return unless item && @actor
  490. w = (width - (standard_padding*2) - 4)
  491. draw_icon(item.icon_index, x, y, enabled)
  492. change_color(normal_color, enabled)
  493. skill_lv = @actor.skills_lv(item.id)
  494. if $D13x[:Skill_Scene] && !SceneManager.scene_is?(Scene_Battle)
  495. refresh_font
  496. text = Skill_Levels::Exp_Set[item.exp_set][skill_lv][1]
  497. draw_text(x + 24, y, w-24, line_height, item.name)
  498. draw_text(x, y, w, line_height, text, 2)
  499. else
  500. text = "#{item.name} #{Skill_Levels::Exp_Set[item.exp_set][skill_lv][1]}"
  501. draw_text(x + 24, y, w-24, line_height, text)
  502. end
  503. end
  504.  
  505. end
  506.  
  507. #===============================================================================
  508. class Game_Interpreter
  509. #===============================================================================
  510. #--------------------------------------------------------------------------
  511. # Increase Skill Level
  512. #--------------------------------------------------------------------------
  513. def level_skill(actor_id, skill_id)
  514. return if actor_id == nil
  515. return if skill_id == nil
  516. actor = $game_actors[actor_id]
  517. actor.increase_skill_proficiency(skill_id)
  518. end
  519. #--------------------------------------------------------------------------
  520. # Gain Skill Exp
  521. #--------------------------------------------------------------------------
  522. def gain_skill_exp(actor_id, skill_id, value = 0)
  523. return if actor_id == nil
  524. return if skill_id == nil
  525. return if value <= 0
  526. actor = $game_actors[actor_id]
  527. skill = $data_skills[skill_id]
  528. actor.increase_skill_exp(skill,value)
  529. end
  530.  
  531. end
  532.  
  533. #==============================================================================#
  534. # http://dekitarpg.wordpress.com/ #
  535. #==============================================================================#
  536. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement