Help with a Script thingy?

● ARCHIVED · READ-ONLY
Started by Feliaria 7 posts View original ↗
  1. Sorry for the non-descriptive title, I'm not sure what this is... Other than a monster of a thingy. Could be because I'm brain dead after two Biology midterms and an OChem midterm in two days. Ouchie.


    So, I'm using Yanfly's Extra Parameter Formula plugin (and a bunch of her others), but I'm having trouble setting something up... I've removed the personally nonsensical Magic Evasion stat with Yanfly's HitAccuracy. By doing so, I have been able to add my own stat. I call it Power, and Power is a % increase in all outgoing damage. Power is also largely controlled by the character's Agility stat. Because of the way my game handles Agility, the higher the character's Agility stat, the lower their Power, and the lower the character's Agility stat, the higher their Power. Anyway, here's my script thingy for Power...


    if (a.isStateAffected(5)) {if (a.agi = 0) {1.62 + base} else {if (a.agi = 1) {1.49 + base}} else {if (a.agi = 2) {1.39 + base}} else {if (a.agi = 3) {1.30 + base}} else {if (a.agi = 4) {1.22 + base}} else {if (a.agi = 5) {1.14 + base}} else {if (a.agi = 6) {1.07 + base}} else {if (a.agi = 7) {1.00 + base}} else {if (a.agi = 8) {0.94 + base}} else {if (a.agi = 9) {0.88 + base}} else {if (a.agi = 10) {0.83 + base}} else {if (a.agi = 11) {0.78 + base}} else {if (a.agi = 12) {0.74 + base}} else {if (a.agi = 13) {0.69 + base}} else {if (a.agi = 14) {0.66 + base}} else {if (a.agi = 15) {0.62 + base}}} else {if (a.agi = 0) {1.39 + base}} else {if (a.agi = 1) {1.30 + base}} else {if (a.agi = 2) {1.22 + base}} else {if (a.agi = 3) {1.14 + base}} else {if (a.agi = 4) {1.07 + base}} else {if (a.agi = 5) {1.00 + base}} else {if (a.agi = 6) {0.94 + base}} else {if (a.agi = 7) {0.88 + base}} else {if (a.agi = 8) {0.83 + base}} else {if (a.agi = 9) {0.78 + base}} else {if (a.agi = 10) {0.74 + base}} else {if (a.agi = 11) {0.69 + base}} else {if (a.agi = 12) {0.66 + base}} else {if (a.agi = 13) {0.62 + base}} else {if (a.agi = 14) {0.59 + base}} else {if (a.agi = 15) {0.56 + base}}}


    However, when I look to see what the character's Power is in Yanfly's Status Menu Core (to make sure it's actually working right), all I get is "Syntax Error: Unexpected Token else". Umm... Honestly, I've never tried making a line of code this big and aren't certain where I went wrong... Could I get some help, please? XD
  2. You've got about 500 else statements there without any matching if statements.  The if and else need to go inside the same pair of {}


    I suggest you separate the whole thing out onto individual lines and use indenting so you can see what belongs with what, fix the issue, then copy it to another file where you can compress it again (or just leave it with multiple lines & indenting so it's easier to read).
  3. Well, here's the uncompressed version. Compressing and injecting it into the project doesn't crash anymore, but it does come out as "NaN%" for Power in the Status Menu. At least that's improvement.


    if (a.isStateAffected(5)) {


       if (a.agi = 0) {


           1.62 + base; 


       } else if (a.agi = 1) {


             1.49 + base; 


          } else if (a.agi = 2) {


                1.39 + base; 


             } else if (a.agi = 3) {


                   1.30 + base; 


                } else if (a.agi = 4) {


                      1.22 + base; 


                   } else if (a.agi = 5) {


                         1.14 + base; 


                      } else if (a.agi = 6) {


                            1.07 + base; 


                         } else if (a.agi = 7) {


                               1.00 + base; 


                            } else if (a.agi = 8) {


                                  0.94 + base; 


                               } else if (a.agi = 9) {


                                      0.88 + base; 


                                  } else if (a.agi = 10) {


                0.83 + base; 


             } else if (a.agi = 11) {


       0.78 + base; 


    } else if (a.agi = 12) {


          0.74 + base; 


       } else if (a.agi = 13) {


             0.69 + base; 


          } else if (a.agi = 14) {


    0.66 + base; 


             } else if (a.agi = 15) {


       0.62 + base; 


    } else {


       if (a.agi = 0)


          1.39 + base;


       } else if (a.agi = 1) {


             1.30 + base; 


          } else if (a.agi = 2) {


                1.22 + base; 


             } else if (a.agi = 3) {


       1.14 + base;


    } else if (a.agi = 4) {


          1.07 + base; 


       } else if (a.agi = 5) {


             1.00 + base; 


          } else if (a.agi = 6) {


    0.94 + base;


             } else if (a.agi = 7) {


       0.88 + base;


    } else if (a.agi = 8) {


          0.83 + base; 


       } else if (a.agi = 9) {


             0.78 + base; 


          } else if (a.agi = 10) {


                0.74 + base;


             } else if (a.agi = 11) {


       0.69 + base;


    } else if (a.agi = 12) {


          0.66 + base;


       } else if (a.agi = 13) {


             0.62 + base;


          } else if (a.agi = 14) {


    0.59 + base;


                                                                                                  } else if (a.agi = 15) {


       0.56 + base;


    }


       }


          }
  4. Hmmm ... it seems to me you'd be able to write a formula instead of all those if/else if statements.


    What's the rule you have for the number you add to base?  What is base?  Does that actually exist?


    Try this: 


    index = a.agi;
    if (!a.isStateAffected(5)) { index += 2; };
    [1.62, 1.49, 1.39, 1.3, 1.22, 1.14, 1.07, 1.00, 0.94, 0.88, 0.83, 0.78, 0.74, 0.69, 0.66, 0.62, 0.59, 0.56][index] + base;




    This is assuming base is actually correct and that's not where the problem is.
  5. Shaz said:
    Hmmm ... it seems to me you'd be able to write a formula instead of all those if/else if statements.


    What's the rule you have for the number you add to base?  What is base?  Does that actually exist?


    Try this: 



    index = a.agi;
    if (!a.isStateAffected(5)) { index += 2; };
    [1.62, 1.49, 1.39, 1.3, 1.22, 1.14, 1.07, 1.00, 0.94, 0.88, 0.83, 0.78, 0.74, 0.69, 0.66, 0.62, 0.59, 0.56][index] + base;




    This is assuming base is actually correct and that's not where the problem is.



    Your thing works, Shaz, thanks!


    Base is any additions to Power from states. I don't know why it's Base instead of Rate, but it is haha XD
  6. as long as it works :)   You didn't use a.base and I'm really not familiar with the battle system, and haven't touched Yanfly's plugins, so I just wasn't sure what it was and what used it.


    That would have been shorter if I could have found a nice pattern with the number sequence, but the increments were gradually increasing, and sometimes they'd drop back to the previous level.  So it was just easier to list them all rather than try to work out a formula.


    Anyway - glad it works.  And it's a lot shorter than what you had :D


    Uh - will a.agi only ever be a number from (and including) 0 to 15?  If it goes above 15, there's going to be a problem.  If that's possible just change the first line to this instead:


    index = a.agi > 15 ? 15 : index.agi;


    That'll ensure you don't get any 'out of range' errors.
  7. Shaz said:
    as long as it works :)   You didn't use a.base and I'm really not familiar with the battle system, and haven't touched Yanfly's plugins, so I just wasn't sure what it was and what used it.


    That would have been shorter if I could have found a nice pattern with the number sequence, but the increments were gradually increasing, and sometimes they'd drop back to the previous level.  So it was just easier to list them all rather than try to work out a formula.


    Anyway - glad it works.  And it's a lot shorter than what you had :D


    Uh - will a.agi only ever be a number from (and including) 0 to 15?  If it goes above 15, there's going to be a problem.  If that's possible just change the first line to this instead:



    index = a.agi > 15 ? 15 : index.agi;


    That'll ensure you don't get any 'out of range' errors.



    Yes, Agility caps at 15. And it is a lot shorter than what I made originally, so yay :D
    And yeah, I know it jumps. I calculated Power through how my game interacts with Agility. 


    Agility controls a series of Action Time+, and from there I was able to determine the character's action economy (average attacks per turn), and then divide the action economy of my 100% Power Agility point (5), by the action economy of the Agility stat. So, 5 Agility has an action economy of 1.39. 0 Agility has an action economy of 1.00. 1.39/1.00=1.39, so 0 Agility has a Power of 139%.


    Anyway, thank you so much for making that for me. I had no idea how I would make something like that without like a bazillion else if statements like you saw XD