1 #include "system/angband.h"
2 #include "core/stuff-handler.h"
5 #include "cmd-magiceat.h"
7 #include "effect/effect-characteristics.h"
8 #include "object/object-flavor.h"
9 #include "player/player-status.h"
10 #include "player/player-class.h"
11 #include "spell/spells-status.h"
12 #include "spell/spells-type.h"
13 #include "monster/monster.h"
14 #include "cmd-spell.h"
15 #include "player/player-effects.h"
16 #include "object/object-kind.h"
17 #include "targeting.h"
18 #include "realm/realm-song.h"
19 #include "view/display-main-window.h"
20 #include "spell/spells2.h"
21 #include "spell/spells3.h"
25 * @param caster_ptr プレーヤーへの参照ポインタ
26 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
28 * @return 作用が実際にあった場合TRUEを返す
30 bool heal_monster(player_type *caster_ptr, DIRECTION dir, HIT_POINT dam)
32 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
33 return (project_hook(caster_ptr, GF_OLD_HEAL, dir, dam, flg));
39 * @param caster_ptr プレーヤーへの参照ポインタ
40 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
42 * @return 作用が実際にあった場合TRUEを返す
44 bool speed_monster(player_type *caster_ptr, DIRECTION dir, int power)
46 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
47 return (project_hook(caster_ptr, GF_OLD_SPEED, dir, power, flg));
53 * @param caster_ptr プレーヤーへの参照ポインタ
54 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
56 * @return 作用が実際にあった場合TRUEを返す
58 bool slow_monster(player_type *caster_ptr, DIRECTION dir, int power)
60 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
61 return (project_hook(caster_ptr, GF_OLD_SLOW, dir, power, flg));
67 * @param caster_ptr プレーヤーへの参照ポインタ
68 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
70 * @return 作用が実際にあった場合TRUEを返す
72 bool sleep_monster(player_type *caster_ptr, DIRECTION dir, int power)
74 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
75 return (project_hook(caster_ptr, GF_OLD_SLEEP, dir, power, flg));
80 * @brief モンスター拘束(STASIS)処理
81 * @param caster_ptr プレーヤーへの参照ポインタ
82 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
83 * @return 作用が実際にあった場合TRUEを返す
84 * @details 威力はプレイヤーレベル*2に固定
86 bool stasis_monster(player_type *caster_ptr, DIRECTION dir)
88 return (fire_ball_hide(caster_ptr, GF_STASIS, dir, caster_ptr->lev * 2, 0));
93 * @brief 邪悪なモンスター拘束(STASIS)処理
94 * @param caster_ptr プレーヤーへの参照ポインタ
95 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
96 * @return 作用が実際にあった場合TRUEを返す
97 * @details 威力はプレイヤーレベル*2に固定
99 bool stasis_evil(player_type *caster_ptr, DIRECTION dir)
101 return (fire_ball_hide(caster_ptr, GF_STASIS_EVIL, dir, caster_ptr->lev * 2, 0));
107 * @param caster_ptr プレーヤーへの参照ポインタ
108 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
109 * @param plev プレイヤーレベル(=効力)
110 * @return 作用が実際にあった場合TRUEを返す
112 bool confuse_monster(player_type *caster_ptr, DIRECTION dir, PLAYER_LEVEL plev)
114 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
115 return (project_hook(caster_ptr, GF_OLD_CONF, dir, plev, flg));
121 * @param caster_ptr プレーヤーへの参照ポインタ
122 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
123 * @param plev プレイヤーレベル(=効力)
124 * @return 作用が実際にあった場合TRUEを返す
126 bool stun_monster(player_type *caster_ptr, DIRECTION dir, PLAYER_LEVEL plev)
128 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
129 return (project_hook(caster_ptr, GF_STUN, dir, plev, flg));
135 * @param caster_ptr プレーヤーへの参照ポインタ
136 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
138 * @return 作用が実際にあった場合TRUEを返す
140 bool poly_monster(player_type *caster_ptr, DIRECTION dir, int power)
142 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
143 bool tester = (project_hook(caster_ptr, GF_OLD_POLY, dir, power, flg));
145 chg_virtue(caster_ptr, V_CHANCE, 1);
152 * @param caster_ptr プレーヤーへの参照ポインタ
153 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
154 * @return 作用が実際にあった場合TRUEを返す
156 bool clone_monster(player_type *caster_ptr, DIRECTION dir)
158 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
159 return (project_hook(caster_ptr, GF_OLD_CLONE, dir, 0, flg));
165 * @param caster_ptr プレーヤーへの参照ポインタ
166 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
167 * @param plev プレイヤーレベル(=効力)
168 * @return 作用が実際にあった場合TRUEを返す
170 bool fear_monster(player_type *caster_ptr, DIRECTION dir, PLAYER_LEVEL plev)
172 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
173 return (project_hook(caster_ptr, GF_TURN_ALL, dir, plev, flg));
177 bool time_walk(player_type *creature_ptr)
179 if (creature_ptr->timewalk)
181 msg_print(_("既に時は止まっている。", "Time is already stopped."));
185 creature_ptr->timewalk = TRUE;
186 msg_print(_("「時よ!」", "You yell 'Time!'"));
187 // msg_print(_("「『ザ・ワールド』!時は止まった!」", "You yell 'The World! Time has stopped!'"));
190 creature_ptr->energy_need -= 1000 + (100 + creature_ptr->csp - 50)*TURNS_PER_TICK / 10;
191 creature_ptr->redraw |= (PR_MAP);
192 creature_ptr->update |= (PU_MONSTERS);
193 creature_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
194 handle_stuff(creature_ptr);
200 * @brief プレイヤーのヒットダイスを振る / Role Hitpoints
201 * @param creature_ptr プレーヤーへの参照ポインタ
202 * @param options スペル共通オプション
205 void roll_hitdice(player_type *creature_ptr, spell_operation options)
207 HIT_POINT min_value = creature_ptr->hitdie + ((PY_MAX_LEVEL + 2) * (creature_ptr->hitdie + 1)) * 3 / 8;
208 HIT_POINT max_value = creature_ptr->hitdie + ((PY_MAX_LEVEL + 2) * (creature_ptr->hitdie + 1)) * 5 / 8;
213 /* Pre-calculate level 1 hitdice */
214 creature_ptr->player_hp[0] = (HIT_POINT)creature_ptr->hitdie;
216 for (int i = 1; i < 4; i++)
218 creature_ptr->player_hp[0] += randint1(creature_ptr->hitdie);
221 /* Roll the hitpoint values */
222 for (int i = 1; i < PY_MAX_LEVEL; i++)
224 creature_ptr->player_hp[i] = creature_ptr->player_hp[i - 1] + randint1(creature_ptr->hitdie);
227 /* Require "valid" hitpoints at highest level */
228 if ((creature_ptr->player_hp[PY_MAX_LEVEL - 1] >= min_value) &&
229 (creature_ptr->player_hp[PY_MAX_LEVEL - 1] <= max_value)) break;
232 PERCENTAGE percent = (int)(((long)creature_ptr->player_hp[PY_MAX_LEVEL - 1] * 200L) /
233 (2 * creature_ptr->hitdie + ((PY_MAX_LEVEL - 1 + 3) * (creature_ptr->hitdie + 1))));
235 /* Update and redraw hitpoints */
236 creature_ptr->update |= (PU_HP);
237 creature_ptr->redraw |= (PR_HP);
238 creature_ptr->window |= (PW_PLAYER);
240 if (!(options & SPOP_NO_UPDATE)) handle_stuff(creature_ptr);
242 if (!(options & SPOP_DISPLAY_MES)) return;
244 if (options & SPOP_DEBUG)
246 msg_format(_("現在の体力ランクは %d/100 です。", "Your life rate is %d/100 now."), percent);
247 creature_ptr->knowledge |= KNOW_HPRATE;
251 msg_print(_("体力ランクが変わった。", "Life rate is changed."));
252 creature_ptr->knowledge &= ~(KNOW_HPRATE);
256 bool life_stream(player_type *creature_ptr, bool message, bool virtue_change)
260 chg_virtue(creature_ptr, V_VITALITY, 1);
261 chg_virtue(creature_ptr, V_UNLIFE, -5);
266 msg_print(_("体中に生命力が満ちあふれてきた!", "You feel life flow through your body!"));
269 restore_level(creature_ptr);
270 (void)set_poisoned(creature_ptr, 0);
271 (void)set_blind(creature_ptr, 0);
272 (void)set_confused(creature_ptr, 0);
273 (void)set_image(creature_ptr, 0);
274 (void)set_stun(creature_ptr, 0);
275 (void)set_cut(creature_ptr,0);
276 (void)restore_all_status(creature_ptr);
277 (void)set_shero(creature_ptr, 0, TRUE);
278 handle_stuff(creature_ptr);
279 hp_player(creature_ptr, 5000);
285 bool heroism(player_type *creature_ptr, int base)
288 if (set_afraid(creature_ptr, 0)) ident = TRUE;
289 if (set_hero(creature_ptr, creature_ptr->hero + randint1(base) + base, FALSE)) ident = TRUE;
290 if (hp_player(creature_ptr, 10)) ident = TRUE;
295 bool berserk(player_type *creature_ptr, int base)
298 if (set_afraid(creature_ptr, 0)) ident = TRUE;
299 if (set_shero(creature_ptr, creature_ptr->shero + randint1(base) + base, FALSE)) ident = TRUE;
300 if (hp_player(creature_ptr, 30)) ident = TRUE;
305 bool cure_light_wounds(player_type *creature_ptr, DICE_NUMBER dice, DICE_SID sides)
308 if (hp_player(creature_ptr, damroll(dice, sides))) ident = TRUE;
309 if (set_blind(creature_ptr, 0)) ident = TRUE;
310 if (set_cut(creature_ptr,creature_ptr->cut - 10)) ident = TRUE;
311 if (set_shero(creature_ptr, 0, TRUE)) ident = TRUE;
316 bool cure_serious_wounds(player_type *creature_ptr, DICE_NUMBER dice, DICE_SID sides)
319 if (hp_player(creature_ptr, damroll(dice, sides))) ident = TRUE;
320 if (set_blind(creature_ptr, 0)) ident = TRUE;
321 if (set_confused(creature_ptr, 0)) ident = TRUE;
322 if (set_cut(creature_ptr,(creature_ptr->cut / 2) - 50)) ident = TRUE;
323 if (set_shero(creature_ptr, 0, TRUE)) ident = TRUE;
328 bool cure_critical_wounds(player_type *creature_ptr, HIT_POINT pow)
331 if (hp_player(creature_ptr, pow)) ident = TRUE;
332 if (set_blind(creature_ptr, 0)) ident = TRUE;
333 if (set_confused(creature_ptr, 0)) ident = TRUE;
334 if (set_poisoned(creature_ptr, 0)) ident = TRUE;
335 if (set_stun(creature_ptr, 0)) ident = TRUE;
336 if (set_cut(creature_ptr,0)) ident = TRUE;
337 if (set_shero(creature_ptr, 0, TRUE)) ident = TRUE;
342 bool true_healing(player_type *creature_ptr, HIT_POINT pow)
345 if (hp_player(creature_ptr, pow)) ident = TRUE;
346 if (set_blind(creature_ptr, 0)) ident = TRUE;
347 if (set_confused(creature_ptr, 0)) ident = TRUE;
348 if (set_poisoned(creature_ptr, 0)) ident = TRUE;
349 if (set_stun(creature_ptr, 0)) ident = TRUE;
350 if (set_cut(creature_ptr,0)) ident = TRUE;
351 if (set_image(creature_ptr, 0)) ident = TRUE;
356 bool restore_mana(player_type *creature_ptr, bool magic_eater)
358 if (creature_ptr->pclass == CLASS_MAGIC_EATER && magic_eater)
361 for (i = 0; i < EATER_EXT * 2; i++)
363 creature_ptr->magic_num1[i] += (creature_ptr->magic_num2[i] < 10) ? EATER_CHARGE * 3 : creature_ptr->magic_num2[i] * EATER_CHARGE / 3;
364 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;
367 for (; i < EATER_EXT * 3; i++)
369 KIND_OBJECT_IDX k_idx = lookup_kind(TV_ROD, i - EATER_EXT * 2);
370 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;
371 if (creature_ptr->magic_num1[i] < 0) creature_ptr->magic_num1[i] = 0;
374 msg_print(_("頭がハッキリとした。", "You feel your head clear."));
375 creature_ptr->window |= (PW_PLAYER);
379 if (creature_ptr->csp >= creature_ptr->msp) return FALSE;
381 creature_ptr->csp = creature_ptr->msp;
382 creature_ptr->csp_frac = 0;
383 msg_print(_("頭がハッキリとした。", "You feel your head clear."));
384 creature_ptr->redraw |= (PR_MANA);
385 creature_ptr->window |= (PW_PLAYER);
386 creature_ptr->window |= (PW_SPELL);
391 bool restore_all_status(player_type *creature_ptr)
394 if (do_res_stat(creature_ptr, A_STR)) ident = TRUE;
395 if (do_res_stat(creature_ptr, A_INT)) ident = TRUE;
396 if (do_res_stat(creature_ptr, A_WIS)) ident = TRUE;
397 if (do_res_stat(creature_ptr, A_DEX)) ident = TRUE;
398 if (do_res_stat(creature_ptr, A_CON)) ident = TRUE;
399 if (do_res_stat(creature_ptr, A_CHR)) ident = TRUE;
404 bool fishing(player_type *creature_ptr)
407 if (!get_direction(creature_ptr, &dir, FALSE, FALSE)) return FALSE;
408 POSITION y = creature_ptr->y + ddy[dir];
409 POSITION x = creature_ptr->x + ddx[dir];
410 creature_ptr->fishing_dir = dir;
411 if (!cave_have_flag_bold(creature_ptr->current_floor_ptr, y, x, FF_WATER))
413 msg_print(_("そこは水辺ではない。", "There is no fishing place."));
417 if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx)
419 GAME_TEXT m_name[MAX_NLEN];
420 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);
421 msg_format(_("%sが邪魔だ!", "%^s is standing in your way."), m_name);
422 free_turn(creature_ptr);
426 set_action(creature_ptr, ACTION_FISH);
427 creature_ptr->redraw |= (PR_STATE);
432 bool cosmic_cast_off(player_type *creature_ptr, object_type *o_ptr)
434 /* Cast off activated item */
436 for (inv = INVEN_RARM; inv <= INVEN_FEET; inv++)
438 if (o_ptr == &creature_ptr->inventory_list[inv]) break;
441 if (inv > INVEN_FEET) return FALSE;
444 object_copy(&forge, o_ptr);
445 inven_item_increase(creature_ptr, inv, (0 - o_ptr->number));
446 inven_item_optimize(creature_ptr, inv);
447 OBJECT_IDX o_idx = drop_near(creature_ptr, &forge, 0, creature_ptr->y, creature_ptr->x);
448 o_ptr = &creature_ptr->current_floor_ptr->o_list[o_idx];
450 GAME_TEXT o_name[MAX_NLEN];
451 object_desc(creature_ptr, o_name, o_ptr, OD_NAME_ONLY);
452 msg_format(_("%sを脱ぎ捨てた。", "You cast off %s."), o_name);
455 msg_print(_("「燃え上がれ俺の小宇宙!」", "You say, 'Burn up my cosmo!"));
456 int t = 20 + randint1(20);
457 (void)set_blind(creature_ptr, creature_ptr->blind + t);
458 (void)set_afraid(creature_ptr, 0);
459 (void)set_tim_esp(creature_ptr, creature_ptr->tim_esp + t, FALSE);
460 (void)set_tim_regen(creature_ptr, creature_ptr->tim_regen + t, FALSE);
461 (void)set_hero(creature_ptr, creature_ptr->hero + t, FALSE);
462 (void)set_blessed(creature_ptr, creature_ptr->blessed + t, FALSE);
463 (void)set_fast(creature_ptr, creature_ptr->fast + t, FALSE);
464 (void)set_shero(creature_ptr, creature_ptr->shero + t, FALSE);
465 if (creature_ptr->pclass == CLASS_FORCETRAINER)
467 P_PTR_KI = creature_ptr->lev * 5 + 190;
468 msg_print(_("気が爆発寸前になった。", "Your force absorbs the explosion."));
476 * @brief プレイヤーの因果混乱処理 / Apply Nexus
477 * @param m_ptr 因果混乱をプレイヤーに与えたモンスターの情報参照ポインタ
480 void apply_nexus(monster_type *m_ptr, player_type *target_ptr)
484 case 1: case 2: case 3:
486 teleport_player(target_ptr, 200, TELEPORT_PASSIVE);
492 teleport_player_to(target_ptr, m_ptr->fy, m_ptr->fx, TELEPORT_PASSIVE);
498 if (randint0(100) < target_ptr->skill_sav)
500 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
504 teleport_level(target_ptr, 0);
510 if (randint0(100) < target_ptr->skill_sav)
512 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
516 msg_print(_("体がねじれ始めた...", "Your body starts to scramble..."));
517 status_shuffle(target_ptr);
525 * @brief プレイヤーのステータスシャッフル処理
526 * @param creature_ptr プレーヤーへの参照ポインタ
529 void status_shuffle(player_type *creature_ptr)
531 /* Pick a pair of stats */
532 int i = randint0(A_MAX);
535 // todo ここのループは一体何をしている?
536 for (j = i; j == i; j = randint0(A_MAX)) /* loop */;
538 BASE_STATUS max1 = creature_ptr->stat_max[i];
539 BASE_STATUS cur1 = creature_ptr->stat_cur[i];
540 BASE_STATUS max2 = creature_ptr->stat_max[j];
541 BASE_STATUS cur2 = creature_ptr->stat_cur[j];
543 creature_ptr->stat_max[i] = max2;
544 creature_ptr->stat_cur[i] = cur2;
545 creature_ptr->stat_max[j] = max1;
546 creature_ptr->stat_cur[j] = cur1;
548 for (int k = 0; k < A_MAX; k++)
550 if (creature_ptr->stat_max[k] > creature_ptr->stat_max_max[k]) creature_ptr->stat_max[k] = creature_ptr->stat_max_max[k];
551 if (creature_ptr->stat_cur[k] > creature_ptr->stat_max_max[k]) creature_ptr->stat_cur[k] = creature_ptr->stat_max_max[k];
554 creature_ptr->update |= PU_BONUS;