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)
21 from GUIDefines
import *
22 from ie_stats
import *
43 def CalcLimits(Abidx
):
44 global Minimum
, Maximum
, Add
46 Race
= CommonTables
.Races
.FindValue (3, GemRB
.GetPlayerStat (MyChar
, IE_RACE
) )
47 RaceName
= CommonTables
.Races
.GetRowName(Race
)
52 tmp
= Abclasrq
.GetValue(KitIndex
, Abidx
)
53 if tmp
!=0 and tmp
>Minimum
:
56 Race
= Abracerq
.GetRowIndex(RaceName
)
57 tmp
= Abracerq
.GetValue(Race
, Abidx
*2)
58 if tmp
!=0 and tmp
>Minimum
:
61 tmp
= Abracerq
.GetValue(Race
, Abidx
*2+1)
62 if tmp
!=0 and tmp
>Maximum
:
65 Race
= Abracead
.GetRowIndex(RaceName
)
66 Add
= Abracead
.GetValue(Race
, Abidx
)# + Abclsmod.GetValue(KitIndex, Abidx)
67 Maximum
= Maximum
+ Add
68 Minimum
= Minimum
+ Add
77 global Minimum
, Maximum
, Add
, HasStrExtra
, PointsLeft
79 GemRB
.SetVar("Ability",0)
80 GemRB
.SetVar("Ability -1",0)
82 SumLabel
= AbilityWindow
.GetControl(0x10000002)
87 e
= GemRB
.Roll(1,100,0)
90 GemRB
.SetVar("StrExtra", e
)
95 v
= GemRB
.Roll(dice
, size
, Add
+3)
100 GemRB
.SetVar("Ability "+str(i
), v
)
101 Label
= AbilityWindow
.GetControl(0x10000003+i
)
102 if i
==0 and v
==18 and HasStrExtra
:
103 Label
.SetText("18/"+str(e
) )
105 Label
.SetText(str(v
) )
110 global AbilityWindow
, TextAreaControl
, DoneButton
111 global PointsLeft
, HasStrExtra
112 global AbilityTable
, Abclasrq
, Abclsmod
, Abracerq
, Abracead
113 global KitIndex
, Minimum
, Maximum
, MyChar
115 if GUICommon
.CloseOtherWindow (OnLoad
):
117 AbilityWindow
.Unload()
121 Abracead
= GemRB
.LoadTable("ABRACEAD")
122 #Abclsmod = GemRB.LoadTable("ABCLSMOD")
123 Abclasrq
= GemRB
.LoadTable("ABCLASRQ")
124 Abracerq
= GemRB
.LoadTable("ABRACERQ")
126 MyChar
= GemRB
.GetVar ("Slot")
127 Kit
= GUICommon
.GetKitIndex (MyChar
)
128 Class
= GemRB
.GetPlayerStat (MyChar
, IE_CLASS
)
129 Class
= CommonTables
.Classes
.FindValue (5, Class
)
131 KitName
= CommonTables
.Classes
.GetRowName(Class
)
133 #rowname is just a number, first value row what we need here
134 KitName
= CommonTables
.KitList
.GetValue(Kit
, 0)
136 #if the class uses the warrior table for saves, then it may have the extra strength
137 if CommonTables
.Classes
.GetValue(Class
, 3)=="SAVEWAR":
142 KitIndex
= Abclasrq
.GetRowIndex(KitName
)
144 GemRB
.LoadWindowPack("GUICG", 640, 480)
145 AbilityTable
= GemRB
.LoadTable("ability")
146 AbilityWindow
= GemRB
.LoadWindow(4)
148 RerollButton
= AbilityWindow
.GetControl(2)
149 RerollButton
.SetText(11982)
150 StoreButton
= AbilityWindow
.GetControl(37)
151 StoreButton
.SetText(17373)
152 RecallButton
= AbilityWindow
.GetControl(38)
153 RecallButton
.SetText(17374)
155 BackButton
= AbilityWindow
.GetControl(36)
156 BackButton
.SetText(15416)
157 BackButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
158 DoneButton
= AbilityWindow
.GetControl(0)
159 DoneButton
.SetText(11973)
160 DoneButton
.SetFlags(IE_GUI_BUTTON_DEFAULT
,OP_OR
)
161 DoneButton
.SetState(IE_GUI_BUTTON_ENABLED
)
166 Button
= AbilityWindow
.GetControl(i
+30)
167 Button
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, JustPress
)
168 Button
.SetVarAssoc("Ability", i
)
170 Button
= AbilityWindow
.GetControl(i
*2+16)
171 Button
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, LeftPress
)
172 Button
.SetVarAssoc("Ability", i
)
174 Button
= AbilityWindow
.GetControl(i
*2+17)
175 Button
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, RightPress
)
176 Button
.SetVarAssoc("Ability", i
)
178 TextAreaControl
= AbilityWindow
.GetControl(29)
179 TextAreaControl
.SetText(17247)
181 StoreButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, StorePress
)
182 RecallButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, RecallPress
)
183 RerollButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, RollPress
)
184 DoneButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, NextPress
)
185 BackButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, BackPress
)
186 AbilityWindow
.ShowModal(MODAL_SHADOW_NONE
)
187 GemRB
.SetRepeatClickFlags(GEM_RK_DISABLE
, OP_NAND
)
193 Abidx
= GemRB
.GetVar("Ability")
194 Ability
= GemRB
.GetVar("Ability "+str(Abidx
) )
196 GemRB
.SetToken("MINIMUM",str(Minimum
) )
197 GemRB
.SetToken("MAXIMUM",str(Maximum
) )
198 TextAreaControl
.SetText(AbilityTable
.GetValue(Abidx
, 1) )
201 GemRB
.SetVar("Ability "+str(Abidx
), Ability
-1)
202 PointsLeft
= PointsLeft
+ 1
203 GemRB
.SetVar("Ability -1",PointsLeft
)
204 SumLabel
= AbilityWindow
.GetControl(0x10000002)
205 SumLabel
.SetText(str(PointsLeft
) )
206 Label
= AbilityWindow
.GetControl(0x10000003+Abidx
)
207 StrExtra
= GemRB
.GetVar("StrExtra")
208 if Abidx
==0 and Ability
==19 and StrExtra
:
209 Label
.SetText("18/"+str(StrExtra
) )
211 Label
.SetText(str(Ability
-1) )
215 Abidx
= GemRB
.GetVar("Ability")
216 Ability
= GemRB
.GetVar("Ability "+str(Abidx
) )
218 GemRB
.SetToken("MINIMUM",str(Minimum
) )
219 GemRB
.SetToken("MAXIMUM",str(Maximum
) )
220 TextAreaControl
.SetText(AbilityTable
.GetValue(Abidx
, 1) )
226 Abidx
= GemRB
.GetVar("Ability")
227 Ability
= GemRB
.GetVar("Ability "+str(Abidx
) )
229 GemRB
.SetToken("MINIMUM",str(Minimum
) )
230 GemRB
.SetToken("MAXIMUM",str(Maximum
) )
231 TextAreaControl
.SetText(AbilityTable
.GetValue(Abidx
, 1) )
234 if Ability
>=Maximum
: #should be more elaborate
236 GemRB
.SetVar("Ability "+str(Abidx
), Ability
+1)
237 PointsLeft
= PointsLeft
- 1
238 GemRB
.SetVar("Ability -1",PointsLeft
)
239 SumLabel
= AbilityWindow
.GetControl(0x10000002)
240 SumLabel
.SetText(str(PointsLeft
) )
241 Label
= AbilityWindow
.GetControl(0x10000003+Abidx
)
242 StrExtra
= GemRB
.GetVar("StrExtra")
243 if Abidx
==0 and Ability
==17 and HasStrExtra
==1:
244 Label
.SetText("18/%02d"%(StrExtra) )
246 Label
.SetText(str(Ability
+1) )
250 TextAreaControl
= AbilityWindow
.GetControl(29)
251 TextAreaControl
.SetText(17247)
255 GemRB
.SetVar("StoredStrExtra",GemRB
.GetVar("StrExtra") )
256 for i
in range(-1,6):
257 GemRB
.SetVar("Stored "+str(i
),GemRB
.GetVar("Ability "+str(i
) ) )
263 e
=GemRB
.GetVar("StoredStrExtra")
264 GemRB
.SetVar("StrExtra",e
)
265 for i
in range(-1,6):
266 v
= GemRB
.GetVar("Stored "+str(i
) )
267 GemRB
.SetVar("Ability "+str(i
), v
)
268 Label
= AbilityWindow
.GetControl(0x10000003+i
)
269 if i
==0 and v
==18 and HasStrExtra
==1:
270 Label
.SetText("18/"+str(e
) )
272 Label
.SetText(str(v
) )
274 PointsLeft
= GemRB
.GetVar("Ability -1")
278 GemRB
.SetRepeatClickFlags(GEM_RK_DISABLE
, OP_OR
)
282 GemRB
.SetRepeatClickFlags(GEM_RK_DISABLE
, OP_OR
)
284 AbilityTable
= GemRB
.LoadTable ("ability")
285 AbilityCount
= AbilityTable
.GetRowCount ()
287 # print our diagnostic as we loop (so as not to duplicate)
288 for i
in range (AbilityCount
):
289 StatID
= AbilityTable
.GetValue (i
, 3)
290 StatName
= AbilityTable
.GetRowName (i
)
291 StatValue
= GemRB
.GetVar ("Ability "+str(i
))
292 GemRB
.SetPlayerStat (MyChar
, StatID
, StatValue
)
293 print "\t",StatName
,":\t", StatValue
295 GemRB
.SetPlayerStat (MyChar
, IE_STREXTRA
, GemRB
.GetVar ("StrExtra"))
296 print "\tSTREXTRA:\t",GemRB
.GetVar ("StrExtra")
298 GemRB
.SetRepeatClickFlags(GEM_RK_DISABLE
, OP_OR
)