Don't exceed your own speed when following a leader.

This commit is contained in:
Steve 2016-04-20 13:53:06 +01:00
parent e56e64ee05
commit 6d8856deae
1 changed files with 24 additions and 10 deletions

View File

@ -709,7 +709,9 @@ static void moveToPlayer(void)
turnToFace(wantedAngle); turnToFace(wantedAngle);
if (player->thrust) if (player->thrust > 0.1)
{
if (self->speed > player->speed)
{ {
oldSpeed = self->speed; oldSpeed = self->speed;
self->speed = sqrt(player->thrust); self->speed = sqrt(player->thrust);
@ -717,6 +719,11 @@ static void moveToPlayer(void)
self->speed = oldSpeed; self->speed = oldSpeed;
} }
else else
{
applyFighterThrust();
}
}
else
{ {
applyFighterBrakes(); applyFighterBrakes();
} }
@ -905,18 +912,25 @@ static void moveToLeader(void)
if (dist <= ((self->leader->type != ET_CAPITAL_SHIP) ? 350 : 550)) if (dist <= ((self->leader->type != ET_CAPITAL_SHIP) ? 350 : 550))
{ {
if (self->leader->thrust) if (self->leader->thrust > 0.1)
{ {
wantedAngle = getAngle(self->leader->x, self->leader->y, self->leader->x + (self->leader->dx * 1000), self->leader->y + (self->leader->dy * 1000)); wantedAngle = getAngle(self->leader->x, self->leader->y, self->leader->x + (self->leader->dx * 1000), self->leader->y + (self->leader->dy * 1000));
turnToFace(wantedAngle); turnToFace(wantedAngle);
if (self->speed > self->leader->speed)
{
oldSpeed = self->speed; oldSpeed = self->speed;
self->speed = sqrt(self->leader->thrust); self->speed = sqrt(self->leader->thrust);
applyFighterThrust(); applyFighterThrust();
self->speed = oldSpeed; self->speed = oldSpeed;
} }
else else
{
applyFighterThrust();
}
}
else
{ {
applyFighterBrakes(); applyFighterBrakes();
} }