monsters, fall into water, etc.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@962 c06c8d41-db1a-0410-9941-cceddc491573
NNG27Y5ZQAZX6UD7F7M4F6KEZBEDFXPEEC3LFUSX4ESKT7K6UJQAC
strcpy(info, "You ");
strcat(info, (wounded_damaged(monster->type)) ? "destroy" : "kill");
strcat(info, " ");
strcat(info, ptr_monam(monster, DESC_NOCAP_THE));
strcat(info, "!");
if (!silent)
{
strcpy(info, "You ");
strcat(info,
(wounded_damaged(monster->type)) ? "destroy" : "kill");
strcat(info, " ");
strcat(info, ptr_monam(monster, DESC_NOCAP_THE));
strcat(info, "!");
}
mmov_x = random2(3) - 1;
mmov_y = random2(3) - 1;
std::vector<coord_def> moves;
int pfound = 0;
for (int yi = -1; yi <= 1; ++yi)
{
for (int xi = -1; xi <= 1; ++xi)
{
coord_def c = monster->pos() + coord_def(xi, yi);
if (in_bounds(c) && !grid_is_solid(grd(c))
&& one_chance_in(++pfound))
{
mmov_x = xi;
mmov_y = yi;
}
}
}
if (one_chance_in(3))
mmov_x = mmov_y = 0;
if (monsters_fight(i, mgrd[monster->x + mmov_x][monster->y + mmov_y]))
{
brkk = true;
}
static void do_move_monster(monsters *monster, int xi, int yi)
{
const int fx = monster->x + xi,
fy = monster->y + yi;
if (!in_bounds(fx, fy))
return;
if (fx == you.x_pos && fy == you.y_pos)
{
monster_attack( monster_index(monster) );
return;
}
if (!xi && !yi)
{
const int mx = monster_index(monster);
monsters_fight( mx, mx );
return;
}
if (mgrd[fx][fy] != NON_MONSTER)
{
monsters_fight( monster_index(monster), mgrd[fx][fy] );
return;
}
if (!xi && !yi)
return;
mgrd[monster->x][monster->y] = NON_MONSTER;
/* this appears to be the real one, ie where the movement occurs: */
monster->x = fx;
monster->y = fy;
if (monster->type == MONS_CURSE_TOE)
{
// Curse toes are a special case; they can only move at half their
// attack rate. To simulate that, the toe loses more energy.
monster->speed_increment -= 5;
}
/* need to put in something so that monster picks up multiple
items (eg ammunition) identical to those it's carrying. */
mgrd[monster->x][monster->y] = monster_index(monster);
// monsters stepping on traps:
mons_trap(monster);
mons_check_pool(monster);
}
void mons_check_pool(monsters *mons, int killer)
{
// Levitating/flying monsters don't make contact with the terrain.
const int lev = mons->levitates();
if (lev == 2 || (lev && !mons->paralysed()))
return;
const int grid = grd(mons->pos());
if (grid == DNGN_LAVA || grid_is_water(grid))
{
const bool message = mons_near(mons);
// don't worry about invisibility - you should be able to
// see if something has fallen into the lava
if (message)
mprf("%s falls into the %s!",
ptr_monam(mons, DESC_CAP_THE),
(grid == DNGN_LAVA ? "lava" : "water"));
// Even fire resistant monsters perish in lava!
if (!monster_habitable_grid(mons, grid))
{
if (message)
{
if (grid == DNGN_LAVA)
simple_monster_message(mons, " is incinerated!");
else
simple_monster_message(mons, " drowns.");
}
monster_die(mons, killer, 0, true);
}
}
}
}
/* this appears to be the real one, ie where the movement occurs: */
monster->x += mmov_x;
monster->y += mmov_y;
if (monster->type == MONS_CURSE_TOE)
{
// Curse toes are a special case; they can only move at half their
// attack rate. To simulate that, the toe loses another action's
// worth of energy when moving.
monster->speed_increment -= 10;
/* need to put in something so that monster picks up multiple
items (eg ammunition) identical to those it's carrying. */
mgrd[monster->x][monster->y] = monster_index(monster);
// monsters stepping on traps:
if (mmov_x != 0 || mmov_y != 0)
{
mons_trap(monster);
}
if (mmov_x || mmov_y || (monster->confused() && one_chance_in(6)))
do_move_monster(monster, mmov_x, mmov_y);
mprf("%s %s %s%s%s%s",
attacker->name(DESC_CAP_THE).c_str(),
attacker->conj_verb( mons_attack_verb(attk) ).c_str(),
mons_defender_name().c_str(),
debug_damage_number().c_str(),
mons_weapon_desc().c_str(),
attack_strength_punctuation().c_str());
if (needs_message)
mprf("%s %s %s%s%s%s",
attacker->name(DESC_CAP_THE).c_str(),
attacker->conj_verb( mons_attack_verb(attk) ).c_str(),
mons_defender_name().c_str(),
debug_damage_number().c_str(),
mons_weapon_desc().c_str(),
attack_strength_punctuation().c_str());
mprf("%s %s %s but doesn't do any damage.",
attacker->name(DESC_CAP_THE).c_str(),
attacker->conj_verb( mons_attack_verb(attk) ).c_str(),
mons_defender_name().c_str());
if (needs_message)
mprf("%s %s %s but doesn't do any damage.",
attacker->name(DESC_CAP_THE).c_str(),
attacker->conj_verb( mons_attack_verb(attk) ).c_str(),
mons_defender_name().c_str());
const int grid = grd(monster->pos());
if (grid == DNGN_LAVA || grid_is_water(grid))
{
if (mons_flies(monster) == 1)
{
// don't worry about invisibility - you should be able to
// see if something has fallen into the lava
if (mons_near(monster))
mprf("%s falls into the %s!",
ptr_monam(monster, DESC_CAP_THE),
(grid == DNGN_LAVA ? "lava" : "water"));
monster_die(monster, pbolt);
}
}
mons_check_pool(monster);