diff --git a/astron/dclass/united.dc b/astron/dclass/united.dc index baf09371..0d66844a 100644 --- a/astron/dclass/united.dc +++ b/astron/dclass/united.dc @@ -338,6 +338,7 @@ from toontown.toon import DistributedNPCPartyPerson/AI from toontown.toon import DistributedNPCPetclerk/AI from toontown.toon import DistributedNPCKartClerk/AI from toontown.toon import DistributedNPCGlove/AI +from toontown.toon import DistributedNPCLaffRestock/AI from toontown.building import DistributedKnockKnockDoor/AI from toontown.building import DistributedElevator/AI from toontown.building import DistributedElevatorFSM/AI @@ -1961,6 +1962,11 @@ dclass DistributedNPCGlove : DistributedNPCToonBase { requestTransformation(uint32) airecv clsend; }; +dclass DistributedNPCLaffRestock : DistributedNPCToonBase { + restock() airecv clsend; + restockResult(int8, int16); +}; + dclass DistributedKnockKnockDoor : DistributedAnimatedProp { }; diff --git a/otp/distributed/DCClassImports.py b/otp/distributed/DCClassImports.py index f36fda44..de933193 100644 --- a/otp/distributed/DCClassImports.py +++ b/otp/distributed/DCClassImports.py @@ -2,7 +2,7 @@ from pandac.PandaModules import * -hashVal = 3970808174L +hashVal = 3008682321L 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 @@ -34,7 +34,7 @@ from toontown.cogdominium import DistributedCogdoInterior, DistributedCogdoBattl 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, 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.toon import DistributedToon, DistributedNPCToonBase, DistributedNPCToon, DistributedSmartNPC, DistributedNPCSpecialQuestGiver, DistributedNPCFlippyInToonHall, DistributedNPCScientist, DistributedNPCClerk, DistributedNPCTailor, DistributedNPCBlocker, DistributedNPCFisherman, DistributedNPCPartyPerson, DistributedNPCPetclerk, DistributedNPCKartClerk, DistributedNPCGlove, DistributedNPCLaffRestock from toontown.tutorial import DistributedBattleTutorial, TutorialManager from toontown.pets import DistributedPetProxy from toontown.coderedemption.TTCodeRedemptionMgr import TTCodeRedemptionMgr diff --git a/toontown/toon/DistributedNPCLaffRestock.py b/toontown/toon/DistributedNPCLaffRestock.py new file mode 100644 index 00000000..9adb7474 --- /dev/null +++ b/toontown/toon/DistributedNPCLaffRestock.py @@ -0,0 +1,63 @@ +from toontown.chat.ChatGlobals import CFSpeech, CFTimeout +from toontown.toonbase import TTLocalizer, ToontownGlobals +from toontown.toontowngui import TTDialog +from DistributedNPCToonBase import DistributedNPCToonBase +import LaffRestockGlobals + +class DistributedNPCLaffRestock(DistributedNPCToonBase): + + def __init__(self, cr): + DistributedNPCToonBase.__init__(self, cr) + + def disable(self): + self.ignoreAll() + self.destroyDialog() + DistributedNPCToonBase.disable(self) + + def destroyDialog(self): + if hasattr(self, 'dialog'): + self.dialog.cleanup() + del self.dialog + + def getCollSphereRadius(self): + return 1.0 + + def handleCollisionSphereEnter(self, collEntry): + laff = base.localAvatar.getMaxHp() - base.localAvatar.getHp() + + if laff <= 0: + self.setChatAbsolute(TTLocalizer.RestockFullLaffMessage, CFSpeech|CFTimeout) + return + + cost = laff * ToontownGlobals.CostPerLaffRestock + + if cost > base.localAvatar.getTotalMoney(): + self.setChatAbsolute(TTLocalizer.RestockNoMoneyMessage % cost, CFSpeech|CFTimeout) + return + + base.cr.playGame.getPlace().setState('stopped') + base.setCellsActive(base.bottomCells, 0) + + self.dialog = TTDialog.TTDialog(style=TTDialog.YesNo, text=TTLocalizer.RestockAskMessage % (laff, cost), command=self.confirmRestock) + self.dialog.show() + + def confirmRestock(self, value): + base.cr.playGame.getPlace().setState('walk') + base.setCellsActive(base.bottomCells, 1) + + if value > 0: + self.sendUpdate('restock') + else: + self.setChatAbsolute(TTLocalizer.RestockLaffCancelMessage, CFSpeech|CFTimeout) + + self.destroyDialog() + + def restockResult(self, state, cost): + if state == LaffRestockGlobals.NO_LAFF: + message = TTLocalizer.RestockFullLaffMessage + elif state == LaffRestockGlobals.NO_MONEY: + message = TTLocalizer.RestockNoMoneyMessage % cost + else: + message = TTLocalizer.RestockLaffMessage + + self.setChatAbsolute(message, CFSpeech|CFTimeout) \ No newline at end of file diff --git a/toontown/toon/DistributedNPCLaffRestockAI.py b/toontown/toon/DistributedNPCLaffRestockAI.py new file mode 100644 index 00000000..478cfdab --- /dev/null +++ b/toontown/toon/DistributedNPCLaffRestockAI.py @@ -0,0 +1,27 @@ +from toontown.toonbase import ToontownGlobals +import LaffRestockGlobals, DistributedNPCToonBaseAI + +class DistributedNPCLaffRestockAI(DistributedNPCToonBaseAI.DistributedNPCToonBaseAI): + + def restock(self): + avId = self.air.getAvatarIdFromSender() + av = self.air.doId2do.get(avId) + + if not av: + return + + laff = av.getMaxHp() - av.getHp() + + if laff <= 0: + self.sendUpdateToAvatarId(avId, 'restockResult', [LaffRestockGlobals.NO_LAFF, 0]) + return + + cost = laff * ToontownGlobals.CostPerLaffRestock + + if cost > av.getTotalMoney(): + self.sendUpdateToAvatarId(avId, 'restockResult', [LaffRestockGlobals.NO_MONEY, cost]) + return + + av.takeMoney(cost) + av.b_setHp(av.getMaxHp()) + self.sendUpdateToAvatarId(avId, 'restockResult', [LaffRestockGlobals.SUCCESS, 0]) \ No newline at end of file diff --git a/toontown/toon/LaffRestockGlobals.py b/toontown/toon/LaffRestockGlobals.py new file mode 100644 index 00000000..b0f28b8b --- /dev/null +++ b/toontown/toon/LaffRestockGlobals.py @@ -0,0 +1,3 @@ +NO_LAFF = 0 +NO_MONEY = 1 +SUCCESS = 2 \ No newline at end of file diff --git a/toontown/toon/NPCToons.py b/toontown/toon/NPCToons.py index 45fffbd0..34401231 100644 --- a/toontown/toon/NPCToons.py +++ b/toontown/toon/NPCToons.py @@ -66,8 +66,9 @@ NPC_PARTYPERSON = 8 NPC_SPECIALQUESTGIVER = 9 NPC_FLIPPYTOONHALL = 10 NPC_SCIENTIST = 11 -NPC_SMART = 13 -NPC_GLOVE = 14 +NPC_SMART = 12 +NPC_GLOVE = 13 +NPC_LAFF_RESTOCK = 14 CLERK_COUNTDOWN_TIME = 120 TAILOR_COUNTDOWN_TIME = 300 @@ -90,6 +91,7 @@ def createNPC(air, npcId, desc, zoneId, posIndex = 0, questCallback = None): import DistributedNPCScientistAI import DistributedSmartNPCAI import DistributedNPCGloveAI + import DistributedNPCLaffRestockAI canonicalZoneId, name, dnaType, gender, protected, type = desc if type == NPC_REGULAR: npc = DistributedNPCToonAI.DistributedNPCToonAI(air, npcId, questCallback=questCallback) @@ -119,6 +121,8 @@ def createNPC(air, npcId, desc, zoneId, posIndex = 0, questCallback = None): npc = DistributedSmartNPCAI.DistributedSmartNPCAI(air, npcId) elif type == NPC_GLOVE and simbase.air.wantGloveNpc: npc = DistributedNPCGloveAI.DistributedNPCGloveAI(air, npcId) + elif type == NPC_LAFF_RESTOCK: + npc = DistributedNPCLaffRestockAI.DistributedNPCLaffRestockAI(air, npcId) else: print 'createNPC() error!!!' npc.setName(name) diff --git a/toontown/toonbase/TTLocalizerEnglish.py b/toontown/toonbase/TTLocalizerEnglish.py index 45fd1fa7..35b57ded 100644 --- a/toontown/toonbase/TTLocalizerEnglish.py +++ b/toontown/toonbase/TTLocalizerEnglish.py @@ -8438,4 +8438,9 @@ DonaldChatter = ["I'm glad you're here today!", 'I like what you are wearing.', 'I love to play tag. Do you?'] NPCFriendUnavailable = 'Unavailable' -FireTalkMessage = "You're fired!" \ No newline at end of file +FireTalkMessage = "You're fired!" +RestockFullLaffMessage = "Sorry, but you're already happy!" +RestockNoMoneyMessage = "Sorry, but you need %s jellybeans to restock your laff!" +RestockAskMessage = "Would you like to restock %s laff for %s jellybeans?" +RestockLaffMessage = "Enjoy your happiness!" +RestockLaffCancelMessage = "Alright. Come back here if you change your mind." \ No newline at end of file diff --git a/toontown/toonbase/ToontownGlobals.py b/toontown/toonbase/ToontownGlobals.py index e5be7258..aa477a9b 100644 --- a/toontown/toonbase/ToontownGlobals.py +++ b/toontown/toonbase/ToontownGlobals.py @@ -1637,4 +1637,5 @@ PropIdToColor = [ ] BugReportSite = 'https://bugs.launchpad.net/toontown-united/+filebug' -TreasureChestSphereRadius = 1.0 \ No newline at end of file +TreasureChestSphereRadius = 1.0 +CostPerLaffRestock = 3 \ No newline at end of file