Exemplo n.º 1
0
def CloseCustomizeWindow ():
	import GUIREC
	global CustomizeWindow
	if CustomizeWindow:
		CustomizeWindow.Unload ()
		CustomizeWindow = None
		GUIREC.UpdateRecordsWindow ()
	return
Exemplo n.º 2
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
Exemplo n.º 3
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()
    GUIREC.UpdateRecordsWindow()
    return
Exemplo n.º 4
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
Exemplo n.º 5
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