00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include <config.h>
00035
00036 #include "file.h"
00037 #include "land.h"
00038 #include "lost.h"
00039 #include "misc.h"
00040 #include "nat.h"
00041 #include "nsc.h"
00042 #include "nuke.h"
00043 #include "optlist.h"
00044 #include "path.h"
00045 #include "plague.h"
00046 #include "plane.h"
00047 #include "prototypes.h"
00048 #include "sect.h"
00049 #include "xy.h"
00050
00051 void
00052 bridgefall(struct sctstr *sp, struct emp_qelem *list)
00053 {
00054 int i;
00055 int j;
00056 struct sctstr sect;
00057 struct sctstr bh_sect;
00058 int nx;
00059 int ny;
00060 int nnx;
00061 int nny;
00062
00063 for (i = 1; i <= 6; i++) {
00064 nx = sp->sct_x + diroff[i][0];
00065 ny = sp->sct_y + diroff[i][1];
00066 getsect(nx, ny, §);
00067 if (sect.sct_type != SCT_BSPAN)
00068 continue;
00069 for (j = 1; j <= 6; j++) {
00070 nnx = nx + diroff[j][0];
00071 nny = ny + diroff[j][1];
00072 if (nnx == sp->sct_x && nny == sp->sct_y)
00073 continue;
00074 getsect(nnx, nny, &bh_sect);
00075 if (bh_sect.sct_type == SCT_BHEAD &&
00076 bh_sect.sct_newtype == SCT_BHEAD)
00077 break;
00078 if (bh_sect.sct_type == SCT_BTOWER)
00079 break;
00080
00081
00082 if (opt_EASY_BRIDGES) {
00083 if (bh_sect.sct_type != SCT_WATER &&
00084 bh_sect.sct_type != SCT_BSPAN)
00085 break;
00086 }
00087 }
00088 if (j > 6) {
00089 knockdown(§, list);
00090 putsect(§);
00091 }
00092 }
00093 }
00094
00095
00096
00097 void
00098 knockdown(struct sctstr *sp, struct emp_qelem *list)
00099 {
00100 struct lndstr land;
00101 struct plnstr plane;
00102 struct nukstr nuke;
00103 struct nstr_item ni;
00104 struct natstr *np;
00105
00106 mpr(sp->sct_own,
00107 "Crumble... SCREEEECH! Splash! Bridge%s falls at %s!\n",
00108 sp->sct_type == SCT_BTOWER ? " tower" : "",
00109 xyas(sp->sct_x, sp->sct_y, sp->sct_own));
00110 sp->sct_type = SCT_WATER;
00111 sp->sct_newtype = SCT_WATER;
00112 makelost(EF_SECTOR, sp->sct_own, 0, sp->sct_x, sp->sct_y);
00113 sp->sct_own = 0;
00114 sp->sct_oldown = 0;
00115 sp->sct_mobil = 0;
00116 sp->sct_effic = 0;
00117
00118
00119 snxtitem_xy(&ni, EF_LAND, sp->sct_x, sp->sct_y);
00120 while (nxtitem(&ni, &land)) {
00121 if (land.lnd_own == 0)
00122 continue;
00123 if (land.lnd_ship >= 0)
00124 continue;
00125 np = getnatp(land.lnd_own);
00126 if (np->nat_flags & NF_BEEP)
00127 mpr(land.lnd_own, "\07");
00128 mpr(land.lnd_own, " AARGH! %s tumbles to its doom!\n",
00129 prland(&land));
00130 land.lnd_effic = 0;
00131 putland(land.lnd_uid, &land);
00132 }
00133
00134 snxtitem_xy(&ni, EF_PLANE, sp->sct_x, sp->sct_y);
00135 while (nxtitem(&ni, &plane)) {
00136 if (plane.pln_own == 0)
00137 continue;
00138 if (plane.pln_flags & PLN_LAUNCHED)
00139 continue;
00140 if (plane.pln_ship >= 0)
00141 continue;
00142
00143 if (ac_isflying(&plane, list))
00144 continue;
00145 np = getnatp(plane.pln_own);
00146 if (np->nat_flags & NF_BEEP)
00147 mpr(plane.pln_own, "\07");
00148 mpr(plane.pln_own, " AARGH! %s tumbles to its doom!\n",
00149 prplane(&plane));
00150 plane.pln_effic = 0;
00151 putplane(plane.pln_uid, &plane);
00152 }
00153
00154 snxtitem_xy(&ni, EF_NUKE, sp->sct_x, sp->sct_y);
00155 while (nxtitem(&ni, &nuke)) {
00156 if (nuke.nuk_own == 0)
00157 continue;
00158 if (nuke.nuk_plane >= 0)
00159 continue;
00160 np = getnatp(nuke.nuk_own);
00161 if (np->nat_flags & NF_BEEP)
00162 mpr(nuke.nuk_own, "\07");
00163 mpr(nuke.nuk_own, " %s sinks to the bottom of the sea!\n",
00164 prnuke(&nuke));
00165 nuke.nuk_effic = 0;
00166 putnuke(nuke.nuk_uid, &nuke);
00167 }
00168 memset(sp->sct_item, 0, sizeof(sp->sct_item));
00169 memset(sp->sct_del, 0, sizeof(sp->sct_del));
00170 memset(sp->sct_dist, 0, sizeof(sp->sct_dist));
00171 sp->sct_pstage = PLG_HEALTHY;
00172 sp->sct_ptime = 0;
00173 sp->sct_che = 0;
00174 sp->sct_che_target = 0;
00175 }