1 /**
2  * @file
3  * @brief Functions used when placing monsters in the dungeon.
4 **/
5 
6 #pragma once
7 
8 #include <vector>
9 
10 #include "conduct-type.h"
11 #include "coord-def.h"
12 #include "dungeon-char-type.h"
13 #include "dungeon-feature-type.h"
14 #include "level-id.h"
15 #include "mgen-enum.h"
16 #include "monster-type.h"
17 #include "tag-version.h"
18 #include "trap-type.h"
19 
20 using std::vector;
21 
22 class monster;
23 class mons_spec;
24 struct mgen_data;
25 
26 /* ***********************************************************************
27  * Creates a monster near the place specified in the mgen_data, producing
28  * a "puff of smoke" message if the monster cannot be placed. This is usually
29  * used for summons and other monsters that want to appear near a given
30  * position like a summon.
31  * Returns -1 on failure, index into env.mons otherwise.
32  * *********************************************************************** */
33 monster* create_monster(mgen_data mg, bool fail_msg = true);
34 
35 /* ***********************************************************************
36  * Primary function to create monsters. See mgen_data for details on monster
37  * placement.
38  * *********************************************************************** */
39 monster* mons_place(mgen_data mg);
40 
41 bool needs_resolution(monster_type mon_type);
42 
43 monster_type resolve_monster_type(monster_type mon_type,
44                                   monster_type &base_type,
45                                   proximity_type proximity = PROX_ANYWHERE,
46                                   coord_def *pos = nullptr,
47                                   unsigned mmask = 0,
48                                   level_id *place = nullptr,
49                                   bool *want_band = nullptr,
50                                   bool allow_ood = true);
51 
52 monster_type fixup_zombie_type(const monster_type cls,
53                                const monster_type base_type);
54 
55 /* ***********************************************************************
56  * This isn't really meant to be a public function. It is a low level
57  * monster placement function used by dungeon building routines and
58  * mons_place(). If you need to put a monster somewhere, use mons_place().
59  * Summoned creatures can be created with create_monster().
60  * *********************************************************************** */
61 monster* place_monster(mgen_data mg, bool force_pos = false, bool dont_place = false);
62 
63 /* ***********************************************************************
64  * Returns a monster class type of a zombie for generation
65  * on the player's current level.
66  * cs:         Restrict to monster types that fit this zombie type
67  *             (e.g. monsters with skeletons for MONS_SKELETON_SMALL)
68  * pos:        Check habitat at position.
69  * for_corpse: Whether this monster is intended only for use as a potentially
70  *             zombifiable corpse. (I.e., whether we care about its speed when
71  *             placing in D...)
72  * *********************************************************************** */
73 monster_type pick_local_zombifiable_monster(level_id place,
74                                             monster_type cs = MONS_NO_MONSTER,
75                                             const coord_def& pos = coord_def(),
76                                             bool for_corpse = false);
77 
78 monster_type pick_local_corpsey_monster(level_id place);
79 
80 void roll_zombie_hp(monster* mon);
81 
82 void define_zombie(monster* mon, monster_type ztype, monster_type cs);
83 
84 bool downgrade_zombie_to_skeleton(monster* mon);
85 
86 class level_id;
87 
88 monster_type pick_random_monster(level_id place,
89                                  monster_type kind = RANDOM_MONSTER,
90                                  level_id *final_place = nullptr,
91                                  bool allow_ood = true);
92 
93 conduct_type god_hates_monster(monster_type type);
94 conduct_type god_hates_monster(const monster &mon);
95 bool mons_can_hate(monster_type type);
96 void check_lovelessness(monster &mon);
97 
98 bool find_habitable_spot_near(const coord_def& where, monster_type mon_type,
99                               int radius, bool allow_centre, coord_def& empty,
100                               const monster* viable_mon = nullptr);
101 
102 monster_type random_demon_by_tier(int tier);
103 monster_type summon_any_demon(monster_type dct, bool use_local_demons = false);
104 
105 bool drac_colour_incompatible(int drac, int colour);
106 
107 bool monster_habitable_grid(const monster* mon,
108                             dungeon_feature_type actual_grid);
109 bool monster_habitable_grid(monster_type mt, dungeon_feature_type actual_grid,
110                             dungeon_feature_type wanted_grid = DNGN_UNSEEN);
111 bool monster_can_submerge(const monster* mon, dungeon_feature_type grid);
112 coord_def find_newmons_square(monster_type mons_class, const coord_def &p,
113                               const monster* viable_mon = nullptr);
114 coord_def find_newmons_square_contiguous(monster_type mons_class,
115                                          const coord_def &start,
116                                          int maxdistance = 3);
117 bool can_spawn_mushrooms(coord_def where);
118 
119 void spawn_random_monsters();
120 
121 void set_vault_mon_list(const vector<mons_spec> &list);
122 
123 void setup_vault_mon_list();
124 
125 monster* get_free_monster();
126 
127 void mons_add_blame(monster* mon, const string &blame_string);
128 
129 void debug_bands();
130 
131 void replace_boris();
132 
133 // Active monster band may influence gear generation on band followers.
134 extern band_type active_monster_band;
135 
136 #define MON_OOD_KEY "mons_is_ood"
137 
138 #if TAG_MAJOR_VERSION == 34
139 #define VAULT_MON_TYPES_KEY   "vault_mon_types"
140 #define VAULT_MON_BASES_KEY   "vault_mon_bases"
141 #define VAULT_MON_PLACES_KEY  "vault_mon_places"
142 #define VAULT_MON_WEIGHTS_KEY "vault_mon_weights"
143 #define VAULT_MON_BANDS_KEY   "vault_mon_bands"
144 #endif
145