TickHook: Fix crash when TickHook isn't set.
[gemrb.git] / gemrb / GUIScripts / bg1 / GUICG7.py
blob0d15d5ddb7beba1fddd91fcafdafa32b7e0fed74
1 # -*-python-*-
2 # GemRB - Infinity Engine Emulator
3 # Copyright (C) 2003-2004 The GemRB Project
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 # character generation, mage spells (GUICG7)
21 import GemRB
22 from GUIDefines import *
23 from ie_stats import *
24 import GUICommon
25 import CommonTables
26 import LUSpellSelection
28 def OnLoad():
29 KitTable = GemRB.LoadTable("magesch")
30 Slot = GemRB.GetVar ("Slot")
31 Class = GemRB.GetPlayerStat (Slot, IE_CLASS)
32 TableName = CommonTables.ClassSkills.GetValue(Class, 2)
34 # make sure we have a correct table
35 if Class == 19:
36 # sorcerer's need their known not max table
37 TableName = "SPLSRCKN"
39 # get our kit index
40 KitIndex = GUICommon.GetKitIndex (Slot)
41 if KitIndex:
42 KitValue = KitTable.GetValue(KitIndex - 21, 3)
44 # bards have kits too
45 if KitValue == -1:
46 KitValue = 0x4000 # we only need it for the spells, so this is ok
47 else:
48 KitValue = 0x4000
50 # open up the spell selection window
51 # remember, it is pc, table, level, diff, kit, chargen
52 IsMulti = GUICommon.IsMultiClassed (Slot, 1)
53 Level = GemRB.GetPlayerStat (Slot, IE_LEVEL)
54 if IsMulti[0]>1:
55 for i in range (1, IsMulti[0]):
56 if CommonTables.ClassSkills.GetValue (IsMulti[i], 2, 0) != "*":
57 Level = GemRB.GetPlayerStat (Slot, IE_LEVEL2+i-1)
58 break
59 GUICommon.SetupSpellLevels(Slot, TableName, IE_SPELL_TYPE_WIZARD, 1)
60 LUSpellSelection.OpenSpellsWindow (Slot, TableName, Level, Level, KitValue, 1,False)
62 return