Example #1
0
int
upd_slmilcosts(natid n, int etu)
{
    struct shpstr *sp;
    struct lndstr *lp;
    int mil = 0;
    int totalmil = 0;
    int mil_pay = 0;
    int i;

    for (i = 0; NULL != (sp = getshipp(i)); i++) {
	if (!sp->shp_own || sp->shp_own != n)
	    continue;
	if ((mil = sp->shp_item[I_MILIT]) > 0)
	    totalmil += mil;
    }
    for (i = 0; NULL != (lp = getlandp(i)); i++) {
	if (!lp->lnd_own || lp->lnd_own != n)
	    continue;
	if ((mil = lp->lnd_item[I_MILIT]) > 0)
	    totalmil += mil;
    }
    mil_pay = totalmil * etu * money_mil;
    return mil_pay;
}
Example #2
0
/*
 * Do fallout meltdown for sector SP.
 * ETUS above 24 are treated as 24 to avoid *huge* kill offs in
 * large ETU games.
 */
void
do_fallout(struct sctstr *sp, int etus)
{
    struct shpstr *spp;
    struct lndstr *lp;
    int i;

/* This check shouldn't be needed, but just in case. :) */
    if (!sp->sct_fallout || !sp->sct_updated)
	return;
    if (etus > 24)
	etus = 24;
    meltitems(etus, sp->sct_fallout, sp->sct_own, sp->sct_item,
	      EF_SECTOR, sp->sct_x, sp->sct_y, 0);
    for (i = 0; NULL != (lp = getlandp(i)); i++) {
	if (!lp->lnd_own)
	    continue;
	if (lp->lnd_x != sp->sct_x || lp->lnd_y != sp->sct_y)
	    continue;
	meltitems(etus, sp->sct_fallout, lp->lnd_own, lp->lnd_item,
		  EF_LAND, lp->lnd_x, lp->lnd_y, lp->lnd_uid);
    }
    for (i = 0; NULL != (spp = getshipp(i)); i++) {
	if (!spp->shp_own)
	    continue;
	if (spp->shp_x != sp->sct_x || spp->shp_y != sp->sct_y)
	    continue;
	if (mchr[(int)spp->shp_type].m_flags & M_SUB)
	    continue;
	meltitems(etus, sp->sct_fallout, spp->shp_own, spp->shp_item,
		  EF_SHIP, spp->shp_x, spp->shp_y, spp->shp_uid);
    }
}
Example #3
0
static int
verify_lands(int may_put)
{
    int retval = 0;
    int i;
    struct lndstr *lp;

    /* laziness: assumes land file is EFF_MEM */
    for (i = 0; (lp = getlandp(i)); i++) {
	if (lp->lnd_own) {
	    if (lp->lnd_ship >= 0 && lp->lnd_land >= 0) {
		verify_fail(EF_LAND, i, NULL, 0, "on two carriers");
		retval = -1;
	    }
	} else {
	    if (lp->lnd_ship >= 0 || lp->lnd_land >= 0) {
		lp->lnd_ship = lp->lnd_land = -1;
		if (may_put)
		    putland(i, lp);
		verify_fail(EF_LAND, i, NULL, 0,
			    "ghost stuck on carrier (fixed)");
	    }
	}
    }
    return retval;
}
Example #4
0
static void
look_land(struct lndstr *lookland)
{
    struct plnstr *pp;
    struct lndstr *lp;
    double drange;
    int range;
    int vrange;
    int i;
    int dist;

    drange = techfact(lookland->lnd_tech, lchr[lookland->lnd_type].l_spy);
    drange *= lookland->lnd_effic / 100.0;
    range = ldround(drange, 1);

    if (range == 0)
	return;

    for (i = 0; NULL != (lp = getlandp(i)); i++) {
	if (lp->lnd_own == player->cnum || lp->lnd_own == 0)
	    continue;
	if (lp->lnd_ship >= 0 || lp->lnd_land >= 0)
	    continue;
	/* Don't always see spies */
	if (lchr[(int)lp->lnd_type].l_flags & L_SPY) {
	    /* If it's on a ship or unit, assume it's hidden
	       enough not to be seen */
	    if (lp->lnd_ship >= 0 || lp->lnd_land >= 0)
		continue;
	    if (!(chance(LND_SPY_DETECT_CHANCE(lp->lnd_effic))))
		continue;
	}
	vrange = ldround((lnd_vis(lp) * range) / 20.0, 1);
	dist = mapdist(lp->lnd_x, lp->lnd_y,
		       lookland->lnd_x, lookland->lnd_y);
	if (dist > vrange)
	    continue;

	pr("%s %s (approx %d mil) @ %s\n",
	   prnatid(lp->lnd_own), prland(lp),
	   roundintby(lp->lnd_item[I_MILIT], 20),
	   xyas(lp->lnd_x, lp->lnd_y, player->cnum));
	if (opt_HIDDEN)
	    setcont(player->cnum, lp->lnd_own, FOUND_LOOK);
    }
    for (i = 0; NULL != (pp = getplanep(i)); i++) {
	if (pp->pln_own == player->cnum || pp->pln_own == 0)
	    continue;
	if (pp->pln_ship >= 0 || pp->pln_land >= 0)
	    continue;
	if (pp->pln_flags & PLN_LAUNCHED)
	    continue;
	vrange = ldround((10 * range) / 20.0, 1);
	dist = mapdist(pp->pln_x, pp->pln_y,
		       lookland->lnd_x, lookland->lnd_y);
	if (dist > vrange)
	    continue;

	pr("%s %s @ %s\n",
	   prnatid(pp->pln_own), prplane(pp),
	   xyas(pp->pln_x, pp->pln_y, player->cnum));
	if (opt_HIDDEN)
	    setcont(player->cnum, pp->pln_own, FOUND_LOOK);
    }
}