Also, can booleans be cast to integers? I have 6 boolean properties as conditional in a quest script so that I could toggle buttons in a menu. This isn't working. The code below shows it as it is now but I'll be changing those conditionals to ints. This means that I need to change some code below and if bools cannot be cast to ints then I need more lines. In the script below, the button vars are bShowButton*
Oh yeah, almost forgot my 3rd question. How many times does a script need to call another script for it to be worth importing said script? This script has one line that calls Game.Function 3 times and this in OnUpdate which runs every 3 seconds until character creation is finished. Is it possible to only import certain functions from a script? Could I copy the native functions from the game script and paste them into this script?
I'm not the best at commenting my code :-p
Spoiler
Scriptname _CCMenuScript extends Quest Conditional{Classic Classes and Birthsigns menu script rewritten by selyb}Actor Property aPlayer AutoSpell Property _CCAcrobatAbilityMagSho AutoSpell Property BoundSword AutoSpell Property HealingHands AutoSpell Property Courage Automessage property _CCTopMenu automessage property _CCAdventurerMenu automessage property _CCSpecializationMenu automessage property _CCCombatSpecializationMenu automessage property _CCStealthSpecializationMenu automessage property _CCMagicSpecializationMenu automessage property _BSTopMenu Automessage property _BSTravelerMenu Automessage property _BSBirthsignMenu Automessage property _BSBirthsignChoiceMenu Automessage property _CCCurrentCharacter Automessage property _CCCurrentBirthsignMenu AutoGlobalVariable property SpeechEasy AutoGlobalVariable property SpeechAverage AutoGlobalVariable property SpeechHard AutoGlobalVariable property SpeechVeryHard Automessage property _CCCustomTopMenu automessage property _CCCustomSpecialist automessage property _CCCustomClassConfirm automessage property _CCCustomSecondarySkills autobool Property bShowButton0 Auto Conditionalbool Property bShowButton1 Auto Conditionalbool Property bShowButton2 Auto Conditionalbool Property bShowButton3 Auto Conditionalbool Property bShowButton4 Auto Conditionalbool Property bShowButton5 Auto ConditionalMessage[] Property aMenus Auto Message[] Property aSignMessages Auto SPELL[] Property aSignSpells1 AutoSPELL[] Property aSignSpells2 Auto Message[] Property aSpecializationMenus Auto ;All 21 menusInt[] Property aClassOptionFlags Auto ;Elements 0-20 to store option flags for each of the 21 classesSPELL[] Property aClassAbilities Auto ;Store the base class abilities, these three arrays are parallelMessage[] Property aCustomSkillMenus Auto ;6 custom character skill menusSPELL[] Property aClassSkill1 Auto ;Store secondary Skills/Spells hereSPELL[] Property aClassSkill2 Auto ;Store tertiary Skills/Spells hereString[] Property aSkills Auto ;Store the actor value names here for use with SetAVBool[] Property aClassChoices Auto ;Elements 0-24 for buildclass optionsEvent OnInit() RegisterForSingleUpdate(1)EndEventEvent OnUpdate() ; selyb - I robbed this line from Character Creation Overhaul by Syclonix and modified it a little If Game.IsFightingControlsEnabled() && Game.IsActivateControlsEnabled() && Game.IsJournalControlsEnabled() && !Utility.IsInMenuMode() MainMenu() Else RegisterForSingleUpdate(3) EndIfEndEventFunction MainMenu() int iPage = 1 int iChoice bool bContinue = True While bContinue If iPage == 1 ;TopMenu iChoice = _CCTopMenu.Show() ; 0 = AdventurerMenu, 1 = SpecializationMenu, 2 = CustomClassMenu iPage = iChoice + 2 ElseIf iPage == 2 ;AdventurerMenu If _CCAdventurerMenu.Show() ;Back iPage = 1 Else ;BSTopMenu iPage = 6 EndIf ElseIf iPage == 3 ;SpecializationMenu iChoice = _CCSpecializationMenu.Show() If iChoice == 3 ;Back iPage =1 Else ;0 is Combat, 1 is Stealth, 2 is Magic iPage = 9 + iChoice EndIf ElseIf iPage == 4 ;CustomClassMenu If CustomClassLoop() iPage = 6 Else ;Cancelled iPage = 1 EndIf ElseIf iPage == 5 ;CurrentBirthsignMenu If _CCCurrentBirthsignMenu.Show() ;Return to game bContinue = False Else ; iPage = 6 EndIf ElseIf iPage == 6 ;BSTopMenu If _BSTopMenu.Show() ;BirthsignChoice iPage = 7 Else ;TravelerMenu iPage = 8 EndIf ElseIf iPage == 7 ;BirthsignChoice iChoice = _BSBirthsignChoiceMenu.Show() If iChoice == 2 ;Back iPage = 6 Else bContinue = !BSHelper(iChoice * 13) EndIf ElseIf iPage == 8 ;TravelerMenu If _BSTravelerMenu.Show() ;Back iPage = 6 Else ;Done bContinue = False EndIf Else ;If iPage > 8 If iPage == 9 iChoice = _CCCombatSpecializationMenu.Show() ElseIf iPage == 10 iChoice = _CCStealthSpecializationMenu.Show() Else ;If iPage == 11 iChoice = _CCMagicSpecializationMenu.Show() EndIf If iChoice == 7 ;Back iPage = 3 Else iChoice *= iPage - 9 If aSpecializationMenus[iChoice].Show() aPlayer.AddSpell(aClassAbilities[iChoice]) If aClassAbilities[iChoice] aPlayer.AddSpell(aClassAbilities[iChoice]) EndIf If iChoice == 3 ; aPlayer.AddSpell(Courage) ElseIf iChoice == 7 ; aPlayer.AddSpell(_CCAcrobatAbilityMagSho) ElseIf iChoice == 8 ;Agent SpeechEasy.SetValue(70) SpeechAverage.SetValue(70) SpeechHard.SetValue(70) SpeechVeryHard.SetValue(70) ElseIf iChoice == 15 ; aPlayer.AddSpell(HealingHands) ElseIf iChoice == 18 ; aPlayer.AddSpell(BoundSword) EndIf SetOptions(aClassOptionFlags[iChoice]) BuildClass() iPage = 6 EndIf EndIf EndIf EndWhileEndFunctionFunction SetOptions(int iFlags) ;This function takes an integer and converts it to 24 booleans ;Without this, we would have to store a boolean array for each of the 21 classes int iCurFlag = 8388608 ;Start with 2^23 int x = 23 ;Current iteration ;Start at option 23 While iFlags ;Once we have found all flags and subtracted them, this will be 0 and we don't need to loop anymore If iFlags / iCurFlag > 1 ;If the current flag exists then this division will be > 1 otherwise a fraction < 1 iFlags -= iCurFlag ;Subtract the current flag from our flags value so that the next loop will work correctlyaClassChoices[x] = True ;Turn the option on EndIf x -= 1 iCurFlag /= 2 ;In binary this means /10 in essence bringing us to the next lower possible flag EndWhileEndFunctionbool Function CustomClassLoop() int iPage = 1 int iChoice int iNumSkills = 7 bool bRet = True int iSpecBonus = 2 While iPage If iPage == 1 ;CustomTopMenu bShowButton5 = !iNumSkills iChoice = _CCCustomTopMenu.Show(iNumSkills) If iChoice == 0 ;SpecBonusMenu iPage = 2 ElseIf iChoice == 4 ;Secondary Skills iPage = 3 ElseIf iChoice == 5 ;Next iPage = 0 ElseIf iChoice == 6 ;Cancel If _CCCustomClassConfirm.Show() bRet = False iPage = 0 EndIf Else iPage = ((iChoice - 1) * 2) + 4 EndIf ElseIf iPage == 2 ;SpecBonusMenu bShowButton0 = iSpecBonus != 1 bShowButton1 = iSpecBonus == 1 bShowButton2 = iSpecBonus != 2 bShowButton3 = iSpecBonus == 2 bShowButton4 = iSpecBonus != 3 bShowButton5 = iSpecBonus == 3 iChoice = _CCCustomSpecialist.Show() If iChoice == 0 iSpecBonus = 1 ElseIf iChoice == 2 iSpecBonus = 2 ElseIf iChoice == 4 iSpecBonus = 3 Else iPage = 1 EndIf ElseIf iPage == 3 ;Secondary Skills iChoice = _CCCustomSecondarySkills.Show() If iChoice == 5 ;Back iPage = 1 Else aClassChoices[18] = iChoice aClassChoices[19] = iChoice != 1 aClassChoices[20] = iChoice != 2 aClassChoices[21] = iChoice != 3 aClassChoices[22] = iChoice != 4 EndIf ElseIf iPage < 10 ;Skill Menus iPage -= 4 ;It makes fewer calculations to subtract 4 here and add it back later ;Buttons 0, 2, and 4 are the add skill buttons. 1, 3, and 5 are the remove buttons corresponding to 0, 2, and 4 ;For 0, 2, and 4 we check to make sure we have available skills and then check to see if the skill has already been chosen bShowButton0 = iNumSkills && !aClassChoices[iPage * 3] bShowButton1 = aClassChoices[iPage * 3] bShowButton2 = iNumSkills && !aClassChoices[(iPage * 3) + 1] bShowButton3 = aClassChoices[(iPage * 3) + 1] bShowButton4 = iNumSkills && !aClassChoices[(iPage * 3) + 2] bShowButton5 = aClassChoices[(iPage * 3) + 2] iChoice = aCustomSkillMenus[iPage].Show(iNumSkills) If iChoice == 8 ;Back iPage = 1 ElseIf iChoice == 7 ;Next iPage += 1 If iPage == 6 iPage = 0 EndIf ElseIf iChoice == 6 ;Prev iPage -= 1 If iPage == -1 iPage = 5 EndIf Else ;Toggle ;If iChoice is 1, 3, or 5, change it to 0, 2, or 4 iChoice -= (iChoice % 2) iChoice *= iPage If aClassChoices[iChoice] aClassChoices[iChoice] = False iNumSkills += 1 Else aClassChoices[iChoice] = True iNumSkills -= 1 EndIf EndIf iPage += 4 EndIf EndWhile If bRet BuildClass() EndIfEndFunctionbool Function BSHelper(int iMenuOffset) ;Use an offset so we can put both eras into the same arrays and reuse the same loops ; This clever function saved us around 140 lines of redundant code ^_^ bool bContinue = True bool bMainMenu = True ;Otherwise submenu int iSign ;This will be used to determine which spells to add int iChoice int iMenu = 3 ;This is used to determine which menu to show While bContinue iChoice = aMenus[iMenu].Show() If bMainMenu If iChoice == 4 ;Back iSign = 0 bContinue = False ElseIf iChoice == 3 ;SerpentMenu iSign = 13 + iMenuOffset Else iMenu = iChoice bMainMenu = False EndIf Else ;SubMenu If iChoice == 4 ;Back bMainMenu = True iMenu = 3 Else iSign = (iMenu * 4) + iChoice + 1 + iMenuOffset EndIf EndIf If iSign If aSignMessages[iSign].Show() ;Back iSign = 0 Else ;Confirmed bContinue = False EndIf EndIf EndWhile If iSign ; CleanUpSigns ; selyb - Since the doom abilities are only passed in an array, we need this loop If iMenuOffset ;This will be non-zero if chose 4E sign menu iChoice = 14 ;I just reused an existing variable that isn't needed anymore in this function While iChoice < 27 ;The doom abilities reside in elements 14 - 26 aPlayer.RemoveSpell(aSignSpells1[iChoice]) iChoice += 1 EndWhile EndIf aPlayer.AddSpell(aSignSpells1[iSign]) If aSignSpells2[iSign] aPlayer.AddSpell(aSignSpells2[iSign]) EndIf Return True ;Global exit Else Return False ;Back to BSTopMenu EndIfEndFunctionFunction BuildClass(int iSpecBonus = 0) ;pass Spec Bonus so we don't have to make a global for it int x ;Used for loop iteration count int iBonus ;/ I use an array of bools along with 5 conditional bools to show/hide menu buttons This shows the order that this script expects skills e.g. in the array of bools 0) OneHanded 1 1) TwoHanded 2 2) Archery 4 3) Block 8 4) Smithing 16 5) HeavyArmor 32 6) LightArmor 64 7) Pickpocket 128 8) Lockpicking 256 9) Sneak 512 10) Alchemy 1024 11) Speech 2048 12) Enchanting 4096 13) Alteration 8192 14) Conjuration 16384 15) Destruction 32768 16) Illusion 65536 17) Restoration 131072 18) CCAcrobaticsAbility 262144 19) CCAthleticsAbility 524288 20) Pilgrim 1048576 21) CCUnarmoredAbility 2097152 22) CCMysticismAbility 4194304 23) CCUnarmedBonus 8388608 /; ;Set SpecBonus If iSpecBonus aPlayer.SetAV(aSkills[iSpecBonus + 17], aPlayer.GetAV(aSkills[iSpecBonus + 17]) + 20) EndIf ;Set Skills + Custom Perks While x < 24 If x < 18 iBonus = -10 If aClassChoices[x] iBonus = 10 EndIf aPlayer.SetAV(aSkills[x], aPlayer.GetAV(aSkills[x] + iBonus)) EndIf If x > 12 aPlayer.AddSpell(aClassSkill1[x - 13]) If x < 21 aPlayer.AddSpell(aClassSkill2[x - 13]) EndIf EndIf EndWhileEndFunction