Advertisement
Dekita

Max TP Control v1.2

Mar 26th, 2014
1,231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.48 KB | None | 0 0
  1. if true # << Make true to use this script, false to disable.
  2. #===============================================================================
  3. #
  4. # ☆ $D13x - Max TP Control
  5. # -- Author : Dekita
  6. # -- Version : 1.2
  7. # -- Level : Easy / Normal
  8. # -- Requires : $D13x Core v2.0+
  9. # -- Engine : RPG Maker VX Ace.
  10. #
  11. #===============================================================================
  12. # ☆ Import
  13. #-------------------------------------------------------------------------------
  14. $D13x={}if$D13x==nil
  15. $D13x[:TP_Control]=true
  16. #===============================================================================
  17. # ☆ Updates
  18. #-------------------------------------------------------------------------------
  19. # D /M /Y
  20. # 26/o3/2o14 - Released update, cant remember when I wrote it...
  21. # 31/o5/2o13 - Added More Help Info for Script Calls.
  22. # 22/o5/2o13 - Started, Finished,
  23. #
  24. #===============================================================================
  25. # ☆ Introduction
  26. #-------------------------------------------------------------------------------
  27. # This script simply allows a little more control over TP..
  28. # Mainly having a max TP limit, and the ability to change the limit
  29. # a variety of different ways...
  30. # Such as script calls and notetags, even pairing this script with others from
  31. # the $D13x engine, like ISPDS, Dev SLUD, Equip Sets...
  32. #
  33. # Each Actor can also gain TP differently.
  34. #
  35. #===============================================================================
  36. # ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
  37. #===============================================================================
  38. # 1. You MUST give credit to "Dekita" !!
  39. # 2. You are NOT allowed to repost this script.(or modified versions)
  40. # 3. You are NOT allowed to convert this script.
  41. # 4. You are NOT allowed to use this script for Commercial games.
  42. # 5. ENJOY!
  43. #
  44. # "FINE PRINT"
  45. # By using this script you hereby agree to the above terms and conditions,
  46. # if any violation of the above terms occurs "legal action" may be taken.
  47. # Not understanding the above terms and conditions does NOT mean that
  48. # they do not apply to you.
  49. # If you wish to discuss the terms and conditions in further detail you can
  50. # contact me at http://dekitarpg.wordpress.com/
  51. #
  52. #===============================================================================
  53. # ☆ Instructions
  54. #-------------------------------------------------------------------------------
  55. # Place Below " ▼ Materials " and Above " ▼ Main " in your script editor.
  56. #
  57. #===============================================================================
  58. # ☆ Script Calls
  59. #-------------------------------------------------------------------------------
  60. # $game_actors[ACTOR_ID].add_max_tp(value)
  61. # $game_actors[ACTOR_ID].sub_max_tp(value)
  62. # $game_actors[ACTOR_ID].div_max_tp(value)
  63. # $game_actors[ACTOR_ID].mul_max_tp(value)
  64. # $game_actors[ACTOR_ID].mod_max_tp(value)
  65. #
  66. # these are the calculatons for each control type
  67. # add : current stat += value
  68. # sub : current stat -= value
  69. # div : current stat /= value
  70. # mul : current stat *= value
  71. # mod : current stat %= value
  72. #
  73. # These script calls modify the Actor value, other items remain in the same order.
  74. #
  75. # There is also a second arguement for all the above script calls,
  76. # it is a boolean arguement to determine if the player should be refreshed.
  77. # eg.. $game_actors[1].add_max_tp(50, false)
  78. # this is very helpfull for maintaining FPS when adding LOTS of stats..
  79. # The default to this arguemet is true.
  80. # If you don't understand what this mean, just disregard this information :)
  81. #
  82. #===============================================================================
  83. # ☆ Notetags ( default )
  84. #-------------------------------------------------------------------------------
  85. # <mtp plus: VALUE>
  86. # VALUE = the value to increase the max tp.
  87. # For use with Weapons / Armors / Enemies / Actors / Classes / States / Skills
  88. #
  89. #-------------------------------------------------------------------------------
  90. # <tp cost: X> << FOR SKiLLS 0NLY
  91. # replace X with the tp cost. for when skills have a higher tp cost than 100.
  92. #
  93. #-------------------------------------------------------------------------------
  94. # <tp type: X>
  95. # replace X with the TP type ID.
  96. #
  97. #-------------------------------------------------------------------------------
  98. # All Increases and Decreases are stacked, using the following calculation ..
  99. # Base + Actor(or Enemy) + Class(if actor) + Equipment(if actor) + States +
  100. # Skills that modify stats or max stats (ie passive skills)
  101. #
  102. #===============================================================================
  103. module TP_Control
  104. #===============================================================================
  105. TP_Type={}# << Keep
  106.  
  107. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  108. # ☆ TP Type Settings
  109. #-----------------------------------------------------------------------------
  110. TP_Type[0]={
  111. :max__tp => "10",
  112. :preserve => true,
  113. :init_tp => "rand * 25",
  114. :take_dmg => "50 * damage_rate * tcr",
  115. :regen_tp => "100 * trg",
  116. }
  117. #-----------------------------------------------------------------------------
  118. TP_Type[1]={
  119. :max__tp => "100",
  120. :preserve => true,
  121. :init_tp => "rand * 50",
  122. :take_dmg => "50 * damage_rate * tcr",
  123. :regen_tp => "100 * trg",
  124. }
  125. #-----------------------------------------------------------------------------
  126. TP_Type[2]={
  127. :max__tp => "0",
  128. :preserve => true,
  129. :init_tp => "rand * 50",
  130. :take_dmg => "50 * damage_rate * tcr",
  131. :regen_tp => "100 * trg",
  132. }
  133. #-----------------------------------------------------------------------------
  134. # Default TP Type id for all actors and enemies
  135. Default_TP_Type = 0
  136. #-----------------------------------------------------------------------------
  137. # Notetag Settings
  138. Notes={
  139. :mtp_increase => /<mtp plus:(.*)>/i ,
  140. :tp_cost => /<tp cost:(.*)>/i ,
  141. }
  142. #####################
  143. # CUSTOMISATION END #
  144. end #####################
  145. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
  146. # #
  147. # http://dekitarpg.wordpress.com/ #
  148. # #
  149. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
  150. #===============================================================================#
  151. # ARE YOU MODIFYING BEYOND THIS POINT? \.\. #
  152. # YES?\.\. #
  153. # OMG, REALLY? \| #
  154. # WELL SLAP MY FACE AND CALL ME A DRAGONITE.\..\.. #
  155. # I REALLY DIDN'T THINK YOU HAD IT IN YOU.\..\.. #
  156. #===============================================================================#
  157. module DataManager
  158. #===============================================================================
  159. #---------------------------------------------------------------------------
  160. # Alias List
  161. #---------------------------------------------------------------------------
  162. class << self
  163. alias :lbd__TPLIM :load_database
  164. end
  165. #---------------------------------------------------------------------------
  166. # Load Database (alias)
  167. #---------------------------------------------------------------------------
  168. def self.load_database
  169. lbd__TPLIM
  170. loa__TMLIM
  171. end
  172. #---------------------------------------------------------------------------
  173. # Load Unique Shit
  174. #---------------------------------------------------------------------------
  175. def self.loa__TMLIM
  176. classes = [$data_weapons, $data_armors , $data_items , $data_skills ,
  177. $data_actors , $data_classes, $data_enemies, $data_states ]
  178. for g in classes
  179. for o in g
  180. next if o == nil
  181. o.loa__TMLIM
  182. end
  183. end
  184. end
  185.  
  186. end # DataManager
  187.  
  188. #===============================================================================
  189. class RPG::BaseItem
  190. #===============================================================================
  191. #-----------------------------------------------------------------------------
  192. # Pi Variables
  193. #-----------------------------------------------------------------------------
  194. attr_accessor :mtp_plus
  195. attr_accessor :tp_type_id
  196. #-----------------------------------------------------------------------------
  197. # Alias List
  198. #-----------------------------------------------------------------------------
  199. def loa__TMLIM
  200. @mtp_plus = 0
  201. @tp_type_id = nil
  202. self.note.split(/[\r\n]+/).each do |line|
  203. case line
  204. when TP_Control::Notes[:mtp_increase]
  205. @mtp_plus = $1.to_i
  206. when TP_Control::Notes[:tp_cost]
  207. next unless self.is_a?(RPG::Skill)
  208. @tp_cost = $1.to_i
  209. when /<tp type:(.*)/i
  210. @tp_type_id = $1.to_i
  211. end
  212. end
  213. end
  214.  
  215. end
  216.  
  217. #===============================================================================
  218. class Game_BattlerBase
  219. #===============================================================================
  220. #-----------------------------------------------------------------------------
  221. # Alias List
  222. #-----------------------------------------------------------------------------
  223. alias :init_tp_control :initialize
  224. #-----------------------------------------------------------------------------
  225. # Initialize
  226. #-----------------------------------------------------------------------------
  227. def initialize(*args, &block)
  228. @tp_type_id = TP_Control::Default_TP_Type
  229. @max_tp_prefix = 0
  230. clear_tp_control
  231. init_tp_control(*args, &block)
  232. end
  233. #-----------------------------------------------------------------------------
  234. # Get TP Data From Main Module
  235. #-----------------------------------------------------------------------------
  236. def tp_type_data(data)
  237. return TP_Control::TP_Type[@tp_type_id][data]
  238. end
  239. #-----------------------------------------------------------------------------
  240. # Atk Lv | Def Lv
  241. #-----------------------------------------------------------------------------
  242. def maximum_tp
  243. base = eval(tp_type_data(:max__tp)) rescue 100
  244. @max_tp_prefix = (base+max_tp_plus).to_i
  245. @max_tp_prefix
  246. end
  247. #-----------------------------------------------------------------------------
  248. # Atk Lv | Def Lv ++
  249. #-----------------------------------------------------------------------------
  250. def max_tp_plus
  251. @max_tp_plus[0]
  252. end
  253. #-----------------------------------------------------------------------------
  254. # Clear Atk Lv | Def Lv
  255. #-----------------------------------------------------------------------------
  256. def clear_tp_control
  257. @max_tp_plus = [0]
  258. end
  259. #-----------------------------------------------------------------------------
  260. # Add Max TP
  261. #-----------------------------------------------------------------------------
  262. def add_max_tp(value, ref = true)
  263. @max_tp_plus[0] += value
  264. refresh if ref
  265. end
  266. #-----------------------------------------------------------------------------
  267. # Sub Max TP
  268. #-----------------------------------------------------------------------------
  269. def sub_max_tp(value, ref = true)
  270. @max_tp_plus[0] -= value
  271. refresh if ref
  272. end
  273. #-----------------------------------------------------------------------------
  274. # Div Max TP
  275. #-----------------------------------------------------------------------------
  276. def div_max_tp(value, ref = true)
  277. @max_tp_plus[0] /= value
  278. refresh if ref
  279. end
  280. #-----------------------------------------------------------------------------
  281. # Mul Max TP
  282. #-----------------------------------------------------------------------------
  283. def mul_max_tp(value, ref = true)
  284. @max_tp_plus[0] *= value
  285. refresh if ref
  286. end
  287. #-----------------------------------------------------------------------------
  288. # Mod Max TP
  289. #-----------------------------------------------------------------------------
  290. def mod_max_tp(value, ref = true)
  291. @max_tp_plus[0] %= value
  292. refresh if ref
  293. end
  294. #-----------------------------------------------------------------------------
  295. # Get Maximum Value of TP (overwrite)
  296. #-----------------------------------------------------------------------------
  297. def max_tp
  298. return maximum_tp
  299. end
  300. #-----------------------------------------------------------------------------
  301. # Get Percentage of TP (overwrite)
  302. #-----------------------------------------------------------------------------
  303. def tp_rate
  304. @tp.to_f / max_tp
  305. end
  306. #-----------------------------------------------------------------------------
  307. # Determine if Preserve TP (overwrite)
  308. #-----------------------------------------------------------------------------
  309. def preserve_tp?
  310. return tp_type_data(:preserve)
  311. end
  312.  
  313. end
  314.  
  315. #===============================================================================
  316. class Game_Battler < Game_BattlerBase
  317. #===============================================================================
  318. #-----------------------------------------------------------------------------
  319. # Initialize TP
  320. #-----------------------------------------------------------------------------
  321. def init_tp
  322. self.tp = eval(tp_type_data(:init_tp))
  323. end
  324. #-----------------------------------------------------------------------------
  325. # Charge TP by Damage Suffered
  326. #-----------------------------------------------------------------------------
  327. def charge_tp_by_damage(damage_rate)
  328. self.tp += eval(tp_type_data(:take_dmg))
  329. end
  330. #-----------------------------------------------------------------------------
  331. # Regenerate TP
  332. #-----------------------------------------------------------------------------
  333. def regenerate_tp
  334. self.tp += eval(tp_type_data(:regen_tp))
  335. end
  336. end
  337.  
  338. #===============================================================================
  339. class Game_Actor < Game_Battler
  340. #===============================================================================
  341. #-----------------------------------------------------------------------------
  342. # Alias List
  343. #-----------------------------------------------------------------------------
  344. alias :sD13x_mtp_init :initialize
  345. #-----------------------------------------------------------------------------
  346. # Initialization
  347. #-----------------------------------------------------------------------------
  348. def initialize(actor_id)
  349. sD13x_mtp_init(actor_id)
  350. set_tp_type_data
  351. end
  352. #-----------------------------------------------------------------------------
  353. # Set TP Data
  354. #-----------------------------------------------------------------------------
  355. def set_tp_type_data
  356. if actor.tp_type_id != nil
  357. @tp_type_id = actor.tp_type_id
  358. end
  359. if self.class.tp_type_id != nil
  360. @tp_type_id = self.class.tp_type_id
  361. end
  362. end
  363. #-----------------------------------------------------------------------------
  364. # Max TP Plus
  365. #-----------------------------------------------------------------------------
  366. def max_tp_plus
  367. base = super
  368. base += actor.mtp_plus
  369. base += self.class.mtp_plus
  370. base += equips.compact.inject(0) {|r, i| r += i.mtp_plus }
  371. base += states.compact.inject(0) {|r, i| r += i.mtp_plus }
  372. if $D13x[:Skill_Lv]
  373. base += skills.compact.inject(0) {|r, i| r += (i.mtp_plus*
  374. Skill_Levels::Exp_Set[i.exp_set][@skills_lv[i.id]][2] ).to_f}
  375. else
  376. base += skills.compact.inject(0) {|r, i| r += i.mtp_plus }
  377. end
  378. base
  379. end
  380.  
  381. end
  382.  
  383. #===============================================================================
  384. class Game_Enemy < Game_Battler
  385. #===============================================================================
  386. #-----------------------------------------------------------------------------
  387. # Alias List
  388. #-----------------------------------------------------------------------------
  389. alias :sD13x_mtp_init :initialize
  390. #-----------------------------------------------------------------------------
  391. # Initialization
  392. #-----------------------------------------------------------------------------
  393. def initialize(index, enemy_id)
  394. sD13x_mtp_init(index, enemy_id)
  395. set_tp_type_data
  396. end
  397. #-----------------------------------------------------------------------------
  398. # Set TP Data
  399. #-----------------------------------------------------------------------------
  400. def set_tp_type_data
  401. if enemy.tp_type_id != nil
  402. @tp_type_id = enemy.tp_type_id
  403. end
  404. end
  405. #-----------------------------------------------------------------------------
  406. # Max TP Plus
  407. #-----------------------------------------------------------------------------
  408. def max_tp_plus
  409. base = super
  410. base += enemy.mtp_plus
  411. base += states.compact.inject(0) {|r, i| r += i.mtp_plus }
  412. base
  413. end
  414.  
  415. end
  416.  
  417. #==============================================================================#
  418. # http://dekitarpg.wordpress.com/ #
  419. #==============================================================================#
  420. end # if true # << Make true to use this script, false to disable.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement