From a867e1184ee229e317a38c551f6281e95b3cdcbd Mon Sep 17 00:00:00 2001
From: Allanis <allanis@saracraft.net>
Date: Mon, 21 Jul 2014 17:51:37 +0100
Subject: [PATCH] [Add] Mark enemies as hostile in patrol missions.

---
 dat/missions/dvaered/dv_patrol.lua |  1 +
 src/llua_pilot.c                   | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/dat/missions/dvaered/dv_patrol.lua b/dat/missions/dvaered/dv_patrol.lua
index 3cc4477..efceed0 100644
--- a/dat/missions/dvaered/dv_patrol.lua
+++ b/dat/missions/dvaered/dv_patrol.lua
@@ -114,6 +114,7 @@ function setNextGoal()
 
     -- Set hooks.
     for k,v in ipairs(enemies) do
+      v:setHostile() -- Should be hostile to player.
       hook.pilot(v, "disable", "death")
       hook.pilot(v, "jump", "death")
     end
diff --git a/src/llua_pilot.c b/src/llua_pilot.c
index a44ffc6..d37eafe 100644
--- a/src/llua_pilot.c
+++ b/src/llua_pilot.c
@@ -47,6 +47,7 @@ static int pilotL_velocity(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 int pilotL_setHostile(lua_State* L);
 static const luaL_reg pilotL_methods[] = {
   { "__eq",       pilotL_eq         },
   { "name",       pilotL_name       },
@@ -57,6 +58,7 @@ static const luaL_reg pilotL_methods[] = {
   { "warp",       pilotL_warp       },
   { "broadcast",  pilotL_broadcast  },
   { "setFaction", pilotL_setFaction },
+  { "setHostile", pilotL_setHosile  },
   { 0, 0 }
 }; /**< Pilot metatable methods. */
 
@@ -634,3 +636,24 @@ static int pilotL_setFaction(lua_State* L) {
   return 0;
 }
 
+/**
+ * @ingroup META_PILOT
+ *
+ * @brief Set the pilot as hostile to player.
+ * @luafunc setHostile()
+ */
+static int pilotL_setHostile() {
+  LuaPilot* lp;
+  Pilot* p;
+
+  /* Get the pilot. */
+  lp = lua_topilot(L, 1);
+  p = pilot_get(lp->pilot);
+  if(p == NULL) return 0;
+
+  /* Set as hostile. */
+  pilot_setHostile(p);
+
+  return 0;
+}
+