/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2010, Dave Pare, Jeff Bailey, Thomas Ruschak,
- * Ken Stevens, Steve McClure
+ * Copyright (C) 1986-2015, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Ken Stevens, Steve McClure, Markus Armbruster
*
- * This program is free software; you can redistribute it and/or modify
+ * Empire is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* ---
*
* Dave Pare, 1986
* Ken Stevens, 1995
* Steve McClure, 1998-2000
- * Markus Armbruster, 2005-2009
+ * Markus Armbruster, 2005-2015
*/
#include <config.h>
+#include "chance.h"
#include "commands.h"
#include "damage.h"
#include "mission.h"
#include "nuke.h"
#include "optlist.h"
#include "path.h"
+#include "plague.h"
#include "plane.h"
#include "ship.h"
struct plnstr plane;
cp = getstarg(player->argp[2], "Target satellite? ", buf);
- if (!check_plane_ok(pp))
- return RET_FAIL;
if (!cp || !*cp)
return RET_SYN;
+ if (!check_plane_ok(pp))
+ return RET_FAIL;
if (!getplane(atoi(cp), &plane) || !plane.pln_own
|| !pln_is_in_orbit(&plane)) {
pr("No such satellite exists!\n");
struct mchrstr *mcp;
struct shpstr target_ship;
struct sctstr sect;
- int rel;
- struct natstr *natp;
struct nukstr nuke;
char buf[1024];
return RET_FAIL;
}
n = atoi(cp);
- if ((n < 0) || !getship(n, &target_ship) ||
- !target_ship.shp_own) {
+ if ((n < 0) || !getship(n, &target_ship) || !target_ship.shp_own) {
pr("Bad ship number!\n");
return RET_FAIL;
}
if (msl_equip(pp, 's') < 0)
return RET_FAIL;
getsect(sx, sy, §);
- if (opt_SLOW_WAR) {
- natp = getnatp(player->cnum);
- rel = getrel(natp, sect.sct_own);
- if ((rel != AT_WAR) && (sect.sct_own != player->cnum) &&
- (sect.sct_own) && (sect.sct_oldown != player->cnum)) {
- pr("You are not at war with the player->owner of the target sector!\n");
- pr_beep();
- pr("Kaboom!!!\n");
- pr("Missile monitoring officer destroys RV before detonation.\n");
- return RET_OK;
- }
- }
if (msl_launch(pp, EF_SECTOR, "sector", sx, sy, sect.sct_own,
&sublaunch) < 0)
return RET_OK;
if (getnuke(nuk_on_plane(pp), &nuke))
detonate(&nuke, sx, sy, pp->pln_flags & PLN_AIRBURST);
else {
- dam = pln_damage(pp, 's', 1);
+ dam = pln_damage(pp, 's', "");
pr("did %d damage in %s\n", PERCENT_DAMAGE(dam),
xyas(sx, sy, player->cnum));
if (sect.sct_own != 0) {
N_SHP_MISS, N_SHP_SMISS, sublaunch,
target_ship.shp_own)) {
pr("splash\n");
- dam = pln_damage(pp, 'p', 0);
+ dam = pln_damage(pp, 'p', NULL);
collateral_damage(target_ship.shp_x, target_ship.shp_y, dam);
return RET_OK;
}
- dam = pln_damage(pp, 'p', 1);
- check_retreat_and_do_shipdamage(&target_ship, dam);
- putship(target_ship.shp_uid, &target_ship);
- getship(target_ship.shp_uid, &target_ship);
- if (!target_ship.shp_own)
+ dam = pln_damage(pp, 'p', "");
+ shipdamage(&target_ship, dam);
+ if (target_ship.shp_effic < SHIP_MINEFF)
pr("%s sunk!\n", prship(&target_ship));
+ if (dam && (target_ship.shp_rflags & RET_INJURED))
+ retreat_ship(&target_ship, 'i');
+ putship(target_ship.shp_uid, &target_ship);
}
return RET_OK;
}
pr("\n");
cp = getstarg(player->argp[2], "Target sector? ", buf);
- if (!check_plane_ok(pp))
- return RET_FAIL;
if (!cp || !*cp)
return RET_SYN;
+ if (!check_plane_ok(pp))
+ return RET_FAIL;
if (!sarg_xy(cp, &sx, &sy)) {
pr("Bad sector designation!\n");
return RET_SYN;
}
i = pp->pln_tech + pp->pln_effic;
if (chance(1.0 - (i / (i + 50.0)))) {
- dir = (random() % 6) + 1;
+ dir = DIR_FIRST + roll0(6);
sx = xnorm(sx + diroff[dir][0]);
sy = ynorm(sy + diroff[dir][1]);
pr("Your trajectory was a little off.\n");
{
struct plist pl;
- memset(&pl, 0, sizeof(struct plist));
+ pl.load = 0;
+ pl.pstage = PLG_HEALTHY;
pl.pcp = plchr + pp->pln_type;
pl.plane = *pp;
+ emp_initque(&pl.queue);
return pln_equip(&pl, NULL, mission);
}