1 # GemRB - Infinity Engine Emulator
2 # Copyright (C) 2003 The GemRB Project
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #character generation, ability (GUICG4)
23 from ie_stats
import *
24 from GUIDefines
import *
42 def CalcLimits(Abidx
):
43 global Minimum
, Maximum
, Add
45 Race
= CommonTables
.Races
.FindValue (3, GemRB
.GetPlayerStat (MyChar
, IE_RACE
) )
46 RaceName
= CommonTables
.Races
.GetRowName(Race
)
51 tmp
= Abclasrq
.GetValue(KitIndex
, Abidx
)
52 if tmp
!=0 and tmp
>Minimum
:
55 Race
= Abracerq
.GetRowIndex(RaceName
)
56 tmp
= Abracerq
.GetValue(Race
, Abidx
*2)
57 if tmp
!=0 and tmp
>Minimum
:
60 tmp
= Abracerq
.GetValue(Race
, Abidx
*2+1)
61 if tmp
!=0 and tmp
>Maximum
:
64 Race
= Abracead
.GetRowIndex(RaceName
)
65 Add
= Abracead
.GetValue(Race
, Abidx
) + Abclsmod
.GetValue(KitIndex
, Abidx
)
66 Maximum
= Maximum
+ Add
67 Minimum
= Minimum
+ Add
76 global Minimum
, Maximum
, Add
, HasStrExtra
, PointsLeft
78 GemRB
.SetVar("Ability",0)
79 GemRB
.SetVar("Ability -1",0)
81 SumLabel
= AbilityWindow
.GetControl(0x10000002)
86 e
= GemRB
.Roll(1,100,0)
89 GemRB
.SetVar("StrExtra", e
)
94 v
= GemRB
.Roll(dice
, size
, Add
+3)
99 GemRB
.SetVar("Ability "+str(i
), v
)
100 Label
= AbilityWindow
.GetControl(0x10000003+i
)
101 if i
==0 and v
==18 and HasStrExtra
:
102 Label
.SetText("18/"+str(e
) )
104 Label
.SetText(str(v
) )
109 global AbilityWindow
, TextAreaControl
, DoneButton
110 global PointsLeft
, HasStrExtra
111 global AbilityTable
, Abclasrq
, Abclsmod
, Abracerq
, Abracead
112 global KitIndex
, Minimum
, Maximum
, MyChar
114 Abracead
= GemRB
.LoadTable("ABRACEAD")
115 Abclsmod
= GemRB
.LoadTable("ABCLSMOD")
116 Abclasrq
= GemRB
.LoadTable("ABCLASRQ")
117 Abracerq
= GemRB
.LoadTable("ABRACERQ")
119 MyChar
= GemRB
.GetVar ("Slot")
120 Kit
= GUICommon
.GetKitIndex (MyChar
)
121 Class
= GemRB
.GetPlayerStat (MyChar
, IE_CLASS
)
122 Class
= CommonTables
.Classes
.FindValue (5, Class
)
124 KitName
= CommonTables
.Classes
.GetRowName(Class
)
126 #rowname is just a number, first value row what we need here
127 KitName
= CommonTables
.KitList
.GetValue(Kit
, 0)
129 #if the class uses the warrior table for saves, then it may have the extra strength
130 if CommonTables
.Classes
.GetValue(Class
, 3)=="SAVEWAR":
135 KitIndex
= Abclasrq
.GetRowIndex(KitName
)
137 GemRB
.LoadWindowPack("GUICG", 640, 480)
138 AbilityTable
= GemRB
.LoadTable("ability")
139 AbilityWindow
= GemRB
.LoadWindow(4)
141 RerollButton
= AbilityWindow
.GetControl(2)
142 RerollButton
.SetText(11982)
143 StoreButton
= AbilityWindow
.GetControl(37)
144 StoreButton
.SetText(17373)
145 RecallButton
= AbilityWindow
.GetControl(38)
146 RecallButton
.SetText(17374)
148 BackButton
= AbilityWindow
.GetControl(36)
149 BackButton
.SetText(15416)
150 BackButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
151 DoneButton
= AbilityWindow
.GetControl(0)
152 DoneButton
.SetText(11973)
153 DoneButton
.SetFlags(IE_GUI_BUTTON_DEFAULT
,OP_OR
)
154 DoneButton
.SetState(IE_GUI_BUTTON_ENABLED
)
159 Label
= AbilityWindow
.GetControl(i
+0x10000009)
160 Label
.SetEvent(IE_GUI_LABEL_ON_PRESS
, eval("OverPress"+str(i
)))
161 Button
= AbilityWindow
.GetControl(i
+30)
162 Button
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, JustPress
)
163 Button
.SetEvent(IE_GUI_MOUSE_LEAVE_BUTTON
, EmptyPress
)
164 Button
.SetVarAssoc("Ability", i
)
166 Button
= AbilityWindow
.GetControl(i
*2+16)
167 Button
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, LeftPress
)
168 Button
.SetVarAssoc("Ability", i
)
170 Button
= AbilityWindow
.GetControl(i
*2+17)
171 Button
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, RightPress
)
172 Button
.SetVarAssoc("Ability", i
)
174 TextAreaControl
= AbilityWindow
.GetControl(29)
175 TextAreaControl
.SetText(17247)
177 StoreButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, StorePress
)
178 RecallButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, RecallPress
)
179 RerollButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, RollPress
)
180 DoneButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, NextPress
)
181 BackButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, BackPress
)
182 AbilityWindow
.SetVisible(WINDOW_VISIBLE
)
183 GemRB
.SetRepeatClickFlags(GEM_RK_DISABLE
, OP_NAND
)
189 Abidx
= GemRB
.GetVar("Ability")
190 Ability
= GemRB
.GetVar("Ability "+str(Abidx
) )
192 GemRB
.SetToken("MINIMUM",str(Minimum
) )
193 GemRB
.SetToken("MAXIMUM",str(Maximum
) )
194 TextAreaControl
.SetText(AbilityTable
.GetValue(Abidx
, 1) )
197 GemRB
.SetVar("Ability "+str(Abidx
), Ability
-1)
198 PointsLeft
= PointsLeft
+ 1
199 GemRB
.SetVar("Ability -1",PointsLeft
)
200 SumLabel
= AbilityWindow
.GetControl(0x10000002)
201 SumLabel
.SetText(str(PointsLeft
) )
202 Label
= AbilityWindow
.GetControl(0x10000003+Abidx
)
203 StrExtra
= GemRB
.GetVar("StrExtra")
204 if Abidx
==0 and Ability
==19 and StrExtra
:
205 Label
.SetText("18/"+str(StrExtra
) )
207 Label
.SetText(str(Ability
-1) )
211 Abidx
= GemRB
.GetVar("Ability")
212 Ability
= GemRB
.GetVar("Ability "+str(Abidx
) )
214 GemRB
.SetToken("MINIMUM",str(Minimum
) )
215 GemRB
.SetToken("MAXIMUM",str(Maximum
) )
216 TextAreaControl
.SetText(AbilityTable
.GetValue(Abidx
, 1) )
222 Abidx
= GemRB
.GetVar("Ability")
223 Ability
= GemRB
.GetVar("Ability "+str(Abidx
) )
225 GemRB
.SetToken("MINIMUM",str(Minimum
) )
226 GemRB
.SetToken("MAXIMUM",str(Maximum
) )
227 TextAreaControl
.SetText(AbilityTable
.GetValue(Abidx
, 1) )
230 if Ability
>=Maximum
: #should be more elaborate
232 GemRB
.SetVar("Ability "+str(Abidx
), Ability
+1)
233 PointsLeft
= PointsLeft
- 1
234 GemRB
.SetVar("Ability -1",PointsLeft
)
235 SumLabel
= AbilityWindow
.GetControl(0x10000002)
236 SumLabel
.SetText(str(PointsLeft
) )
237 Label
= AbilityWindow
.GetControl(0x10000003+Abidx
)
238 StrExtra
= GemRB
.GetVar("StrExtra")
239 if Abidx
==0 and Ability
==17 and HasStrExtra
==1:
240 Label
.SetText("18/%02d"%(StrExtra) )
242 Label
.SetText(str(Ability
+1) )
246 TextAreaControl
= AbilityWindow
.GetControl(29)
247 TextAreaControl
.SetText(17247)
251 GemRB
.SetVar("StoredStrExtra",GemRB
.GetVar("StrExtra") )
252 for i
in range(-1,6):
253 GemRB
.SetVar("Stored "+str(i
),GemRB
.GetVar("Ability "+str(i
) ) )
259 e
=GemRB
.GetVar("StoredStrExtra")
260 GemRB
.SetVar("StrExtra",e
)
261 for i
in range(-1,6):
262 v
= GemRB
.GetVar("Stored "+str(i
) )
263 GemRB
.SetVar("Ability "+str(i
), v
)
264 Label
= AbilityWindow
.GetControl(0x10000003+i
)
265 if i
==0 and v
==18 and HasStrExtra
==1:
266 Label
.SetText("18/"+str(e
) )
268 Label
.SetText(str(v
) )
270 PointsLeft
= GemRB
.GetVar("Ability -1")
275 AbilityWindow
.Unload()
276 GemRB
.SetNextScript("CharGen5")
277 GemRB
.SetVar("StrExtra",0)
278 for i
in range(-1,6):
279 GemRB
.SetVar("Ability "+str(i
),0) #scrapping the abilities
280 GemRB
.SetRepeatClickFlags(GEM_RK_DISABLE
, OP_OR
)
285 AbilityWindow
.Unload()
286 AbilityTable
= GemRB
.LoadTable ("ability")
287 AbilityCount
= AbilityTable
.GetRowCount ()
289 # print our diagnostic as we loop (so as not to duplicate)
290 for i
in range (AbilityCount
):
291 StatID
= AbilityTable
.GetValue (i
, 3)
292 StatName
= AbilityTable
.GetRowName (i
)
293 StatValue
= GemRB
.GetVar ("Ability "+str(i
))
294 GemRB
.SetPlayerStat (MyChar
, StatID
, StatValue
)
295 print "\t",StatName
,":\t", StatValue
297 GemRB
.SetPlayerStat (MyChar
, IE_STREXTRA
, GemRB
.GetVar ("StrExtra"))
298 print "\tSTREXTRA:\t",GemRB
.GetVar ("StrExtra")
300 GemRB
.SetRepeatClickFlags(GEM_RK_DISABLE
, OP_OR
)
301 GemRB
.SetNextScript("CharGen6")
305 Ability
= GemRB
.GetVar("Ability 0")
307 GemRB
.SetToken("MINIMUM",str(Minimum
) )
308 GemRB
.SetToken("MAXIMUM",str(Maximum
) )
309 TextAreaControl
.SetText(AbilityTable
.GetValue(0, 1) )
313 Ability
= GemRB
.GetVar("Ability 1")
315 GemRB
.SetToken("MINIMUM",str(Minimum
) )
316 GemRB
.SetToken("MAXIMUM",str(Maximum
) )
317 TextAreaControl
.SetText(AbilityTable
.GetValue(1, 1) )
321 Ability
= GemRB
.GetVar("Ability 2")
323 GemRB
.SetToken("MINIMUM",str(Minimum
) )
324 GemRB
.SetToken("MAXIMUM",str(Maximum
) )
325 TextAreaControl
.SetText(AbilityTable
.GetValue(2, 1) )
329 Ability
= GemRB
.GetVar("Ability 3")
331 GemRB
.SetToken("MINIMUM",str(Minimum
) )
332 GemRB
.SetToken("MAXIMUM",str(Maximum
) )
333 TextAreaControl
.SetText(AbilityTable
.GetValue(3, 1) )
337 Ability
= GemRB
.GetVar("Ability 4")
339 GemRB
.SetToken("MINIMUM",str(Minimum
) )
340 GemRB
.SetToken("MAXIMUM",str(Maximum
) )
341 TextAreaControl
.SetText(AbilityTable
.GetValue(4, 1) )
345 Ability
= GemRB
.GetVar("Ability 5")
347 GemRB
.SetToken("MINIMUM",str(Minimum
) )
348 GemRB
.SetToken("MAXIMUM",str(Maximum
) )
349 TextAreaControl
.SetText(AbilityTable
.GetValue(5, 1) )