Advertisement
Dekita

equip levels 1.1

Mar 29th, 2014
639
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.13 KB | None | 0 0
  1. if true # << Make true to use this script, false to disable.
  2. #===============================================================================
  3. #
  4. # ☆ $D13x - Equipment - Levels / Exp
  5. # -- Author : Dekita
  6. # -- Version : 1.1
  7. # -- Level : Easy / Normal
  8. # -- Requires : $D13x - Unique Equipment
  9. # -- Engine : RPG Maker VX Ace.
  10. #
  11. #===============================================================================
  12. # ☆ Import
  13. #-------------------------------------------------------------------------------
  14. $D13x={}if$D13x==nil
  15. $D13x[:Equip_Levels] = true
  16. #===============================================================================
  17. # ☆ Updates
  18. #-------------------------------------------------------------------------------
  19. # D /M /Y
  20. # 18/o3/2o13 - Updated Final version before release,
  21. # 23/o2/2o13 - Started, Finished,
  22. #
  23. #===============================================================================
  24. # ☆ Introduction
  25. #-------------------------------------------------------------------------------
  26. # This Script allows weapons and armors to gain exp along with each actor,
  27. # The exp gained and the requirements for each level are defined in
  28. # the customisation module.
  29. #
  30. # You can also enable enemies stats to increase along with the average level
  31. # of all battle members equipment.(to make balancing your database easier ??)
  32. #
  33. # Your equipment "Level" can be named anything, as well as what is shown for
  34. # each level, ie. Lv 1 weapon could say "Grade I" or "Newbie" or whatever..
  35. #
  36. # Equipment can also have its own exp rate similar to actors(exr) defined by
  37. # notetags. Default is 1.0
  38. #
  39. #===============================================================================
  40. # ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
  41. #===============================================================================
  42. # 1. You MUST give credit to "Dekita" !!
  43. # 2. You are NOT allowed to repost this script.(or modified versions)
  44. # 3. You are NOT allowed to convert this script.
  45. # 4. You are NOT allowed to use this script for Commercial games.
  46. # 5. ENJOY!
  47. #
  48. # "FINE PRINT"
  49. # By using this script you hereby agree to the above terms and conditions,
  50. # if any violation of the above terms occurs "legal action" may be taken.
  51. # Not understanding the above terms and conditions does NOT mean that
  52. # they do not apply to you.
  53. # If you wish to discuss the terms and conditions in further detail you can
  54. # contact me at http://dekitarpg.wordpress.com/
  55. #
  56. #===============================================================================
  57. # ☆ Instructions
  58. #-------------------------------------------------------------------------------
  59. # Place Below " ▼ Materials " and Above " ▼ Main " in your script editor.
  60. # Place Under My $D13x Equipment Individualize script.
  61. #
  62. #===============================================================================
  63. # ☆ Notetags ( default )
  64. # For use with Weapon / Armor noteboxes !
  65. #-------------------------------------------------------------------------------
  66. # <max level: I>
  67. # <exp rate: F>
  68. # I = An Interger value eg 1, 2, 3, 4
  69. # F = A Float Value eg. 1.25, 0.67, 1.75
  70. # To be given to equipment
  71. #
  72. #===============================================================================
  73. # ☆ Script Calls
  74. #-------------------------------------------------------------------------------
  75. # equip_gain_exp(actor_id, eqp_slot_id, exp)
  76. # equip_gain_lv(actor_id, eqp_slot_id)
  77. #
  78. # actor_has_weapon_level?(actor_id, equip_id, lv)
  79. # actor_has_wpn_teir_and_lv?(actor_id, equip_id, teir, lv)
  80. # actor_has_armor_level?(actor_id, equip_id, lv)
  81. # actor_has_armr_teir_and_lv?(actor_id, equip_id, teir, lv)
  82. #
  83. # pty_has_weapon_level?(equip_id, lv)
  84. # pty_has_wpn_teir_and_lv?(equip_id, teir, lv)
  85. # pty_has_armor_level?(equip_id, lv)
  86. # pty_has_armr_teir_and_lv?(equip_id, teir, lv)
  87. #
  88. # actor_id = the actor id from the database
  89. # eqp_slot_id = the actors equipment slot id (0 = weapons)
  90. # equip_id = weapon / armor id from the database
  91. # teir = equipments teir
  92. # lv = equipments level
  93. #
  94. #===============================================================================
  95. module Equip_Exp
  96. #===============================================================================
  97.  
  98. #---------------------------------------------------------------------------
  99. # General Settings
  100. #--------------------------------------------------------------------------
  101. Exp_Reset_On_Level = false#true
  102.  
  103. # Mod enemies params using the bonus param multiplier based on the average
  104. # equipment level (from all battle members), true = yes, false = no
  105. Enemy_Param_Mod = true
  106.  
  107. # if this is true, equipment will gain exp (Battle Points) from battle.
  108. Gain_Exp_From_Battle = true # false
  109. #---------------------------------------------------------------------------
  110. # Level Settings
  111. #---------------------------------------------------------------------------
  112. Level_Names={
  113. # Lv => Vocab
  114. 0 => "N/A", # DONT DELETE
  115. 1 => "+1",
  116. 2 => "+2",
  117. 3 => "+3",
  118. 4 => "+4",
  119. 5 => "+5",
  120. 6 => "+6",
  121. 7 => "+7",
  122. 8 => "+8",
  123. 9 => "+9",
  124. }#DONT DELETE
  125.  
  126. Max_Level_Note = /<max level:(.*)>/i
  127.  
  128. #---------------------------------------------------------------------------
  129. # Exp Settings
  130. #---------------------------------------------------------------------------
  131. Exp_Required={
  132. # Lv => Exp Required
  133. 0 => 0, # DONT DELETE
  134. 1 => 100,
  135. 2 => 200,
  136. 3 => 300,
  137. 4 => 400,
  138. 5 => 500,
  139. 6 => 600,
  140. 7 => 700,
  141. 8 => 800,
  142. 9 => 900,
  143. }#DONT DELETE
  144.  
  145. Exp_Vocab = "Battle Points"
  146.  
  147. Exp_Rate_Note = /<exp rate:(.*)>/i
  148.  
  149. Exp_Rate_Vocab = "BP Rate"
  150.  
  151. def self.exp_gain_vocab(a, e)
  152. text = "#{a.name}'s #{e.name} Gained #{default_exp(a,e)} #{Exp_Vocab}!"
  153. return text
  154. end
  155.  
  156. def self.default_exp(actor, equip)
  157. base = ($game_troop.exp_total/10)
  158. membs = $game_party.battle_members.size
  159. value = (base / membs) * equip.exp_rate #* actor.exr
  160. return value.to_i
  161. end
  162.  
  163. #---------------------------------------------------------------------------
  164. # Bonus Param Settings
  165. #---------------------------------------------------------------------------
  166. # Note: Default equip params are multiplied by the value set for their level
  167. # the current params are then replaced by the new value(default * multiplier)
  168. # ALL unique features from equipment remain the same
  169. #---------------------------------------------------------------------------
  170. Bonus_Params_Mult={
  171. # Lv => Params Multiplier
  172. 0 => 1.0, # DONT DELETE
  173. 1 => 1.2,
  174. 2 => 1.4,
  175. 3 => 1.7,
  176. 4 => 2.1,
  177. 5 => 2.6,
  178. 6 => 3.2,
  179. 7 => 3.9,
  180. 8 => 4.7,
  181. 9 => 5.5,
  182. }#DONT DELETE
  183. #####################
  184. # CUSTOMISATION END #
  185. end #####################
  186. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
  187. # #
  188. # http://dekitarpg.wordpress.com/ #
  189. # #
  190. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
  191. #===============================================================================#
  192. # ARE YOU MODIFYING BEYOND THIS POINT? \.\. #
  193. # YES?\.\. #
  194. # OMG, REALLY? \| #
  195. # WELL SLAP MY FACE AND CALL ME A DRAGONITE.\..\.. #
  196. # I REALLY DIDN'T THINK YOU HAD IT IN YOU.\..\.. #
  197. #===============================================================================#
  198. class RPG::EquipItem < RPG::BaseItem
  199. #===============================================================================
  200. #---------------------------------------------------------------------------
  201. # Included modules
  202. #---------------------------------------------------------------------------
  203. include Equip_Exp
  204. #---------------------------------------------------------------------------
  205. # Alias List
  206. #---------------------------------------------------------------------------
  207. alias :deki_equip_Exp :load_unique_equip
  208. #---------------------------------------------------------------------------
  209. # Pi Variables
  210. #---------------------------------------------------------------------------
  211. attr_accessor :level
  212. attr_accessor :exp
  213. attr_accessor :exp_rate
  214. attr_accessor :grade
  215. #---------------------------------------------------------------------------
  216. # load unique shit
  217. #---------------------------------------------------------------------------
  218. def load_unique_equip
  219. deki_equip_Exp
  220. @level = 0
  221. @exp = 0
  222. @exp_rate = 1.0
  223. @max_level = (Exp_Required.size - 1)
  224. @grade = 1
  225. self.note.split(/[\r\n]+/).each do |line|
  226. case line
  227. when Exp_Rate_Note
  228. @exp_rate = $1.to_f
  229. when Max_Level_Note
  230. @max_level = $1.to_i
  231. when /<GRADE:(.*)>/i
  232. @grade = $1.to_i
  233. end
  234. end
  235. end
  236. #---------------------------------------------------------------------------
  237. # Gain Exp
  238. #---------------------------------------------------------------------------
  239. def gain_exp(actor, value = 1)
  240. value.times do
  241. @exp += 1
  242. level_up(actor) if did_level?
  243. end
  244. end
  245. #---------------------------------------------------------------------------
  246. # Max Level Reached ?
  247. #---------------------------------------------------------------------------
  248. def at_max_level?
  249. return true if @level >= @max_level
  250. return false
  251. end
  252. #---------------------------------------------------------------------------
  253. # Did Equip Level ?
  254. #---------------------------------------------------------------------------
  255. def did_level?
  256. return false if at_max_level?
  257. return true if @exp >= Exp_Required[@level+1]
  258. return false
  259. end
  260. #---------------------------------------------------------------------------
  261. # Do Level Increase
  262. #---------------------------------------------------------------------------
  263. def level_up(actor)
  264. @level += 1
  265. @exp = 0 if Exp_Reset_On_Level
  266. display_lv_up(actor)
  267. mod_de_parzz(actor)
  268. end
  269. #---------------------------------------------------------------------------
  270. # Change Params
  271. #---------------------------------------------------------------------------
  272. def mod_de_parzz(actor)
  273. index = 0
  274. d = $data_weapons[@database_id] if self.is_a?(RPG::Weapon)
  275. d = $data_armors [@database_id] if self.is_a?(RPG::Armor)
  276. d.params.each do |par|
  277. stored = self.params[index] - (par * Bonus_Params_Mult[@level-1]).to_i
  278. new_val = (par * Bonus_Params_Mult[@level] + stored).to_i
  279. params[index] = new_val
  280. increase = (params[index] - stored).to_i
  281. display_lv_up_stat_inc(actor, index, increase, d.params[index])
  282. index += 1
  283. end
  284. if $D13x[:Stats_Control]
  285. index = 0
  286. d.pars.each do |pars|
  287. stored = self.pars[index] - (pars * Bonus_Params_Mult[@level-1]).to_i
  288. new_val = (pars * Bonus_Params_Mult[@level] + stored).to_i
  289. @pars[index] = new_val
  290. increase = (@pars[index] - stored).to_i
  291. display_lv_up_stat_inc(actor, index, increase, d.pars[index])
  292. index += 1
  293. end
  294. index = 0
  295. d.xpars.each do |xpars|
  296. stored = self.xpars[index] - (xpars * Bonus_Params_Mult[@level-1]).to_f
  297. new_val = (xpars * Bonus_Params_Mult[@level] + stored).to_f
  298. @xpars[index] = new_val
  299. increase = (@xpars[index] - stored).to_f
  300. display_lv_up_stat_inc(actor, index, increase, d.xpars[index], :x_param)
  301. p @xpars[index]
  302. index += 1
  303. end
  304. index = 0
  305. d.spars.each do |spars|
  306. stored = self.spars[index] - (spars * Bonus_Params_Mult[@level-1]).to_f
  307. new_val = (spars * Bonus_Params_Mult[@level] + stored).to_f
  308. @spars[index] = new_val
  309. increase = (@spars[index] - stored).to_f
  310. display_lv_up_stat_inc(actor, index, increase, d.spars[index], :s_param)
  311. p @spars[index]
  312. index += 1
  313. end
  314. end#if $D13x[:Stats_Control]
  315. end
  316. #---------------------------------------------------------------------------
  317. # Display Level Up
  318. #---------------------------------------------------------------------------
  319. def display_lv_up(actor)
  320. $game_message.new_page
  321. msg = "#{actor.name}'s #{@name} is now #{Level_Names[@level]}"
  322. $game_message.add(msg)
  323. end
  324. #---------------------------------------------------------------------------
  325. # Display Items Stats (after evel up)
  326. #---------------------------------------------------------------------------
  327. def display_lv_up_stat_inc(act, pid, val, par, type = :param)
  328. return if val == 0.0
  329. return if par == 0.0
  330. case type
  331. when :param
  332. $game_message.add("#{@name}'s Base #{Vocab::param(pid)} is now #{val}")
  333. when :x_param
  334. $game_message.add("#{@name}'s Base #{Vocab::x_param(pid)} is now #{val}")
  335. when :s_param
  336. $game_message.add("#{@name}'s Base #{Vocab::s_param(pid)} is now #{val}")
  337. end
  338. end
  339.  
  340. end # RPG::EquipItem
  341.  
  342. #==============================================================================
  343. module BattleManager
  344. #==============================================================================
  345. #---------------------------------------------------------------------------
  346. # Alias List
  347. #---------------------------------------------------------------------------
  348. class << self
  349. alias :disp_unique_exp :display_exp
  350. alias :gain_unique_exp :gain_exp
  351. end
  352. #--------------------------------------------------------------------------
  353. # Display Party EXP Earned
  354. #--------------------------------------------------------------------------
  355. def self.display_exp
  356. disp_unique_exp
  357. display_equip_exp
  358. end
  359. #--------------------------------------------------------------------------
  360. # Display Equip EXP Earned
  361. #--------------------------------------------------------------------------
  362. def self.display_equip_exp
  363. return unless Equip_Exp::Gain_Exp_From_Battle
  364. $game_party.battle_members.each do |actor|
  365. actor.equips.each do |equip|
  366. next if equip == nil
  367. next if equip.at_max_level?
  368. if Equip_Exp.default_exp(actor,equip) > 0
  369. tex = Equip_Exp.exp_gain_vocab(actor,equip)
  370. $game_message.add('\.' + tex)
  371. end
  372. end
  373. end
  374. end
  375. #--------------------------------------------------------------------------
  376. # Party EXP Acquisition and Level Up Display
  377. #--------------------------------------------------------------------------
  378. def self.gain_exp
  379. gain_unique_exp
  380. gain_equip_exp
  381. end
  382. #--------------------------------------------------------------------------
  383. # Equip EXP Acquisition and Level Up Display
  384. #--------------------------------------------------------------------------
  385. def self.gain_equip_exp
  386. $game_party.battle_members.each do |actor|
  387. actor.equips.each do |equip|
  388. next if equip == nil
  389. next if equip.at_max_level?
  390. if Equip_Exp.default_exp(actor,equip) > 0
  391. equip.gain_exp(actor,Equip_Exp.default_exp(actor,equip))
  392. end
  393. end
  394. end
  395. wait_for_message
  396. end
  397.  
  398. end
  399.  
  400. #==============================================================================
  401. class Game_Enemy < Game_Battler
  402. #==============================================================================
  403. if Equip_Exp::Enemy_Param_Mod
  404. #--------------------------------------------------------------------------
  405. # Alias List
  406. #--------------------------------------------------------------------------
  407. alias :param_base_EQUIP_EXP :param_base
  408. #--------------------------------------------------------------------------
  409. # Get Base Value of Parameter
  410. #--------------------------------------------------------------------------
  411. def param_base(param_id)
  412. param_base_EQUIP_EXP(param_id) * Equip_Exp::Bonus_Params_Mult[average_party_equip_level]
  413. end
  414. #--------------------------------------------------------------------------
  415. # Get Average Party Equipment Level
  416. #--------------------------------------------------------------------------
  417. def average_party_equip_level
  418. c = 0
  419. d = 0
  420. $game_party.battle_members.each do |memb|
  421. memb.equips.each do |eqp|
  422. next if eqp == nil
  423. c += 1
  424. d += eqp.level
  425. end
  426. end
  427. c = 1 if d == 0
  428. return (d / c).to_i
  429. end
  430. end # if Enemy_Param_Mod
  431.  
  432. end
  433.  
  434. #==============================================================================
  435. class Game_Interpreter
  436. #==============================================================================
  437. #---------------------------------------------------------------------------
  438. # Adds Exp to an actors equipment
  439. #---------------------------------------------------------------------------
  440. def equip_gain_exp(aid, eqp_id, exp)
  441. return if aid == (nil || 0)
  442. actor = $game_actors[aid]
  443. return if actor.equip[eqp_id] == nil
  444. actor.equips[eqp_id].gain_exp(actor,exp)
  445. end
  446. #---------------------------------------------------------------------------
  447. # Adds Level to an actors equipment
  448. #---------------------------------------------------------------------------
  449. def equip_gain_lv(aid, eqp_id)
  450. return if aid == (nil || 0)
  451. actor = $game_actors[aid]
  452. return if actor.equip[eqp_id] == nil
  453. actor.equips[eqp_id].level_up(actor)
  454. end
  455. #---------------------------------------------------------------------------
  456. # Checks if actor has specific level weapon equipped
  457. #---------------------------------------------------------------------------
  458. def actor_has_weapon_level?(aid, wid, level)
  459. bool = false
  460. $game_actors[aid].weapons.each do |wep|
  461. bool = true if $data_weapons[wep.id].database_id == wid &&
  462. $data_weapons[wep.id].level == level
  463. end
  464. return bool
  465. end
  466. #---------------------------------------------------------------------------
  467. # Checks if actor has specific level weapon equipped
  468. #---------------------------------------------------------------------------
  469. def actor_has_wpn_teir_and_lv?(aid, wid, teir, lv)
  470. bool = false
  471. $game_actors[aid].weapons.each do |wep|
  472. bool = true if $data_weapons[wep.id].database_id == wid &&
  473. $data_weapons[wep.id].level == level &&
  474. $data_weapons[wep.id].teir == teir
  475. end
  476. return bool
  477. end
  478. #---------------------------------------------------------------------------
  479. # Checks if party has specific level weapon
  480. #---------------------------------------------------------------------------
  481. def pty_has_weapon_level?(wid, level)
  482. bool = false
  483. $game_party.weapons.each do |wep|
  484. bool = true if $data_weapons[wep.id].database_id == wid &&
  485. $data_weapons[wep.id].level == level
  486. end
  487. return bool
  488. end
  489. #---------------------------------------------------------------------------
  490. # Checks if party has specific level weapon
  491. #---------------------------------------------------------------------------
  492. def pty_has_wpn_teir_and_lv?(wid, teir, lv)
  493. bool = false
  494. $game_party.weapons.each do |wep|
  495. bool = true if $data_weapons[wep.id].database_id == wid &&
  496. $data_weapons[wep.id].level == level &&
  497. $data_weapons[wep.id].teir == teir
  498. end
  499. return bool
  500. end
  501. #---------------------------------------------------------------------------
  502. # Checks if actor has specific level armor equipped
  503. #---------------------------------------------------------------------------
  504. def actor_has_armor_level?(aid, wid, level)
  505. bool = false
  506. $game_actors[aid].armors.each do |wep|
  507. bool = true if $data_armors[wep.id].database_id == wid &&
  508. $data_armors[wep.id].level == level
  509. end
  510. return bool
  511. end
  512. #---------------------------------------------------------------------------
  513. # Checks if actor has specific level armor equipped
  514. #---------------------------------------------------------------------------
  515. def actor_has_armr_teir_and_lv?(aid, wid, teir, lv)
  516. bool = false
  517. $game_actors[aid].armors.each do |wep|
  518. bool = true if $data_armors[wep.id].database_id == wid &&
  519. $data_armors[wep.id].level == level &&
  520. $data_armors[wep.id].teir == teir
  521. end
  522. return bool
  523. end
  524. #---------------------------------------------------------------------------
  525. # Checks if party has specific level armor
  526. #---------------------------------------------------------------------------
  527. def pty_has_armor_level?(wid, level)
  528. bool = false
  529. $game_party.armors.each do |wep|
  530. bool = true if $data_armors[wep.id].database_id == wid &&
  531. $data_armors[wep.id].level == level
  532. end
  533. return bool
  534. end
  535. #---------------------------------------------------------------------------
  536. # Checks if party has specific level armor
  537. #---------------------------------------------------------------------------
  538. def pty_has_armr_teir_and_lv?(wid, teir, lv)
  539. bool = false
  540. $game_party.armors.each do |wep|
  541. bool = true if $data_armors[wep.id].database_id == wid &&
  542. $data_armors[wep.id].level == level &&
  543. $data_armors[wep.id].teir == teir
  544. end
  545. return bool
  546. end
  547.  
  548. end
  549.  
  550. #==============================================================================#
  551. # - SCRIPT END - #
  552. #==============================================================================#
  553. # http://dekitarpg.wordpress.com/ #
  554. #==============================================================================#
  555.  
  556.  
  557. end # if false / true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement