diff --git a/astron/dclass/united.dc b/astron/dclass/united.dc index e5f0cad0..baf09371 100644 --- a/astron/dclass/united.dc +++ b/astron/dclass/united.dc @@ -362,6 +362,7 @@ from toontown.estate import DistributedBank/AI from toontown.estate import DistributedCloset/AI from toontown.estate import DistributedTrunk/AI from toontown.estate import DistributedPhone/AI +from toontown.estate import DistributedTreasureChest/AI from toontown.effects import DistributedFireworkShow/AI from toontown.estate import DistributedFireworksCannon/AI from toontown.coghq import LobbyManager/AI @@ -2222,6 +2223,11 @@ dclass DistributedPhone : DistributedFurnitureItem { purchaseItemComplete(); }; +dclass DistributedTreasureChest : DistributedObject { + completeSale(bool) airecv clsend; + completeSaleResult(int8, int8, int8); +}; + dclass DistributedFireworkShow : DistributedObject { startShow(uint8, uint8, uint8, int16) broadcast ram; requestFirework(int16/10, int16/10, int16/100, uint8, uint8, uint8) airecv clsend; diff --git a/otp/distributed/DCClassImports.py b/otp/distributed/DCClassImports.py index 4b7d6498..f36fda44 100644 --- a/otp/distributed/DCClassImports.py +++ b/otp/distributed/DCClassImports.py @@ -2,7 +2,7 @@ from pandac.PandaModules import * -hashVal = 2946007471L +hashVal = 3970808174L from toontown.coghq import DistributedCashbotBossSafe, DistributedCashbotBossCrane, DistributedBattleFactory, DistributedCashbotBossTreasure, DistributedCogHQDoor, DistributedSellbotHQDoor, DistributedFactoryElevatorExt, DistributedMintElevatorExt, DistributedLawOfficeElevatorExt, DistributedLawOfficeElevatorInt, LobbyManager, DistributedMegaCorp, DistributedFactory, DistributedLawOffice, DistributedLawOfficeFloor, DistributedLift, DistributedDoorEntity, DistributedSwitch, DistributedButton, DistributedTrigger, DistributedCrushableEntity, DistributedCrusherEntity, DistributedStomper, DistributedStomperPair, DistributedLaserField, DistributedGolfGreenGame, DistributedSecurityCamera, DistributedMover, DistributedElevatorMarker, DistributedBarrelBase, DistributedGagBarrel, DistributedBeanBarrel, DistributedHealBarrel, DistributedGrid, ActiveCell, DirectionalCell, CrusherCell, DistributedCrate, DistributedSinkingPlatform, BattleBlocker, DistributedMint, DistributedMintRoom, DistributedMintBattle, DistributedStage, DistributedStageRoom, DistributedStageBattle, DistributedLawbotBossGavel, DistributedLawbotCannon, DistributedLawbotChair, DistributedCogKart, DistributedCountryClub, DistributedCountryClubRoom, DistributedMoleField, DistributedCountryClubBattle, DistributedMaze, DistributedFoodBelt, DistributedBanquetTable, DistributedGolfSpot @@ -33,7 +33,7 @@ from toontown.friends import TTUFriendsManager from toontown.cogdominium import DistributedCogdoInterior, DistributedCogdoBattleBldg, DistributedCogdoElevatorExt, DistributedCogdoElevatorInt, DistributedCogdoBarrel, DistCogdoGame, DistCogdoLevelGame, DistCogdoBoardroomGame, DistCogdoCraneGame, DistCogdoMazeGame, DistCogdoFlyingGame, DistCogdoCrane, DistCogdoCraneMoneyBag, DistCogdoCraneCog from toontown.uberdog.ARGManager import ARGManager from otp.distributed import Account, DistributedDistrict, DistributedDirectory -from toontown.estate import DistributedCannon, DistributedTarget, EstateManager, DistributedEstate, DistributedHouse, DistributedHouseInterior, DistributedGarden, DistributedHouseDoor, DistributedMailbox, DistributedFurnitureManager, DistributedFurnitureItem, DistributedBank, DistributedCloset, DistributedTrunk, DistributedPhone, DistributedFireworksCannon, DistributedLawnDecor, DistributedGardenPlot, DistributedGardenBox, DistributedFlower, DistributedGagTree, DistributedStatuary, DistributedToonStatuary, DistributedChangingStatuary, DistributedAnimatedStatuary, DistributedPlantBase, DistributedLawnDecor +from toontown.estate import DistributedCannon, DistributedTarget, EstateManager, DistributedEstate, DistributedHouse, DistributedHouseInterior, DistributedGarden, DistributedHouseDoor, DistributedMailbox, DistributedFurnitureManager, DistributedFurnitureItem, DistributedBank, DistributedCloset, DistributedTrunk, DistributedPhone, DistributedTreasureChest, DistributedFireworksCannon, DistributedLawnDecor, DistributedGardenPlot, DistributedGardenBox, DistributedFlower, DistributedGagTree, DistributedStatuary, DistributedToonStatuary, DistributedChangingStatuary, DistributedAnimatedStatuary, DistributedPlantBase, DistributedLawnDecor from toontown.toon import DistributedToon, DistributedNPCToonBase, DistributedNPCToon, DistributedSmartNPC, DistributedNPCSpecialQuestGiver, DistributedNPCFlippyInToonHall, DistributedNPCScientist, DistributedNPCClerk, DistributedNPCTailor, DistributedNPCBlocker, DistributedNPCFisherman, DistributedNPCPartyPerson, DistributedNPCPetclerk, DistributedNPCKartClerk, DistributedNPCGlove from toontown.tutorial import DistributedBattleTutorial, TutorialManager from toontown.pets import DistributedPetProxy diff --git a/toontown/estate/DistributedEstateAI.py b/toontown/estate/DistributedEstateAI.py index bea65ed8..789330ef 100644 --- a/toontown/estate/DistributedEstateAI.py +++ b/toontown/estate/DistributedEstateAI.py @@ -1,9 +1,6 @@ from direct.directnotify import DirectNotifyGlobal from direct.distributed.DistributedObjectAI import DistributedObjectAI from toontown.toonbase import ToontownGlobals -import HouseGlobals -import time, random - from toontown.fishing.DistributedFishingPondAI import DistributedFishingPondAI from toontown.fishing.DistributedFishingTargetAI import DistributedFishingTargetAI from toontown.fishing.DistributedPondBingoManagerAI import DistributedPondBingoManagerAI @@ -12,12 +9,9 @@ from toontown.safezone.DistributedFishingSpotAI import DistributedFishingSpotAI from toontown.safezone.SZTreasurePlannerAI import SZTreasurePlannerAI from toontown.safezone import DistributedTreasureAI from toontown.safezone import TreasureGlobals - from DistributedCannonAI import * from DistributedTargetAI import * -import CannonGlobals - -import TableGlobals +import DistributedTreasureChestAI, CannonGlobals, TableGlobals, HouseGlobals, time, random class Rental: def __init__(self, estate): @@ -168,6 +162,9 @@ class DistributedEstateAI(DistributedObjectAI): spot.generateWithRequired(self.zoneId) self.spots.append(spot) + self.treasureChest = DistributedTreasureChestAI.DistributedTreasureChestAI(self.air) + self.treasureChest.generateWithRequired(self.zoneId) + self.createTreasurePlanner() @@ -189,6 +186,9 @@ class DistributedEstateAI(DistributedObjectAI): if self.rentalHandle: self.rentalHandle.destroy() self.rentalHandle = None + + if self.treasureChest: + self.treasureChest.requestDelete() self.requestDelete() diff --git a/toontown/estate/DistributedTreasureChest.py b/toontown/estate/DistributedTreasureChest.py new file mode 100644 index 00000000..ce92b619 --- /dev/null +++ b/toontown/estate/DistributedTreasureChest.py @@ -0,0 +1,71 @@ +from direct.distributed import DistributedObject +from pandac.PandaModules import * +from toontown.fishing import FishSellGUI +from toontown.toonbase import ToontownGlobals, TTLocalizer +import TreasureChestGlobals + +class DistributedTreasureChest(DistributedObject.DistributedObject): + + def __init__(self, cr): + DistributedObject.DistributedObject.__init__(self, cr) + self.cr = cr + self.createModel(53.5, -152.1, 0.025, -330) + self.initCollisions() + + def destroy(self): + self.ignore('enter' + self.cSphereNode.getName()) + self.cSphereNodePath.removeNode() + self.model.destroy() + self.destroyFishGui() + del self.cSphere + del self.cSphereNode + del self.cSphereNodePath + del self.model + + def destroyFishGui(self): + self.ignore('treasureChestSell') + + if hasattr(self, 'fishGui'): + self.fishGui.destroy() + del self.fishGui + + def createModel(self, x, y, z, h): + self.model = loader.loadModel('phase_4/models/minigames/treasure_chest.bam') + self.model.reparentTo(render) + self.model.setScale(1.5) + self.model.setPos(x, y, z) + self.model.setH(h) + + def initCollisions(self): + self.cSphere = CollisionTube(0.0, 1.0, 0.0, 0.0, 1.0, 5.0, ToontownGlobals.TreasureChestSphereRadius) + self.cSphere.setTangible(0) + self.cSphereNode = CollisionNode('cSphereNode') + self.cSphereNode.addSolid(self.cSphere) + self.cSphereNodePath = self.model.attachNewNode(self.cSphereNode) + self.cSphereNodePath.hide() + self.cSphereNode.setCollideMask(ToontownGlobals.WallBitmask) + self.accept('enter' + self.cSphereNode.getName(), self.handleCollisionSphereEnter) + + def handleCollisionSphereEnter(self, collEntry): + if not base.localAvatar.fishTank.getFish(): + base.localAvatar.setSystemMessage(0, TTLocalizer.STOREOWNER_NOFISH) + return + + base.setCellsActive(base.bottomCells, 0) + base.cr.playGame.getPlace().setState('stopped') + self.acceptOnce('treasureChestSell', self.handleSaleDone) + self.fishGui = FishSellGUI.FishSellGUI('treasureChestSell') + + def handleSaleDone(self, sell): + self.destroyFishGui() + base.setCellsActive(base.bottomCells, 1) + base.cr.playGame.getPlace().setState('walk') + self.sendUpdate('completeSale', [sell]) + + def completeSaleResult(self, state, numFish, maxFish): + if state == TreasureChestGlobals.TROPHY: + base.localAvatar.setSystemMessage(0, TTLocalizer.STOREOWNER_TROPHY % (numFish, maxFish)) + elif state == TreasureChestGlobals.COMPLETE: + base.localAvatar.setSystemMessage(0, TTLocalizer.STOREOWNER_THANKSFISH) + elif state == TreasureChestGlobals.NONE: + base.localAvatar.setSystemMessage(0, TTLocalizer.STOREOWNER_NOFISH) \ No newline at end of file diff --git a/toontown/estate/DistributedTreasureChestAI.py b/toontown/estate/DistributedTreasureChestAI.py new file mode 100644 index 00000000..d9d33263 --- /dev/null +++ b/toontown/estate/DistributedTreasureChestAI.py @@ -0,0 +1,22 @@ +from direct.distributed import DistributedObjectAI +from toontown.fishing import FishGlobals +import TreasureChestGlobals + +class DistributedTreasureChestAI(DistributedObjectAI.DistributedObjectAI): + + def completeSale(self, sell): + avId = self.air.getAvatarIdFromSender() + av = self.air.doId2do.get(avId) + + if not av: + return + + if sell: + trophyResult = self.air.fishManager.creditFishTank(av) + + if trophyResult: + self.sendUpdateToAvatarId(avId, 'completeSaleResult', [TreasureChestGlobals.TROPHY, len(av.fishCollection), FishGlobals.getTotalNumFish()]) + else: + self.sendUpdateToAvatarId(avId, 'completeSaleResult', [TreasureChestGlobals.COMPLETE, 0, 0]) + else: + self.sendUpdateToAvatarId(avId, 'completeSaleResult', [TreasureChestGlobals.NONE, 0, 0]) \ No newline at end of file diff --git a/toontown/estate/EstateLoader.py b/toontown/estate/EstateLoader.py index e44eb2c3..bfc79b1b 100644 --- a/toontown/estate/EstateLoader.py +++ b/toontown/estate/EstateLoader.py @@ -3,7 +3,7 @@ from toontown.toonbase.ToontownGlobals import * from direct.interval.IntervalGlobal import * from direct.fsm import ClassicFSM, State from toontown.safezone import SafeZoneLoader -import random, math, House, Estate, HouseGlobals +import random, math, House, Estate, HouseGlobals from toontown.coghq import MovingPlatform from direct.directnotify import DirectNotifyGlobal diff --git a/toontown/estate/TreasureChestGlobals.py b/toontown/estate/TreasureChestGlobals.py new file mode 100644 index 00000000..fc7278ec --- /dev/null +++ b/toontown/estate/TreasureChestGlobals.py @@ -0,0 +1,3 @@ +TROPHY = 0 +COMPLETE = 1 +NONE = 2 \ No newline at end of file diff --git a/toontown/toonbase/ToontownGlobals.py b/toontown/toonbase/ToontownGlobals.py index d5ee9ece..e5be7258 100644 --- a/toontown/toonbase/ToontownGlobals.py +++ b/toontown/toonbase/ToontownGlobals.py @@ -1637,3 +1637,4 @@ PropIdToColor = [ ] BugReportSite = 'https://bugs.launchpad.net/toontown-united/+filebug' +TreasureChestSphereRadius = 1.0 \ No newline at end of file