def ContingencyOk (): global OtherWindow #set the storage if Target == 2: GemRB.ApplyEffect (pc, "Sequencer:Store", 0, 0, Spell1, Spell2, Spell3, Source) else: GemRB.ApplyEffect (pc, "CastSpellOnCondition", GemRB.GetVar ("ContTarg"), GemRB.GetVar ("ContCond"), Spell1, Spell2, Spell3, Source) #set the innate if GemRB.LearnSpell (pc, Source+"d", LS_MEMO): GemRB.Log (LOG_ERROR, "ContingencyOk", "Failed to learn sequencer/contingency!") OtherWindow.Close () return
def ProfsSave (pc, type=LUPROFS_TYPE_LEVELUP): """Updates the actor with the new proficiencies.""" ProfCount = ProfsTable.GetRowCount () - ProfsTableOffset for i in range(ProfCount): # skip bg1 weapprof.2da proficiencies ProfID = ProfsTable.GetValue (i+ProfsTableOffset, 0) if GameCheck.IsBG1(): ProfID = ProfID + IE_PROFICIENCYBASTARDSWORD SaveProf = GemRB.GetVar ("Prof "+str(i)) if type == LUPROFS_TYPE_CHARGEN and GameCheck.IsBG2(): GemRB.DispelEffect (pc, "Proficiency", ProfID) else: if type != LUPROFS_TYPE_DUALCLASS: OldProf = GemRB.GetPlayerStat (pc, ProfID) & 0x38 SaveProf = OldProf | SaveProf else: # gotta move the old prof to the back for dual class OldProf = GemRB.GetPlayerStat (pc, ProfID) & 0x07 SaveProf = (OldProf << 3) | SaveProf GemRB.SetPlayerStat (pc, ProfID, SaveProf) if GameCheck.IsBG2() and (type == LUPROFS_TYPE_LEVELUP or type == LUPROFS_TYPE_CHARGEN): if SaveProf: GemRB.ApplyEffect (pc, "Proficiency", SaveProf, ProfID) return
def ContingencyOk(): global OtherWindow #set the storage if Target == 2: GemRB.ApplyEffect(pc, "Sequencer:Store", 0, 0, Spell1, Spell2, Spell3, Source) else: GemRB.ApplyEffect(pc, "CastSpellOnCondition", 0, GemRB.GetVar("ContCond"), Spell1, Spell2, Spell3, Source) #set the innate if GemRB.LearnSpell(pc, Source + "d", LS_MEMO): print "EEEEK! Failed to learn sequencer/contingency!\n\n" OtherWindow.Unload() return
def HLADonePress(): """Saves the new HLAs and closes the HLA selection window.""" # save all of our HLAs for i in range(len(HLANewAbilities)): # see if we're going to learn this ability if HLANewAbilities[i] == 0: continue # figure out the ability type HLARef = HLAAbilities[i][0] HLAType = HLARef[5:7] if HLAType == "PR": HLAType = IE_SPELL_TYPE_PRIEST HLALevel = int(HLARef[7]) - 1 elif HLAType == "WI": HLAType = IE_SPELL_TYPE_WIZARD HLALevel = int(HLARef[7]) - 1 else: HLAType = IE_SPELL_TYPE_INNATE HLALevel = 0 # do we need to apply or learn it? if HLARef[:2] == "AP": GemRB.ApplySpell(pc, HLARef[3:]) elif HLARef[:2] == "GA": # make sure it isn't already learned SpellIndex = Spellbook.HasSpell(pc, HLAType, HLALevel, HLARef[3:]) if SpellIndex < 0: # gotta learn it GemRB.LearnSpell(pc, HLARef[3:], 8) else: # memorize it again GemRB.MemorizeSpell(pc, HLAType, HLALevel, SpellIndex) #save the number of this HLA memorized #TODO: check param2 (0 seems to work ok) GemRB.ApplyEffect(pc, "HLA", HLAAbilities[i][2], 0, HLARef[3:]) # close the window if HLAWindow: HLAWindow.Unload() # so redraw skills knows we're done GemRB.SetVar("HLACount", 0) return
def HLADonePress(): """Saves the new HLAs and closes the HLA selection window.""" # save all of our HLAs for i in range(len(HLANewAbilities)): # see if we're going to learn this ability if HLANewAbilities[i] == 0: continue # figure out the ability type HLARef = HLAAbilities[i][0] HLAType = HLARef[5:7] if HLAType == "PR": HLAType = IE_SPELL_TYPE_PRIEST HLALevel = int(HLARef[7]) - 1 elif HLAType == "WI": HLAType = IE_SPELL_TYPE_WIZARD HLALevel = int(HLARef[7]) - 1 else: HLAType = IE_SPELL_TYPE_INNATE HLALevel = 0 # do we need to apply or learn it? if HLARef[:2] == "AP": GemRB.ApplySpell(pc, HLARef[3:]) elif HLARef[:2] == "GA": # learn it or memorize another one Spellbook.LearnSpell(pc, HLARef[3:], HLAType, HLALevel, 1, LS_MEMO) #save the number of this HLA memorized #TODO: check param2 (0 seems to work ok) GemRB.ApplyEffect(pc, "HLA", HLAAbilities[i][2], 0, HLARef[3:]) # close the window if HLAWindow: HLAWindow.Unload() # so redraw skills knows we're done GemRB.SetVar("HLACount", 0) import LevelUp LevelUp.LevelUpWindow.Invalidate() return
def ApplyFeats(MyChar): #don't mess with feats outside of IWD2 if not GameCheck.IsIWD2(): return #feats giving a single innate ability SetSpell(MyChar, "SPIN111", FEAT_WILDSHAPE_BOAR) SetSpell(MyChar, "SPIN197", FEAT_MAXIMIZED_ATTACKS) SetSpell(MyChar, "SPIN231", FEAT_ENVENOM_WEAPON) SetSpell(MyChar, "SPIN245", FEAT_WILDSHAPE_PANTHER) SetSpell(MyChar, "SPIN246", FEAT_WILDSHAPE_SHAMBLER) SetSpell(MyChar, "SPIN275", FEAT_POWER_ATTACK) SetSpell(MyChar, "SPIN276", FEAT_EXPERTISE) SetSpell(MyChar, "SPIN277", FEAT_ARTERIAL_STRIKE) SetSpell(MyChar, "SPIN278", FEAT_HAMSTRING) SetSpell(MyChar, "SPIN279", FEAT_RAPID_SHOT) #extra rage level = GemRB.GetPlayerStat(MyChar, IE_LEVELBARBARIAN) if level>0: if level>=15: GemRB.RemoveSpell(MyChar, "SPIN236") Spell = "SPIN260" else: GemRB.RemoveSpell(MyChar, "SPIN260") Spell = "SPIN236" cnt = GemRB.GetPlayerStat (MyChar, IE_FEAT_EXTRA_RAGE) + (level + 3) // 4 GUICommon.MakeSpellCount(MyChar, Spell, cnt) else: GemRB.RemoveSpell(MyChar, "SPIN236") GemRB.RemoveSpell(MyChar, "SPIN260") #extra smiting level = GemRB.GetPlayerStat(MyChar, IE_LEVELPALADIN) if level>1: cnt = GemRB.GetPlayerStat (MyChar, IE_FEAT_EXTRA_SMITING) + 1 GUICommon.MakeSpellCount(MyChar, "SPIN152", cnt) else: GemRB.RemoveSpell(MyChar, "SPIN152") #extra turning level = GemRB.GetPlayerStat(MyChar, IE_TURNUNDEADLEVEL) if level>0: cnt = GUICommon.GetAbilityBonus(MyChar, IE_CHR) + 3 if cnt<1: cnt = 1 cnt += GemRB.GetPlayerStat (MyChar, IE_FEAT_EXTRA_TURNING) GUICommon.MakeSpellCount(MyChar, "SPIN970", cnt) else: GemRB.RemoveSpell(MyChar, "SPIN970") #stunning fist if GemRB.HasFeat (MyChar, FEAT_STUNNING_FIST): cnt = GemRB.GetPlayerStat(MyChar, IE_CLASSLEVELSUM) // 4 GUICommon.MakeSpellCount(MyChar, "SPIN232", cnt) else: GemRB.RemoveSpell(MyChar, "SPIN232") #remove any previous SPLFOCUS #GemRB.ApplyEffect(MyChar, "RemoveEffects",0,0,"SPLFOCUS") #spell focus stats SPLFocusTable = GemRB.LoadTable ("splfocus") for i in range(SPLFocusTable.GetRowCount()): Row = SPLFocusTable.GetRowName(i) Stat = SPLFocusTable.GetValue(Row, "STAT", GTV_STAT) if Stat: Column = GemRB.GetPlayerStat(MyChar, Stat) if Column: Value = SPLFocusTable.GetValue(i, Column) if Value: #add the effect, value could be 2 or 4, timing mode is 8 - so it is not saved GemRB.ApplyEffect(MyChar, "SpellFocus", Value, i,"","","","SPLFOCUS", 8) return
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, GTV_INT) 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", GTV_STR) 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", GTV_STR), CommonTables.ClassSkills.GetValue(ClassName, "CLERICSPELL", GTV_STR), CommonTables.ClassSkills.GetValue(ClassName, "MAGESPELL", GTV_STR) ] 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), GTV_INT) 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])