RENTALS: Began work on rentals.

This commit is contained in:
Loudrob 2015-03-23 08:56:48 -04:00
parent 2178afb292
commit 0f24fb0ffd
9 changed files with 319 additions and 86 deletions

View file

@ -28,6 +28,9 @@ class CatalogChatItem(CatalogItem.CatalogItem):
def getDisplayName(self): def getDisplayName(self):
return OTPLocalizer.CustomSCStrings[self.customIndex] return OTPLocalizer.CustomSCStrings[self.customIndex]
def getDeliveryTime(self):
return 0
def recordPurchase(self, avatar, optional): def recordPurchase(self, avatar, optional):
if avatar.customMessages.count(self.customIndex) != 0: if avatar.customMessages.count(self.customIndex) != 0:
return ToontownGlobals.P_ReachedPurchaseLimit return ToontownGlobals.P_ReachedPurchaseLimit

View file

@ -55,6 +55,9 @@ class CatalogNametagItem(CatalogItem.CatalogItem):
avatar.b_setNametagStyle(self.nametagStyle) avatar.b_setNametagStyle(self.nametagStyle)
return ToontownGlobals.P_ItemAvailable return ToontownGlobals.P_ItemAvailable
def getDeliveryTime(self):
return 0
def getPicture(self, avatar): def getPicture(self, avatar):
frame = self.makeFrame() frame = self.makeFrame()
if self.nametagStyle == 100: if self.nametagStyle == 100:

View file

@ -47,15 +47,14 @@ class CatalogRentalItem(CatalogItem.CatalogItem):
return TTLocalizer.RentalTypeName return TTLocalizer.RentalTypeName
def recordPurchase(self, avatar, optional): def recordPurchase(self, avatar, optional):
self.notify.debug('rental -- record purchase')
if avatar: if avatar:
self.notify.debug('rental -- has avater') self.notify.debug('rental -- has avatar')
estate = simbase.air.estateManager._lookupEstate(avatar.doId) estate = simbase.air.estateManager._lookupEstate(avatar)
if estate: if estate:
self.notify.debug('rental -- has estate') self.notify.debug('rental -- has estate')
estate.rentItem(self.typeIndex, self.duration) estate.rentItem(self.typeIndex, self.duration)
else: else:
self.notify.debug('rental -- something not there') self.notify.warning('rental -- something not there')
return ToontownGlobals.P_ItemAvailable return ToontownGlobals.P_ItemAvailable
def getPicture(self, avatar): def getPicture(self, avatar):
@ -106,6 +105,9 @@ class CatalogRentalItem(CatalogItem.CatalogItem):
dg.addUint16(self.duration) dg.addUint16(self.duration)
dg.addUint16(self.typeIndex) dg.addUint16(self.typeIndex)
def getDeliveryTime(self):
return 1
def isRental(self): def isRental(self):
return 1 return 1

View file

@ -1,4 +1,4 @@
CANNON_TIMEOUT = 20 CANNON_TIMEOUT = 30
CANNON_MOVIE_LOAD = 1 CANNON_MOVIE_LOAD = 1
CANNON_MOVIE_CLEAR = 2 CANNON_MOVIE_CLEAR = 2
CANNON_MOVIE_FORCE_EXIT = 3 CANNON_MOVIE_FORCE_EXIT = 3

View file

@ -1,29 +1,29 @@
from direct.controls.ControlManager import CollisionHandlerRayStart from pandac.PandaModules import *
from direct.distributed import DistributedObject from toontown.toonbase.ToonBaseGlobal import *
from toontown.toonbase import ToontownGlobals
from direct.distributed.ClockDelta import * from direct.distributed.ClockDelta import *
from direct.interval.IntervalGlobal import *
from direct.fsm import ClassicFSM, State from direct.fsm import ClassicFSM, State
from direct.fsm import State from direct.fsm import State
from direct.gui.DirectGui import *
from direct.interval.IntervalGlobal import *
from direct.task.Task import Task
import math
from pandac.PandaModules import *
from pandac.PandaModules import *
import CannonGlobals
from toontown.effects import DustCloud
from toontown.effects import Splash
from toontown.effects import Wake
from toontown.minigame import CannonGameGlobals
from toontown.minigame import Trajectory
from toontown.nametag.NametagFloat3d import NametagFloat3d
from toontown.toon import ToonHead
from toontown.toonbase import TTLocalizer
from toontown.toonbase import ToontownGlobals
from toontown.toonbase import ToontownGlobals from toontown.toonbase import ToontownGlobals
from toontown.toonbase import ToontownTimer from toontown.toonbase import ToontownTimer
from toontown.toonbase.ToonBaseGlobal import * from direct.task.Task import Task
from toontown.minigame import Trajectory
import math
from toontown.toon import ToonHead
from toontown.effects import Splash
from toontown.effects import DustCloud
from toontown.minigame import CannonGameGlobals
import CannonGlobals
from direct.gui.DirectGui import *
from pandac.PandaModules import *
from toontown.toonbase import TTLocalizer
from direct.distributed import DistributedObject
from toontown.effects import Wake
from direct.controls.ControlManager import CollisionHandlerRayStart
from toontown.nametag.NametagFloat3d import NametagFloat3d
from toontown.nametag.Nametag import Nametag
LAND_TIME = 2 LAND_TIME = 2
WORLD_SCALE = 2.0 WORLD_SCALE = 2.0
@ -267,7 +267,7 @@ class DistributedCannon(DistributedObject.DistributedObject):
self.curPinballScore = 0 self.curPinballScore = 0
self.curPinballMultiplier = 1 self.curPinballMultiplier = 1
self.incrementPinballInfo(0, 0) self.incrementPinballInfo(0, 0)
if self.avId in self.cr.doId2do: if self.cr.doId2do.has_key(self.avId):
self.av = self.cr.doId2do[self.avId] self.av = self.cr.doId2do[self.avId]
self.acceptOnce(self.av.uniqueName('disable'), self.__avatarGone) self.acceptOnce(self.av.uniqueName('disable'), self.__avatarGone)
self.av.stopSmooth() self.av.stopSmooth()
@ -844,6 +844,7 @@ class DistributedCannon(DistributedObject.DistributedObject):
flyTask.info = info flyTask.info = info
seqTask = Task.sequence(shootTask, smokeTask, flyTask) seqTask = Task.sequence(shootTask, smokeTask, flyTask)
if self.av == base.localAvatar: if self.av == base.localAvatar:
print 'disable controls'
base.localAvatar.disableAvatarControls() base.localAvatar.disableAvatarControls()
taskMgr.add(seqTask, self.taskName('flyingToon') + '-' + str(avId)) taskMgr.add(seqTask, self.taskName('flyingToon') + '-' + str(avId))
self.acceptOnce(self.uniqueName('stopFlyTask'), self.__stopFlyTask) self.acceptOnce(self.uniqueName('stopFlyTask'), self.__stopFlyTask)
@ -865,6 +866,7 @@ class DistributedCannon(DistributedObject.DistributedObject):
def removeAvFromCannon(self): def removeAvFromCannon(self):
place = base.cr.playGame.getPlace() place = base.cr.playGame.getPlace()
print 'removeAvFromCannon'
self.notify.debug('self.inWater = %s' % self.inWater) self.notify.debug('self.inWater = %s' % self.inWater)
if place: if place:
if not hasattr(place, 'fsm'): if not hasattr(place, 'fsm'):
@ -893,6 +895,7 @@ class DistributedCannon(DistributedObject.DistributedObject):
self.av.startSmooth() self.av.startSmooth()
self.av.setScale(1, 1, 1) self.av.setScale(1, 1, 1)
if self.av == base.localAvatar: if self.av == base.localAvatar:
print 'enable controls'
base.localAvatar.enableAvatarControls() base.localAvatar.enableAvatarControls()
self.ignore(self.av.uniqueName('disable')) self.ignore(self.av.uniqueName('disable'))
self.__destroyToonModels() self.__destroyToonModels()
@ -1160,6 +1163,7 @@ class DistributedCannon(DistributedObject.DistributedObject):
if hitP[2] > ToontownGlobals.EstateWakeWaterHeight: if hitP[2] > ToontownGlobals.EstateWakeWaterHeight:
self.notify.debug('we hit the ground before we hit water') self.notify.debug('we hit the ground before we hit water')
self.__hitGround(avatar, pos, extraArgs) self.__hitGround(avatar, pos, extraArgs)
print 'but not really'
return return
self.inWater = 1 self.inWater = 1
self.notify.debug('hit water') self.notify.debug('hit water')
@ -1242,7 +1246,7 @@ class DistributedCannon(DistributedObject.DistributedObject):
for id in doIds: for id in doIds:
t = self.cr.doId2do.get(id) t = self.cr.doId2do.get(id)
if t: if t:
pos = t.pos pos = t.nodePath.getPos()
rad = 10.5 rad = 10.5
height = 10.0 height = 10.0
t_impact = trajectory.checkCollisionWithCylinderSides(pos, rad, height) t_impact = trajectory.checkCollisionWithCylinderSides(pos, rad, height)
@ -1508,7 +1512,7 @@ class DistributedCannon(DistributedObject.DistributedObject):
(0, 1, 5, 4), (0, 1, 5, 4),
(0, 4, 7, 3), (0, 4, 7, 3),
(1, 2, 6, 5)] (1, 2, 6, 5)]
for i in xrange(len(vertices)): for i in range(len(vertices)):
vertex = vertices[i] vertex = vertices[i]
vertexWriter.addData3f(vertex[0], vertex[1], vertex[2]) vertexWriter.addData3f(vertex[0], vertex[1], vertex[2])
colorWriter.addData4f(*colors[i]) colorWriter.addData4f(*colors[i])
@ -1577,4 +1581,5 @@ class DistributedCannon(DistributedObject.DistributedObject):
def turnOnBumperCollision(self, whatever = 0): def turnOnBumperCollision(self, whatever = 0):
if self.bumperCol: if self.bumperCol:
self.bumperCol.setCollideMask(ToontownGlobals.WallBitmask)# decompiled 0 files: 0 okay, 1 failed, 0 verify failed self.bumperCol.setCollideMask(ToontownGlobals.WallBitmask)

View file

@ -1,57 +1,102 @@
from direct.directnotify import DirectNotifyGlobal from direct.directnotify import DirectNotifyGlobal
from direct.distributed.DistributedObjectAI import DistributedObjectAI from direct.distributed.DistributedObjectAI import DistributedObjectAI
from direct.distributed.ClockDelta import *
from toontown.minigame import CannonGameGlobals
from toontown.toonbase import ToontownGlobals
import CannonGlobals
class DistributedCannonAI(DistributedObjectAI): class DistributedCannonAI(DistributedObjectAI):
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedCannonAI") notify = DirectNotifyGlobal.directNotify.newCategory("DistributedCannonAI")
def setEstateId(self, todo0): def __init__(self, air):
pass DistributedObjectAI.__init__(self, air)
self.estateId = 0
self.targetId = 0
self.posHpr = (0, 0, 0, 0, 0, 0)
self.bumperPos = ToontownGlobals.PinballCannonBumperInitialPos
self.active = 0
self.avId = 0
def setEstateId(self, estateId):
self.estateId = estateId
def getEstateId(self):
return self.estateId
def setTargetId(self, todo0): def setTargetId(self, targetId):
pass self.targetId = targetId
def getTargetId(self):
return self.targetId
def setPosHpr(self, todo0, todo1, todo2, todo3, todo4, todo5): def setPosHpr(self, x, y, z, h, p, r):
pass self.posHpr = (x, y, z, h, p, r)
def getPosHpr(self):
return self.posHpr
def setActive(self, todo0): def setActive(self, active):
pass self.active = active
self.sendUpdate("setActiveState", [active])
def setActiveState(self, todo0):
pass
def requestEnter(self): def requestEnter(self):
pass avId = self.air.getAvatarIdFromSender()
av = self.air.doId2do.get(avId)
if not av:
return
if not self.avId:
self.avId = avId
self.d_setMovie(CannonGlobals.CANNON_MOVIE_LOAD)
self.acceptOnce(self.air.getAvatarExitEvent(avId), self.__handleUnexpectedExit, extraArgs=[avId])
else:
self.air.writeServerEvent('suspicious', avId, 'DistributedCannonAI.requestEnter cannon already occupied')
self.notify.warning('requestEnter() - cannon already occupied')
def setMovie(self, mode, avId, extraInfo):
self.avId = avId
self.sendUpdate('setMovie', [mode, avId, extraInfo])
def __handleUnexpectedExit(self, avId):
self.notify.warning('avatar:' + str(avId) + ' has exited unexpectedly')
self.__doExit()
def __doExit(self, movie=CannonGlobals.CANNON_MOVIE_FORCE_EXIT):
self.ignore(self.air.getAvatarExitEvent(self.avId))
self.d_setMovie(movie)
self.avId = 0
def requestExit(self): def requestExit(self):
pass pass
def setMovie(self, todo0, todo1): def d_setMovie(self, movie):
pass self.sendUpdate("setMovie", [movie, self.avId])
def setCannonPosition(self, todo0, todo1): def setCannonPosition(self, zRot, angle):
pass self.sendUpdate("updateCannonPosition", [self.avId, zRot, angle])
def setCannonLit(self, todo0, todo1): def setCannonLit(self, zRot, angle):
pass avId = self.air.getAvatarIdFromSender()
if avId != self.avId:
return
fireTime = CannonGameGlobals.FUSE_TIME
self.sendUpdate('setCannonWillFire', [avId, fireTime, zRot, angle, globalClockDelta.getRealNetworkTime()])
def setFired(self): def setFired(self):
pass pass
def setLanded(self): def setLanded(self):
pass self.__doExit(CannonGlobals.CANNON_MOVIE_CLEAR)
self.sendUpdate('setCannonExit', [self.avId])
def updateCannonPosition(self, todo0, todo1, todo2):
pass
def setCannonWillFire(self, todo0, todo1, todo2, todo3, todo4):
pass
def setCannonExit(self, todo0): def setCannonExit(self, todo0):
pass pass
def requestBumperMove(self, todo0, todo1, todo2): def requestBumperMove(self, x, y, z):
pass self.bumperPos = (x, y, z)
self.sendUpdate('setCannonBumperPos', self.getCannonBumperPos())
def setCannonBumperPos(self, todo0, todo1, todo2):
pass
def getCannonBumperPos(self):
return self.bumperPos

View file

@ -149,6 +149,82 @@ class GardenManager:
return packGardenData(NULL_FLOWERS + NULL_TREES, NULL_STATUARY, False) return packGardenData(NULL_FLOWERS + NULL_TREES, NULL_STATUARY, False)
return packGardenData(g.flowersData + g.treesData, g.statuaryIndex) return packGardenData(g.flowersData + g.treesData, g.statuaryIndex)
class Rental:
def __init__(self, estate):
self.estate = estate
self.objects = set()
def destroy(self):
del self.estate
for object in self.objects:
if not object.isDeleted():
object.requestDelete()
taskMgr.remove(object.uniqueName('delete'))
self.objects = set()
class CannonRental(Rental):
def generateObjects(self):
target = DistributedTargetAI(self.estate.air)
target.generateWithRequired(self.estate.zoneId)
for drop in CannonGlobals.cannonDrops:
cannon = DistributedCannonAI(self.estate.air)
cannon.setEstateId(self.estate.doId)
cannon.setTargetId(target.doId)
cannon.setPosHpr(*drop)
cannon.generateWithRequired(self.estate.zoneId)
self.objects.add(cannon)
self.generateTreasures()
self.estate.b_setClouds(1)
def destroy(self):
self.estate.b_setClouds(0)
Rental.destroy(self)
def generateTreasures(self):
doIds = []
z = 35
for i in xrange(20):
x = random.randint(100, 300) - 200
y = random.randint(100, 300) - 200
treasure = DistributedTreasureAI.DistributedTreasureAI(self.estate.air, self, 9, x, y, z)
treasure.generateWithRequired(self.estate.zoneId)
self.objects.add(treasure)
doIds.append(treasure.doId)
self.estate.sendUpdate("setTreasureIds", [doIds])
def grabAttempt(self, avId, treasureId):
av = self.estate.air.doId2do.get(avId)
if av == None:
self.estate.air.writeServerEvent('suspicious', avId, 'TreasurePlannerAI.grabAttempt unknown avatar')
self.estate.notify.warning('avid: %s does not exist' % avId)
return
treasure = self.estate.air.doId2do.get(treasureId)
if self.validAvatar(av):
treasure.d_setGrab(avId)
self.deleteTreasureSoon(treasure)
else:
treasure.d_setReject()
def deleteTreasureSoon(self, treasure):
taskName = treasure.uniqueName('delete')
taskMgr.doMethodLater(5, self.__deleteTreasureNow, taskName, extraArgs=(treasure, taskName))
def __deleteTreasureNow(self, treasure, taskName):
treasure.requestDelete()
def validAvatar(self, av):
if av.getMaxHp() == av.getHp():
return 0
av.toonUp(3)
return 1
class DistributedEstateAI(DistributedObjectAI): class DistributedEstateAI(DistributedObjectAI):
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedEstateAI") notify = DirectNotifyGlobal.directNotify.newCategory("DistributedEstateAI")
def __init__(self, air): def __init__(self, air):
@ -235,6 +311,9 @@ class DistributedEstateAI(DistributedObjectAI):
self.pond.requestDelete() self.pond.requestDelete()
self.pond = None self.pond = None
self.gardenManager.destroy() self.gardenManager.destroy()
if self.rentalHandle:
self.rentalHandle.destroy()
self.rentalHandle = None
if self.treasurePlanner: if self.treasurePlanner:
self.treasurePlanner.stop() self.treasurePlanner.stop()
self.requestDelete() self.requestDelete()
@ -322,18 +401,58 @@ class DistributedEstateAI(DistributedObjectAI):
self.sendUpdate('setRentalTimeStamp', [rental]) self.sendUpdate('setRentalTimeStamp', [rental])
def b_setRentalTimeStamp(self, rental): def b_setRentalTimeStamp(self, rental):
self.setRentalTimeStamp(self, rental) self.setRentalTimeStamp(rental)
self.b_setRentalTimeStamp(self, rental) self.d_setRentalTimeStamp(rental)
def getRentalTimeStamp(self): def getRentalTimeStamp(self):
return self.rentalTimestamp return self.rentalTimestamp
def setRentalType(self, todo0): def b_setRentalType(self, type):
pass self.d_setRentalType(type)
self.setRentalType(type)
def d_setRentalType(self, type):
self.sendUpdate("setRentalType", [type])
def setRentalType(self, type):
expirestamp = self.getRentalTimeStamp()
if expirestamp == 0:
expire = 0
else:
expire = int(expirestamp - time.time())
if expire < 0:
self.rentalType = 0
self.d_setRentalType(0)
self.b_setRentalTimeStamp(0)
else:
if self.rentalType == type:
return
self.rentalType = type
if self.rentalHandle:
self.rentalHandle.destroy()
self.rentalHandle = None
if self.rentalType == ToontownGlobals.RentalCannon:
self.rentalHandle = CannonRental(self)
else:
self.notify.warning('Unknown rental %s' % self.rentalType)
return
self.rentalHandle.generateObjects()
def getRentalType(self): def getRentalType(self):
return 0 return self.rentalType
def rentItem(self, rentType, duration):
self.rentalType = rentType
self.b_setRentalTimeStamp(time.time() + duration * 60)
self.b_setRentalType(rentType)
def setSlot0ToonId(self, id): def setSlot0ToonId(self, id):
self.toons[0] = id self.toons[0] = id

View file

@ -155,12 +155,12 @@ class DistributedTarget(DistributedObject.DistributedObject):
def showTimer(self): def showTimer(self):
if base.localAvatar.animFSM.getCurrentState().getName() != 'ReadBook': if base.localAvatar.animFSM.getCurrentState().getName() != 'ReadBook':
base.setCellsActive([base.rightCells[0]], 0) base.setCellsAvailable([base.rightCells[0]], 0)
self.timer.show() self.timer.show()
def hideTimer(self): def hideTimer(self):
self.timer.hide() self.timer.hide()
base.setCellsActive([base.rightCells[0]], 1) base.setCellsAvailable([base.rightCells[0]], 1)
def setPosition(self, x, y, z): def setPosition(self, x, y, z):
self.geom.setPos(x, y, z) self.geom.setPos(x, y, z)

View file

@ -1,30 +1,86 @@
from direct.directnotify import DirectNotifyGlobal from direct.directnotify import DirectNotifyGlobal
from direct.distributed.DistributedObjectAI import DistributedObjectAI from direct.distributed.DistributedObjectAI import DistributedObjectAI
import CannonGlobals
class DistributedTargetAI(DistributedObjectAI): class DistributedTargetAI(DistributedObjectAI):
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedTargetAI") notify = DirectNotifyGlobal.directNotify.newCategory("DistributedTargetAI")
def setPosition(self, todo0, todo1, todo2): def __init__(self, air):
DistributedObjectAI.__init__(self, air)
self.enabled = 0
self.highscore = 0
self.scoreDict = {}
self.__newGame()
def announceGenerate(self):
DistributedObjectAI.announceGenerate(self)
taskMgr.doMethodLater(10, self.__startNewGame, self.taskName('newGame'))
def __newGame(self):
self.power = 1
self.time = CannonGlobals.CANNON_TIMEOUT
def getPosition(self):
return (0, 0, 40)
def getState(self):
return self.enabled, 2**self.power, self.time
def d_updateState(self):
self.sendUpdate("setState", self.getState())
def d_setReward(self, reward):
self.sendUpdate("setReward", [reward])
def setResult(self, avId):
if avId and self.enabled:
self.power += 1
self.time = int(CannonGlobals.CANNON_TIMEOUT / self.power)
taskMgr.remove(self.taskName('gameover'))
taskMgr.doMethodLater(self.time, self.__gameOver, self.taskName('gameover'))
self.d_updateState()
def __gameOver(self, task):
self.enabled = 0
self.time = 0
self.d_updateState()
taskMgr.doMethodLater(10, self.__startNewGame, self.taskName('newGame'))
for avId in self.scoreDict:
av = self.air.doId2do.get(avId)
if av:
if av.zoneId == self.zoneId:
av.toonUp(2 ** self.power)
return task.done
def __startNewGame(self, task):
self.enabled = 1
self.__newGame()
self.d_updateState()
taskMgr.doMethodLater(self.time, self.__gameOver, self.taskName('gameover'))
return task.done
def setBonus(self, bonus):
pass pass
def setState(self, todo0, todo1, todo2): def setCurPinballScore(self, avId, score, bonus):
pass av = self.air.doId2do.get(avId)
if not av:
return
S = score * bonus
self.scoreDict[avId] = S
if S > self.highscore:
self.highscore = S
self.d_updateHighscore(av, S)
def setReward(self, todo0): def d_updateHighscore(self, av, score):
pass self.sendUpdate("setPinballHiScorer", [av.getName()])
self.sendUpdate("setPinballHiScore", [score])
def setResult(self, todo0): def delete(self):
pass taskMgr.remove(self.taskName('newGame'))
taskMgr.remove(self.taskName('gameover'))
def setBonus(self, todo0):
pass
def setCurPinballScore(self, todo0, todo1, todo2):
pass
def setPinballHiScorer(self, todo0):
pass
def setPinballHiScore(self, todo0):
pass