Help with a Script thingy?

Feliaria

Good with Ideas, Bad with Execution
Veteran
Joined
Feb 4, 2016
Messages
364
Reaction score
50
First Language
English
Primarily Uses
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
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,111
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
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).
 

Feliaria

Good with Ideas, Bad with Execution
Veteran
Joined
Feb 4, 2016
Messages
364
Reaction score
50
First Language
English
Primarily Uses
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.


[SIZE=10.5pt]if (a.isStateAffected(5)) {[/SIZE]


[SIZE=10.5pt]   [/SIZE]if (a.agi = 0) {


[SIZE=10.5pt]       [/SIZE]1.62 + base; 


[SIZE=10.5pt]   [/SIZE]} else if (a.agi = 1) {


[SIZE=10.5pt]         [/SIZE]1.49 + base; 


[SIZE=10.5pt]      [/SIZE]} else if (a.agi = 2) {


[SIZE=10.5pt]            [/SIZE]1.39 + base; 


[SIZE=10.5pt]         [/SIZE]} else if (a.agi = 3) {


[SIZE=10.5pt]               [/SIZE]1.30 + base; 


[SIZE=10.5pt]            [/SIZE]} else if (a.agi = 4) {


[SIZE=10.5pt]                  [/SIZE]1.22 + base; 


[SIZE=10.5pt]               [/SIZE]} else if (a.agi = 5) {


[SIZE=10.5pt]                     [/SIZE]1.14 + base; 


[SIZE=10.5pt]                  [/SIZE]} else if (a.agi = 6) {


[SIZE=10.5pt]                        [/SIZE]1.07 + base; 


[SIZE=10.5pt]                     [/SIZE]} else if (a.agi = 7) {


[SIZE=10.5pt]                           [/SIZE]1.00 + base; 


[SIZE=10.5pt]                        [/SIZE]} else if (a.agi = 8) {


[SIZE=10.5pt]                              [/SIZE]0.94 + base; 


[SIZE=10.5pt]                           [/SIZE]} else if (a.agi = 9) {


[SIZE=10.5pt]                                 [/SIZE] 0.88 + base; 


[SIZE=10.5pt]                              [/SIZE]} else if (a.agi = 10) {


[SIZE=10.5pt]           [/SIZE] 0.83 + base; 


[SIZE=10.5pt]         [/SIZE]} else if (a.agi = 11) {


[SIZE=10.5pt]   [/SIZE]0.78 + base; 


[SIZE=10.5pt]} else if (a.agi = 12) {[/SIZE]


[SIZE=10.5pt]      [/SIZE]0.74 + base; 


[SIZE=10.5pt]   [/SIZE]} else if (a.agi = 13) {


[SIZE=10.5pt]         [/SIZE]0.69 + base; 


[SIZE=10.5pt]      [/SIZE]} else if (a.agi = 14) {


[SIZE=10.5pt]0.66 + base; [/SIZE]


[SIZE=10.5pt]         [/SIZE]} else if (a.agi = 15) {


[SIZE=10.5pt]   [/SIZE]0.62 + base; 


[SIZE=10.5pt]} else { [/SIZE]


[SIZE=10.5pt]   [/SIZE]if (a.agi = 0)


[SIZE=10.5pt]      [/SIZE]1.39 + base;


[SIZE=10.5pt]   [/SIZE]} else if (a.agi = 1) {


[SIZE=10.5pt]         [/SIZE]1.30 + base; 


[SIZE=10.5pt]      [/SIZE]} else if (a.agi = 2) {


[SIZE=10.5pt]            [/SIZE]1.22 + base; 


[SIZE=10.5pt]         [/SIZE]} else if (a.agi = 3) {


[SIZE=10.5pt]   [/SIZE]1.14 + base;


[SIZE=10.5pt]} else if (a.agi = 4) {[/SIZE]


[SIZE=10.5pt]      [/SIZE]1.07 + base; 


[SIZE=10.5pt]   [/SIZE]} else if (a.agi = 5) {


[SIZE=10.5pt]         [/SIZE]1.00 + base; 


[SIZE=10.5pt]      [/SIZE]} else if (a.agi = 6) {


[SIZE=10.5pt]0.94 + base;[/SIZE]


[SIZE=10.5pt]         [/SIZE]} else if (a.agi = 7) {


[SIZE=10.5pt]   [/SIZE]0.88 + base;


[SIZE=10.5pt]} else if (a.agi = 8) {[/SIZE]


[SIZE=10.5pt]      [/SIZE]0.83 + base; 


[SIZE=10.5pt]   [/SIZE]} else if (a.agi = 9) {


[SIZE=10.5pt]         [/SIZE]0.78 + base; 


[SIZE=10.5pt]      [/SIZE]} else if (a.agi = 10) {


[SIZE=10.5pt]            [/SIZE]0.74 + base;


[SIZE=10.5pt]         [/SIZE]} else if (a.agi = 11) {


[SIZE=10.5pt]   [/SIZE]0.69 + base;


[SIZE=10.5pt]} else if (a.agi = 12) {[/SIZE]


[SIZE=10.5pt]      [/SIZE]0.66 + base;


[SIZE=10.5pt]   [/SIZE]} else if (a.agi = 13) {


[SIZE=10.5pt]         [/SIZE]0.62 + base;


[SIZE=10.5pt]      [/SIZE]} else if (a.agi = 14) {


[SIZE=10.5pt]0.59 + base; [/SIZE]


[SIZE=10.5pt]                  [/SIZE]                                                                            } else if (a.agi = 15) {


[SIZE=10.5pt]   [/SIZE]0.56 + base;


[SIZE=10.5pt]}[/SIZE]


[SIZE=10.5pt]   [/SIZE]}


[SIZE=10.5pt]      [/SIZE]}
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,111
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
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.
 
Last edited by a moderator:

Feliaria

Good with Ideas, Bad with Execution
Veteran
Joined
Feb 4, 2016
Messages
364
Reaction score
50
First Language
English
Primarily Uses
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
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,111
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
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.
 
Last edited by a moderator:

Feliaria

Good with Ideas, Bad with Execution
Veteran
Joined
Feb 4, 2016
Messages
364
Reaction score
50
First Language
English
Primarily Uses
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
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,048
Messages
1,018,543
Members
137,834
Latest member
EverNoir
Top