def face(self, direction): """Makes Equismo look at a given the direction. This method makes only heading rotations. `direction': vector """ direction = Vec3(direction.x, direction.y, 0) if direction != Vec3.zero(): direction.normalize() currentDirection = self._currentDirection headingAngle = direction.signedAngleDeg(currentDirection, Vec3.down()) headingAngle += self._currentAngle if abs(headingAngle) > 1: interval = self.model.hprInterval(self._turningSpeed, Point3(headingAngle, 0, 0)) interval.start() self._currentDirection = direction self._currentAngle = headingAngle
def handleCameraFloorInteraction(self): if self.__onLevelGround or not base.localAvatarReachable() or ( base.localAvatarReachable() and base.localAvatar.battleControls): return self.putCameraFloorRayOnCamera() pointA = render.getRelativePoint(camera.getParent(), self.floorLineStart) pointB = pointA + (Vec3.down() * 1000) result = PhysicsUtils.rayTestClosestNotMe(base.localAvatar, pointA, pointB, CIGlobals.FloorGroup) if not result: return camObstrCollisionEntry = result camHeightFromFloor = (camera.getRelativePoint( render, camObstrCollisionEntry.getHitPos())).getZ() heightOfFloorUnderCamera = (camera.getPos()[2] - CIGlobals.FloorOffset) + camHeightFromFloor self.cameraZOffset = camera.getPos()[2] + camHeightFromFloor if self.cameraZOffset < 0: self.cameraZOffset = self.cameraZOffset * 0.33333333329999998 camHeight = max(base.localAvatar.getHeight(), 3.0) if self.cameraZOffset < -(camHeight * 0.5): if self.cameraZOffset < -camHeight: self.cameraZOffset = 0.0 else: self.cameraZOffset = -(camHeight * 0.5) if self.__floorDetected == 0: self.__floorDetected = 1 self.popCameraToDest()
def fireLaser(self, target): self.eyeLaser.show() self.eyeLaser.wrtReparentTo(render) self.eyeLaser.show() self.eyeLaser.lookAt( target, 0, 0, 0 if not hasattr(target, 'height') else target.height / 2.0) self.eyeLaser.setP(self.eyeLaser.getP() + 90) Sequence(Wait(1.0), Func(self.resetEyeLaser)).start() pDir = self.eyeLaser.getQuat(render).xform(Vec3.down()) pPos = self.eyeLaser.getPos(render) pFrom = pPos + (pDir * 1.01) pTo = pPos + (pDir * 50) result = base.physicsWorld.rayTestClosest(pFrom, pTo) if result.hasHit(): node = result.getNode() mask = node.getIntoCollideMask() point = result.getHitPos() dist = (point - pPos).length() self.eyeLaser.setScale(1, 1, dist) if not (mask & CIGlobals.LocalAvGroup).isZero(): if node.hasPythonTag("localAvatar"): char = node.getPythonTag("localAvatar") self.onHitLocalAvatar( char, CIGlobals.calcAttackDamage(dist, 5, 50)) else: self.eyeLaser.setScale(1, 1, 50)
def __floorVisTask(self, task): start = camera.getPos(render) end = start + (Vec3.down() * 500) result = base.physicsWorld.rayTestClosest(start, end, CIGlobals.StreetVisGroup) if result.hasHit(): self.enterZone(result.getNode()) return task.cont
def moveDown(self): vp = base.viewportMgr.activeViewport if not vp or not vp.is2D(): return self.updatePos(self.pos + self.getMoveDelta(Vec3.down(), vp))