2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2006, 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-2005
56 static int build_nuke(struct sctstr *sp,
57 struct nchrstr *np, short *vec);
58 static int build_ship(struct sctstr *sp,
59 struct mchrstr *mp, short *vec,
61 static int build_land(struct sctstr *sp,
62 struct lchrstr *lp, short *vec,
64 static int build_bridge(struct sctstr *sp, short *vec);
65 static int build_tower(struct sctstr *sp, short *vec);
66 static int build_plane(struct sctstr *sp,
67 struct plchrstr *pp, short *vec,
69 static int build_can_afford(double, char *);
72 * build <WHAT> <SECTS> <TYPE|DIR|MEG> [NUMBER]
78 struct nstr_sect nstr;
95 natp = getnatp(player->cnum);
97 getstarg(player->argp[1],
98 "Build (ship, nuke, bridge, plane, land unit, tower)? ",
103 if (!snxtsct(&nstr, player->argp[2])) {
104 pr("Bad sector specification.\n");
107 tlev = (int)natp->nat_level[NAT_TLEV];
108 rlev = (int)natp->nat_level[NAT_RLEV];
112 p = getstarg(player->argp[3], "Plane type? ", buf);
113 if (p == 0 || *p == 0)
115 type = typematch(p, EF_PLANE);
118 rqtech = pp->pl_tech;
123 pr("You can't build that!\n");
124 pr("Use `show plane build %d' to show types you can build.\n", tlev);
129 p = getstarg(player->argp[3], "Ship type? ", buf);
130 if (p == 0 || *p == 0)
132 type = typematch(p, EF_SHIP);
138 if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
142 pr("You can't build that!\n");
143 pr("Use `show ship build %d' to show types you can build.\n", tlev);
148 p = getstarg(player->argp[3], "Land unit type? ", buf);
149 if (p == 0 || *p == 0)
151 type = typematch(p, EF_LAND);
157 if ((lp->l_flags & L_SPY) && !opt_LANDSPIES)
161 pr("You can't build that!\n");
162 pr("Use `show land build %d' to show types you can build.\n", tlev);
167 if (natp->nat_level[NAT_TLEV] + 0.005 < buil_bt) {
168 pr("Building a span requires a tech of %.0f\n", buil_bt);
173 if (!opt_BRIDGETOWERS) {
174 pr("Bridge tower building is disabled.\n");
177 if (natp->nat_level[NAT_TLEV] + 0.005 < buil_tower_bt) {
178 pr("Building a tower requires a tech of %.0f\n",
184 if (!ef_nelem(EF_NUKE_CHR)) {
185 pr("There are no nukes in this game.\n");
188 p = getstarg(player->argp[3], "Nuke type? ", buf);
189 if (p == 0 || *p == 0)
191 type = typematch(p, EF_NUKE);
196 || (drnuke_const > MIN_DRNUKE_CONST &&
197 np->n_tech * drnuke_const > rlev))
202 if (drnuke_const > MIN_DRNUKE_CONST)
203 tt = (tlev < (rlev / drnuke_const) ? (int)tlev :
204 (int)(rlev / drnuke_const));
205 pr("You can't build that!\n");
206 pr("Use `show nuke build %d' to show types you can build.\n", tt);
211 pr("You can't build that!\n");
216 if (what != 'b' && what != 't') {
217 if (player->argp[4]) {
218 number = atoi(player->argp[4]);
222 "Are you sure that you want to build %s of them? ",
224 p = getstarg(player->argp[6], bstr, buf);
225 if (p == 0 || *p != 'y')
231 if (what != 'b' && what != 'n' && what != 't') {
232 if (player->argp[5]) {
233 tlev = atoi(player->argp[5]);
234 if (tlev > natp->nat_level[NAT_TLEV] && !player->god) {
235 pr("Your tech level is only %d.\n",
236 (int)natp->nat_level[NAT_TLEV]);
240 pr("Required tech is %d.\n", rqtech);
243 pr("building with tech level %d.\n", tlev);
247 while (number-- > 0) {
248 while (nxtsct(&nstr, §)) {
254 built = build_land(§, lp, sect.sct_item, tlev);
257 built = build_ship(§, mp, sect.sct_item, tlev);
260 built = build_bridge(§, sect.sct_item);
263 built = build_tower(§, sect.sct_item);
266 built = build_nuke(§, np, sect.sct_item);
269 built = build_plane(§, pp, sect.sct_item, tlev);
272 CANT_HAPPEN("Bad WHAT");
279 snxtsct_rewind(&nstr);
282 pr("Bad sector specification.\n");
288 build_ship(struct sctstr *sp, struct mchrstr *mp,
289 short *vec, int tlev)
292 struct nstr_item nstr;
295 float eff = SHIP_MINEFF / 100.0;
299 hcm = roundavg((double)mp->m_hcm * eff);
300 lcm = roundavg((double)mp->m_lcm * eff);
302 if (sp->sct_type != SCT_HARBR) {
303 pr("Ships must be built in harbours.\n");
306 if (sp->sct_effic < 60 && !player->god) {
307 pr("Sector %s is not 60%% efficient.\n",
308 xyas(sp->sct_x, sp->sct_y, player->cnum));
311 if (vec[I_LCM] < lcm || vec[I_HCM] < hcm) {
312 pr("Not enough materials in %s\n",
313 xyas(sp->sct_x, sp->sct_y, player->cnum));
316 avail = (SHP_BLD_WORK(mp->m_lcm, mp->m_hcm) * SHIP_MINEFF + 99) / 100;
317 if (sp->sct_avail < avail) {
318 pr("Not enough available work in %s to build a %s\n",
319 xyas(sp->sct_x, sp->sct_y, player->cnum), mp->m_name);
320 pr(" (%d available work required)\n", avail);
323 cost = mp->m_cost * SHIP_MINEFF / 100.0;
324 if (!build_can_afford(cost, mp->m_name))
326 if (!trechk(player->cnum, 0, NEWSHP))
328 if (!check_sect_ok(sp))
330 sp->sct_avail -= avail;
331 player->dolcost += cost;
332 snxtitem_all(&nstr, EF_SHIP);
333 while (nxtitem(&nstr, &ship)) {
334 if (ship.shp_own == 0) {
340 ef_extend(EF_SHIP, 50);
342 memset(&ship, 0, sizeof(struct shpstr));
343 ship.shp_x = sp->sct_x;
344 ship.shp_y = sp->sct_y;
345 ship.shp_destx[0] = sp->sct_x;
346 ship.shp_desty[0] = sp->sct_y;
347 ship.shp_destx[1] = sp->sct_x;
348 ship.shp_desty[1] = sp->sct_y;
349 ship.shp_autonav = 0;
350 /* new code for autonav, Chad Zabel 1-15-94 */
351 for (i = 0; i < TMAX; ++i) {
352 ship.shp_tstart[i] = I_NONE;
353 ship.shp_tend[i] = I_NONE;
354 ship.shp_lstart[i] = 0;
355 ship.shp_lend[i] = 0;
357 ship.shp_mission = 0;
358 ship.shp_own = player->cnum;
359 ship.shp_type = mp - mchr;
360 ship.shp_effic = SHIP_MINEFF;
361 if (opt_MOB_ACCESS) {
362 time(&ship.shp_access);
363 ship.shp_mobil = -(etu_per_update / sect_mob_neg_factor);
367 ship.shp_uid = nstr.cur;
370 ship.shp_nxlight = 0;
371 ship.shp_nchoppers = 0;
372 ship.shp_fleet = ' ';
373 memset(ship.shp_item, 0, sizeof(ship.shp_item));
374 ship.shp_pstage = PLG_HEALTHY;
376 ship.shp_mobquota = 0;
378 ship.shp_follow = nstr.cur;
379 ship.shp_name[0] = 0;
380 ship.shp_orig_own = player->cnum;
381 ship.shp_orig_x = sp->sct_x;
382 ship.shp_orig_y = sp->sct_y;
383 ship.shp_fuel = mchr[(int)ship.shp_type].m_fuelc;
385 memset(ship.shp_rpath, 0, sizeof(ship.shp_rpath));
386 shp_set_tech(&ship, tlev);
391 if (sp->sct_pstage == PLG_INFECT)
392 ship.shp_pstage = PLG_EXPOSED;
393 makenotlost(EF_SHIP, ship.shp_own, ship.shp_uid, ship.shp_x,
395 putship(ship.shp_uid, &ship);
396 pr("%s", prship(&ship));
397 pr(" built in sector %s\n", xyas(sp->sct_x, sp->sct_y, player->cnum));
402 build_land(struct sctstr *sp, struct lchrstr *lp,
403 short *vec, int tlev)
406 struct nstr_item nstr;
409 float eff = LAND_MINEFF / 100.0;
410 int mil, lcm, hcm, gun, shell;
414 mil = roundavg(((double)lp->l_mil * eff));
415 shell = roundavg(((double)lp->l_shell * eff));
416 gun = roundavg(((double)lp->l_gun * eff));
418 mil = shell = gun = 0;
420 hcm = roundavg(((double)lp->l_hcm * eff));
421 lcm = roundavg(((double)lp->l_lcm * eff));
423 if (sp->sct_type != SCT_HEADQ) {
424 pr("Land Units must be built in headquarters.\n");
427 if (sp->sct_effic < 60 && !player->god) {
428 pr("Sector %s is not 60%% efficient.\n",
429 xyas(sp->sct_x, sp->sct_y, player->cnum));
432 if (vec[I_LCM] < lcm || vec[I_HCM] < hcm) {
433 pr("Not enough materials in %s\n",
434 xyas(sp->sct_x, sp->sct_y, player->cnum));
438 if (vec[I_GUN] < gun || vec[I_GUN] == 0) {
439 pr("Not enough guns in %s\n",
440 xyas(sp->sct_x, sp->sct_y, player->cnum));
443 if (vec[I_SHELL] < shell) {
444 pr("Not enough shells in %s\n",
445 xyas(sp->sct_x, sp->sct_y, player->cnum));
448 if (vec[I_MILIT] < mil) {
449 pr("Not enough military in %s\n",
450 xyas(sp->sct_x, sp->sct_y, player->cnum));
454 if (!trechk(player->cnum, 0, NEWLND))
456 if (!check_sect_ok(sp))
458 avail = (LND_BLD_WORK(lp->l_lcm, lp->l_hcm) * LAND_MINEFF + 99) / 100;
459 if (sp->sct_avail < avail) {
460 pr("Not enough available work in %s to build a %s\n",
461 xyas(sp->sct_x, sp->sct_y, player->cnum), lp->l_name);
462 pr(" (%d available work required)\n", avail);
465 cost = lp->l_cost * LAND_MINEFF / 100.0;
466 if (!build_can_afford(cost, lp->l_name))
468 sp->sct_avail -= avail;
469 player->dolcost += cost;
470 snxtitem_all(&nstr, EF_LAND);
471 while (nxtitem(&nstr, &land)) {
472 if (land.lnd_own == 0) {
478 ef_extend(EF_LAND, 50);
480 memset(&land, 0, sizeof(struct lndstr));
481 land.lnd_x = sp->sct_x;
482 land.lnd_y = sp->sct_y;
483 land.lnd_own = player->cnum;
484 land.lnd_mission = 0;
485 land.lnd_type = lp - lchr;
486 land.lnd_effic = LAND_MINEFF;
487 if (opt_MOB_ACCESS) {
488 time(&land.lnd_access);
489 land.lnd_mobil = -(etu_per_update / sect_mob_neg_factor);
493 land.lnd_uid = nstr.cur;
500 land.lnd_retreat = morale_base;
501 land.lnd_fuel = lp->l_fuelc;
502 land.lnd_nxlight = 0;
504 memset(land.lnd_rpath, 0, sizeof(land.lnd_rpath));
505 land.lnd_rad_max = 0;
506 memset(land.lnd_item, 0, sizeof(land.lnd_item));
507 land.lnd_pstage = PLG_HEALTHY;
509 lnd_set_tech(&land, tlev);
515 vec[I_SHELL] -= shell;
517 if (sp->sct_pstage == PLG_INFECT)
518 land.lnd_pstage = PLG_EXPOSED;
519 putland(nstr.cur, &land);
520 makenotlost(EF_LAND, land.lnd_own, land.lnd_uid, land.lnd_x,
522 pr("%s", prland(&land));
523 pr(" built in sector %s\n", xyas(sp->sct_x, sp->sct_y, player->cnum));
528 build_bridge(struct sctstr *sp, short *vec)
534 int nx, ny, i, good = 0;
538 if (opt_EASY_BRIDGES == 0) { /* must have a bridge head or tower */
539 if (sp->sct_type != SCT_BTOWER) {
540 if (sp->sct_type != SCT_BHEAD)
542 if (sp->sct_newtype != SCT_BHEAD)
547 if (sp->sct_effic < 60 && !player->god) {
548 pr("Sector %s is not 60%% efficient.\n",
549 xyas(sp->sct_x, sp->sct_y, player->cnum));
553 if (vec[I_HCM] < buil_bh) {
554 pr("%s only has %d unit%s of hcm,\n",
555 xyas(sp->sct_x, sp->sct_y, player->cnum),
556 vec[I_HCM], vec[I_HCM] > 1 ? "s" : "");
557 pr("(a bridge span requires %d)\n", buil_bh);
561 if (!build_can_afford(buil_bc, dchr[SCT_BSPAN].d_name))
563 avail = (SCT_BLD_WORK(0, buil_bh) * SCT_MINEFF + 99) / 100;
564 if (sp->sct_avail < avail) {
565 pr("Not enough available work in %s to build a bridge\n",
566 xyas(sp->sct_x, sp->sct_y, player->cnum));
567 pr(" (%d available work required)\n", avail);
570 if (!player->argp[3]) {
571 pr("Bridge head at %s\n",
572 xyas(sp->sct_x, sp->sct_y, player->cnum));
573 nav_map(sp->sct_x, sp->sct_y, 1);
575 if (!(p = getstarg(player->argp[3], "build span in what direction? ", buf))
579 /* Sanity check time */
580 if (!check_sect_ok(sp))
583 if ((val = chkdir(*p, DIR_FIRST, DIR_LAST)) < 0) {
584 pr("'%c' is not a valid direction...\n", *p);
588 newx = sp->sct_x + diroff[val][0];
589 newy = sp->sct_y + diroff[val][1];
590 if (getsect(newx, newy, §) == 0 || sect.sct_type != SCT_WATER) {
591 pr("%s is not a water sector\n", xyas(newx, newy, player->cnum));
594 if (opt_EASY_BRIDGES) {
597 for (i = 1; i <= 6; i++) {
599 nx = sect.sct_x + diroff[i][0];
600 ny = sect.sct_y + diroff[i][1];
601 getsect(nx, ny, &s2);
602 if ((s2.sct_type != SCT_WATER) && (s2.sct_type != SCT_BSPAN))
606 pr("Bridges must be built adjacent to land or bridge towers.\n");
607 pr("That sector is not adjacent to land or a bridge tower.\n");
610 } /* end EASY_BRIDGES */
611 sp->sct_avail -= avail;
612 player->dolcost += buil_bc;
613 sect.sct_type = SCT_BSPAN;
614 sect.sct_newtype = SCT_BSPAN;
615 sect.sct_effic = SCT_MINEFF;
618 sect.sct_defense = 0;
619 if (!opt_DEFENSE_INFRA)
620 sect.sct_defense = sect.sct_effic;
621 if (opt_MOB_ACCESS) {
622 time(§.sct_access);
623 sect.sct_mobil = -(etu_per_update / sect_mob_neg_factor);
628 map_set(player->cnum, sect.sct_x, sect.sct_y, dchr[SCT_BSPAN].d_mnem, 2);
629 writemap(player->cnum);
631 pr("Bridge span built over %s\n",
632 xyas(sect.sct_x, sect.sct_y, player->cnum));
633 vec[I_HCM] -= buil_bh;
638 build_nuke(struct sctstr *sp, struct nchrstr *np,
643 if (sp->sct_type != SCT_NUKE && !player->god) {
644 pr("Nuclear weapons must be built in nuclear plants.\n");
647 if (sp->sct_effic < 60 && !player->god) {
648 pr("Sector %s is not 60%% efficient.\n",
649 xyas(sp->sct_x, sp->sct_y, player->cnum));
652 if (vec[I_HCM] < np->n_hcm || vec[I_LCM] < np->n_lcm ||
653 vec[I_OIL] < np->n_oil || vec[I_RAD] < np->n_rad) {
654 pr("Not enough materials for a %s bomb in %s\n",
655 np->n_name, xyas(sp->sct_x, sp->sct_y, player->cnum));
656 pr("(%d hcm, %d lcm, %d oil, & %d rads).\n",
657 np->n_hcm, np->n_lcm, np->n_oil, np->n_rad);
660 if (!build_can_afford(np->n_cost, np->n_name))
662 avail = NUK_BLD_WORK(np->n_lcm, np->n_hcm, np->n_oil, np->n_rad);
664 * XXX when nukes turn into units (or whatever), then
665 * make them start at 20%. Since they don't have efficiency
666 * now, we charge all the work right away.
668 if (sp->sct_avail < avail) {
669 pr("Not enough available work in %s to build a %s;\n",
670 xyas(sp->sct_x, sp->sct_y, player->cnum), np->n_name);
671 pr(" (%d available work required)\n", avail);
674 if (!trechk(player->cnum, 0, NEWNUK))
676 if (!check_sect_ok(sp))
678 sp->sct_avail -= avail;
679 player->dolcost += np->n_cost;
680 nuk_add(sp->sct_x, sp->sct_y, np - nchr, 1);
681 vec[I_HCM] -= np->n_hcm;
682 vec[I_LCM] -= np->n_lcm;
683 vec[I_OIL] -= np->n_oil;
684 vec[I_RAD] -= np->n_rad;
685 pr("%s warhead created in %s\n", np->n_name,
686 xyas(sp->sct_x, sp->sct_y, player->cnum));
691 build_plane(struct sctstr *sp, struct plchrstr *pp,
692 short *vec, int tlev)
695 struct nstr_item nstr;
698 float eff = PLANE_MINEFF / 100.0;
702 mil = roundavg(((double)pp->pl_crew * eff));
703 /* Always use at least 1 mil to build a plane */
704 if (mil == 0 && pp->pl_crew > 0)
706 hcm = roundavg(((double)pp->pl_hcm * eff));
707 lcm = roundavg(((double)pp->pl_lcm * eff));
708 if (sp->sct_type != SCT_AIRPT && !player->god) {
709 pr("Planes must be built in airports.\n");
712 if (sp->sct_effic < 60 && !player->god) {
713 pr("Sector %s is not 60%% efficient.\n",
714 xyas(sp->sct_x, sp->sct_y, player->cnum));
717 if (vec[I_LCM] < lcm || vec[I_HCM] < hcm) {
718 pr("Not enough materials in %s\n",
719 xyas(sp->sct_x, sp->sct_y, player->cnum));
722 avail = (PLN_BLD_WORK(pp->pl_lcm, pp->pl_hcm) * PLANE_MINEFF + 99) / 100;
723 if (sp->sct_avail < avail) {
724 pr("Not enough available work in %s to build a %s\n",
725 xyas(sp->sct_x, sp->sct_y, player->cnum), pp->pl_name);
726 pr(" (%d available work required)\n", avail);
729 cost = pp->pl_cost * PLANE_MINEFF / 100.0;
730 if (!build_can_afford(cost, pp->pl_name))
732 if (vec[I_MILIT] < mil || (vec[I_MILIT] == 0 && pp->pl_crew > 0)) {
733 pr("Not enough military for crew in %s\n",
734 xyas(sp->sct_x, sp->sct_y, player->cnum));
737 if (!trechk(player->cnum, 0, NEWPLN))
739 if (!check_sect_ok(sp))
741 sp->sct_avail -= avail;
742 player->dolcost += cost;
743 snxtitem_all(&nstr, EF_PLANE);
745 while (nxtitem(&nstr, &plane)) {
746 if (plane.pln_own == 0) {
751 if (freeplane == 0) {
752 ef_extend(EF_PLANE, 50);
754 memset(&plane, 0, sizeof(struct plnstr));
755 plane.pln_x = sp->sct_x;
756 plane.pln_y = sp->sct_y;
757 plane.pln_own = sp->sct_own;
758 plane.pln_type = pp - plchr;
759 plane.pln_effic = PLANE_MINEFF;
760 if (opt_MOB_ACCESS) {
761 time(&plane.pln_access);
762 plane.pln_mobil = -(etu_per_update / sect_mob_neg_factor);
766 plane.pln_mission = 0;
769 plane.pln_radius = 0;
770 plane.pln_range = UCHAR_MAX; /* will be adjusted by pln_set_tech() */
771 plane.pln_range_max = plane.pln_range;
772 plane.pln_wing = ' ';
775 plane.pln_uid = nstr.cur;
776 plane.pln_nuketype = -1;
777 plane.pln_harden = 0;
779 pln_set_tech(&plane, tlev);
785 makenotlost(EF_PLANE, plane.pln_own, plane.pln_uid, plane.pln_x,
787 putplane(plane.pln_uid, &plane);
788 pr("%s built in sector %s\n", prplane(&plane),
789 xyas(sp->sct_x, sp->sct_y, player->cnum));
794 build_tower(struct sctstr *sp, short *vec)
807 if (sp->sct_type != SCT_BSPAN) {
808 pr("Bridge towers can only be built from bridge spans.\n");
812 if (sp->sct_effic < 60 && !player->god) {
813 pr("Sector %s is not 60%% efficient.\n",
814 xyas(sp->sct_x, sp->sct_y, player->cnum));
818 if (vec[I_HCM] < buil_tower_bh) {
819 pr("%s only has %d unit%s of hcm,\n",
820 xyas(sp->sct_x, sp->sct_y, player->cnum),
821 vec[I_HCM], vec[I_HCM] > 1 ? "s" : "");
822 pr("(a bridge tower requires %d)\n", buil_tower_bh);
826 if (!build_can_afford(buil_tower_bc, dchr[SCT_BTOWER].d_name))
828 avail = (SCT_BLD_WORK(0, buil_tower_bh) * SCT_MINEFF + 99) / 100;
829 if (sp->sct_avail < avail) {
830 pr("Not enough available work in %s to build a bridge tower\n",
831 xyas(sp->sct_x, sp->sct_y, player->cnum));
832 pr(" (%d available work required)\n", avail);
835 if (!player->argp[3]) {
836 pr("Building from %s\n", xyas(sp->sct_x, sp->sct_y, player->cnum));
837 nav_map(sp->sct_x, sp->sct_y, 1);
839 if (!(p = getstarg(player->argp[3], "build tower in what direction? ", buf))
843 /* Sanity check time */
844 if (!check_sect_ok(sp))
847 if ((val = chkdir(*p, DIR_FIRST, DIR_LAST)) < 0) {
848 pr("'%c' is not a valid direction...\n", *p);
852 newx = sp->sct_x + diroff[val][0];
853 newy = sp->sct_y + diroff[val][1];
854 if (getsect(newx, newy, §) == 0 || sect.sct_type != SCT_WATER) {
855 pr("%s is not a water sector\n", xyas(newx, newy, player->cnum));
859 /* Now, check. You aren't allowed to build bridge towers
862 for (i = 1; i <= 6; i++) {
864 nx = sect.sct_x + diroff[i][0];
865 ny = sect.sct_y + diroff[i][1];
866 getsect(nx, ny, &s2);
867 if ((s2.sct_type != SCT_WATER) &&
868 (s2.sct_type != SCT_BTOWER) && (s2.sct_type != SCT_BSPAN)) {
874 pr("Bridge towers cannot be built adjacent to land.\n");
875 pr("That sector is adjacent to land.\n");
879 sp->sct_avail -= avail;
880 player->dolcost += buil_tower_bc;
881 sect.sct_type = SCT_BTOWER;
882 sect.sct_newtype = SCT_BTOWER;
883 sect.sct_effic = SCT_MINEFF;
886 sect.sct_defense = 0;
887 if (opt_MOB_ACCESS) {
888 time(§.sct_access);
889 sect.sct_mobil = -(etu_per_update / sect_mob_neg_factor);
893 if (!opt_DEFENSE_INFRA)
894 sect.sct_defense = sect.sct_effic;
896 map_set(player->cnum, sect.sct_x, sect.sct_y, dchr[SCT_BTOWER].d_mnem, 2);
897 writemap(player->cnum);
899 pr("Bridge tower built in %s\n",
900 xyas(sect.sct_x, sect.sct_y, player->cnum));
901 vec[I_HCM] -= buil_tower_bh;
906 build_can_afford(double cost, char *what)
908 struct natstr *natp = getnatp(player->cnum);
909 if (natp->nat_money < player->dolcost + cost) {
910 pr("Not enough money left to build a %s\n", what);