Freeciv21
Develop your civilization from humble roots to a global empire
actions.h
Go to the documentation of this file.
1 /***********************************************************************
2 _ ._ Copyright (c) 1996-2021 Freeciv21 and Freeciv contributors.
3  \ | This file is part of Freeciv21. Freeciv21 is free software: you
4  \_| can redistribute it and/or modify it under the terms of the
5  .' '. GNU General Public License as published by the Free
6  :O O: Software Foundation, either version 3 of the License,
7  '/ \' or (at your option) any later version. You should have
8  :X: received a copy of the GNU General Public License along with
9  :X: Freeciv21. If not, see https://www.gnu.org/licenses/.
10 ***********************************************************************/
11 
12 #pragma once
13 
14 // common
15 #include "fc_types.h"
16 #include "metaknowledge.h"
17 #include "requirements.h"
18 
19 #define SPECENUM_NAME action_actor_kind
20 #define SPECENUM_VALUE0 AAK_UNIT
21 #define SPECENUM_VALUE0NAME N_("a unit")
22 #define SPECENUM_COUNT AAK_COUNT
23 #include "specenum_gen.h"
24 
25 #define SPECENUM_NAME action_target_kind
26 #define SPECENUM_VALUE0 ATK_CITY
27 #define SPECENUM_VALUE0NAME N_("individual cities")
28 #define SPECENUM_VALUE1 ATK_UNIT
29 #define SPECENUM_VALUE1NAME N_("individual units")
30 #define SPECENUM_VALUE2 ATK_UNITS
31 #define SPECENUM_VALUE2NAME N_("unit stacks")
32 #define SPECENUM_VALUE3 ATK_TILE
33 #define SPECENUM_VALUE3NAME N_("tiles")
34 // No target except the actor itself.
35 #define SPECENUM_VALUE4 ATK_SELF
36 #define SPECENUM_VALUE4NAME N_("itself")
37 #define SPECENUM_COUNT ATK_COUNT
38 #include "specenum_gen.h"
39 
40 // Values used in the network protocol.
41 #define SPECENUM_NAME action_sub_target_kind
42 #define SPECENUM_VALUE0 ASTK_NONE
43 #define SPECENUM_VALUE0NAME N_("nothing")
44 #define SPECENUM_VALUE1 ASTK_BUILDING
45 #define SPECENUM_VALUE1NAME N_("buildings in")
46 #define SPECENUM_VALUE2 ASTK_TECH
47 #define SPECENUM_VALUE2NAME N_("techs from")
48 #define SPECENUM_VALUE3 ASTK_EXTRA
49 #define SPECENUM_VALUE3NAME N_("extras on")
50 #define SPECENUM_VALUE4 ASTK_EXTRA_NOT_THERE
51 #define SPECENUM_VALUE4NAME N_("create extras on")
52 #define SPECENUM_COUNT ASTK_COUNT
53 #include "specenum_gen.h"
54 
55 // Values used in the network protocol.
56 // Names used in file formats but not normally shown to users.
57 #define SPECENUM_NAME gen_action
58 #define SPECENUM_VALUE0 ACTION_ESTABLISH_EMBASSY
59 #define SPECENUM_VALUE0NAME "Establish Embassy"
60 #define SPECENUM_VALUE1 ACTION_ESTABLISH_EMBASSY_STAY
61 #define SPECENUM_VALUE1NAME "Establish Embassy Stay"
62 #define SPECENUM_VALUE2 ACTION_SPY_INVESTIGATE_CITY
63 #define SPECENUM_VALUE2NAME "Investigate City"
64 #define SPECENUM_VALUE3 ACTION_INV_CITY_SPEND
65 #define SPECENUM_VALUE3NAME "Investigate City Spend Unit"
66 #define SPECENUM_VALUE4 ACTION_SPY_POISON
67 #define SPECENUM_VALUE4NAME "Poison City"
68 #define SPECENUM_VALUE5 ACTION_SPY_POISON_ESC
69 #define SPECENUM_VALUE5NAME "Poison City Escape"
70 #define SPECENUM_VALUE6 ACTION_SPY_STEAL_GOLD
71 #define SPECENUM_VALUE6NAME "Steal Gold"
72 #define SPECENUM_VALUE7 ACTION_SPY_STEAL_GOLD_ESC
73 #define SPECENUM_VALUE7NAME "Steal Gold Escape"
74 #define SPECENUM_VALUE8 ACTION_SPY_SABOTAGE_CITY
75 #define SPECENUM_VALUE8NAME "Sabotage City"
76 #define SPECENUM_VALUE9 ACTION_SPY_SABOTAGE_CITY_ESC
77 #define SPECENUM_VALUE9NAME "Sabotage City Escape"
78 #define SPECENUM_VALUE10 ACTION_SPY_TARGETED_SABOTAGE_CITY
79 #define SPECENUM_VALUE10NAME "Targeted Sabotage City"
80 #define SPECENUM_VALUE11 ACTION_SPY_TARGETED_SABOTAGE_CITY_ESC
81 #define SPECENUM_VALUE11NAME "Targeted Sabotage City Escape"
82 #define SPECENUM_VALUE12 ACTION_SPY_SABOTAGE_CITY_PRODUCTION
83 #define SPECENUM_VALUE12NAME "Sabotage City Production"
84 #define SPECENUM_VALUE13 ACTION_SPY_SABOTAGE_CITY_PRODUCTION_ESC
85 #define SPECENUM_VALUE13NAME "Sabotage City Production Escape"
86 #define SPECENUM_VALUE14 ACTION_SPY_STEAL_TECH
87 #define SPECENUM_VALUE14NAME "Steal Tech"
88 #define SPECENUM_VALUE15 ACTION_SPY_STEAL_TECH_ESC
89 #define SPECENUM_VALUE15NAME "Steal Tech Escape Expected"
90 #define SPECENUM_VALUE16 ACTION_SPY_TARGETED_STEAL_TECH
91 #define SPECENUM_VALUE16NAME "Targeted Steal Tech"
92 #define SPECENUM_VALUE17 ACTION_SPY_TARGETED_STEAL_TECH_ESC
93 #define SPECENUM_VALUE17NAME "Targeted Steal Tech Escape Expected"
94 #define SPECENUM_VALUE18 ACTION_SPY_INCITE_CITY
95 #define SPECENUM_VALUE18NAME "Incite City"
96 #define SPECENUM_VALUE19 ACTION_SPY_INCITE_CITY_ESC
97 #define SPECENUM_VALUE19NAME "Incite City Escape"
98 #define SPECENUM_VALUE20 ACTION_TRADE_ROUTE
99 #define SPECENUM_VALUE20NAME "Establish Trade Route"
100 #define SPECENUM_VALUE21 ACTION_MARKETPLACE
101 #define SPECENUM_VALUE21NAME "Enter Marketplace"
102 #define SPECENUM_VALUE22 ACTION_HELP_WONDER
103 #define SPECENUM_VALUE22NAME "Help Wonder"
104 #define SPECENUM_VALUE23 ACTION_SPY_BRIBE_UNIT
105 #define SPECENUM_VALUE23NAME "Bribe Unit"
106 #define SPECENUM_VALUE24 ACTION_SPY_SABOTAGE_UNIT
107 #define SPECENUM_VALUE24NAME "Sabotage Unit"
108 #define SPECENUM_VALUE25 ACTION_SPY_SABOTAGE_UNIT_ESC
109 #define SPECENUM_VALUE25NAME "Sabotage Unit Escape"
110 #define SPECENUM_VALUE26 ACTION_CAPTURE_UNITS
111 #define SPECENUM_VALUE26NAME "Capture Units"
112 #define SPECENUM_VALUE27 ACTION_FOUND_CITY
113 #define SPECENUM_VALUE27NAME "Found City"
114 #define SPECENUM_VALUE28 ACTION_JOIN_CITY
115 #define SPECENUM_VALUE28NAME "Join City"
116 #define SPECENUM_VALUE29 ACTION_STEAL_MAPS
117 #define SPECENUM_VALUE29NAME "Steal Maps"
118 #define SPECENUM_VALUE30 ACTION_STEAL_MAPS_ESC
119 #define SPECENUM_VALUE30NAME "Steal Maps Escape"
120 #define SPECENUM_VALUE31 ACTION_BOMBARD
121 #define SPECENUM_VALUE31NAME "Bombard"
122 #define SPECENUM_VALUE32 ACTION_BOMBARD2
123 #define SPECENUM_VALUE32NAME "Bombard 2"
124 #define SPECENUM_VALUE33 ACTION_BOMBARD3
125 #define SPECENUM_VALUE33NAME "Bombard 3"
126 #define SPECENUM_VALUE34 ACTION_SPY_NUKE
127 #define SPECENUM_VALUE34NAME "Suitcase Nuke"
128 #define SPECENUM_VALUE35 ACTION_SPY_NUKE_ESC
129 #define SPECENUM_VALUE35NAME "Suitcase Nuke Escape"
130 #define SPECENUM_VALUE36 ACTION_NUKE
131 #define SPECENUM_VALUE36NAME "Explode Nuclear"
132 #define SPECENUM_VALUE37 ACTION_NUKE_CITY
133 #define SPECENUM_VALUE37NAME "Nuke City"
134 #define SPECENUM_VALUE38 ACTION_NUKE_UNITS
135 #define SPECENUM_VALUE38NAME "Nuke Units"
136 #define SPECENUM_VALUE39 ACTION_DESTROY_CITY
137 #define SPECENUM_VALUE39NAME "Destroy City"
138 #define SPECENUM_VALUE40 ACTION_EXPEL_UNIT
139 #define SPECENUM_VALUE40NAME "Expel Unit"
140 #define SPECENUM_VALUE41 ACTION_RECYCLE_UNIT
141 #define SPECENUM_VALUE41NAME "Recycle Unit"
142 #define SPECENUM_VALUE42 ACTION_DISBAND_UNIT
143 #define SPECENUM_VALUE42NAME "Disband Unit"
144 #define SPECENUM_VALUE43 ACTION_HOME_CITY
145 #define SPECENUM_VALUE43NAME "Home City"
146 #define SPECENUM_VALUE44 ACTION_UPGRADE_UNIT
147 #define SPECENUM_VALUE44NAME "Upgrade Unit"
148 #define SPECENUM_VALUE45 ACTION_PARADROP
149 #define SPECENUM_VALUE45NAME "Paradrop Unit"
150 #define SPECENUM_VALUE46 ACTION_AIRLIFT
151 #define SPECENUM_VALUE46NAME "Airlift Unit"
152 #define SPECENUM_VALUE47 ACTION_ATTACK
153 #define SPECENUM_VALUE47NAME "Attack"
154 #define SPECENUM_VALUE48 ACTION_SUICIDE_ATTACK
155 #define SPECENUM_VALUE48NAME "Suicide Attack"
156 #define SPECENUM_VALUE49 ACTION_STRIKE_BUILDING
157 #define SPECENUM_VALUE49NAME "Surgical Strike Building"
158 #define SPECENUM_VALUE50 ACTION_STRIKE_PRODUCTION
159 #define SPECENUM_VALUE50NAME "Surgical Strike Production"
160 #define SPECENUM_VALUE51 ACTION_CONQUER_CITY
161 #define SPECENUM_VALUE51NAME "Conquer City"
162 #define SPECENUM_VALUE52 ACTION_CONQUER_CITY2
163 #define SPECENUM_VALUE52NAME "Conquer City 2"
164 #define SPECENUM_VALUE53 ACTION_HEAL_UNIT
165 #define SPECENUM_VALUE53NAME "Heal Unit"
166 #define SPECENUM_VALUE54 ACTION_TRANSFORM_TERRAIN
167 #define SPECENUM_VALUE54NAME "Transform Terrain"
168 #define SPECENUM_VALUE55 ACTION_CULTIVATE
169 #define SPECENUM_VALUE55NAME "Cultivate"
170 #define SPECENUM_VALUE56 ACTION_PLANT
171 #define SPECENUM_VALUE56NAME "Plant"
172 #define SPECENUM_VALUE57 ACTION_PILLAGE
173 #define SPECENUM_VALUE57NAME "Pillage"
174 #define SPECENUM_VALUE58 ACTION_FORTIFY
175 #define SPECENUM_VALUE58NAME "Fortify"
176 #define SPECENUM_VALUE59 ACTION_ROAD
177 #define SPECENUM_VALUE59NAME "Build Road"
178 #define SPECENUM_VALUE60 ACTION_CONVERT
179 #define SPECENUM_VALUE60NAME "Convert Unit"
180 #define SPECENUM_VALUE61 ACTION_BASE
181 #define SPECENUM_VALUE61NAME "Build Base"
182 #define SPECENUM_VALUE62 ACTION_MINE
183 #define SPECENUM_VALUE62NAME "Build Mine"
184 #define SPECENUM_VALUE63 ACTION_IRRIGATE
185 #define SPECENUM_VALUE63NAME "Build Irrigation"
186 #define SPECENUM_VALUE64 ACTION_CLEAN_POLLUTION
187 #define SPECENUM_VALUE64NAME "Clean Pollution"
188 #define SPECENUM_VALUE65 ACTION_CLEAN_FALLOUT
189 #define SPECENUM_VALUE65NAME "Clean Fallout"
190 #define SPECENUM_VALUE66 ACTION_TRANSPORT_ALIGHT
191 #define SPECENUM_VALUE66NAME "Transport Alight"
192 #define SPECENUM_VALUE67 ACTION_TRANSPORT_UNLOAD
193 #define SPECENUM_VALUE67NAME "Transport Unload"
194 #define SPECENUM_VALUE68 ACTION_TRANSPORT_DISEMBARK1
195 #define SPECENUM_VALUE68NAME "Transport Disembark"
196 #define SPECENUM_VALUE69 ACTION_TRANSPORT_DISEMBARK2
197 #define SPECENUM_VALUE69NAME "Transport Disembark 2"
198 #define SPECENUM_VALUE70 ACTION_TRANSPORT_BOARD
199 #define SPECENUM_VALUE70NAME "Transport Board"
200 #define SPECENUM_VALUE71 ACTION_TRANSPORT_EMBARK
201 #define SPECENUM_VALUE71NAME "Transport Embark"
202 #define SPECENUM_VALUE72 ACTION_SPY_SPREAD_PLAGUE
203 #define SPECENUM_VALUE72NAME "Spread Plague"
204 #define SPECENUM_VALUE73 ACTION_SPY_ATTACK
205 #define SPECENUM_VALUE73NAME "Spy Attack"
206 #define SPECENUM_VALUE74 ACTION_USER_ACTION1
207 #define SPECENUM_VALUE74NAME "User Action 1"
208 #define SPECENUM_VALUE75 ACTION_USER_ACTION2
209 #define SPECENUM_VALUE75NAME "User Action 2"
210 #define SPECENUM_VALUE76 ACTION_USER_ACTION3
211 #define SPECENUM_VALUE76NAME "User Action 3"
212 #define SPECENUM_BITVECTOR bv_actions
213 #define SPECENUM_COUNT ACTION_COUNT
214 #include "specenum_gen.h"
215 
216 // Fake action id used in searches to signal "any action at all".
217 #define ACTION_ANY ACTION_COUNT
218 
219 // Fake action id used to signal the absence of any actions.
220 #define ACTION_NONE ACTION_COUNT
221 
222 // Used in the network protocol.
223 #define MAX_NUM_ACTIONS ACTION_COUNT
224 #define NUM_ACTIONS MAX_NUM_ACTIONS
225 
226 /* A battle is against a defender that tries to stop the action where the
227  * defender is in danger. A dice roll without a defender risking anything,
228  * like the roll controlled by EFT_ACTION_ODDS_PCT, isn't a battle. */
229 #define SPECENUM_NAME action_battle_kind
230 #define SPECENUM_VALUE0 ABK_NONE
231 #define SPECENUM_VALUE0NAME N_("no battle")
232 #define SPECENUM_VALUE1 ABK_STANDARD
233 #define SPECENUM_VALUE1NAME N_("battle")
234 #define SPECENUM_VALUE2 ABK_DIPLOMATIC
235 #define SPECENUM_VALUE2NAME N_("diplomatic battle")
236 #define SPECENUM_COUNT ABK_COUNT
237 #include "specenum_gen.h"
238 
239 // Describes how a unit sucessfully performing an action will move it.
240 #define SPECENUM_NAME moves_actor_kind
241 #define SPECENUM_VALUE0 MAK_STAYS
242 #define SPECENUM_VALUE0NAME N_("stays")
243 #define SPECENUM_VALUE1 MAK_REGULAR
244 #define SPECENUM_VALUE1NAME N_("regular")
245 #define SPECENUM_VALUE2 MAK_TELEPORT
246 #define SPECENUM_VALUE2NAME N_("teleport")
247 #define SPECENUM_VALUE3 MAK_ESCAPE
248 #define SPECENUM_VALUE3NAME N_("escape")
249 #define SPECENUM_VALUE4 MAK_FORCED
250 #define SPECENUM_VALUE4NAME N_("forced")
251 #define SPECENUM_VALUE5 MAK_UNREPRESENTABLE
252 #define SPECENUM_VALUE5NAME N_("unrepresentable")
253 #include "specenum_gen.h"
254 
255 // Who ordered the action to be performed?
256 #define SPECENUM_NAME action_requester
257 // The player ordered it directly.
258 #define SPECENUM_VALUE0 ACT_REQ_PLAYER
259 #define SPECENUM_VALUE0NAME N_("the player")
260 // The game it self because the rules requires it.
261 #define SPECENUM_VALUE1 ACT_REQ_RULES
262 #define SPECENUM_VALUE1NAME N_("the game rules")
263 // A server side autonomous agent working for the player.
264 #define SPECENUM_VALUE2 ACT_REQ_SS_AGENT
265 #define SPECENUM_VALUE2NAME N_("a server agent")
266 // Number of action requesters.
267 #define SPECENUM_COUNT ACT_REQ_COUNT
268 #include "specenum_gen.h"
269 
270 /* The last action distance value that is interpreted as an actual
271  * distance rather than as a signal value.
272  *
273  * It is specified literally rather than referring to MAP_DISTANCE_MAX
274  * because Freeciv-web's MAP_DISTANCE_MAX differs from the regular Freeciv
275  * server's MAP_DISTANCE_MAX. A static assertion in actions.c makes sure
276  * that it can cover the whole map. */
277 #define ACTION_DISTANCE_LAST_NON_SIGNAL 128016
278 // No action max distance to target limit.
279 #define ACTION_DISTANCE_UNLIMITED (ACTION_DISTANCE_LAST_NON_SIGNAL + 1)
280 // No action max distance can be bigger than this.
281 #define ACTION_DISTANCE_MAX ACTION_DISTANCE_UNLIMITED
282 
283 // Action target complexity
284 #define SPECENUM_NAME act_tgt_compl
285 /* The action's target is just the primary target. (Just the tile, unit,
286  * city, etc). */
287 #define SPECENUM_VALUE0 ACT_TGT_COMPL_SIMPLE
288 #define SPECENUM_VALUE0NAME N_("simple")
289 /* The action's target is complex because its target is the primary target
290  * and a sub target. (Examples: Tile + Extra and City + Building.) The
291  * player is able to specify details about this action but the server will
292  * fill in missing details so a client can choose to not specify the sub
293  * target. */
294 #define SPECENUM_VALUE1 ACT_TGT_COMPL_FLEXIBLE
295 #define SPECENUM_VALUE1NAME N_("flexible")
296 /* The action's target is complex because its target is the primary target
297  * and a sub target. (Examples: Tile + Extra and City + Building.) The
298  * player is required to specify details about this action because the
299  * server won't fill inn the missing details when unspecified. A client must
300  * therefore specify the sub target of this action. */
301 #define SPECENUM_VALUE2 ACT_TGT_COMPL_MANDATORY
302 #define SPECENUM_VALUE2NAME N_("mandatory")
303 #include "specenum_gen.h"
304 
305 struct action {
307 
308  enum action_result result;
309 
310  enum action_actor_kind actor_kind;
311  enum action_target_kind target_kind;
312  enum action_sub_target_kind sub_target_kind;
313 
314  // Sub target policy.
315  enum act_tgt_compl target_complexity;
316 
317  /* Limits on the distance on the map between the actor and the target.
318  * The action is legal iff the distance is min_distance, max_distance or
319  * a value in between. */
321 
322  // The name of the action shown in the UI
324 
325  /* Suppress automatic help text generation about what enables and/or
326  * disables this action. */
327  bool quiet;
328 
329  /* Actions that blocks this action. The action will be illegal if any
330  * bloking action is legal. */
331  bv_actions blocked_by;
332 
333  /* Successfully performing this action will always consume the actor.
334  * Don't set this for actions that consumes the unit in some cases
335  * (depending on luck, the presence of a flag, etc) but not in other
336  * cases. */
338 
339  union {
340  struct {
341  /* A unit's ability to perform this action will pop up the action
342  * selection dialog before the player asks for it only in exceptional
343  * cases.
344  *
345  * The motivation for setting rare_pop_up is to minimize player
346  * annoyance and mistakes. Getting a pop up every time a unit moves is
347  * annoying. An unexpected offer to do something that in many cases is
348  * destructive can lead the player's muscle memory to perform the
349  * wrong action. */
351 
352  // The unitwaittime setting blocks this action when done too soon.
354 
355  /* How successfully performing the specified action always will move
356  * the actor unit of the specified type. */
357  enum moves_actor_kind moves_actor;
359  } actor;
360 };
361 
363  bool disabled;
365  struct requirement_vector actor_reqs;
366  struct requirement_vector target_reqs;
367 };
368 
369 #define enabler_get_action(_enabler_) action_by_number(_enabler_->action)
370 
371 #define SPECLIST_TAG action_enabler
372 #define SPECLIST_TYPE struct action_enabler
373 #include "speclist.h"
374 #define action_enabler_list_iterate(action_enabler_list, aenabler) \
375  TYPED_LIST_ITERATE(struct action_enabler, action_enabler_list, aenabler)
376 #define action_enabler_list_iterate_end LIST_ITERATE_END
377 
378 #define action_iterate(_act_) \
379  { \
380  action_id _act_; \
381  for (_act_ = 0; _act_ < NUM_ACTIONS; _act_++) {
382 
383 #define action_iterate_end \
384  } \
385  }
386 
387 #define action_by_result_iterate(_paction_, _act_id_, _result_) \
388  { \
389  action_iterate(_act_id_) \
390  { \
391  struct action *_paction_ = action_by_number(_act_id_); \
392  if (!action_has_result(_paction_, _result_)) { \
393  continue; \
394  }
395 
396 #define action_by_result_iterate_end \
397  } \
398  action_iterate_end; \
399  }
400 
401 #define action_list_iterate(_act_list_, _act_id_) \
402  { \
403  int _pos_; \
404  \
405  for (_pos_ = 0; _pos_ < NUM_ACTIONS; _pos_++) { \
406  const action_id _act_id_ = _act_list_[_pos_]; \
407  \
408  if (_act_id_ == ACTION_NONE) { \
409  /* No more actions in this list. */ \
410  break; \
411  }
412 
413 #define action_list_iterate_end \
414  } \
415  }
416 
417 #define action_enablers_iterate(_enabler_) \
418  { \
419  action_iterate(_act_) \
420  { \
421  action_enabler_list_iterate(action_enablers_for_action(_act_), \
422  _enabler_) \
423  {
424 
425 #define action_enablers_iterate_end \
426  } \
427  action_enabler_list_iterate_end; \
428  } \
429  action_iterate_end; \
430  }
431 
432 // The reason why an action should be auto performed.
433 #define SPECENUM_NAME action_auto_perf_cause
434 // Can't pay the unit's upkeep.
435 // (Can be triggered by food, shield or gold upkeep)
436 #define SPECENUM_VALUE0 AAPC_UNIT_UPKEEP
437 #define SPECENUM_VALUE0NAME N_("Unit Upkeep")
438 // A unit moved to an adjacent tile (auto attack).
439 #define SPECENUM_VALUE1 AAPC_UNIT_MOVED_ADJ
440 #define SPECENUM_VALUE1NAME N_("Moved Adjacent")
441 // Number of forced action auto performer causes.
442 #define SPECENUM_COUNT AAPC_COUNT
443 #include "specenum_gen.h"
444 
445 /* An Action Auto Performer rule makes an actor try to perform an action
446  * without being ordered to do so by the player controlling it.
447  * - the first auto performer that matches the cause and fulfills the reqs
448  * is selected.
449  * - the actions listed by the selected auto performer is tried in order
450  * until an action is successful, all actions have been tried or the
451  * actor disappears.
452  * - if no action inside the selected auto performer is legal no action is
453  * performed. The system won't try to select another auto performer.
454  */
456  // The reason for trying to auto perform an action.
457  enum action_auto_perf_cause cause;
458 
459  /* Must be fulfilled if the game should try to force an action from this
460  * action auto performer. */
461  struct requirement_vector reqs;
462 
463  /* Auto perform the first legal action in this list.
464  * The list is terminated by ACTION_NONE. */
466 };
467 
468 #define action_auto_perf_iterate(_act_perf_) \
469  { \
470  int _ap_num_; \
471  \
472  for (_ap_num_ = 0; \
473  _ap_num_ < MAX_NUM_ACTION_AUTO_PERFORMERS \
474  && (action_auto_perf_by_number(_ap_num_)->cause != AAPC_COUNT); \
475  _ap_num_++) { \
476  const struct action_auto_perf *_act_perf_ = \
477  action_auto_perf_by_number(_ap_num_);
478 
479 #define action_auto_perf_iterate_end \
480  } \
481  }
482 
483 #define action_auto_perf_by_cause_iterate(_cause_, _act_perf_) \
484  action_auto_perf_iterate(_act_perf_) \
485  { \
486  if (_act_perf_->cause != _cause_) { \
487  continue; \
488  }
489 
490 #define action_auto_perf_by_cause_iterate_end \
491  } \
492  action_auto_perf_iterate_end
493 
494 #define action_auto_perf_actions_iterate(_autoperf_, _act_id_) \
495  action_list_iterate(_autoperf_->alternatives, _act_id_)
496 
497 #define action_auto_perf_actions_iterate_end action_list_iterate_end
498 
499 /* Hard coded location of action auto performers. Used for conversion while
500  * action auto performers aren't directly exposed to the ruleset. */
501 #define ACTION_AUTO_UPKEEP_FOOD 0
502 #define ACTION_AUTO_UPKEEP_GOLD 1
503 #define ACTION_AUTO_UPKEEP_SHIELD 2
504 #define ACTION_AUTO_MOVED_ADJ 3
505 
506 // Initialization
507 void actions_init();
509 void actions_free();
510 
511 bool actions_are_ready();
512 
513 bool action_id_exists(const action_id act_id);
514 
515 struct action *action_by_number(action_id act_id);
516 struct action *action_by_rule_name(const char *name);
517 
518 enum action_actor_kind action_get_actor_kind(const struct action *paction);
519 #define action_id_get_actor_kind(act_id) \
520  action_get_actor_kind(action_by_number(act_id))
521 enum action_target_kind action_get_target_kind(const struct action *paction);
522 #define action_id_get_target_kind(act_id) \
523  action_get_target_kind(action_by_number(act_id))
524 enum action_sub_target_kind
525 action_get_sub_target_kind(const struct action *paction);
526 #define action_id_get_sub_target_kind(act_id) \
527  action_get_sub_target_kind(action_by_number(act_id))
528 
529 enum action_battle_kind action_get_battle_kind(const struct action *pact);
530 
531 int action_number(const struct action *action);
532 
533 bool action_has_result(const struct action *paction,
534  enum action_result result);
535 #define action_has_result_safe(paction, result) \
536  (paction && action_has_result(paction, result))
537 #define action_id_has_result_safe(act_id, result) \
538  (action_by_number(act_id) \
539  && action_has_result(action_by_number(act_id), result))
540 
541 bool action_has_complex_target(const struct action *paction);
542 #define action_id_has_complex_target(act_id) \
543  action_has_complex_target(action_by_number(act_id))
544 bool action_requires_details(const struct action *paction);
545 #define action_id_requires_details(act_id) \
546  action_requires_details(action_by_number(act_id))
547 
548 int action_get_act_time(const struct action *paction,
549  const struct unit *actor_unit,
550  const struct tile *tgt_tile,
551  const struct extra_type *tgt_extra);
552 #define action_id_get_act_time(act_id, actor_unit, tgt_tile, tgt_extra) \
553  action_get_act_time(action_by_number(act_id), actor_unit, tgt_tile, \
554  tgt_extra)
555 
556 bool action_creates_extra(const struct action *paction,
557  const struct extra_type *pextra);
558 bool action_removes_extra(const struct action *paction,
559  const struct extra_type *pextra);
560 
562 
563 bool action_distance_accepted(const struct action *action,
564  const int distance);
565 #define action_id_distance_accepted(act_id, distance) \
566  action_distance_accepted(action_by_number(act_id), distance)
567 
568 bool action_distance_inside_max(const struct action *action,
569  const int distance);
570 #define action_id_distance_inside_max(act_id, distance) \
571  action_distance_inside_max(action_by_number(act_id), distance)
572 
573 bool action_would_be_blocked_by(const struct action *blocked,
574  const struct action *blocker);
575 #define action_id_would_be_blocked_by(blocked_id, blocker_id) \
576  action_would_be_blocked_by(action_by_number(blocked_id), \
577  action_by_number(blocker_id))
578 
579 int action_get_role(const struct action *paction);
580 #define action_id_get_role(act_id) action_get_role(action_by_number(act_id))
581 
582 enum unit_activity action_get_activity(const struct action *paction);
583 #define action_id_get_activity(act_id) \
584  action_get_activity(action_by_number(act_id))
585 
586 const char *action_rule_name(const struct action *action);
587 const char *action_id_rule_name(action_id act_id);
588 
589 const QString action_name_translation(const struct action *action);
590 const QString action_id_name_translation(action_id act_id);
591 const QString action_prepare_ui_name(action_id act_id, const char *mnemonic,
592  const struct act_prob prob,
593  const QString &custom);
594 
595 const char *action_ui_name_ruleset_var_name(int act);
596 const char *action_ui_name_default(int act);
597 
598 const char *action_min_range_ruleset_var_name(int act);
599 int action_min_range_default(int act);
600 const char *action_max_range_ruleset_var_name(int act);
601 int action_max_range_default(int act);
602 
603 const char *action_target_kind_ruleset_var_name(int act);
605 
606 struct action_enabler_list *action_enablers_for_action(action_id action);
607 
609 void action_enabler_free(struct action_enabler *enabler);
610 struct action_enabler *
611 action_enabler_copy(const struct action_enabler *original);
612 void action_enabler_add(struct action_enabler *enabler);
613 bool action_enabler_remove(struct action_enabler *enabler);
614 
615 struct req_vec_problem *
617 struct req_vec_problem *
618 action_enabler_suggest_repair(const struct action_enabler *enabler);
619 struct req_vec_problem *
621 
623 action_enabler_vector_number(const void *enabler,
624  const struct requirement_vector *vec);
625 struct requirement_vector *
626 action_enabler_vector_by_number(const void *enabler,
627  req_vec_num_in_item vec);
629 
630 struct action *action_is_blocked_by(const action_id act_id,
631  const struct unit *actor_unit,
632  const struct tile *target_tile,
633  const struct city *target_city,
634  const struct unit *target_unit);
635 
636 bool is_action_enabled_unit_on_city(const action_id wanted_action,
637  const struct unit *actor_unit,
638  const struct city *target_city);
639 
640 bool is_action_enabled_unit_on_unit(const action_id wanted_action,
641  const struct unit *actor_unit,
642  const struct unit *target_unit);
643 
644 bool is_action_enabled_unit_on_units(const action_id wanted_action,
645  const struct unit *actor_unit,
646  const struct tile *target_tile);
647 
648 bool is_action_enabled_unit_on_tile(const action_id wanted_action,
649  const struct unit *actor_unit,
650  const struct tile *target_tile,
651  const struct extra_type *target_extra);
652 
653 bool is_action_enabled_unit_on_self(const action_id wanted_action,
654  const struct unit *actor_unit);
655 
656 struct act_prob action_prob_vs_city(const struct unit *actor,
657  const action_id act_id,
658  const struct city *victim);
659 
660 struct act_prob action_prob_vs_unit(const struct unit *actor,
661  const action_id act_id,
662  const struct unit *victim);
663 
664 struct act_prob action_prob_vs_units(const struct unit *actor,
665  const action_id act_id,
666  const struct tile *victims);
667 
668 struct act_prob action_prob_vs_tile(const struct unit *actor,
669  const action_id act_id,
670  const struct tile *victims,
671  const struct extra_type *target_extra);
672 
673 struct act_prob action_prob_self(const struct unit *actor,
674  const action_id act_id);
675 
676 struct act_prob action_prob_unit_vs_tgt(const struct action *paction,
677  const struct unit *act_unit,
678  const struct city *tgt_city,
679  const struct unit *tgt_unit,
680  const struct tile *tgt_tile,
681  const struct extra_type *sub_tgt);
682 
684  const struct unit *actor,
685  const struct city *actor_home,
686  const struct tile *actor_tile,
687  bool omniscient_cheat,
688  const struct city *target);
689 
691  const struct unit *actor,
692  const struct city *actor_home,
693  const struct tile *actor_tile,
694  bool omniscient_cheat,
695  const struct tile *target);
696 
698  action_id act_id, const struct unit *actor,
699  const struct city *actor_home, const struct tile *actor_tile,
700  bool omniscient_cheat, const struct tile *target_tile,
701  const struct extra_type *target_extra);
702 
704  const struct unit *actor,
705  const struct city *actor_home,
706  const struct tile *actor_tile,
707  bool omniscient_cheat);
708 
709 bool action_prob_possible(const struct act_prob probability);
710 
711 bool are_action_probabilitys_equal(const struct act_prob *ap1,
712  const struct act_prob *ap2);
713 
714 int action_prob_cmp_pessimist(const struct act_prob ap1,
715  const struct act_prob ap2);
716 
717 double action_prob_to_0_to_1_pessimist(const struct act_prob ap);
718 
719 struct act_prob action_prob_fall_back(const struct act_prob *ap1,
720  const struct act_prob *ap2);
721 
722 const QString action_prob_explain(const struct act_prob prob);
723 
729 
730 /* Special action probability values. Documented in fc_types.h's
731  * definition of struct act_prob. */
732 #define ACTPROB_IMPOSSIBLE action_prob_new_impossible()
733 #define ACTPROB_CERTAIN action_prob_new_certain()
734 #define ACTPROB_NA action_prob_new_not_relevant()
735 #define ACTPROB_NOT_IMPLEMENTED action_prob_new_not_impl()
736 #define ACTPROB_NOT_KNOWN action_prob_new_unknown()
737 
738 // ACTION_ODDS_PCT_DICE_ROLL_NA must be above 100%.
739 #define ACTION_ODDS_PCT_DICE_ROLL_NA 110
740 int action_dice_roll_initial_odds(const struct action *paction);
741 int action_dice_roll_odds(const struct player *act_player,
742  const struct unit *act_unit,
743  const struct city *tgt_city,
744  const struct player *tgt_player,
745  const struct action *paction);
746 
747 bool action_actor_utype_hard_reqs_ok(enum action_result result,
748  const struct unit_type *actor_unittype);
749 
750 // Reasoning about actions
751 bool action_univs_not_blocking(const struct action *paction,
752  struct universal *actor_uni,
753  struct universal *target_uni);
754 #define action_id_univs_not_blocking(act_id, act_uni, tgt_uni) \
755  action_univs_not_blocking(action_by_number(act_id), act_uni, tgt_uni)
756 
757 bool action_immune_government(struct government *gov, action_id act);
758 
760  const struct player *actor_player,
761  const struct city *target_city);
762 
763 bool is_action_possible_on_unit(action_id act_id, const unit *target_unit);
764 
765 bool action_maybe_possible_actor_unit(const action_id wanted_action,
766  const struct unit *actor_unit);
767 
768 bool action_mp_full_makes_legal(const struct unit *actor,
769  const action_id act_id);
770 
771 // Action lists
772 void action_list_end(action_id *act_list, int size);
773 void action_list_add_all_by_result(action_id *act_list, int *position,
774  enum action_result result);
775 
776 // Action auto performers
777 const struct action_auto_perf *action_auto_perf_by_number(const int num);
778 struct action_auto_perf *action_auto_perf_slot_number(const int num);
779 
780 // Find targets
781 struct city *action_tgt_city(struct unit *actor, struct tile *target_tile,
782  bool accept_all_actions);
783 
784 struct unit *action_tgt_unit(struct unit *actor, struct tile *target_tile,
785  bool accept_all_actions);
786 
787 struct tile *action_tgt_tile(struct unit *actor, struct tile *target_tile,
788  const struct extra_type *target_extra,
789  bool accept_all_actions);
790 
791 struct extra_type *action_tgt_tile_extra(const struct unit *actor,
792  const struct tile *target_tile,
793  bool accept_all_actions);
bool action_removes_extra(const struct action *paction, const struct extra_type *pextra)
Returns TRUE iff the specified action can remove the specified extra.
Definition: actions.cpp:1732
struct requirement_vector * action_enabler_vector_by_number(const void *enabler, req_vec_num_in_item vec)
Returns a writable pointer to the specified requirement vector in the action enabler or nullptr if th...
Definition: actions.cpp:2325
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: actions.cpp:5734
struct act_prob action_prob_vs_city(const struct unit *actor, const action_id act_id, const struct city *victim)
Get the actor unit's probability of successfully performing the chosen action on the target city.
Definition: actions.cpp:4809
bool is_action_enabled_unit_on_unit(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 concerne...
Definition: actions.cpp:4007
bool action_distance_inside_max(const struct action *action, const int distance)
Returns TRUE iff the specified distance between actor and target is sm,aller or equal to the max rang...
Definition: actions.cpp:1303
const char * action_max_range_ruleset_var_name(int act)
Return max range ruleset variable name for the action or nullptr if max range can't be set in the rul...
Definition: actions.cpp:6528
bool action_mp_full_makes_legal(const struct unit *actor, const action_id act_id)
Returns TRUE if the specified action can't be done now but would have been legal if the unit had full...
Definition: actions.cpp:5817
enum action_actor_kind action_get_actor_kind(const struct action *paction)
Get the actor kind of an action.
Definition: actions.cpp:1188
const char * action_rule_name(const struct action *action)
Get the rule name of the action.
Definition: actions.cpp:1343
void actions_init()
Initialize the actions and the action enablers.
Definition: actions.cpp:934
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 ena...
Definition: actions.cpp:2302
const QString action_prepare_ui_name(action_id act_id, const char *mnemonic, const struct act_prob prob, const QString &custom)
Get the UI name ready to show the action in the UI.
Definition: actions.cpp:1412
bool action_has_complex_target(const struct action *paction)
Returns TRUE iff the specified action allows the player to provide details in addition to actor and t...
Definition: actions.cpp:1262
bool action_prob_possible(const struct act_prob probability)
Returns TRUE iff the given action probability belongs to an action that may be possible.
Definition: actions.cpp:5380
struct act_prob action_prob_new_certain()
Returns the certain action probability.
Definition: actions.cpp:5339
struct extra_type * action_tgt_tile_extra(const struct unit *actor, const struct tile *target_tile, bool accept_all_actions)
Find an extra to target for an action at the specified tile.
Definition: actions.cpp:7191
struct action_enabler * action_enabler_copy(const struct action_enabler *original)
Create a new copy of an existing action enabler.
Definition: actions.cpp:1839
void action_list_end(action_id *act_list, int size)
Terminate an action list of the specified size.
Definition: actions.cpp:5881
struct unit * action_tgt_unit(struct unit *actor, struct tile *target_tile, bool accept_all_actions)
Find a unit to target for an action at the specified tile.
Definition: actions.cpp:7050
struct city * action_tgt_city(struct unit *actor, struct tile *target_tile, bool accept_all_actions)
Find a city to target for an action on the specified tile.
Definition: actions.cpp:6983
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: actions.cpp:5657
bool is_action_enabled_unit_on_self(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.
Definition: actions.cpp:4196
int action_get_act_time(const struct action *paction, const struct unit *actor_unit, const struct tile *tgt_tile, const struct extra_type *tgt_extra)
Returns the unit activity time (work) this action takes (requires) or ACT_TIME_INSTANTANEOUS if the a...
Definition: actions.cpp:1598
bool is_action_enabled_unit_on_city(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 concerne...
Definition: actions.cpp:3948
struct req_vec_problem * action_enabler_suggest_repair(const struct action_enabler *enabler)
Returns a suggestion to fix the specified action enabler or nullptr if no fix is found to be needed.
Definition: actions.cpp:2187
struct act_prob action_prob_new_not_relevant()
Returns the n/a action probability.
Definition: actions.cpp:5349
struct act_prob action_prob_unit_vs_tgt(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 *sub_tgt)
Returns the actor unit's probability of successfully performing the specified action against the acti...
Definition: actions.cpp:5163
const char * action_ui_name_ruleset_var_name(int act)
Return ui_name ruleset variable name for the action.
Definition: actions.cpp:5919
void actions_free()
Free the actions and the action enablers.
Definition: actions.cpp:994
struct act_prob action_prob_vs_unit(const struct unit *actor, const action_id act_id, const struct unit *victim)
Get the actor unit's probability of successfully performing the chosen action on the target unit.
Definition: actions.cpp:4871
bool are_action_probabilitys_equal(const struct act_prob *ap1, const struct act_prob *ap2)
Returns TRUE iff ap1 and ap2 are equal.
Definition: actions.cpp:5419
const QString action_prob_explain(const struct act_prob prob)
Explain an action probability in a way suitable for a tool tip for the button that starts it.
Definition: actions.cpp:1504
struct act_prob action_prob_new_not_impl()
Returns the "not implemented" action probability.
Definition: actions.cpp:5359
const char * action_ui_name_default(int act)
Return default ui_name for the action.
Definition: actions.cpp:6087
enum action_battle_kind action_get_battle_kind(const struct action *pact)
Get the battle kind that can prevent an action.
Definition: actions.cpp:1219
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 nullptr if no hard...
Definition: actions.cpp:1902
enum action_sub_target_kind action_get_sub_target_kind(const struct action *paction)
Get the sub target kind of an action.
Definition: actions.cpp:1209
bool action_maybe_possible_actor_unit(const action_id wanted_action, const struct unit *actor_unit)
Returns TRUE if the wanted action (as far as the player knows) can be performed right now by the spec...
Definition: actions.cpp:5765
void action_enabler_free(struct action_enabler *enabler)
Free resources allocated for the action enabler.
Definition: actions.cpp:1827
int action_max_range_default(int act)
Return default max range for the action if it is ruleset settable.
Definition: actions.cpp:6633
int action_number(const struct action *action)
Get the universal number of the action.
Definition: actions.cpp:1338
const char * action_actor_consuming_always_ruleset_var_name(action_id act)
Return actor consuming always ruleset variable name for the action or nullptr if actor consuming alwa...
Definition: actions.cpp:6836
bool is_action_enabled_unit_on_units(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 enab...
Definition: actions.cpp:4078
const char * action_min_range_ruleset_var_name(int act)
Return min range ruleset variable name for the action or nullptr if min range can't be set in the rul...
Definition: actions.cpp:6334
bool action_would_be_blocked_by(const struct action *blocked, const struct action *blocker)
Returns TRUE iff blocked will be illegal if blocker is legal.
Definition: actions.cpp:1326
struct action * action_by_rule_name(const char *name)
Return the action with the given name.
Definition: actions.cpp:1169
const QString action_name_translation(const struct action *action)
Get the action name used when displaying the action in the UI.
Definition: actions.cpp:1353
struct act_prob action_speculate_unit_on_self(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...
Definition: actions.cpp:5303
bool action_immune_government(struct government *gov, action_id act)
Will a player with the government gov be immune to the action act?
Definition: actions.cpp:5687
struct act_prob action_prob_self(const struct unit *actor, const action_id act_id)
Get the actor unit's probability of successfully performing the chosen action on itself.
Definition: actions.cpp:5145
struct act_prob action_speculate_unit_on_city(action_id act_id, const struct unit *actor, const struct city *actor_home, const struct tile *actor_tile, bool omniscient_cheat, const struct city *target)
Returns a speculation about the actor unit's probability of successfully performing the chosen action...
Definition: actions.cpp:5213
int action_dice_roll_initial_odds(const struct action *paction)
Returns the initial odds of an action not failing its dice roll.
Definition: actions.cpp:5580
struct act_prob action_prob_fall_back(const struct act_prob *ap1, const struct act_prob *ap2)
Returns ap1 with ap2 as fall back in cases where ap1 doesn't happen.
Definition: actions.cpp:5510
bool actions_are_ready()
Returns TRUE iff the actions are initialized.
Definition: actions.cpp:1037
struct act_prob action_prob_vs_units(const struct unit *actor, const action_id act_id, const struct tile *victims)
Get the actor unit's probability of successfully performing the chosen action on all units at the tar...
Definition: actions.cpp:5029
void action_list_add_all_by_result(action_id *act_list, int *position, enum action_result result)
Add all actions with the specified result to the specified action list starting at the specified posi...
Definition: actions.cpp:5898
struct act_prob action_speculate_unit_on_units(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...
Definition: actions.cpp:5243
#define MAX_NUM_ACTIONS
Definition: actions.h:223
bool action_univs_not_blocking(const struct action *paction, struct universal *actor_uni, struct universal *target_uni)
Is there any action enablers of the given type not blocked by universals?
Definition: actions.cpp:5856
bool is_action_enabled_unit_on_tile(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 conc...
Definition: actions.cpp:4136
const struct action_auto_perf * action_auto_perf_by_number(const int num)
Returns action auto performer rule number num.
Definition: actions.cpp:5848
const QString action_id_name_translation(action_id act_id)
Get the action name used when displaying the action in the UI.
Definition: actions.cpp:1373
struct tile * action_tgt_tile(struct unit *actor, struct tile *target_tile, const struct extra_type *target_extra, bool accept_all_actions)
Returns the tile iff it, from the point of view of the owner of the actor unit, looks like a target t...
Definition: actions.cpp:7078
const char * action_target_kind_ruleset_var_name(int act)
Return target kind ruleset variable name for the action or nullptr if min range can't be set in the r...
Definition: actions.cpp:6736
struct action_enabler * action_enabler_new()
Create a new action enabler.
Definition: actions.cpp:1810
void action_enabler_add(struct action_enabler *enabler)
Add an action enabler to the current ruleset.
Definition: actions.cpp:1854
struct action * action_by_number(action_id act_id)
Return the action with the given id.
Definition: actions.cpp:1149
enum unit_activity action_get_activity(const struct action *paction)
Returns the unit activity this action may cause or ACTIVITY_LAST if the action doesn't result in a un...
Definition: actions.cpp:1557
bool action_actor_utype_hard_reqs_ok(enum action_result result, const struct unit_type *actor_unittype)
Returns TRUE if the specified unit type can perform an action with the wanted result given that an ac...
Definition: actions.cpp:2776
bool action_requires_details(const struct action *paction)
Returns TRUE iff the specified action REQUIRES the player to provide details in addition to actor and...
Definition: actions.cpp:1275
int action_get_role(const struct action *paction)
Get the unit type role corresponding to the ability to do the specified action.
Definition: actions.cpp:1544
struct action * action_is_blocked_by(const action_id act_id, const struct unit *actor_unit, const struct tile *target_tile, const struct city *target_city, const struct unit *target_unit)
Returns the action that blocks the specified action or nullptr if the specified action isn't blocked.
Definition: actions.cpp:2530
int action_min_range_default(int act)
Return default min range for the action if it is ruleset settable.
Definition: actions.cpp:6430
struct req_vec_problem * action_enabler_suggest_improvement(const struct action_enabler *enabler)
Returns a suggestion to improve the specified action enabler or nullptr if nothing to improve is foun...
Definition: actions.cpp:2251
struct act_prob action_prob_new_impossible()
Returns the impossible action probability.
Definition: actions.cpp:5329
struct act_prob action_prob_vs_tile(const struct unit *actor, const action_id act_id, const struct tile *victims, const struct extra_type *target_extra)
Get the actor unit's probability of successfully performing the chosen action on the target tile.
Definition: actions.cpp:5090
bool action_id_exists(const action_id act_id)
Returns TRUE iff the specified action ID refers to a valid action.
Definition: actions.cpp:1138
bool action_enabler_remove(struct action_enabler *enabler)
Remove an action enabler from the current ruleset.
Definition: actions.cpp:1870
enum action_target_kind action_get_target_kind(const struct action *paction)
Get the target kind of an action.
Definition: actions.cpp:1198
bool action_has_result(const struct action *paction, enum action_result result)
Returns TRUE iff performing the specified action has the specified result.
Definition: actions.cpp:1248
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 nullptr if enablers...
Definition: actions.cpp:2349
bool action_creates_extra(const struct action *paction, const struct extra_type *pextra)
Returns TRUE iff the specified action can create the specified extra.
Definition: actions.cpp:1649
void actions_rs_pre_san_gen()
Generate action related data based on the currently loaded ruleset.
Definition: actions.cpp:984
int action_prob_cmp_pessimist(const struct act_prob ap1, const struct act_prob ap2)
Compare action probabilities.
Definition: actions.cpp:5428
bool action_id_is_rare_pop_up(action_id act_id)
Returns TRUE iff a unit's ability to perform this action will pop up the action selection dialog befo...
Definition: actions.cpp:1290
struct act_prob action_speculate_unit_on_tile(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...
Definition: actions.cpp:5273
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: actions.cpp:5832
double action_prob_to_0_to_1_pessimist(const struct act_prob ap)
Returns double in the range [0-1] representing the minimum of the given action probability.
Definition: actions.cpp:5479
struct act_prob action_prob_new_unknown()
Returns the "user don't know" action probability.
Definition: actions.cpp:5369
const char * action_id_rule_name(action_id act_id)
Get the rule name of the action.
Definition: actions.cpp:1362
bool is_action_possible_on_unit(action_id act_id, const unit *target_unit)
Checks if there is any hopes that the action is possible against the target unit (by chacking the tar...
Definition: actions.cpp:5752
bool action_distance_accepted(const struct action *action, const int distance)
Returns TRUE iff the specified distance between actor and target is within the range acceptable to th...
Definition: actions.cpp:1314
struct action_enabler_list * action_enablers_for_action(action_id action)
Get all enablers for an action in the current ruleset.
Definition: actions.cpp:1884
int action_id
Definition: fc_types.h:306
#define MAX_LEN_NAME
Definition: fc_types.h:61
const char * name
Definition: inputfile.cpp:118
signed char req_vec_num_in_item
req_vec_num_in_item a requirement vectors number in an item.
Definition: requirements.h:143
size_t size
Definition: specvec.h:64
struct requirement_vector reqs
Definition: actions.h:461
enum action_auto_perf_cause cause
Definition: actions.h:457
action_id alternatives[MAX_NUM_ACTIONS]
Definition: actions.h:465
bool disabled
Definition: actions.h:363
action_id action
Definition: actions.h:364
struct requirement_vector actor_reqs
Definition: actions.h:365
struct requirement_vector target_reqs
Definition: actions.h:366
struct action::@10::@11 is_unit
bool unitwaittime_controlled
Definition: actions.h:353
action_id id
Definition: actions.h:306
bool actor_consuming_always
Definition: actions.h:337
bool rare_pop_up
Definition: actions.h:350
int max_distance
Definition: actions.h:320
bool quiet
Definition: actions.h:327
enum action_sub_target_kind sub_target_kind
Definition: actions.h:312
enum moves_actor_kind moves_actor
Definition: actions.h:357
enum action_result result
Definition: actions.h:308
char ui_name[MAX_LEN_NAME]
Definition: actions.h:323
union action::@10 actor
enum action_actor_kind actor_kind
Definition: actions.h:310
enum act_tgt_compl target_complexity
Definition: actions.h:315
bv_actions blocked_by
Definition: actions.h:331
enum action_target_kind target_kind
Definition: actions.h:311
int min_distance
Definition: actions.h:320
Definition: city.h:291
Definition: player.h:231
Definition: tile.h:42
Definition: unit.h:134