From b6e7b93e25b74ab801509de9476644c1690153fe Mon Sep 17 00:00:00 2001 From: Sveinung Kvilhaugsvik Date: Thu, 18 Feb 2021 14:40:43 +0100 Subject: [PATCH] Fake generalize "Heal Unit" This allows two differently named versions. Say one version for a Medic unit and one for a Mechanic unit. See osdn #41602 --- client/gui-qt/dialogs.cpp | 13 +++++++++++++ client/packhand.c | 1 + common/actions.c | 15 +++++++++++++++ common/actions.h | 2 ++ doc/README.actions | 6 ++++++ 5 files changed, 37 insertions(+) diff --git a/client/gui-qt/dialogs.cpp b/client/gui-qt/dialogs.cpp index 5e7db3bf81..c2991957f5 100644 --- a/client/gui-qt/dialogs.cpp +++ b/client/gui-qt/dialogs.cpp @@ -149,6 +149,7 @@ static void conquer_city2(QVariant data1, QVariant data2); static void conquer_extras(QVariant data1, QVariant data2); static void conquer_extras2(QVariant data1, QVariant data2); static void heal_unit(QVariant data1, QVariant data2); +static void heal_unit2(QVariant data1, QVariant data2); static void transport_board(QVariant data1, QVariant data2); static void transport_embark(QVariant data1, QVariant data2); static void transport_alight(QVariant data1, QVariant data2); @@ -231,6 +232,7 @@ static const QHash af_map_init(void) action_function[ACTION_SPY_SABOTAGE_UNIT_ESC] = spy_sabotage_unit_esc; action_function[ACTION_EXPEL_UNIT] = expel_unit; action_function[ACTION_HEAL_UNIT] = heal_unit; + action_function[ACTION_HEAL_UNIT2] = heal_unit2; action_function[ACTION_TRANSPORT_ALIGHT] = transport_alight; action_function[ACTION_TRANSPORT_UNLOAD] = transport_unload; action_function[ACTION_TRANSPORT_BOARD] = transport_board; @@ -2406,6 +2408,17 @@ static void heal_unit(QVariant data1, QVariant data2) request_do_action(ACTION_HEAL_UNIT, actor_id, target_id, 0, ""); } +/***********************************************************************//** + Action "Heal Unit 2" for choice dialog +***************************************************************************/ +static void heal_unit2(QVariant data1, QVariant data2) +{ + int actor_id = data1.toInt(); + int target_id = data2.toInt(); + + request_do_action(ACTION_HEAL_UNIT2, actor_id, target_id, 0, ""); +} + /***********************************************************************//** Action "Transport Board" for choice dialog ***************************************************************************/ diff --git a/client/packhand.c b/client/packhand.c index 586cb7e846..840f13af33 100644 --- a/client/packhand.c +++ b/client/packhand.c @@ -4833,6 +4833,7 @@ static action_id auto_attack_act(const struct act_prob *act_probs) case ACTION_PARADROP: case ACTION_AIRLIFT: case ACTION_HEAL_UNIT: + case ACTION_HEAL_UNIT2: case ACTION_TRANSFORM_TERRAIN: case ACTION_CULTIVATE: case ACTION_PLANT: diff --git a/common/actions.c b/common/actions.c index 62e947126b..fa60da5072 100644 --- a/common/actions.c +++ b/common/actions.c @@ -1023,6 +1023,10 @@ static void hard_code_actions(void) unit_action_new(ACTION_HEAL_UNIT, ACTRES_HEAL_UNIT, FALSE, TRUE, MAK_STAYS, 0, 1, FALSE); + actions[ACTION_HEAL_UNIT2] = + unit_action_new(ACTION_HEAL_UNIT2, ACTRES_HEAL_UNIT, + FALSE, TRUE, + MAK_STAYS, 0, 1, FALSE); actions[ACTION_TRANSFORM_TERRAIN] = unit_action_new(ACTION_TRANSFORM_TERRAIN, ACTRES_TRANSFORM_TERRAIN, TRUE, FALSE, @@ -6797,6 +6801,8 @@ const char *action_ui_name_ruleset_var_name(int act) return "ui_name_conquer_extras_2"; case ACTION_HEAL_UNIT: return "ui_name_heal_unit"; + case ACTION_HEAL_UNIT2: + return "ui_name_heal_unit_2"; case ACTION_TRANSFORM_TERRAIN: return "ui_name_transform_terrain"; case ACTION_CULTIVATE: @@ -7035,6 +7041,7 @@ const char *action_ui_name_default(int act) /* TRANS: _Conquer Extras 2 (100% chance of success). */ return N_("%sConquer Extras 2%s"); case ACTION_HEAL_UNIT: + case ACTION_HEAL_UNIT2: /* TRANS: Heal _Unit (3% chance of success). */ return N_("Heal %sUnit%s"); case ACTION_TRANSFORM_TERRAIN: @@ -7179,6 +7186,7 @@ const char *action_min_range_ruleset_var_name(int act) case ACTION_CONQUER_CITY: case ACTION_CONQUER_CITY2: case ACTION_HEAL_UNIT: + case ACTION_HEAL_UNIT2: case ACTION_TRANSFORM_TERRAIN: case ACTION_CULTIVATE: case ACTION_PLANT: @@ -7282,6 +7290,7 @@ int action_min_range_default(int act) case ACTION_CONQUER_CITY: case ACTION_CONQUER_CITY2: case ACTION_HEAL_UNIT: + case ACTION_HEAL_UNIT2: case ACTION_TRANSFORM_TERRAIN: case ACTION_CULTIVATE: case ACTION_PLANT: @@ -7382,6 +7391,7 @@ const char *action_max_range_ruleset_var_name(int act) case ACTION_CONQUER_CITY: case ACTION_CONQUER_CITY2: case ACTION_HEAL_UNIT: + case ACTION_HEAL_UNIT2: case ACTION_TRANSFORM_TERRAIN: case ACTION_CULTIVATE: case ACTION_PLANT: @@ -7494,6 +7504,7 @@ int action_max_range_default(int act) case ACTION_CONQUER_CITY: case ACTION_CONQUER_CITY2: case ACTION_HEAL_UNIT: + case ACTION_HEAL_UNIT2: case ACTION_TRANSFORM_TERRAIN: case ACTION_CULTIVATE: case ACTION_PLANT: @@ -7608,6 +7619,7 @@ const char *action_target_kind_ruleset_var_name(int act) case ACTION_CONQUER_CITY: case ACTION_CONQUER_CITY2: case ACTION_HEAL_UNIT: + case ACTION_HEAL_UNIT2: case ACTION_TRANSFORM_TERRAIN: case ACTION_CULTIVATE: case ACTION_PLANT: @@ -8083,6 +8095,7 @@ const char *action_actor_consuming_always_ruleset_var_name(action_id act) case ACTION_CONQUER_CITY: case ACTION_CONQUER_CITY2: case ACTION_HEAL_UNIT: + case ACTION_HEAL_UNIT2: case ACTION_TRANSFORM_TERRAIN: case ACTION_CULTIVATE: case ACTION_PLANT: @@ -8210,6 +8223,7 @@ const char *action_blocked_by_ruleset_var_name(const struct action *act) case ACTION_STRIKE_BUILDING: case ACTION_STRIKE_PRODUCTION: case ACTION_HEAL_UNIT: + case ACTION_HEAL_UNIT2: case ACTION_TRANSFORM_TERRAIN: case ACTION_CULTIVATE: case ACTION_PLANT: @@ -8321,6 +8335,7 @@ action_post_success_forced_ruleset_var_name(const struct action *act) case ACTION_STRIKE_BUILDING: case ACTION_STRIKE_PRODUCTION: case ACTION_HEAL_UNIT: + case ACTION_HEAL_UNIT2: case ACTION_TRANSFORM_TERRAIN: case ACTION_CULTIVATE: case ACTION_PLANT: diff --git a/common/actions.h b/common/actions.h index b4ce4e6a29..8696dfb51f 100644 --- a/common/actions.h +++ b/common/actions.h @@ -232,6 +232,8 @@ extern "C" { #define SPECENUM_VALUE82NAME "User Action 2" #define SPECENUM_VALUE83 ACTION_USER_ACTION3 #define SPECENUM_VALUE83NAME "User Action 3" +#define SPECENUM_VALUE84 ACTION_HEAL_UNIT2 +#define SPECENUM_VALUE84NAME "Heal Unit 2" #define SPECENUM_BITVECTOR bv_actions #define SPECENUM_COUNT ACTION_COUNT #include "specenum_gen.h" diff --git a/doc/README.actions b/doc/README.actions index e90ae3053e..b1961ecca8 100644 --- a/doc/README.actions +++ b/doc/README.actions @@ -583,6 +583,12 @@ Actions done by a unit against another unit * actor must be on the same tile as the target or on the tile next to it. * target must be visible for the actor. +"Heal Unit 2" - Restore the target unit's health. + * UI name can be set using ui_name_heal_unit_2 + * actor must be on the same tile as the target or on the tile next to it. + * target must be visible for the actor. + * A copy of "Heal Unit" + "Transport Alight" - Exit target transport to same tile. * UI name can be set using ui_name_transport_alight * actor must be on the same tile as the target -- 2.20.1