Exemple #1
0
void
pln_newlanding(struct emp_qelem *list, coord tx, coord ty, int cno)
{
    struct emp_qelem *qp;
    struct plist *plp;
    struct shpstr ship;
    struct sctstr sect;

    if (cno >= 0)
	getship(cno, &ship);
    for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
	plp = (struct plist *)qp;
	if (cno >= 0) {
	    if (!could_be_on_ship(&plp->plane, &ship))
		pr("\t%s cannot land on ship #%d! %s aborts!\n",
		   prplane(&plp->plane), cno, prplane(&plp->plane));
	    else if (!put_plane_on_ship(&plp->plane, &ship))
		pr("\tNo room on ship #%d! %s aborts!\n",
		   cno, prplane(&plp->plane));
	    else {
		if (plp->plane.pln_own != ship.shp_own) {
		    wu(0, ship.shp_own, "%s %s lands on your %s\n",
		       cname(player->cnum), prplane(&plp->plane),
		       prship(&ship));
		}
		if (plp->pcp->pl_crew && plp->pstage == PLG_INFECT
		    && ship.shp_pstage == PLG_HEALTHY)
		    ship.shp_pstage = PLG_EXPOSED;
	    }
	} else {
	    plp->plane.pln_x = tx;
	    plp->plane.pln_y = ty;
	    getsect(tx, ty, &sect);
	    if (plp->plane.pln_own != sect.sct_own) {
		wu(0, sect.sct_own,
		   "%s %s lands at your sector %s\n",
		   cname(player->cnum),
		   prplane(&plp->plane), xyas(tx, ty, sect.sct_own));
	    }
	    if (plp->pcp->pl_crew && plp->pstage == PLG_INFECT
		&& sect.sct_pstage == PLG_HEALTHY)
		sect.sct_pstage = PLG_EXPOSED;
	    plp->plane.pln_ship = cno;
	}
    }
}
Exemple #2
0
static int
load_plane_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
		int load_unload, int *nshipsp)
{
    struct nstr_item ni;
    struct plnstr pln;
    int loaded = 0;
    char buf[1024];
    char *p;
    char prompt[512];
    struct mchrstr *mcp = mchr + sp->shp_type;

    if (mcp->m_nplanes + mcp->m_nchoppers + mcp->m_nxlight == 0) {
	if (noisy)
	    pr("%s cannot carry planes\n", prship(sp));
	return 0;
    }
    if (load_unload == LOAD &&
	shp_nplane(sp, NULL, NULL, NULL)
		>= mcp->m_nchoppers + mcp->m_nxlight + mcp->m_nplanes) {
	if (noisy)
	    pr("%s doesn't have room for any more planes\n", prship(sp));
	return 0;
    }
    sprintf(prompt, "Plane(s) to %s %s? ",
	    load_unload == LOAD ? "load onto" : "unload from", prship(sp));
    p = getstarg(player->argp[3], prompt, buf);
    if (!p)
	return RET_SYN;
    if (!snxtitem(&ni, EF_PLANE, p, NULL))
	return RET_SYN;

    if (!still_ok_ship(sectp, sp))
	return RET_SYN;

    if (noisy && p && *p)
	noisy = isdigit(*p);

    while (nxtitem(&ni, &pln)) {
	if (!player->owner)
	    continue;
	if (!(plchr[(int)pln.pln_type].pl_flags & P_L)
	    && !(plchr[(int)pln.pln_type].pl_flags & P_E)
	    && !(plchr[(int)pln.pln_type].pl_flags & P_K)
	    && !(plchr[(int)pln.pln_type].pl_flags & P_M)
	    ) {
	    if (noisy)
		pr("You can only load light planes, helos, xtra-light, or missiles onto ships.\n");
	    continue;
	}
	if (load_unload == LOAD && pln.pln_ship > -1) {
	    if (noisy)
		pr("%s is already on ship #%d!\n",
		   prplane(&pln), pln.pln_ship);
	    continue;
	}
	if (load_unload == LOAD && pln.pln_land > -1) {
	    if (noisy)
		pr("%s is already on land unit #%d!\n",
		   prplane(&pln), pln.pln_land);
	    continue;
	}
	if (pln.pln_harden != 0) {
	    if (noisy)
		pr("%s has been hardened and can't be loaded\n",
		   prplane(&pln));
	    continue;
	}

	if (load_unload == UNLOAD) {
	    if (pln.pln_ship != sp->shp_uid)
		continue;
	} else if (sp->shp_x != pln.pln_x || sp->shp_y != pln.pln_y)
	    continue;

	if (!could_be_on_ship(&pln, sp)) {
	    if (noisy) {
		if (plchr[(int)pln.pln_type].pl_flags & P_K)
		    p = "choppers";
		else if (plchr[(int)pln.pln_type].pl_flags & P_E)
		    p = "extra light planes";
		else if (plchr[(int)pln.pln_type].pl_flags & P_M)
		    p = "missiles";
		else
		    p = "planes";
		pr("%s cannot carry %s.\n", prship(sp), p);
	    }
	    continue;
	}
	/* Fit plane on ship */
	if (load_unload == LOAD) {
	    if (!put_plane_on_ship(&pln, sp)) {
		if (noisy)
		    pr("Can't put plane %d on this ship!\n", pln.pln_uid);
		continue;
	    }
	    sprintf(buf, "loaded on your %s at %s",
		    prship(sp), xyas(sp->shp_x, sp->shp_y, sp->shp_own));
	    gift(sp->shp_own, player->cnum, &pln, buf);
	    putplane(pln.pln_uid, &pln);
	} else {
	    pln.pln_ship = -1;
	    sprintf(buf, "unloaded in your %s at %s",
		    dchr[sectp->sct_type].d_name,
		    xyas(sectp->sct_x, sectp->sct_y, sectp->sct_own));
	    gift(sectp->sct_own, player->cnum, &pln, buf);
	    putplane(pln.pln_uid, &pln);
	}
	pr("%s %s %s at %s.\n",
	   prplane(&pln),
	   (load_unload == UNLOAD) ?
	   "unloaded from" : "loaded onto",
	   prship(sp), xyas(sp->shp_x, sp->shp_y, player->cnum));
	loaded = 1;
    }
    *nshipsp += loaded;
    return 0;
}