Beispiel #1
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);
    }
}
Beispiel #2
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;
}
Beispiel #3
0
static void
planerepair(struct plnstr *pp, struct natstr *np, struct bp *bp, int etus)
{
    int build;
    int mvec[I_MAX + 1];
    struct shpstr *carrier;
    struct plchrstr *pcp = &plchr[(int)pp->pln_type];
    struct sctstr *sp = getsectp(pp->pln_x, pp->pln_y);
    int delta;
    int mult;
    int avail;
    int w_p_eff;
    int used;

    carrier = NULL;
    if (pp->pln_ship >= 0) {
	if (pp->pln_effic >= 80)
	    return;
	carrier = getshipp(pp->pln_ship);
	if (CANT_HAPPEN(!carrier))
	    return;
	if (carrier->shp_off)
	    return;
	if (relations_with(carrier->shp_own, pp->pln_own) != ALLIED)
	    return;
    } else {
	if (relations_with(sp->sct_own, pp->pln_own) != ALLIED)
	    return;
    }

    if (sp->sct_off)
	return;
    mult = 1;
    if (np->nat_level[NAT_TLEV] < pp->pln_tech * 0.85)
	mult = 2;

    if (pp->pln_effic == 100)
	return;

    if (!player->simulation)
	avail = sp->sct_avail * 100;
    else
	avail = bp_get_avail(bp, sp) * 100;
    if (carrier)
	avail += etus * carrier->shp_item[I_MILIT] / 2;

    w_p_eff = PLN_BLD_WORK(pcp->pl_lcm, pcp->pl_hcm);
    delta = roundavg((double)avail / w_p_eff);
    if (delta <= 0)
	return;
    if (delta > (int)((float)etus * plane_grow_scale))
	delta = (int)((float)etus * plane_grow_scale);
    if (delta > 100 - pp->pln_effic)
	delta = 100 - pp->pln_effic;

    memset(mvec, 0, sizeof(mvec));
    mvec[I_MILIT] = pcp->pl_crew;
    mvec[I_LCM] = pcp->pl_lcm;
    mvec[I_HCM] = pcp->pl_hcm;
    build = get_materials(sp, bp, mvec, delta);

    if (carrier)
	build = delta;

    used = build * w_p_eff;
    /*
     * I didn't use roundavg here, because I want to
     * penalize the player with a large number of planes.
     */
    if (!player->simulation)
	avail = (sp->sct_avail * 100 - used) / 100;
    else
	avail = (bp_get_avail(bp, sp) * 100 - used) / 100;

    if (avail < 0)
	avail = 0;
    if (!player->simulation)
	sp->sct_avail = avail;
    else
	bp_put_avail(bp, sp, avail);

    if (sp->sct_type != SCT_AIRPT)
	build /= 3;
    if (carrier) {
	if ((pp->pln_effic + build) > 80)
	    build = 80 - pp->pln_effic;
    }

    np->nat_money -= mult * build * pcp->pl_cost / 100.0;

    if (!player->simulation)
	pp->pln_effic += (signed char)build;
}
Beispiel #4
0
static void
look_ship(struct shpstr *lookship)
{
    struct shpstr *sp;
    struct mchrstr *smcp;
    struct mchrstr *tmcp;
    struct sctstr sect;
    int range;
    int vrange;
    int i;
    int dist;

    range = (int)techfact(lookship->shp_tech,
			  mchr[(int)lookship->shp_type].m_vrnge);
    range = range * (lookship->shp_effic / 100.0);
    smcp = &mchr[(int)lookship->shp_type];
    if (smcp->m_flags & M_SUB)
	range = MIN(range, 1);
    for (i = 0; NULL != (sp = getshipp(i)); i++) {
	if (sp->shp_own == player->cnum || sp->shp_own == 0)
	    continue;
	dist = mapdist(sp->shp_x, sp->shp_y,
		       lookship->shp_x, lookship->shp_y);
	if (dist > ship_max_interdiction_range)
	    continue;
	tmcp = &mchr[(int)sp->shp_type];
	if (smcp->m_flags & M_SUB)
	    vrange = (int)(shp_visib(sp) * range / 30.0);
	else
	    vrange = (int)(shp_visib(sp) * range / 20.0);
	getsect(sp->shp_x, sp->shp_y, &sect);
	if (sect.sct_type != SCT_WATER)
	    vrange = MAX(1, vrange);
	if (dist > vrange)
	    continue;
	if (smcp->m_flags & M_SUB) {
	    if (tmcp->m_flags & M_SONAR && dist < 2) {
		if (sp->shp_own != 0)
		    wu(0, sp->shp_own,
		       "%s detected surfacing noises in %s.\n",
		       prship(sp),
		       xyas(lookship->shp_x, lookship->shp_y,
			    sp->shp_own));
	    }
	    if (dist == 0 && (tmcp->m_flags & M_SUB) == 0)
		if (sp->shp_own != 0)
		    wu(0, sp->shp_own,
		       "Periscope spotted in %s by %s\n",
		       xyas(lookship->shp_x, lookship->shp_y,
			    sp->shp_own), prship(sp));
	}
	/* subs at sea only seen by sonar */
	if (tmcp->m_flags & M_SUB && sect.sct_type == SCT_WATER)
	    continue;
	pr("%s %s @ %s\n",
	   prnatid(sp->shp_own), prship(sp),
	   xyas(sp->shp_x, sp->shp_y, player->cnum));
	if (opt_HIDDEN)
	    setcont(player->cnum, sp->shp_own, FOUND_LOOK);
    }
}