Poodletooth-iLand/toontown/toon/DistributedNPCLaffRestock.py

71 lines
2.6 KiB
Python
Raw Normal View History

2015-06-26 07:09:27 +00:00
from otp.nametag.NametagConstants import CFSpeech, CFTimeout
from toontown.toonbase import TTLocalizer, ToontownGlobals
2015-05-11 20:36:31 +00:00
from toontown.toon import NPCToons
from DistributedNPCToonBase import DistributedNPCToonBase
2015-07-25 06:08:54 +00:00
import LaffRestockGlobals, LaffShopGui, time
class DistributedNPCLaffRestock(DistributedNPCToonBase):
def __init__(self, cr):
DistributedNPCToonBase.__init__(self, cr)
2015-07-25 06:08:54 +00:00
self.lastCollision = 0
self.laffDialog = None
def disable(self):
self.ignoreAll()
2015-07-25 06:08:54 +00:00
self.destroyDialog()
DistributedNPCToonBase.disable(self)
2015-07-25 06:08:54 +00:00
def destroyDialog(self):
self.clearChat()
if self.laffDialog:
self.laffDialog.destroy()
self.laffDialog = None
2015-05-11 20:36:31 +00:00
def initToonState(self):
self.setAnimState('neutral', 0.9, None, None)
2015-07-25 06:08:54 +00:00
self.putOnSuit(ToontownGlobals.cogHQZoneId2deptIndex(self.zoneId), rental=True)
2015-05-11 20:36:31 +00:00
if self.name in NPCToons.LaffRestockPositions:
pos = NPCToons.LaffRestockPositions[self.name]
self.setPos(*pos[0])
self.setH(pos[1])
2015-05-11 19:05:59 +00:00
def getCollSphereRadius(self):
2015-07-25 06:08:54 +00:00
return 1.25
def handleCollisionSphereEnter(self, collEntry):
2015-07-25 06:08:54 +00:00
if self.lastCollision > time.time():
return
2015-07-25 06:08:54 +00:00
self.lastCollision = time.time() + ToontownGlobals.NPCCollisionDelay
self.lookAt(base.localAvatar)
if base.localAvatar.getHp() >= base.localAvatar.getMaxHp():
self.setChatAbsolute(TTLocalizer.RestockFullLaffMessage, CFSpeech | CFTimeout)
2015-07-25 06:08:54 +00:00
return
base.cr.playGame.getPlace().fsm.request('stopped')
base.setCellsAvailable(base.bottomCells, 0)
self.destroyDialog()
self.acceptOnce('laffShopDone', self.__laffShopDone)
self.laffDialog = LaffShopGui.LaffShopGui()
def freeAvatar(self):
base.cr.playGame.getPlace().fsm.request('walk')
base.setCellsAvailable(base.bottomCells, 1)
def __laffShopDone(self, state, laff):
self.freeAvatar()
2015-07-25 06:08:54 +00:00
if state == LaffRestockGlobals.TIMER_END:
self.setChatAbsolute(TTLocalizer.STOREOWNER_TOOKTOOLONG, CFSpeech|CFTimeout)
elif state == LaffRestockGlobals.USER_CANCEL:
self.setChatAbsolute(TTLocalizer.STOREOWNER_GOODBYE, CFSpeech|CFTimeout)
elif state == LaffRestockGlobals.RESTOCK:
self.sendUpdate('restock', [laff])
2015-07-25 06:08:54 +00:00
def restockResult(self, state):
if state in LaffRestockGlobals.RestockMessages:
self.setChatAbsolute(LaffRestockGlobals.RestockMessages[state], CFSpeech | CFTimeout)