xref: /original-bsd/games/sail/dr_4.c (revision 27393bdf)
1 /*
2  * Copyright (c) 1983, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)dr_4.c	8.2 (Berkeley) 04/28/95";
10 #endif /* not lint */
11 
12 #include "extern.h"
13 
14 ungrap(from, to)
15 register struct ship *from, *to;
16 {
17 	register k;
18 	char friend;
19 
20 	if ((k = grappled2(from, to)) == 0)
21 		return;
22 	friend = capship(from)->nationality == capship(to)->nationality;
23 	while (--k >= 0) {
24 		if (friend || die() < 3) {
25 			cleangrapple(from, to, 0);
26 			makesignal(from, "ungrappling %s (%c%c)", to);
27 		}
28 	}
29 }
30 
31 grap(from, to)
32 register struct ship *from, *to;
33 {
34 	if (capship(from)->nationality != capship(to)->nationality && die() > 2)
35 		return;
36 	Write(W_GRAP, from, 0, to->file->index, 0, 0, 0);
37 	Write(W_GRAP, to, 0, from->file->index, 0, 0, 0);
38 	makesignal(from, "grappled with %s (%c%c)", to);
39 }
40