OSDN Git Service

[Refactor] #38997 chg_virtue() に player_type * 引数を追加.
[hengband/hengband.git] / src / spells-status.c
index 16b15e7..8b3e01f 100644 (file)
@@ -1,9 +1,22 @@
 #include "angband.h"
+#include "core.h"
+#include "util.h"
+
+#include "cmd-magiceat.h"
 #include "avatar.h"
+#include "floor.h"
+#include "object-flavor.h"
 #include "player-status.h"
+#include "player-class.h"
 #include "spells-status.h"
-#include "projection.h"
 #include "spells.h"
+#include "monster.h"
+#include "cmd-spell.h"
+#include "player-effects.h"
+#include "objectkind.h"
+#include "targeting.h"
+#include "realm-song.h"
+#include "view-mainwindow.h"
 
 /*!
  * @brief モンスター回復処理
@@ -110,7 +123,7 @@ bool poly_monster(DIRECTION dir, int power)
        BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
        bool tester = (project_hook(GF_OLD_POLY, dir, power, flg));
        if (tester)
-               chg_virtue(V_CHANCE, 1);
+               chg_virtue(p_ptr, V_CHANCE, 1);
        return(tester);
 }
 
@@ -156,8 +169,8 @@ void stop_singing(player_type *creature_ptr)
        /* The player is singing? */
        if (!SINGING_SONG_EFFECT(creature_ptr)) return;
 
-       /* Hack -- if called from set_action(), avoid recursive loop */
-       if (creature_ptr->action == ACTION_SING) set_action(ACTION_NONE);
+       /* Hack -- if called from set_action(p_ptr), avoid recursive loop */
+       if (creature_ptr->action == ACTION_SING) set_action(p_ptr, ACTION_NONE);
 
        /* Message text of each song or etc. */
        do_spell(REALM_MUSIC, SINGING_SONG_ID(creature_ptr), SPELL_STOP);
@@ -180,7 +193,6 @@ bool time_walk(player_type *creature_ptr)
 //     msg_print(_("「『ザ・ワールド』!時は止まった!」", "You yell 'The World! Time has stopped!'"));
        msg_print(NULL);
 
-       /* Hack */
        creature_ptr->energy_need -= 1000 + (100 + p_ptr->csp - 50)*TURNS_PER_TICK / 10;
        creature_ptr->redraw |= (PR_MAP);
        creature_ptr->update |= (PU_MONSTERS);
@@ -257,24 +269,24 @@ bool_hack life_stream(bool_hack message, bool_hack virtue_change)
 {
        if (virtue_change)
        {
-               chg_virtue(V_VITALITY, 1);
-               chg_virtue(V_UNLIFE, -5);
+               chg_virtue(p_ptr, V_VITALITY, 1);
+               chg_virtue(p_ptr, V_UNLIFE, -5);
        }
        if (message)
        {
                msg_print(_("体中に生命力が満ちあふれてきた!", "You feel life flow through your body!"));
        }
-       restore_level();
-       (void)set_poisoned(0);
-       (void)set_blind(0);
-       (void)set_confused(0);
-       (void)set_image(0);
-       (void)set_stun(0);
-       (void)set_cut(0);
+       restore_level(p_ptr);
+       (void)set_poisoned(p_ptr, 0);
+       (void)set_blind(p_ptr, 0);
+       (void)set_confused(p_ptr, 0);
+       (void)set_image(p_ptr, 0);
+       (void)set_stun(p_ptr, 0);
+       (void)set_cut(p_ptr,0);
        (void)restore_all_status();
-       (void)set_shero(0, TRUE);
+       (void)set_shero(p_ptr, 0, TRUE);
        handle_stuff();
-       hp_player(5000);
+       hp_player(p_ptr, 5000);
 
        return TRUE;
 }
@@ -282,65 +294,65 @@ bool_hack life_stream(bool_hack message, bool_hack virtue_change)
 bool_hack heroism(int base)
 {
        bool_hack ident = FALSE;
-       if (set_afraid(0)) ident = TRUE;
-       if (set_hero(p_ptr->hero + randint1(base) + base, FALSE)) ident = TRUE;
-       if (hp_player(10)) ident = TRUE;
+       if (set_afraid(p_ptr, 0)) ident = TRUE;
+       if (set_hero(p_ptr, p_ptr->hero + randint1(base) + base, FALSE)) ident = TRUE;
+       if (hp_player(p_ptr, 10)) ident = TRUE;
        return ident;
 }
 
 bool_hack berserk(int base)
 {
        bool_hack ident = FALSE;
-       if (set_afraid(0)) ident = TRUE;
-       if (set_shero(p_ptr->hero + randint1(base) + base, FALSE)) ident = TRUE;
-       if (hp_player(30)) ident = TRUE;
+       if (set_afraid(p_ptr, 0)) ident = TRUE;
+       if (set_shero(p_ptr, p_ptr->shero + randint1(base) + base, FALSE)) ident = TRUE;
+       if (hp_player(p_ptr, 30)) ident = TRUE;
        return ident;
 }
 
 bool_hack cure_light_wounds(DICE_NUMBER dice, DICE_SID sides)
 {
        bool_hack ident = FALSE;
-       if (hp_player(damroll(dice, sides))) ident = TRUE;
-       if (set_blind(0)) ident = TRUE;
-       if (set_cut(p_ptr->cut - 10)) ident = TRUE;
-       if (set_shero(0, TRUE)) ident = TRUE;
+       if (hp_player(p_ptr, damroll(dice, sides))) ident = TRUE;
+       if (set_blind(p_ptr, 0)) ident = TRUE;
+       if (set_cut(p_ptr,p_ptr->cut - 10)) ident = TRUE;
+       if (set_shero(p_ptr, 0, TRUE)) ident = TRUE;
        return ident;
 }
 
 bool_hack cure_serious_wounds(DICE_NUMBER dice, DICE_SID sides)
 {
        bool_hack ident = FALSE;
-       if (hp_player(damroll(dice, sides))) ident = TRUE;
-       if (set_blind(0)) ident = TRUE;
-       if (set_confused(0)) ident = TRUE;
-       if (set_cut((p_ptr->cut / 2) - 50)) ident = TRUE;
-       if (set_shero(0, TRUE)) ident = TRUE;
+       if (hp_player(p_ptr, damroll(dice, sides))) ident = TRUE;
+       if (set_blind(p_ptr, 0)) ident = TRUE;
+       if (set_confused(p_ptr, 0)) ident = TRUE;
+       if (set_cut(p_ptr,(p_ptr->cut / 2) - 50)) ident = TRUE;
+       if (set_shero(p_ptr, 0, TRUE)) ident = TRUE;
        return ident;
 }
 
 bool_hack cure_critical_wounds(HIT_POINT pow)
 {
        bool_hack ident = FALSE;
-       if (hp_player(pow)) ident = TRUE;
-       if (set_blind(0)) ident = TRUE;
-       if (set_confused(0)) ident = TRUE;
-       if (set_poisoned(0)) ident = TRUE;
-       if (set_stun(0)) ident = TRUE;
-       if (set_cut(0)) ident = TRUE;
-       if (set_shero(0, TRUE)) ident = TRUE;
+       if (hp_player(p_ptr, pow)) ident = TRUE;
+       if (set_blind(p_ptr, 0)) ident = TRUE;
+       if (set_confused(p_ptr, 0)) ident = TRUE;
+       if (set_poisoned(p_ptr, 0)) ident = TRUE;
+       if (set_stun(p_ptr, 0)) ident = TRUE;
+       if (set_cut(p_ptr,0)) ident = TRUE;
+       if (set_shero(p_ptr, 0, TRUE)) ident = TRUE;
        return ident;
 }
 
 bool_hack true_healing(HIT_POINT pow)
 {
        bool_hack ident = FALSE;
-       if (hp_player(pow)) ident = TRUE;
-       if (set_blind(0)) ident = TRUE;
-       if (set_confused(0)) ident = TRUE;
-       if (set_poisoned(0)) ident = TRUE;
-       if (set_stun(0)) ident = TRUE;
-       if (set_cut(0)) ident = TRUE;
-       if (set_image(0)) ident = TRUE;
+       if (hp_player(p_ptr, pow)) ident = TRUE;
+       if (set_blind(p_ptr, 0)) ident = TRUE;
+       if (set_confused(p_ptr, 0)) ident = TRUE;
+       if (set_poisoned(p_ptr, 0)) ident = TRUE;
+       if (set_stun(p_ptr, 0)) ident = TRUE;
+       if (set_cut(p_ptr,0)) ident = TRUE;
+       if (set_image(p_ptr, 0)) ident = TRUE;
        return ident;
 }
 
@@ -383,12 +395,12 @@ bool_hack restore_mana(bool_hack magic_eater)
 bool restore_all_status(void)
 {
        bool ident = FALSE;
-       if (do_res_stat(A_STR)) ident = TRUE;
-       if (do_res_stat(A_INT)) ident = TRUE;
-       if (do_res_stat(A_WIS)) ident = TRUE;
-       if (do_res_stat(A_DEX)) ident = TRUE;
-       if (do_res_stat(A_CON)) ident = TRUE;
-       if (do_res_stat(A_CHR)) ident = TRUE;
+       if (do_res_stat(p_ptr, A_STR)) ident = TRUE;
+       if (do_res_stat(p_ptr, A_INT)) ident = TRUE;
+       if (do_res_stat(p_ptr, A_WIS)) ident = TRUE;
+       if (do_res_stat(p_ptr, A_DEX)) ident = TRUE;
+       if (do_res_stat(p_ptr, A_CON)) ident = TRUE;
+       if (do_res_stat(p_ptr, A_CHR)) ident = TRUE;
        return ident;
 }
 
@@ -409,12 +421,12 @@ bool fishing(player_type *creature_ptr)
        else if (current_floor_ptr->grid_array[y][x].m_idx)
        {
                GAME_TEXT m_name[MAX_NLEN];
-               monster_desc(m_name, &m_list[current_floor_ptr->grid_array[y][x].m_idx], 0);
+               monster_desc(m_name, &current_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx], 0);
                msg_format(_("%sが邪魔だ!", "%^s is stand in your way."), m_name);
                free_turn(creature_ptr);
                return FALSE;
        }
-       set_action(ACTION_FISH);
+       set_action(p_ptr, ACTION_FISH);
        creature_ptr->redraw |= (PR_STATE);
        return TRUE;
 }
@@ -431,17 +443,15 @@ bool cosmic_cast_off(player_type *creature_ptr, object_type *o_ptr)
        /* Cast off activated item */
        for (inv = INVEN_RARM; inv <= INVEN_FEET; inv++)
        {
-               if (o_ptr == &inventory[inv]) break;
+               if (o_ptr == &p_ptr->inventory_list[inv]) break;
        }
-
-       /* Paranoia */
        if (inv > INVEN_FEET) return FALSE;
 
        object_copy(&forge, o_ptr);
        inven_item_increase(inv, (0 - o_ptr->number));
        inven_item_optimize(inv);
        o_idx = drop_near(&forge, 0, creature_ptr->y, creature_ptr->x);
-       o_ptr = &o_list[o_idx];
+       o_ptr = &current_floor_ptr->o_list[o_idx];
 
        object_desc(o_name, o_ptr, OD_NAME_ONLY);
        msg_format(_("%sを脱ぎ捨てた。", "You cast off %s."), o_name);
@@ -449,14 +459,14 @@ bool cosmic_cast_off(player_type *creature_ptr, object_type *o_ptr)
        /* Get effects */
        msg_print(_("「燃え上がれ俺の小宇宙!」", "You say, 'Burn up my cosmo!"));
        t = 20 + randint1(20);
-       (void)set_blind(creature_ptr->blind + t);
-       (void)set_afraid(0);
-       (void)set_tim_esp(creature_ptr->tim_esp + t, FALSE);
-       (void)set_tim_regen(creature_ptr->tim_regen + t, FALSE);
-       (void)set_hero(creature_ptr->hero + t, FALSE);
-       (void)set_blessed(creature_ptr->blessed + t, FALSE);
-       (void)set_fast(creature_ptr->fast + t, FALSE);
-       (void)set_shero(creature_ptr->shero + t, FALSE);
+       (void)set_blind(p_ptr, creature_ptr->blind + t);
+       (void)set_afraid(p_ptr, 0);
+       (void)set_tim_esp(p_ptr, creature_ptr->tim_esp + t, FALSE);
+       (void)set_tim_regen(p_ptr, creature_ptr->tim_regen + t, FALSE);
+       (void)set_hero(p_ptr, creature_ptr->hero + t, FALSE);
+       (void)set_blessed(p_ptr, creature_ptr->blessed + t, FALSE);
+       (void)set_fast(p_ptr, creature_ptr->fast + t, FALSE);
+       (void)set_shero(p_ptr, creature_ptr->shero + t, FALSE);
        if (creature_ptr->pclass == CLASS_FORCETRAINER)
        {
                P_PTR_KI = creature_ptr->lev * 5 + 190;
@@ -465,3 +475,83 @@ bool cosmic_cast_off(player_type *creature_ptr, object_type *o_ptr)
 
        return TRUE;
 }
+
+
+/*!
+ * @brief プレイヤーの因果混乱処理 / Apply Nexus
+ * @param m_ptr 因果混乱をプレイヤーに与えたモンスターの情報参照ポインタ
+ * @return なし
+ */
+void apply_nexus(monster_type *m_ptr)
+{
+       switch (randint1(7))
+       {
+       case 1: case 2: case 3:
+       {
+               teleport_player(200, TELEPORT_PASSIVE);
+               break;
+       }
+
+       case 4: case 5:
+       {
+               teleport_player_to(m_ptr->fy, m_ptr->fx, TELEPORT_PASSIVE);
+               break;
+       }
+
+       case 6:
+       {
+               if (randint0(100) < p_ptr->skill_sav)
+               {
+                       msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
+                       break;
+               }
+               teleport_level(0);
+               break;
+       }
+
+       case 7:
+       {
+               if (randint0(100) < p_ptr->skill_sav)
+               {
+                       msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
+                       break;
+               }
+
+               msg_print(_("体がねじれ始めた...", "Your body starts to scramble..."));
+               status_shuffle();
+               break;
+       }
+       }
+}
+
+/*!
+ * @brief プレイヤーのステータスシャッフル処理
+ * @return なし
+ */
+void status_shuffle(void)
+{
+       BASE_STATUS max1, cur1, max2, cur2;
+       int ii, jj, i;
+
+       /* Pick a pair of stats */
+       ii = randint0(A_MAX);
+       for (jj = ii; jj == ii; jj = randint0(A_MAX)) /* loop */;
+
+       max1 = p_ptr->stat_max[ii];
+       cur1 = p_ptr->stat_cur[ii];
+       max2 = p_ptr->stat_max[jj];
+       cur2 = p_ptr->stat_cur[jj];
+
+       p_ptr->stat_max[ii] = max2;
+       p_ptr->stat_cur[ii] = cur2;
+       p_ptr->stat_max[jj] = max1;
+       p_ptr->stat_cur[jj] = cur1;
+
+       for (i = 0; i < A_MAX; i++)
+       {
+               if (p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
+               if (p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
+       }
+
+       p_ptr->update |= (PU_BONUS);
+}