mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
- New Ship Movement model
This commit is contained in:
parent
cf7d53c470
commit
92e5f8fcec
@ -27,8 +27,9 @@ class ShipPilot(PhysicsWalker):
|
||||
wantDebugIndicator = base.config.GetBool(
|
||||
'want-avatar-physics-indicator', 0)
|
||||
|
||||
MAX_STRAIGHT_SAIL_BONUS = 1.25
|
||||
STRAIGHT_SAIL_BONUS_TIME = 10.0
|
||||
MAX_STRAIGHT_SAIL_BONUS = 1.5 # 1.25 Old
|
||||
STRAIGHT_SAIL_BONUS_TIME = 16.0
|
||||
TURNING_BONUS_REDUCTION = 3.0
|
||||
|
||||
# special methods
|
||||
def __init__(self,
|
||||
@ -378,23 +379,29 @@ class ShipPilot(PhysicsWalker):
|
||||
# How far did we move based on the amount of time elapsed?
|
||||
dt = ClockObject.getGlobalClock().getDt()
|
||||
|
||||
if reverse or turnLeft or turnRight or not forward:
|
||||
# Reset Straight Sailing Bonus
|
||||
if reverse:
|
||||
# Reverse kills Travel Speed totally
|
||||
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:
|
||||
# Add in the Straight Sailing Time
|
||||
self.straightHeading += dt
|
||||
self.straightHeading = max(0, min(self.STRAIGHT_SAIL_BONUS_TIME, self.straightHeading))
|
||||
|
||||
# Straight Sailing Acceleration Bonus
|
||||
straightSailBonus = 0.0
|
||||
#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
|
||||
if self.straightHeading > (self.STRAIGHT_SAIL_BONUS_TIME * 0.5):
|
||||
straightSailBonus = (self.straightHeading - (self.STRAIGHT_SAIL_BONUS_TIME * 0.5)) / self.STRAIGHT_SAIL_BONUS_TIME * 0.5
|
||||
straightSailBonus = self.straightHeading / self.STRAIGHT_SAIL_BONUS_TIME
|
||||
straightSailBonus = min(self.MAX_STRAIGHT_SAIL_BONUS, straightSailBonus * self.MAX_STRAIGHT_SAIL_BONUS)
|
||||
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)
|
||||
|
||||
avatarSlideSpeed=self.ship.acceleration * 0.5 * straightSailBonus
|
||||
@ -410,8 +417,10 @@ class ShipPilot(PhysicsWalker):
|
||||
|
||||
# Add in Straight Sailing Multiplier
|
||||
self.__speed *= straightSailBonus
|
||||
self.__speed += self.ship.speedboost
|
||||
# self.__speed *= straightSailBonus
|
||||
self.__slideSpeed *= straightSailBonus
|
||||
maxSpeed = self.ship.maxSpeed * straightSailBonus
|
||||
maxSpeed = self.ship.maxSpeed
|
||||
|
||||
# Enable debug turbo modec
|
||||
debugRunning = inputState.isSet("debugRunning")
|
||||
@ -438,6 +447,16 @@ class ShipPilot(PhysicsWalker):
|
||||
self.currentTurning = 0.0
|
||||
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:
|
||||
self.displayDebugInfo()
|
||||
|
||||
@ -490,10 +509,8 @@ class ShipPilot(PhysicsWalker):
|
||||
newVector = Vec3(step)
|
||||
#newVector=Vec3(rotMat.xform(newVector))
|
||||
#maxLen = maxSpeed
|
||||
if (goForward):
|
||||
maxLen = self.ship.acceleration * straightSailBonus
|
||||
else:
|
||||
maxLen = self.ship.reverseAcceleration
|
||||
|
||||
maxLen = self.__speed
|
||||
|
||||
if newVector.length() > maxLen and \
|
||||
not (debugRunning or base.localAvatar.getTurbo()):
|
||||
|
Loading…
x
Reference in New Issue
Block a user