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_STACK:
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_STACK:
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_STACK:
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_STACK:
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 const struct civ_map *nmap = &(wld.map);
739
740 if (actor == NULL || target == NULL) {
741 /* Can't do any actions if actor or target are missing. */
742 return NULL;
743 }
744
745 action_iterate(act) {
746 struct act_prob prob;
747
749 /* Not a relevant action. */
750 continue;
751 }
752
754 /* Not relevant since not accepted here. */
755 continue;
756 }
757
758 switch (action_id_get_target_kind(act)) {
759 case ATK_TILE:
760 prob = action_prob_vs_tile(nmap, actor, act, target, target_extra);
761 break;
762 case ATK_EXTRAS:
763 prob = action_prob_vs_extras(nmap, actor, act, target, target_extra);
764 break;
765 case ATK_STACK:
766 prob = action_prob_vs_stack(nmap, actor, act, target);
767 break;
768 case ATK_CITY:
769 case ATK_UNIT:
770 case ATK_SELF:
771 /* Target not specified by tile. */
772 continue;
773 case ATK_COUNT:
774 /* Invalid target kind */
776 continue;
777 }
778
779 if (action_prob_possible(prob)) {
780 /* The actor unit may be able to do this action to the target
781 * tile. */
782 return target;
783 }
785
786 return NULL;
787}
788
789/**********************************************************************/
801static bool may_unit_act_vs_tile_extra(const struct unit *actor,
802 const struct tile *tgt_tile,
803 const struct extra_type *tgt_extra,
805{
806 const struct civ_map *nmap = &(wld.map);
807
808 if (actor == NULL || tgt_tile == NULL || tgt_extra == NULL) {
809 /* Can't do any actions if actor or target are missing. */
810 return FALSE;
811 }
812
813 action_iterate(act) {
818 /* Not a relevant action. */
819 continue;
820 }
821
823 /* Not relevant since not accepted here. */
824 continue;
825 }
826
827 switch (action_id_get_target_kind(act)) {
828 case ATK_TILE:
830 tgt_tile, tgt_extra))) {
831 /* The actor unit may be able to do this action to the target
832 * extra. */
833 return TRUE;
834 }
835 break;
836 case ATK_EXTRAS:
838 tgt_tile,
839 tgt_extra))) {
840 /* The actor unit may be able to do this action to the target
841 * extra. */
842 return TRUE;
843 }
844 break;
845 case ATK_CITY:
846 case ATK_UNIT:
847 case ATK_STACK:
848 case ATK_SELF:
849 /* Not supported. */
850 break;
851 case ATK_COUNT:
853 break;
854 }
856
857 return FALSE;
858}
859
860/**********************************************************************/
873 const struct tile *target_tile,
875{
879 return target;
880 }
882
883 return NULL;
884}
885
886/**********************************************************************/
890 struct unit *actor_unit)
891{
892 const struct tile *tgt_tile = unit_tile(actor_unit);
893 const struct civ_map *nmap = &(wld.map);
894
896 NO_TARGET);
897
899 case ASTK_NONE:
900 /* Should not be reached */
902 NO_TARGET);
903 break;
904 case ASTK_BUILDING:
905 /* Implement if a building sub targeted action becomes flexible */
907 NO_TARGET);
908 break;
909 case ASTK_TECH:
910 /* Implement if a tech sub targeted action becomes flexible */
912 NO_TARGET);
913 break;
914 case ASTK_EXTRA:
917 /* Special treatment for "Pillage" */
918 struct extra_type *pextra = NULL;
920
922 action_number(paction), &pextra);
923
924 if (pextra != NULL) {
925 return extra_number(pextra);
926 }
927 }
930 tgt_tile, tgt_extra))) {
931 /* The actor unit may be able to do this action to the target
932 * extra. */
933 return extra_number(tgt_extra);
934 }
936 break;
937 case ASTK_COUNT:
938 /* Should not exist. */
940 NO_TARGET);
941 break;
942 }
943
944 return NO_TARGET;
945}
946
947/**********************************************************************/
952const struct action_auto_perf *
954 const struct unit *actor,
955 const struct player *other_player,
956 const struct output_type *eval_output,
957 const struct action *eval_action)
958{
959 const struct req_context actor_ctxt = {
961 .tile = unit_tile(actor),
962 .unit = actor,
963 .unittype = unit_type_get(actor),
964 .output = eval_output,
965 .action = eval_action,
966 };
967
970 &(const struct req_context) {
971 .player = other_player,
972 },
973 &autoperformer->reqs, RPT_CERTAIN)) {
974 /* Select this action auto performer. */
975 return autoperformer;
976 }
978
979 /* Can't even try to force an action. */
980 return NULL;
981}
982
983#define action_auto_perf_acquire_targets(_target_extra_) \
984 tgt_city = (target_city ? target_city \
985 : action_tgt_city(actor, unit_tile(actor), \
986 TRUE)); \
987 tgt_tile = (target_tile ? target_tile \
988 : action_tgt_tile(actor, unit_tile(actor), \
989 _target_extra_, \
990 TRUE)); \
991 tgt_unit = (target_unit ? target_unit \
992 : action_tgt_unit(actor, unit_tile(actor), \
993 TRUE));
994
995/**********************************************************************/
1003const struct action *
1005 struct unit *actor,
1006 const struct player *other_player,
1007 const struct output_type *eval_output,
1008 const struct action *eval_action,
1009 const struct tile *target_tile,
1010 const struct city *target_city,
1011 const struct unit *target_unit,
1012 const struct extra_type *target_extra)
1013{
1014 int actor_id;
1015
1016 const struct city *tgt_city;
1017 const struct tile *tgt_tile;
1018 const struct unit *tgt_unit;
1019 const struct civ_map *nmap = &(wld.map);
1020
1021 const struct action_auto_perf *autoperf
1022 = action_auto_perf_unit_sel(cause, actor, other_player,
1024
1025 if (!autoperf) {
1026 /* No matching Action Auto Performer. */
1027 return NULL;
1028 }
1029
1030 actor_id = actor->id;
1031
1032 /* Acquire the targets. */
1034
1036 if (action_id_get_actor_kind(act) == AAK_UNIT) {
1037 /* This action can be done by units. */
1038
1039#define perform_action_to(act, actor, tgtid, tgt_extra) \
1040 if (unit_perform_action(unit_owner(actor), \
1041 actor->id, tgtid, tgt_extra, \
1042 NULL, act, ACT_REQ_RULES)) { \
1043 return action_by_number(act); \
1044 }
1045
1046 switch (action_id_get_target_kind(act)) {
1047 case ATK_STACK:
1048 if (tgt_tile
1051 }
1052 break;
1053 case ATK_TILE:
1054 if (tgt_tile
1059 }
1060 break;
1061 case ATK_EXTRAS:
1062 if (tgt_tile
1067 }
1068 break;
1069 case ATK_CITY:
1070 if (tgt_city
1073 }
1074 break;
1075 case ATK_UNIT:
1076 if (tgt_unit
1079 }
1080 break;
1081 case ATK_SELF:
1082 if (actor
1085 }
1086 break;
1087 case ATK_COUNT:
1089 }
1090
1091 if (!unit_is_alive(actor_id)) {
1092 /* The unit is gone. Maybe it was killed in Lua? */
1093 return NULL;
1094 }
1095 }
1097
1098 return NULL;
1099}
1100
1101/**********************************************************************/
1105struct act_prob
1107 struct unit *actor,
1108 const struct player *other_player,
1109 const struct output_type *eval_output,
1110 const struct action *eval_action,
1111 const struct tile *target_tile,
1112 const struct city *target_city,
1113 const struct unit *target_unit,
1114 const struct extra_type *target_extra)
1115{
1116 struct act_prob out;
1117
1118 const struct city *tgt_city;
1119 const struct tile *tgt_tile;
1120 const struct unit *tgt_unit;
1121 const struct civ_map *nmap = &(wld.map);
1122
1123 const struct action_auto_perf *autoperf
1124 = action_auto_perf_unit_sel(cause, actor, other_player,
1126
1127 if (!autoperf) {
1128 /* No matching Action Auto Performer. */
1129 return ACTPROB_IMPOSSIBLE;
1130 }
1131
1133
1134 /* Acquire the targets. */
1136
1138 struct act_prob current = ACTPROB_IMPOSSIBLE;
1139
1140 if (action_id_get_actor_kind(act) == AAK_UNIT) {
1141 /* This action can be done by units. */
1142
1143 switch (action_id_get_target_kind(act)) {
1144 case ATK_STACK:
1145 if (tgt_tile
1147 current = action_prob_vs_stack(nmap, actor, act, tgt_tile);
1148 }
1149 break;
1150 case ATK_TILE:
1151 if (tgt_tile
1155 }
1156 break;
1157 case ATK_EXTRAS:
1158 if (tgt_tile
1161 current = action_prob_vs_extras(nmap, actor, act,
1163 }
1164 break;
1165 case ATK_CITY:
1166 if (tgt_city
1168 current = action_prob_vs_city(nmap, actor, act, tgt_city);
1169 }
1170 break;
1171 case ATK_UNIT:
1172 if (tgt_unit
1174 current = action_prob_vs_unit(nmap, actor, act, tgt_unit);
1175 }
1176 break;
1177 case ATK_SELF:
1178 if (actor
1180 current = action_prob_self(nmap, actor, act);
1181 }
1182 break;
1183 case ATK_COUNT:
1185 }
1186 }
1187
1188 out = action_prob_fall_back(&out, &current);
1190
1191 return out;
1192}
1193
1194/************************************************************************/
1199 const struct unit *act_unit,
1200 const struct city *tgt_city,
1201 const struct player *tgt_player,
1202 const struct action *paction)
1203{
1206 paction);
1207
1208 /* Roll the dice. */
1209 return fc_rand(100) >= odds;
1210}
bool action_prob_possible(const struct act_prob probability)
Definition actions.c:5068
const char * action_name_translation(const struct action *paction)
Definition actions.c:1230
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:5368
struct act_prob action_prob_vs_tile(const struct civ_map *nmap, const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile, const struct extra_type *target_extra)
Definition actions.c:4589
enum action_sub_target_kind action_get_sub_target_kind(const struct action *paction)
Definition actions.c:1119
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:3233
int action_number(const struct action *action)
Definition actions.c:1208
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:3309
struct act_prob action_prob_vs_extras(const struct civ_map *nmap, const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile, const struct extra_type *target_extra)
Definition actions.c:4672
struct act_prob action_prob_self(const struct civ_map *nmap, const struct unit *actor_unit, const action_id act_id)
Definition actions.c:4742
struct act_prob action_prob_fall_back(const struct act_prob *ap1, const struct act_prob *ap2)
Definition actions.c:5276
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:3068
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:3145
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:4231
enum action_target_kind action_get_target_kind(const struct action *paction)
Definition actions.c:1108
struct act_prob action_prob_vs_stack(const struct civ_map *nmap, const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile)
Definition actions.c:4506
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:3458
bool action_id_is_rare_pop_up(action_id act_id)
Definition actions.c:1160
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:4314
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:3386
#define action_auto_perf_by_cause_iterate(_cause_, _act_perf_)
Definition actions.h:354
#define action_auto_perf_actions_iterate_end
Definition actions.h:366
#define action_auto_perf_by_cause_iterate_end
Definition actions.h:360
#define action_has_result(_act_, _res_)
Definition actions.h:184
#define action_auto_perf_actions_iterate(_autoperf_, _act_id_)
Definition actions.h:363
#define action_iterate_end
Definition actions.h:218
#define action_id_get_actor_kind(act_id)
Definition actions.h:413
#define action_get_activity(_pact_)
Definition actions.h:464
#define ACTPROB_IMPOSSIBLE
Definition actions.h:691
#define action_iterate(_act_)
Definition actions.h:214
#define action_id_get_target_kind(act_id)
Definition actions.h:417
#define action_id_has_complex_target(act_id)
Definition actions.h:435
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:220
char * incite_cost
Definition comments.c:76
struct unit struct city struct unit * target_unit
Definition dialogs_g.h:56
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 * actor_unit
Definition dialogs_g.h:55
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:213
@ RPT_CERTAIN
Definition fc_types.h:533
#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:177
#define fc_assert_ret_val(condition, val)
Definition log.h:195
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:291
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:542
#define players_iterate(_pplayer)
Definition player.h:537
void send_player_all_c(struct player *src, struct conn_list *dest)
Definition plrhand.c:1131
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:327
Definition city.h:317
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:2316
int unit_pays_mp_for_action(const struct action *paction, const struct unit *punit)
Definition unit.c:2198
#define unit_tile(_pu)
Definition unit.h:407
#define unit_owner(_pu)
Definition unit.h:406
#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:2882
void wipe_unit(struct unit *punit, enum unit_loss_reason reason, struct player *killer)
Definition unittools.c:2144
void unit_assign_specific_activity_target(struct unit *punit, enum unit_activity *activity, enum gen_action action, 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:1223