4 #include "itemprop-enum.h"
5 #include "random-var.h"
8 #define CLING_KEY "clinging" // 'is creature clinging' property key
13 EV_IGNORE_HELPLESS = 1<<0,
14 EV_IGNORE_PHASESHIFT = 1<<1,
15 EV_IGNORE_UNIDED = 1<<2,
17 DEF_BITFIELD(ev_ignore_type, ev_ignore_bit);
28 virtual int mindex() const = 0;
30 virtual bool is_player() const = 0;
31 bool is_monster() const { return !is_player(); }
32 virtual monster* as_monster() = 0;
33 virtual player* as_player() = 0;
34 virtual const monster* as_monster() const = 0;
35 virtual const player* as_player() const = 0;
37 virtual kill_category kill_alignment() const = 0;
38 virtual god_type deity() const = 0;
40 virtual bool alive() const = 0;
42 // Should return false for perma-summoned things.
43 virtual bool is_summoned(int* duration = nullptr,
44 int* summon_type = nullptr) const = 0;
46 virtual bool is_perm_summoned() const = 0;
48 // [ds] Low-level moveto() - moves the actor without updating relevant
49 // grids, such as mgrd.
50 virtual void moveto(const coord_def &c, bool clear_net = true) = 0;
52 // High-level actor movement. If in doubt, use this. Returns false if the
53 // actor cannot be moved to the target, possibly because it is already
55 virtual bool move_to_pos(const coord_def &c, bool clear_net = true,
56 bool force = false) = 0;
58 virtual void apply_location_effects(const coord_def &oldpos,
59 killer_type killer = KILL_NONE,
60 int killernum = -1) = 0;
62 virtual void set_position(const coord_def &c);
63 const coord_def& pos() const { return position; }
65 virtual bool self_destructs() { return false; }
67 // Blink the actor to the destination. c should be a
68 // valid target, though the method returns false
69 // if the blink fails.
70 virtual bool blink_to(const coord_def &c, bool quiet = false) = 0;
72 virtual bool swimming() const = 0;
73 virtual bool submerged() const = 0;
74 virtual bool floundering() const = 0;
76 // Returns true if the actor is exceptionally well balanced.
77 virtual bool extra_balanced() const = 0;
79 virtual int get_hit_dice() const = 0;
80 virtual int get_experience_level() const = 0;
82 virtual bool shove(const char* feat_name = "") = 0;
83 virtual bool can_pass_through_feat(dungeon_feature_type grid) const = 0;
84 virtual bool can_pass_through(int x, int y) const;
85 virtual bool can_pass_through(const coord_def &c) const;
87 virtual bool is_habitable_feat(dungeon_feature_type actual_grid) const = 0;
88 bool is_habitable(const coord_def &pos) const;
90 virtual size_type body_size(size_part_type psize = PSIZE_TORSO,
91 bool base = false) const = 0;
93 virtual brand_type damage_brand(int which_attack = -1) = 0;
94 virtual int damage_type(int which_attack = -1) = 0;
95 virtual item_def *weapon(int which_attack = -1) const = 0;
96 const item_def *primary_weapon() const
100 virtual random_var attack_delay(const item_def *weapon,
101 const item_def *projectile = nullptr,
102 bool random = true, bool scaled = true,
105 virtual int has_claws(bool allow_tran = true) const = 0;
106 virtual item_def *shield() const = 0;
107 virtual item_def *slot_item(equipment_type eq,
108 bool include_melded=false) const = 0;
109 virtual int wearing(equipment_type slot, int sub_type,
110 bool calc_unid = true) const = 0;
111 virtual int wearing_ego(equipment_type slot, int sub_type,
112 bool calc_unid = true) const = 0;
113 virtual int scan_artefacts(artefact_prop_type which_property,
114 bool calc_unid = true,
115 vector<item_def> *matches = nullptr) const = 0;
117 virtual hands_reqd_type hands_reqd(const item_def &item) const;
119 bool can_wield(const item_def* item,
120 bool ignore_curse = false,
121 bool ignore_brand = false,
122 bool ignore_shield = false,
123 bool ignore_transform = false) const;
124 virtual bool can_wield(const item_def &item,
125 bool ignore_curse = false,
126 bool ignore_brand = false,
127 bool ignore_shield = false,
128 bool ignore_transform = false) const = 0;
129 virtual bool could_wield(const item_def &item,
130 bool ignore_brand = false,
131 bool ignore_transform = false,
132 bool quiet = true) const = 0;
134 virtual void make_hungry(int nutrition, bool silent = true)
138 virtual void lose_energy(energy_use_type, int div = 1, int mult = 1)
141 virtual void gain_energy(energy_use_type, int div = 1, int mult = 1)
145 virtual string name(description_level_type type,
146 bool force_visible = false,
147 bool force_article = false) const = 0;
148 virtual string pronoun(pronoun_type which_pronoun,
149 bool force_visible = false) const = 0;
150 virtual string conj_verb(const string &verb) const = 0;
151 virtual string hand_name(bool plural, bool *can_plural = nullptr) const = 0;
152 virtual string foot_name(bool plural, bool *can_plural = nullptr) const = 0;
153 virtual string arm_name(bool plural, bool *can_plural = nullptr) const = 0;
155 virtual bool fumbles_attack() = 0;
157 virtual bool fights_well_unarmed(int heavy_armour_penalty)
161 // Returns true if the actor has no way to attack (plants, statues).
162 // (statues have only indirect attacks).
163 virtual bool cannot_fight() const = 0;
164 virtual void attacking(actor *other, bool ranged = false) = 0;
165 virtual bool can_go_berserk() const = 0;
166 virtual bool go_berserk(bool intentional, bool potion = false) = 0;
167 virtual bool berserk() const = 0;
168 virtual bool can_see_invisible() const = 0;
169 virtual bool invisible() const = 0;
170 virtual bool nightvision() const = 0;
171 virtual reach_type reach_range() const = 0;
173 // Would looker be able to see the actor when in LOS?
174 virtual bool visible_to(const actor *looker) const = 0;
176 // Is the given cell within LOS of the actor?
177 virtual bool see_cell(const coord_def &c) const;
178 virtual bool see_cell_no_trans(const coord_def &c) const;
180 // Can the actor actually see the target?
181 virtual bool can_see(const actor *target) const;
183 // Visibility as required by messaging. In usual play:
184 // Does the player know what's happening to the actor?
185 bool observable() const;
187 virtual bool is_icy() const = 0;
188 virtual bool is_fiery() const = 0;
189 virtual bool is_skeletal() const = 0;
190 virtual bool can_mutate() const = 0;
191 virtual bool can_safely_mutate(bool temp = true) const = 0;
192 virtual bool can_polymorph() const = 0;
193 virtual bool can_bleed(bool allow_tran = true) const = 0;
194 virtual bool is_stationary() const = 0;
195 virtual bool malmutate(const string &reason) = 0;
196 virtual bool polymorph(int pow) = 0;
197 virtual bool drain_exp(actor *agent, bool quiet = false, int pow = 15) = 0;
198 virtual bool rot(actor *agent, int amount, bool quiet = false) = 0;
199 virtual int hurt(const actor *attacker, int amount,
200 beam_type flavour = BEAM_MISSILE,
201 kill_method_type kill_type = KILLED_BY_MONSTER,
204 bool cleanup_dead = true,
205 bool attacker_effects = true) = 0;
206 virtual bool heal(int amount, bool max_too = false) = 0;
207 virtual void banish(actor *agent, const string &who = "") = 0;
208 virtual void blink(bool allow_partial_control = true) = 0;
209 virtual void teleport(bool right_now = false,
210 bool wizard_tele = false) = 0;
211 virtual bool poison(actor *attacker, int amount = 1, bool force = false) = 0;
212 virtual bool sicken(int amount) = 0;
213 virtual void paralyse(actor *attacker, int strength, string source = "") = 0;
214 virtual void petrify(actor *attacker, bool force = false) = 0;
215 virtual bool fully_petrify(actor *foe, bool quiet = false) = 0;
216 virtual void slow_down(actor *attacker, int strength) = 0;
217 virtual void confuse(actor *attacker, int strength) = 0;
218 virtual void put_to_sleep(actor *attacker, int strength,
219 bool hibernate = false) = 0;
220 virtual void weaken(actor *attacker, int pow) = 0;
221 virtual void expose_to_element(beam_type element, int strength = 0,
222 bool slow_cold_blood = true) = 0;
223 virtual void drain_stat(stat_type stat, int amount) { }
224 virtual void splash_with_acid(const actor* evildoer, int acid_strength = -1,
225 bool allow_corrosion = true,
226 const char* hurt_msg = nullptr) = 0;
227 virtual void corrode_equipment(const char* corrosion_source = "the acid",
230 virtual bool can_hibernate(bool holi_only = false,
231 bool intrinsic_only = false) const;
232 virtual bool can_sleep(bool holi_only = false) const;
233 virtual void check_awaken(int disturbance) = 0;
234 virtual int beam_resists(bolt &beam, int hurted, bool doEffects,
235 string source = "") = 0;
237 virtual int skill(skill_type sk, int scale = 1,
238 bool real = false, bool drained = true) const = 0;
239 int skill_rdiv(skill_type sk, int mult = 1, int div = 1) const;
241 #define TORPOR_SLOWED_KEY "torpor_slowed"
242 bool torpor_slowed() const;
244 virtual int heads() const = 0;
246 virtual int stat_hp() const = 0;
247 virtual int stat_maxhp() const = 0;
249 virtual int stealth () const = 0;
251 virtual bool can_throw_large_rocks() const = 0;
253 virtual int armour_class(bool calc_unid = true) const = 0;
254 virtual int gdr_perc() const = 0;
255 int apply_ac(int damage, int max_damage = 0, ac_type ac_rule = AC_NORMAL,
256 int stab_bypass = 0) const;
257 virtual int evasion(ev_ignore_type ign = EV_IGNORE_NONE,
258 const actor *attacker = nullptr) const = 0;
259 virtual bool shielded() const = 0;
260 virtual int shield_bonus() const = 0;
261 virtual int shield_block_penalty() const = 0;
262 virtual int shield_bypass_ability(int tohit) const = 0;
263 virtual void shield_block_succeeded(actor *foe);
264 virtual int missile_deflection() const = 0; // 1 = RMsl, 2 = DMsl
265 virtual void ablate_deflection() = 0;
267 // Combat-related virtual class methods
268 virtual int unadjusted_body_armour_penalty() const = 0;
269 virtual int adjusted_body_armour_penalty(int scale = 1) const = 0;
270 virtual int adjusted_shield_penalty(int scale) const = 0;
271 virtual int armour_tohit_penalty(bool random_factor, int scale = 1) const = 0;
272 virtual int shield_tohit_penalty(bool random_factor, int scale = 1) const = 0;
274 virtual monster_type mons_species(bool zombie_base = false) const = 0;
276 virtual mon_holy_type holiness(bool temp = true) const = 0;
277 virtual bool undead_or_demonic() const = 0;
278 virtual bool holy_wrath_susceptible() const = 0;
279 virtual bool is_holy(bool spells = true) const = 0;
280 virtual bool is_unholy(bool spells = true) const = 0;
281 virtual bool is_evil(bool spells = true) const = 0;
282 virtual int how_chaotic(bool check_spells_god = false) const = 0;
283 virtual bool is_artificial(bool temp = true) const = 0;
284 virtual bool is_unbreathing() const = 0;
285 virtual bool is_insubstantial() const = 0;
286 virtual int res_acid(bool calc_unid = true) const = 0;
287 virtual bool res_hellfire() const = 0;
288 virtual int res_fire() const = 0;
289 virtual int res_steam() const = 0;
290 virtual int res_cold() const = 0;
291 virtual int res_elec() const = 0;
292 virtual int res_poison(bool temp = true) const = 0;
293 virtual int res_rotting(bool temp = true) const = 0;
294 virtual int res_water_drowning() const = 0;
295 virtual bool res_sticky_flame() const = 0;
296 virtual int res_holy_energy(const actor *attacker) const = 0;
297 virtual int res_negative_energy(bool intrinsic_only = false) const = 0;
298 virtual bool res_torment() const = 0;
299 virtual bool res_wind() const = 0;
300 virtual bool res_petrify(bool temp = true) const = 0;
301 virtual int res_constrict() const = 0;
302 virtual int res_magic() const = 0;
303 virtual int check_res_magic(int power);
304 virtual bool no_tele(bool calc_unid = true, bool permit_id = true,
305 bool blink = false) const = 0;
306 virtual bool inaccuracy() const;
307 virtual bool antimagic_susceptible() const = 0;
309 virtual bool gourmand(bool calc_unid = true, bool items = true) const;
311 virtual bool res_corr(bool calc_unid = true, bool items = true) const;
312 bool has_notele_item(bool calc_unid = true,
313 vector<item_def> *matches = nullptr) const;
314 virtual bool stasis(bool calc_unid = true, bool items = true) const;
315 virtual bool run(bool calc_unid = true, bool items = true) const;
316 virtual bool angry(bool calc_unid = true, bool items = true) const;
317 virtual bool clarity(bool calc_unid = true, bool items = true) const;
318 virtual bool faith(bool calc_unid = true, bool items = true) const;
319 virtual bool warding(bool calc_unid = true, bool items = true) const;
320 virtual int archmagi(bool calc_unid = true, bool items = true) const;
321 virtual bool no_cast(bool calc_unid = true, bool items = true) const;
323 virtual bool rmut_from_item(bool calc_unid = true) const;
324 virtual bool evokable_berserk(bool calc_unid = true) const;
325 virtual bool evokable_invis(bool calc_unid = true) const;
327 // Return an int so we know whether an item is the sole source.
328 virtual int evokable_flight(bool calc_unid = true) const;
329 virtual int spirit_shield(bool calc_unid = true, bool items = true) const;
331 virtual bool is_wall_clinging() const;
332 virtual bool is_banished() const = 0;
333 virtual bool can_cling_to_walls() const = 0;
334 virtual bool can_cling_to(const coord_def& p) const;
335 virtual bool check_clinging(bool stepped, bool door = false);
336 virtual void clear_clinging();
337 virtual bool is_web_immune() const = 0;
338 virtual bool airborne() const = 0;
339 virtual bool ground_level() const;
340 virtual bool stand_on_solid_ground() const;
342 virtual bool paralysed() const = 0;
343 virtual bool cannot_move() const = 0;
344 virtual bool cannot_act() const = 0;
345 virtual bool confused() const = 0;
346 virtual bool caught() const = 0;
347 virtual bool asleep() const { return false; }
349 // self_halo: include own halo (actually if self_halo = false
350 // and has a halo, returns false; so if you have a
351 // halo you're not affected by others' halos for this
353 virtual bool backlit(bool self_halo = true) const = 0;
354 virtual bool umbra() const = 0;
355 // Within any actor's halo?
356 virtual bool haloed() const;
358 virtual bool umbraed() const;
359 #if TAG_MAJOR_VERSION == 34
360 // Being heated by a heat aura?
361 virtual bool heated() const;
363 // Squared halo radius.
364 virtual int halo_radius2() const = 0;
365 // Squared silence radius.
366 virtual int silence_radius2() const = 0;
367 // Squared liquefying radius
368 virtual int liquefying_radius2() const = 0;
369 virtual int umbra_radius2() const = 0;
370 #if TAG_MAJOR_VERSION == 34
371 virtual int heat_radius2() const = 0;
374 virtual bool glows_naturally() const = 0;
376 virtual bool petrifying() const = 0;
377 virtual bool petrified() const = 0;
379 virtual bool liquefied_ground() const = 0;
381 virtual bool handle_trap();
383 virtual void god_conduct(conduct_type thing_done, int level) { }
385 virtual bool incapacitated() const
394 virtual bool wont_attack() const = 0;
395 virtual mon_attitude_type temp_attitude() const = 0;
397 virtual bool has_spell(spell_type spell) const = 0;
399 virtual bool will_trigger_shaft() const;
400 virtual level_id shaft_dest(bool known) const;
401 virtual bool do_shaft() = 0;
405 CrawlHashTable props;
407 int shield_blocks; // Count of shield blocks this round.
409 // Constriction stuff:
411 // What is holding us? Not necessarily a monster.
413 mid_t constricted_by;
416 // Map from mid to duration.
417 typedef map<mid_t, int> constricting_t;
418 // Freed and set to nullptr when empty.
419 constricting_t *constricting;
421 void start_constricting(actor &whom, int duration = 0);
423 void stop_constricting(mid_t whom, bool intentional = false,
425 void stop_constricting_all(bool intentional = false, bool quiet = false);
426 void stop_being_constricted(bool quiet = false);
428 bool can_constrict(actor* defender);
429 void clear_far_constrictions();
430 void accum_has_constricted();
431 void handle_constriction();
432 bool is_constricted() const;
433 bool is_constricting() const;
434 int num_constricting() const;
435 virtual bool has_usable_tentacle() const = 0;
436 virtual int constriction_damage() const = 0;
437 virtual bool clear_far_engulf() = 0;
439 // Be careful using this, as it doesn't keep the constrictor in sync.
440 void clear_constricted();
442 string describe_props() const;
444 string resist_margin_phrase(int margin) const;
446 void collide(coord_def newpos, const actor *agent, int pow);
449 void end_constriction(mid_t whom, bool intentional, bool quiet);
452 bool actor_slime_wall_immune(const actor *actor);