projects
/
super-star-trek.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Clean up ugly FORTRANISH names.
[super-star-trek.git]
/
src
/
ai.c
diff --git
a/src/ai.c
b/src/ai.c
index 1ea8cfa288b329569b8a69a274067be432084ebc..4d9e7ccb8028b7ada14cd3b9549d037c19563da0 100644
(file)
--- a/
src/ai.c
+++ b/
src/ai.c
@@
-12,7
+12,8
@@
static bool tryexit(coord look, int ienm, int loccom, bool irun)
game.state.galaxy[iq.x][iq.y].supernova ||
game.state.galaxy[iq.x][iq.y].klingons > MAXKLQUAD-1)
return false; /* no can do -- neg energy, supernovae, or >MAXKLQUAD-1 Klingons */
game.state.galaxy[iq.x][iq.y].supernova ||
game.state.galaxy[iq.x][iq.y].klingons > MAXKLQUAD-1)
return false; /* no can do -- neg energy, supernovae, or >MAXKLQUAD-1 Klingons */
- if (ienm == IHR) return false; /* Romulans cannot escape! */
+ if (ienm == IHR)
+ return false; /* Romulans cannot escape! */
if (!irun) {
/* avoid intruding on another commander's territory */
if (ienm == IHC) {
if (!irun) {
/* avoid intruding on another commander's territory */
if (ienm == IHC) {
@@
-134,7
+135,8
@@
static void movebaddy(coord com, int loccom, feature ienm)
*/
forces = game.kpower[loccom]+100.0*game.nenhere+400*(nbaddys-1);
*/
forces = game.kpower[loccom]+100.0*game.nenhere+400*(nbaddys-1);
- if (!game.shldup) forces += 1000; /* Good for enemy if shield is down! */
+ if (!game.shldup)
+ forces += 1000; /* Good for enemy if shield is down! */
if (!damaged(DPHASER) || !damaged(DPHOTON)) {
if (damaged(DPHASER)) /* phasers damaged */
forces += 300.0;
if (!damaged(DPHASER) || !damaged(DPHOTON)) {
if (damaged(DPHASER)) /* phasers damaged */
forces += 300.0;
@@
-169,9
+171,12
@@
static void movebaddy(coord com, int loccom, feature ienm)
}
/* calculate preferred number of steps */
nsteps = motion < 0 ? -motion : motion;
}
/* calculate preferred number of steps */
nsteps = motion < 0 ? -motion : motion;
- if (motion > 0 && nsteps > mdist) nsteps = mdist; /* don't overshoot */
- if (nsteps > QUADSIZE) nsteps = QUADSIZE; /* This shouldn't be necessary */
- if (nsteps < 1) nsteps = 1; /* This shouldn't be necessary */
+ if (motion > 0 && nsteps > mdist)
+ nsteps = mdist; /* don't overshoot */
+ if (nsteps > QUADSIZE)
+ nsteps = QUADSIZE; /* This shouldn't be necessary */
+ if (nsteps < 1)
+ nsteps = 1; /* This shouldn't be necessary */
if (idebug) {
proutn("NSTEPS = %d:", nsteps);
}
if (idebug) {
proutn("NSTEPS = %d:", nsteps);
}
@@
-268,7
+273,7
@@
static void movebaddy(coord com, int loccom, feature ienm)
}
void moveklings(void)
}
void moveklings(void)
-/*
move a commander
*/
+/*
Klingon tactical movement
*/
{
coord w;
int i;
{
coord w;
int i;
@@
-304,10
+309,10
@@
void moveklings(void)
movebaddy(w, i, game.quad[w.x][w.y]);
}
movebaddy(w, i, game.quad[w.x][w.y]);
}
- sortkl();
+ sortkl
ings
();
}
}
-static bool movescom(coord iq, bool flag
, bool *ipage
)
+static bool movescom(coord iq, bool flag)
/* commander movement helper */
{
int i;
/* commander movement helper */
{
int i;
@@
-347,7
+352,7
@@
static bool movescom(coord iq, bool flag, bool *ipage)
game.nenhere--;
if (game.condition!=docked)
newcnd();
game.nenhere--;
if (game.condition!=docked)
newcnd();
- sortkl();
+ sortkl
ings
();
}
/* check for a helpful planet */
for (i = 0; i < game.inplan; i++) {
}
/* check for a helpful planet */
for (i = 0; i < game.inplan; i++) {
@@
-357,9
+362,7
@@
static bool movescom(coord iq, bool flag, bool *ipage)
DESTROY(&game.state.planets[i]);
game.state.galaxy[game.state.kscmdr.x][game.state.kscmdr.y].planet = NOPLANET;
if (!damaged(DRADIO) || game.condition == docked) {
DESTROY(&game.state.planets[i]);
game.state.galaxy[game.state.kscmdr.x][game.state.kscmdr.y].planet = NOPLANET;
if (!damaged(DRADIO) || game.condition == docked) {
- if (!*ipage)
- pause_game(true);
- *ipage = true;
+ pause_game(true);
prout(_("Lt. Uhura- \"Captain, Starfleet Intelligence reports"));
proutn(_(" a planet in "));
proutn(cramlc(quadrant, game.state.kscmdr));
prout(_("Lt. Uhura- \"Captain, Starfleet Intelligence reports"));
proutn(_(" a planet in "));
proutn(cramlc(quadrant, game.state.kscmdr));
@@
-372,7
+375,7
@@
static bool movescom(coord iq, bool flag, bool *ipage)
return false; /* looks good! */
}
return false; /* looks good! */
}
-void s
com(bool *ipage
)
+void s
upercommander(void
)
/* move the Super Commander */
{
int i, i2, j, ideltax, ideltay, ifindit, iwhichb;
/* move the Super Commander */
{
int i, i2, j, ideltax, ideltay, ifindit, iwhichb;
@@
-382,7
+385,7
@@
void scom(bool *ipage)
bool flag;
if (idebug)
bool flag;
if (idebug)
- prout("== S
COM
");
+ prout("== S
UPERCOMMANDER
");
/* Decide on being active or passive */
flag = ((NKILLC+NKILLK)/(game.state.date+0.01-game.indate) < 0.1*game.skill*(game.skill+1.0) ||
/* Decide on being active or passive */
flag = ((NKILLC+NKILLK)/(game.state.date+0.01-game.indate) < 0.1*game.skill*(game.skill+1.0) ||
@@
-453,7
+456,8
@@
void scom(bool *ipage)
break;
}
}
break;
}
}
- if (ifindit==0) return; /* Nothing suitable -- wait until next time*/
+ if (ifindit==0)
+ return; /* Nothing suitable -- wait until next time*/
ibq = game.state.baseq[iwhichb];
/* decide how to move toward base */
ideltax = ibq.x - game.state.kscmdr.x;
ibq = game.state.baseq[iwhichb];
/* decide how to move toward base */
ideltax = ibq.x - game.state.kscmdr.x;
@@
-472,32
+476,32
@@
void scom(bool *ipage)
/* try moving in both x and y directions */
iq.x = game.state.kscmdr.x + ideltax;
iq.y = game.state.kscmdr.y + ideltax;
/* try moving in both x and y directions */
iq.x = game.state.kscmdr.x + ideltax;
iq.y = game.state.kscmdr.y + ideltax;
- if (movescom(iq, flag
, ipage
)) {
+ if (movescom(iq, flag)) {
/* failed -- try some other maneuvers */
if (ideltax==0 || ideltay==0) {
/* attempt angle move */
if (ideltax != 0) {
iq.y = game.state.kscmdr.y + 1;
/* failed -- try some other maneuvers */
if (ideltax==0 || ideltay==0) {
/* attempt angle move */
if (ideltax != 0) {
iq.y = game.state.kscmdr.y + 1;
- if (movescom(iq, flag
, ipage
)) {
+ if (movescom(iq, flag)) {
iq.y = game.state.kscmdr.y - 1;
iq.y = game.state.kscmdr.y - 1;
- movescom(iq, flag
, ipage
);
+ movescom(iq, flag);
}
}
else {
iq.x = game.state.kscmdr.x + 1;
}
}
else {
iq.x = game.state.kscmdr.x + 1;
- if (movescom(iq, flag
, ipage
)) {
+ if (movescom(iq, flag)) {
iq.x = game.state.kscmdr.x - 1;
iq.x = game.state.kscmdr.x - 1;
- movescom(iq, flag
, ipage
);
+ movescom(iq, flag);
}
}
}
else {
/* try moving just in x or y */
iq.y = game.state.kscmdr.y;
}
}
}
else {
/* try moving just in x or y */
iq.y = game.state.kscmdr.y;
- if (movescom(iq, flag
, ipage
)) {
+ if (movescom(iq, flag)) {
iq.y = game.state.kscmdr.y + ideltay;
iq.x = game.state.kscmdr.x;
iq.y = game.state.kscmdr.y + ideltay;
iq.x = game.state.kscmdr.x;
- movescom(iq, flag
, ipage
);
+ movescom(iq, flag);
}
}
}
}
}
}
@@
-509,7
+513,8
@@
void scom(bool *ipage)
ibq = game.state.baseq[i];
if (same(ibq, game.state.kscmdr) && same(game.state.kscmdr, game.battle)) {
/* attack the base */
ibq = game.state.baseq[i];
if (same(ibq, game.state.kscmdr) && same(game.state.kscmdr, game.battle)) {
/* attack the base */
- if (flag) return; /* no, don't attack base! */
+ if (flag)
+ return; /* no, don't attack base! */
game.iseenit = false;
game.isatb = 1;
schedule(FSCDBAS, 1.0 +2.0*Rand());
game.iseenit = false;
game.isatb = 1;
schedule(FSCDBAS, 1.0 +2.0*Rand());
@@
-518,9
+523,7
@@
void scom(bool *ipage)
if (damaged(DRADIO) && game.condition != docked)
return; /* no warning */
game.iseenit = true;
if (damaged(DRADIO) && game.condition != docked)
return; /* no warning */
game.iseenit = true;
- if (!*ipage)
- pause_game(true);
- *ipage = true;
+ pause_game(true);
proutn(_("Lt. Uhura- \"Captain, the starbase in "));
proutn(cramlc(quadrant, game.state.kscmdr));
skip(1);
proutn(_("Lt. Uhura- \"Captain, the starbase in "));
proutn(cramlc(quadrant, game.state.kscmdr));
skip(1);
@@
-544,9
+547,7
@@
void scom(bool *ipage)
(damaged(DRADIO) && game.condition != docked) ||
!game.state.galaxy[game.state.kscmdr.x][game.state.kscmdr.y].charted))
return;
(damaged(DRADIO) && game.condition != docked) ||
!game.state.galaxy[game.state.kscmdr.x][game.state.kscmdr.y].charted))
return;
- if (!*ipage)
- pause_game(true);
- *ipage = true;
+ pause_game(true);
prout(_("Lt. Uhura- \"Captain, Starfleet Intelligence reports"));
proutn(_(" the Super-commander is in "));
proutn(cramlc(quadrant, game.state.kscmdr));
prout(_("Lt. Uhura- \"Captain, Starfleet Intelligence reports"));
proutn(_(" the Super-commander is in "));
proutn(cramlc(quadrant, game.state.kscmdr));
@@
-554,11
+555,10
@@
void scom(bool *ipage)
return;
}
return;
}
-void movetho(void)
+void movetho
lian
(void)
/* move the Tholian */
{
int idx, idy, im, i;
/* move the Tholian */
{
int idx, idy, im, i;
- /* Move the Tholian */
if (!game.ithere || game.justin)
return;
if (!game.ithere || game.justin)
return;