Freeciv-3.2
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 if (actor == NULL || target == NULL) {
603 /* Can't do any actions if actor or target are missing. */
604 return FALSE;
605 }
606
607 action_iterate(act) {
610 /* Not a relevant action. */
611 continue;
612 }
613
615 /* Not relevant since not accepted here. */
616 continue;
617 }
618
620 /* The actor unit may be able to do this action to the target
621 * city. */
622 return TRUE;
623 }
625
626 return FALSE;
627}
628
629/**********************************************************************/
640{
641 struct city *target = tile_city(target_tile);
642
643 if (target && may_unit_act_vs_city(actor, target, accept_all_actions)) {
644 /* It may be possible to act against this city. */
645 return target;
646 }
647
648 return NULL;
649}
650
651/**********************************************************************/
663static bool may_unit_act_vs_unit(struct unit *actor, struct unit *target,
665{
666 if (actor == NULL || target == NULL) {
667 /* Can't do any actions if actor or target are missing. */
668 return FALSE;
669 }
670
671 action_iterate(act) {
674 /* Not a relevant action. */
675 continue;
676 }
677
679 /* Not relevant since not accepted here. */
680 continue;
681 }
682
684 /* The actor unit may be able to do this action to the target
685 * unit. */
686 return TRUE;
687 }
689
690 return FALSE;
691}
692
693/**********************************************************************/
705{
706 unit_list_iterate(target_tile->units, target) {
708 return target;
709 }
711
712 return NULL;
713}
714
715/**********************************************************************/
730 struct tile *target,
731 const struct extra_type *target_extra,
733{
734 if (actor == NULL || target == NULL) {
735 /* Can't do any actions if actor or target are missing. */
736 return NULL;
737 }
738
739 action_iterate(act) {
740 struct act_prob prob;
741
743 /* Not a relevant action. */
744 continue;
745 }
746
748 /* Not relevant since not accepted here. */
749 continue;
750 }
751
752 switch (action_id_get_target_kind(act)) {
753 case ATK_TILE:
754 prob = action_prob_vs_tile(actor, act, target, target_extra);
755 break;
756 case ATK_EXTRAS:
757 prob = action_prob_vs_extras(actor, act, target, target_extra);
758 break;
759 case ATK_UNITS:
760 prob = action_prob_vs_stack(actor, act, target);
761 break;
762 case ATK_CITY:
763 case ATK_UNIT:
764 case ATK_SELF:
765 /* Target not specified by tile. */
766 continue;
767 case ATK_COUNT:
768 /* Invalid target kind */
770 continue;
771 }
772
773 if (action_prob_possible(prob)) {
774 /* The actor unit may be able to do this action to the target
775 * tile. */
776 return target;
777 }
779
780 return NULL;
781}
782
783/**********************************************************************/
795static bool may_unit_act_vs_tile_extra(const struct unit *actor,
796 const struct tile *tgt_tile,
797 const struct extra_type *tgt_extra,
799{
800 if (actor == NULL || tgt_tile == NULL || tgt_extra == NULL) {
801 /* Can't do any actions if actor or target are missing. */
802 return FALSE;
803 }
804
805 action_iterate(act) {
810 /* Not a relevant action. */
811 continue;
812 }
813
815 /* Not relevant since not accepted here. */
816 continue;
817 }
818
819 switch (action_id_get_target_kind(act)) {
820 case ATK_TILE:
822 tgt_tile, tgt_extra))) {
823 /* The actor unit may be able to do this action to the target
824 * extra. */
825 return TRUE;
826 }
827 break;
828 case ATK_EXTRAS:
830 tgt_tile,
831 tgt_extra))) {
832 /* The actor unit may be able to do this action to the target
833 * extra. */
834 return TRUE;
835 }
836 break;
837 case ATK_CITY:
838 case ATK_UNIT:
839 case ATK_UNITS:
840 case ATK_SELF:
841 /* Not supported. */
842 break;
843 case ATK_COUNT:
845 break;
846 }
848
849 return FALSE;
850}
851
852/**********************************************************************/
865 const struct tile *target_tile,
867{
871 return target;
872 }
874
875 return NULL;
876}
877
878/**********************************************************************/
882 struct unit *actor_unit)
883{
884 const struct tile *tgt_tile = unit_tile(actor_unit);
885
887 NO_TARGET);
888
890 case ASTK_NONE:
891 /* Should not be reached */
893 NO_TARGET);
894 break;
895 case ASTK_BUILDING:
896 /* Implement if a building sub targeted action becomes flexible */
898 NO_TARGET);
899 break;
900 case ASTK_TECH:
901 /* Implement if a tech sub targeted action becomes flexible */
903 NO_TARGET);
904 break;
905 case ASTK_EXTRA:
908 /* Special treatment for "Pillage" */
909 struct extra_type *pextra;
911
913
914 if (pextra != NULL) {
915 return extra_number(pextra);
916 }
917 }
920 tgt_tile, tgt_extra))) {
921 /* The actor unit may be able to do this action to the target
922 * extra. */
923 return extra_number(tgt_extra);
924 }
926 break;
927 case ASTK_COUNT:
928 /* Should not exist. */
930 NO_TARGET);
931 break;
932 }
933
934 return NO_TARGET;
935}
936
937/**********************************************************************/
942const struct action_auto_perf *
944 const struct unit *actor,
945 const struct player *other_player,
946 const struct output_type *eval_output,
947 const struct action *eval_action)
948{
949 const struct req_context actor_ctxt = {
951 .tile = unit_tile(actor),
952 .unit = actor,
953 .unittype = unit_type_get(actor),
954 .output = eval_output,
955 .action = eval_action,
956 };
957
959 if (are_reqs_active(&actor_ctxt, other_player,
960 &autoperformer->reqs, RPT_CERTAIN)) {
961 /* Select this action auto performer. */
962 return autoperformer;
963 }
965
966 /* Can't even try to force an action. */
967 return NULL;
968}
969
970#define action_auto_perf_acquire_targets(_target_extra_) \
971 tgt_city = (target_city ? target_city \
972 : action_tgt_city(actor, unit_tile(actor), \
973 TRUE)); \
974 tgt_tile = (target_tile ? target_tile \
975 : action_tgt_tile(actor, unit_tile(actor), \
976 _target_extra_, \
977 TRUE)); \
978 tgt_unit = (target_unit ? target_unit \
979 : action_tgt_unit(actor, unit_tile(actor), \
980 TRUE));
981
982/**********************************************************************/
990const struct action *
992 struct unit *actor,
993 const struct player *other_player,
994 const struct output_type *eval_output,
995 const struct action *eval_action,
996 const struct tile *target_tile,
997 const struct city *target_city,
998 const struct unit *target_unit,
999 const struct extra_type *target_extra)
1000{
1001 int actor_id;
1002
1003 const struct city *tgt_city;
1004 const struct tile *tgt_tile;
1005 const struct unit *tgt_unit;
1006 const struct civ_map *nmap = &(wld.map);
1007
1008 const struct action_auto_perf *autoperf
1009 = action_auto_perf_unit_sel(cause, actor, other_player,
1011
1012 if (!autoperf) {
1013 /* No matching Action Auto Performer. */
1014 return NULL;
1015 }
1016
1017 actor_id = actor->id;
1018
1019 /* Acquire the targets. */
1021
1023 if (action_id_get_actor_kind(act) == AAK_UNIT) {
1024 /* This action can be done by units. */
1025
1026#define perform_action_to(act, actor, tgtid, tgt_extra) \
1027 if (unit_perform_action(unit_owner(actor), \
1028 actor->id, tgtid, tgt_extra, \
1029 NULL, act, ACT_REQ_RULES)) { \
1030 return action_by_number(act); \
1031 }
1032
1033 switch (action_id_get_target_kind(act)) {
1034 case ATK_UNITS:
1035 if (tgt_tile
1038 }
1039 break;
1040 case ATK_TILE:
1041 if (tgt_tile
1046 }
1047 break;
1048 case ATK_EXTRAS:
1049 if (tgt_tile
1054 }
1055 break;
1056 case ATK_CITY:
1057 if (tgt_city
1060 }
1061 break;
1062 case ATK_UNIT:
1063 if (tgt_unit
1066 }
1067 break;
1068 case ATK_SELF:
1069 if (actor
1072 }
1073 break;
1074 case ATK_COUNT:
1076 }
1077
1078 if (!unit_is_alive(actor_id)) {
1079 /* The unit is gone. Maybe it was killed in Lua? */
1080 return NULL;
1081 }
1082 }
1084
1085 return NULL;
1086}
1087
1088/**********************************************************************/
1092struct act_prob
1094 struct unit *actor,
1095 const struct player *other_player,
1096 const struct output_type *eval_output,
1097 const struct action *eval_action,
1098 const struct tile *target_tile,
1099 const struct city *target_city,
1100 const struct unit *target_unit,
1101 const struct extra_type *target_extra)
1102{
1103 struct act_prob out;
1104
1105 const struct city *tgt_city;
1106 const struct tile *tgt_tile;
1107 const struct unit *tgt_unit;
1108 const struct civ_map *nmap = &(wld.map);
1109
1110 const struct action_auto_perf *autoperf
1111 = action_auto_perf_unit_sel(cause, actor, other_player,
1113
1114 if (!autoperf) {
1115 /* No matching Action Auto Performer. */
1116 return ACTPROB_IMPOSSIBLE;
1117 }
1118
1120
1121 /* Acquire the targets. */
1123
1125 struct act_prob current = ACTPROB_IMPOSSIBLE;
1126
1127 if (action_id_get_actor_kind(act) == AAK_UNIT) {
1128 /* This action can be done by units. */
1129
1130 switch (action_id_get_target_kind(act)) {
1131 case ATK_UNITS:
1132 if (tgt_tile
1134 current = action_prob_vs_stack(actor, act, tgt_tile);
1135 }
1136 break;
1137 case ATK_TILE:
1138 if (tgt_tile
1142 }
1143 break;
1144 case ATK_EXTRAS:
1145 if (tgt_tile
1148 current = action_prob_vs_extras(actor, act,
1150 }
1151 break;
1152 case ATK_CITY:
1153 if (tgt_city
1155 current = action_prob_vs_city(actor, act, tgt_city);
1156 }
1157 break;
1158 case ATK_UNIT:
1159 if (tgt_unit
1161 current = action_prob_vs_unit(actor, act, tgt_unit);
1162 }
1163 break;
1164 case ATK_SELF:
1165 if (actor
1167 current = action_prob_self(actor, act);
1168 }
1169 break;
1170 case ATK_COUNT:
1172 }
1173 }
1174
1175 out = action_prob_fall_back(&out, &current);
1177
1178 return out;
1179}
1180
1181/************************************************************************/
1186 const struct unit *act_unit,
1187 const struct city *tgt_city,
1188 const struct player *tgt_player,
1189 const struct action *paction)
1190{
1193 paction);
1194
1195 /* Roll the dice. */
1196 return fc_rand (100) >= odds;
1197}
const char * action_name_translation(const struct action *action)
Definition actions.c:1982
struct act_prob action_prob_self(const struct unit *actor_unit, const action_id act_id)
Definition actions.c:5497
bool action_prob_possible(const struct act_prob probability)
Definition actions.c:5823
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:6123
bool is_action_enabled_unit_on_self(const action_id wanted_action, const struct unit *actor_unit)
Definition actions.c:4223
struct act_prob action_prob_vs_city(const struct unit *actor_unit, const action_id act_id, const struct city *target_city)
Definition actions.c:4981
struct act_prob action_prob_vs_unit(const struct unit *actor_unit, const action_id act_id, const struct unit *target_unit)
Definition actions.c:5065
enum action_sub_target_kind action_get_sub_target_kind(const struct action *paction)
Definition actions.c:1871
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:5342
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:3997
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:4073
struct act_prob action_prob_fall_back(const struct act_prob *ap1, const struct act_prob *ap2)
Definition actions.c:6031
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:5258
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:3832
bool is_action_enabled_unit_on_extras(const action_id wanted_action, const struct unit *actor_unit, const struct tile *target_tile, const struct extra_type *target_extra)
Definition actions.c:4150
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:3909
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:5426
enum action_target_kind action_get_target_kind(const struct action *paction)
Definition actions.c:1860
bool action_id_is_rare_pop_up(action_id act_id)
Definition actions.c:1912
#define action_auto_perf_by_cause_iterate(_cause_, _act_perf_)
Definition actions.h:588
#define action_auto_perf_actions_iterate_end
Definition actions.h:600
#define action_auto_perf_by_cause_iterate_end
Definition actions.h:594
#define action_has_result(_act_, _res_)
Definition actions.h:429
#define action_auto_perf_actions_iterate(_autoperf_, _act_id_)
Definition actions.h:597
#define action_iterate_end
Definition actions.h:463
#define action_id_get_actor_kind(act_id)
Definition actions.h:646
#define action_get_activity(_pact_)
Definition actions.h:697
#define ACTPROB_IMPOSSIBLE
Definition actions.h:904
#define action_iterate(_act_)
Definition actions.h:459
#define action_id_get_target_kind(act_id)
Definition actions.h:650
#define action_id_has_complex_target(act_id)
Definition actions.h:668
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:237
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 player *other_player, enum effect_type effect_type)
Definition effects.c:748
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:357
@ RPT_CERTAIN
Definition fc_types.h:704
#define _(String)
Definition fcintl.h:67
const struct ft_color ftc_server
struct world wld
Definition game.c:63
#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:1640
#define players_iterate_end
Definition player.h:537
#define players_iterate(_pplayer)
Definition player.h:532
void send_player_all_c(struct player *src, struct conn_list *dest)
Definition plrhand.c:1125
void player_update_last_war_action(struct player *pplayer)
Definition plrhand.c:863
#define fc_rand(_size)
Definition rand.h:56
bool are_reqs_active(const struct req_context *context, const struct player *other_player, 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:561
Definition city.h:320
char has_reason_to_cancel
Definition player.h:201
const struct player * player
Definition tile.h:50
Definition unit.h:138
int moves_left
Definition unit.h:150
int id
Definition unit.h:145
int index
Definition unit.h:195
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:2249
int unit_pays_mp_for_action(const struct action *paction, const struct unit *punit)
Definition unit.c:2131
#define unit_tile(_pu)
Definition unit.h:390
#define unit_owner(_pu)
Definition unit.h:389
#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:2725
void wipe_unit(struct unit *punit, enum unit_loss_reason reason, struct player *killer)
Definition unittools.c:2135
void unit_assign_specific_activity_target(struct unit *punit, enum unit_activity *activity, struct extra_type **target)
Definition unittools.c:1082
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