Refuse to auto-scuttle where it doesn't pay
When called from the scuttle command, scuttle_tradeship() asks for confirmation when scuttling doesn't pay. When called from the autonav code, it can't ask. Change it to fail then, and use that in nav_ship() to avoid scuttle where it doesn't pay. Also simplify some.
This commit is contained in:
parent
693c1a64c3
commit
faca0eeac5
2 changed files with 20 additions and 26 deletions
|
@ -169,13 +169,8 @@ scuttle_tradeship(struct shpstr *sp, int interactive)
|
||||||
dist = mapdist(sp->shp_x, sp->shp_y,
|
dist = mapdist(sp->shp_x, sp->shp_y,
|
||||||
sp->shp_orig_x, sp->shp_orig_y);
|
sp->shp_orig_x, sp->shp_orig_y);
|
||||||
/* Don't disclose distance to to pirates */
|
/* Don't disclose distance to to pirates */
|
||||||
if (sp->shp_own == sp->shp_orig_own) {
|
if (sp->shp_own == sp->shp_orig_own)
|
||||||
if (interactive)
|
mpr(sp->shp_own, "%s has gone %d sects\n", prship(sp), dist);
|
||||||
pr("%s has gone %d sects\n", prship(sp), dist);
|
|
||||||
else
|
|
||||||
wu(0, sp->shp_own, "%s has gone %d sects\n",
|
|
||||||
prship(sp), dist);
|
|
||||||
}
|
|
||||||
if (dist < trade_1_dist)
|
if (dist < trade_1_dist)
|
||||||
cash = 0;
|
cash = 0;
|
||||||
else if (dist < trade_2_dist)
|
else if (dist < trade_2_dist)
|
||||||
|
@ -193,20 +188,23 @@ scuttle_tradeship(struct shpstr *sp, int interactive)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!interactive && cash) {
|
if (!cash && (dist < 0 || sp->shp_own == sp->shp_orig_own)) {
|
||||||
|
if (interactive) {
|
||||||
|
pr("You won't get any money if you scuttle in %s!",
|
||||||
|
xyas(sp->shp_x, sp->shp_y, player->cnum));
|
||||||
|
sprintf(buf, "Are you sure you want to scuttle %s? ", prship(sp));
|
||||||
|
return confirm(buf);
|
||||||
|
} else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (interactive) {
|
||||||
|
player->dolcost -= cash;
|
||||||
|
} else {
|
||||||
natp = getnatp(sp->shp_own);
|
natp = getnatp(sp->shp_own);
|
||||||
natp->nat_money += cash;
|
natp->nat_money += cash;
|
||||||
putnat(natp);
|
putnat(natp);
|
||||||
wu(0, sp->shp_own, "You just made $%d.\n", (int)cash);
|
wu(0, sp->shp_own, "You just made $%d.\n", (int)cash);
|
||||||
} else if (!cash && !interactive) {
|
|
||||||
wu(0, sp->shp_own, "Unfortunately, you make $0 on this trade.\n");
|
|
||||||
} else if (cash && interactive) {
|
|
||||||
player->dolcost -= cash;
|
|
||||||
} else if (interactive && (dist < 0 || sp->shp_own == sp->shp_orig_own)) {
|
|
||||||
pr("You won't get any money if you scuttle in %s!",
|
|
||||||
xyas(sp->shp_x, sp->shp_y, player->cnum));
|
|
||||||
sprintf(buf, "Are you sure you want to scuttle %s? ", prship(sp));
|
|
||||||
return confirm(buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ally_cash) {
|
if (ally_cash) {
|
||||||
|
|
|
@ -53,23 +53,19 @@ scuttle_it(struct shpstr *sp)
|
||||||
sp->shp_x, sp->shp_y, sp->shp_uid);
|
sp->shp_x, sp->shp_y, sp->shp_uid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (sectp->sct_type != SCT_HARBR || sectp->sct_effic < 2) {
|
|
||||||
wu(0, sp->shp_own,
|
|
||||||
"%s is not in a harbor at least 2%% eff! Not scuttling.\n",
|
|
||||||
prship(sp));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (opt_TRADESHIPS) {
|
if (opt_TRADESHIPS) {
|
||||||
if (!(mchr[(int)sp->shp_type].m_flags & M_TRADE)) {
|
if (!(mchr[(int)sp->shp_type].m_flags & M_TRADE)) {
|
||||||
wu(0, sp->shp_own, "You can only autoscuttle trade ships!\n");
|
wu(0, sp->shp_own, "You can only autoscuttle trade ships!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!scuttle_tradeship(sp, 0)) {
|
||||||
|
wu(0, sp->shp_own,
|
||||||
|
"%s doesn't pay here! Not scuttled.\n", prship(sp));
|
||||||
|
return;
|
||||||
|
}
|
||||||
wu(0, sp->shp_own, "Scuttling %s in sector %s\n",
|
wu(0, sp->shp_own, "Scuttling %s in sector %s\n",
|
||||||
prship(sp), xyas(sp->shp_x, sp->shp_y, sp->shp_own));
|
prship(sp), xyas(sp->shp_x, sp->shp_y, sp->shp_own));
|
||||||
if (opt_TRADESHIPS) {
|
|
||||||
scuttle_tradeship(sp, 0);
|
|
||||||
}
|
|
||||||
scuttle_ship(sp);
|
scuttle_ship(sp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue