2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2008, 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 files README, COPYING and CREDITS in the root of the source
23 * tree for related information and legal notices. It is expected
24 * that future projects/authors will amend these files as needed.
28 * buil.c: Build ships, nukes, bridges, planes, land units, bridge towers
30 * Known contributors to this file:
31 * Steve McClure, 1998-2000
32 * Markus Armbruster, 2004-2006
51 static int build_nuke(struct sctstr *sp,
52 struct nchrstr *np, short *vec, int tlev);
53 static int build_ship(struct sctstr *sp,
54 struct mchrstr *mp, short *vec, int tlev);
55 static int build_land(struct sctstr *sp,
56 struct lchrstr *lp, short *vec, int tlev);
57 static int build_bridge(struct sctstr *sp, short *vec);
58 static int build_tower(struct sctstr *sp, short *vec);
59 static int build_plane(struct sctstr *sp,
60 struct plchrstr *pp, short *vec, int tlev);
61 static int build_can_afford(double, char *);
64 * build <WHAT> <SECTS> <TYPE|DIR|MEG> [NUMBER]
70 struct nstr_sect nstr;
87 natp = getnatp(player->cnum);
89 getstarg(player->argp[1],
90 "Build (ship, nuke, bridge, plane, land unit, tower)? ",
95 if (!snxtsct(&nstr, player->argp[2])) {
96 pr("Bad sector specification.\n");
99 tlev = (int)natp->nat_level[NAT_TLEV];
100 rlev = (int)natp->nat_level[NAT_RLEV];
104 p = getstarg(player->argp[3], "Plane type? ", buf);
105 if (p == 0 || *p == 0)
107 type = ef_elt_byname(EF_PLANE_CHR, p);
110 rqtech = pp->pl_tech;
115 pr("You can't build that!\n");
116 pr("Use `show plane build %d' to show types you can build.\n",
122 p = getstarg(player->argp[3], "Ship type? ", buf);
123 if (p == 0 || *p == 0)
125 type = ef_elt_byname(EF_SHIP_CHR, p);
131 if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
135 pr("You can't build that!\n");
136 pr("Use `show ship build %d' to show types you can build.\n",
142 p = getstarg(player->argp[3], "Land unit type? ", buf);
143 if (p == 0 || *p == 0)
145 type = ef_elt_byname(EF_LAND_CHR, p);
151 if ((lp->l_flags & L_SPY) && !opt_LANDSPIES)
155 pr("You can't build that!\n");
156 pr("Use `show land build %d' to show types you can build.\n",
162 if (natp->nat_level[NAT_TLEV] + 0.005 < buil_bt) {
163 pr("Building a span requires a tech of %.0f\n", buil_bt);
168 if (!opt_BRIDGETOWERS) {
169 pr("Bridge tower building is disabled.\n");
172 if (natp->nat_level[NAT_TLEV] + 0.005 < buil_tower_bt) {
173 pr("Building a tower requires a tech of %.0f\n",
179 if (!ef_nelem(EF_NUKE_CHR)) {
180 pr("There are no nukes in this game.\n");
183 p = getstarg(player->argp[3], "Nuke type? ", buf);
184 if (p == 0 || *p == 0)
186 type = ef_elt_byname(EF_NUKE_CHR, p);
191 || (drnuke_const > MIN_DRNUKE_CONST &&
192 np->n_tech * drnuke_const > rlev))
197 if (drnuke_const > MIN_DRNUKE_CONST)
198 tt = (tlev < (rlev / drnuke_const) ? (int)tlev :
199 (int)(rlev / drnuke_const));
200 pr("You can't build that!\n");
201 pr("Use `show nuke build %d' to show types you can build.\n",
207 pr("You can't build that!\n");
212 if (what != 'b' && what != 't') {
213 if (player->argp[4]) {
214 number = atoi(player->argp[4]);
218 "Are you sure that you want to build %s of them? ",
220 p = getstarg(player->argp[6], bstr, buf);
221 if (p == 0 || *p != 'y')
227 if (what != 'b' && what != 'n' && what != 't') {
228 if (player->argp[5]) {
229 tlev = atoi(player->argp[5]);
230 if (tlev > natp->nat_level[NAT_TLEV] && !player->god) {
231 pr("Your tech level is only %d.\n",
232 (int)natp->nat_level[NAT_TLEV]);
236 pr("Required tech is %d.\n", rqtech);
239 pr("building with tech level %d.\n", tlev);
243 while (number-- > 0) {
244 while (nxtsct(&nstr, §)) {
250 built = build_land(§, lp, sect.sct_item, tlev);
253 built = build_ship(§, mp, sect.sct_item, tlev);
256 built = build_bridge(§, sect.sct_item);
259 built = build_tower(§, sect.sct_item);
262 built = build_nuke(§, np, sect.sct_item, tlev);
265 built = build_plane(§, pp, sect.sct_item, tlev);
275 snxtsct_rewind(&nstr);
278 pr("Bad sector specification.\n");
284 build_ship(struct sctstr *sp, struct mchrstr *mp, short *vec, int tlev)
287 struct nstr_item nstr;
290 double eff = SHIP_MINEFF / 100.0;
294 hcm = roundavg(mp->m_hcm * eff);
295 lcm = roundavg(mp->m_lcm * eff);
297 if (sp->sct_type != SCT_HARBR) {
298 pr("Ships must be built in harbours.\n");
301 if (sp->sct_effic < 60 && !player->god) {
302 pr("Sector %s is not 60%% efficient.\n",
303 xyas(sp->sct_x, sp->sct_y, player->cnum));
306 if (vec[I_LCM] < lcm || vec[I_HCM] < hcm) {
307 pr("Not enough materials in %s\n",
308 xyas(sp->sct_x, sp->sct_y, player->cnum));
311 avail = (SHP_BLD_WORK(mp->m_lcm, mp->m_hcm) * SHIP_MINEFF + 99) / 100;
312 if (sp->sct_avail < avail) {
313 pr("Not enough available work in %s to build a %s\n",
314 xyas(sp->sct_x, sp->sct_y, player->cnum), mp->m_name);
315 pr(" (%d available work required)\n", avail);
318 cost = mp->m_cost * SHIP_MINEFF / 100.0;
319 if (!build_can_afford(cost, mp->m_name))
321 if (!trechk(player->cnum, 0, NEWSHP))
323 if (!check_sect_ok(sp))
325 sp->sct_avail -= avail;
326 player->dolcost += cost;
327 snxtitem_all(&nstr, EF_SHIP);
328 while (nxtitem(&nstr, &ship)) {
329 if (ship.shp_own == 0) {
335 ef_extend(EF_SHIP, 50);
337 memset(&ship, 0, sizeof(struct shpstr));
338 ship.shp_x = sp->sct_x;
339 ship.shp_y = sp->sct_y;
340 ship.shp_destx[0] = sp->sct_x;
341 ship.shp_desty[0] = sp->sct_y;
342 ship.shp_destx[1] = sp->sct_x;
343 ship.shp_desty[1] = sp->sct_y;
344 ship.shp_autonav = 0;
345 /* new code for autonav, Chad Zabel 1-15-94 */
346 for (i = 0; i < TMAX; ++i) {
347 ship.shp_tstart[i] = I_NONE;
348 ship.shp_tend[i] = I_NONE;
349 ship.shp_lstart[i] = 0;
350 ship.shp_lend[i] = 0;
352 ship.shp_mission = 0;
353 ship.shp_own = player->cnum;
354 ship.shp_type = mp - mchr;
355 ship.shp_effic = SHIP_MINEFF;
356 if (opt_MOB_ACCESS) {
357 game_tick_to_now(&ship.shp_access);
358 ship.shp_mobil = -(etu_per_update / sect_mob_neg_factor);
362 ship.shp_uid = nstr.cur;
365 ship.shp_nxlight = 0;
366 ship.shp_nchoppers = 0;
368 memset(ship.shp_item, 0, sizeof(ship.shp_item));
369 ship.shp_pstage = PLG_HEALTHY;
371 ship.shp_mobquota = 0;
373 ship.shp_follow = nstr.cur;
374 ship.shp_name[0] = 0;
375 ship.shp_orig_own = player->cnum;
376 ship.shp_orig_x = sp->sct_x;
377 ship.shp_orig_y = sp->sct_y;
378 ship.shp_fuel = mchr[(int)ship.shp_type].m_fuelc;
380 memset(ship.shp_rpath, 0, sizeof(ship.shp_rpath));
381 shp_set_tech(&ship, tlev);
386 if (sp->sct_pstage == PLG_INFECT)
387 ship.shp_pstage = PLG_EXPOSED;
388 makenotlost(EF_SHIP, ship.shp_own, ship.shp_uid,
389 ship.shp_x, ship.shp_y);
390 putship(ship.shp_uid, &ship);
391 pr("%s", prship(&ship));
392 pr(" built in sector %s\n", xyas(sp->sct_x, sp->sct_y, player->cnum));
397 build_land(struct sctstr *sp, struct lchrstr *lp, short *vec, int tlev)
400 struct nstr_item nstr;
403 double eff = LAND_MINEFF / 100.0;
404 int mil, lcm, hcm, gun, shell;
408 mil = roundavg(lp->l_mil * eff);
409 shell = roundavg(lp->l_shell * eff);
410 gun = roundavg(lp->l_gun * eff);
412 mil = shell = gun = 0;
414 hcm = roundavg(lp->l_hcm * eff);
415 lcm = roundavg(lp->l_lcm * eff);
417 if (sp->sct_type != SCT_HEADQ) {
418 pr("Land Units must be built in headquarters.\n");
421 if (sp->sct_effic < 60 && !player->god) {
422 pr("Sector %s is not 60%% efficient.\n",
423 xyas(sp->sct_x, sp->sct_y, player->cnum));
426 if (vec[I_LCM] < lcm || vec[I_HCM] < hcm) {
427 pr("Not enough materials in %s\n",
428 xyas(sp->sct_x, sp->sct_y, player->cnum));
432 if (vec[I_GUN] < gun || vec[I_GUN] == 0) {
433 pr("Not enough guns in %s\n",
434 xyas(sp->sct_x, sp->sct_y, player->cnum));
437 if (vec[I_SHELL] < shell) {
438 pr("Not enough shells in %s\n",
439 xyas(sp->sct_x, sp->sct_y, player->cnum));
442 if (vec[I_MILIT] < mil) {
443 pr("Not enough military in %s\n",
444 xyas(sp->sct_x, sp->sct_y, player->cnum));
448 if (!trechk(player->cnum, 0, NEWLND))
450 if (!check_sect_ok(sp))
452 avail = (LND_BLD_WORK(lp->l_lcm, lp->l_hcm) * LAND_MINEFF + 99) / 100;
453 if (sp->sct_avail < avail) {
454 pr("Not enough available work in %s to build a %s\n",
455 xyas(sp->sct_x, sp->sct_y, player->cnum), lp->l_name);
456 pr(" (%d available work required)\n", avail);
459 cost = lp->l_cost * LAND_MINEFF / 100.0;
460 if (!build_can_afford(cost, lp->l_name))
462 sp->sct_avail -= avail;
463 player->dolcost += cost;
464 snxtitem_all(&nstr, EF_LAND);
465 while (nxtitem(&nstr, &land)) {
466 if (land.lnd_own == 0) {
472 ef_extend(EF_LAND, 50);
474 memset(&land, 0, sizeof(struct lndstr));
475 land.lnd_x = sp->sct_x;
476 land.lnd_y = sp->sct_y;
477 land.lnd_own = player->cnum;
478 land.lnd_mission = 0;
479 land.lnd_type = lp - lchr;
480 land.lnd_effic = LAND_MINEFF;
481 if (opt_MOB_ACCESS) {
482 game_tick_to_now(&land.lnd_access);
483 land.lnd_mobil = -(etu_per_update / sect_mob_neg_factor);
487 land.lnd_uid = nstr.cur;
494 land.lnd_retreat = morale_base;
495 land.lnd_fuel = lp->l_fuelc;
496 land.lnd_nxlight = 0;
498 memset(land.lnd_rpath, 0, sizeof(land.lnd_rpath));
499 land.lnd_rad_max = 0;
500 memset(land.lnd_item, 0, sizeof(land.lnd_item));
501 land.lnd_pstage = PLG_HEALTHY;
503 lnd_set_tech(&land, tlev);
509 vec[I_SHELL] -= shell;
511 if (sp->sct_pstage == PLG_INFECT)
512 land.lnd_pstage = PLG_EXPOSED;
513 putland(nstr.cur, &land);
514 makenotlost(EF_LAND, land.lnd_own, land.lnd_uid,
515 land.lnd_x, land.lnd_y);
516 pr("%s", prland(&land));
517 pr(" built in sector %s\n", xyas(sp->sct_x, sp->sct_y, player->cnum));
522 build_bridge(struct sctstr *sp, short *vec)
528 int nx, ny, i, good = 0;
532 if (opt_EASY_BRIDGES == 0) { /* must have a bridge head or tower */
533 if (sp->sct_type != SCT_BTOWER) {
534 if (sp->sct_type != SCT_BHEAD)
536 if (sp->sct_newtype != SCT_BHEAD)
541 if (sp->sct_effic < 60 && !player->god) {
542 pr("Sector %s is not 60%% efficient.\n",
543 xyas(sp->sct_x, sp->sct_y, player->cnum));
547 if (vec[I_HCM] < buil_bh) {
548 pr("%s only has %d unit%s of hcm,\n",
549 xyas(sp->sct_x, sp->sct_y, player->cnum),
550 vec[I_HCM], vec[I_HCM] > 1 ? "s" : "");
551 pr("(a bridge span requires %d)\n", buil_bh);
555 if (!build_can_afford(buil_bc, dchr[SCT_BSPAN].d_name))
557 avail = (SCT_BLD_WORK(0, buil_bh) * SCT_MINEFF + 99) / 100;
558 if (sp->sct_avail < avail) {
559 pr("Not enough available work in %s to build a bridge\n",
560 xyas(sp->sct_x, sp->sct_y, player->cnum));
561 pr(" (%d available work required)\n", avail);
564 if (!player->argp[3]) {
565 pr("Bridge head at %s\n",
566 xyas(sp->sct_x, sp->sct_y, player->cnum));
567 nav_map(sp->sct_x, sp->sct_y, 1);
569 p = getstarg(player->argp[3], "build span in what direction? ", buf);
573 /* Sanity check time */
574 if (!check_sect_ok(sp))
577 if ((val = chkdir(*p, DIR_FIRST, DIR_LAST)) < 0) {
578 pr("'%c' is not a valid direction...\n", *p);
582 newx = sp->sct_x + diroff[val][0];
583 newy = sp->sct_y + diroff[val][1];
584 if (getsect(newx, newy, §) == 0 || sect.sct_type != SCT_WATER) {
585 pr("%s is not a water sector\n", xyas(newx, newy, player->cnum));
588 if (opt_EASY_BRIDGES) {
591 for (i = 1; i <= 6; i++) {
593 nx = sect.sct_x + diroff[i][0];
594 ny = sect.sct_y + diroff[i][1];
595 getsect(nx, ny, &s2);
596 if ((s2.sct_type != SCT_WATER) && (s2.sct_type != SCT_BSPAN))
600 pr("Bridges must be built adjacent to land or bridge towers.\n");
601 pr("That sector is not adjacent to land or a bridge tower.\n");
604 } /* end EASY_BRIDGES */
605 sp->sct_avail -= avail;
606 player->dolcost += buil_bc;
607 sect.sct_type = SCT_BSPAN;
608 sect.sct_newtype = SCT_BSPAN;
609 sect.sct_effic = SCT_MINEFF;
612 sect.sct_defense = 0;
613 if (opt_MOB_ACCESS) {
614 game_tick_to_now(§.sct_access);
615 sect.sct_mobil = -(etu_per_update / sect_mob_neg_factor);
620 map_set(player->cnum, sect.sct_x, sect.sct_y, dchr[SCT_BSPAN].d_mnem, 2);
621 writemap(player->cnum);
623 pr("Bridge span built over %s\n",
624 xyas(sect.sct_x, sect.sct_y, player->cnum));
625 vec[I_HCM] -= buil_bh;
630 build_nuke(struct sctstr *sp, struct nchrstr *np, short *vec, int tlev)
633 struct nstr_item nstr;
637 if (sp->sct_type != SCT_NUKE && !player->god) {
638 pr("Nuclear weapons must be built in nuclear plants.\n");
641 if (sp->sct_effic < 60 && !player->god) {
642 pr("Sector %s is not 60%% efficient.\n",
643 xyas(sp->sct_x, sp->sct_y, player->cnum));
646 if (vec[I_HCM] < np->n_hcm || vec[I_LCM] < np->n_lcm ||
647 vec[I_OIL] < np->n_oil || vec[I_RAD] < np->n_rad) {
648 pr("Not enough materials for a %s bomb in %s\n",
649 np->n_name, xyas(sp->sct_x, sp->sct_y, player->cnum));
650 pr("(%d hcm, %d lcm, %d oil, & %d rads).\n",
651 np->n_hcm, np->n_lcm, np->n_oil, np->n_rad);
654 if (!build_can_afford(np->n_cost, np->n_name))
656 avail = NUK_BLD_WORK(np->n_lcm, np->n_hcm, np->n_oil, np->n_rad);
658 * XXX when nukes turn into units (or whatever), then
659 * make them start at 20%. Since they don't have efficiency
660 * now, we charge all the work right away.
662 if (sp->sct_avail < avail) {
663 pr("Not enough available work in %s to build a %s;\n",
664 xyas(sp->sct_x, sp->sct_y, player->cnum), np->n_name);
665 pr(" (%d available work required)\n", avail);
668 if (!trechk(player->cnum, 0, NEWNUK))
670 if (!check_sect_ok(sp))
672 sp->sct_avail -= avail;
673 player->dolcost += np->n_cost;
674 snxtitem_all(&nstr, EF_NUKE);
676 while (nxtitem(&nstr, &nuke)) {
677 if (nuke.nuk_own == 0) {
683 ef_extend(EF_NUKE, 50);
685 memset(&nuke, 0, sizeof(struct nukstr));
686 nuke.nuk_x = sp->sct_x;
687 nuke.nuk_y = sp->sct_y;
688 nuke.nuk_own = sp->sct_own;
689 nuke.nuk_type = np - nchr;
690 nuke.nuk_effic = 100;
691 nuke.nuk_stockpile = 0;
692 nuke.nuk_ship = nuke.nuk_plane = nuke.nuk_land = -1;
693 nuke.nuk_uid = nstr.cur;
694 nuke.nuk_tech = tlev;
696 vec[I_HCM] -= np->n_hcm;
697 vec[I_LCM] -= np->n_lcm;
698 vec[I_OIL] -= np->n_oil;
699 vec[I_RAD] -= np->n_rad;
701 makenotlost(EF_NUKE, nuke.nuk_own, nuke.nuk_uid,
702 nuke.nuk_x, nuke.nuk_y);
703 putnuke(nuke.nuk_uid, &nuke);
704 pr("%s created in %s\n", prnuke(&nuke),
705 xyas(sp->sct_x, sp->sct_y, player->cnum));
710 build_plane(struct sctstr *sp, struct plchrstr *pp, short *vec, int tlev)
713 struct nstr_item nstr;
716 double eff = PLANE_MINEFF / 100.0;
720 mil = roundavg(pp->pl_crew * eff);
721 /* Always use at least 1 mil to build a plane */
722 if (mil == 0 && pp->pl_crew > 0)
724 hcm = roundavg(pp->pl_hcm * eff);
725 lcm = roundavg(pp->pl_lcm * eff);
726 if (sp->sct_type != SCT_AIRPT && !player->god) {
727 pr("Planes must be built in airports.\n");
730 if (sp->sct_effic < 60 && !player->god) {
731 pr("Sector %s is not 60%% efficient.\n",
732 xyas(sp->sct_x, sp->sct_y, player->cnum));
735 if (vec[I_LCM] < lcm || vec[I_HCM] < hcm) {
736 pr("Not enough materials in %s\n",
737 xyas(sp->sct_x, sp->sct_y, player->cnum));
740 avail = (PLN_BLD_WORK(pp->pl_lcm, pp->pl_hcm) * PLANE_MINEFF + 99) / 100;
741 if (sp->sct_avail < avail) {
742 pr("Not enough available work in %s to build a %s\n",
743 xyas(sp->sct_x, sp->sct_y, player->cnum), pp->pl_name);
744 pr(" (%d available work required)\n", avail);
747 cost = pp->pl_cost * PLANE_MINEFF / 100.0;
748 if (!build_can_afford(cost, pp->pl_name))
750 if (vec[I_MILIT] < mil || (vec[I_MILIT] == 0 && pp->pl_crew > 0)) {
751 pr("Not enough military for crew in %s\n",
752 xyas(sp->sct_x, sp->sct_y, player->cnum));
755 if (!trechk(player->cnum, 0, NEWPLN))
757 if (!check_sect_ok(sp))
759 sp->sct_avail -= avail;
760 player->dolcost += cost;
761 snxtitem_all(&nstr, EF_PLANE);
763 while (nxtitem(&nstr, &plane)) {
764 if (plane.pln_own == 0) {
769 if (freeplane == 0) {
770 ef_extend(EF_PLANE, 50);
772 memset(&plane, 0, sizeof(struct plnstr));
773 plane.pln_x = sp->sct_x;
774 plane.pln_y = sp->sct_y;
775 plane.pln_own = sp->sct_own;
776 plane.pln_type = pp - plchr;
777 plane.pln_effic = PLANE_MINEFF;
778 if (opt_MOB_ACCESS) {
779 game_tick_to_now(&plane.pln_access);
780 plane.pln_mobil = -(etu_per_update / sect_mob_neg_factor);
784 plane.pln_mission = 0;
787 plane.pln_radius = 0;
788 plane.pln_range = UCHAR_MAX; /* will be adjusted by pln_set_tech() */
789 plane.pln_range_max = plane.pln_range;
793 plane.pln_uid = nstr.cur;
794 plane.pln_nuketype = -1;
795 plane.pln_harden = 0;
797 pln_set_tech(&plane, tlev);
803 makenotlost(EF_PLANE, plane.pln_own, plane.pln_uid,
804 plane.pln_x, plane.pln_y);
805 putplane(plane.pln_uid, &plane);
806 pr("%s built in sector %s\n", prplane(&plane),
807 xyas(sp->sct_x, sp->sct_y, player->cnum));
812 build_tower(struct sctstr *sp, short *vec)
825 if (sp->sct_type != SCT_BSPAN) {
826 pr("Bridge towers can only be built from bridge spans.\n");
830 if (sp->sct_effic < 60 && !player->god) {
831 pr("Sector %s is not 60%% efficient.\n",
832 xyas(sp->sct_x, sp->sct_y, player->cnum));
836 if (vec[I_HCM] < buil_tower_bh) {
837 pr("%s only has %d unit%s of hcm,\n",
838 xyas(sp->sct_x, sp->sct_y, player->cnum),
839 vec[I_HCM], vec[I_HCM] > 1 ? "s" : "");
840 pr("(a bridge tower requires %d)\n", buil_tower_bh);
844 if (!build_can_afford(buil_tower_bc, dchr[SCT_BTOWER].d_name))
846 avail = (SCT_BLD_WORK(0, buil_tower_bh) * SCT_MINEFF + 99) / 100;
847 if (sp->sct_avail < avail) {
848 pr("Not enough available work in %s to build a bridge tower\n",
849 xyas(sp->sct_x, sp->sct_y, player->cnum));
850 pr(" (%d available work required)\n", avail);
853 if (!player->argp[3]) {
854 pr("Building from %s\n", xyas(sp->sct_x, sp->sct_y, player->cnum));
855 nav_map(sp->sct_x, sp->sct_y, 1);
857 p = getstarg(player->argp[3], "build tower in what direction? ", buf);
861 /* Sanity check time */
862 if (!check_sect_ok(sp))
865 if ((val = chkdir(*p, DIR_FIRST, DIR_LAST)) < 0) {
866 pr("'%c' is not a valid direction...\n", *p);
870 newx = sp->sct_x + diroff[val][0];
871 newy = sp->sct_y + diroff[val][1];
872 if (getsect(newx, newy, §) == 0 || sect.sct_type != SCT_WATER) {
873 pr("%s is not a water sector\n", xyas(newx, newy, player->cnum));
877 /* Now, check. You aren't allowed to build bridge towers
880 for (i = 1; i <= 6; i++) {
882 nx = sect.sct_x + diroff[i][0];
883 ny = sect.sct_y + diroff[i][1];
884 getsect(nx, ny, &s2);
885 if ((s2.sct_type != SCT_WATER) &&
886 (s2.sct_type != SCT_BTOWER) && (s2.sct_type != SCT_BSPAN)) {
892 pr("Bridge towers cannot be built adjacent to land.\n");
893 pr("That sector is adjacent to land.\n");
897 sp->sct_avail -= avail;
898 player->dolcost += buil_tower_bc;
899 sect.sct_type = SCT_BTOWER;
900 sect.sct_newtype = SCT_BTOWER;
901 sect.sct_effic = SCT_MINEFF;
904 sect.sct_defense = 0;
905 if (opt_MOB_ACCESS) {
906 game_tick_to_now(§.sct_access);
907 sect.sct_mobil = -(etu_per_update / sect_mob_neg_factor);
912 map_set(player->cnum, sect.sct_x, sect.sct_y, dchr[SCT_BTOWER].d_mnem, 2);
913 writemap(player->cnum);
915 pr("Bridge tower built in %s\n",
916 xyas(sect.sct_x, sect.sct_y, player->cnum));
917 vec[I_HCM] -= buil_tower_bh;
922 build_can_afford(double cost, char *what)
924 struct natstr *natp = getnatp(player->cnum);
925 if (natp->nat_money < player->dolcost + cost) {
926 pr("Not enough money left to build a %s\n", what);