Advertisement
TheSixth

Individual Skill Cost Features

Jun 6th, 2019
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.70 KB | None | 0 0
  1. =begin
  2.  
  3. - Individual Skill Cost Features v1.0
  4. - Made by: Sixth
  5.  
  6. - Description:
  7. This script will let you make new features that can change the MP/TP cost of
  8. only the specified skills instead of changing the cost globally.
  9.  
  10. - Note-tags:
  11.  
  12. Use these note-tags to add these new features to your actors, classes, enemies,
  13. equipment and states:
  14.  
  15.   <mp cost ex: skill_id, value>
  16.   <tp cost ex: skill_id, value>
  17.  
  18. Replace skill_id with the database ID of the skill.
  19.  
  20. Replace the value with the percentage you want to multiply the cost.
  21. It must be a float value from 0.0 to ... infinity.
  22. 0.0 means 0%, which also means no cost at all for the specified skill.
  23. 0.5 means 50%, so the cost is halved.
  24. 1.5 means 150%, so the cost is doubled.
  25. And so on...
  26.  
  27. Note that this bonus is multiplicative, so if a battler got two features for
  28. the same skill, like:
  29.  
  30.   <mp cost ex: 15, 0.5>
  31.   <mp cost ex: 15, 0.75>
  32.  
  33. It would multiply the cost of Skill 15 by 0.5 * 0.75, which is 0.375, and that
  34. means 37.5% of the original cost at the end.
  35. This is how the default MCR feature works too, in case you wonder...
  36.  
  37. You can use multiple of these note-tags on the same database object to setup a
  38. cost modifier for multiple skills if needed.
  39.  
  40. - Installation:
  41. Place this script below Materials but above Main!
  42.  
  43. If you use other scripts altering the skill cost calculation, your best bet is
  44. to put this above them, because this script overwrites the methods for these
  45. calculation for more precise results (integer conversion in the middle would
  46. ruin it otherwise).
  47.  
  48. =end
  49.  
  50. class RPG::BaseItem
  51.  
  52.   attr_accessor :mp_cost_ex, :tp_cost_ex
  53.  
  54.   def mp_cost_ex
  55.     init_mp_cost_ex if @mp_cost_ex.nil?
  56.     return @mp_cost_ex
  57.   end
  58.  
  59.   def init_mp_cost_ex
  60.     @mp_cost_ex = {}
  61.     cnote = @note.clone
  62.     while cnote =~ /<mp cost ex: (\d+), (.*)>/i
  63.       @mp_cost_ex[$1.to_i] = $2.to_f
  64.       cnote.sub!(/<mp cost ex: (\d+), (.*)>/i,"")
  65.     end
  66.   end
  67.  
  68.   def tp_cost_ex
  69.     init_tp_cost_ex if @tp_cost_ex.nil?
  70.     return @tp_cost_ex
  71.   end
  72.  
  73.   def init_tp_cost_ex
  74.     @tp_cost_ex = {}
  75.     cnote = @note.clone
  76.     while cnote =~ /<tp cost ex: (\d+), (.*)>/i
  77.       @tp_cost_ex[$1.to_i] = $2.to_f
  78.       cnote.sub!(/<tp cost ex: (\d+), (.*)>/i,"")
  79.     end
  80.   end
  81.  
  82. end
  83.  
  84. class Game_BattlerBase
  85.  
  86.   def mp_cost_ex(sid)
  87.     return feature_objects.inject(1.0) {|r,obj| r *= (obj.mp_cost_ex[sid] || 1) }
  88.   end
  89.  
  90.   def tp_cost_ex(sid)
  91.     return feature_objects.inject(1.0) {|r,obj| r *= (obj.tp_cost_ex[sid] || 1) }
  92.   end
  93.  
  94.   def skill_mp_cost(sk)
  95.     return (sk.mp_cost * mcr * mp_cost_ex(sk.id)).to_i
  96.   end
  97.  
  98.   def skill_tp_cost(sk)
  99.     return (sk.tp_cost * tp_cost_ex(sk.id)).to_i
  100.   end
  101.  
  102. end
  103. # End of script!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement