switch source tree from k&r to c99
This commit is contained in:
139
src/mthrowu.c
139
src/mthrowu.c
@@ -5,10 +5,10 @@
|
||||
|
||||
#include "hack.h"
|
||||
|
||||
static int FDECL(monmulti, (struct monst *, struct obj *, struct obj *));
|
||||
static void FDECL(monshoot, (struct monst *, struct obj *, struct obj *));
|
||||
static int FDECL(drop_throw, (struct obj *, BOOLEAN_P, int, int));
|
||||
static int FDECL(m_lined_up, (struct monst *, struct monst *));
|
||||
static int monmulti(struct monst *, struct obj *, struct obj *);
|
||||
static void monshoot(struct monst *, struct obj *, struct obj *);
|
||||
static int drop_throw(struct obj *, boolean, int, int);
|
||||
static int m_lined_up(struct monst *, struct monst *);
|
||||
|
||||
#define URETREATING(x, y) \
|
||||
(distmin(u.ux, u.uy, x, y) > distmin(u.ux0, u.uy0, x, y))
|
||||
@@ -23,8 +23,7 @@ static NEARDATA const char *breathwep[] = {
|
||||
};
|
||||
|
||||
boolean
|
||||
m_has_launcher_and_ammo(mtmp)
|
||||
struct monst *mtmp;
|
||||
m_has_launcher_and_ammo(struct monst* mtmp)
|
||||
{
|
||||
struct obj *mwep = MON_WEP(mtmp);
|
||||
|
||||
@@ -40,10 +39,11 @@ struct monst *mtmp;
|
||||
|
||||
/* hero is hit by something other than a monster */
|
||||
int
|
||||
thitu(tlev, dam, objp, name)
|
||||
int tlev, dam;
|
||||
struct obj **objp;
|
||||
const char *name; /* if null, then format `*objp' */
|
||||
thitu(
|
||||
int tlev,
|
||||
int dam,
|
||||
struct obj **objp,
|
||||
const char *name) /* if null, then format `*objp' */
|
||||
{
|
||||
struct obj *obj = objp ? *objp : 0;
|
||||
const char *onm, *knm;
|
||||
@@ -115,10 +115,11 @@ const char *name; /* if null, then format `*objp' */
|
||||
* Returns 0 if object still exists (not destroyed).
|
||||
*/
|
||||
static int
|
||||
drop_throw(obj, ohit, x, y)
|
||||
register struct obj *obj;
|
||||
boolean ohit;
|
||||
int x, y;
|
||||
drop_throw(
|
||||
register struct obj *obj,
|
||||
boolean ohit,
|
||||
int x,
|
||||
int y)
|
||||
{
|
||||
int retvalu = 1;
|
||||
int create;
|
||||
@@ -159,9 +160,7 @@ int x, y;
|
||||
/* calculate multishot volley count for mtmp throwing otmp (if not ammo) or
|
||||
shooting otmp with mwep (if otmp is ammo and mwep appropriate launcher) */
|
||||
static int
|
||||
monmulti(mtmp, otmp, mwep)
|
||||
struct monst *mtmp;
|
||||
struct obj *otmp, *mwep;
|
||||
monmulti(struct monst* mtmp, struct obj* otmp, struct obj* mwep)
|
||||
{
|
||||
int multishot = 1;
|
||||
|
||||
@@ -220,9 +219,7 @@ struct obj *otmp, *mwep;
|
||||
|
||||
/* mtmp throws otmp, or shoots otmp with mwep, at hero or at monster mtarg */
|
||||
static void
|
||||
monshoot(mtmp, otmp, mwep)
|
||||
struct monst *mtmp;
|
||||
struct obj *otmp, *mwep;
|
||||
monshoot(struct monst* mtmp, struct obj* otmp, struct obj* mwep)
|
||||
{
|
||||
struct monst *mtarg = g.mtarget;
|
||||
int dm = distmin(mtmp->mx, mtmp->my,
|
||||
@@ -279,13 +276,13 @@ struct obj *otmp, *mwep;
|
||||
/* an object launched by someone/thing other than player attacks a monster;
|
||||
return 1 if the object has stopped moving (hit or its range used up) */
|
||||
int
|
||||
ohitmon(mtmp, otmp, range, verbose)
|
||||
struct monst *mtmp; /* accidental target, located at <g.bhitpos.x,.y> */
|
||||
struct obj *otmp; /* missile; might be destroyed by drop_throw */
|
||||
int range; /* how much farther will object travel if it misses;
|
||||
use -1 to signify to keep going even after hit,
|
||||
unless it's gone (used for rolling_boulder_traps) */
|
||||
boolean verbose; /* give message(s) even when you can't see what happened */
|
||||
ohitmon(
|
||||
struct monst *mtmp, /* accidental target, located at <g.bhitpos.x,.y> */
|
||||
struct obj *otmp, /* missile; might be destroyed by drop_throw */
|
||||
int range, /* how much farther will object travel if it misses;
|
||||
use -1 to signify to keep going even after hit,
|
||||
unless it's gone (used for rolling_boulder_traps) */
|
||||
boolean verbose)/* give message(s) even when you can't see what happened */
|
||||
{
|
||||
int damage, tmp;
|
||||
boolean vis, ismimic;
|
||||
@@ -466,10 +463,14 @@ boolean verbose; /* give message(s) even when you can't see what happened */
|
||||
|| (!(pre) && IS_SINK(levl[g.bhitpos.x][g.bhitpos.y].typ)))
|
||||
|
||||
void
|
||||
m_throw(mon, x, y, dx, dy, range, obj)
|
||||
struct monst *mon; /* launching monster */
|
||||
int x, y, dx, dy, range; /* launch point, direction, and range */
|
||||
struct obj *obj; /* missile (or stack providing it) */
|
||||
m_throw(
|
||||
struct monst *mon, /* launching monster */
|
||||
int x,
|
||||
int y,
|
||||
int dx,
|
||||
int dy,
|
||||
int range, /* launch point, direction, and range */
|
||||
struct obj *obj) /* missile (or stack providing it) */
|
||||
{
|
||||
struct monst *mtmp;
|
||||
struct obj *singleobj;
|
||||
@@ -689,8 +690,7 @@ struct obj *obj; /* missile (or stack providing it) */
|
||||
|
||||
/* Monster throws item at another monster */
|
||||
int
|
||||
thrwmm(mtmp, mtarg)
|
||||
struct monst *mtmp, *mtarg;
|
||||
thrwmm(struct monst* mtmp, struct monst* mtarg)
|
||||
{
|
||||
struct obj *otmp, *mwep;
|
||||
register xchar x, y;
|
||||
@@ -737,9 +737,7 @@ struct monst *mtmp, *mtarg;
|
||||
|
||||
/* monster spits substance at monster */
|
||||
int
|
||||
spitmm(mtmp, mattk, mtarg)
|
||||
struct monst *mtmp, *mtarg;
|
||||
struct attack *mattk;
|
||||
spitmm(struct monst* mtmp, struct attack* mattk, struct monst* mtarg)
|
||||
{
|
||||
struct obj *otmp;
|
||||
|
||||
@@ -797,9 +795,7 @@ struct attack *mattk;
|
||||
|
||||
/* monster breathes at monster (ranged) */
|
||||
int
|
||||
breamm(mtmp, mattk, mtarg)
|
||||
struct monst *mtmp, *mtarg;
|
||||
struct attack *mattk;
|
||||
breamm(struct monst* mtmp, struct attack* mattk, struct monst* mtarg)
|
||||
{
|
||||
/* if new breath types are added, change AD_ACID to max type */
|
||||
int typ = (mattk->adtyp == AD_RBRE) ? rnd(AD_ACID) : mattk->adtyp ;
|
||||
@@ -850,9 +846,7 @@ struct attack *mattk;
|
||||
|
||||
/* remove an entire item from a monster's inventory; destroy that item */
|
||||
void
|
||||
m_useupall(mon, obj)
|
||||
struct monst *mon;
|
||||
struct obj *obj;
|
||||
m_useupall(struct monst* mon, struct obj* obj)
|
||||
{
|
||||
obj_extract_self(obj);
|
||||
if (obj->owornmask) {
|
||||
@@ -867,9 +861,7 @@ struct obj *obj;
|
||||
|
||||
/* remove one instance of an item from a monster's inventory */
|
||||
void
|
||||
m_useup(mon, obj)
|
||||
struct monst *mon;
|
||||
struct obj *obj;
|
||||
m_useup(struct monst* mon, struct obj* obj)
|
||||
{
|
||||
if (obj->quan > 1L) {
|
||||
obj->quan--;
|
||||
@@ -881,8 +873,7 @@ struct obj *obj;
|
||||
|
||||
/* monster attempts ranged weapon attack against player */
|
||||
void
|
||||
thrwmu(mtmp)
|
||||
struct monst *mtmp;
|
||||
thrwmu(struct monst* mtmp)
|
||||
{
|
||||
struct obj *otmp, *mwep;
|
||||
xchar x, y;
|
||||
@@ -950,18 +941,14 @@ struct monst *mtmp;
|
||||
|
||||
/* monster spits substance at you */
|
||||
int
|
||||
spitmu(mtmp, mattk)
|
||||
struct monst *mtmp;
|
||||
struct attack *mattk;
|
||||
spitmu(struct monst* mtmp, struct attack* mattk)
|
||||
{
|
||||
return spitmm(mtmp, mattk, &g.youmonst);
|
||||
}
|
||||
|
||||
/* monster breathes at you (ranged) */
|
||||
int
|
||||
breamu(mtmp, mattk)
|
||||
struct monst *mtmp;
|
||||
struct attack *mattk;
|
||||
breamu(struct monst* mtmp, struct attack* mattk)
|
||||
{
|
||||
return breamm(mtmp, mattk, &g.youmonst);
|
||||
}
|
||||
@@ -971,9 +958,12 @@ struct attack *mattk;
|
||||
Stops if fnc return TRUE, or if step was blocked by wall or closed door.
|
||||
Returns TRUE if fnc returned TRUE. */
|
||||
boolean
|
||||
linedup_callback(ax, ay, bx, by, fnc)
|
||||
xchar ax, ay, bx, by;
|
||||
boolean FDECL((*fnc), (int, int));
|
||||
linedup_callback(
|
||||
xchar ax,
|
||||
xchar ay,
|
||||
xchar bx,
|
||||
xchar by,
|
||||
boolean (*fnc)(int, int))
|
||||
{
|
||||
int dx, dy;
|
||||
|
||||
@@ -1004,9 +994,12 @@ boolean FDECL((*fnc), (int, int));
|
||||
}
|
||||
|
||||
boolean
|
||||
linedup(ax, ay, bx, by, boulderhandling)
|
||||
register xchar ax, ay, bx, by;
|
||||
int boulderhandling; /* 0=block, 1=ignore, 2=conditionally block */
|
||||
linedup(
|
||||
register xchar ax,
|
||||
register xchar ay,
|
||||
register xchar bx,
|
||||
register xchar by,
|
||||
int boulderhandling) /* 0=block, 1=ignore, 2=conditionally block */
|
||||
{
|
||||
int dx, dy, boulderspots;
|
||||
|
||||
@@ -1046,8 +1039,7 @@ int boulderhandling; /* 0=block, 1=ignore, 2=conditionally block */
|
||||
}
|
||||
|
||||
static int
|
||||
m_lined_up(mtarg, mtmp)
|
||||
struct monst *mtarg, *mtmp;
|
||||
m_lined_up(struct monst* mtarg, struct monst* mtmp)
|
||||
{
|
||||
boolean utarget = (mtarg == &g.youmonst);
|
||||
xchar tx = utarget ? mtmp->mux : mtarg->mx;
|
||||
@@ -1069,17 +1061,14 @@ struct monst *mtarg, *mtmp;
|
||||
|
||||
/* is mtmp in position to use ranged attack on hero? */
|
||||
boolean
|
||||
lined_up(mtmp)
|
||||
register struct monst *mtmp;
|
||||
lined_up(register struct monst* mtmp)
|
||||
{
|
||||
return m_lined_up(&g.youmonst, mtmp) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/* check if a monster is carrying a particular item */
|
||||
struct obj *
|
||||
m_carrying(mtmp, type)
|
||||
struct monst *mtmp;
|
||||
int type;
|
||||
m_carrying(struct monst* mtmp, int type)
|
||||
{
|
||||
register struct obj *otmp;
|
||||
|
||||
@@ -1090,10 +1079,10 @@ int type;
|
||||
}
|
||||
|
||||
void
|
||||
hit_bars(objp, objx, objy, barsx, barsy, your_fault, from_invent)
|
||||
struct obj **objp; /* *objp will be set to NULL if object breaks */
|
||||
int objx, objy, barsx, barsy;
|
||||
boolean your_fault, from_invent;
|
||||
hit_bars(
|
||||
struct obj **objp, /* *objp will be set to NULL if object breaks */
|
||||
int objx, int objy, int barsx, int barsy,
|
||||
boolean your_fault, boolean from_invent)
|
||||
{
|
||||
struct obj *otmp = *objp;
|
||||
int obj_type = otmp->otyp;
|
||||
@@ -1125,11 +1114,11 @@ boolean your_fault, from_invent;
|
||||
|
||||
/* TRUE iff thrown/kicked/rolled object doesn't pass through iron bars */
|
||||
boolean
|
||||
hits_bars(obj_p, x, y, barsx, barsy, always_hit, whodidit)
|
||||
struct obj **obj_p; /* *obj_p will be set to NULL if object breaks */
|
||||
int x, y, barsx, barsy;
|
||||
int always_hit; /* caller can force a hit for items which would fit through */
|
||||
int whodidit; /* 1==hero, 0=other, -1==just check whether it'll pass thru */
|
||||
hits_bars(
|
||||
struct obj **obj_p, /* *obj_p will be set to NULL if object breaks */
|
||||
int x, int y, int barsx, int barsy,
|
||||
int always_hit, /* caller can force a hit for items which would fit through */
|
||||
int whodidit) /* 1==hero, 0=other, -1==just check whether it'll pass thru */
|
||||
{
|
||||
struct obj *otmp = *obj_p;
|
||||
int obj_type = otmp->otyp;
|
||||
|
||||
Reference in New Issue
Block a user