1 #include "monster-floor/monster-remover.h"
2 #include "core/player-update-types.h"
3 #include "core/stuff-handler.h"
4 #include "floor/floor-object.h"
6 #include "monster-race/monster-race.h"
7 #include "monster-race/race-flags2.h"
8 #include "monster-race/race-flags7.h"
9 #include "monster-race/race-indice-types.h"
10 #include "monster/monster-info.h"
11 #include "monster/monster-status.h"
12 #include "system/floor-type-definition.h"
13 #include "system/monster-type-definition.h"
14 #include "system/object-type-definition.h"
15 #include "target/targeting.h"
18 * @brief モンスター配列からモンスターを消去する / Delete a monster by index.
19 * @param i 消去するモンスターのID
22 * モンスターを削除するとそのモンスターが拾っていたアイテムも同時に削除される。 /
23 * When a monster is deleted, all of its objects are deleted.
25 void delete_monster_idx(player_type *player_ptr, MONSTER_IDX i)
27 floor_type *floor_ptr = player_ptr->current_floor_ptr;
28 monster_type *m_ptr = &floor_ptr->m_list[i];
29 monster_race *r_ptr = &r_info[m_ptr->r_idx];
31 POSITION y = m_ptr->fy;
32 POSITION x = m_ptr->fx;
34 real_r_ptr(m_ptr)->cur_num--;
35 if (r_ptr->flags2 & (RF2_MULTIPLY))
36 floor_ptr->num_repro--;
38 if (monster_csleep_remaining(m_ptr))
39 (void)set_monster_csleep(player_ptr, i, 0);
40 if (monster_fast_remaining(m_ptr))
41 (void)set_monster_fast(player_ptr, i, 0);
42 if (monster_slow_remaining(m_ptr))
43 (void)set_monster_slow(player_ptr, i, 0);
44 if (monster_stunned_remaining(m_ptr))
45 (void)set_monster_stunned(player_ptr, i, 0);
46 if (monster_confused_remaining(m_ptr))
47 (void)set_monster_confused(player_ptr, i, 0);
48 if (monster_fear_remaining(m_ptr))
49 (void)set_monster_monfear(player_ptr, i, 0);
50 if (monster_invulner_remaining(m_ptr))
51 (void)set_monster_invulner(player_ptr, i, 0, FALSE);
56 if (i == player_ptr->health_who)
57 health_track(player_ptr, 0);
59 if (player_ptr->pet_t_m_idx == i)
60 player_ptr->pet_t_m_idx = 0;
61 if (player_ptr->riding_t_m_idx == i)
62 player_ptr->riding_t_m_idx = 0;
63 if (player_ptr->riding == i)
64 player_ptr->riding = 0;
66 floor_ptr->grid_array[y][x].m_idx = 0;
67 OBJECT_IDX next_o_idx = 0;
68 for (OBJECT_IDX this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx) {
70 o_ptr = &floor_ptr->o_list[this_o_idx];
71 next_o_idx = o_ptr->next_o_idx;
72 delete_object_idx(player_ptr, this_o_idx);
75 (void)WIPE(m_ptr, monster_type);
77 lite_spot(player_ptr, y, x);
78 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK)) {
79 player_ptr->update |= (PU_MON_LITE);
84 * @brief プレイヤーのフロア離脱に伴う全モンスター配列の消去 / Delete/Remove all the monsters when the player leaves the level
85 * @param player_ptr プレーヤーへの参照ポインタ
88 * This is an efficient method of simulating multiple calls to the
89 * "delete_monster()" function, with no visual effects.
91 void wipe_monsters_list(player_type *player_ptr)
93 if (!r_info[MON_BANORLUPART].max_num) {
94 if (r_info[MON_BANOR].max_num) {
95 r_info[MON_BANOR].max_num = 0;
96 r_info[MON_BANOR].r_pkills++;
97 r_info[MON_BANOR].r_akills++;
98 if (r_info[MON_BANOR].r_tkills < MAX_SHORT)
99 r_info[MON_BANOR].r_tkills++;
102 if (r_info[MON_LUPART].max_num) {
103 r_info[MON_LUPART].max_num = 0;
104 r_info[MON_LUPART].r_pkills++;
105 r_info[MON_LUPART].r_akills++;
106 if (r_info[MON_LUPART].r_tkills < MAX_SHORT)
107 r_info[MON_LUPART].r_tkills++;
111 floor_type *floor_ptr = player_ptr->current_floor_ptr;
112 for (int i = floor_ptr->m_max - 1; i >= 1; i--) {
113 monster_type *m_ptr = &floor_ptr->m_list[i];
114 if (!monster_is_valid(m_ptr))
117 floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].m_idx = 0;
118 (void)WIPE(m_ptr, monster_type);
122 * Wiping racial counters of all monsters and incrementing of racial
123 * counters of monsters in party_mon[] are required to prevent multiple
124 * generation of unique monster who is the minion of player.
126 for (int i = 1; i < max_r_idx; i++)
127 r_info[i].cur_num = 0;
129 floor_ptr->m_max = 1;
130 floor_ptr->m_cnt = 0;
131 for (int i = 0; i < MAX_MTIMED; i++)
132 floor_ptr->mproc_max[i] = 0;
134 floor_ptr->num_repro = 0;
136 player_ptr->pet_t_m_idx = 0;
137 player_ptr->riding_t_m_idx = 0;
138 health_track(player_ptr, 0);