From 0f70a0e439635a6e1d6eb06a27f6fd1cbf1ba58b Mon Sep 17 00:00:00 2001 From: Sveinung Kvilhaugsvik Date: Tue, 23 Feb 2021 16:18:12 +0100 Subject: [PATCH] "Attack" move cost to the ruleset. Move the move cost of non OneAttack attacks to the ruleset too. See osdn #41646 --- common/unittype.c | 5 ----- data/alien/effects.ruleset | 8 ++++++++ data/civ1/effects.ruleset | 9 +++++++++ data/civ2/effects.ruleset | 9 +++++++++ data/civ2civ3/effects.ruleset | 9 +++++++++ data/classic/effects.ruleset | 9 +++++++++ data/experimental/effects.ruleset | 9 +++++++++ data/multiplayer/effects.ruleset | 9 +++++++++ data/sandbox/effects.ruleset | 9 +++++++++ data/webperimental/effects.ruleset | 9 +++++++++ server/rscompat.c | 18 ++++++++++++++++++ 11 files changed, 98 insertions(+), 5 deletions(-) diff --git a/common/unittype.c b/common/unittype.c index a3fc8f2fbf..479eab8248 100644 --- a/common/unittype.c +++ b/common/unittype.c @@ -1285,11 +1285,6 @@ int utype_pays_mp_for_action_base(const struct action *paction, { int mpco = 0; - if (action_has_result(paction, ACTRES_ATTACK) - && !utype_is_consumed_by_action(paction, putype)) { - mpco += SINGLE_MOVE; - } - return mpco; } diff --git a/data/alien/effects.ruleset b/data/alien/effects.ruleset index 3161d2b51f..1c2496018d 100644 --- a/data/alien/effects.ruleset +++ b/data/alien/effects.ruleset @@ -1037,6 +1037,14 @@ reqs = "Action", "Bombard", "Local", TRUE } +[effect_action_success_move_cost_attack] +type = "Action_Success_Actor_Move_Cost" +value = 4 +reqs = + { "type", "name", "range", "present" + "Action", "Attack", "Local", TRUE + } + [effect_action_success_move_cost_paradrop] type = "Action_Success_Actor_Move_Cost" value = 4 diff --git a/data/civ1/effects.ruleset b/data/civ1/effects.ruleset index 8eb14ad2c8..4b6fc2dd45 100644 --- a/data/civ1/effects.ruleset +++ b/data/civ1/effects.ruleset @@ -1497,6 +1497,15 @@ reqs = "UnitFlag", "OneAttack", "Local", TRUE } +[effect_action_success_attack_normal] +type = "Action_Success_Actor_Move_Cost" +value = 3 +reqs = + { "type", "name", "range", "present" + "Action", "Attack", "Local", TRUE + "UnitFlag", "OneAttack", "Local", FALSE + } + [effect_unit_shield_value_recycle] type = "Unit_Shield_Value_Pct" value = -50 diff --git a/data/civ2/effects.ruleset b/data/civ2/effects.ruleset index 6d9b57c8ca..62fdc9a6cc 100644 --- a/data/civ2/effects.ruleset +++ b/data/civ2/effects.ruleset @@ -2575,6 +2575,15 @@ reqs = "UnitFlag", "OneAttack", "Local", TRUE } +[effect_action_success_attack_normal] +type = "Action_Success_Actor_Move_Cost" +value = 3 +reqs = + { "type", "name", "range", "present" + "Action", "Attack", "Local", TRUE + "UnitFlag", "OneAttack", "Local", FALSE + } + [effect_unit_shield_value_recycle] type = "Unit_Shield_Value_Pct" value = -50 diff --git a/data/civ2civ3/effects.ruleset b/data/civ2civ3/effects.ruleset index cfb63f7d67..d7838b2b3c 100644 --- a/data/civ2civ3/effects.ruleset +++ b/data/civ2civ3/effects.ruleset @@ -4374,6 +4374,15 @@ reqs = "UnitFlag", "OneAttack", "Local", TRUE } +[effect_action_success_attack_normal] +type = "Action_Success_Actor_Move_Cost" +value = 6 +reqs = + { "type", "name", "range", "present" + "Action", "Attack", "Local", TRUE + "UnitFlag", "OneAttack", "Local", FALSE + } + [effect_unit_shield_value_recycle] type = "Unit_Shield_Value_Pct" value = -50 diff --git a/data/classic/effects.ruleset b/data/classic/effects.ruleset index 7093486473..cf3d65d094 100644 --- a/data/classic/effects.ruleset +++ b/data/classic/effects.ruleset @@ -2640,6 +2640,15 @@ reqs = "UnitFlag", "OneAttack", "Local", TRUE } +[effect_action_success_attack_normal] +type = "Action_Success_Actor_Move_Cost" +value = 3 +reqs = + { "type", "name", "range", "present" + "Action", "Attack", "Local", TRUE + "UnitFlag", "OneAttack", "Local", FALSE + } + [effect_unit_shield_value_recycle] type = "Unit_Shield_Value_Pct" value = -50 diff --git a/data/experimental/effects.ruleset b/data/experimental/effects.ruleset index 78ad774f2f..aa8bbf3a85 100644 --- a/data/experimental/effects.ruleset +++ b/data/experimental/effects.ruleset @@ -2953,6 +2953,15 @@ reqs = "UnitFlag", "OneAttack", "Local", TRUE } +[effect_action_success_attack_normal] +type = "Action_Success_Actor_Move_Cost" +value = 9 +reqs = + { "type", "name", "range", "present" + "Action", "Attack", "Local", TRUE + "UnitFlag", "OneAttack", "Local", FALSE + } + [effect_action_success_establish_embassy] type="Action_Success_Actor_Move_Cost" value=65535 diff --git a/data/multiplayer/effects.ruleset b/data/multiplayer/effects.ruleset index b7d2ff0fb9..4fb7483f5a 100644 --- a/data/multiplayer/effects.ruleset +++ b/data/multiplayer/effects.ruleset @@ -2597,6 +2597,15 @@ reqs = "UnitFlag", "OneAttack", "Local", TRUE } +[effect_action_success_attack_normal] +type = "Action_Success_Actor_Move_Cost" +value = 3 +reqs = + { "type", "name", "range", "present" + "Action", "Attack", "Local", TRUE + "UnitFlag", "OneAttack", "Local", FALSE + } + [effect_action_success_establish_embassy] type="Action_Success_Actor_Move_Cost" value=65535 diff --git a/data/sandbox/effects.ruleset b/data/sandbox/effects.ruleset index 0baffbfd25..a84361589a 100644 --- a/data/sandbox/effects.ruleset +++ b/data/sandbox/effects.ruleset @@ -4577,6 +4577,15 @@ reqs = "UnitFlag", "OneAttack", "Local", TRUE } +[effect_action_success_attack_normal] +type = "Action_Success_Actor_Move_Cost" +value = 6 +reqs = + { "type", "name", "range", "present" + "Action", "Attack", "Local", TRUE + "UnitFlag", "OneAttack", "Local", FALSE + } + ; The treasury is better guarded than the drinking water ; See "Poison City Escape" [effect_steal_gold_escape_lower_chance] diff --git a/data/webperimental/effects.ruleset b/data/webperimental/effects.ruleset index bd36b2dbf9..7cf2fb28a0 100644 --- a/data/webperimental/effects.ruleset +++ b/data/webperimental/effects.ruleset @@ -2897,6 +2897,15 @@ reqs = "UnitFlag", "OneAttack", "Local", TRUE } +[effect_action_success_attack_normal] +type = "Action_Success_Actor_Move_Cost" +value = 3 +reqs = + { "type", "name", "range", "present" + "Action", "Attack", "Local", TRUE + "UnitFlag", "OneAttack", "Local", FALSE + } + [effect_strike_half_chance] type = "Action_Odds_Pct" value = -50 diff --git a/server/rscompat.c b/server/rscompat.c index 0c31221056..0fa1a8c753 100644 --- a/server/rscompat.c +++ b/server/rscompat.c @@ -721,6 +721,24 @@ void rscompat_postprocess(struct rscompat_info *info) effect_req_append(peffect, req_from_str("UnitFlag", "Local", FALSE, TRUE, TRUE, "OneAttack")); + action_by_result_iterate(paction, act_id, ACTRES_ATTACK) { + if (paction->actor_consuming_always) { + /* Not relevant. */ + continue; + } + + peffect = effect_new(EFT_ACTION_SUCCESS_MOVE_COST, + SINGLE_MOVE, NULL); + /* The reduction only applies to this action. */ + effect_req_append(peffect, req_from_str("Action", "Local", + FALSE, TRUE, TRUE, + action_rule_name(paction))); + /* The reduction doesn't apply to "OneAttack". */ + effect_req_append(peffect, req_from_str("UnitFlag", "Local", + FALSE, FALSE, TRUE, + "OneAttack")); + } action_by_result_iterate_end; + /* Post successful action move fragment loss for spy post action escape * has moved to the ruleset. */ action_iterate(act_id) { -- 2.20.1