2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23 * related information and legal notices. It is expected that any future
24 * projects/authors will amend these files as needed.
28 * lboard.c: Board an enemy land unit (heavily borrowing from boar.c)
30 * Known contributors to this file:
53 struct combat off[1]; /* boarding sector */
54 struct combat def[1]; /* defending land unit */
55 struct emp_qelem olist; /* boarding units */
56 struct emp_qelem dlist; /* defending units */
57 int ototal; /* total boarding strength */
58 int a_engineer = 0; /* boarder engineers are present */
59 int a_spy = 0; /* the best boarder scout */
65 att_combat_init(def, EF_LAND);
67 * Collect input from the boarder
70 /* What are we boarding? */
72 if (!(p = getstarg(player->argp[1], "Victim land unit #? ", buf)) ||
73 (def->lnd_uid = atoi(p)) < 0)
77 * Ask the boarder what sector they want to board with
80 /* Note: if we allow land units to board other land units, we need
81 * to make sure the code will allow that */
82 if (!(p = getstarg(player->argp[2], "Boarding party from? ", buf)))
85 att_combat_init(off, EF_SECTOR);
86 if (!sarg_xy(p, &off->x, &off->y))
88 getsect(off->x, off->y, §);
89 if (sect.sct_own != player->cnum) {
90 pr("You don't own %s!\n", xyas(off->x, off->y, player->cnum));
93 if (sect.sct_mobil <= 0) {
94 pr("You don't have any mobility in %s!\n",
95 xyas(off->x, off->y, player->cnum));
99 pr("You can only board land units from a sector.\n");
102 if (att_abort(A_LBOARD, off, def)) {
103 pr("Land unit boarding aborted\n");
107 /* Show what we're boarding */
112 /* Ask the player what he wants to board with */
114 att_ask_offense(A_LBOARD, off, def, &olist, &a_spy, &a_engineer);
115 if (att_abort(A_LBOARD, off, def)) {
116 pr("Land unit boarding aborted\n");
117 att_empty_attack(A_LBOARD, 0, def);
118 return att_free_lists(&olist, 0);
122 * Estimate the defense strength and give the player a chance to abort
125 ototal = att_estimate_defense(A_LBOARD, off, &olist, def, a_spy);
126 if (att_abort(A_LBOARD, off, def)) {
127 pr("Land unit boarding aborted\n");
128 att_empty_attack(A_LBOARD, 0, def);
129 return att_free_lists(&olist, 0);
133 * We have now got all the answers from the boarder. From this point
134 * forward, we can assume that this battle is the _only_ thing
135 * happening in the game.
138 /* Get the real defense */
140 att_get_defense(&olist, def, &dlist, a_spy, ototal);
143 * Death, carnage, and destruction.
146 if (!(att_fight(A_LBOARD, off, &olist, 1.0, def, &dlist, 1.0))) {
147 getland(def->lnd_uid, &land);
149 * What about retreat on RET_BOARDED? Well, land units can't
150 * move when the boarder is hostile, and retreating when he
151 * isn't is not useful.