2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2015, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure, Markus Armbruster
6 * Empire 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 3 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, see <http://www.gnu.org/licenses/>.
21 * See files README, COPYING and CREDITS in the root of the source
22 * tree for related information and legal notices. It is expected
23 * that future projects/authors will amend these files as needed.
27 * shpsub.c: Ship subroutine stuff
29 * Known contributors to this file:
31 * Steve McClure, 1996-2000
32 * Markus Armbruster, 2006-2014
50 #include "prototypes.h"
56 static void shp_nav_put_one(struct ulist *);
57 static int shp_check_one_mines(struct ulist *);
58 static int shp_hit_mine(struct shpstr *);
59 static void shp_stays(natid, char *, struct ulist *);
62 shp_find_capable(struct emp_qelem *list, int flags)
67 for (qp = list->q_back; qp != list; qp = qp->q_back) {
68 mlp = (struct ulist *)qp;
69 if (mchr[mlp->unit.ship.shp_type].m_flags & flags)
76 shp_sel(struct nstr_item *ni, struct emp_qelem *list)
81 while (nxtitem(ni, &ship)) {
83 * It would be nice to let deities navigate foreign ships, but
84 * much of the code assumes that only the ship's owner can
87 if (!ship.shp_own || ship.shp_own != player->cnum)
90 if (ontradingblock(EF_SHIP, &ship)) {
91 pr("ship #%d inelligible - it's for sale.\n",
98 memset(ship.shp_rpath, 0, sizeof(ship.shp_rpath));
99 putship(ship.shp_uid, &ship);
100 shp_insque(&ship, list);
106 * Return the new list link.
109 shp_insque(struct shpstr *sp, struct emp_qelem *list)
111 struct ulist *mlp = malloc(sizeof(struct ulist));
113 mlp->unit.ship = *sp;
114 mlp->mobil = sp->shp_mobil;
115 emp_insque(&mlp->queue, list);
119 /* This function assumes that the list was created by shp_sel */
121 shp_nav(struct emp_qelem *list, double *minmobp, double *maxmobp,
124 struct emp_qelem *qp;
125 struct emp_qelem *next;
127 struct shpstr *sp, *flg = NULL;
132 for (qp = list->q_back; qp != list; qp = next) {
134 mlp = (struct ulist *)qp;
135 sp = &mlp->unit.ship;
136 getship(sp->shp_uid, sp);
137 if (sp->shp_own != actor) {
138 mpr(actor, "%s was sunk at %s\n",
139 prship(sp), xyas(sp->shp_x, sp->shp_y, actor));
140 emp_remque(&mlp->queue);
144 /* check crew - uws don't count */
145 if (sp->shp_item[I_MILIT] == 0 && sp->shp_item[I_CIVIL] == 0) {
146 shp_stays(actor, "is crewless", mlp);
149 if (!getsect(sp->shp_x, sp->shp_y, §)) {
150 shp_stays(actor, "was sucked into the sky by a strange looking spaceship", mlp); /* heh -KHS */
153 switch (shp_check_nav(sp, §)) {
156 case SHP_STUCK_CONSTRUCTION:
157 shp_stays(actor, "is caught in a construction zone", mlp);
162 case SHP_STUCK_CANAL:
163 case SHP_STUCK_IMPASSABLE:
164 shp_stays(actor, "is landlocked", mlp);
169 else if (sp->shp_x != flg->shp_x || sp->shp_y != flg->shp_y) {
170 shp_stays(actor, "is not with the flagship", mlp);
173 if (sp->shp_mobil + 1 < (int)mlp->mobil) {
174 mlp->mobil = sp->shp_mobil;
176 if (mlp->mobil < *minmobp)
177 *minmobp = mlp->mobil;
178 if (mlp->mobil > *maxmobp)
179 *maxmobp = mlp->mobil;
184 shp_nav_put(struct emp_qelem *list, natid actor)
186 struct emp_qelem *qp, *next;
190 for (qp = list->q_back; qp != list; qp = next) {
192 mlp = (struct ulist *)qp;
193 sp = &mlp->unit.ship;
194 mpr(actor, "%s stopped at %s\n",
195 prship(sp), xyas(sp->shp_x, sp->shp_y, actor));
196 shp_nav_put_one(mlp);
201 shp_nav_put_one(struct ulist *mlp)
203 mlp->unit.ship.shp_mobil = (int)mlp->mobil;
204 putship(mlp->unit.ship.shp_uid, &mlp->unit.ship);
205 emp_remque(&mlp->queue);
210 * Sweep seamines with engineers in SHIP_LIST for ACTOR.
211 * All ships in SHIP_LIST must be in the same sector.
212 * If EXPLICIT is non-zero, this is for an explicit sweep command from
213 * a player. Else it's an automatic "on the move" sweep.
214 * If TAKEMOB is non-zero, require and charge mobility.
215 * Return non-zero when the ships should stop.
218 shp_sweep(struct emp_qelem *ship_list, int explicit, int takemob,
221 struct emp_qelem *qp;
222 struct emp_qelem *next;
225 int mines, m, max, shells;
227 int stopping = 0, first = 1;
229 mlp = shp_find_capable(ship_list, M_SWEEP);
232 mpr(actor, "No minesweepers!\n");
236 getsect(mlp->unit.ship.shp_x, mlp->unit.ship.shp_y, §);
237 if (sect.sct_type != SCT_WATER) {
239 mpr(actor, "%s is a %s. No seamines there!\n",
240 xyas(sect.sct_x, sect.sct_y, actor),
241 dchr[sect.sct_type].d_name);
245 for (qp = ship_list->q_back; qp != ship_list; qp = next) {
247 mlp = (struct ulist *)qp;
248 if (!(mchr[mlp->unit.ship.shp_type].m_flags & M_SWEEP))
251 if (mlp->mobil <= 0.0) {
253 mpr(actor, "%s is out of mobility!\n",
254 prship(&mlp->unit.ship));
257 mlp->mobil -= shp_mobcost(&mlp->unit.ship);
258 mlp->unit.ship.shp_mobil = (int)mlp->mobil;
260 putship(mlp->unit.ship.shp_uid, &mlp->unit.ship);
261 getsect(mlp->unit.ship.shp_x, mlp->unit.ship.shp_y, §);
262 if (!(mines = sect.sct_mines))
264 max = mchr[mlp->unit.ship.shp_type].m_item[I_SHELL];
265 shells = mlp->unit.ship.shp_item[I_SHELL];
266 for (m = 0; mines > 0 && m < 5; m++) {
269 mpr(actor, "Approaching minefield at %s...\n",
270 xyas(sect.sct_x, sect.sct_y, actor));
273 mpr(actor, "Sweep...\n");
275 shells = MIN(max, shells + 1);
276 changed |= map_set(actor, sect.sct_x, sect.sct_y, 'X', 0);
279 sect.sct_mines = mines;
280 mlp->unit.ship.shp_item[I_SHELL] = shells;
281 putship(mlp->unit.ship.shp_uid, &mlp->unit.ship);
283 if (shp_check_one_mines(mlp)) {
295 shp_check_one_mines(struct ulist *mlp)
300 getsect(mlp->unit.ship.shp_x, mlp->unit.ship.shp_y, §);
301 if (sect.sct_type != SCT_WATER)
305 if (chance(DMINE_HITCHANCE(sect.sct_mines))) {
306 actor = mlp->unit.ship.shp_own;
307 shp_hit_mine(&mlp->unit.ship);
309 if (map_set(actor, sect.sct_x, sect.sct_y, 'X', 0))
312 putship(mlp->unit.ship.shp_uid, &mlp->unit.ship);
313 if (!mlp->unit.ship.shp_own)
320 shp_check_mines(struct emp_qelem *ship_list)
322 struct emp_qelem *qp;
323 struct emp_qelem *next;
327 for (qp = ship_list->q_back; qp != ship_list; qp = next) {
329 mlp = (struct ulist *)qp;
330 if (shp_check_one_mines(mlp)) {
341 shp_stays(natid actor, char *str, struct ulist *mlp)
343 mpr(actor, "%s %s & stays in %s\n",
344 prship(&mlp->unit.ship), str,
345 xyas(mlp->unit.ship.shp_x, mlp->unit.ship.shp_y, actor));
346 shp_nav_put_one(mlp);
350 * Return whether and why SP would be stuck in SECTP.
353 shp_check_nav(struct shpstr *sp, struct sctstr *sectp)
355 switch (dchr[sectp->sct_type].d_nav) {
359 if (!(mchr[sp->shp_type].m_flags & M_CANAL)) {
360 return SHP_STUCK_CANAL;
364 if (sectp->sct_effic < 2)
365 return SHP_STUCK_CONSTRUCTION;
368 if (sectp->sct_effic < 60)
369 return SHP_STUCK_CONSTRUCTION;
375 return SHP_STUCK_IMPASSABLE;
377 return SHP_STUCK_NOT;
381 sect_has_dock(struct sctstr *sect)
383 switch (dchr[sect->sct_type].d_nav) {
393 shp_count(struct emp_qelem *list, int wantflags, int nowantflags,
396 struct emp_qelem *qp;
397 struct emp_qelem *next;
401 for (qp = list->q_back; qp != list; qp = next) {
403 mlp = (struct ulist *)qp;
404 if (mlp->unit.ship.shp_x != x || mlp->unit.ship.shp_y != y)
407 (mchr[mlp->unit.ship.shp_type].m_flags & wantflags) != wantflags)
410 mchr[mlp->unit.ship.shp_type].m_flags & nowantflags)
418 shp_damage_one(struct ulist *mlp, int dam)
420 /* ship might have changed (launched interceptors, missile defense) */
421 getship(mlp->unit.ship.shp_uid, &mlp->unit.ship);
422 shipdamage(&mlp->unit.ship, dam);
423 putship(mlp->unit.ship.shp_uid, &mlp->unit.ship);
424 if (!mlp->unit.ship.shp_own) {
425 emp_remque(&mlp->queue);
431 shp_damage(struct emp_qelem *list, int totdam, int wantflags,
432 int nowantflags, int x, int y)
434 struct emp_qelem *qp;
435 struct emp_qelem *next;
441 || !(count = shp_count(list, wantflags, nowantflags, x, y)))
443 dam = ldround((double)totdam / count, 1);
444 for (qp = list->q_back; qp != list; qp = next) {
446 mlp = (struct ulist *)qp;
447 if (mlp->unit.ship.shp_x != x || mlp->unit.ship.shp_y != y)
450 (mchr[mlp->unit.ship.shp_type].m_flags & wantflags) != wantflags)
453 mchr[mlp->unit.ship.shp_type].m_flags & nowantflags)
455 shp_damage_one(mlp, dam);
461 shp_contains(struct emp_qelem *list, int newx, int newy, int wantflags,
464 struct emp_qelem *qp;
465 struct emp_qelem *next;
468 for (qp = list->q_back; qp != list; qp = next) {
470 mlp = (struct ulist *)qp;
471 /* If the ship isn't in the requested sector, then continue */
472 if (newx != mlp->unit.ship.shp_x || newy != mlp->unit.ship.shp_y)
475 (mchr[mlp->unit.ship.shp_type].m_flags & wantflags) != wantflags)
478 mchr[mlp->unit.ship.shp_type].m_flags & nowantflags)
485 static struct ulist *
486 most_valuable_ship(struct emp_qelem *list, coord x, coord y)
488 struct emp_qelem *qp;
489 struct emp_qelem *next;
491 struct ulist *mvs = NULL;
493 for (qp = list->q_back; qp != list; qp = next) {
495 mlp = (struct ulist *)qp;
496 if (mlp->unit.ship.shp_x != x || mlp->unit.ship.shp_y != y)
498 if (mchr[mlp->unit.ship.shp_type].m_flags & M_SUB)
500 if (!mchr[mlp->unit.ship.shp_type].m_nxlight &&
501 !mchr[mlp->unit.ship.shp_type].m_nchoppers &&
502 mchr[mlp->unit.ship.shp_type].m_cost < 1000 &&
503 !mchr[mlp->unit.ship.shp_type].m_nplanes &&
504 !mchr[mlp->unit.ship.shp_type].m_nland)
510 if (mchr[mlp->unit.ship.shp_type].m_cost * mlp->unit.ship.shp_effic >
511 mchr[mvs->unit.ship.shp_type].m_cost * mvs->unit.ship.shp_effic)
518 shp_easiest_target(struct emp_qelem *list, int wantflags, int nowantflags)
520 struct emp_qelem *qp;
521 struct emp_qelem *next;
524 int easiest = 9876; /* things start great for victim */
527 for (qp = list->q_back; qp != list; qp = next) {
529 mlp = (struct ulist *)qp;
531 (mchr[mlp->unit.ship.shp_type].m_flags & wantflags) != wantflags)
534 mchr[mlp->unit.ship.shp_type].m_flags & nowantflags)
536 hard = shp_hardtarget(&mlp->unit.ship);
538 easiest = hard; /* things get worse for victim */
541 return easiest - count;
545 shp_missile_interdiction(struct emp_qelem *list, coord newx, coord newy,
550 struct emp_qelem msl_list, *qp, *newqp;
554 mvs = most_valuable_ship(list, newx, newy);
558 msl_sel(&msl_list, newx, newy, victim, P_T | P_MAR, 0, MI_INTERDICT);
560 for (qp = msl_list.q_back; qp != &msl_list; qp = newqp) {
562 plp = (struct plist *)qp;
564 if (mvs && mission_pln_equip(plp, NULL, 'p') >= 0) {
565 if (msl_launch(&plp->plane, EF_SHIP, prship(&mvs->unit.ship),
566 newx, newy, victim, &sublaunch) < 0)
569 if (msl_hit(&plp->plane,
570 shp_hardtarget(&mvs->unit.ship), EF_SHIP,
571 N_SHP_MISS, N_SHP_SMISS, sublaunch, victim)) {
572 dam = pln_damage(&plp->plane, 'p', 1);
574 "missile interdiction mission does %d damage to %s!\n",
575 dam, prship(&mvs->unit.ship));
576 shp_damage_one(mvs, dam);
578 dam = pln_damage(&plp->plane, 'p', 0);
579 collateral_damage(newx, newy, dam);
581 mvs = most_valuable_ship(list, newx, newy);
583 plp->plane.pln_effic = 0;
584 putplane(plp->plane.pln_uid, &plp->plane);
593 /* Note that this function has a side effect - it uses coastwatch
594 * ranges to see if it should fire upon a ship. So, this function
595 * is expected to return positive if a ship is in range, and 0 if a
596 * ship is not in range. */
598 notify_coastguard(struct emp_qelem *list, int trange, struct sctstr *sectp)
600 struct emp_qelem *qp;
601 struct emp_qelem *next;
606 natp = getnatp(sectp->sct_own);
608 vrange = sectp->sct_type == SCT_RADAR ? 14 : 4;
609 vrange *= tfact(sectp->sct_own, 1.0) * sectp->sct_effic / 100.0;
617 for (qp = list->q_back; qp != list; qp = next) {
619 mlp = (struct ulist *)qp;
620 if (mchr[mlp->unit.ship.shp_type].m_flags & M_SUB)
622 if (natp->nat_flags & NF_COASTWATCH)
623 wu(0, sectp->sct_own,
624 "%s %s sighted at %s\n",
625 cname(mlp->unit.ship.shp_own),
626 prship(&mlp->unit.ship),
627 xyas(mlp->unit.ship.shp_x, mlp->unit.ship.shp_y,
630 setcont(sectp->sct_own, mlp->unit.ship.shp_own, FOUND_COAST);
637 shp_fort_interdiction(struct emp_qelem *list, coord newx, coord newy,
646 signed char notified[MAXNOC];
649 /* Inform neutral and worse */
650 for (i = 0; i < MAXNOC; ++i) {
651 if (relations_with(i, victim) <= NEUTRAL)
657 snxtsct_dist(&ns, newx, newy, fort_max_interdiction_range);
658 while (nxtsct(&ns, &fsect)) {
661 if (fsect.sct_own == victim)
663 if (notified[fsect.sct_own])
665 trange = mapdist(newx, newy, fsect.sct_x, fsect.sct_y);
666 if (notify_coastguard(list, trange, &fsect))
667 notified[fsect.sct_own] = 1;
669 if (opt_NO_FORT_FIRE)
670 return 0; /* Only coastwatch notify in nofortfire */
671 /* Only fire at Hostile ships */
672 for (i = 0; i < MAXNOC; ++i) {
673 if (relations_with(i, victim) >= NEUTRAL)
676 snxtsct_dist(&ns, newx, newy, fort_max_interdiction_range);
677 while (nxtsct(&ns, &fsect)) {
678 if (!notified[fsect.sct_own])
680 range = roundrange(fortrange(&fsect));
681 trange = mapdist(newx, newy, fsect.sct_x, fsect.sct_y);
684 dam = fort_fire(&fsect);
690 mpr(victim, "Incoming fire does %d damage!\n", dam);
692 mpr(victim, "%s fires at you for %d!\n",
693 xyas(fsect.sct_x, fsect.sct_y, victim), dam);
696 "%s fires at %s ships in %s for %d!\n",
697 xyas(fsect.sct_x, fsect.sct_y,
699 cname(victim), xyas(newx, newy, fsect.sct_own), dam);
700 nreport(fsect.sct_own, N_SHP_SHELL, victim, 1);
703 shp_damage(list, totdam, 0, M_SUB, newx, newy);
708 shp_mission_interdiction(struct emp_qelem *list, coord x, coord y,
709 natid victim, int subs)
711 char *what = subs ? "subs" : "ships";
712 int wantflags = subs ? M_SUB : 0;
713 int nowantflags = subs ? 0 : M_SUB;
714 int mission = subs ? MI_SINTERDICT : MI_INTERDICT;
717 dam = unit_interdict(x, y, victim, what,
718 shp_easiest_target(list, wantflags, nowantflags),
721 shp_damage(list, dam, wantflags, nowantflags, x, y);
726 shp_interdict(struct emp_qelem *list, coord newx, coord newy, natid victim)
730 if (shp_contains(list, newx, newy, 0, M_SUB)) {
731 stopping |= shp_fort_interdiction(list, newx, newy, victim);
733 if (shp_contains(list, newx, newy, 0, M_SUB)) {
734 stopping |= shp_mission_interdiction(list, newx, newy, victim, 0);
735 stopping |= shp_missile_interdiction(list, newx, newy, victim);
738 if (shp_contains(list, newx, newy, M_SUB, 0))
739 stopping |= shp_mission_interdiction(list, newx, newy, victim, 1);
743 /* high value of hardtarget is harder to hit */
745 shp_hardtarget(struct shpstr *sp)
749 struct mchrstr *mcp = mchr + sp->shp_type;
752 getsect(sp->shp_x, sp->shp_y, §);
753 onsea = sect.sct_type == SCT_WATER;
754 if (mcp->m_flags & M_SUB)
756 return (int)((sp->shp_effic / 100.0) *
757 (20 + shp_speed(sp) * onsea / 2.0 - vis));
761 shp_hit_mine(struct shpstr *sp)
765 mpr(sp->shp_own, "Kawhomp! Mine detected in %s!\n",
766 xyas(sp->shp_x, sp->shp_y, sp->shp_own));
768 nreport(sp->shp_own, N_HIT_MINE, 0, 1);
771 if (mchr[sp->shp_type].m_flags & M_SWEEP)
774 shipdamage(sp, ldround(m, 1));
780 shp_nav_one_sector(struct emp_qelem *list, int dir, natid actor)
783 struct emp_qelem *qp;
784 struct emp_qelem *next;
791 enum shp_stuck stuck;
796 if (CANT_HAPPEN(QEMPTY(list)))
799 if (dir <= DIR_STOP || dir >= DIR_VIEW) {
800 shp_nav_put(list, actor);
806 mlp = (struct ulist *)list->q_back;
807 newx = xnorm(mlp->unit.ship.shp_x + dx);
808 newy = ynorm(mlp->unit.ship.shp_y + dy);
809 getsect(newx, newy, §);
811 if (sect.sct_own && relations_with(sect.sct_own, actor) < FRIENDLY) {
812 mpr(actor, "can't go to %s\n", xyas(newx, newy, actor));
817 for (qp = list->q_back; qp != list; qp = next) {
819 mlp = (struct ulist *)qp;
820 switch (shp_check_nav(&mlp->unit.ship, §)) {
824 case SHP_STUCK_CANAL:
829 case SHP_STUCK_CONSTRUCTION:
830 case SHP_STUCK_IMPASSABLE:
831 mpr(actor, "can't go to %s\n", xyas(newx, newy, actor));
836 mpr(actor, "is too large to fit into the canal system at %s\n",
837 xyas(newx, newy, actor));
841 for (qp = list->q_back; qp != list; qp = next) {
843 mlp = (struct ulist *)qp;
844 stuck = shp_check_nav(&mlp->unit.ship, §);
845 if (stuck == SHP_STUCK_CANAL) {
847 "is too large to fit into the canal system at %s",
848 xyas(newx, newy, actor));
849 shp_stays(actor, dp, mlp);
851 } else if (CANT_HAPPEN(stuck != SHP_STUCK_NOT)) {
852 sprintf(dp, "can't go to %s", xyas(newx, newy, actor));
853 shp_stays(actor, dp, mlp);
857 if (mlp->mobil <= 0.0) {
858 shp_stays(actor, "is out of mobility", mlp);
861 mobcost = shp_mobcost(&mlp->unit.ship);
862 mlp->unit.ship.shp_x = newx;
863 mlp->unit.ship.shp_y = newy;
864 if (mlp->mobil - mobcost < -127) {
867 mlp->mobil -= mobcost;
869 mlp->unit.ship.shp_mobil = (int)mlp->mobil;
870 putship(mlp->unit.ship.shp_uid, &mlp->unit.ship);
872 /* Now update the map for this ship */
873 rad_map_set(mlp->unit.ship.shp_own,
874 mlp->unit.ship.shp_x, mlp->unit.ship.shp_y,
875 mlp->unit.ship.shp_effic, mlp->unit.ship.shp_tech,
876 mchr[mlp->unit.ship.shp_type].m_vrnge);
880 stopping |= shp_sweep(list, 0, 0, actor);
883 stopping |= shp_check_mines(list);
886 stopping |= shp_interdict(list, newx, newy, actor);
893 * Check for incoming missiles with a P_MAR flag.
894 * Return True=1 if the missile was shotdown.
897 * Chad Zabel, July 95
901 shp_missile_defense(coord dx, coord dy, natid bombown, int hardtarget)
906 double gun, eff, teff;
908 snxtitem_dist(&ni, EF_SHIP, dx, dy, 1);
910 while (nxtitem(&ni, &ship)) {
914 if (!(mchr[(int)ship.shp_type].m_flags & M_ANTIMISSILE))
917 if (relations_with(ship.shp_own, bombown) >= NEUTRAL)
920 if (ship.shp_effic < 60)
923 if (ship.shp_item[I_MILIT] < 1) /* do we have mil? */
925 if (ship.shp_item[I_GUN] < 1) /* we need at least 1 gun */
927 if (!shp_supply(&ship, I_SHELL, 2))
929 ship.shp_item[I_SHELL] -= 2;
930 putship(ship.shp_uid, &ship);
932 /* now calculate the odds */
933 gun = shp_usable_guns(&ship);
934 eff = ship.shp_effic / 100.0;
935 teff = ship.shp_tech / (ship.shp_tech + 200.0);
936 /* raise 4.5 for better interception -KHS */
937 hitchance = (int)(gun * eff * teff * 4.5) - hardtarget;
938 hitchance = LIMIT_TO(hitchance, 0, 100);
939 hit = pct_chance(hitchance);
941 mpr(bombown, "%s anti-missile system activated...%s\n",
943 hit ? "KABOOOM!! Missile destroyed\n"
944 : "SWOOSH!! anti-missile system failed!!");
945 mpr(ship.shp_own, "Ship #%i anti-missile system activated!\n",
947 mpr(ship.shp_own, "%d%% hitchance...%s\n", hitchance,
948 hit ? "KABOOOM!! Incoming missile destroyed!\n"
949 : "SWOOSH!! Missile evades anti-missile systems\n");
954 return 0; /* all attempts failed */
958 /* Fire missiles at a ship which has fired shells */
960 shp_missdef(struct shpstr *sp, natid victim)
962 struct emp_qelem list;
968 mlp = shp_insque(sp, &list);
969 sprintf(buf, "%s", prship(&mlp->unit.ship));
972 shp_missile_interdiction(&list, sp->shp_x, sp->shp_y, sp->shp_own);
973 getship(sp->shp_uid, sp);
977 "missiles launched in defense did 100%% damage to %s\n",
979 wu(0, victim, "%s sunk!\n", buf);
980 } else if (eff > 0 && sp->shp_effic < eff) {
982 "missiles launched in defense did %d%% damage to %s\n",
983 100 * (eff - sp->shp_effic) / eff, buf);
990 shp_mobcost(struct shpstr *sp)
992 return speed_factor(sp->shp_effic * 0.01 * shp_speed(sp),
997 * Set SP's tech to TLEV along with everything else that depends on it.
1000 shp_set_tech(struct shpstr *sp, int tlev)
1002 struct mchrstr *mcp = mchr + sp->shp_type;
1004 if (CANT_HAPPEN(tlev < mcp->m_tech))
1007 sp->shp_tech = tlev;