[Change] ai.dist() now accepts pilot id's as parameter.

This commit is contained in:
Allanis 2013-07-07 19:11:14 +01:00
parent ef5a8e5a5f
commit a580cdeed3
4 changed files with 30 additions and 9 deletions

View File

@ -29,9 +29,9 @@ ifeq ($(OS),LINUX)
CFLAGS += -D_POSIX_SOURCE
endif
ifdef DEBUG
CFLAGS += -W -Wall -Wextra -Wunused -Wshadow -Wpointer-arith -Wmissing-prototypes -Winline -Wcast-align \
-Wmissing-declarations -fstack-protector -fstack-protector-all -g3 \
-DDEBUG -DLUA_USE_APICHECK -std=c99
CFLAGS += -W -Wall -Wextra -Wunused -Wshadow -Wpointer-arith -Wmissing-prototypes \
-Winline -Wcast-align -Wmissing-declarations -fstack-protector \
-fstack-protector-all -g3 -DDEBUG -DLUA_USE_APICHECK -std=c99
else
CFLAGS += -O2 -funroll-loops -pipe -std=c99
endif

View File

@ -61,7 +61,7 @@ function enter()
pilot.add("Empire Sml Defense")
pilot.add("Collective Sml Swarm")
elseif sys == misn_target then
p = pilot.add("Collective Drone")
p = pilot.add("Collective Drone", "scout")
for k,v in pairs(p) do
hook.pilotDeath(v, "kill")
end

View File

@ -539,10 +539,24 @@ static int ai_pshield(lua_State* L) {
/* Get the distance from the pointer. */
static int ai_getdistance(lua_State* L) {
Vec2* vect;
Pilot* pilot;
LLUA_MIN_ARGS(1);
vect = (lua_islightuserdata(L,1)) ?
(Vec2*)lua_topointer(L,1) : NULL;
/* Vector as a parameter. */
if(lua_islightuserdata(L, 1))
vect = (Vec2*)lua_topointer(L, 1);
/* Pilot id as parameter. */
else if(lua_isnumber(L, 1)) {
pilot = pilot_get((unsigned int) lua_tonumber(L, 1));
vect = &pilot->solid->pos;
} else {
/* Wrong parameter. */
LLUA_INVALID_PARAMETER();
return 0;
}
lua_pushnumber(L, vect_dist(vect, &cur_pilot->solid->pos));
return 1;
}

View File

@ -738,15 +738,20 @@ static int hook_pilotDeath(lua_State* L) {
static int pilot_addFleet(lua_State* L) {
LLUA_MIN_ARGS(1);
Fleet* flt;
char* fltname;
char* fltname, *fltai;;
int i, j;
unsigned int p;
double a;
Vec2 vv, vp, vn;
if(lua_isstring(L, -1)) fltname = (char*) lua_tostring(L, -1);
/* Parse first argument - Fleet name. */
if(lua_isstring(L, 1)) fltname = (char*) lua_tostring(L, 1);
else LLUA_INVALID_PARAMETER();
/* Parse second arguement - Fleet AI override. */
if(lua_isstring(L, 2)) fltai = (char*) lua_tostring(L, 2);
else fltai = NULL;
/* Pull the fleet. */
flt = fleet_get(fltname);
if(flt == NULL) {
@ -772,7 +777,9 @@ static int pilot_addFleet(lua_State* L) {
p = pilot_create(flt->pilots[i].ship,
flt->pilots[i].name,
flt->faction,
flt->ai,
(fltai != NULL) ? /* AI override */
ai_getProfile(fltai) :
flt->ai,
a,
&vp,
&vv,