static char *sccsid
= "@(#)dr_1.c 1.9 83/10/31";
register struct ship
*sp
;
(void) signal(SIGINT
, SIG_IGN
);
(void) signal(SIGQUIT
, SIG_IGN
);
/* ;;; add code here to check the game number. */
ls
= &cc
->ship
[cc
->vessels
];
perror("driver: syncfile");
for (n
= 0; n
< NNATION
; n
++)
sp
->file
= (struct File
*) calloc(1, sizeof (struct File
));
(void) printf("driver: OUT OF MEMORY\n");
sp
->file
->loadL
= L_ROUND
;
sp
->file
->loadR
= L_ROUND
;
sp
->file
->readyR
= R_LOADED
|R_INITIAL
;
sp
->file
->readyL
= R_LOADED
|R_INITIAL
;
sp
->file
->stern
= nat
[sp
->nationality
]++;
sp
->file
->dir
= sp
->shipdir
;
sp
->file
->row
= sp
->shiprow
;
sp
->file
->col
= sp
->shipcol
;
windspeed
= cc
->windspeed
;
register struct ship
*sp
;
if (sp
->file
->captain
[0])
nat
= capship(sp
)->nationality
;
for (k
= 0; k
< NSHIP
; k
++) {
if (sp
->file
->fouls
[k
].turnfoul
== 0)
to
= sp
->file
->fouls
[k
].toship
;
if (nat
!= capship(to
)->nationality
)
if (!toughmelee(sp
, to
, 0, 0))
register struct ship
*sp
, *sq
;
if (!fouled(sp
) && !grappled(sp
))
if (sp
->file
->struck
|| sp
->file
->captured
!= 0)
crew
[0] = sp
->specs
->crew1
!= 0;
crew
[1] = sp
->specs
->crew2
!= 0;
crew
[2] = sp
->specs
->crew3
!= 0;
|| sp
->nationality
== capship(sq
)->nationality
)
switch (sp
->specs
->class - sq
->specs
->class) {
case -3: case -4: case -5:
sendbp(sp
, sq
, crew
[0]*100, 0);
sendbp(sp
, sq
, crew
[1]*10, 0);
if (crew
[0] || crew
[1]) {
sendbp(sp
, sq
, crew
[0]*100+crew
[1]*10,
sendbp(sp
, sq
, crew
[0]*100+crew
[1]*10,
case 2: case 3: case 4: case 5:
sendbp(sp
, sq
, crew
[0]*100+crew
[1]*10+crew
[2],
crew
[0] = crew
[1] = crew
[2] = 0;
fightitout(from
, to
, key
)
struct ship
*fromcap
, *tocap
;
int crewfrom
[3], crewto
[3], menfrom
, mento
;
int pcto
, pcfrom
, fromstrength
, strengthto
, frominjured
, toinjured
;
int index
, totalfrom
= 0, totalto
= 0;
menfrom
= mensent(from
, to
, crewfrom
, &fromcap
, &pcfrom
, key
);
mento
= mensent(to
, from
, crewto
, &tocap
, &pcto
, 0);
if (!menfrom
) { /* if crew surprised */
menfrom
= from
->specs
->crew1
menfrom
= from
->file
->pcrew
;
menfrom
*= 2; /* DBP's fight at an advantage */
fromstrength
= menfrom
* fromcap
->specs
->qual
;
strengthto
= mento
* tocap
->specs
->qual
;
(fromstrength
< strengthto
* 3 && strengthto
< fromstrength
* 3
|| fromstrength
== -1) && count
< 4;
toinjured
= MT
[index
][2 - die() / 3];
frominjured
= MT
[index
][2 - die() / 3];
totalfrom
+= frominjured
;
fromstrength
= menfrom
* fromcap
->specs
->qual
;
strengthto
= mento
* tocap
->specs
->qual
;
if (fromstrength
>= strengthto
* 3 || count
== 4) {
subtract(from
, totalfrom
, crewfrom
, fromcap
, pcfrom
);
subtract(to
, totalto
, crewto
, tocap
, pcto
);
makesignal(from
, "boarders from %s repelled", to
);
(void) sprintf(message
, "killed in melee: %d. %s: %d",
totalto
, from
->shipname
, totalfrom
);
Write(W_SIGNAL
, to
, 1, (int) message
, 0, 0, 0);
} else if (strengthto
>= fromstrength
* 3) {
subtract(from
, totalfrom
, crewfrom
, fromcap
, pcfrom
);
subtract(to
, totalto
, crewto
, tocap
, pcto
);
Write(W_POINTS
, fromcap
, 0,
/* ptr1 points to the shipspec for the ship that was just unboarded.
I guess that what is going on here is that the pointer is multiplied
Write(W_CAPTURED
, from
, 0, to
-SHIP(0), 0, 0, 0);
topoints
= 2 * from
->specs
->pts
+ to
->file
->points
;
topoints
-= from
->specs
->pts
;
Write(W_POINTS
, to
, 0, topoints
, 0, 0, 0);
mento
= crewto
[0] ? crewto
[0] : crewto
[1];
subtract(to
, mento
, crewto
, tocap
, pcto
);
subtract(from
, - mento
, crewfrom
, to
, 0);
(void) sprintf(message
, "captured by the %s!",
Write(W_SIGNAL
, from
, 1, (int) message
, 0, 0, 0);
(void) sprintf(message
, "killed in melee: %d. %s: %d",
totalto
, from
->shipname
, totalfrom
);
Write(W_SIGNAL
, to
, 1, (int) message
, 0, 0, 0);
register struct ship
*sp
, *sq
;
for (sq
= sp
+ 1; sq
< ls
; sq
++)
if (sq
->file
->dir
&& meleeing(sp
, sq
) && meleeing(sq
, sp
))
(void) fightitout(sp
, sq
, 0);
if (sq
->file
->dir
&& meleeing(sq
, sp
))
thwart
= fightitout(sp
, sq
, 1);
if (sq
->file
->dir
&& meleeing(sq
, sp
))
register struct ship
*sp
;
int crew
[3], men
= 0, target
, temp
;
int r
, guns
, ready
, load
, car
;
int index
, rakehim
, sternrake
;
if (sp
->file
->captain
[0] || sp
->file
->dir
== 0)
crew
[0] = sp
->specs
->crew1
;
crew
[1] = sp
->specs
->crew2
;
crew
[2] = sp
->specs
->crew3
;
for (n
= 0; n
< 3; n
++) {
if (sp
->file
->OBP
[n
].turnsent
)
men
+= sp
->file
->OBP
[n
].mensent
;
for (n
= 0; n
< 3; n
++) {
if (sp
->file
->DBP
[n
].turnsent
)
men
+= sp
->file
->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
++) {
ready
= sp
->file
->readyR
;
ready
= sp
->file
->readyL
;
if ((ready
& R_LOADED
) == 0)
closest
= closestenemy(sp
, r
? 'r' : 'l', 0);
if (range(closest
, sp
) > range(sp
, closestenemy(sp
, r
? 'r' : 'l', 1)))
if (closest
->file
->struck
)
target
= range(sp
, closest
);
if (!guns
&& target
>= 3)
if (target
== 1 && sp
->file
->loadwith
== L_GRAPE
)
if (target
<= 3 && closest
->file
->FS
)
if (target
== 1 && load
!= L_GRAPE
)
if (load
> L_CHAIN
&& target
< 6)
rakehim
= gunsbear(sp
, closest
)
&& !gunsbear(closest
, sp
);
temp
= portside(closest
, sp
, 1)
- closest
->file
->dir
+ 1;
sternrake
= temp
> 4 && temp
< 6;
index
= index
> 8 ? 8 : index
;
hit
= HDT
[index
][target
-1];
hit
= HDTrake
[index
][target
-1];
if (rakehim
&& sternrake
)
hit
+= QUAL
[index
][capship(sp
)->specs
->qual
- 1];
for (n
= 0; n
< 3 && sp
->file
->captured
== 0; n
++)
sp
->file
->readyL
&= ~R_INITIAL
;
sp
->file
->readyR
&= ~R_INITIAL
;
if (sp
->file
->captured
!= 0)
hit
+= AMMO
[index
][load
- 1];
if ((temp
>= 5 || temp
== 1) && windspeed
== 5)
if (windspeed
== 6 && temp
== 4)
if (windspeed
== 6 && temp
<= 3)
hit
= hit
> 10 ? 10 : hit
;
table(shootat
, load
, hit
, closest
, sp
, die());
if (people
<= 0 || windspeed
== 7) {
Write(W_TURN
, SHIP(0), 0, turn
, 0, 0, 0);
if (die() >= cc
->windchange
|| !windspeed
) {
Write(W_WIND
, SHIP(0), 0, winddir
, windspeed
, 0, 0);
Signal(fmt
, ship
, a
, b
, c
)