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 */
81 * @brief アイテムが電撃で破損するかどうかを判定する /
82 * Does a given object (usually) hate electricity?
83 * @param o_ptr アイテムの情報参照ポインタ
84 * @return 破損するならばTRUEを返す
86 bool hates_elec(object_type *o_ptr)
105 * @brief アイテムが火炎で破損するかどうかを判定する /
106 * Does a given object (usually) hate fire?
107 * @param o_ptr アイテムの情報参照ポインタ
108 * @return 破損するならばTRUEを返す
110 * Hafted/Polearm weapons have wooden shafts.
111 * Arrows/Bows are mostly wooden.
113 bool hates_fire(object_type *o_ptr)
115 /* Analyze the type */
134 case TV_SORCERY_BOOK:
142 case TV_CRUSADE_BOOK:
144 case TV_HISSATSU_BOOK:
156 /* Staffs/Scrolls burn */
172 * @brief アイテムが冷気で破損するかどうかを判定する /
173 * Does a given object (usually) hate cold?
174 * @param o_ptr アイテムの情報参照ポインタ
175 * @return 破損するならばTRUEを返す
177 bool hates_cold(object_type *o_ptr)
197 * @brief アイテムが酸で破損するかどうかを判定する(メインルーチン) /
199 * @param o_ptr アイテムの情報参照ポインタ
200 * @return 破損するならばTRUEを返す
203 int set_acid_destroy(player_type *owner_ptr, object_type *o_ptr)
205 BIT_FLAGS flgs[TR_FLAG_SIZE];
206 if (!hates_acid(o_ptr)) return FALSE;
207 object_flags(owner_ptr, o_ptr, flgs);
208 if (has_flag(flgs, TR_IGNORE_ACID)) return FALSE;
214 * @brief アイテムが電撃で破損するかどうかを判定する(メインルーチン) /
216 * @param o_ptr アイテムの情報参照ポインタ
217 * @return 破損するならばTRUEを返す
220 int set_elec_destroy(player_type *owner_ptr, object_type *o_ptr)
222 BIT_FLAGS flgs[TR_FLAG_SIZE];
223 if (!hates_elec(o_ptr)) return FALSE;
224 object_flags(owner_ptr, o_ptr, flgs);
225 if (has_flag(flgs, TR_IGNORE_ELEC)) return FALSE;
231 * @brief アイテムが火炎で破損するかどうかを判定する(メインルーチン) /
233 * @param o_ptr アイテムの情報参照ポインタ
234 * @return 破損するならばTRUEを返す
237 int set_fire_destroy(player_type *owner_ptr, object_type *o_ptr)
239 BIT_FLAGS flgs[TR_FLAG_SIZE];
240 if (!hates_fire(o_ptr)) return FALSE;
241 object_flags(owner_ptr, o_ptr, flgs);
242 if (has_flag(flgs, TR_IGNORE_FIRE)) return FALSE;
248 * @brief アイテムが冷気で破損するかどうかを判定する(メインルーチン) /
250 * @param o_ptr アイテムの情報参照ポインタ
251 * @return 破損するならばTRUEを返す
254 int set_cold_destroy(player_type *owner_ptr, object_type *o_ptr)
256 BIT_FLAGS flgs[TR_FLAG_SIZE];
257 if (!hates_cold(o_ptr)) return FALSE;
258 object_flags(owner_ptr, o_ptr, flgs);
259 if (has_flag(flgs, TR_IGNORE_COLD)) return FALSE;
266 * Potions "smash open" and cause an area effect when
267 * @param who 薬破損の主体ID(プレイヤー所持アイテムが壊れた場合0、床上のアイテムの場合モンスターID)
270 * @param k_idx 破損した薬のアイテムID
271 * @return 薬を浴びたモンスターが起こるならばTRUEを返す
274 * (1) they are shattered while in the player's p_ptr->inventory_list,
275 * due to cold (etc) attacks;
276 * (2) they are thrown at a monster, or obstacle;
277 * (3) they are shattered by a "cold ball" or other such spell
278 * while lying on the floor.
281 * who --- who caused the potion to shatter (0=player)
282 * potions that smash on the floor are assumed to
283 * be caused by no-one (who = 1), as are those that
284 * shatter inside the player inventory.
285 * (Not anymore -- I changed this; TY)
286 * y, x --- coordinates of the potion (or player if
287 * the potion was in her inventory);
288 * o_ptr --- pointer to the potion object.
291 bool potion_smash_effect(player_type *owner_ptr, MONSTER_IDX who, POSITION y, POSITION x, KIND_OBJECT_IDX k_idx)
297 object_kind *k_ptr = &k_info[k_idx];
300 case SV_POTION_SALT_WATER:
301 case SV_POTION_SLIME_MOLD:
302 case SV_POTION_LOSE_MEMORIES:
303 case SV_POTION_DEC_STR:
304 case SV_POTION_DEC_INT:
305 case SV_POTION_DEC_WIS:
306 case SV_POTION_DEC_DEX:
307 case SV_POTION_DEC_CON:
308 case SV_POTION_DEC_CHR:
309 case SV_POTION_WATER: /* perhaps a 'water' attack? */
310 case SV_POTION_APPLE_JUICE:
313 case SV_POTION_INFRAVISION:
314 case SV_POTION_DETECT_INVIS:
315 case SV_POTION_SLOW_POISON:
316 case SV_POTION_CURE_POISON:
317 case SV_POTION_BOLDNESS:
318 case SV_POTION_RESIST_HEAT:
319 case SV_POTION_RESIST_COLD:
320 case SV_POTION_HEROISM:
321 case SV_POTION_BESERK_STRENGTH:
322 case SV_POTION_RES_STR:
323 case SV_POTION_RES_INT:
324 case SV_POTION_RES_WIS:
325 case SV_POTION_RES_DEX:
326 case SV_POTION_RES_CON:
327 case SV_POTION_RES_CHR:
328 case SV_POTION_INC_STR:
329 case SV_POTION_INC_INT:
330 case SV_POTION_INC_WIS:
331 case SV_POTION_INC_DEX:
332 case SV_POTION_INC_CON:
333 case SV_POTION_INC_CHR:
334 case SV_POTION_AUGMENTATION:
335 case SV_POTION_ENLIGHTENMENT:
336 case SV_POTION_STAR_ENLIGHTENMENT:
337 case SV_POTION_SELF_KNOWLEDGE:
338 case SV_POTION_EXPERIENCE:
339 case SV_POTION_RESISTANCE:
340 case SV_POTION_INVULNERABILITY:
341 case SV_POTION_NEW_LIFE:
342 /* All of the above potions have no effect when shattered */
344 case SV_POTION_SLOWNESS:
349 case SV_POTION_POISON:
354 case SV_POTION_BLINDNESS:
358 case SV_POTION_BOOZE:
362 case SV_POTION_SLEEP:
366 case SV_POTION_RUINATION:
367 case SV_POTION_DETONATIONS:
369 dam = damroll(25, 25);
372 case SV_POTION_DEATH:
374 dam = k_ptr->level * 10;
378 case SV_POTION_SPEED:
381 case SV_POTION_CURE_LIGHT:
385 case SV_POTION_CURE_SERIOUS:
389 case SV_POTION_CURE_CRITICAL:
390 case SV_POTION_CURING:
394 case SV_POTION_HEALING:
396 dam = damroll(10, 10);
398 case SV_POTION_RESTORE_EXP:
405 dam = damroll(50, 50);
408 case SV_POTION_STAR_HEALING:
410 dam = damroll(50, 50);
413 case SV_POTION_RESTORE_MANA:
415 dam = damroll(10, 10);
422 (void)project(owner_ptr, who, radius, y, x, dam, dt, (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
427 * @brief 矢弾を射撃した場合の破損確率を返す /
428 * Determines the odds of an object breaking when thrown at a monster
429 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
432 * Note that artifacts never break, see the "drop_near()" function.
434 PERCENTAGE breakage_chance(player_type *owner_ptr, object_type *o_ptr, bool has_archer_bonus, SPELL_IDX snipe_type)
436 /* Examine the snipe type */
439 if (snipe_type == SP_KILL_WALL) return 100;
440 if (snipe_type == SP_EXPLODE) return 100;
441 if (snipe_type == SP_PIERCE) return 100;
442 if (snipe_type == SP_FINAL) return 100;
443 if (snipe_type == SP_NEEDLE) return 100;
444 if (snipe_type == SP_EVILNESS) return 40;
445 if (snipe_type == SP_HOLYNESS) return 40;
448 /* Examine the item type */
449 PERCENTAGE archer_bonus = (has_archer_bonus ? (PERCENTAGE)(owner_ptr->lev - 1) / 7 + 4 : 0);
466 /* Sometimes break */
471 return 20 - archer_bonus * 2;
476 return 10 - archer_bonus;