-
- n=(-1*MAX_RETREAT);
- stopping = 0;
- time_to_stop = 0;
- while ((!stopping) && n){
- dx = dy = 0;
- if (lp->lnd_rpath[0] == 0 || lp->lnd_rpath[0] == 0){
- stopping=1;
- continue;
- }
- if (lp->lnd_mobil <= 0.0) {
- wu(0, lp->lnd_own, "%s %s,\nbut ran out of mobility, and couldn't retreat fully!\n",
- prland(lp),
- conditions[findcondition(code)].desc[orig]);
- if (!orig) putland(lp->lnd_uid,lp);
- return 0;
- }
- dir = chkdir(lp->lnd_rpath[0], DIR_STOP, DIR_VIEW);
- bzero(buf,RET_LEN-1);
- bcopy(&lp->lnd_rpath[1],buf,RET_LEN-1);
- bzero(lp->lnd_rpath,RET_LEN);
- bcopy(buf,lp->lnd_rpath,RET_LEN-1);
- if (dir == -1)
- continue;
- if (dir == DIR_STOP)
- stopping++;
- else {
- dx = diroff[dir][0];
- dy = diroff[dir][1];
- }
- n++;
-
- lcp = &lchr[(int)lp->lnd_type];
- newx = xnorm(lp->lnd_x + dx);
- newy = ynorm(lp->lnd_y + dy);
-
- getsect(newx, newy, §);
- if ((sect.sct_type == SCT_WATER) ||
- (sect.sct_type == SCT_MOUNT) ||
- (sect.sct_type == SCT_SANCT) ||
- (sect.sct_type == SCT_WASTE) ||
- (sect.sct_own != lp->lnd_own)){
- wu(0, lp->lnd_own, "%s %s,\nbut could not retreat to %s!\n",
- prland(lp),
- conditions[findcondition(code)].desc[orig],
- xyas(newx, newy, lp->lnd_own));
- if (!orig) putland(lp->lnd_uid,lp);
- return 0;
- }
- mobcost = lnd_mobcost(lp, §, MOB_ROAD);
- lp->lnd_x = newx;
- lp->lnd_y = newy;
- lp->lnd_mobil -= mobcost;
- if (stopping)
- continue;
-
- mines = getvar(V_MINE, (s_char *)§, EF_SECTOR);
- if ((lcp->l_flags & L_ENGINEER) && mines > 0 &&
- (sect.sct_oldown != lp->lnd_own)){
- max = vl_find(V_SHELL, lcp->l_vtype,
- lcp->l_vamt, (int) lcp->l_nv);
- shells = getvar(V_SHELL, (s_char *)lp, EF_LAND);
- for (m=0; mines > 0 && m < 5; m++) {
- if (chance(0.66)) {
- mines--;
- shells = min(max, shells + 1);
- }
- }
- putvar(V_MINE, mines, (s_char *)§, EF_SECTOR);
- putvar(V_SHELL, shells, (s_char *)lp, EF_LAND);
- putsect(§);
- }
- if (mines > 0 && (sect.sct_oldown != lp->lnd_own) &&
- chance(DMINE_HITCHANCE(mines))) {
- wu(0, lp->lnd_own, "%s %s,\nand hit a mine while retreating!\n",
- prland(lp),
- conditions[findcondition(code)].desc[orig],
- xyas(newx, newy, lp->lnd_own));
- nreport(lp->lnd_own, N_LHIT_MINE, 0, 1);
- m = MINE_LDAMAGE();
- landdamage(lp, m);
- mines--;
- putvar(V_MINE, mines, (s_char *)§, EF_SECTOR);
- putsect(§);
- if (lp->lnd_effic < LAND_MINEFF)
- time_to_stop = 1;
- if (!orig) putland(lp->lnd_uid,lp);
- return 0;
+ dir = chkdir(lp->lnd_rpath[0], DIR_STOP, DIR_VIEW);
+ bzero(buf, RET_LEN - 1);
+ bcopy(&lp->lnd_rpath[1], buf, RET_LEN - 1);
+ bzero(lp->lnd_rpath, RET_LEN);
+ bcopy(buf, lp->lnd_rpath, RET_LEN - 1);
+ if (dir == -1)
+ continue;
+ if (dir == DIR_STOP)
+ stopping++;
+ else {
+ dx = diroff[dir][0];
+ dy = diroff[dir][1];
+ }
+ n++;
+
+ lcp = &lchr[(int)lp->lnd_type];
+ newx = xnorm(lp->lnd_x + dx);
+ newy = ynorm(lp->lnd_y + dy);
+
+ getsect(newx, newy, §);
+ if ((sect.sct_type == SCT_WATER) ||
+ (sect.sct_type == SCT_MOUNT) ||
+ (sect.sct_type == SCT_SANCT) ||
+ (sect.sct_type == SCT_WASTE) ||
+ (sect.sct_own != lp->lnd_own)) {
+ wu(0, lp->lnd_own, "%s %s,\nbut could not retreat to %s!\n",
+ prland(lp),
+ conditions[findcondition(code)].desc[orig],
+ xyas(newx, newy, lp->lnd_own));
+ if (!orig)
+ putland(lp->lnd_uid, lp);
+ return 0;
+ }
+ mobcost = lnd_mobcost(lp, §, MOB_ROAD);
+ lp->lnd_x = newx;
+ lp->lnd_y = newy;
+ lp->lnd_mobil -= mobcost;
+ if (stopping)
+ continue;
+
+ mines = getvar(V_MINE, (s_char *)§, EF_SECTOR);
+ if ((lcp->l_flags & L_ENGINEER) && mines > 0 &&
+ (sect.sct_oldown != lp->lnd_own)) {
+ max = vl_find(V_SHELL, lcp->l_vtype,
+ lcp->l_vamt, (int)lcp->l_nv);
+ shells = getvar(V_SHELL, (s_char *)lp, EF_LAND);
+ for (m = 0; mines > 0 && m < 5; m++) {
+ if (chance(0.66)) {
+ mines--;
+ shells = min(max, shells + 1);