Go to the documentation of this file.00001
00002
00003 """
00004 The Morgue object is a global (bases wide) container/manager
00005 for all in game corpses for both player avatars and mobs.
00006 It implements all required looting and despawn functionality
00007
00008
00009 Anoria (c) Gsk 2010
00010 """
00011
00012 import BigWorld
00013 import time
00014
00015 from config import consts
00016
00017 class Morgue( BigWorld.Base ):
00018
00019 def __init__( self ):
00020 BigWorld.Base.__init__(self)
00021 print "Morgue.id=%d registering globally as \"MORGUE\" " % (self.id)
00022 self.registerGlobally("MORGUE", self.registerCB)
00023 delta_t = 1.0 / consts.GAME_UPDATE_RATE
00024 self.addTimer(delta_t, delta_t)
00025 self.corpses = {}
00026
00027 def registerCB(self, success):
00028 print 'Morgue.registerCB(): success=%s' % (success)
00029
00030
00031
00032 def onTimer(self, timerId, userData):
00033 now = time.time()
00034 for id in self.corpses.keys():
00035 spawnTick = self.corpses[id]
00036 if now > spawnTick + 20.0:
00037 print "Morgue.onTimer(): despawning corpse entity %d" % (id)
00038 try:
00039 entity = BigWorld.entities[id]
00040 except:
00041 print "ERROR: Morgue.onTimer() cannot despawn corpse entity %d, entity not found" % (id)
00042 try:
00043 entity.rpcDespawn()
00044 except:
00045 pass
00046
00047 del self.corpses[id]
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 def rpcRegisterCorpse(self, cellMb, pos, dir, modelNumber):
00058 print "Morgue.registerCorpse() at %.2f/%.2f/%.2f/%.2f" % (pos[0],pos[1],pos[2],dir[2])
00059
00060 properties = { "modelName" : "characters/npc/fd_striff/striff.model",
00061 "modelNumber" : modelNumber
00062 }
00063
00064 base = BigWorld.createBaseAnywhere('Corpse', properties, spawnerCellMb = cellMb,
00065 position = pos, direction = dir)
00066
00067 print "Morgue spawned corpse entity %d" % (base.id)
00068
00069 self.corpses[base.id] = time.time()
00070
00071