- New Ship Movement model

This commit is contained in:
Jason Yeung 2009-07-23 00:11:29 +00:00
parent cf7d53c470
commit 92e5f8fcec

View File

@ -27,8 +27,9 @@ class ShipPilot(PhysicsWalker):
wantDebugIndicator = base.config.GetBool( wantDebugIndicator = base.config.GetBool(
'want-avatar-physics-indicator', 0) 'want-avatar-physics-indicator', 0)
MAX_STRAIGHT_SAIL_BONUS = 1.25 MAX_STRAIGHT_SAIL_BONUS = 1.5 # 1.25 Old
STRAIGHT_SAIL_BONUS_TIME = 10.0 STRAIGHT_SAIL_BONUS_TIME = 16.0
TURNING_BONUS_REDUCTION = 3.0
# special methods # special methods
def __init__(self, def __init__(self,
@ -378,26 +379,32 @@ class ShipPilot(PhysicsWalker):
# How far did we move based on the amount of time elapsed? # How far did we move based on the amount of time elapsed?
dt = ClockObject.getGlobalClock().getDt() dt = ClockObject.getGlobalClock().getDt()
if reverse or turnLeft or turnRight or not forward: if reverse:
# Reset Straight Sailing Bonus # Reverse kills Travel Speed totally
self.straightHeading = 0 self.straightHeading = 0
elif self.ship.threatCounter:
# If ship is recently damaged, do not increase Travel Speed
pass
elif turnLeft or turnRight or not forward:
# Reset Straight Sailing Bonus
self.straightHeading -= dt * self.TURNING_BONUS_REDUCTION
else: else:
# Add in the Straight Sailing Time # Add in the Straight Sailing Time
self.straightHeading += dt self.straightHeading += dt
self.straightHeading = max(0, min(self.STRAIGHT_SAIL_BONUS_TIME, self.straightHeading))
# Straight Sailing Acceleration Bonus # Straight Sailing Acceleration Bonus
straightSailBonus = 0.0 straightSailBonus = 0.0
#if self.straightHeading > self.STRAIGHT_SAIL_BONUS_TIME * 0.333: #if self.straightHeading > self.STRAIGHT_SAIL_BONUS_TIME * 0.333:
# straightSailBonus = (self.straightHeading - (self.STRAIGHT_SAIL_BONUS_TIME * 0.333)) / self.STRAIGHT_SAIL_BONUS_TIME * 0.666 # straightSailBonus = (self.straightHeading - (self.STRAIGHT_SAIL_BONUS_TIME * 0.333)) / self.STRAIGHT_SAIL_BONUS_TIME * 0.666
if self.straightHeading > (self.STRAIGHT_SAIL_BONUS_TIME * 0.5): straightSailBonus = self.straightHeading / self.STRAIGHT_SAIL_BONUS_TIME
straightSailBonus = (self.straightHeading - (self.STRAIGHT_SAIL_BONUS_TIME * 0.5)) / self.STRAIGHT_SAIL_BONUS_TIME * 0.5
straightSailBonus = min(self.MAX_STRAIGHT_SAIL_BONUS, straightSailBonus * self.MAX_STRAIGHT_SAIL_BONUS) straightSailBonus = min(self.MAX_STRAIGHT_SAIL_BONUS, straightSailBonus * self.MAX_STRAIGHT_SAIL_BONUS)
straightSailBonus += 1.0 straightSailBonus += 1.0
self.__speed=(forward and self.ship.acceleration * straightSailBonus) or \ self.__speed=(forward and self.ship.acceleration) or \
(reverse and -self.ship.reverseAcceleration) (reverse and -self.ship.reverseAcceleration)
avatarSlideSpeed=self.ship.acceleration *0.5 * straightSailBonus avatarSlideSpeed=self.ship.acceleration * 0.5 * straightSailBonus
#self.__slideSpeed=slide and ( #self.__slideSpeed=slide and (
# (turnLeft and -avatarSlideSpeed) or # (turnLeft and -avatarSlideSpeed) or
# (turnRight and avatarSlideSpeed)) # (turnRight and avatarSlideSpeed))
@ -410,8 +417,10 @@ class ShipPilot(PhysicsWalker):
# Add in Straight Sailing Multiplier # Add in Straight Sailing Multiplier
self.__speed *= straightSailBonus self.__speed *= straightSailBonus
self.__speed += self.ship.speedboost
# self.__speed *= straightSailBonus
self.__slideSpeed *= straightSailBonus self.__slideSpeed *= straightSailBonus
maxSpeed = self.ship.maxSpeed * straightSailBonus maxSpeed = self.ship.maxSpeed
# Enable debug turbo modec # Enable debug turbo modec
debugRunning = inputState.isSet("debugRunning") debugRunning = inputState.isSet("debugRunning")
@ -438,6 +447,16 @@ class ShipPilot(PhysicsWalker):
self.currentTurning = 0.0 self.currentTurning = 0.0
self.__rotationSpeed = self.currentTurning self.__rotationSpeed = self.currentTurning
#print "########################"
#print self.__speed
#print self.ship.acceleration
#print self.ship.speedboost
#print straightSailBonus
# Broadcast Event to Handlers (ShipStatusMeter)
# messenger.send("setShipSpeed-%s" % (self.ship.getDoId()), [self.__speed, self.ship.acceleration * (1+self.MAX_STRAIGHT_SAIL_BONUS) * (1+self.MAX_STRAIGHT_SAIL_BONUS)])
messenger.send("setShipSpeed-%s" % (self.ship.getDoId()), [self.__speed, self.ship.acceleration * (1+self.MAX_STRAIGHT_SAIL_BONUS) + self.ship.speedboost])
if self.wantDebugIndicator: if self.wantDebugIndicator:
self.displayDebugInfo() self.displayDebugInfo()
@ -490,10 +509,8 @@ class ShipPilot(PhysicsWalker):
newVector = Vec3(step) newVector = Vec3(step)
#newVector=Vec3(rotMat.xform(newVector)) #newVector=Vec3(rotMat.xform(newVector))
#maxLen = maxSpeed #maxLen = maxSpeed
if (goForward):
maxLen = self.ship.acceleration * straightSailBonus maxLen = self.__speed
else:
maxLen = self.ship.reverseAcceleration
if newVector.length() > maxLen and \ if newVector.length() > maxLen and \
not (debugRunning or base.localAvatar.getTurbo()): not (debugRunning or base.localAvatar.getTurbo()):