Poodletooth-iLand/toontown/building/DistributedKnockKnockDoorAI.py

50 lines
1.8 KiB
Python
Raw Normal View History

2015-03-03 16:10:12 -06:00
from direct.task.Task import Task
from otp.ai.AIBaseGlobal import *
2015-06-27 12:01:51 -05:00
from toontown.toonbase import ToontownGlobals
import DistributedAnimatedPropAI
import time
2015-03-03 16:10:12 -06:00
class DistributedKnockKnockDoorAI(DistributedAnimatedPropAI.DistributedAnimatedPropAI):
def __init__(self, air, propId):
DistributedAnimatedPropAI.DistributedAnimatedPropAI.__init__(self, air, propId)
self.fsm.setName('DistributedKnockKnockDoor')
self.propId = propId
self.doLaterTask = None
2015-08-22 17:33:08 -05:00
def delete(self):
DistributedAnimatedPropAI.DistributedAnimatedPropAI.delete(self)
2015-03-03 16:10:12 -06:00
def enterOff(self):
DistributedAnimatedPropAI.DistributedAnimatedPropAI.enterOff(self)
def exitOff(self):
DistributedAnimatedPropAI.DistributedAnimatedPropAI.exitOff(self)
def attractTask(self, task):
self.fsm.request('attract')
return Task.done
def enterAttract(self):
DistributedAnimatedPropAI.DistributedAnimatedPropAI.enterAttract(self)
def exitAttract(self):
DistributedAnimatedPropAI.DistributedAnimatedPropAI.exitAttract(self)
def enterPlaying(self):
DistributedAnimatedPropAI.DistributedAnimatedPropAI.enterPlaying(self)
self.doLaterTask = taskMgr.doMethodLater(9, self.attractTask, self.uniqueName('knockKnock-timer'))
def exitPlaying(self):
DistributedAnimatedPropAI.DistributedAnimatedPropAI.exitPlaying(self)
taskMgr.remove(self.doLaterTask)
self.doLaterTask = None
2015-07-05 18:59:25 -05:00
2015-06-27 12:01:51 -05:00
def requestToonup(self):
av = self.air.doId2do.get(self.air.getAvatarIdFromSender())
if (not av) or av.getHp() == av.getMaxHp() or av.getNextKnockHeal() > time.time():
return
av.toonUp(ToontownGlobals.KnockKnockHeal)
2015-07-05 18:59:25 -05:00
av.b_setNextKnockHeal(int(time.time() + ToontownGlobals.KnockKnockCooldown))