6 #include "object/object-broken.h"
7 #include "effect/effect-characteristics.h"
8 #include "mind/snipe-types.h"
9 #include "object-enchant/tr-types.h"
10 #include "object/object-flags.h"
11 #include "object/object-kind.h"
12 #include "effect/effect-processor.h"
13 #include "spell/spell-types.h"
14 #include "sv-definition/sv-potion-types.h"
15 #include "util/bit-flags-calculator.h"
18 * @brief アイテムが酸で破損するかどうかを判定する
19 * @param o_ptr アイテムの情報参照ポインタ
20 * @return 破損するならばTRUEを返す
21 * Note that amulets, rods, and high-level spell books are immune
22 * to "inventory damage" of any kind. Also sling ammo and shovels.
23 * Does a given class of objects (usually) hate acid?
24 * Note that acid can either melt or corrode something.
26 bool hates_acid(object_type *o_ptr)
28 /* Analyze the type */
51 /* Staffs/Scrolls are wood/paper */
78 * @brief アイテムが電撃で破損するかどうかを判定する /
79 * Does a given object (usually) hate electricity?
80 * @param o_ptr アイテムの情報参照ポインタ
81 * @return 破損するならばTRUEを返す
83 bool hates_elec(object_type *o_ptr)
99 * @brief アイテムが火炎で破損するかどうかを判定する /
100 * Does a given object (usually) hate fire?
101 * @param o_ptr アイテムの情報参照ポインタ
102 * @return 破損するならばTRUEを返す
104 * Hafted/Polearm weapons have wooden shafts.
105 * Arrows/Bows are mostly wooden.
107 bool hates_fire(object_type *o_ptr)
109 /* Analyze the type */
128 case TV_SORCERY_BOOK:
136 case TV_CRUSADE_BOOK:
138 case TV_HISSATSU_BOOK:
150 /* Staffs/Scrolls burn */
163 * @brief アイテムが冷気で破損するかどうかを判定する /
164 * Does a given object (usually) hate cold?
165 * @param o_ptr アイテムの情報参照ポインタ
166 * @return 破損するならばTRUEを返す
168 bool hates_cold(object_type *o_ptr)
185 * @brief アイテムが酸で破損するかどうかを判定する(メインルーチン) /
187 * @param o_ptr アイテムの情報参照ポインタ
188 * @return 破損するならばTRUEを返す
191 int set_acid_destroy(player_type *owner_ptr, object_type *o_ptr)
193 BIT_FLAGS flgs[TR_FLAG_SIZE];
194 if (!hates_acid(o_ptr)) return FALSE;
195 object_flags(owner_ptr, o_ptr, flgs);
196 if (have_flag(flgs, TR_IGNORE_ACID)) return FALSE;
202 * @brief アイテムが電撃で破損するかどうかを判定する(メインルーチン) /
204 * @param o_ptr アイテムの情報参照ポインタ
205 * @return 破損するならばTRUEを返す
208 int set_elec_destroy(player_type *owner_ptr, object_type *o_ptr)
210 BIT_FLAGS flgs[TR_FLAG_SIZE];
211 if (!hates_elec(o_ptr)) return FALSE;
212 object_flags(owner_ptr, o_ptr, flgs);
213 if (have_flag(flgs, TR_IGNORE_ELEC)) return FALSE;
219 * @brief アイテムが火炎で破損するかどうかを判定する(メインルーチン) /
221 * @param o_ptr アイテムの情報参照ポインタ
222 * @return 破損するならばTRUEを返す
225 int set_fire_destroy(player_type *owner_ptr, object_type *o_ptr)
227 BIT_FLAGS flgs[TR_FLAG_SIZE];
228 if (!hates_fire(o_ptr)) return FALSE;
229 object_flags(owner_ptr, o_ptr, flgs);
230 if (have_flag(flgs, TR_IGNORE_FIRE)) return FALSE;
236 * @brief アイテムが冷気で破損するかどうかを判定する(メインルーチン) /
238 * @param o_ptr アイテムの情報参照ポインタ
239 * @return 破損するならばTRUEを返す
242 int set_cold_destroy(player_type *owner_ptr, object_type *o_ptr)
244 BIT_FLAGS flgs[TR_FLAG_SIZE];
245 if (!hates_cold(o_ptr)) return FALSE;
246 object_flags(owner_ptr, o_ptr, flgs);
247 if (have_flag(flgs, TR_IGNORE_COLD)) return FALSE;
254 * Potions "smash open" and cause an area effect when
255 * @param who 薬破損の主体ID(プレイヤー所持アイテムが壊れた場合0、床上のアイテムの場合モンスターID)
258 * @param k_idx 破損した薬のアイテムID
259 * @return 薬を浴びたモンスターが起こるならばTRUEを返す
262 * (1) they are shattered while in the player's p_ptr->inventory_list,
263 * due to cold (etc) attacks;
264 * (2) they are thrown at a monster, or obstacle;
265 * (3) they are shattered by a "cold ball" or other such spell
266 * while lying on the floor.
269 * who --- who caused the potion to shatter (0=player)
270 * potions that smash on the floor are assumed to
271 * be caused by no-one (who = 1), as are those that
272 * shatter inside the player inventory.
273 * (Not anymore -- I changed this; TY)
274 * y, x --- coordinates of the potion (or player if
275 * the potion was in her inventory);
276 * o_ptr --- pointer to the potion object.
279 bool potion_smash_effect(player_type *owner_ptr, MONSTER_IDX who, POSITION y, POSITION x, KIND_OBJECT_IDX k_idx)
285 object_kind *k_ptr = &k_info[k_idx];
288 case SV_POTION_SALT_WATER:
289 case SV_POTION_SLIME_MOLD:
290 case SV_POTION_LOSE_MEMORIES:
291 case SV_POTION_DEC_STR:
292 case SV_POTION_DEC_INT:
293 case SV_POTION_DEC_WIS:
294 case SV_POTION_DEC_DEX:
295 case SV_POTION_DEC_CON:
296 case SV_POTION_DEC_CHR:
297 case SV_POTION_WATER: /* perhaps a 'water' attack? */
298 case SV_POTION_APPLE_JUICE:
301 case SV_POTION_INFRAVISION:
302 case SV_POTION_DETECT_INVIS:
303 case SV_POTION_SLOW_POISON:
304 case SV_POTION_CURE_POISON:
305 case SV_POTION_BOLDNESS:
306 case SV_POTION_RESIST_HEAT:
307 case SV_POTION_RESIST_COLD:
308 case SV_POTION_HEROISM:
309 case SV_POTION_BESERK_STRENGTH:
310 case SV_POTION_RES_STR:
311 case SV_POTION_RES_INT:
312 case SV_POTION_RES_WIS:
313 case SV_POTION_RES_DEX:
314 case SV_POTION_RES_CON:
315 case SV_POTION_RES_CHR:
316 case SV_POTION_INC_STR:
317 case SV_POTION_INC_INT:
318 case SV_POTION_INC_WIS:
319 case SV_POTION_INC_DEX:
320 case SV_POTION_INC_CON:
321 case SV_POTION_INC_CHR:
322 case SV_POTION_AUGMENTATION:
323 case SV_POTION_ENLIGHTENMENT:
324 case SV_POTION_STAR_ENLIGHTENMENT:
325 case SV_POTION_SELF_KNOWLEDGE:
326 case SV_POTION_EXPERIENCE:
327 case SV_POTION_RESISTANCE:
328 case SV_POTION_INVULNERABILITY:
329 case SV_POTION_NEW_LIFE:
330 /* All of the above potions have no effect when shattered */
332 case SV_POTION_SLOWNESS:
337 case SV_POTION_POISON:
342 case SV_POTION_BLINDNESS:
346 case SV_POTION_BOOZE:
350 case SV_POTION_SLEEP:
354 case SV_POTION_RUINATION:
355 case SV_POTION_DETONATIONS:
357 dam = damroll(25, 25);
360 case SV_POTION_DEATH:
362 dam = k_ptr->level * 10;
366 case SV_POTION_SPEED:
369 case SV_POTION_CURE_LIGHT:
373 case SV_POTION_CURE_SERIOUS:
377 case SV_POTION_CURE_CRITICAL:
378 case SV_POTION_CURING:
382 case SV_POTION_HEALING:
384 dam = damroll(10, 10);
386 case SV_POTION_RESTORE_EXP:
393 dam = damroll(50, 50);
396 case SV_POTION_STAR_HEALING:
398 dam = damroll(50, 50);
401 case SV_POTION_RESTORE_MANA:
403 dam = damroll(10, 10);
410 (void)project(owner_ptr, who, radius, y, x, dam, dt, (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
415 * @brief 矢弾を射撃した場合の破損確率を返す /
416 * Determines the odds of an object breaking when thrown at a monster
417 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
420 * Note that artifacts never break, see the "drop_near()" function.
422 PERCENTAGE breakage_chance(player_type *owner_ptr, object_type *o_ptr, bool has_archer_bonus, SPELL_IDX snipe_type)
424 /* Examine the snipe type */
427 if (snipe_type == SP_KILL_WALL) return 100;
428 if (snipe_type == SP_EXPLODE) return 100;
429 if (snipe_type == SP_PIERCE) return 100;
430 if (snipe_type == SP_FINAL) return 100;
431 if (snipe_type == SP_NEEDLE) return 100;
432 if (snipe_type == SP_EVILNESS) return 40;
433 if (snipe_type == SP_HOLYNESS) return 40;
436 /* Examine the item type */
437 PERCENTAGE archer_bonus = (has_archer_bonus ? (PERCENTAGE)(owner_ptr->lev - 1) / 7 + 4 : 0);
454 /* Sometimes break */
459 return 20 - archer_bonus * 2;
464 return 10 - archer_bonus;