From 0d73fe8aabb00c18396d5306cbbec500edd284f8 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Tue, 20 Oct 2026 20:00:16 +0300
Subject: [PATCH 90/90] Add select_actres_action_unit_on_unit()

See RM #2394

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 common/actions.c | 24 ++++++++++++++++++++++++
 common/actions.h |  4 ++++
 2 files changed, 28 insertions(+)

diff --git a/common/actions.c b/common/actions.c
index 1c1fb466c2..3bb881f8be 100644
--- a/common/actions.c
+++ b/common/actions.c
@@ -7647,3 +7647,27 @@ enum gen_action select_actres_action_unit_on_city(struct civ_map *nmap,
 
   return ACTION_NONE;
 }
+
+/************************************************************************//**
+  Can unit do any action with the given action result to unit?
+  Returns one of the possible actions, or ACTION_NONE.
+****************************************************************************/
+enum gen_action select_actres_action_unit_on_unit(struct civ_map *nmap,
+                                                  enum action_result actres,
+                                                  struct unit *punit,
+                                                  struct unit *target)
+{
+  if (actres >= ACTRES_LAST) {
+    return ACTION_NONE;
+  }
+
+  action_list_iterate(action_list_by_result(actres), paction) {
+    enum gen_action act = action_number(paction);
+
+    if (is_action_enabled_unit_on_unit(nmap, act, punit, target)) {
+      return act;
+    }
+  } action_list_iterate_end;
+
+  return ACTION_NONE;
+}
diff --git a/common/actions.h b/common/actions.h
index 05a7ca76b4..6bcda3b5ef 100644
--- a/common/actions.h
+++ b/common/actions.h
@@ -783,6 +783,10 @@ enum gen_action select_actres_action_unit_on_city(struct civ_map *nmap,
                                                   enum action_result actres,
                                                   struct unit *punit,
                                                   struct city *pcity);
+enum gen_action select_actres_action_unit_on_unit(struct civ_map *nmap,
+                                                  enum action_result actres,
+                                                  struct unit *punit,
+                                                  struct unit *target);
 
 #ifdef __cplusplus
 }
-- 
2.53.0

