Create general EffectMgr for cheesy effects, implement getEndDate for holidays, and implement Ides of March

This commit is contained in:
John 2015-06-23 15:27:14 +03:00
parent 7b3ded4f3f
commit 2b6ca4e5cd
10 changed files with 96 additions and 70 deletions

View file

@ -332,7 +332,7 @@ from toontown.coghq import BattleBlocker/AI
from toontown.ai import DistributedBlackCatMgr/AI
from toontown.ai import DistributedReportMgr/AI
from toontown.ai import DistributedPolarPlaceEffectMgr/AI
from toontown.ai import DistributedGreenToonEffectMgr/AI
from toontown.ai import DistributedEffectMgr/AI
from toontown.ai import DistributedResistanceEmoteMgr/AI
from toontown.ai import DistributedScavengerHuntTarget/AI
from toontown.ai import DistributedTrickOrTreatTarget/AI
@ -2431,8 +2431,9 @@ dclass DistributedPolarPlaceEffectMgr : DistributedObject {
addPolarPlaceEffect() airecv clsend;
};
dclass DistributedGreenToonEffectMgr : DistributedObject {
addGreenToonEffect() airecv clsend;
dclass DistributedEffectMgr : DistributedObject {
setHoliday(uint8) required broadcast;
addEffect() airecv clsend;
};
dclass DistributedResistanceEmoteMgr : DistributedObject {

View file

@ -0,0 +1,26 @@
from direct.distributed.DistributedObject import DistributedObject
from otp.speedchat import SpeedChatGlobals
import HolidayGlobals
class DistributedEffectMgr(DistributedObject):
def delete(self):
self.ignoreAll()
DistributedObject.delete(self)
def setHoliday(self, holiday):
self.holiday = holiday
print 'holiday is %s' % self.holiday
self.accept(SpeedChatGlobals.SCStaticTextMsgEvent, self.__saidPhrase)
def __saidPhrase(self, phraseId):
if not self.cr.newsManager.isHolidayRunning(self.holiday):
return
holidayInfo = HolidayGlobals.getHoliday(self.holiday)
if 'speedchatIndex' not in holidayInfo or phraseId != holidayInfo['speedchatIndex']:
return
self.sendUpdate('addEffect')
self.cr.newsManager.broadcastHoliday(holidayInfo, 'effectMessage')

View file

@ -0,0 +1,26 @@
from direct.distributed.DistributedObjectAI import DistributedObjectAI
import HolidayGlobals
class DistributedEffectMgrAI(DistributedObjectAI):
def __init__(self, air, holiday, effectId):
DistributedObjectAI.__init__(self, air)
self.holiday = holiday
self.effectId = effectId
def getHoliday(self):
return self.holiday
def addEffect(self):
if not self.air.newsManager.isHolidayRunning(self.holiday):
return
av = self.air.doId2do.get(self.air.getAvatarIdFromSender())
if not av:
return
holiday = HolidayGlobals.getHoliday(self.holiday)
expireTime = int(HolidayGlobals.getUnixTime(HolidayGlobals.getEndDate(holiday)) / 60)
av.b_setCheesyEffect(self.effectId, 0, expireTime)

View file

@ -1,32 +0,0 @@
from direct.directnotify import DirectNotifyGlobal
from direct.distributed import DistributedObject
from direct.interval.IntervalGlobal import *
from otp.speedchat import SpeedChatGlobals
from toontown.toonbase import TTLocalizer
class DistributedGreenToonEffectMgr(DistributedObject.DistributedObject):
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedGreenToonEffectMgr')
def __init__(self, cr):
DistributedObject.DistributedObject.__init__(self, cr)
def announceGenerate(self):
DistributedObject.DistributedObject.announceGenerate(self)
DistributedGreenToonEffectMgr.notify.debug('announceGenerate')
self.accept(SpeedChatGlobals.SCStaticTextMsgEvent, self.phraseSaid)
def phraseSaid(self, phraseId):
greenPhrase = 30450
if phraseId == greenPhrase:
self.addGreenToonEffect()
def delete(self):
self.ignore(SpeedChatGlobals.SCStaticTextMsgEvent)
DistributedObject.DistributedObject.delete(self)
def addGreenToonEffect(self):
DistributedGreenToonEffectMgr.notify.debug('addGreenToonEffect')
av = base.localAvatar
self.sendUpdate('addGreenToonEffect', [])
msgTrack = Sequence(Func(av.setSystemMessage, 0, TTLocalizer.GreenToonEffectMsg))
msgTrack.start()

View file

@ -1,20 +0,0 @@
from direct.directnotify import DirectNotifyGlobal
from direct.distributed.DistributedObjectAI import DistributedObjectAI
from direct.distributed.ClockDelta import *
from direct.fsm.FSM import FSM
class DistributedGreenToonEffectMgrAI(DistributedObjectAI, FSM):
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedGreenToonEffectMgrAI")
def __init__(self, air):
DistributedObjectAI.__init__(self, air)
FSM.__init__(self, 'GreenToonFSM')
self.air = air
def enterOff(self):
self.requestDelete()
def addGreenToonEffect(self):
avId = self.air.getAvatarIdFromSender()
av = self.air.doId2do.get(avId)
av.b_setCheesyEffect(15, 0, 0)

View file

@ -1,4 +1,5 @@
from toontown.toonbase import ToontownGlobals, TTLocalizer
import calendar, datetime
Holidays = {
ToontownGlobals.LAUGHING_MAN: {
@ -43,8 +44,35 @@ Holidays = {
'startMessage': TTLocalizer.AprilToonsWeekStart,
'ongoingMessage': TTLocalizer.AprilToonsWeekStart,
'endMessage': TTLocalizer.AprilToonsWeekEnd
},
ToontownGlobals.IDES_OF_MARCH: {
'startMonth': 3,
'startDay': 14,
'endMonth': 3,
'endDay': 20,
'startMessage': TTLocalizer.IdesOfMarchStart,
'ongoingMessage': TTLocalizer.IdesOfMarchStart,
'endMessage': TTLocalizer.IdesOfMarchEnd,
'speedchatIndex': 30450, # It's easy to be green!
'effectMessage': TTLocalizer.GreenToonEffectMsg
}
}
def getHoliday(id):
return Holidays.get(id, {})
def getUnixTime(date):
epoch = datetime.datetime.fromtimestamp(0)
delta = date - epoch
return delta.total_seconds()
def getEndDate(holiday):
rightNow = datetime.datetime.now()
endMonth = holiday['endMonth'] if 'endMonth' in holiday else rightNow.month
endDay = holiday['endDay'] if 'endDay' in holiday else (rightNow.day if 'weekDay' in holiday else calendar.monthrange(rightNow.year, endMonth)[1])
date = datetime.datetime(rightNow.year, endMonth, endDay)
date += datetime.timedelta(days=1)
return date

View file

@ -60,6 +60,8 @@ class NewsManager(DistributedObject):
base.localAvatar.startAprilToonsControls()
base.localAvatar.chatMgr.chatInputSpeedChat.addAprilToonsMenu()
elif id == ToontownGlobals.IDES_OF_MARCH:
base.localAvatar.chatMgr.chatInputSpeedChat.addIdesOfMarchMenu()
def endSpecialHoliday(self, id):
if id == ToontownGlobals.LAUGHING_MAN:
@ -70,3 +72,5 @@ class NewsManager(DistributedObject):
base.localAvatar.stopAprilToonsControls()
base.localAvatar.chatMgr.chatInputSpeedChat.removeAprilToonsMenu()
elif id == ToontownGlobals.IDES_OF_MARCH:
base.localAvatar.chatMgr.chatInputSpeedChat.removeIdesOfMarchMenu()

View file

@ -393,9 +393,6 @@ class PlayGame(StateData.StateData):
base.localAvatar.chatMgr.obscure(1, 1)
base.localAvatar.obscureFriendsListButton(1)
requestStatus['how'] = 'tutorial'
if base.config.GetString('language', 'english') == 'japanese':
musicVolume = base.config.GetFloat('tutorial-music-volume', 0.5)
requestStatus['musicVolume'] = musicVolume
self.hood.enter(requestStatus)
def exitTutorialHood(self):
@ -557,8 +554,4 @@ class PlayGame(StateData.StateData):
return self.place
def getPlaceId(self):
if self.hood:
return self.hood.hoodId
else:
return None
return None
return self.hood.hoodId if self.hood else None

View file

@ -4,11 +4,10 @@ from toontown.safezone import DistributedButterflyAI
from toontown.safezone import DistributedDGFlowerAI
from toontown.safezone import DistributedTrolleyAI
from toontown.toonbase import ToontownGlobals
#from toontown.ai import DistributedGreenToonEffectMgrAI
from toontown.ai import DistributedTrickOrTreatTargetAI
from toontown.ai import DistributedEffectMgrAI, DistributedTrickOrTreatTargetAI
class DGHoodAI(HoodAI.HoodAI):
def __init__(self, air):
HoodAI.HoodAI.__init__(self, air,
ToontownGlobals.DaisyGardens,
@ -28,8 +27,8 @@ class DGHoodAI(HoodAI.HoodAI):
if simbase.config.GetBool('want-butterflies', True):
self.createButterflies()
#self.GreenToonEffectManager = DistributedGreenToonEffectMgrAI.DistributedGreenToonEffectMgrAI(self.air)
#self.GreenToonEffectManager.generateWithRequired(5819)
self.greenToonMgr = DistributedEffectMgrAI.DistributedEffectMgrAI(self.air, ToontownGlobals.IDES_OF_MARCH, 15)
self.greenToonMgr.generateWithRequired(5819)
if simbase.air.wantHalloween:
self.TrickOrTreatTargetManager = DistributedTrickOrTreatTargetAI.DistributedTrickOrTreatTargetAI(self.air)

View file

@ -7988,6 +7988,7 @@ WinterCarolingStart = 'Caroling has come to Toontown. Sing for your Snowman Head
ExpandedClosetsStart = 'Attention Toons: For a limited time, Members can purchase the new 50 item Closet from the Cattlelog for the low price of 50 Jellybeans!'
KartingTicketsHolidayStart = 'Get double tickets from Practice races at Goofy Speedway today!'
IdesOfMarchStart = 'Toons go GREEN!'
IdesOfMarchEnd = 'Hope you had fun being green.'
LogoutForced = 'You have done something wrong\n and are being logged out automatically,\n additionally your account may be frozen.\n Try going on a walk outside, it is fun.'
CountryClubToonEnterElevator = '%s \nhas jumped in the golf kart.'
CountryClubBossConfrontedMsg = '%s is battling the Club President!'