[Change] Make accel speed dependent, not thrust.
This commit is contained in:
parent
9e2bda007b
commit
5b29539c17
@ -112,7 +112,7 @@ incombat([number id])
|
|||||||
|
|
||||||
accel(number mod)
|
accel(number mod)
|
||||||
-- Accelerates the pilot.
|
-- 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.
|
-- return nil.
|
||||||
|
|
||||||
turn(number mod)
|
turn(number mod)
|
||||||
|
15
src/ai.c
15
src/ai.c
@ -637,8 +637,19 @@ static int ai_incombat(lua_State* L) {
|
|||||||
|
|
||||||
// Accelerate the pilot based on a param.
|
// Accelerate the pilot based on a param.
|
||||||
static int ai_accel(lua_State* L) {
|
static int ai_accel(lua_State* L) {
|
||||||
pilot_acc = (lua_gettop(L) > 1 && lua_isnumber(L, 1)) ?
|
double n;
|
||||||
ABS((double)lua_tonumber(L, 1)) : 1.;
|
|
||||||
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
6
src/ai.h
6
src/ai.h
@ -1,9 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "lua.h"
|
#include "lua.h"
|
||||||
|
|
||||||
#define MIN_DIR_ERR 1.0*M_PI/180.
|
#define MIN_DIR_ERR 5.0*M_PI/180.
|
||||||
#define MAX_DIR_ERR 0.1*M_PI/180.
|
#define MAX_DIR_ERR 0.5*M_PI/180.
|
||||||
#define MIN_VEL_ERR 1.0
|
#define MIN_VEL_ERR 5.0
|
||||||
|
|
||||||
#define FACE_WVEL 0.1 // Weight of velocity compared to position to face.
|
#define FACE_WVEL 0.1 // Weight of velocity compared to position to face.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user