Yanfly Skill Cost: More than 1 custom cost possible?

A particular gun in my game is supposed to use 2 items per shot, a lead ball and black powder. I have no idea how to get a second
cost icon to show up, or how to make the skill consume 1 of each item.

I've moved this thread to RGSSx Script Support. Thank you.



I thought I saw an example of this on the website years ago, maybe it's still there on the official site where you get the script?
Moved to: RGSSx Script Support

I thought I saw an example of this on the website years ago, maybe it's still there on the official site where you get the script?
I looked, and there were no examples. Several people asked on the original site and got no answer.
there were no examples
Yanfly Skill Cost Manager

Ruby:
<custom cost requirement>
$game_party.has_item?($data_items[black power])
$game_party.has_item?($data_items[lead ball])
</custom cost requirement>

$game_party.lose_item(@ItEm, number)
Ruby:
<custom cost perform>
$game_party.lose_item(black power, 1)
$game_party.lose_item(lead ball, 1)
</custom cost perform>

Should work. Change the items to the item id numbers #
e.g.
$game_party.has_item?($data_items[25])
$game_party.lose_item(25, 1)

And show the icons should be
<custom cost icon: black power> # again icon numbers not the words
<custom cost icon: lead ball>
So if I try to do a battle test the game crashes. Here's what my item notetag looks like after modifying it based on your post.

<custom cost: 1x>
<custom cost size: 16>
<custom cost icon: 2895>
<custom cost icon: 908>

<custom cost requirement>
$game_party.has_item?($data_items[154])
$game_party.has_item?($data_items[155])
</custom cost requirement>
<custom cost perform>
$game_party.lose_item(154, 1)
$game_party.lose_item(155l, 1)
</custom cost perform>
@cthulhusquid Minor glitch in your code and how I thought the script works.
<custom cost: 1x>
<custom cost size: 16>
<custom cost icon: 2895>
<custom cost icon: 908>
<custom cost requirement>
$game_party.has_item?($data_items[154]); # <- added ;
$game_party.has_item?($data_items[155])
</custom cost requirement>
<custom cost perform>
$game_party.lose_item(154, 1); # <- added ;
$game_party.lose_item(155, 1) # <- removed extra character
</custom cost perform>

But now I'm testing it and it doesn't seem to take both items into account. wiIl Try a few things and see what works best.
At the moment I got the skill to work but it does not remove any items.
$game_party.has_item?($data_items[154]); # <- added ;
This will treat it as a different line, instead of adding ;, add && instead
This will treat it as a different line, instead of adding ;, add && instead
Yes got that part just a minute ago before I checked back here. But it still does not process the cost. No items are lost.
It also only lets you use one icon.
Yes got that part just a minute ago before I checked back here. But it still does not process the cost. No items are lost.
It also only lets you use one icon.
Because the method lose_item needs an actual object, not id. That way, you can put weapon/armor object when you want to. So $game_party.lose_item($data_items[154], 1 )

Idk about the icon part. I don't have the script in my end to check.
I'm almost getting fast enough. I just figured that out as well.
Thanks.
<custom cost: 1x>
<custom cost size: 16>
<custom cost icon: 2895>
<custom cost requirement>
$game_party.has_item?($data_items[154]) &&
$game_party.has_item?($data_items[155])
</custom cost requirement>
<custom cost perform>
$game_party.lose_item($data_items[154], 1) &&
$game_party.lose_item($data_items[155], 1)
</custom cost perform>


the icon part
Ruby:
  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
    draw_text(rect, text, 2)
    cx = text_size(text).width + 4
    rect.width -= cx
    reset_font_settings
  end
Ruby:
    CUSTOM_COST_ICON = /<(?:CUSTOM_COST_ICON|custom cost icon):[ ](\d+)>/i
      when YEA::REGEXP::SKILL::CUSTOM_COST_ICON
        @custom_cost_icon = $1.to_i
There are two options I could think of
1. Replace @custom_cost_icon with array. And each time it detects the notetag, add the icon index in that array. So, instead of using =, use << instead. Of course, that would change the method to draw the custom skill cost method.
2. Hardcode the draw_custom_skill_cost for that particular skill id. So when a certain skill id is detected, add conditional if to draw two icons.
Replace @custom_cost_icon with array
Got it done. Took a bit of testing and finding an expression that would work. Haven't learned that portion yet. (doing a ruby course on udemy)

<custom cost icon: 2895>
<custom cost icon: 908>
change those into
<custom cost icon: 2895, 908>

This works. Add as a new script under skill cost manager
Ruby:
module YEA
  module REGEXP
  module SKILL
    CUSTOM_COST_ICON = /<(?:CUSTOM_COST_ICON|custom cost icon):[ ](\d+(?:[ ]*,[ ]*\d+)*)>/i
  end # SKILL
  end # REGEXP
end # YEA

class RPG::Skill < RPG::UsableItem
  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 = "0"
    @custom_cost_colour = 0
    @custom_cost_size = 20
    @custom_cost_icon = []
    @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 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
        $1.scan(/\d+/).each { |num|
        @custom_cost_icon.push(num.to_i) if num.to_i > 0 }
      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 # RPG::Skill

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[0]
    icon2 = skill.custom_cost_icon[1] if !skill.custom_cost_icon[1].nil?
    if icon > 0
      draw_icon(icon, rect.x + rect.width-24, rect.y, enable?(skill))
      rect.width -= 24
      draw_icon(icon2, rect.x + rect.width-24, rect.y, enable?(skill)) if !skill.custom_cost_icon[1].nil?
      rect.width -= 24 if !skill.custom_cost_icon[1].nil?
    end
    contents.font.size = skill.custom_cost_size
    text = skill.custom_cost_text
    draw_text(rect, text, 2)
    cx = text_size(text).width + 4
    rect.width -= cx
    reset_font_settings
  end
end
So when I add that script in, what should my item notetags look like?
what should my item notetags look like?
change those into
<custom cost icon: 2895, 908>
It works, thank you so much!

Also, if others want to use this as a future reference, here is what the item notetags will look like:
Spoiler
<custom cost: 1x>
<custom cost size: 16>
<custom cost icon: icon 1, icon 2>
<custom cost requirement>
$game_party.has_item?($data_items[Item ID 1]) &&
$game_party.has_item?($data_items[Item ID 2])
</custom cost requirement>
<custom cost perform>
$game_party.lose_item($data_items[Item ID 1], 1) &&
$game_party.lose_item($data_items[Item ID 2], 1)
</custom cost perform>

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-skill-cost-more-than-1-custom-cost-possible.121661/