Пример #1
0
def OnLoad():
    global SkillWindow, DoneButton, MyChar

    GemRB.LoadWindowPack("GUICG", 640, 480)
    SkillWindow = GemRB.LoadWindow(6)
    MyChar = GemRB.GetVar("Slot")

    Levels = [GemRB.GetPlayerStat (MyChar, IE_LEVEL), \
      GemRB.GetPlayerStat (MyChar, IE_LEVEL2), \
      GemRB.GetPlayerStat (MyChar, IE_LEVEL3)]
    LUSkillsSelection.SetupSkillsWindow (MyChar, \
     LUSkillsSelection.LUSKILLS_TYPE_CHARGEN, SkillWindow, RedrawSkills, [0,0,0], Levels)

    if not GemRB.GetVar("SkillPointsLeft"):  #skipping
        GemRB.SetNextScript("GUICG9")
        return

    BackButton = SkillWindow.GetControl(25)
    BackButton.SetText(15416)
    BackButton.SetFlags(IE_GUI_BUTTON_CANCEL, OP_OR)
    BackButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, BackPress)

    DoneButton = SkillWindow.GetControl(0)
    DoneButton.SetText(11973)
    DoneButton.SetFlags(IE_GUI_BUTTON_DEFAULT, OP_OR)
    DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, NextPress)
    DoneButton.SetState(IE_GUI_BUTTON_DISABLED)
    GemRB.SetRepeatClickFlags(GEM_RK_DISABLE, OP_NAND)

    RedrawSkills()
    SkillWindow.SetVisible(WINDOW_VISIBLE)
    return
Пример #2
0
def OnLoad():
	global SkillWindow, DoneButton

	SkillWindow = GemRB.LoadWindow(6, "GUICG")

	MyChar = GemRB.GetVar ("Slot")

	Levels = [GemRB.GetPlayerStat (MyChar, IE_LEVEL), \
			GemRB.GetPlayerStat (MyChar, IE_LEVEL2), \
			GemRB.GetPlayerStat (MyChar, IE_LEVEL3)]
	LUSkillsSelection.SetupSkillsWindow (MyChar, LUSkillsSelection.LUSKILLS_TYPE_CHARGEN, SkillWindow, RedrawSkills, [0,0,0], Levels,0,False)
	
	BackButton = SkillWindow.GetControl(25)
	BackButton.SetText(15416)
	BackButton.OnPress (lambda: CharGenCommon.back(SkillWindow))

	DoneButton = SkillWindow.GetControl(0)
	DoneButton.SetText(11973)
	DoneButton.MakeDefault()
	DoneButton.OnPress (NextPress)
	DoneButton.SetState(IE_GUI_BUTTON_DISABLED)

	RedrawSkills()
	SkillWindow.ShowModal(MODAL_SHADOW_NONE)
	return
Пример #3
0
def OnLoad():
    global SkillWindow, DoneButton, MyChar

    SkillWindow = GemRB.LoadWindow(6, "GUICG")
    CharGenCommon.PositionCharGenWin(SkillWindow)

    MyChar = GemRB.GetVar("Slot")

    Levels = [GemRB.GetPlayerStat (MyChar, IE_LEVEL), \
      GemRB.GetPlayerStat (MyChar, IE_LEVEL2), \
      GemRB.GetPlayerStat (MyChar, IE_LEVEL3)]
    LUSkillsSelection.SetupSkillsWindow (MyChar, \
     LUSkillsSelection.LUSKILLS_TYPE_CHARGEN, SkillWindow, RedrawSkills, [0,0,0], Levels)

    # can't be moved earlier as this var will be set in the setup call above
    if not GemRB.GetVar("SkillPointsLeft"):  #skipping
        if SkillWindow:
            SkillWindow.Unload()
        GemRB.SetNextScript("GUICG9")
        return

    BackButton = SkillWindow.GetControl(25)
    BackButton.SetText(15416)
    BackButton.MakeEscape()
    BackButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, BackPress)

    DoneButton = SkillWindow.GetControl(0)
    DoneButton.SetText(11973)
    DoneButton.MakeDefault()
    DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, NextPress)
    DoneButton.SetDisabled(True)

    RedrawSkills()
    SkillWindow.Focus()
    return
Пример #4
0
def OnLoad():
    global SkillWindow, DoneButton

    if GUICommon.CloseOtherWindow(OnLoad):
        if (SkillWindow):
            SkillWindow.Unload()
            SkillWindow = None
        return

    GemRB.LoadWindowPack("GUICG", 640, 480)
    SkillWindow = GemRB.LoadWindow(6)

    MyChar = GemRB.GetVar("Slot")

    Levels = [GemRB.GetPlayerStat (MyChar, IE_LEVEL), \
      GemRB.GetPlayerStat (MyChar, IE_LEVEL2), \
      GemRB.GetPlayerStat (MyChar, IE_LEVEL3)]
    LUSkillsSelection.SetupSkillsWindow(
        MyChar, LUSkillsSelection.LUSKILLS_TYPE_CHARGEN, SkillWindow,
        RedrawSkills, [0, 0, 0], Levels, 0, False)

    BackButton = SkillWindow.GetControl(25)
    BackButton.SetText(15416)
    BackButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, CharGenCommon.BackPress)

    DoneButton = SkillWindow.GetControl(0)
    DoneButton.SetText(11973)
    DoneButton.SetFlags(IE_GUI_BUTTON_DEFAULT, OP_OR)
    DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, NextPress)
    DoneButton.SetState(IE_GUI_BUTTON_DISABLED)
    GemRB.SetRepeatClickFlags(GEM_RK_DISABLE, OP_NAND)

    RedrawSkills()
    SkillWindow.ShowModal(MODAL_SHADOW_NONE)
    return
Пример #5
0
def OpenSkillsWindow():
    """Opens the skills selection window.

	This will allow the selection of thief skills for appropriate classes, or
	auto-assign them for classes that recieve skills based on level."""

    global DCSkillsWindow, DCSkillsDoneButton

    DCSkillsWindow = GemRB.LoadWindow(7)
    if GameCheck.IsBG2():
        LUSkillsSelection.SetupSkillsWindow (pc, \
         LUSkillsSelection.LUSKILLS_TYPE_DUALCLASS, DCSkillsWindow, DCSkillsRedraw, classid=NewClassId)
    else:
        LUSkillsSelection.SetupSkillsWindow (pc, \
         LUSkillsSelection.LUSKILLS_TYPE_DUALCLASS, DCSkillsWindow, \
         DCSkillsRedraw, [0,0,0], [1,1,1], NewClassId, False)

    #just go back if we can't assign skills
    if GemRB.GetVar("SkillPointsLeft") <= 0:
        DCSkillsWindow.Close()
        return

    # setup the back and done buttons
    BackButton = DCSkillsWindow.GetControl(24)
    BackButton.SetText(15416)
    BackButton.MakeEscape()
    BackButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, DCSkillsBackPress)

    DCSkillsDoneButton = DCSkillsWindow.GetControl(25)
    DCSkillsDoneButton.SetText(11973)
    DCSkillsDoneButton.MakeDefault()
    DCSkillsDoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, DCSkillsDonePress)
    DCSkillsDoneButton.SetState(IE_GUI_BUTTON_DISABLED)

    # setup the default text area
    TextArea = DCSkillsWindow.GetControl(22)
    TextArea.SetText(17248)

    DCSkillsWindow.ShowModal(MODAL_SHADOW_GRAY)
    DCSkillsRedraw()
    return
Пример #6
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])
Пример #7
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])
Пример #8
0
def OpenLevelUpWindow ():
	global LevelUpWindow
	global SavThrows
	global HPGained
	global WeapProfType, CurrWeapProf, WeapProfGained
	global NumOfPrimLevUp, NumOfSecoLevUp

	GemRB.HideGUI ()

	if LevelUpWindow != None:
		if LevelUpWindow:
			LevelUpWindow.Unload ()
		LevelUpWindow = None
		GemRB.SetVar ("FloatWindow", -1)

		GemRB.UnhideGUI()
		return

	GemRB.LoadWindowPack ("GUIREC") # since we get called from NewLife
	LevelUpWindow = Window = GemRB.LoadWindow (4)
	GemRB.SetVar ("FloatWindow", LevelUpWindow.ID)

	# Accept
	Button = Window.GetControl (0)
	Button.SetText (4192)
	Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, AcceptLevelUp)

	pc = GemRB.GameGetSelectedPCSingle ()

	# These are used to identify Nameless One
	BioTable = GemRB.LoadTable ("bios")
	Specific = GemRB.GetPlayerStat (pc, IE_SPECIFIC)
	AvatarName = BioTable.GetRowName (Specific+1)

	# These will be used for saving throws
	SavThrUpdated = False
	SavThrows = [0,0,0,0,0]
	SavThrows[0] = GemRB.GetPlayerStat (pc, IE_SAVEVSDEATH)
	SavThrows[1] = GemRB.GetPlayerStat (pc, IE_SAVEVSWANDS)
	SavThrows[2] = GemRB.GetPlayerStat (pc, IE_SAVEVSPOLY)
	SavThrows[3] = GemRB.GetPlayerStat (pc, IE_SAVEVSBREATH)
	SavThrows[4] = GemRB.GetPlayerStat (pc, IE_SAVEVSSPELL)

	HPGained = 0
	ConHPBon = 0
	Thac0Updated = False
	Thac0 = 0
	WeapProfGained = 0

	ClasWeapTable = GemRB.LoadTable ("weapprof")
	WeapProfType = -1
	CurrWeapProf = -1
	#This does not apply to Nameless since he uses unused slots system
	#Nameless is Specific == 1
	if Specific != "1":
		# Searching for the column name where value is 1
		for i in range (5):
			WeapProfName = ClasWeapTable.GetRowName (i)
			value = ClasWeapTable.GetValue (WeapProfName, AvatarName)
			if value == 1:
				WeapProfType = i
				break

	if WeapProfType!=-1:
		CurrWeapProf = GemRB.GetPlayerStat (pc, IE_PROFICIENCYBASTARDSWORD + WeapProfType)

	# Recording this avatar's current proficiency level
	# Since Nameless one is not covered, hammer and club can't occur
	# What is the avatar's class (Which we can use to lookup XP)
	Class = GUICommon.GetClassRowName (pc)

	# name
	Label = Window.GetControl (0x10000000)
	Label.SetText (GemRB.GetPlayerName (pc, 1))

	# class
	Label = Window.GetControl (0x10000001)
	Label.SetText (CommonTables.Classes.GetValue (Class, "NAME_REF"))

	# Armor Class
	Label = Window.GetControl (0x10000023)
	Label.SetText (str (GemRB.GetPlayerStat (pc, IE_ARMORCLASS)))

	# Thief Skills
	# For now we shall set them to the current levels and disable the increment buttons
	# Points Left
	Label = Window.GetControl (0x10000006)
	Label.SetText ('0')
	# Stealth
	Label = Window.GetControl (0x10000008)
	Label.SetText (str (GemRB.GetPlayerStat (pc, IE_STEALTH)) + '%')
	# Detect Traps
	Label = Window.GetControl (0x1000000A)
	Label.SetText (str (GemRB.GetPlayerStat (pc, IE_TRAPS)) + '%')
	# Pick Pockets
	Label = Window.GetControl (0x1000000C)
	Label.SetText (str (GemRB.GetPlayerStat (pc, IE_PICKPOCKET)) + '%')
	# Open Doors
	Label = Window.GetControl (0x1000000E)
	Label.SetText (str (GemRB.GetPlayerStat (pc, IE_LOCKPICKING)) + '%')
	# Plus and Minus buttons
	LUSkillsSelection.SetupSkillsWindow (pc, LUSkillsSelection.LUSKILLS_TYPE_LEVELUP, LevelUpWindow, RedrawSkills, [0,0,0], [1,1,1], 0, False)
	RedrawSkills()

	# Is avatar multi-class?
	if avatar_header['SecoLevel'] == 0:
		# avatar is single class
		# What will be avatar's next level?
		NextLevel = avatar_header['PrimLevel'] + 1
		while avatar_header['XP'] >= GetNextLevelExp (NextLevel, Class):
			NextLevel = NextLevel + 1
		NumOfPrimLevUp = NextLevel - avatar_header['PrimLevel'] # How many levels did we go up?

		# Is avatar Nameless One?
		if Specific == "1":
			# Saving Throws
			# Nameless One gets the best possible throws from all the classes except Priest
			FigSavThrTable = GemRB.LoadTable ("SAVEWAR")
			MagSavThrTable = GemRB.LoadTable ("SAVEWIZ")
			ThiSavThrTable = GemRB.LoadTable ("SAVEROG")
			# For Nameless, we also need to know his levels in every class, so that we pick
			# the right values from the corresponding tables. Also we substract one, so
			# that we may use them as column indices in tables.
			FighterLevel = GemRB.GetPlayerStat (pc, IE_LEVEL) - 1
			MageLevel = GemRB.GetPlayerStat (pc, IE_LEVEL2) - 1
			ThiefLevel = GemRB.GetPlayerStat (pc, IE_LEVEL3) - 1
			# this is the constitution bonus type for this level
			CONType = 1
			# We are leveling up one of those levels. Therefore, one of them has to be updated.
			if avatar_header['PrimClass'] == "FIGHTER":
				FighterLevel = NextLevel - 1
				CONType = 0
			elif avatar_header['PrimClass'] == "MAGE":
				MageLevel = NextLevel - 1
			else:
				ThiefLevel = NextLevel - 1

			ConHPBon = GetConHPBonus (pc, NumOfPrimLevUp, 0, CONType)
			# Now we need to update the saving throws with the best values from those tables.
			# The smaller the number, the better saving throw it is.
			# We also need to check if any of the levels are larger than 21, since
			# after that point the table runs out, and the throws remain the
			# same
			if FighterLevel < 21:
				for i in range (5):
					Throw = FigSavThrTable.GetValue (i, FighterLevel)
					if Throw < SavThrows[i]:
						SavThrows[i] = Throw
						SavThrUpdated = True
			if MageLevel < 21:
				for i in range (5):
					Throw = MagSavThrTable.GetValue (i, MageLevel)
					if Throw < SavThrows[i]:
						SavThrows[i] = Throw
						SavThrUpdated = True
			if ThiefLevel < 21:
				for i in range (5):
					Throw = ThiSavThrTable.GetValue (i, ThiefLevel)
					if Throw < SavThrows[i]:
						SavThrows[i] = Throw
						SavThrUpdated = True
			# Cleaning up
		else:
			#How many weapon procifiencies we get
			for i in range (NumOfPrimLevUp):
				if HasGainedWeapProf (pc, CurrWeapProf + WeapProfGained, avatar_header['PrimLevel'] + i, avatar_header['PrimClass']):
					WeapProfGained += 1

			# Saving Throws
			# Loading the right saving throw table
			SavThrTable = GemRB.LoadTable (CommonTables.Classes.GetValue (Class, "SAVE"))
			# Updating the current saving throws. They are changed only if the
			# new ones are better than current. The smaller the number, the better.
			# We need to substract one from the NextLevel, so that we get right values.
			# We also need to check if NextLevel is larger than 21, since after that point
			# the table runs out, and the throws remain the same 
			if NextLevel < 22:
				for i in range (5):
					Throw = SavThrTable.GetValue (i, NextLevel-1)
					if Throw < SavThrows[i]:
						SavThrows[i] = Throw
						SavThrUpdated = True
			# Cleaning Up

			# Hit Points Gained and Hit Points from Constitution Bonus
			for i in range (NumOfPrimLevUp):
				HPGained = HPGained + GetSingleClassHP (Class, avatar_header['PrimLevel'])

			if avatar_header['PrimClass'] == "FIGHTER":
				CONType = 0
			else:
				CONType = 1
			ConHPBon = GetConHPBonus (pc, NumOfPrimLevUp, 0, CONType)

			# Thac0
			Thac0 = GetThac0 (Class, NextLevel)
			# Is the new thac0 better than old? (The smaller, the better)
			if Thac0 < GemRB.GetPlayerStat (pc, IE_TOHIT, 1):
				Thac0Updated = True

	else:
		# avatar is multi class
		# we have only fighter/X multiclasses, so this
		# part is a bit hardcoded
		PrimNextLevel = 0
		SecoNextLevel = 0
		NumOfPrimLevUp = 0
		NumOfSecoLevUp = 0

		# What will be avatar's next levels?
		PrimNextLevel = avatar_header['PrimLevel']
		while avatar_header['XP'] >= GetNextLevelExp (PrimNextLevel, "FIGHTER"):
			PrimNextLevel = PrimNextLevel + 1
		# How many primary levels did we go up?
		NumOfPrimLevUp = PrimNextLevel - avatar_header['PrimLevel']

		for i in range (NumOfPrimLevUp):
			if HasGainedWeapProf (pc, CurrWeapProf + WeapProfGained, avatar_header['PrimLevel'] + i, avatar_header['PrimClass']):
				WeapProfGained += 1

		# Saving Throws
		FigSavThrTable = GemRB.LoadTable ("SAVEWAR")
		if PrimNextLevel < 22:
			for i in range (5):
				Throw = FigSavThrTable.GetValue (i, PrimNextLevel - 1)
				if Throw < SavThrows[i]:
					SavThrows[i] = Throw
					SavThrUpdated = True
		# Which multi class is it?
		if GemRB.GetPlayerStat (pc, IE_CLASS) == 7:
			# avatar is Fighter/Mage (Dak'kon)
			Class = "MAGE"
			SavThrTable = GemRB.LoadTable ("SAVEWIZ")
		else:
			# avatar is Fighter/Thief (Annah)
			Class = "THIEF"
			SavThrTable = GemRB.LoadTable ("SAVEROG")
		
		SecoNextLevel = avatar_header['SecoLevel']
		while avatar_header['XP'] >= GetNextLevelExp (SecoNextLevel, Class):
			SecoNextLevel = SecoNextLevel + 1
		# How many secondary levels did we go up?
		NumOfSecoLevUp = SecoNextLevel - avatar_header['SecoLevel']
		if SecoNextLevel < 22:
			for i in range (5):
				Throw = SavThrTable.GetValue (i, SecoNextLevel - 1)
				if Throw < SavThrows[i]:
					SavThrows[i] = Throw
					SavThrUpdated = True

		# Hit Points Gained and Hit Points from Constitution Bonus (multiclass)
		for i in range (NumOfPrimLevUp):
			HPGained = HPGained + GetSingleClassHP ("FIGHTER", avatar_header['PrimLevel'])/2

		for i in range (NumOfSecoLevUp):
			HPGained = HPGained + GetSingleClassHP (Class, avatar_header['SecoLevel'])/2
		ConHPBon = GetConHPBonus (pc, NumOfPrimLevUp, NumOfSecoLevUp, 2)

		# Thac0
		# Multi class use the primary class level to determine Thac0
		Thac0 = GetThac0 (Class, PrimNextLevel)
		# Is the new thac0 better than old? (The smaller the better)
		if Thac0 < GemRB.GetPlayerStat (pc, IE_TOHIT, 1):
			Thac0Updated = True


	# Displaying the saving throws
	# Death
	Label = Window.GetControl (0x10000019)
	Label.SetText (str (SavThrows[0]))
	# Wand
	Label = Window.GetControl (0x1000001B)
	Label.SetText (str (SavThrows[1]))
	# Polymorph
	Label = Window.GetControl (0x1000001D)
	Label.SetText (str (SavThrows[2]))
	# Breath
	Label = Window.GetControl (0x1000001F)
	Label.SetText (str (SavThrows[3]))
	# Spell
	Label = Window.GetControl (0x10000021)
	Label.SetText (str (SavThrows[4]))

	FinalCurHP = GemRB.GetPlayerStat (pc, IE_HITPOINTS) + HPGained
	FinalMaxHP = GemRB.GetPlayerStat (pc, IE_MAXHITPOINTS) + HPGained

	# Current HP
	Label = Window.GetControl (0x10000025)
	Label.SetText (str (FinalCurHP))

	# Max HP
	Label = Window.GetControl (0x10000027)
	Label.SetText (str (FinalMaxHP))

	# Displaying level up info
	overview = ""
	if CurrWeapProf!=-1 and WeapProfGained>0:
		overview = overview + GemRB.GetString (38715) + '\n' + '+' + str (WeapProfGained) + '\n'

	overview = overview + str (HPGained) + " " + GemRB.GetString (38713) + '\n'
	overview = overview + str (ConHPBon) + " " + GemRB.GetString (38727) + '\n'

	if SavThrUpdated:
		overview = overview + GemRB.GetString (38719) + '\n'
	if Thac0Updated:
		GemRB.SetPlayerStat (pc, IE_TOHIT, Thac0)
		overview = overview + GemRB.GetString (38718) + '\n'

	Text = Window.GetControl (3)
	Text.SetText (overview)

	GemRB.UnhideGUI ()
	Window.ShowModal (MODAL_SHADOW_GRAY)
Пример #9
0
def OpenLevelUpWindow():
    global LevelUpWindow
    global SavThrows
    global HPGained
    global WeapProfType, CurrWeapProf, WeapProfGained
    global NumOfPrimLevUp, NumOfSecoLevUp

    global LevelDiff, Level, Classes, NumClasses

    LevelUpWindow = Window = GemRB.LoadWindow(
        4, "GUIREC")  # since we get called from NewLife

    # Accept
    Button = Window.GetControl(0)
    Button.SetText(4192)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, AcceptLevelUp)

    pc = GemRB.GameGetSelectedPCSingle()

    # These are used to identify Nameless One
    BioTable = GemRB.LoadTable("bios")
    Specific = GemRB.GetPlayerStat(pc, IE_SPECIFIC)
    AvatarName = BioTable.GetRowName(Specific)

    # These will be used for saving throws
    SavThrUpdated = False
    SavThrows = [0, 0, 0, 0, 0]
    SavThrows[0] = GemRB.GetPlayerStat(pc, IE_SAVEVSDEATH)
    SavThrows[1] = GemRB.GetPlayerStat(pc, IE_SAVEVSWANDS)
    SavThrows[2] = GemRB.GetPlayerStat(pc, IE_SAVEVSPOLY)
    SavThrows[3] = GemRB.GetPlayerStat(pc, IE_SAVEVSBREATH)
    SavThrows[4] = GemRB.GetPlayerStat(pc, IE_SAVEVSSPELL)

    HPGained = 0
    ConHPBon = 0
    Thac0Updated = False
    Thac0 = 0
    WeapProfGained = 0

    WeapProfType = -1
    CurrWeapProf = 0

    # Count the number of existing weapon procifiencies
    if GUICommon.IsNamelessOne(pc):
        # TNO: Count the total amount of unassigned proficiencies
        CurrWeapProf = GemRB.GetPlayerStat(pc, IE_FREESLOTS)
    else:
        # Scan the weapprof table for the characters favoured weapon proficiency (WeapProfType)
        # This does not apply to Nameless since he uses unused slots system
        for i in range(6):
            WeapProfName = CommonTables.WeapProfs.GetRowName(i)
            value = CommonTables.WeapProfs.GetValue(WeapProfName, AvatarName)
            if value == 1:
                WeapProfType = i
                break

    for i in range(6):
        CurrWeapProf += GemRB.GetPlayerStat(pc, IE_PROFICIENCYBASTARDSWORD + i)

    # What is the avatar's class (Which we can use to lookup XP)
    Class = GUICommon.GetClassRowName(pc)

    # name
    Label = Window.GetControl(0x10000000)
    Label.SetText(GemRB.GetPlayerName(pc, 1))

    # class
    Label = Window.GetControl(0x10000001)
    Label.SetText(CommonTables.Classes.GetValue(Class, "NAME_REF"))

    # Armor Class
    Label = Window.GetControl(0x10000023)
    Label.SetText(str(GemRB.GetPlayerStat(pc, IE_ARMORCLASS)))

    # 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

    if not IsMulti:
        NumClasses = 1
        Classes = [GemRB.GetPlayerStat(pc, IE_CLASS)]

    if GUICommon.IsNamelessOne(pc):
        # Override the multiclass info for TNO
        IsMulti = 1
        NumClasses = 3
        # Fighter, Mage, Thief ID
        Classes = [2, 1, 4]

    Level = LUCommon.GetNextLevels(pc, Classes)
    LevelDiff = LUCommon.GetLevelDiff(pc, Level)

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

    # Thief Skills
    Level1 = []
    for i in range(len(Level)):
        Level1.append(Level[i] - LevelDiff[i])
    LUSkillsSelection.SetupSkillsWindow(
        pc, LUSkillsSelection.LUSKILLS_TYPE_LEVELUP, LevelUpWindow,
        RedrawSkills, Level1, Level, 0, False)
    RedrawSkills()

    # Is avatar multi-class?
    if avatar_header['SecoLevel'] == 0:
        # avatar is single class
        # What will be avatar's next level?
        NextLevel = avatar_header['PrimLevel'] + 1
        while avatar_header['XP'] >= GetNextLevelExp(NextLevel, Class):
            NextLevel = NextLevel + 1
        NumOfPrimLevUp = NextLevel - avatar_header[
            'PrimLevel']  # How many levels did we go up?

        #How many weapon procifiencies we get
        for i in range(NumOfPrimLevUp):
            WeapProfGained += GainedWeapProfs(pc,
                                              CurrWeapProf + WeapProfGained,
                                              avatar_header['PrimLevel'] + i,
                                              AvatarName)

        # Hit Points Gained and Hit Points from Constitution Bonus
        for i in range(NumOfPrimLevUp):
            HPGained = HPGained + GetSingleClassHP(Class,
                                                   avatar_header['PrimLevel'])
        if Class == "FIGHTER":
            CONType = 0
        else:
            CONType = 1
        ConHPBon = GetConHPBonus(pc, NumOfPrimLevUp, 0, CONType)

        # Thac0
        Thac0 = GetThac0(Class, NextLevel)
        # Is the new thac0 better than old? (The smaller, the better)
        if Thac0 < GemRB.GetPlayerStat(pc, IE_TOHIT, 1):
            Thac0Updated = True

        # Saving Throws
        if GUICommon.IsNamelessOne(pc):
            # Nameless One always uses the best possible save from each class
            FigSavThrTable = GemRB.LoadTable("SAVEWAR")
            MagSavThrTable = GemRB.LoadTable("SAVEWIZ")
            ThiSavThrTable = GemRB.LoadTable("SAVEROG")

            FighterLevel = GemRB.GetPlayerStat(pc, IE_LEVEL) - 1
            MageLevel = GemRB.GetPlayerStat(pc, IE_LEVEL2) - 1
            ThiefLevel = GemRB.GetPlayerStat(pc, IE_LEVEL3) - 1

            # We are leveling up one of those levels. Therefore, one of them has to be updated.
            if Class == "FIGHTER":
                FighterLevel = NextLevel - 1
            elif Class == "MAGE":
                MageLevel = NextLevel - 1
            else:
                ThiefLevel = NextLevel - 1

            # Now we need to update the saving throws with the best values from those tables.
            # The smaller the number, the better saving throw it is.
            # We also need to check if any of the levels are larger than 21, since
            # after that point the table runs out, and the throws remain the
            # same
            if FighterLevel < 21:
                for i in range(5):
                    Throw = FigSavThrTable.GetValue(i, FighterLevel)
                    if Throw < SavThrows[i]:
                        SavThrows[i] = Throw
                        SavThrUpdated = True
            if MageLevel < 21:
                for i in range(5):
                    Throw = MagSavThrTable.GetValue(i, MageLevel)
                    if Throw < SavThrows[i]:
                        SavThrows[i] = Throw
                        SavThrUpdated = True
            if ThiefLevel < 21:
                for i in range(5):
                    Throw = ThiSavThrTable.GetValue(i, ThiefLevel)
                    if Throw < SavThrows[i]:
                        SavThrows[i] = Throw
                        SavThrUpdated = True
        else:
            SavThrTable = GemRB.LoadTable(
                CommonTables.Classes.GetValue(Class, "SAVE"))
            # Updating the current saving throws. They are changed only if the
            # new ones are better than current. The smaller the number, the better.
            # We need to substract one from the NextLevel, so that we get right values.
            # We also need to check if NextLevel is larger than 21, since after that point
            # the table runs out, and the throws remain the same
            if NextLevel < 22:
                for i in range(5):
                    Throw = SavThrTable.GetValue(i, NextLevel - 1)
                    if Throw < SavThrows[i]:
                        SavThrows[i] = Throw
                        SavThrUpdated = True

    else:
        # avatar is multi class
        # we have only fighter/X multiclasses, so this
        # part is a bit hardcoded
        PrimNextLevel = 0
        SecoNextLevel = 0
        NumOfPrimLevUp = 0
        NumOfSecoLevUp = 0

        # What will be avatar's next levels?
        PrimNextLevel = avatar_header['PrimLevel']
        while avatar_header['XP'] >= GetNextLevelExp(PrimNextLevel, "FIGHTER"):
            PrimNextLevel = PrimNextLevel + 1
        # How many primary levels did we go up?
        NumOfPrimLevUp = PrimNextLevel - avatar_header['PrimLevel']

        for i in range(NumOfPrimLevUp):
            WeapProfGained += GainedWeapProfs(pc,
                                              CurrWeapProf + WeapProfGained,
                                              avatar_header['PrimLevel'] + i,
                                              AvatarName)

        # Saving Throws
        FigSavThrTable = GemRB.LoadTable("SAVEWAR")
        if PrimNextLevel < 22:
            for i in range(5):
                Throw = FigSavThrTable.GetValue(i, PrimNextLevel - 1)
                if Throw < SavThrows[i]:
                    SavThrows[i] = Throw
                    SavThrUpdated = True
        # Which multi class is it?
        if GemRB.GetPlayerStat(pc, IE_CLASS) == 7:
            # avatar is Fighter/Mage (Dak'kon)
            Class = "MAGE"
            SavThrTable = GemRB.LoadTable("SAVEWIZ")
        else:
            # avatar is Fighter/Thief (Annah)
            Class = "THIEF"
            SavThrTable = GemRB.LoadTable("SAVEROG")

        SecoNextLevel = avatar_header['SecoLevel']
        while avatar_header['XP'] >= GetNextLevelExp(SecoNextLevel, Class):
            SecoNextLevel = SecoNextLevel + 1
        # How many secondary levels did we go up?
        NumOfSecoLevUp = SecoNextLevel - avatar_header['SecoLevel']
        if SecoNextLevel < 22:
            for i in range(5):
                Throw = SavThrTable.GetValue(i, SecoNextLevel - 1)
                if Throw < SavThrows[i]:
                    SavThrows[i] = Throw
                    SavThrUpdated = True

        # Hit Points Gained and Hit Points from Constitution Bonus (multiclass)
        for i in range(NumOfPrimLevUp):
            HPGained = HPGained + GetSingleClassHP(
                "FIGHTER", avatar_header['PrimLevel']) / 2

        for i in range(NumOfSecoLevUp):
            HPGained = HPGained + GetSingleClassHP(
                Class, avatar_header['SecoLevel']) / 2
        ConHPBon = GetConHPBonus(pc, NumOfPrimLevUp, NumOfSecoLevUp, 2)

        # Thac0
        # Multi class use the primary class level to determine Thac0
        Thac0 = GetThac0(Class, PrimNextLevel)
        # Is the new thac0 better than old? (The smaller the better)
        if Thac0 < GemRB.GetPlayerStat(pc, IE_TOHIT, 1):
            Thac0Updated = True

    # Displaying the saving throws
    # Death
    Label = Window.GetControl(0x10000019)
    Label.SetText(str(SavThrows[0]))
    # Wand
    Label = Window.GetControl(0x1000001B)
    Label.SetText(str(SavThrows[1]))
    # Polymorph
    Label = Window.GetControl(0x1000001D)
    Label.SetText(str(SavThrows[2]))
    # Breath
    Label = Window.GetControl(0x1000001F)
    Label.SetText(str(SavThrows[3]))
    # Spell
    Label = Window.GetControl(0x10000021)
    Label.SetText(str(SavThrows[4]))

    FinalCurHP = GemRB.GetPlayerStat(pc, IE_HITPOINTS) + HPGained
    FinalMaxHP = GemRB.GetPlayerStat(pc, IE_MAXHITPOINTS) + HPGained

    # Current HP
    Label = Window.GetControl(0x10000025)
    Label.SetText(str(FinalCurHP))

    # Max HP
    Label = Window.GetControl(0x10000027)
    Label.SetText(str(FinalMaxHP))

    # Displaying level up info
    overview = ""
    if CurrWeapProf != -1 and WeapProfGained > 0:
        overview = overview + GemRB.GetString(38715) + '\n' + '+' + str(
            WeapProfGained) + '\n'

    overview = overview + str(HPGained) + " " + GemRB.GetString(38713) + '\n'
    overview = overview + str(ConHPBon) + " " + GemRB.GetString(38727) + '\n'

    if SavThrUpdated:
        overview = overview + GemRB.GetString(38719) + '\n'
    if Thac0Updated:
        GemRB.SetPlayerStat(pc, IE_TOHIT, Thac0)
        overview = overview + GemRB.GetString(38718) + '\n'

    Text = Window.GetControl(3)
    Text.SetText(overview)

    Window.ShowModal(MODAL_SHADOW_GRAY)