7 #include "object-flavor.h"
8 #include "player-status.h"
9 #include "spells-status.h"
12 #include "cmd-spell.h"
13 #include "player-effects.h"
14 #include "objectkind.h"
15 #include "targeting.h"
19 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
21 * @return 作用が実際にあった場合TRUEを返す
23 bool heal_monster(DIRECTION dir, HIT_POINT dam)
25 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
26 return (project_hook(GF_OLD_HEAL, dir, dam, flg));
31 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
33 * @return 作用が実際にあった場合TRUEを返す
35 bool speed_monster(DIRECTION dir, int power)
37 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
38 return (project_hook(GF_OLD_SPEED, dir, power, flg));
43 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
45 * @return 作用が実際にあった場合TRUEを返す
47 bool slow_monster(DIRECTION dir, int power)
49 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
50 return (project_hook(GF_OLD_SLOW, dir, power, flg));
55 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
57 * @return 作用が実際にあった場合TRUEを返す
59 bool sleep_monster(DIRECTION dir, int power)
61 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
62 return (project_hook(GF_OLD_SLEEP, dir, power, flg));
66 * @brief モンスター拘束(STASIS)処理
67 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
68 * @return 作用が実際にあった場合TRUEを返す
69 * @details 威力はプレイヤーレベル*2に固定
71 bool stasis_monster(DIRECTION dir)
73 return (fire_ball_hide(GF_STASIS, dir, p_ptr->lev * 2, 0));
77 * @brief 邪悪なモンスター拘束(STASIS)処理
78 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
79 * @return 作用が実際にあった場合TRUEを返す
80 * @details 威力はプレイヤーレベル*2に固定
82 bool stasis_evil(DIRECTION dir)
84 return (fire_ball_hide(GF_STASIS_EVIL, dir, p_ptr->lev * 2, 0));
89 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
90 * @param plev プレイヤーレベル(=効力)
91 * @return 作用が実際にあった場合TRUEを返す
93 bool confuse_monster(DIRECTION dir, PLAYER_LEVEL plev)
95 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
96 return (project_hook(GF_OLD_CONF, dir, plev, flg));
101 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
102 * @param plev プレイヤーレベル(=効力)
103 * @return 作用が実際にあった場合TRUEを返す
105 bool stun_monster(DIRECTION dir, PLAYER_LEVEL plev)
107 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
108 return (project_hook(GF_STUN, dir, plev, flg));
113 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
115 * @return 作用が実際にあった場合TRUEを返す
117 bool poly_monster(DIRECTION dir, int power)
119 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
120 bool tester = (project_hook(GF_OLD_POLY, dir, power, flg));
122 chg_virtue(V_CHANCE, 1);
128 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
129 * @return 作用が実際にあった場合TRUEを返す
131 bool clone_monster(DIRECTION dir)
133 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
134 return (project_hook(GF_OLD_CLONE, dir, 0, flg));
139 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
140 * @param plev プレイヤーレベル(=効力)
141 * @return 作用が実際にあった場合TRUEを返す
143 bool fear_monster(DIRECTION dir, PLAYER_LEVEL plev)
145 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
146 return (project_hook(GF_TURN_ALL, dir, plev, flg));
150 * @brief 歌の停止を処理する / Stop singing if the player is a Bard
153 void stop_singing(player_type *creature_ptr)
155 if (creature_ptr->pclass != CLASS_BARD) return;
157 /* Are there interupted song? */
158 if (INTERUPTING_SONG_EFFECT(creature_ptr))
160 /* Forget interupted song */
161 INTERUPTING_SONG_EFFECT(creature_ptr) = MUSIC_NONE;
165 /* The player is singing? */
166 if (!SINGING_SONG_EFFECT(creature_ptr)) return;
168 /* Hack -- if called from set_action(), avoid recursive loop */
169 if (creature_ptr->action == ACTION_SING) set_action(ACTION_NONE);
171 /* Message text of each song or etc. */
172 do_spell(REALM_MUSIC, SINGING_SONG_ID(creature_ptr), SPELL_STOP);
174 SINGING_SONG_EFFECT(creature_ptr) = MUSIC_NONE;
175 SINGING_SONG_ID(creature_ptr) = 0;
176 creature_ptr->update |= (PU_BONUS);
177 creature_ptr->redraw |= (PR_STATUS);
180 bool time_walk(player_type *creature_ptr)
182 if (creature_ptr->timewalk)
184 msg_print(_("既に時は止まっている。", "Time is already stopped."));
187 creature_ptr->timewalk = TRUE;
188 msg_print(_("「時よ!」", "You yell 'Time!'"));
189 // msg_print(_("「『ザ・ワールド』!時は止まった!」", "You yell 'The World! Time has stopped!'"));
193 creature_ptr->energy_need -= 1000 + (100 + p_ptr->csp - 50)*TURNS_PER_TICK / 10;
194 creature_ptr->redraw |= (PR_MAP);
195 creature_ptr->update |= (PU_MONSTERS);
196 creature_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
202 * @brief プレイヤーのヒットダイスを振る / Role Hitpoints
203 * @param options スペル共通オプション
206 void roll_hitdice(player_type *creature_ptr, SPOP_FLAGS options)
210 /* Minimum hitpoints at highest level */
211 HIT_POINT min_value = creature_ptr->hitdie + ((PY_MAX_LEVEL + 2) * (creature_ptr->hitdie + 1)) * 3 / 8;
213 /* Maximum hitpoints at highest level */
214 HIT_POINT max_value = creature_ptr->hitdie + ((PY_MAX_LEVEL + 2) * (creature_ptr->hitdie + 1)) * 5 / 8;
221 /* Pre-calculate level 1 hitdice */
222 creature_ptr->player_hp[0] = (HIT_POINT)creature_ptr->hitdie;
224 for (i = 1; i < 4; i++)
226 creature_ptr->player_hp[0] += randint1(creature_ptr->hitdie);
229 /* Roll the hitpoint values */
230 for (i = 1; i < PY_MAX_LEVEL; i++)
232 creature_ptr->player_hp[i] = creature_ptr->player_hp[i - 1] + randint1(creature_ptr->hitdie);
235 /* Require "valid" hitpoints at highest level */
236 if ((creature_ptr->player_hp[PY_MAX_LEVEL - 1] >= min_value) &&
237 (creature_ptr->player_hp[PY_MAX_LEVEL - 1] <= max_value)) break;
240 percent = (int)(((long)creature_ptr->player_hp[PY_MAX_LEVEL - 1] * 200L) /
241 (2 * creature_ptr->hitdie + ((PY_MAX_LEVEL - 1 + 3) * (creature_ptr->hitdie + 1))));
243 /* Update and redraw hitpoints */
244 creature_ptr->update |= (PU_HP);
245 creature_ptr->redraw |= (PR_HP);
246 creature_ptr->window |= (PW_PLAYER);
248 if (!(options & SPOP_NO_UPDATE)) handle_stuff();
250 if (options & SPOP_DISPLAY_MES)
252 if (options & SPOP_DEBUG)
254 msg_format(_("現在の体力ランクは %d/100 です。", "Your life rate is %d/100 now."), percent);
255 creature_ptr->knowledge |= KNOW_HPRATE;
259 msg_print(_("体力ランクが変わった。", "Life rate is changed."));
260 creature_ptr->knowledge &= ~(KNOW_HPRATE);
265 bool_hack life_stream(bool_hack message, bool_hack virtue_change)
269 chg_virtue(V_VITALITY, 1);
270 chg_virtue(V_UNLIFE, -5);
274 msg_print(_("体中に生命力が満ちあふれてきた!", "You feel life flow through your body!"));
277 (void)set_poisoned(0);
279 (void)set_confused(0);
283 (void)restore_all_status();
284 (void)set_shero(0, TRUE);
291 bool_hack heroism(int base)
293 bool_hack ident = FALSE;
294 if (set_afraid(0)) ident = TRUE;
295 if (set_hero(p_ptr->hero + randint1(base) + base, FALSE)) ident = TRUE;
296 if (hp_player(10)) ident = TRUE;
300 bool_hack berserk(int base)
302 bool_hack ident = FALSE;
303 if (set_afraid(0)) ident = TRUE;
304 if (set_shero(p_ptr->shero + randint1(base) + base, FALSE)) ident = TRUE;
305 if (hp_player(30)) ident = TRUE;
309 bool_hack cure_light_wounds(DICE_NUMBER dice, DICE_SID sides)
311 bool_hack ident = FALSE;
312 if (hp_player(damroll(dice, sides))) ident = TRUE;
313 if (set_blind(0)) ident = TRUE;
314 if (set_cut(p_ptr->cut - 10)) ident = TRUE;
315 if (set_shero(0, TRUE)) ident = TRUE;
319 bool_hack cure_serious_wounds(DICE_NUMBER dice, DICE_SID sides)
321 bool_hack ident = FALSE;
322 if (hp_player(damroll(dice, sides))) ident = TRUE;
323 if (set_blind(0)) ident = TRUE;
324 if (set_confused(0)) ident = TRUE;
325 if (set_cut((p_ptr->cut / 2) - 50)) ident = TRUE;
326 if (set_shero(0, TRUE)) ident = TRUE;
330 bool_hack cure_critical_wounds(HIT_POINT pow)
332 bool_hack ident = FALSE;
333 if (hp_player(pow)) ident = TRUE;
334 if (set_blind(0)) ident = TRUE;
335 if (set_confused(0)) ident = TRUE;
336 if (set_poisoned(0)) ident = TRUE;
337 if (set_stun(0)) ident = TRUE;
338 if (set_cut(0)) ident = TRUE;
339 if (set_shero(0, TRUE)) ident = TRUE;
343 bool_hack true_healing(HIT_POINT pow)
345 bool_hack ident = FALSE;
346 if (hp_player(pow)) ident = TRUE;
347 if (set_blind(0)) ident = TRUE;
348 if (set_confused(0)) ident = TRUE;
349 if (set_poisoned(0)) ident = TRUE;
350 if (set_stun(0)) ident = TRUE;
351 if (set_cut(0)) ident = TRUE;
352 if (set_image(0)) ident = TRUE;
356 bool_hack restore_mana(bool_hack magic_eater)
358 bool_hack ident = FALSE;
360 if (p_ptr->pclass == CLASS_MAGIC_EATER && magic_eater)
363 for (i = 0; i < EATER_EXT * 2; i++)
365 p_ptr->magic_num1[i] += (p_ptr->magic_num2[i] < 10) ? EATER_CHARGE * 3 : p_ptr->magic_num2[i] * EATER_CHARGE / 3;
366 if (p_ptr->magic_num1[i] > p_ptr->magic_num2[i] * EATER_CHARGE) p_ptr->magic_num1[i] = p_ptr->magic_num2[i] * EATER_CHARGE;
368 for (; i < EATER_EXT * 3; i++)
370 KIND_OBJECT_IDX k_idx = lookup_kind(TV_ROD, i - EATER_EXT * 2);
371 p_ptr->magic_num1[i] -= ((p_ptr->magic_num2[i] < 10) ? EATER_ROD_CHARGE * 3 : p_ptr->magic_num2[i] * EATER_ROD_CHARGE / 3)*k_info[k_idx].pval;
372 if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
374 msg_print(_("頭がハッキリとした。", "You feel your head clear."));
375 p_ptr->window |= (PW_PLAYER);
378 else if (p_ptr->csp < p_ptr->msp)
380 p_ptr->csp = p_ptr->msp;
382 msg_print(_("頭がハッキリとした。", "You feel your head clear."));
383 p_ptr->redraw |= (PR_MANA);
384 p_ptr->window |= (PW_PLAYER);
385 p_ptr->window |= (PW_SPELL);
392 bool restore_all_status(void)
395 if (do_res_stat(A_STR)) ident = TRUE;
396 if (do_res_stat(A_INT)) ident = TRUE;
397 if (do_res_stat(A_WIS)) ident = TRUE;
398 if (do_res_stat(A_DEX)) ident = TRUE;
399 if (do_res_stat(A_CON)) ident = TRUE;
400 if (do_res_stat(A_CHR)) ident = TRUE;
404 bool fishing(player_type *creature_ptr)
409 if (!get_direction(&dir, FALSE, FALSE)) return FALSE;
410 y = creature_ptr->y + ddy[dir];
411 x = creature_ptr->x + ddx[dir];
412 creature_ptr->fishing_dir = dir;
413 if (!cave_have_flag_bold(y, x, FF_WATER))
415 msg_print(_("そこは水辺ではない。", "There is no fishing place."));
418 else if (current_floor_ptr->grid_array[y][x].m_idx)
420 GAME_TEXT m_name[MAX_NLEN];
421 monster_desc(m_name, ¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx], 0);
422 msg_format(_("%sが邪魔だ!", "%^s is stand in your way."), m_name);
423 free_turn(creature_ptr);
426 set_action(ACTION_FISH);
427 creature_ptr->redraw |= (PR_STATE);
432 bool cosmic_cast_off(player_type *creature_ptr, object_type *o_ptr)
437 GAME_TEXT o_name[MAX_NLEN];
440 /* Cast off activated item */
441 for (inv = INVEN_RARM; inv <= INVEN_FEET; inv++)
443 if (o_ptr == &p_ptr->inventory_list[inv]) break;
445 if (inv > INVEN_FEET) return FALSE;
447 object_copy(&forge, o_ptr);
448 inven_item_increase(inv, (0 - o_ptr->number));
449 inven_item_optimize(inv);
450 o_idx = drop_near(&forge, 0, creature_ptr->y, creature_ptr->x);
451 o_ptr = ¤t_floor_ptr->o_list[o_idx];
453 object_desc(o_name, o_ptr, OD_NAME_ONLY);
454 msg_format(_("%sを脱ぎ捨てた。", "You cast off %s."), o_name);
457 msg_print(_("「燃え上がれ俺の小宇宙!」", "You say, 'Burn up my cosmo!"));
458 t = 20 + randint1(20);
459 (void)set_blind(creature_ptr->blind + t);
461 (void)set_tim_esp(creature_ptr->tim_esp + t, FALSE);
462 (void)set_tim_regen(creature_ptr->tim_regen + t, FALSE);
463 (void)set_hero(creature_ptr->hero + t, FALSE);
464 (void)set_blessed(creature_ptr->blessed + t, FALSE);
465 (void)set_fast(creature_ptr->fast + t, FALSE);
466 (void)set_shero(creature_ptr->shero + t, FALSE);
467 if (creature_ptr->pclass == CLASS_FORCETRAINER)
469 P_PTR_KI = creature_ptr->lev * 5 + 190;
470 msg_print(_("気が爆発寸前になった。", "Your force are immediatly before explosion."));
478 * @brief プレイヤーの因果混乱処理 / Apply Nexus
479 * @param m_ptr 因果混乱をプレイヤーに与えたモンスターの情報参照ポインタ
482 void apply_nexus(monster_type *m_ptr)
486 case 1: case 2: case 3:
488 teleport_player(200, TELEPORT_PASSIVE);
494 teleport_player_to(m_ptr->fy, m_ptr->fx, TELEPORT_PASSIVE);
500 if (randint0(100) < p_ptr->skill_sav)
502 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
511 if (randint0(100) < p_ptr->skill_sav)
513 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
517 msg_print(_("体がねじれ始めた...", "Your body starts to scramble..."));
525 * @brief プレイヤーのステータスシャッフル処理
528 void status_shuffle(void)
530 BASE_STATUS max1, cur1, max2, cur2;
533 /* Pick a pair of stats */
534 ii = randint0(A_MAX);
535 for (jj = ii; jj == ii; jj = randint0(A_MAX)) /* loop */;
537 max1 = p_ptr->stat_max[ii];
538 cur1 = p_ptr->stat_cur[ii];
539 max2 = p_ptr->stat_max[jj];
540 cur2 = p_ptr->stat_cur[jj];
542 p_ptr->stat_max[ii] = max2;
543 p_ptr->stat_cur[ii] = cur2;
544 p_ptr->stat_max[jj] = max1;
545 p_ptr->stat_cur[jj] = cur1;
547 for (i = 0; i < A_MAX; i++)
549 if (p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
550 if (p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
553 p_ptr->update |= (PU_BONUS);