diff --git a/dat/mission.xml b/dat/mission.xml
index b5c3cfa..1d142d6 100644
--- a/dat/mission.xml
+++ b/dat/mission.xml
@@ -77,5 +77,18 @@
Bar
Omega Station
-
+
+
+ emp_collective05
+
+ 1
+
+
+ player.getFaction("Empire") > 5
+ Collective Distraction
+ 100
+ Bar
+ Omega Station
+
+
diff --git a/src/llua_pilot.c b/src/llua_pilot.c
index 10d4f02..fef7ac0 100644
--- a/src/llua_pilot.c
+++ b/src/llua_pilot.c
@@ -12,7 +12,7 @@
#include "lluadef.h"
#include "rng.h"
#include "pilot.h"
-#include "pilot.h"
+#include "player.h"
#include "llua_pilot.h"
static int pilotL_createmetatable(lua_State* L);
@@ -36,6 +36,7 @@ static int pilotL_rename(lua_State* L);
static int pilotL_position(lua_State* L);
static int pilotL_warp(lua_State* L);
static int pilotL_broadcast(lua_State* L);
+static int pilotL_setFaction(lua_State* L);
static const luaL_reg pilotL_methods[] = {
{ "__eq", pilotL_eq },
{ "name", pilotL_name },
@@ -44,6 +45,7 @@ static const luaL_reg pilotL_methods[] = {
{ "pos", pilotL_position },
{ "warp", pilotL_warp },
{ "broadcast", pilotL_broadcast },
+ { "setFaction", pilotL_setFaction },
{ 0, 0 }
}; /**< Pilot metatable methods. */
@@ -508,3 +510,30 @@ static int pilotL_broadcast(lua_State* L) {
return 0;
}
+/**
+ * @fn
+ */
+static int pilotL_setFaction(lua_State* L) {
+ LLUA_MIN_ARGS(2);
+ Pilot* p;
+ LuaPilot* lp;
+ int fid;
+ char* faction;
+
+ /* Parse parameters. */
+ lp = lua_topilot(L, 1);
+ if(lua_isstring(L, 2))
+ faction = (char*)lua_tostring(L,2);
+ else LLUA_INVALID_PARAMETER();
+
+ /* Get pilot/faction. */
+ p = pilot_get(lp->pilot);
+ if(p == NULL) return 0;
+ fid = faction_get(faction);
+
+ /* Set the new faction. */
+ p->faction = fid;
+
+ return 0;
+}
+