2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2004, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23 * related information and legal notices. It is expected that any future
24 * projects/authors will amend these files as needed.
28 * multifire.c: Fire at other sectors/ships
30 * Known contributors to this file:
55 targ_land, targ_ship, targ_sub, targ_unit, targ_bogus
59 struct emp_qelem queue; /* list of fired things */
60 int type; /* ship? otherwise sector */
61 int uid; /* ship uid */
62 coord x, y; /* sector coords */
63 int defdam; /* damage defenders did */
64 int victim; /* who I was shooting at */
73 static void add_to_fired_queue(struct emp_qelem *, struct emp_qelem *);
74 static int defend(struct emp_qelem *al,
76 enum targ_type target,
77 enum targ_type attacker,
81 struct shpstr *fship, int fx, int fy, int *nd);
82 static void do_defdam(struct emp_qelem *, double);
83 static int quiet_bigdef(int, struct emp_qelem *, natid, natid, coord,
85 static void use_ammo(struct emp_qelem *);
114 enum targ_type target, attacker, orig_attacker;
117 struct nstr_item nbst;
123 struct emp_qelem fired, defended;
131 emp_initque(&defended);
133 while ((type != EF_SECTOR) && (type != EF_SHIP) && (type != EF_LAND)) {
134 if (!(p = getstarg(player->argp[1],
135 "Firing from ship(s), sect(s), or land unit(s)? ",
140 if (type == EF_SECTOR) {
141 if (opt_NO_FORT_FIRE) {
142 pr("Fort firing is disabled.\n");
145 orig_attacker = attacker = targ_land;
147 } else if (type == EF_SHIP) {
148 orig_attacker = attacker = targ_ship;
149 } else if (type == EF_LAND) {
150 orig_attacker = attacker = targ_unit;
152 pr("Please type 'sh', 'l', or 'se'!\n");
154 if ((ptr = getstarg(player->argp[2], "Firing from? ", buf)) == 0
158 if (!snxtitem(&nbst, type, ptr))
161 if (player->aborted) {
162 pr("Fire aborted.\n");
165 while (nxtitem(&nbst, (s_char *)&item)) {
166 attacker = orig_attacker;
167 if (attacker == targ_unit) {
168 if (!getland(item.land.lnd_uid, &fland))
170 if (!getsect(item.land.lnd_x, item.land.lnd_y, &fsect))
172 if (item.land.lnd_own != player->cnum)
175 if (fland.lnd_frg == 0) {
176 pr("Unit %d cannot fire!\n", fland.lnd_uid);
179 if (lnd_getmil(&fland) < 1) {
180 pr("Unit %d cannot fire because it has no military!\n",
184 if (fland.lnd_ship >= 0) {
185 pr("Unit %d cannot fire because it is on a ship!\n",
189 if (fland.lnd_land >= 0) {
190 pr("Unit %d cannot fire because it is on a land unit!\n",
194 if (fland.lnd_effic < LAND_MINFIREEFF) {
195 pr("Unit %d cannot fire because it is less than %d%% efficient\n", fland.lnd_uid, LAND_MINFIREEFF);
198 resupply_commod(&fland, I_SHELL); /* Get more shells */
199 putland(fland.lnd_uid, &fland);
200 if (fland.lnd_item[I_SHELL] == 0) {
201 pr("%s -- not enough shells\n", prland(&fland));
204 } else if (attacker == targ_ship) {
205 if (!getship(item.ship.shp_uid, &fship))
207 if (item.ship.shp_own != player->cnum)
209 if (item.ship.shp_item[I_MILIT] < 1) {
210 pr("Not enough mil on ship #%d\n", item.ship.shp_uid);
213 gun = item.ship.shp_item[I_GUN];
214 gun = min(gun, item.ship.shp_glim);
215 if (item.ship.shp_frnge == 0) {
216 pr("Ships %d cannot fire guns!\n", item.ship.shp_uid);
220 pr("Not enough guns on ship #%d\n", item.ship.shp_uid);
223 if (item.ship.shp_item[I_SHELL] == 0) {
224 pr("Not enough shells on ship #%d\n", item.ship.shp_uid);
227 if (item.ship.shp_effic < 60) {
228 pr("Ship #%d is crippled!\n", item.ship.shp_uid);
231 fshipno = fship.shp_uid;
232 } else if (attacker == targ_land) {
233 if (!getsect(item.sect.sct_x, item.sect.sct_y, &fsect))
235 if (item.sect.sct_own != player->cnum)
237 if (item.sect.sct_type != SCT_FORTR)
239 if (item.sect.sct_effic < ((u_char)FORTEFF)) {
240 pr("Fort not efficient enough to fire!\n");
243 if (item.sect.sct_item[I_GUN] == 0) {
244 pr("Not enough guns in sector %s!\n",
245 xyas(item.sect.sct_x, item.sect.sct_y, player->cnum));
248 if (item.sect.sct_item[I_SHELL] == 0) {
249 pr("Not enough shells in sector %s!\n",
250 xyas(item.sect.sct_x, item.sect.sct_y, player->cnum));
253 if (item.sect.sct_item[I_MILIT] < 5) {
254 pr("Not enough military in sector %s!\n",
255 xyas(item.sect.sct_x, item.sect.sct_y, player->cnum));
258 pr("\nSector %s firing\n",
259 xyas(item.sect.sct_x, item.sect.sct_y, player->cnum));
261 if ((ptr = getstarg(player->argp[3], "Firing at? ", buf)) == 0
264 if (player->aborted) {
265 pr("Fire aborted.\n");
269 (void)strcpy(vbuf, ptr);
274 if (target == targ_ship) {
275 vshipno = atoi(vbuf);
276 if (vshipno < 0 || !getship(vshipno, &vship) ||
278 pr("No such ship exists!\n");
281 target = (mchr[(int)vship.shp_type].m_flags & M_SUB) ?
282 targ_sub : targ_ship;
283 vict = vship.shp_own;
286 if (!getsect(x, y, &vsect)) {
287 pr("No such sector exists!\n");
291 if (!sarg_xy(vbuf, &x, &y) || !getsect(x, y, &vsect)) {
292 pr("No such sector exists!\n");
295 /* We check the sector type, but we only use it for damage, not
296 reporting. That way, you don't get extra information you wouldn't
297 normally get. Besides, what if they want to slam water? :) */
298 if (vsect.sct_type == SCT_SANCT || vsect.sct_type == SCT_WATER)
302 vict = vsect.sct_own;
306 if (attacker == targ_ship) {
307 if (fship.shp_own != player->cnum) {
308 pr("Not your ship!\n");
311 if (target == targ_sub || target == targ_ship) {
312 if (fship.shp_uid == vship.shp_uid) {
313 pr("You can't fire upon yourself!\n");
320 attacker = (mchr[fship.shp_type].m_flags & M_SUB) ?
321 targ_sub : targ_ship;
322 if (attacker == targ_sub){
323 pr("Subs may not fire normally.. use torpedo.\n");
327 attacker = targ_ship;
328 if ((mil = fship.shp_item[I_MILIT]) < 1) {
329 pr("Not enough military for firing crew.\n");
332 gun = fship.shp_item[I_GUN];
333 gun = min(gun, fship.shp_glim);
334 if (fship.shp_frnge == 0 || gun == 0) {
335 pr("Insufficient arms.\n");
338 shell = fship.shp_item[I_SHELL];
340 shell += supply_commod(fship.shp_own, fship.shp_x,
341 fship.shp_y, I_SHELL, 2 - shell);
346 if (fship.shp_effic < 60) {
347 pr("Ship #%d is crippled (%d%%)\n", fshipno,
351 range = techfact(fship.shp_tech,
352 (double)fship.shp_frnge / 2.0);
353 range2 = (double)roundrange(range);
354 pr("range is %.2f (%.2f)\n", range2, range);
355 if (target == targ_sub) {
356 if ((mchr[(int)fship.shp_type].m_flags & M_DCH) == 0) {
357 pr("A %s can't drop depth charges!\n",
358 mchr[(int)fship.shp_type].m_name);
362 pr("Not enough shells for depth charge!\n");
366 gun = min(gun, shell * 2);
367 gun = min(gun, mil / 2);
370 guneff = seagun(fship.shp_effic, shots);
372 shell -= ldround(((double)shots) / 2.0, 1);
373 fship.shp_item[I_SHELL] = shell;
374 if (opt_NOMOBCOST == 0)
375 fship.shp_mobil = max(fship.shp_mobil - 15, -100);
376 putship(fship.shp_uid, &fship);
377 } else if (attacker == targ_unit) {
378 if (fland.lnd_own != player->cnum) {
379 pr("Not your unit!\n");
383 if (target == targ_land) {
384 if (fland.lnd_x == vsect.sct_x
385 && fland.lnd_y == vsect.sct_y) {
386 pr("You can't fire upon yourself!\n");
394 if (fland.lnd_frg == 0) {
395 pr("Unit %d cannot fire!\n", fland.lnd_uid);
398 if (fland.lnd_item[I_SHELL] == 0) {
399 pr("%s -- not enough shells\n", prland(&fland));
403 shell = fland.lnd_item[I_SHELL];
405 range = techfact((int)fland.lnd_tech,
406 (double)fland.lnd_frg / 2.0);
407 range2 = (double)roundrange(range);
408 pr("range is %.2f (%.2f)\n", range2, range);
409 if (target == targ_sub) {
410 pr("A %s can't drop depth charges!\n",
411 lchr[(int)fland.lnd_type].l_name);
415 gun = fland.lnd_item[I_GUN];
417 pr("%s -- not enough guns\n", prland(&fland));
421 dam = (int)landunitgun(fland.lnd_effic, fland.lnd_dam, gun,
422 fland.lnd_ammo, shell);
423 if (target == targ_ship) {
424 if (chance(((double)fland.lnd_acc) / 100.0))
425 dam = ldround(((double)dam / 2.0), 1);
428 resupply_commod(&fland, I_SHELL); /* Get more shells */
429 putland(fland.lnd_uid, &fland);
433 if (fsect.sct_own != player->cnum ||
434 fsect.sct_type != SCT_FORTR) {
435 pr("No fortress at %s\n", xyas(fsect.sct_x,
436 fsect.sct_y, player->cnum));
439 if (target == targ_land) {
440 if (fsect.sct_x == vsect.sct_x
441 && fsect.sct_y == vsect.sct_y) {
442 pr("You can't fire upon yourself!\n");
446 attacker = targ_land;
447 if ((gun = fsect.sct_item[I_GUN]) == 0) {
448 pr("Insufficient arms.\n");
451 shell = fsect.sct_item[I_SHELL];
453 shell += supply_commod(fsect.sct_own, fsect.sct_x,
454 fsect.sct_y, I_SHELL, 1);
459 if (fsect.sct_item[I_MILIT] < 5) {
460 pr("Not enough military for firing crew.\n");
463 if (target == targ_sub) {
464 pr("Target ship not sighted!\n");
469 range = tfactfire(player->cnum, 7.0);
470 if (fsect.sct_effic > 59)
472 range2 = (double)roundrange(range);
473 pr("range is %.2f (%.2f)\n", range2, range);
474 guneff = landgun((int)fsect.sct_effic, gun);
477 fsect.sct_item[I_SHELL] = shell;
480 trange = mapdist(x, y, fx, fy);
481 if (trange > range2) {
482 pr("Target out of range.\n");
487 pr("Target out of range. Thud.\n");
490 pr("Target ship out of range. Splash.\n");
499 fland.lnd_mission = 0;
500 putland(fland.lnd_uid, &fland);
503 fship.shp_mission = 0;
504 putship(fship.shp_uid, &fship);
509 if (target == targ_bogus) {
510 if (vsect.sct_type == SCT_SANCT) {
511 pr("%s is a %s!!\n", vbuf,
512 dchr[SCT_SANCT].d_name);
514 } else if (vsect.sct_type == SCT_WATER) {
515 pr("You must specify a ship in sector %s!\n",
523 if (!trechk(player->cnum, vict, SEAFIR))
527 if (!trechk(player->cnum, vict, SUBFIR))
532 if (!trechk(player->cnum, vict, LANFIR))
540 if (target == targ_land) {
541 natp = getnatp(player->cnum);
542 rel = getrel(natp, vict);
543 if ((rel != AT_WAR) && (player->cnum != vict) &&
544 (vict) && (vsect.sct_oldown != player->cnum)) {
545 pr("You're not at war with them!\n");
555 if (vship.shp_rflags & RET_DCHRGED)
556 retreat_ship(&vship, 'd');
561 prb = (double)(range2 ? (trange / range2) : 1.0);
570 pr("Wind deflects shell%s.\n", splur(shots));
571 /* dam = (int)((double)dam / 2.0);*/
574 (double)((double)(90 - (random() % 11)) /
584 nreport(player->cnum, N_SCT_SHELL, vict, 1);
585 if (vict && vict != player->cnum)
587 "Country #%d shelled sector %s for %d damage.\n",
588 player->cnum, xyas(x, y, vict), dam);
589 pr("Shell%s hit sector %s for %d damage.\n",
590 splur(shots), xyas(x, y, player->cnum), dam);
591 /* Ok, it wasn't a bogus target, so do damage. */
592 if (target != targ_bogus)
593 sectdamage(&vsect, dam, 0);
596 nreport(player->cnum, N_SHP_SHELL, vict, 1);
599 if ((target != targ_sub) ||
600 ((vship.shp_rflags & RET_DCHRGED) == 0))
601 check_retreat_and_do_shipdamage(&vship, dam);
603 shipdamage(&vship, dam);
606 "Country #%d shelled %s in %s for %d damage.\n",
607 player->cnum, prship(&vship),
608 xyas(vship.shp_x, vship.shp_y, vict), dam);
610 pr("Shell%s hit %s in %s for %d damage.\n",
611 splur(shots), prsub(&vship),
612 xyas(vship.shp_x, vship.shp_y, player->cnum), dam);
614 if (vship.shp_effic < SHIP_MINEFF)
615 pr("%s sunk!\n", prsub(&vship));
619 /* Ok, now, check if we had a bogus target. If so,
620 just continue on, since there is no defender. */
621 if (target == targ_bogus)
623 if (attacker == targ_unit) {
624 attacker = targ_land;
625 getsect(fland.lnd_x, fland.lnd_y, &fsect);
628 defend(&fired, &defended, target, attacker, &vsect, &fsect,
629 &vship, &fship, fx, fy, &ndefending);
635 putship(vship.shp_uid, &vship);
638 if ((totaldefdam == 0) && (target == targ_ship))
639 if (vship.shp_rflags & RET_INJURED)
640 retreat_ship(&vship, 'h');
646 if ((target == targ_ship) || (target == targ_sub)) {
647 if (fship.shp_effic > SHIP_MINEFF) {
648 shp_missdef(&fship, vict);
651 putship(fship.shp_uid, &fship);
658 odds = ((double)ndefending) / ((double)nfiring);
661 do_defdam(&fired, odds);
666 defend(struct emp_qelem *al, struct emp_qelem *dl, enum targ_type target,
667 enum targ_type attacker, struct sctstr *vsect, struct sctstr *fsect,
668 struct shpstr *vship, struct shpstr *fship, int fx, int fy, int *nd)
672 int vict, nfiring = 0;
676 if (attacker == targ_land)
677 aown = fsect->sct_own;
679 aown = fship->shp_own;
681 if (target == targ_land)
682 vict = vsect->sct_own;
684 vict = vship->shp_own;
687 (dam = quiet_bigdef(attacker, dl, vict, aown, fx, fy, &nfiring))) {
690 fp = (struct flist *)malloc(sizeof(struct flist));
691 memset(fp, 0, sizeof(struct flist));
696 fp->x = fsect->sct_x;
697 fp->y = fsect->sct_y;
698 fp->type = targ_land;
701 fp->type = targ_ship;
702 fp->uid = fship->shp_uid;
705 emp_insque(&fp->queue, al);
712 do_defdam(struct emp_qelem *list, double odds)
715 int dam, vict, first = 1;
719 struct emp_qelem *qp, *next;
721 for (qp = list->q_forw; qp != list; qp = next) {
723 fp = (struct flist *)qp;
724 if (fp->type == targ_ship) {
725 if (!getship(fp->uid, &ship) || !ship.shp_own)
730 pr("\nDefenders fire back!\n");
733 dam = (odds * (double)fp->defdam);
735 if (fp->type == targ_ship) {
737 pr("Return fire hit %s in %s for %d damage.\n",
739 xyas(ship.shp_x, ship.shp_y, player->cnum), dam);
742 "Return fire hit %s in %s for %d damage.\n",
743 prsub(&ship), xyas(ship.shp_x, ship.shp_y, vict), dam);
744 shipdamage(&ship, dam);
745 putship(ship.shp_uid, &ship);
747 getsect(fp->x, fp->y, §);
749 pr("Return fire hit sector %s for %d damage.\n",
750 xyas(fp->x, fp->y, player->cnum), dam);
751 sectdamage(§, dam, 0);
754 wu(0, vict, "Return fire hit sector %s for %d damage.\n",
755 xyas(fp->x, fp->y, vict), dam);
757 emp_remque(&fp->queue);
763 quiet_bigdef(int attacker, struct emp_qelem *list, natid own, natid aown,
764 coord ax, coord ay, int *nfiring)
767 double range, erange, hitchance;
771 int dam, dam2, rel, rel2;
773 struct sctstr firing;
781 snxtitem_dist(&ni, EF_SHIP, ax, ay, 8);
782 while (nxtitem(&ni, &ship)) {
783 if (ship.shp_own == 0)
786 if ((mchr[(int)ship.shp_type].m_flags & M_SUB) &&
787 (attacker == targ_land))
790 rel = getrel(getnatp(ship.shp_own), own);
791 rel2 = getrel(getnatp(ship.shp_own), aown);
792 if ((ship.shp_own != own) && ((rel != ALLIED) || (rel2 != AT_WAR)))
794 /* Don't shoot yourself */
795 if (ship.shp_own == aown)
797 if (ship.shp_effic < 60)
800 gun = ship.shp_item[I_GUN];
801 shell = ship.shp_item[I_SHELL];
803 if (ship.shp_item[I_MILIT] < 1)
806 if (mchr[(int)ship.shp_type].m_flags & M_SUB) {
807 if (shell < SHP_TORP_SHELLS)
808 shell += supply_commod(ship.shp_own, ship.shp_x, ship.shp_y,
809 I_SHELL, SHP_TORP_SHELLS - shell);
810 if (shell < SHP_TORP_SHELLS)
815 if (ship.shp_mobil <= 0)
818 erange = ship.shp_effic *
819 techfact(ship.shp_tech, ((double)ship.shp_frnge))
821 erange = (double)roundrange(erange);
822 range = mapdist(ship.shp_x, ship.shp_y, ax, ay);
825 if (!line_of_sight((s_char **)0, ship.shp_x, ship.shp_y, ax, ay))
829 fp = (struct flist *)malloc(sizeof(struct flist));
830 memset(fp, 0, sizeof(struct flist));
831 fp->type = targ_ship;
832 fp->uid = ship.shp_uid;
833 add_to_fired_queue(&fp->queue, list);
835 nreport(ship.shp_own, N_FIRE_BACK, player->cnum, 1);
837 hitchance = DTORP_HITCHANCE(range, ship.shp_visib);
838 if (!chance(hitchance))
841 dam += TORP_DAMAGE();
843 range = techfact(ship.shp_tech,
844 ship.shp_frnge * ship.shp_effic / 200.0);
845 range = (double)roundrange(range);
846 if (range < ni.curdist)
848 /* must have gun, shell, and milit to fire */
850 shell += supply_commod(ship.shp_own, ship.shp_x, ship.shp_y,
852 /* only need 1 shell, so don't check that */
855 nshot = min(gun, ship.shp_item[I_MILIT]);
856 nshot = min(nshot, ship.shp_glim);
860 fp = (struct flist *)malloc(sizeof(struct flist));
861 memset(fp, 0, sizeof(struct flist));
862 fp->type = targ_ship;
863 fp->uid = ship.shp_uid;
864 add_to_fired_queue(&fp->queue, list);
865 nreport(ship.shp_own, N_FIRE_BACK, player->cnum, 1);
866 dam += seagun(ship.shp_effic, nshot);
869 snxtitem_dist(&ni, EF_LAND, ax, ay, 8);
870 while (nxtitem(&ni, &land)) {
871 if (land.lnd_own == 0)
873 if (land.lnd_effic < LAND_MINFIREEFF)
875 /* Can't fire if on a ship */
876 if (land.lnd_ship >= 0)
878 if (land.lnd_land >= 0)
880 /* Gotta have military */
881 if (lnd_getmil(&land) < 1)
883 /* Don't shoot yourself */
884 if (land.lnd_own == aown)
887 rel = getrel(getnatp(land.lnd_own), own);
888 rel2 = getrel(getnatp(land.lnd_own), aown);
890 if ((land.lnd_own != own) && ((rel != ALLIED) || (rel2 != AT_WAR)))
894 range = techfact((int)land.lnd_tech, (double)land.lnd_frg / 2.0);
895 range = (double)roundrange(range);
896 if (range < ni.curdist)
900 if (!has_supply(&land))
903 gun = land.lnd_item[I_GUN];
904 shell = land.lnd_item[I_SHELL];
906 if (land.lnd_item[I_MILIT] == 0 || shell == 0 || gun == 0)
909 dam2 = (int)landunitgun(land.lnd_effic, land.lnd_dam, gun,
910 land.lnd_ammo, shell);
913 fp = (struct flist *)malloc(sizeof(struct flist));
914 memset(fp, 0, sizeof(struct flist));
915 fp->type = targ_unit;
916 fp->uid = land.lnd_uid;
917 add_to_fired_queue(&fp->queue, list);
919 putland(land.lnd_uid, &land);
920 nreport(land.lnd_own, N_FIRE_BACK, player->cnum, 1);
925 * Determine if any nearby gun-equipped sectors are within
926 * range and able to fire at an attacker. Firing sectors
927 * need to have guns, shells, and military. Sector being
928 * attacked is x,y -- attacker is at ax,ay.
931 if (!opt_NO_FORT_FIRE) {
932 snxtsct_dist(&ns, ax, ay, 8);
933 while (nxtsct(&ns, &firing)) {
935 if (firing.sct_type != SCT_FORTR)
937 if (firing.sct_own == 0)
939 rel = getrel(getnatp(firing.sct_own), own);
940 rel2 = getrel(getnatp(firing.sct_own), aown);
942 if ((firing.sct_own != own) &&
943 ((rel != ALLIED) || (rel2 != AT_WAR)))
945 /* Don't shoot yourself */
946 if (firing.sct_own == aown)
948 tech = tfactfire(firing.sct_own, 1.0);
950 if (firing.sct_effic > 59) /* fort bonus */
952 range = (double)roundrange(range);
953 if (range < ns.curdist)
956 gun = firing.sct_item[I_GUN];
957 shell = firing.sct_item[I_SHELL];
960 shell += supply_commod(firing.sct_own,
961 firing.sct_x, firing.sct_y,
963 if (gun == 0 || firing.sct_item[I_MILIT] < 5 || shell == 0)
966 fp = (struct flist *)malloc(sizeof(struct flist));
967 memset(fp, 0, sizeof(struct flist));
968 fp->x = firing.sct_x;
969 fp->y = firing.sct_y;
970 fp->type = targ_land;
971 add_to_fired_queue(&fp->queue, list);
972 nreport(firing.sct_own, N_FIRE_BACK, player->cnum, 1);
975 dam += landgun((int)firing.sct_effic, gun);
979 return ((*nfiring) == 0 ? 0 : (dam / (*nfiring)));
983 use_ammo(struct emp_qelem *list)
985 struct emp_qelem *qp, *next;
995 /* use 1 shell from everyone */
996 for (qp = list->q_forw; qp != list; qp = next) {
998 fp = (struct flist *)qp;
999 if (fp->type == targ_ship) {
1000 getship(fp->uid, &ship);
1001 item = ship.shp_item;
1002 if (mchr[(int)ship.shp_type].m_flags & M_SUB) {
1003 shell = item[I_SHELL];
1004 shell -= SHP_TORP_SHELLS - 1;
1007 item[I_SHELL] = shell;
1008 putship(ship.shp_uid, &ship);
1009 mcp = &mchr[(int)ship.shp_type];
1010 mobcost = ship.shp_effic * 0.01 * ship.shp_speed;
1011 mobcost = (480.0 / (mobcost +
1012 techfact(ship.shp_tech, mobcost)));
1013 /* mob cost = 1/2 a sect's mob */
1015 ship.shp_mobil -= mobcost;
1017 } else if (fp->type == targ_land) {
1018 getsect(fp->x, fp->y, §);
1019 item = sect.sct_item;
1021 getland(fp->uid, &land);
1022 item = land.lnd_item;
1024 shell = item[I_SHELL];
1028 item[I_SHELL] = shell;
1029 if (fp->type == targ_ship)
1030 putship(ship.shp_uid, &ship);
1031 else if (fp->type == targ_land)
1034 putland(land.lnd_uid, &land);
1036 emp_remque(&fp->queue);
1043 add_to_fired_queue(struct emp_qelem *elem, struct emp_qelem *list)
1045 struct emp_qelem *qp;
1046 struct flist *fp, *ep;
1049 ep = (struct flist *)elem;
1051 /* Don't put them on the list if they're already there */
1052 for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
1053 fp = (struct flist *)qp;
1054 if ((fp->type == targ_ship) && (fp->uid == ep->uid))
1056 if ((fp->type != targ_ship) && (fp->x == ep->x) &&
1062 emp_insque(elem, list);