/* Handle the Terrifying Aura of Fear! */ void fear_process_p(void) { int i, r_level; for (i = 1; i < m_max; i++) { monster_type *m_ptr = &m_list[i]; monster_race *r_ptr; if (!m_ptr->r_idx) continue; if (!m_ptr->ml) continue; r_ptr = &r_info[m_ptr->ap_r_idx]; if (!(r_ptr->flags2 & RF2_AURA_FEAR)) continue; if (is_pet(m_ptr) || is_friendly(m_ptr)) continue; if (!projectable(py, px, m_ptr->fy, m_ptr->fx)) continue; r_level = _r_level(r_ptr); if (!fear_save_p(r_level/MAX(1, m_ptr->cdis-2))) { char m_name[80]; monster_desc(m_name, m_ptr, 0); msg_format("You behold the terrifying visage of %s!", m_name); mon_lore_2(m_ptr, RF2_AURA_FEAR); fear_add_p(r_level/MAX(1, m_ptr->cdis-2)); } } }
bool fear_p_hurt_m(int m_idx, int dam) { monster_type *m_ptr = &m_list[m_idx]; monster_race *r_ptr = &r_info[m_ptr->ap_r_idx]; bool result = FALSE; /* Apply Aura of Fear to the Player for non-melee damage */ if (!melee_hack && (r_ptr->flags2 & RF2_AURA_FEAR)) { int r_level = _r_level(r_ptr); if (!fear_save_p(r_level)) { mon_lore_2(m_ptr, RF2_AURA_FEAR); fear_add_p(r_level/MAX(1, m_ptr->cdis - 2)); } } if (!MON_MONFEAR(m_ptr) && !(r_ptr->flags3 & (RF3_NO_FEAR))) { int percentage = (100 * m_ptr->hp) / m_ptr->maxhp; int n = 10; n = n * adj_fear_m[p_ptr->stat_ind[A_CHR]] / 100; if ((n >= percentage) || (dam >= m_ptr->hp && randint0(100) < 80)) { if (!fear_save_m(m_ptr)) { result = TRUE; set_monster_monfear(m_idx, randint1(10) + 20); } } } return result; }
bool fear_allow_melee(int m_idx) { if (p_ptr->afraid) { if ( p_ptr->pclass == CLASS_DUELIST && p_ptr->lev >= 5 && p_ptr->duelist_target_idx == m_idx ) { /* Duelist: Fearless Duel */ if (!fear_save_p(p_ptr->afraid)) return FALSE; } else if (!fear_save_p(3*p_ptr->afraid)) return FALSE; } return TRUE; }
void vampire_check_light_status(void) { static int _last_light_penalty = -1; if ((cave[py][px].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW) { _light_penalty = 1; if (!dun_level && is_daytime()) _light_penalty++; if (res_pct(RES_LITE) < 0) _light_penalty++; } else _light_penalty = 0; if (_light_penalty != _last_light_penalty) { _last_light_penalty = _light_penalty; if (_light_penalty) { int n = _light_penalty * _light_penalty * _light_penalty * MAX(1, dun_level/5); if (!fear_save_p(n)) { msg_print("You fear the light!"); fear_add_p(FEAR_SCARED); } } p_ptr->update |= PU_BONUS; p_ptr->redraw |= PR_STATUS; } }
void fear_hurt_p(int old_hp, int new_hp) { if (p_ptr->pclass != CLASS_BLOOD_KNIGHT && p_ptr->pclass != CLASS_BLOOD_MAGE) { int old_hurt = _get_hurt_level(old_hp); int new_hurt = _get_hurt_level(new_hp); if (new_hurt > old_hurt) { if ( !fear_save_p(fear_threat_level()) || (new_hurt > HURT_50 && !fear_save_p(fear_threat_level())) ) { fear_add_p(new_hurt); } else msg_format("You stand your ground!"); } } }
void fear_scare_p(monster_type *m_ptr) { monster_race *r_ptr = &r_info[m_ptr->ap_r_idx]; int r_level = _r_level(r_ptr); if (fear_save_p(r_level)) msg_print("You refuse to be frightened."); else fear_add_p(r_level); }
void fear_heal_p(int old_hp, int new_hp) { if (p_ptr->pclass != CLASS_BLOOD_KNIGHT && p_ptr->pclass != CLASS_BLOOD_MAGE && p_ptr->afraid) { int old_hurt = _get_hurt_level(old_hp); int new_hurt = _get_hurt_level(new_hp); if (new_hurt < old_hurt && fear_save_p(fear_threat_level())) _decrease_p(1); } }
void vampire_take_light_damage(int amt) { if (!fear_save_p(amt)) { msg_print("You fear the light!"); fear_add_p(FEAR_SCARED); } if (randint1(p_ptr->chp) < amt && !res_save_default(RES_LITE)) { int k = 0; cptr act = NULL; switch (randint1(12)) { case 1: case 2: case 3: case 4: case 5: msg_print("You feel your unlife force diminish."); lose_exp(100 + (p_ptr->exp / 100) * MON_DRAIN_LIFE); break; case 6: case 7: case 8: case 9: switch (randint1(6)) { case 1: k = A_STR; act = "strong"; break; case 2: k = A_INT; act = "bright"; break; case 3: k = A_WIS; act = "wise"; break; case 4: k = A_DEX; act = "agile"; break; case 5: k = A_CON; act = "hale"; break; case 6: k = A_CHR; act = "confident"; break; } msg_format("You're not as %s as you used to be.", act); p_ptr->stat_cur[k] = (p_ptr->stat_cur[k] * 3) / 4; if (p_ptr->stat_cur[k] < 3) p_ptr->stat_cur[k] = 3; break; case 10: msg_print("You're not as powerful as you used to be."); for (k = 0; k < 6; k++) { p_ptr->stat_cur[k] = (p_ptr->stat_cur[k] * 7) / 8; if (p_ptr->stat_cur[k] < 3) p_ptr->stat_cur[k] = 3; } break; case 11: case 12: if (disenchant_player()) msg_print("You feel diminished!"); break; } p_ptr->update |= PU_BONUS; } }
void fear_terrify_p(monster_type *m_ptr) { monster_race *r_ptr = &r_info[m_ptr->ap_r_idx]; int r_level = _r_level(r_ptr); if (fear_save_p(r_level)) { if (disturb_minor) msg_print("You stand your ground!"); } else fear_add_p(r_level); }
bool fear_set_p(int v) { int old_lvl, new_lvl; bool notice = FALSE; /* Hack -- Force good values */ v = (v > 10000) ? 10000 : (v < 0) ? 0 : v; if (p_ptr->is_dead) return FALSE; old_lvl = _get_level(p_ptr->afraid); new_lvl = _get_level(v); if (new_lvl > old_lvl) { msg_format("You feel <color:%c>%s</color>.", _get_level_color(new_lvl), _get_level_name(new_lvl)); if (old_lvl <= FEAR_SCARED && one_in_(6) && !fear_save_p(v/5)) do_dec_stat(A_CHR); if (p_ptr->special_defense & KATA_MASK) { msg_print("Your posture gets loose."); p_ptr->special_defense &= ~KATA_MASK; p_ptr->update |= PU_BONUS; p_ptr->update |= PU_MONSTERS; p_ptr->redraw |= PR_STATE; p_ptr->redraw |= PR_STATUS; p_ptr->action = ACTION_NONE; } notice = TRUE; p_ptr->counter = FALSE; virtue_add(VIRTUE_VALOUR, -1); } else if (new_lvl < old_lvl) { if (new_lvl == FEAR_BOLD) msg_print("Your fears finally subside."); else { msg_format("You are no longer %s, but you still feel %s.", _get_level_name(old_lvl), _get_level_name(new_lvl)); } notice = TRUE; } p_ptr->afraid = v; p_ptr->redraw |= PR_EFFECTS; if (!notice) return FALSE; if (disturb_state) disturb(0, 0); handle_stuff(); return TRUE; }
void fear_p_touch_m(monster_type *m_ptr) { monster_race *r_ptr = &r_info[m_ptr->ap_r_idx]; if (r_ptr->flags2 & RF2_AURA_FEAR) { int r_level = _r_level(r_ptr); if (!fear_save_p(r_level)) { mon_lore_2(m_ptr, RF2_AURA_FEAR); fear_add_p(r_level); } } }
/* Recovery from Fear */ void fear_recover_p(void) { if (p_ptr->afraid) { int threat = fear_threat_level(); if (fear_save_p(threat + p_ptr->afraid / 10)) { int lvls = 1; while (lvls < 3 && fear_save_p(threat + p_ptr->afraid)) lvls++; _decrease_p(lvls); } else if (p_ptr->afraid >= FEAR_SCARED && !fear_save_p((threat + p_ptr->afraid)/6)) { if (p_ptr->afraid >= FEAR_PETRIFIED) { p_ptr->energy_need += 100 * TURNS_PER_TICK / 10; msg_print("You are scared stiff!"); disturb(1, 0); } else if (p_ptr->afraid >= FEAR_TERRIFIED) { p_ptr->energy_need += 60 * TURNS_PER_TICK / 10; msg_print("You shudder uncontrollably!"); disturb(1, 0); } else { p_ptr->energy_need += 30 * TURNS_PER_TICK / 10; msg_print("You tremble in terror!"); disturb(1, 0); } } } }
void fear_update_m(monster_type *m_ptr) { monster_race *r_ptr = &r_info[m_ptr->ap_r_idx]; if ((r_ptr->flags2 & RF2_AURA_FEAR) && m_ptr->ml && !is_pet(m_ptr) && !is_friendly(m_ptr)) { int r_level = _r_level(r_ptr); if (!fear_save_p(r_level)) { char m_name[80]; monster_desc(m_name, m_ptr, 0); msg_format("You behold the terrifying visage of %s!", m_name); mon_lore_2(m_ptr, RF2_AURA_FEAR); fear_add_p(r_level); } } }
static void do_cmd_eat_food_aux(int item) { int ident, lev; object_type *o_ptr; if (music_singing_any()) bard_stop_singing(); if (hex_spelling_any()) stop_hex_spell_all(); warlock_stop_singing(); /* Get the item (in the pack) */ if (item >= 0) { o_ptr = &inventory[item]; } /* Get the item (on the floor) */ else { o_ptr = &o_list[0 - item]; } if (object_is_mushroom(o_ptr) && o_ptr->art_name && o_ptr->timeout) { msg_print("Your mushroom is still charging."); return; } /* Sound */ sound(SOUND_EAT); /* Take a turn */ energy_use = 100; /* Identity not known yet */ ident = FALSE; /* Object level */ lev = k_info[o_ptr->k_idx].level; if (o_ptr->tval == TV_FOOD) { /* Analyze the food */ switch (o_ptr->sval) { case SV_FOOD_POISON: { if (!res_save_default(RES_POIS)) { if (set_poisoned(p_ptr->poisoned + randint0(10) + 10, FALSE)) ident = TRUE; } break; } case SV_FOOD_BLINDNESS: { if (!res_save_default(RES_BLIND)) { if (set_blind(p_ptr->blind + randint0(200) + 200, FALSE)) ident = TRUE; } break; } case SV_FOOD_PARANOIA: { if (!fear_save_p(fear_threat_level())) ident = fear_add_p(FEAR_SCARED); break; } case SV_FOOD_CONFUSION: { if (!res_save_default(RES_CONF)) { if (set_confused(p_ptr->confused + randint0(10) + 10, FALSE)) ident = TRUE; } break; } case SV_FOOD_HALLUCINATION: { if (!res_save_default(RES_CHAOS)) { if (set_image(p_ptr->image + randint0(25) + 25, FALSE)) ident = TRUE; } break; } case SV_FOOD_PARALYSIS: { if (!p_ptr->free_act) { if (set_paralyzed(randint1(4), FALSE)) { ident = TRUE; } } break; } case SV_FOOD_WEAKNESS: { take_hit(DAMAGE_NOESCAPE, damroll(6, 6), "poisonous food", -1); (void)do_dec_stat(A_STR); ident = TRUE; break; } case SV_FOOD_SICKNESS: { take_hit(DAMAGE_NOESCAPE, damroll(6, 6), "poisonous food", -1); (void)do_dec_stat(A_CON); ident = TRUE; break; } case SV_FOOD_STUPIDITY: { take_hit(DAMAGE_NOESCAPE, damroll(8, 8), "poisonous food", -1); (void)do_dec_stat(A_INT); ident = TRUE; break; } case SV_FOOD_NAIVETY: { take_hit(DAMAGE_NOESCAPE, damroll(8, 8), "poisonous food", -1); (void)do_dec_stat(A_WIS); ident = TRUE; break; } case SV_FOOD_UNHEALTH: { take_hit(DAMAGE_NOESCAPE, damroll(10, 10), "poisonous food", -1); (void)do_dec_stat(A_CON); ident = TRUE; break; } case SV_FOOD_DISEASE: { take_hit(DAMAGE_NOESCAPE, damroll(10, 10), "poisonous food", -1); (void)do_dec_stat(A_STR); ident = TRUE; break; } case SV_FOOD_CURE_POISON: { if (set_poisoned(0, TRUE)) ident = TRUE; break; } case SV_FOOD_CURE_BLINDNESS: { if (set_blind(0, TRUE)) ident = TRUE; break; } case SV_FOOD_CURE_PARANOIA: { if (p_ptr->afraid) { fear_clear_p(); ident = TRUE; } break; } case SV_FOOD_CURE_CONFUSION: { if (set_confused(0, TRUE)) ident = TRUE; break; } case SV_FOOD_CURE_SERIOUS: { if (hp_player(damroll(6, 8))) ident = TRUE; if (set_cut((p_ptr->cut / 2) - 50, TRUE)) ident = TRUE; break; } case SV_FOOD_RESTORE_STR: { if (do_res_stat(A_STR)) ident = TRUE; break; } case SV_FOOD_RESTORE_CON: { if (do_res_stat(A_CON)) ident = TRUE; break; } case SV_FOOD_RESTORING: { if (do_res_stat(A_STR)) ident = TRUE; if (do_res_stat(A_INT)) ident = TRUE; if (do_res_stat(A_WIS)) ident = TRUE; if (do_res_stat(A_DEX)) ident = TRUE; if (do_res_stat(A_CON)) ident = TRUE; if (do_res_stat(A_CHR)) ident = TRUE; break; } case SV_FOOD_RATION: case SV_FOOD_BISCUIT: case SV_FOOD_JERKY: case SV_FOOD_SLIME_MOLD: { msg_print("That tastes good."); ident = TRUE; break; } case SV_FOOD_AMBROSIA: { msg_print("That tastes divine!"); set_poisoned(0, TRUE); hp_player(damroll(15, 15)); do_res_stat(A_STR); do_res_stat(A_INT); do_res_stat(A_WIS); do_res_stat(A_DEX); do_res_stat(A_CON); do_res_stat(A_CHR); restore_level(); ident = TRUE; break; } case SV_FOOD_WAYBREAD: { msg_print("That tastes good."); (void)set_poisoned(0, TRUE); (void)hp_player(damroll(4, 8)); ident = TRUE; break; } case SV_FOOD_PINT_OF_ALE: case SV_FOOD_PINT_OF_WINE: { msg_print("That tastes good."); ident = TRUE; break; } } } if (prace_is_(RACE_SNOTLING) && object_is_mushroom(o_ptr)) { int lev = k_info[o_ptr->k_idx].level; int dur = lev + randint1(lev); set_fast(p_ptr->fast + dur, FALSE); set_shield(p_ptr->shield + dur, FALSE); set_hero(p_ptr->hero + dur, FALSE); set_tim_building_up(p_ptr->tim_building_up + dur, FALSE); } /* Combine / Reorder the pack (later) */ p_ptr->notice |= (PN_COMBINE | PN_REORDER); if (!(object_is_aware(o_ptr))) { virtue_add(VIRTUE_KNOWLEDGE, -1); virtue_add(VIRTUE_PATIENCE, -1); virtue_add(VIRTUE_CHANCE, 1); } /* We have tried it */ if (o_ptr->tval == TV_FOOD) object_tried(o_ptr); stats_on_use(o_ptr, 1); /* The player is now aware of the object */ if (ident && !object_is_aware(o_ptr)) { object_aware(o_ptr); stats_on_notice(o_ptr, 1); gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev); }
bool fear_allow_magic(void) { if (p_ptr->afraid && !fear_save_p(p_ptr->afraid)) return FALSE; return TRUE; }
static void do_cmd_eat_food_aux(obj_ptr obj) { int lev = k_info[obj->k_idx].level; bool ident = FALSE; if (music_singing_any()) bard_stop_singing(); if (hex_spelling_any()) stop_hex_spell_all(); warlock_stop_singing(); if (object_is_mushroom(obj) && obj->art_name && obj->timeout) { msg_print("Your mushroom is still charging."); return; } sound(SOUND_EAT); energy_use = 100; ident = FALSE; /* Food may have effects */ if (obj->tval == TV_FOOD) { switch (obj->sval) { case SV_FOOD_POISON: { if (!res_save_default(RES_POIS)) { if (set_poisoned(p_ptr->poisoned + randint0(10) + 10, FALSE)) ident = TRUE; } break; } case SV_FOOD_BLINDNESS: { if (!res_save_default(RES_BLIND)) { if (set_blind(p_ptr->blind + randint0(200) + 200, FALSE)) ident = TRUE; } break; } case SV_FOOD_PARANOIA: { if (!fear_save_p(fear_threat_level())) ident = fear_add_p(FEAR_SCARED); break; } case SV_FOOD_CONFUSION: { if (!res_save_default(RES_CONF)) { if (set_confused(p_ptr->confused + randint0(10) + 10, FALSE)) ident = TRUE; } break; } case SV_FOOD_HALLUCINATION: { if (!res_save_default(RES_CHAOS)) { if (set_image(p_ptr->image + randint0(25) + 25, FALSE)) ident = TRUE; } break; } case SV_FOOD_PARALYSIS: { if (!p_ptr->free_act) { if (set_paralyzed(randint1(4), FALSE)) { ident = TRUE; } } else equip_learn_flag(OF_FREE_ACT); break; } case SV_FOOD_WEAKNESS: { take_hit(DAMAGE_NOESCAPE, damroll(6, 6), "poisonous food", -1); do_dec_stat(A_STR); ident = TRUE; break; } case SV_FOOD_SICKNESS: { take_hit(DAMAGE_NOESCAPE, damroll(6, 6), "poisonous food", -1); do_dec_stat(A_CON); ident = TRUE; break; } case SV_FOOD_STUPIDITY: { take_hit(DAMAGE_NOESCAPE, damroll(8, 8), "poisonous food", -1); do_dec_stat(A_INT); ident = TRUE; break; } case SV_FOOD_NAIVETY: { take_hit(DAMAGE_NOESCAPE, damroll(8, 8), "poisonous food", -1); do_dec_stat(A_WIS); ident = TRUE; break; } case SV_FOOD_UNHEALTH: { take_hit(DAMAGE_NOESCAPE, damroll(10, 10), "poisonous food", -1); do_dec_stat(A_CON); ident = TRUE; break; } case SV_FOOD_DISEASE: { take_hit(DAMAGE_NOESCAPE, damroll(10, 10), "poisonous food", -1); do_dec_stat(A_STR); ident = TRUE; break; } case SV_FOOD_CURE_POISON: { if (set_poisoned(0, TRUE)) ident = TRUE; break; } case SV_FOOD_CURE_BLINDNESS: { if (set_blind(0, TRUE)) ident = TRUE; break; } case SV_FOOD_CURE_PARANOIA: { if (p_ptr->afraid) { fear_clear_p(); ident = TRUE; } break; } case SV_FOOD_CURE_CONFUSION: { if (set_confused(0, TRUE)) ident = TRUE; break; } case SV_FOOD_CURE_SERIOUS: { if (hp_player(damroll(6, 8))) ident = TRUE; if (set_cut((p_ptr->cut / 2) - 50, TRUE)) ident = TRUE; break; } case SV_FOOD_RESTORE_STR: { if (do_res_stat(A_STR)) ident = TRUE; break; } case SV_FOOD_RESTORE_CON: { if (do_res_stat(A_CON)) ident = TRUE; break; } case SV_FOOD_RESTORING: { if (do_res_stat(A_STR)) ident = TRUE; if (do_res_stat(A_INT)) ident = TRUE; if (do_res_stat(A_WIS)) ident = TRUE; if (do_res_stat(A_DEX)) ident = TRUE; if (do_res_stat(A_CON)) ident = TRUE; if (do_res_stat(A_CHR)) ident = TRUE; break; } case SV_FOOD_RATION: case SV_FOOD_BISCUIT: case SV_FOOD_JERKY: case SV_FOOD_SLIME_MOLD: { msg_print("That tastes good."); ident = TRUE; break; } case SV_FOOD_AMBROSIA: { msg_print("That tastes divine!"); set_poisoned(0, TRUE); hp_player(damroll(15, 15)); do_res_stat(A_STR); do_res_stat(A_INT); do_res_stat(A_WIS); do_res_stat(A_DEX); do_res_stat(A_CON); do_res_stat(A_CHR); restore_level(); ident = TRUE; break; } case SV_FOOD_WAYBREAD: { msg_print("That tastes good."); set_poisoned(0, TRUE); hp_player(damroll(4, 8)); ident = TRUE; break; } case SV_FOOD_PINT_OF_ALE: case SV_FOOD_PINT_OF_WINE: { msg_print("That tastes good."); ident = TRUE; break; } } } if (prace_is_(RACE_SNOTLING) && object_is_mushroom(obj)) { int dur = lev + randint1(lev); set_fast(p_ptr->fast + dur, FALSE); set_shield(p_ptr->shield + dur, FALSE); set_hero(p_ptr->hero + dur, FALSE); set_tim_building_up(p_ptr->tim_building_up + dur, FALSE); } if (!object_is_aware(obj)) { virtue_add(VIRTUE_KNOWLEDGE, -1); virtue_add(VIRTUE_PATIENCE, -1); virtue_add(VIRTUE_CHANCE, 1); } /* We have tried it */ if (obj->tval == TV_FOOD) object_tried(obj); stats_on_use(obj, 1); /* The player is now aware of the object */ if (ident && !object_is_aware(obj)) { object_aware(obj); stats_on_notice(obj, 1); gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev); p_ptr->notice |= PN_OPTIMIZE_PACK; }
bool fear_allow_shoot(void) { if (p_ptr->afraid && !fear_save_p(3*p_ptr->afraid)) return FALSE; return TRUE; }