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 #include <config.h>
00036
00037 #include "combat.h"
00038 #include "commands.h"
00039 #include "item.h"
00040 #include "land.h"
00041 #include "mission.h"
00042 #include "path.h"
00043 #include "plane.h"
00044 #include "ship.h"
00045
00046 static int paradrop(struct emp_qelem *list, coord x, coord y);
00047
00048 int
00049 para(void)
00050 {
00051 int mission_flags;
00052 coord tx, ty;
00053 coord ax, ay;
00054 int ap_to_target;
00055 char flightpath[MAX_PATH_LEN];
00056 struct nstr_item ni_bomb;
00057 struct nstr_item ni_esc;
00058 struct sctstr target;
00059 struct emp_qelem bomb_list;
00060 struct emp_qelem esc_list;
00061 int wantflags;
00062 struct sctstr ap_sect;
00063 char buf[1024];
00064
00065 wantflags = P_P;
00066 if (!snxtitem(&ni_bomb, EF_PLANE, player->argp[1]))
00067 return RET_SYN;
00068 if (!snxtitem(&ni_esc, EF_PLANE,
00069 getstarg(player->argp[2], "escort(s)? ", buf)))
00070 pr("No escorts...\n");
00071 if (!get_assembly_point(player->argp[3], &ap_sect, buf))
00072 return RET_SYN;
00073 ax = ap_sect.sct_x;
00074 ay = ap_sect.sct_y;
00075 if (getpath(flightpath, player->argp[4], ax, ay, 0, 0, P_FLYING) == 0
00076 || *flightpath == 0)
00077 return RET_SYN;
00078 tx = ax;
00079 ty = ay;
00080 (void)pathtoxy(flightpath, &tx, &ty, fcost);
00081 getsect(tx, ty, &target);
00082 pr("LZ is %s\n", xyas(tx, ty, player->cnum));
00083 ap_to_target = strlen(flightpath);
00084 if (flightpath[ap_to_target - 1] == 'h')
00085 ap_to_target--;
00086 pr("range to target is %d\n", ap_to_target);
00087
00088
00089
00090 pln_sel(&ni_bomb, &bomb_list, &ap_sect, ap_to_target,
00091 2, P_C | wantflags, P_M | P_O);
00092 pln_sel(&ni_esc, &esc_list, &ap_sect, ap_to_target,
00093 2, P_ESC | P_F, P_M | P_O);
00094
00095
00096
00097 mission_flags = 0;
00098 mission_flags |= P_X;
00099 mission_flags |= P_H;
00100 mission_flags = pln_arm(&bomb_list, 2 * ap_to_target, 'a',
00101 &ichr[I_MILIT], 0, mission_flags);
00102 if (QEMPTY(&bomb_list)) {
00103 pr("No planes could be equipped for the mission.\n");
00104 return RET_FAIL;
00105 }
00106 mission_flags = pln_arm(&esc_list, 2 * ap_to_target, 'a',
00107 &ichr[I_MILIT], P_ESC | P_F, mission_flags);
00108 ac_encounter(&bomb_list, &esc_list, ax, ay, flightpath, mission_flags,
00109 0, 0, 0);
00110 if (QEMPTY(&bomb_list)) {
00111 pr("No planes got through fighter defenses\n");
00112 } else {
00113 getsect(tx, ty, &target);
00114 paradrop(&bomb_list, tx, ty);
00115 }
00116 pln_put(&bomb_list);
00117 pln_put(&esc_list);
00118 return RET_OK;
00119 }
00120
00121 static int
00122 paradrop(struct emp_qelem *list, coord x, coord y)
00123 {
00124 struct combat off[1];
00125 struct combat def[1];
00126 struct emp_qelem olist;
00127 struct emp_qelem dlist;
00128 int ototal;
00129 int a_engineer = 0;
00130 int a_spy = 0;
00131 double osupport = 1.0;
00132 double dsupport = 1.0;
00133 struct plist *plp;
00134 struct emp_qelem *qp;
00135
00136
00137
00138 att_combat_init(def, EF_SECTOR);
00139 def->x = x;
00140 def->y = y;
00141 if (att_abort(A_PARA, 0, def))
00142 return RET_FAIL;
00143
00144
00145
00146 if (att_show(def))
00147 return RET_FAIL;
00148
00149
00150
00151 emp_initque(&olist);
00152 att_combat_init(off, EF_PLANE);
00153 for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
00154 plp = (struct plist *)qp;
00155 if (plp->pcp->pl_flags & (P_V | P_C))
00156 off->troops += plp->misc;
00157 }
00158 off->mil = off->troops;
00159 if (att_abort(A_PARA, off, def)) {
00160 pr("Air-Assault aborted\n");
00161 return RET_OK;
00162 }
00163
00164 ototal = att_get_offense(A_PARA, off, &olist, def);
00165 if (att_abort(A_PARA, off, def)) {
00166 pr("Air-assault aborted\n");
00167 return RET_OK;
00168 }
00169
00170
00171
00172 att_get_defense(&olist, def, &dlist, a_spy, ototal);
00173
00174
00175
00176 att_get_support(A_PARA, 0, 0, 0, 0,
00177 &olist, off, &dlist, def, &osupport, &dsupport,
00178 a_engineer);
00179
00180 if (att_abort(A_PARA, off, def)) {
00181 pr("Air-assault aborted\n");
00182 return RET_OK;
00183 }
00184
00185
00186
00187
00188 att_fight(A_PARA, off, &olist, osupport, def, &dlist, dsupport);
00189
00190 return RET_OK;
00191 }