noelburgundy27

Yanfly Skill Cost Eval Patch

Jun 19th, 2014
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.39 KB | None | 0 0
  1. =begin
  2. Patch by estriole
  3. This helps you define a current actor and make a custom cost eval for
  4. user-based costs. More or less it helps you use a custom formula to use for
  5. displaying the skill cost. Only function is geared towards user-related stats.
  6. ==========================================================
  7. Requires Yanfly's Skill Cost Manager above it to function
  8. ==========================================================
  9. Use this notetag format in the skill
  10.  
  11. <custom_cost_eval: formula>
  12. Replace formula with a formula
  13. EXAMPLE!
  14. <custom_cost_eval: cur_actor.level * 5>
  15.  
  16. In the skills window, it will display the new skill cost. e.g. 5 at Lv1, 10 at Lv2
  17.  
  18. =end
  19.  
  20. def cur_actor
  21. SceneManager.scene.is_a?(Scene_Battle) ? BattleManager.actor : $game_party.menu_actor
  22. end
  23.  
  24. class RPG::Skill < RPG::UsableItem
  25.   attr_accessor :custom_cost_text_eval
  26.   def load_notetags_scm
  27.     @hp_cost = 0
  28.     @gold_cost = 0
  29.     @hp_cost_percent = 0.0
  30.     @mp_cost_percent = 0.0
  31.     @tp_cost_percent = 0.0
  32.     @gold_cost_percent = 0.0
  33.    
  34.     @custom_cost_text = ""
  35.     @custom_cost_colour = 0
  36.     @custom_cost_size = 20
  37.     @custom_cost_icon = 0
  38.     @custom_cost_requirement = ""
  39.     @custom_cost_perform = ""
  40.    
  41.     @use_custom_cost = false
  42.     @custom_cost_req_on = false
  43.     @custom_cost_per_on = false
  44.     #---
  45.     self.note.split(/[\r\n]+/).each { |line|
  46.       case line
  47.       #---
  48.       when YEA::REGEXP::SKILL::MP_COST_SET
  49.         @mp_cost = $1.to_i
  50.       when YEA::REGEXP::SKILL::MP_COST_PER
  51.         @mp_cost_percent = $1.to_i * 0.01
  52.       when YEA::REGEXP::SKILL::TP_COST_SET
  53.         @tp_cost = $1.to_i
  54.       when YEA::REGEXP::SKILL::TP_COST_PER
  55.         @tp_cost_percent = $1.to_i * 0.01
  56.       when YEA::REGEXP::SKILL::HP_COST_SET
  57.         @hp_cost = $1.to_i
  58.       when YEA::REGEXP::SKILL::HP_COST_PER
  59.         @hp_cost_percent = $1.to_i * 0.01
  60.       when YEA::REGEXP::SKILL::GOLD_COST_SET
  61.         @gold_cost = $1.to_i
  62.       when YEA::REGEXP::SKILL::GOLD_COST_PER
  63.         @gold_cost_percent = $1.to_i * 0.01
  64.       #---
  65.       when YEA::REGEXP::SKILL::HP_COST_MIN
  66.         @hp_cost_min = $1.to_i
  67.       when YEA::REGEXP::SKILL::HP_COST_MAX
  68.         @hp_cost_max = $1.to_i
  69.       when YEA::REGEXP::SKILL::MP_COST_MIN
  70.         @mp_cost_min = $1.to_i
  71.       when YEA::REGEXP::SKILL::MP_COST_MAX
  72.         @mp_cost_max = $1.to_i
  73.       when YEA::REGEXP::SKILL::TP_COST_MIN
  74.         @tp_cost_min = $1.to_i
  75.       when YEA::REGEXP::SKILL::TP_COST_MAX
  76.         @tp_cost_max = $1.to_i
  77.       when YEA::REGEXP::SKILL::GOLD_COST_MIN
  78.         @gold_cost_min = $1.to_i
  79.       when YEA::REGEXP::SKILL::GOLD_COST_MAX
  80.         @gold_cost_max = $1.to_i
  81.       #---
  82.       when YEA::REGEXP::SKILL::CUSTOM_COST_TEXT
  83.         @custom_cost_text = $1.to_s
  84.       when /<(?:CUSTOM_COST_EVAL|custom cost eval):[ ](.*)>/i
  85.         @custom_cost_text_eval = $1.to_s
  86.       when YEA::REGEXP::SKILL::CUSTOM_COST_COLOUR
  87.         @custom_cost_colour = $1.to_i
  88.       when YEA::REGEXP::SKILL::CUSTOM_COST_SIZE
  89.         @custom_cost_size = $1.to_i
  90.       when YEA::REGEXP::SKILL::CUSTOM_COST_ICON
  91.         @custom_cost_icon = $1.to_i
  92.       when YEA::REGEXP::SKILL::CUSTOM_COST_REQUIREMENT_ON
  93.         @custom_cost_req_on = true
  94.         @use_custom_cost = true
  95.       when YEA::REGEXP::SKILL::CUSTOM_COST_REQUIREMENT_OFF
  96.         @custom_cost_req_on = false
  97.         @use_custom_cost = true
  98.       when YEA::REGEXP::SKILL::CUSTOM_COST_PERFORM_ON
  99.         @custom_cost_per_on = true
  100.         @use_custom_cost = true
  101.       when YEA::REGEXP::SKILL::CUSTOM_COST_PERFORM_OFF
  102.         @custom_cost_per_on = false
  103.         @use_custom_cost = true
  104.       else
  105.         @custom_cost_requirement += line.to_s if @custom_cost_req_on
  106.         @custom_cost_perform += line.to_s if @custom_cost_per_on
  107.       #---
  108.       end
  109.     } # self.note.split
  110.     #---
  111.   end
  112. end
  113.  
  114. class Window_SkillList < Window_Selectable
  115.   def draw_custom_skill_cost(rect, skill)
  116.     return unless skill.use_custom_cost
  117.     change_color(text_color(skill.custom_cost_colour), enable?(skill))
  118.     icon = skill.custom_cost_icon
  119.     if icon > 0
  120.       draw_icon(icon, rect.x + rect.width-24, rect.y, enable?(skill))
  121.       rect.width -= 24
  122.     end
  123.     contents.font.size = skill.custom_cost_size
  124.     text = eval(skill.custom_cost_text_eval).to_i.to_s + skill.custom_cost_text
  125.     draw_text(rect, text, 2)
  126.     cx = text_size(text).width + 4
  127.     rect.width -= cx
  128.     reset_font_settings
  129.   end
  130. end
Advertisement
Add Comment
Please, Sign In to add comment