[MOD] BG:EE Chargen Abilities Screen - show stored values and simple auto roller.
Faydark
Member Posts: 279
After reading the UI examples in the sticky thread, I decided I'd take a stab at changing something that I've always wanted to change in the character generation screen: Being able to see my stored roll without having to actually use the recall button (thus losing my current roll).
Based on the autoroller UI mod examples from @Freche and @Dee, I made some further changes to incorporate both features (stored roll display and auto roller). It's not beautified or anything, but it gets the job done.
Once you click the autoroll button, it will continue to roll until the button is clicked again. It will store any total roll that is higher than the previously stored roll. Additionally, if it rolls the same number as the previously stored roll, but the exceptional strength roll is higher, it will store the total roll (for races/classes that have exceptional strength). End result: leave it running and you will have the maximum roll the game would let you have. =D
If you simply want only the auto roller and the stored value display and don't use any other UI mods, then you can just unzip the attached file into your override directory and be on your way.
If instead you would like to manually add the changes:
Due to the limited data available to the LUA code, I had to do some creative string interpretations, hence the multiple changes to existing code. Sorry!
All of these changes need to be made in UI.menu.
In menu 'CHARGEN_RACE', add the following to the end of the DONE_BUTTON action (before the end double quote):
In menu 'CHARGEN_CLASS', add the following to the end of the DONE_BUTTON action (before the end double quote):
And finally, replace the all of the menu 'CHARGEN_ABILITIES' code with the following:
BG:EE no SoD:
BG:EE with SoD:
Feel free to take it and do as you will with it, and I hope it helps someone else.
Updates:
v0006 - Updated for SoD 2.1.63.2 UI changes.
v0005 - Fixed autoroller script I broke while tinkering. Lowered rerolls to about 15000 per second, was causing music/interactivity loss at higher rate.
v0004 - autoroller now rolls about 150000 rolls per second.
Based on the autoroller UI mod examples from @Freche and @Dee, I made some further changes to incorporate both features (stored roll display and auto roller). It's not beautified or anything, but it gets the job done.
Once you click the autoroll button, it will continue to roll until the button is clicked again. It will store any total roll that is higher than the previously stored roll. Additionally, if it rolls the same number as the previously stored roll, but the exceptional strength roll is higher, it will store the total roll (for races/classes that have exceptional strength). End result: leave it running and you will have the maximum roll the game would let you have. =D
If you simply want only the auto roller and the stored value display and don't use any other UI mods, then you can just unzip the attached file into your override directory and be on your way.
If instead you would like to manually add the changes:
Due to the limited data available to the LUA code, I had to do some creative string interpretations, hence the multiple changes to existing code. Sorry!
All of these changes need to be made in UI.menu.
In menu 'CHARGEN_RACE', add the following to the end of the DONE_BUTTON action (before the end double quote):
; chargen.selectedRace = chargen.races[ currentChargenRace ].id
In menu 'CHARGEN_CLASS', add the following to the end of the DONE_BUTTON action (before the end double quote):
chargen.selectedClass = chargen.class[ currentChargenClass ].id
And finally, replace the all of the menu 'CHARGEN_ABILITIES' code with the following:
BG:EE no SoD:
`
--auto-roller version 2016.04.09.0002
raceHasExceptionalStr = {
true, -- Human
true, -- Elf
true, -- Half-Elf
true, -- Dwarf
false, -- Halfling
true, -- Gnome
true -- Half-Orc
}
classHasExceptionalStr = {
false, -- Mage
true, -- Fighter
false, -- Cleric
false, -- Thief
false, -- Bard
true, -- Paladin
true, -- Fighter / Mage
true, -- Fighter / Cleric
true, -- Fighter / Thief
true, -- Fighter / Mage / Thief
false, -- Druid
true, -- Ranger
false, -- Mage / Thief
false, -- Cleric / Mage
false, -- Cleric / Thief
true, -- Fighter / Druid
true, -- Fighter / Mage / Cleric
true, -- Cleric / Ranger
false, -- Sorcerer
false, -- Monk
false -- Shaman
}
function HasExceptionalStrength( )
return raceHasExceptionalStr[ chargen.selectedRace ] and classHasExceptionalStr[ chargen.selectedClass ]
end
function ShowExceptionalStrength( )
local strength = tonumber( string.sub( chargen.ability[ 1 ].roll, 1, 2 ) )
local abilityToDec = 2
if strength ~= nil then
while ( strength ~= nil ) and ( strength < 18 ) do
createCharScreen:OnAbilityPlusMinusButtonClick( abilityToDec, false )
abilityToDec = abilityToDec + 1
if( abilityToDec == 7 ) then
abilityToDec = 2
end
createCharScreen:OnAbilityPlusMinusButtonClick( 1, true )
strength = tonumber( string.sub( chargen.ability[ 1 ].roll, 1, 2 ) )
end
end
end
RerollFrame = 0
storedTotalRoll = 0
function GetAutoRoll()
if rolling == 1 then
RerollFrame = RerollFrame + 1
if RerollFrame > 1 then
RerollFrame = 0
end
if RerollFrame == 0 then
createCharScreen:OnAbilityReRollButtonClick()
local exceptionalStrength = 0
if( HasExceptionalStrength() ) then
ShowExceptionalStrength( )
exceptionalStrength = tonumber( string.sub( chargen.ability[ 1 ].roll, 4 ) )
if exceptionalStrength ~= nil then
if exceptionalStrength == 0 then
exceptionalStrength = 100
end
else
exceptionalStrength = 0
end
end
if ( ( storedTotalRoll == chargen.totalRoll ) and ( chargen.ability[ 1 ].exceptional < exceptionalStrength ) ) or
( storedTotalRoll < chargen.totalRoll ) then
storedTotalRoll = chargen.totalRoll
chargen.ability[ 1 ].exceptional = exceptionalStrength
chargen.ability[ 1 ].storedRoll = chargen.ability[ 1 ].roll
chargen.ability[ 2 ].storedRoll = chargen.ability[ 2 ].roll
chargen.ability[ 3 ].storedRoll = chargen.ability[ 3 ].roll
chargen.ability[ 4 ].storedRoll = chargen.ability[ 4 ].roll
chargen.ability[ 5 ].storedRoll = chargen.ability[ 5 ].roll
chargen.ability[ 6 ].storedRoll = chargen.ability[ 6 ].roll
createCharScreen:OnAbilityStoreButtonClick()
end
end
end
return
end
`
menu
{
name 'CHARGEN_ABILITIES'
align center center
ignoreesc
onopen "ticksPassed = 0; ticksStarting = 0"
label
{
area 0 0 1024 768
mosaic 'GUICGB'
enabled "CurrentlyInGame()"
}
label
{
area 0 156 1024 612
mosaic GUISMDB
}
label
{
area 20 174 496 48
text "ABILITIES_TITLE"
text style "title"
}
list
{
column
{
width 40
label
{
area 0 0 190 55
text lua "t(chargen.ability[rowNumber].name)"
text style "normal"
align right center
}
}
column
{
width 22
label
{
area 0 0 90 55
text lua "chargen.ability[rowNumber].roll"
text style "normal"
align center center
}
}
column
{
width 9
label
{
area 0 6 45 42
bam GUIOSW
frame lua "currentCellCheck(3)"
sequence 0
}
}
column
{
width 12
label
{
area 0 6 45 42
bam GUIOSW
frame lua "currentCellCheck(4)"
sequence 1
}
}
column
{
width 22
label
{
area 0 0 90 55
text lua "chargen.ability[rowNumber].storedRoll"
text style "normal"
align center center
}
}
action
"
if ticksStarting < 10 then
if cellNumber == 3 then
createCharScreen:OnAbilityPlusMinusButtonClick(currentChargenAbility, true)
elseif cellNumber == 4 then
createCharScreen:OnAbilityPlusMinusButtonClick(currentChargenAbility, false)
end
end
cellNumber = nil
ticksPassed = 0
ticksStarting = 0
"
actionUpdate "
ticksStarting = ticksStarting + 1
if ticksStarting > 10 then
ticksPassed = ticksPassed + 1
if ticksPassed > 7 then
if cellNumber == 3 then
createCharScreen:OnAbilityPlusMinusButtonClick(currentChargenAbility, true)
elseif cellNumber == 4 then
createCharScreen:OnAbilityPlusMinusButtonClick(currentChargenAbility, false)
end
ticksPassed = 0
end
end
"
rowheight 54
hidehighlight
area 32 254 492 322
table "chargen.ability"
var currentChargenAbility
}
label
{
area 32 580 186 42
text "TOTAL_ROLL_NORMAL"
text style "normal"
text align right center
}
label
{
area 248 580 50 42
text lua "chargen.totalRoll"
text style "normal"
text align center center
}
label
{
area 334 580 94 42
text lua "chargen.extraAbilityPoints"
text style "normal"
text align center center
}
label
{
area 458 580 50 42
text lua "storedTotalRoll"
text style "normal"
text align center center
}
text
{
area 582 192 404 406
text lua "abilityOrGeneralHelp()"
text style "normal"
scrollbar 'GUISCRC'
}
button
{
area 568 638 142 40
bam GUIOSTSM
sequence 0
text "AUTO-REROLL"
text style "button"
action "
if rolling == 1 then
rolling = 0
createCharScreen:OnAbilityRecallButtonClick()
else
chargen.ability[ 1 ].exceptional = tonumber( string.sub( chargen.ability[ 1 ].roll, 4 ) )
if chargen.ability[ 1 ].exceptional ~= nil then
if chargen.ability[ 1 ].exceptional == 0 then
chargen.ability[ 1 ].exceptional = 100
end
else
chargen.ability[ 1 ].exceptional = 0
end
storedTotalRoll = chargen.totalRoll
rolling = 1
end"
}
button
{
mosaic lua "GetAutoRoll()"
area 1 1 1 1
}
button
{
area 368 628 142 40
bam GUIOSTSM
sequence 0
text "REROLL_BUTTON"
text style "button"
action "createCharScreen:OnAbilityReRollButtonClick()"
}
button
{
area 60 628 142 40
bam GUIOSTSM
sequence 0
text "STORE_BUTTON"
text style "button"
action "
local exceptionalStrength = tonumber( string.sub( chargen.ability[ 1 ].roll, 4 ) )
if exceptionalStrength ~= nil then
if exceptionalStrength == 0 then
exceptionalStrength = 100
end
else
exceptionalStrength = 0
end
storedTotalRoll = chargen.totalRoll
chargen.ability[ 1 ].exceptional = exceptionalStrength
chargen.ability[ 1 ].storedRoll = chargen.ability[ 1 ].roll
chargen.ability[ 2 ].storedRoll = chargen.ability[ 2 ].roll
chargen.ability[ 3 ].storedRoll = chargen.ability[ 3 ].roll
chargen.ability[ 4 ].storedRoll = chargen.ability[ 4 ].roll
chargen.ability[ 5 ].storedRoll = chargen.ability[ 5 ].roll
chargen.ability[ 6 ].storedRoll = chargen.ability[ 6 ].roll
createCharScreen:OnAbilityStoreButtonClick()
"
}
button
{
area 214 628 142 40
bam GUIOSTSM
sequence 0
text "RECALL_BUTTON"
text style "button"
clickable lua "createCharScreen:IsAbilityRecallButtonClickable()"
action "createCharScreen:OnAbilityRecallButtonClick()"
}
button
{
on '8'
action "createCharScreen:OnCheatyMcCheaterson()"
}
button
{
on escape
area 194 718 232 44
bam GUIOSTUL
text "BACK_BUTTON"
text style "button"
action "Infinity_PopMenu(); createCharScreen:OnCancelButtonClick()"
}
button
{
on return
area 438 718 206 44
bam GUIOSTUM
text "DONE_BUTTON"
text style "button"
clickable lua "createCharScreen:IsDoneButtonClickable()"
action "Infinity_PopMenu(); createCharScreen:OnDoneButtonClick()"
}
}
BG:EE with SoD:
`
--auto-roller version 2016.04.13.0005
raceHasExceptionalStr = {
true, -- Human
true, -- Elf
true, -- Half-Elf
true, -- Dwarf
false, -- Halfling
true, -- Gnome
true -- Half-Orc
}
classHasExceptionalStr = {
false, -- Mage
true, -- Fighter
false, -- Cleric
false, -- Thief
false, -- Bard
true, -- Paladin
true, -- Fighter / Mage
true, -- Fighter / Cleric
true, -- Fighter / Thief
true, -- Fighter / Mage / Thief
false, -- Druid
true, -- Ranger
false, -- Mage / Thief
false, -- Cleric / Mage
false, -- Cleric / Thief
true, -- Fighter / Druid
true, -- Fighter / Mage / Cleric
true, -- Cleric / Ranger
false, -- Sorcerer
false, -- Monk
false -- Shaman
}
function HasExceptionalStrength( )
return raceHasExceptionalStr[ chargen.selectedRace ] and classHasExceptionalStr[ chargen.selectedClass ]
end
function ShowExceptionalStrength( )
local strength = tonumber( string.sub( chargen.ability[ 1 ].roll, 1, 2 ) )
local abilityToDec = 2
if strength ~= nil then
while ( strength ~= nil ) and ( strength < 18 ) do
createCharScreen:OnAbilityPlusMinusButtonClick( abilityToDec, false )
abilityToDec = abilityToDec + 1
if( abilityToDec == 7 ) then
abilityToDec = 2
end
createCharScreen:OnAbilityPlusMinusButtonClick( 1, true )
strength = tonumber( string.sub( chargen.ability[ 1 ].roll, 1, 2 ) )
end
end
end
function AutoRoll( )
createCharScreen:OnAbilityReRollButtonClick()
local exceptionalStrength = 0
if( HasExceptionalStrength() ) then
ShowExceptionalStrength( )
exceptionalStrength = tonumber( string.sub( chargen.ability[ 1 ].roll, 4 ) )
if exceptionalStrength ~= nil then
if exceptionalStrength == 0 then
exceptionalStrength = 100
end
else
exceptionalStrength = 0
end
end
if ( ( storedTotalRoll == chargen.totalRoll ) and ( chargen.ability[ 1 ].exceptional < exceptionalStrength ) ) or
( storedTotalRoll < chargen.totalRoll ) then
storedTotalRoll = chargen.totalRoll
chargen.ability[ 1 ].exceptional = exceptionalStrength
chargen.ability[ 1 ].storedRoll = chargen.ability[ 1 ].roll
chargen.ability[ 2 ].storedRoll = chargen.ability[ 2 ].roll
chargen.ability[ 3 ].storedRoll = chargen.ability[ 3 ].roll
chargen.ability[ 4 ].storedRoll = chargen.ability[ 4 ].roll
chargen.ability[ 5 ].storedRoll = chargen.ability[ 5 ].roll
chargen.ability[ 6 ].storedRoll = chargen.ability[ 6 ].roll
createCharScreen:OnAbilityStoreButtonClick()
end
end
RerollFrame = 0
storedTotalRoll = 0
function UpdateAutoRoll()
if rolling == 1 then
RerollFrame = RerollFrame + 1
if RerollFrame > 1 then
RerollFrame = 0
end
if RerollFrame == 0 then
local index = 1
for index = 1, 1000, 1 do
AutoRoll( )
end
end
end
end
`
menu
{
name 'CHARGEN_ABILITIES'
modal
align center center
ignoreesc
onopen "ticksPassed = 0; ticksStarting = 0"
label
{
area 0 0 864 710
mosaic GUICGROL
}
label
{
area 220 22 426 44
text "ABILITIES_TITLE"
text style "title"
}
list
{
column
{
width 34
label
{
area 0 0 100 55
text lua "t(chargen.ability[rowNumber].name)"
text style "normal"
align right center
}
}
column
{
width 18
label
{
area 0 0 50 55
text lua "chargen.ability[rowNumber].storedRoll"
text style "normal"
align center center
}
}
column
{
width 13
label
{
area 0 0 50 55
text lua "chargen.ability[rowNumber].roll"
text style "normal"
align center center
}
}
column
{
width 22
label
{
area 36 6 45 42
bam GUIOSW
frame lua "currentCellCheck(4)"
sequence 0
}
}
column
{
width 15
label
{
area 0 6 45 42
bam GUIOSW
frame lua "currentCellCheck(5)"
sequence 1
}
}
action
"
if ticksStarting < 10 then
if cellNumber == 4 then
createCharScreen:OnAbilityPlusMinusButtonClick(currentChargenAbility, true)
elseif cellNumber == 5 then
createCharScreen:OnAbilityPlusMinusButtonClick(currentChargenAbility, false)
end
end
cellNumber = nil
ticksPassed = 0
ticksStarting = 0
"
actionUpdate
"
ticksStarting = ticksStarting + 1
if ticksStarting > 10 then
ticksPassed = ticksPassed + 1
if ticksPassed > 2 then
if cellNumber == 4 then
createCharScreen:OnAbilityPlusMinusButtonClick(currentChargenAbility, true)
elseif cellNumber == 5 then
createCharScreen:OnAbilityPlusMinusButtonClick(currentChargenAbility, false)
end
ticksPassed = 0
end
end
"
rowheight 54
hidehighlight
area 34 85 386 325
table "chargen.ability"
var currentChargenAbility
}
label
{
area 34 410 100 54
text "TOTAL_ROLL_NORMAL"
text style "normal"
text align right center
}
label
{
area 164 410 50 54
text lua "storedTotalRoll"
text style "normal"
text align center center
}
label
{
area 233 410 50 54
text lua "chargen.totalRoll"
text style "normal"
text align center center
}
label
{
area 322 410 94 54
text lua "chargen.extraAbilityPoints"
text style "normal"
text align center center
}
text
{
area 442 91 394 505
text lua "abilityOrGeneralHelp()"
text style "normal"
scrollbar 'GUISCRC'
}
button
{
area 230 480 200 44
bam GUIBUTNT
sequence 0
text "AUTO-REROLL"
text style "button"
action "
if rolling == 1 then
rolling = 0
createCharScreen:OnAbilityRecallButtonClick()
else
chargen.ability[ 1 ].exceptional = tonumber( string.sub( chargen.ability[ 1 ].roll, 4 ) )
if chargen.ability[ 1 ].exceptional ~= nil then
if chargen.ability[ 1 ].exceptional == 0 then
chargen.ability[ 1 ].exceptional = 100
end
else
chargen.ability[ 1 ].exceptional = 0
end
storedTotalRoll = chargen.totalRoll
rolling = 1
end"
}
button
{
mosaic lua "UpdateAutoRoll()"
area 1 1 1 1
}
button
{
area 26 480 200 44
bam GUIBUTNT
sequence 0
text "REROLL_BUTTON"
text style "button"
action "createCharScreen:OnAbilityReRollButtonClick()"
}
button
{
area 26 531 200 44
bam GUIBUTNT
sequence 0
text "STORE_BUTTON"
text style "button"
action "
local exceptionalStrength = tonumber( string.sub( chargen.ability[ 1 ].roll, 4 ) )
if exceptionalStrength ~= nil then
if exceptionalStrength == 0 then
exceptionalStrength = 100
end
else
exceptionalStrength = 0
end
storedTotalRoll = chargen.totalRoll
chargen.ability[ 1 ].exceptional = exceptionalStrength
chargen.ability[ 1 ].storedRoll = chargen.ability[ 1 ].roll
chargen.ability[ 2 ].storedRoll = chargen.ability[ 2 ].roll
chargen.ability[ 3 ].storedRoll = chargen.ability[ 3 ].roll
chargen.ability[ 4 ].storedRoll = chargen.ability[ 4 ].roll
chargen.ability[ 5 ].storedRoll = chargen.ability[ 5 ].roll
chargen.ability[ 6 ].storedRoll = chargen.ability[ 6 ].roll
createCharScreen:OnAbilityStoreButtonClick()
"
}
button
{
area 26 582 200 44
bam GUIBUTNT
sequence 0
text "RECALL_BUTTON"
text style "button"
clickable lua "createCharScreen:IsAbilityRecallButtonClickable()"
action "createCharScreen:OnAbilityRecallButtonClick()"
}
button
{
on '8'
action "createCharScreen:OnCheatyMcCheaterson()"
}
button
{
on escape
area 196 653 230 44
bam GUIBUTMT
text "BACK_BUTTON"
text style "button"
action "Infinity_PopMenu(); createCharScreen:OnCancelButtonClick()"
}
button
{
on return
area 438 653 230 44
bam GUIBUTMT
text "DONE_BUTTON"
text style "button"
clickable lua "createCharScreen:IsDoneButtonClickable()"
action "Infinity_PopMenu(); createCharScreen:OnDoneButtonClick()"
}
}
Feel free to take it and do as you will with it, and I hope it helps someone else.
Updates:
v0006 - Updated for SoD 2.1.63.2 UI changes.
v0005 - Fixed autoroller script I broke while tinkering. Lowered rerolls to about 15000 per second, was causing music/interactivity loss at higher rate.
v0004 - autoroller now rolls about 150000 rolls per second.
Post edited by Faydark on
8
Comments
My only comment would be a more general one - doesn't constant screen updating mean that the rolling process is slower?
The rolling process could be made a lot faster by removing the "animation" system and just going with a fast loop that you have to break somehow (perhaps keypress?) but it will "soft lock" BGEE while it's running and following on from @Freche original idea, I decided to stick with the animated version to keep the UI responsive and the autoroller easy to control.
For my own roller I used the faster one from @Freche but added a count function to limit the number of rolls to 100,000 (which takes about 40seconds).
I'm at work atm, but tonight I'll modify the original post with a version that does ~150000 rolls per second. It didn't really speed things up to be honest, still took a while to get a 99 roll for my FMT test case, but getting to 92+ was pretty quick.
@smeagolheart Can you describe how you're using it and I can see if I can repro it here and fix the bug(s) if there are any. Video would be great if the steps are complex.
button { area 230 480 200 44 bam GUIBUTNT sequence 0 text "AUTO-REROLL" text style "button" action " if rolling == 1 then rolling = 0 createCharScreen:OnAbilityRecallButtonClick() else chargen.ability[ 1 ].exceptional = tonumber( string.sub( chargen.ability[ 1 ].roll, 4 ) ) if chargen.ability[ 1 ].exceptional ~= nil then if chargen.ability[ 1 ].exceptional == 0 then chargen.ability[ 1 ].exceptional = 100 end else chargen.ability[ 1 ].exceptional = 0 end storedTotalRoll = chargen.totalRoll rolling = 1 end" }
@Runeks, @GrimLefourbe Oops, looks like I broke something while playing around before uploading. I'll fix is asap.
The autoroll button doesn't directly call the autoroll function, it sets that rolling var to 1 and then the autorolling function that is updated in the background for animation purposes checks that var every frame and rolls again if it's set to 1.
@GrimLefourbe in version 0005, look at the call to UpdateAutoRoll( ). That call is attached to a dummy "invisible" button. The "mosaic" keyword means "run whatever is attached here periodically", and some clever people in the original UI mod thread figured that out and @Freche used it to write his autoroller script.
(like I got a 103 roll better !)