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."));
215 creature_ptr->timewalk = TRUE;
216 msg_print(_("「時よ!」", "You yell 'Time!'"));
217 // msg_print(_("「『ザ・ワールド』!時は止まった!」", "You yell 'The World! Time has stopped!'"));
220 creature_ptr->energy_need -= 1000 + (100 + creature_ptr->csp - 50)*TURNS_PER_TICK / 10;
221 creature_ptr->redraw |= (PR_MAP);
222 creature_ptr->update |= (PU_MONSTERS);
223 creature_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
230 * @brief プレイヤーのヒットダイスを振る / Role Hitpoints
231 * @param creature_ptr プレーヤーへの参照ポインタ
232 * @param options スペル共通オプション
235 void roll_hitdice(player_type *creature_ptr, SPOP_FLAGS options)
237 HIT_POINT min_value = creature_ptr->hitdie + ((PY_MAX_LEVEL + 2) * (creature_ptr->hitdie + 1)) * 3 / 8;
238 HIT_POINT max_value = creature_ptr->hitdie + ((PY_MAX_LEVEL + 2) * (creature_ptr->hitdie + 1)) * 5 / 8;
243 /* Pre-calculate level 1 hitdice */
244 creature_ptr->player_hp[0] = (HIT_POINT)creature_ptr->hitdie;
246 for (int i = 1; i < 4; i++)
248 creature_ptr->player_hp[0] += randint1(creature_ptr->hitdie);
251 /* Roll the hitpoint values */
252 for (int i = 1; i < PY_MAX_LEVEL; i++)
254 creature_ptr->player_hp[i] = creature_ptr->player_hp[i - 1] + randint1(creature_ptr->hitdie);
257 /* Require "valid" hitpoints at highest level */
258 if ((creature_ptr->player_hp[PY_MAX_LEVEL - 1] >= min_value) &&
259 (creature_ptr->player_hp[PY_MAX_LEVEL - 1] <= max_value)) break;
262 PERCENTAGE percent = (int)(((long)creature_ptr->player_hp[PY_MAX_LEVEL - 1] * 200L) /
263 (2 * creature_ptr->hitdie + ((PY_MAX_LEVEL - 1 + 3) * (creature_ptr->hitdie + 1))));
265 /* Update and redraw hitpoints */
266 creature_ptr->update |= (PU_HP);
267 creature_ptr->redraw |= (PR_HP);
268 creature_ptr->window |= (PW_PLAYER);
270 if (!(options & SPOP_NO_UPDATE)) handle_stuff();
272 if (!(options & SPOP_DISPLAY_MES)) return;
274 if (options & SPOP_DEBUG)
276 msg_format(_("現在の体力ランクは %d/100 です。", "Your life rate is %d/100 now."), percent);
277 creature_ptr->knowledge |= KNOW_HPRATE;
281 msg_print(_("体力ランクが変わった。", "Life rate is changed."));
282 creature_ptr->knowledge &= ~(KNOW_HPRATE);
286 bool_hack life_stream(player_type *creature_ptr, bool_hack message, bool_hack virtue_change)
290 chg_virtue(creature_ptr, V_VITALITY, 1);
291 chg_virtue(creature_ptr, V_UNLIFE, -5);
296 msg_print(_("体中に生命力が満ちあふれてきた!", "You feel life flow through your body!"));
299 restore_level(creature_ptr);
300 (void)set_poisoned(creature_ptr, 0);
301 (void)set_blind(creature_ptr, 0);
302 (void)set_confused(creature_ptr, 0);
303 (void)set_image(creature_ptr, 0);
304 (void)set_stun(creature_ptr, 0);
305 (void)set_cut(creature_ptr,0);
306 (void)restore_all_status(creature_ptr);
307 (void)set_shero(creature_ptr, 0, TRUE);
309 hp_player(creature_ptr, 5000);
315 bool_hack heroism(player_type *creature_ptr, int base)
317 bool_hack ident = FALSE;
318 if (set_afraid(creature_ptr, 0)) ident = TRUE;
319 if (set_hero(creature_ptr, creature_ptr->hero + randint1(base) + base, FALSE)) ident = TRUE;
320 if (hp_player(creature_ptr, 10)) ident = TRUE;
325 bool_hack berserk(player_type *creature_ptr, int base)
327 bool_hack ident = FALSE;
328 if (set_afraid(creature_ptr, 0)) ident = TRUE;
329 if (set_shero(creature_ptr, creature_ptr->shero + randint1(base) + base, FALSE)) ident = TRUE;
330 if (hp_player(creature_ptr, 30)) ident = TRUE;
335 bool_hack cure_light_wounds(player_type *creature_ptr, DICE_NUMBER dice, DICE_SID sides)
337 bool_hack ident = FALSE;
338 if (hp_player(creature_ptr, damroll(dice, sides))) ident = TRUE;
339 if (set_blind(creature_ptr, 0)) ident = TRUE;
340 if (set_cut(creature_ptr,creature_ptr->cut - 10)) ident = TRUE;
341 if (set_shero(creature_ptr, 0, TRUE)) ident = TRUE;
346 bool_hack cure_serious_wounds(player_type *creature_ptr, DICE_NUMBER dice, DICE_SID sides)
348 bool_hack ident = FALSE;
349 if (hp_player(creature_ptr, damroll(dice, sides))) ident = TRUE;
350 if (set_blind(creature_ptr, 0)) ident = TRUE;
351 if (set_confused(creature_ptr, 0)) ident = TRUE;
352 if (set_cut(creature_ptr,(creature_ptr->cut / 2) - 50)) ident = TRUE;
353 if (set_shero(creature_ptr, 0, TRUE)) ident = TRUE;
358 bool_hack cure_critical_wounds(player_type *creature_ptr, HIT_POINT pow)
360 bool_hack ident = FALSE;
361 if (hp_player(creature_ptr, pow)) ident = TRUE;
362 if (set_blind(creature_ptr, 0)) ident = TRUE;
363 if (set_confused(creature_ptr, 0)) ident = TRUE;
364 if (set_poisoned(creature_ptr, 0)) ident = TRUE;
365 if (set_stun(creature_ptr, 0)) ident = TRUE;
366 if (set_cut(creature_ptr,0)) ident = TRUE;
367 if (set_shero(creature_ptr, 0, TRUE)) ident = TRUE;
372 bool_hack true_healing(player_type *creature_ptr, HIT_POINT pow)
374 bool_hack ident = FALSE;
375 if (hp_player(creature_ptr, pow)) ident = TRUE;
376 if (set_blind(creature_ptr, 0)) ident = TRUE;
377 if (set_confused(creature_ptr, 0)) ident = TRUE;
378 if (set_poisoned(creature_ptr, 0)) ident = TRUE;
379 if (set_stun(creature_ptr, 0)) ident = TRUE;
380 if (set_cut(creature_ptr,0)) ident = TRUE;
381 if (set_image(creature_ptr, 0)) ident = TRUE;
386 bool_hack restore_mana(player_type *creature_ptr, bool_hack magic_eater)
388 if (creature_ptr->pclass == CLASS_MAGIC_EATER && magic_eater)
391 for (i = 0; i < EATER_EXT * 2; i++)
393 creature_ptr->magic_num1[i] += (creature_ptr->magic_num2[i] < 10) ? EATER_CHARGE * 3 : creature_ptr->magic_num2[i] * EATER_CHARGE / 3;
394 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;
397 for (; i < EATER_EXT * 3; i++)
399 KIND_OBJECT_IDX k_idx = lookup_kind(TV_ROD, i - EATER_EXT * 2);
400 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;
401 if (creature_ptr->magic_num1[i] < 0) creature_ptr->magic_num1[i] = 0;
404 msg_print(_("頭がハッキリとした。", "You feel your head clear."));
405 creature_ptr->window |= (PW_PLAYER);
409 if (creature_ptr->csp >= creature_ptr->msp) return FALSE;
411 creature_ptr->csp = creature_ptr->msp;
412 creature_ptr->csp_frac = 0;
413 msg_print(_("頭がハッキリとした。", "You feel your head clear."));
414 creature_ptr->redraw |= (PR_MANA);
415 creature_ptr->window |= (PW_PLAYER);
416 creature_ptr->window |= (PW_SPELL);
421 bool restore_all_status(player_type *creature_ptr)
424 if (do_res_stat(creature_ptr, A_STR)) ident = TRUE;
425 if (do_res_stat(creature_ptr, A_INT)) ident = TRUE;
426 if (do_res_stat(creature_ptr, A_WIS)) ident = TRUE;
427 if (do_res_stat(creature_ptr, A_DEX)) ident = TRUE;
428 if (do_res_stat(creature_ptr, A_CON)) ident = TRUE;
429 if (do_res_stat(creature_ptr, A_CHR)) ident = TRUE;
434 bool fishing(player_type *creature_ptr)
437 if (!get_direction(creature_ptr, &dir, FALSE, FALSE)) return FALSE;
438 POSITION y = creature_ptr->y + ddy[dir];
439 POSITION x = creature_ptr->x + ddx[dir];
440 creature_ptr->fishing_dir = dir;
441 if (!cave_have_flag_bold(creature_ptr->current_floor_ptr, y, x, FF_WATER))
443 msg_print(_("そこは水辺ではない。", "There is no fishing place."));
447 if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx)
449 GAME_TEXT m_name[MAX_NLEN];
450 monster_desc(m_name, &creature_ptr->current_floor_ptr->m_list[creature_ptr->current_floor_ptr->grid_array[y][x].m_idx], 0);
451 msg_format(_("%sが邪魔だ!", "%^s is stand in your way."), m_name);
452 free_turn(creature_ptr);
456 set_action(creature_ptr, ACTION_FISH);
457 creature_ptr->redraw |= (PR_STATE);
462 bool cosmic_cast_off(player_type *creature_ptr, object_type *o_ptr)
464 /* Cast off activated item */
466 for (inv = INVEN_RARM; inv <= INVEN_FEET; inv++)
468 if (o_ptr == &creature_ptr->inventory_list[inv]) break;
471 if (inv > INVEN_FEET) return FALSE;
474 object_copy(&forge, o_ptr);
475 inven_item_increase(inv, (0 - o_ptr->number));
476 inven_item_optimize(inv);
477 OBJECT_IDX o_idx = drop_near(creature_ptr, &forge, 0, creature_ptr->y, creature_ptr->x);
478 o_ptr = &creature_ptr->current_floor_ptr->o_list[o_idx];
480 GAME_TEXT o_name[MAX_NLEN];
481 object_desc(o_name, o_ptr, OD_NAME_ONLY);
482 msg_format(_("%sを脱ぎ捨てた。", "You cast off %s."), o_name);
485 msg_print(_("「燃え上がれ俺の小宇宙!」", "You say, 'Burn up my cosmo!"));
486 int t = 20 + randint1(20);
487 (void)set_blind(creature_ptr, creature_ptr->blind + t);
488 (void)set_afraid(creature_ptr, 0);
489 (void)set_tim_esp(creature_ptr, creature_ptr->tim_esp + t, FALSE);
490 (void)set_tim_regen(creature_ptr, creature_ptr->tim_regen + t, FALSE);
491 (void)set_hero(creature_ptr, creature_ptr->hero + t, FALSE);
492 (void)set_blessed(creature_ptr, creature_ptr->blessed + t, FALSE);
493 (void)set_fast(creature_ptr, creature_ptr->fast + t, FALSE);
494 (void)set_shero(creature_ptr, creature_ptr->shero + t, FALSE);
495 if (creature_ptr->pclass == CLASS_FORCETRAINER)
497 P_PTR_KI = creature_ptr->lev * 5 + 190;
498 msg_print(_("気が爆発寸前になった。", "Your force are immediatly before explosion."));
506 * @brief プレイヤーの因果混乱処理 / Apply Nexus
507 * @param m_ptr 因果混乱をプレイヤーに与えたモンスターの情報参照ポインタ
510 void apply_nexus(monster_type *m_ptr, player_type *target_ptr)
514 case 1: case 2: case 3:
516 teleport_player(target_ptr, 200, TELEPORT_PASSIVE);
522 teleport_player_to(target_ptr, m_ptr->fy, m_ptr->fx, TELEPORT_PASSIVE);
528 if (randint0(100) < target_ptr->skill_sav)
530 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
534 teleport_level(target_ptr, 0);
540 if (randint0(100) < target_ptr->skill_sav)
542 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
546 msg_print(_("体がねじれ始めた...", "Your body starts to scramble..."));
547 status_shuffle(target_ptr);
555 * @brief プレイヤーのステータスシャッフル処理
556 * @param creature_ptr プレーヤーへの参照ポインタ
559 void status_shuffle(player_type *creature_ptr)
561 /* Pick a pair of stats */
562 int i = randint0(A_MAX);
565 // todo ここのループは一体何をしている?
566 for (j = i; j == i; j = randint0(A_MAX)) /* loop */;
568 BASE_STATUS max1 = creature_ptr->stat_max[i];
569 BASE_STATUS cur1 = creature_ptr->stat_cur[i];
570 BASE_STATUS max2 = creature_ptr->stat_max[j];
571 BASE_STATUS cur2 = creature_ptr->stat_cur[j];
573 creature_ptr->stat_max[i] = max2;
574 creature_ptr->stat_cur[i] = cur2;
575 creature_ptr->stat_max[j] = max1;
576 creature_ptr->stat_cur[j] = cur1;
578 for (int k = 0; k < A_MAX; k++)
580 if (creature_ptr->stat_max[k] > creature_ptr->stat_max_max[k]) creature_ptr->stat_max[k] = creature_ptr->stat_max_max[k];
581 if (creature_ptr->stat_cur[k] > creature_ptr->stat_max_max[k]) creature_ptr->stat_cur[k] = creature_ptr->stat_max_max[k];
584 creature_ptr->update |= PU_BONUS;