* Copyright (c) 1983 Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
static char sccsid
[] = "@(#)pl_3.c 5.3 (Berkeley) %G%";
int index
, rakehim
, sternrake
;
int hhits
= 0, ghits
= 0, rhits
= 0, chits
= 0;
int guns
, car
, ready
, shootat
, hit
;
for (n
= 0; n
< 3; n
++) {
men
+= mf
->OBP
[n
].mensent
;
for (n
= 0; n
< 3; n
++) {
men
+= mf
->DBP
[n
].mensent
;
crew
[0] = men
/100 ? 0 : crew
[0] != 0;
crew
[1] = (men
%100)/10 ? 0 : crew
[1] != 0;
crew
[2] = men
%10 ? 0 : crew
[2] != 0;
for (r
= 0; r
< 2; r
++) {
if (!guns
&& !car
|| load
== L_EMPTY
|| (ready
& R_LOADED
) == 0)
if (mf
->struck
|| !crew
[2])
closest
= closestenemy(ms
, (r
? 'r' : 'l'), 1);
if (closest
->file
->struck
)
target
= range(ms
, closest
);
if (target
> rangeofshot
[load
] || !guns
&& target
>= 3)
Signal("%s (%c%c) within range of %s broadside.",
closest
, r
? "right" : "left");
if (load
> L_CHAIN
&& target
< 6) {
switch (sgetch("Aim for hull or rigging? ",
Signal("'Avast there! Hold your fire.'",
if (sgetch("Fire? ", (struct ship
*)0, 1) == 'n') {
Signal("Belay that! Hold your fire.",
rakehim
= gunsbear(ms
, closest
) && !gunsbear(closest
, ms
);
temp
= portside(closest
, ms
, 1) - closest
->file
->dir
+ 1;
sternrake
= temp
> 4 && temp
< 6;
Signal("Raking the %s!", closest
);
Signal("Stern Rake! %s splintering!", closest
);
index
= index
> 8 ? 8 : index
;
hit
= HDT
[index
][target
-1];
hit
= HDTrake
[index
][target
-1];
if (rakehim
&& sternrake
)
hit
+= QUAL
[index
][mc
->qual
-1];
for (n
= 0; n
< 3 && mf
->captured
== 0; n
++)
hit
+= AMMO
[index
][load
- 1];
if (((temp
= mc
->class) >= 5 || temp
== 1) && windspeed
== 5)
if (windspeed
== 6 && temp
== 4)
if (windspeed
== 6 && temp
<= 3)
t
= &(shootat
== RIGGING
? RigTable
: HullTable
)
table(shootat
, load
, hit
, closest
, ms
, roll
);
Signal("Damage inflicted on the %s:",
(struct ship
*)0, closest
->shipname
);
Signal("\t%d HULL, %d GUNS, %d CREW, %d RIGGING",
(struct ship
*)0, hhits
, ghits
, chits
, rhits
);
Signal("Unable to fire %s broadside",
(struct ship
*)0, r
? "right" : "left");
register struct ship
*sp
;
if (sp
== ms
|| sp
->file
->dir
== 0)
if (range(ms
, sp
) > 1 && !grappled2(ms
, sp
))
switch (sgetch("Attempt to grapple or ungrapple %s (%c%c): ",
|| ms
->nationality
== capship(sp
)->nationality
) {
Write(W_GRAP
, ms
, 0, sp
->file
->index
, 0, 0, 0);
Write(W_GRAP
, sp
, 0, player
, 0, 0, 0);
Signal("Attempt succeeds!", (struct ship
*)0);
makesignal(ms
, "grappled with %s (%c%c)", sp
);
Signal("Attempt fails.", (struct ship
*)0);
for (i
= grappled2(ms
, sp
); --i
>= 0;) {
== capship(sp
)->nationality
Signal("Attempt succeeds!",
"ungrappling with %s (%c%c)",
register struct ship
*to
;
if (fouled2(ms
, to
) == 0)
if (sgetch("Attempt to unfoul with the %s (%c%c)? ", to
, 1) != 'y')
for (i
= fouled2(ms
, to
); --i
>= 0;) {
Signal("Attempt succeeds!", (struct ship
*)0);
makesignal(ms
, "Unfouling %s (%c%c)", to
);
Signal("Attempt fails.", (struct ship
*)0);