Freeciv-3.2
|
#include <math.h>
#include <stdarg.h>
#include "astring.h"
#include "actions.h"
#include "city.h"
#include "combat.h"
#include "fc_interface.h"
#include "game.h"
#include "map.h"
#include "metaknowledge.h"
#include "movement.h"
#include "nation.h"
#include "research.h"
#include "server_settings.h"
#include "unit.h"
#include "specvec.h"
Go to the source code of this file.
Data Structures | |
struct | action_enabler_contradiction |
struct | ae_contra_or |
struct | obligatory_req |
#define ACTPROB_VAL_1_PCT (ACTPROB_VAL_MAX / 100) |
#define obligatory_req_vector_iterate | ( | obreq_vec, | |
pobreq | |||
) | TYPED_VECTOR_ITERATE(struct obligatory_req, obreq_vec, pobreq) |
#define obligatory_req_vector_iterate_end VECTOR_ITERATE_END |
#define SPECVEC_TAG obligatory_req |
#define SPECVEC_TYPE struct obligatory_req |
|
static |
Returns the action probability for when a target is unseen.
Definition at line 4466 of file actions.c.
Referenced by action_prob_vs_city_full(), and action_prob_vs_stack_full().
Return actor consuming always ruleset variable name for the action or NULL if actor consuming always can't be set in the ruleset.
TODO: make actions generic and put actor consuming always in a field of the action.
Definition at line 7600 of file actions.c.
Referenced by load_action_actor_consuming_always(), and save_action_actor_consuming_always().
bool action_actor_utype_hard_reqs_ok | ( | const struct action * | paction, |
const struct unit_type * | actor_unittype | ||
) |
Returns TRUE if the specified unit type can perform the specified action given that an action enabler later will enable it.
This is done by checking the action result's hard requirements. Hard requirements must be TRUE before an action can be done. The reason why is usually that code dealing with the action assumes that the requirements are true. A requirement may also end up here if it can't be expressed in a requirement vector or if its absence makes the action pointless.
paction | the action to check the hard reqs for |
actor_unittype | the unit type that may be able to act |
Definition at line 3356 of file actions.c.
Referenced by action_enabler_suggest_improvement(), action_enabler_utype_possible_actor(), action_has_possible_actor_hard_reqs(), expl_act_not_enabl(), and unit_can_act_cache_set().
|
static |
Returns TRUE if the specified unit type can perform the specified action given that an action enabler later will enable it.
This is done by checking the action result's hard requirements. Hard requirements must be TRUE before an action can be done. The reason why is usually that code dealing with the action assumes that the requirements are true. A requirement may also end up here if it can't be expressed in a requirement vector or if its absence makes the action pointless.
When adding a new hard requirement here: explain why it is a hard requirement in a comment.
paction | the action to check the hard reqs for |
actor_unittype | the unit type that may be able to act |
ignore_third_party | ignore if potential targets etc exists |
Definition at line 3149 of file actions.c.
Referenced by action_actor_utype_hard_reqs_ok(), and action_hard_reqs_actor().
void action_array_add_all_by_result | ( | action_id * | act_array, |
int * | position, | ||
enum action_result | result | ||
) |
Add all actions with the specified result to the specified action array starting at the specified position.
act_array | the array to add the actions to |
position | index in act_array that is updated as action are added |
result | all actions with this result are added. |
Definition at line 6486 of file actions.c.
Referenced by adv_data_phase_init(), auto_settlers_ruleset_init(), dai_upgrade_units(), and helptext_building().
Terminate an action array of the specified size.
act_array | the array to end |
size | the number of elements to include in the list |
Definition at line 6469 of file actions.c.
Referenced by adv_data_phase_init(), auto_settlers_ruleset_init(), dai_upgrade_units(), helptext_building(), and save_action_auto_actions().
const struct action_auto_perf * action_auto_perf_by_number | ( | const int | num | ) |
Returns action auto performer rule number num.
Used in action_auto_perf_iterate()
WARNING: If the cause of the returned action performer rule is AAPC_COUNT it means that it is unused.
Definition at line 6437 of file actions.c.
Referenced by save_action_auto_actions(), save_action_auto_uflag_block(), and save_actions_ruleset().
struct action_auto_perf * action_auto_perf_slot_number | ( | const int | num | ) |
Returns action auto performer rule slot number num so it can be filled.
Definition at line 6421 of file actions.c.
Referenced by action_auto_perf_by_number(), handle_ruleset_action_auto(), load_action_post_success_force(), load_ruleset_actions(), load_ruleset_cities(), and sanity_check_ruleset_data().
Return action blocked by ruleset variable name for the action or NULL if actor consuming always can't be set in the ruleset.
TODO: make actions generic and put blocked by actions in a field of the action.
Definition at line 7757 of file actions.c.
Referenced by load_action_blocked_by_list(), and save_action_blocked_by().
Return the action with the given name.
Returns NULL if no action with the given name exists.
Definition at line 1840 of file actions.c.
Referenced by api_find_action_by_name(), api_find_action_type_by_name(), tab_enabler::edit_type(), load_ruleset_actions(), sg_load_savefile(), and universal_value_from_str().
Returns the initial odds of an action not failing its dice roll.
Definition at line 6097 of file actions.c.
Referenced by action_dice_roll_odds(), effect_list_sanity_cb(), and helptext_unit().
int action_dice_roll_odds | ( | const struct player * | act_player, |
const struct unit * | act_unit, | ||
const struct city * | tgt_city, | ||
const struct player * | tgt_player, | ||
const struct action * | paction | ||
) |
Returns the odds of an action not failing its dice roll.
Definition at line 6121 of file actions.c.
Referenced by action_failed_dice_roll(), and action_prob_pre_action_dice_roll().
Returns TRUE iff the specified distance between actor and target is within the range acceptable to the specified action.
Definition at line 1945 of file actions.c.
Referenced by is_action_possible().
Returns TRUE iff the specified distance between actor and target is sm,aller or equal to the max range accepted by the specified action.
Definition at line 1934 of file actions.c.
Referenced by action_distance_accepted(), expl_act_not_enabl(), and sanity_check_ruleset_data().
|
static |
Find out if the action is enabled, may be enabled or isn't enabled given what the player owning the actor knowns.
A player don't always know everything needed to figure out if an action is enabled or not. A server side AI with the same limits on its knowledge as a human player or a client should use this to figure out what is what.
Assumes to be called from the point of view of the actor. Its knowledge is assumed to be given in the parameters.
Returns TRI_YES if the action is enabled, TRI_NO if it isn't and TRI_MAYBE if the player don't know enough to tell.
If meta knowledge is missing TRI_MAYBE will be returned.
target may be NULL. This is equivalent to passing an empty context.
Definition at line 4259 of file actions.c.
Referenced by action_prob().
void action_enabler_add | ( | struct action_enabler * | enabler | ) |
Add an action enabler to the current ruleset.
Definition at line 2282 of file actions.c.
Referenced by tab_enabler::add_now(), tab_enabler::edit_type(), handle_ruleset_action_enabler(), load_ruleset_actions(), rscompat_enabler_add_obligatory_hard_reqs(), and rscompat_postprocess().
struct action_enabler * action_enabler_copy | ( | const struct action_enabler * | original | ) |
Create a new copy of an existing action enabler.
Definition at line 2267 of file actions.c.
Referenced by fix_enabler_item::fix_enabler_item(), rscompat_enabler_add_obligatory_hard_reqs(), and rscompat_postprocess().
void action_enabler_free | ( | struct action_enabler * | enabler | ) |
Free resources allocated for the action enabler.
Definition at line 2255 of file actions.c.
Referenced by actions_free(), and fix_enabler_item::~fix_enabler_item().
struct action_enabler * action_enabler_new | ( | void | ) |
Create a new action enabler.
Definition at line 2236 of file actions.c.
Referenced by action_enabler_copy(), tab_enabler::add_now(), handle_ruleset_action_enabler(), and load_ruleset_actions().
bool action_enabler_possible_actor | ( | const struct action_enabler * | ae | ) |
Returns TRUE iff the specified action enabler may have an actor that it may be enabled for in the current ruleset. An enabler can't be enabled if no potential actor fulfills both its action's hard requirements and its own actor requirement vector, actor_reqs. Note that the answer may be "no" even if this function returns TRUE. It may just be unable to detect it.
ae | the action enabler to check |
Definition at line 6342 of file actions.c.
Referenced by ruleset_purge_unused_enablers().
bool action_enabler_remove | ( | struct action_enabler * | enabler | ) |
Remove an action enabler from the current ruleset.
Returns TRUE on success.
Definition at line 2299 of file actions.c.
Referenced by tab_enabler::edit_type().
struct req_vec_problem * action_enabler_suggest_improvement | ( | const struct action_enabler * | enabler | ) |
Returns a suggestion to improve the specified action enabler or NULL if nothing to improve is found to be needed. It is the responsibility of the caller to free the suggestion when it is done with it. A possible improvement isn't always an error.
enabler | the enabler to improve |
Definition at line 2745 of file actions.c.
Referenced by enabler_problem_level(), fix_enabler_item::find_next_problem(), and sanity_check_ruleset_data().
struct req_vec_problem * action_enabler_suggest_repair | ( | const struct action_enabler * | enabler | ) |
Returns a suggestion to fix the specified action enabler or NULL if no fix is found to be needed. It is the responsibility of the caller to free the suggestion with req_vec_problem_free() when it is done with it.
Definition at line 2679 of file actions.c.
Referenced by action_enabler_suggest_improvement(), enabler_problem_level(), fix_enabler_item::find_next_problem(), rscompat_enabler_add_obligatory_hard_reqs(), and sanity_check_ruleset_data().
struct req_vec_problem * action_enabler_suggest_repair_oblig | ( | const struct action_enabler * | enabler | ) |
Returns a suggestion to add an obligatory hard requirement to an action enabler or NULL if no hard obligatory reqs were missing. It is the responsibility of the caller to free the suggestion when it is done with it.
enabler | the action enabler to suggest a fix for. |
Definition at line 2439 of file actions.c.
Referenced by action_enabler_suggest_repair().
bool action_enabler_utype_possible_actor | ( | const struct action_enabler * | ae, |
const struct unit_type * | act_utype | ||
) |
Returns TRUE iff the specified action enabler may be active for an actor of the specified unit type in the current ruleset. Note that the answer may be "no" even if this function returns TRUE. It may just be unable to detect it.
ae | the action enabler to check |
act_utype | the candidate actor unit type |
Definition at line 6315 of file actions.c.
Referenced by action_enabler_possible_actor().
struct requirement_vector * action_enabler_vector_by_number | ( | const void * | enabler, |
req_vec_num_in_item | number | ||
) |
Returns a writable pointer to the specified requirement vector in the action enabler or NULL if the action enabler doesn't have a requirement vector with that requirement vector number.
enabler | the action enabler that may own the vector. |
number | the item's requirement vector number. |
Definition at line 2832 of file actions.c.
Referenced by rscompat_enabler_add_obligatory_hard_reqs(), and fix_enabler_item::vector_getter().
const char * action_enabler_vector_by_number_name | ( | req_vec_num_in_item | vec | ) |
Returns the name of the given requirement vector number n in an action enabler or NULL if enablers don't have a requirement vector with that number.
vec | the requirement vector to name |
Definition at line 2856 of file actions.c.
Referenced by rscompat_enabler_add_obligatory_hard_reqs(), and fix_enabler_item::vector_namer().
req_vec_num_in_item action_enabler_vector_number | ( | const void * | enabler, |
const struct requirement_vector * | vec | ||
) |
Returns the requirement vector number of the specified requirement vector in the specified action enabler.
enabler | the action enabler that may own the vector. |
vec | the requirement vector to number. |
Definition at line 2809 of file actions.c.
Referenced by action_enabler_suggest_improvement(), action_enabler_suggest_repair(), ae_suggest_repair_if_no_oblig(), enabler_first_self_contradiction(), and enabler_tile_tgt_local_diplrel_implies_claimed().
struct action_enabler_list * action_enablers_for_action | ( | action_id | action | ) |
Get all enablers for an action in the current ruleset.
Definition at line 2315 of file actions.c.
Referenced by action_enabled_local(), action_enabler_add(), action_enabler_remove(), action_ever_possible(), action_immune_government(), action_is_in_use(), action_may_happen_unit_on_city(), action_maybe_possible_actor_unit(), action_univs_not_blocking(), adjust_improvement_wants_by_effects(), city_production_caravan_shields_init(), does_nation_block_action(), does_terrain_block_action(), helptext_building(), helptext_unit(), is_action_enabled(), is_target_possible(), is_universal_needed(), tab_misc::refresh_stats(), rscompat_enablers_add_obligatory_hard_reqs(), ruleset_purge_redundant_reqs_enablers(), ruleset_purge_unused_enablers(), sanity_check_ruleset_data(), utype_may_act_move_frags(), and utype_may_act_tgt_city_tile().
Is the action ever possible? Currently just checks that there's any action enablers for the action.
Definition at line 8092 of file actions.c.
Referenced by create_unit_menu(), dai_upgrade_units(), present_unit_callback(), and units_report_selection_callback().
enum action_actor_kind action_get_actor_kind | ( | const struct action * | paction | ) |
Get the actor kind of an action.
Definition at line 1859 of file actions.c.
Referenced by action_enabler_possible_actor(), action_enabler_suggest_improvement(), action_enabler_utype_possible_actor(), action_get_role(), action_has_possible_actor_hard_reqs(), action_is_blocked_by(), api_edit_perform_action_unit_vs_city(), api_edit_perform_action_unit_vs_city_impr(), api_edit_perform_action_unit_vs_city_tech(), api_edit_perform_action_unit_vs_self(), api_edit_perform_action_unit_vs_tile(), api_edit_perform_action_unit_vs_tile_extra(), api_edit_perform_action_unit_vs_unit(), auto_settlers_speculate_can_act_at(), dai_action_choose_sub_tgt_unit_vs_city(), dai_action_value_unit_vs_city(), dai_diplomat_city(), effect_list_sanity_cb(), local_dipl_rel_action_cache_set(), local_dipl_rel_tile_other_tgt_action_cache_set(), request_action_details_callback(), simple_action_callback(), simple_action_callback(), tgt_citytile_act_cache_set(), unit_can_act_cache_set(), unit_state_action_cache_set(), utype_is_moved_to_tgt_by_action(), utype_is_unmoved_by_action(), and utype_may_do_escape_action().
enum action_sub_target_kind action_get_sub_target_kind | ( | const struct action * | paction | ) |
Get the sub target kind of an action.
Definition at line 1880 of file actions.c.
Referenced by action_sub_target_id_for_action(), go_act_menu::create(), execute_orders(), helptext_unit(), real_menus_init(), real_menus_update(), simple_action_callback(), simple_action_callback(), unit_goto_and_callback(), and unit_goto_and_callback().
enum action_target_kind action_get_target_kind | ( | const struct action * | paction | ) |
Get the target kind of an action.
Definition at line 1869 of file actions.c.
Referenced by action_is_blocked_by(), action_prob_unit_vs_tgt(), action_target_neg_util(), api_edit_perform_action_unit_vs_city(), api_edit_perform_action_unit_vs_city_impr(), api_edit_perform_action_unit_vs_city_tech(), api_edit_perform_action_unit_vs_self(), api_edit_perform_action_unit_vs_tile(), api_edit_perform_action_unit_vs_tile_extra(), api_edit_perform_action_unit_vs_unit(), api_methods_action_target_kind(), auto_settlers_speculate_can_act_at(), blocked_find_target_city(), blocked_find_target_tile(), dai_action_choose_sub_tgt_unit_vs_city(), dai_action_value_unit_vs_city(), dai_diplomat_city(), diplomat_infiltrate_tile(), effect_list_sanity_cb(), enabler_first_self_contradiction(), enabler_tile_tgt_local_diplrel_implies_claimed(), expl_act_not_enabl(), get_act_sel_action_custom_text(), helptext_unit(), is_action_possible(), local_dipl_rel_action_cache_set(), need_war_player_hlp(), notify_actor_caught(), notify_actor_success(), notify_victim_caught(), notify_victim_success(), request_action_details_callback(), sanity_check_ruleset_data(), simple_action_callback(), simple_action_callback(), texai_tile_worker_task_select(), and unit_perform_action().
Get the action name with a mnemonic ready to display in the UI.
Definition at line 2019 of file actions.c.
Referenced by real_menus_init(), and real_menus_update().
|
static |
Returns TRUE iff the wanted action is possible as far as the actor is concerned given that an action enabler later will enable it. Will, unlike action_actor_utype_hard_reqs_ok(), check the actor unit's current state.
Can return maybe when not omniscient. Should always return yes or no when omniscient.
Passing NULL for actor is equivalent to passing an empty context. This may or may not be legal depending on the action.
Definition at line 3376 of file actions.c.
Referenced by action_maybe_possible_actor_unit(), and is_action_possible().
Returns TRUE iff the specified action has an actor that fulfills its hard requirements in the current ruleset.
paction | the action to check |
Definition at line 6373 of file actions.c.
Referenced by action_is_in_use().
Returns TRUE iff the specified action ID refers to a valid action.
Definition at line 1829 of file actions.c.
Referenced by action_by_rule_name(), action_enabler_add(), action_enabler_remove(), action_enabler_suggest_repair_oblig(), action_enablers_for_action(), action_id_is_rare_pop_up(), action_mp_full_makes_legal(), action_prepare_ui_name(), action_target_neg_util(), tab_enabler::add_now(), ae_suggest_repair_if_no_oblig(), do_map_click(), does_nation_block_action(), does_terrain_block_action(), execute_orders(), handle_ruleset_action(), handle_ruleset_action_enabler(), handle_unit_action_answer(), key_unit_action_select_tgt(), request_unit_goto(), send_goto_route(), sg_load_player_unit(), unit_order_list_is_sane(), unit_perform_action(), unpackage_unit(), and utype_may_act_move_frags().
Returns TRUE iff a unit's ability to perform this action will pop up the action selection dialog before the player asks for it only in exceptional cases.
An example of an exceptional case is when the player tries to move a unit to a tile it can't move to but can perform this action to.
Definition at line 1921 of file actions.c.
Referenced by action_tgt_tile(), may_unit_act_vs_city(), may_unit_act_vs_tile_extra(), and may_unit_act_vs_unit().
Get the action name used when displaying the action in the UI. Nothing is added to the UI name.
Definition at line 2011 of file actions.c.
Referenced by action_name_translation(), api_methods_action_name_translation(), unit_item::create_actions(), create_unit_menu(), create_units_order_widgets(), execute_orders(), helptext_building(), helptext_government(), helptext_unit(), illegal_action(), illegal_action_msg(), mr_menu::menus_sensitive(), popup_newcity_dialog(), present_unit_callback(), qtg_request_action_confirmation(), real_menus_update(), request_action_confirmation(), request_unit_goto(), mr_menu::setup_menus(), sg_load_player_unit(), and units_orders_city_dlg_callback().
Get the rule name of the action.
Definition at line 2000 of file actions.c.
Referenced by action_prepare_ui_name(), action_prob_self_full(), action_prob_vs_city_full(), action_prob_vs_extras_full(), action_prob_vs_stack_full(), action_prob_vs_tile_full(), action_prob_vs_unit_full(), action_rule_name(), api_methods_action_rule_name(), handle_unit_orders(), is_action_enabled_unit_on_city_full(), is_action_enabled_unit_on_extras_full(), is_action_enabled_unit_on_self_full(), is_action_enabled_unit_on_stack_full(), is_action_enabled_unit_on_tile_full(), is_action_enabled_unit_on_unit_full(), is_action_possible_on_city(), menu_unit_goto_and_add_accel(), sanity_check_ruleset_data(), sg_save_savefile(), tab_enabler::tab_enabler(), and unit_order_list_is_sane().
bool action_immune_government | ( | struct government * | gov, |
action_id | act | ||
) |
Will a player with the government gov be immune to the action act?
Definition at line 6173 of file actions.c.
Referenced by adv_gov_action_immunity_want(), and helptext_government().
struct action * action_is_blocked_by | ( | const struct civ_map * | nmap, |
const struct action * | act, | ||
const struct unit * | actor_unit, | ||
const struct tile * | target_tile_arg, | ||
const struct city * | target_city_arg, | ||
const struct unit * | target_unit | ||
) |
Returns the action that blocks the specified action or NULL if the specified action isn't blocked.
An action that can block another blocks when it is forced and possible.
Definition at line 3036 of file actions.c.
Referenced by action_prob_vs_city_full(), action_prob_vs_stack_full(), expl_act_not_enabl(), and is_action_possible().
Returns TRUE if the specified action may be enabled in the current ruleset.
paction | the action to check if is in use. |
Definition at line 6398 of file actions.c.
Referenced by action_immune_government(), helptext_building(), helptext_unit(), ruleset_purge_unused_enablers(), save_action_actor_consuming_always(), save_action_auto_actions(), save_action_blocked_by(), save_action_kind(), save_action_post_success_force(), save_bv_actions(), and universal_never_there().
struct action_list * action_list_by_activity | ( | enum unit_activity | activity | ) |
Returns action list by activity.
Definition at line 8145 of file actions.c.
Referenced by unit_activity_handling_targeted().
struct action_list * action_list_by_result | ( | enum action_result | result | ) |
Return max range ruleset variable name for the action or NULL if max range can't be set in the ruleset.
TODO: make actions generic and put max_range in a field of the action.
Definition at line 7276 of file actions.c.
Referenced by load_action_range_max(), save_action_max_range(), and save_action_range().
bool action_maybe_possible_actor_unit | ( | const struct civ_map * | nmap, |
const action_id | act_id, | ||
const struct unit * | actor_unit | ||
) |
Returns TRUE if the wanted action (as far as the player knows) can be performed right now by the specified actor unit if an approriate target is provided.
Definition at line 6237 of file actions.c.
Referenced by act_prob_unseen_target(), can_unit_paradrop(), can_unit_teleport(), and handle_unit_get_actions().
Return min range ruleset variable name for the action or NULL if min range can't be set in the ruleset.
TODO: Make actions generic and put min_range in a field of the action.
Definition at line 7116 of file actions.c.
Referenced by load_action_range(), and save_action_range().
Returns TRUE if the specified action can't be done now but would have been legal if the unit had full movement.
Definition at line 6292 of file actions.c.
Referenced by execute_orders(), and expl_act_not_enabl().
Get the action name used when displaying the action in the UI. Nothing is added to the UI name.
This always returns the same static string, just modified according to the call. Copy the result if you want it to remain valid over another call to this function.
Definition at line 1991 of file actions.c.
Referenced by go_act_menu::create(), do_paradrop(), do_unit_strike_city_building(), do_unit_strike_city_production(), helptext_unit(), illegal_action_pay_price(), key_unit_action_select_tgt(), notify_actor_caught(), notify_actor_success(), notify_global_caught(), notify_global_success(), notify_victim_caught(), notify_victim_success(), req_text_insert(), spy_poison(), spy_spread_plague(), unit_attack_civilian_casualties(), unit_bombard(), unit_do_help_build(), and universal_name_translation().
Get the universal number of the action.
Definition at line 1969 of file actions.c.
Referenced by action_blocked_by_ruleset_var_name(), action_post_success_forced_ruleset_var_name(), action_would_be_blocked_by(), adv_unit_move(), are_universals_equal(), dai_diplomat_city(), dai_unit_move(), is_action_req_active(), unit_activity_handling_targeted(), unit_order_activity_to_action(), and universal_number().
Return action post success forced action ruleset variable name for the action or NULL if it can't be set in the ruleset.
Definition at line 7933 of file actions.c.
Referenced by load_action_post_success_force(), and save_action_post_success_force().
const char * action_prepare_ui_name | ( | action_id | act_id, |
const char * | mnemonic, | ||
const struct act_prob | prob, | ||
const char * | custom | ||
) |
Get the UI name ready to show the action in the UI. It is possible to add a client specific mnemonic; it is assumed that if the mnemonic appears in the action name it can be escaped by doubling. Success probability information is interpreted and added to the text. A custom text can be inserted before the probability information.
The returned string is in statically allocated astring, and thus this function is not thread-safe.
Definition at line 2073 of file actions.c.
Referenced by action_entry(), action_entry(), action_entry(), action_entry_update(), action_entry_update(), action_get_ui_name_mnemonic(), and action_id_name_translation().
|
static |
An action's probability of success.
"Success" indicates that the action achieves its goal, not that the actor survives. For actions that cost money it is assumed that the player has and is willing to spend the money. This is so the player can figure out what their odds are before deciding to get the extra money.
Passing NULL for actor or target is equivalent to passing an empty context. This may or may not be legal depending on the action.
Definition at line 4576 of file actions.c.
Referenced by action_prob_self_full(), action_prob_vs_city_full(), action_prob_vs_extras_full(), action_prob_vs_stack_full(), action_prob_vs_tile_full(), and action_prob_vs_unit_full().
Returns ap1 and ap2 - as in both ap1 and ap2 happening. Said in math that is: P(A) * P(B)
Definition at line 5959 of file actions.c.
Referenced by action_prob_battle_then_dice_roll().
|
static |
Returns the action probability of an action winning a potential pre action battle - like a diplomatic battle - and then not failing its dice roll. Shouldn't leak information.
Definition at line 4528 of file actions.c.
Referenced by action_prob().
Compare action probabilities. Prioritize the lowest possible value.
Definition at line 5881 of file actions.c.
Referenced by compare_units().
Explain an action probability in a way suitable for a tool tip for the button that starts it.
The returned string is in statically allocated astring, and thus this function is not thread-safe.
Definition at line 2184 of file actions.c.
Referenced by act_sel_action_tool_tip().
Returns ap1 with ap2 as fall back in cases where ap1 doesn't happen. Said in math that is: P(A) + P(A') * P(B)
This is useful to calculate the probability of doing action A or, when A is impossible, falling back to doing action B.
Definition at line 6029 of file actions.c.
Referenced by action_auto_perf_unit_prob().
Returns TRUE iff the given action probability represents a special signal value rather than a regular action probability value.
Definition at line 5864 of file actions.c.
Referenced by action_prob(), action_prob_and(), action_prob_cmp_pessimist(), action_prob_explain(), action_prob_fall_back(), action_prob_to_0_to_1_pessimist(), action_prob_to_text(), and action_prob_vs_stack_full().
Returns TRUE iff the given action probability represents that support for finding this action probability currently is missing from Freeciv.
Definition at line 5853 of file actions.c.
Referenced by action_prob_and(), action_prob_cmp_pessimist(), action_prob_explain(), action_prob_fall_back(), action_prob_possible(), action_prob_to_0_to_1_pessimist(), action_prob_to_text(), and action_prob_vs_stack_full().
Returns TRUE iff the given action probability represents the lack of an action probability.
Definition at line 5842 of file actions.c.
Referenced by action_prepare_ui_name(), action_prob_and(), action_prob_cmp_pessimist(), action_prob_fall_back(), action_prob_to_0_to_1_pessimist(), and action_prob_to_text().
Returns TRUE iff the given action probability belongs to an action that may be possible.
Definition at line 5821 of file actions.c.
Referenced by action_entry(), action_entry(), action_entry(), action_entry_update(), action_entry_update(), action_prob_vs_stack_full(), action_selection_refresh(), action_sub_target_id_for_action(), action_tgt_tile(), auto_attack_act(), auto_settlers_speculate_can_act_at(), can_unit_change_homecity_to(), can_unit_deboard_or_be_unloaded(), create_advances_list(), create_improvements_list(), dai_diplomat_bribe_nearby(), dai_diplomat_city(), dai_manage_paratrooper(), do_disband_alternative(), do_unit_paradrop_to(), do_unit_teleport_to(), execute_orders(), get_act_sel_action_custom_text(), get_discounted_reward(), handle_city_name_suggestion_req(), handle_unit_actions(), handle_unit_get_actions(), illegal_action(), may_unit_act_vs_city(), may_unit_act_vs_tile_extra(), may_unit_act_vs_unit(), popup_action_selection(), popup_sabotage_dialog(), popup_sabotage_dialog(), random_movements(), request_unit_load(), settler_evaluate_improvements(), spy_steal_popup_shared(), spy_steal_shared(), texai_tile_worker_task_select(), unit_can_add_or_build_city(), unit_can_airlift_to(), unit_can_help_build_wonder_here(), and unit_survive_autoattack().
|
static |
Returns the action probability of an action not failing its dice roll without leaking information.
Definition at line 4484 of file actions.c.
Referenced by action_prob(), and action_prob_battle_then_dice_roll().
struct act_prob action_prob_self | ( | const struct civ_map * | nmap, |
const struct unit * | actor_unit, | ||
const action_id | act_id | ||
) |
Get the actor unit's probability of successfully performing the chosen action on itself.
Definition at line 5495 of file actions.c.
Referenced by action_auto_perf_unit_prob(), action_prob_unit_vs_tgt(), do_disband_alternative(), execute_orders(), and handle_unit_get_actions().
|
static |
Get the actor unit's probability of successfully performing the chosen action on itself.
Definition at line 5442 of file actions.c.
Referenced by action_prob_self(), and action_speculate_unit_on_self().
Returns double in the range [0-1] representing the minimum of the given action probability.
Definition at line 5932 of file actions.c.
Referenced by unit_survive_autoattack().
Returns a text representation of the action probability prob unless it is a signal. Returns NULL if prob is a signal.
The returned string is in statically allocated astring, and thus this function is not thread-safe.
Definition at line 2032 of file actions.c.
Referenced by action_prepare_ui_name().
struct act_prob action_prob_unit_vs_tgt | ( | const struct civ_map * | nmap, |
const struct action * | paction, | ||
const struct unit * | act_unit, | ||
const struct city * | tgt_city, | ||
const struct unit * | tgt_unit, | ||
const struct tile * | tgt_tile, | ||
const struct extra_type * | extra_tgt | ||
) |
Returns the actor unit's probability of successfully performing the specified action against the action specific target.
nmap | Map to consult |
paction | The action to perform |
act_unit | The actor unit |
tgt_city | The target for city targeted actions |
tgt_unit | The target for unit targeted actions |
tgt_tile | The target for tile and unit stack targeted actions |
extra_tgt | The target for extra sub targeted actions |
Definition at line 5517 of file actions.c.
Referenced by dai_manage_paratrooper(), do_unit_paradrop_to(), do_unit_teleport_to(), and illegal_action().
struct act_prob action_prob_vs_city | ( | const struct civ_map * | nmap, |
const struct unit * | actor_unit, | ||
const action_id | act_id, | ||
const struct city * | target_city | ||
) |
Get the actor unit's probability of successfully performing the chosen action on the target city.
Definition at line 4984 of file actions.c.
Referenced by action_auto_perf_unit_prob(), action_prob_unit_vs_tgt(), can_unit_change_homecity_to(), dai_diplomat_city(), do_disband_alternative(), execute_orders(), handle_unit_get_actions(), may_unit_act_vs_city(), unit_can_add_or_build_city(), unit_can_airlift_to(), and unit_can_help_build_wonder_here().
|
static |
Get the actor unit's probability of successfully performing the chosen action on the target city.
Definition at line 4897 of file actions.c.
Referenced by action_prob_vs_city(), and action_speculate_unit_on_city().
struct act_prob action_prob_vs_extras | ( | const struct civ_map * | nmap, |
const struct unit * | actor_unit, | ||
const action_id | act_id, | ||
const struct tile * | target_tile, | ||
const struct extra_type * | target_extra | ||
) |
Get the actor unit's probability of successfully performing the chosen action on the extras at the target tile.
Definition at line 5425 of file actions.c.
Referenced by action_auto_perf_unit_prob(), action_prob_unit_vs_tgt(), action_tgt_tile(), do_disband_alternative(), execute_orders(), handle_unit_get_actions(), and may_unit_act_vs_tile_extra().
|
static |
Get the actor unit's probability of successfully performing the chosen action on the extras at the target tile.
Definition at line 5359 of file actions.c.
Referenced by action_prob_vs_extras(), and action_speculate_unit_on_extras().
struct act_prob action_prob_vs_stack | ( | const struct civ_map * | nmap, |
const struct unit * | actor_unit, | ||
const action_id | act_id, | ||
const struct tile * | target_tile | ||
) |
Get the actor unit's probability of successfully performing the chosen action on all units at the target tile.
Definition at line 5259 of file actions.c.
Referenced by action_auto_perf_unit_prob(), action_prob_unit_vs_tgt(), action_tgt_tile(), do_disband_alternative(), execute_orders(), handle_unit_get_actions(), and random_movements().
|
static |
Get the actor unit's probability of successfully performing the chosen action on all units at the target tile.
Definition at line 5084 of file actions.c.
Referenced by action_prob_vs_stack(), and action_speculate_unit_on_stack().
struct act_prob action_prob_vs_tile | ( | const struct civ_map * | nmap, |
const struct unit * | actor_unit, | ||
const action_id | act_id, | ||
const struct tile * | target_tile, | ||
const struct extra_type * | target_extra | ||
) |
Get the actor unit's probability of successfully performing the chosen action on the target tile.
Definition at line 5342 of file actions.c.
Referenced by action_auto_perf_unit_prob(), action_prob_unit_vs_tgt(), action_sub_target_id_for_action(), action_tgt_tile(), do_disband_alternative(), execute_orders(), handle_city_name_suggestion_req(), handle_unit_get_actions(), may_unit_act_vs_tile_extra(), and unit_can_add_or_build_city().
|
static |
Get the actor unit's probability of successfully performing the chosen action on the target tile.
Definition at line 5276 of file actions.c.
Referenced by action_prob_vs_tile(), and action_speculate_unit_on_tile().
struct act_prob action_prob_vs_unit | ( | const struct civ_map * | nmap, |
const struct unit * | actor_unit, | ||
const action_id | act_id, | ||
const struct unit * | target_unit | ||
) |
Get the actor unit's probability of successfully performing the chosen action on the target unit.
Definition at line 5067 of file actions.c.
Referenced by action_auto_perf_unit_prob(), action_prob_unit_vs_tgt(), can_unit_deboard_or_be_unloaded(), dai_diplomat_bribe_nearby(), do_disband_alternative(), execute_orders(), handle_unit_get_actions(), may_unit_act_vs_unit(), and request_unit_load().
|
static |
Get the actor unit's probability of successfully performing the chosen action on the target unit.
Definition at line 5000 of file actions.c.
Referenced by action_prob_vs_unit(), and action_speculate_unit_on_unit().
Get the rule name of the action.
Definition at line 1977 of file actions.c.
Referenced by action_enabler_suggest_improvement(), action_get_role(), action_new(), ae_suggest_repair_if_no_oblig(), autoadjust_ruleset_data(), blocked_find_target_city(), blocked_find_target_tile(), dai_diplomat_city(), enabler_first_self_contradiction(), enabler_tile_tgt_local_diplrel_implies_claimed(), execute_orders(), fix_enabler_item::fix_enabler_item(), is_universal_needed(), tab_enabler::refresh(), rscompat_enabler_add_obligatory_hard_reqs(), rscompat_postprocess(), ruleset_purge_redundant_reqs_enablers(), ruleset_purge_unused_enablers(), sanity_check_ruleset_data(), save_action_blocked_by(), save_actions_ruleset(), unit_can_act_cache_set(), universal_kind_values(), universal_rule_name(), tab_enabler::update_enabler_info(), utype_act_takes_all_mp_cache_set(), and utype_act_takes_all_mp_ustate_cache_set().
struct act_prob action_speculate_unit_on_city | ( | const struct civ_map * | nmap, |
const action_id | act_id, | ||
const struct unit * | actor, | ||
const struct city * | actor_home, | ||
const struct tile * | actor_tile, | ||
const bool | omniscient_cheat, | ||
const struct city * | target | ||
) |
Returns a speculation about the actor unit's probability of successfully performing the chosen action on the target city given the specified game state changes.
Definition at line 5574 of file actions.c.
Referenced by auto_settlers_speculate_can_act_at(), and get_discounted_reward().
struct act_prob action_speculate_unit_on_extras | ( | const struct civ_map * | nmap, |
action_id | act_id, | ||
const struct unit * | actor, | ||
const struct city * | actor_home, | ||
const struct tile * | actor_tile, | ||
bool | omniscient_cheat, | ||
const struct tile * | target_tile, | ||
const struct extra_type * | target_extra | ||
) |
Returns a speculation about the actor unit's probability of successfully performing the chosen action to the extras at the target tile (and, if specified, specific extra) given the specified game state changes.
Definition at line 5709 of file actions.c.
Referenced by auto_settlers_speculate_can_act_at().
struct act_prob action_speculate_unit_on_self | ( | const struct civ_map * | nmap, |
action_id | act_id, | ||
const struct unit * | actor, | ||
const struct city * | actor_home, | ||
const struct tile * | actor_tile, | ||
bool | omniscient_cheat | ||
) |
Returns a speculation about the actor unit's probability of successfully performing the chosen action on itself given the specified game state changes.
Definition at line 5743 of file actions.c.
Referenced by auto_settlers_speculate_can_act_at().
struct act_prob action_speculate_unit_on_stack | ( | const struct civ_map * | nmap, |
action_id | act_id, | ||
const struct unit * | actor, | ||
const struct city * | actor_home, | ||
const struct tile * | actor_tile, | ||
bool | omniscient_cheat, | ||
const struct tile * | target | ||
) |
Returns a speculation about the actor unit's probability of successfully performing the chosen action on the target unit stack given the specified game state changes.
Definition at line 5642 of file actions.c.
Referenced by auto_settlers_speculate_can_act_at().
struct act_prob action_speculate_unit_on_tile | ( | const struct civ_map * | nmap, |
action_id | act_id, | ||
const struct unit * | actor, | ||
const struct city * | actor_home, | ||
const struct tile * | actor_tile, | ||
bool | omniscient_cheat, | ||
const struct tile * | target_tile, | ||
const struct extra_type * | target_extra | ||
) |
Returns a speculation about the actor unit's probability of successfully performing the chosen action on the target tile (and, if specified, extra) given the specified game state changes.
Definition at line 5675 of file actions.c.
Referenced by auto_settlers_speculate_can_act_at(), settler_evaluate_improvements(), and texai_tile_worker_task_select().
const char * action_target_kind_help | ( | enum action_target_kind | kind | ) |
Return description of the action target kind suitable to use in the helptext.
Definition at line 8125 of file actions.c.
Referenced by helptext_government(), and helptext_unit().
Return target kind ruleset variable name for the action or NULL if target kind can't be set in the ruleset.
TODO: make actions generic and put target_kind in a field of the action.
Definition at line 7445 of file actions.c.
Referenced by load_action_kind(), and save_action_kind().
Return default ui_name for the action
Definition at line 6773 of file actions.c.
Referenced by load_action_ui_name(), and save_action_ui_name().
Return ui_name ruleset variable name for the action.
TODO: make actions generic and put ui_name in a field of the action.
Definition at line 6506 of file actions.c.
Referenced by load_ruleset_actions(), and save_actions_ruleset().
Returns TRUE iff blocked will be illegal if blocker is legal.
Definition at line 1957 of file actions.c.
Referenced by action_is_blocked_by(), autoadjust_ruleset_data(), and helptext_unit().
Returns TRUE iff the actions are initialized.
Doesn't care about action enablers.
Definition at line 1717 of file actions.c.
Referenced by action_prepare_ui_name(), and go_act_menu::update().
Free the actions and the action enablers.
Definition at line 1664 of file actions.c.
Referenced by game_ruleset_free().
Initialize the actions and the action enablers.
Definition at line 1594 of file actions.c.
Referenced by game_ruleset_init().
Generate action related data based on the currently loaded ruleset. Done before ruleset sanity checking and ruleset compatibility post processing.
Definition at line 1654 of file actions.c.
Referenced by handle_rulesets_ready(), and load_rulesetdir().
|
static |
Tell an ae_contra_or that one of its users is done with it.
contra | the ae_contra_or the user is done with. |
Definition at line 184 of file actions.c.
Referenced by actions_free().
|
static |
Returns a suggestion to add an obligatory hard requirement to an action enabler or NULL if no hard obligatory reqs were missing. It is the responsibility of the caller to free the suggestion when it is done with it.
enabler | the action enabler to suggest a fix for. |
oblig | hard obligatory requirements to check |
Definition at line 2335 of file actions.c.
Referenced by action_enabler_suggest_repair_oblig().
|
static |
The action probability that pattacker will win a diplomatic battle.
It is assumed that pattacker and pdefender have different owners and that the defender can defend in a diplomatic battle.
See diplomat_success_vs_defender() in server/diplomats.c
Definition at line 4361 of file actions.c.
Referenced by ap_diplomat_battle().
|
static |
The action probability that pattacker will win a diplomatic battle.
See diplomat_infiltrate_tile() in server/diplomats.c
Definition at line 4438 of file actions.c.
Referenced by action_prob(), and action_prob_battle_then_dice_roll().
Returns TRUE iff ap1 and ap2 are equal.
Definition at line 5872 of file actions.c.
Referenced by action_prob_and(), action_prob_fall_back(), and send_packet_unit_actions_100().
|
static |
Returns the target city for actions that may block the specified action. This is needed because some actions can be blocked by an action with a different target kind. The target city argument could therefore be missing.
Example: The ATK_SELF action ACTION_DISBAND_UNIT can be blocked by the ATK_CITY action ACTION_DISBAND_UNIT_RECOVER.
Definition at line 2982 of file actions.c.
Referenced by action_is_blocked_by().
|
static |
Returns the target tile for actions that may block the specified action. This is needed because some actions can be blocked by an action with a different target kind. The target tile could therefore be missing.
Example: The ATK_SELF action ACTION_DISBAND_UNIT can be blocked by the ATK_CITY action ACTION_DISBAND_UNIT_RECOVER.
Definition at line 2924 of file actions.c.
Referenced by action_is_blocked_by().
|
static |
Returns the first action enabler specific clarification possibility in the specified enabler or NULL if no enabler specific contradiction is found.
enabler | the enabler to look at |
Definition at line 2727 of file actions.c.
Referenced by action_enabler_suggest_improvement().
|
static |
Returns the first action enabler specific contradiction in the specified enabler or NULL if no enabler specific contradiction is found.
enabler | the enabler to look at |
Definition at line 2607 of file actions.c.
Referenced by action_enabler_suggest_repair().
|
static |
Detects a local DiplRel requirement in a tile targeted action without an explicit claimed requirement in the target reqs.
enabler | the enabler to look at |
Definition at line 2534 of file actions.c.
Referenced by action_enabler_suggest_repair().
FC_STATIC_ASSERT | ( | MAP_DISTANCE_MAX<= | ACTION_DISTANCE_LAST_NON_SIGNAL, |
action_range_can_not_cover_the_whole_map | |||
) |
Hard code the obligatory hard requirements that don't depend on the rest of the ruleset. They are sorted by requirement to make it easy to read, modify and explain them.
Definition at line 354 of file actions.c.
Referenced by actions_init().
Hard code the obligatory hard requirements that needs access to the ruleset before they can be generated.
Definition at line 887 of file actions.c.
Referenced by actions_rs_pre_san_gen().
|
static |
Returns TRUE if the wanted action is enabled.
Note that the action may disable it self because of hard requirements even if an action enabler returns TRUE.
Passing NULL for actor or target is equivalent to passing an empty context. This may or may not be legal depending on the action.
Definition at line 3737 of file actions.c.
Referenced by is_action_enabled_unit_on_city_full(), is_action_enabled_unit_on_extras_full(), is_action_enabled_unit_on_self_full(), is_action_enabled_unit_on_stack_full(), is_action_enabled_unit_on_tile_full(), and is_action_enabled_unit_on_unit_full().
bool is_action_enabled_unit_on_city | ( | const struct civ_map * | nmap, |
const action_id | wanted_action, | ||
const struct unit * | actor_unit, | ||
const struct city * | target_city | ||
) |
Returns TRUE if actor_unit can do wanted_action to target_city as far as action enablers are concerned.
See note in is_action_enabled() for why the action may still be disabled.
Definition at line 3841 of file actions.c.
Referenced by action_auto_perf_unit_do(), action_auto_perf_unit_prob(), action_is_blocked_by(), api_edit_perform_action_unit_vs_city(), api_edit_perform_action_unit_vs_city_impr(), api_edit_perform_action_unit_vs_city_tech(), dai_caravan_goto(), dai_manage_caravan(), dai_unit_attack(), handle_unit_action_query(), handle_unit_type_upgrade(), unit_can_airlift_to(), and unit_do_disband_trad().
|
static |
Returns TRUE if actor_unit can do wanted_action to target_city as far as action enablers are concerned.
See note in is_action_enabled() for why the action may still be disabled.
Definition at line 3776 of file actions.c.
Referenced by action_speculate_unit_on_city(), and is_action_enabled_unit_on_city().
bool is_action_enabled_unit_on_extras | ( | const struct civ_map * | nmap, |
const action_id | wanted_action, | ||
const struct unit * | actor_unit, | ||
const struct tile * | target_tile, | ||
const struct extra_type * | target_extra | ||
) |
Returns TRUE if actor_unit can do wanted_action to the extras at target_tile as far as action enablers are concerned.
See note in is_action_enabled() for why the action may still be disabled.
Definition at line 4159 of file actions.c.
Referenced by action_auto_perf_unit_do(), action_auto_perf_unit_prob(), action_is_blocked_by(), api_edit_perform_action_unit_vs_tile(), api_edit_perform_action_unit_vs_tile_extra(), and dai_unit_attack().
|
static |
Returns TRUE if actor_unit can do wanted_action to the extras at target_tile as far as action enablers are concerned.
See note in is_action_enabled() for why the action may still be disabled.
Definition at line 4101 of file actions.c.
Referenced by action_speculate_unit_on_extras(), and is_action_enabled_unit_on_extras().
bool is_action_enabled_unit_on_self | ( | const struct civ_map * | nmap, |
const action_id | wanted_action, | ||
const struct unit * | actor_unit | ||
) |
Returns TRUE if actor_unit can do wanted_action to itself as far as action enablers are concerned.
See note in is_action_enabled() for why the action still may be disabled.
Definition at line 4231 of file actions.c.
Referenced by action_auto_perf_unit_do(), action_auto_perf_unit_prob(), action_is_blocked_by(), api_edit_perform_action_unit_vs_self(), can_unit_do_activity_targeted_at(), and unit_do_disband_trad().
|
static |
Returns TRUE if actor_unit can do wanted_action to itself as far as action enablers are concerned.
See note in is_action_enabled() for why the action still may be disabled.
Definition at line 4179 of file actions.c.
Referenced by action_speculate_unit_on_self(), and is_action_enabled_unit_on_self().
bool is_action_enabled_unit_on_stack | ( | const struct civ_map * | nmap, |
const action_id | wanted_action, | ||
const struct unit * | actor_unit, | ||
const struct tile * | target_tile | ||
) |
Returns TRUE if actor_unit can do wanted_action to all units on the target_tile as far as action enablers are concerned.
See note in is_action_enabled() for why the action may still be disabled.
Definition at line 4006 of file actions.c.
Referenced by action_auto_perf_unit_do(), action_auto_perf_unit_prob(), action_is_blocked_by(), api_edit_perform_action_unit_vs_tile(), api_edit_perform_action_unit_vs_tile_extra(), and dai_unit_attack().
|
static |
Returns TRUE if actor_unit can do wanted_action to all units on the target_tile as far as action enablers are concerned.
See note in is_action_enabled() for why the action may still be disabled.
Definition at line 3936 of file actions.c.
Referenced by action_speculate_unit_on_stack(), and is_action_enabled_unit_on_stack().
bool is_action_enabled_unit_on_tile | ( | const struct civ_map * | nmap, |
const action_id | wanted_action, | ||
const struct unit * | actor_unit, | ||
const struct tile * | target_tile, | ||
const struct extra_type * | target_extra | ||
) |
Returns TRUE if actor_unit can do wanted_action to the target_tile as far as action enablers are concerned.
See note in is_action_enabled() for why the action may still be disabled.
Definition at line 4082 of file actions.c.
Referenced by action_auto_perf_unit_do(), action_auto_perf_unit_prob(), action_is_blocked_by(), adv_unit_move(), api_edit_perform_action_unit_vs_tile(), api_edit_perform_action_unit_vs_tile_extra(), can_unit_do_activity_targeted_at(), dai_manage_paratrooper(), dai_unit_attack(), dai_unit_move(), random_movements(), and unit_move_handling().
|
static |
Returns TRUE if actor_unit can do wanted_action to the target_tile as far as action enablers are concerned.
See note in is_action_enabled() for why the action may still be disabled.
Definition at line 4024 of file actions.c.
Referenced by action_speculate_unit_on_tile(), and is_action_enabled_unit_on_tile().
bool is_action_enabled_unit_on_unit | ( | const struct civ_map * | nmap, |
const action_id | wanted_action, | ||
const struct unit * | actor_unit, | ||
const struct unit * | target_unit | ||
) |
Returns TRUE if actor_unit can do wanted_action to target_unit as far as action enablers are concerned.
See note in is_action_enabled() for why the action may still be disabled.
Definition at line 3918 of file actions.c.
Referenced by action_auto_perf_unit_do(), action_auto_perf_unit_prob(), action_is_blocked_by(), adv_unit_move(), api_edit_perform_action_unit_vs_unit(), can_unit_deboard_or_be_unloaded(), dai_diplomat_bribe_nearby(), dai_hunter_try_launch(), dai_unit_attack(), dai_unit_move(), handle_unit_action_query(), unit_move_handling(), and unleash_barbarians().
|
static |
Returns TRUE if actor_unit can do wanted_action to target_unit as far as action enablers are concerned.
See note in is_action_enabled() for why the action may still be disabled.
Definition at line 3859 of file actions.c.
Referenced by action_speculate_unit_on_unit(), and is_action_enabled_unit_on_unit().
|
static |
Returns if the wanted action is possible given that an action enabler later will enable it.
Can return maybe when not omniscient. Should always return yes or no when omniscient.
This is done by checking the action's hard requirements. Hard requirements must be fulfilled before an action can be done. The reason why is usually that code dealing with the action assumes that requirements are true. A requirement may also end up here if it can't be expressed in a requirement vector or if its absence makes the action pointless.
When adding a new hard requirement here: explain why it is a hard requirement in a comment. remember that this is called from action_prob(). Should information the player don't have access to be used in a test it must check if the evaluation can see the thing being tested.
Passing NULL for actor or target is equivalent to passing an empty context. This may or may not be legal depending on the action.
Definition at line 3562 of file actions.c.
Referenced by action_prob(), and is_action_enabled().
bool is_action_possible_on_city | ( | action_id | act_id, |
const struct player * | actor_player, | ||
const struct city * | target_city | ||
) |
Returns TRUE if the wanted action can be done to the target city.
Definition at line 6214 of file actions.c.
Referenced by adjust_improvement_wants_by_effects(), dai_choose_diplomat_offensive(), find_city_to_diplomat(), and impr_protects_vs_actions().
|
static |
Find out if the effect value is known
The knowledge of the actor is assumed to be given in the parameters.
If meta knowledge is missing TRI_MAYBE will be returned.
context may be NULL. This is equivalent to passing an empty context.
Definition at line 4305 of file actions.c.
Referenced by action_prob_pre_action_dice_roll(), and ap_dipl_battle_win().
|
static |
Return TRUE iff the action enabler is active
actor may be NULL. This is equivalent to passing an empty context. target may be NULL. This is equivalent to passing an empty context.
Definition at line 3718 of file actions.c.
Referenced by is_action_enabled().
|
static |
Returns TRUE if the wanted action can be done to the target.
target may be NULL. This is equivalent to passing an empty context.
Definition at line 6196 of file actions.c.
Referenced by is_action_possible_on_city().
|
static |
Register an obligatory hard requirement for the specified action results.
contras | if one alternative here doesn't contradict the enabler it is accepted. |
error_message | error message if an enabler contradicts all contras. Followed by a list of action results that should be unable to contradict all specified contradictions. |
Definition at line 247 of file actions.c.
Referenced by hard_code_oblig_hard_reqs(), and hard_code_oblig_hard_reqs_ruleset().
|
static |
Register an obligatory hard requirement for the specified action sub results.
contras | if one alternative here doesn't contradict the enabler it is accepted. |
error_message | error message if an enabler contradicts all contras. Followed by a list of action sub results that should be unable to contradict all specified contradictions. |
Definition at line 336 of file actions.c.
Referenced by hard_code_oblig_hard_reqs().
|
static |
Register an obligatory hard requirement for the action results it applies to.
The vararg parameter is a list of action ids it applies to terminated by ACTION_NONE.
Definition at line 267 of file actions.c.
Referenced by hard_code_oblig_hard_reqs(), and hard_code_oblig_hard_reqs_ruleset().
|
static |
Returns a new array of alternative action enabler contradictions. Only one has to not contradict the enabler for it to be seen as fulfilled.
alternatives | the number of action enabler contradictions followed by the enabler contradictions specified as alternating contradicting requirement and a bool that is TRUE if the requirement contradicts the enabler's target requirement vector and FALSE if it contradicts the enabler's actor vector. |
Definition at line 155 of file actions.c.
Referenced by hard_code_oblig_hard_reqs(), hard_code_oblig_hard_reqs_ruleset(), and oblig_hard_req_register().
|
static |
Returns the first requirement in the specified requirement vector that contradicts the specified requirement or NULL if no contradiction was detected.
req | the requirement that may contradict the vector |
vec | the requirement vector to look in |
Definition at line 2511 of file actions.c.
Referenced by enabler_first_self_contradiction(), and enabler_tile_tgt_local_diplrel_implies_claimed().
|
static |
Returns the first local DiplRel requirement in the specified requirement vector or NULL if it doesn't have a local DiplRel requirement.
vec | the requirement vector to look in |
Definition at line 2490 of file actions.c.
Referenced by enabler_first_self_contradiction(), and enabler_tile_tgt_local_diplrel_implies_claimed().
|
static |
Does the target has any techs the actor don't?
Definition at line 4325 of file actions.c.
Referenced by action_prob().
Returns the local building type of a city target.
target_city can't be NULL
Definition at line 2876 of file actions.c.
Referenced by action_prob_vs_city_full(), and is_action_enabled_unit_on_city_full().
Returns the local unit type of a city target.
target_city can't be NULL
Definition at line 2899 of file actions.c.
Referenced by action_prob_vs_city_full(), and is_action_enabled_unit_on_city_full().
|
static |
Create a new action performed by a unit actor.
Definition at line 1804 of file actions.c.
Referenced by hard_code_actions().
|
static |
Register an obligatory hard requirement for the specified action results.
contras | if one alternative here doesn't contradict the enabler it is accepted. |
error_message | error message if an enabler contradicts all contras. |
args | list of action results that should be unable to contradict all specified contradictions. |
Definition at line 203 of file actions.c.
Referenced by oblig_hard_req_reg(), and oblig_hard_req_register().
|
static |
Register an obligatory hard requirement for the specified action sub results.
contras | if one alternative here doesn't contradict the enabler it is accepted. |
error_message | error message if an enabler contradicts all contras. |
args | list of action sub results that should be unable to contradict all specified contradictions. |
Definition at line 294 of file actions.c.
Referenced by oblig_hard_req_reg_sub_res().
Definition at line 98 of file actions.c.
Referenced by action_by_number().
|
static |
Definition at line 102 of file actions.c.
Referenced by action_enablers_for_action(), actions_free(), and actions_init().
|
static |
Definition at line 97 of file actions.c.
Referenced by action_id_exists(), action_id_is_rare_pop_up(), action_id_rule_name(), action_prepare_ui_name(), actions_are_ready(), actions_free(), city_widget::display_header_menu(), plr_widget::display_header_menu(), hard_code_actions(), and sg_save_player_cities().
Definition at line 100 of file actions.c.
Referenced by actions_are_ready(), actions_free(), and actions_init().
|
static |
Definition at line 142 of file actions.c.
Referenced by action_list_by_activity(), action_new(), actions_free(), and actions_init().
|
static |
Definition at line 141 of file actions.c.
Referenced by action_list_by_result(), action_new(), actions_free(), and actions_init().
struct action_auto_perf auto_perfs[MAX_NUM_ACTION_AUTO_PERFORMERS] |
Definition at line 99 of file actions.c.
Referenced by action_auto_perf_slot_number(), actions_free(), and actions_init().
|
static |
Definition at line 105 of file actions.c.
Referenced by action_enabler_suggest_repair_oblig(), actions_free(), actions_init(), and voblig_hard_req_reg().
|
static |
Definition at line 106 of file actions.c.
Referenced by action_enabler_suggest_repair_oblig(), actions_free(), actions_init(), and voblig_hard_req_reg_sub_res().
|
static |
Definition at line 108 of file actions.c.
Referenced by action_prepare_ui_name(), and actions_free().