00001
00002
00003
00004
00005
00006
00007
00008 #ifndef SPL_UTIL_H
00009 #define SPL_UTIL_H
00010
00011 #include "enum.h"
00012
00013 enum spschool_flag_type
00014 {
00015 SPTYP_NONE = 0,
00016 SPTYP_CONJURATION = 1<<0,
00017 SPTYP_HEXES = 1<<1,
00018 SPTYP_CHARMS = 1<<2,
00019 SPTYP_FIRE = 1<<3,
00020 SPTYP_ICE = 1<<4,
00021 SPTYP_TRANSMUTATION = 1<<5,
00022 SPTYP_NECROMANCY = 1<<6,
00023 SPTYP_SUMMONING = 1<<7,
00024 SPTYP_DIVINATION = 1<<8,
00025 SPTYP_TRANSLOCATION = 1<<9,
00026 SPTYP_POISON = 1<<10,
00027 SPTYP_EARTH = 1<<11,
00028 SPTYP_AIR = 1<<12,
00029 SPTYP_HOLY = 1<<13,
00030 SPTYP_LAST_EXPONENT = 13,
00031 NUM_SPELL_TYPES = 15,
00032 SPTYP_RANDOM = 1<<14,
00033 };
00034
00035 struct bolt;
00036 class dist;
00037
00038 enum spell_highlight_colours
00039 {
00040 COL_UNKNOWN = LIGHTGRAY,
00041 COL_UNMEMORIZED = LIGHTBLUE,
00042 COL_MEMORIZED = LIGHTGRAY,
00043 COL_USELESS = DARKGRAY,
00044 COL_INAPPLICABLE = COL_USELESS,
00045 COL_FORBIDDEN = LIGHTRED,
00046
00047 COL_EMPOWERED = LIGHTGREEN,
00048 COL_FAVORED = GREEN,
00049 };
00050
00051 bool is_valid_spell(spell_type spell);
00052 void init_spell_descs(void);
00053 void init_spell_name_cache();
00054 spell_type spell_by_name(std::string name, bool partial_match = false);
00055
00056 spschool_flag_type school_by_name(std::string name);
00057
00058 int get_spell_slot_by_letter(char letter);
00059 int get_spell_slot(spell_type spell);
00060 spell_type get_spell_by_letter(char letter);
00061
00062 bool add_spell_to_memory(spell_type spell);
00063 bool del_spell_from_memory_by_slot(int slot);
00064 bool del_spell_from_memory(spell_type spell);
00065
00066 int spell_hunger(spell_type which_spell, bool rod = false);
00067 int spell_mana(spell_type which_spell);
00068 int spell_difficulty(spell_type which_spell);
00069 int spell_power_cap(spell_type spell);
00070 int spell_range(spell_type spell, int pow, bool real_cast,
00071 bool player_spell=true);
00072 int spell_noise(spell_type spell);
00073 int spell_noise(unsigned int disciplines, int level);
00074
00075 const char *get_spell_target_prompt(spell_type which_spell);
00076
00077 bool spell_needs_tracer(spell_type spell);
00078 bool spell_is_direct_explosion(spell_type spell);
00079 bool spell_needs_foe(spell_type spell);
00080 bool spell_harms_target(spell_type spell);
00081 bool spell_harms_area(spell_type spell);
00082 bool spell_sanctuary_castable(spell_type spell);
00083 int spell_levels_required(spell_type which_spell);
00084
00085 unsigned int get_spell_flags(spell_type which_spell);
00086
00087 bool spell_typematch(spell_type which_spell, unsigned int which_discipline);
00088 unsigned int get_spell_disciplines(spell_type which_spell);
00089 bool disciplines_conflict(unsigned int disc1, unsigned int disc2);
00090 int count_bits(unsigned int bits);
00091
00092 const char *spell_title(spell_type which_spell);
00093 const char* spelltype_short_name(int which_spelltype);
00094 const char* spelltype_long_name(int which_spelltype);
00095
00096 typedef int cell_func(coord_def where, int pow, int aux, actor *agent);
00097 typedef int monster_func(monster* mon, int pow);
00098 typedef int cloud_func(coord_def where, int pow, int spreadrate,
00099 cloud_type type, const actor* agent, int colour,
00100 std::string name, std::string tile);
00101
00102 int apply_area_visible(cell_func cf, int power,
00103 bool pass_through_trans = false, actor *agent = NULL);
00104
00105 int apply_area_square(cell_func cf, const coord_def& where, int power,
00106 actor *agent = NULL);
00107
00108 int apply_area_around_square(cell_func cf, const coord_def& where, int power,
00109 actor *agent = NULL);
00110
00111 int apply_monsters_around_square(monster_func mf, const coord_def& where,
00112 int power);
00113
00114 int apply_random_around_square(cell_func cf, const coord_def& where,
00115 bool hole_in_middle, int power, int max_targs,
00116 actor *agent = NULL);
00117
00118 int apply_one_neighbouring_square(cell_func cf, int power, actor *agent = NULL);
00119
00120 int apply_area_within_radius(cell_func cf, const coord_def& where,
00121 int pow, int radius, int ctype,
00122 actor *agent = NULL);
00123
00124 void apply_area_cloud(cloud_func func, const coord_def& where,
00125 int pow, int number, cloud_type ctype,
00126 const actor *agent,
00127 int spread_rate = -1, int colour = -1,
00128 std::string name = "", std::string tile = "");
00129
00130 bool spell_direction(dist &spelld, bolt &pbolt,
00131 targeting_type restrict = DIR_NONE,
00132 targ_mode_type mode = TARG_HOSTILE,
00133
00134 int range = 0,
00135 bool needs_path = true, bool may_target_monster = true,
00136 bool may_target_self = false,
00137 const char *target_prefix = NULL,
00138 const char *prompt = NULL,
00139 bool cancel_at_self = false);
00140
00141 skill_type spell_type2skill (unsigned int which_spelltype);
00142
00143 spell_type zap_type_to_spell(zap_type zap);
00144
00145 bool spell_is_useless(spell_type spell, bool transient = false);
00146 bool spell_is_empowered(spell_type spell);
00147 bool spell_is_useful(spell_type spell);
00148 bool spell_is_risky(spell_type spell);
00149
00150 int spell_highlight_by_utility(spell_type spell,
00151 int default_color = COL_UNKNOWN,
00152 bool transient = false,
00153 bool rod_spell = false);
00154 bool spell_no_hostile_in_range(spell_type spell, int minRange);
00155
00156 #endif