2 from GUIDefines
import *
8 import LUProfsSelection
11 GemRB
.SetToken("NextScript","CharGen")
12 GemRB
.SetNextScript("ImportFile") #import
16 MyChar
= GemRB
.GetVar ("Slot")
17 GemRB
.CreatePlayer ("charbase", MyChar |
0x8000 )
21 MyChar
= GemRB
.GetVar ("Slot")
22 GemRB
.CreatePlayer ("", MyChar |
0x8000 )
27 MyChar
= GemRB
.GetVar ("Slot")
28 GemRB
.SetPlayerStat (MyChar
, IE_SEX
, 0)
31 #print "unset Portrait"
32 GemRB
.SetToken("SmallPortrait","")
33 GemRB
.SetToken("LargePortrait","")
36 MyChar
= GemRB
.GetVar ("Slot")
39 if GemRB
.GetPlayerStat(MyChar
,IE_SEX
) == 1:
40 return area
.Append(1050)
42 return area
.Append(1051)
46 MyChar
= GemRB
.GetVar ("Slot")
47 GemRB
.SetPlayerStat (MyChar
, IE_RACE
, 0)
50 MyChar
= GemRB
.GetVar ("Slot")
51 RaceID
= GemRB
.GetPlayerStat (MyChar
, IE_RACE
)
52 RaceIndex
= CommonTables
.Races
.FindValue(3,RaceID
)
53 RaceCap
= CommonTables
.Races
.GetValue(RaceIndex
,2)
54 area
.Append(1048,-1) # new line
60 MyChar
= GemRB
.GetVar ("Slot")
61 GemRB
.SetPlayerStat (MyChar
, IE_CLASS
, 0)
62 GemRB
.SetPlayerStat (MyChar
, IE_KIT
, 0)
65 MyChar
= GemRB
.GetVar ("Slot")
66 ClassTitle
= GUICommon
.GetActorClassTitle(MyChar
)
68 area
.Append(12136, -1)
70 area
.Append(ClassTitle
)
72 def guardSpecialist():
73 return GemRB
.GetVar("Specialist") == 1
75 def guardMultiClass():
76 return GemRB
.GetVar("Multi Class") == 1
81 MyChar
= GemRB
.GetVar ("Slot")
82 GemRB
.SetPlayerStat (MyChar
, IE_ALIGNMENT
,0)
84 def getAlignment(area
):
85 AlignmentTable
= GemRB
.LoadTable("aligns")
87 MyChar
= GemRB
.GetVar ("Slot")
88 AllignID
= GemRB
.GetPlayerStat (MyChar
, IE_ALIGNMENT
)
92 AllignIndex
= AlignmentTable
.FindValue(3,AllignID
)
93 AllignCap
= AlignmentTable
.GetValue(AllignIndex
,2)
94 area
.Append(AllignCap
)
99 MyChar
= GemRB
.GetVar ("Slot")
100 AbilityTable
= GemRB
.LoadTable ("ability")
101 AbilityCount
= AbilityTable
.GetRowCount ()
103 # set all our abilites to zero
104 GemRB
.SetPlayerStat (MyChar
, IE_STREXTRA
, 0)
105 for i
in range(AbilityCount
):
106 StatID
= AbilityTable
.GetValue (i
, 3)
107 GemRB
.SetPlayerStat (MyChar
, StatID
, 0)
109 def getAbilities(area
):
110 MyChar
= GemRB
.GetVar ("Slot")
111 AbilityTable
= GemRB
.LoadTable ("ability")
112 AbilityCount
= AbilityTable
.GetRowCount ()
113 for i
in range(AbilityCount
):
114 v
= AbilityTable
.GetValue(i
,2)
115 id = AbilityTable
.GetValue(i
,3)
117 area
.Append(": "+str(GemRB
.GetPlayerStat(MyChar
,id)))
123 MyChar
= GemRB
.GetVar ("Slot")
124 GemRB
.SetPlayerStat(MyChar
, IE_HATEDRACE
, 0 )
127 MyChar
= GemRB
.GetVar ("Slot")
128 Class
= GemRB
.GetPlayerStat(MyChar
,IE_CLASS
)
129 ClassName
= CommonTables
.ClassSkills
.GetRowName(Class
)
130 TableName
= CommonTables
.ClassSkills
.GetValue(ClassName
, "HATERACE")
131 return TableName
!= "*"
133 def getHatedRace(TextAreaControl
):
134 MyChar
= GemRB
.GetVar ("Slot")
135 Race
= GemRB
.GetPlayerStat(MyChar
, IE_HATEDRACE
)
137 HateRaceTable
= GemRB
.LoadTable ("HATERACE")
138 Row
= HateRaceTable
.FindValue (1, Race
)
139 info
= GemRB
.GetString (HateRaceTable
.GetValue(Row
, 0))
141 #TextAreaControl.Append("\n")
142 info
= ": " + info
+ "\n"
143 TextAreaControl
.Append(15982)
144 TextAreaControl
.Append(info
)
146 def unsetMageSpells():
147 print("unsetMageSpells")
148 MyChar
= GemRB
.GetVar ("Slot")
150 GUICommon
.RemoveKnownSpells (MyChar
, IE_SPELL_TYPE_WIZARD
, 1, 5, 1)
152 def guardMageSpells():
153 MyChar
= GemRB
.GetVar ("Slot")
154 Class
= GemRB
.GetPlayerStat(MyChar
,IE_CLASS
)
155 TableName
= CommonTables
.ClassSkills
.GetValue(Class
, 2)
156 return TableName
!= "*"
158 def getMageSpells(TextAreaControl
):
159 MyChar
= GemRB
.GetVar ("Slot")
162 for level
in range(0, 9):
163 for j
in range(0, GemRB
.GetKnownSpellsCount (MyChar
, IE_SPELL_TYPE_WIZARD
, level
) ):
164 Spell
= GemRB
.GetKnownSpell (MyChar
, IE_SPELL_TYPE_WIZARD
, level
, j
)
165 Spell
= GemRB
.GetSpell (Spell
['SpellResRef'], 1)['SpellName']
166 info
+= GemRB
.GetString (Spell
) + "\n"
168 info
= "\n" + info
+ "\n"
169 TextAreaControl
.Append (11027)
170 TextAreaControl
.Append (info
)
173 SkillTable
= GemRB
.LoadTable("skills")
174 RowCount
= SkillTable
.GetRowCount()-2
176 MyChar
= GemRB
.GetVar ("Slot")
177 Kit
= GemRB
.GetPlayerStat (MyChar
, IE_KIT
)
180 KitName
= CommonTables
.KitList
.GetValue(Kit
, 0) #rowname is just a number
181 PointsLeft
= SkillTable
.GetValue("FIRST_LEVEL",KitName
)
186 ClassID
= GemRB
.GetPlayerStat (MyChar
, IE_CLASS
)
187 ClassIndex
= CommonTables
.Classes
.FindValue(5,ClassID
)
188 KitName
= CommonTables
.Classes
.GetRowName(ClassIndex
)
190 for i
in range(RowCount
):
191 SkillName
= SkillTable
.GetRowName(i
+2)
192 if SkillTable
.GetValue(SkillName
, KitName
)==1:
198 import LUSkillsSelection
199 MyChar
= GemRB
.GetVar ("Slot")
200 LUSkillsSelection
.SkillsNullify ()
201 LUSkillsSelection
.SkillsSave (MyChar
)
203 def getSkills(TextAreaControl
):
204 MyChar
= GemRB
.GetVar ("Slot")
205 # thieving and other skills
207 SkillTable
= GemRB
.LoadTable ("skills")
208 ClassID
= GemRB
.GetPlayerStat (MyChar
, IE_CLASS
)
209 Class
= CommonTables
.Classes
.FindValue (5, ClassID
)
210 ClassName
= CommonTables
.Classes
.GetRowName(Class
)
211 RangerSkills
= CommonTables
.ClassSkills
.GetValue (ClassName
, "RANGERSKILL")
212 BardSkills
= CommonTables
.ClassSkills
.GetValue (ClassName
, "BARDSKILL")
213 KitName
= GUICommon
.GetKitIndex (MyChar
)
217 KitName
= CommonTables
.KitList
.GetValue (KitName
, 0)
219 if SkillTable
.GetValue ("RATE", KitName
) != -1 or BardSkills
!= "*" or RangerSkills
!= "*":
220 for skill
in range(SkillTable
.GetRowCount () - 2):
221 name
= GemRB
.GetString (SkillTable
.GetValue (skill
+2, 1))
222 id = SkillTable
.GetValue (skill
+2, 2)
223 available
= SkillTable
.GetValue (SkillTable
.GetRowName (skill
+2), KitName
)
224 value
= GemRB
.GetPlayerStat(MyChar
,id)
225 if value
>= 0 and available
!= -1:
226 info
+= name
+ ": " + str(value
) + "\n"
229 info
= "\n" + info
+ "\n"
230 TextAreaControl
.Append("\n")
231 TextAreaControl
.Append (8442)
232 TextAreaControl
.Append (info
)
235 MyChar
= GemRB
.GetVar ("Slot")
236 LUProfsSelection
.ProfsNullify ()
237 LUProfsSelection
.ProfsSave(MyChar
, LUProfsSelection
.LUPROFS_TYPE_CHARGEN
)
239 def getProfi(TextAreaControl
):
240 MyChar
= GemRB
.GetVar ("Slot")
241 # weapon proficiencies
242 TextAreaControl
.Append ("\n")
243 TextAreaControl
.Append (9466)
244 TextAreaControl
.Append ("\n")
245 TmpTable
=GemRB
.LoadTable ("weapprof")
246 ProfCount
= TmpTable
.GetRowCount ()
247 #bg2 weapprof.2da contains the bg1 proficiencies too, skipping those
248 for i
in range(ProfCount
):
249 # 4294967296 overflows to -1 on some arches, so we use a smaller invalid strref
250 id = TmpTable
.GetValue (i
, 0)+IE_PROFICIENCYBASTARDSWORD
251 Weapon
= GemRB
.GetString (TmpTable
.GetValue (i
, 1))
252 Value
= GemRB
.GetPlayerStat (MyChar
,id)
255 for plus
in range(0, Value
):
257 TextAreaControl
.Append (Weapon
+ pluses
+ "\n")
261 MyChar
= GemRB
.GetVar ("Slot")
262 GUICommon
.SetColorStat (MyChar
, IE_HAIR_COLOR
, 0 )
263 GUICommon
.SetColorStat (MyChar
, IE_SKIN_COLOR
, 0 )
264 GUICommon
.SetColorStat (MyChar
, IE_MAJOR_COLOR
, 0 )
265 GUICommon
.SetColorStat (MyChar
, IE_MINOR_COLOR
, 0 )
268 MyChar
= GemRB
.GetVar ("Slot")
269 GemRB
.SetPlayerSound(MyChar
,"")
274 MyChar
= GemRB
.GetVar ("Slot")
275 GemRB
.SetPlayerName (MyChar
, "", 0)
277 def getName(TextAreaControl
):
278 MyChar
= GemRB
.GetVar ("Slot")
279 name
= GemRB
.GetPlayerName(MyChar
)
281 TextAreaControl
.Append(name
+ "\n")
284 def setDivineSpells():
285 MyChar
= GemRB
.GetVar ("Slot")
287 ClassID
= GemRB
.GetPlayerStat (MyChar
, IE_CLASS
)
288 Class
= CommonTables
.Classes
.FindValue (5, ClassID
)
289 ClassName
= CommonTables
.Classes
.GetRowName(Class
)
291 DruidTable
= CommonTables
.ClassSkills
.GetValue (ClassName
, "DRUIDSPELL")
292 ClericTable
= CommonTables
.ClassSkills
.GetValue (ClassName
, "CLERICSPELL")
294 print("CGG setDivineSpells: CP1",ClassID
,Class
,ClassName
,DruidTable
,ClericTable
)
296 AllignID
= GemRB
.GetPlayerStat (MyChar
, IE_ALIGNMENT
)
298 if ClericTable
!= "*":
299 learnDivine(MyChar
,0x4000,ClericTable
,AllignID
)
300 if DruidTable
!= "*":
301 learnDivine(MyChar
,0x8000,DruidTable
,AllignID
)
305 def learnDivine(MyChar
,ClassFlag
,TableName
,AllignID
):
306 #print ("CGG setDivineSpells: CP2",MyChar,ClassFlag,TableName,AllignID )
307 GUICommon
.SetupSpellLevels(MyChar
, TableName
, IE_SPELL_TYPE_PRIEST
, 1)
308 Learnable
= GUICommon
.GetLearnablePriestSpells( ClassFlag
, AllignID
, 1)
309 for i
in range(len(Learnable
) ):
310 #print ("CGG setDivineSpells: CP3",Learnable[i])
311 if -1 == GUICommon
.HasSpell(MyChar
,IE_SPELL_TYPE_PRIEST
,1,Learnable
[i
]):
312 #print ("CGG setDivineSpells: CP4",Learnable[i])
313 GemRB
.LearnSpell (MyChar
, Learnable
[i
], 0)
315 def unsetDivineSpells():
316 print("unsetDivineSpells")
317 MyChar
= GemRB
.GetVar ("Slot")
318 GUICommon
.RemoveKnownSpells (MyChar
, IE_SPELL_TYPE_PRIEST
, 1, 1, 1)
320 def getDivineSpells(TextAreaControl
):
321 MyChar
= GemRB
.GetVar ("Slot")
324 for level
in range(0, 7):
325 for j
in range(0, GemRB
.GetKnownSpellsCount (MyChar
, IE_SPELL_TYPE_PRIEST
, level
) ):
326 Spell
= GemRB
.GetKnownSpell (MyChar
, IE_SPELL_TYPE_PRIEST
, level
, j
)
327 Spell
= GemRB
.GetSpell (Spell
['SpellResRef'], 1)['SpellName']
328 info
+= GemRB
.GetString (Spell
) + "\n"
330 info
= "\n" + info
+ "\n"
331 TextAreaControl
.Append (11028)
332 TextAreaControl
.Append (info
)
337 MyChar
= GemRB
.GetVar ("Slot")
339 ClassID
= GemRB
.GetPlayerStat (MyChar
, IE_CLASS
)
340 Class
= CommonTables
.Classes
.FindValue (5, ClassID
)
341 ClassName
= CommonTables
.Classes
.GetRowName(Class
)
344 AllignID
= GemRB
.GetPlayerStat (MyChar
, IE_ALIGNMENT
)
346 TmpTable
=GemRB
.LoadTable ("repstart")
347 AlignmentTable
= GemRB
.LoadTable ("aligns")
348 t
= TmpTable
.GetValue (AllignID
,0) * 10
349 GemRB
.SetPlayerStat (MyChar
, IE_REPUTATION
, t
)
351 #lore, thac0, hp, and saves
352 GemRB
.SetPlayerStat (MyChar
, IE_MAXHITPOINTS
, 0)
353 GemRB
.SetPlayerStat (MyChar
, IE_HITPOINTS
, 0)
354 LUCommon
.SetupSavingThrows (MyChar
)
355 LUCommon
.SetupThaco (MyChar
)
356 LUCommon
.SetupLore (MyChar
)
357 LUCommon
.SetupHP (MyChar
)
359 #slot 1 is the protagonist
361 GemRB
.GameSetReputation( t
)
364 TmpTable
=GemRB
.LoadTable ("strtgold")
365 t
= GemRB
.Roll (TmpTable
.GetValue (ClassName
,"ROLLS"),TmpTable
.GetValue(ClassName
,"SIDES"), TmpTable
.GetValue (ClassName
,"MODIFIER") )
366 GemRB
.SetPlayerStat (MyChar
, IE_GOLD
, t
*TmpTable
.GetValue (ClassName
,"MULTIPLIER") )
368 #set the base number of attacks; effects will add the proficiency bonus
369 GemRB
.SetPlayerStat (MyChar
, IE_NUMBEROFATTACKS
, 2)
372 GUICommon
.SetColorStat (MyChar
, IE_METAL_COLOR
, 0x1B )
373 GUICommon
.SetColorStat (MyChar
, IE_LEATHER_COLOR
, 0x16 )
374 GUICommon
.SetColorStat (MyChar
, IE_ARMOR_COLOR
, 0x17 )
377 LargePortrait
= GemRB
.GetToken ("LargePortrait")
378 SmallPortrait
= GemRB
.GetToken ("SmallPortrait")
379 GemRB
.FillPlayerInfo (MyChar
, LargePortrait
, SmallPortrait
)
380 #10 is a weapon slot (see slottype.2da row 10)
381 GemRB
.CreateItem (MyChar
, "staf01", 10, 1, 0, 0)
382 GemRB
.SetEquippedQuickSlot (MyChar
, 0)
384 playmode
= GemRB
.GetVar ("PlayMode")
386 GUICommon
.CloseOtherWindow(None)
389 CharGenCommon
.close()
390 if GemRB
.GetVar("GUIEnhancements"):
391 GemRB
.SaveCharacter ( GemRB
.GetVar ("Slot"), "gembak" )
394 #show the export window
395 GemRB
.SetToken("NextScript","CharGen")
396 GemRB
.SetNextScript ("ExportFile")