/* * Describe an item up for sale. "tgp" is a union containing * the details of the generic item. * Return 1 on success, 0 on error */ int trade_desc(struct empobj *tgp) { i_type it; struct sctstr sect; struct nukstr *np; struct shpstr *sp; struct plnstr *pp; struct lndstr *lp; struct nstr_item ni; struct plnstr plane; struct lndstr land; struct nukstr nuke; switch (tgp->ef_type) { case EF_NUKE: np = (struct nukstr *)tgp; pr("(%3d) tech %d %d%% %s #%d", np->nuk_own, np->nuk_tech, np->nuk_effic, nchr[(int)np->nuk_type].n_name, np->nuk_uid); break; case EF_SHIP: sp = (struct shpstr *)tgp; pr("(%3d) tech %d %d%% %s [", sp->shp_own, sp->shp_tech, sp->shp_effic, prship(sp)); for (it = I_NONE + 1; it <= I_MAX; ++it) { if (sp->shp_item[it]) pr("%c:%d ", ichr[it].i_mnem, sp->shp_item[it]); } pr("] #%d", sp->shp_uid); snxtitem_cargo(&ni, EF_PLANE, EF_SHIP, sp->shp_uid); while (nxtitem(&ni, &plane)) { pr("\n\t\t\t\t tech %3d %3d%% %s #%d", plane.pln_tech, plane.pln_effic, plchr[(int)plane.pln_type].pl_name, plane.pln_uid); if (getnuke(nuk_on_plane(&plane), &nuke)) pr("(%s)", nchr[nuke.nuk_type].n_name); } snxtitem_cargo(&ni, EF_LAND, EF_SHIP, sp->shp_uid); while (nxtitem(&ni, &land)) { pr("\n\t\t\t\t tech %3d %3d%% %s #%d", land.lnd_tech, land.lnd_effic, lchr[(int)land.lnd_type].l_name, land.lnd_uid); if (pln_first_on_land(&land) >= 0) { snxtitem_cargo(&ni, EF_PLANE, EF_LAND, land.lnd_uid); while (nxtitem(&ni, &plane)) { pr("\n\t\t\t\t tech %3d %3d%% %s #%d", plane.pln_tech, plane.pln_effic, plchr[(int)plane.pln_type].pl_name, plane.pln_uid); if (getnuke(nuk_on_plane(&plane), &nuke)) pr("(%s)", nchr[nuke.nuk_type].n_name); } } } getsect(sp->shp_x, sp->shp_y, §); if (sect.sct_type != SCT_WATER) pr(" in a %s %s", cname(sect.sct_own), dchr[sect.sct_type].d_name); else pr(" at sea"); break; case EF_LAND: lp = (struct lndstr *)tgp; pr("(%3d) tech %d %d%% %s [", lp->lnd_own, lp->lnd_tech, lp->lnd_effic, lchr[(int)lp->lnd_type].l_name); for (it = I_NONE + 1; it <= I_MAX; ++it) { if (lp->lnd_item[it]) pr("%c:%d ", ichr[it].i_mnem, lp->lnd_item[it]); } pr("] #%d", lp->lnd_uid); break; case EF_PLANE: pp = (struct plnstr *)tgp; pr("(%3d) tech %d %d%% %s #%d", pp->pln_own, pp->pln_tech, pp->pln_effic, plchr[(int)pp->pln_type].pl_name, pp->pln_uid); if (getnuke(nuk_on_plane(pp), &nuke)) pr("(%s)", nchr[nuke.nuk_type].n_name); break; default: pr("flaky unit type %d", tgp->uid); break; } return 1; }
int pdump(void) { int nplanes; struct nstr_item np; struct plnstr plane; struct nukstr nuke; int field[128]; struct natstr *natp; int n, i; time_t now; if (!snxtitem(&np, EF_PLANE, player->argp[1], NULL)) return RET_SYN; prdate(); if (!player->argp[2]) { for (n = 1; n <= 32; n++) field[n - 1] = n; field[n - 1] = 0; } else { n = 2; i = 0; while (player->argp[n]) { if (!strcmp("type", player->argp[n])) { field[i++] = 1; } else if (!strcmp("x", player->argp[n])) { field[i++] = 2; } else if (!strcmp("y", player->argp[n])) { field[i++] = 3; } else if (!strcmp("wing", player->argp[n])) { field[i++] = 4; } else if (!strcmp("eff", player->argp[n])) { field[i++] = 5; } else if (!strcmp("mob", player->argp[n])) { field[i++] = 6; } else if (!strcmp("tech", player->argp[n])) { field[i++] = 7; } else if (!strcmp("att", player->argp[n])) { field[i++] = 8; } else if (!strcmp("def", player->argp[n])) { field[i++] = 9; } else if (!strcmp("acc", player->argp[n])) { field[i++] = 10; } else if (!strcmp("react", player->argp[n])) { field[i++] = 11; } else if (!strcmp("range", player->argp[n])) { field[i++] = 12; } else if (!strcmp("load", player->argp[n])) { field[i++] = 13; } else if (!strcmp("fuel", player->argp[n])) { field[i++] = 14; } else if (!strcmp("hard", player->argp[n])) { field[i++] = 15; } else if (!strcmp("ship", player->argp[n])) { field[i++] = 16; } else if (!strcmp("land", player->argp[n])) { field[i++] = 17; } else if (!strcmp("laun", player->argp[n])) { field[i++] = 18; } else if (!strcmp("orb", player->argp[n])) { field[i++] = 19; } else if (!strcmp("nuke", player->argp[n])) { field[i++] = 20; } else if (!strcmp("grd", player->argp[n])) { field[i++] = 21; } else { pr("Unrecognized field %s\n", player->argp[n]); } if (n++ > 100) { pr("Too many fields\n"); return RET_FAIL; } } field[i] = 0; } if (player->god) pr(" "); time(&now); pr("DUMP PLANES %ld\n", (long)now); if (player->god) pr("own "); pr("id"); n = 0; while (field[n]) { switch (field[n]) { case 1: pr(" type"); break; case 2: pr(" x"); break; case 3: pr(" y"); break; case 4: pr(" wing"); break; case 5: pr(" eff"); break; case 6: pr(" mob"); break; case 7: pr(" tech"); break; case 8: pr(" att"); break; case 9: pr(" def"); break; case 10: pr(" acc"); break; case 11: pr(" react"); break; case 12: pr(" range"); break; case 13: pr(" load"); break; case 14: pr(" fuel"); break; case 15: pr(" hard"); break; case 16: pr(" ship"); break; case 17: pr(" land"); break; case 18: pr(" laun"); break; case 19: pr(" orb"); break; case 20: pr(" nuke"); break; case 21: pr(" grd"); break; } n++; } pr("\n"); nplanes = 0; natp = getnatp(player->cnum); while (nxtitem(&np, &plane)) { if (!player->owner || plane.pln_own == 0) continue; nplanes++; if (player->god) pr("%d ", plane.pln_own); pr("%d", np.cur); n = 0; while (field[n]) { switch (field[n++]) { case 1: pr(" %.4s", plchr[(int)plane.pln_type].pl_name); break; case 2: pr(" %d", xrel(natp, plane.pln_x)); break; case 3: pr(" %d", yrel(natp, plane.pln_y)); break; case 4: pr(" %c", plane.pln_wing ? plane.pln_wing : '~'); break; case 5: pr(" %d", plane.pln_effic); break; case 6: pr(" %d", plane.pln_mobil); break; case 7: pr(" %d", plane.pln_tech); break; case 8: pr(" %d", pln_att(&plane)); break; case 9: pr(" %d", pln_def(&plane)); break; case 10: pr(" %d", pln_acc(&plane)); break; case 11: pr(" %d", plane.pln_range); break; case 12: pr(" %d", pln_range_max(&plane)); break; case 13: pr(" %d", pln_load(&plane)); break; case 14: pr(" %d", plchr[(int)plane.pln_type].pl_fuel); break; case 15: pr(" %d", plane.pln_harden); break; case 16: pr(" %d", plane.pln_ship); break; case 17: pr(" %d", plane.pln_land); break; case 18: pr(pln_is_in_orbit(&plane) ? " Y" : " N"); break; case 19: pr(pln_is_in_orbit(&plane) && (plane.pln_flags & PLN_SYNCHRONOUS) ? " Y" : " N"); break; case 20: if (getnuke(nuk_on_plane(&plane), &nuke)) { pr(" %.5s", nchr[nuke.nuk_type].n_name); break; } else pr(" N/A"); break; case 21: pr(" %c", plane.pln_flags & PLN_AIRBURST ? 'A' : 'G'); break; } } pr("\n"); } if (nplanes == 0) { if (player->argp[1]) pr("%s: No plane(s)\n", player->argp[1]); else pr("%s: No plane(s)\n", ""); return RET_FAIL; } else pr("%d plane%s\n", nplanes, splur(nplanes)); return RET_OK; }
int msl_launch(struct plnstr *pp, int type, char *what, coord x, coord y, natid victim, int *sublaunchp) { struct shpstr ship; struct nukstr nuke; int sublaunch = 0; char *base, *in_or_at, *from; mpr(pp->pln_own, "Preparing to launch %s at %s %s %s%s\n", prplane(pp), cname(victim), what, type != EF_SECTOR ? "in " : "", xyas(x, y, pp->pln_own)); if (pp->pln_ship >= 0) { getship(pp->pln_ship, &ship); base = prship(&ship); in_or_at = " in "; if (mchr[(int)ship.shp_type].m_flags & M_SUB) { sublaunch = 1; from = "in hatch"; } else from = "on deck"; } else { if (pp->pln_harden > 0) { base = "missile silo"; in_or_at = " at "; from = "in silo"; } else { base = in_or_at = ""; from = "on launch pad"; } } mpr(pp->pln_own, "\tLaunching from %s%s%s\n", base, in_or_at, xyas(pp->pln_x, pp->pln_y, pp->pln_own)); CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED); pp->pln_flags |= PLN_LAUNCHED; putplane(pp->pln_uid, pp); if (chance((0.05 + (100 - pp->pln_effic) / 100.0) * (1 - techfact(pp->pln_tech, 1.0)))) { mpr(pp->pln_own, "KABOOOOM! Missile explodes %s!\n", from); if (getnuke(nuk_on_plane(pp), &nuke)) { mpr(pp->pln_own, "%s lost!\n", prnuke(&nuke)); nuke.nuk_effic = 0; putnuke(nuke.nuk_uid, &nuke); } #if 0 /* * Disabled for now, because it breaks callers that call * msl_launch() for each member of a list of planes, created * by msl_sel() or perform_mission(). Damage to the base can * damage other planes. Any copies of them in the list become * stale. When msl_launch() modifies and writes back such a * stale copy, the damage gets wiped out, triggering a seqno * oops. */ if (chance(0.33)) { struct sctstr sect; int dam; dam = pln_damage(pp, 'p', NULL) / 2; if (pp->pln_ship >= 0) { shipdamage(&ship, dam); putship(ship.shp_uid, &ship); } else { mpr(pp->pln_own, "Explosion damages %s %d%%\n", xyas(pp->pln_x, pp->pln_y, pp->pln_own), dam); getsect(pp->pln_x, pp->pln_y, §); sectdamage(§, dam); putsect(§); } } #endif return -1; } mpr(pp->pln_own, "\tSHWOOOOOSH! Missile launched!\n"); if (type != EF_PLANE) mpr(victim, "Incoming %s missile sighted at %s...\n", sublaunch ? "sub-launched" : cname(pp->pln_own), xyas(x, y, victim)); if (type == EF_SECTOR || type == EF_LAND) { if (msl_abm_intercept(pp, x, y, sublaunch)) return -1; } if (type == EF_SHIP) { if (shp_missile_defense(x, y, pp->pln_own, pln_def(pp))) { return -1; } } if (sublaunchp) *sublaunchp = sublaunch; return 0; }