Exemple #1
0
def SetupSpellsWindow(chargen=0):
    if chargen:
        MyChar = GemRB.GetVar("Slot")
        Class = GemRB.GetPlayerStat(MyChar, IE_CLASS)
        ClassName = GUICommon.GetClassRowName(Class, "class")
        Level = 0
        LevelDiff = 1
        KitValue = GemRB.GetPlayerStat(MyChar, IE_KIT)
    else:
        MyChar = GemRB.GameGetSelectedPCSingle()
        ClassIndex = GemRB.GetVar("LUClass")
        ClassName = GUICommon.GetClassRowName(ClassIndex, "index")
        LevelDiff = GemRB.GetVar("LevelDiff")
        Level = GemRB.GetPlayerStat(MyChar, IE_CLASSLEVELSUM)
        # this is only used for detecting specialists!
        KitValue = GemRB.GetVar("LUKit")

    SpellTableName = CommonTables.ClassSkills.GetValue(ClassName, "MAGESPELL")

    # charbase has domain slots reserved, so nuke them
    if chargen:
        Spellbook.UnsetupSpellLevels(MyChar, "MXSPLCLR", IE_IWD2_SPELL_DOMAIN,
                                     1)

    # learn priest spells if any and setup spell levels
    # but first nullify any previous spells
    if chargen:
        for row in range(CommonTables.ClassSkills.GetRowCount()):
            rowname = CommonTables.ClassSkills.GetRowName(row)
            SpellBookType = CommonTables.ClassSkills.GetValue(
                rowname, "SPLTYPE")
            if SpellBookType != "*":
                Spellbook.RemoveKnownSpells(MyChar, SpellBookType, 1, 9, 0)
        Spellbook.RemoveKnownSpells(MyChar, IE_IWD2_SPELL_DOMAIN, 1, 9, 0)
    IDLUCommon.LearnAnySpells(MyChar, ClassName, chargen)

    # make sure we have a correct table and that we're eligible
    BookType = CommonTables.ClassSkills.GetValue(ClassName, "BOOKTYPE")
    canLearn = chargen or Spellbook.IsSorcererBook(BookType)  # bard / sorcerer
    if SpellTableName == "*" or not canLearn:
        if chargen:
            GemRB.SetNextScript("CharGen7")
        else:
            import GUIREC
            GUIREC.FinishLevelUp()
        return

    SpellBookType = CommonTables.ClassSkills.GetValue(ClassName, "SPLTYPE")
    LUSpellSelection.OpenSpellsWindow(MyChar, SpellTableName,
                                      Level + LevelDiff, LevelDiff, KitValue,
                                      chargen, True, SpellBookType)
Exemple #2
0
def DCProfsDonePress():
    """Goes to the next applicable step.

	This is either skill selection, spell selection, or nothing."""

    global NewMageSpells, NewPriestMask

    # check for mage spells and thief skills
    SpellTable = CommonTables.ClassSkills.GetValue(ClassName, "MAGESPELL")
    ClericTable = CommonTables.ClassSkills.GetValue(ClassName, "CLERICSPELL")
    DruidTable = CommonTables.ClassSkills.GetValue(ClassName, "DRUIDSPELL")
    if SpellTable != "*":
        # we go 2,2 to get an extra spell
        # TODO: add a mod to the function instead?
        LUSpellSelection.OpenSpellsWindow(pc, SpellTable, 2, 2, 0)
        SpellTable = GemRB.LoadTable(SpellTable)
        GemRB.SetMemorizableSpellsCount(pc, SpellTable.GetValue(0, 0),
                                        IE_SPELL_TYPE_WIZARD, 0)
        NewMageSpells = 1
    if ClericTable != "*":
        print "Setting PriestMask"
        if not GemRB.HasResource(ClericTable, RES_2DA, 1):
            ClericTable = "MXSPLPRS"  # iwd1 doesn't have a DRUIDSPELL column in the table
        # make sure we can cast spells at this level (paladins)
        ClericTable = GemRB.LoadTable(ClericTable)
        if ClericTable.GetRowName(0) == "1":
            NewPriestMask = 0x4000
    elif DruidTable != "*":
        # make sure we can cast spells at this level (rangers)
        if GUICommon.HasTOB():
            DruidTable = GemRB.LoadTable(DruidTable)
            if DruidTable.GetRowName(0) == "1":
                NewPriestMask = 0x8000
        else:
            NewPriestMask = 0x8000

    # open the thieves selection window
    OpenSkillsWindow()

    # we can be done now
    DCMainDoneButton.SetState(IE_GUI_BUTTON_ENABLED)

    # close out the profs window (don't assign yet!)
    if DCProfsWindow:
        DCProfsWindow.Unload()
    return
Exemple #3
0
def OnLoad():
    KitTable = GemRB.LoadTable("magesch")
    Slot = GemRB.GetVar("Slot")
    Class = GemRB.GetPlayerStat(Slot, IE_CLASS)
    ClassName = GUICommon.GetClassRowName(Class, "class")
    TableName = CommonTables.ClassSkills.GetValue(ClassName, "MAGESPELL")

    # make sure we have a correct table
    if TableName == "*":
        GemRB.SetNextScript("GUICG6")
        return
    if Class == 19:
        # sorcerers need their known not max table or they would progress too slowly
        TableName = "SPLSRCKN"

    # get our kit index
    KitIndex = GUICommon.GetKitIndex(Slot)
    if KitIndex:
        KitValue = KitTable.GetValue(KitIndex - 21, 3)

        # bards have kits too
        if KitValue == -1:
            KitValue = 0x4000  # we only need it for the spells, so this is ok
    else:
        KitValue = 0x4000

    # open up the spell selection window
    # remember, it is pc, table, level, diff, kit, chargen
    IsMulti = GUICommon.IsMultiClassed(Slot, 1)
    Level = GemRB.GetPlayerStat(Slot, IE_LEVEL)
    if IsMulti[0] > 1:
        for i in range(1, IsMulti[0]):
            ClassName = GUICommon.GetClassRowName(IsMulti[i], "class")
            if CommonTables.ClassSkills.GetValue(ClassName, "MAGESPELL",
                                                 GTV_STR) != "*":
                Level = GemRB.GetPlayerStat(Slot, IE_LEVEL2 + i - 1)
            break

    LUSpellSelection.OpenSpellsWindow(Slot, TableName, Level, Level, KitValue,
                                      1)

    return
Exemple #4
0
def OpenLevelUpWindow():
    """Sets up the level up window."""
    import GUIREC

    global LevelUpWindow, TextAreaControl, NewProfPoints, actor
    global DoneButton
    global NewSkillPoints, KitName, LevelDiff
    global Level, Classes, NumClasses, DualSwap, IsMulti
    global OldHPMax, OldSaves, OldLore, OldThaco, DeltaDSpells, DeltaWSpells
    global NewDSpells, NewWSpells, OldDSpells, OldWSpells, pc, HLACount, ClassName, IsDual

    LevelUpWindow = GemRB.LoadWindow(3)

    if GameCheck.IsBG2():
        InfoButton = LevelUpWindow.GetControl(125)
        InfoButton.SetText(13707)
        InfoButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, LevelUpInfoPress)

    DoneButton = LevelUpWindow.GetControl(0)
    DoneButton.SetText(11962)
    DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, LevelUpDonePress)
    DoneButton.SetState(IE_GUI_BUTTON_DISABLED)
    DoneButton.SetFlags(IE_GUI_BUTTON_DEFAULT, OP_OR)

    # hide "Character Generation"
    Label = LevelUpWindow.CreateLabel(
        0x1000007e, 0, 0, 0, 0, "NUMBER", "",
        IE_FONT_ALIGN_CENTER | IE_FONT_SINGLE_LINE)

    # name
    pc = GemRB.GameGetSelectedPCSingle()
    actor = Actor.Actor(pc)
    Label = LevelUpWindow.GetControl(0x10000000 + 90)
    Label.SetText(GemRB.GetPlayerName(pc))

    if GameCheck.IsBG1() or GameCheck.IsIWD1():
        # armorclass
        Label = LevelUpWindow.GetControl(0x10000057)
        Label.SetText(str(GemRB.GetPlayerStat(pc, IE_ARMORCLASS)))
        Label.SetTooltip(17183)

        # hp now
        Label = LevelUpWindow.GetControl(0x10000058)
        Label.SetText(str(GemRB.GetPlayerStat(pc, IE_HITPOINTS)))
        Label.SetTooltip(17184)

        # hp max
        Label = LevelUpWindow.GetControl(0x10000059)
        Label.SetText(str(GemRB.GetPlayerStat(pc, IE_MAXHITPOINTS)))
        Label.SetTooltip(17378)

    # some current values
    OldHPMax = GemRB.GetPlayerStat(pc, IE_MAXHITPOINTS, 1)
    OldThaco = GemRB.GetPlayerStat(pc, IE_TOHIT, 1)
    OldLore = GemRB.GetPlayerStat(pc, IE_LORE, 1)
    for i in range(5):
        OldSaves[i] = GemRB.GetPlayerStat(pc, IE_SAVEVSDEATH + i, 1)

    # class
    Label = LevelUpWindow.GetControl(0x10000000 + 106)
    Label.SetText(GUICommon.GetActorClassTitle(pc))
    print "Title:", GUICommon.GetActorClassTitle(
        pc), "\tActor Title:", actor.ClassTitle()

    Class = GemRB.GetPlayerStat(pc, IE_CLASS)
    print "Class:", Class, "\tActor Class:", actor.classid
    SkillTable = GemRB.LoadTable("skills")

    # kit
    ClassName = GUICommon.GetClassRowName(Class, "class")
    Kit = GUICommon.GetKitIndex(pc)
    print "Kit:", Kit, "\tActor Kit:", actor.KitIndex()
    print "ClassName:", ClassName, "\tActor ClassNames:", actor.ClassNames()

    # need this for checking gnomes
    RaceName = GemRB.GetPlayerStat(pc, IE_RACE, 1)
    RaceName = CommonTables.Races.FindValue(3, RaceName)
    RaceName = CommonTables.Races.GetRowName(RaceName)

    # figure our our proficiency table and index
    if Kit == 0:
        KitName = ClassName
    else:
        #rowname is just a number, the kitname is the first data column
        KitName = CommonTables.KitList.GetValue(Kit, 0)

    # our multiclass variables
    IsMulti = GUICommon.IsMultiClassed(pc, 1)
    Classes = [IsMulti[1], IsMulti[2], IsMulti[3]]
    NumClasses = IsMulti[0]  # 2 or 3 if IsMulti; 0 otherwise
    IsMulti = NumClasses > 1
    IsDual = 0
    DualSwap = 0

    # not multi, check dual
    if not IsMulti:
        # check if we're dual classed
        IsDual = GUICommon.IsDualClassed(pc, 1)
        Classes = [IsDual[2], IsDual[1]]  # make sure the new class is first

        # either dual or single only care about 1 class
        NumClasses = 1

        # not dual, must be single
        if IsDual[0] == 0:
            Classes = [Class]
        else:  # make sure Classes[1] is a class, not a kit
            if IsDual[0] == 1:  # kit
                Classes[1] = CommonTables.KitList.GetValue(IsDual[1], 7)
            else:  # class
                TmpClassName = GUICommon.GetClassRowName(Classes[1], "index")
                Classes[1] = CommonTables.Classes.GetValue(TmpClassName, "ID")

        # store a boolean for IsDual
        IsDual = IsDual[0] > 0

    print "NumClasses:", NumClasses, "\tActor NumClasses:", actor.NumClasses()

    Level = [0] * 3
    LevelDiff = [0] * 3

    # reorganize the leves if we're dc so the one we want to use is in Level[0]
    # and the old one is in Level[1] (used to regain old class abilities)
    if IsDual:
        # convert the classes from indicies to class id's
        DualSwap = GUICommon.IsDualSwap(pc)
        ClassName = GUICommon.GetClassRowName(Classes[0], "index")
        KitName = ClassName  # for simplicity throughout the code
        Classes[0] = CommonTables.Classes.GetValue(ClassName, "ID")
        # Class[1] is taken care of above

        # we need the old level as well
        if DualSwap:
            Level[1] = GemRB.GetPlayerStat(pc, IE_LEVEL)
        else:
            Level[1] = GemRB.GetPlayerStat(pc, IE_LEVEL2)

    print "Classes:", Classes, "\tActor Classes:", actor.Classes()
    print "IsDual:", IsDual > 0, "\tActor IsDual", actor.isdual

    hp = 0
    HaveCleric = 0
    # clear some globals, since we may get called multiple times with different classes
    DeltaWSpells = 0
    DeltaDSpells = 0
    OldDSpells = [0] * 7
    OldWSpells = [0] * 9
    NewDSpells = [0] * 7
    NewWSpells = [0] * 9

    # get a bunch of different things each level
    for i in range(NumClasses):
        #		print "Class:",Classes[i]
        # we don't care about the current level, but about the to-be-achieved one
        # get the next level
        Level[i] = LUCommon.GetNextLevelFromExp(
            GemRB.GetPlayerStat(pc, IE_XP) / NumClasses, Classes[i])
        TmpClassName = GUICommon.GetClassRowName(Classes[i], "class")

        # find the level diff for each classes (3 max, obviously)
        if i == 0:
            if DualSwap:
                LevelDiff[i] = Level[i] - GemRB.GetPlayerStat(pc, IE_LEVEL2)
            else:
                LevelDiff[i] = Level[i] - GemRB.GetPlayerStat(pc, IE_LEVEL)
        elif i == 1:
            LevelDiff[i] = Level[i] - GemRB.GetPlayerStat(pc, IE_LEVEL2)
        elif i == 2:
            LevelDiff[i] = Level[i] - GemRB.GetPlayerStat(pc, IE_LEVEL3)

#		print "Level (",i,"):",Level[i]
#		print "Level Diff (",i,"):",LevelDiff[i]

# save our current and next spell amounts
        StartLevel = Level[i] - LevelDiff[i]
        DruidTable = CommonTables.ClassSkills.GetValue(TmpClassName,
                                                       "DRUIDSPELL", GTV_STR)
        ClericTable = CommonTables.ClassSkills.GetValue(
            TmpClassName, "CLERICSPELL", GTV_STR)
        MageTable = CommonTables.ClassSkills.GetValue(TmpClassName,
                                                      "MAGESPELL", GTV_STR)

        # see if we have mage spells
        if MageTable != "*":
            # we get 1 extra spell per level if we're a specialist
            Specialist = 0
            if CommonTables.KitList.GetValue(
                    Kit, 7) == 1:  # see if we're a kitted mage
                Specialist = 1

            if Spellbook.HasSorcererBook(pc, Classes[i]):
                MageTable = "SPLSRCKN"

            MageTable = GemRB.LoadTable(MageTable)
            # loop through each spell level and save the amount possible to cast (current)
            for j in range(MageTable.GetColumnCount()):
                NewWSpells[j] = MageTable.GetValue(str(Level[i]), str(j + 1),
                                                   GTV_INT)
                OldWSpells[j] = MageTable.GetValue(str(StartLevel), str(j + 1),
                                                   GTV_INT)
                if NewWSpells[
                        j] > 0:  # don't want specialist to get 1 in levels they should have 0
                    NewWSpells[j] += Specialist
                if OldWSpells[j] > 0:
                    OldWSpells[j] += Specialist
            DeltaWSpells = sum(NewWSpells) - sum(OldWSpells)
        elif ClericTable != "*":
            # check for cleric spells
            if not GemRB.HasResource(ClericTable, RES_2DA, 1):
                ClericTable = "MXSPLPRS"  # iwd1 doesn't have a DRUIDSPELL column in the table
            ClericTable = GemRB.LoadTable(ClericTable)
            HaveCleric = 1
            # same as above
            for j in range(ClericTable.GetColumnCount()):
                NewDSpells[j] = ClericTable.GetValue(str(Level[i]), str(j + 1),
                                                     GTV_INT)
                OldDSpells[j] = ClericTable.GetValue(str(StartLevel),
                                                     str(j + 1), GTV_INT)
            DeltaDSpells = sum(NewDSpells) - sum(OldDSpells)
        elif DruidTable != "*":
            # clerics have precedence in multis (ranger/cleric)
            if HaveCleric == 0:
                #use MXSPLPRS if we can't find the resource (SoA fix)
                if not GemRB.HasResource(DruidTable, RES_2DA):
                    DruidTable = "MXSPLPRS"

                # check druid spells
                DruidTable = GemRB.LoadTable(DruidTable)
                # same as above
                for j in range(DruidTable.GetColumnCount()):
                    NewDSpells[j] = DruidTable.GetValue(
                        str(Level[i]), str(j + 1), GTV_INT)
                    OldDSpells[j] = DruidTable.GetValue(
                        str(StartLevel), str(j + 1), GTV_INT)
                DeltaDSpells = sum(NewDSpells) - sum(OldDSpells)


# this is handled by core
#		# setup class bonuses for this class
#		if IsMulti or IsDual or Kit == 0:
#			ABTable = CommonTables.ClassSkills.GetValue (TmpClassName, "ABILITIES")
#		else: # single-classed with a kit
#			ABTable = CommonTables.KitList.GetValue (str(Kit), "ABILITIES")
#
#		# add the abilites if we have a table to ref
#		if ABTable != "*" and GemRB.HasResource (ABTable, RES_2DA, 1):
#			GUICommon.AddClassAbilities (pc, ABTable, Level[i], LevelDiff[i])

    print "Actor CurrentLevels:", actor.Levels()
    print "Levels:", Level, "Actor NextLevels:", actor.NextLevels()
    print "LevelDiffs:", LevelDiff, "Actor LevelDiffs:", actor.LevelDiffs()

    #update our saves, thaco, hp and lore
    LUCommon.SetupSavingThrows(pc, Level)
    LUCommon.SetupThaco(pc, Level)
    LUCommon.SetupLore(pc, LevelDiff)
    LUCommon.SetupHP(pc, Level, LevelDiff)

    # use total levels for HLAs
    HLACount = 0
    if GameCheck.HasTOB():  # make sure SoA doesn't try to get it
        HLATable = GemRB.LoadTable("lunumab")
        # we need to check each level against a multi value (this is kinda screwy)
        if actor.multiclass:
            print "Actor HLA Names:",["MULTI"+str(actor.NumClasses())+name \
             for name in actor.ClassNames()]
        else:
            print "Actor HLA Names:", actor.ClassNames()

        for i in range(NumClasses):
            if IsMulti:
                # get the row name for lookup ex. MULTI2FIGHTER, MULTI3THIEF
                MultiName = GUICommon.GetClassRowName(Classes[i], "class")
                MultiName = "MULTI" + str(NumClasses) + MultiName
            else:
                MultiName = ClassName

            # if we can't learn for this class, we can't learn at all
            FirstLevel = HLATable.GetValue(MultiName, "FIRST_LEVEL", GTV_INT)
            if Level[i] < FirstLevel:
                HLACount = 0
                break

            if (Level[i] - LevelDiff[i]) < FirstLevel:
                # count only from FirstLevel up
                HLACount += (Level[i] - FirstLevel + 1)
            else:
                HLACount += LevelDiff[i]

        # set values required by the hla level up code
        HLACount = HLACount / HLATable.GetValue(ClassName, "RATE", GTV_INT)
        GemRB.SetVar("HLACount", HLACount)
    if GameCheck.IsBG2():
        HLAButton = LevelUpWindow.GetControl(126)
        if HLACount:
            HLAButton.SetText(4954)
            HLAButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, LevelUpHLAPress)
        else:
            HLAButton.SetFlags(IE_GUI_BUTTON_DISABLED, OP_OR)

    # setup our profs
    Level1 = []
    for i in range(len(Level)):
        Level1.append(Level[i] - LevelDiff[i])
    if GameCheck.IsBG2():
        LUProfsSelection.SetupProfsWindow(
            pc, LUProfsSelection.LUPROFS_TYPE_LEVELUP, LevelUpWindow,
            RedrawSkills, Level1, Level)
    else:
        LUProfsSelection.SetupProfsWindow(
            pc, LUProfsSelection.LUPROFS_TYPE_LEVELUP, LevelUpWindow,
            RedrawSkills, Level1, Level, 0, False, 0)
    NewProfPoints = GemRB.GetVar("ProfsPointsLeft")

    #we autohide the skills and let SetupSkillsWindow show them if needbe
    for i in range(4):
        HideSkills(i)
    if GameCheck.IsBG2():
        LUSkillsSelection.SetupSkillsWindow(
            pc, LUSkillsSelection.LUSKILLS_TYPE_LEVELUP, LevelUpWindow,
            RedrawSkills, Level1, Level)
    else:
        LUSkillsSelection.SetupSkillsWindow(
            pc, LUSkillsSelection.LUSKILLS_TYPE_LEVELUP, LevelUpWindow,
            RedrawSkills, Level1, Level, 0, False)
    NewSkillPoints = GemRB.GetVar("SkillPointsLeft")

    if GameCheck.IsBG2():
        TextAreaControl = LevelUpWindow.GetControl(110)
        TextAreaControl.SetText(GetLevelUpNews())
    else:
        TextAreaControl = LevelUpWindow.GetControl(42)
        TextAreaControl.SetText(GUIREC.GetStatOverview(pc, LevelDiff))

    RedrawSkills()
    GemRB.SetRepeatClickFlags(GEM_RK_DISABLE, OP_NAND)
    LevelUpWindow.ShowModal(MODAL_SHADOW_GRAY)

    # if we have a sorcerer who can learn spells, we need to do spell selection
    for c in range(len(Classes)):
        if Spellbook.HasSorcererBook(pc, Classes[c]) and DeltaWSpells > 0:
            LUSpellSelection.OpenSpellsWindow(pc, "SPLSRCKN", Level[c],
                                              LevelDiff[c])
Exemple #5
0
def OpenLevelUpWindow():
	"""Sets up the level up window."""
	import GUIREC

	global LevelUpWindow, TextAreaControl, NewProfPoints, actor
	global DoneButton
	global NewSkillPoints, KitName, LevelDiff
	global Level, Classes, NumClasses, DualSwap, IsMulti
	global OldHPMax, OldSaves, OldLore, OldThaco, DeltaDSpells, DeltaWSpells
	global NewDSpells, NewWSpells, OldDSpells, OldWSpells, pc, HLACount, ClassName, IsDual

	LevelUpWindow = GemRB.LoadWindow (3)

	if GameCheck.IsBG2():
		InfoButton = LevelUpWindow.GetControl (125)
		InfoButton.SetText (13707)
		InfoButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, LevelUpInfoPress)
		# hide "Character Generation"
		LevelUpWindow.DeleteControl(0x1000007e)

	DoneButton = LevelUpWindow.GetControl (0)
	DoneButton.SetText (11962)
	DoneButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, LevelUpDonePress)
	DoneButton.SetState (IE_GUI_BUTTON_DISABLED)
	DoneButton.MakeDefault()
	# also disable closing by ESC, so we don't stack upgrades
	DoneButton.MakeEscape ()

	# name
	pc = GemRB.GameGetSelectedPCSingle ()
	actor = Actor.Actor(pc)
	Label = LevelUpWindow.GetControl (0x10000000+90)
	Label.SetText (GemRB.GetPlayerName (pc))

	# some current values
	OldHPMax = GemRB.GetPlayerStat (pc, IE_MAXHITPOINTS, 1)
	OldThaco = GemRB.GetPlayerStat (pc, IE_TOHIT, 1)
	OldLore = GemRB.GetPlayerStat (pc, IE_LORE, 1)
	for i in range (5):
		OldSaves[i] = GemRB.GetPlayerStat (pc, IE_SAVEVSDEATH+i, 1)

	# class
	Label = LevelUpWindow.GetControl (0x10000000+106)
	Label.SetText (GUICommon.GetActorClassTitle (pc))
	print("Title: " + GUICommon.GetActorClassTitle (pc) + "\tActor Title: " + actor.ClassTitle())

	Class = GemRB.GetPlayerStat (pc, IE_CLASS)
	print("Class: " + str(Class) + "\tActor Class: " + str(actor.classid))

	# kit
	ClassName = GUICommon.GetClassRowName (Class, "class")
	Kit = GUICommon.GetKitIndex (pc)
	print("Kit: " + str(Kit) + "\tActor Kit: " + str(actor.KitIndex()))
	print("ClassName: " + ClassName + "\tActor ClassNames: " + str(actor.ClassNames()))

	# need this for checking gnomes
	RaceName = GemRB.GetPlayerStat (pc, IE_RACE, 1)
	RaceName = CommonTables.Races.FindValue (3, RaceName)
	RaceName = CommonTables.Races.GetRowName (RaceName)

	# figure our our proficiency table and index
	if Kit == 0:
		KitName = ClassName
	else:
		#rowname is just a number, the kitname is the first data column
		KitName = CommonTables.KitList.GetValue(Kit, 0)

	# our multiclass variables
	IsMulti = GUICommon.IsMultiClassed (pc, 1)
	Classes = [IsMulti[1], IsMulti[2], IsMulti[3]]
	NumClasses = IsMulti[0] # 2 or 3 if IsMulti; 0 otherwise
	IsMulti = NumClasses > 1
	IsDual = 0
	DualSwap = 0

	# not multi, check dual
	if not IsMulti:
		# check if we're dual classed
		IsDual = GUICommon.IsDualClassed (pc, 1)
		Classes = []

		# either dual or single only care about 1 class
		NumClasses = 1

		# not dual, must be single
		if IsDual[0] == 0:
			Classes = [Class]
		else: # resolve kits to classes (new class goes first)
			if IsDual[0] == 3: # 1st kit
				Classes.append (CommonTables.KitList.GetValue (IsDual[2], 7))
			else: # 1st class
				Classes.append (CommonTables.Classes.GetValue (IsDual[2], 5))
			if IsDual[0] == 1: # 2nd kit
				Classes.append (CommonTables.KitList.GetValue (IsDual[1], 7))
			else: # 2nd class
				Classes.append (CommonTables.Classes.GetValue (IsDual[1], 5))

		# store a boolean for IsDual
		IsDual = IsDual[0] > 0

	print("NumClasses: " + str(NumClasses) + "\tActor NumClasses: " + str(actor.NumClasses()))

	if IsDual:
		# convert the classes from indicies to class id's
		DualSwap = GUICommon.IsDualSwap (pc)
		ClassName = GUICommon.GetClassRowName (Classes[0], "index")
		KitName = ClassName # for simplicity throughout the code

	print("Classes: " + str(Classes) + "\tActor Classes: " + str(actor.Classes()))
	print("IsDual: " + str(IsDual > 0) + "\tActor IsDual: " + str(actor.isdual))

	# get the next target levels and difference between levels
	Level = LUCommon.GetNextLevels(pc, Classes)
	LevelDiff = LUCommon.GetLevelDiff(pc, Level)

	# clear some globals, since we may get called multiple times with different classes
	DeltaWSpells = 0
	DeltaDSpells = 0
	OldDSpells = [0]*7
	OldWSpells = [0]*9
	NewDSpells = [0]*7
	NewWSpells = [0]*9

	# calculate the new spells (results are stored in global variables)
	GetNewSpells(pc, Classes, Level, LevelDiff, Kit)

# this is handled by core
#		# setup class bonuses for this class
#		if IsMulti or IsDual or Kit == 0:
#			ABTable = CommonTables.ClassSkills.GetValue (TmpClassName, "ABILITIES")
#		else: # single-classed with a kit
#			ABTable = CommonTables.KitList.GetValue (str(Kit), "ABILITIES")
#
#		# add the abilites if we have a table to ref
#		if ABTable != "*" and GemRB.HasResource (ABTable, RES_2DA, 1):
#			GUICommon.AddClassAbilities (pc, ABTable, Level[i], LevelDiff[i])

	print("Actor CurrentLevels:" + str(actor.Levels()))
	print("Levels: " + str(Level) + "\tActor NextLevels: " + str(actor.NextLevels()))
	print("LevelDiffs: " + str(LevelDiff) + "\tActor LevelDiffs: " + str(actor.LevelDiffs()))

	#update our saves, thaco, hp and lore
	LUCommon.SetupSavingThrows (pc, Level)
	LUCommon.SetupThaco (pc, Level)
	LUCommon.SetupLore (pc, LevelDiff)
	LUCommon.SetupHP (pc, Level, LevelDiff)

	# we set up these labels so late, so they can show the new HP
	if GameCheck.IsBG1() or GameCheck.IsIWD1():
		# armorclass
		Label = LevelUpWindow.GetControl (0x10000057)
		Label.SetText (str (GemRB.GetPlayerStat (pc, IE_ARMORCLASS)))
		Label.SetTooltip (17183)

		# hp now
		Label = LevelUpWindow.GetControl (0x10000058)
		Label.SetText (str (GemRB.GetPlayerStat (pc, IE_HITPOINTS)))
		Label.SetTooltip (17184)

		# hp max
		Label = LevelUpWindow.GetControl (0x10000059)
		Label.SetText (str (GemRB.GetPlayerStat (pc, IE_MAXHITPOINTS)))
		Label.SetTooltip (17378)

	# use total levels for HLAs
	HLACount = 0
	if GameCheck.HasTOB(): # make sure SoA doesn't try to get it
		HLATable = GemRB.LoadTable("lunumab")
		# we need to check each level against a multi value (this is kinda screwy)
		if actor.multiclass:
			print("Actor HLA Names: " + str(["MULTI" + str(actor.NumClasses()) + name \
				for name in actor.ClassNames()]))
		else:
			print("Actor HLA Names: " + str(actor.ClassNames()))

		for i in range (NumClasses):
			if IsMulti:
				# get the row name for lookup ex. MULTI2FIGHTER, MULTI3THIEF
				MultiName = GUICommon.GetClassRowName (Classes[i], "class")
				MultiName = "MULTI" + str(NumClasses) + MultiName
			else:
				MultiName = ClassName

			# if we can't learn for this class, we can't learn at all
			FirstLevel = HLATable.GetValue (MultiName, "FIRST_LEVEL", GTV_INT)
			if Level[i] < FirstLevel:
				HLACount = 0
				break

			if (Level[i] - LevelDiff[i]) < FirstLevel:
				# count only from FirstLevel up
				HLACount += (Level[i] - FirstLevel + 1)
			else:
				HLACount += LevelDiff[i]

		# set values required by the hla level up code
		HLACount = HLACount // HLATable.GetValue (ClassName, "RATE", GTV_INT)
		GemRB.SetVar ("HLACount", HLACount)
	if GameCheck.IsBG2():
		HLAButton = LevelUpWindow.GetControl (126)
		if HLACount:
			HLAButton.SetText (4954)
			HLAButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, LevelUpHLAPress)
		else:
			HLAButton.SetFlags (IE_GUI_BUTTON_DISABLED, OP_OR)

	# setup our profs
	Level1 = []
	for i in range (len (Level)):
		Level1.append (Level[i]-LevelDiff[i])
	if GameCheck.IsBG2():
		LUProfsSelection.SetupProfsWindow (pc, LUProfsSelection.LUPROFS_TYPE_LEVELUP, LevelUpWindow, RedrawSkills, Level1, Level)
	else:
		LUProfsSelection.SetupProfsWindow (pc, LUProfsSelection.LUPROFS_TYPE_LEVELUP, LevelUpWindow, RedrawSkills, Level1, Level, 0, False, 0)
	NewProfPoints = GemRB.GetVar ("ProfsPointsLeft")

	#we autohide the skills and let SetupSkillsWindow show them if needbe
	for i in range (4):
		HideSkills (i)
	if GameCheck.IsBG2():
		LUSkillsSelection.SetupSkillsWindow (pc, LUSkillsSelection.LUSKILLS_TYPE_LEVELUP, LevelUpWindow, RedrawSkills, Level1, Level)
	else:
		LUSkillsSelection.SetupSkillsWindow (pc, LUSkillsSelection.LUSKILLS_TYPE_LEVELUP, LevelUpWindow, RedrawSkills, Level1, Level, 0, False)
	NewSkillPoints = GemRB.GetVar ("SkillPointsLeft")

	if GameCheck.IsBG2():
		TextAreaControl = LevelUpWindow.GetControl(110)
		TextAreaControl.SetText(GetLevelUpNews())
	else:
		TextAreaControl = LevelUpWindow.GetControl(42)
		TextAreaControl.SetText(GUIREC.GetStatOverview(pc, LevelDiff))

	RedrawSkills()
	LevelUpWindow.ShowModal (MODAL_SHADOW_GRAY)

	# if we have a sorcerer who can learn spells, we need to do spell selection
	for c in range(NumClasses):
		if Spellbook.HasSorcererBook (pc, Classes[c]) and DeltaWSpells > 0:
			LUSpellSelection.OpenSpellsWindow (pc, "SPLSRCKN", Level[c], LevelDiff[c])