• R/O
  • HTTP
  • SSH
  • HTTPS

hengband: Commit

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


Commit MetaInfo

Revision78320a791eeb1c6e815a3caf3c00df0af497e7f8 (tree)
Time2019-02-20 23:45:48
AuthorDeskull <deskull@user...>
CommiterDeskull

Log Message

[Fix] #37353 term.c/h 追加のコミットし忘れ修正。 / Fix forgotten commit of term.c/h.

Change Summary

Incremental Difference

--- /dev/null
+++ b/src/term.c
@@ -0,0 +1,188 @@
1+#include "angband.h"
2+#include "term.h"
3+
4+/*!
5+ * @brief 万色表現用にランダムな色を選択する関数 /
6+ * Get a legal "multi-hued" color for drawing "spells"
7+ * @param max 色IDの最大値
8+ * @return 選択した色ID
9+ */
10+TERM_COLOR mh_attr(int max)
11+{
12+ switch (randint1(max))
13+ {
14+ case 1: return (TERM_RED);
15+ case 2: return (TERM_GREEN);
16+ case 3: return (TERM_BLUE);
17+ case 4: return (TERM_YELLOW);
18+ case 5: return (TERM_ORANGE);
19+ case 6: return (TERM_VIOLET);
20+ case 7: return (TERM_L_RED);
21+ case 8: return (TERM_L_GREEN);
22+ case 9: return (TERM_L_BLUE);
23+ case 10: return (TERM_UMBER);
24+ case 11: return (TERM_L_UMBER);
25+ case 12: return (TERM_SLATE);
26+ case 13: return (TERM_WHITE);
27+ case 14: return (TERM_L_WHITE);
28+ case 15: return (TERM_L_DARK);
29+ }
30+
31+ return (TERM_WHITE);
32+}
33+
34+
35+/*!
36+ * @brief 魔法属性に応じたエフェクトの色を返す /
37+ * Return a color to use for the bolt/ball spells
38+ * @param type 魔法属性
39+ * @return 対応する色ID
40+ */
41+TERM_COLOR spell_color(EFFECT_ID type)
42+{
43+ /* Check if A.B.'s new graphics should be used (rr9) */
44+ if (streq(ANGBAND_GRAF, "new") || streq(ANGBAND_GRAF, "ne2"))
45+ {
46+ /* Analyze */
47+ switch (type)
48+ {
49+ case GF_PSY_SPEAR: return (0x06);
50+ case GF_MISSILE: return (0x0F);
51+ case GF_ACID: return (0x04);
52+ case GF_ELEC: return (0x02);
53+ case GF_FIRE: return (0x00);
54+ case GF_COLD: return (0x01);
55+ case GF_POIS: return (0x03);
56+ case GF_HOLY_FIRE: return (0x00);
57+ case GF_HELL_FIRE: return (0x00);
58+ case GF_MANA: return (0x0E);
59+ /* by henkma */
60+ case GF_SEEKER: return (0x0E);
61+ case GF_SUPER_RAY: return (0x0E);
62+
63+ case GF_ARROW: return (0x0F);
64+ case GF_WATER: return (0x04);
65+ case GF_NETHER: return (0x07);
66+ case GF_CHAOS: return (mh_attr(15));
67+ case GF_DISENCHANT: return (0x05);
68+ case GF_NEXUS: return (0x0C);
69+ case GF_CONFUSION: return (mh_attr(4));
70+ case GF_SOUND: return (0x09);
71+ case GF_SHARDS: return (0x08);
72+ case GF_FORCE: return (0x09);
73+ case GF_INERTIAL: return (0x09);
74+ case GF_GRAVITY: return (0x09);
75+ case GF_TIME: return (0x09);
76+ case GF_LITE_WEAK: return (0x06);
77+ case GF_LITE: return (0x06);
78+ case GF_DARK_WEAK: return (0x07);
79+ case GF_DARK: return (0x07);
80+ case GF_PLASMA: return (0x0B);
81+ case GF_METEOR: return (0x00);
82+ case GF_ICE: return (0x01);
83+ case GF_ROCKET: return (0x0F);
84+ case GF_DEATH_RAY: return (0x07);
85+ case GF_NUKE: return (mh_attr(2));
86+ case GF_DISINTEGRATE: return (0x05);
87+ case GF_PSI:
88+ case GF_PSI_DRAIN:
89+ case GF_TELEKINESIS:
90+ case GF_DOMINATION:
91+ case GF_DRAIN_MANA:
92+ case GF_MIND_BLAST:
93+ case GF_BRAIN_SMASH:
94+ return (0x09);
95+ case GF_CAUSE_1:
96+ case GF_CAUSE_2:
97+ case GF_CAUSE_3:
98+ case GF_CAUSE_4: return (0x0E);
99+ case GF_HAND_DOOM: return (0x07);
100+ case GF_CAPTURE: return (0x0E);
101+ case GF_IDENTIFY: return (0x01);
102+ case GF_ATTACK: return (0x0F);
103+ case GF_PHOTO: return (0x06);
104+ }
105+ }
106+ /* Normal tiles or ASCII */
107+ else
108+ {
109+ TERM_COLOR a;
110+ SYMBOL_CODE c;
111+
112+ /* Lookup the default colors for this type */
113+ concptr s = quark_str(gf_color[type]);
114+
115+ if (!s) return (TERM_WHITE);
116+
117+ /* Pick a random color */
118+ c = s[randint0(strlen(s))];
119+
120+ /* Lookup this color */
121+ a = my_strchr(color_char, c) - color_char;
122+
123+ /* Invalid color (note check for < 0 removed, gave a silly
124+ * warning because bytes are always >= 0 -- RG) */
125+ if (a > 15) return (TERM_WHITE);
126+
127+ /* Use this color */
128+ return (a);
129+ }
130+
131+ /* Standard "color" */
132+ return (TERM_WHITE);
133+}
134+
135+
136+/*!
137+ * @brief 始点から終点にかけた方向毎にボルトのキャラクタを返す /
138+ * Find the attr/char pair to use for a spell effect
139+ * @param y 始点Y座標
140+ * @param x 始点X座標
141+ * @param ny 終点Y座標
142+ * @param nx 終点X座標
143+ * @param typ 魔法の効果属性
144+ * @return 方向キャラID
145+ * @details
146+ * <pre>
147+ * It is moving (or has moved) from (x,y) to (nx,ny).
148+ * If the distance is not "one", we (may) return "*".
149+ * </pre>
150+ */
151+u16b bolt_pict(POSITION y, POSITION x, POSITION ny, POSITION nx, EFFECT_ID typ)
152+{
153+ int base;
154+
155+ byte k;
156+
157+ TERM_COLOR a;
158+ SYMBOL_CODE c;
159+
160+ /* No motion (*) */
161+ if ((ny == y) && (nx == x)) base = 0x30;
162+
163+ /* Vertical (|) */
164+ else if (nx == x) base = 0x40;
165+
166+ /* Horizontal (-) */
167+ else if (ny == y) base = 0x50;
168+
169+ /* Diagonal (/) */
170+ else if ((ny - y) == (x - nx)) base = 0x60;
171+
172+ /* Diagonal (\) */
173+ else if ((ny - y) == (nx - x)) base = 0x70;
174+
175+ /* Weird (*) */
176+ else base = 0x30;
177+
178+ /* Basic spell color */
179+ k = spell_color(typ);
180+
181+ /* Obtain attr/char */
182+ a = misc_to_attr[base + k];
183+ c = misc_to_char[base + k];
184+
185+ /* Create pict */
186+ return (PICT(a, c));
187+}
188+
--- /dev/null
+++ b/src/term.h
@@ -0,0 +1,5 @@
1+#pragma once
2+
3+TERM_COLOR mh_attr(int max);
4+TERM_COLOR spell_color(EFFECT_ID type);
5+u16b bolt_pict(POSITION y, POSITION x, POSITION ny, POSITION nx, EFFECT_ID typ);
Show on old repository browser