mirror of
https://github.com/vattam/BSDGames.git
synced 2025-12-21 03:14:50 +00:00
copy in from cvs; cvs2svn fucked up big time
git-svn-id: file:///srv/svn/joey/trunk/src/packages/bsdgames@9775 a4a2c43b-8ac3-0310-8836-e0e880c912e2
This commit is contained in:
93
sail/dr_1.c
93
sail/dr_1.c
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: dr_1.c,v 1.7 1998/08/30 09:19:40 veego Exp $ */
|
||||
/* $NetBSD: dr_1.c,v 1.18 2001/02/05 01:10:08 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -38,15 +38,21 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)dr_1.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: dr_1.c,v 1.7 1998/08/30 09:19:40 veego Exp $");
|
||||
__RCSID("$NetBSD: dr_1.c,v 1.18 2001/02/05 01:10:08 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include "driver.h"
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "extern.h"
|
||||
#include "driver.h"
|
||||
|
||||
static int fightitout(struct ship *, struct ship *, int);
|
||||
|
||||
void
|
||||
unfoul()
|
||||
unfoul(void)
|
||||
{
|
||||
struct ship *sp;
|
||||
struct ship *to;
|
||||
@@ -62,14 +68,14 @@ unfoul()
|
||||
!is_toughmelee(sp, to, 0, 0))
|
||||
continue;
|
||||
for (i = fouled2(sp, to); --i >= 0;)
|
||||
if (die() <= 2)
|
||||
if (dieroll() <= 2)
|
||||
cleanfoul(sp, to, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
boardcomp()
|
||||
boardcomp(void)
|
||||
{
|
||||
int crew[3];
|
||||
struct ship *sp, *sq;
|
||||
@@ -133,10 +139,8 @@ boardcomp()
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
fightitout(from, to, key)
|
||||
struct ship *from, *to;
|
||||
int key;
|
||||
static int
|
||||
fightitout(struct ship *from, struct ship *to, int key)
|
||||
{
|
||||
struct ship *fromcap, *tocap;
|
||||
int crewfrom[3], crewto[3], menfrom, mento;
|
||||
@@ -173,12 +177,12 @@ int key;
|
||||
index = fromstrength/10;
|
||||
if (index > 8)
|
||||
index = 8;
|
||||
toinjured = MT[index][2 - die() / 3];
|
||||
toinjured = MT[index][2 - dieroll() / 3];
|
||||
totalto += toinjured;
|
||||
index = strengthto/10;
|
||||
if (index > 8)
|
||||
index = 8;
|
||||
frominjured = MT[index][2 - die() / 3];
|
||||
frominjured = MT[index][2 - dieroll() / 3];
|
||||
totalfrom += frominjured;
|
||||
menfrom -= frominjured;
|
||||
mento -= toinjured;
|
||||
@@ -187,21 +191,21 @@ int key;
|
||||
}
|
||||
if (fromstrength >= strengthto * 3 || count == 4) {
|
||||
unboard(to, from, 0);
|
||||
subtract(from, totalfrom, crewfrom, fromcap, pcfrom);
|
||||
subtract(to, totalto, crewto, tocap, pcto);
|
||||
subtract(from, fromcap, totalfrom, crewfrom, pcfrom);
|
||||
subtract(to, tocap, totalto, crewto, pcto);
|
||||
makemsg(from, "boarders from %s repelled", to->shipname);
|
||||
(void) sprintf(message, "killed in melee: %d. %s: %d",
|
||||
sprintf(message, "killed in melee: %d. %s: %d",
|
||||
totalto, from->shipname, totalfrom);
|
||||
Write(W_SIGNAL, to, 1, (long) message, 0, 0, 0);
|
||||
Writestr(W_SIGNAL, to, message);
|
||||
if (key)
|
||||
return 1;
|
||||
} else if (strengthto >= fromstrength * 3) {
|
||||
unboard(from, to, 0);
|
||||
subtract(from, totalfrom, crewfrom, fromcap, pcfrom);
|
||||
subtract(to, totalto, crewto, tocap, pcto);
|
||||
subtract(from, fromcap, totalfrom, crewfrom, pcfrom);
|
||||
subtract(to, tocap, totalto, crewto, pcto);
|
||||
if (key) {
|
||||
if (fromcap != from)
|
||||
Write(W_POINTS, fromcap, 0,
|
||||
Write(W_POINTS, fromcap,
|
||||
fromcap->file->points -
|
||||
from->file->struck
|
||||
? from->specs->pts
|
||||
@@ -212,22 +216,21 @@ int key;
|
||||
I guess that what is going on here is that the pointer is multiplied
|
||||
or something. */
|
||||
|
||||
Write(W_CAPTURED, from, 0, to->file->index, 0, 0, 0);
|
||||
Write(W_CAPTURED, from, to->file->index, 0, 0, 0);
|
||||
topoints = 2 * from->specs->pts + to->file->points;
|
||||
if (from->file->struck)
|
||||
topoints -= from->specs->pts;
|
||||
Write(W_POINTS, to, 0, topoints, 0, 0, 0);
|
||||
Write(W_POINTS, to, topoints, 0, 0, 0);
|
||||
mento = crewto[0] ? crewto[0] : crewto[1];
|
||||
if (mento) {
|
||||
subtract(to, mento, crewto, tocap, pcto);
|
||||
subtract(from, - mento, crewfrom, to, 0);
|
||||
subtract(to, tocap, mento, crewto, pcto);
|
||||
subtract(from, to, - mento, crewfrom, 0);
|
||||
}
|
||||
(void) sprintf(message, "captured by the %s!",
|
||||
to->shipname);
|
||||
Write(W_SIGNAL, from, 1, (long) message, 0, 0, 0);
|
||||
(void) sprintf(message, "killed in melee: %d. %s: %d",
|
||||
sprintf(message, "captured by the %s!", to->shipname);
|
||||
Writestr(W_SIGNAL, from, message);
|
||||
sprintf(message, "killed in melee: %d. %s: %d",
|
||||
totalto, from->shipname, totalfrom);
|
||||
Write(W_SIGNAL, to, 1, (long) message, 0, 0, 0);
|
||||
Writestr(W_SIGNAL, to, message);
|
||||
mento = 0;
|
||||
return 0;
|
||||
}
|
||||
@@ -236,7 +239,7 @@ int key;
|
||||
}
|
||||
|
||||
void
|
||||
resolve()
|
||||
resolve(void)
|
||||
{
|
||||
int thwart;
|
||||
struct ship *sp, *sq;
|
||||
@@ -246,7 +249,7 @@ resolve()
|
||||
continue;
|
||||
for (sq = sp + 1; sq < ls; sq++)
|
||||
if (sq->file->dir && meleeing(sp, sq) && meleeing(sq, sp))
|
||||
(void) fightitout(sp, sq, 0);
|
||||
fightitout(sp, sq, 0);
|
||||
thwart = 2;
|
||||
foreachship(sq) {
|
||||
if (sq->file->dir && meleeing(sq, sp))
|
||||
@@ -267,7 +270,7 @@ resolve()
|
||||
}
|
||||
|
||||
void
|
||||
compcombat()
|
||||
compcombat(void)
|
||||
{
|
||||
int n;
|
||||
struct ship *sp;
|
||||
@@ -392,14 +395,14 @@ compcombat()
|
||||
if (hit >= 0) {
|
||||
if (load != L_GRAPE)
|
||||
hit = hit > 10 ? 10 : hit;
|
||||
table(shootat, load, hit, closest, sp, die());
|
||||
table(sp, closest, shootat, load, hit, dieroll());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
next()
|
||||
next(void)
|
||||
{
|
||||
if (++turn % 55 == 0) {
|
||||
if (alive)
|
||||
@@ -421,12 +424,16 @@ next()
|
||||
}
|
||||
}
|
||||
if (best > 0.0) {
|
||||
char *p = getenv("WOTD");
|
||||
if (p == 0)
|
||||
char *tp = getenv("WOTD");
|
||||
const char *p;
|
||||
if (tp == 0)
|
||||
p = "Driver";
|
||||
if (islower(*p))
|
||||
*p = toupper(*p);
|
||||
(void) strncpy(bestship->file->captain, p,
|
||||
else {
|
||||
if (islower(*tp))
|
||||
*tp = toupper(*tp);
|
||||
p = tp;
|
||||
}
|
||||
strncpy(bestship->file->captain, p,
|
||||
sizeof bestship->file->captain);
|
||||
bestship->file->captain
|
||||
[sizeof bestship->file->captain - 1] = 0;
|
||||
@@ -434,9 +441,9 @@ next()
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
Write(W_TURN, SHIP(0), 0, turn, 0, 0, 0);
|
||||
if (turn % 7 == 0 && (die() >= cc->windchange || !windspeed)) {
|
||||
switch (die()) {
|
||||
Write(W_TURN, SHIP(0), turn, 0, 0, 0);
|
||||
if (turn % 7 == 0 && (dieroll() >= cc->windchange || !windspeed)) {
|
||||
switch (dieroll()) {
|
||||
case 1:
|
||||
winddir = 1;
|
||||
break;
|
||||
@@ -460,7 +467,7 @@ next()
|
||||
if (winddir < 1)
|
||||
winddir += 8;
|
||||
if (windspeed)
|
||||
switch (die()) {
|
||||
switch (dieroll()) {
|
||||
case 1:
|
||||
case 2:
|
||||
windspeed--;
|
||||
@@ -472,7 +479,7 @@ next()
|
||||
}
|
||||
else
|
||||
windspeed++;
|
||||
Write(W_WIND, SHIP(0), 0, winddir, windspeed, 0, 0);
|
||||
Write(W_WIND, SHIP(0), winddir, windspeed, 0, 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user