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, class (GUICG2)
23 from ie_stats
import *
24 from GUIDefines
import *
32 global ClassWindow
, TextAreaControl
, DoneButton
, MyChar
34 GemRB
.LoadWindowPack("GUICG", 640, 480)
35 ClassWindow
= GemRB
.LoadWindow(2)
37 MyChar
= GemRB
.GetVar ("Slot")
38 Race
= GUICommon
.RaceTable
.FindValue (3, GemRB
.GetPlayerStat (MyChar
, IE_RACE
) )
39 RaceName
= GUICommon
.RaceTable
.GetRowName(Race
)
41 ClassCount
= GUICommon
.ClassTable
.GetRowCount()+1
44 #radiobutton groups must be set up before doing anything else to them
45 for i
in range(1,ClassCount
):
46 if GUICommon
.ClassTable
.GetValue(i
-1,4):
49 Button
= ClassWindow
.GetControl(j
+7)
51 Button
= ClassWindow
.GetControl(j
+2)
52 Button
.SetFlags(IE_GUI_BUTTON_RADIOBUTTON
, OP_OR
)
53 Button
.SetState(IE_GUI_BUTTON_DISABLED
)
57 GemRB
.SetVar("MAGESCHOOL",0)
59 for i
in range(1,ClassCount
):
60 ClassName
= GUICommon
.ClassTable
.GetRowName(i
-1)
61 Allowed
= GUICommon
.ClassTable
.GetValue(ClassName
, RaceName
)
62 if GUICommon
.ClassTable
.GetValue(i
-1,4):
67 Button
= ClassWindow
.GetControl(j
+7)
69 Button
= ClassWindow
.GetControl(j
+2)
71 t
= GUICommon
.ClassTable
.GetValue(i
-1, 0)
77 GemRB
.SetVar("MAGESCHOOL",5) #illusionist
78 Button
.SetState(IE_GUI_BUTTON_ENABLED
)
79 Button
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, ClassPress
)
80 Button
.SetVarAssoc("Class", i
)
82 MultiClassButton
= ClassWindow
.GetControl(10)
83 MultiClassButton
.SetText(11993)
85 MultiClassButton
.SetState(IE_GUI_BUTTON_DISABLED
)
87 BackButton
= ClassWindow
.GetControl(14)
88 BackButton
.SetText(15416)
89 BackButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
90 DoneButton
= ClassWindow
.GetControl(0)
91 DoneButton
.SetText(11973)
92 DoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
94 TextAreaControl
= ClassWindow
.GetControl(13)
96 Class
= GemRB
.GetVar("Class")-1
98 TextAreaControl
.SetText(17242)
99 DoneButton
.SetState(IE_GUI_BUTTON_DISABLED
)
101 TextAreaControl
.SetText(GUICommon
.ClassTable
.GetValue(Class
,1) )
102 DoneButton
.SetState(IE_GUI_BUTTON_ENABLED
)
104 MultiClassButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, MultiClassPress
)
105 DoneButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, NextPress
)
106 BackButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, BackPress
)
107 ClassWindow
.SetVisible(WINDOW_VISIBLE
)
113 GemRB
.SetNextScript("CharGen3")
114 GemRB
.SetVar("Class",0) #scrapping the class value
118 # find the class from the class table
119 ClassIndex
= GemRB
.GetVar ("Class") - 1
120 Class
= GUICommon
.ClassTable
.GetValue (ClassIndex
, 5)
121 GemRB
.SetPlayerStat (MyChar
, IE_CLASS
, Class
)
122 ClassName
= GUICommon
.ClassTable
.GetRowName (GUICommon
.ClassTable
.FindValue (5, Class
))
123 # protect against barbarians; this stat will be overwritten later
124 GemRB
.SetPlayerStat (MyChar
, IE_HITPOINTS
, ClassIndex
)
126 #assign the correct XP
127 if GUICommon
.GameIsTOB():
128 GemRB
.SetPlayerStat (MyChar
, IE_XP
, GUICommon
.ClassSkillsTable
.GetValue (ClassName
, "STARTXP2"))
130 GemRB
.SetPlayerStat (MyChar
, IE_XP
, GUICommon
.ClassSkillsTable
.GetValue (ClassName
, "STARTXP"))
132 #create an array to get all the classes from
134 IsMulti
= GUICommon
.IsMultiClassed (MyChar
, 1)
136 NumClasses
= IsMulti
[0]
137 Classes
= [IsMulti
[1], IsMulti
[2], IsMulti
[3]]
139 Classes
= [GemRB
.GetPlayerStat (MyChar
, IE_CLASS
)]
141 #loop through each class and update it's level
142 xp
= GemRB
.GetPlayerStat (MyChar
, IE_XP
)/NumClasses
143 for i
in range (NumClasses
):
144 CurrentLevel
= LUCommon
.GetNextLevelFromExp (xp
, Classes
[i
])
146 GemRB
.SetPlayerStat (MyChar
, IE_LEVEL
, CurrentLevel
)
148 GemRB
.SetPlayerStat (MyChar
, IE_LEVEL2
+i
-1, CurrentLevel
)
150 def MultiClassPress():
151 GemRB
.SetVar("Class Kit",0)
154 GemRB
.SetNextScript("GUICG10")
161 GemRB
.SetNextScript("GUICG22")
168 GemRB
.SetNextScript("CharGen4") #alignment