turn. Unless one of the monster involved was a giant spore or ball lightning, in which case if the explosion caused the death of the final monster then the exploder is considered to be the winner (with "giant spore v giant spore" the first to explode is the winner).
Figure out if a fight is still ongoing by doing book-keeping on how many members of each faction is alive, rather than sweeping through menv[] after every turn looking for living monsters.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8263 c06c8d41-db1a-0410-9941-cceddc491573
K4CJM2GNQKZAPQT3FD2FSG4IXBUUZS42VSXH3QCVSWTZ3JOZT6YQC
Y26UG3JWXZG3USM5R36UIZAZWVSC67ZKPE6CSIP3SUBVPB7MZSGQC
PKXXBHS3LWLPZI2QVRX22MSQ4R2626IXRSNHFFYHXYTLJJQU54LQC
CKKQS65COJ4KKOWYCKSEAPTH2X6HZSCFOT62JQOK5QDSILBKSFDAC
WGM77XP66ZEIRWAOKAJDICJ4ZBEUKGAEY6MZQQJ2LUWG5PCG722QC
ESHSNJO7LNU6GCDNEBRZAXZYVJK63CUGSXO5FO2Q6ZVGJGJ5NXOQC
IDVXNMJFRENWKNSEHT4TU3XZKY5IDJ6LEPHKEMCIMVQSJFFHGQFAC
R32CQ6FQJTQLB35P3HENIDCBDT3UWXBBCDAAUWHUQO6G6NKEDPKQC
bool found_friend = false;
bool found_enemy = false;
unwind_bool state(crawl_state.arena, false);
::more();
}
void count_foes()
{
int orig_a = faction_a.active_members;
int orig_b = faction_b.active_members;
faction_a.active_members = 0;
faction_b.active_members = 0;
return (false);
if (orig_a != faction_a.active_members
|| orig_b != faction_b.active_members)
{
mpr("Book-keeping error in faction member count.", MSGCH_ERROR);
more();
}
}
// Returns true as long as at least one member of each faction is alive.
bool fight_is_on()
{
if (faction_a.active_members > 0 && faction_b.active_members > 0)
return true;
// Sync up our book-keeping with the actual state.
count_foes();
return (faction_a.active_members > 0 && faction_b.active_members > 0);
mprf(msg,
team_a_won ? faction_a.desc.c_str() : faction_b.desc.c_str());
if (Options.arena_dump_msgs || Options.arena_list_eq)
msg = "---------- " + msg + " ----------";
if (was_tied)
mprf(msg.c_str());
else
mprf(msg.c_str(),
team_a_won ? faction_a.desc.c_str() : faction_b.desc.c_str());
if (monster->attitude == ATT_FRIENDLY)
arena::faction_a.active_members--;
else if (monster->attitude == ATT_HOSTILE)
arena::faction_b.active_members--;
// Was the death caused by the suicide attack of a gas spore or
// ball lightning which was the final member of its faction?
if (arena::faction_a.active_members <= 0
&& arena::faction_b.active_members <= 0
&& !invalid_monster_index(killer_index)
&& menv[killer_index].type != -1)
{
const monsters* atk = &menv[killer_index];
if (monster->attitude != atk->attitude && mons_self_destructs(atk))
{
if (atk->attitude == ATT_FRIENDLY)
arena::faction_a.suicide_attack = true;
else if (atk->attitude == ATT_HOSTILE)
arena::faction_b.suicide_attack = true;
}
}