예제 #1
0
def FixInnates(pc):
	import Spellbook
	from ie_spells import LS_MEMO
	from ie_stats import IE_ALIGNMENT
	# adds the spell: SPIN822 (slayer change) if needed
	if Spellbook.HasSpell (pc, IE_SPELL_TYPE_INNATE, 1, "SPIN822") == -1:
		GemRB.LearnSpell (pc, "SPIN822", LS_MEMO)

	# apply starting (alignment dictated) abilities (just to be replaced later)
	# pc, table, new level, level diff, alignment
	AlignmentAbbrev = CommonTables.Aligns.FindValue ("VALUE", GemRB.GetPlayerStat (pc, IE_ALIGNMENT))
	GUICommon.AddClassAbilities (pc, "abstart", 6,6, AlignmentAbbrev)

	# some old/new pairs are the same, so we can skip them
	# all the innates are doubled
	old = [ "SPIN101", "SPIN102", "SPIN104", "SPIN105" ]
	new = [ "SPIN200", "SPIN201", "SPIN202", "SPIN203" ]
	for i in range(len(old)):
		if GemRB.RemoveSpell (pc, old[i]):
			Spellbook.LearnSpell (pc, new[i], IE_SPELL_TYPE_INNATE, 3, 2, LS_MEMO)
예제 #2
0
파일: CharGenEnd.py 프로젝트: dhewg/gemrb
def OnLoad():
    # Lay on hands, turn undead and backstab multiplier get set by the core
    # set my character up
    MyChar = GemRB.GetVar("Slot")
    Class = GemRB.GetPlayerStat(MyChar, IE_CLASS)
    ClassIndex = CommonTables.Classes.FindValue(5, Class)
    ClassName = CommonTables.Classes.GetRowName(ClassIndex)
    IsMulti = GUICommon.IsMultiClassed(MyChar, 1)
    Levels = [GemRB.GetPlayerStat (MyChar, IE_LEVEL), GemRB.GetPlayerStat (MyChar, IE_LEVEL2), \
      GemRB.GetPlayerStat (MyChar, IE_LEVEL3)]

    # weapon proficiencies
    # set the base number of attacks; effects will add the proficiency bonus
    # 2 means 1 attack, because this is the number of attacks in 2 rounds
    GemRB.SetPlayerStat(MyChar, IE_NUMBEROFATTACKS, 2)

    #lore, thac0, hp, and saves
    GemRB.SetPlayerStat(MyChar, IE_MAXHITPOINTS, 0)
    GemRB.SetPlayerStat(MyChar, IE_HITPOINTS, 0)
    LUCommon.SetupSavingThrows(MyChar)
    LUCommon.SetupThaco(MyChar)
    LUCommon.SetupLore(MyChar)
    LUCommon.SetupHP(MyChar)

    # mage spells
    TableName = CommonTables.ClassSkills.GetValue(Class, 2, 0)
    if TableName != "*":
        index = 0
        if IsMulti[0] > 1:
            #find out which class gets mage spells
            for i in range(IsMulti[0]):
                if CommonTables.ClassSkills.GetValue(IsMulti[i + 1], 2,
                                                     0) != "*":
                    index = i
                    break
        GUICommon.SetupSpellLevels(MyChar, TableName, IE_SPELL_TYPE_WIZARD,
                                   Levels[index])

    # apply class/kit abilities
    KitIndex = GUICommon.GetKitIndex(MyChar)
    if IsMulti[0] > 1:
        #get the class abilites for each class
        for i in range(IsMulti[0]):
            TmpClassName = CommonTables.Classes.GetRowName(
                CommonTables.Classes.FindValue(5, IsMulti[i + 1]))
            ABTable = CommonTables.ClassSkills.GetValue(
                TmpClassName, "ABILITIES")
            if ABTable != "*" and GemRB.HasResource(ABTable, RES_2DA, 1):
                GUICommon.AddClassAbilities(MyChar, ABTable, Levels[i],
                                            Levels[i])
    else:
        if KitIndex:
            ABTable = CommonTables.KitList.GetValue(str(KitIndex), "ABILITIES")
        else:
            ABTable = CommonTables.ClassSkills.GetValue(ClassName, "ABILITIES")
        if ABTable != "*" and GemRB.HasResource(ABTable, RES_2DA, 1):
            GUICommon.AddClassAbilities(MyChar, ABTable, Levels[0], Levels[0])

    # apply starting (alignment dictated) abilities
    # pc, table, new level, level diff, alignment
    AlignmentTable = GemRB.LoadTable("aligns")
    AlignmentAbbrev = AlignmentTable.FindValue(
        3, GemRB.GetPlayerStat(MyChar, IE_ALIGNMENT))
    GUICommon.AddClassAbilities(MyChar, "abstart", 6, 6, AlignmentAbbrev)

    # setup starting gold (uses a roll dictated by class
    TmpTable = GemRB.LoadTable("strtgold")
    temp = GemRB.Roll(TmpTable.GetValue(Class, 1), TmpTable.GetValue(Class, 0),
                      TmpTable.GetValue(Class, 2))
    GemRB.SetPlayerStat(MyChar, IE_GOLD, temp * TmpTable.GetValue(Class, 3))

    # save the appearance
    GUICommon.SetColorStat(MyChar, IE_HAIR_COLOR, GemRB.GetVar("HairColor"))
    GUICommon.SetColorStat(MyChar, IE_SKIN_COLOR, GemRB.GetVar("SkinColor"))
    GUICommon.SetColorStat(MyChar, IE_MAJOR_COLOR, GemRB.GetVar("MajorColor"))
    GUICommon.SetColorStat(MyChar, IE_MINOR_COLOR, GemRB.GetVar("MinorColor"))
    #GUICommon.SetColorStat (MyChar, IE_METAL_COLOR, 0x1B )
    #GUICommon.SetColorStat (MyChar, IE_LEATHER_COLOR, 0x16 )
    #GUICommon.SetColorStat (MyChar, IE_ARMOR_COLOR, 0x17 )
    GemRB.SetPlayerStat(MyChar, IE_EA, 2)

    # save the name and starting xp (can level right away in game)
    GemRB.SetPlayerName(MyChar, GemRB.GetToken("CHARNAME"), 0)

    # does all the rest
    LargePortrait = GemRB.GetToken("LargePortrait")
    SmallPortrait = GemRB.GetToken("SmallPortrait")
    GemRB.FillPlayerInfo(MyChar, LargePortrait, SmallPortrait)

    if GUICommon.GameIsTOB():
        # add the starting inventory for tob
        GiveEquipment(MyChar, ClassName, KitIndex)

    playmode = GemRB.GetVar("PlayMode")
    if playmode >= 0:
        if GemRB.GetVar("GUIEnhancements"):
            GemRB.SaveCharacter(MyChar, "gembak")
        #LETS PLAY!!
        GemRB.EnterGame()
        GemRB.ExecuteString("EquipMostDamagingMelee()", MyChar)
    else:
        #leaving multi player pregen
        if CharGenWindow:
            CharGenWindow.Unload()
        #when export is done, go to start
        if GUICommon.HasTOB():
            GemRB.SetToken("NextScript", "Start2")
        else:
            GemRB.SetToken("NextScript", "Start")
        GemRB.SetNextScript("ExportFile")  #export
    return
예제 #3
0
def OnLoad():
    # Lay on hands, turn undead and backstab multiplier get set by the core
    # set my character up
    MyChar = GemRB.GetVar("Slot")
    ClassName = GUICommon.GetClassRowName(MyChar)
    IsMulti = GUICommon.IsMultiClassed(MyChar, 1)
    Levels = [GemRB.GetPlayerStat (MyChar, IE_LEVEL), GemRB.GetPlayerStat (MyChar, IE_LEVEL2), \
      GemRB.GetPlayerStat (MyChar, IE_LEVEL3)]

    # weapon proficiencies
    # set the base number of attacks; effects will add the proficiency bonus
    # 2 means 1 attack, because this is the number of attacks in 2 rounds
    GemRB.SetPlayerStat(MyChar, IE_NUMBEROFATTACKS, 2)

    #lore, thac0, hp, and saves
    GemRB.SetPlayerStat(MyChar, IE_MAXHITPOINTS, 0)
    GemRB.SetPlayerStat(MyChar, IE_HITPOINTS, 0)
    LUCommon.SetupSavingThrows(MyChar)
    LUCommon.SetupThaco(MyChar)
    LUCommon.SetupLore(MyChar)
    LUCommon.SetupHP(MyChar)

    # mage spells
    TableName = CommonTables.ClassSkills.GetValue(ClassName, "MAGESPELL",
                                                  GTV_STR)
    if TableName != "*":
        index = 0
        if IsMulti[0] > 1:
            #find out which class gets mage spells
            for i in range(IsMulti[0]):
                TmpClassName = GUICommon.GetClassRowName(
                    IsMulti[i + 1], "class")
                if CommonTables.ClassSkills.GetValue(TmpClassName, "MAGESPELL",
                                                     GTV_STR) != "*":
                    index = i
                    break
        Spellbook.SetupSpellLevels(MyChar, TableName, IE_SPELL_TYPE_WIZARD,
                                   Levels[index])

    # apply class/kit abilities
    GUICommon.ResolveClassAbilities(MyChar, ClassName)

    # alignment based bhaal powers are added in FixInnates later
    # unless we're starting with SoA
    if GemRB.GetVar("oldgame") == 1:
        AlignmentAbbrev = CommonTables.Aligns.FindValue(
            "VALUE", GemRB.GetPlayerStat(MyChar, IE_ALIGNMENT))
        GUICommon.AddClassAbilities(MyChar, "abstart", 6, 6, AlignmentAbbrev)

    # setup starting gold (uses a roll dictated by class
    TmpTable = GemRB.LoadTable("strtgold")
    temp = GemRB.Roll(TmpTable.GetValue(ClassName, "ROLLS"),
                      TmpTable.GetValue(ClassName, "SIDES"),
                      TmpTable.GetValue(ClassName, "MODIFIER"))
    GemRB.SetPlayerStat(MyChar, IE_GOLD,
                        temp * TmpTable.GetValue(ClassName, "MULTIPLIER"))

    # save the appearance
    GUICommon.SetColorStat(MyChar, IE_HAIR_COLOR, GemRB.GetVar("HairColor"))
    GUICommon.SetColorStat(MyChar, IE_SKIN_COLOR, GemRB.GetVar("SkinColor"))
    GUICommon.SetColorStat(MyChar, IE_MAJOR_COLOR, GemRB.GetVar("MajorColor"))
    GUICommon.SetColorStat(MyChar, IE_MINOR_COLOR, GemRB.GetVar("MinorColor"))
    #GUICommon.SetColorStat (MyChar, IE_METAL_COLOR, 0x1B )
    #GUICommon.SetColorStat (MyChar, IE_LEATHER_COLOR, 0x16 )
    #GUICommon.SetColorStat (MyChar, IE_ARMOR_COLOR, 0x17 )
    GemRB.SetPlayerStat(MyChar, IE_EA, 2)

    # save the name and starting xp (can level right away in game)
    GemRB.SetPlayerName(MyChar, GemRB.GetToken("CHARNAME"), 0)

    # does all the rest
    LargePortrait = GemRB.GetToken("LargePortrait")
    SmallPortrait = GemRB.GetToken("SmallPortrait")
    GemRB.FillPlayerInfo(MyChar, LargePortrait, SmallPortrait)

    # biography
    Bio = GemRB.GetToken("BIO")
    BioStrRef = 33347
    if Bio:
        BioStrRef = 62016
        GemRB.CreateString(BioStrRef, Bio)
    GemRB.SetPlayerString(MyChar, 74, BioStrRef)

    if GameCheck.IsTOB():
        # will also add the starting inventory for tob
        GemRB.GameSetExpansion(4)
        # no torture, let's refresh all the spells, at least for sorcerers
        # TODO: autopick memorisations for mages? Did they have a memorisation choice step like in bg1?
        GemRB.ChargeSpells(MyChar)

    playmode = GemRB.GetVar("PlayMode")
    if playmode >= 0:
        GemRB.SaveCharacter(MyChar, "gembak")
        #LETS PLAY!!
        GemRB.EnterGame()
        GemRB.ExecuteString("EquipMostDamagingMelee()", MyChar)
    else:
        #when export is done, go to start
        if GameCheck.HasTOB():
            GemRB.SetToken("NextScript", "Start2")
        else:
            GemRB.SetToken("NextScript", "Start")
        GemRB.SetNextScript("ExportFile")  #export
    return
예제 #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
    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
예제 #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

    # 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
예제 #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","",1)

	# 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)
		ac = GemRB.GetPlayerStat (pc, IE_ARMORCLASS)
		#This is a temporary solution, the core engine should set the stat correctly!
		ac += GemRB.GetAbilityBonus (IE_DEX, 2, GemRB.GetPlayerStat (pc, IE_DEX) )
		Label.SetText (str (ac))
		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", 0)
		ClericTable = CommonTables.ClassSkills.GetValue (TmpClassName, "CLERICSPELL", 0)
		MageTable = CommonTables.ClassSkills.GetValue (TmpClassName, "MAGESPELL", 0)

		# 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
			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), 1)
				OldWSpells[j] = MageTable.GetValue (str(StartLevel), str(j+1), 1)
				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), 1)
				OldDSpells[j] = ClericTable.GetValue (str(StartLevel), str(j+1), 1)
			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), 1)
					OldDSpells[j] = DruidTable.GetValue (str(StartLevel), str(j+1), 1)
				DeltaDSpells = sum(NewDSpells)-sum(OldDSpells)

		# 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", 1)
			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", 1)
		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
	if (Classes[0] == 19) and (DeltaWSpells > 0): # open our sorc spell selection window
		LUSpellSelection.OpenSpellsWindow (pc, "SPLSRCKN", Level[0], LevelDiff[0])
예제 #7
0
def ReactivateBaseClass ():
	"""Regains all abilities of the base dual-class.

	Proficiencies, THACO, saves, spells, and innate abilites,
	most noteably."""

	# we construct the Classes array, so that the active class is always first and the base is second
	ClassName = GUICommon.GetClassRowName (Classes[1], "class")
	KitIndex = GUICommon.GetKitIndex (pc)

	# reactivate all our proficiencies
	TmpTable = GemRB.LoadTable ("weapprof")
	ProfsTableOffset = 0
	if GameCheck.IsBG2 ():
		ProfsTableOffset = 8 # skip bg1 weapprof.2da proficiencies
	ProfCount = TmpTable.GetRowCount () - ProfsTableOffset
	for i in range(ProfCount):
		ProfID = TmpTable.GetValue (i+ProfsTableOffset, 0)
		if GameCheck.IsBG1():
			ProfID = ProfID + IE_PROFICIENCYBASTARDSWORD
		Value = GemRB.GetPlayerStat (pc, ProfID)
		OldProf = (Value & 0x38) >> 3
		NewProf = Value & 0x07
		if OldProf > NewProf:
			Value = (OldProf << 3) | OldProf
			print "Value:",Value
			if GameCheck.IsBG2():
				GemRB.ApplyEffect (pc, "Proficiency", Value, ProfID )
			else:
				GemRB.SetPlayerStat (pc, ProfID, Value)

	# see if this thac0 is lower than our current thac0
	ThacoTable = GemRB.LoadTable ("THAC0")
	TmpThaco = ThacoTable.GetValue(Classes[1]-1, Level[1]-1, 1)
	if TmpThaco < GemRB.GetPlayerStat (pc, IE_TOHIT, 1):
		GemRB.SetPlayerStat (pc, IE_TOHIT, TmpThaco)

	# see if all our saves are lower than our current saves
	SavesTable = CommonTables.Classes.GetValue (ClassName, "SAVE", 0)
	SavesTable = GemRB.LoadTable (SavesTable)
	for i in range (5):
		# see if this save is lower than our old save
		TmpSave = SavesTable.GetValue (i, Level[1]-1)
		if TmpSave < GemRB.GetPlayerStat (pc, IE_SAVEVSDEATH+i, 1):
			GemRB.SetPlayerStat (pc, IE_SAVEVSDEATH+i, TmpSave)

	# see if we're a caster
	SpellTables = [CommonTables.ClassSkills.GetValue (ClassName, "DRUIDSPELL", 0), CommonTables.ClassSkills.GetValue (ClassName, "CLERICSPELL", 0), CommonTables.ClassSkills.GetValue (ClassName, "MAGESPELL", 0)]
	if SpellTables[2] != "*": # casts mage spells
		# set up our memorizations
		SpellTable = GemRB.LoadTable (SpellTables[2])
		for i in range (9):
			# if we can cast more spells at this level (should be always), then update
			NumSpells = SpellTable.GetValue (Level[1]-1, i)
			if NumSpells > GemRB.GetMemorizableSpellsCount (pc, IE_SPELL_TYPE_WIZARD, i, 1):
				GemRB.SetMemorizableSpellsCount (pc, NumSpells, IE_SPELL_TYPE_WIZARD, i)
	elif SpellTables[1] != "*" or SpellTables[0] != "*": # casts priest spells
		# get the correct table and mask
		if SpellTables[1] != "*": # clerical spells
			SpellTable = GemRB.LoadTable (SpellTables[1])
			ClassMask = 0x4000
		else: # druidic spells
			if not GemRB.HasResource(SpellTables[0], RES_2DA):
				SpellTables[0] = "MXSPLPRS"
			SpellTable = GemRB.LoadTable (SpellTables[0])
			ClassMask = 0x8000

		# loop through each spell level
		for i in range (7):
			# update if we can cast more spells at this level
			NumSpells = SpellTable.GetValue (str(Level[1]), str(i+1), 1)
			if not NumSpells:
				continue
			if NumSpells > GemRB.GetMemorizableSpellsCount (pc, IE_SPELL_TYPE_PRIEST, i, 1):
				GemRB.SetMemorizableSpellsCount (pc, NumSpells, IE_SPELL_TYPE_PRIEST, i)

			# also re-learn the spells if we have to
			# WARNING: this fixes the error whereby rangers dualed to clerics still got all druid spells
			#	they will now only get druid spells up to the level they could cast
			#	this should probably be noted somewhere (ranger/cleric multis still function the same,
			#	but that could be remedied if desired)
			Learnable = Spellbook.GetLearnablePriestSpells(ClassMask, 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])

	# setup class bonuses for this class
	if KitIndex == 0: # no kit
		ABTable = CommonTables.ClassSkills.GetValue (ClassName, "ABILITIES")
	else: # kit
		ABTable = CommonTables.KitList.GetValue (KitIndex, 4, 0)
	print "ABTable:",ABTable

	# add the abilites if we have a table to ref
	if ABTable != "*" and GemRB.HasResource (ABTable, RES_2DA, 1):
		GUICommon.AddClassAbilities (pc, ABTable, Level[1], Level[1]) # relearn class abilites
예제 #8
0
def setAccept():	
	#set my character up
	MyChar = GemRB.GetVar ("Slot")

	ClassName = GUICommon.GetClassRowName (MyChar)
	
	#reputation
	AllignID = GemRB.GetPlayerStat (MyChar, IE_ALIGNMENT)
	
	TmpTable=GemRB.LoadTable ("repstart")
	t = TmpTable.GetValue (AllignID,0) * 10
	GemRB.SetPlayerStat (MyChar, IE_REPUTATION, t)

	#lore, thac0, hp, and saves
	GemRB.SetPlayerStat (MyChar, IE_MAXHITPOINTS, 0)
	GemRB.SetPlayerStat (MyChar, IE_HITPOINTS, 0)
	LUCommon.SetupSavingThrows (MyChar)
	LUCommon.SetupThaco (MyChar)
	LUCommon.SetupLore (MyChar)
	LUCommon.SetupHP (MyChar)

	#slot 1 is the protagonist
	if MyChar == 1:
		GemRB.GameSetReputation( t )

	#gold
	TmpTable=GemRB.LoadTable ("strtgold")
	t = GemRB.Roll (TmpTable.GetValue (ClassName,"ROLLS"),TmpTable.GetValue(ClassName,"SIDES"), TmpTable.GetValue (ClassName,"MODIFIER") )
	GemRB.SetPlayerStat (MyChar, IE_GOLD, t*TmpTable.GetValue (ClassName,"MULTIPLIER") )

	#set the base number of attacks; effects will add the proficiency bonus
	GemRB.SetPlayerStat (MyChar, IE_NUMBEROFATTACKS, 2)

	#colors
	GUICommon.SetColorStat (MyChar, IE_METAL_COLOR, 0x1B )
	GUICommon.SetColorStat (MyChar, IE_LEATHER_COLOR, 0x16 )
	GUICommon.SetColorStat (MyChar, IE_ARMOR_COLOR, 0x17 )

	#does all the rest
	LargePortrait = GemRB.GetToken ("LargePortrait")
	SmallPortrait = GemRB.GetToken ("SmallPortrait")
	GemRB.FillPlayerInfo (MyChar, LargePortrait, SmallPortrait)
	#10 is a weapon slot (see slottype.2da row 10)
	GemRB.CreateItem (MyChar, "staf01", 10, 1, 0, 0)
	GemRB.SetEquippedQuickSlot (MyChar, 0)

	# apply class/kit abilities
	IsMulti = GUICommon.IsMultiClassed (MyChar, 1)
	Levels = [GemRB.GetPlayerStat (MyChar, IE_LEVEL), GemRB.GetPlayerStat (MyChar, IE_LEVEL2), \
			GemRB.GetPlayerStat (MyChar, IE_LEVEL3)]
	KitIndex = GUICommon.GetKitIndex (MyChar)
	if IsMulti[0]>1:
		#get the class abilites for each class
		for i in range (IsMulti[0]):
			TmpClassName = GUICommon.GetClassRowName (IsMulti[i+1], "class")
			ABTable = CommonTables.ClassSkills.GetValue (TmpClassName, "ABILITIES")
			if ABTable != "*" and GemRB.HasResource (ABTable, RES_2DA, 1):
				GUICommon.AddClassAbilities (MyChar, ABTable, Levels[i], Levels[i])
	else:
		if KitIndex:
			ABTable = CommonTables.KitList.GetValue (str(KitIndex), "ABILITIES")
		else:
			ABTable = CommonTables.ClassSkills.GetValue (ClassName, "ABILITIES")
		if ABTable != "*" and GemRB.HasResource (ABTable, RES_2DA, 1):
			GUICommon.AddClassAbilities (MyChar, ABTable, Levels[0], Levels[0])

	#LETS PLAY!!
	playmode = GemRB.GetVar ("PlayMode")
	
	GUICommon.CloseOtherWindow(None)
	
	if playmode >=0:
		CharGenCommon.close()
		if GemRB.GetVar("GUIEnhancements"):
			GemRB.SaveCharacter ( GemRB.GetVar ("Slot"), "gembak" )
		GemRB.EnterGame()
	else:
		#show the export window
		GemRB.SetToken("NextScript","CharGen")
		GemRB.SetNextScript ("ExportFile")
예제 #9
0
파일: Spellbook.py 프로젝트: harijan/gemrb
def SetupSpellIcons(Window, BookType, Start=0, Offset=0):
    actor = GemRB.GameGetFirstSelectedActor()

    # bardsongs weren't saved in iwd1, so learn them now if needed
    if BookType == (1 << IE_IWD2_SPELL_SONG) and HasSpell(
            actor, IE_SPELL_TYPE_SONG, 0, "SPIN151") == -1:
        import GUICommon
        level = GemRB.GetPlayerStat(actor, IE_LEVEL)
        GUICommon.AddClassAbilities(actor, "clabbard", level, level)

    # check if we're dealing with a temporary spellbook
    if GemRB.GetVar("ActionLevel") == UAW_2DASPELLS:
        allSpells = GetSpellinfoSpells(actor, BookType)
    else:
        # construct the spellbook of usable (not depleted) memorized spells
        # the getters expect the BookType as: 0 priest, 1 mage, 2 innate
        if BookType == -1:
            # Nahal's reckless dweomer can use any known spell
            allSpells = GetKnownSpells(actor, IE_SPELL_TYPE_WIZARD)
        else:
            allSpells = []
            for i in range(16):
                if BookType & (1 << i):
                    allSpells += GetUsableMemorizedSpells(actor, i)
            if not len(allSpells):
                raise AttributeError(
                    "Error, unknown BookType passed to SetupSpellIcons: %d! Bailing out!"
                    % (BookType))

    if BookType == -1:
        memorizedSpells = allSpells
        # reset Type, so we can choose the surge spell instead of just getting a redraw of the action bar
        GemRB.SetVar("Type", 3)
    else:
        memorizedSpells = SortUsableSpells(allSpells)

    # start creating the controls
    import GUICommonWindows
    # TODO: ASCOL, ROWS
    #AsCol = CommonTables.SpellDisplay.GetValue (layout, "AS_COL")
    #Rows = CommonTables.SpellDisplay.GetValue (layout, "ROWS")
    More = len(memorizedSpells) > 12 or Start > 0

    # scroll left button
    if More:
        Button = Window.GetControl(Offset)
        Button.SetText("")
        if Start:
            GUICommonWindows.SetActionIconWorkaround(Button, ACT_LEFT, 0)
            Button.SetState(IE_GUI_BUTTON_UNPRESSED)
        else:
            Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_SET)
            Button.SetState(IE_GUI_BUTTON_DISABLED)

    # disable all spells if fx_disable_spellcasting was run with the same type
    # but only if there are any spells of that type to disable
    disabled_spellcasting = GemRB.GetPlayerStat(actor, IE_CASTING, 0)
    actionLevel = GemRB.GetVar("ActionLevel")

    #order is: mage, cleric, innate, class, song, (defaults to 1, item)
    spellSections = [2, 4, 8, 16, 16]

    # create the spell icon buttons
    buttonCount = 12 - More * 2  # GUIBT_COUNT in PCStatsStruct
    for i in range(buttonCount):
        Button = Window.GetControl(i + Offset + More)
        Button.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS, None)

        if i + Start >= len(memorizedSpells):
            Button.SetState(IE_GUI_BUTTON_DISABLED)
            Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_SET)
            Button.SetText("")
            continue
        Spell = memorizedSpells[i + Start]
        spellType = Spell['SpellType']
        if spellType > 4:
            spellType = 1
        else:
            spellType = spellSections[spellType]
        if BookType == -1:
            Button.SetVarAssoc("Spell", Spell['SpellIndex'] + i + Start)
        else:
            Button.SetVarAssoc("Spell", Spell['SpellIndex'])

        # disable spells that should be cast from the inventory or can't be cast while silenced or ...
        # see splspec.2da for all the reasons; silence is handled elsewhere
        specialSpell = GemRB.CheckSpecialSpell(actor, Spell['SpellResRef'])
        specialSpell = (specialSpell & SP_IDENTIFY) or (
            (specialSpell & SP_SURGE) and actionLevel == UAW_ALLMAGE)
        if specialSpell & SP_SILENCE and Spell[
                'HeaderFlags'] & 0x2000000:  # SF_IGNORES_SILENCE
            specialSpell ^= SP_SILENCE

        disabled = disabled_spellcasting & spellType
        if disabled_spellcasting == 16:  # ignore type
            disabled = not (Spell["HeaderFlags"] & 0x4000)  # SF_HLA
        if specialSpell or disabled:
            Button.SetState(IE_GUI_BUTTON_DISABLED)
            Button.EnableBorder(1, 0)
        else:
            Button.SetState(IE_GUI_BUTTON_UNPRESSED)
            Button.SetEvent(IE_GUI_BUTTON_ON_PRESS,
                            GUICommonWindows.SpellPressed)
            Button.SetEvent(IE_GUI_BUTTON_ON_SHIFT_PRESS,
                            GUICommonWindows.SpellShiftPressed)

        if Spell['SpellResRef']:
            Button.SetSprites("guibtbut", 0, 0, 1, 2, 3)
            Button.SetSpellIcon(Spell['SpellResRef'], 1)
            Button.SetFlags(
                IE_GUI_BUTTON_PICTURE | IE_GUI_BUTTON_ALIGN_BOTTOM
                | IE_GUI_BUTTON_ALIGN_RIGHT, OP_SET)
            Button.SetTooltip(Spell['SpellName'])

            if Spell['MemoCount'] > 0 and BookType != -1:
                Button.SetText(str(Spell['MemoCount']))
            else:
                Button.SetText("")

    # scroll right button
    if More:
        Button = Window.GetControl(Offset + buttonCount + 1)
        GUICommonWindows.SetActionIconWorkaround(Button, ACT_RIGHT,
                                                 buttonCount)
        Button.SetText("")
        if len(memorizedSpells) - Start > 10:
            Button.SetState(IE_GUI_BUTTON_UNPRESSED)
        else:
            Button.SetState(IE_GUI_BUTTON_DISABLED)
            Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_SET)
예제 #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
    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