[Change] Make accel speed dependent, not thrust.

This commit is contained in:
Allanis 2013-04-20 15:30:33 +01:00
parent 9e2bda007b
commit 5b29539c17
3 changed files with 17 additions and 6 deletions

View File

@ -112,7 +112,7 @@ incombat([number id])
accel(number mod)
-- Accelerates the pilot.
-- mod float that represents acceleration ratio between 0(stopped) and 1(max accel).
-- mod float that represents speed to accel to (1. is full speed, 0. is stopped).
-- return nil.
turn(number mod)

View File

@ -637,8 +637,19 @@ static int ai_incombat(lua_State* L) {
// Accelerate the pilot based on a param.
static int ai_accel(lua_State* L) {
pilot_acc = (lua_gettop(L) > 1 && lua_isnumber(L, 1)) ?
ABS((double)lua_tonumber(L, 1)) : 1.;
double n;
if(lua_gettop(L) > 1 && lua_isnumber(L, 1)) {
n = (double)lua_tonumber(L,1);
if(n > 1.) n = 1.;
else if(n < 0.) n = 0.;
if(VMOD(cur_pilot->solid->vel) > (n * cur_pilot->speed))
pilot_acc = 0.;
} else
pilot_acc = 1.;
return 0;
}

View File

@ -1,9 +1,9 @@
#pragma once
#include "lua.h"
#define MIN_DIR_ERR 1.0*M_PI/180.
#define MAX_DIR_ERR 0.1*M_PI/180.
#define MIN_VEL_ERR 1.0
#define MIN_DIR_ERR 5.0*M_PI/180.
#define MAX_DIR_ERR 0.5*M_PI/180.
#define MIN_VEL_ERR 5.0
#define FACE_WVEL 0.1 // Weight of velocity compared to position to face.