Chairs.. my blood went into this..

This commit is contained in:
John 2015-07-31 01:15:21 +03:00
parent 0c06b40b39
commit 49b2422187
12 changed files with 300 additions and 39 deletions

View file

@ -291,6 +291,7 @@ from toontown.estate import DistributedCloset/AI
from toontown.estate import DistributedTrunk/AI
from toontown.estate import DistributedPhone/AI
from toontown.estate import DistributedRewardCrate/AI
from toontown.estate import DistributedChair/AI
from toontown.effects import DistributedFireworkShow/AI
from toontown.estate import DistributedFireworksCannon/AI
from toontown.coghq import LobbyManager/AI
@ -2097,6 +2098,12 @@ dclass DistributedRewardCrate : DistributedFurnitureItem {
useKeyResponse(uint8, uint32);
};
dclass DistributedChair : DistributedFurnitureItem {
setAvId(uint32) broadcast ram;
requestSit(uint8) airecv clsend;
setStatus(uint8) broadcast ram;
};
dclass DistributedFireworkShow : DistributedObject {
startShow(uint8, uint8, uint8, int16) broadcast ram;
requestFirework(int16/10, int16/10, int16/100, uint8, uint8, uint8) airecv clsend;

View file

@ -62,6 +62,7 @@ class LocalAvatar(DistributedAvatar.DistributedAvatar, DistributedSmoothNode.Dis
self.sleepFlag = 0
self.isDisguised = 0
self.movingFlag = 0
self.preventCameraDisable = False
self.lastNeedH = None
self.accept('friendOnline', self.__friendOnline)
self.accept('friendOffline', self.__friendOffline)
@ -73,6 +74,9 @@ class LocalAvatar(DistributedAvatar.DistributedAvatar, DistributedSmoothNode.Dis
self.accept('avatarMoving', self.clearPageUpDown)
self.showNametag2d()
self.setPickable(0)
def setPreventCameraDisable(self, prevent):
self.preventCameraDisable = prevent
def useSwimControls(self):
self.controlManager.use('swim', self)
@ -421,7 +425,7 @@ class LocalAvatar(DistributedAvatar.DistributedAvatar, DistributedSmoothNode.Dis
self.controlManager.setSpeeds(OTPGlobals.ToonForwardSlowSpeed, OTPGlobals.ToonJumpSlowForce, OTPGlobals.ToonReverseSlowSpeed, OTPGlobals.ToonRotateSlowSpeed)
def pageUp(self):
if not self.avatarControlsEnabled:
if not (self.avatarControlsEnabled or self.preventCameraDisable):
return
self.wakeUp()
if not self.isPageUp:
@ -433,7 +437,7 @@ class LocalAvatar(DistributedAvatar.DistributedAvatar, DistributedSmoothNode.Dis
self.clearPageUpDown()
def pageDown(self):
if not self.avatarControlsEnabled:
if not (self.avatarControlsEnabled and self.preventCameraDisable):
return
self.wakeUp()
if not self.isPageDown:
@ -452,7 +456,7 @@ class LocalAvatar(DistributedAvatar.DistributedAvatar, DistributedSmoothNode.Dis
self.setCameraPositionByIndex(self.cameraIndex)
def nextCameraPos(self, forward):
if not self.avatarControlsEnabled:
if not (self.avatarControlsEnabled or self.preventCameraDisable):
return
self.wakeUp()
self.__cameraHasBeenMoved = 1
@ -465,6 +469,10 @@ class LocalAvatar(DistributedAvatar.DistributedAvatar, DistributedSmoothNode.Dis
if self.cameraIndex < 0:
self.cameraIndex = len(self.cameraPositions) - 1
self.setCameraPositionByIndex(self.cameraIndex)
def setCameraPosition(self, index):
self.cameraIndex = index
self.setCameraPositionByIndex(index)
def initCameraPositions(self):
camHeight = self.getClampedAvatarHeight()

View file

@ -17,12 +17,13 @@ FLRug = 4
FLPainting = 8
FLOnTable = 16
FLIsTable = 32
FLPhone = 64
FLCrate = 128
FLBillboard = 256
FLTrunk = 512
FLBoysOnly = 1024
FLGirlsOnly = 2048
FLBillboard = 64
FLPhone = 128
FLCrate = 256
FLChair = 512
FLTrunk = 1024
FLBoysOnly = 2048
FLGirlsOnly = 4096
furnitureColors = [
(0.792, 0.353, 0.29, 1.0),
(0.176, 0.592, 0.439, 1.0),
@ -74,16 +75,36 @@ MaxClosetIds = (508, 518)
TvToPosScale = {
1530: ((-1.15, -0.5, 1.1), (2.5, 1.7, 1.4)),
1531: ((-2.3, -0.2, 1.6), (5, 5, 5)),
1532: ((-7, -0.2, 1.8), (15, 10, 8.5))
1531: ((-2.3, -0.2, 2.522), (5, 3.75, 3.187)),
1532: ((-7, -0.2, 2.8), (15, 10, 7.8))
}
ChairToPosHpr = {
100: ((0, -3.9, 0.88), (180, 0, 0), (0, -4.9, 0), -3.0),
105: ((0, -3.9, 0.88), (180, 0, 0), (0, -4.9, 0), -3.0),
110: ((0, -1.6, 0.5), (180, 0, 0), (0, -2.6, 0), 0.0),
120: ((0, -1.6, 0.5), (180, 0, 0), (0, -2.6, 0), 0.0),
130: ((0, -2.8, 0.5), (180, 0, 0), (0, -3.8, 0), -2.0),
140: ((0, -1.6, 0.5), (180, 0, 0), (0, -2.6, 0), 0.0),
145: ((0, -2.1, 0.2), (180, 0, 0), (0, -3.1, 0), 0.0),
160: ((-1.7, 0, 0.9), (90, 0, 0), (-2.7, 0, 0), 0.0),
170: ((0, 1.8, 0.4), (0, 0, 0), (0, 2.8, 0), 0.0),
700: ((0, -1.2, 0.5), (180, 0, 0), (0, -2.2, 0), 0.0),
705: ((0, -1.2, 0.5), (180, 0, 0), (0, -2.2, 0), 0.0),
710: ((0, -1.1, 0.4), (180, 0, 0), (0, -2.1, 0), 0.0),
715: ((0, -1.1, 0.4), (180, 0, 0), (0, -2.1, 0), 0.0),
720: ((0, -2.7, 0.2), (180, 0, 0), (0, -3.7, 0), -3.0)
}
def getChairCollOffset(furnitureId):
return ChairToPosHpr[furnitureId][3]
FurnitureTypes = {
100: ('phase_5.5/models/estate/chairA', # Model
None, # Color
None, # Color Options
80), # Base Price
# Flags
80, # Base Price
FLChair), # Flags
# Scale
105: ('phase_5.5/models/estate/chairAdesat',
None,
@ -93,27 +114,33 @@ FurnitureTypes = {
3: (('**/cushion*', furnitureColors[3]), ('**/arm*', furnitureColors[3])),
4: (('**/cushion*', furnitureColors[4]), ('**/arm*', furnitureColors[4])),
5: (('**/cushion*', furnitureColors[5]), ('**/arm*', furnitureColors[5]))},
160),
160,
FLChair),
110: ('phase_3.5/models/modules/chair',
None,
None,
40),
40,
FLChair),
120: ('phase_5.5/models/estate/deskChair',
None,
None,
60),
60,
FLChair),
130: ('phase_5.5/models/estate/BugRoomChair',
None,
None,
160),
160,
FLChair),
140: ('phase_5.5/models/estate/UWlobsterChair',
None,
None,
200),
200,
FLChair),
145: ('phase_5.5/models/estate/UWlifeSaverChair',
None,
None,
200),
200,
FLChair),
150: ('phase_5.5/models/estate/West_saddleStool2',
None,
None,
@ -121,11 +148,13 @@ FurnitureTypes = {
160: ('phase_5.5/models/estate/West_nativeChair',
None,
None,
160),
160,
FLChair),
170: ('phase_5.5/models/estate/cupcakeChair',
None,
None,
240),
240,
FLChair),
200: ('phase_5.5/models/estate/regular_bed',
None,
None,
@ -415,7 +444,8 @@ FurnitureTypes = {
700: ('phase_3.5/models/modules/couch_1person',
None,
None,
230),
230,
FLChair),
705: ('phase_5.5/models/estate/couch_1personDesat',
None,
{0: (('**/*couch', furnitureColors[0]),),
@ -424,11 +454,13 @@ FurnitureTypes = {
3: (('**/*couch', furnitureColors[3]),),
4: (('**/*couch', furnitureColors[4]),),
5: (('**/*couch', furnitureColors[5]),)},
460),
460,
FLChair),
710: ('phase_3.5/models/modules/couch_2person',
None,
None,
230),
230,
FLChair),
715: ('phase_5.5/models/estate/couch_2personDesat',
None,
{0: (('**/*couch', furnitureColors[0]),),
@ -437,11 +469,13 @@ FurnitureTypes = {
3: (('**/*couch', furnitureColors[3]),),
4: (('**/*couch', furnitureColors[4]),),
5: (('**/*couch', furnitureColors[5]),)},
460),
460,
FLChair),
720: ('phase_5.5/models/estate/West_HayCouch',
None,
None,
420),
420,
FLChair),
730: ('phase_5.5/models/estate/twinkieCouch',
None,
None,

View file

@ -7,7 +7,6 @@ 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')
@ -105,11 +104,9 @@ class DistributedLevelBattleAI(DistributedBattleAI.DistributedBattleAI):
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)
toon.addToDeliverySchedule(item)
def enterFaceOff(self):
self.notify.debug('DistributedLevelBattleAI.enterFaceOff()')

View file

@ -0,0 +1,145 @@
from direct.interval.IntervalGlobal import *
from direct.gui.DirectGui import *
from toontown.effects import DustCloud
from toontown.toonbase import ToontownGlobals, TTLocalizer
from toontown.toontowngui import TTDialog
from toontown.quest import Quests
import DistributedFurnitureItem
from toontown.catalog import CatalogFurnitureItem
class DistributedChair(DistributedFurnitureItem.DistributedFurnitureItem):
def __init__(self, cr):
DistributedFurnitureItem.DistributedFurnitureItem.__init__(self, cr)
self.dialog = None
self.exitButton = None
self.locked = False
self.avId = ToontownGlobals.CHAIR_NONE
def loadModel(self):
model = DistributedFurnitureItem.DistributedFurnitureItem.loadModel(self)
cSphere = CollisionSphere(0.0, CatalogFurnitureItem.getChairCollOffset(self.item.furnitureType), 1.0, 1.575)
cSphere.setTangible(0)
colNode = CollisionNode('Chair-%s' % self.doId)
colNode.addSolid(cSphere)
cSpherePath = model.attachNewNode(colNode)
cSpherePath.setCollideMask(ToontownGlobals.WallBitmask)
self.accept('enterChair-%s' % self.doId, self.__enterSphere)
return model
def disable(self):
av = base.cr.doId2do.get(self.avId)
if av:
self.resetAvatar(av)
self.ignoreAll()
DistributedFurnitureItem.DistributedFurnitureItem.disable(self)
def getChair(self):
return CatalogFurnitureItem.ChairToPosHpr[self.item.furnitureType]
def destroyGui(self):
if self.exitButton:
self.exitButton.destroy()
self.exitButton = None
if self.dialog:
self.dialog.destroy()
self.dialog = None
def setupGui(self):
castGui = loader.loadModel('phase_4/models/gui/fishingGui')
self.exitButton = DirectButton(parent=base.a2dBottomRight, relief=None, text=('', TTLocalizer.FishingExit, TTLocalizer.FishingExit), text_align=TextNode.ACenter, text_scale=0.1, text_fg=Vec4(1, 1, 1, 1), text_shadow=Vec4(0, 0, 0, 1), text_pos=(0.0, -0.12), pos=(-0.158, 0, 0.14), image=(castGui.find('**/exit_buttonUp'), castGui.find('**/exit_buttonDown'), castGui.find('**/exit_buttonRollover')), command=self.sendUpdate, extraArgs=['requestSit', [ToontownGlobals.CHAIR_STOP]])
castGui.removeNode()
base.localAvatar.stopSleepWatch()
base.localAvatar.startSleepWatch(self.__handleFallingAsleep)
def resetAvatar(self, av):
av.loop('neutral')
av.setPos(av.getPos(render))
av.getGeomNode().setHpr(0, 0, 0)
av.setH(self.getH() + self.getChair()[1][0])
av.reparentTo(render)
if av == base.localAvatar:
base.localAvatar.setPreventCameraDisable(False)
base.cr.playGame.getPlace().setState('walk')
def setAvId(self, avId):
print 'Get av id %s' % avId
if avId == ToontownGlobals.CHAIR_NONE:
self.avId = avId
return
chair = self.getChair()
av = base.cr.doId2do.get(avId)
if not av:
return
sitStartDuration = av.getDuration('sit-start')
sequence = Sequence(Func(av.loop, 'walk'), av.getGeomNode().hprInterval(0.25, chair[1]), Parallel(Sequence(Wait(sitStartDuration * 0.25), av.posInterval(sitStartDuration * 0.25, chair[0])), ActorInterval(av, 'sit-start')), Func(av.setAnimState, 'Sit', 1.0))
av.setPosHpr(chair[2], (0, 0, 0))
av.reparentTo(self)
if av == base.localAvatar:
base.cr.playGame.getPlace().setState('walk')
base.localAvatar.setPreventCameraDisable(True)
base.cr.playGame.getPlace().setState('stopped')
sequence.append(Func(self.setupGui))
sequence.start()
self.avId = avId
def setStatus(self, status):
print 'Got status %s %s' % (status, self.avId)
av = base.cr.doId2do.get(self.avId)
if not av:
print 'RIP'
return
if status == ToontownGlobals.CHAIR_LOCKED:
print 'locked'
self.locked = True
if status == ToontownGlobals.CHAIR_UNEXPECTED_EXIT:
print 'unexpected'
self.resetAvatar(av)
else:
print 'rektangle'
sitStartDuration = av.getDuration('sit-start')
self.destroyGui()
Sequence(Parallel(ActorInterval(av, 'sit-start', startTime=sitStartDuration, endTime=0.0), Sequence(Wait(sitStartDuration * 0.25), av.posInterval(sitStartDuration * 0.25, self.getChair()[2]))), Func(self.resetAvatar, av)).start()
def resetAvatar(self, av):
av.loop('neutral')
av.setPos(av.getPos(render))
av.getGeomNode().setHpr(0, 0, 0)
av.setH(self.getH() + self.getChair()[1][0])
av.reparentTo(render)
if av == base.localAvatar:
base.localAvatar.setPreventCameraDisable(False)
base.cr.playGame.getPlace().setState('walk')
self.destroyGui()
def __enterSphere(self, collisionEntry):
if self.locked or self.avId in base.cr.doId2do:
return
base.cr.playGame.getPlace().setState('stopped')
self.dialog = TTDialog.TTDialog(style=TTDialog.TwoChoice, text=TTLocalizer.ChairAskToUse, fadeScreen=1, command=self.__handleDialogResponse)
def __handleDialogResponse(self, response):
self.destroyGui()
if response < 0:
base.cr.playGame.getPlace().setState('walk')
return
self.sendUpdate('requestSit', [ToontownGlobals.CHAIR_START])
def __handleFallingAsleep(self, arg):
self.sendUpdate('requestSit', [ToontownGlobals.CHAIR_STOP])

View file

@ -0,0 +1,57 @@
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
class DistributedChairAI(DistributedFurnitureItemAI):
def __init__(self, air, furnitureMgr, itemType):
DistributedFurnitureItemAI.__init__(self, air, furnitureMgr, itemType)
self.avId = ToontownGlobals.CHAIR_NONE
def destroy(self):
self.ignoreAll()
DistributedFurnitureItemAI.destroy(self)
def b_setAvId(self, avId):
self.avId = avId
self.sendUpdate('setAvId', [avId])
def b_resetAvId(self):
self.b_setAvId(ToontownGlobals.CHAIR_NONE)
def b_resetAvWithAnim(self, reason):
self.sendUpdate('setStatus', [reason])
self.b_resetAvId()
def getAvId(self):
return self.avId
def getSitResponse(self):
return ToontownGlobals.CHAIR_NONE
def requestSit(self, requestCode):
avId = self.air.getAvatarIdFromSender()
av = self.air.doId2do.get(avId)
if not av:
return
if requestCode == ToontownGlobals.CHAIR_START:
if self.avId in self.air.doId2do:
return
self.b_setAvId(avId)
self.acceptOnce(self.air.getAvatarExitEvent(avId), self.__handleUnexpectedExit)
elif requestCode == ToontownGlobals.CHAIR_STOP:
if self.avId != avId:
return
self.b_resetAvWithAnim(ToontownGlobals.CHAIR_EXIT)
self.ignoreAll()
def __handleUnexpectedExit(self):
self.b_resetAvWithAnim(ToontownGlobals.CHAIR_UNEXPECTED_EXIT)

View file

@ -1,7 +1,7 @@
from direct.distributed.DistributedObjectAI import DistributedObjectAI
from toontown.catalog.CatalogItemList import CatalogItemList
from toontown.catalog import CatalogItem
from toontown.catalog.CatalogFurnitureItem import CatalogFurnitureItem, FLTrunk, FLCloset, FLBank, FLPhone, FLCrate
from toontown.catalog.CatalogFurnitureItem import CatalogFurnitureItem, FLTrunk, FLCloset, FLBank, FLPhone, FLCrate, FLChair
from toontown.catalog.CatalogWallpaperItem import CatalogWallpaperItem
from toontown.catalog.CatalogMouldingItem import CatalogMouldingItem
from toontown.catalog.CatalogFlooringItem import CatalogFlooringItem
@ -13,6 +13,7 @@ from DistributedClosetAI import DistributedClosetAI
from DistributedTrunkAI import DistributedTrunkAI
from DistributedBankAI import DistributedBankAI
from DistributedRewardCrateAI import DistributedRewardCrateAI
from DistributedChairAI import DistributedChairAI
from otp.ai.MagicWordGlobal import *
class FurnitureError(Exception):
@ -246,6 +247,8 @@ class DistributedFurnitureManagerAI(DistributedObjectAI):
do = DistributedPhoneAI(self.air, self, item)
elif item.getFlags() & FLCrate:
do = DistributedRewardCrateAI(self.air, self, item)
elif item.getFlags() & FLChair:
do = DistributedChairAI(self.air, self, item)
else:
do = DistributedFurnitureItemAI(self.air, self, item)

View file

@ -40,10 +40,11 @@ class Walk(StateData.StateData):
self.fsm.request('off')
self.ignore('control')
base.localAvatar.disableAvatarControls()
base.localAvatar.stopUpdateSmartCamera()
if not base.localAvatar.preventCameraDisable:
base.localAvatar.stopUpdateSmartCamera()
base.localAvatar.detachCamera()
base.localAvatar.stopPosHprBroadcast()
base.localAvatar.stopBlink()
base.localAvatar.detachCamera()
base.localAvatar.stopGlitchKiller()
base.localAvatar.collisionsOff()
base.localAvatar.controlManager.placeOnFloor()

View file

@ -34,7 +34,6 @@ class ShtikerBook(DirectFrame, StateData.StateData):
self.pageOrder = [TTLocalizer.OptionsPageTitle,
TTLocalizer.ShardPageTitle,
TTLocalizer.MapPageTitle,
TTLocalizer.StatPageTitle,
TTLocalizer.InventoryPageTitle,
TTLocalizer.QuestPageToonTasks,
TTLocalizer.TrackPageShortTitle,
@ -46,7 +45,8 @@ class ShtikerBook(DirectFrame, StateData.StateData):
TTLocalizer.GardenPageTitle,
TTLocalizer.GolfPageTitle,
TTLocalizer.PhotoPageTitle,
TTLocalizer.EventsPageName]
TTLocalizer.EventsPageName,
TTLocalizer.StatPageTitle]
def setSafeMode(self, setting):
self.safeMode = setting

View file

@ -307,9 +307,6 @@ class LocalToon(DistributedToon.DistributedToon, LocalAvatar.LocalAvatar):
self.shardPage = ShardPage.ShardPage()
self.shardPage.load()
self.book.addPage(self.shardPage, pageName=TTLocalizer.ShardPageTitle)
self.statPage = StatPage.StatPage()
self.statPage.load()
self.book.addPage(self.statPage, pageName=TTLocalizer.StatPageTitle)
self.mapPage = MapPage.MapPage()
self.mapPage.load()
self.book.addPage(self.mapPage, pageName=TTLocalizer.MapPageTitle)
@ -342,6 +339,9 @@ class LocalToon(DistributedToon.DistributedToon, LocalAvatar.LocalAvatar):
self.photoPage.load()
self.book.addPage(self.photoPage, pageName=TTLocalizer.PhotoPageTitle)
self.addEventsPage()
self.statPage = StatPage.StatPage()
self.statPage.load()
self.book.addPage(self.statPage, pageName=TTLocalizer.StatPageTitle)
self.book.setPage(self.mapPage, enterPage=False)
self.laffMeter = LaffMeter.LaffMeter(self.style, self.hp, self.maxHp)
self.laffMeter.setAvatar(self)

View file

@ -8652,6 +8652,8 @@ Stats = [
StatResetAsk = 'Are you sure you want to reset your stats? This is an irreversible action!'
StatResetDone = 'Your stats have been reset.'
ChairAskToUse = 'Would you like to sit on this chair?'
Blacklist = [
"$1ut",
"$h1t",

View file

@ -1665,4 +1665,11 @@ STAT_GOLF = 17
STAT_SOS = 18
STAT_UNITES = 19
STAT_SLIPS = 20
STAT_GAGS = 21
STAT_GAGS = 21
CHAIR_START = 0
CHAIR_STOP = 1
CHAIR_NONE = 0
CHAIR_EXIT = 1
CHAIR_LOCKED = 2
CHAIR_UNEXPECTED_EXIT = 3