From 6becda3f166f991a38c9a7f9c4261ee3ebc77e76 Mon Sep 17 00:00:00 2001 From: John Date: Sat, 29 Aug 2015 15:24:40 +0300 Subject: [PATCH] The teleport button now takes jellybeans for usage + add proper teleport coordinates for Toon Hall --- dependencies/astron/dclass/stride.dc | 1 + toontown/building/ToonInterior.py | 13 ++++---- toontown/quest/QuestPoster.py | 44 +++++++++++++++++++------ toontown/toon/DistributedToon.py | 3 ++ toontown/toonbase/TTLocalizerEnglish.py | 3 ++ toontown/toonbase/ToontownGlobals.py | 15 ++++++++- 6 files changed, 62 insertions(+), 17 deletions(-) diff --git a/dependencies/astron/dclass/stride.dc b/dependencies/astron/dclass/stride.dc index 0c222f16..5cc646c6 100644 --- a/dependencies/astron/dclass/stride.dc +++ b/dependencies/astron/dclass/stride.dc @@ -755,6 +755,7 @@ dclass DistributedToon : DistributedPlayer { requestNametagStyle(uint8) airecv ownsend; requestFishingRod(uint8) airecv ownsend; wipeStats() airecv ownsend; + takeMoney(int16) airecv ownsend; }; dclass DistributedPartyGate : DistributedObject { diff --git a/toontown/building/ToonInterior.py b/toontown/building/ToonInterior.py index 0e39640d..fb2f05d8 100755 --- a/toontown/building/ToonInterior.py +++ b/toontown/building/ToonInterior.py @@ -176,16 +176,17 @@ class ToonInterior(Place.Place): def enterTeleportIn(self, requestStatus): modelType = DistributedToonInterior.DistributedToonInterior(base.cr).getModelType(self.getZoneId()) - if ZoneUtil.isHQ(self.zoneId): + if self.zoneId == ToontownGlobals.ToonHall: + base.localAvatar.setPosHpr(-63.5, 30.5, ToontownGlobals.FloorOffset, 90.0, 0.0, 0.0) + elif ZoneUtil.isHQ(self.zoneId): base.localAvatar.setPosHpr(-5.5, -1.5, ToontownGlobals.FloorOffset, 0.0, 0.0, 0.0) elif ZoneUtil.isPetshop(self.zoneId): base.localAvatar.setPosHpr(0, 0, ToontownGlobals.FloorOffset, 45.0, 0.0, 0.0) + elif modelType in InteriorTypes: + area = InteriorTypes[modelType] + base.localAvatar.setPosHpr(area[0], area[1], ToontownGlobals.FloorOffset, area[2], 0.0, 0.0) else: - if modelType in InteriorTypes: - area = InteriorTypes[modelType] - base.localAvatar.setPosHpr(area[0], area[1], ToontownGlobals.FloorOffset, area[2], 0.0, 0.0) - else: - base.localAvatar.setPosHpr(2.5, 11.5, ToontownGlobals.FloorOffset, 45.0, 0.0, 0.0) + base.localAvatar.setPosHpr(2.5, 11.5, ToontownGlobals.FloorOffset, 45.0, 0.0, 0.0) Place.Place.enterTeleportIn(self, requestStatus) def enterTeleportOut(self, requestStatus): diff --git a/toontown/quest/QuestPoster.py b/toontown/quest/QuestPoster.py index a5b9c577..9ccb40cf 100755 --- a/toontown/quest/QuestPoster.py +++ b/toontown/quest/QuestPoster.py @@ -73,11 +73,18 @@ class QuestPoster(DirectFrame): self.teleportButton = DirectButton(parent=self.questFrame, relief=None, image=circleModel, text=TTLocalizer.TeleportButton, text_scale=0.035, text_pos=(-0.0025, -0.015), pos=(0.175, 0, 0.125), scale=0.75) #, text_bg=(0, 0.75, 1, 1) self.teleportButton.hide() self.laffMeter = None - return + self.dialog = None def destroy(self): self._deleteGeoms() + self.destroyDialog() DirectFrame.destroy(self) + + def destroyDialog(self, extra=None): + if self.dialog: + self.dialog.destroy() + self.dialog = None + base.cr.playGame.getPlace().setState('walk') def _deleteGeoms(self): for icon in (self.lQuestIcon, self.rQuestIcon): @@ -153,11 +160,7 @@ class QuestPoster(DirectFrame): def loadElevator(self, building, numFloors): elevatorNodePath = hidden.attachNewNode('elevatorNodePath') elevatorModel = loader.loadModel('phase_4/models/modules/elevator') - floorIndicator = [None, - None, - None, - None, - None] + floorIndicator = [None] * 5 npc = elevatorModel.findAllMatches('**/floor_light_?;+s') for i in xrange(npc.getNumPaths()): np = npc.getPath(i) @@ -174,6 +177,9 @@ class QuestPoster(DirectFrame): elevatorNodePath.setPosHpr(0, 0, 0, 0, 0, 0) def teleportToShop(self, npcId): + if base.cr.playGame.getPlace().getState() != 'walk': + return + npcZone = NPCToons.getNPCZone(npcId) npcHood = ZoneUtil.getCanonicalHoodId(npcZone) hqZone = {2000:2520, 1000:1507, 3000:3508, 4000:4504, 5000:5502, 7000:7503, 9000:9505} @@ -184,15 +190,32 @@ class QuestPoster(DirectFrame): zoneId = 2000 npcHood = ZoneUtil.getCanonicalHoodId(zoneId) npcZone = hqZone.get(npcHood, 2520) + + cost = ToontownGlobals.getTeleportButtonCost(npcHood) + self.destroyDialog() + base.cr.playGame.getPlace().setState('stopped') + + if base.localAvatar.getTotalMoney() < cost: + self.dialog = TTDialog.TTDialog(style=TTDialog.Acknowledge, text=TTLocalizer.TeleportButtonNoMoney % cost, command=self.destroyDialog) + else: + self.dialog = TTDialog.TTDialog(style=TTDialog.YesNo, text=TTLocalizer.TeleportButtonConfirm % cost, command=lambda value: self.teleportToShopConfirm(npcZone, npcHood, cost, value)) - base.cr.buildingQueryMgr.d_isSuit(npcZone, lambda isSuit: self.teleportToShopCallback(npcZone, npcHood, isSuit)) + self.dialog.show() - def teleportToShopCallback(self, npcZone, npcHood, flag): + def teleportToShopConfirm(self, npcZone, npcHood, cost, value): + self.destroyDialog() + + if value > 0: + base.cr.buildingQueryMgr.d_isSuit(npcZone, lambda isSuit: self.teleportToShopCallback(npcZone, npcHood, cost, isSuit)) + + def teleportToShopCallback(self, npcZone, npcHood, cost, flag): if flag: - self.teleportButton.setColorScale(0.3, 0.3, 0.3, 1.0) + base.cr.playGame.getPlace().setState('stopped') + self.dialog = TTDialog.TTDialog(style=TTDialog.Acknowledge, text=TTLocalizer.TeleportButtonTakenOver, command=self.destroyDialog) + self.dialog.show() return - self.teleportButton.setColorScale(1.0, 1.0, 1.0, 1.0) + base.localAvatar.takeMoney(cost) base.cr.playGame.getPlace().requestTeleport(npcHood, npcZone, base.localAvatar.defaultShard, -1) def fitGeometry(self, geom, fFlip = 0, dimension = 0.8): @@ -228,6 +251,7 @@ class QuestPoster(DirectFrame): self.rPictureFrame.hide() self.questProgress.hide() self.teleportButton.hide() + self.destroyDialog() if hasattr(self, 'chooseButton'): self.chooseButton.destroy() del self.chooseButton diff --git a/toontown/toon/DistributedToon.py b/toontown/toon/DistributedToon.py index cb8cd4c6..794a85fe 100755 --- a/toontown/toon/DistributedToon.py +++ b/toontown/toon/DistributedToon.py @@ -1258,6 +1258,9 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute def getTotalMoney(self): return self.getBankMoney() + self.getMoney() + + def takeMoney(self, money): + self.sendUpdate('takeMoney', [money]) def setEmblems(self, emblems): if self.emblems != emblems: diff --git a/toontown/toonbase/TTLocalizerEnglish.py b/toontown/toonbase/TTLocalizerEnglish.py index 3696b9ab..6545a166 100755 --- a/toontown/toonbase/TTLocalizerEnglish.py +++ b/toontown/toonbase/TTLocalizerEnglish.py @@ -8727,6 +8727,9 @@ ShardPageShardTitle = '%s Population: %s' ShardPageTeleport = 'Teleport to\n%s' TeleportButton = 'Teleport' +TeleportButtonNoMoney = 'Sorry, but you need %s jellybeans to teleport!' +TeleportButtonConfirm = 'Would you like to spend %s jellybeans to teleport?' +TeleportButtonTakenOver = 'Sorry, but this shop has been taken over by the Cogs!' BattleCogPopup = '\x01androidGreen\x01Group attacks:\x02\n%s\n\n\x01androidGreen\x01Regular attacks:\x02\n%s' BattleCogPopupAttack = '%s %s HP' diff --git a/toontown/toonbase/ToontownGlobals.py b/toontown/toonbase/ToontownGlobals.py index 6e4ede84..baa76345 100755 --- a/toontown/toonbase/ToontownGlobals.py +++ b/toontown/toonbase/ToontownGlobals.py @@ -1688,4 +1688,17 @@ TV_OK = 2 COLOR_SATURATION_MIN = 0.5 COLOR_SATURATION_MAX = 0.8 COLOR_VALUE_MIN = 0.5 -COLOR_VALUE_MAX = 0.8 \ No newline at end of file +COLOR_VALUE_MAX = 0.8 + +TELEPORT_BUTTON_DEFAULT_COST = 50 +TELEPORT_BUTTON_COSTS = { + ToontownCentral: 5, + DonaldsDock: 15, + DaisyGardens: 30, + MinniesMelodyland: 45, + TheBrrrgh: 60, + DonaldsDreamland: 75 +} + +def getTeleportButtonCost(hoodId): + return TELEPORT_BUTTON_COSTS.get(hoodId, TELEPORT_BUTTON_DEFAULT_COST) \ No newline at end of file