Esempio n. 1
0
static void
fire_dchrg(struct shpstr *sp, struct shpstr *targ, int ntargets)
{
    int range, erange, dam;

    erange = roundrange(shp_fire_range(sp));
    range = mapdist(sp->shp_x, sp->shp_y, targ->shp_x, targ->shp_y);
    if (range > erange)
	return;

    if ((mchr[(int)targ->shp_type].m_flags & M_SUB) == 0) {
	/* Return fire to a torpedo boat */
	if (mchr[sp->shp_type].m_flags & M_SUB)
	    return;		/* sub deck gun can't return fire */
	dam = shp_fire(sp);
	putship(sp->shp_uid, sp);
	if (dam < 0)
	    return;
	if (ntargets > 2)
	    dam /= ntargets / 2;

	pr_beep();
	pr("Kaboom!!! Incoming shells!\n");
	if (sp->shp_own != 0)
	    wu(0, sp->shp_own,
	       "%s fired at %s\n", prship(sp), prship(targ));
	pr_beep();
	pr("BLAM! %d damage!\n", dam);
    } else {
	/* Return fire to a submarine */
	dam = shp_dchrg(sp);
	putship(sp->shp_uid, sp);
	if (dam < 0)
	    return;
	if (ntargets > 2)
	    dam /= ntargets / 2;

	pr("\nCAPTAIN!  !!Depth charges!!...\n");
	if (sp->shp_own != 0)
	    wu(0, sp->shp_own,
	       "%s depth charged %s\n", prship(sp), prsub(targ));
	pr("click...WHAM!  %d damage!\n", dam);
    }
    shipdamage(targ, dam);
    putship(targ->shp_uid, targ);
}
Esempio n. 2
0
int
check_lmines(coord x, coord y, double weight)
{
    struct sctstr sect;
    int dam = 0;

    getsect(x, y, &sect);
    if (SCT_LANDMINES(&sect) > 0 &&
	sect.sct_oldown != player->cnum &&
	chance(DMINE_LHITCHANCE(sect.sct_mines)) && chance(weight / 100.0)) {
	pr_beep();
	pr("Blammo! Landmines detected! in %s  ",
	   xyas(sect.sct_x, sect.sct_y, player->cnum));
	dam = roll(20);
	--sect.sct_mines;
	putsect(&sect);
	pr("%d damage sustained.\n", dam);
    }
    return dam;
}