From ab67c16beac79657a3ff8a450735d4539b083989 Mon Sep 17 00:00:00 2001 From: deskull Date: Wed, 6 Mar 2019 00:02:17 +0900 Subject: [PATCH] [Refactor] #37353 potion_smash_effect() to object-broken.c. --- src/cmd-quaff.c | 1 + src/cmd2.c | 1 + src/externs.h | 1 - src/object-broken.c | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/object-broken.h | 2 + src/player-damage.c | 1 + src/spells1.c | 1 + src/spells3.c | 167 --------------------------------------------------- 8 files changed, 174 insertions(+), 168 deletions(-) create mode 100644 src/object-broken.c create mode 100644 src/object-broken.h diff --git a/src/cmd-quaff.c b/src/cmd-quaff.c index 3c0dcd8c4..255411269 100644 --- a/src/cmd-quaff.c +++ b/src/cmd-quaff.c @@ -14,6 +14,7 @@ #include "spells-status.h" #include "realm-hex.h" #include "spells-floor.h" +#include "object-broken.h" /*! * @brief 薬を飲むコマンドのサブルーチン / diff --git a/src/cmd2.c b/src/cmd2.c index bb277075b..e59243bc6 100644 --- a/src/cmd2.c +++ b/src/cmd2.c @@ -29,6 +29,7 @@ #include "grid.h" #include "feature.h" #include "player-move.h" +#include "object-broken.h" /*! * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理 diff --git a/src/externs.h b/src/externs.h index f4f763bf1..c50296e02 100644 --- a/src/externs.h +++ b/src/externs.h @@ -974,7 +974,6 @@ extern bool mundane_spell(bool only_equip); extern bool identify_item(object_type *o_ptr); extern bool identify_fully(bool only_equip); extern bool recharge(int power); -extern bool potion_smash_effect(MONSTER_IDX who, POSITION y, POSITION x, KIND_OBJECT_IDX k_idx); extern void display_spell_list(void); extern EXP experience_of_spell(SPELL_IDX spell, REALM_IDX use_realm); extern MANA_POINT mod_need_mana(MANA_POINT need_mana, SPELL_IDX spell, REALM_IDX realm); diff --git a/src/object-broken.c b/src/object-broken.c new file mode 100644 index 000000000..149452b2c --- /dev/null +++ b/src/object-broken.c @@ -0,0 +1,168 @@ +#include "angband.h" +#include "projection.h" + +/*! + * @brief 薬の破損効果処理 / + * Potions "smash open" and cause an area effect when + * @param who 薬破損の主体ID(プレイヤー所持アイテムが壊れた場合0、床上のアイテムの場合モンスターID) + * @param y 破壊時のY座標 + * @param x 破壊時のX座標 + * @param k_idx 破損した薬のアイテムID + * @return 薬を浴びたモンスターが起こるならばTRUEを返す + * @details + *
+ * (1) they are shattered while in the player's inventory,
+ * due to cold (etc) attacks;
+ * (2) they are thrown at a monster, or obstacle;
+ * (3) they are shattered by a "cold ball" or other such spell
+ * while lying on the floor.
+ *
+ * Arguments:
+ *    who   ---  who caused the potion to shatter (0=player)
+ *          potions that smash on the floor are assumed to
+ *          be caused by no-one (who = 1), as are those that
+ *          shatter inside the player inventory.
+ *          (Not anymore -- I changed this; TY)
+ *    y, x  --- coordinates of the potion (or player if
+ *          the potion was in her inventory);
+ *    o_ptr --- pointer to the potion object.
+ * 
+ */ +bool potion_smash_effect(MONSTER_IDX who, POSITION y, POSITION x, KIND_OBJECT_IDX k_idx) +{ + int radius = 2; + int dt = 0; + int dam = 0; + bool angry = FALSE; + + object_kind *k_ptr = &k_info[k_idx]; + + switch (k_ptr->sval) + { + case SV_POTION_SALT_WATER: + case SV_POTION_SLIME_MOLD: + case SV_POTION_LOSE_MEMORIES: + case SV_POTION_DEC_STR: + case SV_POTION_DEC_INT: + case SV_POTION_DEC_WIS: + case SV_POTION_DEC_DEX: + case SV_POTION_DEC_CON: + case SV_POTION_DEC_CHR: + case SV_POTION_WATER: /* perhaps a 'water' attack? */ + case SV_POTION_APPLE_JUICE: + return TRUE; + + case SV_POTION_INFRAVISION: + case SV_POTION_DETECT_INVIS: + case SV_POTION_SLOW_POISON: + case SV_POTION_CURE_POISON: + case SV_POTION_BOLDNESS: + case SV_POTION_RESIST_HEAT: + case SV_POTION_RESIST_COLD: + case SV_POTION_HEROISM: + case SV_POTION_BESERK_STRENGTH: + case SV_POTION_RES_STR: + case SV_POTION_RES_INT: + case SV_POTION_RES_WIS: + case SV_POTION_RES_DEX: + case SV_POTION_RES_CON: + case SV_POTION_RES_CHR: + case SV_POTION_INC_STR: + case SV_POTION_INC_INT: + case SV_POTION_INC_WIS: + case SV_POTION_INC_DEX: + case SV_POTION_INC_CON: + case SV_POTION_INC_CHR: + case SV_POTION_AUGMENTATION: + case SV_POTION_ENLIGHTENMENT: + case SV_POTION_STAR_ENLIGHTENMENT: + case SV_POTION_SELF_KNOWLEDGE: + case SV_POTION_EXPERIENCE: + case SV_POTION_RESISTANCE: + case SV_POTION_INVULNERABILITY: + case SV_POTION_NEW_LIFE: + /* All of the above potions have no effect when shattered */ + return FALSE; + case SV_POTION_SLOWNESS: + dt = GF_OLD_SLOW; + dam = 5; + angry = TRUE; + break; + case SV_POTION_POISON: + dt = GF_POIS; + dam = 3; + angry = TRUE; + break; + case SV_POTION_BLINDNESS: + dt = GF_DARK; + angry = TRUE; + break; + case SV_POTION_BOOZE: /* Booze */ + dt = GF_OLD_CONF; + angry = TRUE; + break; + case SV_POTION_SLEEP: + dt = GF_OLD_SLEEP; + angry = TRUE; + break; + case SV_POTION_RUINATION: + case SV_POTION_DETONATIONS: + dt = GF_SHARDS; + dam = damroll(25, 25); + angry = TRUE; + break; + case SV_POTION_DEATH: + dt = GF_DEATH_RAY; /* !! */ + dam = k_ptr->level * 10; + angry = TRUE; + radius = 1; + break; + case SV_POTION_SPEED: + dt = GF_OLD_SPEED; + break; + case SV_POTION_CURE_LIGHT: + dt = GF_OLD_HEAL; + dam = damroll(2, 3); + break; + case SV_POTION_CURE_SERIOUS: + dt = GF_OLD_HEAL; + dam = damroll(4, 3); + break; + case SV_POTION_CURE_CRITICAL: + case SV_POTION_CURING: + dt = GF_OLD_HEAL; + dam = damroll(6, 3); + break; + case SV_POTION_HEALING: + dt = GF_OLD_HEAL; + dam = damroll(10, 10); + break; + case SV_POTION_RESTORE_EXP: + dt = GF_STAR_HEAL; + dam = 0; + radius = 1; + break; + case SV_POTION_LIFE: + dt = GF_STAR_HEAL; + dam = damroll(50, 50); + radius = 1; + break; + case SV_POTION_STAR_HEALING: + dt = GF_OLD_HEAL; + dam = damroll(50, 50); + radius = 1; + break; + case SV_POTION_RESTORE_MANA: /* MANA */ + dt = GF_MANA; + dam = damroll(10, 10); + radius = 1; + break; + default: + /* Do nothing */; + } + + (void)project(who, radius, y, x, dam, dt, (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1); + + /* XXX those potions that explode need to become "known" */ + return angry; +} diff --git a/src/object-broken.h b/src/object-broken.h new file mode 100644 index 000000000..05f48bfff --- /dev/null +++ b/src/object-broken.h @@ -0,0 +1,2 @@ +#pragma once +extern bool potion_smash_effect(MONSTER_IDX who, POSITION y, POSITION x, KIND_OBJECT_IDX k_idx); diff --git a/src/player-damage.c b/src/player-damage.c index 426b262f6..c25b3f236 100644 --- a/src/player-damage.c +++ b/src/player-damage.c @@ -2,6 +2,7 @@ #include "player-damage.h" #include "artifact.h" #include "object-hook.h" +#include "object-broken.h" /*! diff --git a/src/spells1.c b/src/spells1.c index 42a3fb7ef..6313b91e4 100644 --- a/src/spells1.c +++ b/src/spells1.c @@ -35,6 +35,7 @@ #include "player-move.h" #include "realm-hex.h" #include "object-hook.h" +#include "object-broken.h" #include "term.h" #include "grid.h" #include "feature.h" diff --git a/src/spells3.c b/src/spells3.c index b9d0f3302..5485722f9 100644 --- a/src/spells3.c +++ b/src/spells3.c @@ -2702,173 +2702,6 @@ bool recharge(int power) /*! - * @brief 薬の破損効果処理 / - * Potions "smash open" and cause an area effect when - * @param who 薬破損の主体ID(プレイヤー所持アイテムが壊れた場合0、床上のアイテムの場合モンスターID) - * @param y 破壊時のY座標 - * @param x 破壊時のX座標 - * @param k_idx 破損した薬のアイテムID - * @return 薬を浴びたモンスターが起こるならばTRUEを返す - * @details - *
- * (1) they are shattered while in the player's inventory,
- * due to cold (etc) attacks;
- * (2) they are thrown at a monster, or obstacle;
- * (3) they are shattered by a "cold ball" or other such spell
- * while lying on the floor.
- *
- * Arguments:
- *    who   ---  who caused the potion to shatter (0=player)
- *          potions that smash on the floor are assumed to
- *          be caused by no-one (who = 1), as are those that
- *          shatter inside the player inventory.
- *          (Not anymore -- I changed this; TY)
- *    y, x  --- coordinates of the potion (or player if
- *          the potion was in her inventory);
- *    o_ptr --- pointer to the potion object.
- * 
- */ -bool potion_smash_effect(MONSTER_IDX who, POSITION y, POSITION x, KIND_OBJECT_IDX k_idx) -{ - int radius = 2; - int dt = 0; - int dam = 0; - bool angry = FALSE; - - object_kind *k_ptr = &k_info[k_idx]; - - switch (k_ptr->sval) - { - case SV_POTION_SALT_WATER: - case SV_POTION_SLIME_MOLD: - case SV_POTION_LOSE_MEMORIES: - case SV_POTION_DEC_STR: - case SV_POTION_DEC_INT: - case SV_POTION_DEC_WIS: - case SV_POTION_DEC_DEX: - case SV_POTION_DEC_CON: - case SV_POTION_DEC_CHR: - case SV_POTION_WATER: /* perhaps a 'water' attack? */ - case SV_POTION_APPLE_JUICE: - return TRUE; - - case SV_POTION_INFRAVISION: - case SV_POTION_DETECT_INVIS: - case SV_POTION_SLOW_POISON: - case SV_POTION_CURE_POISON: - case SV_POTION_BOLDNESS: - case SV_POTION_RESIST_HEAT: - case SV_POTION_RESIST_COLD: - case SV_POTION_HEROISM: - case SV_POTION_BESERK_STRENGTH: - case SV_POTION_RES_STR: - case SV_POTION_RES_INT: - case SV_POTION_RES_WIS: - case SV_POTION_RES_DEX: - case SV_POTION_RES_CON: - case SV_POTION_RES_CHR: - case SV_POTION_INC_STR: - case SV_POTION_INC_INT: - case SV_POTION_INC_WIS: - case SV_POTION_INC_DEX: - case SV_POTION_INC_CON: - case SV_POTION_INC_CHR: - case SV_POTION_AUGMENTATION: - case SV_POTION_ENLIGHTENMENT: - case SV_POTION_STAR_ENLIGHTENMENT: - case SV_POTION_SELF_KNOWLEDGE: - case SV_POTION_EXPERIENCE: - case SV_POTION_RESISTANCE: - case SV_POTION_INVULNERABILITY: - case SV_POTION_NEW_LIFE: - /* All of the above potions have no effect when shattered */ - return FALSE; - case SV_POTION_SLOWNESS: - dt = GF_OLD_SLOW; - dam = 5; - angry = TRUE; - break; - case SV_POTION_POISON: - dt = GF_POIS; - dam = 3; - angry = TRUE; - break; - case SV_POTION_BLINDNESS: - dt = GF_DARK; - angry = TRUE; - break; - case SV_POTION_BOOZE: /* Booze */ - dt = GF_OLD_CONF; - angry = TRUE; - break; - case SV_POTION_SLEEP: - dt = GF_OLD_SLEEP; - angry = TRUE; - break; - case SV_POTION_RUINATION: - case SV_POTION_DETONATIONS: - dt = GF_SHARDS; - dam = damroll(25, 25); - angry = TRUE; - break; - case SV_POTION_DEATH: - dt = GF_DEATH_RAY; /* !! */ - dam = k_ptr->level * 10; - angry = TRUE; - radius = 1; - break; - case SV_POTION_SPEED: - dt = GF_OLD_SPEED; - break; - case SV_POTION_CURE_LIGHT: - dt = GF_OLD_HEAL; - dam = damroll(2, 3); - break; - case SV_POTION_CURE_SERIOUS: - dt = GF_OLD_HEAL; - dam = damroll(4, 3); - break; - case SV_POTION_CURE_CRITICAL: - case SV_POTION_CURING: - dt = GF_OLD_HEAL; - dam = damroll(6, 3); - break; - case SV_POTION_HEALING: - dt = GF_OLD_HEAL; - dam = damroll(10, 10); - break; - case SV_POTION_RESTORE_EXP: - dt = GF_STAR_HEAL; - dam = 0; - radius = 1; - break; - case SV_POTION_LIFE: - dt = GF_STAR_HEAL; - dam = damroll(50, 50); - radius = 1; - break; - case SV_POTION_STAR_HEALING: - dt = GF_OLD_HEAL; - dam = damroll(50, 50); - radius = 1; - break; - case SV_POTION_RESTORE_MANA: /* MANA */ - dt = GF_MANA; - dam = damroll(10, 10); - radius = 1; - break; - default: - /* Do nothing */ ; - } - - (void)project(who, radius, y, x, dam, dt, (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1); - - /* XXX those potions that explode need to become "known" */ - return angry; -} - - -/*! * @brief プレイヤーの全既知呪文を表示する / * Hack -- Display all known spells in a window * return なし -- 2.11.0