XEEN: Move check code for nearby monsters to it's own method

This commit is contained in:
Paul Gilbert 2018-04-05 20:06:14 -04:00
parent a54850cae0
commit 8648a48080
3 changed files with 15 additions and 4 deletions

View File

@ -2087,4 +2087,13 @@ void Combat::shootRangedWeapon() {
rangedAttack(POW_ARROW);
}
bool Combat::areMonstersPresent() const {
for (int idx = 0; idx < 26; ++idx) {
if (_attackMonsters[idx] != -1)
return true;
}
return false;
}
} // End of namespace Xeen

View File

@ -305,6 +305,11 @@ public:
* Fires off a ranged attack at all oncoming monsters
*/
void shootRangedWeapon();
/**
* Returns true if there are any monsters in the vacinity
*/
bool areMonstersPresent() const;
};
} // End of namespace Xeen

View File

@ -689,10 +689,7 @@ void Party::giveTreasure() {
if (!_treasure._hasItems && !_treasure._gold && !_treasure._gems)
return;
bool monstersPresent = false;
for (int idx = 0; idx < 26 && !monstersPresent; ++idx)
monstersPresent = combat._attackMonsters[idx] != -1;
bool monstersPresent = combat.areMonstersPresent();
if (_vm->_mode != MODE_RECORD_EVENTS && monstersPresent)
return;