Skip to content

Commit

Permalink
Add internal action type "Gain Veterancy"
Browse files Browse the repository at this point in the history
See osdn #48000

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
  • Loading branch information
cazfi committed May 12, 2023
1 parent b023311 commit dc2a4b9
Show file tree
Hide file tree
Showing 15 changed files with 120 additions and 18 deletions.
16 changes: 16 additions & 0 deletions common/actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -1465,6 +1465,10 @@ static void hard_code_actions(void)
unit_action_new(ACTION_TELEPORT, ACTRES_TELEPORT,
TRUE, TRUE,
MAK_TELEPORT, 1, 1, FALSE);
actions[ACTION_GAIN_VETERANCY] =
unit_action_new(ACTION_GAIN_VETERANCY, ACTRES_ENABLER_CHECK,
TRUE, FALSE,
MAK_STAYS, 0, 0, FALSE);
actions[ACTION_USER_ACTION1] =
unit_action_new(ACTION_USER_ACTION1, ACTRES_NONE,
FALSE, TRUE,
Expand Down Expand Up @@ -6942,6 +6946,9 @@ const char *action_ui_name_ruleset_var_name(int act)
return "ui_name_user_action_3";
case ACTION_USER_ACTION4:
return "ui_name_user_action_4";
case ACTION_GAIN_VETERANCY:
fc_assert(!action_id_is_internal(act)); /* Fail always */
break;
case ACTION_COUNT:
break;
}
Expand Down Expand Up @@ -7264,6 +7271,9 @@ const char *action_ui_name_default(int act)
case ACTION_USER_ACTION4:
/* TRANS: _User Action 4 (100% chance of success). */
return N_("%sUser Action 4%s");
case ACTION_GAIN_VETERANCY:
fc_assert(!action_id_is_internal(act)); /* Fail always */
break;
}

return NULL;
Expand Down Expand Up @@ -7387,6 +7397,7 @@ const char *action_min_range_ruleset_var_name(int act)
case ACTION_UNIT_MOVE2:
case ACTION_UNIT_MOVE3:
case ACTION_SPY_ESCAPE:
case ACTION_GAIN_VETERANCY:
/* Min range is not ruleset changeable */
return NULL;
case ACTION_NUKE:
Expand Down Expand Up @@ -7610,6 +7621,7 @@ const char *action_max_range_ruleset_var_name(int act)
case ACTION_UNIT_MOVE2:
case ACTION_UNIT_MOVE3:
case ACTION_SPY_ESCAPE:
case ACTION_GAIN_VETERANCY:
/* Max range is not ruleset changeable */
return NULL;
case ACTION_HELP_WONDER:
Expand Down Expand Up @@ -7859,6 +7871,7 @@ const char *action_target_kind_ruleset_var_name(int act)
case ACTION_UNIT_MOVE3:
case ACTION_TELEPORT:
case ACTION_SPY_ESCAPE:
case ACTION_GAIN_VETERANCY:
/* Target kind is not ruleset changeable */
return NULL;
case ACTION_NUKE:
Expand Down Expand Up @@ -8295,6 +8308,7 @@ const char *action_actor_consuming_always_ruleset_var_name(action_id act)
case ACTION_UNIT_MOVE2:
case ACTION_UNIT_MOVE3:
case ACTION_TELEPORT:
case ACTION_GAIN_VETERANCY:
case ACTION_SPY_ESCAPE:
/* Actor consuming always is not ruleset changeable */
return NULL;
Expand Down Expand Up @@ -8468,6 +8482,7 @@ const char *action_blocked_by_ruleset_var_name(const struct action *act)
case ACTION_HUT_FRIGHTEN2:
case ACTION_HUT_FRIGHTEN3:
case ACTION_HUT_FRIGHTEN4:
case ACTION_GAIN_VETERANCY:
case ACTION_USER_ACTION1:
case ACTION_USER_ACTION2:
case ACTION_USER_ACTION3:
Expand Down Expand Up @@ -8614,6 +8629,7 @@ action_post_success_forced_ruleset_var_name(const struct action *act)
case ACTION_UNIT_MOVE2:
case ACTION_UNIT_MOVE3:
case ACTION_TELEPORT:
case ACTION_GAIN_VETERANCY:
case ACTION_SPY_ESCAPE:
case ACTION_USER_ACTION1:
case ACTION_USER_ACTION2:
Expand Down
20 changes: 12 additions & 8 deletions common/actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,19 @@ const char *gen_action_name_update_cb(const char *old_name);
#define SPECENUM_VALUE112 ACTION_TELEPORT
#define SPECENUM_VALUE112NAME "Teleport"

/* Enabler checks only */
#define SPECENUM_VALUE113 ACTION_GAIN_VETERANCY
#define SPECENUM_VALUE113NAME "Gain Veterancy"

/* User actions */
#define SPECENUM_VALUE113 ACTION_USER_ACTION1
#define SPECENUM_VALUE113NAME "User Action 1"
#define SPECENUM_VALUE114 ACTION_USER_ACTION2
#define SPECENUM_VALUE114NAME "User Action 2"
#define SPECENUM_VALUE115 ACTION_USER_ACTION3
#define SPECENUM_VALUE115NAME "User Action 3"
#define SPECENUM_VALUE116 ACTION_USER_ACTION4
#define SPECENUM_VALUE116NAME "User Action 4"
#define SPECENUM_VALUE114 ACTION_USER_ACTION1
#define SPECENUM_VALUE114NAME "User Action 1"
#define SPECENUM_VALUE115 ACTION_USER_ACTION2
#define SPECENUM_VALUE115NAME "User Action 2"
#define SPECENUM_VALUE116 ACTION_USER_ACTION3
#define SPECENUM_VALUE116NAME "User Action 3"
#define SPECENUM_VALUE117 ACTION_USER_ACTION4
#define SPECENUM_VALUE117NAME "User Action 4"
#define SPECENUM_BITVECTOR bv_actions
#define SPECENUM_COUNT ACTION_COUNT
#define SPECENUM_NAME_UPDATER
Expand Down
7 changes: 7 additions & 0 deletions data/alien/actions.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -1025,3 +1025,10 @@ actor_reqs =
"UnitState", "OnNativeTile", "Local", FALSE
"CityTile", "Center", "Tile", FALSE
}

[actionenabler_gain_veterancy]
action = "Gain Veterancy"
actor_reqs =
{ "type", "name", "range", "present"
"UnitFlag", "NoVeteran", "Local", FALSE
}
13 changes: 10 additions & 3 deletions data/civ1/actions.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -804,8 +804,15 @@ actor_reqs =
[actionenabler_hut_enter_from_transport]
action = "Enter Hut 2"
actor_reqs =
{ "type", "name", "range", "present"
"MinMoveFrags", "1", "Local", TRUE
"UnitState", "Transported", "Local", TRUE
{ "type", "name", "range", "present"
"MinMoveFrags", "1", "Local", TRUE
"UnitState", "Transported", "Local", TRUE
"UnitClassFlag", "HutNothing", "Local", FALSE
}

[actionenabler_gain_veterancy]
action = "Gain Veterancy"
actor_reqs =
{ "type", "name", "range", "present"
"UnitFlag", "NoVeteran", "Local", FALSE
}
11 changes: 9 additions & 2 deletions data/civ2/actions.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,14 @@ actor_reqs =
[actionenabler_hut_frighten]
action = "Frighten Hut"
actor_reqs =
{ "type", "name", "range"
"MinMoveFrags", "1", "Local"
{ "type", "name", "range"
"MinMoveFrags", "1", "Local"
"UnitClassFlag", "HutFrighten", "Local"
}

[actionenabler_gain_veterancy]
action = "Gain Veterancy"
actor_reqs =
{ "type", "name", "range", "present"
"UnitFlag", "NoVeteran", "Local", FALSE
}
7 changes: 7 additions & 0 deletions data/civ2civ3/actions.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -1471,3 +1471,10 @@ actor_reqs =
"CityTile", "Center", "Tile", FALSE
"UnitClassFlag", "HutFrighten", "Local", TRUE
}

[actionenabler_gain_veterancy]
action = "Gain Veterancy"
actor_reqs =
{ "type", "name", "range", "present"
"UnitFlag", "NoVeteran", "Local", FALSE
}
7 changes: 7 additions & 0 deletions data/classic/actions.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -1341,3 +1341,10 @@ target_reqs =
{ "type", "name", "range", "present"
"CityTile", "Extras Owned", "Tile", FALSE
}

[actionenabler_gain_veterancy]
action = "Gain Veterancy"
actor_reqs =
{ "type", "name", "range", "present"
"UnitFlag", "NoVeteran", "Local", FALSE
}
7 changes: 7 additions & 0 deletions data/goldkeep/actions.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -1408,3 +1408,10 @@ target_reqs =
{ "type", "name", "range", "present"
"CityTile", "Extras Owned", "Tile", FALSE
}

[actionenabler_gain_veterancy]
action = "Gain Veterancy"
actor_reqs =
{ "type", "name", "range", "present"
"UnitFlag", "NoVeteran", "Local", FALSE
}
7 changes: 7 additions & 0 deletions data/granularity/actions.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -334,3 +334,10 @@ actor_reqs =
"MinMoveFrags", "5", "Local", TRUE
"UnitState", "Transported", "Local", FALSE
}

[actionenabler_gain_veterancy]
action = "Gain Veterancy"
actor_reqs =
{ "type", "name", "range", "present"
"UnitFlag", "NoVeteran", "Local", FALSE
}
13 changes: 10 additions & 3 deletions data/multiplayer/actions.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -1321,11 +1321,18 @@ target_reqs =
[actionenabler_claim_extra_unowned_from_non_native]
action = "Conquer Extras 2"
actor_reqs =
{ "type", "name", "range", "present"
"MinMoveFrags", "1", "Local", TRUE
"UnitState", "OnNativeTile", "Local", FALSE
{ "type", "name", "range", "present"
"MinMoveFrags", "1", "Local", TRUE
"UnitState", "OnNativeTile", "Local", FALSE
}
target_reqs =
{ "type", "name", "range", "present"
"CityTile", "Extras Owned", "Tile", FALSE
}

[actionenabler_gain_veterancy]
action = "Gain Veterancy"
actor_reqs =
{ "type", "name", "range", "present"
"UnitFlag", "NoVeteran", "Local", FALSE
}
7 changes: 7 additions & 0 deletions data/sandbox/actions.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -2805,3 +2805,10 @@ actor_reqs =
"CityTile", "Center", "Tile", FALSE
"UnitClassFlag", "HutFrighten", "Local", TRUE
}

[actionenabler_gain_veterancy]
action = "Gain Veterancy"
actor_reqs =
{ "type", "name", "range", "present"
"UnitFlag", "NoVeteran", "Local", FALSE
}
7 changes: 7 additions & 0 deletions data/webperimental/actions.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -1590,3 +1590,10 @@ target_reqs =
{ "type", "name", "range", "present"
"CityTile", "Extras Owned", "Tile", FALSE
}

[actionenabler_gain_veterancy]
action = "Gain Veterancy"
actor_reqs =
{ "type", "name", "range", "present"
"UnitFlag", "NoVeteran", "Local", FALSE
}
12 changes: 12 additions & 0 deletions doc/README.actions
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ Should the player order a unit to do an illegal action the server will
inform the player that their unit was unable to perform the action. The
actor unit may also lose a ruleset configurable amount of move fragments.

Some action enablers guard things that user is not able to initiate,
but which will happen automatically. These are listed as
'internal' actions.


Example
=======
[actionenabler_veil_the_threat_of_terror]
Expand Down Expand Up @@ -1503,6 +1508,13 @@ Actions done by a unit to it self
* UI name can be set using ui_name_homeless
* the actor unit must have a home city. (!)

Internal actions
================

"Gain Veterancy" - unit can get new veterancy levels
* Unit's veterancy system must have veterancy levels for the unit
to advance to.

Ruleset defined actions
=======================
User actions are "blank". The ruleset does everything they do. The following
Expand Down
2 changes: 1 addition & 1 deletion fc_version
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ DEFAULT_FOLLOW_TAG=S3_3
# On FREECIV_DEBUG builds, optional capability "debug" gets automatically
# appended to this.
#
NETWORK_CAPSTRING="+Freeciv.Devel-${MAIN_VERSION}-2023.May.10"
NETWORK_CAPSTRING="+Freeciv.Devel-${MAIN_VERSION}-2023.May.12"
FREECIV_DISTRIBUTOR=""

if test "x$FREECIV_LABEL_FORCE" != "x" ; then
Expand Down
2 changes: 1 addition & 1 deletion server/unittools.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ static bool maybe_become_veteran_real(struct unit *punit, int base_chance,
fc_assert_ret_val(vlevel != NULL, FALSE);

if (punit->veteran + 1 >= vsystem->levels
|| unit_has_type_flag(punit, UTYF_NO_VETERAN)) {
|| !is_action_enabled_unit_on_self(ACTION_GAIN_VETERANCY, punit)) {
return FALSE;
} else if (!settler) {
int mod = base_chance + get_unit_bonus(punit, EFT_VETERAN_COMBAT);
Expand Down

0 comments on commit dc2a4b9

Please sign in to comment.