2 #include "core/stuff-handler.h"
5 #include "cmd-magiceat.h"
7 #include "effect/effect-characteristics.h"
8 #include "object-flavor.h"
9 #include "player-status.h"
10 #include "player-class.h"
11 #include "spells-status.h"
12 #include "spell/spells-type.h"
14 #include "cmd-spell.h"
15 #include "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"
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));
175 bool time_walk(player_type *creature_ptr)
177 if (creature_ptr->timewalk)
179 msg_print(_("既に時は止まっている。", "Time is already stopped."));
183 creature_ptr->timewalk = TRUE;
184 msg_print(_("「時よ!」", "You yell 'Time!'"));
185 // msg_print(_("「『ザ・ワールド』!時は止まった!」", "You yell 'The World! Time has stopped!'"));
188 creature_ptr->energy_need -= 1000 + (100 + creature_ptr->csp - 50)*TURNS_PER_TICK / 10;
189 creature_ptr->redraw |= (PR_MAP);
190 creature_ptr->update |= (PU_MONSTERS);
191 creature_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
192 handle_stuff(creature_ptr);
198 * @brief プレイヤーのヒットダイスを振る / Role Hitpoints
199 * @param creature_ptr プレーヤーへの参照ポインタ
200 * @param options スペル共通オプション
203 void roll_hitdice(player_type *creature_ptr, spell_operation options)
205 HIT_POINT min_value = creature_ptr->hitdie + ((PY_MAX_LEVEL + 2) * (creature_ptr->hitdie + 1)) * 3 / 8;
206 HIT_POINT max_value = creature_ptr->hitdie + ((PY_MAX_LEVEL + 2) * (creature_ptr->hitdie + 1)) * 5 / 8;
211 /* Pre-calculate level 1 hitdice */
212 creature_ptr->player_hp[0] = (HIT_POINT)creature_ptr->hitdie;
214 for (int i = 1; i < 4; i++)
216 creature_ptr->player_hp[0] += randint1(creature_ptr->hitdie);
219 /* Roll the hitpoint values */
220 for (int i = 1; i < PY_MAX_LEVEL; i++)
222 creature_ptr->player_hp[i] = creature_ptr->player_hp[i - 1] + randint1(creature_ptr->hitdie);
225 /* Require "valid" hitpoints at highest level */
226 if ((creature_ptr->player_hp[PY_MAX_LEVEL - 1] >= min_value) &&
227 (creature_ptr->player_hp[PY_MAX_LEVEL - 1] <= max_value)) break;
230 PERCENTAGE percent = (int)(((long)creature_ptr->player_hp[PY_MAX_LEVEL - 1] * 200L) /
231 (2 * creature_ptr->hitdie + ((PY_MAX_LEVEL - 1 + 3) * (creature_ptr->hitdie + 1))));
233 /* Update and redraw hitpoints */
234 creature_ptr->update |= (PU_HP);
235 creature_ptr->redraw |= (PR_HP);
236 creature_ptr->window |= (PW_PLAYER);
238 if (!(options & SPOP_NO_UPDATE)) handle_stuff(creature_ptr);
240 if (!(options & SPOP_DISPLAY_MES)) return;
242 if (options & SPOP_DEBUG)
244 msg_format(_("現在の体力ランクは %d/100 です。", "Your life rate is %d/100 now."), percent);
245 creature_ptr->knowledge |= KNOW_HPRATE;
249 msg_print(_("体力ランクが変わった。", "Life rate is changed."));
250 creature_ptr->knowledge &= ~(KNOW_HPRATE);
254 bool life_stream(player_type *creature_ptr, bool message, bool virtue_change)
258 chg_virtue(creature_ptr, V_VITALITY, 1);
259 chg_virtue(creature_ptr, V_UNLIFE, -5);
264 msg_print(_("体中に生命力が満ちあふれてきた!", "You feel life flow through your body!"));
267 restore_level(creature_ptr);
268 (void)set_poisoned(creature_ptr, 0);
269 (void)set_blind(creature_ptr, 0);
270 (void)set_confused(creature_ptr, 0);
271 (void)set_image(creature_ptr, 0);
272 (void)set_stun(creature_ptr, 0);
273 (void)set_cut(creature_ptr,0);
274 (void)restore_all_status(creature_ptr);
275 (void)set_shero(creature_ptr, 0, TRUE);
276 handle_stuff(creature_ptr);
277 hp_player(creature_ptr, 5000);
283 bool heroism(player_type *creature_ptr, int base)
286 if (set_afraid(creature_ptr, 0)) ident = TRUE;
287 if (set_hero(creature_ptr, creature_ptr->hero + randint1(base) + base, FALSE)) ident = TRUE;
288 if (hp_player(creature_ptr, 10)) ident = TRUE;
293 bool berserk(player_type *creature_ptr, int base)
296 if (set_afraid(creature_ptr, 0)) ident = TRUE;
297 if (set_shero(creature_ptr, creature_ptr->shero + randint1(base) + base, FALSE)) ident = TRUE;
298 if (hp_player(creature_ptr, 30)) ident = TRUE;
303 bool cure_light_wounds(player_type *creature_ptr, DICE_NUMBER dice, DICE_SID sides)
306 if (hp_player(creature_ptr, damroll(dice, sides))) ident = TRUE;
307 if (set_blind(creature_ptr, 0)) ident = TRUE;
308 if (set_cut(creature_ptr,creature_ptr->cut - 10)) ident = TRUE;
309 if (set_shero(creature_ptr, 0, TRUE)) ident = TRUE;
314 bool cure_serious_wounds(player_type *creature_ptr, DICE_NUMBER dice, DICE_SID sides)
317 if (hp_player(creature_ptr, damroll(dice, sides))) ident = TRUE;
318 if (set_blind(creature_ptr, 0)) ident = TRUE;
319 if (set_confused(creature_ptr, 0)) ident = TRUE;
320 if (set_cut(creature_ptr,(creature_ptr->cut / 2) - 50)) ident = TRUE;
321 if (set_shero(creature_ptr, 0, TRUE)) ident = TRUE;
326 bool cure_critical_wounds(player_type *creature_ptr, HIT_POINT pow)
329 if (hp_player(creature_ptr, pow)) ident = TRUE;
330 if (set_blind(creature_ptr, 0)) ident = TRUE;
331 if (set_confused(creature_ptr, 0)) ident = TRUE;
332 if (set_poisoned(creature_ptr, 0)) ident = TRUE;
333 if (set_stun(creature_ptr, 0)) ident = TRUE;
334 if (set_cut(creature_ptr,0)) ident = TRUE;
335 if (set_shero(creature_ptr, 0, TRUE)) ident = TRUE;
340 bool true_healing(player_type *creature_ptr, HIT_POINT pow)
343 if (hp_player(creature_ptr, pow)) ident = TRUE;
344 if (set_blind(creature_ptr, 0)) ident = TRUE;
345 if (set_confused(creature_ptr, 0)) ident = TRUE;
346 if (set_poisoned(creature_ptr, 0)) ident = TRUE;
347 if (set_stun(creature_ptr, 0)) ident = TRUE;
348 if (set_cut(creature_ptr,0)) ident = TRUE;
349 if (set_image(creature_ptr, 0)) ident = TRUE;
354 bool restore_mana(player_type *creature_ptr, bool magic_eater)
356 if (creature_ptr->pclass == CLASS_MAGIC_EATER && magic_eater)
359 for (i = 0; i < EATER_EXT * 2; i++)
361 creature_ptr->magic_num1[i] += (creature_ptr->magic_num2[i] < 10) ? EATER_CHARGE * 3 : creature_ptr->magic_num2[i] * EATER_CHARGE / 3;
362 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;
365 for (; i < EATER_EXT * 3; i++)
367 KIND_OBJECT_IDX k_idx = lookup_kind(TV_ROD, i - EATER_EXT * 2);
368 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;
369 if (creature_ptr->magic_num1[i] < 0) creature_ptr->magic_num1[i] = 0;
372 msg_print(_("頭がハッキリとした。", "You feel your head clear."));
373 creature_ptr->window |= (PW_PLAYER);
377 if (creature_ptr->csp >= creature_ptr->msp) return FALSE;
379 creature_ptr->csp = creature_ptr->msp;
380 creature_ptr->csp_frac = 0;
381 msg_print(_("頭がハッキリとした。", "You feel your head clear."));
382 creature_ptr->redraw |= (PR_MANA);
383 creature_ptr->window |= (PW_PLAYER);
384 creature_ptr->window |= (PW_SPELL);
389 bool restore_all_status(player_type *creature_ptr)
392 if (do_res_stat(creature_ptr, A_STR)) ident = TRUE;
393 if (do_res_stat(creature_ptr, A_INT)) ident = TRUE;
394 if (do_res_stat(creature_ptr, A_WIS)) ident = TRUE;
395 if (do_res_stat(creature_ptr, A_DEX)) ident = TRUE;
396 if (do_res_stat(creature_ptr, A_CON)) ident = TRUE;
397 if (do_res_stat(creature_ptr, A_CHR)) ident = TRUE;
402 bool fishing(player_type *creature_ptr)
405 if (!get_direction(creature_ptr, &dir, FALSE, FALSE)) return FALSE;
406 POSITION y = creature_ptr->y + ddy[dir];
407 POSITION x = creature_ptr->x + ddx[dir];
408 creature_ptr->fishing_dir = dir;
409 if (!cave_have_flag_bold(creature_ptr->current_floor_ptr, y, x, FF_WATER))
411 msg_print(_("そこは水辺ではない。", "There is no fishing place."));
415 if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx)
417 GAME_TEXT m_name[MAX_NLEN];
418 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);
419 msg_format(_("%sが邪魔だ!", "%^s is standing in your way."), m_name);
420 free_turn(creature_ptr);
424 set_action(creature_ptr, ACTION_FISH);
425 creature_ptr->redraw |= (PR_STATE);
430 bool cosmic_cast_off(player_type *creature_ptr, object_type *o_ptr)
432 /* Cast off activated item */
434 for (inv = INVEN_RARM; inv <= INVEN_FEET; inv++)
436 if (o_ptr == &creature_ptr->inventory_list[inv]) break;
439 if (inv > INVEN_FEET) return FALSE;
442 object_copy(&forge, o_ptr);
443 inven_item_increase(creature_ptr, inv, (0 - o_ptr->number));
444 inven_item_optimize(creature_ptr, inv);
445 OBJECT_IDX o_idx = drop_near(creature_ptr, &forge, 0, creature_ptr->y, creature_ptr->x);
446 o_ptr = &creature_ptr->current_floor_ptr->o_list[o_idx];
448 GAME_TEXT o_name[MAX_NLEN];
449 object_desc(creature_ptr, o_name, o_ptr, OD_NAME_ONLY);
450 msg_format(_("%sを脱ぎ捨てた。", "You cast off %s."), o_name);
453 msg_print(_("「燃え上がれ俺の小宇宙!」", "You say, 'Burn up my cosmo!"));
454 int t = 20 + randint1(20);
455 (void)set_blind(creature_ptr, creature_ptr->blind + t);
456 (void)set_afraid(creature_ptr, 0);
457 (void)set_tim_esp(creature_ptr, creature_ptr->tim_esp + t, FALSE);
458 (void)set_tim_regen(creature_ptr, creature_ptr->tim_regen + t, FALSE);
459 (void)set_hero(creature_ptr, creature_ptr->hero + t, FALSE);
460 (void)set_blessed(creature_ptr, creature_ptr->blessed + t, FALSE);
461 (void)set_fast(creature_ptr, creature_ptr->fast + t, FALSE);
462 (void)set_shero(creature_ptr, creature_ptr->shero + t, FALSE);
463 if (creature_ptr->pclass == CLASS_FORCETRAINER)
465 P_PTR_KI = creature_ptr->lev * 5 + 190;
466 msg_print(_("気が爆発寸前になった。", "Your force absorbs the explosion."));
474 * @brief プレイヤーの因果混乱処理 / Apply Nexus
475 * @param m_ptr 因果混乱をプレイヤーに与えたモンスターの情報参照ポインタ
478 void apply_nexus(monster_type *m_ptr, player_type *target_ptr)
482 case 1: case 2: case 3:
484 teleport_player(target_ptr, 200, TELEPORT_PASSIVE);
490 teleport_player_to(target_ptr, m_ptr->fy, m_ptr->fx, TELEPORT_PASSIVE);
496 if (randint0(100) < target_ptr->skill_sav)
498 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
502 teleport_level(target_ptr, 0);
508 if (randint0(100) < target_ptr->skill_sav)
510 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
514 msg_print(_("体がねじれ始めた...", "Your body starts to scramble..."));
515 status_shuffle(target_ptr);
523 * @brief プレイヤーのステータスシャッフル処理
524 * @param creature_ptr プレーヤーへの参照ポインタ
527 void status_shuffle(player_type *creature_ptr)
529 /* Pick a pair of stats */
530 int i = randint0(A_MAX);
533 // todo ここのループは一体何をしている?
534 for (j = i; j == i; j = randint0(A_MAX)) /* loop */;
536 BASE_STATUS max1 = creature_ptr->stat_max[i];
537 BASE_STATUS cur1 = creature_ptr->stat_cur[i];
538 BASE_STATUS max2 = creature_ptr->stat_max[j];
539 BASE_STATUS cur2 = creature_ptr->stat_cur[j];
541 creature_ptr->stat_max[i] = max2;
542 creature_ptr->stat_cur[i] = cur2;
543 creature_ptr->stat_max[j] = max1;
544 creature_ptr->stat_cur[j] = cur1;
546 for (int k = 0; k < A_MAX; k++)
548 if (creature_ptr->stat_max[k] > creature_ptr->stat_max_max[k]) creature_ptr->stat_max[k] = creature_ptr->stat_max_max[k];
549 if (creature_ptr->stat_cur[k] > creature_ptr->stat_max_max[k]) creature_ptr->stat_cur[k] = creature_ptr->stat_max_max[k];
552 creature_ptr->update |= PU_BONUS;