Freeciv-3.3
Loading...
Searching...
No Matches
actiontools.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996-2015 - Freeciv Development Team
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18/* utility */
19#include "rand.h"
20
21/* common */
22#include "actions.h"
23
24/* server */
25#include "aiiface.h"
26#include "nation.h"
27#include "notify.h"
28#include "plrhand.h"
29#include "unithand.h"
30#include "unittools.h"
31
32#include "actiontools.h"
33
34typedef void (*action_notify)(struct player *,
35 const struct action *,
36 struct player *,
37 struct player *,
38 const struct tile *,
39 const char *);
40
41/**********************************************************************/
63
64/**********************************************************************/
68 int actor_id, struct unit *actor)
69{
70 if (unit_is_alive(actor_id)) {
74 }
75}
76
77/**********************************************************************/
81 int target_id, struct unit *target)
82{
83 if (unit_is_alive(target_id)) {
85 NULL,
86 &(const struct req_context) {
87 .player = unit_owner(target),
88 .city = unit_tile(target) ? tile_city(unit_tile(target)) : NULL,
89 .tile = unit_tile(target),
90 .unit = target,
91 .unittype = unit_type_get(target),
92 .action = paction,
93 },
94 NULL,
96
97 target->moves_left = MAX(0, target->moves_left - spent_mp);
98 send_unit_info(NULL, target);
99 }
100}
101
102/**********************************************************************/
106 int actor_id, struct unit *actor)
107{
110}
111
112/**********************************************************************/
116 struct player *victim_player,
117 const bool int_outrage)
118{
119 if (int_outrage) {
120 /* This action is seen as a reason for any other player, no matter who
121 * the victim was, to declare war on the actor. It could be used to
122 * label certain actions atrocities in rule sets where international
123 * outrage over an action fits the setting. */
124
126 if (oplayer != offender) {
129 }
131 } else if (victim_player && offender != victim_player) {
132 /* If an unclaimed tile is nuked there is no victim to give casus
133 * belli. If an actor nukes their own tile, they are more than willing
134 * to forgive themself. */
135
136 /* Give the victim player a casus belli. */
138 2;
140 }
142}
143
144/**********************************************************************/
150static void action_consequence_common(const struct action *paction,
151 struct player *offender,
152 const struct unit_type *offender_utype,
153 struct player *victim_player,
154 const struct tile *victim_tile,
155 const char *victim_link,
159 const enum effect_type eft)
160{
162
165
166 if (cbr >= CBR_VICTIM_ONLY) {
167 /* In this situation the specified action provides a casus belli
168 * against the actor. */
169
170 /* International outrage: This isn't just between the offender and the
171 * victim. */
172 const bool int_outrage = (cbr == CBR_INTERNATIONAL_OUTRAGE);
173
174 /* Notify the involved players by sending them a message. */
179
180 if (int_outrage) {
181 /* Every other player gets a casus belli against the actor. Tell each
182 * players about it. */
187 }
188
189 /* Give casus belli. */
191
192 /* Notify players controlled by the built in AI. */
194
195 /* Update the clients. */
197
199 /* The actor player was just sent. */
200 /* An action against an ownerless tile is victimless. */
202 }
203 }
204}
205
206/**********************************************************************/
210static void notify_actor_caught(struct player *receiver,
211 const struct action *paction,
212 struct player *offender,
213 struct player *victim_player,
214 const struct tile *victim_tile,
215 const char *victim_link)
216{
218 /* There is no victim or the actor did this to themself. */
219 return;
220 }
221
222 /* Custom message based on action type. */
224 case ATK_CITY:
225 notify_player(receiver, victim_tile,
227 /* TRANS: Suitcase Nuke ... San Francisco */
228 _("You have caused an diplomatic incident getting caught"
229 " trying to do %s to %s."),
232 break;
233 case ATK_UNIT:
234 case ATK_UNITS:
235 notify_player(receiver, victim_tile,
237 /* TRANS: Bribe Enemy Unit ... American ... Partisan */
238 _("You have caused an diplomatic incident getting caught"
239 " trying to do %s to %s %s."),
243 break;
244 case ATK_TILE:
245 case ATK_EXTRAS:
246 notify_player(receiver, victim_tile,
248 /* TRANS: Explode Nuclear ... (54, 26) */
249 _("You have caused an diplomatic incident getting caught"
250 " trying to do %s at %s."),
253 break;
254 case ATK_SELF:
255 /* Special actor notice not needed. Actor is victim. */
256 break;
257 case ATK_COUNT:
259 break;
260 }
261}
262
263/**********************************************************************/
267static void notify_victim_caught(struct player *receiver,
268 const struct action *paction,
269 struct player *offender,
270 struct player *victim_player,
271 const struct tile *victim_tile,
272 const char *victim_link)
273{
275 /* There is no victim or the actor did this to themself. */
276 return;
277 }
278
279 /* Custom message based on action type. */
281 case ATK_CITY:
282 notify_player(receiver, victim_tile,
284 /* TRANS: Europeans ... Suitcase Nuke ... San Francisco */
285 _("The %s have caused an diplomatic incident getting caught"
286 " trying to do %s to %s."),
290 break;
291 case ATK_UNIT:
292 case ATK_UNITS:
293 notify_player(receiver, victim_tile,
295 /* TRANS: Europeans ... Bribe Enemy Unit ... Partisan */
296 _("The %s have caused an diplomatic incident getting caught"
297 " trying to do %s to your %s."),
301 break;
302 case ATK_TILE:
303 case ATK_EXTRAS:
304 notify_player(receiver, victim_tile,
306 /* TRANS: Europeans ... Explode Nuclear ... (54, 26) */
307 _("The %s have caused an diplomatic incident getting caught"
308 " trying to do %s at %s."),
312 break;
313 case ATK_SELF:
314 /* Special victim notice not needed. Actor is victim. */
315 break;
316 case ATK_COUNT:
318 break;
319 }
320}
321
322/**********************************************************************/
326static void notify_global_caught(struct player *receiver,
327 const struct action *paction,
328 struct player *offender,
329 struct player *victim_player,
330 const struct tile *victim_tile,
331 const char *victim_link)
332{
333 if (receiver == offender) {
334 notify_player(receiver, victim_tile,
336 /* TRANS: Suitcase Nuke */
337 _("Getting caught while trying to do %s gives "
338 "everyone a casus belli against you."),
340 } else if (receiver == victim_player) {
341 notify_player(receiver, victim_tile,
343 /* TRANS: Suitcase Nuke ... Europeans */
344 _("Getting caught while trying to do %s to you gives "
345 "everyone a casus belli against the %s."),
348 } else if (victim_player == NULL) {
349 notify_player(receiver, victim_tile,
351 /* TRANS: Europeans ... Suitcase Nuke */
352 _("You now have a casus belli against the %s. "
353 "They got caught trying to do %s."),
356 } else {
357 notify_player(receiver, victim_tile,
359 /* TRANS: Europeans ... Suitcase Nuke ... Americans */
360 _("You now have a casus belli against the %s. "
361 "They got caught trying to do %s to the %s."),
365 }
366}
367
368/**********************************************************************/
388
389/**********************************************************************/
393static void notify_actor_success(struct player *receiver,
394 const struct action *paction,
395 struct player *offender,
396 struct player *victim_player,
397 const struct tile *victim_tile,
398 const char *victim_link)
399{
401 /* There is no victim or the actor did this to themself. */
402 return;
403 }
404
405 /* Custom message based on action type. */
407 case ATK_CITY:
408 notify_player(receiver, victim_tile,
410 /* TRANS: Suitcase Nuke ... San Francisco */
411 _("You have caused an diplomatic incident doing %s to %s."),
414 break;
415 case ATK_UNIT:
416 case ATK_UNITS:
417 notify_player(receiver, victim_tile,
419 /* TRAND: Bribe Enemy Unit ... American ... Partisan */
420 _("You have caused an diplomatic incident doing %s to %s %s."),
424 break;
425 case ATK_TILE:
426 case ATK_EXTRAS:
427 notify_player(receiver, victim_tile,
429 /* TRANS: Explode Nuclear ... (54, 26) */
430 _("You have caused an diplomatic incident doing %s at %s."),
433 break;
434 case ATK_SELF:
435 /* Special actor notice not needed. Actor is victim. */
436 break;
437 case ATK_COUNT:
439 break;
440 }
441}
442
443/**********************************************************************/
447static void notify_victim_success(struct player *receiver,
448 const struct action *paction,
449 struct player *offender,
450 struct player *victim_player,
451 const struct tile *victim_tile,
452 const char *victim_link)
453{
455 /* There is no victim or the actor did this to themself. */
456 return;
457 }
458
459 /* Custom message based on action type. */
461 case ATK_CITY:
462 notify_player(receiver, victim_tile,
464 /* TRANS: Europeans ... Suitcase Nuke ... San Francisco */
465 _("The %s have caused an diplomatic incident doing %s to %s."),
469 break;
470 case ATK_UNIT:
471 case ATK_UNITS:
472 notify_player(receiver, victim_tile,
474 /* TRANS: Europeans ... Bribe Enemy Unit ... Partisan */
475 _("The %s have caused an diplomatic incident doing "
476 "%s to your %s."),
480 break;
481 case ATK_TILE:
482 case ATK_EXTRAS:
483 notify_player(receiver, victim_tile,
485 /* TRANS: Europeans ... Explode Nuclear ... (54, 26) */
486 _("The %s have caused an diplomatic incident doing %s at %s."),
490 break;
491 case ATK_SELF:
492 /* Special victim notice not needed. Actor is victim. */
493 break;
494 case ATK_COUNT:
496 break;
497 }
498}
499
500/**********************************************************************/
504static void notify_global_success(struct player *receiver,
505 const struct action *paction,
506 struct player *offender,
507 struct player *victim_player,
508 const struct tile *victim_tile,
509 const char *victim_link)
510{
511 if (receiver == offender) {
512 notify_player(receiver, victim_tile,
514 /* TRANS: Suitcase Nuke */
515 _("Doing %s gives everyone a casus belli against you."),
517 } else if (receiver == victim_player) {
518 notify_player(receiver, victim_tile,
520 /* TRANS: Suitcase Nuke ... Europeans */
521 _("Doing %s to you gives everyone a casus belli against "
522 "the %s."),
525 } else if (victim_player == NULL) {
526 notify_player(receiver, victim_tile,
528 /* TRANS: Europeans ... Suitcase Nuke */
529 _("You now have a casus belli against the %s. "
530 "They did %s."),
533 } else {
534 notify_player(receiver, victim_tile,
536 /* TRANS: Europeans ... Suitcase Nuke ... Americans */
537 _("You now have a casus belli against the %s. "
538 "They did %s to the %s."),
542 }
543}
544
545/**********************************************************************/
565
566/**************************************************************************
567 Take care of any consequences (like casus belli) of successfully
568 completing the given action.
569
570 victim_player can be NULL
571**************************************************************************/
586
587/**********************************************************************/
599static bool may_unit_act_vs_city(struct unit *actor, struct city *target,
601{
602 const struct civ_map *nmap = &(wld.map);
603
604 if (actor == NULL || target == NULL) {
605 /* Can't do any actions if actor or target are missing. */
606 return FALSE;
607 }
608
609 action_iterate(act) {
612 /* Not a relevant action. */
613 continue;
614 }
615
617 /* Not relevant since not accepted here. */
618 continue;
619 }
620
622 /* The actor unit may be able to do this action to the target
623 * city. */
624 return TRUE;
625 }
627
628 return FALSE;
629}
630
631/**********************************************************************/
642{
643 struct city *target = tile_city(target_tile);
644
645 if (target && may_unit_act_vs_city(actor, target, accept_all_actions)) {
646 /* It may be possible to act against this city. */
647 return target;
648 }
649
650 return NULL;
651}
652
653/**********************************************************************/
665static bool may_unit_act_vs_unit(struct unit *actor, struct unit *target,
667{
668 const struct civ_map *nmap = &(wld.map);
669
670 if (actor == NULL || target == NULL) {
671 /* Can't do any actions if actor or target are missing. */
672 return FALSE;
673 }
674
675 action_iterate(act) {
678 /* Not a relevant action. */
679 continue;
680 }
681
683 /* Not relevant since not accepted here. */
684 continue;
685 }
686
688 /* The actor unit may be able to do this action to the target
689 * unit. */
690 return TRUE;
691 }
693
694 return FALSE;
695}
696
697/**********************************************************************/
709{
710 unit_list_iterate(target_tile->units, target) {
712 return target;
713 }
715
716 return NULL;
717}
718
719/**********************************************************************/
734 struct tile *target,
735 const struct extra_type *target_extra,
737{
738 if (actor == NULL || target == NULL) {
739 /* Can't do any actions if actor or target are missing. */
740 return NULL;
741 }
742
743 action_iterate(act) {
744 struct act_prob prob;
745
747 /* Not a relevant action. */
748 continue;
749 }
750
752 /* Not relevant since not accepted here. */
753 continue;
754 }
755
756 switch (action_id_get_target_kind(act)) {
757 case ATK_TILE:
758 prob = action_prob_vs_tile(actor, act, target, target_extra);
759 break;
760 case ATK_EXTRAS:
761 prob = action_prob_vs_extras(actor, act, target, target_extra);
762 break;
763 case ATK_UNITS:
764 prob = action_prob_vs_stack(actor, act, target);
765 break;
766 case ATK_CITY:
767 case ATK_UNIT:
768 case ATK_SELF:
769 /* Target not specified by tile. */
770 continue;
771 case ATK_COUNT:
772 /* Invalid target kind */
774 continue;
775 }
776
777 if (action_prob_possible(prob)) {
778 /* The actor unit may be able to do this action to the target
779 * tile. */
780 return target;
781 }
783
784 return NULL;
785}
786
787/**********************************************************************/
799static bool may_unit_act_vs_tile_extra(const struct unit *actor,
800 const struct tile *tgt_tile,
801 const struct extra_type *tgt_extra,
803{
804 if (actor == NULL || tgt_tile == NULL || tgt_extra == NULL) {
805 /* Can't do any actions if actor or target are missing. */
806 return FALSE;
807 }
808
809 action_iterate(act) {
814 /* Not a relevant action. */
815 continue;
816 }
817
819 /* Not relevant since not accepted here. */
820 continue;
821 }
822
823 switch (action_id_get_target_kind(act)) {
824 case ATK_TILE:
826 tgt_tile, tgt_extra))) {
827 /* The actor unit may be able to do this action to the target
828 * extra. */
829 return TRUE;
830 }
831 break;
832 case ATK_EXTRAS:
834 tgt_tile,
835 tgt_extra))) {
836 /* The actor unit may be able to do this action to the target
837 * extra. */
838 return TRUE;
839 }
840 break;
841 case ATK_CITY:
842 case ATK_UNIT:
843 case ATK_UNITS:
844 case ATK_SELF:
845 /* Not supported. */
846 break;
847 case ATK_COUNT:
849 break;
850 }
852
853 return FALSE;
854}
855
856/**********************************************************************/
869 const struct tile *target_tile,
871{
875 return target;
876 }
878
879 return NULL;
880}
881
882/**********************************************************************/
886 struct unit *actor_unit)
887{
888 const struct tile *tgt_tile = unit_tile(actor_unit);
889
891 NO_TARGET);
892
894 case ASTK_NONE:
895 /* Should not be reached */
897 NO_TARGET);
898 break;
899 case ASTK_BUILDING:
900 /* Implement if a building sub targeted action becomes flexible */
902 NO_TARGET);
903 break;
904 case ASTK_TECH:
905 /* Implement if a tech sub targeted action becomes flexible */
907 NO_TARGET);
908 break;
909 case ASTK_EXTRA:
912 /* Special treatment for "Pillage" */
913 struct extra_type *pextra = NULL;
915
917
918 if (pextra != NULL) {
919 return extra_number(pextra);
920 }
921 }
924 tgt_tile, tgt_extra))) {
925 /* The actor unit may be able to do this action to the target
926 * extra. */
927 return extra_number(tgt_extra);
928 }
930 break;
931 case ASTK_COUNT:
932 /* Should not exist. */
934 NO_TARGET);
935 break;
936 }
937
938 return NO_TARGET;
939}
940
941/**********************************************************************/
946const struct action_auto_perf *
948 const struct unit *actor,
949 const struct player *other_player,
950 const struct output_type *eval_output,
951 const struct action *eval_action)
952{
953 const struct req_context actor_ctxt = {
955 .tile = unit_tile(actor),
956 .unit = actor,
957 .unittype = unit_type_get(actor),
958 .output = eval_output,
959 .action = eval_action,
960 };
961
964 &(const struct req_context) {
965 .player = other_player,
966 },
967 &autoperformer->reqs, RPT_CERTAIN)) {
968 /* Select this action auto performer. */
969 return autoperformer;
970 }
972
973 /* Can't even try to force an action. */
974 return NULL;
975}
976
977#define action_auto_perf_acquire_targets(_target_extra_) \
978 tgt_city = (target_city ? target_city \
979 : action_tgt_city(actor, unit_tile(actor), \
980 TRUE)); \
981 tgt_tile = (target_tile ? target_tile \
982 : action_tgt_tile(actor, unit_tile(actor), \
983 _target_extra_, \
984 TRUE)); \
985 tgt_unit = (target_unit ? target_unit \
986 : action_tgt_unit(actor, unit_tile(actor), \
987 TRUE));
988
989/**********************************************************************/
997const struct action *
999 struct unit *actor,
1000 const struct player *other_player,
1001 const struct output_type *eval_output,
1002 const struct action *eval_action,
1003 const struct tile *target_tile,
1004 const struct city *target_city,
1005 const struct unit *target_unit,
1006 const struct extra_type *target_extra)
1007{
1008 int actor_id;
1009
1010 const struct city *tgt_city;
1011 const struct tile *tgt_tile;
1012 const struct unit *tgt_unit;
1013 const struct civ_map *nmap = &(wld.map);
1014
1015 const struct action_auto_perf *autoperf
1016 = action_auto_perf_unit_sel(cause, actor, other_player,
1018
1019 if (!autoperf) {
1020 /* No matching Action Auto Performer. */
1021 return NULL;
1022 }
1023
1024 actor_id = actor->id;
1025
1026 /* Acquire the targets. */
1028
1030 if (action_id_get_actor_kind(act) == AAK_UNIT) {
1031 /* This action can be done by units. */
1032
1033#define perform_action_to(act, actor, tgtid, tgt_extra) \
1034 if (unit_perform_action(unit_owner(actor), \
1035 actor->id, tgtid, tgt_extra, \
1036 NULL, act, ACT_REQ_RULES)) { \
1037 return action_by_number(act); \
1038 }
1039
1040 switch (action_id_get_target_kind(act)) {
1041 case ATK_UNITS:
1042 if (tgt_tile
1045 }
1046 break;
1047 case ATK_TILE:
1048 if (tgt_tile
1053 }
1054 break;
1055 case ATK_EXTRAS:
1056 if (tgt_tile
1061 }
1062 break;
1063 case ATK_CITY:
1064 if (tgt_city
1067 }
1068 break;
1069 case ATK_UNIT:
1070 if (tgt_unit
1073 }
1074 break;
1075 case ATK_SELF:
1076 if (actor
1079 }
1080 break;
1081 case ATK_COUNT:
1083 }
1084
1085 if (!unit_is_alive(actor_id)) {
1086 /* The unit is gone. Maybe it was killed in Lua? */
1087 return NULL;
1088 }
1089 }
1091
1092 return NULL;
1093}
1094
1095/**********************************************************************/
1099struct act_prob
1101 struct unit *actor,
1102 const struct player *other_player,
1103 const struct output_type *eval_output,
1104 const struct action *eval_action,
1105 const struct tile *target_tile,
1106 const struct city *target_city,
1107 const struct unit *target_unit,
1108 const struct extra_type *target_extra)
1109{
1110 struct act_prob out;
1111
1112 const struct city *tgt_city;
1113 const struct tile *tgt_tile;
1114 const struct unit *tgt_unit;
1115 const struct civ_map *nmap = &(wld.map);
1116
1117 const struct action_auto_perf *autoperf
1118 = action_auto_perf_unit_sel(cause, actor, other_player,
1120
1121 if (!autoperf) {
1122 /* No matching Action Auto Performer. */
1123 return ACTPROB_IMPOSSIBLE;
1124 }
1125
1127
1128 /* Acquire the targets. */
1130
1132 struct act_prob current = ACTPROB_IMPOSSIBLE;
1133
1134 if (action_id_get_actor_kind(act) == AAK_UNIT) {
1135 /* This action can be done by units. */
1136
1137 switch (action_id_get_target_kind(act)) {
1138 case ATK_UNITS:
1139 if (tgt_tile
1141 current = action_prob_vs_stack(actor, act, tgt_tile);
1142 }
1143 break;
1144 case ATK_TILE:
1145 if (tgt_tile
1149 }
1150 break;
1151 case ATK_EXTRAS:
1152 if (tgt_tile
1155 current = action_prob_vs_extras(actor, act,
1157 }
1158 break;
1159 case ATK_CITY:
1160 if (tgt_city
1162 current = action_prob_vs_city(nmap, actor, act, tgt_city);
1163 }
1164 break;
1165 case ATK_UNIT:
1166 if (tgt_unit
1168 current = action_prob_vs_unit(nmap, actor, act, tgt_unit);
1169 }
1170 break;
1171 case ATK_SELF:
1172 if (actor
1174 current = action_prob_self(actor, act);
1175 }
1176 break;
1177 case ATK_COUNT:
1179 }
1180 }
1181
1182 out = action_prob_fall_back(&out, &current);
1184
1185 return out;
1186}
1187
1188/************************************************************************/
1193 const struct unit *act_unit,
1194 const struct city *tgt_city,
1195 const struct player *tgt_player,
1196 const struct action *paction)
1197{
1200 paction);
1201
1202 /* Roll the dice. */
1203 return fc_rand(100) >= odds;
1204}
struct act_prob action_prob_self(const struct unit *actor_unit, const action_id act_id)
Definition actions.c:4717
bool action_prob_possible(const struct act_prob probability)
Definition actions.c:5044
const char * action_name_translation(const struct action *paction)
Definition actions.c:1205
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)
Definition actions.c:5344
enum action_sub_target_kind action_get_sub_target_kind(const struct action *paction)
Definition actions.c:1094
struct act_prob action_prob_vs_tile(const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile, const struct extra_type *target_extra)
Definition actions.c:4562
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)
Definition actions.c:3217
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)
Definition actions.c:3293
struct act_prob action_prob_fall_back(const struct act_prob *ap1, const struct act_prob *ap2)
Definition actions.c:5252
struct act_prob action_prob_vs_stack(const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile)
Definition actions.c:4478
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)
Definition actions.c:3052
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)
Definition actions.c:3129
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)
Definition actions.c:4203
struct act_prob action_prob_vs_extras(const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile, const struct extra_type *target_extra)
Definition actions.c:4646
enum action_target_kind action_get_target_kind(const struct action *paction)
Definition actions.c:1083
bool is_action_enabled_unit_on_self(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit)
Definition actions.c:3442
bool action_id_is_rare_pop_up(action_id act_id)
Definition actions.c:1135
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)
Definition actions.c:4286
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)
Definition actions.c:3370
#define action_auto_perf_by_cause_iterate(_cause_, _act_perf_)
Definition actions.h:345
#define action_auto_perf_actions_iterate_end
Definition actions.h:357
#define action_auto_perf_by_cause_iterate_end
Definition actions.h:351
#define action_has_result(_act_, _res_)
Definition actions.h:175
#define action_auto_perf_actions_iterate(_autoperf_, _act_id_)
Definition actions.h:354
#define action_iterate_end
Definition actions.h:209
#define action_id_get_actor_kind(act_id)
Definition actions.h:403
#define action_get_activity(_pact_)
Definition actions.h:454
#define ACTPROB_IMPOSSIBLE
Definition actions.h:665
#define action_iterate(_act_)
Definition actions.h:205
#define action_id_get_target_kind(act_id)
Definition actions.h:407
#define action_id_has_complex_target(act_id)
Definition actions.h:425
static void notify_actor_success(struct player *receiver, const struct action *paction, struct player *offender, struct player *victim_player, const struct tile *victim_tile, const char *victim_link)
void action_consequence_complete(const struct action *paction, struct player *offender, const struct unit_type *offender_utype, struct player *victim_player, const struct tile *victim_tile, const char *victim_link)
const struct action_auto_perf * action_auto_perf_unit_sel(const enum action_auto_perf_cause cause, const struct unit *actor, const struct player *other_player, const struct output_type *eval_output, const struct action *eval_action)
struct tile * action_tgt_tile(struct unit *actor, struct tile *target, const struct extra_type *target_extra, bool accept_all_actions)
static void notify_victim_success(struct player *receiver, const struct action *paction, struct player *offender, struct player *victim_player, const struct tile *victim_tile, const char *victim_link)
void action_success_target_pay_mp(struct action *paction, int target_id, struct unit *target)
Definition actiontools.c:80
void action_consequence_caught(const struct action *paction, struct player *offender, const struct unit_type *offender_utype, struct player *victim_player, const struct tile *victim_tile, const char *victim_link)
static bool may_unit_act_vs_city(struct unit *actor, struct city *target, bool accept_all_actions)
void(* action_notify)(struct player *, const struct action *, struct player *, struct player *, const struct tile *, const char *)
Definition actiontools.c:34
struct act_prob action_auto_perf_unit_prob(const enum action_auto_perf_cause cause, struct unit *actor, const struct player *other_player, const struct output_type *eval_output, const struct action *eval_action, const struct tile *target_tile, const struct city *target_city, const struct unit *target_unit, const struct extra_type *target_extra)
static void notify_global_success(struct player *receiver, const struct action *paction, struct player *offender, struct player *victim_player, const struct tile *victim_tile, const char *victim_link)
static void notify_victim_caught(struct player *receiver, const struct action *paction, struct player *offender, struct player *victim_player, const struct tile *victim_tile, const char *victim_link)
const struct action * action_auto_perf_unit_do(const enum action_auto_perf_cause cause, struct unit *actor, const struct player *other_player, const struct output_type *eval_output, const struct action *eval_action, const struct tile *target_tile, const struct city *target_city, const struct unit *target_unit, const struct extra_type *target_extra)
struct unit * action_tgt_unit(struct unit *actor, struct tile *target_tile, bool accept_all_actions)
void action_consequence_success(const struct action *paction, struct player *offender, const struct unit_type *offender_utype, struct player *victim_player, const struct tile *victim_tile, const char *victim_link)
#define perform_action_to(act, actor, tgtid, tgt_extra)
static void notify_global_caught(struct player *receiver, const struct action *paction, struct player *offender, struct player *victim_player, const struct tile *victim_tile, const char *victim_link)
static void action_success_actor_consume(struct action *paction, int actor_id, struct unit *actor)
Definition actiontools.c:44
static void notify_actor_caught(struct player *receiver, const struct action *paction, struct player *offender, struct player *victim_player, const struct tile *victim_tile, const char *victim_link)
struct city * action_tgt_city(struct unit *actor, struct tile *target_tile, bool accept_all_actions)
static void action_give_casus_belli(struct player *offender, struct player *victim_player, const bool int_outrage)
struct extra_type * action_tgt_tile_extra(const struct unit *actor, const struct tile *target_tile, bool accept_all_actions)
static void action_consequence_common(const struct action *paction, struct player *offender, const struct unit_type *offender_utype, struct player *victim_player, const struct tile *victim_tile, const char *victim_link, const action_notify notify_actor, const action_notify notify_victim, const action_notify notify_global, const enum effect_type eft)
void action_success_actor_price(struct action *paction, int actor_id, struct unit *actor)
static bool may_unit_act_vs_unit(struct unit *actor, struct unit *target, bool accept_all_actions)
bool action_failed_dice_roll(const struct player *act_player, const struct unit *act_unit, const struct city *tgt_city, const struct player *tgt_player, const struct action *paction)
int action_sub_target_id_for_action(const struct action *paction, struct unit *actor_unit)
static void action_success_pay_mp(struct action *paction, int actor_id, struct unit *actor)
Definition actiontools.c:67
#define action_auto_perf_acquire_targets(_target_extra_)
static bool may_unit_act_vs_tile_extra(const struct unit *actor, const struct tile *tgt_tile, const struct extra_type *tgt_extra, bool accept_all_actions)
@ INCIDENT_ACTION
Definition ai.h:46
void call_incident(enum incident_type type, enum casus_belli_range scope, const struct action *paction, struct player *violator, struct player *victim)
Definition aiiface.c:235
char * incite_cost
Definition comments.c:74
struct unit struct city struct unit * target_unit
Definition dialogs_g.h:56
struct unit * actor_unit
Definition dialogs_g.h:55
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit * actor
Definition dialogs_g.h:73
struct unit struct city struct unit struct tile * target_tile
Definition dialogs_g.h:57
struct unit struct city * target_city
Definition dialogs_g.h:56
struct unit struct city struct unit struct tile struct extra_type * target_extra
Definition dialogs_g.h:57
int get_target_bonus_effects(struct effect_list *plist, const struct req_context *context, const struct req_context *other_context, enum effect_type effect_type)
Definition effects.c:744
int extra_number(const struct extra_type *pextra)
Definition extras.c:161
#define EXTRA_NONE
Definition extras.h:85
#define extra_type_re_active_iterate_end
Definition extras.h:329
#define extra_type_re_active_iterate(_p)
Definition extras.h:325
#define NO_TARGET
Definition fc_types.h:358
@ RPT_CERTAIN
Definition fc_types.h:678
#define _(String)
Definition fcintl.h:67
const struct ft_color ftc_server
struct world wld
Definition game.c:62
#define fc_assert(condition)
Definition log.h:176
#define fc_assert_ret_val(condition, val)
Definition log.h:194
const char * nation_adjective_for_player(const struct player *pplayer)
Definition nation.c:169
const char * nation_plural_for_player(const struct player *pplayer)
Definition nation.c:178
void notify_player(const struct player *pplayer, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
Definition notify.c:292
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
Definition player.c:324
enum casus_belli_range casus_belli_range_for(const struct player *offender, const struct unit_type *off_ut, const struct player *tgt_plr, const enum effect_type outcome, const struct action *paction, const struct tile *tgt_tile)
Definition player.c:1644
#define players_iterate_end
Definition player.h:539
#define players_iterate(_pplayer)
Definition player.h:534
void send_player_all_c(struct player *src, struct conn_list *dest)
Definition plrhand.c:1129
void player_update_last_war_action(struct player *pplayer)
Definition plrhand.c:865
#define fc_rand(_size)
Definition rand.h:56
bool are_reqs_active(const struct req_context *context, const struct req_context *other_context, const struct requirement_vector *reqs, const enum req_problem_type prob_type)
#define MAX(x, y)
Definition shared.h:54
enum action_auto_perf_cause cause
Definition actions.h:318
Definition city.h:320
char has_reason_to_cancel
Definition player.h:203
const struct player * player
Definition tile.h:50
Definition unit.h:140
int moves_left
Definition unit.h:152
int id
Definition unit.h:147
int index
Definition unit.h:198
struct civ_map map
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
bool unit_is_alive(int id)
Definition unit.c:2291
int unit_pays_mp_for_action(const struct action *paction, const struct unit *punit)
Definition unit.c:2173
#define unit_tile(_pu)
Definition unit.h:397
#define unit_owner(_pu)
Definition unit.h:396
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
void send_unit_info(struct conn_list *dest, struct unit *punit)
Definition unittools.c:2878
void wipe_unit(struct unit *punit, enum unit_loss_reason reason, struct player *killer)
Definition unittools.c:2140
void unit_assign_specific_activity_target(struct unit *punit, enum unit_activity *activity, struct extra_type **target)
Definition unittools.c:1083
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
bool utype_is_consumed_by_action(const struct action *paction, const struct unit_type *utype)
Definition unittype.c:1219