Posted: Wed Oct 21, 2009 5:07 pm
Ill look at it. But according to the code a full dead stop is never possible. All movement goes over the function appluThrust:Thargoid wrote:Also as I said in the thread I'm sure I've seen the hired escorts and some other ships fly, dead-stop, tumble and then shoot off again at speed, which would be another manifestation of this kind of action.
Code: Select all
- (void) applyThrust:(double) delta_t
{
GLfloat dt_thrust = thrust * delta_t;
BOOL canBurn = [self hasFuelInjection] && (fuel > MIN_FUEL);
BOOL isUsingAfterburner = (canBurn && (flightSpeed > maxFlightSpeed) && (desired_speed >= flightSpeed));
float max_available_speed = maxFlightSpeed;
if (canBurn) max_available_speed *= [self afterburnerFactor];
position = vector_add(position, vector_multiply_scalar(velocity, delta_t));
if (thrust)
{
GLfloat velmag = magnitude(velocity);
if (velmag)
{
GLfloat vscale = fmaxf((velmag - dt_thrust) / velmag, 0.0f);
scale_vector(&velocity, vscale);
}
}
if (behaviour == BEHAVIOUR_TUMBLE) return;
// check for speed
if (desired_speed > max_available_speed)
desired_speed = max_available_speed;
if (flightSpeed > desired_speed)
{
[self decrease_flight_speed: dt_thrust];
if (flightSpeed < desired_speed) flightSpeed = desired_speed;
}
if (flightSpeed < desired_speed)
{
[self increase_flight_speed: dt_thrust];
if (flightSpeed > desired_speed) flightSpeed = desired_speed;
}
[self moveForward: delta_t*flightSpeed];
// burn fuel at the appropriate rate
if (isUsingAfterburner) // no fuelconsumption on slowdown
{
fuel_accumulator -= delta_t * AFTERBURNER_NPC_BURNRATE;
while (fuel_accumulator < 0.0)
{
fuel--;
fuel_accumulator += 1.0;
}
}
}
After the break off halfway the code, the speed is decreased but also the [self moveForward: delta_t*flightSpeed]; makes that the actual ship is moved forward according to speed. performTumble is maybe mend as full stop as a very special effect With any other behaviour it will slow down according the thrust settings.