2 * @brief スピード等のステータスに影響のある魔法の処理
7 #include "spell/spells-status.h"
8 #include "cmd-action/cmd-spell.h"
9 #include "cmd-item/cmd-magiceat.h"
10 #include "core/stuff-handler.h"
11 #include "effect/effect-characteristics.h"
12 #include "floor/floor-object.h"
13 #include "inventory/inventory-object.h"
14 #include "io/targeting.h"
15 #include "mind/mind-force-trainer.h"
16 #include "monster/monster-describer.h"
17 #include "object/object-flavor.h"
18 #include "object/object-generator.h"
19 #include "object/object-kind-hook.h"
20 #include "object/object-kind.h"
21 #include "player/avatar.h"
22 #include "player/player-class.h"
23 #include "player/player-effects.h"
24 #include "player/player-status.h"
25 #include "spell-kind/spells-launcher.h"
26 #include "spell-kind/spells-teleport.h"
27 #include "spell/spell-types.h"
28 #include "view/display-main-window.h"
29 #include "view/display-messages.h"
33 * @param caster_ptr プレーヤーへの参照ポインタ
34 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
36 * @return 作用が実際にあった場合TRUEを返す
38 bool heal_monster(player_type *caster_ptr, DIRECTION dir, HIT_POINT dam)
40 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
41 return (project_hook(caster_ptr, GF_OLD_HEAL, dir, dam, flg));
47 * @param caster_ptr プレーヤーへの参照ポインタ
48 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
50 * @return 作用が実際にあった場合TRUEを返す
52 bool speed_monster(player_type *caster_ptr, DIRECTION dir, int power)
54 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
55 return (project_hook(caster_ptr, GF_OLD_SPEED, dir, power, flg));
61 * @param caster_ptr プレーヤーへの参照ポインタ
62 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
64 * @return 作用が実際にあった場合TRUEを返す
66 bool slow_monster(player_type *caster_ptr, DIRECTION dir, int power)
68 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
69 return (project_hook(caster_ptr, GF_OLD_SLOW, dir, power, flg));
75 * @param caster_ptr プレーヤーへの参照ポインタ
76 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
78 * @return 作用が実際にあった場合TRUEを返す
80 bool sleep_monster(player_type *caster_ptr, DIRECTION dir, int power)
82 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
83 return (project_hook(caster_ptr, GF_OLD_SLEEP, dir, power, flg));
88 * @brief モンスター拘束(STASIS)処理
89 * @param caster_ptr プレーヤーへの参照ポインタ
90 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
91 * @return 作用が実際にあった場合TRUEを返す
92 * @details 威力はプレイヤーレベル*2に固定
94 bool stasis_monster(player_type *caster_ptr, DIRECTION dir)
96 return (fire_ball_hide(caster_ptr, GF_STASIS, dir, caster_ptr->lev * 2, 0));
101 * @brief 邪悪なモンスター拘束(STASIS)処理
102 * @param caster_ptr プレーヤーへの参照ポインタ
103 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
104 * @return 作用が実際にあった場合TRUEを返す
105 * @details 威力はプレイヤーレベル*2に固定
107 bool stasis_evil(player_type *caster_ptr, DIRECTION dir)
109 return (fire_ball_hide(caster_ptr, GF_STASIS_EVIL, dir, caster_ptr->lev * 2, 0));
115 * @param caster_ptr プレーヤーへの参照ポインタ
116 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
117 * @param plev プレイヤーレベル(=効力)
118 * @return 作用が実際にあった場合TRUEを返す
120 bool confuse_monster(player_type *caster_ptr, DIRECTION dir, PLAYER_LEVEL plev)
122 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
123 return (project_hook(caster_ptr, GF_OLD_CONF, dir, plev, flg));
129 * @param caster_ptr プレーヤーへの参照ポインタ
130 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
131 * @param plev プレイヤーレベル(=効力)
132 * @return 作用が実際にあった場合TRUEを返す
134 bool stun_monster(player_type *caster_ptr, DIRECTION dir, PLAYER_LEVEL plev)
136 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
137 return (project_hook(caster_ptr, GF_STUN, dir, plev, flg));
143 * @param caster_ptr プレーヤーへの参照ポインタ
144 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
146 * @return 作用が実際にあった場合TRUEを返す
148 bool poly_monster(player_type *caster_ptr, DIRECTION dir, int power)
150 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
151 bool tester = (project_hook(caster_ptr, GF_OLD_POLY, dir, power, flg));
153 chg_virtue(caster_ptr, V_CHANCE, 1);
160 * @param caster_ptr プレーヤーへの参照ポインタ
161 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
162 * @return 作用が実際にあった場合TRUEを返す
164 bool clone_monster(player_type *caster_ptr, DIRECTION dir)
166 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
167 return (project_hook(caster_ptr, GF_OLD_CLONE, dir, 0, flg));
173 * @param caster_ptr プレーヤーへの参照ポインタ
174 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
175 * @param plev プレイヤーレベル(=効力)
176 * @return 作用が実際にあった場合TRUEを返す
178 bool fear_monster(player_type *caster_ptr, DIRECTION dir, PLAYER_LEVEL plev)
180 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
181 return (project_hook(caster_ptr, GF_TURN_ALL, dir, plev, flg));
185 bool time_walk(player_type *creature_ptr)
187 if (creature_ptr->timewalk)
189 msg_print(_("既に時は止まっている。", "Time is already stopped."));
193 creature_ptr->timewalk = TRUE;
194 msg_print(_("「時よ!」", "You yell 'Time!'"));
195 // msg_print(_("「『ザ・ワールド』!時は止まった!」", "You yell 'The World! Time has stopped!'"));
198 creature_ptr->energy_need -= 1000 + (100 + creature_ptr->csp - 50)*TURNS_PER_TICK / 10;
199 creature_ptr->redraw |= (PR_MAP);
200 creature_ptr->update |= (PU_MONSTERS);
201 creature_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
202 handle_stuff(creature_ptr);
208 * @brief プレイヤーのヒットダイスを振る / Role Hitpoints
209 * @param creature_ptr プレーヤーへの参照ポインタ
210 * @param options スペル共通オプション
213 void roll_hitdice(player_type *creature_ptr, spell_operation options)
215 HIT_POINT min_value = creature_ptr->hitdie + ((PY_MAX_LEVEL + 2) * (creature_ptr->hitdie + 1)) * 3 / 8;
216 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 (int i = 1; i < 4; i++)
226 creature_ptr->player_hp[0] += randint1(creature_ptr->hitdie);
229 /* Roll the hitpoint values */
230 for (int 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 PERCENTAGE 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(creature_ptr);
250 if (!(options & SPOP_DISPLAY_MES)) return;
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);
264 bool life_stream(player_type *creature_ptr, bool message, bool virtue_change)
268 chg_virtue(creature_ptr, V_VITALITY, 1);
269 chg_virtue(creature_ptr, V_UNLIFE, -5);
274 msg_print(_("体中に生命力が満ちあふれてきた!", "You feel life flow through your body!"));
277 restore_level(creature_ptr);
278 (void)set_poisoned(creature_ptr, 0);
279 (void)set_blind(creature_ptr, 0);
280 (void)set_confused(creature_ptr, 0);
281 (void)set_image(creature_ptr, 0);
282 (void)set_stun(creature_ptr, 0);
283 (void)set_cut(creature_ptr,0);
284 (void)restore_all_status(creature_ptr);
285 (void)set_shero(creature_ptr, 0, TRUE);
286 handle_stuff(creature_ptr);
287 hp_player(creature_ptr, 5000);
293 bool heroism(player_type *creature_ptr, int base)
296 if (set_afraid(creature_ptr, 0)) ident = TRUE;
297 if (set_hero(creature_ptr, creature_ptr->hero + randint1(base) + base, FALSE)) ident = TRUE;
298 if (hp_player(creature_ptr, 10)) ident = TRUE;
303 bool berserk(player_type *creature_ptr, int base)
306 if (set_afraid(creature_ptr, 0)) ident = TRUE;
307 if (set_shero(creature_ptr, creature_ptr->shero + randint1(base) + base, FALSE)) ident = TRUE;
308 if (hp_player(creature_ptr, 30)) ident = TRUE;
313 bool cure_light_wounds(player_type *creature_ptr, DICE_NUMBER dice, DICE_SID sides)
316 if (hp_player(creature_ptr, damroll(dice, sides))) ident = TRUE;
317 if (set_blind(creature_ptr, 0)) ident = TRUE;
318 if (set_cut(creature_ptr,creature_ptr->cut - 10)) ident = TRUE;
319 if (set_shero(creature_ptr, 0, TRUE)) ident = TRUE;
324 bool cure_serious_wounds(player_type *creature_ptr, DICE_NUMBER dice, DICE_SID sides)
327 if (hp_player(creature_ptr, damroll(dice, sides))) ident = TRUE;
328 if (set_blind(creature_ptr, 0)) ident = TRUE;
329 if (set_confused(creature_ptr, 0)) ident = TRUE;
330 if (set_cut(creature_ptr,(creature_ptr->cut / 2) - 50)) ident = TRUE;
331 if (set_shero(creature_ptr, 0, TRUE)) ident = TRUE;
336 bool cure_critical_wounds(player_type *creature_ptr, HIT_POINT pow)
339 if (hp_player(creature_ptr, pow)) ident = TRUE;
340 if (set_blind(creature_ptr, 0)) ident = TRUE;
341 if (set_confused(creature_ptr, 0)) ident = TRUE;
342 if (set_poisoned(creature_ptr, 0)) ident = TRUE;
343 if (set_stun(creature_ptr, 0)) ident = TRUE;
344 if (set_cut(creature_ptr,0)) ident = TRUE;
345 if (set_shero(creature_ptr, 0, TRUE)) ident = TRUE;
350 bool true_healing(player_type *creature_ptr, HIT_POINT pow)
353 if (hp_player(creature_ptr, pow)) ident = TRUE;
354 if (set_blind(creature_ptr, 0)) ident = TRUE;
355 if (set_confused(creature_ptr, 0)) ident = TRUE;
356 if (set_poisoned(creature_ptr, 0)) ident = TRUE;
357 if (set_stun(creature_ptr, 0)) ident = TRUE;
358 if (set_cut(creature_ptr,0)) ident = TRUE;
359 if (set_image(creature_ptr, 0)) ident = TRUE;
364 bool restore_mana(player_type *creature_ptr, bool magic_eater)
366 if (creature_ptr->pclass == CLASS_MAGIC_EATER && magic_eater)
369 for (i = 0; i < EATER_EXT * 2; i++)
371 creature_ptr->magic_num1[i] += (creature_ptr->magic_num2[i] < 10) ? EATER_CHARGE * 3 : creature_ptr->magic_num2[i] * EATER_CHARGE / 3;
372 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;
375 for (; i < EATER_EXT * 3; i++)
377 KIND_OBJECT_IDX k_idx = lookup_kind(TV_ROD, i - EATER_EXT * 2);
378 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;
379 if (creature_ptr->magic_num1[i] < 0) creature_ptr->magic_num1[i] = 0;
382 msg_print(_("頭がハッキリとした。", "You feel your head clear."));
383 creature_ptr->window |= (PW_PLAYER);
387 if (creature_ptr->csp >= creature_ptr->msp) return FALSE;
389 creature_ptr->csp = creature_ptr->msp;
390 creature_ptr->csp_frac = 0;
391 msg_print(_("頭がハッキリとした。", "You feel your head clear."));
392 creature_ptr->redraw |= (PR_MANA);
393 creature_ptr->window |= (PW_PLAYER);
394 creature_ptr->window |= (PW_SPELL);
399 bool restore_all_status(player_type *creature_ptr)
402 if (do_res_stat(creature_ptr, A_STR)) ident = TRUE;
403 if (do_res_stat(creature_ptr, A_INT)) ident = TRUE;
404 if (do_res_stat(creature_ptr, A_WIS)) ident = TRUE;
405 if (do_res_stat(creature_ptr, A_DEX)) ident = TRUE;
406 if (do_res_stat(creature_ptr, A_CON)) ident = TRUE;
407 if (do_res_stat(creature_ptr, A_CHR)) ident = TRUE;
412 bool fishing(player_type *creature_ptr)
415 if (!get_direction(creature_ptr, &dir, FALSE, FALSE)) return FALSE;
416 POSITION y = creature_ptr->y + ddy[dir];
417 POSITION x = creature_ptr->x + ddx[dir];
418 creature_ptr->fishing_dir = dir;
419 if (!cave_have_flag_bold(creature_ptr->current_floor_ptr, y, x, FF_WATER))
421 msg_print(_("そこは水辺ではない。", "There is no fishing place."));
425 if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx)
427 GAME_TEXT m_name[MAX_NLEN];
428 monster_desc(creature_ptr, m_name, &creature_ptr->current_floor_ptr->m_list[creature_ptr->current_floor_ptr->grid_array[y][x].m_idx], 0);
429 msg_format(_("%sが邪魔だ!", "%^s is standing in your way."), m_name);
430 free_turn(creature_ptr);
434 set_action(creature_ptr, ACTION_FISH);
435 creature_ptr->redraw |= (PR_STATE);
440 bool cosmic_cast_off(player_type *creature_ptr, object_type *o_ptr)
442 /* Cast off activated item */
444 for (inv = INVEN_RARM; inv <= INVEN_FEET; inv++)
446 if (o_ptr == &creature_ptr->inventory_list[inv]) break;
449 if (inv > INVEN_FEET) return FALSE;
452 object_copy(&forge, o_ptr);
453 inven_item_increase(creature_ptr, inv, (0 - o_ptr->number));
454 inven_item_optimize(creature_ptr, inv);
455 OBJECT_IDX o_idx = drop_near(creature_ptr, &forge, 0, creature_ptr->y, creature_ptr->x);
456 o_ptr = &creature_ptr->current_floor_ptr->o_list[o_idx];
458 GAME_TEXT o_name[MAX_NLEN];
459 object_desc(creature_ptr, o_name, o_ptr, OD_NAME_ONLY);
460 msg_format(_("%sを脱ぎ捨てた。", "You cast off %s."), o_name);
463 msg_print(_("「燃え上がれ俺の小宇宙!」", "You say, 'Burn up my cosmo!"));
464 int t = 20 + randint1(20);
465 (void)set_blind(creature_ptr, creature_ptr->blind + t);
466 (void)set_afraid(creature_ptr, 0);
467 (void)set_tim_esp(creature_ptr, creature_ptr->tim_esp + t, FALSE);
468 (void)set_tim_regen(creature_ptr, creature_ptr->tim_regen + t, FALSE);
469 (void)set_hero(creature_ptr, creature_ptr->hero + t, FALSE);
470 (void)set_blessed(creature_ptr, creature_ptr->blessed + t, FALSE);
471 (void)set_fast(creature_ptr, creature_ptr->fast + t, FALSE);
472 (void)set_shero(creature_ptr, creature_ptr->shero + t, FALSE);
473 if (creature_ptr->pclass == CLASS_FORCETRAINER)
475 set_current_ki(creature_ptr, TRUE, creature_ptr->lev * 5 + 190);
476 msg_print(_("気が爆発寸前になった。", "Your force absorbs the explosion."));
484 * @brief プレイヤーの因果混乱処理 / Apply Nexus
485 * @param m_ptr 因果混乱をプレイヤーに与えたモンスターの情報参照ポインタ
488 void apply_nexus(monster_type *m_ptr, player_type *target_ptr)
492 case 1: case 2: case 3:
494 teleport_player(target_ptr, 200, TELEPORT_PASSIVE);
500 teleport_player_to(target_ptr, m_ptr->fy, m_ptr->fx, TELEPORT_PASSIVE);
506 if (randint0(100) < target_ptr->skill_sav)
508 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
512 teleport_level(target_ptr, 0);
518 if (randint0(100) < target_ptr->skill_sav)
520 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
524 msg_print(_("体がねじれ始めた...", "Your body starts to scramble..."));
525 status_shuffle(target_ptr);
533 * @brief プレイヤーのステータスシャッフル処理
534 * @param creature_ptr プレーヤーへの参照ポインタ
537 void status_shuffle(player_type *creature_ptr)
539 /* Pick a pair of stats */
540 int i = randint0(A_MAX);
543 // todo ここのループは一体何をしている?
544 for (j = i; j == i; j = randint0(A_MAX)) /* loop */;
546 BASE_STATUS max1 = creature_ptr->stat_max[i];
547 BASE_STATUS cur1 = creature_ptr->stat_cur[i];
548 BASE_STATUS max2 = creature_ptr->stat_max[j];
549 BASE_STATUS cur2 = creature_ptr->stat_cur[j];
551 creature_ptr->stat_max[i] = max2;
552 creature_ptr->stat_cur[i] = cur2;
553 creature_ptr->stat_max[j] = max1;
554 creature_ptr->stat_cur[j] = cur1;
556 for (int k = 0; k < A_MAX; k++)
558 if (creature_ptr->stat_max[k] > creature_ptr->stat_max_max[k]) creature_ptr->stat_max[k] = creature_ptr->stat_max_max[k];
559 if (creature_ptr->stat_cur[k] > creature_ptr->stat_max_max[k]) creature_ptr->stat_cur[k] = creature_ptr->stat_max_max[k];
562 creature_ptr->update |= PU_BONUS;