Skill Cost Manager

Last Updated: 2012.08.06
Download Link
Github Link

This script adds more functionality towards skill costs. Skills can now cost HP, more MP, more TP, gold, and even have custom costs. The way the skill costs are drawn in the display windows are changed to deliver more effective and reliable information to the player. And if four skill costs aren’t enough to satisfy you, you can even make your own custom skill costs.

The MP Cost limit is raised using notetags and skills can now cost a percentage of an actor’s maximum MP value, too.

<mp cost: x>

Sets the skill’s MP cost to x. Allows MP cost to exceed 9999, which is RPG Maker VX Ace’s database editor’s maximum limit.

<mp cost: x%>

Sets the MP cost to a percentage of the actor’s MaxMP. If a normal MP cost is present on the skill, too, then this value is added to the MP cost.

The TP Cost limit is raised for those who use a higher Max TP value than 100. There also exists notetags for TP percentage costs.

<tp cost: x>

Sets the skill’s TP cost to x. Allows TP cost to exceed 100, which is RPG Maker VX Ace’s database editor’s maximum limit.

<tp cost: x%>

Sets the TP cost to a percentage of the actor’s MaxTP. If a normal TP cost is present on the skill, too, then this value is added to the TP cost.

Skills can now cost HP. The actor must have more than the HP cost to use the skill. HP costs can also cost a percentage of the actor’s MaxHP.

<hp cost: x>

Sets the skill’s HP cost to x. This function did not exist by default in RPG Maker VX Ace.

<hp cost: x%>

Sets the HP cost to a percentage of the actor’s MaxHP. If a normal HP cost is present on the skill, too, then this value is added to the HP cost.

Skills can also require gold. Have it cost a set amount of gold or a percentage of the party’s total gold.

<gold cost: x>

Sets the skill’s gold cost to x. Enemies with skills that cost gold do not use gold. If the player does not have enough gold, the skill can’t be used.

<gold cost: x%>

Sets the skill’s gold cost equal to a percentage of the party’s total gold. If both a regular gold cost and a percentile gold cost is used, the total of both values will be the skill’s gold cost.

The skill list window will now show all of the skill’s cost requirements when before it only showed only TP or MP with priority for TP than MP. This script also enables the option to use icons and to change suffixes for skill costs. Skill costs reposition themselves relative to each other. However, if you have too many skill costs, the costs WILL overlap the skill’s name. I am not responsible if you decide to make your skill list window look like a mess of a Christmas Tree.

Lunatics can create their own custom skill costs using the custom cost notetags. Change the way skills cost to your liking.

<custom cost: string>

If you decide to have a custom cost for your game, insert this notetag to change what displays in the skill menu visually.

<custom cost colour: x>

This is the “Window” skin text colour used for the custom cost. By default, it is text colour 0, which is the white colour.

<custom cost size: x>

This is the text font size used for the custom cost in the display windows. By default, it is font size 20.

<custom cost icon: x>

If you wish to use an icon for your custom cost, replace x with the icon ID you wish to show in display windows. By default, it is 0 (and not shown).

<custom cost requirement>
 string
 string
</custom cost requirement>

Sets the custom cost requirement of the skill with an eval function using the strings in between. The strings are a part of one line even if in the notebox they are on separate lines.

<custom cost perform>
 string
 string
</custom cost perform>

Sets how the custom cost payment is done with an eval function using the strings in between. The strings are a part of one line even if in the notebox they are on separate lines.

There are now “traits” that reduce TP costs, HP costs, and Gold costs. These can go on actors, classes, weapons, armours, enemies, and states. There isn’t one for MP costs because there already exists a “trait” for MP costs in those respective objects. However, I felt it was a little unfair that only MP would get the better treatment from traits.

<hp cost rate: x%>

Allows the actor to drop the HP cost of skills to x%.

<tp cost rate: x%>

Allows the actor to drop the TP cost of skills to x%.

<gold cost rate: x%>

Allows the actor to drop the Gold cost of skills to x%.

You can now set a maximum and/or minimum cap for how much a skill can cost. This is important for those percentile cost skills where it won’t overcharge a player but won’t undercharge them either.

<hp cost max: x>
<hp cost min: x>

Sets the maximum and minimum range of the HP Cost of the skill. If you do not use this tag, there will be no maximum and/or minimum range.

<mp cost max: x>
<mp cost min: x>

Sets the maximum and minimum range of the MP Cost of the skill. If you do not use this tag, there will be no maximum and/or minimum range.

<tp cost max: x>
<tp cost min: x>

Sets the maximum and minimum range of the TP Cost of the skill. If you do not use this tag, there will be no maximum and/or minimum range.

<gold cost max: x>
<gold cost min: x>

Sets the maximum and minimum range of the Gold Cost of the skill. If you do not use this tag, there will be no maximum and/or minimum range.

And that’s all, folks!

95 comments on “Skill Cost Manager

    • Greetings Ms. or Mr. Yanfly.

      I’ve modified your script very slightly to include Current HP, MP and TP Costs and I wondered if you wanted the modified version?
      I know that your script has not been updated in almost 3 years, but you might still be interested.

      • Sure, I’ll just cleanup and add the descriptions about the tags, I’ll upload it, and reply here.

      • I tried your revised script, but I get an error when I try to use the skill:
        Script ‘Scene_Battle’ line 584: NoMethodError occurred.
        undefined method ‘make_targets’ for nil:NilClass

        I’ve even tried it in a clean game with no other scripts and I still get that error. Help is appreciated.

  1. If I set the HP Cost of a skill to 100%, would the actor using it die after performing the skill, or will it just not work?
    I was thinking along the lines of the Kamikaze skill, where the actor dies after unleashing a powerful attack.

  2. Love this one, but i don’t understand how to make them cost items as the first screenshot, I want archer skills to cost arrows and some ninja skill to cost kunai’s

    • http://www.rpgmakervxace.net/index.php?/topic/461-help-with-creating-an-archer-mage-class/

      See the last post in the link above. What I did is utilised Ace Equip Engine to create my own equipment slot that only accepts the arrows. Here, I also made the arrows ‘armour’, not items.

      To fix the items window from showing the arrows as armour, I have started to port KGC’s CategorizeItem script to VXAce. With that, I can create my own categories and manually force each item, weapon and armour into a category of choice.
      While I think I’ve done much conversion, I need help with some issues.
      Maybe Yanfly can check the script?? =P

    • There is no edit button…..
      I assumed that you would be equipping arrows. If not, then you can surely have the skill cost items. See the 7th screenshot. Use the “custom cost requirement” and the “custom perform” tags (in screenshot).

      • Yeah, i think that wordpress should have that option, I hate when My user name is changed to my real name -.- that just reveal my real identity as person and writer.

        I wasn’t thiking on equip them just have them on inventory but i think that your idea is better so I’ll try the solution of that threat when I get to configure that script (I just started to port my project to Ace), thank you.

  3. I dont know why, but when i set the cost of a skill to be “gold”, i can’t see its cost in the skill manager nor in the battle skill window, and the skill can be used even if you don’t have any gold at all.

  4. Just something I want to run by you. I want to make a Skill that sends a player character into an empowered state. There are no buffs in my game, but the characters do use various transformations. The transformations alter the character’s original stat(s) by percentage (Ex: Attack 105%) and their sprite changes to a different one (usually a custom one I’ve created, sometimes just their color). While one of the Transformation States (only one at a time) is active, the character loses a percentage of their MP each turn (different states have different costs). When their MP reaches 0, the TS is released and their stats return to normal.

    That’s the basis of it. I just want to know if any combination of your scripts would work in helping me to achieve this.

  5. It’s a little complex, but this can be done through eventing (I am an event nub, so there might be better ways to do it).

    Note: Troop Tab. Copy-paste after done.

    Just do a state for each transformation, and make a check using variables and conditional branches.

    [Troop]

    Var[82] = [MP Check]; set variable equal to [Sairen's MP]
    —– Input all variables for all actors —–

    Open Cond 1:
    {
    EX: [Sairen] has state [Grathnode Inferia] on.
    -> possibly a script call changing battler sprite? Well, Yanfly’s visual battlers won’t be out for quite some time, so you’ll need to script something that allows you to use sprites (like Ramiro’s), and also allows script calls to change the sprite in battle.
    v—- Put another cond. branch inside it.
    -> if variable 82 [MP Check] = 0
    ——> then remove [Grathnode Inferia]
    }
    Close Cond 1

    …And do that for each transformation.

    It seems tedious, depending on the amount of transformation. I guess it can be used alongside Kread-Ex’s Morph, as to give skills for reach transformation. Haven’t tried it out yet.

  6. I apologize for replying much later than the last, but I find I’m having a problem with this. Much like Seiryuki, I am using this script to create ammunition. Everything works fine until I have one arrow remaining.

    This is what I have in my note tag for the arrow item (weapon)
    $game_party.item_number($data_weapons[3])>=1

    $game_party.lose_item(($data_weapons[3]), 1)

    When I have 1 arrow remaining, the skill becomes disabled until I have more than 1 arrow in the equip slot. I have tried this with and without Asagi’s Gun License script by Kread-EX. The problem I’m finding is the equipped item isn’t removed. Is there a way around this?

    • Thanks for trying the method! I didn’t get around to trying it out myself and I’m sorry for that.
      Hm, so the item doesn’t reach zero? I haven’t started my game so I haven’t got a chance to test things.
      I figure it might be possible to solve the issue through the $game_party.lose_item method. The method might be only treating with “items” and not catering for the armours and weapons we are using as the cost.
      Unfortunately, I can’t use RMVXAce at work and my monitor at home is currently dead.

      Maybe someone, or YF if he has time, can check that lose_item method, if that is the problem.

      • It’s a great system and a lot can come from it. I’d rather get this to work some how to make my game more strategic than have infinite arrows.

        I’m working on a common event method that adds the arrows to the armor inventory when a corresponding arrow exists in the player inventory and de-equips the arrow once the arrows are depleted.

  7. Well… that worked about as far as nothing. The script/event hybrid system only works best with one ammo type, and even still there are bugs. oh well… maybe someone will make a working ammo script.

  8. Any chance you could add a tag that makes it so a skill costs all of the user’s CURRENT MP, and not their max MP? KGC_MPCostalter for VX had it, and I figure it would be a breeze for someone as great as you to do it. I would do it myself, but I have no scripting knowledge.

    • Actually scratch that, I figured it out. However, I’d like to change that request to a tag that makes it so the skill does damage based on how much MP was spent, seeing as setting the skill to “b.mp” will result in 0 damage (damage is calculated after MP is spent; because the skill costs all MP, the user’s current MP during damage calculation is 0). Again, this should be a cinch for someone like yourself.

      • Could you tell us how you figured it out? I’m still working on that one little bit, trying to get the actual cost to show up in the Skills window instead of just being lame and putting “100% MP” or something

      • To cyborg mermaid: Copy this and paste it in the skill’s notetag, using v.1.03 or newer of this script:

        self.mp = 0

        self.mp > 0

  9. Hiya
    First up – Fantastic scripts, Yanfly. They improve RPGmaker immensely!

    Having slight problem with this script, though. When in use, I have an actors with the feature:
    Sp-Parameter [TCR] * 200%
    (This made him gain TP faster than normal).

    With this script installed, though – it appears that the Sp-Parameter [TCR] no longer works.

    Was wondering if you had any suggestions?

    Thanks again

  10. I was wondering how one would make the skill cost items…
    For example, Fire I would require the item ‘Level I Components’ and without it, you couldnt cast. Is there a way?

  11. I can’t seem to get the hp costs to work properly, I’ve set up them up like in the screen/script but the skill works without costing hp..am I doing something wrong? :o

  12. I put the script into my game, and in the notebox of my skill I put “”
    but in battle my tp doesn’t increase past 100, why?

  13. irk, wordpress ignored everything between “”. Good to know. The first sentence should have been: “If I put ‘tp cost: 10%’ in a skill the skill always costs 10tp.”

    • I’m pretty sure that’s because the max TP set by default is 100 and the TP % cost goes by the max value of whatever it’s using. 10% of 100 is 10.

      • Yes, that’s exactly it. Percentage costs are taken from the maximum value, not the current. If you want to use current TP, you have to do it lunatic-style:

        (custom cost: 10%TP)
        (custom cost colour: X)
        (custom cost requirement)
        self.tp>0
        (/custom cost requirement)
        (custom cost perform)
        self.tp -= self.tp/10
        (/custom cost perform)

        Replace X with your TP colour, replace parenthesis with triangle brackets and it should work.

      • Though I’m unsure whether the cost is subtracted before or after damage calculation. If it’s before and you are using a.tp in the damage formula, you’ll have to do some tricks if you want the original value (or just multiply by 10/9).

  14. I’m wondering if there could be a function to do something like this:

    Skill: Fire
    SP Required to Cast: 50
    BUT, when used, change user’s SP to 0. (Uses all SP)

  15. Hey there, love the script, was just wondering:
    Can you set it up so you can have multiple ammo types (e.g. different types of arrows/bullets) and a skill can use any of them. So something like:

    $game_party.item_number($data_items[1]) >= 1 OR $game_party.item_number($data_items[2]) >= 1 OR
    $game_party.item_number($data_items[3]) >= 1

    Then in the perform part have a Conditional Branch to make it use the worst ammo first?

    Conditional Branch: [Arrow] in Inventory
    $game_party.lose_item($data_items[1], 1)
    Else
    Conditional Branch: [Bronze Arrow] in Inventory
    $game_party.lose_item($data_items[2], 1)
    Else
    Conditional Branch: [Iron Arrow] in Inventory
    $game_party.lose_item($data_items[3], 1)
    Else

    Branch End
    Branch End
    Branch End

  16. Can someone tell me how to display a variable as a custom cost, if it’s possible? I want to display the current amount of an item the party has as the cost.

    • I too am wondering this situation. On the custom cost section, I’m attempting to display the characters level plus a specific amount as the mana cost.

      First I attempted:
      <mp cost: self.level+5.
      This does not work.

      Second I created the custom spell all together, and used:

      But this LITERALLY displays #{self.level+5} MP as the mana cost.

      Is there a way to display a dynamic variable as the cost?

  17. Hello, I love you scripts, all of them. Most of the time I find my own way of working out any problem I have with something involving your scripts but this time I can’t seem to find the problem. I’m using your cost manager to make potions cost herbs but whenever I use the skill to make it with the cost

    $game_party.item_number($data_items[17]) >=2

    $game_party.lose_item(($data_item[17]), 2)

    it gives me a script error.
    If anyone could help me out a bit, maybe i’m just being stupid about something or not seeing something that is right in front of me. :P
    Thank you in advance.

    • Not sure why but it didn’t get the whole cost for the skill.
      .
      .
      .
      .

      .
      .$game_party.item_number($data_items[17]) >=2
      .

      .
      .$game_party.lose_item(($data_item[17]), 2)
      .

      • (custom cost: 3x)
        (custom cost colour: 0)
        (custom cost size: 16)
        (custom cost icon: 1707)

        (custom cost requirement)
        $game_party.item_number($data_items[17]) >=2
        (/custom cost requirement)

        (custom cost perform)
        $game_party.lose_item(($data_item[17]), 2)
        (/custom cost perform)

        Hopefully it works this time -_-

  18. awsome scrpit, but i am coming up with an error when trying to set up a skill that uses an item to use it. here is the notetag i used in the skill. like up above

    $game_party.item_number($data_items[2]) >=1

    $game_party.lose_item(($data_item[2]), 1)

    when i go to play test and made sure i hade the item needed to use the skill. with in battle i go to use the skill and i get this error message

    Script ‘skill cost manger’ line 596: syntaxerror occurred.
    untermined regexp meets end of file.

    has anyone else had this issue, and knows how to fix it? Thank you for your help.

      • Have the same problem …
        Notetag:

        $game_party.item_number($data_items[1])
        >=3

        $game_party.lose_item(($data_items[1]),3)

        Any solutions?

    • I’m currently trying to have the player only be able to use skills while under the effects of a state, otherwise they’re greyed out. I tried doing this with my novice scripting skills and I keep getting a nil class undefined method error.

      This is me attempting to code.

      $game_battler.state_id($data_states[57])

      The script error given states that ‘state_id’ is an undefined method, should i be using something else or am I going about this in the completely wrong way?

  19. I’m also having an error i cant seem to fix, try to use it same as above, but my error reads:

    line 596: NoMethodError occurred.
    undefined method ‘[]‘ for nil:NilClass

    the line in question is this :

    #————————————————————————–
    # new method: pay_custom_cost
    #————————————————————————–
    def pay_custom_cost(skill)
    return unless skill.use_custom_cost
    596 eval(skill.custom_cost_perform)
    end

    • I’m trying to make a skill that can only be used if a item is in the inventory (Arrow / Bullet) I have the item but it doesn’t work. In the skill note tag I put:

      $game_party.item_number($data_items[66])
      >= 1

      $game_party.lose_item(($data_item[66]), 1)

      Am I doing something wrong?

    • You did use the (custom cost requirement) and ” perform), did you?

      Just putting those two lines, isn’t going to do anything, because the script doesn’t know what exactly you mean by the two lines, and you have to make clear that the first is the requirement, and the second is the perform.

  20. Nice script too ^^ but i get a error xD hey :D nice script :D but i get a error if i equip a weapon ^^
    Script Skill cost line 669: TypeError occurred
    nil cant be coerced into float
    Thats the error… where is the problem? xD
    same error with Cooldown script… what shall i do? ^^

  21. It’d be really nice if this script could gain compatibility with another script. They’re very similar, however, I greatly appreciate effects that both contribute.
    This script shows Hp, Tp, Mp, and or Gold cost which is much preferred. The other script makes it much easier to make a skill use up items and even require that skills need certain conditions like a state to be able to use. Both are very useful for me.

    This is the other script I was talking about: http://forums.rpgmakerweb.com/index.php?/topic/3345-skill-costs/

  22. What about having a skill cost JP? What would go in the “custom cost requirement” and “custom cost perform” sections to make a skill cost JP? (Referring to the JP Manager script)

  23. Hi I keep getting a error when i click on the menu the skill with the custom cost is in.
    when i’m in battle and I click it the game crashes and says syntax error, skill cost line 577 unexpected tGEQ. What’s up with that?

  24. Hi Yanfly i got a problem, when using your script(not even touching it just having it imported) with one of Galvs shorts scripts the game will hang, the script in question is very simple it changes the games base module of death from being 0 hp to 0 mp, its an essential in my game where i heavily modified the battle system, i`m just wondering why is this happening, his is a very short and simple script 10 lines, but i havent even touched yours and its cauing the battler who`s hp is 0 but alive to be unable to use any skills whatsoever. Any advice?

  25. Is there a way to make the mp-cost based on the level? I tried this:
    $game_actor(6).level * 5
    Dosen’t work…^^ Can someone help me pls?

    • Don’t forget:
      (custom cost requirement)
      self.mp >= self.level * 5
      (/custom cost requirement)
      And make some cost out of (custom cost: lvl×3 MP) or something.

    • Put the following in custom requirement:
      $game_party.item_number($data_items[1]) >= 1 && $game_party.item_number($data_items[8]) >= 1

      And the follwoing in custom perform:
      $game_party.lose_item(($data_items[1]),1) && $game_party.lose_item(($data_items[8]),1)

      It’s about the &&.

  26. Hi, wonderful script :)
    I would like to know if it is possible for an ActorA in order to use one skill to do it with an ActorB stats?

    Example :
    An evil witch wandering with his sla.. familiar and use the HP of the familiar in order to attack. (And not the HP of the skill user).

    I can still do it via eventing but if the HP of the familiar is not high enough, it will display a message “Skill fail” and the player will use one turn for nothing.

    Thanks.

  27. Hello, just a question. There is a custom requirement for action X I have that pertains to the number of live enemies of a certain ID in the troop. It is satisfied when all of the battlers’ actions are set (therefore action X is added to the action list), but when the player attacks and kills an enemy, it nullifies the condition. Come time to execute action X, I think–although I am not sure–because the condition is false, my game gets stuck in an endless loop as it cannot execute the action X, yet it has already been set to be executed.
    :(

    Is there a way to prevent this engine from checking certain custom requirements right before executing the action to resolve this issue?

  28. Hey guys, can anyone explain me how to make a skill only work if the target’s HP is 25% or under? I already used:
    (custom skill requirement)
    hp <= mhp / 4 # self.X = caster, X = other
    (/custom cost requirement)
    But that didn't work.

  29. I have a quick question if somebody can help me, I added a Merchant class based on the one from Bravely Default and a cost I’m aiming for is 50 Gold * level. can this be done? I tried (gold cost = 50*a.level) and (gold cost: 50*self.lvl) but they end costing nothing and I tried (custom cost: 50*Level)
    (custom cost requirement)
    50Gold*self.level
    (/custom cost requirement)
    (custom cost perform)
    50Gold*self.level
    (/custom cost perform)
    But they result in a crash when I pick Special, am I typing something in wrong? Can this even be done, any help is appreciated

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s