X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/56b3b679266d099eba0ac4e8282b239c652357c3..HEAD:/phantasia/fight.c diff --git a/phantasia/fight.c b/phantasia/fight.c index f23c37a5..5d0508e8 100644 --- a/phantasia/fight.c +++ b/phantasia/fight.c @@ -1,27 +1,44 @@ -/* $NetBSD: fight.c,v 1.5 1999/09/08 21:57:18 jsm Exp $ */ +/* $NetBSD: fight.c,v 1.15 2021/05/02 12:50:46 rillig Exp $ */ /* * fight.c Phantasia monster fighting routines */ -#include "include.h" +#include +#include +#include +#include + +#include "macros.h" +#include "phantdefs.h" +#include "phantstruct.h" +#include "phantglobs.h" + +#undef bool +#include + +static void awardtreasure(void); +static void callmonster(int); +static void cancelmonster(void); +static void cursedtreasure(void); +static void hitmonster(double); +static void monsthits(void); +static int pickmonster(void); +static void playerhits(void); +static void scramblestats(void); +static void throwspell(void); void -encounter(particular) - int particular; +encounter(int particular) { - bool firsthit = Player.p_blessing; /* set if player gets the - * first hit */ - int flockcnt = 1; /* how many time flocked */ + volatile bool firsthit = Player.p_blessing; /* set if player gets + * the first hit */ + volatile int flockcnt = 1; /* how many time flocked */ /* let others know what we are doing */ Player.p_status = S_MONSTER; writerecord(&Player, Fileloc); -#if __GNUC__ - (void)&firsthit; /* XXX shut up gcc */ -#endif - #ifdef SYS5 flushinp(); #endif @@ -155,8 +172,8 @@ encounter(particular) clrtobot(); } -int -pickmonster() +static int +pickmonster(void) { if (Player.p_specialtype == SC_VALAR) /* even chance of any monster */ @@ -195,8 +212,8 @@ pickmonster() return ((int) ROLL(14.0, 25.0)); } -void -playerhits() +static void +playerhits(void) { double inflict; /* damage inflicted */ int ch; /* input */ @@ -338,8 +355,8 @@ playerhits() } -void -monsthits() +static void +monsthits(void) { double inflict; /* damage inflicted */ int ch; /* input */ @@ -396,7 +413,7 @@ monsthits() /* takes some of the player's strength */ inflict = ROLL(1.0, (Circle - 1.0) / 2.0); inflict = MIN(Player.p_strength, inflict); - mvprintw(Lines++, 0, "%s sapped %0.f of your strength!", + mvprintw(Lines++, 0, "%s sapped %.0f of your strength!", Enemyname, inflict); Player.p_strength -= inflict; Player.p_might -= inflict; @@ -549,7 +566,7 @@ monsthits() mvprintw(Lines++, 0, "%s flew away, and left you to contend with one of its friends.", Enemyname); - Whichmonster = 55 + (drandom() > 0.5) ? 22 : 0; + Whichmonster = 55 + ((drandom() > 0.5) ? 22 : 0); longjmp(Fightenv, 0); /* NOTREACHED */ @@ -588,8 +605,8 @@ SPECIALHIT: } } -void -cancelmonster() +static void +cancelmonster(void) { Curmonster.m_energy = 0.0; Curmonster.m_experience = 0.0; @@ -597,9 +614,8 @@ cancelmonster() Curmonster.m_flock = 0.0; } -void -hitmonster(inflict) - double inflict; +static void +hitmonster(double inflict) { mvprintw(Lines++, 0, "You hit %s %.0f times!", Enemyname, inflict); Curmonster.m_energy -= inflict; @@ -625,8 +641,8 @@ hitmonster(inflict) } } -void -throwspell() +static void +throwspell(void) { double inflict; /* damage inflicted */ double dtemp; /* for dtemporary calculations */ @@ -835,9 +851,8 @@ throwspell() } } -void -callmonster(which) - int which; +static void +callmonster(int which) { struct monster Othermonster; /* to find a name for mimics */ @@ -869,7 +884,7 @@ callmonster(which) Curmonster.m_energy = Player.p_might * 30.0; Curmonster.m_type = SM_MORGOTH; Curmonster.m_speed = Player.p_speed * 1.1 - + (Player.p_specialtype == SC_EXVALAR) ? Player.p_speed : 0.0; + + ((Player.p_specialtype == SC_EXVALAR) ? Player.p_speed : 0.0); Curmonster.m_flock = 0.0; Curmonster.m_treasuretype = 0; Curmonster.m_experience = 0.0; @@ -913,8 +928,8 @@ callmonster(which) Curmonster.m_melee = Curmonster.m_skirmish = 0.0; } -void -awardtreasure() +static void +awardtreasure(void) { int whichtreasure; /* calculated treasure to grant */ int temp; /* temporary */ @@ -1257,7 +1272,7 @@ awardtreasure() * l * a * r - * + * * ri * n * g @@ -1275,7 +1290,7 @@ awardtreasure() /* b * a * d - * + * * ri * n * g @@ -1301,6 +1316,7 @@ awardtreasure() /* fall through to treasure type 9 if * no treasure from above */ + /* FALLTHROUGH */ case 9: /* treasure type 9 */ switch (whichtreasure) { case 1: @@ -1311,8 +1327,8 @@ awardtreasure() ++Player.p_crowns; break; } - /* fall through otherwise */ + /* FALLTHROUGH */ case 2: addstr("You've been blessed!\n"); Player.p_blessing = TRUE; @@ -1337,8 +1353,8 @@ awardtreasure() } } -void -cursedtreasure() +static void +cursedtreasure(void) { if (Player.p_charms > 0) { addstr("But your charm saved you!\n"); @@ -1354,8 +1370,8 @@ cursedtreasure() } } -void -scramblestats() +static void +scramblestats(void) { double dbuf[6]; /* to put statistic in */ double dtemp1, dtemp2; /* for swapping values */