mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2025-01-09 17:53:50 +00:00
Don't tell me I forgot to push the actual crates
This commit is contained in:
parent
75ffd52621
commit
0308b56ac4
3 changed files with 211 additions and 1 deletions
7
dependencies/config/release/dev.prc
vendored
7
dependencies/config/release/dev.prc
vendored
|
@ -40,4 +40,9 @@ want-instant-parties #t
|
|||
want-instant-delivery #t
|
||||
cogdo-pop-factor 1.5
|
||||
cogdo-ratio 0.5
|
||||
default-directnotify-level info
|
||||
default-directnotify-level info
|
||||
|
||||
# Crates:
|
||||
dont-destroy-crates #t
|
||||
get-key-reward-always #t
|
||||
get-crate-reward-always #t
|
88
toontown/estate/DistributedRewardCrate.py
Normal file
88
toontown/estate/DistributedRewardCrate.py
Normal file
|
@ -0,0 +1,88 @@
|
|||
from direct.interval.IntervalGlobal import *
|
||||
from toontown.effects import DustCloud
|
||||
from toontown.toonbase import ToontownGlobals, TTLocalizer
|
||||
from toontown.toontowngui import TTDialog
|
||||
from toontown.quest import Quests
|
||||
from DistributedFurnitureItem import DistributedFurnitureItem
|
||||
|
||||
class DistributedRewardCrate(DistributedFurnitureItem):
|
||||
|
||||
def __init__(self, cr):
|
||||
DistributedFurnitureItem.__init__(self, cr)
|
||||
self.dialog = None
|
||||
|
||||
def loadModel(self):
|
||||
model = DistributedFurnitureItem.loadModel(self)
|
||||
cSphere = CollisionSphere(0.0, 0.0, 1.0, 2.25)
|
||||
cSphere.setTangible(0)
|
||||
colNode = CollisionNode('Crate-%s' % self.doId)
|
||||
colNode.addSolid(cSphere)
|
||||
cSpherePath = model.attachNewNode(colNode)
|
||||
cSpherePath.setCollideMask(ToontownGlobals.WallBitmask)
|
||||
self.accept('enterCrate-%s' % self.doId, self.__enterSphere)
|
||||
return model
|
||||
|
||||
def disable(self):
|
||||
self.ignoreAll()
|
||||
DistributedFurnitureItem.disable(self)
|
||||
|
||||
def destroyDialog(self):
|
||||
if self.dialog:
|
||||
self.dialog.destroy()
|
||||
self.dialog = None
|
||||
|
||||
def showDialog(self, text):
|
||||
base.cr.playGame.getPlace().setState('stopped')
|
||||
self.dialog = TTDialog.TTDialog(style=TTDialog.Acknowledge, text=text, text_wordwrap=15, fadeScreen=1, command=self.__destroyDialog)
|
||||
|
||||
def __destroyDialog(self, arg):
|
||||
self.destroyDialog()
|
||||
base.cr.playGame.getPlace().setState('walk')
|
||||
|
||||
def __enterSphere(self, collisionEntry):
|
||||
if base.localAvatar.doId != self.furnitureMgr.ownerId:
|
||||
self.useKeyResponse(ToontownGlobals.CRATE_NOT_OWNER, 0)
|
||||
return
|
||||
elif not base.localAvatar.getCrateKeys():
|
||||
self.useKeyResponse(ToontownGlobals.CRATE_NO_KEYS, 0)
|
||||
return
|
||||
|
||||
base.cr.playGame.getPlace().setState('stopped')
|
||||
self.dialog = TTDialog.TTDialog(style=TTDialog.TwoChoice, text=TTLocalizer.CrateAskToUse, fadeScreen=1, command=self.__handleDialogResponse)
|
||||
|
||||
def __handleDialogResponse(self, response):
|
||||
self.destroyDialog()
|
||||
|
||||
if response < 0:
|
||||
base.cr.playGame.getPlace().setState('walk')
|
||||
return
|
||||
|
||||
self.sendUpdate('requestKeyUsage')
|
||||
|
||||
def useKeyResponse(self, responseCode, amount):
|
||||
if responseCode == ToontownGlobals.CRATE_NOT_OWNER:
|
||||
self.showDialog(TTLocalizer.CrateNotOwner)
|
||||
return
|
||||
elif responseCode == ToontownGlobals.CRATE_NO_KEYS:
|
||||
self.showDialog(TTLocalizer.CrateNoKeys)
|
||||
return
|
||||
elif responseCode == ToontownGlobals.CRATE_BEANS:
|
||||
self.showDialog(TTLocalizer.CrateBeanPrize % amount)
|
||||
elif responseCode == ToontownGlobals.CRATE_BUFFS:
|
||||
buff = Quests.RewardDict[amount]
|
||||
|
||||
self.showDialog(TTLocalizer.CrateBuffPrize % buff[0](amount, buff[1:]).getString())
|
||||
elif responseCode == ToontownGlobals.CRATE_NAMETAGS:
|
||||
self.showDialog(TTLocalizer.CrateNametagPrize)
|
||||
elif responseCode == ToontownGlobals.CRATE_EMOTES:
|
||||
self.showDialog(TTLocalizer.CrateEmotePrize)
|
||||
elif responseCode == ToontownGlobals.CRATE_CLOTHING:
|
||||
self.showDialog(TTLocalizer.CrateClothingPrize)
|
||||
elif responseCode == ToontownGlobals.CRATE_ACCESSORIES:
|
||||
self.showDialog(TTLocalizer.CrateAccessoryPrize)
|
||||
|
||||
dustCloud = DustCloud.DustCloud(fBillboard=0, wantSound=1)
|
||||
dustCloud.setBillboardAxis(2.0)
|
||||
dustCloud.setScale(0.6)
|
||||
dustCloud.createTrack()
|
||||
Sequence(Func(dustCloud.reparentTo, render), Func(dustCloud.setPos, self.getPos()), dustCloud.track, Func(dustCloud.detachNode), Func(dustCloud.destroy)).start()
|
117
toontown/estate/DistributedRewardCrateAI.py
Normal file
117
toontown/estate/DistributedRewardCrateAI.py
Normal file
|
@ -0,0 +1,117 @@
|
|||
from toontown.catalog import CatalogAccessoryItem, CatalogClothingItem, CatalogNametagItem, CatalogEmoteItem
|
||||
from toontown.catalog.CatalogAccessoryItemGlobals import *
|
||||
from toontown.toonbase import ToontownGlobals, TTLocalizer
|
||||
from toontown.toon import ToonDNA
|
||||
from toontown.quest import Quests
|
||||
from DistributedFurnitureItemAI import DistributedFurnitureItemAI
|
||||
import random, time
|
||||
|
||||
RANDOM_PRIZES = [ToontownGlobals.CRATE_BEANS] * 10 + [ToontownGlobals.CRATE_BUFFS] * 5 + [ToontownGlobals.CRATE_NAMETAGS] * 10 + [ToontownGlobals.CRATE_EMOTES] * 10 + [ToontownGlobals.CRATE_CLOTHING] * 30 + [ToontownGlobals.CRATE_ACCESSORIES] * 35
|
||||
|
||||
class DistributedRewardCrateAI(DistributedFurnitureItemAI):
|
||||
|
||||
def __init__(self, air, furnitureMgr, item):
|
||||
DistributedFurnitureItemAI.__init__(self, air, furnitureMgr, item)
|
||||
|
||||
def requestKeyUsage(self):
|
||||
avId = self.air.getAvatarIdFromSender()
|
||||
av = self.air.doId2do.get(avId)
|
||||
|
||||
if not av:
|
||||
return
|
||||
|
||||
if avId != self.furnitureMgr.ownerId:
|
||||
self.sendUpdateToAvatarId(avId, 'useKeyResponse', [ToontownGlobals.CRATE_NOT_OWNER, 0])
|
||||
return
|
||||
elif not av.getCrateKeys():
|
||||
self.sendUpdateToAvatarId(avId, 'useKeyResponse', [ToontownGlobals.CRATE_NO_KEYS, 0])
|
||||
return
|
||||
|
||||
av.removeCrateKeys(1)
|
||||
self.choosePrize(av)
|
||||
|
||||
if not config.GetBool('dont-destroy-crate', False):
|
||||
self.furnitureMgr.deleteItemFromRoom(self.doId, False)
|
||||
|
||||
def choosePrize(self, av, tryNumber = 0):
|
||||
if tryNumber == 10:
|
||||
self.giveBeans(av)
|
||||
return
|
||||
|
||||
prizeType = random.choice(RANDOM_PRIZES)
|
||||
|
||||
if prizeType == ToontownGlobals.CRATE_BEANS:
|
||||
self.giveBeans(av)
|
||||
elif prizeType == ToontownGlobals.CRATE_BUFFS:
|
||||
buffId = random.choice(Quests.BuffRewardIds)
|
||||
buff = Quests.RewardDict[buffId]
|
||||
|
||||
buff[0](buffId, buff[1:]).sendRewardAI(av)
|
||||
self.sendUpdateToAvatarId(av.doId, 'useKeyResponse', [ToontownGlobals.CRATE_BUFFS, buffId])
|
||||
elif prizeType == ToontownGlobals.CRATE_NAMETAGS:
|
||||
allNametags = xrange(len(TTLocalizer.NametagFonts))
|
||||
playerNametags = av.nametagStyles
|
||||
remainingNametags = [nametag for nametag in allNametags if nametag not in playerNametags]
|
||||
|
||||
if not remainingNametags:
|
||||
self.choosePrize(av, tryNumber + 1)
|
||||
return
|
||||
|
||||
nametag = random.choice(remainingNametags)
|
||||
item = CatalogNametagItem.CatalogNametagItem(nametag, 0)
|
||||
|
||||
if item.reachedPurchaseLimit(av):
|
||||
return
|
||||
|
||||
self.addToOrder(av, item)
|
||||
self.sendUpdateToAvatarId(av.doId, 'useKeyResponse', [ToontownGlobals.CRATE_NAMETAGS, 0])
|
||||
elif prizeType == ToontownGlobals.CRATE_EMOTES:
|
||||
playerEmotes = av.emoteAccess
|
||||
remainingEmotes = [i for i, access in enumerate(playerEmotes) if not access]
|
||||
|
||||
if not remainingEmotes:
|
||||
self.choosePrize(av, tryNumber + 1)
|
||||
return
|
||||
|
||||
emote = random.choice(remainingEmotes)
|
||||
item = CatalogEmoteItem.CatalogEmoteItem(emote, 0)
|
||||
|
||||
if item.reachedPurchaseLimit(av):
|
||||
self.choosePrize(av, tryNumber + 1)
|
||||
return
|
||||
|
||||
self.addToOrder(av, item)
|
||||
self.sendUpdateToAvatarId(av.doId, 'useKeyResponse', [ToontownGlobals.CRATE_EMOTES, 0])
|
||||
elif prizeType == ToontownGlobals.CRATE_CLOTHING:
|
||||
clothing = CatalogClothingItem.ClothingTypes.keys()
|
||||
random.shuffle(clothing)
|
||||
|
||||
for id in clothing:
|
||||
item = CatalogClothingItem.CatalogClothingItem(id, 0)
|
||||
|
||||
if not item.notOfferedTo(av) and not item.reachedPurchaseLimit(av):
|
||||
self.addToOrder(av, item)
|
||||
self.sendUpdateToAvatarId(av.doId, 'useKeyResponse', [ToontownGlobals.CRATE_CLOTHING, 0])
|
||||
return
|
||||
elif prizeType == ToontownGlobals.CRATE_ACCESSORIES:
|
||||
accessories = AccessoryTypes.keys()
|
||||
random.shuffle(accessories)
|
||||
|
||||
for id in accessories:
|
||||
item = CatalogAccessoryItem.CatalogAccessoryItem(id, 0)
|
||||
|
||||
if not item.reachedPurchaseLimit(av):
|
||||
self.addToOrder(av, item)
|
||||
self.sendUpdateToAvatarId(av.doId, 'useKeyResponse', [ToontownGlobals.CRATE_ACCESSORIES, 0])
|
||||
return
|
||||
|
||||
def addToOrder(self, av, item):
|
||||
item.deliveryDate = int(time.time() / 60. + .5)
|
||||
av.onOrder.append(item)
|
||||
av.b_setDeliverySchedule(av.onOrder)
|
||||
|
||||
def giveBeans(self, av):
|
||||
beans = random.randint(1, 15) * 100
|
||||
|
||||
av.addMoney(beans)
|
||||
self.sendUpdateToAvatarId(av.doId, 'useKeyResponse', [ToontownGlobals.CRATE_BEANS, beans])
|
Loading…
Reference in a new issue