mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2025-01-09 17:53:50 +00:00
Some pet file edits
This commit is contained in:
parent
fc3606d658
commit
6bd6420254
13 changed files with 11 additions and 404 deletions
|
@ -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
|
|
|
@ -33,8 +33,8 @@ class PetAvatarPanel(AvatarPanel.AvatarPanel):
|
||||||
base.panel = self
|
base.panel = self
|
||||||
gui = loader.loadModel('phase_3.5/models/gui/PetControlPannel')
|
gui = loader.loadModel('phase_3.5/models/gui/PetControlPannel')
|
||||||
guiScale = 0.116
|
guiScale = 0.116
|
||||||
guiPos = (1.12, 0, 0.3)
|
guiPos = (-0.213, 0, -0.70)
|
||||||
self.frame = DirectFrame(parent=aspect2dp, image=gui, scale=guiScale, pos=guiPos, relief=None)
|
self.frame = DirectFrame(parent=base.a2dTopRight, image=gui, scale=guiScale, pos=guiPos, relief=None)
|
||||||
disabledImageColor = Vec4(0.6, 0.6, 0.6, 1)
|
disabledImageColor = Vec4(0.6, 0.6, 0.6, 1)
|
||||||
text0Color = Vec4(1, 1, 1, 1)
|
text0Color = Vec4(1, 1, 1, 1)
|
||||||
text1Color = Vec4(0.5, 1, 0.5, 1)
|
text1Color = Vec4(0.5, 1, 0.5, 1)
|
||||||
|
|
|
@ -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
|
|
|
@ -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])
|
|
|
@ -58,5 +58,4 @@ ZoneToCostRange = {ToontownGlobals.ToontownCentral: (100, 500),
|
||||||
ToontownGlobals.DaisyGardens: (1000, 2500),
|
ToontownGlobals.DaisyGardens: (1000, 2500),
|
||||||
ToontownGlobals.MinniesMelodyland: (1500, 3000),
|
ToontownGlobals.MinniesMelodyland: (1500, 3000),
|
||||||
ToontownGlobals.TheBrrrgh: (2500, 4000),
|
ToontownGlobals.TheBrrrgh: (2500, 4000),
|
||||||
ToontownGlobals.DonaldsDreamland: (3000, 5000),
|
ToontownGlobals.DonaldsDreamland: (3000, 5000)}
|
||||||
ToontownGlobals.FunnyFarm: (3700, 5800)}
|
|
||||||
|
|
|
@ -84,13 +84,7 @@ PetRarities = {'body': {ToontownGlobals.ToontownCentral: {'threeStripe': 50,
|
||||||
'tigerStripe': 20,
|
'tigerStripe': 20,
|
||||||
'turtle': 25,
|
'turtle': 25,
|
||||||
'giraffe': 20,
|
'giraffe': 20,
|
||||||
'leopard': 10},
|
'leopard': 10}
|
||||||
ToontownGlobals.FunnyFarm: {'leopard': 20,
|
|
||||||
'giraffe': 20,
|
|
||||||
'dots': 10,
|
|
||||||
'tigerStripe': 25,
|
|
||||||
'turtle': 25}
|
|
||||||
|
|
||||||
}}
|
}}
|
||||||
BodyTextures = {'dots': 'phase_4/maps/BeanbodyDots6.jpg',
|
BodyTextures = {'dots': 'phase_4/maps/BeanbodyDots6.jpg',
|
||||||
'threeStripe': 'phase_4/maps/Beanbody3stripes6.jpg',
|
'threeStripe': 'phase_4/maps/Beanbody3stripes6.jpg',
|
||||||
|
|
|
@ -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)
|
|
|
@ -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)
|
|
|
@ -20,6 +20,7 @@ def housePointCollision(x, y):
|
||||||
for i, h in enumerate(houses):
|
for i, h in enumerate(houses):
|
||||||
if inCircle(x, y, h, houseRadius):
|
if inCircle(x, y, h, houseRadius):
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def generatePos():
|
def generatePos():
|
||||||
|
@ -60,6 +61,7 @@ def houseCollision(pt1, pt2):
|
||||||
for i, h in enumerate(houses):
|
for i, h in enumerate(houses):
|
||||||
if lineInCircle(pt1, pt2, h):
|
if lineInCircle(pt1, pt2, h):
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def generatePath(start, end):
|
def generatePath(start, end):
|
||||||
|
|
|
@ -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])
|
|
|
@ -120,8 +120,7 @@ class PetTraits:
|
||||||
ToontownGlobals.DaisyGardens: (0.4, 0.75),
|
ToontownGlobals.DaisyGardens: (0.4, 0.75),
|
||||||
ToontownGlobals.MinniesMelodyland: (0.5, 0.8),
|
ToontownGlobals.MinniesMelodyland: (0.5, 0.8),
|
||||||
ToontownGlobals.TheBrrrgh: (0.6, 0.85),
|
ToontownGlobals.TheBrrrgh: (0.6, 0.85),
|
||||||
ToontownGlobals.DonaldsDreamland: (0.7, 0.9),
|
ToontownGlobals.DonaldsDreamland: (0.7, 0.9)}
|
||||||
ToontownGlobals.FunnyFarm: (0.8, 0.9)}
|
|
||||||
|
|
||||||
class StdDecDistrib(TraitDistribution):
|
class StdDecDistrib(TraitDistribution):
|
||||||
TraitType = TraitDistribution.TraitTypes.DECREASING
|
TraitType = TraitDistribution.TraitTypes.DECREASING
|
||||||
|
@ -130,8 +129,7 @@ class PetTraits:
|
||||||
ToontownGlobals.DaisyGardens: (0.25, 0.6),
|
ToontownGlobals.DaisyGardens: (0.25, 0.6),
|
||||||
ToontownGlobals.MinniesMelodyland: (0.2, 0.5),
|
ToontownGlobals.MinniesMelodyland: (0.2, 0.5),
|
||||||
ToontownGlobals.TheBrrrgh: (0.15, 0.4),
|
ToontownGlobals.TheBrrrgh: (0.15, 0.4),
|
||||||
ToontownGlobals.DonaldsDreamland: (0.1, 0.3),
|
ToontownGlobals.DonaldsDreamland: (0.1, 0.3)}
|
||||||
ToontownGlobals.FunnyFarm: (0.05, 0.2)}
|
|
||||||
|
|
||||||
class ForgetfulnessDistrib(TraitDistribution):
|
class ForgetfulnessDistrib(TraitDistribution):
|
||||||
TraitType = TraitDistribution.TraitTypes.DECREASING
|
TraitType = TraitDistribution.TraitTypes.DECREASING
|
||||||
|
@ -140,8 +138,7 @@ class PetTraits:
|
||||||
ToontownGlobals.DaisyGardens: (0.0, 0.8),
|
ToontownGlobals.DaisyGardens: (0.0, 0.8),
|
||||||
ToontownGlobals.MinniesMelodyland: (0.0, 0.7),
|
ToontownGlobals.MinniesMelodyland: (0.0, 0.7),
|
||||||
ToontownGlobals.TheBrrrgh: (0.0, 0.6),
|
ToontownGlobals.TheBrrrgh: (0.0, 0.6),
|
||||||
ToontownGlobals.DonaldsDreamland: (0.0, 0.5),
|
ToontownGlobals.DonaldsDreamland: (0.0, 0.5)}
|
||||||
ToontownGlobals.FunnyFarm: (0.0, 0.4)}
|
|
||||||
|
|
||||||
TraitDescs = (('forgetfulness', ForgetfulnessDistrib(), True),
|
TraitDescs = (('forgetfulness', ForgetfulnessDistrib(), True),
|
||||||
('boredomThreshold', StdIncDistrib(), True),
|
('boredomThreshold', StdIncDistrib(), True),
|
||||||
|
|
|
@ -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)
|
|
Loading…
Reference in a new issue