X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Fmind.c;h=9783e009c0f9a9378c8a64ea8260cc32cecd448d;hb=8a1422ffd9d4ab98d0a9ed846cb74011a7ec6264;hp=a4b529815fad2bd57bc7fd307e654a0a5653a81c;hpb=2f0a3f4be0bb024ec1f57aa4063621978d6fa218;p=hengband%2Fhengband.git diff --git a/src/mind.c b/src/mind.c index a4b529815..9783e009c 100644 --- a/src/mind.c +++ b/src/mind.c @@ -1,15 +1,15 @@ /* File: mind.c */ -/* Purpose: Mindcrafter code */ - /* - * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke + * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke * - * This software may be copied and distributed for educational, research, and - * not for profit purposes provided that this copyright and statement are - * included in all such copies. + * This software may be copied and distributed for educational, research, + * and not for profit purposes provided that this copyright and statement + * are included in all such copies. Other copyrights may also apply. */ +/* Purpose: Mindcrafter code */ + #include "angband.h" #include "mindtips.h" @@ -322,9 +322,9 @@ void mindcraft_info(char *p, int use_mind, int power) case 11: sprintf(p, " %s%dd6", s_dam, plev / 2); break; case 12: sprintf(p, " %sd%d+%d", s_dam, plev * 3, plev * 3); break; #ifdef JP - case 13: sprintf(p, " ¹ÔÆ°:%d²ó", (p_ptr->csp + p_ptr->energy - 50)/100); break; + case 13: sprintf(p, " ¹ÔÆ°:%ld²ó", (p_ptr->csp + 100-p_ptr->energy_need - 50)/100); break; #else - case 13: sprintf(p, " %d acts.", (p_ptr->csp + p_ptr->energy - 50)/100); break; + case 13: sprintf(p, " %ld acts.", (p_ptr->csp + 100-p_ptr->energy_need - 50)/100); break; #endif } break; @@ -347,7 +347,7 @@ void mindcraft_info(char *p, int use_mind, int power) case 8: sprintf(p, " %s10d6+%d", s_dam, plev * 3 / 2 + boost * 3 / 5); break; case 9: break; #ifdef JP - case 10: sprintf(p, " ºÇÂç%dɤ", 1+boost/100); break; + case 10: sprintf(p, " ºÇÂç%dÂÎ", 1+boost/100); break; #else case 10: sprintf(p, " max %d", 1+boost/100); break; #endif @@ -524,15 +524,18 @@ void mindcraft_info(char *p, int use_mind, int power) #ifdef ALLOW_REPEAT /* TNB */ - /* Get the spell, if available */ - if (repeat_pull(sn)) + /* Get the spell, if available */ + if (repeat_pull(sn)) { - /* Verify the spell */ - if (mind_ptr->info[*sn].min_lev <= plev) - { - /* Success */ - return (TRUE); - } + /* Hack -- If requested INVEN_FORCE(1111), pull again */ + if (*sn == INVEN_FORCE) repeat_pull(sn); + + /* Verify the spell */ + if (mind_ptr->info[*sn].min_lev <= plev) + { + /* Success */ + return (TRUE); + } } #endif /* ALLOW_REPEAT -- TNB */ @@ -568,15 +571,15 @@ void mindcraft_info(char *p, int use_mind, int power) #else (void)strnfmt(out_val, 78, "(%^ss %c-%c, *=List, ESC=exit) Use which %s? ", #endif - p, I2A(0), I2A(num - 1), p); + p, I2A(0), I2A(num - 1), p); } if (use_menu && !only_browse) screen_save(); /* Get a spell from the user */ - choice= (always_show_list || use_menu) ? ESCAPE:1 ; - while (!flag) - { + choice= (always_show_list || use_menu) ? ESCAPE:1 ; + while (!flag) + { if(choice==ESCAPE) choice = ' '; else if( !get_com(out_val, &choice, TRUE) )break; @@ -588,7 +591,6 @@ void mindcraft_info(char *p, int use_mind, int power) { if (!only_browse) screen_load(); return (FALSE); - break; } case '8': @@ -610,6 +612,7 @@ void mindcraft_info(char *p, int use_mind, int power) case 'x': case 'X': case '\r': + case '\n': { i = menu_line - 1; ask = FALSE; @@ -692,9 +695,7 @@ put_str(format("Lv %s Fail Info", ((use_mind == MIND_BERSERKER) || (use_mind chance += 5 * (mana_cost - p_ptr->csp); } - if (p_ptr->pseikaku == SEIKAKU_NAMAKE) chance += 10; - if (p_ptr->pseikaku == SEIKAKU_KIREMONO) chance -= 3; - if ((p_ptr->pseikaku == SEIKAKU_GAMAN) || (p_ptr->pseikaku == SEIKAKU_CHIKARA)) chance++; + chance += p_ptr->to_m_chance; /* Extract the minimum failure rate */ minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]]; @@ -808,14 +809,10 @@ put_str(format("Lv %s Fail Info", ((use_mind == MIND_BERSERKER) || (use_mind if (redraw && !only_browse) screen_load(); /* Show choices */ - if (show_choices) - { - /* Update */ - p_ptr->window |= (PW_SPELL); + p_ptr->window |= (PW_SPELL); - /* Window stuff */ - window_stuff(); - } + /* Window stuff */ + window_stuff(); /* Abort if needed */ if (!flag) return (FALSE); @@ -852,7 +849,7 @@ static bool cast_mindcrafter_spell(int spell) { chg_virtue(V_KNOWLEDGE, 1); chg_virtue(V_ENLIGHTEN, 1); - wiz_lite(FALSE, FALSE); + wiz_lite(FALSE); } else if (plev > 19) map_area(DETECT_RAD_MAP); @@ -862,7 +859,7 @@ static bool cast_mindcrafter_spell(int spell) b = detect_monsters_normal(DETECT_RAD_DEFAULT); if (plev > 14) b |= detect_monsters_invis(DETECT_RAD_DEFAULT); if (plev > 4) { - b |= detect_traps(DETECT_RAD_DEFAULT); + b |= detect_traps(DETECT_RAD_DEFAULT, TRUE); b |= detect_doors(DETECT_RAD_DEFAULT); } } @@ -892,11 +889,11 @@ if (!b) msg_print(" break; case 2: /* Minor displace */ - teleport_player(10); + teleport_player(10, 0L); break; case 3: /* Major displace */ - teleport_player(plev * 5); + teleport_player(plev * 5, 0L); break; case 4: /* Domination */ @@ -933,7 +930,6 @@ if (!b) msg_print(" return psychometry(); else return ident_spell(FALSE); - break; case 8: /* Mindwave */ #ifdef JP @@ -957,7 +953,7 @@ msg_print(" * Only heal when Adrenalin Channeling is not active. We check * that by checking if the player isn't fast and 'heroed' atm. */ - if (!p_ptr->fast || !p_ptr->hero) + if (!IS_FAST() || !IS_HERO()) { hp_player(plev); } @@ -982,7 +978,7 @@ msg_print(" /* This is always a radius-0 ball now */ if (fire_ball(GF_PSI_DRAIN, dir, b, 0)) - p_ptr->energy -= randint1(150); + p_ptr->energy_need += randint1(150); break; case 12: /* psycho-spear */ @@ -1009,7 +1005,8 @@ msg_print(" #endif msg_print(NULL); - p_ptr->energy += (p_ptr->csp + 950); + /* Hack */ + p_ptr->energy_need -= 1000 + (100 + p_ptr->csp - 50)*TURNS_PER_TICK/10; /* Redraw map */ p_ptr->redraw |= (PR_MAP); @@ -1059,7 +1056,7 @@ static bool cast_force_spell(int spell) (void)lite_area(damroll(2, (plev / 2)), (plev / 10) + 1); break; case 2: - set_tim_ffall(randint1(30) + 30 + boost / 5, FALSE); + set_tim_levitation(randint1(30) + 30 + boost / 5, FALSE); break; case 3: project_length = plev / 8 + 3; @@ -1077,6 +1074,7 @@ static bool cast_force_spell(int spell) msg_print("You improved the Force."); #endif p_ptr->magic_num1[0] += (70 + plev); + p_ptr->update |= (PU_BONUS); if (randint1(p_ptr->magic_num1[0]) > (plev * 4 + 120)) { #ifdef JP @@ -1113,11 +1111,12 @@ static bool cast_force_spell(int spell) int oy = y, ox = x; int m_idx = cave[y][x].m_idx; monster_type *m_ptr = &m_list[m_idx]; + monster_race *r_ptr = &r_info[m_ptr->r_idx]; char m_name[80]; monster_desc(m_name, m_ptr, 0); - if (randint1(r_info[m_ptr->r_idx].level * 3 / 2) > randint0(dam / 2) + dam/2) + if (randint1(r_ptr->level * 3 / 2) > randint0(dam / 2) + dam/2) { #ifdef JP msg_format("%s¤ÏÈô¤Ð¤µ¤ì¤Ê¤«¤Ã¤¿¡£", m_name); @@ -1153,6 +1152,9 @@ static bool cast_force_spell(int spell) update_mon(m_idx, TRUE); lite_spot(oy, ox); lite_spot(ty, tx); + + if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK)) + p_ptr->update |= (PU_MON_LITE); } } } @@ -1164,44 +1166,14 @@ static bool cast_force_spell(int spell) break; case 9: { - monster_type *m_ptr; - char m_name[80]; + int m_idx; if (!target_set(TARGET_KILL)) return FALSE; - if (!cave[target_row][target_col].m_idx) break; - if (!los(py, px, target_row, target_col)) break; - m_ptr = &m_list[cave[target_row][target_col].m_idx]; - monster_desc(m_name, m_ptr, 0); - if (m_ptr->invulner) - { - m_ptr->invulner = 0; -#ifdef JP -msg_format("%s¤Ï¤â¤¦ÌµÅ¨¤Ç¤Ï¤Ê¤¤¡£", m_name); -#else - msg_format("%^s is no longer invulnerable.", m_name); -#endif - } - if (m_ptr->fast) - { - m_ptr->fast = 0; -#ifdef JP -msg_format("%s¤Ï¤â¤¦²Ã®¤µ¤ì¤Æ¤¤¤Ê¤¤¡£", m_name); -#else - msg_format("%^s is no longer fast.", m_name); -#endif - } - if (m_ptr->slow) - { - m_ptr->slow = 0; -#ifdef JP -msg_format("%s¤Ï¤â¤¦¸ºÂ®¤µ¤ì¤Æ¤¤¤Ê¤¤¡£", m_name); -#else - msg_format("%^s is no longer slow.", m_name); -#endif - } - p_ptr->redraw |= (PR_HEALTH); - if (p_ptr->riding == cave[target_row][target_col].m_idx) p_ptr->redraw |= (PR_UHEALTH); - + m_idx = cave[target_row][target_col].m_idx; + if (!m_idx) break; + if (!player_has_los_bold(target_row, target_col)) break; + if (!projectable(py, px, target_row, target_col)) break; + dispel_monster_status(m_idx); break; } case 10: @@ -1210,7 +1182,7 @@ msg_format("%s bool success = FALSE; for (i = 0; i < 1 + boost/100; i++) - if (summon_specific(-1, py, px, plev, SUMMON_PHANTOM, FALSE, TRUE, TRUE, FALSE, FALSE)) + if (summon_specific(-1, py, px, plev, SUMMON_PHANTOM, PM_FORCE_PET)) success = TRUE; if (success) { @@ -1250,6 +1222,7 @@ msg_print(" } p_ptr->magic_num1[0] = 0; + p_ptr->update |= (PU_BONUS); return TRUE; } @@ -1262,7 +1235,7 @@ static int number_of_mirrors( void ) int val=0; for( x=0 ; x < cur_wid ; x++ ){ for( y=0 ; y < cur_hgt ; y++ ){ - if( cave[y][x].feat == FEAT_MIRROR )val++; + if (is_mirror_grid(&cave[y][x])) val++; } } return val; @@ -1280,7 +1253,7 @@ static bool cast_mirror_spell(int spell) { /* mirror of seeing */ case 0: - tmp = cave[py][px].feat == FEAT_MIRROR ? 4 : 0; + tmp = is_mirror_grid(&cave[py][px]) ? 4 : 0; if( plev + tmp > 4)detect_monsters_normal(DETECT_RAD_DEFAULT); if( plev + tmp > 18 )detect_monsters_invis(DETECT_RAD_DEFAULT); if( plev + tmp > 28 )set_tim_esp(plev,FALSE); @@ -1296,7 +1269,7 @@ static bool cast_mirror_spell(int spell) /* drip of light */ case 1: if( number_of_mirrors() < 4 + plev/10 ){ - warding_mirror(); + place_mirror(); } else { #ifdef JP @@ -1308,7 +1281,7 @@ msg_format("There are too many mirrors to control!"); break; case 2: if (!get_aim_dir(&dir)) return FALSE; - if ( plev > 9 && cave[py][px].feat == FEAT_MIRROR ){ + if ( plev > 9 && is_mirror_grid(&cave[py][px]) ) { fire_beam(GF_LITE, dir,damroll(3+((plev-1)/5),4)); } else { @@ -1317,7 +1290,7 @@ msg_format("There are too many mirrors to control!"); break; /* warped mirror */ case 3: - teleport_player(10); + teleport_player(10, 0L); break; /* mirror of light */ case 4: @@ -1325,7 +1298,7 @@ msg_format("There are too many mirrors to control!"); break; /* mirror of wandering */ case 5: - teleport_player(plev * 5); + teleport_player(plev * 5, 0L); break; /* robe of dust */ case 6: @@ -1346,8 +1319,8 @@ msg_format("There are too many mirrors to control!"); case 9: for(x=0;xupdate |= (PU_VIEW | PU_LITE | PU_FLOW); - - /* Update the monsters */ - p_ptr->update |= (PU_DISTANCE); - - /* Window stuff */ - p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON); - - /* Handle stuff XXX XXX XXX */ - handle_stuff(); + (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP); } break; } @@ -1553,7 +1496,7 @@ static bool cast_berserk_spell(int spell) m_ptr = &m_list[c_ptr->m_idx]; /* Hack -- attack monsters */ - if (c_ptr->m_idx && (m_ptr->ml || cave_floor_bold(y, x))) + if (c_ptr->m_idx && (m_ptr->ml || cave_have_flag_bold(y, x, FF_PROJECT))) py_attack(y, x, 0); } break; @@ -1590,12 +1533,12 @@ static bool cast_ninja_spell(int spell) case 1: if (plev > 44) { - wiz_lite(FALSE, TRUE); + wiz_lite(TRUE); } detect_monsters_normal(DETECT_RAD_DEFAULT); if (plev > 4) { - detect_traps(DETECT_RAD_DEFAULT); + detect_traps(DETECT_RAD_DEFAULT, TRUE); detect_doors(DETECT_RAD_DEFAULT); detect_stairs(DETECT_RAD_DEFAULT); } @@ -1606,9 +1549,7 @@ static bool cast_ninja_spell(int spell) break; case 2: { - teleport_player(10); - if (cave[py][px].info & (CAVE_GLOW | CAVE_MNLT)) set_superstealth(FALSE); - else if (p_ptr->cur_lite <= 0) set_superstealth(TRUE); + teleport_player(10, 0L); break; } case 3: @@ -1628,9 +1569,7 @@ static bool cast_ninja_spell(int spell) } case 4: { - teleport_player(p_ptr->lev*5); - if (cave[py][px].info & (CAVE_GLOW | CAVE_MNLT)) set_superstealth(FALSE); - else if (p_ptr->cur_lite <= 0) set_superstealth(TRUE); + teleport_player(p_ptr->lev * 5, 0L); break; } case 5: @@ -1649,9 +1588,7 @@ msg_print(" #endif else { - teleport_player(30); - if (cave[py][px].info & (CAVE_GLOW | CAVE_MNLT)) set_superstealth(FALSE); - else if (p_ptr->cur_lite <= 0) set_superstealth(TRUE); + teleport_player(30, 0L); } } else @@ -1674,23 +1611,16 @@ msg_print(" } case 7: return ident_spell(FALSE); - break; case 8: - set_tim_ffall(randint1(20) + 20, FALSE); + set_tim_levitation(randint1(20) + 20, FALSE); break; case 9: fire_ball(GF_FIRE, 0, 50+plev, plev/10+2); - teleport_player(30); - if (cave[py][px].info & (CAVE_GLOW | CAVE_MNLT)) set_superstealth(FALSE); - else if (p_ptr->cur_lite <= 0) set_superstealth(TRUE); + teleport_player(30, 0L); set_oppose_fire(plev, FALSE); break; case 10: - project_length = 5; - if (!get_aim_dir(&dir)) return FALSE; - project_hook(GF_ATTACK, dir, HISSATSU_NYUSIN, PROJECT_STOP | PROJECT_KILL | PROJECT_NO_REF); - - break; + return rush_attack(NULL); case 11: { int i; @@ -1734,7 +1664,9 @@ msg_print(" if (!target_set(TARGET_KILL)) return FALSE; m_idx = cave[target_row][target_col].m_idx; if (!m_idx) break; + if (m_idx == p_ptr->riding) break; if (!player_has_los_bold(target_row, target_col)) break; + if (!projectable(py, px, target_row, target_col)) break; m_ptr = &m_list[m_idx]; monster_desc(m_name, m_ptr, 0); #ifdef JP @@ -1749,12 +1681,11 @@ msg_print(" { int ny = GRID_Y(path_g[i]); int nx = GRID_X(path_g[i]); - + cave_type *c_ptr = &cave[ny][nx]; + if (in_bounds(ny, nx) && cave_empty_bold(ny, nx) && - cave[ny][nx].feat != FEAT_GLYPH && - cave[ny][nx].feat != FEAT_MINOR_GLYPH && - !(cave[ny][nx].feat >= FEAT_PATTERN_START && - cave[ny][nx].feat <= FEAT_PATTERN_XTRA2)) + !(c_ptr->info & CAVE_OBJECT) && + !pattern_tile(ny, nx)) { ty = ny; tx = nx; @@ -1763,7 +1694,7 @@ msg_print(" /* Update the old location */ cave[target_row][target_col].m_idx = 0; - /* Update the new location */ + /* Update the new location */ cave[ty][tx].m_idx = m_idx; /* Move the monster */ @@ -1771,7 +1702,7 @@ msg_print(" m_ptr->fx = tx; /* Wake the monster up */ - m_ptr->csleep = 0; + (void)set_monster_csleep(m_idx, 0); /* Update the monster (new location) */ update_mon(m_idx, TRUE); @@ -1782,7 +1713,17 @@ msg_print(" /* Redraw the new grid */ lite_spot(ty, tx); - p_ptr->update |= (PU_MON_LITE); + if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK)) + p_ptr->update |= (PU_MON_LITE); + + if (m_ptr->ml) + { + /* Auto-Recall if possible and visible */ + monster_race_track(m_ptr->ap_r_idx); + + /* Track a new monster */ + health_track(m_idx); + } break; } @@ -1812,9 +1753,7 @@ msg_print(" fire_ball(GF_POIS, 0, 75+plev*2/3, plev/5+2); fire_ball(GF_OLD_DRAIN, 0, 75+plev*2/3, plev/5+2); fire_ball(GF_CONFUSION, 0, 75+plev*2/3, plev/5+2); - teleport_player(30); - if (cave[py][px].info & (CAVE_GLOW | CAVE_MNLT)) set_superstealth(FALSE); - else if (p_ptr->cur_lite <= 0) set_superstealth(TRUE); + teleport_player(30, 0L); break; case 18: { @@ -1826,11 +1765,11 @@ msg_print(" int typ = one_in_(2) ? GF_FIRE : one_in_(3) ? GF_NETHER : GF_PLASMA; int attempts = 1000; - while(attempts--) + while (attempts--) { scatter(&y, &x, py, px, 4, 0); - if ((y != py) || (x != px)) break; + if (!player_bold(y, x)) break; } project(0, 0, y, x, damroll(6 + plev / 8, 10), typ, (PROJECT_BEAM | PROJECT_THRU | PROJECT_GRID | PROJECT_KILL), -1); @@ -1968,9 +1907,7 @@ if (!get_check(" /* Reduce failure rate by "effective" level adjustment */ chance -= 3 * (plev - spell.min_lev); - if (p_ptr->pseikaku == SEIKAKU_NAMAKE) chance += 10; - if (p_ptr->pseikaku == SEIKAKU_KIREMONO) chance -= 3; - if ((p_ptr->pseikaku == SEIKAKU_GAMAN) || (p_ptr->pseikaku == SEIKAKU_CHIKARA)) chance++; + chance += p_ptr->to_m_chance; /* Reduce failure rate by INT/WIS adjustment */ chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1); @@ -2075,7 +2012,7 @@ msg_format("%s msg_print("Your mind unleashes its power in an uncontrollable storm!"); #endif - project(1, 2 + plev / 10, py, px, plev * 2, + project(PROJECT_WHO_UNCTRL_POWER, 2 + plev / 10, py, px, plev * 2, GF_MANA, PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID | PROJECT_ITEM, -1); p_ptr->csp = MAX(0, p_ptr->csp - plev * MAX(1, plev / 10)); } @@ -2092,8 +2029,7 @@ msg_print(" #else msg_print("Weird visions seem to dance before your eyes..."); #endif - teleport_player(10); - + teleport_player(10, TELEPORT_PASSIVE); } else if (b < 96) { @@ -2114,7 +2050,7 @@ msg_format("%s msg_print("Your mind unleashes its power in an uncontrollable storm!"); #endif - project(1, 2 + plev / 10, py, px, plev * 2, + project(PROJECT_WHO_UNCTRL_POWER, 2 + plev / 10, py, px, plev * 2, GF_MANA, PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID | PROJECT_ITEM, -1); p_ptr->csp = MAX(0, p_ptr->csp - plev * MAX(1, plev / 10)); } @@ -2142,7 +2078,7 @@ msg_format("%s break; case MIND_MIRROR_MASTER: /* Cast the spell */ - if( cave[py][px].feat == FEAT_MIRROR )on_mirror = TRUE; + if( is_mirror_grid(&cave[py][px]) )on_mirror = TRUE; cast = cast_mirror_spell(n); break; case MIND_NINJUTSU: @@ -2167,7 +2103,7 @@ msg_format("%s /* teleport from mirror costs small energy */ if( on_mirror && p_ptr->pclass == CLASS_MIRROR_MASTER ) { - if( n==2 || n==4 || n==6 || n==15 )energy_use = 50; + if( n==3 || n==5 || n==7 || n==16 )energy_use = 50; } if ((use_mind == MIND_BERSERKER) || (use_mind == MIND_NINJUTSU)) @@ -2282,7 +2218,7 @@ void do_cmd_mind_browse(void) Term_erase(12, 17, 255); Term_erase(12, 16, 255); - roff_to_buf( mind_tips[use_mind][n],62,temp); + roff_to_buf(mind_tips[use_mind][n], 62, temp, sizeof(temp)); for(j=0, line = 17;temp[j];j+=(1+strlen(&temp[j]))) { prt(&temp[j], line, 15); @@ -2300,6 +2236,4 @@ void do_cmd_mind_browse(void) (void)inkey(); } } - - screen_load(); }