From: Laszlo T. <ave...@us...> - 2006-06-17 12:07:25
|
Update of /cvsroot/gemrb/gemrb/gemrb/GUIScripts/pst In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv9368/GUIScripts/pst Modified Files: GUIREC.py Log Message: improved PST levelup (used lotana's patches) Index: GUIREC.py =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/GUIScripts/pst/GUIREC.py,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** GUIREC.py 13 Jun 2006 15:23:52 -0000 1.48 --- GUIREC.py 17 Jun 2006 12:07:19 -0000 1.49 *************** *** 289,293 **** # faction faction = GemRB.GetPlayerStat (pc, IE_FACTION) - print "FACTION:", faction FactionTable = GemRB.LoadTable ("FACTIONS") faction_help = GemRB.GetString (GemRB.GetTableValue (FactionTable, faction, 0)) --- 289,292 ---- *************** *** 491,495 **** return - def GetCharacterHeader (pc): global avatar_header --- 490,493 ---- *************** *** 502,507 **** Specific = "%d"%GemRB.GetPlayerStat (pc, IE_SPECIFIC) # Nameless is a special case (dual class) ! if GemRB.GetTableValue (BioTable, Specific, "PC") == "NAMELESS_ONE": avatar_header['PrimClass'] = GemRB.GetTableRowName (ClassTable, Class) avatar_header['SecoClass'] = "*" --- 500,508 ---- Specific = "%d"%GemRB.GetPlayerStat (pc, IE_SPECIFIC) + #Nameless is Specific == 1 + avatar_header['Specific'] = Specific + # Nameless is a special case (dual class) ! if Specific == 1: avatar_header['PrimClass'] = GemRB.GetTableRowName (ClassTable, Class) avatar_header['SecoClass'] = "*" *************** *** 560,564 **** NextLevelTable = GemRB.LoadTable ("XPLEVEL") ! if (Level < 21): NextLevel = GemRB.GetTableValue (NextLevelTable, Class, str (Level + 1)) else: --- 561,565 ---- NextLevelTable = GemRB.LoadTable ("XPLEVEL") ! if (Level < 20): NextLevel = GemRB.GetTableValue (NextLevelTable, Class, str (Level + 1)) else: *************** *** 951,959 **** GemRB.SetPlayerStat (pc, IE_SAVEVSSPELL, SavThrows[4]) oldhp = GemRB.GetPlayerStat (pc, IE_HITPOINTS) ! GemRB.SetPlayerStat (pc, IE_HITPOINTS, HPBonus+oldhp) oldhp = GemRB.GetPlayerStat (pc, IE_MAXHITPOINTS) ! GemRB.SetPlayerStat (pc, IE_MAXHITPOINTS, HPBonus+oldhp) ! #this is not good in case of the nameless one, who is dual classed ! GemRB.SetPlayerStat (pc, IE_LEVEL, GemRB.GetPlayerStat (pc, IE_LEVEL)+1) UpdateRecordsWindow () --- 952,970 ---- GemRB.SetPlayerStat (pc, IE_SAVEVSSPELL, SavThrows[4]) oldhp = GemRB.GetPlayerStat (pc, IE_HITPOINTS) ! GemRB.SetPlayerStat (pc, IE_HITPOINTS, HPGained+oldhp) oldhp = GemRB.GetPlayerStat (pc, IE_MAXHITPOINTS) ! GemRB.SetPlayerStat (pc, IE_MAXHITPOINTS, 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) ! GemRB.SetPlayerStat (pc, IE_LEVEL2, GemRB.GetPlayerStat (pc, IE_LEVEL2)+NumOfSecoLevUp) UpdateRecordsWindow () *************** *** 962,968 **** global LevelUpWindow global SavThrows ! global HPBonus ! global FinalCurHP ! global FinalMaxHP GemRB.HideGUI () --- 973,979 ---- global LevelUpWindow global SavThrows ! global HPGained ! global WeapProfType, CurrWeapProf, WeapProfGained ! global NumOfPrimLevUp, NumOfSecoLevUp GemRB.HideGUI () *************** *** 990,993 **** --- 1001,1005 ---- BioTable = GemRB.LoadTable ("bios") Specific = "%d"%GemRB.GetPlayerStat (pc, IE_SPECIFIC) + AvatarName = GemRB.GetTableValue (BioTable, Specific, "PC") # These will be used for saving throws *************** *** 1004,1007 **** --- 1016,1040 ---- Thac0Updated = False Thac0 = 0 + WeapProfGained = 0 + + ClasWeapTable = GemRB.LoadTable ("weapprof") + WeapProfType = -1 + CurrWeapProf = -1 + #This does not apply to Nameless since he uses unused slots system + #Nameless is Specific == 1 + if Specific != "1": + # Searching for the column name where value is 1 + for i in range (5): + WeapProfName = GemRB.GetTableRowName (ClasWeapTable, i) + value = GemRB.GetTableValue (ClasWeapTable, AvatarName, WeapProfName) + if value == 1: + WeapProfType = i + break + + if WeapProfType!=-1: + CurrWeapProf = GemRB.GetPlayerStat (pc, IE_WEAPPROF+WeapProfType) + + # Recording this avatar's current proficiency level + # Since Nameless one is not covered, hammer and club can't occur # What is the avatar's class (Which we can use to lookup XP) ClassRow = GemRB.GetPlayerStat (pc, IE_CLASS)-1 *************** *** 1049,1055 **** while avatar_header['XP'] >= GetNextLevelExp (NextLevel, Class): NextLevel = NextLevel + 1 ! NumOfLevUp = NextLevel - avatar_header['PrimLevel'] # How many levels did we go up? # Is avatar Nameless One? ! if GemRB.GetTableValue (BioTable, Specific, "PC") == "NAMELESS_ONE": # Saving Throws # Nameless One gets the best possible throws from all the classes except Priest --- 1082,1089 ---- while avatar_header['XP'] >= GetNextLevelExp (NextLevel, Class): NextLevel = NextLevel + 1 ! NumOfPrimLevUp = NextLevel - avatar_header['PrimLevel'] # How many levels did we go up? ! # Is avatar Nameless One? ! if Specific == "1": # Saving Throws # Nameless One gets the best possible throws from all the classes except Priest *************** *** 1063,1073 **** --- 1097,1113 ---- MageLevel = GemRB.GetPlayerStat (pc, IE_LEVEL2) - 1 ThiefLevel = GemRB.GetPlayerStat (pc, IE_LEVEL3) - 1 + # this is the constitution bonus type for this level + CONType = 1 # We are leveling up one of those levels. Therefore, one of them has to be updated. if avatar_header['PrimClass'] == "Fighter": FighterLevel = NextLevel - 1 + CONType = 0 elif avatar_header['PrimClass'] == "Mage": MageLevel = NextLevel - 1 else: ThiefLevel = NextLevel - 1 + + ConHPBon = GetConHPBonus (pc, NumOfPrimLevUp, CONType) + # Now we need to update the saving throws with the best values from those tables. # The smaller the number, the better saving throw it is. *************** *** 1098,1101 **** --- 1138,1146 ---- GemRB.UnloadTable (ThiSavThrTable) else: + #How many weapon procifiencies we get + for i in range (NumOfPrimLevUp): + if HasGainedWeapProf (pc, CurrWeapProf + WeapProfGained, avatar_header['PrimLevel'] + i, avatar_header['PrimClass']): + WeapProfGained += 1 + # Saving Throws # Loading the right saving throw table *************** *** 1116,1122 **** # Hit Points Gained and Hit Points from Constitution Bonus ! for i in range (NumOfLevUp): HPGained = HPGained + GetSingleClassHP (Class, avatar_header['PrimLevel']) ! ConHPBon = ConHPBon + GetConHPBonus (pc) # Thac0 Thac0 = GetThac0 (Class, NextLevel) --- 1161,1169 ---- # Hit Points Gained and Hit Points from Constitution Bonus ! for i in range (NumOfPrimLevUp): HPGained = HPGained + GetSingleClassHP (Class, avatar_header['PrimLevel']) ! ! ConHPBon = GetConHPBonus (pc, NumOfPrimLevUp, 0) ! # Thac0 Thac0 = GetThac0 (Class, NextLevel) *************** *** 1127,1130 **** --- 1174,1179 ---- else: # avatar is multi class + # we have only fighter/X multiclasses, so this + # part is a bit hardcoded PrimNextLevel = 0 SecoNextLevel = 0 *************** *** 1139,1142 **** --- 1188,1195 ---- NumOfPrimLevUp = PrimNextLevel - avatar_header['PrimLevel'] + for i in range (NumOfPrimLevUp): + if HasGainedWeapProf (pc, CurrWeapProf + WeapProfGained, avatar_header['PrimLevel'] + i, avatar_header['PrimClass']): + WeapProfGained += 1 + # Saving Throws FigSavThrTable = GemRB.LoadTable ("SAVEWAR") *************** *** 1151,1184 **** if GemRB.GetPlayerStat (pc, IE_CLASS) == 7: # avatar is Fighter/Mage (Dak'kon) ! SecoNextLevel = avatar_header['SecoLevel'] ! while avatar_header['XP'] >= GetNextLevelExp (SecoNextLevel, "MAGE"): ! SecoNextLevel = SecoNextLevel + 1 ! # How many secondary levels did we go up? ! NumOfSecoLevUp = SecoNextLevel - avatar_header['SecoLevel'] ! MagSavThrTable = GemRB.LoadTable ("SAVEWIZ") ! if SecoNextLevel < 22: ! for i in range (5): ! Throw = GemRB.GetTableValue (MagSavThrTable, i, SecoNextLevel - 1) ! if Throw < SavThrows[i]: ! SavThrows[i] = Throw ! SavThrUpdated = True ! GemRB.UnloadTable (MagSavThrTable) else: # avatar is Fighter/Thief (Annah) ! SecoNextLevel = avatar_header['SecoLevel'] ! while avatar_header['XP'] >= GetNextLevelExp (SecoNextLevel, "THIEF"): ! SecoNextLevel = SecoNextLevel + 1 ! # How many secondary levels did we go up? ! NumOfSecoLevUp = SecoNextLevel - avatar_header['SecoLevel'] ! ThiSavThrTable = GemRB.LoadTable ("SAVEROG") ! if SecoNextLevel < 22: ! for i in range (5): ! Throw = GemRB.GetTableValue (ThiSavThrTable, i, SecoNextLevel - 1) ! if Throw < SavThrows[i]: ! SavThrows[i] = Throw ! SavThrUpdated = True ! GemRB.UnloadTable (ThiSavThrTable) ! # Hit Points Gained and Hit Points from Constitution Bonus ! print "TODO: Implement Multi-Class HP generation." # Thac0 --- 1204,1234 ---- if GemRB.GetPlayerStat (pc, IE_CLASS) == 7: # avatar is Fighter/Mage (Dak'kon) ! Class = "MAGE" ! SavThrTable = GemRB.LoadTable ("SAVEWIZ") else: # avatar is Fighter/Thief (Annah) ! Class = "THIEF" ! SavThrTable = GemRB.LoadTable ("SAVEROG") ! ! SecoNextLevel = avatar_header['SecoLevel'] ! while avatar_header['XP'] >= GetNextLevelExp (SecoNextLevel, Class): ! SecoNextLevel = SecoNextLevel + 1 ! # How many secondary levels did we go up? ! NumOfSecoLevUp = SecoNextLevel - avatar_header['SecoLevel'] ! if SecoNextLevel < 22: ! for i in range (5): ! Throw = GemRB.GetTableValue (SavThrTable, i, SecoNextLevel - 1) ! if Throw < SavThrows[i]: ! SavThrows[i] = Throw ! SavThrUpdated = True ! GemRB.UnloadTable (SavThrTable) ! ! # Hit Points Gained and Hit Points from Constitution Bonus (multiclass) ! for i in range (NumOfPrimLevUp): ! HPGained = HPGained + GetSingleClassHP ("FIGHTER", avatar_header['PrimLevel'])/2 ! ! for i in range (NumOfSecoLevUp): ! HPGained = HPGained + GetSingleClassHP (Class, avatar_header['SecoLevel'])/2 ! ConHPBon = GetConHPBonus (pc, NumOfPrimLevUp, NumOfSecoLevUp, 2) # Thac0 *************** *** 1207,1215 **** GemRB.SetText (Window, Label, str (SavThrows[4])) - # For some reason, Constitution Bonus is not added - # to the current HP in the IE version FinalCurHP = GemRB.GetPlayerStat (pc, IE_HITPOINTS) + HPGained ! HPBonus = ConHPBon + HPGained ! FinalMaxHP = GemRB.GetPlayerStat (pc, IE_MAXHITPOINTS) + HPBonus # Current HP --- 1257,1262 ---- GemRB.SetText (Window, Label, str (SavThrows[4])) FinalCurHP = GemRB.GetPlayerStat (pc, IE_HITPOINTS) + HPGained ! FinalMaxHP = GemRB.GetPlayerStat (pc, IE_MAXHITPOINTS) + HPGained # Current HP *************** *** 1223,1226 **** --- 1270,1276 ---- # Displaying level up info overview = "" + if CurrWeapProf!=-1 and WeapProfGained>0: + overview = overview + '+' + str (WeapProfGained) + ' ' + GemRB.GetString (WeapProfDispStr) + '\n' + overview = overview + str (HPGained) + " " + GemRB.GetString (38713) + '\n' overview = overview + str (ConHPBon) + " " + GemRB.GetString (38727) + '\n' *************** *** 1246,1250 **** Level = 20 ! # We need the Level as a string, so that we can use the collumn names Level = str (Level) --- 1296,1300 ---- Level = 20 ! # We need the Level as a string, so that we can use the column names Level = str (Level) *************** *** 1257,1277 **** return GemRB.Roll (Rolls, Sides, Modif) ! def GetConHPBonus (pc): ConHPBonTable = GemRB.LoadTable ("HPCONBON") - Class = GemRB.GetPlayerStat (pc, IE_CLASS) ! if Class == 2: ! # Fighter ! return GemRB.GetTableValue (ConHPBonTable, str (GemRB.GetPlayerStat (pc, IE_CON)), "WARRIOR") ! elif (Class == 7) or (Class == 9): ! # Fighter/Mage or Fighter/Thief ! # Just like HP, multi-class'es CON bonus is divided by the number of classes. In ! # case of Planescape, it is always two. Also since Annah and Dak'kon are Fighters, ! # Warrior collumn is used. ! return GemRB.GetTableValue (ConHPBonTable, str (GemRB.GetPlayerStat (pc, IE_CON)), "WARRIOR") / 2 ! else: # Mage, Priest or Thief ! return GemRB.GetTableValue (ConHPBonTable, str (GemRB.GetPlayerStat (pc, IE_CON)), "OTHER") ! def GetThac0 (Class, Level): --- 1307,1321 ---- return GemRB.Roll (Rolls, Sides, Modif) ! def GetConHPBonus (pc, fighterlevels, otherlevels, type): ConHPBonTable = GemRB.LoadTable ("HPCONBON") ! con = str (GemRB.GetPlayerStat (pc, IE_CON)) ! if type == 0: ! # Pure fighter ! return GemRB.GetTableValue (ConHPBonTable, con, "WARRIOR") * fighterlevels ! if type == 1: # Mage, Priest or Thief ! return GemRB.GetTableValue (ConHPBonTable, con, "OTHER") * otherlevels ! return GemRB.GetTableValue (ConHPBonTable, con, "WARRIOR") * fighterlevels / 2 + GemRB.GetTableValue (ConHPBonTable, con, "OTHER") * otherlevels / 2 def GetThac0 (Class, Level): *************** *** 1284,1287 **** --- 1328,1343 ---- return GemRB.GetTableValue (Thac0Table, Class, str (Level)) + #apparently the original code doesn't follow profsmax/profs tables + def HasGainedWeapProf (pc, currProf, currLevel, Class): + #only fighters gain weapon proficiencies + if Class!="FIGHTER": + return False + #hardcoded limit is 4 + if currProf>3: + return False + if CurrProf>(currLevel-1)/3: + return False + return True + ################################################### # End of file GUIREC.py |