Finds a target. Self is currently not attacking anything, so try to find a target Returns TRUE if an enemy was sighted When a player fires a missile, the point of impact becomes a fakeplayer so that monsters that see the impact will respond as if they had seen the player. To avoid spending too m
(SubgameEntity self, GameExportsImpl gameExports)
| 278 | * slower noticing monsters. |
| 279 | */ |
| 280 | static boolean FindTarget(SubgameEntity self, GameExportsImpl gameExports) { |
| 281 | boolean heardit; |
| 282 | int r; |
| 283 | |
| 284 | if ((self.monsterinfo.aiflags & GameDefines.AI_GOOD_GUY) != 0) { |
| 285 | if (self.goalentity != null && self.goalentity.inuse |
| 286 | && self.goalentity.classname != null) { |
| 287 | if (self.goalentity.classname.equals("target_actor")) |
| 288 | return false; |
| 289 | } |
| 290 | |
| 291 | //FIXME look for monsters? |
| 292 | return false; |
| 293 | } |
| 294 | |
| 295 | // if we're going to a combat point, just proceed |
| 296 | if ((self.monsterinfo.aiflags & GameDefines.AI_COMBAT_POINT) != 0) |
| 297 | return false; |
| 298 | |
| 299 | // if the first spawnflag bit is set, the monster will only wake up on |
| 300 | // really seeing the player, not another monster getting angry or |
| 301 | // hearing something |
| 302 | // revised behavior so they will wake up if they "see" a player make a |
| 303 | // noise but not weapon impact/explosion noises |
| 304 | |
| 305 | heardit = false; |
| 306 | SubgameEntity client; |
| 307 | if ((gameExports.level.sight_entity_framenum >= (gameExports.level.framenum - 1)) |
| 308 | && 0 == (self.spawnflags & 1)) { |
| 309 | client = gameExports.level.sight_entity; |
| 310 | if (client.enemy == self.enemy) |
| 311 | return false; |
| 312 | } else if (gameExports.level.sound_entity_framenum >= (gameExports.level.framenum - 1)) { |
| 313 | client = gameExports.level.sound_entity; |
| 314 | heardit = true; |
| 315 | } else if (null != (self.enemy) |
| 316 | && (gameExports.level.sound2_entity_framenum >= (gameExports.level.framenum - 1)) |
| 317 | && 0 != (self.spawnflags & 1)) { |
| 318 | client = gameExports.level.sound2_entity; |
| 319 | heardit = true; |
| 320 | } else { |
| 321 | client = gameExports.level.sight_client; |
| 322 | if (client == null) |
| 323 | return false; // no clients to get mad at |
| 324 | } |
| 325 | |
| 326 | // if the entity went away, forget it |
| 327 | if (!client.inuse) |
| 328 | return false; |
| 329 | |
| 330 | if (client.getClient() != null) { |
| 331 | if ((client.flags & GameDefines.FL_NOTARGET) != 0) |
| 332 | return false; |
| 333 | } else if ((client.svflags & Defines.SVF_MONSTER) != 0) { |
| 334 | if (client.enemy == null) |
| 335 | return false; |
| 336 | if ((client.enemy.flags & GameDefines.FL_NOTARGET) != 0) |
| 337 | return false; |
no test coverage detected