• R/O
  • HTTP
  • SSH
  • HTTPS

hengband: Commit

変愚蛮怒のメインリポジトリです


Commit MetaInfo

Revision3fb67749dde26221865bf2a7cbc816bf6b7ab646 (tree)
Time2019-02-16 19:19:47
AuthorDeskull <deskull@user...>
CommiterDeskull

Log Message

[Refactor] #37353 spells3.c から関数をいくつか spell-object.c へ移動。 / Move some functions in spells3.c to spell-object.c.

Change Summary

Incremental Difference

--- a/src/cmd-activate.c
+++ b/src/cmd-activate.c
@@ -15,6 +15,7 @@
1515 #include "artifact.h"
1616 #include "avatar.h"
1717 #include "spells-status.h"
18+#include "spells-object.h"
1819 #include "realm-hex.h"
1920 #include "player-status.h"
2021
--- a/src/externs.h
+++ b/src/externs.h
@@ -1033,11 +1033,6 @@ extern PERCENTAGE mod_spell_chance_2(PERCENTAGE chance);
10331033 extern PERCENTAGE spell_chance(SPELL_IDX spell, REALM_IDX realm);
10341034 extern bool spell_okay(int spell, bool learned, bool study_pray, int realm);
10351035 extern void print_spells(SPELL_IDX target_spell, SPELL_IDX *spells, int num, TERM_LEN y, TERM_LEN x, REALM_IDX realm);
1036-extern bool rustproof(void);
1037-extern bool curse_armor(void);
1038-extern bool curse_weapon_object(bool force, object_type *o_ptr);
1039-extern bool curse_weapon(bool force, int slot);
1040-extern bool brand_bolts(void);
10411036 extern bool polymorph_monster(POSITION y, POSITION x);
10421037 extern bool dimension_door(void);
10431038 extern bool mirror_tunnel(void);
--- a/src/realm-nature.c
+++ b/src/realm-nature.c
@@ -3,6 +3,7 @@
33 #include "projection.h"
44 #include "spells-summon.h"
55 #include "spells-status.h"
6+#include "spells-object.h"
67 #include "avatar.h"
78
89
--- a/src/spells-object.c
+++ b/src/spells-object.c
@@ -3,6 +3,7 @@
33 #include "spells-object.h"
44 #include "object-hook.h"
55 #include "player-status.h"
6+#include "avatar.h"
67
78
89 typedef struct
@@ -421,7 +422,6 @@ void amusement(POSITION y1, POSITION x1, int num, bool known)
421422 /* Paranoia - reroll if nothing */
422423 if (!(i_ptr->k_idx)) continue;
423424
424- /* Drop the object */
425425 (void)drop_near(i_ptr, -1, y1, x1);
426426
427427 num--;
@@ -462,7 +462,234 @@ void acquirement(POSITION y1, POSITION x1, int num, bool great, bool special, bo
462462 object_known(i_ptr);
463463 }
464464
465- /* Drop the object */
466465 (void)drop_near(i_ptr, -1, y1, x1);
467466 }
468467 }
468+
469+/*!
470+ * @brief 防具呪縛処理 /
471+ * Curse the players armor
472+ * @return 実際に呪縛されたらTRUEを返す
473+ */
474+bool curse_armor(void)
475+{
476+ int i;
477+ object_type *o_ptr;
478+
479+ GAME_TEXT o_name[MAX_NLEN];
480+
481+ /* Curse the body armor */
482+ o_ptr = &inventory[INVEN_BODY];
483+
484+ /* Nothing to curse */
485+ if (!o_ptr->k_idx) return (FALSE);
486+
487+ object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
488+
489+ /* Attempt a saving throw for artifacts */
490+ if (object_is_artifact(o_ptr) && (randint0(100) < 50))
491+ {
492+ /* Cool */
493+#ifdef JP
494+ msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
495+ "恐怖の暗黒オーラ", "防具", o_name);
496+#else
497+ msg_format("A %s tries to %s, but your %s resists the effects!",
498+ "terrible black aura", "surround your armor", o_name);
499+#endif
500+
501+ }
502+
503+ /* not artifact or failed save... */
504+ else
505+ {
506+ msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
507+ chg_virtue(V_ENCHANT, -5);
508+
509+ /* Blast the armor */
510+ o_ptr->name1 = 0;
511+ o_ptr->name2 = EGO_BLASTED;
512+ o_ptr->to_a = 0 - randint1(5) - randint1(5);
513+ o_ptr->to_h = 0;
514+ o_ptr->to_d = 0;
515+ o_ptr->ac = 0;
516+ o_ptr->dd = 0;
517+ o_ptr->ds = 0;
518+
519+ for (i = 0; i < TR_FLAG_SIZE; i++)
520+ o_ptr->art_flags[i] = 0;
521+
522+ /* Curse it */
523+ o_ptr->curse_flags = TRC_CURSED;
524+
525+ /* Break it */
526+ o_ptr->ident |= (IDENT_BROKEN);
527+ p_ptr->update |= (PU_BONUS | PU_MANA);
528+ p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
529+ }
530+
531+ return (TRUE);
532+}
533+
534+/*!
535+ * @brief 武器呪縛処理 /
536+ * Curse the players weapon
537+ * @param force 無条件に呪縛を行うならばTRUE
538+ * @param o_ptr 呪縛する武器のアイテム情報参照ポインタ
539+ * @return 実際に呪縛されたらTRUEを返す
540+ */
541+bool curse_weapon_object(bool force, object_type *o_ptr)
542+{
543+ int i;
544+ GAME_TEXT o_name[MAX_NLEN];
545+
546+ /* Nothing to curse */
547+ if (!o_ptr->k_idx) return (FALSE);
548+ object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
549+
550+ /* Attempt a saving throw */
551+ if (object_is_artifact(o_ptr) && (randint0(100) < 50) && !force)
552+ {
553+ /* Cool */
554+#ifdef JP
555+ msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
556+ "恐怖の暗黒オーラ", "武器", o_name);
557+#else
558+ msg_format("A %s tries to %s, but your %s resists the effects!",
559+ "terrible black aura", "surround your weapon", o_name);
560+#endif
561+ }
562+
563+ /* not artifact or failed save... */
564+ else
565+ {
566+ if (!force) msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
567+ chg_virtue(V_ENCHANT, -5);
568+
569+ /* Shatter the weapon */
570+ o_ptr->name1 = 0;
571+ o_ptr->name2 = EGO_SHATTERED;
572+ o_ptr->to_h = 0 - randint1(5) - randint1(5);
573+ o_ptr->to_d = 0 - randint1(5) - randint1(5);
574+ o_ptr->to_a = 0;
575+ o_ptr->ac = 0;
576+ o_ptr->dd = 0;
577+ o_ptr->ds = 0;
578+
579+ for (i = 0; i < TR_FLAG_SIZE; i++)
580+ o_ptr->art_flags[i] = 0;
581+
582+ /* Curse it */
583+ o_ptr->curse_flags = TRC_CURSED;
584+
585+ /* Break it */
586+ o_ptr->ident |= (IDENT_BROKEN);
587+ p_ptr->update |= (PU_BONUS | PU_MANA);
588+ p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
589+ }
590+
591+ return (TRUE);
592+}
593+
594+/*!
595+ * @brief 武器呪縛処理のメインルーチン /
596+ * Curse the players weapon
597+ * @param force 無条件に呪縛を行うならばTRUE
598+ * @param slot 呪縛する武器の装備スロット
599+ * @return 実際に呪縛されたらTRUEを返す
600+ */
601+bool curse_weapon(bool force, int slot)
602+{
603+ /* Curse the weapon */
604+ return curse_weapon_object(force, &inventory[slot]);
605+}
606+
607+
608+/*!
609+ * @brief 防具の錆止め防止処理
610+ * @return ターン消費を要する処理を行ったならばTRUEを返す
611+ */
612+bool rustproof(void)
613+{
614+ OBJECT_IDX item;
615+ object_type *o_ptr;
616+ GAME_TEXT o_name[MAX_NLEN];
617+ concptr q, s;
618+
619+ /* Select a piece of armour */
620+ item_tester_hook = object_is_armour;
621+
622+ q = _("どの防具に錆止めをしますか?", "Rustproof which piece of armour? ");
623+ s = _("錆止めできるものがありません。", "You have nothing to rustproof.");
624+
625+ o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
626+ if (!o_ptr) return FALSE;
627+
628+ object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
629+
630+ add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
631+
632+ if ((o_ptr->to_a < 0) && !object_is_cursed(o_ptr))
633+ {
634+#ifdef JP
635+ msg_format("%sは新品同様になった!", o_name);
636+#else
637+ msg_format("%s %s look%s as good as new!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
638+#endif
639+
640+ o_ptr->to_a = 0;
641+ }
642+
643+#ifdef JP
644+ msg_format("%sは腐食しなくなった。", o_name);
645+#else
646+ msg_format("%s %s %s now protected against corrosion.", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "are" : "is"));
647+#endif
648+
649+ calc_android_exp();
650+ return TRUE;
651+}
652+
653+/*!
654+ * @brief ボルトのエゴ化処理(火炎エゴのみ) /
655+ * Enchant some bolts
656+ * @return 常にTRUEを返す
657+ */
658+bool brand_bolts(void)
659+{
660+ int i;
661+
662+ /* Use the first acceptable bolts */
663+ for (i = 0; i < INVEN_PACK; i++)
664+ {
665+ object_type *o_ptr = &inventory[i];
666+
667+ /* Skip non-bolts */
668+ if (o_ptr->tval != TV_BOLT) continue;
669+
670+ /* Skip artifacts and ego-items */
671+ if (object_is_artifact(o_ptr) || object_is_ego(o_ptr))
672+ continue;
673+
674+ /* Skip cursed/broken items */
675+ if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) continue;
676+
677+ /* Randomize */
678+ if (randint0(100) < 75) continue;
679+
680+ msg_print(_("クロスボウの矢が炎のオーラに包まれた!", "Your bolts are covered in a fiery aura!"));
681+
682+ /* Ego-item */
683+ o_ptr->name2 = EGO_FLAME;
684+ enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
685+ return (TRUE);
686+ }
687+
688+ if (flush_failure) flush();
689+
690+ /* Fail */
691+ msg_print(_("炎で強化するのに失敗した。", "The fiery enchantment failed."));
692+
693+ return (TRUE);
694+}
695+
--- a/src/spells-object.h
+++ b/src/spells-object.h
@@ -4,3 +4,8 @@ extern bool create_ammo(void);
44 extern bool import_magic_device(void);
55 extern void amusement(POSITION y1, POSITION x1, int num, bool known);
66 extern void acquirement(POSITION y1, POSITION x1, int num, bool great, bool special, bool known);
7+extern bool curse_armor(void);
8+extern bool curse_weapon_object(bool force, object_type *o_ptr);
9+extern bool curse_weapon(bool force, int slot);
10+extern bool rustproof(void);
11+extern bool brand_bolts(void);
--- a/src/spells3.c
+++ b/src/spells3.c
@@ -3851,237 +3851,6 @@ void print_spells(SPELL_IDX target_spell, SPELL_IDX *spells, int num, TERM_LEN y
38513851 prt("", y + i + 1, x);
38523852 }
38533853
3854-
3855-
3856-/*!
3857- * @brief 防具の錆止め防止処理
3858- * @return ターン消費を要する処理を行ったならばTRUEを返す
3859- */
3860-bool rustproof(void)
3861-{
3862- OBJECT_IDX item;
3863- object_type *o_ptr;
3864- GAME_TEXT o_name[MAX_NLEN];
3865- concptr q, s;
3866-
3867- /* Select a piece of armour */
3868- item_tester_hook = object_is_armour;
3869-
3870- q = _("どの防具に錆止めをしますか?", "Rustproof which piece of armour? ");
3871- s = _("錆止めできるものがありません。", "You have nothing to rustproof.");
3872-
3873- o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
3874- if (!o_ptr) return FALSE;
3875-
3876- object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3877-
3878- add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
3879-
3880- if ((o_ptr->to_a < 0) && !object_is_cursed(o_ptr))
3881- {
3882-#ifdef JP
3883- msg_format("%sは新品同様になった!",o_name);
3884-#else
3885- msg_format("%s %s look%s as good as new!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
3886-#endif
3887-
3888- o_ptr->to_a = 0;
3889- }
3890-
3891-#ifdef JP
3892- msg_format("%sは腐食しなくなった。", o_name);
3893-#else
3894- msg_format("%s %s %s now protected against corrosion.", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "are" : "is"));
3895-#endif
3896-
3897- calc_android_exp();
3898- return TRUE;
3899-}
3900-
3901-
3902-/*!
3903- * @brief 防具呪縛処理 /
3904- * Curse the players armor
3905- * @return 実際に呪縛されたらTRUEを返す
3906- */
3907-bool curse_armor(void)
3908-{
3909- int i;
3910- object_type *o_ptr;
3911-
3912- GAME_TEXT o_name[MAX_NLEN];
3913-
3914- /* Curse the body armor */
3915- o_ptr = &inventory[INVEN_BODY];
3916-
3917- /* Nothing to curse */
3918- if (!o_ptr->k_idx) return (FALSE);
3919-
3920- object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
3921-
3922- /* Attempt a saving throw for artifacts */
3923- if (object_is_artifact(o_ptr) && (randint0(100) < 50))
3924- {
3925- /* Cool */
3926-#ifdef JP
3927- msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
3928- "恐怖の暗黒オーラ", "防具", o_name);
3929-#else
3930- msg_format("A %s tries to %s, but your %s resists the effects!",
3931- "terrible black aura", "surround your armor", o_name);
3932-#endif
3933-
3934- }
3935-
3936- /* not artifact or failed save... */
3937- else
3938- {
3939- msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
3940- chg_virtue(V_ENCHANT, -5);
3941-
3942- /* Blast the armor */
3943- o_ptr->name1 = 0;
3944- o_ptr->name2 = EGO_BLASTED;
3945- o_ptr->to_a = 0 - randint1(5) - randint1(5);
3946- o_ptr->to_h = 0;
3947- o_ptr->to_d = 0;
3948- o_ptr->ac = 0;
3949- o_ptr->dd = 0;
3950- o_ptr->ds = 0;
3951-
3952- for (i = 0; i < TR_FLAG_SIZE; i++)
3953- o_ptr->art_flags[i] = 0;
3954-
3955- /* Curse it */
3956- o_ptr->curse_flags = TRC_CURSED;
3957-
3958- /* Break it */
3959- o_ptr->ident |= (IDENT_BROKEN);
3960- p_ptr->update |= (PU_BONUS | PU_MANA);
3961- p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
3962- }
3963-
3964- return (TRUE);
3965-}
3966-
3967-/*!
3968- * @brief 武器呪縛処理 /
3969- * Curse the players weapon
3970- * @param force 無条件に呪縛を行うならばTRUE
3971- * @param o_ptr 呪縛する武器のアイテム情報参照ポインタ
3972- * @return 実際に呪縛されたらTRUEを返す
3973- */
3974-bool curse_weapon_object(bool force, object_type *o_ptr)
3975-{
3976- int i;
3977- GAME_TEXT o_name[MAX_NLEN];
3978-
3979- /* Nothing to curse */
3980- if (!o_ptr->k_idx) return (FALSE);
3981- object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
3982-
3983- /* Attempt a saving throw */
3984- if (object_is_artifact(o_ptr) && (randint0(100) < 50) && !force)
3985- {
3986- /* Cool */
3987-#ifdef JP
3988- msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
3989- "恐怖の暗黒オーラ", "武器", o_name);
3990-#else
3991- msg_format("A %s tries to %s, but your %s resists the effects!",
3992- "terrible black aura", "surround your weapon", o_name);
3993-#endif
3994- }
3995-
3996- /* not artifact or failed save... */
3997- else
3998- {
3999- if (!force) msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
4000- chg_virtue(V_ENCHANT, -5);
4001-
4002- /* Shatter the weapon */
4003- o_ptr->name1 = 0;
4004- o_ptr->name2 = EGO_SHATTERED;
4005- o_ptr->to_h = 0 - randint1(5) - randint1(5);
4006- o_ptr->to_d = 0 - randint1(5) - randint1(5);
4007- o_ptr->to_a = 0;
4008- o_ptr->ac = 0;
4009- o_ptr->dd = 0;
4010- o_ptr->ds = 0;
4011-
4012- for (i = 0; i < TR_FLAG_SIZE; i++)
4013- o_ptr->art_flags[i] = 0;
4014-
4015- /* Curse it */
4016- o_ptr->curse_flags = TRC_CURSED;
4017-
4018- /* Break it */
4019- o_ptr->ident |= (IDENT_BROKEN);
4020- p_ptr->update |= (PU_BONUS | PU_MANA);
4021- p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
4022- }
4023-
4024- return (TRUE);
4025-}
4026-
4027-/*!
4028- * @brief 武器呪縛処理のメインルーチン /
4029- * Curse the players weapon
4030- * @param force 無条件に呪縛を行うならばTRUE
4031- * @param slot 呪縛する武器の装備スロット
4032- * @return 実際に呪縛されたらTRUEを返す
4033- */
4034-bool curse_weapon(bool force, int slot)
4035-{
4036- /* Curse the weapon */
4037- return curse_weapon_object(force, &inventory[slot]);
4038-}
4039-
4040-
4041-/*!
4042- * @brief ボルトのエゴ化処理(火炎エゴのみ) /
4043- * Enchant some bolts
4044- * @return 常にTRUEを返す
4045- */
4046-bool brand_bolts(void)
4047-{
4048- int i;
4049-
4050- /* Use the first acceptable bolts */
4051- for (i = 0; i < INVEN_PACK; i++)
4052- {
4053- object_type *o_ptr = &inventory[i];
4054-
4055- /* Skip non-bolts */
4056- if (o_ptr->tval != TV_BOLT) continue;
4057-
4058- /* Skip artifacts and ego-items */
4059- if (object_is_artifact(o_ptr) || object_is_ego(o_ptr))
4060- continue;
4061-
4062- /* Skip cursed/broken items */
4063- if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) continue;
4064-
4065- /* Randomize */
4066- if (randint0(100) < 75) continue;
4067-
4068- msg_print(_("クロスボウの矢が炎のオーラに包まれた!", "Your bolts are covered in a fiery aura!"));
4069-
4070- /* Ego-item */
4071- o_ptr->name2 = EGO_FLAME;
4072- enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
4073- return (TRUE);
4074- }
4075-
4076- if (flush_failure) flush();
4077-
4078- /* Fail */
4079- msg_print(_("炎で強化するのに失敗した。", "The fiery enchantment failed."));
4080-
4081- return (TRUE);
4082-}
4083-
4084-
40853854 /*!
40863855 * @brief 変身処理向けにモンスターの近隣レベル帯モンスターを返す /
40873856 * Helper function -- return a "nearby" race for polymorphing
Show on old repository browser