(SubgameEntity targ, SubgameEntity attacker, GameExportsImpl gameExports)
| 270 | } |
| 271 | |
| 272 | private static void M_ReactToDamage(SubgameEntity targ, SubgameEntity attacker, GameExportsImpl gameExports) { |
| 273 | if ((null != attacker.getClient()) |
| 274 | && 0 != (attacker.svflags & Defines.SVF_MONSTER)) |
| 275 | return; |
| 276 | |
| 277 | if (attacker == targ || attacker == targ.enemy) |
| 278 | return; |
| 279 | |
| 280 | // do not react to notargets |
| 281 | if ((attacker.flags & FL_NOTARGET) != 0) { |
| 282 | return; |
| 283 | } |
| 284 | |
| 285 | // if we are a good guy monster and our attacker is a player |
| 286 | // or another good guy, do not get mad at them |
| 287 | if (0 != (targ.monsterinfo.aiflags & GameDefines.AI_GOOD_GUY)) { |
| 288 | if (attacker.getClient() != null |
| 289 | || (attacker.monsterinfo.aiflags & GameDefines.AI_GOOD_GUY) != 0) |
| 290 | return; |
| 291 | } |
| 292 | |
| 293 | // we now know that we are not both good guys |
| 294 | |
| 295 | // if attacker is a client, get mad at them because he's good and we're |
| 296 | // not |
| 297 | if (attacker.getClient() != null) { |
| 298 | targ.monsterinfo.aiflags &= ~GameDefines.AI_SOUND_TARGET; |
| 299 | |
| 300 | // this can only happen in coop (both new and old enemies are |
| 301 | // clients) |
| 302 | // only switch if can't see the current enemy |
| 303 | if (targ.enemy != null && targ.enemy.getClient() != null) { |
| 304 | if (GameUtil.visible(targ, targ.enemy, gameExports)) { |
| 305 | targ.oldenemy = attacker; |
| 306 | return; |
| 307 | } |
| 308 | targ.oldenemy = targ.enemy; |
| 309 | } |
| 310 | targ.enemy = attacker; |
| 311 | if (0 == (targ.monsterinfo.aiflags & GameDefines.AI_DUCKED)) |
| 312 | GameUtil.FoundTarget(targ, gameExports); |
| 313 | return; |
| 314 | } |
| 315 | |
| 316 | // it's the same base (walk/swim/fly) type and a different classname and |
| 317 | // it's not a tank |
| 318 | // (they spray too much), get mad at them |
| 319 | if (((targ.flags & (GameDefines.FL_FLY | GameDefines.FL_SWIM)) == (attacker.flags & (GameDefines.FL_FLY | GameDefines.FL_SWIM))) |
| 320 | && (!(targ.classname.equals(attacker.classname))) |
| 321 | && (!(attacker.classname.equals("monster_tank"))) |
| 322 | && (!(attacker.classname.equals("monster_supertank"))) |
| 323 | && (!(attacker.classname.equals("monster_makron"))) |
| 324 | && (!(attacker.classname.equals("monster_jorg")))) { |
| 325 | if (targ.enemy != null && targ.enemy.getClient() != null) |
| 326 | targ.oldenemy = targ.enemy; |
| 327 | targ.enemy = attacker; |
| 328 | if (0 == (targ.monsterinfo.aiflags & GameDefines.AI_DUCKED)) |
| 329 | GameUtil.FoundTarget(targ, gameExports); |
no test coverage detected