From 6bd6420254ea125784c8d2d875afbc2e6ed0ad47 Mon Sep 17 00:00:00 2001 From: John Cote Date: Sat, 9 May 2015 01:23:58 -0400 Subject: [PATCH] Some pet file edits --- toontown/pets/DistributedPetUD.py | 53 ---------------------- toontown/pets/Pet.py | 2 +- toontown/pets/PetAvatarPanel.py | 4 +- toontown/pets/PetChase.py | 74 ------------------------------- toontown/pets/PetCollider.py | 67 ---------------------------- toontown/pets/PetConstants.py | 3 +- toontown/pets/PetDNA.py | 8 +--- toontown/pets/PetFlee.py | 63 -------------------------- toontown/pets/PetLeash.py | 20 --------- toontown/pets/PetMoverAI.py | 4 +- toontown/pets/PetSphere.py | 47 -------------------- toontown/pets/PetTraits.py | 9 ++-- toontown/pets/PetWander.py | 61 ------------------------- 13 files changed, 11 insertions(+), 404 deletions(-) delete mode 100644 toontown/pets/DistributedPetUD.py delete mode 100644 toontown/pets/PetChase.py delete mode 100644 toontown/pets/PetCollider.py delete mode 100644 toontown/pets/PetFlee.py delete mode 100644 toontown/pets/PetLeash.py delete mode 100644 toontown/pets/PetSphere.py delete mode 100644 toontown/pets/PetWander.py diff --git a/toontown/pets/DistributedPetUD.py b/toontown/pets/DistributedPetUD.py deleted file mode 100644 index 09d56b3d..00000000 --- a/toontown/pets/DistributedPetUD.py +++ /dev/null @@ -1,53 +0,0 @@ -from direct.directnotify import DirectNotifyGlobal -from direct.distributed.DistributedObjectUD import DistributedObjectUD - -class DistributedPetUD(DistributedObjectUD): - notify = DirectNotifyGlobal.directNotify.newCategory("DistributedPetUD") - - def setDNA(self, dna): - pass - - def setOwnerId(self, ownerId): - pass - - def setTraitSeed(self, traitSeed): - pass - - def setSafeZone(self, safeZone): - pass - - def setHead(self, head): - pass - - def setEars(self, ears): - pass - - def setNose(self, nose): - pass - - def setTail(self, tail): - pass - - def setBodyTexture(self, bodyTexture): - pass - - def setColor(self, color): - pass - - def setColorScale(self, colorScale): - pass - - def setEyeColor(self, eyeColor): - pass - - def setGender(self, gender): - pass - - def setLastSeenTimestamp(self, timestamp): - pass - - def setTrickAptitudes(self, aptitudes): - pass - - def setLastSeenTimestamp(self, timestamp): - pass diff --git a/toontown/pets/Pet.py b/toontown/pets/Pet.py index 7f5c9498..67f45c3d 100644 --- a/toontown/pets/Pet.py +++ b/toontown/pets/Pet.py @@ -26,7 +26,7 @@ Component2IconDict = {'boredom': 'Bored', 'anger': 'Angry', 'surprise': 'Surprised', 'affection': 'Love'} - + from toontown.nametag import * from toontown.nametag.NametagGlobals import * diff --git a/toontown/pets/PetAvatarPanel.py b/toontown/pets/PetAvatarPanel.py index 19e985a3..2316985f 100644 --- a/toontown/pets/PetAvatarPanel.py +++ b/toontown/pets/PetAvatarPanel.py @@ -33,8 +33,8 @@ class PetAvatarPanel(AvatarPanel.AvatarPanel): base.panel = self gui = loader.loadModel('phase_3.5/models/gui/PetControlPannel') guiScale = 0.116 - guiPos = (1.12, 0, 0.3) - self.frame = DirectFrame(parent=aspect2dp, image=gui, scale=guiScale, pos=guiPos, relief=None) + guiPos = (-0.213, 0, -0.70) + self.frame = DirectFrame(parent=base.a2dTopRight, image=gui, scale=guiScale, pos=guiPos, relief=None) disabledImageColor = Vec4(0.6, 0.6, 0.6, 1) text0Color = Vec4(1, 1, 1, 1) text1Color = Vec4(0.5, 1, 0.5, 1) diff --git a/toontown/pets/PetChase.py b/toontown/pets/PetChase.py deleted file mode 100644 index a178aaf7..00000000 --- a/toontown/pets/PetChase.py +++ /dev/null @@ -1,74 +0,0 @@ -from pandac.PandaModules import * -from direct.showbase.PythonUtil import reduceAngle -from otp.movement import Impulse -import math - -class PetChase(Impulse.Impulse): - - def __init__(self, target = None, minDist = None, moveAngle = None): - Impulse.Impulse.__init__(self) - self.target = target - if minDist is None: - minDist = 5.0 - self.minDist = minDist - if moveAngle is None: - moveAngle = 20.0 - self.moveAngle = moveAngle - self.lookAtNode = NodePath('lookatNode') - self.lookAtNode.hide() - self.vel = None - self.rotVel = None - return - - def setTarget(self, target): - self.target = target - - def destroy(self): - self.lookAtNode.removeNode() - del self.lookAtNode - del self.target - del self.vel - del self.rotVel - - def _setMover(self, mover): - Impulse.Impulse._setMover(self, mover) - self.lookAtNode.reparentTo(self.nodePath) - self.vel = self.VecType(0) - self.rotVel = self.VecType(0) - - def _process(self, dt): - Impulse.Impulse._process(self, dt) - me = self.nodePath - target = self.target - targetPos = target.getPos(me) - x = targetPos[0] - y = targetPos[1] - distance = math.sqrt(x * x + y * y) - self.lookAtNode.lookAt(target) - relH = reduceAngle(self.lookAtNode.getH(me)) - epsilon = 0.005 - rotSpeed = self.mover.getRotSpeed() - if relH < -epsilon: - vH = -rotSpeed - elif relH > epsilon: - vH = rotSpeed - else: - vH = 0 - if abs(vH * dt) > abs(relH): - vH = relH / dt - if distance > self.minDist and abs(relH) < self.moveAngle: - vForward = self.mover.getFwdSpeed() - else: - vForward = 0 - distanceLeft = distance - self.minDist - if distance > self.minDist and vForward * dt > distanceLeft: - vForward = distanceLeft / dt - if vForward: - self.vel.setY(vForward) - self.mover.addShove(self.vel) - if vH: - self.rotVel.setX(vH) - self.mover.addRotShove(self.rotVel) - - def setMinDist(self, minDist): - self.minDist = minDist diff --git a/toontown/pets/PetCollider.py b/toontown/pets/PetCollider.py deleted file mode 100644 index 61e950ff..00000000 --- a/toontown/pets/PetCollider.py +++ /dev/null @@ -1,67 +0,0 @@ -from pandac.PandaModules import * -from direct.showbase.PythonUtil import reduceAngle -from otp.movement import Impulse -from otp.otpbase import OTPGlobals - -class PetCollider(Impulse.Impulse): - SerialNum = 0 - - def __init__(self, petRadius, collTrav): - Impulse.Impulse.__init__(self) - self.petRadius = petRadius - self.collTrav = collTrav - self.vel = None - self.rotVel = None - self.vH = 0 - self.fwdCLine = CollisionSegment(0.0, 0.0, 0.0, 0.0, 1.0, 0.0) - self.leftCLine = CollisionSegment(0.0, 0.0, 0.0, -1.0, 1.0, 0.0) - self.rightCLine = CollisionSegment(0.0, 0.0, 0.0, 1.0, 1.0, 0.0) - self.calcCollLines() - cLineNode = CollisionNode('cLineNode') - cLineNode.addSolid(self.fwdCLine) - cLineNode.addSolid(self.leftCLine) - cLineNode.addSolid(self.rightCLine) - cLineNode.setFromCollideMask(OTPGlobals.WallBitmask) - cLineNode.setIntoCollideMask(BitMask32.allOff()) - self.cLineNodePath = hidden.attachNewNode(cLineNode) - self.cHandler = CollisionHandlerEvent() - self.cHandler.addInPattern(self._getCollisionEvent()) - self.cHandler.addAgainPattern(self._getCollisionEvent()) - self.collTrav.addCollider(self.cLineNodePath, self.cHandler) - self.accept(self._getCollisionEvent(), self.handleCollision) - return - - def _setMover(self, mover): - Impulse.Impulse._setMover(self, mover) - self.cLineNodePath.reparentTo(self.nodePath) - self.vel = self.VecType(0) - self.rotVel = self.VecType(0) - - def destroy(self): - self.ignore(self._getCollisionEvent()) - self.collTrav.removeCollider(self.cLineNodePath) - del self.cHandler - del self.collTrav - self.cLineNodePath.removeNode() - del self.cLineNodePath - del self.vel - - def calcCollLines(self): - self.fwdCLine.setPointB(Point3(0, self.mover.getFwdSpeed(), 0)) - self.leftCLine.setPointB(Point3(-self.petRadius, self.petRadius, 0)) - self.rightCLine.setPointB(Point3(self.petRadius, self.petRadius, 0)) - - def _getSerialNum(self): - if not hasattr(self, 'serialNum'): - self.serialNum = PetCollider.SerialNum - PetCollider.SerialNum += 1 - return self.serialNum - - def _getCollisionEvent(self): - return 'petFeeler-%s' % self._getSerialNum() - - def handleCollision(self, collEntry): - print 'collision!' - cPoint = collEntry.getSurfacePoint(self.cLineNodePath) - cNormal = collEntry.getSurfaceNormal(self.cLineNodePath) - messenger.send(self.mover.getCollisionEventName(), [cPoint, cNormal]) diff --git a/toontown/pets/PetConstants.py b/toontown/pets/PetConstants.py index 02480b7c..72c4c9e2 100644 --- a/toontown/pets/PetConstants.py +++ b/toontown/pets/PetConstants.py @@ -58,5 +58,4 @@ ZoneToCostRange = {ToontownGlobals.ToontownCentral: (100, 500), ToontownGlobals.DaisyGardens: (1000, 2500), ToontownGlobals.MinniesMelodyland: (1500, 3000), ToontownGlobals.TheBrrrgh: (2500, 4000), - ToontownGlobals.DonaldsDreamland: (3000, 5000), - ToontownGlobals.FunnyFarm: (3700, 5800)} + ToontownGlobals.DonaldsDreamland: (3000, 5000)} diff --git a/toontown/pets/PetDNA.py b/toontown/pets/PetDNA.py index 0983e579..421e72e7 100644 --- a/toontown/pets/PetDNA.py +++ b/toontown/pets/PetDNA.py @@ -84,13 +84,7 @@ PetRarities = {'body': {ToontownGlobals.ToontownCentral: {'threeStripe': 50, 'tigerStripe': 20, 'turtle': 25, 'giraffe': 20, - 'leopard': 10}, - ToontownGlobals.FunnyFarm: {'leopard': 20, - 'giraffe': 20, - 'dots': 10, - 'tigerStripe': 25, - 'turtle': 25} - + 'leopard': 10} }} BodyTextures = {'dots': 'phase_4/maps/BeanbodyDots6.jpg', 'threeStripe': 'phase_4/maps/Beanbody3stripes6.jpg', diff --git a/toontown/pets/PetFlee.py b/toontown/pets/PetFlee.py deleted file mode 100644 index 38ac3a3e..00000000 --- a/toontown/pets/PetFlee.py +++ /dev/null @@ -1,63 +0,0 @@ -from pandac.PandaModules import * -from direct.showbase.PythonUtil import reduceAngle -from otp.movement import Impulse - -class PetFlee(Impulse.Impulse): - - def __init__(self, chaser = None, maxDist = 50.0, moveAngle = 20.0): - Impulse.Impulse.__init__(self) - self.chaser = chaser - self.maxDist = maxDist - self.moveAngle = moveAngle - self.lookAtNode = NodePath('lookatNode') - self.lookAtNode.hide() - self.vel = None - self.rotVel = None - return - - def destroy(self): - self.lookAtNode.removeNode() - del self.lookAtNode - del self.chaser - del self.vel - del self.rotVel - - def setChaser(self, chaser): - self.chaser = chaser - - def _setMover(self, mover): - Impulse.Impulse._setMover(self, mover) - self.lookAtNode.reparentTo(self.nodePath) - self.vel = self.VecType(0) - self.rotVel = self.VecType(0) - - def _process(self, dt): - Impulse.Impulse._process(self, dt) - me = self.nodePath - chaser = self.chaser - chaserPos = chaser.getPos(me) - chaserPos.setZ(0) - distance = self.VecType(chaserPos).length() - self.lookAtNode.lookAt(chaser) - relH = reduceAngle(self.lookAtNode.getH(me) + 180.0) - epsilon = 0.005 - rotSpeed = self.mover.getRotSpeed() - if relH < -epsilon: - vH = -rotSpeed - elif relH > epsilon: - vH = rotSpeed - else: - vH = 0 - if abs(vH * dt) > abs(relH): - vH = relH / dt - if distance < self.maxDist and abs(relH) < self.moveAngle: - vForward = self.mover.getFwdSpeed() - else: - vForward = 0 - distanceLeft = self.maxDist - distance - if distanceLeft > 0.0 and vForward * dt > distanceLeft: - vForward = distanceLeft / dt - self.vel.setY(vForward) - self.rotVel.setX(vH) - self.mover.addShove(self.vel) - self.mover.addRotShove(self.rotVel) diff --git a/toontown/pets/PetLeash.py b/toontown/pets/PetLeash.py deleted file mode 100644 index 94de2f46..00000000 --- a/toontown/pets/PetLeash.py +++ /dev/null @@ -1,20 +0,0 @@ -from pandac.PandaModules import * -from otp.movement import Impulse - -class PetLeash(Impulse.Impulse): - - def __init__(self, origin, length): - Impulse.Impulse.__init__(self) - self.origin = origin - self.length = length - - def _process(self, dt): - Impulse.Impulse._process(self, dt) - myPos = self.nodePath.getPos() - myDist = self.VecType(myPos - self.origin.getPos()).length() - if myDist > self.length: - excess = myDist - self.length - shove = self.VecType(myPos) - shove.normalize() - shove *= -excess - self.mover.addShove(shove) diff --git a/toontown/pets/PetMoverAI.py b/toontown/pets/PetMoverAI.py index c4554ea7..e884886a 100644 --- a/toontown/pets/PetMoverAI.py +++ b/toontown/pets/PetMoverAI.py @@ -20,6 +20,7 @@ def housePointCollision(x, y): for i, h in enumerate(houses): if inCircle(x, y, h, houseRadius): return 1 + return 0 def generatePos(): @@ -60,6 +61,7 @@ def houseCollision(pt1, pt2): for i, h in enumerate(houses): if lineInCircle(pt1, pt2, h): return 1 + return 0 def generatePath(start, end): @@ -87,7 +89,7 @@ def angle(A, B): return math.atan2(by-ay, bx-ax) -class PetMoverAI(FSM): +class PetMoverAI(FSM): def __init__(self, pet): self.pet = pet FSM.__init__(self, 'PetMoverAI-%d' % self.pet.doId) diff --git a/toontown/pets/PetSphere.py b/toontown/pets/PetSphere.py deleted file mode 100644 index e4677b51..00000000 --- a/toontown/pets/PetSphere.py +++ /dev/null @@ -1,47 +0,0 @@ -from pandac.PandaModules import * -from direct.showbase.PythonUtil import reduceAngle -from otp.movement import Impulse -from otp.otpbase import OTPGlobals - -class PetSphere(Impulse.Impulse): - SerialNum = 0 - - def __init__(self, petRadius, collTrav): - Impulse.Impulse.__init__(self) - self.serialNum = PetSphere.SerialNum - PetSphere.SerialNum += 1 - self.petRadius = petRadius - self.collTrav = collTrav - - def _setMover(self, mover): - Impulse.Impulse._setMover(self, mover) - self.cSphere = CollisionSphere(0.0, 0.0, 0.0, self.petRadius) - cSphereNode = CollisionNode('PetSphere') - cSphereNode.addSolid(self.cSphere) - self.cSphereNodePath = hidden.attachNewNode(cSphereNode) - self.cSphereNodePath.reparentTo(self.nodePath) - cSphereNode.setFromCollideMask(OTPGlobals.WallBitmask) - cSphereNode.setIntoCollideMask(OTPGlobals.WallBitmask) - self.pusher = CollisionHandlerPusher() - self.pusher.setHorizontal(1) - self.pusher.setInPattern('enter%in') - self.pusher.setOutPattern('exit%in') - self.pusher.addCollider(self.cSphereNodePath, self.nodePath) - self.pusher.addInPattern(self._getCollisionEvent()) - self.collTrav.addCollider(self.cSphereNodePath, self.pusher) - self.accept(self._getCollisionEvent(), self._handleCollision) - - def _clearMover(self, mover): - self.ignore(self._getCollisionEvent()) - self.collTrav.removeCollider(self.cSphereNodePath) - del self.cSphere - del self.pusher - del self.collTrav - self.cSphereNodePath.removeNode() - del self.cSphereNodePath - - def _getCollisionEvent(self): - return 'petSphereColl-%s' % self.serialNum - - def _handleCollision(self, collEntry): - messenger.send(self.mover.getCollisionEventName(), [collEntry]) diff --git a/toontown/pets/PetTraits.py b/toontown/pets/PetTraits.py index 1ce07ef4..538b1ecf 100644 --- a/toontown/pets/PetTraits.py +++ b/toontown/pets/PetTraits.py @@ -120,8 +120,7 @@ class PetTraits: ToontownGlobals.DaisyGardens: (0.4, 0.75), ToontownGlobals.MinniesMelodyland: (0.5, 0.8), ToontownGlobals.TheBrrrgh: (0.6, 0.85), - ToontownGlobals.DonaldsDreamland: (0.7, 0.9), - ToontownGlobals.FunnyFarm: (0.8, 0.9)} + ToontownGlobals.DonaldsDreamland: (0.7, 0.9)} class StdDecDistrib(TraitDistribution): TraitType = TraitDistribution.TraitTypes.DECREASING @@ -130,8 +129,7 @@ class PetTraits: ToontownGlobals.DaisyGardens: (0.25, 0.6), ToontownGlobals.MinniesMelodyland: (0.2, 0.5), ToontownGlobals.TheBrrrgh: (0.15, 0.4), - ToontownGlobals.DonaldsDreamland: (0.1, 0.3), - ToontownGlobals.FunnyFarm: (0.05, 0.2)} + ToontownGlobals.DonaldsDreamland: (0.1, 0.3)} class ForgetfulnessDistrib(TraitDistribution): TraitType = TraitDistribution.TraitTypes.DECREASING @@ -140,8 +138,7 @@ class PetTraits: ToontownGlobals.DaisyGardens: (0.0, 0.8), ToontownGlobals.MinniesMelodyland: (0.0, 0.7), ToontownGlobals.TheBrrrgh: (0.0, 0.6), - ToontownGlobals.DonaldsDreamland: (0.0, 0.5), - ToontownGlobals.FunnyFarm: (0.0, 0.4)} + ToontownGlobals.DonaldsDreamland: (0.0, 0.5)} TraitDescs = (('forgetfulness', ForgetfulnessDistrib(), True), ('boredomThreshold', StdIncDistrib(), True), diff --git a/toontown/pets/PetWander.py b/toontown/pets/PetWander.py deleted file mode 100644 index e2374708..00000000 --- a/toontown/pets/PetWander.py +++ /dev/null @@ -1,61 +0,0 @@ -from pandac.PandaModules import * -from direct.showbase.PythonUtil import reduceAngle, randFloat, normalDistrib -from direct.showbase import DirectObject -from toontown.pets.PetChase import PetChase -from toontown.pets import PetConstants - -class PetWander(PetChase, DirectObject.DirectObject): - - def __init__(self, minDist = 5.0, moveAngle = 20.0): - self.movingTarget = hidden.attachNewNode('petWanderTarget') - PetChase.__init__(self, self.movingTarget, minDist, moveAngle) - self.targetMoveCountdown = 0 - self.collEvent = None - self.gotCollision = False - return - - def isCpp(self): - return 0 - - def __ignoreCollisions(self): - if self.collEvent is not None: - self.ignore(self.collEvent) - self.collEvent = None - return - - def _setMover(self, mover): - PetChase._setMover(self, mover) - self.mover = mover - self.__ignoreCollisions() - self.collEvent = mover.getCollisionEventName() - self.accept(self.collEvent, self._handleCollision) - - def _clearMover(self, mover): - PetChase._clearMover(self, mover) - self.__ignoreCollisions() - - def _handleCollision(self, collEntry): - self.gotCollision = True - self.movingTarget.setPos(self.getNodePath().getPos()) - self.targetMoveCountdown *= 0.5 - - def destroy(self): - self.__ignoreCollisions() - self.movingTarget.removeNode() - del self.movingTarget - - def _process(self, dt): - self.targetMoveCountdown -= dt - if self.targetMoveCountdown <= 0.0: - distance = normalDistrib(3.0, 30.0) - heading = normalDistrib(-(90 + 45), 90 + 45) - if self.gotCollision: - self.gotCollision = False - heading = heading + 180 - target = self.getTarget() - target.setPos(self.getNodePath().getPos()) - target.setH(target, heading) - target.setY(target, distance) - duration = distance / self.mover.getFwdSpeed() - self.targetMoveCountdown = duration * randFloat(1.2, 3.0) - PetChase._process(self, dt)