@@ -163,6 +163,9 @@ creature *generateMonster(short monsterID, boolean itemPossible, boolean mutatio
163
163
return monst ;
164
164
}
165
165
166
+ /// @brief Checks if the player knows a monster's location via telepathy or entrancement.
167
+ /// @param monst the monster
168
+ /// @return true if the monster is either entranced or revealed by telepathy
166
169
boolean monsterRevealed (creature * monst ) {
167
170
if (monst == & player ) {
168
171
return false;
@@ -191,6 +194,15 @@ boolean monsterHiddenBySubmersion(const creature *monst, const creature *observe
191
194
return false;
192
195
}
193
196
197
+ /// @brief Checks if a creature is in a state that hides it from an observer.
198
+ /// A creature is hidden if it's dormant, invisible (and not exposed by gas), or submerged (and the observer isn't).
199
+ /// However, leader/followers and player/allies are never hidden from each other.
200
+ /// Ignores line of sight, stealth, lighting, clairvoyance, telepathy, and terrain (except deep water).
201
+ /// Used for bolt targeting/paths (player & monsters), whip/spear attacks (player & monsters).
202
+ /// Called by canSeeMonster and canDirectlySeeMonster. A bit of a misnomer since monst can be the player.
203
+ /// @param monst the creature
204
+ /// @param observer the observer
205
+ /// @return true if the creature is hidden from the observer
194
206
boolean monsterIsHidden (const creature * monst , const creature * observer ) {
195
207
if (monst -> bookkeepingFlags & MB_IS_DORMANT ) {
196
208
return true;
@@ -209,6 +221,14 @@ boolean monsterIsHidden(const creature *monst, const creature *observer) {
209
221
return false;
210
222
}
211
223
224
+ /// @brief Checks if the player has full knowledge about a creature,
225
+ /// i.e. they know where it is, and what kind it is. Ignores hallucination.
226
+ /// Equivalent to the monster being not hidden and either on a visible cell or revealed.
227
+ /// Some notable uses include: auto-targeting (staffs, wands, etc.), determining which monsters
228
+ /// display in the sidebar, auto-id of unidentified items (staffs, wands, runics, etc.), and the
229
+ /// verbiage used in combat/dungeon messages (or whether a message appears at all).
230
+ /// @param monst the monster
231
+ /// @return true if the monster is not hidden and the player knows its location
212
232
boolean canSeeMonster (creature * monst ) {
213
233
if (monst == & player ) {
214
234
return true;
@@ -220,7 +240,11 @@ boolean canSeeMonster(creature *monst) {
220
240
return false;
221
241
}
222
242
223
- // This is different from canSeeMonster() in that it counts only physical sight -- not clairvoyance or telepathy.
243
+ /// @brief Checks if the player can physically see a monster (i.e. line of sight and adequate lighting).
244
+ /// Ignores telepathy, but invisible allies are treated as visible. Clairvoyant lighting is ignored, but
245
+ /// darkening is a factor because it affects a cell's VISIBLE flag.
246
+ /// @param monst the monster
247
+ /// @return true if the player can physically see the monster
224
248
boolean canDirectlySeeMonster (creature * monst ) {
225
249
if (monst == & player ) {
226
250
return true;
@@ -1478,6 +1502,14 @@ boolean monsterAvoids(creature *monst, pos p) {
1478
1502
return false;
1479
1503
}
1480
1504
1505
+ /// @brief Attempts to utilize a monster's turn by either initiating movement or launching an attack.
1506
+ /// Aims to shift the monster one space closer to the destination by evaluating the feasibility
1507
+ /// of moves in different directions. If the destination is occupied by an accessible enemy within
1508
+ /// melee range (including whip/spear), the monster will attack instead of moving.
1509
+ /// @param monst the monster
1510
+ /// @param targetLoc the destination
1511
+ /// @param willingToAttackPlayer
1512
+ /// @return true if a turn-consuming action was performed
1481
1513
static boolean moveMonsterPassivelyTowards (creature * monst , pos targetLoc , boolean willingToAttackPlayer ) {
1482
1514
const int x = monst -> loc .x ;
1483
1515
const int y = monst -> loc .y ;
@@ -2430,6 +2462,7 @@ boolean monsterSummons(creature *monst, boolean alwaysUse) {
2430
2462
2431
2463
// Some monsters never make good targets irrespective of what bolt we're contemplating.
2432
2464
// Return false for those. Otherwise, return true.
2465
+ // Used for monster-cast bolts only.
2433
2466
static boolean generallyValidBoltTarget (creature * caster , creature * target ) {
2434
2467
if (caster == target ) {
2435
2468
// Can't target yourself; that's the fundamental theorem of Brogue bolts.
@@ -2482,6 +2515,7 @@ static boolean targetEligibleForCombatBuff(creature *caster, creature *target) {
2482
2515
2483
2516
// Make a decision as to whether the given caster should fire the given bolt at the given target.
2484
2517
// Assumes that the conditions in generallyValidBoltTarget have already been satisfied.
2518
+ // Used for monster-cast bolts only.
2485
2519
static boolean specificallyValidBoltTarget (creature * caster , creature * target , enum boltType theBoltType ) {
2486
2520
2487
2521
if ((boltCatalog [theBoltType ].flags & BF_TARGET_ALLIES )
@@ -2924,6 +2958,9 @@ static void monsterMillAbout(creature *monst, short movementChance) {
2924
2958
}
2925
2959
}
2926
2960
2961
+ /// @brief Handles the given allied monster's turn under normal circumstances
2962
+ /// e.g. not discordant, fleeing, paralyzed or entranced
2963
+ /// @param monst the allied monster
2927
2964
static void moveAlly (creature * monst ) {
2928
2965
creature * closestMonster = NULL ;
2929
2966
short i , j , x , y , dir , shortestDistance , leashLength ;
@@ -3586,9 +3623,15 @@ void setMonsterLocation(creature *monst, pos newLoc) {
3586
3623
}
3587
3624
}
3588
3625
3589
- // Tries to move the given monster in the given vector; returns true if the move was legal
3590
- // (including attacking player, vomiting or struggling in vain)
3591
- // Be sure that dx, dy are both in the range [-1, 1] or the move will sometimes fail due to the diagonal check.
3626
+ /// @brief Tries to move a monster one space or perform a melee attack in the given direction.
3627
+ /// Handles confused movement, turn-consuming non-movement actions like vomiting, and unique
3628
+ /// attack patterns (axe-like, whip, spear). Fast-moving monsters get 2 turns, moving one
3629
+ /// space each time.
3630
+ /// @param monst the monster
3631
+ /// @param dx the x axis component of the direction [-1, 0, 1]
3632
+ /// @param dy the y axis component of the direction [-1, 0, 1]
3633
+ /// @return true if a turn-consuming action was performed. otherwise false (e.g. monster is
3634
+ /// unwilling to attack or blocked by terrain)
3592
3635
boolean moveMonster (creature * monst , short dx , short dy ) {
3593
3636
short x = monst -> loc .x , y = monst -> loc .y ;
3594
3637
short newX , newY ;
0 commit comments