本文整理汇总了C++中Monster::decrease_hp方法的典型用法代码示例。如果您正苦于以下问题:C++ Monster::decrease_hp方法的具体用法?C++ Monster::decrease_hp怎么用?C++ Monster::decrease_hp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Monster
的用法示例。
在下文中一共展示了Monster::decrease_hp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drain
//drain: Do drain hit points from player schtick
void drain()
{
Monster* monster;
int cnt;
struct Room *room;
Monster **dp;
bool in_passage;
Monster *drainee[40];
//First count how many things we need to spread the hit points among
cnt = 0;
if (game->level().get_tile(game->hero().position()) == DOOR)
room = game->level().get_passage(game->hero().position());
else room = NULL;
in_passage = game->hero().room()->is_gone();
dp = drainee;
for (auto it = game->level().monsters.begin(); it != game->level().monsters.end(); ++it) {
monster = *it;
if (monster->room() == game->hero().room() || monster->room() == room ||
(in_passage && game->level().get_tile(monster->position()) == DOOR && game->level().get_passage(monster->position()) == game->hero().room())) {
*dp++ = monster;
}
}
if ((cnt = dp - drainee) == 0) {
msg("you have a tingling feeling");
return;
}
*dp = NULL;
cnt = game->hero().drain_hp() / cnt + 1;
//Now zot all of the monsters
for (dp = drainee; *dp; dp++)
{
monster = *dp;
if (!monster->decrease_hp(cnt, true))
killed_by_hero(monster, game->hero().can_see_monster(monster));
else
monster->start_run();
}
}