home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 1.5)
-
- import Bladex
- import GameState
- import MemPersistence
- import BBLib
- import string
-
- class MainCharState(GameState.EntityPersonState):
- '''Clase para grabar el estado del jugador'''
-
- def __init__(self, ent_name = 'Player1'):
- entity = Bladex.GetEntity(ent_name)
- if not entity:
- return None
-
- import Actions
- self.Props = { }
- self.Props['Life'] = entity.Life
- self.Props['Level'] = entity.Level
- self.Props['PartialLevel'] = entity.PartialLevel
- self.Props['Energy'] = entity.Energy
- GameState.EntityPersonState.__init__(self, entity)
- inv = entity.GetInventory()
- self.Inventory = { }
- self.Inventory['Objects'] = []
- for i in range(inv.nKindObjects):
- for name in Actions.GetListOfObjectsAt(inv, i):
- self.Inventory['Objects'].append(self._MainCharState__GetObjAux(name))
-
-
- self.Inventory['Weapons'] = []
- for i in range(inv.nWeapons):
- self.Inventory['Weapons'].append(self._MainCharState__GetObjAux(inv.GetWeapon(i)))
-
- self.Inventory['Shields'] = []
- for i in range(inv.nShields):
- self.Inventory['Shields'].append(self._MainCharState__GetObjAux(inv.GetShield(i)))
-
- self.Inventory['Quivers'] = []
- for i in range(inv.nQuivers):
- self.Inventory['Quivers'].append(self._MainCharState__GetObjAux(inv.GetQuiver(i)))
-
- self.Inventory['Keys'] = []
- for i in range(inv.nKeys):
- self.Inventory['Keys'].append(self._MainCharState__GetObjAux(inv.GetKey(i)))
-
- self.Inventory['SpecialKeys'] = []
- for i in range(inv.nSpecialKeys):
- self.Inventory['SpecialKeys'].append(self._MainCharState__GetObjAux(inv.GetSpecialKey(i)))
-
- self.Inventory['Tablets'] = []
- for i in range(inv.nTablets):
- self.Inventory['Tablets'].append(self._MainCharState__GetObjAux(inv.GetTablet(i)))
-
- self.Inventory['InvLeft'] = self._MainCharState__GetObjAux(entity.InvLeft)
- self.Inventory['InvLeft2'] = self._MainCharState__GetObjAux(entity.InvLeft2)
- self.Inventory['InvLeftBack'] = self._MainCharState__GetObjAux(entity.InvLeftBack)
- self.Inventory['InvRightBack'] = self._MainCharState__GetObjAux(entity.InvRightBack)
-
-
- def __GetBOD(self, ent_kind):
- RM = BBLib.GetResourceManager()
- for i in range(RM.NResources(BBLib.B_CID_OBJDSCR)):
- if RM.IsResourceLoaded(BBLib.B_CID_OBJDSCR, i):
- if RM.GetResourceName(BBLib.B_CID_OBJDSCR, i) == ent_kind:
- return RM.GetResourceFile(BBLib.B_CID_OBJDSCR, i)
-
-
-
- return None
-
-
- def __GetObjAux(self, obj):
- if not obj:
- return None
-
- objKind = Bladex.GetEntity(obj).Kind
- return (obj, objKind, self._MainCharState__GetBOD(objKind))
-
-
- def GetProps(self):
- temp = { }
- temp['Life'] = self.Props['Life']
- temp['Level'] = self.Props['Level']
- temp['PartialLevel'] = self.Props['PartialLevel']
- temp['Energy'] = self.Props['Energy']
- return (self.CreationProps, temp, self.Inventory)
-
-
-
- def CreateMainCharWithProps(props):
- CreationProps = props[0]
- Props = props[1]
- Inventory = props[2]
- import Basic_Funcs
- import AniSound
- import Reference
- import Sparks
- import Breakings
- import ItemTypes
- import Actions
- char = Bladex.CreateEntity('Player1', CreationProps['Kind'], 0, 0, 0, 'Person')
- char.Data = Basic_Funcs.PlayerPerson(char)
- inv = char.GetInventory()
- AniSound.AsignarSonidosCaballero('Player1')
- char.Level = Props['Level']
- char.PartialLevel = Props['PartialLevel']
- char.Life = Props['Life']
- char.Energy = Props['Energy']
- for i in Inventory['Objects']:
- GameState.CreateEntAux(i, 'Physic')
- Actions.ExtendedTakeObject(inv, i[0])
-
- for i in Inventory['Weapons']:
- obj = GameState.CreateEntAux(i, 'Weapon')
- object_flag = Reference.GiveObjectFlag(i[0])
- Breakings.SetBreakableWS(i[0])
-
- for i in Inventory['Shields']:
- GameState.CreateEntAux(i, 'Weapon')
- inv.AddShield(i[0])
- Sparks.MakeShield(i[0])
- Breakings.SetBreakableWS(i[0])
-
- for i in Inventory['Quivers']:
- obj = GameState.CreateEntAux(i, 'Weapon')
- ItemTypes.ItemDefaultFuncs(obj)
- inv.AddQuiver(i[0])
-
- for i in Inventory['Keys']:
- GameState.CreateEntAux(i, 'Physic')
- inv.AddKey(i[0])
-
- for i in Inventory['SpecialKeys']:
- GameState.CreateEntAux(i, 'Physic')
- inv.AddSpecialKey(i[0])
-
- for i in Inventory['Tablets']:
- GameState.CreateEntAux(i, 'Physic')
- inv.AddTablet(i[0])
-
-
-
- def RestoreMainCharState(key):
- props = MemPersistence.Get(key)
- if props:
- CreateMainCharWithProps(props)
- return 1
-
- return 0
-
-
- def SaveMainCharState(key):
- ent_state = MainCharState('Player1')
- props = ent_state.GetProps()
- MemPersistence.Store(key, props)
-
- VisitedMaps = [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0]
- PlacedTablets = [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0]
- MText = []
- BaList = []
- for a in range(17):
- MText.append([])
-
- PWeapons = []
- PItems = []
-
- def MapText(MapNum, MapTex):
- if MapNum == -1:
- BaList.append(MapTex)
- else:
- MText[MapNum - 1].append(MapTex)
-
-
- def PickedWeapon(Weapon):
- PWeapons.append(Weapon)
-
-
- def PickedItems(Item):
- PItems.append(Item)
-
-
- def Set2DMapValuesAux():
- return [
- VisitedMaps,
- PlacedTablets,
- MText,
- PWeapons,
- PItems,
- BaList]
-
-
- def Get2DMapValuesAux(vals):
- global VisitedMaps, PlacedTablets, MText, PWeapons, PItems, BaList
- if vals:
- VisitedMaps = vals[0]
- PlacedTablets = vals[1]
- MText = vals[2]
- PWeapons = vals[3]
- PItems = vals[4]
- BaList = vals[5]
- return 1
-
- return 0
-
-
- def Get2DMapValues():
- print 'Get2DMapValues()'
- vals = MemPersistence.Get('2DMapValues')
- if vals:
- return Get2DMapValuesAux(vals)
- else:
- print "Get2DMapValues() -> can't find vals."
- return 0
-
-
- def GetCarriedTablets():
- a = [
- 0,
- 0,
- 0,
- 0,
- 0,
- 0]
- for i in MemPersistence.Get('MainChar')[2]['Tablets']:
- a[string.atoi(i[0][len('tablilla')]) - 1] = 1
-
- return a
-
-
- def BeginLevel():
- pj = RestoreMainCharState('MainChar')
- if pj:
- return Get2DMapValues()
-
- return 0
-
- LevelNames = [
- 'barb_m1',
- 'ragnar_m2',
- 'dwarf_m3',
- 'ruins_m4',
- 'mine_m5',
- 'labyrinth_m6',
- 'tomb_m7',
- 'island_m8',
- 'orc_m9',
- 'orlok_m10',
- 'ice_m11',
- 'btomb_m12',
- 'desert_m13',
- 'volcano_m14',
- 'palace_m15',
- 'tower_m16',
- 'chaos_m17']
- BackLevelNames = [
- 'mine_back',
- 'labyrinth_back',
- 'tomb_back',
- 'ice_back',
- 'btomb_back',
- 'desert_back',
- 'palace_back']
-
- def EndOfLevel():
- import string
- print 'EndOfLevel()'
- print 'Preparing main char for the travel.'
- import Actions
- Actions.PutAllInBack('Player1')
- Actions.RemoveAllKeys('Player1')
- Actions.RemoveNoTravelObjects('Player1')
- pname = Bladex.GetCurrentMap()
- name = string.lower(pname)
- if name == 'palace_m15':
- name = 'palace_back'
-
- if not (name in BackLevelNames):
- iIndex = LevelNames.index(name)
- else:
- iIndex = BackLevelNames.index(name)
- VisitedMaps[14] = 1
- Bladex.SetStringValue('LastVisitedMap', 'M_' + str(iIndex + 1))
- VisitedMaps[iIndex] = 1
- print iIndex
- MemPersistence.Store('2DMapValues', Set2DMapValuesAux())
- SaveMainCharState('MainChar')
- Bladex.LoadLevel('2dMap')
-
-