Jump to content
TheCaliMack

Skill Cost Manager (Level-based cost)

Recommended Posts

I need help with Yanfly's Skill Cost Manager. Link is this: http://yanflychannel.wordpress.com/rmvxa/gameplay-scripts/skill-cost-manager/

 

The skill's cost is user-based: self.level * 3

 

Now, my problem is the custom cost tag; it uses string strictly.

 

I'm trying to make it so that it displays the value of (self.level * 3). Instead, it writes the algorithm itself. Can anyone give me a quick fix?

 

EDIT:

Below is the script given to me by estriole.

 

 

=begin
Patch by estriole
This helps you define a current actor and make a custom cost eval for
user-based costs. More or less it helps you use a custom formula to use for
displaying the skill cost. Only function is geared towards user-related stats.
==========================================================
Requires Yanfly's Skill Cost Manager above it to function
==========================================================
Use this notetag format in the skill

<custom_cost_eval: formula>
Replace formula with a formula
EXAMPLE!
<custom_cost_eval: cur_actor.level * 5>

In the skills window, it will display the new skill cost. e.g. 5 at Lv1, 10 at Lv2

=end

def cur_actor
SceneManager.scene.is_a?(Scene_Battle) ? BattleManager.actor : $game_party.menu_actor
end
 
class RPG::Skill < RPG::UsableItem
  attr_accessor :custom_cost_text_eval
  def load_notetags_scm
    @hp_cost = 0
    @gold_cost = 0
    @hp_cost_percent = 0.0
    @mp_cost_percent = 0.0
    @tp_cost_percent = 0.0
    @gold_cost_percent = 0.0
    
    @custom_cost_text = ""
    @custom_cost_colour = 0
    @custom_cost_size = 20
    @custom_cost_icon = 0
    @custom_cost_requirement = ""
    @custom_cost_perform = ""
    
    @use_custom_cost = false
    @custom_cost_req_on = false
    @custom_cost_per_on = false
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEA::REGEXP::SKILL::MP_COST_SET
        @mp_cost = $1.to_i
      when YEA::REGEXP::SKILL::MP_COST_PER
        @mp_cost_percent = $1.to_i * 0.01
      when YEA::REGEXP::SKILL::TP_COST_SET
        @tp_cost = $1.to_i
      when YEA::REGEXP::SKILL::TP_COST_PER
        @tp_cost_percent = $1.to_i * 0.01
      when YEA::REGEXP::SKILL::HP_COST_SET
        @hp_cost = $1.to_i
      when YEA::REGEXP::SKILL::HP_COST_PER
        @hp_cost_percent = $1.to_i * 0.01
      when YEA::REGEXP::SKILL::GOLD_COST_SET
        @gold_cost = $1.to_i
      when YEA::REGEXP::SKILL::GOLD_COST_PER
        @gold_cost_percent = $1.to_i * 0.01
      #---
      when YEA::REGEXP::SKILL::HP_COST_MIN
        @hp_cost_min = $1.to_i
      when YEA::REGEXP::SKILL::HP_COST_MAX
        @hp_cost_max = $1.to_i
      when YEA::REGEXP::SKILL::MP_COST_MIN
        @mp_cost_min = $1.to_i
      when YEA::REGEXP::SKILL::MP_COST_MAX
        @mp_cost_max = $1.to_i
      when YEA::REGEXP::SKILL::TP_COST_MIN
        @tp_cost_min = $1.to_i
      when YEA::REGEXP::SKILL::TP_COST_MAX
        @tp_cost_max = $1.to_i
      when YEA::REGEXP::SKILL::GOLD_COST_MIN
        @gold_cost_min = $1.to_i
      when YEA::REGEXP::SKILL::GOLD_COST_MAX
        @gold_cost_max = $1.to_i
      #---
      when YEA::REGEXP::SKILL::CUSTOM_COST_TEXT
        @custom_cost_text = $1.to_s
      when /<(?:CUSTOM_COST_EVAL|custom cost eval):[ ](.*)>/i
        @custom_cost_text_eval = $1.to_s
      when YEA::REGEXP::SKILL::CUSTOM_COST_COLOUR
        @custom_cost_colour = $1.to_i
      when YEA::REGEXP::SKILL::CUSTOM_COST_SIZE
        @custom_cost_size = $1.to_i
      when YEA::REGEXP::SKILL::CUSTOM_COST_ICON
        @custom_cost_icon = $1.to_i
      when YEA::REGEXP::SKILL::CUSTOM_COST_REQUIREMENT_ON
        @custom_cost_req_on = true
        @use_custom_cost = true
      when YEA::REGEXP::SKILL::CUSTOM_COST_REQUIREMENT_OFF
        @custom_cost_req_on = false
        @use_custom_cost = true
      when YEA::REGEXP::SKILL::CUSTOM_COST_PERFORM_ON
        @custom_cost_per_on = true
        @use_custom_cost = true
      when YEA::REGEXP::SKILL::CUSTOM_COST_PERFORM_OFF
        @custom_cost_per_on = false
        @use_custom_cost = true
      else
        @custom_cost_requirement += line.to_s if @custom_cost_req_on
        @custom_cost_perform += line.to_s if @custom_cost_per_on
      #---
      end
    } # self.note.split
    #---
  end 
end
 
class Window_SkillList < Window_Selectable
  def draw_custom_skill_cost(rect, skill)
    return unless skill.use_custom_cost
    change_color(text_color(skill.custom_cost_colour), enable?(skill))
    icon = skill.custom_cost_icon
    if icon > 0
      draw_icon(icon, rect.x + rect.width-24, rect.y, enable?(skill))
      rect.width -= 24
    end
    contents.font.size = skill.custom_cost_size
    text = eval(skill.custom_cost_text_eval).to_s + skill.custom_cost_text
    draw_text(rect, text, 2)
    cx = text_size(text).width + 4
    rect.width -= cx
    reset_font_settings
  end
end

 

 

Use <custom_cost_eval: cur_actor.level * 3> as an example. With yanfly Skill Cost Manager above this script, this will display the product of the formula (e.g. 9) and with custom text will show the inputted custom text afterwards. (e.g. 9SP).

 

Now you can base cost out of a character's level (like I did), or a character's stats (e.g. cur_actor.atk).

Edited by mackintosh

Share this post


Link to post
Share on other sites

The only simple workaround I can see here is if the skill is only going to be used by one actor, you can use

$game_actors[id].level * 3

where id is the id for the actor.

 

Might be another solution that would allow it to work for the current actor but I'm not seeing it. :huh:

Share this post


Link to post
Share on other sites

@mackintosh: can you clarify what you means.

do you mean you want the skill cost to 'show' string "self.level * 3" ? in skill windows?

since you can already do that using

<custom_cost: self.level x 3>

 

or do you want it to show the value of self.level * 3 in skill window?

ex: your level 3 then show 9 if yes try this...

 

find this line:

 

      when YEA::REGEXP::SKILL::CUSTOM_COST_TEXT
        @custom_cost_text = $1.to_s

change it to

 

      when YEA::REGEXP::SKILL::CUSTOM_COST_TEXT
        @custom_cost_text = $1.to_s
      when /<(?:CUSTOM_COST_EVAL|custom cost eval):[ ](.*)>/i
        @custom_cost_text = "" if !@custom_cost_text
        @custom_cost_text += eval($1).to_s

then you could use <custom_cost_eval: self.level * 3>

 

you could also use both of them. custom cost eval will be added AFTER normal custom_cost

ex:

<custom_cost: HP>

<custom_cost_eval: self.level * 3>

 

it will show HP9 if your level is 3

Share this post


Link to post
Share on other sites

 

@mackintosh: can you clarify what you means.

do you mean you want the skill cost to 'show' string "self.level * 3" ? in skill windows?

since you can already do that using

<custom_cost: self.level x 3>

 

or do you want it to show the value of self.level * 3 in skill window?

ex: your level 3 then show 9 if yes try this...

 

find this line:

      when YEA::REGEXP::SKILL::CUSTOM_COST_TEXT
        @custom_cost_text = $1.to_s
change it to

      when YEA::REGEXP::SKILL::CUSTOM_COST_TEXT
        @custom_cost_text = $1.to_s
      when /<(?:CUSTOM_COST_EVAL|custom cost eval):[ ](.*)>/i
        @custom_cost_text = "" if !@custom_cost_text
        @custom_cost_text += eval($1).to_s
then you could use <custom_cost_eval: self.level * 3>

 

you could also use both of them. custom cost eval will be added AFTER normal custom_cost

ex:

<custom_cost: HP>

<custom_cost_eval: self.level * 3>

 

it will show HP9 if your level is 3

 

I'm happy you got what I meant. Yes, I want it to show the value of [self.level * 3]

 

Thanks for the tip, but sadly I get the error:

 

Line 520: No Method Error Occured. undefined method 'level' for #<RPG::Skill:0x5ab1b5c>

 

Any way to fix it? [Hoping for an RSVP.] I'm not good at scripting and I have no idea how to resolve this.

Edited by mackintosh

Share this post


Link to post
Share on other sites

ah yes... you cannot use self.level.

 

put this script BELOW yanfly script

def cur_actor
SceneManager.scene.is_a?(Scene_Battle) ? BattleManager.actor : $game_party.menu_actor
end
 
class RPG::Skill < RPG::UsableItem
  attr_accessor :custom_cost_text_eval
  def load_notetags_scm
    @hp_cost = 0
    @gold_cost = 0
    @hp_cost_percent = 0.0
    @mp_cost_percent = 0.0
    @tp_cost_percent = 0.0
    @gold_cost_percent = 0.0
    
    @custom_cost_text = ""
    @custom_cost_colour = 0
    @custom_cost_size = 20
    @custom_cost_icon = 0
    @custom_cost_requirement = ""
    @custom_cost_perform = ""
    
    @use_custom_cost = false
    @custom_cost_req_on = false
    @custom_cost_per_on = false
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEA::REGEXP::SKILL::MP_COST_SET
        @mp_cost = $1.to_i
      when YEA::REGEXP::SKILL::MP_COST_PER
        @mp_cost_percent = $1.to_i * 0.01
      when YEA::REGEXP::SKILL::TP_COST_SET
        @tp_cost = $1.to_i
      when YEA::REGEXP::SKILL::TP_COST_PER
        @tp_cost_percent = $1.to_i * 0.01
      when YEA::REGEXP::SKILL::HP_COST_SET
        @hp_cost = $1.to_i
      when YEA::REGEXP::SKILL::HP_COST_PER
        @hp_cost_percent = $1.to_i * 0.01
      when YEA::REGEXP::SKILL::GOLD_COST_SET
        @gold_cost = $1.to_i
      when YEA::REGEXP::SKILL::GOLD_COST_PER
        @gold_cost_percent = $1.to_i * 0.01
      #---
      when YEA::REGEXP::SKILL::HP_COST_MIN
        @hp_cost_min = $1.to_i
      when YEA::REGEXP::SKILL::HP_COST_MAX
        @hp_cost_max = $1.to_i
      when YEA::REGEXP::SKILL::MP_COST_MIN
        @mp_cost_min = $1.to_i
      when YEA::REGEXP::SKILL::MP_COST_MAX
        @mp_cost_max = $1.to_i
      when YEA::REGEXP::SKILL::TP_COST_MIN
        @tp_cost_min = $1.to_i
      when YEA::REGEXP::SKILL::TP_COST_MAX
        @tp_cost_max = $1.to_i
      when YEA::REGEXP::SKILL::GOLD_COST_MIN
        @gold_cost_min = $1.to_i
      when YEA::REGEXP::SKILL::GOLD_COST_MAX
        @gold_cost_max = $1.to_i
      #---
      when YEA::REGEXP::SKILL::CUSTOM_COST_TEXT
        @custom_cost_text = $1.to_s
      when /<(?:CUSTOM_COST_EVAL|custom cost eval):[ ](.*)>/i
        @custom_cost_text_eval = $1.to_s
      when YEA::REGEXP::SKILL::CUSTOM_COST_COLOUR
        @custom_cost_colour = $1.to_i
      when YEA::REGEXP::SKILL::CUSTOM_COST_SIZE
        @custom_cost_size = $1.to_i
      when YEA::REGEXP::SKILL::CUSTOM_COST_ICON
        @custom_cost_icon = $1.to_i
      when YEA::REGEXP::SKILL::CUSTOM_COST_REQUIREMENT_ON
        @custom_cost_req_on = true
        @use_custom_cost = true
      when YEA::REGEXP::SKILL::CUSTOM_COST_REQUIREMENT_OFF
        @custom_cost_req_on = false
        @use_custom_cost = true
      when YEA::REGEXP::SKILL::CUSTOM_COST_PERFORM_ON
        @custom_cost_per_on = true
        @use_custom_cost = true
      when YEA::REGEXP::SKILL::CUSTOM_COST_PERFORM_OFF
        @custom_cost_per_on = false
        @use_custom_cost = true
      else
        @custom_cost_requirement += line.to_s if @custom_cost_req_on
        @custom_cost_perform += line.to_s if @custom_cost_per_on
      #---
      end
    } # self.note.split
    #---
  end 
end
 
class Window_SkillList < Window_Selectable
  def draw_custom_skill_cost(rect, skill)
    return unless skill.use_custom_cost
    change_color(text_color(skill.custom_cost_colour), enable?(skill))
    icon = skill.custom_cost_icon
    if icon > 0
      draw_icon(icon, rect.x + rect.width-24, rect.y, enable?(skill))
      rect.width -= 24
    end
    contents.font.size = skill.custom_cost_size
    text = skill.custom_cost_text + eval(skill.custom_cost_text_eval).to_s
    draw_text(rect, text, 2)
    cx = text_size(text).width + 4
    rect.width -= cx
    reset_font_settings
  end
end
 

then use:

<custom_cost_eval: cur_actor.level * 3>

 

EDIT: I write above at 2 am. and didn't test it. tell me if there's something wrong >.<.

Edited by estriole

Share this post


Link to post
Share on other sites

ah yes... you cannot use self.level.

 

put this script BELOW yanfly script

 

 

def cur_actor
SceneManager.scene.is_a?(Scene_Battle) ? BattleManager.actor : $game_party.menu_actor
end
 
class RPG::Skill < RPG::UsableItem
  attr_accessor :custom_cost_text_eval
  def load_notetags_scm
    @hp_cost = 0
    @gold_cost = 0
    @hp_cost_percent = 0.0
    @mp_cost_percent = 0.0
    @tp_cost_percent = 0.0
    @gold_cost_percent = 0.0
    
    @custom_cost_text = ""
    @custom_cost_colour = 0
    @custom_cost_size = 20
    @custom_cost_icon = 0
    @custom_cost_requirement = ""
    @custom_cost_perform = ""
    
    @use_custom_cost = false
    @custom_cost_req_on = false
    @custom_cost_per_on = false
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEA::REGEXP::SKILL::MP_COST_SET
        @mp_cost = $1.to_i
      when YEA::REGEXP::SKILL::MP_COST_PER
        @mp_cost_percent = $1.to_i * 0.01
      when YEA::REGEXP::SKILL::TP_COST_SET
        @tp_cost = $1.to_i
      when YEA::REGEXP::SKILL::TP_COST_PER
        @tp_cost_percent = $1.to_i * 0.01
      when YEA::REGEXP::SKILL::HP_COST_SET
        @hp_cost = $1.to_i
      when YEA::REGEXP::SKILL::HP_COST_PER
        @hp_cost_percent = $1.to_i * 0.01
      when YEA::REGEXP::SKILL::GOLD_COST_SET
        @gold_cost = $1.to_i
      when YEA::REGEXP::SKILL::GOLD_COST_PER
        @gold_cost_percent = $1.to_i * 0.01
      #---
      when YEA::REGEXP::SKILL::HP_COST_MIN
        @hp_cost_min = $1.to_i
      when YEA::REGEXP::SKILL::HP_COST_MAX
        @hp_cost_max = $1.to_i
      when YEA::REGEXP::SKILL::MP_COST_MIN
        @mp_cost_min = $1.to_i
      when YEA::REGEXP::SKILL::MP_COST_MAX
        @mp_cost_max = $1.to_i
      when YEA::REGEXP::SKILL::TP_COST_MIN
        @tp_cost_min = $1.to_i
      when YEA::REGEXP::SKILL::TP_COST_MAX
        @tp_cost_max = $1.to_i
      when YEA::REGEXP::SKILL::GOLD_COST_MIN
        @gold_cost_min = $1.to_i
      when YEA::REGEXP::SKILL::GOLD_COST_MAX
        @gold_cost_max = $1.to_i
      #---
      when YEA::REGEXP::SKILL::CUSTOM_COST_TEXT
        @custom_cost_text = $1.to_s
      when /<(?:CUSTOM_COST_EVAL|custom cost eval):[ ](.*)>/i
        @custom_cost_text_eval = $1.to_s
      when YEA::REGEXP::SKILL::CUSTOM_COST_COLOUR
        @custom_cost_colour = $1.to_i
      when YEA::REGEXP::SKILL::CUSTOM_COST_SIZE
        @custom_cost_size = $1.to_i
      when YEA::REGEXP::SKILL::CUSTOM_COST_ICON
        @custom_cost_icon = $1.to_i
      when YEA::REGEXP::SKILL::CUSTOM_COST_REQUIREMENT_ON
        @custom_cost_req_on = true
        @use_custom_cost = true
      when YEA::REGEXP::SKILL::CUSTOM_COST_REQUIREMENT_OFF
        @custom_cost_req_on = false
        @use_custom_cost = true
      when YEA::REGEXP::SKILL::CUSTOM_COST_PERFORM_ON
        @custom_cost_per_on = true
        @use_custom_cost = true
      when YEA::REGEXP::SKILL::CUSTOM_COST_PERFORM_OFF
        @custom_cost_per_on = false
        @use_custom_cost = true
      else
        @custom_cost_requirement += line.to_s if @custom_cost_req_on
        @custom_cost_perform += line.to_s if @custom_cost_per_on
      #---
      end
    } # self.note.split
    #---
  end 
end
 
class Window_SkillList < Window_Selectable
  def draw_custom_skill_cost(rect, skill)
    return unless skill.use_custom_cost
    change_color(text_color(skill.custom_cost_colour), enable?(skill))
    icon = skill.custom_cost_icon
    if icon > 0
      draw_icon(icon, rect.x + rect.width-24, rect.y, enable?(skill))
      rect.width -= 24
    end
    contents.font.size = skill.custom_cost_size
    text = skill.custom_cost_text + eval(skill.custom_cost_text_eval).to_s
    draw_text(rect, text, 2)
    cx = text_size(text).width + 4
    rect.width -= cx
    reset_font_settings
  end
end
 

 

then use:

<custom_cost_eval: cur_actor.level * 3>

 

EDIT: I write above at 2 am. and didn't test it. tell me if there's something wrong >.<.

 

DUDE/CHICK, I LOVE YOU!!!

 

It works like a charm. Now my problem is setting up the custom cost SP to go after the cost, but I can probably figure that on my own.

 

Or make an excuse and just not write it like "SP36" (what comes out) or "36SP" and just stick with a colored "36".

I mean, it makes it look cleaner and stuff and the colors would be enough, making only colorblinded gamers confused.

 

AGAIN, THANK YOU!

Edited by mackintosh

Share this post


Link to post
Share on other sites

It's okay to propagate the script you gave me as long as I credit you, right estriole?

And I should probably share this link to Yanfly.

 

Basically, this topic has been solved. So... yeah! I edited the first post to include the script, too, for easy findings.

Share this post


Link to post
Share on other sites

Topic closed because problem is solved.

 

If one of you would like to post the script in the completed scripts section that would be welcome.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted