Esempio n. 1
0
def AcceptLevelUp():
	OpenLevelUpWindow()
	#do level up
	pc = GemRB.GameGetSelectedPCSingle ()
	GemRB.SetPlayerStat (pc, IE_SAVEVSDEATH, SavThrows[0])
	GemRB.SetPlayerStat (pc, IE_SAVEVSWANDS, SavThrows[1])
	GemRB.SetPlayerStat (pc, IE_SAVEVSPOLY, SavThrows[2])
	GemRB.SetPlayerStat (pc, IE_SAVEVSBREATH, SavThrows[3])
	GemRB.SetPlayerStat (pc, IE_SAVEVSSPELL, SavThrows[4])
	oldhp = GemRB.GetPlayerStat (pc, IE_MAXHITPOINTS, 1)
	GemRB.SetPlayerStat (pc, IE_MAXHITPOINTS, HPGained+oldhp)
	oldhp = GemRB.GetPlayerStat (pc, IE_HITPOINTS, 1)
	GemRB.SetPlayerStat (pc, IE_HITPOINTS, HPGained+oldhp)
	#increase weapon proficiency if needed
	if WeapProfType!=-1:
		GemRB.SetPlayerStat (pc, WeapProfType, CurrWeapProf + WeapProfGained )
	Specific = GemRB.GetPlayerStat (pc, IE_SPECIFIC)
	if Specific == 1:
		#TODO:
		#the nameless one is dual classed
		#so we have to determine which level to increase
		GemRB.SetPlayerStat (pc, IE_LEVEL, GemRB.GetPlayerStat (pc, IE_LEVEL)+NumOfPrimLevUp)
	else:
		GemRB.SetPlayerStat (pc, IE_LEVEL, GemRB.GetPlayerStat (pc, IE_LEVEL)+NumOfPrimLevUp)
		if avatar_header['SecoLevel'] != 0:
			GemRB.SetPlayerStat (pc, IE_LEVEL2, GemRB.GetPlayerStat (pc, IE_LEVEL2)+NumOfSecoLevUp)
	
	LUSkillsSelection.SkillsSave (pc)
	UpdateRecordsWindow ()
Esempio n. 2
0
def AcceptLevelUp():
    #do level up
    pc = GemRB.GameGetSelectedPCSingle()
    GemRB.SetPlayerStat(pc, IE_SAVEVSDEATH, SavThrows[0])
    GemRB.SetPlayerStat(pc, IE_SAVEVSWANDS, SavThrows[1])
    GemRB.SetPlayerStat(pc, IE_SAVEVSPOLY, SavThrows[2])
    GemRB.SetPlayerStat(pc, IE_SAVEVSBREATH, SavThrows[3])
    GemRB.SetPlayerStat(pc, IE_SAVEVSSPELL, SavThrows[4])
    oldhp = GemRB.GetPlayerStat(pc, IE_MAXHITPOINTS, 1)
    GemRB.SetPlayerStat(pc, IE_MAXHITPOINTS, HPGained + oldhp)
    oldhp = GemRB.GetPlayerStat(pc, IE_HITPOINTS, 1)
    GemRB.SetPlayerStat(pc, IE_HITPOINTS, HPGained + oldhp)

    # Weapon Proficiencies
    if WeapProfType != -1:
        # Companion NPC's get points added directly to their chosen weapon
        GemRB.SetPlayerStat(pc, IE_PROFICIENCYBASTARDSWORD + WeapProfType,
                            CurrWeapProf + WeapProfGained)
    else:
        # TNO has points added to the "Unused Slots" dummy proficiency
        freeSlots = GemRB.GetPlayerStat(pc, IE_FREESLOTS)
        GemRB.SetPlayerStat(pc, IE_FREESLOTS, freeSlots + WeapProfGained)

    SwitcherClass = GUICommon.NamelessOneClass(pc)
    if SwitcherClass:
        # Handle saving of TNO class level in the correct CRE stat
        Levels = {
            "FIGHTER": GemRB.GetPlayerStat(pc, IE_LEVEL),
            "MAGE": GemRB.GetPlayerStat(pc, IE_LEVEL2),
            "THIEF": GemRB.GetPlayerStat(pc, IE_LEVEL3)
        }
        LevelStats = {
            "FIGHTER": IE_LEVEL,
            "MAGE": IE_LEVEL2,
            "THIEF": IE_LEVEL3
        }
        GemRB.SetPlayerStat(pc, LevelStats[SwitcherClass],
                            Levels[SwitcherClass] + NumOfPrimLevUp)
    else:
        GemRB.SetPlayerStat(pc, IE_LEVEL,
                            GemRB.GetPlayerStat(pc, IE_LEVEL) + NumOfPrimLevUp)
        if avatar_header['SecoLevel'] != 0:
            GemRB.SetPlayerStat(
                pc, IE_LEVEL2,
                GemRB.GetPlayerStat(pc, IE_LEVEL2) + NumOfSecoLevUp)

    LUSkillsSelection.SkillsSave(pc)

    # Spells
    LevelUp.pc = pc
    LevelUp.Classes = Classes
    LevelUp.NumClasses = NumClasses
    # (we need to override the globals this function uses there since they wouldn't have been set)
    LevelUp.SaveNewSpells()

    LevelUpWindow.Close()
    NewLife.OpenLUStatsWindow(True, sum(LevelDiff))
Esempio n. 3
0
def NextPress():
    if SkillWindow:
        SkillWindow.Unload()
    # save all skills

    LUSkillsSelection.SkillsSave(MyChar)

    GemRB.SetNextScript("GUICG9")  #weapon proficiencies
    return
Esempio n. 4
0
def NextPress():
    if SkillWindow:
        SkillWindow.Unload()
    # save all skills

    LUSkillsSelection.SkillsSave(MyChar)

    GemRB.SetRepeatClickFlags(GEM_RK_DISABLE, OP_OR)
    GemRB.SetNextScript("GUICG9")  #weapon proficiencies
    return
Esempio n. 5
0
def LevelUpDonePress():
    """Updates the PC with the new choices.

	Closes the window when finished."""
    import GUICommonWindows
    import GUIREC

    # proficiencies
    LUProfsSelection.ProfsSave(pc)

    # skills
    LUSkillsSelection.SkillsSave(pc)

    # level
    if DualSwap:  # swap the IE_LEVELs around if a backward dual
        GemRB.SetPlayerStat(pc, IE_LEVEL2, Level[0])
        GemRB.SetPlayerStat(pc, IE_LEVEL, Level[1])
    else:
        GemRB.SetPlayerStat(pc, IE_LEVEL, Level[0])
        GemRB.SetPlayerStat(pc, IE_LEVEL2, Level[1])
    GemRB.SetPlayerStat(pc, IE_LEVEL3, Level[2])

    print("Levels:", Level[0], "/", Level[1], "/", Level[2])

    # spells
    SaveNewSpells()

    # hlas
    # level, xp and other stuff by the core?

    # 5261 - Regained abilities from inactive class
    if IsDual:  # we're dual classed
        print("activation?")
        if (Level[0] - LevelDiff[0]) <= Level[1] and Level[0] > Level[
                1]:  # our new classes now surpasses our old class
            print("reactivating base class")
            ReactivateBaseClass()

    if LevelUpWindow:
        LevelUpWindow.Close()
    GUICommonWindows.UpdatePortraitWindow()
    return
Esempio n. 6
0
def unsetSkill():
    import LUSkillsSelection
    MyChar = GemRB.GetVar("Slot")
    LUSkillsSelection.SkillsNullify()
    LUSkillsSelection.SkillsSave(MyChar)
Esempio n. 7
0
def NextPress():
	SkillWindow.Close()
	MyChar = GemRB.GetVar ("Slot")
	LUSkillsSelection.SkillsSave(MyChar)
	CharGenCommon.next()
Esempio n. 8
0
def DCMainDonePress():
    """Saves our dualclass changes and closes the window.

	This de-activates our old class and readjusts the basic actor stats, such as
	THAC0, spell casting, proficiencies, and so forth, to the new class."""
    import GUIREC
    global ClassName

    # save our proficiencies
    LUProfsSelection.ProfsSave(pc, LUProfsSelection.LUPROFS_TYPE_DUALCLASS)

    # remove old class abilities
    KitIndex = GUICommon.GetKitIndex(pc)
    if KitIndex:
        ABTable = CommonTables.KitList.GetValue(str(KitIndex), "ABILITIES")
    else:
        ABTable = CommonTables.ClassSkills.GetValue(OldClassName, "ABILITIES")
    if ABTable != "*" and GemRB.HasResource(ABTable, RES_2DA, 1):
        GUICommon.RemoveClassAbilities(pc, ABTable,
                                       GemRB.GetPlayerStat(pc, IE_LEVEL))

    # remove old class casting
    if not NewMageSpells:
        for i in range(9):
            GemRB.SetMemorizableSpellsCount(pc, 0, IE_SPELL_TYPE_WIZARD, i)
    Spellbook.RemoveKnownSpells(pc, IE_SPELL_TYPE_PRIEST, 1, 7, 1)

    # apply our class abilities
    ABTable = CommonTables.ClassSkills.GetValue(ClassName, "ABILITIES")
    if ABTable != "*" and GemRB.HasResource(ABTable, RES_2DA, 1):
        GUICommon.AddClassAbilities(pc, ABTable)

    # learn our new priest spells
    if NewPriestMask:
        Spellbook.LearnPriestSpells(pc, 1, NewPriestMask)
        GemRB.SetMemorizableSpellsCount(pc, 1, IE_SPELL_TYPE_PRIEST, 0)

    # save our thief skills if we have them
    LUSkillsSelection.SkillsSave(pc)

    # NOTE: the ordering here is very deliberate, don't touch!
    # for the dc detection code to work in core, some level and mc bits info has to be there
    # 3 PCF functions (class, kit, level) all need more info
    # testcase: dualclassing and checking how the actionbar evolves

    # mark the actor as dualclassed
    OldMCFlags = GemRB.GetPlayerStat(pc, IE_MC_FLAGS, 1)
    NewMCBit = CommonTables.Classes.GetValue(OldClassName, "MC_WAS_ID",
                                             GTV_INT)
    GemRB.SetPlayerStat(pc, IE_MC_FLAGS, OldMCFlags | NewMCBit)

    # calculate new dc/mc class combo
    OldClassId = GemRB.GetPlayerStat(pc, IE_CLASS)
    MultClassId = (1 << (NewClassId - 1)) | (1 << (OldClassId - 1))
    MultClassId = CommonTables.Classes.FindValue("MULTI", MultClassId)
    MultClassId = CommonTables.Classes.GetRowName(MultClassId)
    MultClassId = CommonTables.Classes.GetValue(MultClassId, "ID")

    # fake update our levels (no PCF), so the PCF can be ran later on correct values
    # core only looks at the level difference when determining dc class order
    DSOverride = {"old": OldClassId, "new": NewClassId, "mc": MultClassId}
    Level1 = GemRB.GetPlayerStat(pc, IE_LEVEL)
    if GUICommon.IsDualSwap(pc, DSOverride):
        GemRB.SetPlayerStat(pc, IE_LEVEL2, 0, 0)
    else:
        GemRB.SetPlayerStat(pc, IE_LEVEL2, Level1 - 1, 0)
        GemRB.SetPlayerStat(pc, IE_LEVEL, 0, 0)

    # finally set the new class
    GemRB.SetPlayerStat(pc, IE_CLASS, MultClassId)

    # update our levels and xp
    if GUICommon.IsDualSwap(pc, DSOverride):
        GemRB.SetPlayerStat(pc, IE_LEVEL2, 1)
    else:
        GemRB.SetPlayerStat(pc, IE_LEVEL2, Level1, 0)
        GemRB.SetPlayerStat(pc, IE_LEVEL, 1)
    GemRB.SetPlayerStat(pc, IE_XP, 0)

    # END of order matters NOTE

    # new thac0
    ThacoTable = GemRB.LoadTable("THAC0")
    GemRB.SetPlayerStat(pc, IE_TOHIT,
                        ThacoTable.GetValue(NewClassId - 1, 0, GTV_INT))

    # new saves
    SavesTable = CommonTables.Classes.GetValue(ClassName, "SAVE", GTV_STR)
    SavesTable = GemRB.LoadTable(SavesTable)
    for i in range(5):
        GemRB.SetPlayerStat(pc, IE_SAVEVSDEATH + i, SavesTable.GetValue(i, 0))

    # dump any equipped items that are now unusable
    DumpUnusableItems(pc)

    # close our window
    if DCMainWindow:
        DCMainWindow.Unload()
    return
Esempio n. 9
0
def LevelUpDonePress():
    """Updates the PC with the new choices.

	Closes the window when finished."""
    import GUICommonWindows
    import GUIREC
    global SkillTable

    # proficiencies
    LUProfsSelection.ProfsSave(pc)

    # skills
    LUSkillsSelection.SkillsSave(pc)

    # level
    if DualSwap:  # swap the IE_LEVELs around if a backward dual
        GemRB.SetPlayerStat(pc, IE_LEVEL2, Level[0])
        GemRB.SetPlayerStat(pc, IE_LEVEL, Level[1])
    else:
        GemRB.SetPlayerStat(pc, IE_LEVEL, Level[0])
        GemRB.SetPlayerStat(pc, IE_LEVEL2, Level[1])
    GemRB.SetPlayerStat(pc, IE_LEVEL3, Level[2])

    print "Levels:", Level[0], "/", Level[1], "/", Level[2]

    # save our number of memorizable spells per level
    if DeltaWSpells > 0:
        # loop through each wizard spell level
        for i in range(len(NewWSpells)):
            if NewWSpells[i] > 0:  # we have new spells, so update
                GemRB.SetMemorizableSpellsCount(pc, NewWSpells[i],
                                                IE_SPELL_TYPE_WIZARD, i)

    # save our number of memorizable priest spells
    if DeltaDSpells > 0:  # druids and clerics count
        for i in range(len(NewDSpells)):
            # get each update
            if NewDSpells[i] > 0:
                GemRB.SetMemorizableSpellsCount(pc, NewDSpells[i],
                                                IE_SPELL_TYPE_PRIEST, i)

            # learn all the spells we're given, but don't have, up to our given casting level
            # bonus spells don't count in determining if we can use this level
            if GemRB.GetMemorizableSpellsCount(
                    pc, IE_SPELL_TYPE_PRIEST, i,
                    0) > 0:  # we can memorize spells of this level
                for j in range(NumClasses):  # loop through each class
                    TmpClassName = GUICommon.GetClassRowName(
                        Classes[j], "class")
                    IsDruid = CommonTables.ClassSkills.GetValue(
                        TmpClassName, "DRUIDSPELL", GTV_STR)
                    IsCleric = CommonTables.ClassSkills.GetValue(
                        TmpClassName, "CLERICSPELL", GTV_STR)
                    if IsCleric == "*" and IsDruid == "*":  # no divine spells (so mage/cleric multis don't screw up)
                        continue
                    elif IsCleric == "*":  # druid spells
                        ClassFlag = 0x8000
                    else:  # cleric spells
                        ClassFlag = 0x4000

                    Learnable = Spellbook.GetLearnablePriestSpells(
                        ClassFlag, GemRB.GetPlayerStat(pc, IE_ALIGNMENT),
                        i + 1)
                    for k in range(len(Learnable)
                                   ):  # loop through all the learnable spells
                        if Spellbook.HasSpell(
                                pc, IE_SPELL_TYPE_PRIEST, i, Learnable[k]
                        ) < 0:  # only write it if we don't yet know it
                            GemRB.LearnSpell(pc, Learnable[k])

    # hlas
    # level, xp and other stuff by the core?

    # 5261 - Regained abilities from inactive class
    if IsDual:  # we're dual classed
        print "activation?"
        if (Level[0] - LevelDiff[0]) <= Level[1] and Level[0] > Level[
                1]:  # our new classes now surpasses our old class
            print "reactivating base class"
            ReactivateBaseClass()

    if LevelUpWindow:
        LevelUpWindow.Unload()
    GUICommonWindows.UpdatePortraitWindow()
    GUIREC.UpdateRecordsWindow()

    GemRB.SetRepeatClickFlags(GEM_RK_DISABLE, OP_OR)
    return
Esempio n. 10
0
def DCMainDonePress():
    """Saves our dualclass changes and closes the window.

	This de-activates our old class and readjusts the basic actor stats, such as
	THAC0, spell casting, proficiencies, and so forth, to the new class."""
    import GUIREC

    # save our proficiencies
    LUProfsSelection.ProfsSave(pc, LUProfsSelection.LUPROFS_TYPE_DUALCLASS)

    # remove old class abilities
    KitIndex = GUICommon.GetKitIndex(pc)
    if KitIndex:
        ABTable = CommonTables.KitList.GetValue(str(KitIndex), "ABILITIES")
    else:
        ABTable = CommonTables.ClassSkills.GetValue(OldClassName, "ABILITIES")
    if ABTable != "*" and GemRB.HasResource(ABTable, RES_2DA, 1):
        GUICommon.RemoveClassAbilities(pc, ABTable,
                                       GemRB.GetPlayerStat(pc, IE_LEVEL))

    # remove old class casting
    if not NewMageSpells:
        for i in range(9):
            GemRB.SetMemorizableSpellsCount(pc, 0, IE_SPELL_TYPE_WIZARD, i)
    GUICommon.RemoveKnownSpells(pc, IE_SPELL_TYPE_PRIEST, 1, 7, 1)

    # apply our class abilities
    ABTable = CommonTables.ClassSkills.GetValue(ClassName, "ABILITIES")
    if ABTable != "*" and GemRB.HasResource(ABTable, RES_2DA, 1):
        GUICommon.AddClassAbilities(pc, ABTable)

    # learn our new priest spells
    if NewPriestMask:
        GUICommon.LearnPriestSpells(pc, 1, NewPriestMask)
        GemRB.SetMemorizableSpellsCount(pc, 1, IE_SPELL_TYPE_PRIEST, 0)

    # save our thief skills if we have them
    LUSkillsSelection.SkillsSave(pc)

    # save our new class and say was multi
    OldClassId = GemRB.GetPlayerStat(pc, IE_CLASS)
    MultClassId = (1 << (NewClassId - 1)) | (1 << (OldClassId - 1))
    MultClassId = CommonTables.Classes.FindValue(4, MultClassId)
    MultClassId = CommonTables.Classes.GetValue(MultClassId, 5)
    GemRB.SetPlayerStat(pc, IE_CLASS, MultClassId)
    GemRB.SetPlayerStat(
        pc, IE_MC_FLAGS,
        CommonTables.Classes.GetValue(OldClassName, "MC_WAS_ID", 1))

    # update our levels and xp
    if GUICommon.IsDualSwap(pc):
        GemRB.SetPlayerStat(pc, IE_LEVEL2, 1)
    else:
        GemRB.SetPlayerStat(pc, IE_LEVEL2, GemRB.GetPlayerStat(pc, IE_LEVEL),
                            0)
        GemRB.SetPlayerStat(pc, IE_LEVEL, 1)
    GemRB.SetPlayerStat(pc, IE_XP, 0)

    # new thac0
    ThacoTable = GemRB.LoadTable("THAC0")
    GemRB.SetPlayerStat(pc, IE_TOHIT,
                        ThacoTable.GetValue(NewClassId - 1, 0, 1))

    # new saves
    SavesTable = CommonTables.Classes.GetValue(
        CommonTables.Classes.FindValue(5, NewClassId), 3, 0)
    SavesTable = GemRB.LoadTable(SavesTable)
    for i in range(5):
        GemRB.SetPlayerStat(pc, IE_SAVEVSDEATH + i, SavesTable.GetValue(i, 0))

    # close our window
    if DCMainWindow:
        DCMainWindow.Unload()
    GUIREC.UpdateRecordsWindow()
    return
Esempio n. 11
0
def OnLoad():
	MyChar = GemRB.GetVar ("Slot")

	# nullify our thieving skills
	LUSkillsSelection.SkillsNullify ()
	LUSkillsSelection.SkillsSave (MyChar)

	# nullify our proficiencies
	LUProfsSelection.ProfsNullify ()

	# nully other variables
	GemRB.SetVar ("HatedRace", 0)

	# save our previous stats:
	# 	abilities
	AbilityTable = GemRB.LoadTable ("ability")
	AbilityCount = AbilityTable.GetRowCount ()

	# print our diagnostic as we loop (so as not to duplicate)
	print "CharGen6 output:"

	#remove all known spells and nullify the memorizable counts
	Spellbook.RemoveKnownSpells (MyChar, IE_SPELL_TYPE_WIZARD, 1,9, 1)
	Spellbook.RemoveKnownSpells (MyChar, IE_SPELL_TYPE_PRIEST, 1,7, 1)

	# learn divine spells if appropriate
	ClassName = GUICommon.GetClassRowName (MyChar)
	TableName = CommonTables.ClassSkills.GetValue (ClassName, "CLERICSPELL", 0) # cleric spells

	if TableName == "*": # only druid spells or no spells at all
		TableName = CommonTables.ClassSkills.GetValue (ClassName, "DRUIDSPELL", 0)
		ClassFlag = 0x8000
	elif CommonTables.ClassSkills.GetValue (ClassName, "DRUIDSPELL", 0) != "*": # cleric and druid spells
		ClassFlag = 0
	else: # only cleric spells
		ClassFlag = 0x4000

	if TableName != "*":
		#figure out which class casts spells and use the level of the class
		#to setup the priest spells
		Levels = [GemRB.GetPlayerStat (MyChar, IE_LEVEL), \
				GemRB.GetPlayerStat (MyChar, IE_LEVEL2), \
				GemRB.GetPlayerStat (MyChar, IE_LEVEL3)]
		index = 0
		IsMulti = GUICommon.IsMultiClassed (MyChar, 1)
		if IsMulti[0]>1:
			#loop through each multiclass until we come across the class that gives
			#divine spells; because clerics have a lower id than rangers, they should
			#be looked at first in Cleric/Ranger multi's, which is correct
			foundindex = 0
			for i in range (IsMulti[0]):
				ClassName = GUICommon.GetClassRowName (IsMulti[i+1], "class")
				for table in "CLERICSPELL", "DRUIDSPELL":
					if CommonTables.ClassSkills.GetValue (ClassName, table) != "*":
						index = i
						foundindex = 1
						break
				if foundindex:
					break

		#set our memorizable counts
		Spellbook.SetupSpellLevels (MyChar, TableName, IE_SPELL_TYPE_PRIEST, Levels[index])

		#learn all our priest spells up to the level we can learn
		for level in range (8):
			if GemRB.GetMemorizableSpellsCount (MyChar, IE_SPELL_TYPE_PRIEST, level, 0) <= 0:
				Spellbook.LearnPriestSpells (MyChar, level, ClassFlag)
				break
	CharGenCommon.DisplayOverview (6)
	return
Esempio n. 12
0
def DCMainDonePress():
    """Saves our dualclass changes and closes the window.

	This de-activates our old class and readjusts the basic actor stats, such as
	THAC0, spell casting, proficiencies, and so forth, to the new class."""
    import GUIREC
    global ClassName

    # save our proficiencies
    LUProfsSelection.ProfsSave(pc, LUProfsSelection.LUPROFS_TYPE_DUALCLASS)

    # remove old class abilities
    KitIndex = GUICommon.GetKitIndex(pc)
    if KitIndex:
        ABTable = CommonTables.KitList.GetValue(str(KitIndex), "ABILITIES")
    else:
        ABTable = CommonTables.ClassSkills.GetValue(OldClassName, "ABILITIES")
    if ABTable != "*" and GemRB.HasResource(ABTable, RES_2DA, 1):
        GUICommon.RemoveClassAbilities(pc, ABTable,
                                       GemRB.GetPlayerStat(pc, IE_LEVEL))

    # remove old class casting
    if not NewMageSpells:
        for i in range(9):
            GemRB.SetMemorizableSpellsCount(pc, 0, IE_SPELL_TYPE_WIZARD, i)
    Spellbook.RemoveKnownSpells(pc, IE_SPELL_TYPE_PRIEST, 1, 7, 1)

    # apply our class abilities
    ABTable = CommonTables.ClassSkills.GetValue(ClassName, "ABILITIES")
    if ABTable != "*" and GemRB.HasResource(ABTable, RES_2DA, 1):
        GUICommon.AddClassAbilities(pc, ABTable)

    # learn our new priest spells
    if NewPriestMask:
        Spellbook.LearnPriestSpells(pc, 1, NewPriestMask)
        GemRB.SetMemorizableSpellsCount(pc, 1, IE_SPELL_TYPE_PRIEST, 0)

    # save our thief skills if we have them
    LUSkillsSelection.SkillsSave(pc)

    # save our new class and say was multi
    OldClassId = GemRB.GetPlayerStat(pc, IE_CLASS)
    MultClassId = (1 << (NewClassId - 1)) | (1 << (OldClassId - 1))
    MultClassId = CommonTables.Classes.FindValue("MULTI", MultClassId)
    MultClassId = CommonTables.Classes.GetRowName(MultClassId)
    MultClassId = CommonTables.Classes.GetValue(MultClassId, "ID")
    GemRB.SetPlayerStat(pc, IE_CLASS, MultClassId)
    GemRB.SetPlayerStat(
        pc, IE_MC_FLAGS,
        CommonTables.Classes.GetValue(OldClassName, "MC_WAS_ID", 1))

    # update our levels and xp
    if GUICommon.IsDualSwap(pc):
        GemRB.SetPlayerStat(pc, IE_LEVEL2, 1)
    else:
        GemRB.SetPlayerStat(pc, IE_LEVEL2, GemRB.GetPlayerStat(pc, IE_LEVEL),
                            0)
        GemRB.SetPlayerStat(pc, IE_LEVEL, 1)
    GemRB.SetPlayerStat(pc, IE_XP, 0)

    # new thac0
    ThacoTable = GemRB.LoadTable("THAC0")
    GemRB.SetPlayerStat(pc, IE_TOHIT,
                        ThacoTable.GetValue(NewClassId - 1, 0, 1))

    # new saves
    SavesTable = CommonTables.Classes.GetValue(ClassName, "SAVE", 0)
    SavesTable = GemRB.LoadTable(SavesTable)
    for i in range(5):
        GemRB.SetPlayerStat(pc, IE_SAVEVSDEATH + i, SavesTable.GetValue(i, 0))

    # dump any equipped items that are now unusable
    SlotTypes = [
        SLOT_ARMOUR, SLOT_SHIELD, SLOT_HELM, SLOT_RING, SLOT_CLOAK, SLOT_BOOT,
        SLOT_AMULET, SLOT_GLOVE, SLOT_BELT, SLOT_ITEM, SLOT_WEAPON, SLOT_QUIVER
    ]
    for type in SlotTypes:
        Slots = GemRB.GetSlots(pc, type)
        if not len(Slots):
            # nothing there
            continue
        for slot in Slots:
            SlotType = GemRB.GetSlotType(slot, pc)
            CREItem = GemRB.GetSlotItem(pc, slot)
            if not GemRB.CanUseItemType(SlotType["Type"],
                                        CREItem["ItemResRef"], pc):
                # move it to a free inventory slot by mimicking dragging
                Item = GemRB.GetItem(CREItem["ItemResRef"])
                GemRB.DragItem(pc, slot, Item["ItemIcon"])
                GemRB.DropDraggedItem(pc, -3)

    # close our window
    if DCMainWindow:
        DCMainWindow.Unload()
    GUIREC.UpdateRecordsWindow()
    return
Esempio n. 13
0
def NextPress():
    MyChar = GemRB.GetVar("Slot")
    LUSkillsSelection.SkillsSave(MyChar)
    GemRB.SetRepeatClickFlags(GEM_RK_DISABLE, OP_OR)
    CharGenCommon.next()