Initial work on crates and keys + ~factorywarp fix

This commit is contained in:
John 2015-07-27 13:44:29 +03:00
parent 3e81a8c468
commit 48ba472271
21 changed files with 153 additions and 36 deletions

View file

@ -720,7 +720,7 @@ dclass DistributedToon : DistributedPlayer {
setUnlimitedSwing(uint8) broadcast ownrecv ram;
logSuspiciousEvent(char [0-1024]) ownsend airecv;
forceLogoutWithNotify() ownrecv;
setPinkSlips(uint8 = 0) required ownrecv db;
setSpecialInventory(uint8[] = [0, 0]) required ownrecv db;
setNametagStyle(uint8 = 0) required broadcast ownrecv db;
setNametagStyles(uint8[] = [0]) required broadcast ownrecv db;
setMail(simpleMail []) ownrecv;
@ -825,6 +825,7 @@ dclass DistributedBossCog : DistributedNode {
setToonIds(uint32[], uint32[], uint32[]) broadcast ram;
setBattleIds(uint8, uint32, uint32) broadcast ram;
setArenaSide(uint8) broadcast ram;
setKeyReward(bool) required broadcast ram;
avatarEnter() airecv clsend;
avatarExit() airecv clsend;
avatarNearEnter() airecv clsend;
@ -974,6 +975,7 @@ dclass DistributedBattleTutorial : DistributedBattle {
};
dclass DistributedLevelBattle : DistributedBattle {
announceCrateReward() broadcast;
};
dclass DistributedBattleFactory : DistributedLevelBattle {

View file

@ -891,7 +891,13 @@ FurnitureTypes = {
None,
None,
200,
FLPainting)
FLPainting),
10040: ('phase_10/models/cashbotHQ/CBWoodCrate',
None,
None,
0,
None,
0.5)
}
class CatalogFurnitureItem(CatalogAtticItem.CatalogAtticItem):

View file

@ -22,6 +22,7 @@ class DistributedBattleFactoryAI(DistributedLevelBattleAI.DistributedLevelBattle
return self.level.factoryId
def handleToonsWon(self, toons):
self.handleCrateReward(toons)
for toon in toons:
recovered, notRecovered = self.air.questManager.recoverItems(toon, self.suitsKilled, self.getTaskZoneId())
self.toonItems[toon.doId][0].extend(recovered)

View file

@ -29,6 +29,7 @@ class DistributedCountryClubBattleAI(DistributedLevelBattleAI.DistributedLevelBa
amount = ToontownGlobals.CountryClubCogBuckRewards[self.level.countryClubId]
index = ToontownGlobals.cogHQZoneId2deptIndex(self.level.countryClubId)
extraMerits[index] = amount
self.handleCrateReward(toons)
for toon in toons:
recovered, notRecovered = self.air.questManager.recoverItems(toon, self.suitsKilled, self.getTaskZoneId())
self.toonItems[toon.doId][0].extend(recovered)

View file

@ -28,7 +28,6 @@ class DistributedFactory(DistributedLevel.DistributedLevel, FactoryBase.FactoryB
self.joiningReserves = []
self.suitsInitialized = 0
self.goonClipPlanes = {}
base.localAvatar.physControls.setCollisionRayHeight(10.0)
def createEntityCreator(self):
return FactoryEntityCreator.FactoryEntityCreator(level=self)
@ -39,14 +38,15 @@ class DistributedFactory(DistributedLevel.DistributedLevel, FactoryBase.FactoryB
self.factoryViews = FactoryCameraViews.FactoryCameraViews(self)
base.localAvatar.chatMgr.chatInputSpeedChat.addFactoryMenu()
self.accept('SOSPanelEnter', self.handleSOSPanel)
base.factory = self
def delete(self):
DistributedLevel.DistributedLevel.delete(self)
base.localAvatar.chatMgr.chatInputSpeedChat.removeFactoryMenu()
self.factoryViews.delete()
del self.factoryViews
del base.factory
self.ignore('SOSPanelEnter')
base.localAvatar.physControls.setCollisionRayHeight(CollisionHandlerRayStart)
def setFactoryId(self, id):
FactoryBase.FactoryBase.setFactoryId(self, id)
@ -166,10 +166,7 @@ def factoryWarp(zoneNum):
"""
Warp to a specific factory zone.
"""
factory = [base.cr.doFind('DistributedFactory'), base.cr.doFind('DistributedMegaCorp')]
for f in factory:
if (not f) or (not isinstance(f, DistributedFactory)):
return 'You must be in a factory.'
factory = f
factory.warpToZone(zoneNum)
if not hasattr(base, 'factory'):
return 'You must be in a factory!'
base.factory.warpToZone(zoneNum)
return 'Warped to zone: %d' % zoneNum

View file

@ -89,6 +89,15 @@ class DistributedLevelBattle(DistributedBattle.DistributedBattle):
def onWaitingForJoin(self):
self.lockLevelViz()
def announceCrateReward(self):
track = Sequence()
for i, message in enumerate(TTLocalizer.CrateRewardMessages):
track.append(Func(base.localAvatar.setSystemMessage, 0, message))
track.append(Wait(1.5))
track.start()
def __faceOff(self, ts, name, callback):
if len(self.suits) == 0:

View file

@ -1,11 +1,13 @@
from toontown.battle import DistributedBattleAI
from toontown.battle import DistributedBattleBaseAI
from toontown.catalog import CatalogFurnitureItem
from direct.directnotify import DirectNotifyGlobal
from direct.fsm import State
from direct.fsm import ClassicFSM
from toontown.battle.BattleBase import *
import CogDisguiseGlobals
from direct.showbase.PythonUtil import addListsByValue
import time
class DistributedLevelBattleAI(DistributedBattleAI.DistributedBattleAI):
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedLevelBattleAI')
@ -96,6 +98,18 @@ class DistributedLevelBattleAI(DistributedBattleAI.DistributedBattleAI):
def handleToonsWon(self, toons):
pass
def handleCrateReward(self, toons):
if not (config.GetBool('get-crate-reward-always', False) or random.random() <= 0.25):
return
self.sendUpdate('announceCrateReward')
item = CatalogFurnitureItem.CatalogFurnitureItem(10040)
item.deliveryDate = int(time.time() / 60. + .5)
for toon in toons:
toon.onOrder.append(item)
toon.b_setDeliverySchedule(toon.onOrder)
def enterFaceOff(self):
self.notify.debug('DistributedLevelBattleAI.enterFaceOff()')

View file

@ -28,6 +28,7 @@ class DistributedMintBattleAI(DistributedLevelBattleAI.DistributedLevelBattleAI)
amount = ToontownGlobals.MintCogBuckRewards[self.level.mintId]
index = ToontownGlobals.cogHQZoneId2deptIndex(self.level.mintId)
extraMerits[index] = amount
self.handleCrateReward(toons)
for toon in toons:
recovered, notRecovered = self.air.questManager.recoverItems(toon, self.suitsKilled, self.getTaskZoneId())
self.toonItems[toon.doId][0].extend(recovered)

View file

@ -36,6 +36,7 @@ class DistributedStageBattleAI(DistributedLevelBattleAI.DistributedLevelBattleAI
amount = ToontownGlobals.StageNoticeRewards[self.level.stageId]
index = ToontownGlobals.cogHQZoneId2deptIndex(self.level.stageId)
extraMerits[index] = amount
self.handleCrateReward(toons)
for toon in toons:
recovered, notRecovered = self.air.questManager.recoverItems(toon, self.suitsKilled, self.getTaskZoneId())
self.toonItems[toon.doId][0].extend(recovered)

View file

@ -44,6 +44,7 @@ class DistributedBossCog(DistributedAvatar.DistributedAvatar, BossCog.BossCog):
self.battleB = None
self.battleRequest = None
self.arenaSide = 0
self.keyReward = False
self.toonSphere = None
self.localToonIsSafe = 0
self.__toonsStuckToFloor = []
@ -303,6 +304,9 @@ class DistributedBossCog(DistributedAvatar.DistributedAvatar, BossCog.BossCog):
def setArenaSide(self, arenaSide):
self.arenaSide = arenaSide
def setKeyReward(self, reward):
self.keyReward = reward
def setState(self, state):
self.request(state)

View file

@ -44,8 +44,8 @@ class DistributedBossCogAI(DistributedAvatarAI.DistributedAvatarAI):
self.attackCode = None
self.attackAvId = 0
self.hitCount = 0
self.keyReward = config.GetBool('get-key-reward-always', False) or random.random() <= 0.15
AllBossCogs.append(self)
return
def delete(self):
self.ignoreAll()
@ -182,6 +182,9 @@ class DistributedBossCogAI(DistributedAvatarAI.DistributedAvatarAI):
def getState(self):
return self.state
def getKeyReward(self):
return self.keyReward
def formatReward(self):
return 'unspecified'
@ -259,7 +262,7 @@ class DistributedBossCogAI(DistributedAvatarAI.DistributedAvatarAI):
pass
def enterEpilogue(self):
pass
self.giveKeyReward()
def exitEpilogue(self):
pass
@ -606,3 +609,13 @@ class DistributedBossCogAI(DistributedAvatarAI.DistributedAvatarAI):
def doNextAttack(self, task):
self.b_setAttackCode(ToontownGlobals.BossCogNoAttack)
def giveKeyReward(self):
if not self.keyReward:
return
for toonId in self.involvedToons:
toon = self.air.doId2do.get(toonId)
if toon:
toon.addCrateKeys(1)

View file

@ -861,6 +861,10 @@ class DistributedBossbotBoss(DistributedBossCog.DistributedBossCog, FSM.FSM):
speech += TTLocalizer.BossbotRTHPBoost
else:
speech += TTLocalizer.BossbotRTMaxed % (ToontownGlobals.MaxCogSuitLevel + 1)
if self.keyReward:
speech += TTLocalizer.BossRTKeyReward
return speech
def __arrangeToonsAroundResistanceToonForReward(self):

View file

@ -659,6 +659,10 @@ class DistributedCashbotBoss(DistributedBossCog.DistributedBossCog, FSM.FSM):
speech += TTLocalizer.ResistanceToonHPBoost
else:
speech += TTLocalizer.ResistanceToonMaxed % (ToontownGlobals.MaxCogSuitLevel + 1)
if self.keyReward:
speech += TTLocalizer.BossRTKeyReward
return speech
def enterOff(self):

View file

@ -1643,6 +1643,10 @@ class DistributedLawbotBoss(DistributedBossCog.DistributedBossCog, FSM.FSM):
speech += TTLocalizer.WitnessToonHPBoost
else:
speech += TTLocalizer.WitnessToonMaxed % (ToontownGlobals.MaxCogSuitLevel + 1)
if self.keyReward:
speech += TTLocalizer.BossRTKeyReward
return speech
def __positionToonsInFrontOfCannons(self):

View file

@ -457,6 +457,12 @@ class DistributedSellbotBoss(DistributedBossCog.DistributedBossCog, FSM.FSM):
speech += TTLocalizer.CagedToonHPBoost
else:
speech += TTLocalizer.CagedToonMaxed % (ToontownGlobals.MaxCogSuitLevel + 1)
if self.keyReward:
speech += TTLocalizer.BossRTKeyReward
return speech
return speech
def __makeCageOpenMovie(self):

View file

@ -172,6 +172,7 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
self.ignored = []
self.reported = []
self.trueFriends = []
self.specialInventory = [0, 0, 0, 0, 0]
def disable(self):
for soundSequence in self.soundSequenceList:
@ -1936,13 +1937,16 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
return self.unlimitedSwing
def getPinkSlips(self):
if hasattr(self, 'pinkSlips'):
return self.pinkSlips
else:
return 0
return self.specialInventory[0]
def getCrateKeys(self):
return self.specialInventory[1]
def setPinkSlips(self, pinkSlips):
self.pinkSlips = pinkSlips
def setSpecialInventory(self, specialInventory):
self.specialInventory = specialInventory
def getSpecialInventory(self):
return self.specialInventory
def setDisplayName(self, str):
if not self.isDisguised:

View file

@ -3662,27 +3662,44 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo
self.sendUpdate('setUnlimitedSwing', [unlimitedSwing])
def b_setPinkSlips(self, pinkSlips):
self.d_setPinkSlips(pinkSlips)
self.setPinkSlips(pinkSlips)
self.specialInventory[0] = pinkSlips
self.b_setSpecialInventory(self.specialInventory)
def b_setCrateKeys(self, crateKeys):
self.specialInventory[1] = crateKeys
self.b_setSpecialInventory(self.specialInventory)
def b_setSpecialInventory(self, specialInventory):
self.d_setSpecialInventory(specialInventory)
self.setSpecialInventory(specialInventory)
def d_setPinkSlips(self, pinkSlips):
self.sendUpdate('setPinkSlips', [pinkSlips])
def d_setSpecialInventory(self, specialInventory):
self.sendUpdate('setSpecialInventory', [specialInventory])
def setPinkSlips(self, pinkSlips):
self.pinkSlips = pinkSlips
def setSpecialInventory(self, specialInventory):
self.specialInventory = specialInventory
def getPinkSlips(self):
return self.pinkSlips
return self.specialInventory[0]
def getCrateKeys(self):
return self.specialInventory[1]
def addPinkSlips(self, amountToAdd):
pinkSlips = min(self.pinkSlips + amountToAdd, 255)
pinkSlips = min(self.getPinkSlips() + amountToAdd, 255)
self.b_setPinkSlips(pinkSlips)
def removePinkSlips(self, amount):
if hasattr(self, 'autoRestockPinkSlips') and self.autoRestockPinkSlips:
amount = 0
pinkSlips = max(self.pinkSlips - amount, 0)
pinkSlips = max(self.getPinkSlips() - amount, 0)
self.b_setPinkSlips(pinkSlips)
def addCrateKeys(self, amountToAdd):
self.b_setCrateKeys(min(self.getCrateKeys() + amountToAdd, 255))
def removeeCrateKeys(self, amount):
self.b_setCrateKeys(max(self.getCrateKeys() - amount, 0))
def b_setNametagStyle(self, nametagStyle):
self.d_setNametagStyle(nametagStyle)
@ -4350,6 +4367,17 @@ def fires(count):
invoker.b_setPinkSlips(count)
return 'You were given %d fires.' % count
@magicWord(category=CATEGORY_PROGRAMMER, types=[int])
def crateKeys(count):
"""
Modifies the invoker's crate key count.
"""
invoker = spellbook.getInvoker()
if not 0 <= count <= 255:
return 'Your crate key must be in range (0-255).'
invoker.b_setCrateKeys(count)
return 'You were given %d crate keys.' % count
@magicWord(category=CATEGORY_PROGRAMMER, types=[int])
def maxMoney(maxMoney):
"""

View file

@ -460,7 +460,7 @@ class DistributedToonUD(DistributedObjectUD):
def forceLogoutWithNotify(self):
pass
def setPinkSlips(self, todo0):
def setSpecialInventory(self, todo0):
pass
def setNametagStyle(self, todo0):

View file

@ -116,11 +116,20 @@ class InventoryNew(InventoryBase.InventoryBase, DirectFrame):
DirectFrame.hide(self)
def updateTotalPropsText(self):
textTotal = TTLocalizer.InventoryTotalGags % (self.totalProps, self.toon.getMaxCarry())
textTotal = '%s\n\n' % (TTLocalizer.InventoryTotalGags % (self.totalProps, self.toon.getMaxCarry()))
if localAvatar.getPinkSlips() > 1:
textTotal = textTotal + '\n\n' + TTLocalizer.InventroyPinkSlips % localAvatar.getPinkSlips()
textTotal += TTLocalizer.InventoryPinkSlips % localAvatar.getPinkSlips()
textTotal += '\n'
elif localAvatar.getPinkSlips() == 1:
textTotal = textTotal + '\n\n' + TTLocalizer.InventroyPinkSlip
textTotal += TTLocalizer.InventoryPinkSlip
textTotal += '\n'
if localAvatar.getCrateKeys() > 1:
textTotal += TTLocalizer.InventoryCrateKeys % localAvatar.getCrateKeys()
elif localAvatar.getCrateKeys() == 1:
textTotal += TTLocalizer.InventoryCrateKey
self.totalLabel['text'] = textTotal
def unload(self):

View file

@ -1659,8 +1659,8 @@ class LocalToon(DistributedToon.DistributedToon, LocalAvatar.LocalAvatar):
self.tipPage.load()
self.book.addPage(self.tipPage, pageName=TTLocalizer.TIPPageTitle)
def setPinkSlips(self, pinkSlips):
DistributedToon.DistributedToon.setPinkSlips(self, pinkSlips)
def setSpecialInventory(self, specialInventory):
DistributedToon.DistributedToon.setSpecialInventory(self, specialInventory)
self.inventory.updateTotalPropsText()
def hasActiveBoardingGroup(self):

View file

@ -3982,8 +3982,10 @@ TIPPageTitle = 'TIP'
SuitBaseNameWithLevel = '%(name)s\n%(dept)s\nLevel %(level)s'
HealthForceAcknowledgeMessage = 'You cannot leave the playground until your Laff meter is smiling!'
InventoryTotalGags = 'Total gags\n%d / %d'
InventroyPinkSlips = '%s Pink Slips'
InventroyPinkSlip = '1 Pink Slip'
InventoryPinkSlips = '%s Pink Slips'
InventoryPinkSlip = '1 Pink Slip'
InventoryCrateKeys = '%s Crate Keys'
InventoryCrateKey = '1 Crate Key'
InventoryDelete = 'DELETE'
InventoryDeleteAll = 'DELETE ALL'
InventoryDone = 'DONE'
@ -5188,7 +5190,8 @@ FurnitureNames = {100: 'Armchair',
10000: 'Short Pumpkin',
10010: 'Tall Pumpkin',
10020: 'Winter Tree',
10030: 'Winter Wreath'}
10030: 'Winter Wreath',
10040: 'Cog Nation Crate'}
ClothingArticleNames = ('Shirt',
'Shirt',
'Shirt',
@ -8118,6 +8121,7 @@ BossbotRTCongratulations = "You did it! You've demoted the C.E.O.!\x07Here, tak
BossbotRTHPBoost = "\x07You've done a lot of work for the Resistance.\x07The Toon Council has decided to give you another Laff point. Congratulations!"
BossbotRTMaxed = '\x07I see that you have a level %s Cog Suit. Very impressive!\x07On behalf of the Toon Council, thank you for coming back to defend more Toons!'
BossbotRTLastPromotion = "\x07Wow, you've reached level %s on your Cog Suit!\x07Cogs don't get promoted higher than that.\x07You can't upgrade your Cog Suit anymore, but you can certainly keep working for the Resistance!"
BossRTKeyReward = '\x07By the way, thanks to your exquisite performance, the Toon Council has decided to offer to you a Cog Nation Crate key!\x07Using this, you will be able to open the crates you have earned in the cog factories.'
GolfAreaAttackTaunt = 'Fore!'
OvertimeAttackTaunts = ["It's time to reorganize.", "Now let's downsize."]
ElevatorBossBotBoss = 'Bossbot Clubhouse'
@ -8608,6 +8612,11 @@ CEOSpeech = [
'I am very delighted by this news, I just wanted to thank you all for working so hard for this news.',
"Wait, what's going on? I can't see but I hear explosions."
] # Len of words + 10
CrateRewardMessage1 = 'Nice! You have earned a crate! It will arrive in your mailbox shortly.'
CrateRewardMessage2 = 'You can open it with keys from boss battles.'
CrateRewardMessages = [CrateRewardMessage1, CrateRewardMessage2]
Blacklist = [
"$1ut",
"$h1t",