00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include <config.h>
00037
00038 #include "combat.h"
00039 #include "commands.h"
00040 #include "land.h"
00041 #include "mission.h"
00042 #include "path.h"
00043 #include "ship.h"
00044
00045 int
00046 atta(void)
00047 {
00048 struct combat off[6];
00049 struct combat def[1];
00050 coord newx, newy;
00051 struct sctstr sect;
00052 int fort_sup, ship_sup, land_sup, plane_sup;
00053 struct emp_qelem olist;
00054 struct emp_qelem dlist;
00055 int ototal;
00056 int a_engineer = 0;
00057 int a_spy = 0;
00058 double osupport = 1.0;
00059 double dsupport = 1.0;
00060 int last, n;
00061 char *p;
00062 char buf[1024];
00063 int rel;
00064
00065 att_combat_init(def, EF_SECTOR);
00066
00067
00068
00069
00070
00071
00072 if (!(p = getstarg(player->argp[1], "Sector : ", buf)))
00073 return RET_SYN;
00074 if (!sarg_xy(p, &def->x, &def->y))
00075 return RET_SYN;
00076 if (att_abort(A_ATTACK, 0, def))
00077 return RET_FAIL;
00078
00079
00080
00081 if (att_show(def))
00082 return RET_FAIL;
00083
00084
00085
00086 att_ask_support(2, &fort_sup, &ship_sup, &land_sup, &plane_sup);
00087 if (att_abort(A_ATTACK, 0, def)) {
00088 att_empty_attack(A_ATTACK, 0, def);
00089 return RET_OK;
00090 }
00091
00092
00093
00094 for (n = 0, last = -1; n < 6; ++n) {
00095 newx = def->x + diroff[n + 1][0];
00096 newy = def->y + diroff[n + 1][1];
00097 getsect(newx, newy, §);
00098 rel = getrel(getnatp(sect.sct_own), player->cnum);
00099 if (!player->owner && rel != ALLIED)
00100 continue;
00101 att_combat_init(&off[++last], EF_SECTOR);
00102 off[last].x = sect.sct_x;
00103 off[last].y = sect.sct_y;
00104 }
00105 off->last = last;
00106
00107
00108
00109 att_ask_offense(A_ATTACK, off, def, &olist, &a_spy, &a_engineer);
00110 if (att_abort(A_ATTACK, off, def)) {
00111 pr("Attack aborted\n");
00112 att_empty_attack(A_ATTACK, 0, def);
00113 return att_free_lists(&olist, 0);
00114 }
00115
00116 ototal = att_get_offense(A_ATTACK, off, &olist, def);
00117 if (att_abort(A_ATTACK, off, def)) {
00118 pr("Attack aborted\n");
00119 att_empty_attack(A_ATTACK, 0, def);
00120 return att_free_lists(&olist, 0);
00121 }
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131 att_get_defense(&olist, def, &dlist, a_spy, ototal);
00132
00133
00134
00135 att_get_support(A_ATTACK, fort_sup, ship_sup, land_sup, plane_sup,
00136 &olist, off, &dlist, def, &osupport, &dsupport,
00137 a_engineer);
00138 if (att_abort(A_ATTACK, off, def)) {
00139 pr("Attack aborted\n");
00140 att_empty_attack(A_ATTACK, 0, def);
00141 return att_free_lists(&olist, &dlist);
00142 }
00143
00144
00145
00146
00147
00148 att_fight(A_ATTACK, off, &olist, osupport, def, &dlist, dsupport);
00149
00150 return RET_OK;
00151 }