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(player_type *caster_ptr, DIRECTION dir, HIT_POINT dam)
30 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
31 return (project_hook(caster_ptr, GF_OLD_HEAL, dir, dam, flg));
37 * @param caster_ptr プレーヤーへの参照ポインタ
38 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
40 * @return 作用が実際にあった場合TRUEを返す
42 bool speed_monster(player_type *caster_ptr, DIRECTION dir, int power)
44 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
45 return (project_hook(caster_ptr, GF_OLD_SPEED, dir, power, flg));
51 * @param caster_ptr プレーヤーへの参照ポインタ
52 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
54 * @return 作用が実際にあった場合TRUEを返す
56 bool slow_monster(player_type *caster_ptr, DIRECTION dir, int power)
58 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
59 return (project_hook(caster_ptr, GF_OLD_SLOW, dir, power, flg));
65 * @param caster_ptr プレーヤーへの参照ポインタ
66 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
68 * @return 作用が実際にあった場合TRUEを返す
70 bool sleep_monster(player_type *caster_ptr, DIRECTION dir, int power)
72 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
73 return (project_hook(caster_ptr, GF_OLD_SLEEP, dir, power, flg));
78 * @brief モンスター拘束(STASIS)処理
79 * @param caster_ptr プレーヤーへの参照ポインタ
80 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
81 * @return 作用が実際にあった場合TRUEを返す
82 * @details 威力はプレイヤーレベル*2に固定
84 bool stasis_monster(player_type *caster_ptr, DIRECTION dir)
86 return (fire_ball_hide(caster_ptr, GF_STASIS, dir, caster_ptr->lev * 2, 0));
91 * @brief 邪悪なモンスター拘束(STASIS)処理
92 * @param caster_ptr プレーヤーへの参照ポインタ
93 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
94 * @return 作用が実際にあった場合TRUEを返す
95 * @details 威力はプレイヤーレベル*2に固定
97 bool stasis_evil(player_type *caster_ptr, DIRECTION dir)
99 return (fire_ball_hide(caster_ptr, GF_STASIS_EVIL, dir, caster_ptr->lev * 2, 0));
105 * @param caster_ptr プレーヤーへの参照ポインタ
106 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
107 * @param plev プレイヤーレベル(=効力)
108 * @return 作用が実際にあった場合TRUEを返す
110 bool confuse_monster(player_type *caster_ptr, DIRECTION dir, PLAYER_LEVEL plev)
112 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
113 return (project_hook(caster_ptr, GF_OLD_CONF, dir, plev, flg));
119 * @param caster_ptr プレーヤーへの参照ポインタ
120 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
121 * @param plev プレイヤーレベル(=効力)
122 * @return 作用が実際にあった場合TRUEを返す
124 bool stun_monster(player_type *caster_ptr, DIRECTION dir, PLAYER_LEVEL plev)
126 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
127 return (project_hook(caster_ptr, GF_STUN, dir, plev, flg));
133 * @param caster_ptr プレーヤーへの参照ポインタ
134 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
136 * @return 作用が実際にあった場合TRUEを返す
138 bool poly_monster(player_type *caster_ptr, DIRECTION dir, int power)
140 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
141 bool tester = (project_hook(caster_ptr, GF_OLD_POLY, dir, power, flg));
143 chg_virtue(caster_ptr, V_CHANCE, 1);
150 * @param caster_ptr プレーヤーへの参照ポインタ
151 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
152 * @return 作用が実際にあった場合TRUEを返す
154 bool clone_monster(player_type *caster_ptr, DIRECTION dir)
156 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
157 return (project_hook(caster_ptr, GF_OLD_CLONE, dir, 0, flg));
163 * @param caster_ptr プレーヤーへの参照ポインタ
164 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
165 * @param plev プレイヤーレベル(=効力)
166 * @return 作用が実際にあった場合TRUEを返す
168 bool fear_monster(player_type *caster_ptr, DIRECTION dir, PLAYER_LEVEL plev)
170 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
171 return (project_hook(caster_ptr, GF_TURN_ALL, dir, plev, flg));
176 * @brief 歌の停止を処理する / Stop singing if the player is a Bard
179 void stop_singing(player_type *creature_ptr)
181 if (creature_ptr->pclass != CLASS_BARD) return;
183 /* Are there interupted song? */
184 if (INTERUPTING_SONG_EFFECT(creature_ptr))
186 /* Forget interupted song */
187 INTERUPTING_SONG_EFFECT(creature_ptr) = MUSIC_NONE;
191 /* The player is singing? */
192 if (!SINGING_SONG_EFFECT(creature_ptr)) return;
194 /* Hack -- if called from set_action(), avoid recursive loop */
195 if (creature_ptr->action == ACTION_SING) set_action(creature_ptr, ACTION_NONE);
197 /* Message text of each song or etc. */
198 exe_spell(creature_ptr, REALM_MUSIC, SINGING_SONG_ID(creature_ptr), SPELL_STOP);
200 SINGING_SONG_EFFECT(creature_ptr) = MUSIC_NONE;
201 SINGING_SONG_ID(creature_ptr) = 0;
202 creature_ptr->update |= (PU_BONUS);
203 creature_ptr->redraw |= (PR_STATUS);
207 bool time_walk(player_type *creature_ptr)
209 if (creature_ptr->timewalk)
211 msg_print(_("既に時は止まっている。", "Time is already stopped."));
214 creature_ptr->timewalk = TRUE;
215 msg_print(_("「時よ!」", "You yell 'Time!'"));
216 // msg_print(_("「『ザ・ワールド』!時は止まった!」", "You yell 'The World! Time has stopped!'"));
219 creature_ptr->energy_need -= 1000 + (100 + creature_ptr->csp - 50)*TURNS_PER_TICK / 10;
220 creature_ptr->redraw |= (PR_MAP);
221 creature_ptr->update |= (PU_MONSTERS);
222 creature_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
229 * @brief プレイヤーのヒットダイスを振る / Role Hitpoints
230 * @param options スペル共通オプション
233 void roll_hitdice(player_type *creature_ptr, SPOP_FLAGS options)
237 /* Minimum hitpoints at highest level */
238 HIT_POINT min_value = creature_ptr->hitdie + ((PY_MAX_LEVEL + 2) * (creature_ptr->hitdie + 1)) * 3 / 8;
240 /* Maximum hitpoints at highest level */
241 HIT_POINT max_value = creature_ptr->hitdie + ((PY_MAX_LEVEL + 2) * (creature_ptr->hitdie + 1)) * 5 / 8;
248 /* Pre-calculate level 1 hitdice */
249 creature_ptr->player_hp[0] = (HIT_POINT)creature_ptr->hitdie;
251 for (i = 1; i < 4; i++)
253 creature_ptr->player_hp[0] += randint1(creature_ptr->hitdie);
256 /* Roll the hitpoint values */
257 for (i = 1; i < PY_MAX_LEVEL; i++)
259 creature_ptr->player_hp[i] = creature_ptr->player_hp[i - 1] + randint1(creature_ptr->hitdie);
262 /* Require "valid" hitpoints at highest level */
263 if ((creature_ptr->player_hp[PY_MAX_LEVEL - 1] >= min_value) &&
264 (creature_ptr->player_hp[PY_MAX_LEVEL - 1] <= max_value)) break;
267 percent = (int)(((long)creature_ptr->player_hp[PY_MAX_LEVEL - 1] * 200L) /
268 (2 * creature_ptr->hitdie + ((PY_MAX_LEVEL - 1 + 3) * (creature_ptr->hitdie + 1))));
270 /* Update and redraw hitpoints */
271 creature_ptr->update |= (PU_HP);
272 creature_ptr->redraw |= (PR_HP);
273 creature_ptr->window |= (PW_PLAYER);
275 if (!(options & SPOP_NO_UPDATE)) handle_stuff();
277 if (options & SPOP_DISPLAY_MES)
279 if (options & SPOP_DEBUG)
281 msg_format(_("現在の体力ランクは %d/100 です。", "Your life rate is %d/100 now."), percent);
282 creature_ptr->knowledge |= KNOW_HPRATE;
286 msg_print(_("体力ランクが変わった。", "Life rate is changed."));
287 creature_ptr->knowledge &= ~(KNOW_HPRATE);
293 bool_hack life_stream(player_type *creature_ptr, bool_hack message, bool_hack virtue_change)
297 chg_virtue(creature_ptr, V_VITALITY, 1);
298 chg_virtue(creature_ptr, V_UNLIFE, -5);
302 msg_print(_("体中に生命力が満ちあふれてきた!", "You feel life flow through your body!"));
304 restore_level(creature_ptr);
305 (void)set_poisoned(creature_ptr, 0);
306 (void)set_blind(creature_ptr, 0);
307 (void)set_confused(creature_ptr, 0);
308 (void)set_image(creature_ptr, 0);
309 (void)set_stun(creature_ptr, 0);
310 (void)set_cut(creature_ptr,0);
311 (void)restore_all_status(creature_ptr);
312 (void)set_shero(creature_ptr, 0, TRUE);
314 hp_player(creature_ptr, 5000);
320 bool_hack heroism(player_type *creature_ptr, int base)
322 bool_hack ident = FALSE;
323 if (set_afraid(creature_ptr, 0)) ident = TRUE;
324 if (set_hero(creature_ptr, creature_ptr->hero + randint1(base) + base, FALSE)) ident = TRUE;
325 if (hp_player(creature_ptr, 10)) ident = TRUE;
330 bool_hack berserk(player_type *creature_ptr, int base)
332 bool_hack ident = FALSE;
333 if (set_afraid(creature_ptr, 0)) ident = TRUE;
334 if (set_shero(creature_ptr, creature_ptr->shero + randint1(base) + base, FALSE)) ident = TRUE;
335 if (hp_player(creature_ptr, 30)) ident = TRUE;
340 bool_hack cure_light_wounds(player_type *creature_ptr, DICE_NUMBER dice, DICE_SID sides)
342 bool_hack ident = FALSE;
343 if (hp_player(creature_ptr, damroll(dice, sides))) ident = TRUE;
344 if (set_blind(creature_ptr, 0)) ident = TRUE;
345 if (set_cut(creature_ptr,creature_ptr->cut - 10)) ident = TRUE;
346 if (set_shero(creature_ptr, 0, TRUE)) ident = TRUE;
351 bool_hack cure_serious_wounds(player_type *creature_ptr, DICE_NUMBER dice, DICE_SID sides)
353 bool_hack ident = FALSE;
354 if (hp_player(creature_ptr, damroll(dice, sides))) ident = TRUE;
355 if (set_blind(creature_ptr, 0)) ident = TRUE;
356 if (set_confused(creature_ptr, 0)) ident = TRUE;
357 if (set_cut(creature_ptr,(creature_ptr->cut / 2) - 50)) ident = TRUE;
358 if (set_shero(creature_ptr, 0, TRUE)) ident = TRUE;
363 bool_hack cure_critical_wounds(player_type *creature_ptr, HIT_POINT pow)
365 bool_hack ident = FALSE;
366 if (hp_player(creature_ptr, pow)) ident = TRUE;
367 if (set_blind(creature_ptr, 0)) ident = TRUE;
368 if (set_confused(creature_ptr, 0)) ident = TRUE;
369 if (set_poisoned(creature_ptr, 0)) ident = TRUE;
370 if (set_stun(creature_ptr, 0)) ident = TRUE;
371 if (set_cut(creature_ptr,0)) ident = TRUE;
372 if (set_shero(creature_ptr, 0, TRUE)) ident = TRUE;
377 bool_hack true_healing(player_type *creature_ptr, HIT_POINT pow)
379 bool_hack ident = FALSE;
380 if (hp_player(creature_ptr, pow)) ident = TRUE;
381 if (set_blind(creature_ptr, 0)) ident = TRUE;
382 if (set_confused(creature_ptr, 0)) ident = TRUE;
383 if (set_poisoned(creature_ptr, 0)) ident = TRUE;
384 if (set_stun(creature_ptr, 0)) ident = TRUE;
385 if (set_cut(creature_ptr,0)) ident = TRUE;
386 if (set_image(creature_ptr, 0)) ident = TRUE;
391 bool_hack restore_mana(player_type *creature_ptr, bool_hack magic_eater)
393 bool_hack ident = FALSE;
395 if (creature_ptr->pclass == CLASS_MAGIC_EATER && magic_eater)
398 for (i = 0; i < EATER_EXT * 2; i++)
400 creature_ptr->magic_num1[i] += (creature_ptr->magic_num2[i] < 10) ? EATER_CHARGE * 3 : creature_ptr->magic_num2[i] * EATER_CHARGE / 3;
401 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;
403 for (; i < EATER_EXT * 3; i++)
405 KIND_OBJECT_IDX k_idx = lookup_kind(TV_ROD, i - EATER_EXT * 2);
406 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;
407 if (creature_ptr->magic_num1[i] < 0) creature_ptr->magic_num1[i] = 0;
409 msg_print(_("頭がハッキリとした。", "You feel your head clear."));
410 creature_ptr->window |= (PW_PLAYER);
413 else if (creature_ptr->csp < creature_ptr->msp)
415 creature_ptr->csp = creature_ptr->msp;
416 creature_ptr->csp_frac = 0;
417 msg_print(_("頭がハッキリとした。", "You feel your head clear."));
418 creature_ptr->redraw |= (PR_MANA);
419 creature_ptr->window |= (PW_PLAYER);
420 creature_ptr->window |= (PW_SPELL);
428 bool restore_all_status(player_type *creature_ptr)
431 if (do_res_stat(creature_ptr, A_STR)) ident = TRUE;
432 if (do_res_stat(creature_ptr, A_INT)) ident = TRUE;
433 if (do_res_stat(creature_ptr, A_WIS)) ident = TRUE;
434 if (do_res_stat(creature_ptr, A_DEX)) ident = TRUE;
435 if (do_res_stat(creature_ptr, A_CON)) ident = TRUE;
436 if (do_res_stat(creature_ptr, A_CHR)) ident = TRUE;
441 bool fishing(player_type *creature_ptr)
446 if (!get_direction(creature_ptr, &dir, FALSE, FALSE)) return FALSE;
447 y = creature_ptr->y + ddy[dir];
448 x = creature_ptr->x + ddx[dir];
449 creature_ptr->fishing_dir = dir;
450 if (!cave_have_flag_bold(creature_ptr->current_floor_ptr, y, x, FF_WATER))
452 msg_print(_("そこは水辺ではない。", "There is no fishing place."));
455 else if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx)
457 GAME_TEXT m_name[MAX_NLEN];
458 monster_desc(m_name, &creature_ptr->current_floor_ptr->m_list[creature_ptr->current_floor_ptr->grid_array[y][x].m_idx], 0);
459 msg_format(_("%sが邪魔だ!", "%^s is stand in your way."), m_name);
460 free_turn(creature_ptr);
463 set_action(creature_ptr, ACTION_FISH);
464 creature_ptr->redraw |= (PR_STATE);
469 bool cosmic_cast_off(player_type *creature_ptr, object_type *o_ptr)
474 GAME_TEXT o_name[MAX_NLEN];
477 /* Cast off activated item */
478 for (inv = INVEN_RARM; inv <= INVEN_FEET; inv++)
480 if (o_ptr == &creature_ptr->inventory_list[inv]) break;
482 if (inv > INVEN_FEET) return FALSE;
484 object_copy(&forge, o_ptr);
485 inven_item_increase(inv, (0 - o_ptr->number));
486 inven_item_optimize(inv);
487 o_idx = drop_near(&forge, 0, creature_ptr->y, creature_ptr->x);
488 o_ptr = &creature_ptr->current_floor_ptr->o_list[o_idx];
490 object_desc(o_name, o_ptr, OD_NAME_ONLY);
491 msg_format(_("%sを脱ぎ捨てた。", "You cast off %s."), o_name);
494 msg_print(_("「燃え上がれ俺の小宇宙!」", "You say, 'Burn up my cosmo!"));
495 t = 20 + randint1(20);
496 (void)set_blind(creature_ptr, creature_ptr->blind + t);
497 (void)set_afraid(creature_ptr, 0);
498 (void)set_tim_esp(creature_ptr, creature_ptr->tim_esp + t, FALSE);
499 (void)set_tim_regen(creature_ptr, creature_ptr->tim_regen + t, FALSE);
500 (void)set_hero(creature_ptr, creature_ptr->hero + t, FALSE);
501 (void)set_blessed(creature_ptr, creature_ptr->blessed + t, FALSE);
502 (void)set_fast(creature_ptr, creature_ptr->fast + t, FALSE);
503 (void)set_shero(creature_ptr, creature_ptr->shero + t, FALSE);
504 if (creature_ptr->pclass == CLASS_FORCETRAINER)
506 P_PTR_KI = creature_ptr->lev * 5 + 190;
507 msg_print(_("気が爆発寸前になった。", "Your force are immediatly before explosion."));
515 * @brief プレイヤーの因果混乱処理 / Apply Nexus
516 * @param m_ptr 因果混乱をプレイヤーに与えたモンスターの情報参照ポインタ
519 void apply_nexus(monster_type *m_ptr, player_type *target_ptr)
523 case 1: case 2: case 3:
525 teleport_player(target_ptr, 200, TELEPORT_PASSIVE);
531 teleport_player_to(target_ptr, m_ptr->fy, m_ptr->fx, TELEPORT_PASSIVE);
537 if (randint0(100) < target_ptr->skill_sav)
539 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
542 teleport_level(target_ptr, 0);
548 if (randint0(100) < target_ptr->skill_sav)
550 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
554 msg_print(_("体がねじれ始めた...", "Your body starts to scramble..."));
555 status_shuffle(target_ptr);
562 * @brief プレイヤーのステータスシャッフル処理
565 void status_shuffle(player_type *creature_ptr)
567 BASE_STATUS max1, cur1, max2, cur2;
570 /* Pick a pair of stats */
571 ii = randint0(A_MAX);
572 for (jj = ii; jj == ii; jj = randint0(A_MAX)) /* loop */;
574 max1 = creature_ptr->stat_max[ii];
575 cur1 = creature_ptr->stat_cur[ii];
576 max2 = creature_ptr->stat_max[jj];
577 cur2 = creature_ptr->stat_cur[jj];
579 creature_ptr->stat_max[ii] = max2;
580 creature_ptr->stat_cur[ii] = cur2;
581 creature_ptr->stat_max[jj] = max1;
582 creature_ptr->stat_cur[jj] = cur1;
584 for (i = 0; i < A_MAX; i++)
586 if (creature_ptr->stat_max[i] > creature_ptr->stat_max_max[i]) creature_ptr->stat_max[i] = creature_ptr->stat_max_max[i];
587 if (creature_ptr->stat_cur[i] > creature_ptr->stat_max_max[i]) creature_ptr->stat_cur[i] = creature_ptr->stat_max_max[i];
590 creature_ptr->update |= (PU_BONUS);