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 dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
25 * @return 作用が実際にあった場合TRUEを返す
27 bool heal_monster(DIRECTION dir, HIT_POINT dam)
29 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
30 return (project_hook(GF_OLD_HEAL, dir, dam, flg));
35 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
37 * @return 作用が実際にあった場合TRUEを返す
39 bool speed_monster(DIRECTION dir, int power)
41 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
42 return (project_hook(GF_OLD_SPEED, dir, power, flg));
47 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
49 * @return 作用が実際にあった場合TRUEを返す
51 bool slow_monster(DIRECTION dir, int power)
53 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
54 return (project_hook(GF_OLD_SLOW, dir, power, flg));
59 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
61 * @return 作用が実際にあった場合TRUEを返す
63 bool sleep_monster(DIRECTION dir, int power)
65 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
66 return (project_hook(GF_OLD_SLEEP, dir, power, flg));
70 * @brief モンスター拘束(STASIS)処理
71 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
72 * @return 作用が実際にあった場合TRUEを返す
73 * @details 威力はプレイヤーレベル*2に固定
75 bool stasis_monster(DIRECTION dir)
77 return (fire_ball_hide(GF_STASIS, dir, p_ptr->lev * 2, 0));
81 * @brief 邪悪なモンスター拘束(STASIS)処理
82 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
83 * @return 作用が実際にあった場合TRUEを返す
84 * @details 威力はプレイヤーレベル*2に固定
86 bool stasis_evil(DIRECTION dir)
88 return (fire_ball_hide(GF_STASIS_EVIL, dir, p_ptr->lev * 2, 0));
93 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
94 * @param plev プレイヤーレベル(=効力)
95 * @return 作用が実際にあった場合TRUEを返す
97 bool confuse_monster(DIRECTION dir, PLAYER_LEVEL plev)
99 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
100 return (project_hook(GF_OLD_CONF, dir, plev, flg));
105 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
106 * @param plev プレイヤーレベル(=効力)
107 * @return 作用が実際にあった場合TRUEを返す
109 bool stun_monster(DIRECTION dir, PLAYER_LEVEL plev)
111 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
112 return (project_hook(GF_STUN, dir, plev, flg));
117 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
119 * @return 作用が実際にあった場合TRUEを返す
121 bool poly_monster(DIRECTION dir, int power)
123 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
124 bool tester = (project_hook(GF_OLD_POLY, dir, power, flg));
126 chg_virtue(V_CHANCE, 1);
132 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
133 * @return 作用が実際にあった場合TRUEを返す
135 bool clone_monster(DIRECTION dir)
137 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
138 return (project_hook(GF_OLD_CLONE, dir, 0, flg));
143 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
144 * @param plev プレイヤーレベル(=効力)
145 * @return 作用が実際にあった場合TRUEを返す
147 bool fear_monster(DIRECTION dir, PLAYER_LEVEL plev)
149 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
150 return (project_hook(GF_TURN_ALL, dir, plev, flg));
154 * @brief 歌の停止を処理する / Stop singing if the player is a Bard
157 void stop_singing(player_type *creature_ptr)
159 if (creature_ptr->pclass != CLASS_BARD) return;
161 /* Are there interupted song? */
162 if (INTERUPTING_SONG_EFFECT(creature_ptr))
164 /* Forget interupted song */
165 INTERUPTING_SONG_EFFECT(creature_ptr) = MUSIC_NONE;
169 /* The player is singing? */
170 if (!SINGING_SONG_EFFECT(creature_ptr)) return;
172 /* Hack -- if called from set_action(), avoid recursive loop */
173 if (creature_ptr->action == ACTION_SING) set_action(ACTION_NONE);
175 /* Message text of each song or etc. */
176 do_spell(REALM_MUSIC, SINGING_SONG_ID(creature_ptr), SPELL_STOP);
178 SINGING_SONG_EFFECT(creature_ptr) = MUSIC_NONE;
179 SINGING_SONG_ID(creature_ptr) = 0;
180 creature_ptr->update |= (PU_BONUS);
181 creature_ptr->redraw |= (PR_STATUS);
184 bool time_walk(player_type *creature_ptr)
186 if (creature_ptr->timewalk)
188 msg_print(_("既に時は止まっている。", "Time is already stopped."));
191 creature_ptr->timewalk = TRUE;
192 msg_print(_("「時よ!」", "You yell 'Time!'"));
193 // msg_print(_("「『ザ・ワールド』!時は止まった!」", "You yell 'The World! Time has stopped!'"));
197 creature_ptr->energy_need -= 1000 + (100 + p_ptr->csp - 50)*TURNS_PER_TICK / 10;
198 creature_ptr->redraw |= (PR_MAP);
199 creature_ptr->update |= (PU_MONSTERS);
200 creature_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
206 * @brief プレイヤーのヒットダイスを振る / Role Hitpoints
207 * @param options スペル共通オプション
210 void roll_hitdice(player_type *creature_ptr, SPOP_FLAGS options)
214 /* Minimum hitpoints at highest level */
215 HIT_POINT min_value = creature_ptr->hitdie + ((PY_MAX_LEVEL + 2) * (creature_ptr->hitdie + 1)) * 3 / 8;
217 /* Maximum hitpoints at highest level */
218 HIT_POINT max_value = creature_ptr->hitdie + ((PY_MAX_LEVEL + 2) * (creature_ptr->hitdie + 1)) * 5 / 8;
225 /* Pre-calculate level 1 hitdice */
226 creature_ptr->player_hp[0] = (HIT_POINT)creature_ptr->hitdie;
228 for (i = 1; i < 4; i++)
230 creature_ptr->player_hp[0] += randint1(creature_ptr->hitdie);
233 /* Roll the hitpoint values */
234 for (i = 1; i < PY_MAX_LEVEL; i++)
236 creature_ptr->player_hp[i] = creature_ptr->player_hp[i - 1] + randint1(creature_ptr->hitdie);
239 /* Require "valid" hitpoints at highest level */
240 if ((creature_ptr->player_hp[PY_MAX_LEVEL - 1] >= min_value) &&
241 (creature_ptr->player_hp[PY_MAX_LEVEL - 1] <= max_value)) break;
244 percent = (int)(((long)creature_ptr->player_hp[PY_MAX_LEVEL - 1] * 200L) /
245 (2 * creature_ptr->hitdie + ((PY_MAX_LEVEL - 1 + 3) * (creature_ptr->hitdie + 1))));
247 /* Update and redraw hitpoints */
248 creature_ptr->update |= (PU_HP);
249 creature_ptr->redraw |= (PR_HP);
250 creature_ptr->window |= (PW_PLAYER);
252 if (!(options & SPOP_NO_UPDATE)) handle_stuff();
254 if (options & SPOP_DISPLAY_MES)
256 if (options & SPOP_DEBUG)
258 msg_format(_("現在の体力ランクは %d/100 です。", "Your life rate is %d/100 now."), percent);
259 creature_ptr->knowledge |= KNOW_HPRATE;
263 msg_print(_("体力ランクが変わった。", "Life rate is changed."));
264 creature_ptr->knowledge &= ~(KNOW_HPRATE);
269 bool_hack life_stream(bool_hack message, bool_hack virtue_change)
273 chg_virtue(V_VITALITY, 1);
274 chg_virtue(V_UNLIFE, -5);
278 msg_print(_("体中に生命力が満ちあふれてきた!", "You feel life flow through your body!"));
281 (void)set_poisoned(0);
283 (void)set_confused(0);
287 (void)restore_all_status();
288 (void)set_shero(0, TRUE);
295 bool_hack heroism(int base)
297 bool_hack ident = FALSE;
298 if (set_afraid(0)) ident = TRUE;
299 if (set_hero(p_ptr->hero + randint1(base) + base, FALSE)) ident = TRUE;
300 if (hp_player(10)) ident = TRUE;
304 bool_hack berserk(int base)
306 bool_hack ident = FALSE;
307 if (set_afraid(0)) ident = TRUE;
308 if (set_shero(p_ptr->shero + randint1(base) + base, FALSE)) ident = TRUE;
309 if (hp_player(30)) ident = TRUE;
313 bool_hack cure_light_wounds(DICE_NUMBER dice, DICE_SID sides)
315 bool_hack ident = FALSE;
316 if (hp_player(damroll(dice, sides))) ident = TRUE;
317 if (set_blind(0)) ident = TRUE;
318 if (set_cut(p_ptr->cut - 10)) ident = TRUE;
319 if (set_shero(0, TRUE)) ident = TRUE;
323 bool_hack cure_serious_wounds(DICE_NUMBER dice, DICE_SID sides)
325 bool_hack ident = FALSE;
326 if (hp_player(damroll(dice, sides))) ident = TRUE;
327 if (set_blind(0)) ident = TRUE;
328 if (set_confused(0)) ident = TRUE;
329 if (set_cut((p_ptr->cut / 2) - 50)) ident = TRUE;
330 if (set_shero(0, TRUE)) ident = TRUE;
334 bool_hack cure_critical_wounds(HIT_POINT pow)
336 bool_hack ident = FALSE;
337 if (hp_player(pow)) ident = TRUE;
338 if (set_blind(0)) ident = TRUE;
339 if (set_confused(0)) ident = TRUE;
340 if (set_poisoned(0)) ident = TRUE;
341 if (set_stun(0)) ident = TRUE;
342 if (set_cut(0)) ident = TRUE;
343 if (set_shero(0, TRUE)) ident = TRUE;
347 bool_hack true_healing(HIT_POINT pow)
349 bool_hack ident = FALSE;
350 if (hp_player(pow)) ident = TRUE;
351 if (set_blind(0)) ident = TRUE;
352 if (set_confused(0)) ident = TRUE;
353 if (set_poisoned(0)) ident = TRUE;
354 if (set_stun(0)) ident = TRUE;
355 if (set_cut(0)) ident = TRUE;
356 if (set_image(0)) ident = TRUE;
360 bool_hack restore_mana(bool_hack magic_eater)
362 bool_hack ident = FALSE;
364 if (p_ptr->pclass == CLASS_MAGIC_EATER && magic_eater)
367 for (i = 0; i < EATER_EXT * 2; i++)
369 p_ptr->magic_num1[i] += (p_ptr->magic_num2[i] < 10) ? EATER_CHARGE * 3 : p_ptr->magic_num2[i] * EATER_CHARGE / 3;
370 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;
372 for (; i < EATER_EXT * 3; i++)
374 KIND_OBJECT_IDX k_idx = lookup_kind(TV_ROD, i - EATER_EXT * 2);
375 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;
376 if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
378 msg_print(_("頭がハッキリとした。", "You feel your head clear."));
379 p_ptr->window |= (PW_PLAYER);
382 else if (p_ptr->csp < p_ptr->msp)
384 p_ptr->csp = p_ptr->msp;
386 msg_print(_("頭がハッキリとした。", "You feel your head clear."));
387 p_ptr->redraw |= (PR_MANA);
388 p_ptr->window |= (PW_PLAYER);
389 p_ptr->window |= (PW_SPELL);
396 bool restore_all_status(void)
399 if (do_res_stat(A_STR)) ident = TRUE;
400 if (do_res_stat(A_INT)) ident = TRUE;
401 if (do_res_stat(A_WIS)) ident = TRUE;
402 if (do_res_stat(A_DEX)) ident = TRUE;
403 if (do_res_stat(A_CON)) ident = TRUE;
404 if (do_res_stat(A_CHR)) ident = TRUE;
408 bool fishing(player_type *creature_ptr)
413 if (!get_direction(&dir, FALSE, FALSE)) return FALSE;
414 y = creature_ptr->y + ddy[dir];
415 x = creature_ptr->x + ddx[dir];
416 creature_ptr->fishing_dir = dir;
417 if (!cave_have_flag_bold(y, x, FF_WATER))
419 msg_print(_("そこは水辺ではない。", "There is no fishing place."));
422 else if (current_floor_ptr->grid_array[y][x].m_idx)
424 GAME_TEXT m_name[MAX_NLEN];
425 monster_desc(m_name, ¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx], 0);
426 msg_format(_("%sが邪魔だ!", "%^s is stand in your way."), m_name);
427 free_turn(creature_ptr);
430 set_action(ACTION_FISH);
431 creature_ptr->redraw |= (PR_STATE);
436 bool cosmic_cast_off(player_type *creature_ptr, object_type *o_ptr)
441 GAME_TEXT o_name[MAX_NLEN];
444 /* Cast off activated item */
445 for (inv = INVEN_RARM; inv <= INVEN_FEET; inv++)
447 if (o_ptr == &p_ptr->inventory_list[inv]) break;
449 if (inv > INVEN_FEET) return FALSE;
451 object_copy(&forge, o_ptr);
452 inven_item_increase(inv, (0 - o_ptr->number));
453 inven_item_optimize(inv);
454 o_idx = drop_near(&forge, 0, creature_ptr->y, creature_ptr->x);
455 o_ptr = ¤t_floor_ptr->o_list[o_idx];
457 object_desc(o_name, o_ptr, OD_NAME_ONLY);
458 msg_format(_("%sを脱ぎ捨てた。", "You cast off %s."), o_name);
461 msg_print(_("「燃え上がれ俺の小宇宙!」", "You say, 'Burn up my cosmo!"));
462 t = 20 + randint1(20);
463 (void)set_blind(creature_ptr->blind + t);
465 (void)set_tim_esp(creature_ptr->tim_esp + t, FALSE);
466 (void)set_tim_regen(creature_ptr->tim_regen + t, FALSE);
467 (void)set_hero(creature_ptr->hero + t, FALSE);
468 (void)set_blessed(creature_ptr->blessed + t, FALSE);
469 (void)set_fast(creature_ptr->fast + t, FALSE);
470 (void)set_shero(creature_ptr->shero + t, FALSE);
471 if (creature_ptr->pclass == CLASS_FORCETRAINER)
473 P_PTR_KI = creature_ptr->lev * 5 + 190;
474 msg_print(_("気が爆発寸前になった。", "Your force are immediatly before explosion."));
482 * @brief プレイヤーの因果混乱処理 / Apply Nexus
483 * @param m_ptr 因果混乱をプレイヤーに与えたモンスターの情報参照ポインタ
486 void apply_nexus(monster_type *m_ptr)
490 case 1: case 2: case 3:
492 teleport_player(200, TELEPORT_PASSIVE);
498 teleport_player_to(m_ptr->fy, m_ptr->fx, TELEPORT_PASSIVE);
504 if (randint0(100) < p_ptr->skill_sav)
506 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
515 if (randint0(100) < p_ptr->skill_sav)
517 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
521 msg_print(_("体がねじれ始めた...", "Your body starts to scramble..."));
529 * @brief プレイヤーのステータスシャッフル処理
532 void status_shuffle(void)
534 BASE_STATUS max1, cur1, max2, cur2;
537 /* Pick a pair of stats */
538 ii = randint0(A_MAX);
539 for (jj = ii; jj == ii; jj = randint0(A_MAX)) /* loop */;
541 max1 = p_ptr->stat_max[ii];
542 cur1 = p_ptr->stat_cur[ii];
543 max2 = p_ptr->stat_max[jj];
544 cur2 = p_ptr->stat_cur[jj];
546 p_ptr->stat_max[ii] = max2;
547 p_ptr->stat_cur[ii] = cur2;
548 p_ptr->stat_max[jj] = max1;
549 p_ptr->stat_cur[jj] = cur1;
551 for (i = 0; i < A_MAX; i++)
553 if (p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
554 if (p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
557 p_ptr->update |= (PU_BONUS);