00001 #ifndef MONSTER_H
00002 #define MONSTER_H
00003
00004 #include "actor.h"
00005 #include <stdint.h>
00006
00007 const int KRAKEN_TENTACLE_RANGE = 3;
00008 #define TIDE_CALL_TURN "tide-call-turn"
00009
00010 #define MAX_DAMAGE_COUNTER 10000
00011
00012 class mon_enchant
00013 {
00014 public:
00015 enchant_type ench;
00016 int degree;
00017 int duration, maxduration;
00018 kill_category who;
00019
00020 public:
00021 mon_enchant(enchant_type e = ENCH_NONE, int deg = 0,
00022 kill_category whose = KC_OTHER,
00023 int dur = 0);
00024
00025 killer_type killer() const;
00026 int kill_agent() const;
00027
00028 operator std::string () const;
00029 const char *kill_category_desc(kill_category) const;
00030 void merge_killer(kill_category who);
00031 void cap_degree();
00032
00033 void set_duration(const monster* mons, const mon_enchant *exist);
00034
00035 bool operator < (const mon_enchant &other) const
00036 {
00037 return (ench < other.ench);
00038 }
00039
00040 bool operator == (const mon_enchant &other) const
00041 {
00042
00043 return (ench == other.ench);
00044 }
00045
00046 mon_enchant &operator += (const mon_enchant &other);
00047 mon_enchant operator + (const mon_enchant &other) const;
00048
00049 private:
00050 int modded_speed(const monster* mons, int hdplus) const;
00051 int calc_duration(const monster* mons, const mon_enchant *added) const;
00052 };
00053
00054 enchant_type name_to_ench(const char *name);
00055
00056 typedef std::map<enchant_type, mon_enchant> mon_enchant_list;
00057
00058 struct monsterentry;
00059
00060 class monster : public actor
00061 {
00062 public:
00063 monster();
00064 monster(const monster& other);
00065 ~monster();
00066
00067 monster& operator = (const monster& other);
00068 void reset();
00069
00070 public:
00071
00072 std::string mname;
00073
00074 int hit_points;
00075 int max_hit_points;
00076 int hit_dice;
00077 int ac;
00078 int ev;
00079 int speed;
00080 int speed_increment;
00081
00082 coord_def target;
00083 coord_def patrol_point;
00084 mutable montravel_target_type travel_target;
00085 std::vector<coord_def> travel_path;
00086 FixedVector<short, NUM_MONSTER_SLOTS> inv;
00087 monster_spells spells;
00088 mon_attitude_type attitude;
00089 beh_type behaviour;
00090 unsigned short foe;
00091 int8_t ench_countdown;
00092 mon_enchant_list enchantments;
00093 uint64_t flags;
00094
00095 unsigned int experience;
00096 monster_type base_monster;
00097 unsigned int number;
00098 int colour;
00099
00100 int foe_memory;
00101
00102
00103 int shield_blocks;
00104
00105 god_type god;
00106
00107
00108 std::auto_ptr<ghost_demon> ghost;
00109
00110 std::string seen_context;
00111
00112
00113 int damage_friendly;
00114 int damage_total;
00115
00116 CrawlHashTable props;
00117
00118 public:
00119 void set_new_monster_id();
00120
00121 mon_attitude_type temp_attitude() const;
00122
00123
00124
00125 bool is_named() const;
00126
00127
00128
00129 bool has_base_name() const;
00130
00131 const monsterentry *find_monsterentry() const;
00132 monster_type get_mislead_type() const;
00133
00134 void init_experience();
00135
00136 void mark_summoned(int longevity, bool mark_items_summoned,
00137 int summon_type = 0);
00138 bool is_summoned(int* duration = NULL, int* summon_type = NULL) const;
00139 bool has_action_energy() const;
00140 void check_redraw(const coord_def &oldpos) const;
00141 void apply_location_effects(const coord_def &oldpos,
00142 killer_type killer = KILL_NONE,
00143 int killernum = -1);
00144
00145 void moveto(const coord_def& c);
00146 bool move_to_pos(const coord_def &newpos);
00147 bool blink_to(const coord_def& c, bool quiet = false);
00148
00149 kill_category kill_alignment() const;
00150
00151 int foe_distance() const;
00152 bool needs_berserk(bool check_spells = true) const;
00153
00154
00155 bool has_hydra_multi_attack() const;
00156 bool has_multitargeting() const;
00157
00158
00159 bool can_use_spells() const;
00160
00161
00162 bool is_priest() const;
00163
00164
00165
00166 bool is_actual_spellcaster() const;
00167
00168
00169 bool is_shapeshifter() const;
00170
00171 bool has_ench(enchant_type ench) const;
00172 bool has_ench(enchant_type ench, enchant_type ench2) const;
00173 mon_enchant get_ench(enchant_type ench,
00174 enchant_type ench2 = ENCH_NONE) const;
00175 bool add_ench(const mon_enchant &);
00176 void update_ench(const mon_enchant &);
00177 bool del_ench(enchant_type ench, bool quiet = false, bool effect = true);
00178 bool lose_ench_duration(const mon_enchant &e, int levels);
00179 bool lose_ench_levels(const mon_enchant &e, int lev);
00180 void lose_energy(energy_use_type et, int div = 1, int mult = 1);
00181
00182 void scale_hp(int num, int den);
00183 bool gain_exp(int exp);
00184
00185 void react_to_damage(const actor *oppressor, int damage, beam_type flavour);
00186
00187 void forget_random_spell();
00188
00189 void add_enchantment_effect(const mon_enchant &me, bool quiet = false);
00190 void remove_enchantment_effect(const mon_enchant &me, bool quiet = false);
00191 void apply_enchantments();
00192 void apply_enchantment(const mon_enchant &me);
00193
00194 bool can_drink_potion(potion_type ptype) const;
00195 bool should_drink_potion(potion_type ptype) const;
00196 item_type_id_state_type drink_potion_effect(potion_type pot_eff);
00197
00198 void timeout_enchantments(int levels);
00199
00200 bool is_travelling() const;
00201 bool is_patrolling() const;
00202 bool needs_transit() const;
00203 void set_transit(const level_id &destination);
00204 bool find_place_to_live(bool near_player = false);
00205 bool find_home_near_place(const coord_def &c);
00206 bool find_home_near_player();
00207 bool find_home_anywhere();
00208
00209 void set_ghost(const ghost_demon &ghost, bool has_name = true);
00210 void ghost_init();
00211 void pandemon_init();
00212 void dancing_weapon_init();
00213 void labrat_init();
00214 void uglything_init(bool only_mutate = false);
00215 void uglything_mutate(uint8_t force_colour = BLACK);
00216 void uglything_upgrade();
00217 void destroy_inventory();
00218 void load_spells(mon_spellbook_type spellbook);
00219
00220 actor *get_foe() const;
00221
00222
00223 int mindex() const;
00224 int get_experience_level() const;
00225 god_type deity() const;
00226 bool alive() const;
00227 bool defined() const { return alive(); }
00228 bool swimming() const;
00229 bool wants_submerge() const;
00230
00231 bool submerged() const;
00232 bool can_drown() const;
00233 bool floundering() const;
00234 bool extra_balanced() const;
00235 bool can_pass_through_feat(dungeon_feature_type grid) const;
00236 bool is_habitable_feat(dungeon_feature_type actual_grid) const;
00237 size_type body_size(size_part_type psize = PSIZE_TORSO,
00238 bool base = false) const;
00239 int body_weight(bool base = false) const;
00240 int total_weight() const;
00241 int damage_brand(int which_attack = -1);
00242 int damage_type(int which_attack = -1);
00243
00244 item_def *slot_item(equipment_type eq, bool include_melded=false);
00245 item_def *mslot_item(mon_inv_type sl) const;
00246 item_def *weapon(int which_attack = -1);
00247 item_def *launcher();
00248 item_def *missiles();
00249 item_def *shield();
00250
00251 bool can_wield(const item_def &item,
00252 bool ignore_curse = false,
00253 bool ignore_brand = false,
00254 bool ignore_shield = false,
00255 bool ignore_transform = false) const;
00256 bool could_wield(const item_def &item,
00257 bool ignore_brand = false,
00258 bool ignore_transform = false) const;
00259
00260 int missile_count();
00261 void wield_melee_weapon(int near = -1);
00262 void swap_weapons(int near = -1);
00263
00264 bool pickup_item(item_def &item, int near = -1, bool force = false);
00265 void pickup_message(const item_def &item, int near);
00266 bool pickup_wand(item_def &item, int near);
00267 bool pickup_scroll(item_def &item, int near);
00268 bool pickup_potion(item_def &item, int near);
00269 bool pickup_gold(item_def &item, int near);
00270 bool pickup_launcher(item_def &launcher, int near, bool force = false);
00271 bool pickup_melee_weapon(item_def &item, int near);
00272 bool pickup_throwable_weapon(item_def &item, int near);
00273 bool pickup_weapon(item_def &item, int near, bool force);
00274 bool pickup_armour(item_def &item, int near, bool force);
00275 bool pickup_misc(item_def &item, int near);
00276 bool pickup_missile(item_def &item, int near, bool force);
00277 void equip(item_def &item, int slot, int near = -1);
00278 bool unequip(item_def &item, int slot, int near = -1,
00279 bool force = false);
00280
00281 bool can_use_missile(const item_def &item) const;
00282
00283 std::string name(description_level_type type,
00284 bool force_visible = false) const;
00285
00286
00287
00288
00289 std::string base_name(description_level_type type,
00290 bool force_visible = false) const;
00291
00292
00293 std::string full_name(description_level_type type,
00294 bool use_comma = false) const;
00295 std::string pronoun(pronoun_type pro, bool force_visible = false) const;
00296 std::string conj_verb(const std::string &verb) const;
00297 std::string hand_name(bool plural, bool *can_plural = NULL) const;
00298 std::string foot_name(bool plural, bool *can_plural = NULL) const;
00299 std::string arm_name(bool plural, bool *can_plural = NULL) const;
00300
00301 bool fumbles_attack(bool verbose = true);
00302 bool cannot_fight() const;
00303
00304 int skill(skill_type skill, bool skill_bump = false) const;
00305
00306 void attacking(actor *other);
00307 bool can_go_berserk() const;
00308 void go_berserk(bool intentional, bool potion = false);
00309 void go_frenzy();
00310 bool berserk() const;
00311 bool frenzied() const;
00312 bool has_lifeforce() const;
00313 bool can_mutate() const;
00314 bool can_safely_mutate() const;
00315 bool can_bleed() const;
00316 bool mutate();
00317 void banish(const std::string &who = "");
00318 void expose_to_element(beam_type element, int strength = 0);
00319
00320 int mons_species() const;
00321
00322 mon_holy_type holiness() const;
00323 bool undead_or_demonic() const;
00324 bool is_holy() const;
00325 bool is_unholy() const;
00326 bool is_evil() const;
00327 bool is_unclean() const;
00328 bool is_known_chaotic() const;
00329 bool is_chaotic() const;
00330 bool is_artificial() const;
00331 bool is_unbreathing() const;
00332 bool is_insubstantial() const;
00333 int res_hellfire() const;
00334 int res_fire() const;
00335 int res_steam() const;
00336 int res_cold() const;
00337 int res_elec() const;
00338 int res_poison(bool temp = true) const;
00339 int res_rotting(bool temp = true) const;
00340 int res_asphyx() const;
00341 int res_water_drowning() const;
00342 int res_sticky_flame() const;
00343 int res_holy_energy(const actor *) const;
00344 int res_negative_energy() const;
00345 int res_torment() const;
00346 int res_acid() const;
00347 int res_wind() const;
00348 int res_magic() const;
00349
00350 flight_type flight_mode() const;
00351 bool is_levitating() const;
00352 bool is_wall_clinging() const;
00353 bool can_cling_to(const coord_def& p) const;
00354 bool invisible() const;
00355 bool can_see_invisible() const;
00356 bool visible_to(const actor *looker) const;
00357 bool near_foe() const;
00358 reach_type reach_range() const;
00359
00360 bool is_icy() const;
00361 bool is_fiery() const;
00362 bool is_skeletal() const;
00363 bool paralysed() const;
00364 bool cannot_move() const;
00365 bool cannot_act() const;
00366 bool confused() const;
00367 bool confused_by_you() const;
00368 bool caught() const;
00369 bool asleep() const;
00370 bool backlit(bool check_haloed = true, bool self_halo = true) const;
00371 int halo_radius2() const;
00372 int silence_radius2() const;
00373 int liquefying_radius2 () const;
00374 bool glows_naturally() const;
00375 bool petrified() const;
00376 bool petrifying() const;
00377
00378 bool friendly() const;
00379 bool neutral() const;
00380 bool good_neutral() const;
00381 bool strict_neutral() const;
00382 bool wont_attack() const;
00383 bool pacified() const;
00384 bool withdrawn() const {return has_ench(ENCH_WITHDRAWN);};
00385
00386 bool has_spells() const;
00387 bool has_spell(spell_type spell) const;
00388 bool has_holy_spell() const;
00389 bool has_unholy_spell() const;
00390 bool has_evil_spell() const;
00391 bool has_unclean_spell() const;
00392 bool has_chaotic_spell() const;
00393
00394 bool has_attack_flavour(int flavour) const;
00395 bool has_damage_type(int dam_type);
00396
00397 bool can_throw_large_rocks() const;
00398 bool can_speak();
00399
00400 int armour_class() const;
00401 int melee_evasion(const actor *attacker, ev_ignore_type evit) const;
00402
00403 void poison(actor *agent, int amount = 1, bool force = false);
00404 bool sicken(int strength);
00405 bool bleed(int amount, int degree);
00406 void paralyse(actor *, int str);
00407 void petrify(actor *, int str);
00408 void slow_down(actor *, int str);
00409 void confuse(actor *, int strength);
00410 bool drain_exp(actor *, bool quiet = false, int pow = 3);
00411 bool rot(actor *, int amount, int immediate = 0, bool quiet = false);
00412 int hurt(const actor *attacker, int amount,
00413 beam_type flavour = BEAM_MISSILE,
00414 bool cleanup_dead = true);
00415 bool heal(int amount, bool max_too = false);
00416 void blink(bool allow_partial_control = true);
00417 void teleport(bool right_now = false,
00418 bool abyss_shift = false,
00419 bool wizard_tele = false);
00420
00421 void hibernate(int power = 0);
00422 void put_to_sleep(actor *attacker, int power = 0);
00423 void check_awaken(int disturbance);
00424 int beam_resists(bolt &beam, int hurted, bool doEffects, std::string source = "");
00425
00426 int stat_hp() const { return hit_points; }
00427 int stat_maxhp() const { return max_hit_points; }
00428
00429 int shield_bonus() const;
00430 int shield_block_penalty() const;
00431 void shield_block_succeeded(actor *foe);
00432 int shield_bypass_ability(int tohit) const;
00433
00434 actor_type atype() const { return ACT_MONSTER; }
00435 monster* as_monster() { return this; }
00436 player* as_player() { return NULL; }
00437 const monster* as_monster() const { return this; }
00438 const player* as_player() const { return NULL; }
00439
00440
00441 void check_speed();
00442 void upgrade_type(monster_type after, bool adjust_hd, bool adjust_hp);
00443
00444 std::string describe_enchantments() const;
00445
00446 int action_energy(energy_use_type et) const;
00447
00448 bool do_shaft();
00449 bool has_spell_of_type(unsigned) const;
00450
00451 void bind_melee_flags();
00452 void bind_spell_flags();
00453 void calc_speed();
00454
00455 private:
00456 void init_with(const monster& mons);
00457 void swap_slots(mon_inv_type a, mon_inv_type b);
00458 bool need_message(int &near) const;
00459 bool level_up();
00460 bool level_up_change();
00461 bool pickup(item_def &item, int slot, int near, bool force_merge = false);
00462 void equip_weapon(item_def &item, int near, bool msg = true);
00463 void equip_armour(item_def &item, int near);
00464 void unequip_weapon(item_def &item, int near, bool msg = true);
00465 void unequip_armour(item_def &item, int near);
00466
00467 bool decay_enchantment(const mon_enchant &me, bool decay_degree = true);
00468
00469 bool drop_item(int eslot, int near);
00470 bool wants_weapon(const item_def &item) const;
00471 bool wants_armour(const item_def &item) const;
00472 void lose_pickup_energy();
00473 bool check_set_valid_home(const coord_def &place,
00474 coord_def &chosen,
00475 int &nvalid) const;
00476 };
00477
00478 #endif