Compare commits

..

1 Commits

Author SHA1 Message Date
kongju 04751c9b09 cyq
2 years ago

@ -17,7 +17,7 @@ NEARDATA const struct c_color_names c_color_names = {
"black", "amber", "golden", "light blue", "red", "green", "black", "amber", "golden", "light blue", "red", "green",
"silver", "blue", "purple", "white", "orange" "silver", "blue", "purple", "white", "orange"
}; };
const char *c_obj_colors[] = { const char *c_obj_colors[] = { //这里定义了一些物品的颜色
"black", /* CLR_BLACK */ "black", /* CLR_BLACK */
"red", /* CLR_RED */ "red", /* CLR_RED */
"green", /* CLR_GREEN */ "green", /* CLR_GREEN */
@ -36,8 +36,8 @@ const char *c_obj_colors[] = {
"white", /* CLR_WHITE */ "white", /* CLR_WHITE */
}; };
const struct c_common_strings c_common_strings = const struct c_common_strings c_common_strings = //结构体变量中包含了一些常见的字符串,用于文本输出
{ "Nothing happens.", { "Nothing happens.", //在游戏中提供反馈、描述情况,进行交互
"That's enough tries!", "That's enough tries!",
"That is a silly thing to %s.", "That is a silly thing to %s.",
"shudder for a moment.", "shudder for a moment.",
@ -50,33 +50,34 @@ const struct c_common_strings c_common_strings =
{ "mon", "you" } { "mon", "you" }
}; };
const struct savefile_info default_sfinfo = { const struct savefile_info default_sfinfo = { //定义了保存文件的默认信息
#ifdef NHSTDC #ifdef NHSTDC //用于保存文件格式的标志位
0x00000000UL 0x00000000UL
#else #else
0x00000000L 0x00000000L
#endif #endif
#if defined(COMPRESS) || defined(ZLIB_COMP) #if defined(COMPRESS) || defined(ZLIB_COMP) //用于外部压缩标志位
| SFI1_EXTERNALCOMP | SFI1_EXTERNALCOMP
#endif #endif
#if defined(ZEROCOMP) #if defined(ZEROCOMP)
| SFI1_ZEROCOMP | SFI1_ZEROCOMP //零压缩标志位
#endif #endif
#if defined(RLECOMP) #if defined(RLECOMP)
| SFI1_RLECOMP | SFI1_RLECOMP //RLE压缩标志
#endif #endif
, ,
#ifdef NHSTDC #ifdef NHSTDC
0x00000000UL, 0x00000000UL 0x00000000UL, 0x00000000UL //保留字段
#else #else
0x00000000L, 0x00000000L 0x00000000L, 0x00000000L
#endif #endif
}; };
const char disclosure_options[] = "iavgco"; const char disclosure_options[] = "iavgco"; //是一个字符数组,包含了几个选项。这些选项用于控制信息的披露程度。
char emptystr[] = {0}; /* non-const */ char emptystr[] = {0}; /* non-const */ //是一个字符数组,用于表示空字符串。它是非常量数组,可以被修改。
NEARDATA struct flag flags; /* extern declaration is in flag.h, not decl.h */ NEARDATA struct flag flags; /* extern declaration is in flag.h, not decl.h */
//是一个结构体变量用于存储游戏中的标志位。该变量在flag.h中有外部声明。
/* Global windowing data, defined here for multi-window-system support */ /* Global windowing data, defined here for multi-window-system support */
#ifdef WIN32 #ifdef WIN32
@ -84,25 +85,28 @@ boolean fqn_prefix_locked[PREFIX_COUNT] = { FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE }; FALSE };
//是一个布尔数组用于表示文件名前缀是否被锁定。在这段代码中它被初始化为全为FALSE。
#endif #endif
#ifdef PREFIXES_IN_USE #ifdef PREFIXES_IN_USE
const char *fqn_prefix_names[PREFIX_COUNT] = { const char *fqn_prefix_names[PREFIX_COUNT] = {
"hackdir", "leveldir", "savedir", "bonesdir", "datadir", "hackdir", "leveldir", "savedir", "bonesdir", "datadir",
"scoredir", "lockdir", "sysconfdir", "configdir", "troubledir" "scoredir", "lockdir", "sysconfdir", "configdir", "troubledir"
}; };//是一个字符串指针数组,包含了一些文件名前缀的名称。这些名称用于指定不同类型文件的存储路径。
#endif #endif
/* x/y/z deltas for the 10 movement directions (8 compass pts, 2 down/up) */ /* x/y/z deltas for the 10 movement directions (8 compass pts, 2 down/up) */
const schar xdir[N_DIRS_Z] = { -1, -1, 0, 1, 1, 1, 0, -1, 0, 0 }; const schar xdir[N_DIRS_Z] = { -1, -1, 0, 1, 1, 1, 0, -1, 0, 0 };
const schar ydir[N_DIRS_Z] = { 0, -1, -1, -1, 0, 1, 1, 1, 0, 0 }; const schar ydir[N_DIRS_Z] = { 0, -1, -1, -1, 0, 1, 1, 1, 0, 0 };
const schar zdir[N_DIRS_Z] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, -1 }; const schar zdir[N_DIRS_Z] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, -1 };
//是三个有符号字符数组分别表示十个移动方向包括八个主要方向和上下方向的x、y和z轴的增量。
/* redordered directions, cardinals first */ /* redordered directions, cardinals first */
const schar dirs_ord[N_DIRS] = const schar dirs_ord[N_DIRS] =
{ DIR_W, DIR_N, DIR_E, DIR_S, DIR_NW, DIR_NE, DIR_SE, DIR_SW }; { DIR_W, DIR_N, DIR_E, DIR_S, DIR_NW, DIR_NE, DIR_SE, DIR_SW };
//是一个有符号字符数组,表示经过重新排序的移动方向。首先是四个基本方向,然后是四个对角线方向。
NEARDATA boolean has_strong_rngseed = FALSE; NEARDATA boolean has_strong_rngseed = FALSE; //是一个布尔变量,用于表示是否具有强随机种子。
struct engr *head_engr; struct engr *head_engr;
NEARDATA struct instance_flags iflags; NEARDATA struct instance_flags iflags; //是一个结构体变量,用于存储游戏实例的标志位。
/* NOTE: the order of these words exactly corresponds to the /* NOTE: the order of these words exactly corresponds to the
order of oc_material values #define'd in objclass.h. */ order of oc_material values #define'd in objclass.h. */
const char *materialnm[] = { "mysterious", "liquid", "wax", "organic", const char *materialnm[] = { "mysterious", "liquid", "wax", "organic",
@ -111,29 +115,35 @@ const char *materialnm[] = { "mysterious", "liquid", "wax", "organic",
"metal", "copper", "silver", "gold", "metal", "copper", "silver", "gold",
"platinum", "mithril", "plastic", "glass", "platinum", "mithril", "plastic", "glass",
"gemstone", "stone" }; "gemstone", "stone" };
const char quitchars[] = " \r\n\033"; //是一个字符串指针数组包含了一些物品材质的名称。这些名称与objclass.h中定义的oc_material值的顺序完全对应。
NEARDATA struct savefile_info sfcap, sfrestinfo, sfsaveinfo;
const int shield_static[SHIELD_COUNT] = { const char quitchars[] = " \r\n\033";//是一个包含一些表示退出字符的字符串,包括空格、回车、换行和转义字符。
NEARDATA struct savefile_info sfcap, sfrestinfo, sfsaveinfo; //结构体变量,用于保存文件的信息。
const int shield_static[SHIELD_COUNT] = {//是一个整型数组,包含了一些盾牌的静态符号。
S_ss1, S_ss2, S_ss3, S_ss2, S_ss1, S_ss2, S_ss4, /* 7 per row */ S_ss1, S_ss2, S_ss3, S_ss2, S_ss1, S_ss2, S_ss4, /* 7 per row */
S_ss1, S_ss2, S_ss3, S_ss2, S_ss1, S_ss2, S_ss4, S_ss1, S_ss2, S_ss3, S_ss2, S_ss1, S_ss2, S_ss4,
S_ss1, S_ss2, S_ss3, S_ss2, S_ss1, S_ss2, S_ss4, S_ss1, S_ss2, S_ss3, S_ss2, S_ss1, S_ss2, S_ss4,
}; };
NEARDATA struct you u; NEARDATA struct you u;//结构体变量,用于表示玩家角色的状态和属性。
NEARDATA time_t ubirthday; NEARDATA time_t ubirthday; //是一个time_t类型的变量表示玩家角色的出生时间。
NEARDATA struct u_realtime urealtime; NEARDATA struct u_realtime urealtime; //用于表示游戏时间的实时信息。
NEARDATA struct obj *uwep, *uarm, *uswapwep, NEARDATA struct obj *uwep, *uarm, *uswapwep, //结构体的指针变量,用于表示玩家角色的装备和物品。
*uquiver, /* quiver */ *uquiver, /* quiver */
*uarmu, /* under-wear, so to speak */ *uarmu, /* under-wear, so to speak */
*uskin, /* dragon armor, if a dragon */ *uskin, /* dragon armor, if a dragon */
*uarmc, *uarmh, *uarms, *uarmg,*uarmf, *uamul, *uarmc, *uarmh, *uarms, *uarmg,*uarmf, *uamul,
*uright, *uleft, *ublindf, *uchain, *uball; *uright, *uleft, *ublindf, *uchain, *uball;
const char vowels[] = "aeiouAEIOU"; const char vowels[] = "aeiouAEIOU"; //是一个包含元音字母的字符串,包括小写和大写的元音字母。
NEARDATA winid WIN_MESSAGE, WIN_STATUS, WIN_MAP, WIN_INVEN; NEARDATA winid WIN_MESSAGE, WIN_STATUS, WIN_MAP, WIN_INVEN;//是窗口标识符winid类型变量用于表示游戏中的不同窗口。
const char ynchars[] = "yn"; const char ynchars[] = "yn"; //是包含一些表示"yes"和"no"的字符的字符串。
const char ynqchars[] = "ynq"; const char ynqchars[] = "ynq";
const char ynaqchars[] = "ynaq"; const char ynaqchars[] = "ynaq";
const char ynNaqchars[] = "yn#aq"; const char ynNaqchars[] = "yn#aq";
NEARDATA long yn_number = 0L; NEARDATA long yn_number = 0L;
//这些变量的定义用于实现游戏的逻辑和界面显示等功能。
//其中包括随机数种子、文本输出、文件操作、游戏状态、时间管理、玩家角色属性、装备和物品等。
#ifdef PANICTRACE #ifdef PANICTRACE
const char *ARGV0; const char *ARGV0;

@ -46,6 +46,7 @@ static int eat_ok(struct obj *);
static int offer_ok(struct obj *); static int offer_ok(struct obj *);
static int tin_ok(struct obj *); static int tin_ok(struct obj *);
/* also used to see if you're allowed to eat cats and dogs */
#define CANNIBAL_ALLOWED() (Role_if(PM_CAVE_DWELLER) || Race_if(PM_ORC)) #define CANNIBAL_ALLOWED() (Role_if(PM_CAVE_DWELLER) || Race_if(PM_ORC))
/* monster types that cause hero to be turned into stone if eaten */ /* monster types that cause hero to be turned into stone if eaten */
@ -83,7 +84,8 @@ static const struct victual_info zero_victual = { 0 };
static int getobj_else = 0; static int getobj_else = 0;
/* /*
* * Decide whether a particular object can be eaten by the possibly
* polymorphed character. Not used for monster checks.
*/ */
boolean boolean
is_edible(register struct obj *obj) is_edible(register struct obj *obj)
@ -118,7 +120,8 @@ is_edible(register struct obj *obj)
return (boolean) (obj->oclass == FOOD_CLASS); return (boolean) (obj->oclass == FOOD_CLASS);
} }
/* 用于英雄的初始化、生命挽救、修复因饥饿产生的负面效果以及提供增益效果 */ /* used for hero init, life saving (if choking), and prayer results of fix
starving, fix weak from hunger, or golden glow boon (if u.uhunger < 900) */
void void
init_uhunger(void) init_uhunger(void)
{ {
@ -173,7 +176,7 @@ eatmdone(void)
return 0; return 0;
} }
/* 处理角色进食结束后的某些更新操作 */ /* called when hallucination is toggled */
void void
eatmupdate(void) eatmupdate(void)
{ {
@ -209,7 +212,7 @@ eatmupdate(void)
} }
} }
/* 这个函数的主要目的是根据给定的食物对象和布尔值来生成一个特定的名字。 */ /* ``[the(] singular(food, xname) [)]'' */
static const char * static const char *
food_xname(struct obj *food, boolean the_pfx) food_xname(struct obj *food, boolean the_pfx)
{ {
@ -238,7 +241,7 @@ food_xname(struct obj *food, boolean the_pfx)
* *
* To a full belly all food is bad. (It.) * To a full belly all food is bad. (It.)
*/ */
static void//述玩家角色吃东西时发生的情况的函数 static void
choke(struct obj *food) choke(struct obj *food)
{ {
/* only happens if you were satiated */ /* only happens if you were satiated */
@ -284,7 +287,7 @@ choke(struct obj *food)
} }
} }
/*重新计算一个对象的重量 */ /* modify object wt. depending on time spent consuming it */
static void static void
recalc_wt(void) recalc_wt(void)
{ {
@ -301,7 +304,7 @@ recalc_wt(void)
debugpline1("New weight = %d", piece->owt); debugpline1("New weight = %d", piece->owt);
} }
/* 指示在进食回合结束后进行重置操作 */ /* called when eating interrupted by an event */
void void
reset_eat(void) reset_eat(void)
{ {
@ -315,7 +318,7 @@ reset_eat(void)
return; return;
} }
/* 计算并返回一个对象的营养值 */ /* base nutrition of a food-class object */
unsigned unsigned
obj_nutrition(struct obj *otmp) obj_nutrition(struct obj *otmp)
{ {
@ -374,7 +377,7 @@ touchfood(struct obj *otmp)
* do_reset_eat() at the beginning of eatfood()) and check for null pointers * do_reset_eat() at the beginning of eatfood()) and check for null pointers
* in do_reset_eat(). * in do_reset_eat().
*/ */
void//处理食物消失 void
food_disappears(struct obj *obj) food_disappears(struct obj *obj)
{ {
if (obj == gc.context.victual.piece) if (obj == gc.context.victual.piece)
@ -387,7 +390,7 @@ food_disappears(struct obj *obj)
/* renaming an object used to result in it having a different address, /* renaming an object used to result in it having a different address,
so the sequence start eating/opening, get interrupted, name the food, so the sequence start eating/opening, get interrupted, name the food,
resume eating/opening would restart from scratch */ resume eating/opening would restart from scratch */
void//替换特定的食物对象。 void
food_substitution(struct obj *old_obj, struct obj *new_obj) food_substitution(struct obj *old_obj, struct obj *new_obj)
{ {
if (old_obj == gc.context.victual.piece) { if (old_obj == gc.context.victual.piece) {
@ -400,7 +403,7 @@ food_substitution(struct obj *old_obj, struct obj *new_obj)
} }
} }
static void//重置与食物相关的某些属性 static void
do_reset_eat(void) do_reset_eat(void)
{ {
debugpline0("do_reset_eat..."); debugpline0("do_reset_eat...");
@ -427,7 +430,7 @@ do_reset_eat(void)
attribute or because of polymorph shape or worn or carried gear), return attribute or because of polymorph shape or worn or carried gear), return
its timeout, otherwise return 0 */ its timeout, otherwise return 0 */
long long
temp_resist(int prop)//检查某个属性由prop指定是否具有临时抗性 temp_resist(int prop)
{ {
struct prop *p = &u.uprops[prop]; struct prop *p = &u.uprops[prop];
long timeout = p->intrinsic & TIMEOUT; long timeout = p->intrinsic & TIMEOUT;
@ -446,7 +449,7 @@ temp_resist(int prop)//检查某个属性由prop指定是否具有临时
} }
/* if temp resist against 'prop' is about to timeout, extend it slightly */ /* if temp resist against 'prop' is about to timeout, extend it slightly */
static void//判断当前属性通过prop参数指定是否具有临时抗性 static void
maybe_extend_timed_resist(int prop) maybe_extend_timed_resist(int prop)
{ {
long timeout = temp_resist(prop); long timeout = temp_resist(prop);
@ -465,7 +468,7 @@ maybe_extend_timed_resist(int prop)
/* called each move during eating process */ /* called each move during eating process */
static int static int
eatfood(void)//处理角色进食的逻辑。 eatfood(void)
{ {
struct obj *food = gc.context.victual.piece; struct obj *food = gc.context.victual.piece;
@ -509,7 +512,7 @@ eatfood(void)//处理角色进食的逻辑。
} }
static void static void
done_eating(boolean message)//处理角色完成进食后的逻辑。 done_eating(boolean message)
{ {
struct obj *piece = gc.context.victual.piece; struct obj *piece = gc.context.victual.piece;
@ -541,7 +544,7 @@ done_eating(boolean message)//处理角色完成进食后的逻辑。
} }
void void
eating_conducts(struct permonst *pd)//处理与角色进食相关的行为和记录。 eating_conducts(struct permonst *pd)
{ {
int ll_conduct = 0; int ll_conduct = 0;
@ -568,7 +571,7 @@ eating_conducts(struct permonst *pd)//处理与角色进食相关的行为和记
/* handle side-effects of mind flayer's tentacle attack */ /* handle side-effects of mind flayer's tentacle attack */
int int
eat_brains(//处理角色吃怪物的脑子的行为 eat_brains(
struct monst *magr, struct monst *magr,
struct monst *mdef, struct monst *mdef,
boolean visflag, boolean visflag,
@ -717,7 +720,7 @@ eat_brains(//处理角色吃怪物的脑子的行为
/* eating a corpse or egg of one's own species is usually naughty */ /* eating a corpse or egg of one's own species is usually naughty */
static boolean static boolean
maybe_cannibal(int pm, boolean allowmsg)//判断角色是否可能成为食人族。 maybe_cannibal(int pm, boolean allowmsg)
{ {
static NEARDATA long ate_brains = 0L; static NEARDATA long ate_brains = 0L;
struct permonst *fptr = &mons[pm]; /* food type */ struct permonst *fptr = &mons[pm]; /* food type */
@ -749,7 +752,7 @@ maybe_cannibal(int pm, boolean allowmsg)//判断角色是否可能成为食人
return FALSE; return FALSE;
} }
static void//它处理玩家尝试吃怪物肉的情况 static void
cprefx(register int pm) cprefx(register int pm)
{ {
(void) maybe_cannibal(pm, TRUE); (void) maybe_cannibal(pm, TRUE);
@ -844,7 +847,7 @@ fix_petrification(void)
/* intrinsic_possible() returns TRUE iff a monster can give an intrinsic. */ /* intrinsic_possible() returns TRUE iff a monster can give an intrinsic. */
int int
intrinsic_possible(int type, struct permonst *ptr)//判断给定的怪物类型是否具有某些特性 intrinsic_possible(int type, struct permonst *ptr)
{ {
int res = 0; int res = 0;
@ -915,7 +918,7 @@ intrinsic_possible(int type, struct permonst *ptr)//判断给定的怪物类型
* intrinsic it is trying to give you. * intrinsic it is trying to give you.
*/ */
boolean boolean
should_givit(int type, struct permonst *ptr)//是否应该给予某种特性或能力。 should_givit(int type, struct permonst *ptr)
{ {
int chance; int chance;
@ -957,7 +960,7 @@ temp_givit(int type, struct permonst *ptr)
* and what type of intrinsic it is trying to give you. * and what type of intrinsic it is trying to give you.
*/ */
static void static void
givit(int type, register struct permonst *ptr)//是否给予怪物某种特性或能力。 givit(int type, register struct permonst *ptr)
{ {
debugpline1("Attempting to give intrinsic %d", type); debugpline1("Attempting to give intrinsic %d", type);
@ -1057,7 +1060,7 @@ givit(int type, register struct permonst *ptr)//是否给予怪物某种特性
} }
static void static void
eye_of_newt_buzz(void)//加角色的某种魔法能量值 eye_of_newt_buzz(void)
{ {
/* MRKR: "eye of newt" may give small magical energy boost */ /* MRKR: "eye of newt" may give small magical energy boost */
if (rn2(3) || 3 * u.uen <= 2 * u.uenmax) { if (rn2(3) || 3 * u.uen <= 2 * u.uenmax) {
@ -1082,7 +1085,7 @@ eye_of_newt_buzz(void)//加角色的某种魔法能量值
DISABLE_WARNING_FORMAT_NONLITERAL DISABLE_WARNING_FORMAT_NONLITERAL
/* called after completely consuming a corpse */ /* called after completely consuming a corpse */
static void//处理角色变身或模仿其他生物的功能 static void
cpostfx(int pm) cpostfx(int pm)
{ {
int tmp = 0; int tmp = 0;
@ -1279,7 +1282,7 @@ RESTORE_WARNING_FORMAT_NONLITERAL
* Non-deterministic; should only be called once per corpse. * Non-deterministic; should only be called once per corpse.
*/ */
int int
corpse_intrinsic(struct permonst *ptr)//检查一个怪物是否具有某种内在属性 corpse_intrinsic(struct permonst *ptr)
{ {
/* Check the monster for all of the intrinsics. If this /* Check the monster for all of the intrinsics. If this
* monster can give more than one, pick one to try to give * monster can give more than one, pick one to try to give
@ -1316,7 +1319,7 @@ corpse_intrinsic(struct permonst *ptr)//检查一个怪物是否具有某种内
} }
void void
violated_vegetarian(void)//角色违反了素食主义的情节 violated_vegetarian(void)
{ {
u.uconduct.unvegetarian++; u.uconduct.unvegetarian++;
if (Role_if(PM_MONK)) { if (Role_if(PM_MONK)) {

File diff suppressed because it is too large Load Diff

@ -1539,7 +1539,7 @@ mon_learns_traps(struct monst *mtmp, int ttyp)
mtmp->mtrapseen |= (1L << (ttyp - 1)); mtmp->mtrapseen |= (1L << (ttyp - 1));
} }
/* monsters see a trap trigger, and remember it */
void void
mons_see_trap(struct trap *ttmp) mons_see_trap(struct trap *ttmp)
{ {

@ -54,13 +54,13 @@ rnd_hallublast(void)
boolean boolean
m_has_launcher_and_ammo(struct monst* mtmp) m_has_launcher_and_ammo(struct monst* mtmp)
{ {
struct obj *mwep = MON_WEP(mtmp);//从怪物结构中获取其持有的武器。 struct obj *mwep = MON_WEP(mtmp);
if (mwep && is_launcher(mwep)) {//如果怪物有武器,并且这个武器是一个发射器,执行括号内的代码。 if (mwep && is_launcher(mwep)) {
struct obj *otmp; struct obj *otmp;
for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj)//遍历怪物的物品栏。 for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj)
if (ammo_and_launcher(otmp, mwep))//如果找到与发射器匹配的弹药函数返回TRUE。 if (ammo_and_launcher(otmp, mwep))
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
@ -68,10 +68,10 @@ m_has_launcher_and_ammo(struct monst* mtmp)
/* hero is hit by something other than a monster (though it could be a /* hero is hit by something other than a monster (though it could be a
missile thrown or shot by a monster) */ missile thrown or shot by a monster) */
int//角色被某种物体(例如魔法瓶中的酸液)击中的情况 int
thitu( thitu(
int tlev, /* 用于决定是否击中英雄的ACArmor Class防御力的伪级别。 */ int tlev, /* pseudo-level used when deciding whether to hit hero's AC */
int dam,//表示伤害值。 int dam,
struct obj **objp, struct obj **objp,
const char *name) /* if null, then format `*objp' */ const char *name) /* if null, then format `*objp' */
{ {
@ -155,7 +155,7 @@ thitu(
* Returns 0 if object still exists (not destroyed). * Returns 0 if object still exists (not destroyed).
*/ */
static int static int
drop_throw(//处理一个对象obj在被投掷或落下时的行为 drop_throw(
register struct obj *obj, register struct obj *obj,
boolean ohit, boolean ohit,
coordxy x, coordxy x,
@ -163,8 +163,8 @@ drop_throw(//处理一个对象obj在被投掷或落下时的行为
{ {
int retvalu = 1; int retvalu = 1;
int create; int create;
struct monst *mtmp;//用于指向当前位置上的怪物。 struct monst *mtmp;
struct trap *t;//用于指向当前位置上的陷阱。 struct trap *t;
if (obj->otyp == CREAM_PIE || obj->oclass == VENOM_CLASS if (obj->otyp == CREAM_PIE || obj->oclass == VENOM_CLASS
|| (ohit && obj->otyp == EGG)) || (ohit && obj->otyp == EGG))
@ -509,7 +509,7 @@ ucatchgem(
struct monst *mon) struct monst *mon)
{ {
/* won't catch rock or gray stone; catch (then drop) worthless glass */ /* won't catch rock or gray stone; catch (then drop) worthless glass */
if (gem->otyp <= LAST_GLASS_GEM && is_unicorn(gy.youmonst.data)) {//如果传入的宝石gem是一个玻璃宝石包括各种颜色的玻璃宝石并且当前玩家gy.youmonst.data是独角兽 if (gem->otyp <= LAST_GLASS_GEM && is_unicorn(gy.youmonst.data)) {
char *gem_xname = xname(gem), char *gem_xname = xname(gem),
*mon_s_name = s_suffix(mon_nam(mon)); *mon_s_name = s_suffix(mon_nam(mon));
@ -781,14 +781,14 @@ m_throw(
/* Monster throws item at another monster */ /* Monster throws item at another monster */
int int
thrwmm(struct monst* mtmp, struct monst* mtarg)//用于处理一个怪物mtmp对另一个怪物mtarg的攻击 thrwmm(struct monst* mtmp, struct monst* mtarg)
{ {
struct obj *otmp, *mwep; struct obj *otmp, *mwep;
register coordxy x, y; register coordxy x, y;
boolean ispole; boolean ispole;
/* Polearms won't be applied by monsters against other monsters */ /* Polearms won't be applied by monsters against other monsters */
if (mtmp->weapon_check == NEED_WEAPON || !MON_WEP(mtmp)) {//如果怪物没有合适的武器(例如长柄武器),它会尝试装备一个远程武器。 if (mtmp->weapon_check == NEED_WEAPON || !MON_WEP(mtmp)) {
mtmp->weapon_check = NEED_RANGED_WEAPON; mtmp->weapon_check = NEED_RANGED_WEAPON;
/* mon_wield_item resets weapon_check as appropriate */ /* mon_wield_item resets weapon_check as appropriate */
if (mon_wield_item(mtmp) != 0) if (mon_wield_item(mtmp) != 0)
@ -806,10 +806,10 @@ thrwmm(struct monst* mtmp, struct monst* mtarg)//用于处理一个怪物mtmp
mwep = MON_WEP(mtmp); /* wielded weapon */ mwep = MON_WEP(mtmp); /* wielded weapon */
if (!ispole && m_lined_up(mtarg, mtmp)) {//如果怪物有合适的远程武器,它会检查怪物和目标的位置 if (!ispole && m_lined_up(mtarg, mtmp)) {
int chance = max(BOLT_LIM - distmin(x, y, mtarg->mx, mtarg->my), 1); int chance = max(BOLT_LIM - distmin(x, y, mtarg->mx, mtarg->my), 1);
if (!mtarg->mflee || !rn2(chance)) {//怪物会计算一个攻击成功的概率(基于与目标之间的距离)。如果这个概率大于随机数生成器产生的值,那么怪物会尝试进行攻击。 if (!mtarg->mflee || !rn2(chance)) {
if (ammo_and_launcher(otmp, mwep) if (ammo_and_launcher(otmp, mwep)
&& dist2(mtmp->mx, mtmp->my, mtarg->mx, mtarg->my) && dist2(mtmp->mx, mtmp->my, mtarg->mx, mtarg->my)
> PET_MISSILE_RANGE2) > PET_MISSILE_RANGE2)
@ -1327,7 +1327,7 @@ hits_bars(
&& obj_type != WAX_CANDLE && obj_type != LENSES && obj_type != WAX_CANDLE && obj_type != LENSES
&& obj_type != TIN_WHISTLE && obj_type != MAGIC_WHISTLE); && obj_type != TIN_WHISTLE && obj_type != MAGIC_WHISTLE);
break; break;
case ROCK_CLASS: case ROCK_CLASS: /* includes boulder */
if (obj_type != STATUE || mons[otmp->corpsenm].msize > MZ_TINY) if (obj_type != STATUE || mons[otmp->corpsenm].msize > MZ_TINY)
hits = TRUE; hits = TRUE;
break; break;

@ -3067,7 +3067,7 @@ green_mon(struct monst *mon)
if (iflags.use_color) if (iflags.use_color)
return (ptr->mcolor == CLR_GREEN || ptr->mcolor == CLR_BRIGHT_GREEN); return (ptr->mcolor == CLR_GREEN || ptr->mcolor == CLR_BRIGHT_GREEN);
#endif #endif
/* approximation */
if (strstri(ptr->pmnames[NEUTRAL], "green") if (strstri(ptr->pmnames[NEUTRAL], "green")
|| (ptr->pmnames[MALE] && strstri(ptr->pmnames[MALE], "green")) || (ptr->pmnames[MALE] && strstri(ptr->pmnames[MALE], "green"))
|| (ptr->pmnames[FEMALE] && strstri(ptr->pmnames[FEMALE], "green"))) || (ptr->pmnames[FEMALE] && strstri(ptr->pmnames[FEMALE], "green")))

@ -1478,7 +1478,7 @@ validate(NHFILE *nhfp, const char *name, boolean without_waitsynch_perfile)
if (nhfp->structlevel) if (nhfp->structlevel)
rlen = (readLenType) read(nhfp->fd, (genericptr_t) &sfi, rlen = (readLenType) read(nhfp->fd, (genericptr_t) &sfi,
sizeof sfi); sizeof sfi);
minit(); minit(); /* ZEROCOMP */
if (rlen == 0) { if (rlen == 0) {
if (verbose) { if (verbose) {
pline("File \"%s\" is empty during save file feature check?", pline("File \"%s\" is empty during save file feature check?",

@ -22,7 +22,7 @@ struct rnglist_t {
enum { CORE = 0, DISP = 1 }; enum { CORE = 0, DISP = 1 };
static struct rnglist_t rnglist[] = { static struct rnglist_t rnglist[] = {
{ rn2, FALSE, { 0 } }, { rn2, FALSE, { 0 } }, /* CORE */
{ rn2_on_display_rng, FALSE, { 0 } }, /* DISP */ { rn2_on_display_rng, FALSE, { 0 } }, /* DISP */
}; };

@ -847,7 +847,8 @@ place_monster(struct monst* mon, coordxy x, coordxy y)
char buf[QBUFSZ]; char buf[QBUFSZ];
buf[0] = '\0'; buf[0] = '\0';
/* normal map bounds are <1..COLNO-1,0..ROWNO-1> but sometimes
vault guards (either living or dead) are parked at <0,0> */
if (!isok(x, y) && (x != 0 || y != 0 || !mon->isgd)) { if (!isok(x, y) && (x != 0 || y != 0 || !mon->isgd)) {
describe_level(buf, 0); describe_level(buf, 0);
impossible("trying to place %s at <%d,%d> mstate:%lx on %s", impossible("trying to place %s at <%d,%d> mstate:%lx on %s",

@ -19,7 +19,8 @@ static void see_lamp_flicker(struct obj *, const char *);
static void lantern_message(struct obj *); static void lantern_message(struct obj *);
static void cleanup_burn(ANY_P *, long); static void cleanup_burn(ANY_P *, long);
/* used by wizard mode #timeout and #wizintrinsic; order by 'interest'
for timeout countdown, where most won't occur in normal play */
static const struct propname { static const struct propname {
int prop_num; int prop_num;
const char *prop_name; const char *prop_name;

@ -12,14 +12,14 @@ static NEARDATA int utcnt, utpnt;
static NEARDATA coord utrack[UTSZ]; static NEARDATA coord utrack[UTSZ];
void void
initrack(void) /* 初始化路径*/ initrack(void)
{ {
utcnt = utpnt = 0; utcnt = utpnt = 0;
} }
/* add to track */ /* add to track */
void void
settrack(void)/* 添加路径 */ settrack(void)
{ {
if (utcnt < UTSZ) if (utcnt < UTSZ)
utcnt++; utcnt++;
@ -31,8 +31,7 @@ settrack(void)/* 添加路径 */
} }
coord * coord *
gettrack(coordxy x, coordxy y)/* 寻找路径 */ gettrack(coordxy x, coordxy y)
{ {
register int cnt, ndist; register int cnt, ndist;
register coord *tc; register coord *tc;

@ -836,7 +836,7 @@ gd_move_cleanup(
*/ */
x = grd->mx, y = grd->my; x = grd->mx, y = grd->my;
see_guard = canspotmon(grd); see_guard = canspotmon(grd);
parkguard(grd); parkguard(grd); /* move to <0,0> */
wallify_vault(grd); wallify_vault(grd);
restfakecorr(grd); restfakecorr(grd);
debugpline2("gd_move_cleanup: %scleanup%s", debugpline2("gd_move_cleanup: %scleanup%s",

Loading…
Cancel
Save