]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - sail/pl_3.c
1 /* $NetBSD: pl_3.c,v 1.3 1995/04/22 10:37:09 cgd Exp $ */
4 * Copyright (c) 1983, 1993
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 static char sccsid
[] = "@(#)pl_3.c 8.1 (Berkeley) 5/31/93";
40 static char rcsid
[] = "$NetBSD: pl_3.c,v 1.3 1995/04/22 10:37:09 cgd Exp $";
51 int index
, rakehim
, sternrake
;
52 int hhits
= 0, ghits
= 0, rhits
= 0, chits
= 0;
55 int guns
, car
, ready
, shootat
, hit
;
62 for (n
= 0; n
< 3; n
++) {
63 if (mf
->OBP
[n
].turnsent
)
64 men
+= mf
->OBP
[n
].mensent
;
66 for (n
= 0; n
< 3; n
++) {
67 if (mf
->DBP
[n
].turnsent
)
68 men
+= mf
->DBP
[n
].mensent
;
71 crew
[0] = men
/100 ? 0 : crew
[0] != 0;
72 crew
[1] = (men%100
)/10 ? 0 : crew
[1] != 0;
73 crew
[2] = men%10
? 0 : crew
[2] != 0;
75 for (r
= 0; r
< 2; r
++) {
87 if (!guns
&& !car
|| load
== L_EMPTY
|| (ready
& R_LOADED
) == 0)
89 if (mf
->struck
|| !crew
[2])
91 closest
= closestenemy(ms
, (r
? 'r' : 'l'), 1);
94 if (closest
->file
->struck
)
96 target
= range(ms
, closest
);
97 if (target
> rangeofshot
[load
] || !guns
&& target
>= 3)
99 Signal("%s (%c%c) within range of %s broadside.",
100 closest
, r
? "right" : "left");
101 if (load
> L_CHAIN
&& target
< 6) {
102 switch (sgetch("Aim for hull or rigging? ",
103 (struct ship
*)0, 1)) {
112 Signal("'Avast there! Hold your fire.'",
116 if (sgetch("Fire? ", (struct ship
*)0, 1) == 'n') {
118 Signal("Belay that! Hold your fire.",
126 rakehim
= gunsbear(ms
, closest
) && !gunsbear(closest
, ms
);
127 temp
= portside(closest
, ms
, 1) - closest
->file
->dir
+ 1;
132 sternrake
= temp
> 4 && temp
< 6;
135 Signal("Raking the %s!", closest
);
137 Signal("Stern Rake! %s splintering!", closest
);
141 index
= (index
- 1)/3;
142 index
= index
> 8 ? 8 : index
;
144 hit
= HDT
[index
][target
-1];
146 hit
= HDTrake
[index
][target
-1];
147 if (rakehim
&& sternrake
)
149 hit
+= QUAL
[index
][mc
->qual
-1];
150 for (n
= 0; n
< 3 && mf
->captured
== 0; n
++)
156 if (ready
& R_INITIAL
)
161 if (mf
->captured
!= 0)
166 hit
+= AMMO
[index
][load
- 1];
167 if (((temp
= mc
->class) >= 5 || temp
== 1) && windspeed
== 5)
169 if (windspeed
== 6 && temp
== 4)
171 if (windspeed
== 6 && temp
<= 3)
181 t
= &(shootat
== RIGGING
? RigTable
: HullTable
)
187 if (closest
->file
->FS
)
189 if (load
== L_CHAIN
) {
194 table(shootat
, load
, hit
, closest
, ms
, roll
);
196 Signal("Damage inflicted on the %s:",
197 (struct ship
*)0, closest
->shipname
);
198 Signal("\t%d HULL, %d GUNS, %d CREW, %d RIGGING",
199 (struct ship
*)0, hhits
, ghits
, chits
, rhits
);
202 mf
->readyL
= R_EMPTY
;
205 mf
->readyR
= R_EMPTY
;
209 Signal("Unable to fire %s broadside",
210 (struct ship
*)0, r
? "right" : "left");
219 register struct ship
*sp
;
223 if (sp
== ms
|| sp
->file
->dir
== 0)
225 if (range(ms
, sp
) > 1 && !grappled2(ms
, sp
))
227 switch (sgetch("Attempt to grapple or ungrapple %s (%c%c): ",
231 || ms
->nationality
== capship(sp
)->nationality
) {
232 Write(W_GRAP
, ms
, 0, sp
->file
->index
, 0, 0, 0);
233 Write(W_GRAP
, sp
, 0, player
, 0, 0, 0);
234 Signal("Attempt succeeds!", (struct ship
*)0);
235 makesignal(ms
, "grappled with %s (%c%c)", sp
);
237 Signal("Attempt fails.", (struct ship
*)0);
240 for (i
= grappled2(ms
, sp
); --i
>= 0;) {
242 == capship(sp
)->nationality
244 cleangrapple(ms
, sp
, 0);
245 Signal("Attempt succeeds!",
248 "ungrappling with %s (%c%c)",
251 Signal("Attempt fails.",
261 register struct ship
*to
;
265 if (fouled2(ms
, to
) == 0)
267 if (sgetch("Attempt to unfoul with the %s (%c%c)? ", to
, 1) != 'y')
269 for (i
= fouled2(ms
, to
); --i
>= 0;) {
271 cleanfoul(ms
, to
, 0);
272 Signal("Attempt succeeds!", (struct ship
*)0);
273 makesignal(ms
, "Unfouling %s (%c%c)", to
);
275 Signal("Attempt fails.", (struct ship
*)0);