OSDN Git Service

Merge pull request #163 from backwardsEric/english-an-equipment
[hengbandforosx/hengbandosx.git] / src / mind / mind-mirror-master.c
1 #include "mind/mind-mirror-master.h"
2 #include "cmd-action/cmd-pet.h"
3 #include "core/disturbance.h"
4 #include "core/player-redraw-types.h"
5 #include "core/player-update-types.h"
6 #include "core/stuff-handler.h"
7 #include "effect/effect-characteristics.h"
8 #include "effect/effect-feature.h"
9 #include "effect/effect-item.h"
10 #include "effect/effect-monster.h"
11 #include "effect/effect-processor.h"
12 #include "effect/spells-effect-util.h"
13 #include "floor/cave.h"
14 #include "game-option/disturbance-options.h"
15 #include "game-option/map-screen-options.h"
16 #include "game-option/special-options.h"
17 #include "grid/feature.h"
18 #include "io/cursor.h"
19 #include "io/screen-util.h"
20 #include "mind/mind-magic-resistance.h"
21 #include "mind/mind-numbers.h"
22 #include "spell-kind/spells-detection.h"
23 #include "spell-kind/spells-floor.h"
24 #include "spell-kind/spells-launcher.h"
25 #include "spell-kind/spells-lite.h"
26 #include "spell-kind/spells-sight.h"
27 #include "spell-kind/spells-teleport.h"
28 #include "spell-kind/spells-world.h"
29 #include "spell/spell-types.h"
30 #include "status/body-improvement.h"
31 #include "status/buff-setter.h"
32 #include "status/sight-setter.h"
33 #include "system/floor-type-definition.h"
34 #include "target/grid-selector.h"
35 #include "target/projection-path-calculator.h"
36 #include "target/target-getter.h"
37 #include "term/gameterm.h"
38 #include "util/bit-flags-calculator.h"
39 #include "view/display-messages.h"
40 #include "world/world.h"
41
42 /*
43  * @brief Multishadow effects is determined by turn
44  */
45 bool check_multishadow(player_type *creature_ptr) { return (creature_ptr->multishadow != 0) && ((current_world_ptr->game_turn & 1) != 0); }
46
47 /*!
48  * 静水
49  * @param creature_ptr プレーヤーへの参照ポインタ
50  * @return ペットを操っている場合を除きTRUE
51  */
52 bool mirror_concentration(player_type *creature_ptr)
53 {
54     if (total_friends) {
55         msg_print(_("今はペットを操ることに集中していないと。", "Your pets demand all of your attention."));
56         return FALSE;
57     }
58
59     if (!is_mirror_grid(&creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x])) {
60         msg_print(_("鏡の上でないと集中できない!", "There's no mirror here!"));
61         return TRUE;
62     }
63
64     msg_print(_("少し頭がハッキリした。", "You feel your head clear a little."));
65
66     creature_ptr->csp += (5 + creature_ptr->lev * creature_ptr->lev / 100);
67     if (creature_ptr->csp >= creature_ptr->msp) {
68         creature_ptr->csp = creature_ptr->msp;
69         creature_ptr->csp_frac = 0;
70     }
71
72     creature_ptr->redraw |= PR_MANA;
73     return TRUE;
74 }
75
76 /*!
77  * @brief 全鏡の消去 / Remove all mirrors in this floor
78  * @param caster_ptr プレーヤーへの参照ポインタ
79  * @param explode 爆発処理を伴うならばTRUE
80  * @return なし
81  */
82 void remove_all_mirrors(player_type *caster_ptr, bool explode)
83 {
84     for (POSITION x = 0; x < caster_ptr->current_floor_ptr->width; x++) {
85         for (POSITION y = 0; y < caster_ptr->current_floor_ptr->height; y++) {
86             if (!is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[y][x]))
87                 continue;
88
89             remove_mirror(caster_ptr, y, x);
90             if (!explode)
91                 continue;
92
93             project(caster_ptr, 0, 2, y, x, caster_ptr->lev / 2 + 5, GF_SHARDS,
94                 (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
95         }
96     }
97 }
98
99 /*!
100  * @brief 鏡魔法「封魔結界」の効果処理
101  * @param dam ダメージ量
102  * @return 効果があったらTRUEを返す
103  */
104 bool binding_field(player_type *caster_ptr, HIT_POINT dam)
105 {
106     POSITION mirror_x[10], mirror_y[10]; /* 鏡はもっと少ない */
107     int mirror_num = 0; /* 鏡の数 */
108     int msec = delay_factor * delay_factor * delay_factor;
109
110     /* 三角形の頂点 */
111     POSITION point_x[3];
112     POSITION point_y[3];
113
114     /* Default target of monsterspell is player */
115     monster_target_y = caster_ptr->y;
116     monster_target_x = caster_ptr->x;
117
118     for (POSITION x = 0; x < caster_ptr->current_floor_ptr->width; x++) {
119         for (POSITION y = 0; y < caster_ptr->current_floor_ptr->height; y++) {
120             if (is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[y][x]) && distance(caster_ptr->y, caster_ptr->x, y, x) <= get_max_range(caster_ptr)
121                 && distance(caster_ptr->y, caster_ptr->x, y, x) != 0 && player_has_los_bold(caster_ptr, y, x)
122                 && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x)) {
123                 mirror_y[mirror_num] = y;
124                 mirror_x[mirror_num] = x;
125                 mirror_num++;
126             }
127         }
128     }
129
130     if (mirror_num < 2)
131         return FALSE;
132
133     point_x[0] = randint0(mirror_num);
134     do {
135         point_x[1] = randint0(mirror_num);
136     } while (point_x[0] == point_x[1]);
137
138     point_y[0] = mirror_y[point_x[0]];
139     point_x[0] = mirror_x[point_x[0]];
140     point_y[1] = mirror_y[point_x[1]];
141     point_x[1] = mirror_x[point_x[1]];
142     point_y[2] = caster_ptr->y;
143     point_x[2] = caster_ptr->x;
144
145     POSITION x = point_x[0] + point_x[1] + point_x[2];
146     POSITION y = point_y[0] + point_y[1] + point_y[2];
147
148     POSITION centersign = (point_x[0] * 3 - x) * (point_y[1] * 3 - y) - (point_y[0] * 3 - y) * (point_x[1] * 3 - x);
149     if (centersign == 0)
150         return FALSE;
151
152     POSITION x1 = point_x[0] < point_x[1] ? point_x[0] : point_x[1];
153     x1 = x1 < point_x[2] ? x1 : point_x[2];
154     POSITION y1 = point_y[0] < point_y[1] ? point_y[0] : point_y[1];
155     y1 = y1 < point_y[2] ? y1 : point_y[2];
156
157     POSITION x2 = point_x[0] > point_x[1] ? point_x[0] : point_x[1];
158     x2 = x2 > point_x[2] ? x2 : point_x[2];
159     POSITION y2 = point_y[0] > point_y[1] ? point_y[0] : point_y[1];
160     y2 = y2 > point_y[2] ? y2 : point_y[2];
161
162     for (y = y1; y <= y2; y++) {
163         for (x = x1; x <= x2; x++) {
164             if (centersign * ((point_x[0] - x) * (point_y[1] - y) - (point_y[0] - y) * (point_x[1] - x)) >= 0
165                 && centersign * ((point_x[1] - x) * (point_y[2] - y) - (point_y[1] - y) * (point_x[2] - x)) >= 0
166                 && centersign * ((point_x[2] - x) * (point_y[0] - y) - (point_y[2] - y) * (point_x[0] - x)) >= 0) {
167                 if (player_has_los_bold(caster_ptr, y, x) && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x)) {
168                     if (!(caster_ptr->blind) && panel_contains(y, x)) {
169                         u16b p = bolt_pict(y, x, y, x, GF_MANA);
170                         print_rel(caster_ptr, PICT_C(p), PICT_A(p), y, x);
171                         move_cursor_relative(y, x);
172                         if (fresh_after) {
173                             term_fresh();
174                             term_xtra(TERM_XTRA_DELAY, msec);
175                         }
176                     }
177                 }
178             }
179         }
180     }
181
182     for (y = y1; y <= y2; y++) {
183         for (x = x1; x <= x2; x++) {
184             if (centersign * ((point_x[0] - x) * (point_y[1] - y) - (point_y[0] - y) * (point_x[1] - x)) >= 0
185                 && centersign * ((point_x[1] - x) * (point_y[2] - y) - (point_y[1] - y) * (point_x[2] - x)) >= 0
186                 && centersign * ((point_x[2] - x) * (point_y[0] - y) - (point_y[2] - y) * (point_x[0] - x)) >= 0) {
187                 if (player_has_los_bold(caster_ptr, y, x) && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x)) {
188                     (void)affect_feature(caster_ptr, 0, 0, y, x, dam, GF_MANA);
189                 }
190             }
191         }
192     }
193
194     for (y = y1; y <= y2; y++) {
195         for (x = x1; x <= x2; x++) {
196             if (centersign * ((point_x[0] - x) * (point_y[1] - y) - (point_y[0] - y) * (point_x[1] - x)) >= 0
197                 && centersign * ((point_x[1] - x) * (point_y[2] - y) - (point_y[1] - y) * (point_x[2] - x)) >= 0
198                 && centersign * ((point_x[2] - x) * (point_y[0] - y) - (point_y[2] - y) * (point_x[0] - x)) >= 0) {
199                 if (player_has_los_bold(caster_ptr, y, x) && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x)) {
200                     (void)affect_item(caster_ptr, 0, 0, y, x, dam, GF_MANA);
201                 }
202             }
203         }
204     }
205
206     for (y = y1; y <= y2; y++) {
207         for (x = x1; x <= x2; x++) {
208             if (centersign * ((point_x[0] - x) * (point_y[1] - y) - (point_y[0] - y) * (point_x[1] - x)) >= 0
209                 && centersign * ((point_x[1] - x) * (point_y[2] - y) - (point_y[1] - y) * (point_x[2] - x)) >= 0
210                 && centersign * ((point_x[2] - x) * (point_y[0] - y) - (point_y[2] - y) * (point_x[0] - x)) >= 0) {
211                 if (player_has_los_bold(caster_ptr, y, x) && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x)) {
212                     (void)affect_monster(caster_ptr, 0, 0, y, x, dam, GF_MANA, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP), TRUE);
213                 }
214             }
215         }
216     }
217
218     if (one_in_(7)) {
219         msg_print(_("鏡が結界に耐えきれず、壊れてしまった。", "The field broke a mirror"));
220         remove_mirror(caster_ptr, point_y[0], point_x[0]);
221     }
222
223     return TRUE;
224 }
225
226 /*!
227  * @brief 鏡魔法「鏡の封印」の効果処理
228  * @param dam ダメージ量
229  * @return 効果があったらTRUEを返す
230  */
231 void seal_of_mirror(player_type *caster_ptr, HIT_POINT dam)
232 {
233     for (POSITION x = 0; x < caster_ptr->current_floor_ptr->width; x++) {
234         for (POSITION y = 0; y < caster_ptr->current_floor_ptr->height; y++) {
235             if (!is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[y][x]))
236                 continue;
237
238             if (!affect_monster(caster_ptr, 0, 0, y, x, dam, GF_GENOCIDE, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP), TRUE))
239                 continue;
240
241             if (!caster_ptr->current_floor_ptr->grid_array[y][x].m_idx) {
242                 remove_mirror(caster_ptr, y, x);
243             }
244         }
245     }
246 }
247
248 /*!
249  * 幻惑の光 @ 鏡使いだけでなく混沌の戦士も使える
250  * @param creature_ptr プレーヤーへの参照ポインタ
251  * @return 常にTRUE
252  */
253 bool confusing_light(player_type *creature_ptr)
254 {
255     msg_print(_("辺りを睨んだ...", "You glare at nearby monsters..."));
256     slow_monsters(creature_ptr, creature_ptr->lev);
257     stun_monsters(creature_ptr, creature_ptr->lev * 4);
258     confuse_monsters(creature_ptr, creature_ptr->lev * 4);
259     turn_monsters(creature_ptr, creature_ptr->lev * 4);
260     stasis_monsters(creature_ptr, creature_ptr->lev * 4);
261     return TRUE;
262 }
263
264 /*!
265  * @brief 鏡設置処理
266  * @return 実際に設置が行われた場合TRUEを返す
267  */
268 bool place_mirror(player_type *caster_ptr)
269 {
270     if (!cave_clean_bold(caster_ptr->current_floor_ptr, caster_ptr->y, caster_ptr->x)) {
271         msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
272         return FALSE;
273     }
274
275     /* Create a mirror */
276     caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].info |= CAVE_OBJECT;
277     caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].mimic = feat_mirror;
278
279     /* Turn on the light */
280     caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].info |= CAVE_GLOW;
281
282     note_spot(caster_ptr, caster_ptr->y, caster_ptr->x);
283     lite_spot(caster_ptr, caster_ptr->y, caster_ptr->x);
284     update_local_illumination(caster_ptr, caster_ptr->y, caster_ptr->x);
285
286     return TRUE;
287 }
288
289 /*!
290  * @brief 鏡抜け処理のメインルーチン /
291  * Mirror Master's Dimension Door
292  * @param caster_ptr プレーヤーへの参照ポインタ
293  * @return ターンを消費した場合TRUEを返す
294  */
295 bool mirror_tunnel(player_type *caster_ptr)
296 {
297     POSITION x = 0, y = 0;
298     if (!tgt_pt(caster_ptr, &x, &y))
299         return FALSE;
300     if (exe_dimension_door(caster_ptr, x, y))
301         return TRUE;
302
303     msg_print(_("鏡の世界をうまく通れなかった!", "You could not enter the mirror!"));
304     return TRUE;
305 }
306
307 /*
308  * Set "multishadow", notice observable changes
309  */
310 bool set_multishadow(player_type *creature_ptr, TIME_EFFECT v, bool do_dec)
311 {
312     bool notice = FALSE;
313     v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
314
315     if (creature_ptr->is_dead)
316         return FALSE;
317
318     if (v) {
319         if (creature_ptr->multishadow && !do_dec) {
320             if (creature_ptr->multishadow > v)
321                 return FALSE;
322         } else if (!creature_ptr->multishadow) {
323             msg_print(_("あなたの周りに幻影が生まれた。", "Your Shadow enveloped you."));
324             notice = TRUE;
325         }
326     } else {
327         if (creature_ptr->multishadow) {
328             msg_print(_("幻影が消えた。", "Your Shadow disappears."));
329             notice = TRUE;
330         }
331     }
332
333     creature_ptr->multishadow = v;
334     creature_ptr->redraw |= (PR_STATUS);
335
336     if (!notice)
337         return FALSE;
338
339     if (disturb_state)
340         disturb(creature_ptr, FALSE, FALSE);
341     creature_ptr->update |= (PU_BONUS);
342     handle_stuff(creature_ptr);
343     return TRUE;
344 }
345
346 /*!
347  * @brief 一時的破片のオーラの継続時間をセットする / Set "dustrobe", notice observable changes
348  * @param v 継続時間
349  * @param do_dec 現在の継続時間より長い値のみ上書きする
350  * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。
351  */
352 bool set_dustrobe(player_type *creature_ptr, TIME_EFFECT v, bool do_dec)
353 {
354     bool notice = FALSE;
355     v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
356
357     if (creature_ptr->is_dead)
358         return FALSE;
359
360     if (v) {
361         if (creature_ptr->dustrobe && !do_dec) {
362             if (creature_ptr->dustrobe > v)
363                 return FALSE;
364         } else if (!creature_ptr->dustrobe) {
365             msg_print(_("体が鏡のオーラで覆われた。", "You are enveloped by mirror shards."));
366             notice = TRUE;
367         }
368     } else {
369         if (creature_ptr->dustrobe) {
370             msg_print(_("鏡のオーラが消えた。", "The mirror shards disappear."));
371             notice = TRUE;
372         }
373     }
374
375     creature_ptr->dustrobe = v;
376     creature_ptr->redraw |= (PR_STATUS);
377
378     if (!notice)
379         return FALSE;
380
381     if (disturb_state)
382         disturb(creature_ptr, FALSE, FALSE);
383     creature_ptr->update |= (PU_BONUS);
384     handle_stuff(creature_ptr);
385     return TRUE;
386 }
387
388 /*!
389  * @brief 現在フロアに存在している鏡の数を数える / calculate mirrors
390  * @return 鏡の枚数
391  */
392 static int number_of_mirrors(floor_type *floor_ptr)
393 {
394     int val = 0;
395     for (POSITION x = 0; x < floor_ptr->width; x++) {
396         for (POSITION y = 0; y < floor_ptr->height; y++) {
397             if (is_mirror_grid(&floor_ptr->grid_array[y][x]))
398                 val++;
399         }
400     }
401
402     return val;
403 }
404
405 /*!
406  * @brief 鏡魔法の発動 /
407  * do_cmd_cast calls this function if the player's class is 'Mirror magic'.
408  * @param spell 発動する特殊技能のID
409  * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
410  */
411 bool cast_mirror_spell(player_type *caster_ptr, mind_mirror_master_type spell)
412 {
413     DIRECTION dir;
414     PLAYER_LEVEL plev = caster_ptr->lev;
415     int tmp;
416     TIME_EFFECT t;
417     POSITION x, y;
418     switch (spell) {
419     case MIRROR_SEEING:
420         tmp = is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x]) ? 4 : 0;
421         if (plev + tmp > 4)
422             detect_monsters_normal(caster_ptr, DETECT_RAD_DEFAULT);
423         if (plev + tmp > 18)
424             detect_monsters_invis(caster_ptr, DETECT_RAD_DEFAULT);
425         if (plev + tmp > 28)
426             set_tim_esp(caster_ptr, (TIME_EFFECT)plev, FALSE);
427         if (plev + tmp > 38)
428             map_area(caster_ptr, DETECT_RAD_MAP);
429         if (tmp == 0 && plev < 5) {
430             msg_print(_("鏡がなくて集中できなかった!", "You need a mirror to concentrate!"));
431         }
432         break;
433     case MAKE_MIRROR:
434         if (number_of_mirrors(caster_ptr->current_floor_ptr) < 4 + plev / 10)
435             place_mirror(caster_ptr);
436         else
437             msg_format(_("これ以上鏡は制御できない!", "There are too many mirrors to control!"));
438
439         break;
440     case DRIP_LIGHT:
441         if (!get_aim_dir(caster_ptr, &dir))
442             return FALSE;
443
444         if (plev > 9 && is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x]))
445             fire_beam(caster_ptr, GF_LITE, dir, damroll(3 + ((plev - 1) / 5), 4));
446         else
447             fire_bolt(caster_ptr, GF_LITE, dir, damroll(3 + ((plev - 1) / 5), 4));
448
449         break;
450     case WRAPPED_MIRROR:
451         teleport_player(caster_ptr, 10, TELEPORT_SPONTANEOUS);
452         break;
453     case MIRROR_LIGHT:
454         (void)lite_area(caster_ptr, damroll(2, (plev / 2)), (plev / 10) + 1);
455         break;
456     case WANDERING_MIRROR:
457         teleport_player(caster_ptr, plev * 5, TELEPORT_SPONTANEOUS);
458         break;
459     case ROBE_DUST:
460         set_dustrobe(caster_ptr, 20 + randint1(20), FALSE);
461         break;
462     case BANISHING_MIRROR:
463         if (!get_aim_dir(caster_ptr, &dir))
464             return FALSE;
465
466         (void)fire_beam(caster_ptr, GF_AWAY_ALL, dir, plev);
467         break;
468     case MIRROR_CRASHING:
469         if (!get_aim_dir(caster_ptr, &dir))
470             return FALSE;
471
472         fire_ball(caster_ptr, GF_SHARDS, dir, damroll(8 + ((plev - 5) / 4), 8), (plev > 20 ? (plev - 20) / 8 + 1 : 0));
473         break;
474     case SLEEPING_MIRROR:
475         for (x = 0; x < caster_ptr->current_floor_ptr->width; x++)
476             for (y = 0; y < caster_ptr->current_floor_ptr->height; y++)
477                 if (is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[y][x]))
478                     project(caster_ptr, 0, 2, y, x, (HIT_POINT)plev, GF_OLD_SLEEP,
479                         (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
480
481         break;
482     case SEEKER_RAY:
483         if (!get_aim_dir(caster_ptr, &dir))
484             return FALSE;
485
486         fire_beam(caster_ptr, GF_SEEKER, dir, damroll(11 + (plev - 5) / 4, 8));
487         break;
488     case SEALING_MIRROR:
489         seal_of_mirror(caster_ptr, plev * 4 + 100);
490         break;
491     case WATER_SHIELD:
492         t = 20 + randint1(20);
493         set_shield(caster_ptr, t, FALSE);
494         if (plev > 31)
495             set_tim_reflect(caster_ptr, t, FALSE);
496
497         if (plev > 39)
498             set_resist_magic(caster_ptr, t, FALSE);
499
500         break;
501     case SUPER_RAY:
502         if (!get_aim_dir(caster_ptr, &dir))
503             return FALSE;
504
505         fire_beam(caster_ptr, GF_SUPER_RAY, dir, 150 + randint1(2 * plev));
506         break;
507     case ILLUSION_LIGHT:
508         tmp = is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x]) ? 4 : 3;
509         slow_monsters(caster_ptr, plev);
510         stun_monsters(caster_ptr, plev * tmp * 2);
511         confuse_monsters(caster_ptr, plev * tmp);
512         turn_monsters(caster_ptr, plev * tmp);
513         stasis_monsters(caster_ptr, plev * tmp);
514         break;
515     case MIRROR_SHIFT:
516         if (!is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x])) {
517             msg_print(_("鏡の国の場所がわからない!", "You cannot find out where the mirror is!"));
518             break;
519         }
520
521         reserve_alter_reality(caster_ptr, randint0(21) + 15);
522         break;
523     case MIRROR_TUNNEL:
524         msg_print(_("鏡の世界を通り抜け…  ", "You try to enter the mirror..."));
525         return mirror_tunnel(caster_ptr);
526     case RECALL_MIRROR:
527         return recall_player(caster_ptr, randint0(21) + 15);
528     case MULTI_SHADOW:
529         set_multishadow(caster_ptr, 6 + randint1(6), FALSE);
530         break;
531     case BINDING_FIELD:
532         if (!binding_field(caster_ptr, plev * 11 + 5))
533             msg_print(_("適当な鏡を選べなかった!", "You were not able to choose suitable mirrors!"));
534
535         break;
536     case RUFFNOR_MIRROR:
537         (void)set_invuln(caster_ptr, randint1(4) + 4, FALSE);
538         break;
539     default:
540         msg_print(_("なに?", "Zap?"));
541         break;
542     }
543
544     caster_ptr->magic_num1[0] = 0;
545     return TRUE;
546 }