Variable in a formula as an MP cost?

Discussion in 'RGSS3 Script Requests' started by Cuddlebuns, May 28, 2019.

Thread Status:
Not open for further replies.
  1. Cuddlebuns

    Cuddlebuns Villager Member

    Messages:
    22
    Likes Received:
    2
    Location:
    Canada
    First Language:
    English
    Primarily Uses:
    RMVXA
    Is there a way for the MP cost of a skill to be determined by a variable? A rough formula would be "v[n] = MP cost".
     
    #1
  2. ??????

    ?????? Diabolical Codemaster Veteran

    Messages:
    6,264
    Likes Received:
    2,310
    Location:
    Your OS
    First Language:
    Binary
    Primarily Uses:
    RMMV
    Code:
    a.mp -= v[n]
    ?
     
    #2
  3. Cuddlebuns

    Cuddlebuns Villager Member

    Messages:
    22
    Likes Received:
    2
    Location:
    Canada
    First Language:
    English
    Primarily Uses:
    RMVXA
    Where would I paste this in the database?
     
    #3
  4. ??????

    ?????? Diabolical Codemaster Veteran

    Messages:
    6,264
    Likes Received:
    2,310
    Location:
    Your OS
    First Language:
    Binary
    Primarily Uses:
    RMMV
    oh, sorry :D

    upload_2019-5-27_22-56-17.png

    In the formula section of the desired skill or item. You can use any valid javascrip there, and a few objects are available. you have access to the attacker, which has mp. its just a case of reducing the mp..

    the ; in the formula signifies a new line to the game interpreter. so it would do the damage, then take the mp (but it would seem to be the same time to the player)

    Hope this helped :*
     
    #4
    Dreadshadow and Cuddlebuns like this.
  5. Cuddlebuns

    Cuddlebuns Villager Member

    Messages:
    22
    Likes Received:
    2
    Location:
    Canada
    First Language:
    English
    Primarily Uses:
    RMVXA
    Thank you so much!
     
    #5
    ?????? likes this.
  6. ??????

    ?????? Diabolical Codemaster Veteran

    Messages:
    6,264
    Likes Received:
    2,310
    Location:
    Your OS
    First Language:
    Binary
    Primarily Uses:
    RMMV
    np, hope it works, I havent messed with the formula box of mv much - it woulda worked for ace though :D
     
    #6
  7. Andar

    Andar Veteran Veteran

    Messages:
    28,001
    Likes Received:
    6,327
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    @Cuddlebuns @??????
    Unfortunately the Diabolical Codemaster made a tiny but important mistake...

    The damage done is always the last number processed in the damage formula, so the cost reduction needs to come first:
    Code:
    a.mp-=v[5]; a.atk*4 - b.def*2
    
    Additionally, while this does reduce the MP by the cost, the engine no longer prevents the use of the spell if the actor has less MP than set in variable 5, he would always be able to case this skill even with 0 MP (because the skill cost itself needs to be set to 0)

    To prevent that you'll need a script that allows for different skill costs - for example the one from Yanfly or from Tsukihime.
    That would even allow you to set items as skill costs in addition to MP and TP however
     
    #7
    Cuddlebuns, Dreadshadow and ?????? like this.
  8. ??????

    ?????? Diabolical Codemaster Veteran

    Messages:
    6,264
    Likes Received:
    2,310
    Location:
    Your OS
    First Language:
    Binary
    Primarily Uses:
    RMMV
    Well, there you go lol

    My oopsie :D
     
    #8
  9. slimmmeiske2

    slimmmeiske2 Little Red Riding Hood Moderator

    Messages:
    5,203
    Likes Received:
    3,936
    Location:
    Belgium
    First Language:
    Dutch
    Primarily Uses:
    RMXP

    This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

     
    #9
Thread Status:
Not open for further replies.

Share This Page