From: <ave...@us...> - 2007-08-11 00:38:45
|
Revision: 4757 http://gemrb.svn.sourceforge.net/gemrb/?rev=4757&view=rev Author: avenger_teambg Date: 2007-08-10 17:38:43 -0700 (Fri, 10 Aug 2007) Log Message: ----------- FindTableValue can have an optional start row parameter iwd2: implemented favored race Modified Paths: -------------- gemrb/trunk/gemrb/GUIScripts/iwd2/CharGen9.py gemrb/trunk/gemrb/GUIScripts/iwd2/GUICommonWindows.py gemrb/trunk/gemrb/GUIScripts/iwd2/GUIREC.py gemrb/trunk/gemrb/docs/en/GUIScript/FindTableValue.txt gemrb/trunk/gemrb/override/iwd2/races.2da Modified: gemrb/trunk/gemrb/GUIScripts/iwd2/CharGen9.py =================================================================== --- gemrb/trunk/gemrb/GUIScripts/iwd2/CharGen9.py 2007-08-09 22:07:28 UTC (rev 4756) +++ gemrb/trunk/gemrb/GUIScripts/iwd2/CharGen9.py 2007-08-11 00:38:43 UTC (rev 4757) @@ -155,9 +155,26 @@ GemRB.SetEvent (CharGenWindow, BackButton, IE_GUI_BUTTON_ON_PRESS, "BackPress") GemRB.SetEvent (CharGenWindow, AcceptButton, IE_GUI_BUTTON_ON_PRESS, "NextPress") GemRB.SetEvent (CharGenWindow, BiographyButton, IE_GUI_BUTTON_ON_PRESS, "BioPress") - GemRB.SetVisible (CharGenWindow,1) + GemRB.SetVisible (CharGenWindow, 1) return +def SetRaceAbilities(MyChar, racetitle): + ability = GemRB.LoadTable ("racespab") + resource = GemRB.GetTableValue (ability, racetitle, "SPECIAL_ABILITIES_FILE") + GemRB.UnloadTable (ability) + if resource=="*": + return + + ability = GemRB.LoadTable (resource) + rows = GemRB.GetTableRowCount (ability) + for i in range(rows): + resource = GemRB.GetTableValue (ability, i, 0) + count = GemRB.GetTableValue (ability, i,1) + for j in range(count): + GemRB.LearnSpell (MyChar, resource) + GemRB.UnloadTable (ability) + return + def SetRaceResistances(MyChar, racetitle): resistances = GemRB.LoadTable ("racersmd") GemRB.SetPlayerStat (MyChar, IE_RESISTFIRE, GemRB.GetTableValue ( resistances, racetitle, "FIRE") ) @@ -243,7 +260,8 @@ row = GemRB.FindTableValue (TmpTable, 3, race ) racename = GemRB.GetTableRowName (TmpTable, row) if row!=-1: - SetRaceResistances( MyChar, GemRB.GetTableRowName (TmpTable, row) ) + SetRaceResistances( MyChar, racename ) + SetRaceAbilities( MyChar, racename ) GemRB.UnloadTable (TmpTable) #base class Modified: gemrb/trunk/gemrb/GUIScripts/iwd2/GUICommonWindows.py =================================================================== --- gemrb/trunk/gemrb/GUIScripts/iwd2/GUICommonWindows.py 2007-08-09 22:07:28 UTC (rev 4756) +++ gemrb/trunk/gemrb/GUIScripts/iwd2/GUICommonWindows.py 2007-08-11 00:38:43 UTC (rev 4757) @@ -265,19 +265,25 @@ GemRB.UnloadTable (Table) return RaceTitle -def GetActorClassTitle (actor): - ClassTitle = GemRB.GetPlayerStat (actor, IE_TITLE1) +#find the kit title for a given class (multiple kits are available) +def GetActorClassTitle (actor, Class): + #no idea if this still works + #ClassTitle = GemRB.GetPlayerStat (actor, IE_TITLE1) Kit = GemRB.GetPlayerStat (actor, IE_KIT) - Class = GemRB.GetPlayerStat (actor, IE_CLASS) ClassTable = GemRB.LoadTable ("classes") - if Kit==0x4000 or Kit==0: #pure class - ClassIndex = Class - else: #bad, because kit clashes with classid - ClassIndex = GemRB.FindTableValue (ClassTable, 2, Kit) + ClassTitle = GemRB.GetTableValue (ClassTable, Class, 0) + #the real class value + Class += 1 + row = 0 + while row>=0: + row = GemRB.FindTableValue (ClassTable, 3, Class, row) + if row<0: + break + if Kit&GemRB.GetTableValue (ClassTable, row, 2): + ClassTitle=GemRB.GetTableValue (ClassTable, row, 0) + break + row+=1 - if ClassTitle==0: - ClassTitle=GemRB.GetTableValue (ClassTable, ClassIndex, 0) - GemRB.UnloadTable (ClassTable) return ClassTitle Modified: gemrb/trunk/gemrb/GUIScripts/iwd2/GUIREC.py =================================================================== --- gemrb/trunk/gemrb/GUIScripts/iwd2/GUIREC.py 2007-08-09 22:07:28 UTC (rev 4756) +++ gemrb/trunk/gemrb/GUIScripts/iwd2/GUIREC.py 2007-08-11 00:38:43 UTC (rev 4757) @@ -176,13 +176,29 @@ return True return False -def GetFavoredClass (pc): - return "???" +def GetFavoredClass (pc, code): + if GemRB.GetPlayerStat (pc, IE_SEX)==1: + code = code&15 + else: + code = (code>>8)&15 + return code-1 + def GetAbilityBonus (pc, stat): Ability = GemRB.GetPlayerStat (pc, stat) return Ability//2-5 +#class is ignored +def GetNextLevelExp (Level, Adjustment): + NextLevelTable = GemRB.LoadTable ("XPLEVEL") + + if Adjustment>5: + Adjustment = 5 + if (Level < GemRB.GetTableColumnCount (NextLevelTable, 4) - 5): + return str(GemRB.GetTableValue (NextLevelTable, 4, Level + Adjustment ) ) + + return GemRB.GetString(24342) #godhood + #barbarian, bard, cleric, druid, fighter, monk, paladin, ranger, rogue, sorcerer, wizard Classes = [IE_LEVELBARBARIAN, IE_LEVELBARD, IE_LEVELCLERIC, IE_LEVELDRUID, \ IE_LEVEL, IE_LEVELMONK, IE_LEVELPALADIN, IE_LEVELRANGER, IE_LEVEL3, \ @@ -190,28 +206,54 @@ def DisplayGeneral (pc): Window = RecordsWindow - RaceTable = GemRB.LoadTable("races") - ClassTable = GemRB.LoadTable("classes") - AlignTable = GemRB.LoadTable("aligns") #levels GemRB.TextAreaAppend (Window, RecordsTextArea, "[color=ffff00]") GemRB.TextAreaAppend (Window, RecordsTextArea, 40308) GemRB.TextAreaAppend (Window, RecordsTextArea, " - ") GemRB.TextAreaAppend (Window, RecordsTextArea, 40309) - tmp = GemRB.GetPlayerStat (pc, IE_CLASSLEVELSUM) - GemRB.TextAreaAppend (Window, RecordsTextArea, ": "+str(tmp) ) + levelsum = GemRB.GetPlayerStat (pc, IE_CLASSLEVELSUM) + #TODO: get special level penalty for subrace + adj = 0 + GemRB.TextAreaAppend (Window, RecordsTextArea, ": "+str(levelsum) ) GemRB.TextAreaAppend (Window, RecordsTextArea, "[/color]\n") + #the class name for highest + highest = None + tmp = 0 for i in range(11): level = GemRB.GetPlayerStat (pc, Classes[i]) + if level: - Class = GemRB.GetTableValue (ClassTable, i, 0) + Class = GetActorClassTitle (pc, i ) GemRB.TextAreaAppend (Window, RecordsTextArea, Class, -1) GemRB.TextAreaAppend (Window, RecordsTextArea, ": "+str(level) ) + if tmp<level: + highest = i + tmp = level GemRB.TextAreaAppend (Window, RecordsTextArea, 40310,-1) - GemRB.TextAreaAppend (Window, RecordsTextArea, ": "+GetFavoredClass(pc) ) + RaceTable = GemRB.LoadTable("races") + ClassTable = GemRB.LoadTable("classes") + AlignTable = GemRB.LoadTable("aligns") + + #get the subrace value + Value = GemRB.GetPlayerStat(pc,IE_RACE) + Value2 = GemRB.GetPlayerStat(pc,IE_SUBRACE) + if Value2: + Value = Value<<16 | Value2 + tmp = GemRB.FindTableValue (RaceTable, 3, Value) + Race = GemRB.GetTableValue (RaceTable, tmp, 2) + tmp = GemRB.GetTableValue (RaceTable, tmp, 8) + if tmp == -1: + tmp = highest + else: + tmp = GetFavoredClass(pc, tmp) + + tmp = GemRB.GetTableValue (ClassTable, tmp, 0) + GemRB.TextAreaAppend (Window, RecordsTextArea, ": ") + GemRB.TextAreaAppend (Window, RecordsTextArea, tmp) + #experience GemRB.TextAreaAppend (Window, RecordsTextArea, "\n\n[color=ffff00]") GemRB.TextAreaAppend (Window, RecordsTextArea, 17089) @@ -221,7 +263,8 @@ xp = GemRB.GetPlayerStat (pc, IE_XP) GemRB.TextAreaAppend (Window, RecordsTextArea, ": "+str(xp) ) GemRB.TextAreaAppend (Window, RecordsTextArea, 17091,-1) - GemRB.TextAreaAppend (Window, RecordsTextArea, ": " ) + tmp = GetNextLevelExp (levelsum, adj) + GemRB.TextAreaAppend (Window, RecordsTextArea, ": "+tmp ) #current effects GemRB.TextAreaAppend (Window, RecordsTextArea, "\n\n[color=ffff00]") @@ -239,12 +282,6 @@ GemRB.TextAreaAppend (Window, RecordsTextArea, 1048) GemRB.TextAreaAppend (Window, RecordsTextArea, "[/color]") - Value = GemRB.GetPlayerStat(pc,IE_RACE) - Value2 = GemRB.GetPlayerStat(pc,IE_SUBRACE) - if Value2: - Value = Value<<16 | Value2 - tmp = GemRB.FindTableValue (RaceTable, 3, Value) - Race = GemRB.GetTableValue (RaceTable, tmp, 2) GemRB.TextAreaAppend (Window, RecordsTextArea, Race,-1) #alignment Modified: gemrb/trunk/gemrb/docs/en/GUIScript/FindTableValue.txt =================================================================== --- gemrb/trunk/gemrb/docs/en/GUIScript/FindTableValue.txt 2007-08-09 22:07:28 UTC (rev 4756) +++ gemrb/trunk/gemrb/docs/en/GUIScript/FindTableValue.txt 2007-08-11 00:38:43 UTC (rev 4757) @@ -1,11 +1,15 @@ -Prototype: GemRB.FindTableValue(TableIndex, ColumnIndex, Value) +Prototype: GemRB.FindTableValue(TableIndex, ColumnIndex, Value[, Start]) -Description: Returns the first rowcount of a field of a 2DA Table. +Description: Returns the first rowcount of a field value in a 2DA Table. If Start +is omitted, the search starts from the beginning. This command doesn't work with +a string value. Parameters: -TableIndex - returned by a previous LoadTable command. -ColumnIndex - the index of the column in which you look for the value. +TableIndex - integer, returned by a previous LoadTable command. +ColumnIndex - integer, the index of the column in which you look for the value. +Value - integer, The value to find in the table +Start - integer, The starting row Return value: numeric, -1 if the value isn't to be found Modified: gemrb/trunk/gemrb/override/iwd2/races.2da =================================================================== --- gemrb/trunk/gemrb/override/iwd2/races.2da 2007-08-09 22:07:28 UTC (rev 4756) +++ gemrb/trunk/gemrb/override/iwd2/races.2da 2007-08-11 00:38:43 UTC (rev 4757) @@ -1,19 +1,19 @@ 2DA V1.0 -1 - NAME_REF DESC_REF CAP_REF ID USABILITY HAIR SKIN SKILL_COLUMN -HUMAN 7193 9550 1096 1 0x08000000 HAIRNORM SKINNORM 23 -DWARF 7182 9551 1100 4 0x01000000 HAIRNORM SKINNORM 29 -ELF 7194 9552 1097 2 0x00800000 HAIRNORM SKINNORM 26 -GNOME 7196 9553 1099 6 0x10000000 HAIRNORM SKINNORM 35 -HALF_ELF 7197 9555 1098 3 0x02000000 HAIRNORM SKINNORM 37 -HALF_ORC 22 25 23 7 0x80000000 HAIRNORM SKINNORM 38 -HALFLING 7195 9554 5374 5 0x04000000 HAIRNORM SKINNORM 32 -HUMAN_AASIMAR 5377 5386 5377 0x10001 0x00000000 HAIRAASM SKINAASM 24 -HUMAN_TIEFLING 5378 5388 5378 0x10002 0x00000000 HAIRTIEF SKINTIEF 25 -ELF_DROW 5379 5394 5379 0x20001 0x00000000 HAIRDARK SKINDARK 27 -ELF_WILD 5380 5397 5380 0x20002 0x00000000 HAIRWOOD SKINWOOD 28 -DWARF_GOLD 5381 5413 5381 0x40001 0x00000000 HAIRGOLD SKINGOLD 30 -DWARF_GRAY 5382 5416 5382 0x40002 0x00000000 HAIRGRAY SKINGRAY 31 -HALFLING_STRONGHEART 5383 5660 5383 0x50001 0x00000000 HAIRNORM SKINNORM 33 -HALFLING_GHOSTWISE 5384 5661 5384 0x50002 0x00000000 HAIRNORM SKINNORM 34 -GNOME_DEEP 5385 5662 5385 0x60001 0x00000000 HAIRNORM SKINNORM 36 + NAME_REF DESC_REF CAP_REF ID USABILITY HAIR SKIN SKILL_COLUMN FAVORED_CLASS +HUMAN 7193 9550 1096 1 0x08000000 HAIRNORM SKINNORM 23 -1 +DWARF 7182 9551 1100 4 0x01000000 HAIRNORM SKINNORM 29 0x505 +ELF 7194 9552 1097 2 0x00800000 HAIRNORM SKINNORM 26 0xb0b +GNOME 7196 9553 1099 6 0x10000000 HAIRNORM SKINNORM 35 0xb0b +HALF_ELF 7197 9555 1098 3 0x02000000 HAIRNORM SKINNORM 37 -1 +HALF_ORC 22 25 23 7 0x80000000 HAIRNORM SKINNORM 38 0x101 +HALFLING 7195 9554 5374 5 0x04000000 HAIRNORM SKINNORM 32 0x909 +HUMAN_AASIMAR 5377 5386 5377 0x10001 0x00000000 HAIRAASM SKINAASM 24 0x707 +HUMAN_TIEFLING 5378 5388 5378 0x10002 0x00000000 HAIRTIEF SKINTIEF 25 0x909 +ELF_DROW 5379 5394 5379 0x20001 0x00000000 HAIRDARK SKINDARK 27 0x30b +ELF_WILD 5380 5397 5380 0x20002 0x00000000 HAIRWOOD SKINWOOD 28 0xa0a +DWARF_GOLD 5381 5413 5381 0x40001 0x00000000 HAIRGOLD SKINGOLD 30 0x505 +DWARF_GRAY 5382 5416 5382 0x40002 0x00000000 HAIRGRAY SKINGRAY 31 0x505 +HALFLING_STRONGHEART 5383 5660 5383 0x50001 0x00000000 HAIRNORM SKINNORM 33 0x909 +HALFLING_GHOSTWISE 5384 5661 5384 0x50002 0x00000000 HAIRNORM SKINNORM 34 0x101 +GNOME_DEEP 5385 5662 5385 0x60001 0x00000000 HAIRNORM SKINNORM 36 0xb0b This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |