Advertisement
Dekita

$D13x Skill Levels 1.2

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