diff --git a/scripts/ai/API b/scripts/ai/API index c83d407..cdcb9a2 100644 --- a/scripts/ai/API +++ b/scripts/ai/API @@ -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) diff --git a/src/ai.c b/src/ai.c index 51b3dd9..7469b17 100644 --- a/src/ai.c +++ b/src/ai.c @@ -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; } diff --git a/src/ai.h b/src/ai.h index 59bf5e9..7d7dfb9 100644 --- a/src/ai.h +++ b/src/ai.h @@ -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.