1 #pragma once 2 3 #include "enchant-type.h" 4 #include "externs.h" 5 #include "kill-category.h" 6 7 #define INFINITE_DURATION 30000 8 #define MAX_ENCH_DEGREE_DEFAULT 4 9 #define MAX_ENCH_DEGREE_ABJURATION 6 10 11 class actor; 12 class monster; 13 14 void update_mons_cloud_ring(monster* mons); 15 16 class mon_enchant 17 { 18 public: 19 enchant_type ench; 20 int degree; // The higher the degree, the faster the degree 21 // decays, but degrees of 1 do not decay -- they 22 // just run out when the duration does. 23 int duration, maxduration; 24 kill_category who; // Source's alignment. 25 mid_t source; // Who set this enchantment? 26 27 public: 28 mon_enchant(enchant_type e = ENCH_NONE, int deg = 0, 29 const actor *whose = 0, 30 int dur = 0); 31 32 killer_type killer() const; 33 int kill_agent() const; 34 actor* agent() const; 35 36 operator string () const; 37 const char *kill_category_desc(kill_category) const; 38 void merge_killer(kill_category who, mid_t whos); 39 void cap_degree(); 40 41 void set_duration(const monster* mons, const mon_enchant *exist); 42 43 bool operator < (const mon_enchant &other) const 44 { 45 return ench < other.ench; 46 } 47 48 bool operator == (const mon_enchant &other) const 49 { 50 // NOTE: This does *not* check who/degree. 51 return ench == other.ench; 52 } 53 54 mon_enchant &operator += (const mon_enchant &other); 55 mon_enchant operator + (const mon_enchant &other) const; 56 57 private: 58 int modded_speed(const monster* mons, int hdplus) const; 59 int calc_duration(const monster* mons, const mon_enchant *added) const; 60 }; 61 62 enchant_type name_to_ench(const char *name); 63