MCPcopy Create free account
hub / github.com/crawl/crawl / polar_vortex_damage

Function polar_vortex_damage

crawl-ref/source/spl-vortex.cc:243–481  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

241}
242
243void polar_vortex_damage(actor *caster, int dur)
244{
245 if (!dur)
246 return;
247
248 int pow;
249 const int max_radius = min(POLAR_VORTEX_RADIUS, (int)you.current_vision);
250
251 if (caster->is_player())
252 pow = you.props[VORTEX_POWER_KEY].get_int();
253 else
254 // XXX TODO: use the normal spellpower calc functions
255 pow = caster->as_monster()->get_hit_dice() * 4;
256 const coord_def org = caster->pos();
257 int noise = 0;
258 WindSystem winds(org);
259
260 const coord_def old_player_pos = you.pos();
261 coord_def new_player_pos = old_player_pos;
262
263 int age = _vortex_age(caster);
264 ASSERT(age >= 0);
265
266 vector<coord_def> move_avail; // legal destinations
267 map<mid_t, coord_def> move_dest; // chosen destination
268 int rdurs[POLAR_VORTEX_RADIUS + 1]; // durations at radii
269 int cnt_open = 0;
270 int cnt_all = 0;
271
272 distance_iterator count_i(org, false);
273 distance_iterator dam_i(org, true);
274 for (int r = 1; r <= max_radius; r++)
275 {
276 while (count_i && count_i.radius() == r)
277 {
278 if (winds.has_wind(*count_i))
279 cnt_open++;
280 ++cnt_all;
281 ++count_i;
282 }
283 // effective age at radius r
284 int rage = age - _age_needed(r);
285 /* Not just "portion of time affected":
286 **
287 **
288 ----++----
289 **......
290 **........
291 here, damage done is 3/4, not 1/2.
292 */
293 // effective duration at the radius
294 int rdur = _rdam(rage + abs(dur)) - _rdam(rage);
295 rdurs[r] = rdur;
296 // power at the radius
297 int rpow = div_rand_round(pow * cnt_open * rdur, cnt_all * 100);
298 if (!rpow)
299 break;
300

Callers 3

_decrement_durationsFunction · 0.85
apply_enchantmentMethod · 0.85
_place_twister_cloudsFunction · 0.85

Calls 15

_vortex_ageFunction · 0.85
_age_neededFunction · 0.85
_rdamFunction · 0.85
absFunction · 0.85
feat_is_treeFunction · 0.85
have_passiveFunction · 0.85
is_temp_terrainFunction · 0.85
bernoulliFunction · 0.85
destroy_wallFunction · 0.85
mprFunction · 0.85
actor_atFunction · 0.85
could_harmFunction · 0.85

Tested by

no test coverage detected