2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2007, 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
50 static int build_nuke(struct sctstr *sp,
51 struct nchrstr *np, short *vec, int tlev);
52 static int build_ship(struct sctstr *sp,
53 struct mchrstr *mp, short *vec, int tlev);
54 static int build_land(struct sctstr *sp,
55 struct lchrstr *lp, short *vec, int tlev);
56 static int build_bridge(struct sctstr *sp, short *vec);
57 static int build_tower(struct sctstr *sp, short *vec);
58 static int build_plane(struct sctstr *sp,
59 struct plchrstr *pp, short *vec, int tlev);
60 static int build_can_afford(double, char *);
63 * build <WHAT> <SECTS> <TYPE|DIR|MEG> [NUMBER]
69 struct nstr_sect nstr;
86 natp = getnatp(player->cnum);
88 getstarg(player->argp[1],
89 "Build (ship, nuke, bridge, plane, land unit, tower)? ",
94 if (!snxtsct(&nstr, player->argp[2])) {
95 pr("Bad sector specification.\n");
98 tlev = (int)natp->nat_level[NAT_TLEV];
99 rlev = (int)natp->nat_level[NAT_RLEV];
103 p = getstarg(player->argp[3], "Plane type? ", buf);
104 if (p == 0 || *p == 0)
106 type = ef_elt_byname(EF_PLANE_CHR, p);
109 rqtech = pp->pl_tech;
114 pr("You can't build that!\n");
115 pr("Use `show plane build %d' to show types you can build.\n",
121 p = getstarg(player->argp[3], "Ship type? ", buf);
122 if (p == 0 || *p == 0)
124 type = ef_elt_byname(EF_SHIP_CHR, p);
130 if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
134 pr("You can't build that!\n");
135 pr("Use `show ship build %d' to show types you can build.\n",
141 p = getstarg(player->argp[3], "Land unit type? ", buf);
142 if (p == 0 || *p == 0)
144 type = ef_elt_byname(EF_LAND_CHR, p);
150 if ((lp->l_flags & L_SPY) && !opt_LANDSPIES)
154 pr("You can't build that!\n");
155 pr("Use `show land build %d' to show types you can build.\n",
161 if (natp->nat_level[NAT_TLEV] + 0.005 < buil_bt) {
162 pr("Building a span requires a tech of %.0f\n", buil_bt);
167 if (!opt_BRIDGETOWERS) {
168 pr("Bridge tower building is disabled.\n");
171 if (natp->nat_level[NAT_TLEV] + 0.005 < buil_tower_bt) {
172 pr("Building a tower requires a tech of %.0f\n",
178 if (!ef_nelem(EF_NUKE_CHR)) {
179 pr("There are no nukes in this game.\n");
182 p = getstarg(player->argp[3], "Nuke type? ", buf);
183 if (p == 0 || *p == 0)
185 type = ef_elt_byname(EF_NUKE_CHR, p);
190 || (drnuke_const > MIN_DRNUKE_CONST &&
191 np->n_tech * drnuke_const > rlev))
196 if (drnuke_const > MIN_DRNUKE_CONST)
197 tt = (tlev < (rlev / drnuke_const) ? (int)tlev :
198 (int)(rlev / drnuke_const));
199 pr("You can't build that!\n");
200 pr("Use `show nuke build %d' to show types you can build.\n",
206 pr("You can't build that!\n");
211 if (what != 'b' && what != 't') {
212 if (player->argp[4]) {
213 number = atoi(player->argp[4]);
217 "Are you sure that you want to build %s of them? ",
219 p = getstarg(player->argp[6], bstr, buf);
220 if (p == 0 || *p != 'y')
226 if (what != 'b' && what != 'n' && what != 't') {
227 if (player->argp[5]) {
228 tlev = atoi(player->argp[5]);
229 if (tlev > natp->nat_level[NAT_TLEV] && !player->god) {
230 pr("Your tech level is only %d.\n",
231 (int)natp->nat_level[NAT_TLEV]);
235 pr("Required tech is %d.\n", rqtech);
238 pr("building with tech level %d.\n", tlev);
242 while (number-- > 0) {
243 while (nxtsct(&nstr, §)) {
249 built = build_land(§, lp, sect.sct_item, tlev);
252 built = build_ship(§, mp, sect.sct_item, tlev);
255 built = build_bridge(§, sect.sct_item);
258 built = build_tower(§, sect.sct_item);
261 built = build_nuke(§, np, sect.sct_item, tlev);
264 built = build_plane(§, pp, sect.sct_item, tlev);
274 snxtsct_rewind(&nstr);
277 pr("Bad sector specification.\n");
283 build_ship(struct sctstr *sp, struct mchrstr *mp, short *vec, int tlev)
286 struct nstr_item nstr;
289 double eff = SHIP_MINEFF / 100.0;
293 hcm = roundavg(mp->m_hcm * eff);
294 lcm = roundavg(mp->m_lcm * eff);
296 if (sp->sct_type != SCT_HARBR) {
297 pr("Ships must be built in harbours.\n");
300 if (sp->sct_effic < 60 && !player->god) {
301 pr("Sector %s is not 60%% efficient.\n",
302 xyas(sp->sct_x, sp->sct_y, player->cnum));
305 if (vec[I_LCM] < lcm || vec[I_HCM] < hcm) {
306 pr("Not enough materials in %s\n",
307 xyas(sp->sct_x, sp->sct_y, player->cnum));
310 avail = (SHP_BLD_WORK(mp->m_lcm, mp->m_hcm) * SHIP_MINEFF + 99) / 100;
311 if (sp->sct_avail < avail) {
312 pr("Not enough available work in %s to build a %s\n",
313 xyas(sp->sct_x, sp->sct_y, player->cnum), mp->m_name);
314 pr(" (%d available work required)\n", avail);
317 cost = mp->m_cost * SHIP_MINEFF / 100.0;
318 if (!build_can_afford(cost, mp->m_name))
320 if (!trechk(player->cnum, 0, NEWSHP))
322 if (!check_sect_ok(sp))
324 sp->sct_avail -= avail;
325 player->dolcost += cost;
326 snxtitem_all(&nstr, EF_SHIP);
327 while (nxtitem(&nstr, &ship)) {
328 if (ship.shp_own == 0) {
334 ef_extend(EF_SHIP, 50);
336 memset(&ship, 0, sizeof(struct shpstr));
337 ship.shp_x = sp->sct_x;
338 ship.shp_y = sp->sct_y;
339 ship.shp_destx[0] = sp->sct_x;
340 ship.shp_desty[0] = sp->sct_y;
341 ship.shp_destx[1] = sp->sct_x;
342 ship.shp_desty[1] = sp->sct_y;
343 ship.shp_autonav = 0;
344 /* new code for autonav, Chad Zabel 1-15-94 */
345 for (i = 0; i < TMAX; ++i) {
346 ship.shp_tstart[i] = I_NONE;
347 ship.shp_tend[i] = I_NONE;
348 ship.shp_lstart[i] = 0;
349 ship.shp_lend[i] = 0;
351 ship.shp_mission = 0;
352 ship.shp_own = player->cnum;
353 ship.shp_type = mp - mchr;
354 ship.shp_effic = SHIP_MINEFF;
355 if (opt_MOB_ACCESS) {
356 time(&ship.shp_access);
357 ship.shp_mobil = -(etu_per_update / sect_mob_neg_factor);
361 ship.shp_uid = nstr.cur;
364 ship.shp_nxlight = 0;
365 ship.shp_nchoppers = 0;
367 memset(ship.shp_item, 0, sizeof(ship.shp_item));
368 ship.shp_pstage = PLG_HEALTHY;
370 ship.shp_mobquota = 0;
372 ship.shp_follow = nstr.cur;
373 ship.shp_name[0] = 0;
374 ship.shp_orig_own = player->cnum;
375 ship.shp_orig_x = sp->sct_x;
376 ship.shp_orig_y = sp->sct_y;
377 ship.shp_fuel = mchr[(int)ship.shp_type].m_fuelc;
379 memset(ship.shp_rpath, 0, sizeof(ship.shp_rpath));
380 shp_set_tech(&ship, tlev);
385 if (sp->sct_pstage == PLG_INFECT)
386 ship.shp_pstage = PLG_EXPOSED;
387 makenotlost(EF_SHIP, ship.shp_own, ship.shp_uid,
388 ship.shp_x, ship.shp_y);
389 putship(ship.shp_uid, &ship);
390 pr("%s", prship(&ship));
391 pr(" built in sector %s\n", xyas(sp->sct_x, sp->sct_y, player->cnum));
396 build_land(struct sctstr *sp, struct lchrstr *lp, short *vec, int tlev)
399 struct nstr_item nstr;
402 double eff = LAND_MINEFF / 100.0;
403 int mil, lcm, hcm, gun, shell;
407 mil = roundavg(lp->l_mil * eff);
408 shell = roundavg(lp->l_shell * eff);
409 gun = roundavg(lp->l_gun * eff);
411 mil = shell = gun = 0;
413 hcm = roundavg(lp->l_hcm * eff);
414 lcm = roundavg(lp->l_lcm * eff);
416 if (sp->sct_type != SCT_HEADQ) {
417 pr("Land Units must be built in headquarters.\n");
420 if (sp->sct_effic < 60 && !player->god) {
421 pr("Sector %s is not 60%% efficient.\n",
422 xyas(sp->sct_x, sp->sct_y, player->cnum));
425 if (vec[I_LCM] < lcm || vec[I_HCM] < hcm) {
426 pr("Not enough materials in %s\n",
427 xyas(sp->sct_x, sp->sct_y, player->cnum));
431 if (vec[I_GUN] < gun || vec[I_GUN] == 0) {
432 pr("Not enough guns in %s\n",
433 xyas(sp->sct_x, sp->sct_y, player->cnum));
436 if (vec[I_SHELL] < shell) {
437 pr("Not enough shells in %s\n",
438 xyas(sp->sct_x, sp->sct_y, player->cnum));
441 if (vec[I_MILIT] < mil) {
442 pr("Not enough military in %s\n",
443 xyas(sp->sct_x, sp->sct_y, player->cnum));
447 if (!trechk(player->cnum, 0, NEWLND))
449 if (!check_sect_ok(sp))
451 avail = (LND_BLD_WORK(lp->l_lcm, lp->l_hcm) * LAND_MINEFF + 99) / 100;
452 if (sp->sct_avail < avail) {
453 pr("Not enough available work in %s to build a %s\n",
454 xyas(sp->sct_x, sp->sct_y, player->cnum), lp->l_name);
455 pr(" (%d available work required)\n", avail);
458 cost = lp->l_cost * LAND_MINEFF / 100.0;
459 if (!build_can_afford(cost, lp->l_name))
461 sp->sct_avail -= avail;
462 player->dolcost += cost;
463 snxtitem_all(&nstr, EF_LAND);
464 while (nxtitem(&nstr, &land)) {
465 if (land.lnd_own == 0) {
471 ef_extend(EF_LAND, 50);
473 memset(&land, 0, sizeof(struct lndstr));
474 land.lnd_x = sp->sct_x;
475 land.lnd_y = sp->sct_y;
476 land.lnd_own = player->cnum;
477 land.lnd_mission = 0;
478 land.lnd_type = lp - lchr;
479 land.lnd_effic = LAND_MINEFF;
480 if (opt_MOB_ACCESS) {
481 time(&land.lnd_access);
482 land.lnd_mobil = -(etu_per_update / sect_mob_neg_factor);
486 land.lnd_uid = nstr.cur;
493 land.lnd_retreat = morale_base;
494 land.lnd_fuel = lp->l_fuelc;
495 land.lnd_nxlight = 0;
497 memset(land.lnd_rpath, 0, sizeof(land.lnd_rpath));
498 land.lnd_rad_max = 0;
499 memset(land.lnd_item, 0, sizeof(land.lnd_item));
500 land.lnd_pstage = PLG_HEALTHY;
502 lnd_set_tech(&land, tlev);
508 vec[I_SHELL] -= shell;
510 if (sp->sct_pstage == PLG_INFECT)
511 land.lnd_pstage = PLG_EXPOSED;
512 putland(nstr.cur, &land);
513 makenotlost(EF_LAND, land.lnd_own, land.lnd_uid,
514 land.lnd_x, land.lnd_y);
515 pr("%s", prland(&land));
516 pr(" built in sector %s\n", xyas(sp->sct_x, sp->sct_y, player->cnum));
521 build_bridge(struct sctstr *sp, short *vec)
527 int nx, ny, i, good = 0;
531 if (opt_EASY_BRIDGES == 0) { /* must have a bridge head or tower */
532 if (sp->sct_type != SCT_BTOWER) {
533 if (sp->sct_type != SCT_BHEAD)
535 if (sp->sct_newtype != SCT_BHEAD)
540 if (sp->sct_effic < 60 && !player->god) {
541 pr("Sector %s is not 60%% efficient.\n",
542 xyas(sp->sct_x, sp->sct_y, player->cnum));
546 if (vec[I_HCM] < buil_bh) {
547 pr("%s only has %d unit%s of hcm,\n",
548 xyas(sp->sct_x, sp->sct_y, player->cnum),
549 vec[I_HCM], vec[I_HCM] > 1 ? "s" : "");
550 pr("(a bridge span requires %d)\n", buil_bh);
554 if (!build_can_afford(buil_bc, dchr[SCT_BSPAN].d_name))
556 avail = (SCT_BLD_WORK(0, buil_bh) * SCT_MINEFF + 99) / 100;
557 if (sp->sct_avail < avail) {
558 pr("Not enough available work in %s to build a bridge\n",
559 xyas(sp->sct_x, sp->sct_y, player->cnum));
560 pr(" (%d available work required)\n", avail);
563 if (!player->argp[3]) {
564 pr("Bridge head at %s\n",
565 xyas(sp->sct_x, sp->sct_y, player->cnum));
566 nav_map(sp->sct_x, sp->sct_y, 1);
568 p = getstarg(player->argp[3], "build span in what direction? ", buf);
572 /* Sanity check time */
573 if (!check_sect_ok(sp))
576 if ((val = chkdir(*p, DIR_FIRST, DIR_LAST)) < 0) {
577 pr("'%c' is not a valid direction...\n", *p);
581 newx = sp->sct_x + diroff[val][0];
582 newy = sp->sct_y + diroff[val][1];
583 if (getsect(newx, newy, §) == 0 || sect.sct_type != SCT_WATER) {
584 pr("%s is not a water sector\n", xyas(newx, newy, player->cnum));
587 if (opt_EASY_BRIDGES) {
590 for (i = 1; i <= 6; i++) {
592 nx = sect.sct_x + diroff[i][0];
593 ny = sect.sct_y + diroff[i][1];
594 getsect(nx, ny, &s2);
595 if ((s2.sct_type != SCT_WATER) && (s2.sct_type != SCT_BSPAN))
599 pr("Bridges must be built adjacent to land or bridge towers.\n");
600 pr("That sector is not adjacent to land or a bridge tower.\n");
603 } /* end EASY_BRIDGES */
604 sp->sct_avail -= avail;
605 player->dolcost += buil_bc;
606 sect.sct_type = SCT_BSPAN;
607 sect.sct_newtype = SCT_BSPAN;
608 sect.sct_effic = SCT_MINEFF;
611 sect.sct_defense = 0;
612 if (opt_MOB_ACCESS) {
613 time(§.sct_access);
614 sect.sct_mobil = -(etu_per_update / sect_mob_neg_factor);
619 map_set(player->cnum, sect.sct_x, sect.sct_y, dchr[SCT_BSPAN].d_mnem, 2);
620 writemap(player->cnum);
622 pr("Bridge span built over %s\n",
623 xyas(sect.sct_x, sect.sct_y, player->cnum));
624 vec[I_HCM] -= buil_bh;
629 build_nuke(struct sctstr *sp, struct nchrstr *np, short *vec, int tlev)
632 struct nstr_item nstr;
636 if (sp->sct_type != SCT_NUKE && !player->god) {
637 pr("Nuclear weapons must be built in nuclear plants.\n");
640 if (sp->sct_effic < 60 && !player->god) {
641 pr("Sector %s is not 60%% efficient.\n",
642 xyas(sp->sct_x, sp->sct_y, player->cnum));
645 if (vec[I_HCM] < np->n_hcm || vec[I_LCM] < np->n_lcm ||
646 vec[I_OIL] < np->n_oil || vec[I_RAD] < np->n_rad) {
647 pr("Not enough materials for a %s bomb in %s\n",
648 np->n_name, xyas(sp->sct_x, sp->sct_y, player->cnum));
649 pr("(%d hcm, %d lcm, %d oil, & %d rads).\n",
650 np->n_hcm, np->n_lcm, np->n_oil, np->n_rad);
653 if (!build_can_afford(np->n_cost, np->n_name))
655 avail = NUK_BLD_WORK(np->n_lcm, np->n_hcm, np->n_oil, np->n_rad);
657 * XXX when nukes turn into units (or whatever), then
658 * make them start at 20%. Since they don't have efficiency
659 * now, we charge all the work right away.
661 if (sp->sct_avail < avail) {
662 pr("Not enough available work in %s to build a %s;\n",
663 xyas(sp->sct_x, sp->sct_y, player->cnum), np->n_name);
664 pr(" (%d available work required)\n", avail);
667 if (!trechk(player->cnum, 0, NEWNUK))
669 if (!check_sect_ok(sp))
671 sp->sct_avail -= avail;
672 player->dolcost += np->n_cost;
673 snxtitem_all(&nstr, EF_NUKE);
675 while (nxtitem(&nstr, &nuke)) {
676 if (nuke.nuk_own == 0) {
682 ef_extend(EF_NUKE, 50);
684 memset(&nuke, 0, sizeof(struct nukstr));
685 nuke.nuk_x = sp->sct_x;
686 nuke.nuk_y = sp->sct_y;
687 nuke.nuk_own = sp->sct_own;
688 nuke.nuk_type = np - nchr;
689 nuke.nuk_effic = 100;
690 nuke.nuk_stockpile = 0;
691 nuke.nuk_ship = nuke.nuk_plane = nuke.nuk_land = -1;
692 nuke.nuk_uid = nstr.cur;
693 nuke.nuk_tech = tlev;
695 vec[I_HCM] -= np->n_hcm;
696 vec[I_LCM] -= np->n_lcm;
697 vec[I_OIL] -= np->n_oil;
698 vec[I_RAD] -= np->n_rad;
700 makenotlost(EF_NUKE, nuke.nuk_own, nuke.nuk_uid,
701 nuke.nuk_x, nuke.nuk_y);
702 putnuke(nuke.nuk_uid, &nuke);
703 pr("%s created in %s\n", prnuke(&nuke),
704 xyas(sp->sct_x, sp->sct_y, player->cnum));
709 build_plane(struct sctstr *sp, struct plchrstr *pp, short *vec, int tlev)
712 struct nstr_item nstr;
715 double eff = PLANE_MINEFF / 100.0;
719 mil = roundavg(pp->pl_crew * eff);
720 /* Always use at least 1 mil to build a plane */
721 if (mil == 0 && pp->pl_crew > 0)
723 hcm = roundavg(pp->pl_hcm * eff);
724 lcm = roundavg(pp->pl_lcm * eff);
725 if (sp->sct_type != SCT_AIRPT && !player->god) {
726 pr("Planes must be built in airports.\n");
729 if (sp->sct_effic < 60 && !player->god) {
730 pr("Sector %s is not 60%% efficient.\n",
731 xyas(sp->sct_x, sp->sct_y, player->cnum));
734 if (vec[I_LCM] < lcm || vec[I_HCM] < hcm) {
735 pr("Not enough materials in %s\n",
736 xyas(sp->sct_x, sp->sct_y, player->cnum));
739 avail = (PLN_BLD_WORK(pp->pl_lcm, pp->pl_hcm) * PLANE_MINEFF + 99) / 100;
740 if (sp->sct_avail < avail) {
741 pr("Not enough available work in %s to build a %s\n",
742 xyas(sp->sct_x, sp->sct_y, player->cnum), pp->pl_name);
743 pr(" (%d available work required)\n", avail);
746 cost = pp->pl_cost * PLANE_MINEFF / 100.0;
747 if (!build_can_afford(cost, pp->pl_name))
749 if (vec[I_MILIT] < mil || (vec[I_MILIT] == 0 && pp->pl_crew > 0)) {
750 pr("Not enough military for crew in %s\n",
751 xyas(sp->sct_x, sp->sct_y, player->cnum));
754 if (!trechk(player->cnum, 0, NEWPLN))
756 if (!check_sect_ok(sp))
758 sp->sct_avail -= avail;
759 player->dolcost += cost;
760 snxtitem_all(&nstr, EF_PLANE);
762 while (nxtitem(&nstr, &plane)) {
763 if (plane.pln_own == 0) {
768 if (freeplane == 0) {
769 ef_extend(EF_PLANE, 50);
771 memset(&plane, 0, sizeof(struct plnstr));
772 plane.pln_x = sp->sct_x;
773 plane.pln_y = sp->sct_y;
774 plane.pln_own = sp->sct_own;
775 plane.pln_type = pp - plchr;
776 plane.pln_effic = PLANE_MINEFF;
777 if (opt_MOB_ACCESS) {
778 time(&plane.pln_access);
779 plane.pln_mobil = -(etu_per_update / sect_mob_neg_factor);
783 plane.pln_mission = 0;
786 plane.pln_radius = 0;
787 plane.pln_range = UCHAR_MAX; /* will be adjusted by pln_set_tech() */
788 plane.pln_range_max = plane.pln_range;
792 plane.pln_uid = nstr.cur;
793 plane.pln_nuketype = -1;
794 plane.pln_harden = 0;
796 pln_set_tech(&plane, tlev);
802 makenotlost(EF_PLANE, plane.pln_own, plane.pln_uid,
803 plane.pln_x, plane.pln_y);
804 putplane(plane.pln_uid, &plane);
805 pr("%s built in sector %s\n", prplane(&plane),
806 xyas(sp->sct_x, sp->sct_y, player->cnum));
811 build_tower(struct sctstr *sp, short *vec)
824 if (sp->sct_type != SCT_BSPAN) {
825 pr("Bridge towers can only be built from bridge spans.\n");
829 if (sp->sct_effic < 60 && !player->god) {
830 pr("Sector %s is not 60%% efficient.\n",
831 xyas(sp->sct_x, sp->sct_y, player->cnum));
835 if (vec[I_HCM] < buil_tower_bh) {
836 pr("%s only has %d unit%s of hcm,\n",
837 xyas(sp->sct_x, sp->sct_y, player->cnum),
838 vec[I_HCM], vec[I_HCM] > 1 ? "s" : "");
839 pr("(a bridge tower requires %d)\n", buil_tower_bh);
843 if (!build_can_afford(buil_tower_bc, dchr[SCT_BTOWER].d_name))
845 avail = (SCT_BLD_WORK(0, buil_tower_bh) * SCT_MINEFF + 99) / 100;
846 if (sp->sct_avail < avail) {
847 pr("Not enough available work in %s to build a bridge tower\n",
848 xyas(sp->sct_x, sp->sct_y, player->cnum));
849 pr(" (%d available work required)\n", avail);
852 if (!player->argp[3]) {
853 pr("Building from %s\n", xyas(sp->sct_x, sp->sct_y, player->cnum));
854 nav_map(sp->sct_x, sp->sct_y, 1);
856 p = getstarg(player->argp[3], "build tower in what direction? ", buf);
860 /* Sanity check time */
861 if (!check_sect_ok(sp))
864 if ((val = chkdir(*p, DIR_FIRST, DIR_LAST)) < 0) {
865 pr("'%c' is not a valid direction...\n", *p);
869 newx = sp->sct_x + diroff[val][0];
870 newy = sp->sct_y + diroff[val][1];
871 if (getsect(newx, newy, §) == 0 || sect.sct_type != SCT_WATER) {
872 pr("%s is not a water sector\n", xyas(newx, newy, player->cnum));
876 /* Now, check. You aren't allowed to build bridge towers
879 for (i = 1; i <= 6; i++) {
881 nx = sect.sct_x + diroff[i][0];
882 ny = sect.sct_y + diroff[i][1];
883 getsect(nx, ny, &s2);
884 if ((s2.sct_type != SCT_WATER) &&
885 (s2.sct_type != SCT_BTOWER) && (s2.sct_type != SCT_BSPAN)) {
891 pr("Bridge towers cannot be built adjacent to land.\n");
892 pr("That sector is adjacent to land.\n");
896 sp->sct_avail -= avail;
897 player->dolcost += buil_tower_bc;
898 sect.sct_type = SCT_BTOWER;
899 sect.sct_newtype = SCT_BTOWER;
900 sect.sct_effic = SCT_MINEFF;
903 sect.sct_defense = 0;
904 if (opt_MOB_ACCESS) {
905 time(§.sct_access);
906 sect.sct_mobil = -(etu_per_update / sect_mob_neg_factor);
911 map_set(player->cnum, sect.sct_x, sect.sct_y, dchr[SCT_BTOWER].d_mnem, 2);
912 writemap(player->cnum);
914 pr("Bridge tower built in %s\n",
915 xyas(sect.sct_x, sect.sct_y, player->cnum));
916 vec[I_HCM] -= buil_tower_bh;
921 build_can_afford(double cost, char *what)
923 struct natstr *natp = getnatp(player->cnum);
924 if (natp->nat_money < player->dolcost + cost) {
925 pr("Not enough money left to build a %s\n", what);