Code cleanup
[crawl.git] / crawl-ref / source / mon-stealth.cc
blob23b4cbbc1023cb10fc9eb07e4afc50abbebb50ce
1 /*
2 * File: mon-stealth.cc
3 * Summary: Monsters stealth methods.
4 */
6 #include "AppHdr.h"
8 #include "monster.h"
9 #include "mon-util.h"
11 static int _clamp_stealth (int stealth)
13 if (stealth > 3)
15 return (3);
17 else if (stealth < -3)
19 return (-3);
21 else
23 return (stealth);
27 // Monster stealth is a value between:
29 // -3 - Extremely unstealthy
30 // -2 - Very unstealthy
31 // -1 - Unstealthy
32 // 0 - Normal
33 // 1 - Stealthy
34 // 2 - Very stealthy
35 // 3 - Extremely stealthy
37 int monster::stealth() const
39 int base_stealth = -(std::min((int) body_size(), 6) - 3);
41 int actual_stealth = base_stealth;
43 // Undead are inherently more stealthy.
44 if (holiness() == MH_UNDEAD)
46 // Zombies are less stealthy.
47 if (type == MONS_ZOMBIE_SMALL)
48 actual_stealth--;
50 // Larger zombies even more so.
51 else if (type == MONS_ZOMBIE_LARGE)
52 actual_stealth -= 2;
54 // Other undead are otherwise stealthy.
55 else
56 actual_stealth++;
59 // If you're floundering in water, you're unstealthy.
60 if (floundering())
61 actual_stealth -= 2;
63 // Orcs are a noisy bunch and get a penalty here to affect orc wizard
64 // invisibility.
65 if (mons_genus(this->type) == MONS_ORC)
66 actual_stealth--;
68 // Not an issue with invisibility, but glowing or haloes make you
69 // unstealthy.
70 if (glows_naturally() || halo_radius2() != -1)
71 actual_stealth -= 3;
73 // Some specific overrides
74 if (type == MONS_UNSEEN_HORROR)
75 actual_stealth = 3;
77 return _clamp_stealth(actual_stealth);