怪物投掷

luojunhui_branch
luojunhui 10 months ago
parent 478c6ca51a
commit b17f7e3bdd

@ -54,13 +54,13 @@ rnd_hallublast(void)
boolean
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;
for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj)
if (ammo_and_launcher(otmp, mwep))
for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj)//遍历怪物的物品栏。
if (ammo_and_launcher(otmp, mwep))//如果找到与发射器匹配的弹药函数返回TRUE。
return TRUE;
}
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
missile thrown or shot by a monster) */
int
int//角色被某种物体(例如魔法瓶中的酸液)击中的情况
thitu(
int tlev, /* pseudo-level used when deciding whether to hit hero's AC */
int dam,
int tlev, /* 用于决定是否击中英雄的ACArmor Class防御力的伪级别。 */
int dam,//表示伤害值。
struct obj **objp,
const char *name) /* if null, then format `*objp' */
{
@ -155,7 +155,7 @@ thitu(
* Returns 0 if object still exists (not destroyed).
*/
static int
drop_throw(
drop_throw(//处理一个对象obj在被投掷或落下时的行为
register struct obj *obj,
boolean ohit,
coordxy x,
@ -163,8 +163,8 @@ drop_throw(
{
int retvalu = 1;
int create;
struct monst *mtmp;
struct trap *t;
struct monst *mtmp;//用于指向当前位置上的怪物。
struct trap *t;//用于指向当前位置上的陷阱。
if (obj->otyp == CREAM_PIE || obj->oclass == VENOM_CLASS
|| (ohit && obj->otyp == EGG))
@ -509,7 +509,7 @@ ucatchgem(
struct monst *mon)
{
/* won't catch rock or gray stone; catch (then drop) worthless glass */
if (gem->otyp <= LAST_GLASS_GEM && is_unicorn(gy.youmonst.data)) {
if (gem->otyp <= LAST_GLASS_GEM && is_unicorn(gy.youmonst.data)) {//如果传入的宝石gem是一个玻璃宝石包括各种颜色的玻璃宝石并且当前玩家gy.youmonst.data是独角兽
char *gem_xname = xname(gem),
*mon_s_name = s_suffix(mon_nam(mon));
@ -781,14 +781,14 @@ m_throw(
/* Monster throws item at another monster */
int
thrwmm(struct monst* mtmp, struct monst* mtarg)
thrwmm(struct monst* mtmp, struct monst* mtarg)//用于处理一个怪物mtmp对另一个怪物mtarg的攻击
{
struct obj *otmp, *mwep;
register coordxy x, y;
boolean ispole;
/* 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;
/* mon_wield_item resets weapon_check as appropriate */
if (mon_wield_item(mtmp) != 0)
@ -806,10 +806,10 @@ thrwmm(struct monst* mtmp, struct monst* mtarg)
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);
if (!mtarg->mflee || !rn2(chance)) {
if (!mtarg->mflee || !rn2(chance)) {//怪物会计算一个攻击成功的概率(基于与目标之间的距离)。如果这个概率大于随机数生成器产生的值,那么怪物会尝试进行攻击。
if (ammo_and_launcher(otmp, mwep)
&& dist2(mtmp->mx, mtmp->my, mtarg->mx, mtarg->my)
> PET_MISSILE_RANGE2)

Loading…
Cancel
Save