@rob
I agree with you 100%. However, I have been wrestling with this for a couple of weeks now and this is the only way I have found to get this to work.
What is "this"?? The "Advanced Learning" class feature of the Warmage class from the Complete Arcane sourcebook:
"
At 3rd, 6th, 11th, and 16th level, a warmage can add a new spell to his list, representing the result of personal study and experimentation. The spell must be a wizard spell of the evocation school, and of a level no higher than that of the highest-level spell the warmage already knows. Once a new spell is selected, it is forever added to that warmage’s spell list and can be cast just like any other spell on the warmage’s list."
I am using the Secondary Spells functionality to apply this and using my script to manipulate cSecMax based on what they have already chosen (cSecCur).
So, for example, at 3rd lvl, the Warmage gets to choose ONE first lvl spell to add to their list...easy peasy.
At 6th level, the get to add ONE additional spell, but it can be a 1st, 2nd, or 3rd lvl spell. So, the possible combinations they could have at sixth level once they've chosen their Advanced Learning spell are two 1st lvl spells, one 1st and one 2nd, or one 1st and one 3rd lvl spell (3 permutations).
At 11th level, the number of permutations goes up to 11.
I'm handling these permutations via nested conditionals that check what choices they have already made (cSecCur) and once they meet one of the possible combinations, it removes their ability to choose anything else by setting cSecMax for the other spell levels back to zero:
if (level < 16) then
hero.child[cHelpWRM].field[cSecMax].arrayvalue[1] = 3
hero.child[cHelpWRM].field[cSecMax].arrayvalue[2] = 2
hero.child[cHelpWRM].field[cSecMax].arrayvalue[3] = 1
hero.child[cHelpWRM].field[cSecMax].arrayvalue[4] = 1
hero.child[cHelpWRM].field[cSecMax].arrayvalue[5] = 1
if (cur1 = 3) then
hero.child[cHelpWRM].field[cSecMax].arrayvalue[1] = 3
hero.child[cHelpWRM].field[cSecMax].arrayvalue[2] = 0
hero.child[cHelpWRM].field[cSecMax].arrayvalue[3] = 0
hero.child[cHelpWRM].field[cSecMax].arrayvalue[4] = 0
hero.child[cHelpWRM].field[cSecMax].arrayvalue[5] = 0
endif
if (cur1 = 2) then
if (cur2 = 1) then
hero.child[cHelpWRM].field[cSecMax].arrayvalue[1] = 2
hero.child[cHelpWRM].field[cSecMax].arrayvalue[2] = 1
hero.child[cHelpWRM].field[cSecMax].arrayvalue[3] = 0
hero.child[cHelpWRM].field[cSecMax].arrayvalue[4] = 0
hero.child[cHelpWRM].field[cSecMax].arrayvalue[5] = 0
endif
endif
if (cur1 = 2) then
if (cur3 = 1) then
hero.child[cHelpWRM].field[cSecMax].arrayvalue[1] = 2
hero.child[cHelpWRM].field[cSecMax].arrayvalue[2] = 0
hero.child[cHelpWRM].field[cSecMax].arrayvalue[3] = 1
hero.child[cHelpWRM].field[cSecMax].arrayvalue[4] = 0
hero.child[cHelpWRM].field[cSecMax].arrayvalue[5] = 0
endif
endif
Now, up to 11th level, everything fits in one script and works PERFECTLY.
It is when I get up to the possible permutations for 16th level that I run into size issues for there are 63 possible combinations that I have to check for.
Now, I have already done all the scripting. I just need to find a way to fit it into the EvalScript sections. I know I can break up the script into 3 parts, but my problem is that at the beginning of each script, I am resetting the cSecMax fields to their new values based on their new level and I don't want those values reset by part-2 of the script if the condition was met in part-1. That is why I was asking about variable persistence or the ability to prevent future scripts from running.
If you or anyone knows of a better (and simpler) way to do this, I would greatly appreciate it.
Thanks.
-GP