00001
00002
00003
00004
00005
00006
00007
00008 #ifndef BEAM_H
00009 #define BEAM_H
00010
00011
00012 #include "externs.h"
00013 #include "random.h"
00014 #include "ray.h"
00015
00016 class monster;
00017
00018 enum mon_resist_type
00019 {
00020 MON_RESIST,
00021 MON_UNAFFECTED,
00022 MON_AFFECTED,
00023 MON_OTHER,
00024 };
00025
00026 class dist;
00027
00028 typedef FixedArray<int, 19, 19> explosion_map;
00029
00030 struct tracer_info
00031 {
00032 int count;
00033 int power;
00034 int hurt;
00035 int helped;
00036 bool dont_stop;
00037
00038 tracer_info();
00039 void reset();
00040
00041 const tracer_info &operator += (const tracer_info &other);
00042 };
00043
00044 struct bolt;
00045
00046 typedef bool (*range_used_func)(const bolt& beam, const actor* victim,
00047 int &used);
00048 typedef bool (*beam_damage_func)(bolt& beam, actor* victim, int &dmg,
00049 std::string &dmg_msg);
00050 typedef bool (*beam_hit_func)(bolt& beam, actor* victim, int dmg,
00051 int corpse);
00052 typedef bool (*explosion_aoe_func)(bolt& beam, const coord_def& target);
00053 typedef bool (*beam_affect_func)(const bolt &beam, const actor *victim);
00054
00055 struct bolt
00056 {
00057
00058 spell_type origin_spell;
00059
00060 int range;
00061 unsigned glyph;
00062 int colour;
00063 beam_type flavour;
00064 beam_type real_flavour;
00065
00066
00067 bool drop_item;
00068 item_def* item;
00069 coord_def source;
00070 coord_def target;
00071 dice_def damage;
00072 int ench_power, hit;
00073 killer_type thrower;
00074 int ex_size;
00075
00076
00077
00078 int beam_source;
00079 std::string source_name;
00080
00081
00082
00083 std::string name;
00084 std::string short_name;
00085 std::string hit_verb;
00086
00087
00088
00089 int loudness;
00090 std::string noise_msg;
00091
00092 bool is_beam;
00093 bool is_explosion;
00094 bool is_big_cloud;
00095 bool aimed_at_spot;
00096 std::string aux_source;
00097
00098 bool affects_nothing;
00099 bool affects_items;
00100
00101 bool effect_known;
00102
00103 int draw_delay;
00104
00105 bolt* special_explosion;
00106
00107
00108 bool was_missile;
00109
00110
00111
00112 std::vector<range_used_func> range_funcs;
00113 std::vector<beam_damage_func> damage_funcs;
00114 std::vector<beam_hit_func> hit_funcs;
00115 std::vector<explosion_aoe_func> aoe_funcs;
00116
00117
00118
00119
00120 beam_affect_func affect_func;
00121
00122
00123 bool obvious_effect;
00124
00125 bool seen;
00126 bool heard;
00127
00128 std::vector<coord_def> path_taken;
00129
00130
00131 int extra_range_used;
00132 bool is_tracer;
00133 bool aimed_at_feet;
00134 bool msg_generated;
00135 bool noise_generated;
00136 bool passed_target;
00137 bool in_explosion_phase;
00138 bool smart_monster;
00139 bool can_see_invis;
00140 mon_attitude_type attitude;
00141 int foe_ratio;
00142
00143 tracer_info foe_info;
00144 tracer_info friend_info;
00145
00146 bool chose_ray;
00147 bool beam_cancelled;
00148 bool dont_stop_player;
00149
00150 int bounces;
00151 coord_def bounce_pos;
00152
00153
00154 int reflections;
00155 int reflector;
00156
00157 bool use_target_as_pos;
00158 bool auto_hit;
00159
00160 ray_def ray;
00161
00162 #ifdef USE_TILE
00163 int tile_beam;
00164 #endif
00165
00166 public:
00167 bolt();
00168
00169 bool is_enchantment() const;
00170 void set_target(const dist &targ);
00171 void set_agent(actor *agent);
00172 void setup_retrace();
00173
00174
00175 killer_type killer() const;
00176
00177 kill_category whose_kill() const;
00178
00179 actor* agent() const;
00180
00181 void fire();
00182
00183
00184
00185 std::string get_short_name() const;
00186 std::string get_source_name() const;
00187
00188
00189
00190 mon_resist_type apply_enchantment_to_monster(monster* mon);
00191
00192
00193 bool explode(bool show_more = true, bool hole_in_the_middle = false);
00194 bool knockback_actor(actor *actor);
00195
00196 bool visible() const;
00197
00198 bool can_affect_actor(const actor *act) const;
00199
00200 private:
00201 void do_fire();
00202 coord_def pos() const;
00203 coord_def leg_source() const;
00204
00205
00206 bool is_blockable() const;
00207 bool is_superhot() const;
00208 bool is_fiery() const;
00209 maybe_bool affects_wall(dungeon_feature_type wall) const;
00210 bool can_affect_wall_actor(const actor *act) const;
00211 bool actor_wall_shielded(const actor *act) const;
00212 bool is_bouncy(dungeon_feature_type feat) const;
00213 bool stop_at_target() const;
00214 bool has_saving_throw() const;
00215 bool is_harmless(const monster* mon) const;
00216 bool harmless_to_player() const;
00217 bool is_reflectable(const item_def *item) const;
00218 bool nasty_to(const monster* mon) const;
00219 bool nice_to(const monster* mon) const;
00220 bool found_player() const;
00221 bool need_regress() const;
00222
00223 int beam_source_as_target() const;
00224
00225 int range_used_on_hit(const actor* victim) const;
00226
00227 std::string zapper() const;
00228
00229 std::set<std::string> message_cache;
00230 void emit_message(msg_channel_type chan, const char* msg);
00231 void step();
00232 bool hit_wall();
00233
00234 bool damage_ignores_armour() const;
00235 bool apply_hit_funcs(actor* victim, int dmg, int corpse = -1);
00236 bool apply_dmg_funcs(actor* victim, int &dmg,
00237 std::vector<std::string> &messages);
00238
00239
00240
00241
00242 public:
00243 void affect_cell();
00244 void affect_wall();
00245 void affect_actor(actor *act);
00246 void affect_monster(monster* m);
00247 void affect_player();
00248 void affect_ground();
00249 void affect_place_clouds();
00250 void affect_place_explosion_clouds();
00251 void affect_endpoint();
00252
00253 void beam_hits_actor(actor *act);
00254
00255
00256 void affect_player_enchantment();
00257 void tracer_affect_player();
00258 void tracer_affect_monster(monster* mon);
00259 bool handle_statue_disintegration(monster* mon);
00260 void apply_bolt_paralysis(monster* mons);
00261 void apply_bolt_petrify(monster* mons);
00262 void enchantment_affect_monster(monster* mon);
00263 mon_resist_type try_enchant_monster(monster* mon, int &res_margin);
00264 void tracer_enchantment_affect_monster(monster* mon);
00265 void tracer_nonenchantment_affect_monster(monster* mon);
00266 void update_hurt_or_helped(monster* mon);
00267 bool attempt_block(monster* mon);
00268 void handle_stop_attack_prompt(monster* mon);
00269 bool determine_damage(monster* mon, int& preac, int& postac, int& final,
00270 std::vector<std::string> &messages);
00271 void monster_post_hit(monster* mon, int dmg);
00272 bool misses_player();
00273
00274 void initialise_fire();
00275 void apply_beam_conducts();
00276 void choose_ray();
00277 void draw(const coord_def& p);
00278 void bounce();
00279 void reflect();
00280 void fake_flavour();
00281 void digging_wall_effect();
00282 void fire_wall_effect();
00283 void elec_wall_effect();
00284 void nuke_wall_effect();
00285 void drop_object();
00286 int range_used(bool leg_only = false) const;
00287 void finish_beam();
00288 bool fuzz_invis_tracer();
00289
00290 void internal_ouch(int dam);
00291
00292
00293 void refine_for_explosion();
00294 void explosion_draw_cell(const coord_def& p);
00295 void explosion_affect_cell(const coord_def& p);
00296 void determine_affected_cells(explosion_map& m, const coord_def& delta,
00297 int count, int r,
00298 bool stop_at_statues, bool stop_at_walls);
00299 };
00300
00301 int mons_adjust_flavoured(monster* mons, bolt &pbolt, int hurted,
00302 bool doFlavouredEffects = true);
00303
00304
00305 bool enchant_monster_with_flavour(monster* mon, actor *atk,
00306 beam_type flavour, int powc = 0);
00307
00308 bool enchant_monster_invisible(monster* mon, const std::string how);
00309
00310 void mass_enchantment(enchant_type wh_enchant, int pow, int who,
00311 int *m_succumbed = NULL, int *m_attempted = NULL);
00312
00313 bool poison_monster(monster* mons, kill_category who, int levels = 1,
00314 bool force = false, bool verbose = true);
00315 bool miasma_monster(monster* mons, kill_category who);
00316 bool napalm_monster(monster* mons, kill_category who, int levels = 1,
00317 bool verbose = true);
00318 void fire_tracer(const monster* mons, struct bolt &pbolt,
00319 bool explode_only = false);
00320 void mimic_alert(monster* mimic);
00321 bool zapping(zap_type ztype, int power, bolt &pbolt,
00322 bool needs_tracer = false, const char* msg = NULL);
00323 bool player_tracer(zap_type ztype, int power, bolt &pbolt, int range = 0);
00324
00325 void init_zap_index();
00326 void clear_zap_info_on_exit();
00327
00328 int zap_power_cap(zap_type ztype);
00329
00330 #endif