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

Function player_shield_class

crawl-ref/source/player.cc:2281–2325  ·  view source on GitHub ↗

* Calculate the SH value used internally. * * Exactly twice the value displayed to players, for legacy reasons. * @param Whether to include temporary effects like TSO's divine shield. * @return The player's current SH value. */

Source from the content-addressed store, hash-verified

2279 * @return The player's current SH value.
2280 */
2281int player_shield_class(int scale, bool random, bool ignore_temporary)
2282{
2283 int shield = 0;
2284
2285 if (!ignore_temporary && you.incapacitated())
2286 return 0;
2287
2288 const item_def *shield_item = you.shield();
2289 if (shield_item)
2290 shield += _sh_from_shield(*shield_item);
2291
2292 // mutations
2293 // +4, +6, +8 (displayed values)
2294 shield += (you.get_mutation_level(MUT_LARGE_BONE_PLATES) > 0
2295 ? you.get_mutation_level(MUT_LARGE_BONE_PLATES) * 400 + 400
2296 : 0);
2297
2298 // Icemail and Ephemeral Shield aren't active all of the time, so consider
2299 // them temporary; this behaviour is consistent with how icemail's AC
2300 // is dealt with.
2301 if (!ignore_temporary
2302 && you.get_mutation_level(MUT_CONDENSATION_SHIELD) > 0
2303 && !you.duration[DUR_ICEMAIL_DEPLETED])
2304 {
2305 shield += ICEMAIL_MAX * 100;
2306 }
2307 if (!ignore_temporary
2308 && you.get_mutation_level(MUT_EPHEMERAL_SHIELD)
2309 && you.duration[DUR_EPHEMERAL_SHIELD])
2310 {
2311 shield += you.get_mutation_level(MUT_EPHEMERAL_SHIELD) * 1400;
2312 }
2313
2314 shield += qazlal_sh_boost() * 100;
2315 shield += you.wearing_jewellery(AMU_REFLECTION) * AMU_REFLECT_SH * 100;
2316 shield += you.scan_artefacts(ARTP_SHIELDING) * 200;
2317
2318 if (!ignore_temporary && you.duration[DUR_PARRYING])
2319 shield += player_parrying() * 200;
2320
2321 if (you.has_mutation(MUT_RECKLESS))
2322 shield /= 2;
2323
2324 return random ? div_rand_round(shield * scale, 100) : ((shield * scale) / 100);
2325}
2326
2327/**
2328 * Calculate the SH value that should be displayed to players.

Callers 6

temp_sh_modMethod · 0.85
shield_bonusMethod · 0.85
misses_playerMethod · 0.85
_describe_mons_to_hitFunction · 0.85

Calls 10

_sh_from_shieldFunction · 0.85
qazlal_sh_boostFunction · 0.85
player_parryingFunction · 0.85
get_mutation_levelMethod · 0.80
wearing_jewelleryMethod · 0.80
has_mutationMethod · 0.80
div_rand_roundFunction · 0.70
incapacitatedMethod · 0.45
shieldMethod · 0.45
scan_artefactsMethod · 0.45

Tested by

no test coverage detected