Advertisement
Dekita

$D13x Skill Levels 1.1

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