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)
22 from ie_stats
import *
23 from GUIDefines
import *
41 def CalcLimits(Abidx
):
42 global Minimum
, Maximum
, Add
44 Race
= GUICommon
.RaceTable
.FindValue (3, GemRB
.GetPlayerStat (MyChar
, IE_RACE
) )
45 RaceName
= GUICommon
.RaceTable
.GetRowName(Race
)
50 tmp
= Abclasrq
.GetValue(KitIndex
, Abidx
)
51 if tmp
!=0 and tmp
>Minimum
:
54 Race
= Abracerq
.GetRowIndex(RaceName
)
55 tmp
= Abracerq
.GetValue(Race
, Abidx
*2)
56 if tmp
!=0 and tmp
>Minimum
:
59 tmp
= Abracerq
.GetValue(Race
, Abidx
*2+1)
60 if tmp
!=0 and tmp
>Maximum
:
63 Race
= Abracead
.GetRowIndex(RaceName
)
64 Add
= Abracead
.GetValue(Race
, Abidx
) + Abclsmod
.GetValue(KitIndex
, Abidx
)
65 Maximum
= Maximum
+ Add
66 Minimum
= Minimum
+ Add
75 global Minimum
, Maximum
, Add
, HasStrExtra
, PointsLeft
77 GemRB
.SetVar("Ability",0)
78 GemRB
.SetVar("Ability -1",0)
80 SumLabel
= AbilityWindow
.GetControl(0x10000002)
85 e
= GemRB
.Roll(1,100,0)
88 GemRB
.SetVar("StrExtra", e
)
93 v
= GemRB
.Roll(dice
, size
, Add
+3)
98 GemRB
.SetVar("Ability "+str(i
), v
)
99 Label
= AbilityWindow
.GetControl(0x10000003+i
)
100 if i
==0 and v
==18 and HasStrExtra
:
101 Label
.SetText("18/"+str(e
) )
103 Label
.SetText(str(v
) )
108 global AbilityWindow
, TextAreaControl
, DoneButton
109 global PointsLeft
, HasStrExtra
110 global AbilityTable
, Abclasrq
, Abclsmod
, Abracerq
, Abracead
111 global KitIndex
, Minimum
, Maximum
, MyChar
113 Abracead
= GemRB
.LoadTable("ABRACEAD")
114 Abclsmod
= GemRB
.LoadTable("ABCLSMOD")
115 Abclasrq
= GemRB
.LoadTable("ABCLASRQ")
116 Abracerq
= GemRB
.LoadTable("ABRACERQ")
118 MyChar
= GemRB
.GetVar ("Slot")
119 Kit
= GUICommon
.GetKitIndex (MyChar
)
120 Class
= GemRB
.GetPlayerStat (MyChar
, IE_CLASS
)
121 Class
= GUICommon
.ClassTable
.FindValue (5, Class
)
123 KitName
= GUICommon
.ClassTable
.GetRowName(Class
)
125 #rowname is just a number, first value row what we need here
126 KitName
= GUICommon
.KitListTable
.GetValue(Kit
, 0)
128 #if the class uses the warrior table for saves, then it may have the extra strength
129 if GUICommon
.ClassTable
.GetValue(Class
, 3)=="SAVEWAR":
134 KitIndex
= Abclasrq
.GetRowIndex(KitName
)
136 GemRB
.LoadWindowPack("GUICG", 640, 480)
137 AbilityTable
= GemRB
.LoadTable("ability")
138 AbilityWindow
= GemRB
.LoadWindow(4)
140 RerollButton
= AbilityWindow
.GetControl(2)
141 RerollButton
.SetText(11982)
142 StoreButton
= AbilityWindow
.GetControl(37)
143 StoreButton
.SetText(17373)
144 RecallButton
= AbilityWindow
.GetControl(38)
145 RecallButton
.SetText(17374)
147 BackButton
= AbilityWindow
.GetControl(36)
148 BackButton
.SetText(15416)
149 BackButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
150 DoneButton
= AbilityWindow
.GetControl(0)
151 DoneButton
.SetText(11973)
152 DoneButton
.SetFlags(IE_GUI_BUTTON_DEFAULT
,OP_OR
)
153 DoneButton
.SetState(IE_GUI_BUTTON_ENABLED
)
158 Label
= AbilityWindow
.GetControl(i
+0x10000009)
159 Label
.SetEvent(IE_GUI_LABEL_ON_PRESS
, eval("OverPress"+str(i
)))
160 Button
= AbilityWindow
.GetControl(i
+30)
161 Button
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, JustPress
)
162 Button
.SetEvent(IE_GUI_MOUSE_LEAVE_BUTTON
, EmptyPress
)
163 Button
.SetVarAssoc("Ability", i
)
165 Button
= AbilityWindow
.GetControl(i
*2+16)
166 Button
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, LeftPress
)
167 Button
.SetVarAssoc("Ability", i
)
169 Button
= AbilityWindow
.GetControl(i
*2+17)
170 Button
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, RightPress
)
171 Button
.SetVarAssoc("Ability", i
)
173 TextAreaControl
= AbilityWindow
.GetControl(29)
174 TextAreaControl
.SetText(17247)
176 StoreButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, StorePress
)
177 RecallButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, RecallPress
)
178 RerollButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, RollPress
)
179 DoneButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, NextPress
)
180 BackButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, BackPress
)
181 AbilityWindow
.SetVisible(WINDOW_VISIBLE
)
182 GemRB
.SetRepeatClickFlags(GEM_RK_DISABLE
, OP_NAND
)
188 Abidx
= GemRB
.GetVar("Ability")
189 Ability
= GemRB
.GetVar("Ability "+str(Abidx
) )
191 GemRB
.SetToken("MINIMUM",str(Minimum
) )
192 GemRB
.SetToken("MAXIMUM",str(Maximum
) )
193 TextAreaControl
.SetText(AbilityTable
.GetValue(Abidx
, 1) )
196 GemRB
.SetVar("Ability "+str(Abidx
), Ability
-1)
197 PointsLeft
= PointsLeft
+ 1
198 GemRB
.SetVar("Ability -1",PointsLeft
)
199 SumLabel
= AbilityWindow
.GetControl(0x10000002)
200 SumLabel
.SetText(str(PointsLeft
) )
201 Label
= AbilityWindow
.GetControl(0x10000003+Abidx
)
202 StrExtra
= GemRB
.GetVar("StrExtra")
203 if Abidx
==0 and Ability
==19 and StrExtra
:
204 Label
.SetText("18/"+str(StrExtra
) )
206 Label
.SetText(str(Ability
-1) )
210 Abidx
= GemRB
.GetVar("Ability")
211 Ability
= GemRB
.GetVar("Ability "+str(Abidx
) )
213 GemRB
.SetToken("MINIMUM",str(Minimum
) )
214 GemRB
.SetToken("MAXIMUM",str(Maximum
) )
215 TextAreaControl
.SetText(AbilityTable
.GetValue(Abidx
, 1) )
221 Abidx
= GemRB
.GetVar("Ability")
222 Ability
= GemRB
.GetVar("Ability "+str(Abidx
) )
224 GemRB
.SetToken("MINIMUM",str(Minimum
) )
225 GemRB
.SetToken("MAXIMUM",str(Maximum
) )
226 TextAreaControl
.SetText(AbilityTable
.GetValue(Abidx
, 1) )
229 if Ability
>=Maximum
: #should be more elaborate
231 GemRB
.SetVar("Ability "+str(Abidx
), Ability
+1)
232 PointsLeft
= PointsLeft
- 1
233 GemRB
.SetVar("Ability -1",PointsLeft
)
234 SumLabel
= AbilityWindow
.GetControl(0x10000002)
235 SumLabel
.SetText(str(PointsLeft
) )
236 Label
= AbilityWindow
.GetControl(0x10000003+Abidx
)
237 StrExtra
= GemRB
.GetVar("StrExtra")
238 if Abidx
==0 and Ability
==17 and HasStrExtra
==1:
239 Label
.SetText("18/%02d"%(StrExtra) )
241 Label
.SetText(str(Ability
+1) )
245 TextAreaControl
= AbilityWindow
.GetControl(29)
246 TextAreaControl
.SetText(17247)
250 GemRB
.SetVar("StoredStrExtra",GemRB
.GetVar("StrExtra") )
251 for i
in range(-1,6):
252 GemRB
.SetVar("Stored "+str(i
),GemRB
.GetVar("Ability "+str(i
) ) )
258 e
=GemRB
.GetVar("StoredStrExtra")
259 GemRB
.SetVar("StrExtra",e
)
260 for i
in range(-1,6):
261 v
= GemRB
.GetVar("Stored "+str(i
) )
262 GemRB
.SetVar("Ability "+str(i
), v
)
263 Label
= AbilityWindow
.GetControl(0x10000003+i
)
264 if i
==0 and v
==18 and HasStrExtra
==1:
265 Label
.SetText("18/"+str(e
) )
267 Label
.SetText(str(v
) )
269 PointsLeft
= GemRB
.GetVar("Ability -1")
274 AbilityWindow
.Unload()
275 GemRB
.SetNextScript("CharGen5")
276 GemRB
.SetVar("StrExtra",0)
277 for i
in range(-1,6):
278 GemRB
.SetVar("Ability "+str(i
),0) #scrapping the abilities
279 GemRB
.SetRepeatClickFlags(GEM_RK_DISABLE
, OP_OR
)
284 AbilityWindow
.Unload()
285 AbilityTable
= GemRB
.LoadTable ("ability")
286 AbilityCount
= AbilityTable
.GetRowCount ()
288 # print our diagnostic as we loop (so as not to duplicate)
289 for i
in range (AbilityCount
):
290 StatID
= AbilityTable
.GetValue (i
, 3)
291 StatName
= AbilityTable
.GetRowName (i
)
292 StatValue
= GemRB
.GetVar ("Ability "+str(i
))
293 GemRB
.SetPlayerStat (MyChar
, StatID
, StatValue
)
294 print "\t",StatName
,":\t", StatValue
296 GemRB
.SetPlayerStat (MyChar
, IE_STREXTRA
, GemRB
.GetVar ("StrExtra"))
297 print "\tSTREXTRA:\t",GemRB
.GetVar ("StrExtra")
299 GemRB
.SetRepeatClickFlags(GEM_RK_DISABLE
, OP_OR
)
300 GemRB
.SetNextScript("CharGen6")
304 Ability
= GemRB
.GetVar("Ability 0")
306 GemRB
.SetToken("MINIMUM",str(Minimum
) )
307 GemRB
.SetToken("MAXIMUM",str(Maximum
) )
308 TextAreaControl
.SetText(AbilityTable
.GetValue(0, 1) )
312 Ability
= GemRB
.GetVar("Ability 1")
314 GemRB
.SetToken("MINIMUM",str(Minimum
) )
315 GemRB
.SetToken("MAXIMUM",str(Maximum
) )
316 TextAreaControl
.SetText(AbilityTable
.GetValue(1, 1) )
320 Ability
= GemRB
.GetVar("Ability 2")
322 GemRB
.SetToken("MINIMUM",str(Minimum
) )
323 GemRB
.SetToken("MAXIMUM",str(Maximum
) )
324 TextAreaControl
.SetText(AbilityTable
.GetValue(2, 1) )
328 Ability
= GemRB
.GetVar("Ability 3")
330 GemRB
.SetToken("MINIMUM",str(Minimum
) )
331 GemRB
.SetToken("MAXIMUM",str(Maximum
) )
332 TextAreaControl
.SetText(AbilityTable
.GetValue(3, 1) )
336 Ability
= GemRB
.GetVar("Ability 4")
338 GemRB
.SetToken("MINIMUM",str(Minimum
) )
339 GemRB
.SetToken("MAXIMUM",str(Maximum
) )
340 TextAreaControl
.SetText(AbilityTable
.GetValue(4, 1) )
344 Ability
= GemRB
.GetVar("Ability 5")
346 GemRB
.SetToken("MINIMUM",str(Minimum
) )
347 GemRB
.SetToken("MAXIMUM",str(Maximum
) )
348 TextAreaControl
.SetText(AbilityTable
.GetValue(5, 1) )