5 #include "cmd-magiceat.h"
8 #include "object-flavor.h"
9 #include "player-status.h"
10 #include "player-class.h"
11 #include "spells-status.h"
14 #include "cmd-spell.h"
15 #include "player-effects.h"
16 #include "objectkind.h"
17 #include "targeting.h"
18 #include "realm-song.h"
19 #include "view-mainwindow.h"
23 * @param caster_ptr プレーヤーへの参照ポインタ
24 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
26 * @return 作用が実際にあった場合TRUEを返す
28 bool heal_monster(DIRECTION dir, HIT_POINT dam)
30 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
31 return (project_hook(p_ptr, GF_OLD_HEAL, dir, dam, flg));
36 * @param caster_ptr プレーヤーへの参照ポインタ
37 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
39 * @return 作用が実際にあった場合TRUEを返す
41 bool speed_monster(DIRECTION dir, int power)
43 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
44 return (project_hook(p_ptr, GF_OLD_SPEED, dir, power, flg));
49 * @param caster_ptr プレーヤーへの参照ポインタ
50 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
52 * @return 作用が実際にあった場合TRUEを返す
54 bool slow_monster(DIRECTION dir, int power)
56 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
57 return (project_hook(p_ptr, GF_OLD_SLOW, dir, power, flg));
62 * @param caster_ptr プレーヤーへの参照ポインタ
63 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
65 * @return 作用が実際にあった場合TRUEを返す
67 bool sleep_monster(DIRECTION dir, int power)
69 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
70 return (project_hook(p_ptr, GF_OLD_SLEEP, dir, power, flg));
74 * @brief モンスター拘束(STASIS)処理
75 * @param caster_ptr プレーヤーへの参照ポインタ
76 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
77 * @return 作用が実際にあった場合TRUEを返す
78 * @details 威力はプレイヤーレベル*2に固定
80 bool stasis_monster(DIRECTION dir)
82 return (fire_ball_hide(p_ptr, GF_STASIS, dir, p_ptr->lev * 2, 0));
86 * @brief 邪悪なモンスター拘束(STASIS)処理
87 * @param caster_ptr プレーヤーへの参照ポインタ
88 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
89 * @return 作用が実際にあった場合TRUEを返す
90 * @details 威力はプレイヤーレベル*2に固定
92 bool stasis_evil(DIRECTION dir)
94 return (fire_ball_hide(p_ptr, GF_STASIS_EVIL, dir, p_ptr->lev * 2, 0));
99 * @param caster_ptr プレーヤーへの参照ポインタ
100 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
101 * @param plev プレイヤーレベル(=効力)
102 * @return 作用が実際にあった場合TRUEを返す
104 bool confuse_monster(DIRECTION dir, PLAYER_LEVEL plev)
106 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
107 return (project_hook(p_ptr, GF_OLD_CONF, dir, plev, flg));
112 * @param caster_ptr プレーヤーへの参照ポインタ
113 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
114 * @param plev プレイヤーレベル(=効力)
115 * @return 作用が実際にあった場合TRUEを返す
117 bool stun_monster(DIRECTION dir, PLAYER_LEVEL plev)
119 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
120 return (project_hook(p_ptr, GF_STUN, dir, plev, flg));
125 * @param caster_ptr プレーヤーへの参照ポインタ
126 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
128 * @return 作用が実際にあった場合TRUEを返す
130 bool poly_monster(DIRECTION dir, int power)
132 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
133 bool tester = (project_hook(p_ptr, GF_OLD_POLY, dir, power, flg));
135 chg_virtue(p_ptr, V_CHANCE, 1);
141 * @param caster_ptr プレーヤーへの参照ポインタ
142 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
143 * @return 作用が実際にあった場合TRUEを返す
145 bool clone_monster(DIRECTION dir)
147 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
148 return (project_hook(p_ptr, GF_OLD_CLONE, dir, 0, flg));
153 * @param caster_ptr プレーヤーへの参照ポインタ
154 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
155 * @param plev プレイヤーレベル(=効力)
156 * @return 作用が実際にあった場合TRUEを返す
158 bool fear_monster(DIRECTION dir, PLAYER_LEVEL plev)
160 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
161 return (project_hook(p_ptr, GF_TURN_ALL, dir, plev, flg));
165 * @brief 歌の停止を処理する / Stop singing if the player is a Bard
168 void stop_singing(player_type *creature_ptr)
170 if (creature_ptr->pclass != CLASS_BARD) return;
172 /* Are there interupted song? */
173 if (INTERUPTING_SONG_EFFECT(creature_ptr))
175 /* Forget interupted song */
176 INTERUPTING_SONG_EFFECT(creature_ptr) = MUSIC_NONE;
180 /* The player is singing? */
181 if (!SINGING_SONG_EFFECT(creature_ptr)) return;
183 /* Hack -- if called from set_action(), avoid recursive loop */
184 if (creature_ptr->action == ACTION_SING) set_action(creature_ptr, ACTION_NONE);
186 /* Message text of each song or etc. */
187 exe_spell(creature_ptr, REALM_MUSIC, SINGING_SONG_ID(creature_ptr), SPELL_STOP);
189 SINGING_SONG_EFFECT(creature_ptr) = MUSIC_NONE;
190 SINGING_SONG_ID(creature_ptr) = 0;
191 creature_ptr->update |= (PU_BONUS);
192 creature_ptr->redraw |= (PR_STATUS);
195 bool time_walk(player_type *creature_ptr)
197 if (creature_ptr->timewalk)
199 msg_print(_("既に時は止まっている。", "Time is already stopped."));
202 creature_ptr->timewalk = TRUE;
203 msg_print(_("「時よ!」", "You yell 'Time!'"));
204 // msg_print(_("「『ザ・ワールド』!時は止まった!」", "You yell 'The World! Time has stopped!'"));
207 creature_ptr->energy_need -= 1000 + (100 + creature_ptr->csp - 50)*TURNS_PER_TICK / 10;
208 creature_ptr->redraw |= (PR_MAP);
209 creature_ptr->update |= (PU_MONSTERS);
210 creature_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
216 * @brief プレイヤーのヒットダイスを振る / Role Hitpoints
217 * @param options スペル共通オプション
220 void roll_hitdice(player_type *creature_ptr, SPOP_FLAGS options)
224 /* Minimum hitpoints at highest level */
225 HIT_POINT min_value = creature_ptr->hitdie + ((PY_MAX_LEVEL + 2) * (creature_ptr->hitdie + 1)) * 3 / 8;
227 /* Maximum hitpoints at highest level */
228 HIT_POINT max_value = creature_ptr->hitdie + ((PY_MAX_LEVEL + 2) * (creature_ptr->hitdie + 1)) * 5 / 8;
235 /* Pre-calculate level 1 hitdice */
236 creature_ptr->player_hp[0] = (HIT_POINT)creature_ptr->hitdie;
238 for (i = 1; i < 4; i++)
240 creature_ptr->player_hp[0] += randint1(creature_ptr->hitdie);
243 /* Roll the hitpoint values */
244 for (i = 1; i < PY_MAX_LEVEL; i++)
246 creature_ptr->player_hp[i] = creature_ptr->player_hp[i - 1] + randint1(creature_ptr->hitdie);
249 /* Require "valid" hitpoints at highest level */
250 if ((creature_ptr->player_hp[PY_MAX_LEVEL - 1] >= min_value) &&
251 (creature_ptr->player_hp[PY_MAX_LEVEL - 1] <= max_value)) break;
254 percent = (int)(((long)creature_ptr->player_hp[PY_MAX_LEVEL - 1] * 200L) /
255 (2 * creature_ptr->hitdie + ((PY_MAX_LEVEL - 1 + 3) * (creature_ptr->hitdie + 1))));
257 /* Update and redraw hitpoints */
258 creature_ptr->update |= (PU_HP);
259 creature_ptr->redraw |= (PR_HP);
260 creature_ptr->window |= (PW_PLAYER);
262 if (!(options & SPOP_NO_UPDATE)) handle_stuff();
264 if (options & SPOP_DISPLAY_MES)
266 if (options & SPOP_DEBUG)
268 msg_format(_("現在の体力ランクは %d/100 です。", "Your life rate is %d/100 now."), percent);
269 creature_ptr->knowledge |= KNOW_HPRATE;
273 msg_print(_("体力ランクが変わった。", "Life rate is changed."));
274 creature_ptr->knowledge &= ~(KNOW_HPRATE);
279 bool_hack life_stream(player_type *creature_ptr, bool_hack message, bool_hack virtue_change)
283 chg_virtue(creature_ptr, V_VITALITY, 1);
284 chg_virtue(creature_ptr, V_UNLIFE, -5);
288 msg_print(_("体中に生命力が満ちあふれてきた!", "You feel life flow through your body!"));
290 restore_level(creature_ptr);
291 (void)set_poisoned(creature_ptr, 0);
292 (void)set_blind(creature_ptr, 0);
293 (void)set_confused(creature_ptr, 0);
294 (void)set_image(creature_ptr, 0);
295 (void)set_stun(creature_ptr, 0);
296 (void)set_cut(creature_ptr,0);
297 (void)restore_all_status(creature_ptr);
298 (void)set_shero(creature_ptr, 0, TRUE);
300 hp_player(creature_ptr, 5000);
305 bool_hack heroism(player_type *creature_ptr, int base)
307 bool_hack ident = FALSE;
308 if (set_afraid(creature_ptr, 0)) ident = TRUE;
309 if (set_hero(creature_ptr, creature_ptr->hero + randint1(base) + base, FALSE)) ident = TRUE;
310 if (hp_player(creature_ptr, 10)) ident = TRUE;
314 bool_hack berserk(player_type *creature_ptr, int base)
316 bool_hack ident = FALSE;
317 if (set_afraid(creature_ptr, 0)) ident = TRUE;
318 if (set_shero(creature_ptr, creature_ptr->shero + randint1(base) + base, FALSE)) ident = TRUE;
319 if (hp_player(creature_ptr, 30)) ident = TRUE;
323 bool_hack cure_light_wounds(player_type *creature_ptr, DICE_NUMBER dice, DICE_SID sides)
325 bool_hack ident = FALSE;
326 if (hp_player(creature_ptr, damroll(dice, sides))) ident = TRUE;
327 if (set_blind(creature_ptr, 0)) ident = TRUE;
328 if (set_cut(creature_ptr,creature_ptr->cut - 10)) ident = TRUE;
329 if (set_shero(creature_ptr, 0, TRUE)) ident = TRUE;
333 bool_hack cure_serious_wounds(player_type *creature_ptr, DICE_NUMBER dice, DICE_SID sides)
335 bool_hack ident = FALSE;
336 if (hp_player(creature_ptr, damroll(dice, sides))) ident = TRUE;
337 if (set_blind(creature_ptr, 0)) ident = TRUE;
338 if (set_confused(creature_ptr, 0)) ident = TRUE;
339 if (set_cut(creature_ptr,(creature_ptr->cut / 2) - 50)) ident = TRUE;
340 if (set_shero(creature_ptr, 0, TRUE)) ident = TRUE;
344 bool_hack cure_critical_wounds(player_type *creature_ptr, HIT_POINT pow)
346 bool_hack ident = FALSE;
347 if (hp_player(creature_ptr, pow)) ident = TRUE;
348 if (set_blind(creature_ptr, 0)) ident = TRUE;
349 if (set_confused(creature_ptr, 0)) ident = TRUE;
350 if (set_poisoned(creature_ptr, 0)) ident = TRUE;
351 if (set_stun(creature_ptr, 0)) ident = TRUE;
352 if (set_cut(creature_ptr,0)) ident = TRUE;
353 if (set_shero(creature_ptr, 0, TRUE)) ident = TRUE;
357 bool_hack true_healing(player_type *creature_ptr, HIT_POINT pow)
359 bool_hack ident = FALSE;
360 if (hp_player(creature_ptr, pow)) ident = TRUE;
361 if (set_blind(creature_ptr, 0)) ident = TRUE;
362 if (set_confused(creature_ptr, 0)) ident = TRUE;
363 if (set_poisoned(creature_ptr, 0)) ident = TRUE;
364 if (set_stun(creature_ptr, 0)) ident = TRUE;
365 if (set_cut(creature_ptr,0)) ident = TRUE;
366 if (set_image(creature_ptr, 0)) ident = TRUE;
370 bool_hack restore_mana(player_type *creature_ptr, bool_hack magic_eater)
372 bool_hack ident = FALSE;
374 if (creature_ptr->pclass == CLASS_MAGIC_EATER && magic_eater)
377 for (i = 0; i < EATER_EXT * 2; i++)
379 creature_ptr->magic_num1[i] += (creature_ptr->magic_num2[i] < 10) ? EATER_CHARGE * 3 : creature_ptr->magic_num2[i] * EATER_CHARGE / 3;
380 if (creature_ptr->magic_num1[i] > creature_ptr->magic_num2[i] * EATER_CHARGE) creature_ptr->magic_num1[i] = creature_ptr->magic_num2[i] * EATER_CHARGE;
382 for (; i < EATER_EXT * 3; i++)
384 KIND_OBJECT_IDX k_idx = lookup_kind(TV_ROD, i - EATER_EXT * 2);
385 creature_ptr->magic_num1[i] -= ((creature_ptr->magic_num2[i] < 10) ? EATER_ROD_CHARGE * 3 : creature_ptr->magic_num2[i] * EATER_ROD_CHARGE / 3)*k_info[k_idx].pval;
386 if (creature_ptr->magic_num1[i] < 0) creature_ptr->magic_num1[i] = 0;
388 msg_print(_("頭がハッキリとした。", "You feel your head clear."));
389 creature_ptr->window |= (PW_PLAYER);
392 else if (creature_ptr->csp < creature_ptr->msp)
394 creature_ptr->csp = creature_ptr->msp;
395 creature_ptr->csp_frac = 0;
396 msg_print(_("頭がハッキリとした。", "You feel your head clear."));
397 creature_ptr->redraw |= (PR_MANA);
398 creature_ptr->window |= (PW_PLAYER);
399 creature_ptr->window |= (PW_SPELL);
406 bool restore_all_status(player_type *creature_ptr)
409 if (do_res_stat(creature_ptr, A_STR)) ident = TRUE;
410 if (do_res_stat(creature_ptr, A_INT)) ident = TRUE;
411 if (do_res_stat(creature_ptr, A_WIS)) ident = TRUE;
412 if (do_res_stat(creature_ptr, A_DEX)) ident = TRUE;
413 if (do_res_stat(creature_ptr, A_CON)) ident = TRUE;
414 if (do_res_stat(creature_ptr, A_CHR)) ident = TRUE;
418 bool fishing(player_type *creature_ptr)
423 if (!get_direction(creature_ptr, &dir, FALSE, FALSE)) return FALSE;
424 y = creature_ptr->y + ddy[dir];
425 x = creature_ptr->x + ddx[dir];
426 creature_ptr->fishing_dir = dir;
427 if (!cave_have_flag_bold(creature_ptr->current_floor_ptr, y, x, FF_WATER))
429 msg_print(_("そこは水辺ではない。", "There is no fishing place."));
432 else if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx)
434 GAME_TEXT m_name[MAX_NLEN];
435 monster_desc(m_name, &creature_ptr->current_floor_ptr->m_list[creature_ptr->current_floor_ptr->grid_array[y][x].m_idx], 0);
436 msg_format(_("%sが邪魔だ!", "%^s is stand in your way."), m_name);
437 free_turn(creature_ptr);
440 set_action(creature_ptr, ACTION_FISH);
441 creature_ptr->redraw |= (PR_STATE);
446 bool cosmic_cast_off(player_type *creature_ptr, object_type *o_ptr)
451 GAME_TEXT o_name[MAX_NLEN];
454 /* Cast off activated item */
455 for (inv = INVEN_RARM; inv <= INVEN_FEET; inv++)
457 if (o_ptr == &creature_ptr->inventory_list[inv]) break;
459 if (inv > INVEN_FEET) return FALSE;
461 object_copy(&forge, o_ptr);
462 inven_item_increase(inv, (0 - o_ptr->number));
463 inven_item_optimize(inv);
464 o_idx = drop_near(&forge, 0, creature_ptr->y, creature_ptr->x);
465 o_ptr = &creature_ptr->current_floor_ptr->o_list[o_idx];
467 object_desc(o_name, o_ptr, OD_NAME_ONLY);
468 msg_format(_("%sを脱ぎ捨てた。", "You cast off %s."), o_name);
471 msg_print(_("「燃え上がれ俺の小宇宙!」", "You say, 'Burn up my cosmo!"));
472 t = 20 + randint1(20);
473 (void)set_blind(creature_ptr, creature_ptr->blind + t);
474 (void)set_afraid(creature_ptr, 0);
475 (void)set_tim_esp(creature_ptr, creature_ptr->tim_esp + t, FALSE);
476 (void)set_tim_regen(creature_ptr, creature_ptr->tim_regen + t, FALSE);
477 (void)set_hero(creature_ptr, creature_ptr->hero + t, FALSE);
478 (void)set_blessed(creature_ptr, creature_ptr->blessed + t, FALSE);
479 (void)set_fast(creature_ptr, creature_ptr->fast + t, FALSE);
480 (void)set_shero(creature_ptr, creature_ptr->shero + t, FALSE);
481 if (creature_ptr->pclass == CLASS_FORCETRAINER)
483 P_PTR_KI = creature_ptr->lev * 5 + 190;
484 msg_print(_("気が爆発寸前になった。", "Your force are immediatly before explosion."));
492 * @brief プレイヤーの因果混乱処理 / Apply Nexus
493 * @param m_ptr 因果混乱をプレイヤーに与えたモンスターの情報参照ポインタ
496 void apply_nexus(monster_type *m_ptr, player_type *target_ptr)
500 case 1: case 2: case 3:
502 teleport_player(target_ptr, 200, TELEPORT_PASSIVE);
508 teleport_player_to(target_ptr, m_ptr->fy, m_ptr->fx, TELEPORT_PASSIVE);
514 if (randint0(100) < target_ptr->skill_sav)
516 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
519 teleport_level(target_ptr, 0);
525 if (randint0(100) < target_ptr->skill_sav)
527 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
531 msg_print(_("体がねじれ始めた...", "Your body starts to scramble..."));
532 status_shuffle(target_ptr);
539 * @brief プレイヤーのステータスシャッフル処理
542 void status_shuffle(player_type *creature_ptr)
544 BASE_STATUS max1, cur1, max2, cur2;
547 /* Pick a pair of stats */
548 ii = randint0(A_MAX);
549 for (jj = ii; jj == ii; jj = randint0(A_MAX)) /* loop */;
551 max1 = creature_ptr->stat_max[ii];
552 cur1 = creature_ptr->stat_cur[ii];
553 max2 = creature_ptr->stat_max[jj];
554 cur2 = creature_ptr->stat_cur[jj];
556 creature_ptr->stat_max[ii] = max2;
557 creature_ptr->stat_cur[ii] = cur2;
558 creature_ptr->stat_max[jj] = max1;
559 creature_ptr->stat_cur[jj] = cur1;
561 for (i = 0; i < A_MAX; i++)
563 if (creature_ptr->stat_max[i] > creature_ptr->stat_max_max[i]) creature_ptr->stat_max[i] = creature_ptr->stat_max_max[i];
564 if (creature_ptr->stat_cur[i] > creature_ptr->stat_max_max[i]) creature_ptr->stat_cur[i] = creature_ptr->stat_max_max[i];
567 creature_ptr->update |= (PU_BONUS);