00001
00002
00003
00004
00005
00006
00007
00008 #ifndef MONUTIL_H
00009 #define MONUTIL_H
00010
00011 #include "mon-util.h"
00012
00013 #include "externs.h"
00014 #include "enum.h"
00015 #include "mon-enum.h"
00016 #include "mon_resist_def.h"
00017 #include "player.h"
00018 #include "monster.h"
00019
00020 struct bolt;
00021
00022
00023
00024 struct mon_attack_def
00025 {
00026 mon_attack_type type;
00027 mon_attack_flavour flavour;
00028 int damage;
00029
00030 static mon_attack_def attk(int dam,
00031 mon_attack_type typ = AT_HIT,
00032 mon_attack_flavour flav = AF_PLAIN)
00033 {
00034 mon_attack_def def = { typ, flav, dam };
00035 return (def);
00036 }
00037 };
00038
00039
00040
00041 struct mon_energy_usage
00042 {
00043 public:
00044 int8_t move;
00045 int8_t swim;
00046 int8_t attack;
00047 int8_t missile;
00048 int8_t spell;
00049 int8_t special;
00050 int8_t item;
00051
00052
00053
00054 int8_t pickup_percent;
00055
00056 public:
00057 mon_energy_usage(int mv = 10, int sw = 10, int att = 10, int miss = 10,
00058 int spl = 10, int spc = 10, int itm = 10, int pick = 100)
00059 : move(mv), swim(sw), attack(att), missile(miss),
00060 spell(spl), special(spc), item(itm), pickup_percent(pick)
00061 {
00062 }
00063
00064 static mon_energy_usage attack_cost(int cost, int sw = 10)
00065 {
00066 mon_energy_usage me;
00067 me.attack = cost;
00068 me.swim = sw;
00069 return me;
00070 }
00071
00072 static mon_energy_usage missile_cost(int cost)
00073 {
00074 mon_energy_usage me;
00075 me.missile = cost;
00076 return me;
00077 }
00078
00079 static mon_energy_usage swim_cost (int cost)
00080 {
00081 mon_energy_usage me;
00082 me.swim = cost;
00083 return me;
00084 }
00085
00086 static mon_energy_usage move_cost(int mv, int sw = 10)
00087 {
00088 const mon_energy_usage me(mv, sw);
00089 return me;
00090 }
00091
00092 mon_energy_usage operator | (const mon_energy_usage &o) const
00093 {
00094 return mon_energy_usage(combine(move, o.move),
00095 combine(swim, o.swim),
00096 combine(attack, o.attack),
00097 combine(missile, o.missile),
00098 combine(spell, o.spell),
00099 combine(special, o.special),
00100 combine(item, o.item),
00101 combine(pickup_percent, o.pickup_percent,
00102 100));
00103 }
00104 private:
00105 int8_t combine(int8_t a, int8_t b, int8_t def = 10) const {
00106 return (b != def? b : a);
00107 }
00108 };
00109
00110 struct monsterentry
00111 {
00112 short mc;
00113
00114 char showchar;
00115 uint8_t colour;
00116 const char *name;
00117
00118 uint64_t bitfields;
00119 mon_resist_def resists;
00120
00121 short weight;
00122
00123
00124
00125
00126 int8_t exp_mod;
00127
00128 monster_type genus,
00129 species;
00130
00131 mon_holy_type holiness;
00132
00133 short resist_magic;
00134
00135
00136 mon_attack_def attack[4];
00137
00138
00139
00140
00141
00142
00143
00144 unsigned hpdice[4];
00145
00146 int8_t AC;
00147 int8_t ev;
00148 mon_spellbook_type sec;
00149 corpse_effect_type corpse_thingy;
00150 zombie_size_type zombie_size;
00151 shout_type shouts;
00152 mon_intel_type intel;
00153 habitat_type habitat;
00154 flight_type fly;
00155 int8_t speed;
00156 mon_energy_usage energy_usage;
00157 mon_itemuse_type gmon_use;
00158 mon_itemeat_type gmon_eat;
00159 size_type size;
00160 };
00161
00162 habitat_type grid2habitat(dungeon_feature_type grid);
00163 dungeon_feature_type habitat2grid(habitat_type ht);
00164
00165 monsterentry *get_monster_data(int mc);
00166 const mon_resist_def &get_mons_class_resists(int mc);
00167 mon_resist_def get_mons_resists(const monster* mon);
00168
00169 void init_monsters();
00170 void init_monster_symbols();
00171
00172 monster *monster_at(const coord_def &pos);
00173
00174
00175 std::string mons_type_name(int type, description_level_type desc);
00176
00177 bool give_monster_proper_name(monster* mon, bool orcs_only = true);
00178
00179 flight_type mons_class_flies(int mc);
00180 flight_type mons_flies(const monster* mon, bool temp = true);
00181
00182 bool mons_class_amphibious(int mc);
00183 bool mons_class_flattens_trees(int mc);
00184 int mons_class_res_wind(int mc);
00185 bool mons_amphibious(const monster* mon);
00186 bool mons_flattens_trees(const monster* mon);
00187 bool mons_class_wall_shielded(int mc);
00188 bool mons_wall_shielded(const monster* mon);
00189
00190 mon_itemuse_type mons_class_itemuse(int mc);
00191 mon_itemuse_type mons_itemuse(const monster* mon);
00192 mon_itemeat_type mons_class_itemeat(int mc);
00193 mon_itemeat_type mons_itemeat(const monster* mon);
00194
00195 bool mons_sense_invis(const monster* mon);
00196
00197 int get_shout_noise_level(const shout_type shout);
00198 shout_type mons_shouts(int mclass, bool demon_shout = false);
00199
00200 bool mons_is_ghost_demon(int mc);
00201 bool mons_is_unique(int mc);
00202 bool mons_is_pghost(int mc);
00203
00204 int mons_difficulty(int mc);
00205 int exper_value(const monster* mon);
00206
00207 int hit_points(int hit_dice, int min_hp, int rand_hp);
00208
00209 int mons_class_hit_dice(int mc);
00210
00211 bool mons_immune_magic(const monster* mon);
00212 std::string mons_resist_string(const monster* mon, int res_margin);
00213 std::string resist_margin_phrase(int margin);
00214
00215 int mons_damage(int mc, int rt);
00216 mon_attack_def mons_attack_spec(const monster* mon, int attk_number);
00217
00218 corpse_effect_type mons_corpse_effect(int mc);
00219
00220 bool mons_class_flag(int mc, uint64_t bf);
00221
00222 int mons_unusable_items(const monster* mon);
00223
00224 mon_holy_type mons_class_holiness(int mc);
00225
00226 bool mons_is_mimic(int mc);
00227 bool mons_is_item_mimic(int mc);
00228 bool mons_is_feat_mimic(int mc);
00229 void discover_mimic(monster* mimic);
00230
00231
00232 bool mons_is_statue(int mc, bool allow_disintegrate = false);
00233 bool mons_is_demon(int mc);
00234 bool mons_is_draconian(int mc);
00235 bool mons_is_conjured(int mc);
00236
00237 bool mons_class_wields_two_weapons(int mc);
00238 bool mons_wields_two_weapons(const monster* m);
00239 bool mons_self_destructs(const monster* m);
00240
00241 mon_intel_type mons_class_intel(int mc);
00242 mon_intel_type mons_intel(const monster* mon);
00243
00244
00245
00246 habitat_type mons_class_habitat(int mc);
00247 habitat_type mons_habitat(const monster* mon);
00248 habitat_type mons_class_primary_habitat(int mc);
00249 habitat_type mons_primary_habitat(const monster* mon);
00250 habitat_type mons_class_secondary_habitat(int mc);
00251 habitat_type mons_secondary_habitat(const monster* mon);
00252
00253 bool intelligent_ally(const monster* mon);
00254
00255 bool mons_skeleton(int mc);
00256
00257 int mons_weight(int mc);
00258 mon_resist_def serpent_of_hell_resists(int flavour);
00259
00260 int mons_class_base_speed(int mc);
00261 int mons_class_zombie_base_speed(int zombie_base_mc);
00262 int mons_base_speed(const monster* mon);
00263 int mons_real_base_speed(int mc);
00264
00265 bool mons_class_can_regenerate(int mc);
00266 bool mons_can_regenerate(const monster* mon);
00267 bool mons_class_can_display_wounds(int mc);
00268 bool mons_can_display_wounds(const monster* mon);
00269 zombie_size_type zombie_class_size(monster_type cs);
00270 int mons_zombie_size(int mc);
00271 monster_type mons_zombie_base(const monster* mon);
00272 bool mons_class_is_zombified(int mc);
00273 monster_type mons_base_type(const monster* mon);
00274 bool mons_class_can_leave_corpse(monster_type mc);
00275 bool mons_is_zombified(const monster* mons);
00276 bool mons_class_can_be_zombified(int mc);
00277 bool mons_can_be_zombified(const monster* mon);
00278 bool mons_class_can_use_stairs(int mc);
00279 bool mons_can_use_stairs(const monster* mon);
00280 bool mons_enslaved_body_and_soul(const monster* mon);
00281 bool mons_enslaved_soul(const monster* mon);
00282 bool name_zombie(monster* mon, int mc, const std::string mon_name);
00283 bool name_zombie(monster* mon, const monster* orig);
00284
00285 int mons_power(int mc);
00286
00287 wchar_t mons_char(int mc);
00288 char mons_base_char(int mc);
00289
00290 int mons_class_colour(int mc);
00291 int mons_colour(const monster* mon);
00292
00293 void mons_load_spells(monster* mon, mon_spellbook_type book);
00294
00295 monster_type royal_jelly_ejectable_monster();
00296 monster_type random_draconian_monster_species();
00297
00298 void define_monster(monster* mons);
00299
00300 void mons_pacify(monster* mon, mon_attitude_type att = ATT_GOOD_NEUTRAL);
00301
00302 bool mons_should_fire(struct bolt &beam);
00303
00304 bool ms_direct_nasty(spell_type monspell);
00305
00306 bool ms_useful_fleeing_out_of_sight(const monster* mon, spell_type monspell);
00307 bool ms_quick_get_away(const monster* mon, spell_type monspell);
00308 bool ms_waste_of_time(const monster* mon, spell_type monspell);
00309 bool ms_low_hitpoint_cast(const monster* mon, spell_type monspell);
00310
00311 bool mons_has_los_ability(monster_type mon_type);
00312 bool mons_has_los_attack(const monster* mon);
00313 bool mons_has_ranged_spell(const monster* mon, bool attack_only = false,
00314 bool ench_too = true);
00315 bool mons_has_ranged_attack(const monster* mon);
00316 bool mons_has_ranged_ability(const monster* mon);
00317
00318 const char *mons_pronoun(monster_type mon_type, pronoun_type variant,
00319 bool visible = true);
00320
00321 bool mons_aligned(const actor *m1, const actor *m2);
00322 bool mons_atts_aligned(mon_attitude_type fr1, mon_attitude_type fr2);
00323
00324 bool mons_att_wont_attack(mon_attitude_type fr);
00325 mon_attitude_type mons_attitude(const monster* m);
00326
00327 bool mons_foe_is_mons(const monster* mons);
00328
00329 bool mons_behaviour_perceptible(const monster* mon);
00330 bool mons_is_native_in_branch(const monster* mons,
00331 const branch_type branch = you.where_are_you);
00332 bool mons_is_poisoner(const monster* mon);
00333
00334
00335
00336 bool mons_is_confused(const monster* m, bool class_too = false);
00337
00338 bool mons_is_wandering(const monster* m);
00339 bool mons_is_seeking(const monster* m);
00340 bool mons_is_fleeing(const monster* m);
00341 bool mons_is_panicking(const monster* m);
00342 bool mons_is_cornered(const monster* m);
00343 bool mons_is_lurking(const monster* m);
00344 bool mons_is_batty(const monster* m);
00345 bool mons_is_influenced_by_sanctuary(const monster* m);
00346 bool mons_is_fleeing_sanctuary(const monster* m);
00347 bool mons_was_seen(const monster* m);
00348 bool mons_is_known_mimic(const monster* m);
00349 bool mons_is_unknown_mimic(const monster* m);
00350 bool mons_is_skeletal(int mc);
00351 bool mons_class_is_slime(int mc);
00352 bool mons_is_slime(const monster* mon);
00353 bool mons_class_is_plant(int mc);
00354 bool mons_is_plant(const monster* mon);
00355 bool mons_eats_items(const monster* mon);
00356 bool mons_eats_corpses(const monster* mon);
00357 bool mons_eats_food(const monster* mon);
00358 monster_type mons_genus(int mc);
00359 monster_type mons_detected_base(monster_type mt);
00360 monster_type mons_species(int mc);
00361
00362 bool mons_looks_stabbable(const monster* m);
00363 bool mons_looks_distracted(const monster* m);
00364
00365 void mons_start_fleeing_from_sanctuary(monster* mons);
00366 void mons_stop_fleeing_from_sanctuary(monster* mons);
00367
00368 bool mons_landlubbers_in_reach(const monster* mons);
00369
00370 bool mons_class_is_confusable(int mc);
00371 bool mons_class_is_slowable(int mc);
00372 bool mons_class_is_stationary(int mc);
00373 bool mons_is_stationary(const monster* mon);
00374 bool mons_class_is_firewood(int mc);
00375 bool mons_is_firewood(const monster* mon);
00376 bool mons_has_body(const monster* mon);
00377
00378 int cheibriados_monster_player_speed_delta(const monster* mon);
00379 bool cheibriados_thinks_mons_is_fast(const monster* mon);
00380 bool mons_is_projectile(int mc);
00381 bool mons_has_blood(int mc);
00382
00383 bool invalid_monster(const monster* mon);
00384 bool invalid_monster_type(monster_type mt);
00385 bool invalid_monster_index(int i);
00386
00387 void mons_remove_from_grid(const monster* mon);
00388
00389 bool monster_shover(const monster* m);
00390
00391 bool monster_senior(const monster* first, const monster* second,
00392 bool fleeing = false);
00393 monster_type draco_subspecies(const monster* mon);
00394 std::string ugly_thing_colour_name(uint8_t colour);
00395 std::string ugly_thing_colour_name(const monster* mon);
00396 uint8_t ugly_thing_random_colour();
00397 int str_to_ugly_thing_colour(const std::string &s);
00398 uint8_t random_monster_colour();
00399 uint8_t random_large_abomination_colour();
00400 uint8_t random_small_abomination_colour();
00401 int ugly_thing_colour_offset(const uint8_t colour);
00402 std::string draconian_colour_name(monster_type mon_type);
00403 monster_type draconian_colour_by_name(const std::string &colour);
00404
00405 monster_type random_monster_at_grid(const coord_def& p);
00406 monster_type random_monster_at_grid(dungeon_feature_type grid);
00407
00408 void init_mon_name_cache();
00409 monster_type get_monster_by_name(std::string name, bool exact = false);
00410
00411 std::string do_mon_str_replacements(const std::string &msg,
00412 const monster* mons, int s_type = -1);
00413
00414 mon_body_shape get_mon_shape(const monster* mon);
00415 mon_body_shape get_mon_shape(const int type);
00416
00417 std::string get_mon_shape_str(const monster* mon);
00418 std::string get_mon_shape_str(const int type);
00419 std::string get_mon_shape_str(const mon_body_shape shape);
00420
00421 bool mons_class_can_pass(int mc, const dungeon_feature_type grid);
00422 bool mons_can_open_door(const monster* mon, const coord_def& pos);
00423 bool mons_can_eat_door(const monster* mon, const coord_def& pos);
00424 bool mons_can_traverse(const monster* mon, const coord_def& pos,
00425 bool checktraps = true);
00426
00427 mon_inv_type equip_slot_to_mslot(equipment_type eq);
00428 mon_inv_type item_to_mslot(const item_def &item);
00429
00430 int scan_mon_inv_randarts(const monster* mon,
00431 artefact_prop_type ra_prop);
00432
00433 bool player_or_mon_in_sanct(const monster* mons);
00434
00435 int get_dist_to_nearest_monster();
00436 actor *actor_by_mid(mid_t m);
00437 monster *monster_by_mid(mid_t m);
00438
00439 bool mons_is_tentacle(int mc);
00440 void init_anon();
00441 actor *find_agent(mid_t m, kill_category kc);
00442 const char* mons_class_name(monster_type mc);
00443
00444 #endif