diff -w -c -r Borg/borg1.c adamborg/borg1.c *** Borg/borg1.c Sun Apr 13 23:19:47 1997 --- adamborg/borg1.c Sun Apr 13 23:23:21 1997 *************** *** 4,9 **** --- 4,10 ---- #include "angband.h" + #ifdef ALLOW_BORG #include "borg1.h" *************** *** 43,53 **** */ bool auto_flag_save = FALSE; /* Save savefile at each level */ - bool auto_flag_dump = FALSE; /* Save savefile at each death */ - /* * Use a simple internal random number generator */ --- 44,53 ---- */ bool auto_flag_save = FALSE; /* Save savefile at each level */ bool auto_flag_dump = FALSE; /* Save savefile at each death */ + bool borg_save; /* do a save next level */ /* * Use a simple internal random number generator */ *************** *** 59,65 **** --- 59,67 ---- u32b auto_rand_local; /* Save personal setting */ + bool auto_do_star_id; + /* * Hack -- Time variables */ *************** *** 66,72 **** s16b c_t = 0L; /* Current "time" */ - /* * Hack -- Other time variables */ --- 68,73 ---- *************** *** 96,105 **** --- 97,109 ---- bool goal_recalling; /* Currently waiting for recall */ + s16b borg_times_twitch; /* how often twitchy on this level */ + bool stair_less; /* Use the next "up" staircase */ bool stair_more; /* Use the next "down" staircase */ s32b auto_began; /* When this level began */ + s32b auto_time_town; /* how long it has been since I was in town */ s16b avoidance = 0; /* Current danger thresh-hold */ *************** *** 106,115 **** --- 110,132 ---- bool auto_failure; /* Notice failure */ bool auto_simulate; /* Simulation flag */ + bool borg_attacking; /* Simulation flag */ bool auto_completed; /* Completed the level */ + /* defence flags */ + bool borg_prot_from_evil; + bool borg_speed; + bool borg_bless; + bool borg_temp_fire; + bool borg_temp_cold; + bool borg_temp_acid; + bool borg_temp_poison; + bool borg_temp_elec; + s16b borg_goi; + bool borg_shield; + /* * Current shopping information */ *************** *** 133,138 **** --- 150,158 ---- int g_x; /* Goal location (X) */ int g_y; /* Goal location (Y) */ + /* BIG HACK! Assume only 10 cursed artifacts */ + int bad_obj_x[10]; /* Dropped cursed artifact at location (X) */ + int bad_obj_y[10]; /* Dropped cursed artifact at location (Y) */ /* *************** *** 152,157 **** --- 172,178 ---- bool do_cut; /* Currently bleeding */ bool do_stun; /* Currently stunned */ + bool do_heavy_stun; /* Currently very stunned */ bool do_image; /* May be hallucinating */ bool do_study; /* May learn spells */ *************** *** 170,176 **** --- 191,205 ---- s16b my_stat_cur[6]; /* Current "natural" stat values */ s16b my_stat_use[6]; /* Current "resulting" stat values */ s16b my_stat_ind[6]; /* Current "additions" to stat values */ + bool my_need_stat_check[6]; /* do I need to check my stats? */ + s16b my_stat_add[6]; /* additions to stats This will allow upgrading of */ + /* equiptment to allow a ring of int +4 to be traded */ + /* for a ring of int +6 even if maximized to allow a */ + /* later swap to be better. */ + + s16b home_stat_add[6]; + s16b my_ac; /* Base armor */ s16b my_to_ac; /* Plusses to ac */ s16b my_to_hit; /* Plusses to hit */ *************** *** 187,203 **** byte my_resist_cold; /* Resist cold */ byte my_resist_pois; /* Resist poison */ ! byte my_resist_fear; /* Resist fear */ byte my_resist_lite; /* Resist light */ byte my_resist_dark; /* Resist darkness */ - byte my_resist_blind; /* Resist blindness */ - byte my_resist_confu; /* Resist confusion */ - byte my_resist_sound; /* Resist sound */ - byte my_resist_shard; /* Resist shards */ - byte my_resist_nexus; /* Resist nexus */ - byte my_resist_nethr; /* Resist nether */ byte my_resist_chaos; /* Resist chaos */ byte my_resist_disen; /* Resist disenchant */ byte my_sustain_str; /* Keep strength */ byte my_sustain_int; /* Keep intelligence */ --- 216,232 ---- byte my_resist_cold; /* Resist cold */ byte my_resist_pois; /* Resist poison */ ! byte my_resist_conf; /* Resist confusion */ ! byte my_resist_sound; /* Resist sound */ byte my_resist_lite; /* Resist light */ byte my_resist_dark; /* Resist darkness */ byte my_resist_chaos; /* Resist chaos */ byte my_resist_disen; /* Resist disenchant */ + byte my_resist_shard; /* Resist shards */ + byte my_resist_nexus; /* Resist nexus */ + byte my_resist_blind; /* Resist blindness */ + byte my_resist_neth; /* Resist nether */ + byte my_resist_fear; /* Resist fear */ byte my_sustain_str; /* Keep strength */ byte my_sustain_int; /* Keep intelligence */ *************** *** 218,223 **** --- 247,268 ---- byte my_telepathy; /* Telepathy */ byte my_slow_digest; /* Slower digestion */ + /* various slays */ + byte my_slay_animal; + byte my_slay_evil; + byte my_slay_undead; + byte my_slay_demon; + byte my_slay_orc; + byte my_slay_troll; + byte my_slay_giant; + byte my_slay_dragon; + byte my_kill_dragon; + byte my_impact; + byte my_brand_acid; + byte my_brand_elec; + byte my_brand_fire; + byte my_brand_cold; + s16b my_see_infra; /* Infravision range */ s16b my_skill_dis; /* Skill: Disarming */ *************** *** 263,273 **** --- 308,324 ---- s16b amt_fuel; s16b amt_food; s16b amt_ident; + s16b amt_star_ident; s16b amt_recall; s16b amt_phase; s16b amt_escape; s16b amt_teleport; + s16b amt_teleport_staff; + s16b amt_heal; + s16b amt_ez_heal; + s16b amt_mana; + s16b amt_ez_mana; s16b amt_cure_critical; s16b amt_cure_serious; *************** *** 282,287 **** --- 333,340 ---- s16b amt_fix_stat[6]; s16b amt_fix_exp; + s16b amt_speed; + s16b amt_enchant_to_a; s16b amt_enchant_to_d; s16b amt_enchant_to_h; *************** *** 291,299 **** * Various "amounts" (for the home) */ - s16b num_fuel; s16b num_food; s16b num_ident; s16b num_recall; s16b num_phase; s16b num_escape; --- 344,352 ---- * Various "amounts" (for the home) */ s16b num_food; s16b num_ident; + s16b num_star_ident; s16b num_recall; s16b num_phase; s16b num_escape; *************** *** 309,320 **** --- 362,420 ---- s16b num_fix_stat[6]; s16b num_fix_exp; + s16b num_mana; + s16b num_heal; s16b num_enchant_to_a; s16b num_enchant_to_d; s16b num_enchant_to_h; + s16b num_artifact; + s16b home_slot_free; + s16b home_damage; + s16b num_duplicate_items; + s16b num_slow_digest; + s16b num_regenerate; + s16b num_telepathy; + s16b num_lite; + s16b num_see_inv; + s16b num_ffall; + s16b num_free_act; + s16b num_hold_life; + s16b num_immune_acid; + s16b num_immune_elec; + s16b num_immune_fire; + s16b num_immune_cold; + s16b num_resist_acid; + s16b num_resist_elec; + s16b num_resist_fire; + s16b num_resist_cold; + s16b num_resist_pois; + s16b num_resist_conf; + s16b num_resist_sound; + s16b num_resist_lite; + s16b num_resist_dark; + s16b num_resist_chaos; + s16b num_resist_disen; + s16b num_resist_shard; + s16b num_resist_nexus; + s16b num_resist_blind; + s16b num_resist_neth; + s16b num_speed; + s16b num_edged_weapon; + s16b num_bad_gloves; + s16b num_weapons; + s16b num_bow; + s16b num_rings; + s16b num_neck; + s16b num_armor; + s16b num_cloaks; + s16b num_shields; + s16b num_hats; + s16b num_gloves; + s16b num_boots; + /* * Hack -- extra state variables */ *************** *** 324,329 **** --- 424,430 ---- int auto_max_level = 0; /* Maximum player level */ int auto_max_depth = 0; /* Maximum dungeon depth */ + int fear_depth = 0; /* Maximum dungeon depth */ /* *************** *** 342,347 **** --- 443,450 ---- int auto_level; /* Current level */ + bool borg_king; /* We won! Time to retire. */ + s32b auto_exp; /* Current experience */ s32b auto_gold; /* Current gold */ *************** *** 348,354 **** int auto_speed; /* Current speed */ ! int auto_ac; /* Current class */ int auto_chp; /* Current hitpoints */ int auto_mhp; /* Maximum hitpoints */ --- 451,457 ---- int auto_speed; /* Current speed */ ! int auto_ac; /* Current ac */ int auto_chp; /* Current hitpoints */ int auto_mhp; /* Maximum hitpoints */ *************** *** 478,484 **** /* * Hack -- depth readiness */ ! bool auto_fear_depth[128]; /* --- 581,594 ---- /* * Hack -- depth readiness */ ! int auto_fear_depth = 0; /* number of times level completed */ ! bool finished_level; ! bool borg_collect_potions_morgoth; ! /* a 3 state boolean */ ! /*-1 = not checked yet */ ! /* 0 = not ready */ ! /* 1 = ready */ ! int borg_ready_morgoth; /* *************** *** 645,653 **** bool auto_do_crush_slow = FALSE; - /* * Query the "attr/char" at a given location on the screen * We return "zero" if the given location was legal --- 755,764 ---- bool auto_do_crush_slow = FALSE; + /* am I fighting a unique? */ + bool borg_fighting_unique; /* * Query the "attr/char" at a given location on the screen * We return "zero" if the given location was legal *************** *** 984,990 **** int i; /* Nothing ready */ ! if (auto_key_head == auto_key_tail) return (0); /* Extract the keypress */ i = auto_key_queue[auto_key_tail]; --- 1095,1102 ---- int i; /* Nothing ready */ ! if (auto_key_head == auto_key_tail) ! return (0); /* Extract the keypress */ i = auto_key_queue[auto_key_tail]; *************** *** 1176,1181 **** --- 1288,1306 ---- auto_level = atoi(buf); } + /* Extract current level */ + if (0 == borg_what_text(COL_TITLE, ROW_TITLE, -8, &t_a, buf)) + { + /* Note "Lev" vs "LEV" */ + borg_king = (buf[0] == '*' && + buf[1] == '*' && + buf[2] == 'K' && + buf[3] == 'I' && + buf[4] == 'N' && + buf[5] == 'G' && + buf[6] == '*' && + buf[7] == '*'); + } /* Assume experience is fine */ do_fix_exp = FALSE; *************** *** 1208,1213 **** --- 1333,1343 ---- { /* Extract "Fast (+x)" or "Slow (-x)" */ auto_speed = 110 + atoi(buf + 6); + + /* if hasting, it doesn't count as 'auto_speed'. The speed */ + /* gained from hasting is counted seperately. */ + if (borg_speed) + auto_speed -= 10; } /* Extract armor class */ *************** *** 1252,1258 **** /* Clear all the "state flags" */ do_weak = do_hungry = do_full = do_gorged = FALSE; do_blind = do_confused = do_afraid = do_poisoned = FALSE; ! do_cut = do_stun = do_image = do_study = FALSE; /* Check for hunger */ if (0 == borg_what_text(COL_HUNGRY, ROW_HUNGRY, -1, &t_a, buf)) --- 1382,1388 ---- /* Clear all the "state flags" */ do_weak = do_hungry = do_full = do_gorged = FALSE; do_blind = do_confused = do_afraid = do_poisoned = FALSE; ! do_cut = do_stun = do_heavy_stun = do_image = do_study = FALSE; /* Check for hunger */ if (0 == borg_what_text(COL_HUNGRY, ROW_HUNGRY, -1, &t_a, buf)) *************** *** 1309,1316 **** /* XXX XXX Check for stun */ if (0 == borg_what_text(COL_STUN, ROW_STUN, -1, &t_a, buf)) { ! /* Check for any text */ ! if (isalpha(buf[0])) do_stun = TRUE; } --- 1439,1449 ---- /* XXX XXX Check for stun */ if (0 == borg_what_text(COL_STUN, ROW_STUN, -1, &t_a, buf)) { ! /* Check for Stun */ ! if (buf[0] == 'S') do_stun = TRUE; ! ! /* Check for Heavy Stun */ ! if (buf[0] == 'H') do_heavy_stun = TRUE; } *************** *** 1368,1373 **** --- 1501,1507 ---- /* Prapare a local random number seed */ + if (!auto_rand_local) auto_rand_local = rand_int(0x10000000); *************** *** 1543,1555 **** /* Hack -- Access max depth */ auto_max_depth = p_ptr->max_dlv; } #else #ifdef MACINTOSH static int HACK = 0; ! #endif /* MACINTOSH */ ! #endif /* ALLOW_BORG */ --- 1677,1695 ---- /* Hack -- Access max depth */ auto_max_depth = p_ptr->max_dlv; + + /* HACK when restarting the fear depth is the current max depth */ + fear_depth = p_ptr->max_dlv; + auto_fear_depth = 0; + finished_level = FALSE; } + #else #ifdef MACINTOSH static int HACK = 0; ! #endif ! #endif diff -w -c -r Borg/borg1.h adamborg/borg1.h *** Borg/borg1.h Sun Apr 13 23:19:57 1997 --- adamborg/borg1.h Sun Apr 13 23:23:31 1997 *************** *** 364,370 **** --- 364,372 ---- extern bool auto_cheat_panel; /* Cheat for "panel mode" */ + extern bool auto_do_star_id; + /* * Various silly flags */ *************** *** 373,379 **** --- 375,383 ---- extern bool auto_flag_dump; /* Save savefile at each death */ + extern bool borg_save; /* do a save next time we get to press a key! */ + /* * Use a simple internal random number generator */ *************** *** 420,429 **** --- 424,436 ---- extern bool goal_recalling; /* Currently waiting for recall */ + extern s16b borg_times_twitch; /* how often twitchy on this level */ + extern bool stair_less; /* Use the next "up" staircase */ extern bool stair_more; /* Use the next "down" staircase */ extern s32b auto_began; /* When this level began */ + extern s32b auto_time_town; /* how long it has been since I was in town */ extern s16b avoidance; /* Current danger thresh-hold */ *************** *** 430,440 **** extern bool auto_failure; /* Notice failure */ extern bool auto_simulate; /* Simulation flag */ extern bool auto_completed; /* Completed the level */ - /* * Shop goals */ --- 437,458 ---- extern bool auto_failure; /* Notice failure */ extern bool auto_simulate; /* Simulation flag */ + extern bool borg_attacking; /* Are we attacking a monster? */ extern bool auto_completed; /* Completed the level */ + /* defence flags */ + extern bool borg_prot_from_evil; + extern bool borg_speed; + extern bool borg_bless; + extern bool borg_temp_fire; + extern bool borg_temp_cold; + extern bool borg_temp_acid; + extern bool borg_temp_poison; + extern bool borg_temp_elec; + extern s16b borg_goi; + extern bool borg_shield; /* * Shop goals */ *************** *** 457,463 **** --- 475,484 ---- extern int g_x; /* Goal location (X) */ extern int g_y; /* Goal location (Y) */ + extern int bad_obj_x[10]; /* Dropped cursed artifact at location (X) */ + extern int bad_obj_y[10]; /* Dropped cursed artifact at location (Y) */ + /* * State variables extracted from the screen */ *************** *** 475,480 **** --- 496,502 ---- extern bool do_cut; /* Currently bleeding */ extern bool do_stun; /* Currently stunned */ + extern bool do_heavy_stun; /* Currently stunned */ extern bool do_image; /* May be hallucinating */ extern bool do_study; /* May learn spells */ *************** *** 494,500 **** --- 516,527 ---- extern s16b my_stat_cur[6]; /* Current "natural" stat values */ extern s16b my_stat_use[6]; /* Current "resulting" stat values */ extern s16b my_stat_ind[6]; /* Current "additions" to stat values */ + extern bool my_need_stat_check[6]; /* do I need to check my stats */ + extern s16b my_stat_add[6]; /* aditions to stats */ + + extern s16b home_stat_add[6]; + extern s16b my_ac; /* Base armor */ extern s16b my_to_ac; /* Plusses to ac */ extern s16b my_to_hit; /* Plusses to hit */ *************** *** 511,527 **** extern byte my_resist_cold; /* Resist cold */ extern byte my_resist_pois; /* Resist poison */ ! extern byte my_resist_fear; /* Resist fear */ extern byte my_resist_lite; /* Resist light */ extern byte my_resist_dark; /* Resist darkness */ - extern byte my_resist_blind; /* Resist blindness */ - extern byte my_resist_confu; /* Resist confusion */ - extern byte my_resist_sound; /* Resist sound */ - extern byte my_resist_shard; /* Resist shards */ - extern byte my_resist_nexus; /* Resist nexus */ - extern byte my_resist_nethr; /* Resist nether */ extern byte my_resist_chaos; /* Resist chaos */ extern byte my_resist_disen; /* Resist disenchant */ extern byte my_sustain_str; /* Keep strength */ extern byte my_sustain_int; /* Keep intelligence */ --- 538,554 ---- extern byte my_resist_cold; /* Resist cold */ extern byte my_resist_pois; /* Resist poison */ ! extern byte my_resist_conf; /* Resist confusion */ ! extern byte my_resist_sound; /* Resist sound */ extern byte my_resist_lite; /* Resist light */ extern byte my_resist_dark; /* Resist darkness */ extern byte my_resist_chaos; /* Resist chaos */ extern byte my_resist_disen; /* Resist disenchant */ + extern byte my_resist_shard; /* Resist shards */ + extern byte my_resist_nexus; /* Resist nexus */ + extern byte my_resist_blind; /* Resist blindness */ + extern byte my_resist_neth; /* Resist nether */ + extern byte my_resist_fear; /* Resist fear */ extern byte my_sustain_str; /* Keep strength */ extern byte my_sustain_int; /* Keep intelligence */ *************** *** 542,547 **** --- 569,590 ---- extern byte my_telepathy; /* Telepathy */ extern byte my_slow_digest; /* Slower digestion */ + /* various slays */ + extern byte my_slay_animal; + extern byte my_slay_evil; + extern byte my_slay_undead; + extern byte my_slay_demon; + extern byte my_slay_orc; + extern byte my_slay_troll; + extern byte my_slay_giant; + extern byte my_slay_dragon; + extern byte my_kill_dragon; + extern byte my_impact; + extern byte my_brand_acid; + extern byte my_brand_elec; + extern byte my_brand_fire; + extern byte my_brand_cold; + extern s16b my_see_infra; /* Infravision range */ extern s16b my_skill_dis; /* Skill: Disarming */ *************** *** 588,598 **** --- 631,647 ---- extern s16b amt_fuel; extern s16b amt_food; extern s16b amt_ident; + extern s16b amt_star_ident; extern s16b amt_recall; extern s16b amt_phase; extern s16b amt_escape; extern s16b amt_teleport; + extern s16b amt_teleport_staff; + extern s16b amt_heal; + extern s16b amt_ez_heal; + extern s16b amt_mana; + extern s16b amt_ez_mana; extern s16b amt_cure_critical; extern s16b amt_cure_serious; *************** *** 608,613 **** --- 657,664 ---- extern s16b amt_fix_exp; + extern s16b amt_speed; + extern s16b amt_enchant_to_a; extern s16b amt_enchant_to_d; extern s16b amt_enchant_to_h; *************** *** 617,625 **** * Various "amounts" (for the home) */ - extern s16b num_fuel; extern s16b num_food; extern s16b num_ident; extern s16b num_recall; extern s16b num_phase; extern s16b num_escape; --- 668,676 ---- * Various "amounts" (for the home) */ extern s16b num_food; extern s16b num_ident; + extern s16b num_star_ident; extern s16b num_recall; extern s16b num_phase; extern s16b num_escape; *************** *** 635,647 **** --- 686,746 ---- extern s16b num_fix_stat[6]; extern s16b num_fix_exp; + extern s16b num_mana; + extern s16b num_heal; extern s16b num_enchant_to_a; extern s16b num_enchant_to_d; extern s16b num_enchant_to_h; + extern s16b num_artifact; + extern s16b home_slot_free; + extern s16b home_damage; + extern s16b num_duplicate_items; + extern s16b num_slow_digest; + extern s16b num_regenerate; + extern s16b num_telepathy; + extern s16b num_lite; + extern s16b num_see_inv; + extern s16b num_ffall; + extern s16b num_free_act; + extern s16b num_hold_life; + extern s16b num_immune_acid; + extern s16b num_immune_elec; + extern s16b num_immune_fire; + extern s16b num_immune_cold; + extern s16b num_resist_acid; + extern s16b num_resist_elec; + extern s16b num_resist_fire; + extern s16b num_resist_cold; + extern s16b num_resist_pois; + extern s16b num_resist_conf; + extern s16b num_resist_sound; + extern s16b num_resist_lite; + extern s16b num_resist_dark; + extern s16b num_resist_chaos; + extern s16b num_resist_disen; + extern s16b num_resist_shard; + extern s16b num_resist_nexus; + extern s16b num_resist_blind; + extern s16b num_resist_neth; + extern s16b num_speed; + extern s16b num_edged_weapon; + extern s16b num_bad_gloves; + extern s16b num_weapons; + extern s16b num_bow; + extern s16b num_rings; + extern s16b num_neck; + extern s16b num_armor; + extern s16b num_cloaks; + extern s16b num_shields; + extern s16b num_hats; + extern s16b num_gloves; + extern s16b num_boots; + + /* * Hack -- extra state variables */ *************** *** 650,655 **** --- 749,755 ---- extern int auto_max_level; /* Maximum player level */ extern int auto_max_depth; /* Maximum dungeon depth */ + extern int fear_depth; /* fear below this dungeon depth */ *************** *** 669,674 **** --- 769,776 ---- extern int auto_level; /* Current level */ + extern bool borg_king; /* We won! */ + extern s32b auto_exp; /* Current experience */ extern s32b auto_gold; /* Current gold */ *************** *** 803,811 **** /* * Hack -- depth readiness */ ! extern bool auto_fear_depth[128]; - /* * Hack -- extra fear per "region" */ --- 905,915 ---- /* * Hack -- depth readiness */ ! extern int auto_fear_depth; ! extern bool finished_level; ! extern bool borg_collect_potions_morgoth; ! extern int borg_ready_morgoth; /* * Hack -- extra fear per "region" */ *************** *** 964,969 **** --- 1068,1075 ---- extern bool auto_do_crush_slow; + /* am I fighting a unique */ + extern bool borg_fighting_unique; diff -w -c -r Borg/borg2.c adamborg/borg2.c *** Borg/borg2.c Sun Apr 13 23:20:09 1997 --- adamborg/borg2.c Sun Apr 13 23:23:44 1997 *************** *** 620,627 **** ar = borg_free_room(); /* Initialize the new room */ ! ar->x = ar->x1 = x1; ar->x2 = x2; ! ar->y = ar->y1 = y1; ar->y2 = y2; /* Save the room index */ i = ar->self; --- 620,629 ---- ar = borg_free_room(); /* Initialize the new room */ ! /* ar->x = ar->x1 = x1; ar->x2 = x2;*/ ! /* ar->y = ar->y1 = y1; ar->y2 = y2;*/ ! ar->x1 = x1; ar->x2 = x2; ! ar->y1 = y1; ar->y2 = y2; /* Save the room index */ i = ar->self; *************** *** 660,667 **** /* That room is now "gone" */ ar->when = 0L; ! ar->x1 = ar->x2 = ar->x = 0; ! ar->y1 = ar->y2 = ar->y = 0; /* Add it to the "free list" */ auto_rooms[j].free = auto_rooms[0].free; --- 662,671 ---- /* That room is now "gone" */ ar->when = 0L; ! /* ar->x1 = ar->x2 = ar->x = 0; */ ! /* ar->y1 = ar->y2 = ar->y = 0; */ ! ar->x1 = ar->x2 = 0; ! ar->y1 = ar->y2 = 0; /* Add it to the "free list" */ auto_rooms[j].free = auto_rooms[0].free; *************** *** 761,767 **** /* * Clear out the "room" array */ ! static void borg_wipe_rooms(void) { int i, x, y; --- 765,771 ---- /* * Clear out the "room" array */ ! void borg_wipe_rooms(void) { int i, x, y; *************** *** 1047,1054 **** /* Get the grid */ ag = &auto_grids[y][x]; ! /* Hack -- assume unknown grids are walls */ ! if (dist && (ag->feat == FEAT_NONE)) break; /* Never pass through walls/doors */ if (dist && (!borg_cave_floor_grid(ag))) break; --- 1051,1059 ---- /* Get the grid */ ag = &auto_grids[y][x]; ! /* Assume all unknow grids more than distance 10 from you */ ! /* are walls. */ ! if ((dist > 10) && (ag->feat == FEAT_NONE)) break; /* Never pass through walls/doors */ if (dist && (!borg_cave_floor_grid(ag))) break; *************** *** 1906,1915 **** } #else #ifdef MACINTOSH static int HACK = 0; ! #endif /* MACINTOSH */ ! #endif /* ALLOW_BORG */ --- 1911,1921 ---- } + #else #ifdef MACINTOSH static int HACK = 0; ! #endif ! #endif diff -w -c -r Borg/borg2.h adamborg/borg2.h *** Borg/borg2.h Sun Apr 13 23:20:12 1997 --- adamborg/borg2.h Sun Apr 13 23:23:46 1997 *************** *** 59,64 **** --- 59,68 ---- */ extern bool borg_clear_room(int y, int x); + /* + * Clear out the "room" array + */ + extern void borg_wipe_rooms(void); #endif diff -w -c -r Borg/borg3.c adamborg/borg3.c *** Borg/borg3.c Sun Apr 13 23:20:31 1997 --- adamborg/borg3.c Sun Apr 13 23:24:16 1997 *************** *** 34,39 **** --- 34,40 ---- */ auto_item *safe_items; /* Safety "inventory" */ + auto_item *safe_home; /* Safety "home stuff" */ auto_shop *safe_shops; /* Safety "shops" */ *************** *** 339,345 **** 85 /* A "Magic Missile" */, 5 /* "Detect Monsters" */, 75 /* E "Phase Door" */, ! 75 /* D "Light Area" */, 5 /* "Treasure Detection" */, 55 /* H "Cure Light Wounds" */, 5 /* "Object Detection" */, --- 340,346 ---- 85 /* A "Magic Missile" */, 5 /* "Detect Monsters" */, 75 /* E "Phase Door" */, ! 65 /* D "Light Area" */, 5 /* "Treasure Detection" */, 55 /* H "Cure Light Wounds" */, 5 /* "Object Detection" */, *************** *** 366,372 **** 55 /* O "Recharge Item I" */, 5 /* "Sleep II" */, 5 /* "Polymorph Other" */, ! 95 /* O "Identify" */, 5 /* "Sleep III" */, 85 /* A "Fire Bolt" */, 5 /* "Slow Monster" */, --- 367,373 ---- 55 /* O "Recharge Item I" */, 5 /* "Sleep II" */, 5 /* "Polymorph Other" */, ! 96 /* O "Identify" */, 5 /* "Sleep III" */, 85 /* A "Fire Bolt" */, 5 /* "Slow Monster" */, *************** *** 378,384 **** 85 /* A "Frost Ball" */, 75 /* O "Recharge Item II" */, 5 /* "Teleport Other" */, ! 5 /* "Haste Self" */, 85 /* A "Fire Ball" */, 0 /* X "Word of Destruction" */, 5 /* "Genocide" */, --- 379,385 ---- 85 /* A "Frost Ball" */, 75 /* O "Recharge Item II" */, 5 /* "Teleport Other" */, ! 75 /* "Haste Self" */, 85 /* A "Fire Ball" */, 0 /* X "Word of Destruction" */, 5 /* "Genocide" */, *************** *** 388,398 **** { /* Resistance of Scarabtarices (sval 4) */ ! 5 /* "Resist Fire" */, ! 5 /* "Resist Cold" */, ! 5 /* "Resist Acid" */, ! 5 /* "Resist Poison" */, ! 5 /* "Resistance" */, 0 /* "(blank)" */, 0 /* "(blank)" */, 0 /* "(blank)" */, --- 389,399 ---- { /* Resistance of Scarabtarices (sval 4) */ ! 70 /* "Resist Fire" */, ! 65 /* "Resist Cold" */, ! 60 /* "Resist Acid" */, ! 70 /* "Resist Poison" */, ! 75 /* "Resistance" */, 0 /* "(blank)" */, 0 /* "(blank)" */, 0 /* "(blank)" */, *************** *** 428,437 **** { /* Tenser's transformations... (sval 7) */ 55 /* H "Heroism" */, ! 5 /* "Shield" */, 55 /* H "Berserker" */, ! 5 /* "Essence of Speed" */, ! 5 /* "Globe of Invulnerability" */, 0 /* "(blank)" */, 0 /* "(blank)" */, 0 /* "(blank)" */, --- 429,438 ---- { /* Tenser's transformations... (sval 7) */ 55 /* H "Heroism" */, ! 75 /* "Shield" */, 55 /* H "Berserker" */, ! 75 /* "Essence of Speed" */, ! 75 /* "Globe of Invulnerability" */, 0 /* "(blank)" */, 0 /* "(blank)" */, 0 /* "(blank)" */, *************** *** 461,468 **** 5 /* "Detect Evil" */, 55 /* H "Cure Light Wounds" */, 5 /* "Bless" */, ! 65 /* H "Remove Fear" */, ! 65 /* D "Call Light" */, 75 /* D "Find Traps" */, 75 /* D "Detect Doors/Stairs" */, 5 /* "Slow Poison" */, --- 462,469 ---- 5 /* "Detect Evil" */, 55 /* H "Cure Light Wounds" */, 5 /* "Bless" */, ! 35 /* H "Remove Fear" */, ! 35 /* D "Call Light" */, 75 /* D "Find Traps" */, 75 /* D "Detect Doors/Stairs" */, 5 /* "Slow Poison" */, *************** *** 485,491 **** { /* Chants and Blessings (sval 2) */ 65 /* H "Neutralize Poison" */, ! 85 /* A "Orb of Draining" */, 55 /* H "Cure Critical Wounds" */, 5 /* "Sense Invisible" */, 5 /* "Protection from Evil" */, --- 486,492 ---- { /* Chants and Blessings (sval 2) */ 65 /* H "Neutralize Poison" */, ! 90 /* A "Orb of Draining" */, 55 /* H "Cure Critical Wounds" */, 5 /* "Sense Invisible" */, 5 /* "Protection from Evil" */, *************** *** 549,559 **** { /* Holy Infusions (sval 7) */ ! 55 /* F "Unbarring Ways" */, ! 55 /* O "Recharging" */, 5 /* "Dispel Curse" */, ! 55 /* O "Enchant Weapon" */, ! 55 /* O "Enchant Armour" */, 5 /* "Elemental Brand" */, 0 /* "(blank)" */, 0 /* "(blank)" */, --- 550,560 ---- { /* Holy Infusions (sval 7) */ ! 50 /* F "Unbarring Ways" */, ! 50 /* O "Recharging" */, 5 /* "Dispel Curse" */, ! 50 /* O "Enchant Weapon" */, ! 50 /* O "Enchant Armour" */, 5 /* "Elemental Brand" */, 0 /* "(blank)" */, 0 /* "(blank)" */, *************** *** 678,687 **** --- 679,1195 ---- return (-1); } + /* + * Get the *ID information + * + * This function pulls the information from the screen if it is not passed + * a *real* item. It is only passed in *real* items if the borg is allowed + * to 'cheat' for inventory. + * This function returns TRUE if space needs to be pressed + */ + bool borg_object_star_id_aux(auto_item *borg_item, object_type *real_item) + { + u32b f1, f2, f3; + /* If a real item pointer is passed in then we are cheating to get */ + /* the data directly from the real item */ + if (real_item) + { + object_flags(real_item, &f1, &f2, &f3); + } + else + { + int i; + byte t_a; + char buf[71]; + + for (i = 2; i < 22; i++) + { + if (!(0 == borg_what_text(15, i, 65, &t_a, buf))) + { + /* bummer, problem reading from screen */ + borg_oops("cannot read from screen"); + return FALSE; + } + + /* Gives Stat Bonus */ + if (prefix(buf, "It affects your strength.")) + { + f1 &= TR1_STR; + continue; + } + if (prefix(buf, "It affects your intelligence.")) + { + f1 &= TR1_INT; + continue; + } + if (prefix(buf, "It affects your wisdom.")) + { + f1 &= TR1_WIS; + continue; + } + if (prefix(buf, "It affects your dexterity.")) + { + f1 &= TR1_DEX; + continue; + } + if (prefix(buf, "It affects your constitution.")) + { + f1 &= TR1_CON; + continue; + } + if (prefix(buf, "It affects your charisma.")) + { + f1 &= TR1_CHR; + continue; + } + /* Gives stealth Bonus */ + if (prefix(buf, "It affects your stealth.")) + { + f1 &= TR1_STEALTH; + continue; + } + /* Gives searching Bonus */ + if (prefix(buf, "It affects your searching.")) + { + f1 &= TR1_SEARCH; + continue; + } + /* Gives Infravision Bonus */ + if (prefix(buf, "It affects your infravision.")) + { + f1 &= TR1_INFRA; + continue; + } + /* Gives digging Bonus */ + if (prefix(buf, "It affects your ability to tunnel.")) + { + f1 &= TR1_TUNNEL; + continue; + } + /* Gives Speed Bonus (Wee!) */ + if (prefix(buf, "It affects your speed.")) + { + f1 &= TR1_SPEED; + continue; + } + /* Gives Extra Blows */ + if (prefix(buf, "It affects your attack speed.")) + { + f1 &= TR1_BLOWS; + continue; + } + /* Various Brands */ + if (prefix(buf, "It does extra damage from acid.")) + { + f1 &= TR1_BRAND_ACID; + continue; + } + if (prefix(buf, "It does extra damage from electricity.")) + { + f1 &= TR1_BRAND_ELEC; + continue; + } + if (prefix(buf, "It does extra damage from fire.")) + { + f1 &= TR1_BRAND_FIRE; + continue; + } + if (prefix(buf, "It does extra damage from frost.")) + { + f1 &= TR1_BRAND_COLD; + continue; + } + /* This is Grond. */ + if (prefix(buf, "It can cause earthquakes.")) + { + f1 &= TR1_IMPACT; + continue; + } + /* *SLAY* Dragon */ + if (prefix(buf, "It is a great bane of dragons.")) + { + f1 &= TR1_KILL_DRAGON; + continue; + } + /* Various Slays */ + if (prefix(buf, "It is especially deadly against dragons.")) + { + f1 &= TR1_SLAY_DRAGON; + continue; + } + if (prefix(buf, "It is especially deadly against orcs.")) + { + f1 &= TR1_SLAY_ORC; + continue; + } + if (prefix(buf, "It is especially deadly against trolls.")) + { + f1 &= TR1_SLAY_TROLL; + continue; + } + if (prefix(buf, "It is especially deadly against giants.")) + { + f1 &= TR1_SLAY_GIANT; + continue; + } + if (prefix(buf, "It strikes at demons with holy wrath.")) + { + f1 &= TR1_SLAY_DEMON; + continue; + } + if (prefix(buf, "It strikes at undead with holy wrath.")) + { + f1 &= TR1_SLAY_UNDEAD; + continue; + } + if (prefix(buf, "It fights against evil with holy fury.")) + { + f1 &= TR1_SLAY_EVIL; + continue; + } + if (prefix(buf, "It is especially deadly against natural creatures.")) + { + f1 &= TR1_SLAY_ANIMAL; + continue; + } + /* Various Sustains */ + if (prefix(buf, "It sustains your strength.")) + { + f2 &= TR2_SUST_STR; + continue; + } + if (prefix(buf, "It sustains your intelligence.")) + { + f2 &= TR2_SUST_INT; + continue; + } + if (prefix(buf, "It sustains your wisdom.")) + { + f2 &= TR2_SUST_WIS; + continue; + } + if (prefix(buf, "It sustains your dexterity.")) + { + f2 &= TR2_SUST_DEX; + continue; + } + if (prefix(buf, "It sustains your constitution.")) + { + f2 &= TR2_SUST_CON; + continue; + } + if (prefix(buf, "It sustains your charisma.")) + { + f2 &= TR2_SUST_CHR; + continue; + } + /* Various immunities */ + if (prefix(buf, "It provides immunity to acid.")) + { + f2 &= TR2_IM_ACID; + continue; + } + if (prefix(buf, "It provides immunity to electricity.")) + { + f2 &= TR2_IM_ELEC; + continue; + } + if (prefix(buf, "It provides immunity to fire.")) + { + f2 &= TR2_IM_FIRE; + continue; + } + if (prefix(buf, "It provides immunity to cold.")) + { + f2 &= TR2_IM_COLD; + continue; + } + /* Free Action */ + if (prefix(buf, "It provides immunity to paralysis.")) + { + f2 &= TR2_FREE_ACT; + continue; + } + /* Hold Life */ + if (prefix(buf, "It provides resistance to life draining.")) + { + f2 &= TR2_HOLD_LIFE; + continue; + } + /* Resists */ + if (prefix(buf, "It provides resistance to acid.")) + { + f2 &= TR2_RES_ACID; + continue; + } + if (prefix(buf, "It provides resistance to electricity.")) + { + f2 &= TR2_RES_ELEC; + continue; + } + if (prefix(buf, "It provides resistance to fire.")) + { + f2 &= TR2_RES_FIRE; + continue; + } + if (prefix(buf, "It provides resistance to cold.")) + { + f2 &= TR2_RES_COLD; + continue; + } + if (prefix(buf, "It provides resistance to poison.")) + { + f2 &= TR2_RES_POIS; + continue; + } + if (prefix(buf, "It provides resistance to light.")) + { + f2 &= TR2_RES_LITE; + continue; + } + if (prefix(buf, "It provides resistance to dark.")) + { + f2 &= TR2_RES_DARK; + continue; + } + if (prefix(buf, "It provides resistance to blindness.")) + { + f2 &= TR2_RES_BLIND; + continue; + } + if (prefix(buf, "It provides resistance to confusion.")) + { + f2 &= TR2_RES_CONF; + continue; + } + if (prefix(buf, "It provides resistance to sound.")) + { + f2 &= TR2_RES_SOUND; + continue; + } + if (prefix(buf, "It provides resistance to shards.")) + { + f2 &= TR2_RES_SHARDS; + continue; + } + if (prefix(buf, "It provides resistance to nether.")) + { + f2 &= TR2_RES_NETHER; + continue; + } + if (prefix(buf, "It provides resistance to nexus.")) + { + f2 &= TR2_RES_NEXUS; + continue; + } + if (prefix(buf, "It provides resistance to chaos.")) + { + f2 &= TR2_RES_CHAOS; + continue; + } + if (prefix(buf, "It provides resistance to disenchantment.")) + { + f2 &= TR2_RES_DISEN; + continue; + } + /* Feather Fall */ + if (prefix(buf, "It induces feather falling.")) + { + f3 &= TR3_FEATHER; + continue; + } + /* It Glows! */ + if (prefix(buf, "It provides permanent light.")) + { + f3 &= TR3_LITE; + continue; + } + /* See Invisible */ + if (prefix(buf, "It allows you to see invisible monsters.")) + { + f3 &= TR3_SEE_INVIS; + continue; + } + /* ESP */ + if (prefix(buf, "It gives telepathic powers.")) + { + f3 &= TR3_TELEPATHY; + continue; + } + /* Slow Digestion */ + if (prefix(buf, "It slows your metabolism.")) + { + f3 &= TR3_SLOW_DIGEST; + continue; + } + /* Regenerate */ + if (prefix(buf, "It speeds your regenerative powers.")) + { + f3 &= TR3_REGEN; + continue; + } + /* Extra Mult for Missle Weapons */ + if (prefix(buf, "It fires missiles with extra might.")) + { + f3 &= TR3_XTRA_MIGHT; + continue; + } + /* Extra Shots */ + if (prefix(buf, "It fires missiles excessively fast.")) + { + f3 &= TR3_XTRA_SHOTS; + continue; + } + /* The One Ring! */ + if (prefix(buf, "It drains experience.")) + { + f3 &= TR3_DRAIN_EXP; + continue; + } + /* Teleports (cursed) */ + if (prefix(buf, "It induces random teleportation.")) + { + f3 &= TR3_TELEPORT; + continue; + } + /* Aggravate */ + if (prefix(buf, "It aggravates nearby creatures.")) + { + f3 &= TR3_AGGRAVATE; + continue; + } + /* Can be used by priests */ + if (prefix(buf, "It has been blessed by the gods.")) + { + f3 &= TR3_BLESSED; + continue; + } + /* Perma-curse */ + if (prefix(buf, "It is permanently cursed.")) + { + f3 &= TR3_PERMA_CURSE; + continue; + } + /* Regualar old curse */ + if (prefix(buf, "It is cursed.")) + { + f3 &= TR3_CURSED; + continue; + } + /* Item imunity */ + if (prefix(buf, "It cannot be harmed by acid.")) + { + f3 &= TR3_IGNORE_ACID; + continue; + } + if (prefix(buf, "It cannot be harmed by electricity.")) + { + f3 &= TR3_IGNORE_ELEC; + continue; + } + if (prefix(buf, "It cannot be harmed by fire.")) + { + f3 &= TR3_IGNORE_FIRE; + continue; + } + if (prefix(buf, "It cannot be harmed by cold.")) + { + f3 &= TR3_IGNORE_COLD; + continue; + } + /* press space to go to next screen. */ + if (prefix(buf, "-- more --")) + { + return (TRUE); + } + + } + } + + borg_item->flags1 = f1; + borg_item->flags2 = f2; + borg_item->flags3 = f3; + + borg_item->needs_I = FALSE; + return (FALSE); + } + /* + * Look for an item that needs to be analysed because it has been *ID*d + * + * This will go through inventory and look for items that were just*ID*'d + * and examine them for their bonuses. + */ + bool borg_object_star_id( void ) + { + int i; + + /* look in inventory and equiptment for something to *id* */ + for (i = 0; i < INVEN_TOTAL; i++) + { + if (auto_items[i].needs_I) + { + if ((auto_cheat_equip && i >= INVEN_WIELD ) || + auto_cheat_inven && i < INVEN_WIELD ) + { + /* cheat to get the information. */ + borg_object_star_id_aux( &auto_items[i], &inventory[i]); + } + else + { + byte t_a; + + char buf[10]; + + /* Check to see if we are looking at the 'I' screen. */ + if (!(0 == borg_what_text(0, 0, 9, &t_a, buf) && + buf[0] == 'E' & + buf[1] == 'x' & + buf[2] == 'a' & + buf[3] == 'm' & + buf[4] == 'i' & + buf[5] == 'n' & + buf[6] == 'i' & + buf[7] == 'n' & + buf[8] == 'g') ) + { + borg_keypress('I'); + if (i < INVEN_WIELD) + { + borg_keypress(I2A(i)); + } + else + { + borg_keypress('/'); + borg_keypress(I2A(i - INVEN_WIELD)); + } + return (TRUE); + } + + /* Look at the screen to get the information */ + if (borg_object_star_id_aux( &auto_items[i], 0 )) + { + borg_keypress(' '); + return (TRUE); + } + + /* Get rid of the *ID* screen */ + borg_keypress(' '); + borg_keypress(' '); + borg_keypress(' '); + return (TRUE); + } + } + } + return (FALSE); + } + + + + /* * Determine the "base price" of a known item (see below) * * This function is adapted from "object_value_known()". *************** *** 952,958 **** /* Save a pointer to the inscription */ item->note = scan; - /* Empty item */ if (!desc[0]) return; --- 1460,1465 ---- *************** *** 1267,1272 **** --- 1774,1785 ---- case TV_WAND: case TV_STAFF: { + /* assume 1 charge unless empty. This will allow use of */ + /* staffs of teleport to get away when hit with a forget spell. */ + item->pval = 1; + + if (streq(item->note, "{empty}")) item->pval = 0; + /* Require the prefix and suffix */ if (!prefix(tail, " (")) break; /* --(-- */ if (!suffix(tail, " charge)") && !suffix(tail, " charges)")) break; *************** *** 1704,1709 **** --- 2217,2225 ---- /* Apply "discount" if any */ if (item->discount) item->value -= item->value * item->discount / 100; + + /* Assume not fully Identified. */ + item->needs_I = item->fully_identified = FALSE; } *************** *** 2038,2046 **** return (FALSE); } - - - /* * Determine if borg can cast a given spell (when fully rested) */ --- 2554,2559 ---- *************** *** 2087,2092 **** --- 2600,2686 ---- } /* + * fail rate on a spell + */ + static int borg_spell_fail_rate(int book, int what) + { + int chance, minfail; + auto_magic *as = &auto_magics[book][what]; + + /* Access the spell */ + chance = as->sfail; + + /* Reduce failure rate by "effective" level adjustment */ + chance -= 3 * (auto_level - as->level); + + /* Reduce failure rate by INT/WIS adjustment */ + chance -= 3 * (adj_mag_stat[my_stat_ind[A_INT]] - 1); + + /* Not enough mana to cast */ + /* Do not bother with this check because it will be taken care + of seperatly. + if (as->power > auto_csp) + { + chance += 5 * (as->power - auto_csp); + } + */ + + /* Extract the minimum failure rate */ + minfail = adj_mag_fail[my_stat_ind[A_INT]]; + + /* Non mage characters never get too good */ + if (auto_class != CLASS_MAGE) + { + if (minfail < 5) minfail = 5; + } + + /* Minimum failure rate */ + if (chance < minfail) chance = minfail; + + /* Stunning makes spells harder */ + if (do_heavy_stun) chance += 25; + if (do_stun) chance += 15; + + /* Always a 5 percent chance of working */ + if (chance > 95) chance = 95; + + /* Return the chance */ + return (chance); + + + } + + /* + * same as borg_spell_okay with a fail % check + */ + bool borg_spell_okay_fail(int book, int what, int allow_fail ) + { + if (borg_spell_fail_rate(book, what) > allow_fail) + return FALSE; + return borg_spell_okay( book, what ); + } + + /* + * Same as borg_spell with a fail % check + */ + bool borg_spell_fail(int book, int what, int allow_fail) + { + if (borg_spell_fail_rate(book, what) > allow_fail) + return FALSE; + return borg_spell( book, what ); + } + + /* + * Same as borg_spell_legal with a fail % check + */ + bool borg_spell_legal_fail(int book, int what, int allow_fail) + { + if (borg_spell_fail_rate(book, what) > allow_fail) + return FALSE; + return borg_spell_legal( book, what ); + } + + /* * Attempt to cast a spell */ bool borg_spell(int book, int what) *************** *** 2162,2168 **** --- 2756,2854 ---- return (TRUE); } + static int borg_prayer_fail_rate(int book, int what) + { + int chance, minfail; + auto_magic *as = &auto_magics[book][what]; + + /* Access the spell */ + chance = as->sfail; + + /* Reduce failure rate by "effective" level adjustment */ + chance -= 3 * (auto_level - as->level); + + /* Reduce failure rate by INT/WIS adjustment */ + chance -= 3 * (adj_mag_stat[my_stat_ind[A_WIS]] - 1); + + /* Not enough mana to cast */ + /* Do not bother with this check because it will be taken care + of seperatly. + if (as->power > auto_csp) + { + chance += 5 * (as->power - auto_csp); + } + */ + /* Extract the minimum failure rate */ + minfail = adj_mag_fail[my_stat_ind[A_WIS]]; + + /* Non priest characters never get too good */ + if (auto_class != CLASS_PRIEST) + { + if (minfail < 5) minfail = 5; + } + + /* Hack -- Priest prayer penalty for "edged" weapons -DGK */ + if (auto_class == CLASS_PRIEST) + { + auto_item *item; + + item = &auto_items[INVEN_WIELD]; + + /* Penalize non-blessed edged weapons */ + if (((item->tval == TV_SWORD) || (item->tval == TV_POLEARM)) && + (!(item->flags3 & TR3_BLESSED))) + { + chance += 25; + } + } + /* Minimum failure rate */ + if (chance < minfail) chance = minfail; + + /* Stunning makes spells harder */ + if (do_heavy_stun) chance += 25; + if (do_stun) chance += 15; + + /* Always a 5 percent chance of working */ + if (chance > 95) chance = 95; + + /* Return the chance */ + return (chance); + + + } + + /* + * same as borg_prayer_okay with a fail % check + */ + bool borg_prayer_okay_fail(int book, int what, int allow_fail ) + { + if (borg_prayer_fail_rate(book, what) > allow_fail) + return FALSE; + return borg_prayer_okay( book, what ); + } + + /* + * Same as borg_prayer with a fail % check + */ + bool borg_prayer_fail(int book, int what, int allow_fail) + { + if (borg_prayer_fail_rate(book, what) > allow_fail) + return FALSE; + return borg_prayer( book, what ); + } + + /* + * Same as borg_prayer_legal with a fail % check + */ + bool borg_prayer_legal_fail(int book, int what, int allow_fail) + { + if (borg_prayer_fail_rate(book, what) > allow_fail) + return FALSE; + return borg_prayer_legal( book, what ); + } + + /* * Attempt to pray a prayer */ bool borg_prayer(int book, int what) *************** *** 2192,2201 **** return (TRUE); } - - - - /* * Cheat the "equip" screen */ --- 2878,2883 ---- *************** *** 2219,2230 **** } /* Ignore "unchanged" items */ if (streq(buf, auto_items[i].desc)) continue; ! /* Analyze the item (no price) */ borg_item_analyze(&auto_items[i], buf); } } /* --- 2901,2925 ---- } /* Ignore "unchanged" items */ + /* !FIX do I still need this? I forget... AJG */ + if (auto_items[i].needs_I) + { if (streq(buf, auto_items[i].desc)) continue; ! } /* Analyze the item (no price) */ borg_item_analyze(&auto_items[i], buf); + + /* get the fully id stuff */ + #ifdef ID_MENTAL + if (inventory[i].ident & ID_MENTAL) + { + auto_items[i].fully_identified = TRUE; + auto_items[i].needs_I = TRUE; + auto_do_star_id = TRUE; } + #endif } + } /* *************** *** 2255,2263 **** --- 2950,2970 ---- /* Ignore "unchanged" items */ if (streq(buf, auto_items[i].desc)) continue; + /* inventory changed so goals must change. */ + goal_shop = goal_ware = goal_item = -1; + /* Analyze the item (no price) */ borg_item_analyze(&auto_items[i], buf); + /* get the fully id stuff */ + #ifdef ID_MENTAL + if (inventory[i].ident & ID_MENTAL) + { + auto_items[i].fully_identified = TRUE; + auto_items[i].needs_I = TRUE; + auto_do_star_id = TRUE; + } + #endif /* Note changed inventory */ auto_do_crush_junk = TRUE; auto_do_crush_hole = TRUE; *************** *** 2328,2335 **** --- 3035,3052 ---- /* Analyze the item (no price) */ borg_item_analyze(&auto_items[i], buf); + + /* get the fully *id* stuff */ + #ifdef ID_MENTAL + if (inventory[i].ident & ID_MENTAL) + { + auto_items[i].fully_identified = TRUE; + auto_items[i].needs_I = TRUE; + auto_do_star_id = TRUE; } + #endif } + } /* *************** *** 2408,2413 **** --- 3125,3139 ---- /* Analyze the item (no price) */ borg_item_analyze(&auto_items[i], buf); + /* get the fully id stuff */ + #ifdef ID_MENTAL + if (inventory[i].ident & ID_MENTAL) + { + auto_items[i].fully_identified = TRUE; + auto_items[i].needs_I = TRUE; + auto_do_star_id = TRUE; + } + #endif /* Note changed inventory */ auto_do_crush_junk = TRUE; auto_do_crush_hole = TRUE; *************** *** 2416,2424 **** } - - - /* * Hack -- Cheat the "spell" info (given the book) * --- 3142,3147 ---- *************** *** 2447,2454 **** /* Note "forgotten" spells */ if ((j < 32) ? ! ((p_ptr->spell_forgotten1 & (1L << j))) : ! ((p_ptr->spell_forgotten2 & (1L << (j - 32))))) { /* Forgotten */ as->status = BORG_MAGIC_LOST; --- 3170,3177 ---- /* Note "forgotten" spells */ if ((j < 32) ? ! ((spell_forgotten1 & (1L << j))) : ! ((spell_forgotten2 & (1L << (j - 32))))) { /* Forgotten */ as->status = BORG_MAGIC_LOST; *************** *** 2463,2470 **** /* Note "unknown" spells */ else if (!((j < 32) ? ! (p_ptr->spell_learned1 & (1L << j)) : ! (p_ptr->spell_learned2 & (1L << (j - 32))))) { /* Unknown */ as->status = BORG_MAGIC_OKAY; --- 3186,3193 ---- /* Note "unknown" spells */ else if (!((j < 32) ? ! (spell_learned1 & (1L << j)) : ! (spell_learned2 & (1L << (j - 32))))) { /* Unknown */ as->status = BORG_MAGIC_OKAY; *************** *** 2472,2479 **** /* Note "untried" spells */ else if (!((j < 32) ? ! (p_ptr->spell_worked1 & (1L << j)) : ! (p_ptr->spell_worked2 & (1L << (j - 32))))) { /* Untried */ as->status = BORG_MAGIC_TEST; --- 3195,3202 ---- /* Note "untried" spells */ else if (!((j < 32) ? ! (spell_worked1 & (1L << j)) : ! (spell_worked2 & (1L << (j - 32))))) { /* Untried */ as->status = BORG_MAGIC_TEST; *************** *** 2488,2497 **** } } - - - - /* * Hack -- Parse the "spell" info (given the book) */ --- 3211,3216 ---- *************** *** 2567,2576 **** /* * Prepare a book */ ! void borg_prepare_book(int book) { int i, what; --- 3286,3296 ---- + /* * Prepare a book */ ! static void prepare_book_info(int book) { int i, what; *************** *** 2646,2651 **** --- 3366,3374 ---- /* Extract the level and power */ as->level = s_ptr->slevel; as->power = s_ptr->smana; + + /* extract fail rate. */ + as->sfail = s_ptr->sfail; } } *************** *** 2652,2657 **** --- 3375,3393 ---- /* + * Hack -- prepare some stuff based on the player race and class + */ + void prepare_race_class_info(void) + { + int book; + + /* Initialize the various spell arrays by book */ + for (book = 0; book < 9; book++) prepare_book_info(book); + } + + + + /* * Sorting hook -- comp function -- see below * * We use "u" to point to an array of strings, and "v" to point to *************** *** 2753,2758 **** --- 3489,3495 ---- /* Make the "safe" inventory array */ C_MAKE(safe_items, INVEN_TOTAL, auto_item); + C_MAKE(safe_home, STORE_INVEN_MAX, auto_item); /* Make the "safe" stores in the town */ C_MAKE(safe_shops, 8, auto_shop); *************** *** 2781,2786 **** --- 3518,3524 ---- if (k_ptr->flags3 & TR3_INSTA_ART) continue; /* Hack -- make an item */ + /* invcopy(&hack, k); This has gone - Tim */ object_prep(&hack, k); /* Describe a "plural" object */ *************** *** 2835,2840 **** --- 3573,3579 ---- if (k_ptr->flags3 & TR3_INSTA_ART) continue; /* Hack -- make an item */ + /* invcopy(&hack, k); this has changed - Tim*/ object_prep(&hack, k); /* Describe a "singular" object */ *************** *** 2866,2871 **** --- 3605,3611 ---- k = lookup_kind(a_ptr->tval, a_ptr->sval); /* Hack -- make an item */ + /* invcopy(&hack, k); this has changed - Tim */ object_prep(&hack, k); /* Save the index */ *************** *** 2965,2974 **** } #else #ifdef MACINTOSH static int HACK = 0; ! #endif /* MACINTOSH */ ! #endif /* ALLOW_BORG */ --- 3705,3715 ---- } + #else #ifdef MACINTOSH static int HACK = 0; ! #endif ! #endif diff -w -c -r Borg/borg3.h adamborg/borg3.h *** Borg/borg3.h Sun Apr 13 23:20:34 1997 --- adamborg/borg3.h Sun Apr 13 23:24:19 1997 *************** *** 55,60 **** --- 55,64 ---- bool able; /* True if item is identified */ + bool fully_identified; /* True if item is fully identified (AJG) */ + + bool needs_I; /* True if item needs to be 'I'd (AJG) */ + bool xxxx; /* Unused */ byte tval; /* Item type */ *************** *** 155,160 **** --- 159,166 ---- byte power; /* Required power */ + byte sfail; /* Minimum chance of failure */ + byte cheat; /* Actual "spell index" (or 99) */ }; *************** *** 174,179 **** --- 180,186 ---- */ extern auto_item *safe_items; /* Safety "inventory" */ + extern auto_item *safe_home; /* Safety "home" */ extern auto_shop *safe_shops; /* Safety "shops" */ *************** *** 198,203 **** --- 205,216 ---- extern void borg_item_analyze(auto_item *item, cptr desc); + /* look for a *id*'d item */ + extern bool borg_object_star_id( void ); + + /* look for a *id*'d item */ + extern bool borg_object_star_id_aux(auto_item *borg_item, object_type *real_item); + /* * Inscribe an object */ *************** *** 242,247 **** --- 255,263 ---- extern bool borg_spell_legal(int book, int what); extern bool borg_spell_okay(int book, int what); extern bool borg_spell(int book, int what); + extern bool borg_spell_fail(int book, int what, int allow_fail); + extern bool borg_spell_okay_fail(int book, int what, int allow_fail ); + extern bool borg_spell_legal_fail(int book, int what, int allow_fail ); /* * Prayer functions *************** *** 249,254 **** --- 265,273 ---- extern bool borg_prayer_legal(int book, int what); extern bool borg_prayer_okay(int book, int what); extern bool borg_prayer(int book, int what); + extern bool borg_prayer_fail(int book, int what, int allow_fail); + extern bool borg_prayer_okay_fail(int book, int what, int allow_fail ); + extern bool borg_prayer_legal_fail(int book, int what, int allow_fail ); *************** *** 267,275 **** extern void borg_parse_spell(int book); /* ! * Prepare a book */ ! extern void borg_prepare_book(int book); /* * Initialize this file --- 286,294 ---- extern void borg_parse_spell(int book); /* ! * Hack -- prepare stuff based on the race/class */ ! extern void prepare_race_class_info(void); /* * Initialize this file diff -w -c -r Borg/borg4.c adamborg/borg4.c *** Borg/borg4.c Sun Apr 13 23:20:55 1997 --- adamborg/borg4.c Sun Apr 13 23:25:02 1997 *************** *** 11,16 **** --- 11,17 ---- #include "borg3.h" #include "borg4.h" + bool borg_full_damage; /* make danger = full damage. */ /* * Note that we assume that any item with quantity zero does not exist, *************** *** 71,85 **** int extra_shots = 0; int extra_might = 0; - int stat_add[6]; - auto_item *item; - /* Clear the stat modifiers */ - for (i = 0; i < 6; i++) stat_add[i] = 0; - /* Clear the armor class */ my_ac = 0; --- 72,81 ---- *************** *** 87,97 **** my_to_hit = my_to_dam = my_to_ac = 0; ! /* Reset blows */ my_num_blow = 1; ! /* Reset shots */ ! my_num_fire = 0; /* Assume normal speed */ --- 83,93 ---- my_to_hit = my_to_dam = my_to_ac = 0; ! /* Start with a single blow per turn */ my_num_blow = 1; ! /* Start with a single shot per turn */ ! my_num_fire = 1; /* Assume normal speed */ *************** *** 126,131 **** --- 122,142 ---- my_telepathy = FALSE; my_lite = FALSE; + my_slay_animal = FALSE; + my_slay_evil = FALSE; + my_slay_undead = FALSE; + my_slay_demon = FALSE; + my_slay_orc = FALSE; + my_slay_troll = FALSE; + my_slay_giant = FALSE; + my_slay_dragon = FALSE; + my_kill_dragon = FALSE; + my_impact = FALSE; + my_brand_acid = FALSE; + my_brand_elec = FALSE; + my_brand_fire = FALSE; + my_brand_cold = FALSE; + my_immune_acid = FALSE; my_immune_elec = FALSE; my_immune_fire = FALSE; *************** *** 136,152 **** my_resist_fire = FALSE; my_resist_cold = FALSE; my_resist_pois = FALSE; ! my_resist_fear = FALSE; my_resist_lite = FALSE; my_resist_dark = FALSE; - my_resist_blind = FALSE; - my_resist_confu = FALSE; - my_resist_sound = FALSE; - my_resist_shard = FALSE; - my_resist_nexus = FALSE; - my_resist_nethr = FALSE; my_resist_chaos = FALSE; my_resist_disen = FALSE; my_sustain_str = FALSE; my_sustain_int = FALSE; --- 147,163 ---- my_resist_fire = FALSE; my_resist_cold = FALSE; my_resist_pois = FALSE; ! my_resist_conf = FALSE; ! my_resist_sound = FALSE; my_resist_lite = FALSE; my_resist_dark = FALSE; my_resist_chaos = FALSE; my_resist_disen = FALSE; + my_resist_shard = FALSE; + my_resist_nexus = FALSE; + my_resist_blind = FALSE; + my_resist_neth = FALSE; + my_resist_fear = FALSE; my_sustain_str = FALSE; my_sustain_int = FALSE; *************** *** 216,221 **** --- 227,234 ---- if (auto_race == RACE_HIGH_ELF) my_resist_lite = TRUE; if (auto_race == RACE_HIGH_ELF) my_see_inv = TRUE; + /* Clear the stat modifiers */ + for (i = 0; i < 6; i++) my_stat_add[i] = 0; /* Scan the usable inventory */ for (i = INVEN_WIELD; i < INVEN_TOTAL; i++) *************** *** 226,238 **** if (!item->iqty) continue; /* Affect stats */ ! if (item->flags1 & TR1_STR) stat_add[A_STR] += item->pval; ! if (item->flags1 & TR1_INT) stat_add[A_INT] += item->pval; ! if (item->flags1 & TR1_WIS) stat_add[A_WIS] += item->pval; ! if (item->flags1 & TR1_DEX) stat_add[A_DEX] += item->pval; ! if (item->flags1 & TR1_CON) stat_add[A_CON] += item->pval; ! if (item->flags1 & TR1_CHR) stat_add[A_CHR] += item->pval; /* Affect infravision */ if (item->flags1 & TR1_INFRA) my_see_infra += item->pval; --- 239,267 ---- if (!item->iqty) continue; /* Affect stats */ ! if (item->flags1 & TR1_STR) my_stat_add[A_STR] += item->pval; ! if (item->flags1 & TR1_INT) my_stat_add[A_INT] += item->pval; ! if (item->flags1 & TR1_WIS) my_stat_add[A_WIS] += item->pval; ! if (item->flags1 & TR1_DEX) my_stat_add[A_DEX] += item->pval; ! if (item->flags1 & TR1_CON) my_stat_add[A_CON] += item->pval; ! if (item->flags1 & TR1_CHR) my_stat_add[A_CHR] += item->pval; + /* various slays */ + if (item->flags1 & TR1_SLAY_ANIMAL) my_slay_animal = TRUE; + if (item->flags1 & TR1_SLAY_EVIL) my_slay_evil = TRUE; + if (item->flags1 & TR1_SLAY_UNDEAD) my_slay_undead = TRUE; + if (item->flags1 & TR1_SLAY_DEMON) my_slay_demon = TRUE; + if (item->flags1 & TR1_SLAY_ORC) my_slay_orc = TRUE; + if (item->flags1 & TR1_SLAY_TROLL) my_slay_troll = TRUE; + if (item->flags1 & TR1_SLAY_GIANT) my_slay_giant = TRUE; + if (item->flags1 & TR1_SLAY_DRAGON) my_slay_dragon = TRUE; + if (item->flags1 & TR1_KILL_DRAGON) my_kill_dragon = TRUE; + if (item->flags1 & TR1_IMPACT) my_impact = TRUE; + if (item->flags1 & TR1_BRAND_ACID) my_brand_acid = TRUE; + if (item->flags1 & TR1_BRAND_ELEC) my_brand_elec = TRUE; + if (item->flags1 & TR1_BRAND_FIRE) my_brand_fire = TRUE; + if (item->flags1 & TR1_BRAND_COLD) my_brand_cold = TRUE; + /* Affect infravision */ if (item->flags1 & TR1_INFRA) my_see_infra += item->pval; *************** *** 255,284 **** if (item->flags1 & TR1_BLOWS) extra_blows += item->pval; /* Boost shots */ ! if (item->flags1 & TR1_SHOTS) extra_shots += item->pval; /* Boost might */ ! if (item->flags1 & TR1_MIGHT) extra_might += item->pval; ! /* Good flags */ if (item->flags3 & TR3_SLOW_DIGEST) my_slow_digest = TRUE; ! if (item->flags3 & TR3_FEATHER) my_ffall = TRUE; ! if (item->flags3 & TR3_LITE) my_lite = TRUE; if (item->flags3 & TR3_REGEN) my_regenerate = TRUE; if (item->flags3 & TR3_TELEPATHY) my_telepathy = TRUE; if (item->flags3 & TR3_SEE_INVIS) my_see_inv = TRUE; ! if (item->flags3 & TR3_FREE_ACT) my_free_act = TRUE; ! if (item->flags3 & TR3_HOLD_LIFE) my_hold_life = TRUE; - /* Bad flags */ - if (item->flags3 & TR3_TELEPORT) my_teleport = TRUE; - if (item->flags3 & TR3_AGGRAVATE) my_aggravate = TRUE; - /* Immunity flags */ ! if (item->flags2 & TR2_IM_FIRE) my_immune_fire = TRUE; ! if (item->flags2 & TR2_IM_ACID) my_immune_acid = TRUE; ! if (item->flags2 & TR2_IM_COLD) my_immune_cold = TRUE; ! if (item->flags2 & TR2_IM_ELEC) my_immune_elec = TRUE; /* Resistance flags */ if (item->flags2 & TR2_RES_ACID) my_resist_acid = TRUE; --- 284,328 ---- if (item->flags1 & TR1_BLOWS) extra_blows += item->pval; /* Boost shots */ ! if (item->flags3 & TR3_XTRA_SHOTS) extra_shots++; /* Boost might */ ! if (item->flags3 & TR3_XTRA_MIGHT) extra_might++; ! /* Various flags */ if (item->flags3 & TR3_SLOW_DIGEST) my_slow_digest = TRUE; ! if (item->flags3 & TR3_AGGRAVATE) my_aggravate = TRUE; ! if (item->flags3 & TR3_TELEPORT) my_teleport = TRUE; if (item->flags3 & TR3_REGEN) my_regenerate = TRUE; if (item->flags3 & TR3_TELEPATHY) my_telepathy = TRUE; + if (item->flags3 & TR3_LITE) my_lite = TRUE; if (item->flags3 & TR3_SEE_INVIS) my_see_inv = TRUE; ! if (item->flags3 & TR3_FEATHER) my_ffall = TRUE; ! if (item->flags2 & TR2_FREE_ACT) my_free_act = TRUE; ! if (item->flags2 & TR2_HOLD_LIFE) my_hold_life = TRUE; /* Immunity flags */ ! /* if you are immune you automaticly resist */ ! if (item->flags2 & TR2_IM_FIRE) ! { ! my_immune_fire = TRUE; ! my_resist_fire = TRUE; ! } ! if (item->flags2 & TR2_IM_ACID) ! { ! my_immune_acid = TRUE; ! my_resist_acid = TRUE; ! } ! if (item->flags2 & TR2_IM_COLD) ! { ! my_immune_cold = TRUE; ! my_resist_cold = TRUE; ! } ! if (item->flags2 & TR2_IM_ELEC) ! { ! my_immune_elec = TRUE; ! my_resist_elec = TRUE; ! } /* Resistance flags */ if (item->flags2 & TR2_RES_ACID) my_resist_acid = TRUE; *************** *** 286,302 **** if (item->flags2 & TR2_RES_FIRE) my_resist_fire = TRUE; if (item->flags2 & TR2_RES_COLD) my_resist_cold = TRUE; if (item->flags2 & TR2_RES_POIS) my_resist_pois = TRUE; ! if (item->flags2 & TR2_RES_FEAR) my_resist_fear = TRUE; if (item->flags2 & TR2_RES_LITE) my_resist_lite = TRUE; if (item->flags2 & TR2_RES_DARK) my_resist_dark = TRUE; - if (item->flags2 & TR2_RES_BLIND) my_resist_blind = TRUE; - if (item->flags2 & TR2_RES_CONFU) my_resist_confu = TRUE; - if (item->flags2 & TR2_RES_SOUND) my_resist_sound = TRUE; - if (item->flags2 & TR2_RES_SHARD) my_resist_shard = TRUE; - if (item->flags2 & TR2_RES_NEXUS) my_resist_nexus = TRUE; - if (item->flags2 & TR2_RES_NETHR) my_resist_nethr = TRUE; if (item->flags2 & TR2_RES_CHAOS) my_resist_chaos = TRUE; if (item->flags2 & TR2_RES_DISEN) my_resist_disen = TRUE; /* Sustain flags */ if (item->flags2 & TR2_SUST_STR) my_sustain_str = TRUE; --- 330,345 ---- if (item->flags2 & TR2_RES_FIRE) my_resist_fire = TRUE; if (item->flags2 & TR2_RES_COLD) my_resist_cold = TRUE; if (item->flags2 & TR2_RES_POIS) my_resist_pois = TRUE; ! if (item->flags2 & TR2_RES_CONF) my_resist_conf = TRUE; ! if (item->flags2 & TR2_RES_SOUND) my_resist_sound = TRUE; if (item->flags2 & TR2_RES_LITE) my_resist_lite = TRUE; if (item->flags2 & TR2_RES_DARK) my_resist_dark = TRUE; if (item->flags2 & TR2_RES_CHAOS) my_resist_chaos = TRUE; if (item->flags2 & TR2_RES_DISEN) my_resist_disen = TRUE; + if (item->flags2 & TR2_RES_SHARDS) my_resist_shard = TRUE; + if (item->flags2 & TR2_RES_NEXUS) my_resist_nexus = TRUE; + if (item->flags2 & TR2_RES_BLIND) my_resist_blind = TRUE; + if (item->flags2 & TR2_RES_NETHER) my_resist_neth = TRUE; /* Sustain flags */ if (item->flags2 & TR2_SUST_STR) my_sustain_str = TRUE; *************** *** 324,330 **** } /* Hack -- Chaos / Confusion */ ! if (my_resist_chaos) my_resist_confu = TRUE; /* Update "stats" */ --- 367,373 ---- } /* Hack -- Chaos / Confusion */ ! if (my_resist_chaos) my_resist_conf = TRUE; /* Update "stats" */ *************** *** 333,339 **** int use, ind; /* Extract the new "use_stat" value for the stat */ ! use = modify_stat_value(my_stat_cur[i], stat_add[i]); /* Save the stat */ my_stat_use[i] = use; --- 376,382 ---- int use, ind; /* Extract the new "use_stat" value for the stat */ ! use = modify_stat_value(my_stat_cur[i], my_stat_add[i]); /* Save the stat */ my_stat_use[i] = use; *************** *** 386,391 **** --- 429,444 ---- /* Examine the "current bow" */ item = &auto_items[INVEN_BOW]; + /* attacking with bare hands */ + if (item->iqty == 0) + { + item->ds = 0; + item->dd = 0; + item->to_d = 0; + item->to_h = 0; + item->weight = 0; + } + /* It is hard to carholdry a heavy bow */ if (hold < item->weight / 10) { *************** *** 394,451 **** } /* Compute "extra shots" if needed */ ! if (item->iqty) { ! /* Single shot */ ! my_num_fire = 1; ! ! /* Analyze bow */ switch (item->sval) { case SV_SLING: - { my_ammo_tval = TV_SHOT; my_ammo_sides = 3; my_ammo_power = 2; break; - } case SV_SHORT_BOW: - { my_ammo_tval = TV_ARROW; my_ammo_sides = 4; my_ammo_power = 2; break; - } case SV_LONG_BOW: - { my_ammo_tval = TV_ARROW; my_ammo_sides = 4; my_ammo_power = 3; break; - } case SV_LIGHT_XBOW: - { my_ammo_tval = TV_BOLT; my_ammo_sides = 5; my_ammo_power = 3; break; - } case SV_HEAVY_XBOW: - { my_ammo_tval = TV_BOLT; my_ammo_sides = 5; my_ammo_power = 4; break; } - } - /* Light */ - if (hold >= item->weight / 10) - { /* Add in extra power */ my_ammo_power += extra_might; --- 447,488 ---- } /* Compute "extra shots" if needed */ ! if (item->iqty && (hold >= item->weight / 10)) { ! /* Take note of required "tval" for missiles */ switch (item->sval) { case SV_SLING: my_ammo_tval = TV_SHOT; my_ammo_sides = 3; my_ammo_power = 2; break; case SV_SHORT_BOW: my_ammo_tval = TV_ARROW; my_ammo_sides = 4; my_ammo_power = 2; break; case SV_LONG_BOW: my_ammo_tval = TV_ARROW; my_ammo_sides = 4; my_ammo_power = 3; break; case SV_LIGHT_XBOW: my_ammo_tval = TV_BOLT; my_ammo_sides = 5; my_ammo_power = 3; break; case SV_HEAVY_XBOW: my_ammo_tval = TV_BOLT; my_ammo_sides = 5; my_ammo_power = 4; break; } /* Add in extra power */ my_ammo_power += extra_might; *************** *** 453,459 **** my_ammo_range = 10 + my_ammo_power * 5; /* Hack -- High Level Rangers shoot arrows quickly */ ! if ((auto_class == CLASS_RANGER) && (my_ammo_tval == TV_ARROW)) { /* Extra shot at level 20 */ if (auto_max_level >= 20) my_num_fire++; --- 490,496 ---- my_ammo_range = 10 + my_ammo_power * 5; /* Hack -- High Level Rangers shoot arrows quickly */ ! if ((auto_class == 4) && (my_ammo_tval == TV_ARROW)) { /* Extra shot at level 20 */ if (auto_max_level >= 20) my_num_fire++; *************** *** 464,480 **** /* Add in the "bonus shots" */ my_num_fire += extra_shots; - } - } - /* Paranoia */ /* Require at least one shot */ if (my_num_fire < 1) my_num_fire = 1; /* Examine the "main weapon" */ item = &auto_items[INVEN_WIELD]; /* It is hard to hold a heavy weapon */ if (hold < item->weight / 10) { --- 501,526 ---- /* Add in the "bonus shots" */ my_num_fire += extra_shots; /* Require at least one shot */ if (my_num_fire < 1) my_num_fire = 1; + } + /* Examine the "main weapon" */ item = &auto_items[INVEN_WIELD]; + /* attacking with bare hands */ + if (item->iqty == 0) + { + item->ds = 0; + item->dd = 0; + item->to_d = 0; + item->to_h = 0; + item->weight = 0; + } + /* It is hard to hold a heavy weapon */ if (hold < item->weight / 10) { *************** *** 624,629 **** --- 670,690 ---- if (!item->able) continue; /* Enchant all weapons (to hit) */ + if (borg_prayer_legal(7, 3)) + { + if (item->to_h < 12) + { + my_need_enchant_to_h += (12 - item->to_h); + } + + /* Enchant all weapons (to damage) */ + if (item->to_d < 12) + { + my_need_enchant_to_d += (12 - item->to_d); + } + } + else + { if (item->to_h < 8) { my_need_enchant_to_h += (8 - item->to_h); *************** *** 635,640 **** --- 696,702 ---- my_need_enchant_to_d += (8 - item->to_d); } } + } /* Hack -- enchant all the equipment (armor) */ for (i = INVEN_BODY; i <= INVEN_FEET; i++) *************** *** 648,658 **** --- 710,730 ---- if (!item->able) continue; /* Note need for enchantment */ + if (borg_prayer_legal(7, 4)) + { + if (item->to_a < 15) + { + my_need_enchant_to_a += (15 - item->to_a); + } + } + else + { if (item->to_a < 8) { my_need_enchant_to_a += (8 - item->to_a); } } + } /* Examine the lite */ *************** *** 677,688 **** if (!item->pval) my_cur_lite = 0; /* Artifact lites -- radius three */ ! if (item->name1) my_cur_lite = 3; /* Artifact lites -- assume glowing */ ! if (item->name1) my_lite = TRUE; } } /* --- 749,765 ---- if (!item->pval) my_cur_lite = 0; /* Artifact lites -- radius three */ ! /* HACK assume non-torch/non lantern lite is artifact */ ! if ((item->sval != SV_LITE_TORCH) && ! (item->sval != SV_LITE_LANTERN)) ! { ! my_cur_lite = 3; /* Artifact lites -- assume glowing */ ! my_lite = TRUE; } } + } /* *************** *** 701,712 **** --- 778,795 ---- amt_fuel = 0; amt_food = 0; amt_ident = 0; + amt_star_ident = 0; amt_recall = 0; amt_phase = 0; amt_escape = 0; amt_teleport = 0; + amt_teleport_staff = 0; /* Reset healing */ + amt_mana = 0; + amt_ez_mana = 0; + amt_heal = 0; + amt_ez_heal = 0; amt_cure_critical = 0; amt_cure_serious = 0; *************** *** 743,748 **** --- 826,833 ---- amt_fix_stat[A_CHR] = 0; amt_fix_exp = 0; + amt_speed = 0; + /* Reset enchantment */ amt_enchant_to_a = 0; amt_enchant_to_d = 0; *************** *** 799,804 **** --- 884,898 ---- /* Analyze */ switch (item->sval) { + case SV_POTION_HEALING: + amt_heal += item->iqty; + break; + + case SV_POTION_STAR_HEALING: + case SV_POTION_LIFE: + amt_ez_heal += item->iqty; + break; + case SV_POTION_CURE_CRITICAL: amt_cure_critical += item->iqty; break; *************** *** 858,863 **** --- 952,966 ---- case SV_POTION_RESTORE_EXP: amt_fix_exp += item->iqty; break; + + case SV_POTION_SPEED: + amt_speed += item->iqty; + break; + + case SV_POTION_RESTORE_MANA: + amt_mana += item->iqty; + break; + } break; *************** *** 873,878 **** --- 976,985 ---- amt_ident += item->iqty; break; + case SV_SCROLL_STAR_IDENTIFY: + amt_star_ident += item->iqty; + break; + case SV_SCROLL_PHASE_DOOR: amt_phase += item->iqty; break; *************** *** 927,932 **** --- 1034,1048 ---- amt_detect_trap += item->iqty * 100; amt_detect_door += item->iqty * 100; break; + + case SV_ROD_SPEED: + amt_speed += item->iqty * 100; + break; + + case SV_ROD_HEALING: + /* only +1 per rod because of long charge time. */ + amt_ez_heal += item->iqty; + break; } break; *************** *** 944,950 **** --- 1060,1082 ---- case SV_STAFF_TELEPORTATION: amt_teleport += item->iqty * item->pval; + /* do not count staffs with no changes */ + if (item->pval) + amt_teleport_staff += item->iqty; break; + + case SV_STAFF_SPEED: + amt_speed += item->iqty * item->pval; + break; + + case SV_STAFF_HEALING: + amt_ez_heal += item->iqty * item->pval; + break; + + case SV_STAFF_THE_MAGI: + amt_ez_mana += item->iqty * item->pval; + break; + } break; *************** *** 976,981 **** --- 1108,1143 ---- /* Count them */ amt_missile += item->iqty; + /* if we have shit loads of cash (as we will at level 35), */ + /* enchant missiles */ + if (auto_level > 35) + { + if (borg_prayer_legal(7, 3) && item->iqty >= 10) + { + if (item->to_h < 10) + { + my_need_enchant_to_h += (10 - item->to_h); + } + + if (item->to_d < 10) + { + my_need_enchant_to_d += (10 - item->to_d); + } + } + else + { + if (item->to_h < 8) + { + my_need_enchant_to_h += (8 - item->to_h); + } + + if (item->to_d < 8) + { + my_need_enchant_to_d += (8 - item->to_d); + } + } + } + break; } } *************** *** 984,990 **** /*** Process the Spells and Prayers ***/ /* Handle "satisfy hunger" -> infinite food */ ! if (borg_spell_legal(2, 0) || borg_prayer_legal(1, 5)) { amt_food += 1000; } --- 1146,1152 ---- /*** Process the Spells and Prayers ***/ /* Handle "satisfy hunger" -> infinite food */ ! if (borg_spell_legal_fail(2, 0, 20) || borg_prayer_legal_fail(1, 5, 20)) { amt_food += 1000; } *************** *** 1034,1053 **** amt_enchant_to_a += 1000; } /*** Process the Needs ***/ /* No need for fuel */ ! if (auto_items[INVEN_LITE].name1) amt_fuel += 1000; /* No need to *buy* stat increase potions */ ! if (my_stat_cur[A_STR] >= 18+80) amt_add_stat[A_STR] += 1000; ! if (my_stat_cur[A_INT] >= 18+80) amt_add_stat[A_INT] += 1000; ! if (my_stat_cur[A_WIS] >= 18+80) amt_add_stat[A_WIS] += 1000; ! if (my_stat_cur[A_DEX] >= 18+80) amt_add_stat[A_DEX] += 1000; ! if (my_stat_cur[A_CON] >= 18+80) amt_add_stat[A_CON] += 1000; ! if (my_stat_cur[A_CHR] >= 18+80) amt_add_stat[A_CHR] += 1000; /* No need to *buy* stat repair potions XXX XXX XXX */ if (!do_fix_stat[A_STR]) amt_fix_stat[A_STR] += 1000; if (!do_fix_stat[A_INT]) amt_fix_stat[A_INT] += 1000; --- 1196,1246 ---- amt_enchant_to_a += 1000; } + /* Handle recall */ + if (borg_prayer_legal(4, 4) || borg_spell_legal(5, 4)) + { + amt_recall += 1000; + } + /* speed spells */ + if ( borg_spell_legal( 3, 3 ) || + borg_spell_legal( 7, 3 )) + { + amt_speed += 1000; + } + + /*** Process the Needs ***/ /* No need for fuel */ ! if ((auto_items[INVEN_LITE].sval != SV_LITE_TORCH) && ! (auto_items[INVEN_LITE].sval != SV_LITE_LANTERN)) amt_fuel += 1000; /* No need to *buy* stat increase potions */ ! if (my_stat_cur[A_STR] >= (18+100) + 10 * p_ptr->maximize * ! (rp_ptr->r_adj[A_STR] + cp_ptr->c_adj[A_STR])) ! amt_add_stat[A_STR] += 1000; + if (my_stat_cur[A_INT] >= (18+100) + 10 * p_ptr->maximize * + (rp_ptr->r_adj[A_INT] + cp_ptr->c_adj[A_INT])) + amt_add_stat[A_INT] += 1000; + + if (my_stat_cur[A_WIS] >= (18+100) + 10 * p_ptr->maximize * + (rp_ptr->r_adj[A_WIS] + cp_ptr->c_adj[A_WIS])) + amt_add_stat[A_WIS] += 1000; + + if (my_stat_cur[A_DEX] >= (18+100) + 10 * p_ptr->maximize * + (rp_ptr->r_adj[A_DEX] + cp_ptr->c_adj[A_DEX])) + amt_add_stat[A_DEX] += 1000; + + if (my_stat_cur[A_CON] >= (18+100) + 10 * p_ptr->maximize * + (rp_ptr->r_adj[A_CON] + cp_ptr->c_adj[A_CON])) + amt_add_stat[A_CON] += 1000; + + if (my_stat_cur[A_CHR] >= (18+100) + 10 * p_ptr->maximize * + (rp_ptr->r_adj[A_CHR] + cp_ptr->c_adj[A_CHR])) + amt_add_stat[A_CHR] += 1000; + /* No need to *buy* stat repair potions XXX XXX XXX */ if (!do_fix_stat[A_STR]) amt_fix_stat[A_STR] += 1000; if (!do_fix_stat[A_INT]) amt_fix_stat[A_INT] += 1000; *************** *** 1078,1112 **** /* * Helper function -- notice the home equipment */ ! static void borg_notice_home_aux1(void) { - /* Nothing */ - } - - /* - * Helper function -- notice the home inventory - */ - static void borg_notice_home_aux2(void) - { - int i; - - auto_item *item; - - auto_shop *shop = &auto_shops[7]; - - /*** Reset counters ***/ /* Reset basic */ - num_fuel = 0; num_food = 0; num_ident = 0; num_recall = 0; num_phase = 0; num_escape = 0; num_teleport = 0; /* Reset healing */ num_cure_critical = 0; num_cure_serious = 0; --- 1271,1340 ---- /* * Helper function -- notice the home equipment */ ! static void borg_notice_home_aux1(auto_item* in_item, bool no_items) { /*** Reset counters ***/ /* Reset basic */ num_food = 0; num_ident = 0; + num_star_ident = 0; num_recall = 0; num_phase = 0; num_escape = 0; num_teleport = 0; + num_artifact = 0; + + num_slow_digest = 0; + num_regenerate = 0; + num_telepathy = 0; + num_see_inv = 0; + num_ffall = 0; + num_free_act = 0; + num_hold_life = 0; + num_immune_acid = 0; + num_immune_elec = 0; + num_immune_fire = 0; + num_immune_cold = 0; + num_resist_acid = 0; + num_resist_elec = 0; + num_resist_fire = 0; + num_resist_cold = 0; + num_resist_pois = 0; + num_resist_conf = 0; + num_resist_sound = 0; + num_resist_lite = 0; + num_resist_dark = 0; + num_resist_chaos = 0; + num_resist_disen = 0; + num_resist_shard = 0; + num_resist_nexus = 0; + num_resist_blind = 0; + num_resist_neth = 0; + home_stat_add[A_STR] = 0; + home_stat_add[A_INT] = 0; + home_stat_add[A_WIS] = 0; + home_stat_add[A_DEX] = 0; + home_stat_add[A_CON] = 0; + home_stat_add[A_CHR] = 0; + num_weapons = 0; + + num_bow =0; + num_rings = 0; + num_neck = 0; + num_armor = 0; + num_cloaks = 0; + num_shields = 0; + num_hats = 0; + num_gloves = 0; + num_boots = 0; + num_lite = 0; + num_speed = 0; + num_edged_weapon = 0; + num_bad_gloves= 0; + /* Reset healing */ num_cure_critical = 0; num_cure_serious = 0; *************** *** 1133,1138 **** --- 1361,1368 ---- num_fix_stat[A_CON] = 0; num_fix_stat[A_CHR] = 0; num_fix_exp = 0; + num_mana = 0; + num_heal = 0; /* Reset enchantment */ num_enchant_to_a = 0; *************** *** 1139,1162 **** num_enchant_to_d = 0; num_enchant_to_h = 0; /*** Process the inventory ***/ /* Scan the home */ ! for (i = 0; i < STORE_INVEN_MAX; i++) { item = &shop->ware[i]; /* Skip empty items */ ! if (!item->iqty) continue; /* Hack -- skip un-aware items */ ! if (!item->kind) continue; /* Analyze the item */ switch (item->tval) { /* Books */ case TV_MAGIC_BOOK: case TV_PRAYER_BOOK: --- 1369,1771 ---- num_enchant_to_d = 0; num_enchant_to_h = 0; + home_slot_free = 0; + home_damage = 0; + num_duplicate_items = 0; + } + + + /* + * This checks for duplicate items in the home + */ + static void borg_notice_home_dupe(auto_item *item, bool check_sval, int i) + { + /* eventually check for power overlap... armor of resistence is same as weak elvenkind.*/ + /* two armors of elvenkind that resist poison is a dupe. AJG*/ + + int dupe_count, x; + auto_item *item2; + + /* check for a duplicate. */ + /* be carefull about extra powers (elvenkind/magi) */ + switch (item->name2) + { + case EGO_BLESS_BLADE: + case EGO_PERMANENCE: + case EGO_ELVENKIND: + case EGO_MAGI: + case EGO_AMAN: + return; + break; + case EGO_HA: + case EGO_DF: + default: + break; + } + + /* if this is a stack of items then all after the first are a */ + /* duplicate */ + dupe_count = item->iqty-1; + + /* Look for other items before this one that are the same */ + for (x = 0; x < i; x++) + { + if (x < STORE_INVEN_MAX) + item2 = &auto_shops[7].ware[x]; + else + /* Check what the borg has on as well.*/ + item2 = &auto_items[((x-STORE_INVEN_MAX)+INVEN_WIELD)]; + + /* if everything matches it is a duplicate item */ + /* Note that we only check sval on certain items. This */ + /* is because, for example, two pairs of dragon armor */ + /* are not the same unless thier subtype (color) matches */ + /* but a defender is a defender even if one is a dagger and */ + /* one is a mace */ + if ( (item->tval == item2->tval) && + (check_sval ? (item->sval == item2->sval) : TRUE) && + (item->name1 == item2->name1) && + (item->name2 == item2->name2) ) + { + dupe_count++; + } + } + + /* there can be one dupe of rings because there are two ring slots. */ + if (item->tval == TV_RING && dupe_count) + dupe_count--; + + /* Add this items count to the total duplicate count */ + num_duplicate_items += dupe_count; + } + + /* + * Helper function -- notice the home inventory + */ + static void borg_notice_home_aux2(auto_item *in_item, bool no_items) + { + int i; + + auto_item *item; + + auto_shop *shop = &auto_shops[7]; + /*** Process the inventory ***/ /* Scan the home */ ! for (i = 0; i < (STORE_INVEN_MAX+(INVEN_TOTAL-INVEN_WIELD)); i++) { + if (no_items) break; + + if (!in_item) + if (i < STORE_INVEN_MAX) item = &shop->ware[i]; + else + item = &auto_items[((i-STORE_INVEN_MAX)+INVEN_WIELD)]; + else + item = in_item; /* Skip empty items */ ! if (!item->iqty) ! { ! home_slot_free++; ! continue; ! } /* Hack -- skip un-aware items */ ! if (!item->kind) ! { ! home_slot_free++; ! continue; ! } + if (item->flags3 & TR3_SLOW_DIGEST) num_slow_digest += item->iqty; + if (item->flags3 & TR3_REGEN) num_regenerate += item->iqty; + if (item->flags3 & TR3_TELEPATHY) num_telepathy += item->iqty; + if (item->flags3 & TR3_SEE_INVIS) num_see_inv += item->iqty; + if (item->flags3 & TR3_FEATHER) num_ffall += item->iqty; + if (item->flags2 & TR2_FREE_ACT) num_free_act += item->iqty; + if (item->flags2 & TR2_HOLD_LIFE) num_hold_life += item->iqty; + if (item->flags2 & TR2_IM_FIRE) + { + num_immune_fire += item->iqty; + num_resist_fire += item->iqty; + } + if (item->flags2 & TR2_IM_ACID) + { + num_immune_acid += item->iqty; + num_resist_acid += item->iqty; + } + if (item->flags2 & TR2_IM_COLD) + { + num_immune_cold += item->iqty; + num_resist_cold += item->iqty; + } + if (item->flags2 & TR2_IM_ELEC) + { + num_immune_elec += item->iqty; + num_resist_elec += item->iqty; + } + if (item->flags2 & TR2_RES_ACID) num_resist_acid += item->iqty; + if (item->flags2 & TR2_RES_ELEC) num_resist_elec += item->iqty; + if (item->flags2 & TR2_RES_FIRE) num_resist_fire += item->iqty; + if (item->flags2 & TR2_RES_COLD) num_resist_cold += item->iqty; + if (item->flags2 & TR2_RES_POIS) num_resist_pois += item->iqty; + if (item->flags2 & TR2_RES_SOUND) num_resist_sound += item->iqty; + if (item->flags2 & TR2_RES_LITE) num_resist_lite += item->iqty; + if (item->flags2 & TR2_RES_DARK) num_resist_dark += item->iqty; + if (item->flags2 & TR2_RES_CHAOS) num_resist_chaos += item->iqty; + /* chaos also does confusion */ + if (item->flags2 & TR2_RES_CONF || item->flags2 & TR2_RES_CHAOS) + num_resist_conf += item->iqty; + if (item->flags2 & TR2_RES_DISEN) num_resist_disen += item->iqty; + if (item->flags2 & TR2_RES_SHARDS) num_resist_shard += item->iqty; + if (item->flags2 & TR2_RES_NEXUS) num_resist_nexus += item->iqty; + if (item->flags2 & TR2_RES_BLIND) num_resist_blind += item->iqty; + if (item->flags2 & TR2_RES_NETHER) num_resist_neth += item->iqty; + /* count up bonus to stats */ + /* HACK only collect stat rings above +3 */ + if (item->flags1 & TR1_STR) + { + if (item->tval != TV_RING || item->pval > 3) + home_stat_add[A_STR] += item->pval * item->iqty; + } + if (item->flags1 & TR1_INT) + { + if (item->tval != TV_RING || item->pval > 3) + home_stat_add[A_INT] += item->pval * item->iqty; + } + if (item->flags1 & TR1_WIS) + { + if (item->tval != TV_RING || item->pval > 3) + home_stat_add[A_WIS] += item->pval * item->iqty; + } + if (item->flags1 & TR1_DEX) + { + if (item->tval != TV_RING || item->pval > 3) + home_stat_add[A_DEX] += item->pval * item->iqty; + } + if (item->flags1 & TR1_CON) + { + if (item->tval != TV_RING || item->pval > 3) + home_stat_add[A_CON] += item->pval * item->iqty; + } + if (item->flags1 & TR1_CHR) + { + if (item->tval != TV_RING || item->pval > 3) + home_stat_add[A_CHR] += item->pval * item->iqty; + } + + /* count up bonus to speed */ + if (item->flags1 & TR1_SPEED) num_speed += item->pval * item->iqty; + + /* count artifacts */ + if (item->name1) num_artifact += item->iqty; + /* Analyze the item */ switch (item->tval) { + case TV_SOFT_ARMOR: + case TV_HARD_ARMOR: + num_armor += item->iqty; + + /* see if this item is duplicated */ + borg_notice_home_dupe( item, FALSE, i ); + break; + + case TV_DRAG_ARMOR: + num_armor += item->iqty; + + /* see if this item is duplicated */ + borg_notice_home_dupe( item, TRUE, i ); + break; + + case TV_CLOAK: + num_cloaks += item->iqty; + + /* see if this item is duplicated */ + borg_notice_home_dupe( item, FALSE, i ); + + break; + + case TV_SHIELD: + num_shields += item->iqty; + + /* see if this item is duplicated */ + borg_notice_home_dupe( item, FALSE, i ); + break; + + case TV_HELM: + case TV_CROWN: + num_hats += item->iqty; + + /* see if this item is duplicated */ + borg_notice_home_dupe( item, FALSE, i ); + + break; + + case TV_GLOVES: + num_gloves += item->iqty; + + /* most gloves hurt magic for spell-casters */ + if (mb_ptr->spell_book == TV_MAGIC_BOOK) + { + /* Penalize non-usable gloves */ + if (item->iqty && + (!(item->flags2 & TR2_FREE_ACT)) && + (!((item->flags1 & TR1_DEX) && (item->pval > 0)))) + { + num_bad_gloves += item->iqty; + } + } + + /* gloves of slaying give a damage bonus */ + home_damage += item->to_d * 3; + + /* see if this item is duplicated */ + borg_notice_home_dupe( item, FALSE, i ); + + break; + + case TV_LITE: + num_lite += item->iqty; + break; + + case TV_BOOTS: + num_boots += item->iqty; + + /* see if this item is duplicated */ + borg_notice_home_dupe( item, FALSE, i ); + break; + + case TV_SWORD: + case TV_POLEARM: + case TV_HAFTED: + case TV_DIGGING: + { + s16b num_blow; + + num_weapons += item->iqty; + /* most edged weapons hurt magic for priests */ + if (auto_class == CLASS_PRIEST) + { + /* Penalize non-blessed edged weapons */ + if (((item->tval == TV_SWORD) || (item->tval == TV_POLEARM)) && + (!(item->flags3 & TR3_BLESSED))) + { + num_edged_weapon += item->iqty; + } + } + + + /* NOTE: This damage does not take slays into account. */ + /* it is just a rough estimate to make sure the glave of pain*/ + /* is kept if it is found */ + /* It is hard to hold a heavy weapon */ + num_blow = 1; + if (adj_str_hold[my_stat_ind[A_STR]] >= item->weight / 10) + { + int str_index, dex_index; + int num = 0, wgt = 0, mul = 0, div = 0; + + /* Analyze the class */ + switch (auto_class) + { + /* Warrior */ + case 0: num = 6; wgt = 30; mul = 5; break; + + /* Mage */ + case 1: num = 4; wgt = 40; mul = 2; break; + + /* Priest (was mul = 3.5) */ + case 2: num = 5; wgt = 35; mul = 3; break; + + /* Rogue */ + case 3: num = 5; wgt = 30; mul = 3; break; + + /* Ranger */ + case 4: num = 5; wgt = 35; mul = 4; break; + + /* Paladin */ + case 5: num = 5; wgt = 30; mul = 4; break; + } + + /* Enforce a minimum "weight" */ + div = ((item->weight < wgt) ? wgt : item->weight); + + /* Access the strength vs weight */ + str_index = (adj_str_blow[my_stat_ind[A_STR]] * mul / div); + + /* Maximal value */ + if (str_index > 11) str_index = 11; + + /* Index by dexterity */ + dex_index = (adj_dex_blow[my_stat_ind[A_DEX]]); + + /* Maximal value */ + if (dex_index > 11) dex_index = 11; + + /* Use the blows table */ + num_blow = blows_table[str_index][dex_index]; + + /* Maximal value */ + if (num_blow > num) num_blow = num; + + } + + /* Require at least one blow */ + if (num_blow < 1) num_blow = 1; + + if (item->flags1 & TR1_BLOWS) + num_blow += item->pval; + num_blow *= item->iqty; + if ( item->to_d > 8 || auto_level < 15 ) + { + home_damage += num_blow * (item->dd * (item->ds) + + (my_to_dam + item->to_d)); + } + else + { + home_damage += num_blow * (item->dd * (item->ds) + + (my_to_dam + 8)); + } + + /* see if this item is a duplicate */ + borg_notice_home_dupe( item, FALSE, i ); + break; + } + + case TV_BOW: + num_bow += item->iqty; + + /* see if this item is a duplicate */ + borg_notice_home_dupe( item, FALSE, i ); + break; + + case TV_RING: + num_rings += item->iqty; + + /*ring of damage */ + #if 0 + /* these are common as dirt so i commented this out */ + home_damage += item->to_d * 10; + #endif + + /* see if this item is a duplicate */ + borg_notice_home_dupe( item, TRUE, i ); + + break; + + case TV_AMULET: + num_neck += item->iqty; + + /* see if this item is a duplicate */ + borg_notice_home_dupe( item, TRUE, i ); + break; + + /* Books */ case TV_MAGIC_BOOK: case TV_PRAYER_BOOK: *************** *** 1225,1230 **** --- 1834,1847 ---- case SV_POTION_RESTORE_EXP: num_fix_exp += item->iqty; break; + + case SV_POTION_RESTORE_MANA: + num_mana += item->iqty; + break; + + case SV_POTION_HEALING: + num_heal += item->iqty; + break; } break; *************** *** 1240,1245 **** --- 1857,1866 ---- num_ident += item->iqty; break; + case SV_SCROLL_STAR_IDENTIFY: + num_star_ident += item->iqty; + break; + case SV_SCROLL_PHASE_DOOR: num_phase += item->iqty; break; *************** *** 1289,1294 **** --- 1910,1919 ---- /* Staffs */ case TV_STAFF: + /* only collect staves with more than 3 charges at high level */ + if (item->pval <= 3 && auto_level > 30) + break; + /* Analyze */ switch (item->sval) { *************** *** 1304,1318 **** break; - /* Flasks */ - case TV_FLASK: - - /* Use as fuel for lanterns */ - num_fuel += item->iqty; - - break; - - /* Missiles */ case TV_SHOT: case TV_ARROW: --- 1929,1934 ---- *************** *** 1329,1334 **** --- 1945,1953 ---- break; } + + /* if only doing one item, break. */ + if (in_item) break; } *************** *** 1359,1370 **** num_enchant_to_a += 1000; } /*** Process the Needs ***/ - /* No need for fuel */ - if (auto_items[INVEN_LITE].name1) num_fuel += 1000; - /* Hack -- No need for stat repair */ if (my_sustain_str) num_fix_stat[A_STR] += 1000; if (my_sustain_int) num_fix_stat[A_INT] += 1000; --- 1978,1997 ---- num_enchant_to_a += 1000; } + /* handle restore */ + if (borg_prayer_legal(6, 4)) + { + num_fix_exp += 1000; + } + /* Handle recall */ + if (borg_prayer_legal(4, 4) || borg_spell_legal(5, 4)) + { + num_recall += 1000; + } + /*** Process the Needs ***/ /* Hack -- No need for stat repair */ if (my_sustain_str) num_fix_stat[A_STR] += 1000; if (my_sustain_int) num_fix_stat[A_INT] += 1000; *************** *** 1372,1396 **** if (my_sustain_dex) num_fix_stat[A_DEX] += 1000; if (my_sustain_con) num_fix_stat[A_CON] += 1000; if (my_sustain_chr) num_fix_stat[A_CHR] += 1000; } - /* ! * Extract various bonuses */ ! void borg_notice_home(void) { /* Notice the home equipment */ ! borg_notice_home_aux1(); /* Notice the home inventory */ ! borg_notice_home_aux2(); } - - - - /* * Helper function -- calculate "power" of equipment */ --- 1999,2031 ---- if (my_sustain_dex) num_fix_stat[A_DEX] += 1000; if (my_sustain_con) num_fix_stat[A_CON] += 1000; if (my_sustain_chr) num_fix_stat[A_CHR] += 1000; + + /* race bonuses */ + if (auto_race == RACE_ELF) num_resist_lite = 1000; + if (auto_race == RACE_GNOME) num_free_act = 1000; + if (auto_race == RACE_DWARF) num_resist_blind = 1000; + if (auto_race == RACE_HALF_ORC) num_resist_dark = 1000; + if (auto_race == RACE_HIGH_ELF) num_resist_lite = 1000; + if (auto_race == RACE_HIGH_ELF) num_see_inv = 1000; } /* ! * Extract the bonuses for items in the home. ! * ! * in_item is passed in if you want to pretent that in_item is ! * the only item in the home. ! * no_items is passed in as TRUE if you want to pretend that the ! * home is empty. */ ! void borg_notice_home(auto_item *in_item, bool no_items) { /* Notice the home equipment */ ! borg_notice_home_aux1(in_item, no_items); /* Notice the home inventory */ ! borg_notice_home_aux2(in_item, no_items); } /* * Helper function -- calculate "power" of equipment */ *************** *** 1399,1404 **** --- 2034,2041 ---- int hold; int damage; + int i; + int cur_wgt = 0; int max_wgt = 0; *************** *** 1407,1436 **** auto_item *item; ! /* Obtain the "hold" value */ hold = adj_str_hold[my_stat_ind[A_STR]]; - /*** Analyze weapon ***/ /* Examine current weapon */ item = &auto_items[INVEN_WIELD]; ! /* Calculate "average" damage per "normal" blow (times 2) */ ! damage = (item->dd * (item->ds + 1) + ((my_to_dam + item->to_d) * 2)); - /* XXX XXX XXX reward "extra" damage from "slaying" flags */ - /* Reward "damage" */ ! value += (my_num_blow * damage * 500L); /* Reward "bonus to hit" */ ! value += ((my_to_hit + item->to_h) * 100L); /* Hack -- It is hard to hold a heavy weapon */ if (hold < item->weight / 10) value -= 500000L; - /*** Analyze bow ***/ /* Examine current bow */ --- 2044,2107 ---- auto_item *item; ! /* Obtain the "hold" value (weight limit for weapons) */ hold = adj_str_hold[my_stat_ind[A_STR]]; /*** Analyze weapon ***/ /* Examine current weapon */ item = &auto_items[INVEN_WIELD]; ! /* Calculate "average" damage per "normal" blow */ ! /* and assume we can enchant up to +8 if auto_level > 25 */ ! if ( item->to_d > 8 || auto_level < 25 ) ! { ! damage = (item->dd * (item->ds) + (my_to_dam + item->to_d)); ! } ! else ! { ! damage = (item->dd * (item->ds) + (my_to_dam + 8)); ! } /* Reward "damage" */ ! value += (my_num_blow * damage * 110L); /* Reward "bonus to hit" */ ! if ( item->to_h > 8 || auto_level < 25 ) ! value += ((my_to_hit + item->to_h) * 25L); ! else ! value += ((my_to_hit + 8) * 25L); + /* assume 2x base damage for x% of creatures */ + damage = (item->dd * (item->ds)) * 2 * my_num_blow * 110L; + + if (my_slay_animal) value += (damage * 2) / 10; + if (my_slay_evil) value += (damage * 2) / 10; + + /* assume 3x base damage for x% of creatures */ + damage = (item->dd * (item->ds)) * 3 * my_num_blow * 110L; + + if (my_slay_undead) value += (damage * 9) / 100; + if (my_slay_demon) value += (damage * 6) / 100; + if (my_slay_orc) value += (damage * 9) / 100; + if (my_slay_troll) value += (damage * 9) / 100; + if (my_slay_giant) value += (damage * 9) / 100; + if (my_slay_dragon) value += (damage * 11) / 100; + if (my_brand_acid) value += (damage * 17) / 100; + if (my_brand_elec) value += (damage * 17) / 100; + if (my_brand_fire) value += (damage * 14) / 100; + if (my_brand_cold) value += (damage * 14) / 100; + + /* assume 5x base damage for x% of creatures */ + damage = (item->dd * (item->ds)) * 5 * my_num_blow * 110L; + if (my_kill_dragon) value += (damage * 11) / 100; + + /* what ever... Will never get this anyway. it is only on Grond */ + if (my_impact) value += 5000L; + /* Hack -- It is hard to hold a heavy weapon */ if (hold < item->weight / 10) value -= 500000L; /*** Analyze bow ***/ /* Examine current bow */ *************** *** 1437,1449 **** item = &auto_items[INVEN_BOW]; /* Calculate "average" damage per "normal" shot (times 2) */ ! damage = ((my_ammo_sides + 1) + (item->to_d * 2)) * my_ammo_power; /* Reward "damage" */ ! value += (my_num_fire * damage * 500L); /* Reward "bonus to hit" */ ! value += ((my_to_hit + item->to_h) * 100L); /* Analyze the class */ switch (auto_class) --- 2108,2126 ---- item = &auto_items[INVEN_BOW]; /* Calculate "average" damage per "normal" shot (times 2) */ ! if ( item->to_d > 8 || auto_level < 25 ) ! damage = ((my_ammo_sides) + (item->to_d)) * my_ammo_power; ! else ! damage = (my_ammo_sides + 8) * my_ammo_power; /* Reward "damage" */ ! value += (my_num_fire * damage * 300L); /* Reward "bonus to hit" */ ! if ( item->to_h > 8 || auto_level < 25 ) ! value += ((my_to_hit + item->to_h) * 50L); ! else ! value += ((my_to_hit + 8) * 50L); /* Analyze the class */ switch (auto_class) *************** *** 1453,1477 **** case CLASS_ROGUE: case CLASS_PRIEST: case CLASS_PALADIN: ! if (my_ammo_tval == TV_BOLT) value += 200000L; /* Prefer bows */ case CLASS_MAGE: case CLASS_RANGER: ! if (my_ammo_tval == TV_ARROW) value += 100000L; } /* Hack -- It is hard to hold a heavy weapon */ if (hold < item->weight / 10) value -= 500000L; - /*** Reward various things ***/ /* Hack -- Reward light radius */ value += (my_cur_lite * 1000000L); /* Hack -- Reward speed */ ! value += ((my_speed - 100) * 100000L); /* Hack -- Reward strength bonus */ value += (my_stat_ind[A_STR] * 500L); --- 2130,2164 ---- case CLASS_ROGUE: case CLASS_PRIEST: case CLASS_PALADIN: ! if (my_ammo_tval == TV_BOLT) value += 50000L; /* Prefer bows */ case CLASS_MAGE: case CLASS_RANGER: ! if (my_ammo_tval == TV_ARROW) value += 30000L; } /* Hack -- It is hard to hold a heavy weapon */ if (hold < item->weight / 10) value -= 500000L; /*** Reward various things ***/ /* Hack -- Reward light radius */ value += (my_cur_lite * 1000000L); + /* HACK reward upgrading artifact lites. (for activation) */ + /* do this by assuming more valueable artifact lights are better */ + if (my_cur_lite == 3) + value += (auto_items[INVEN_LITE].value / 1000); + /* Hack -- Reward speed */ ! if (my_speed < 130) ! value += ((my_speed - 110) * 20000L); ! else ! if (my_speed < 140) ! value += ((my_speed - 130) * 5000L) + 400000L; ! else ! value += ((my_speed - 140) * 500L) + 450000L; /* Hack -- Reward strength bonus */ value += (my_stat_ind[A_STR] * 500L); *************** *** 1479,1547 **** /* Hack -- Reward intelligence bonus */ if (mb_ptr->spell_book == TV_MAGIC_BOOK) { ! value += (my_stat_ind[A_INT] * 200L); } /* Hack -- Reward wisdom bonus */ if (mb_ptr->spell_book == TV_PRAYER_BOOK) { ! value += (my_stat_ind[A_WIS] * 200L); } ! /* Hack -- Reward charisma bonus */ ! value += (my_stat_ind[A_CHR] * 10L); /*** Reward current skills ***/ /* Hack -- tiny rewards */ ! value += (my_skill_dis * 1L); ! value += (my_skill_dev * 1L); ! value += (my_skill_sav * 1L); ! value += (my_skill_stl * 1L); value += (my_skill_srh * 1L); value += (my_skill_fos * 1L); ! value += (my_skill_thn * 1L); ! value += (my_skill_thb * 1L); ! value += (my_skill_tht * 1L); ! value += (my_skill_dig * 1L); /*** Reward current flags ***/ /* Various flags */ - if (my_see_inv) value += 5000L; - if (my_free_act) value += 10000L; if (my_slow_digest) value += 10L; - if (my_regenerate) value += 50000L; if (my_ffall) value += 10L; - if (my_hold_life) value += 10000L; - if (my_telepathy) value += 50000L; if (my_lite) value += 2000L; /* Immunity flags */ ! if (my_immune_acid) value += 80000L; if (my_immune_elec) value += 40000L; if (my_immune_fire) value += 60000L; ! if (my_immune_cold) value += 30000L; /* Resistance flags */ - if (my_resist_acid) value += 8000L; - if (my_resist_elec) value += 4000L; - if (my_resist_fire) value += 6000L; if (my_resist_cold) value += 3000L; if (my_resist_pois) value += 20000L; ! if (my_resist_fear) value += 2000L; if (my_resist_lite) value += 200L; if (my_resist_dark) value += 200L; - if (my_resist_blind) value += 5000L; - if (my_resist_confu) value += 5000L; - if (my_resist_sound) value += 100L; - if (my_resist_shard) value += 100L; - if (my_resist_nexus) value += 100L; - if (my_resist_nethr) value += 2000L; if (my_resist_chaos) value += 2000L; if (my_resist_disen) value += 5000L; /* Sustain flags */ if (my_sustain_str) value += 50L; --- 2166,2296 ---- /* Hack -- Reward intelligence bonus */ if (mb_ptr->spell_book == TV_MAGIC_BOOK) { ! value += (my_stat_ind[A_INT] * 500L); ! ! /* Bonus for sp. */ ! value += ((adj_mag_mana[my_stat_ind[A_INT]] * auto_level) / 2) * 175L; ! ! /* bonus for fail rate */ ! value += adj_mag_stat[my_stat_ind[A_INT]] * 3100L; ! ! /* mage should try to get min fail to 0 */ ! if (auto_class == CLASS_MAGE) ! { ! if (adj_mag_fail[my_stat_ind[A_INT]] < 1) ! value += 70000L; ! } + } /* Hack -- Reward wisdom bonus */ if (mb_ptr->spell_book == TV_PRAYER_BOOK) { ! value += (my_stat_ind[A_WIS] * 500L); ! ! /* Bonus for sp. */ ! value += ((adj_mag_mana[my_stat_ind[A_WIS]] * auto_level) / 2) * 150L; ! ! /* bonus for fail rate */ ! value += adj_mag_stat[my_stat_ind[A_WIS]] * 3000L; ! ! /* priest should try to get min fail to 0 */ ! if (auto_class == CLASS_PRIEST) ! { ! if (adj_mag_fail[my_stat_ind[A_WIS]] < 1) ! value += 70000L; } ! } + /* Bonus for hp. */ + value += (((adj_con_mhp[my_stat_ind[A_CON]] -128) * auto_level) / 2) *100L; + + /* HACK - a small bonus for adding to stats even above max. */ + /* This will allow us to swap a ring of int +6 for */ + /* our ring of int +2 even though we are at max int because */ + /* we are wielding a weapon that has +4 int */ + /* later it might be nice to swap to a weapon that does not */ + /* have an int bonus */ + for (i = 0; i < 6; i++) value += my_stat_add[i]; + + /* Hack -- Reward charisma bonus up to level 25 */ + if (auto_level < 25) + value += (my_stat_ind[A_CHR] * 10L); + /*** Reward current skills ***/ /* Hack -- tiny rewards */ ! value += (my_skill_dis * 2L); ! value += (my_skill_dev * 50L); ! value += (my_skill_sav * 50L); ! /* perfect saves are very nice */ ! if (my_skill_sav > 99) ! value += 10000; ! value += (my_skill_stl * 2L); value += (my_skill_srh * 1L); value += (my_skill_fos * 1L); ! value += (my_skill_thn * 10L); ! value += (my_skill_thb * 70L); ! value += (my_skill_tht * 2L); ! value += (my_skill_dig * 2L); /*** Reward current flags ***/ /* Various flags */ if (my_slow_digest) value += 10L; if (my_ffall) value += 10L; if (my_lite) value += 2000L; + if (my_telepathy) + { + if (my_see_inv) value += 500L; + } + else + if (my_see_inv) value += 5000L; + if (my_free_act) value += 10000L; + /* after you max out you are pretty safe from drainers.*/ + if (auto_level < 50) + { + if (my_hold_life) value += 2000L; + } + else + { + if (my_hold_life) value += 200L; + } + if (my_regenerate) value += 2000L; + if (my_telepathy) value += 50000L; + /* Immunity flags */ ! if (my_immune_cold) value += 30000L; if (my_immune_elec) value += 40000L; if (my_immune_fire) value += 60000L; ! if (my_immune_acid) value += 80000L; /* Resistance flags */ if (my_resist_cold) value += 3000L; + if (my_resist_elec) value += 4000L; + if (my_resist_acid) value += 6000L; + if (my_resist_fire) value += 8000L; + /* extra bonus for getting all basic resist */ + if (my_resist_fire && + my_resist_acid && + my_resist_elec && + my_resist_cold) value += 17500L; if (my_resist_pois) value += 20000L; ! if (my_resist_sound) value += 2000L; if (my_resist_lite) value += 200L; if (my_resist_dark) value += 200L; if (my_resist_chaos) value += 2000L; + if (my_resist_conf) value += 5000L; if (my_resist_disen) value += 5000L; + if (my_resist_shard) value += 100L; + if (my_resist_nexus) value += 100L; + if (my_resist_blind) value += 5000L; + if (my_resist_neth) value += 5500L; + if (my_resist_fear) value += 2000L; /* Sustain flags */ if (my_sustain_str) value += 50L; *************** *** 1549,1570 **** if (my_sustain_wis) value += 50L; if (my_sustain_con) value += 50L; if (my_sustain_dex) value += 50L; - if (my_sustain_chr) value += 50L; /*** XXX XXX XXX Reward "necessary" flags ***/ /* Mega-Hack -- See invisible (level 10) */ ! if (my_see_inv && (auto_max_depth+1 >= 10)) value += 100000L; /* Mega-Hack -- Free action (level 20) */ if (my_free_act && (auto_max_depth+1 >= 20)) value += 100000L; /*** Reward powerful armor ***/ /* Reward armor */ ! value += ((my_ac + my_to_ac) * 300L); /*** Penalize various things ***/ --- 2298,2330 ---- if (my_sustain_wis) value += 50L; if (my_sustain_con) value += 50L; if (my_sustain_dex) value += 50L; /*** XXX XXX XXX Reward "necessary" flags ***/ /* Mega-Hack -- See invisible (level 10) */ ! if ((my_see_inv || my_telepathy) && (auto_max_depth+1 >= 10)) value += 100000L; /* Mega-Hack -- Free action (level 20) */ if (my_free_act && (auto_max_depth+1 >= 20)) value += 100000L; + /* Mega-Hack -- resist nether (level 50) */ + if (my_resist_neth && (auto_max_depth+1 >= 50)) value += 100000L; + /* Mega-Hack -- resist poison (level 40) */ + if (my_resist_pois && (auto_max_depth+1 >= 40)) value += 100000L; + + /* Mega-Hack -- resist disenchant (level 60) */ + if (my_resist_disen && (auto_max_depth+1 >= 60)) value += 100000L; + /*** Reward powerful armor ***/ /* Reward armor */ ! /* HACK first 10 points are very important */ ! if ((my_ac + my_to_ac) < 10) ! value += ((my_ac + my_to_ac) * 10000L); ! else ! value += (((my_ac + my_to_ac)-10) * 15L) + 100000L; /*** Penalize various things ***/ *************** *** 1573,1579 **** if (my_teleport) value -= 100000L; if (my_aggravate) value -= 50000L; - /*** Penalize armor weight ***/ /* Compute the total armor weight */ --- 2333,2338 ---- *************** *** 1590,1599 **** /* Hack -- heavy armor hurts magic */ if ((mb_ptr->spell_book) && (((cur_wgt - max_wgt) / 10) > 0) && ! (auto_max_level < 20)) { /* Mega-Hack -- Penalize heavy armor which hurts mana */ ! value -= (((cur_wgt - max_wgt) / 10) * (20 - auto_max_level) * 10L); } --- 2349,2358 ---- /* Hack -- heavy armor hurts magic */ if ((mb_ptr->spell_book) && (((cur_wgt - max_wgt) / 10) > 0) && ! (auto_max_level < 30)) { /* Mega-Hack -- Penalize heavy armor which hurts mana */ ! value -= (((cur_wgt - max_wgt) / 10) * (30 - auto_max_level) * 10L); } *************** *** 1606,1612 **** /* Penalize non-usable gloves */ if (item->iqty && ! (!(item->flags3 & TR3_FREE_ACT)) && (!((item->flags1 & TR1_DEX) && (item->pval > 0)))) { /* Hack -- Major penalty */ --- 2365,2371 ---- /* Penalize non-usable gloves */ if (item->iqty && ! (!(item->flags2 & TR2_FREE_ACT)) && (!((item->flags1 & TR1_DEX) && (item->pval > 0)))) { /* Hack -- Major penalty */ *************** *** 1628,1633 **** --- 2387,2437 ---- } } + + /* HUGE MEGA MONDO HACK! prepare for the big fight */ + /* go after Morgoth new priorities. */ + if ((auto_max_depth+1 >= 100) && + borg_collect_potions_morgoth) + { + /* protect from stat drain */ + if (my_sustain_str) value += 30000L; + if (my_sustain_int) value += 30000L; + if (my_sustain_wis) value += 30000L; + if (my_sustain_con) value += 30000L; + if (my_sustain_dex) value += 30000L; + + /* Another bonus for resist nether, poison and base four */ + if (my_resist_neth) value += 100000L; + if (my_resist_disen) value += 100000L; + + /* to protect against summoned baddies */ + if (my_resist_pois) value += 100000L; + if (my_resist_fire && + my_resist_acid && + my_resist_elec && + my_resist_cold) value += 100000L; + + /* another damage bonus! need to hit hard to kill morgoth */ + item = &auto_items[INVEN_WIELD]; + + /* Calculate "average" damage per "normal" blow (times 2) */ + if ( item->to_d > 8 || auto_level < 25 ) + { + damage = (item->dd * (item->ds) + (my_to_dam + item->to_d)); + } + else + { + damage = (item->dd * (item->ds) + (my_to_dam + 8)); + } + + /* Reward "damage" */ + value += (my_num_blow * damage * 110L); + damage = (item->dd * (item->ds)) * 2 * my_num_blow * 110L; + if (my_slay_evil) value += (damage * 2) / 10; + damage = (item->dd * (item->ds)) * 3 * my_num_blow * 110L; + if (my_slay_giant) value += (damage * 9) / 100; + } + /* Result */ return (value); } *************** *** 1652,1657 **** --- 2456,2467 ---- for (; k < 10 && k < amt_fuel; k++) value += 6000L; /* Reward food */ + /* if weak, do not count food spells */ + if (do_weak && amt_food > 1000) + amt_food -= 1000; + /* if hungry, food is THE top priority */ + if (do_hungry) + if (amt_food) value += 100000; k = 0; for (; k < 5 && k < amt_food; k++) value += 50000L; for (; k < 10 && k < amt_food; k++) value += 5000L; *************** *** 1661,1666 **** --- 2471,2479 ---- for (; k < 20 && k < amt_ident; k++) value += 6000L; for (; k < 40 && k < amt_ident; k++) value += 600L; + /* Reward *id* (only carry one!) */ + if (amt_star_ident) value += 10000L; + /* Reward recall */ k = 0; for (; k < 3 && k < amt_recall; k++) value += 50000L; *************** *** 1667,1673 **** for (; k < 5 && k < amt_recall; k++) value += 5000L; /* Reward phase */ ! k = 0; for (; k < 20 && k < amt_phase; k++) value += 500L; /* Reward escape */ --- 2480,2488 ---- for (; k < 5 && k < amt_recall; k++) value += 5000L; /* Reward phase */ ! k = 1; ! /* first phase door is very important */ ! if (amt_phase) value += 50000; for (; k < 20 && k < amt_phase; k++) value += 500L; /* Reward escape */ *************** *** 1678,1686 **** --- 2493,2581 ---- k = 0; for (; k < 5 && k < amt_teleport; k++) value += 10000L; + /* Reward teleport staves */ + /*(try to carry more than one if we can afford it)*/ + if (auto_level > 25) + { + k = 0; + for (; k < 2 && k < amt_teleport_staff; k++) value += 2000L; + } /*** Healing ***/ + if (auto_mhp > 400) + { + /* normally keep all the heal you can get */ + int heal_to_keep = 100; + /* until getting ready for Morgoth */ + if (fear_depth > 98) + { + /* if almost at Morgoth, keep only 5 to wipe out last uniques */ + heal_to_keep = 5; + + /* unless we are heading for Morgoth land, then only keep one */ + /* this will prevent us from whiping out our supply on Morgoth */ + if (fear_depth > 99) + { + /* if in town, don't carry any */ + if (!auto_depth) + heal_to_keep = 0; + else + heal_to_keep = 1; + + /* unless going after morgoth, then get all potions! */ + if (borg_collect_potions_morgoth) + heal_to_keep = 100; + } + } + + k = 0; + for (; k < heal_to_keep && k < amt_heal; k++) value += 4000L; + + /* preists do not collect extra heals, */ + /* they clutter inventory too much */ + if (auto_class != CLASS_PRIEST) + { + k = 0; + for (; k < 100 && k < amt_ez_heal; k++) value += 4000L; + } + } + + /* Restore Mana */ + if (auto_msp > 100) + { + /* normally keep all the restore manas you can get */ + int mana_to_keep = 100; + + /* getting ready for Morgoth */ + if (fear_depth > 98) + { + /* if almost at Morgoth, keep only 5 to wipe out last uniques */ + mana_to_keep = 5; + + /* unless we are heading for Morgoth land, then only keep one */ + /* this will prevent us from whiping out our supply on Morgoth */ + if (fear_depth > 99) + { + /* if in town, don't carry any */ + if (!auto_depth) + mana_to_keep = 0; + else + mana_to_keep = 1; + + /* unless going after Morgoth, then get all potions! */ + if (borg_collect_potions_morgoth) + mana_to_keep = 100; + } + } + + k = 0; + for (; k < mana_to_keep && k < amt_mana; k++) value += 4000L; + + k = 0; + for (; k < 100 && k < amt_ez_mana; k++) value += 4000L; + } + /* Reward cure critical */ k = 0; for (; k < 5 && k < amt_cure_critical; k++) value += 5000L; *************** *** 1687,1697 **** for (; k < 20 && k < amt_cure_critical; k++) value += 500L; /* Reward cure serious */ k = 0; ! for (; k < 5 && k < amt_cure_serious; k++) value += 500L; ! for (; k < 10 && k < amt_cure_serious; k++) value += 50L; - /*** Detection ***/ /* Reward detect trap */ --- 2582,2595 ---- for (; k < 20 && k < amt_cure_critical; k++) value += 500L; /* Reward cure serious */ + /* only reward serious if low on crits */ + if (amt_cure_critical < 10) + { k = 0; ! for (; k < 5 && k < amt_cure_serious; k++) value += 50L; ! for (; k < 10 && k < amt_cure_serious; k++) value += 5L; ! } /*** Detection ***/ /* Reward detect trap */ *************** *** 1702,1707 **** --- 2600,2608 ---- k = 0; for (; k < 1 && k < amt_detect_door; k++) value += 2000L; + /* Reward speed potions/staves */ + k = 0; + for (; k < 50 && k < amt_speed; k++) value += 5000L; /*** Missiles ***/ *************** *** 1708,1714 **** /* Reward missiles */ k = 0; for (; k < 10 && k < amt_missile; k++) value += 1000L; ! for (; k < 30 && k < amt_missile; k++) value += 100L; /*** Various ***/ --- 2609,2615 ---- /* Reward missiles */ k = 0; for (; k < 10 && k < amt_missile; k++) value += 1000L; ! for (; k < 50 && k < amt_missile; k++) value += 100L; /*** Various ***/ *************** *** 1715,1725 **** /* Hack -- Reward add stat */ if (amt_add_stat[A_STR]) value += 50000; if (amt_add_stat[A_INT]) value += 50000; if (amt_add_stat[A_WIS]) value += 50000; if (amt_add_stat[A_DEX]) value += 50000; if (amt_add_stat[A_CON]) value += 50000; ! if (amt_add_stat[A_CHR]) value += 50000; /* Hack -- Reward fix stat */ if (amt_fix_stat[A_STR]) value += 10000; --- 2616,2631 ---- /* Hack -- Reward add stat */ if (amt_add_stat[A_STR]) value += 50000; + if (amt_add_stat[A_INT]) value += 20000; + if (mb_ptr->spell_book == TV_MAGIC_BOOK) if (amt_add_stat[A_INT]) value += 50000; + + if (amt_add_stat[A_WIS]) value += 20000; + if (mb_ptr->spell_book == TV_PRAYER_BOOK) if (amt_add_stat[A_WIS]) value += 50000; if (amt_add_stat[A_DEX]) value += 50000; if (amt_add_stat[A_CON]) value += 50000; ! if (amt_add_stat[A_CHR]) value += 20000; /* Hack -- Reward fix stat */ if (amt_fix_stat[A_STR]) value += 10000; *************** *** 1732,1748 **** /* Hack -- Restore experience */ if (amt_fix_exp) value += 500000; - /*** Enchantment ***/ /* Reward enchant armor */ ! if (amt_enchant_to_a && my_need_enchant_to_a) value += 300L; /* Reward enchant weapon to hit */ ! if (amt_enchant_to_h && my_need_enchant_to_h) value += 100L; /* Reward enchant weapon to damage */ ! if (amt_enchant_to_d && my_need_enchant_to_d) value += 500L; /*** Hack -- books ***/ --- 2638,2653 ---- /* Hack -- Restore experience */ if (amt_fix_exp) value += 500000; /*** Enchantment ***/ /* Reward enchant armor */ ! if (amt_enchant_to_a && my_need_enchant_to_a) value += 14L; /* Reward enchant weapon to hit */ ! if (amt_enchant_to_h && my_need_enchant_to_h) value += 24L; /* Reward enchant weapon to damage */ ! if (amt_enchant_to_d && my_need_enchant_to_d) value += 109L; /*** Hack -- books ***/ *************** *** 1781,1787 **** /* Reward the book */ k = 0; for (; k < 1 && k < amt_book[book]; k++) value += 500000L; ! for (; k < 2 && k < amt_book[book]; k++) value += 100000L; } } --- 2686,2695 ---- /* Reward the book */ k = 0; for (; k < 1 && k < amt_book[book]; k++) value += 500000L; ! if (auto_max_depth > 5) ! for (; k < 2 && k < amt_book[book]; k++) value += 10000L; ! if (auto_max_depth > 50) ! for (; k < 4 && k < amt_book[book]; k++) value += 10000L; } } *************** *** 1818,1823 **** --- 2726,3073 ---- { s32b value = 0L; + /* This would be better seperated by item type (so 1 bonus for resist cold armor */ + /* 1 bonus for resist cold shield... but that would take a bunch more code. */ + + /* !FIX These number are heavily weighted toward the mage... they should adjusted */ + /* to be less mageocentric. Also I just made them up. They seem to work but */ + /* should probably be based on something more real. */ + + /* try to collect at least 2 of each resist/power (for swapping) */ + /* This can be used to get rid of extra artifacts... */ + if (num_slow_digest == 1) + value += 50L; + else + if (num_slow_digest == 2) + value += 70L; + else + if (num_slow_digest > 2) + value += 70L + (num_slow_digest - 2) * 5L; + + if (num_regenerate == 1) + value += 75L; + else + if (num_regenerate == 2) + value += 100L; + else + if (num_regenerate > 2) + value += 100L + (num_regenerate - 2) * 10L; + + if (num_telepathy == 1) + value += 1000L; + else + if (num_telepathy == 2) + value += 1500L; + else + if (num_telepathy > 2) + value += 1500L + (num_telepathy - 2) * 10L; + + if (num_see_inv == 1) + value += 800L; + else + if (num_see_inv == 2) + value += 1200L; + else + if (num_see_inv > 2) + value += 1200L + (num_see_inv - 2) * 10L; + + if (num_ffall == 1) + value += 10L; + else + if (num_ffall == 2) + value += 15L; + else + if (num_ffall > 2) + value += 15L + (num_ffall - 2) * 1L; + + if (num_free_act == 1) + value += 1000L; + else + if (num_free_act == 2) + value += 1500L; + else + if (num_free_act > 2) + value += 1500L + (num_free_act - 2) * 10L; + + if (num_hold_life == 1) + value += 1000L; + else + if (num_hold_life == 2) + value += 1500L; + else + if (num_hold_life > 2) + value += 1500L + (num_hold_life - 2) * 10L; + + if (num_resist_acid == 1) + value += 1000L; + else + if (num_resist_acid == 2) + value += 1500L; + else + if (num_resist_acid > 2) + value += 1500L + (num_resist_acid - 2) * 1L; + if (num_immune_acid == 1) + value += 3000L; + else + if (num_immune_acid == 2) + value += 5000L; + else + if (num_immune_acid > 2) + value += 5000L + (num_immune_acid - 2) * 30L; + + if (num_resist_elec == 1) + value += 1000L; + else + if (num_resist_elec == 2) + value += 1500L; + else + if (num_resist_elec > 2) + value += 1500L + (num_resist_elec - 2) * 1L; + if (num_immune_elec == 1) + value += 3000L; + else + if (num_immune_elec == 2) + value += 5000L; + else + if (num_immune_elec > 2) + value += 5000L + (num_immune_elec - 2) * 30L; + + if (num_resist_fire == 1) + value += 1000L; + else + if (num_resist_fire == 2) + value += 1500L; + else + if (num_resist_fire > 2) + value += 1500L + (num_resist_fire - 2) * 1L; + if (num_immune_fire == 1) + value += 3000L; + else + if (num_immune_fire == 2) + value += 5000L; + else + if (num_immune_fire > 2) + value += 5000L + (num_immune_fire - 2) * 30L; + + if (num_resist_cold == 1) + value += 1000L; + else + if (num_resist_cold == 2) + value += 1500L; + else + if (num_resist_cold > 2) + value += 1500L + (num_resist_cold - 2) * 1L; + if (num_immune_cold == 1) + value += 3000L; + else + if (num_immune_cold == 2) + value += 5000L; + else + if (num_immune_cold > 2) + value += 5000L + (num_immune_cold - 2) * 30L; + + if (num_resist_pois == 1) + value += 5000L; + else + if (num_resist_pois == 2) + value += 9000L; + else + if (num_resist_pois > 2) + value += 9000L + (num_resist_pois - 2) * 40L; + + if (num_resist_conf == 1) + value += 2000L; + else + if (num_resist_conf == 2) + value += 3500L; + else + if (num_resist_conf > 2) + value += 3500L + (num_resist_conf - 2) * 45L; + + if (num_resist_sound == 1) + value += 100L; + else + if (num_resist_sound == 2) + value += 150L; + else + if (num_resist_sound > 2) + value += 150L + (num_resist_sound - 2) * 1L; + + if (num_resist_lite == 1) + value += 100L; + else + if (num_resist_lite == 2) + value += 150L; + else + if (num_resist_lite > 2) + value += 150L + (num_resist_lite - 2) * 1L; + + if (num_resist_dark == 1) + value += 100L; + else + if (num_resist_dark == 2) + value += 150L; + else + if (num_resist_dark > 2) + value += 150L + (num_resist_dark - 2) * 1L; + + if (num_resist_chaos == 1) + value += 1000L; + else + if (num_resist_chaos == 2) + value += 1500L; + else + if (num_resist_chaos > 2) + value += 1500L + (num_resist_chaos - 2) * 10L; + + if (num_resist_disen == 1) + value += 5000L; + else + if (num_resist_disen == 2) + value += 7000L; + else + if (num_resist_disen > 2) + value += 7000L + (num_resist_disen - 2) * 35L; + + if (num_resist_shard == 1) + value += 100L; + else + if (num_resist_shard == 2) + value += 150L; + else + if (num_resist_shard > 2) + value += 150L + (num_resist_shard - 2) * 1L; + + if (num_resist_nexus == 1) + value += 200L; + else + if (num_resist_nexus == 2) + value += 300L; + else + if (num_resist_nexus > 2) + value += 300L + (num_resist_nexus - 2) * 2L; + + if (num_resist_blind == 1) + value += 500L; + else + if (num_resist_blind == 2) + value += 700L; + else + if (num_resist_blind > 2) + value += 700L + (num_resist_blind - 2) * 5L; + + if (num_resist_neth == 1) + value += 5000L; + else + if (num_resist_neth == 2) + value += 7000L; + else + if (num_resist_neth > 2) + value += 7000L + (num_resist_neth - 2) * 45L; + + /* stat gain items as well...(good to carry ring of dex +6 in */ + /* house even if I don't need it right now) */ + if (home_stat_add[A_STR] < 9) + value += home_stat_add[A_STR] * 500L; + else + if (home_stat_add[A_STR] < 15) + value += 9 * 500L + (home_stat_add[A_STR] - 9) * 200L; + else + value += 9 * 500L + 6 * 200L + + (home_stat_add[A_STR] - 15) * 1L; + + if (home_stat_add[A_DEX] < 9) + value += home_stat_add[A_DEX] * 500L; + else + if (home_stat_add[A_DEX] < 15) + value += 9 * 500L + (home_stat_add[A_DEX] - 9) * 200L; + else + value += 9 * 500L + 6 * 200L + + (home_stat_add[A_DEX] - 15) * 1L; + + /* HACK extra con for thorin and other such things */ + if (home_stat_add[A_CON] < 15) + value += home_stat_add[A_CON] * 500L; + else + if (home_stat_add[A_CON] < 21) + value += 15 * 500L + (home_stat_add[A_CON] - 15) * 200L; + else + value += 15 * 500L + 6 * 200L + (home_stat_add[A_CON] - 21) * 1L; + + /* int and wis are only bonused for spell casters. */ + if (mb_ptr->spell_book == TV_MAGIC_BOOK) + { + if (home_stat_add[A_INT] < 20) + value += home_stat_add[A_INT] * 600L; + else + if (home_stat_add[A_INT] < 26) + value += 20 * 600L + (home_stat_add[A_INT] - 20) * 300L; + else + value += 20 * 300L + 6 * 300L + + (home_stat_add[A_INT] - 26) * 5L; + } + + if (mb_ptr->spell_book == TV_PRAYER_BOOK) + { + if (home_stat_add[A_WIS] < 20) + value += home_stat_add[A_WIS] * 600L; + else + if (home_stat_add[A_WIS] < 26) + value += 20 * 600L + (home_stat_add[A_WIS] - 20) * 300L; + else + value += 20 * 600L + 6 * 300L + + (home_stat_add[A_WIS] - 26) * 3L; + } + + /* do a minus for too many duplicates. This way we do not store */ + /* useless items and spread out types of items. */ + if (num_weapons > 5) + value -= (num_weapons - 5) * 2000L; + else + if (num_weapons > 1) + value -= (num_weapons - 1) * 100L; + if (num_bow > 2) + value -= (num_bow - 2) * 1000L; + if (num_rings > 6) + value -= (num_rings - 6) * 4000L; + else + if (num_rings > 4) + value -= (num_rings - 4) * 2000L; + if (num_neck > 3) + value -= (num_neck - 3) * 1500L; + else + if (num_neck > 2) + value -= (num_neck - 2) * 700L; + if (num_armor > 6) + value -= (num_armor - 6) * 1000L; + if (num_cloaks > 3) + value -= (num_cloaks - 3) * 1000L; + if (num_shields > 3) + value -= (num_shields - 3) * 1000L; + if (num_hats > 4) + value -= (num_hats - 4) * 1000L; + if (num_gloves > 3) + value -= (num_gloves - 3) * 1000L; + if (num_boots > 2) + value -= (num_boots - 2) * 1000L; + /* HACK no spare lite sorces. Not needed */ + if (num_lite > 1) + value -= 5000L; + + value += home_damage * 5L; + + value += num_speed * 1000L; + + /* if edged and priest, dump it */ + value -= num_edged_weapon * 3000L; + + /* if gloves and mage or ranger and not FA/Dex, dump it. */ + value -= num_bad_gloves * 3000L; + + /* do not allow duplication of items. */ + value -= num_duplicate_items * 50000L; + + /* Return the value */ return (value); } *************** *** 1830,1836 **** */ static s32b borg_power_home_aux2(void) { ! int i, k, book; s32b value = 0L; --- 3080,3086 ---- */ static s32b borg_power_home_aux2(void) { ! int k, book; s32b value = 0L; *************** *** 1837,1923 **** /*** Basic abilities ***/ - /* Collect fuel */ - for (k = 0; k < 10 && k < num_fuel; k++) value += 1000L - k*10L; - /* Collect food */ ! for (k = 0; k < 10 && k < num_food; k++) value += 800L - k*10L; /* Collect ident */ ! for (k = 0; k < 10 && k < num_ident; k++) value += 200L - k*10L; /* Collect recall */ ! for (k = 0; k < 10 && k < num_recall; k++) value += 300L - k*10L; - /* Collect phase */ - for (k = 0; k < 10 && k < num_phase; k++) value += 200L - k*10L; - /* Collect escape */ ! for (k = 0; k < 10 && k < num_escape; k++) value += 200L - k*10L; /* Collect teleport */ ! for (k = 0; k < 10 && k < num_teleport; k++) value += 200L - k*10L; /*** Healing ***/ /* Collect cure critical */ ! for (k = 0; k < 10 && k < num_cure_critical; k++) value += 150L - k*10L; - /* Collect cure serious */ - for (k = 0; k < 10 && k < num_cure_serious; k++) value += 120L - k*10L; - - - /*** Missiles ***/ - - /* Collect missiles */ - for (k = 0; k < 50 && k < num_missile; k++) value += 10L; - - /*** Various ***/ - /* Hack -- Collect restore life levels */ - for (k = 0; k < 5 && k < num_fix_exp; k++) value += 500L - k*10L; - - /*** Enchantment ***/ - - /* Reward enchant armor */ - for (k = 0; k < 5 && k < num_enchant_to_a; k++) value += 20L - k*1L; - - /*** Hack -- books ***/ /* Reward books */ for (book = 0; book < 4; book++) { /* Collect up to 5 copies of each normal book */ for (k = 0; k < 5 && k < num_book[book]; k++) { /* Hack -- only stockpile useful books */ ! if (amt_book[book]) value += 500L - k*10L; } } - - /*** Mega-Hack -- artifacts ***/ - /* Reward artifacts in the home */ ! for (i = 0; i < STORE_INVEN_MAX; i++) ! { ! auto_item *item = &auto_shops[7].ware[i]; - /* Skip empty items */ - if (!item->iqty) continue; - - /* Skip non-artifacts */ - if (!item->name1) continue; - - /* Reward artifacts */ - value += 100L; - } - - /* Return the value */ return (value); } --- 3087,3161 ---- /*** Basic abilities ***/ /* Collect food */ ! for (k = 0; k < 10 && k < num_food; k++) value += 8000L - k*10L; /* Collect ident */ ! for (k = 0; k < 50 && k < num_ident; k++) value += 2000L - k*10L; + /* Collect *id*ent */ + for (k = 0; k < 50 && k < num_star_ident; k++) value += 5000L - k*10L; + /* Collect recall */ ! for (k = 0; k < 50 && k < num_recall; k++) value += 3000L - k*10L; /* Collect escape */ ! for (k = 0; k < 50 && k < num_escape; k++) value += 2000L - k*10L; /* Collect teleport */ ! for (k = 0; k < 50 && k < num_teleport; k++) value += 400L - k*8L; + /* collect heal/mana */ + if (auto_msp > 100) + for (k = 0; k < 50 && k < num_mana; k++) value += 2000L - k*8L; + if (auto_mhp > 400) + for (k = 0; k < 50 && k < num_heal; k++) value += 2000L - k*8L; + /* collect potions to go after Morgoth */ + if (((auto_msp <= 100) || (num_mana > 14)) && (num_heal > 9)) + { + borg_collect_potions_morgoth = TRUE; + } + /*** Healing ***/ /* Collect cure critical */ ! if (auto_level > 35) ! for (k = 0; k < 90 && k < num_cure_critical; k++) value += 1500L-k*10L; ! else ! for (k = 0; k < 30 && k < num_cure_critical; k++) value += 1500L-k*10L; /*** Various ***/ + if (auto_level > 35) + for (k = 0; k < 70 && k < num_fix_exp; k++) value += 5000L - k*10L; + else + for (k = 0; k < 5 && k < num_fix_exp; k++) value += 5000L - k*10L; /*** Hack -- books ***/ /* Reward books */ for (book = 0; book < 4; book++) { + if (auto_level > 35) /* Collect up to 5 copies of each normal book */ + for (k = 0; k < 70 && k < num_book[book]; k++) + { + /* Hack -- only stockpile useful books */ + if (num_book[book]) value += 5000L - k*10L; + } + else + /* Collect up to 5 copies of each normal book */ for (k = 0; k < 5 && k < num_book[book]; k++) { /* Hack -- only stockpile useful books */ ! if (num_book[book]) value += 5000L - k*10L; } } /* Reward artifacts in the home */ ! value += num_artifact * 500L; /* Return the value */ return (value); } *************** *** 1941,1947 **** } - /* * Calculate base danger from a monster's physical attacks * --- 3179,3184 ---- *************** *** 1954,2166 **** { int k, n = 0; auto_kill *kill = &auto_kills[i]; monster_race *r_ptr = &r_info[kill->r_idx]; /* Mega-Hack -- unknown monsters */ if (kill->r_idx >= MAX_R_IDX) return (1000); - /* Analyze each physical attack */ for (k = 0; k < 4; k++) { int z = 0; ! int method = r_ptr->blow[k].method; ! int effect = r_ptr->blow[k].effect; ! int d_dice = r_ptr->blow[k].d_dice; ! int d_side = r_ptr->blow[k].d_side; /* Done */ ! if (!method) break; /* Analyze the attack */ ! switch (effect) { case RBE_HURT: ! z = (d_dice * d_side); ! z -= (z * ((my_ac < 150) ? my_ac : 150) / 250); ! n += z; break; case RBE_POISON: ! z = (d_dice * d_side); if (my_resist_pois) break; ! n += 10; break; case RBE_UN_BONUS: ! z = (d_dice * d_side); if (my_resist_disen) break; ! n += 500; break; case RBE_UN_POWER: ! z = (d_dice * d_side); ! n += 100; break; case RBE_EAT_GOLD: ! z = (d_dice * d_side); if (100 <= adj_dex_safe[my_stat_ind[A_DEX]] + auto_level) break; if (auto_gold < 100) break; ! n += 10; break; case RBE_EAT_ITEM: ! z = (d_dice * d_side); if (100 <= adj_dex_safe[my_stat_ind[A_DEX]] + auto_level) break; ! n += 20; break; case RBE_EAT_FOOD: ! z = (d_dice * d_side); if (amt_food > 5) break; ! n += 5; break; case RBE_EAT_LITE: ! z = (d_dice * d_side); if (amt_fuel > 5) break; ! n += 20; break; case RBE_ACID: if (my_immune_acid) break; ! z = (d_dice * d_side); if (my_resist_acid) z = (z + 2) / 3; ! n += 40; break; case RBE_ELEC: if (my_immune_elec) break; ! z = (d_dice * d_side); if (my_resist_elec) z = (z + 2) / 3; ! n += 20; break; case RBE_FIRE: if (my_immune_fire) break; ! z = (d_dice * d_side); if (my_resist_fire) z = (z + 2) / 3; ! n += 40; break; case RBE_COLD: if (my_immune_cold) break; ! z = (d_dice * d_side); if (my_resist_cold) z = (z + 2) / 3; ! n += 20; break; case RBE_BLIND: ! z = (d_dice * d_side); if (my_resist_blind) break; ! n += 10; break; case RBE_CONFUSE: ! z = (d_dice * d_side); ! if (my_resist_confu) break; ! n += 10; break; case RBE_TERRIFY: ! z = (d_dice * d_side); if (my_resist_fear) break; ! n += 10; break; case RBE_PARALYZE: ! z = (d_dice * d_side); if (my_free_act) break; ! n += 50; break; case RBE_LOSE_STR: ! z = (d_dice * d_side); if (my_sustain_str) break; if (auto_stat[A_STR] <= 3) break; ! n += 50; break; case RBE_LOSE_DEX: ! z = (d_dice * d_side); if (my_sustain_dex) break; if (auto_stat[A_DEX] <= 3) break; ! n += 50; break; case RBE_LOSE_CON: ! z = (d_dice * d_side); if (my_sustain_con) break; if (auto_stat[A_CON] <= 3) break; ! n += 50; break; case RBE_LOSE_INT: ! z = (d_dice * d_side); if (my_sustain_int) break; if (auto_stat[A_INT] <= 3) break; ! n += 50; break; case RBE_LOSE_WIS: ! z = (d_dice * d_side); if (my_sustain_wis) break; if (auto_stat[A_WIS] <= 3) break; ! n += 50; break; case RBE_LOSE_CHR: ! z = (d_dice * d_side); if (my_sustain_chr) break; if (auto_stat[A_CHR] <= 3) break; ! n += 50; break; case RBE_LOSE_ALL: ! z = (d_dice * d_side); ! n += 200; break; case RBE_SHATTER: ! z = (d_dice * d_side); ! z -= (z * ((my_ac < 150) ? my_ac : 150) / 250); ! n += 100; break; case RBE_EXP_10: ! z = (d_dice * d_side); if (my_hold_life) break; ! n += 100; break; case RBE_EXP_20: ! z = (d_dice * d_side); if (my_hold_life) break; ! n += 150; break; case RBE_EXP_40: ! z = (d_dice * d_side); if (my_hold_life) break; ! n += 200; break; case RBE_EXP_80: ! z = (d_dice * d_side); if (my_hold_life) break; ! n += 250; break; } /* Add in damage */ n += z; } /* Return danger */ return (n); } --- 3191,3616 ---- { int k, n = 0; + int power, chance; + + s16b ac = my_ac; + auto_kill *kill = &auto_kills[i]; monster_race *r_ptr = &r_info[kill->r_idx]; + /* goi gives +100 to ac */ + if (borg_goi) + ac += 100; + /* shields gives +50 to ac */ + if (borg_shield) + ac += 50; + /* Mega-Hack -- unknown monsters */ if (kill->r_idx >= MAX_R_IDX) return (1000); /* Analyze each physical attack */ for (k = 0; k < 4; k++) { int z = 0; ! monster_blow *b_ptr = &r_ptr->blow[k]; + power = 0; + /* Done */ ! if (!b_ptr->method) break; /* Analyze the attack */ ! switch (b_ptr->effect) { case RBE_HURT: ! z = (b_ptr->d_dice * b_ptr->d_side); ! z -= (z * ((ac < 150) ? ac : 150) / 250); ! /* if invulnurable, no damage */ ! if (borg_goi && !borg_attacking) ! z = 0; ! /* stun */ ! if ((b_ptr->d_side < 3) && (z > 19)) ! n += 150; ! power = 60; break; case RBE_POISON: ! z = (b_ptr->d_dice * b_ptr->d_side); ! power = 5; if (my_resist_pois) break; ! if (borg_temp_poison) break; ! if (!borg_full_damage) ! z += 10; break; case RBE_UN_BONUS: ! z = (b_ptr->d_dice * b_ptr->d_side); ! power = 20; ! if (borg_goi && !borg_attacking) ! z = 0; if (my_resist_disen) break; ! /* if invulnurable, no damage */ ! if (!borg_full_damage) ! z += 500; break; case RBE_UN_POWER: ! z = (b_ptr->d_dice * b_ptr->d_side); ! /* if invulnurable, no damage */ ! if (borg_goi && !borg_attacking) ! z = 0; ! if (!borg_full_damage) ! z += 20; ! power = 15; break; case RBE_EAT_GOLD: ! z = (b_ptr->d_dice * b_ptr->d_side); ! /* if in town and low level avoid them stupid urchins */ ! if (auto_level < 3) z += 50; ! /* if invulnurable, no damage */ ! power = 5; ! if (borg_goi && !borg_attacking) ! z = 0; if (100 <= adj_dex_safe[my_stat_ind[A_DEX]] + auto_level) break; if (auto_gold < 100) break; ! if (!borg_full_damage) ! z += 5; break; case RBE_EAT_ITEM: ! z = (b_ptr->d_dice * b_ptr->d_side); ! /* if invulnurable, no damage */ ! power = 5; ! if (borg_goi && !borg_attacking) ! z = 0; if (100 <= adj_dex_safe[my_stat_ind[A_DEX]] + auto_level) break; ! if (!borg_full_damage) ! z += 20; break; case RBE_EAT_FOOD: ! z = (b_ptr->d_dice * b_ptr->d_side); ! power = 5; ! /* if invulnurable, no damage */ ! if (borg_goi && !borg_attacking) ! z = 0; if (amt_food > 5) break; ! if (!borg_full_damage) ! z += 5; break; case RBE_EAT_LITE: ! z = (b_ptr->d_dice * b_ptr->d_side); ! power = 5; ! /* if invulnurable, no damage */ ! if (borg_goi && !borg_attacking) ! z = 0; if (amt_fuel > 5) break; ! if (!borg_full_damage) ! z += 20; break; case RBE_ACID: if (my_immune_acid) break; ! z = (b_ptr->d_dice * b_ptr->d_side); if (my_resist_acid) z = (z + 2) / 3; ! if (borg_temp_acid) z = (z + 2) / 3; ! /* if invulnurable, no damage */ ! if (borg_goi && !borg_attacking) ! z = 0; ! if (!borg_full_damage) ! z += 20; break; case RBE_ELEC: if (my_immune_elec) break; ! z = (b_ptr->d_dice * b_ptr->d_side); ! power = 10; ! /* if invulnurable, no damage */ ! if (borg_goi && !borg_attacking) ! z = 0; if (my_resist_elec) z = (z + 2) / 3; ! if (borg_temp_elec) z = (z + 2) / 3; ! if (!borg_full_damage) ! z += 10; break; case RBE_FIRE: if (my_immune_fire) break; ! z = (b_ptr->d_dice * b_ptr->d_side); ! power = 10; ! /* if invulnurable, no damage */ ! if (borg_goi && !borg_attacking) ! z = 0; if (my_resist_fire) z = (z + 2) / 3; ! if (borg_temp_fire) z = (z + 2) / 3; ! if (!borg_full_damage) ! z += 20; break; case RBE_COLD: if (my_immune_cold) break; ! z = (b_ptr->d_dice * b_ptr->d_side); ! power = 10; ! /* if invulnurable, no damage */ ! if (borg_goi && !borg_attacking) ! z = 0; if (my_resist_cold) z = (z + 2) / 3; ! if (borg_temp_cold) z = (z + 2) / 3; ! if (!borg_full_damage) ! z += 15; break; case RBE_BLIND: ! z = (b_ptr->d_dice * b_ptr->d_side); ! power = 2; ! /* if invulnurable, no damage */ ! if (borg_goi && !borg_attacking) ! z = 0; if (my_resist_blind) break; ! if (!borg_full_damage) ! z += 10; break; case RBE_CONFUSE: ! z = (b_ptr->d_dice * b_ptr->d_side); ! power = 10; ! /* if invulnurable, no damage */ ! if (borg_goi && !borg_attacking) ! z = 0; ! if (my_resist_conf) break; ! if (!borg_full_damage) ! z += 10; break; case RBE_TERRIFY: ! z = (b_ptr->d_dice * b_ptr->d_side); ! power = 10; ! /* if invulnurable, no damage */ ! if (borg_goi && !borg_attacking) ! z = 0; if (my_resist_fear) break; ! if (!borg_full_damage) ! z += 10; break; case RBE_PARALYZE: ! z = (b_ptr->d_dice * b_ptr->d_side); ! power = 2; ! /* if invulnurable, no damage */ ! if (borg_goi && !borg_attacking) ! z = 0; if (my_free_act) break; ! z += 200; break; case RBE_LOSE_STR: ! z = (b_ptr->d_dice * b_ptr->d_side); ! /* if invulnurable, no damage */ ! if (borg_goi && !borg_attacking) ! z = 0; if (my_sustain_str) break; if (auto_stat[A_STR] <= 3) break; ! if (borg_prayer_legal(6, 3)) break; ! if (!borg_full_damage) ! { ! z += 50; ! /* extra scary to have str drain below 10 */ ! if (auto_stat[A_STR] < 10) ! z += 250; ! } break; case RBE_LOSE_DEX: ! z = (b_ptr->d_dice * b_ptr->d_side); ! /* if invulnurable, no damage */ ! if (borg_goi && !borg_attacking) ! z = 0; if (my_sustain_dex) break; if (auto_stat[A_DEX] <= 3) break; ! if (borg_prayer_legal(6, 3)) break; ! if (!borg_full_damage) ! z += 50; break; case RBE_LOSE_CON: ! z = (b_ptr->d_dice * b_ptr->d_side); ! /* if invulnurable, no damage */ ! if (borg_goi && !borg_attacking) ! z = 0; if (my_sustain_con) break; if (auto_stat[A_CON] <= 3) break; ! if (borg_prayer_legal(6, 3)) break; ! if (!borg_full_damage) ! { ! z += 50; ! /* extra scary to have con drain below 8 */ ! if (auto_stat[A_STR] < 8) ! z += 250; ! } break; case RBE_LOSE_INT: ! z = (b_ptr->d_dice * b_ptr->d_side); ! /* if invulnurable, no damage */ ! if (borg_goi && !borg_attacking) ! z = 0; if (my_sustain_int) break; if (auto_stat[A_INT] <= 3) break; ! if (borg_prayer_legal(6, 3)) break; ! if (!borg_full_damage) ! { ! z += 5; ! /* extra scary for spell caster */ ! if (mb_ptr->spell_book == TV_MAGIC_BOOK) ! z += 100; ! } break; case RBE_LOSE_WIS: ! z = (b_ptr->d_dice * b_ptr->d_side); ! /* if invulnurable, no damage */ ! if (borg_goi && !borg_attacking) ! z = 0; if (my_sustain_wis) break; if (auto_stat[A_WIS] <= 3) break; ! if (borg_prayer_legal(6, 3)) break; ! if (!borg_full_damage) ! { ! z += 5; ! /* extra scary for pray'er */ ! if (mb_ptr->spell_book == TV_PRAYER_BOOK) ! z += 100; ! } break; case RBE_LOSE_CHR: ! z = (b_ptr->d_dice * b_ptr->d_side); ! /* if invulnurable, no damage */ ! if (borg_goi && !borg_attacking) ! z = 0; if (my_sustain_chr) break; if (auto_stat[A_CHR] <= 3) break; ! if (borg_prayer_legal(6, 3)) break; ! if (!borg_full_damage) ! z += 5; break; case RBE_LOSE_ALL: ! z = (b_ptr->d_dice * b_ptr->d_side); ! power = 2; ! /* if invulnurable, no damage */ ! if (borg_goi && !borg_attacking) ! z = 0; ! /* only morgoth. HACK to make it easier to fight him */ break; + z += 50; + break; case RBE_SHATTER: ! z = (b_ptr->d_dice * b_ptr->d_side); ! z -= (z * ((ac < 150) ? ac : 150) / 250); ! power = 60; ! /* if invulnurable, no damage */ ! if (borg_goi && !borg_attacking) ! z = 0; ! if (borg_goi && !borg_attacking) ! z += 150; break; case RBE_EXP_10: ! z = (b_ptr->d_dice * b_ptr->d_side); ! /* if invulnurable, no damage */ ! if (borg_goi && !borg_attacking) ! z = 0; if (my_hold_life) break; ! /* do not worry about drain exp after level 50 */ ! if (auto_level == 50) break; ! if (borg_prayer_legal(6, 4)) break; ! if (!borg_full_damage) ! z += 100; break; case RBE_EXP_20: ! z = (b_ptr->d_dice * b_ptr->d_side); ! /* if invulnurable, no damage */ ! if (borg_goi && !borg_attacking) ! z = 0; if (my_hold_life) break; ! /* do not worry about drain exp after level 50 */ ! if (auto_level == 50) break; ! if (borg_prayer_legal(6, 4)) break; ! if (!borg_full_damage) ! z += 150; break; case RBE_EXP_40: ! z = (b_ptr->d_dice * b_ptr->d_side); ! /* if invulnurable, no damage */ ! if (borg_goi && !borg_attacking) ! z = 0; if (my_hold_life) break; ! /* do not worry about drain exp after level 50 */ ! if (auto_level == 50) break; ! if (borg_prayer_legal(6, 4)) break; ! if (!borg_full_damage) ! z += 200; break; case RBE_EXP_80: ! z = (b_ptr->d_dice * b_ptr->d_side); ! /* if invulnurable, no damage */ ! if (borg_goi && !borg_attacking) ! z = 0; if (my_hold_life) break; ! /* do not worry about drain exp after level 50 */ ! if (auto_level == 50) break; ! if (borg_prayer_legal(6, 4)) break; ! if (!borg_full_damage) ! z += 250; break; } + + /* if we are doing partial damage reduse for % chance that it will */ + /* hit you. */ + if (!borg_full_damage) + { + /* figure out chance that monster will hit you. */ + /* add a 30% bonus in to account for bad luck. */ + if ((r_ptr->level + power) > 0) + chance = 130 - (((ac * 300) / 4) / ((r_ptr->level + power) * 3)); + else + chance = -1; + + /* always have a 5% chance of hitting. */ + if (chance < 0) + z = (z * 5) / 100; + + if (chance < 100) + z = (z * chance) / 100; + } + /* Add in damage */ n += z; } + + if (!borg_full_damage) + { + /* Hack -- Apply "protection from evil" */ + if ((borg_prot_from_evil) && + (r_ptr->flags3 & RF3_EVIL) && + (auto_level >= r_ptr->level)) + { + n = (n * (100 - (50 + auto_level)))/100; + } + } + /* Return danger */ return (n); } *************** *** 2186,2192 **** monster_race *r_ptr = &r_info[kill->r_idx]; - /* Mega-Hack -- unknown monsters */ if (kill->r_idx >= MAX_R_IDX) return (1000); --- 3636,3641 ---- *************** *** 2231,2236 **** --- 3680,3688 ---- switch (spell[q]) { case 96+0: /* RF4_SHRIEK */ + /* if looking at full damage, things that are just annoying */ + /* do not count.*/ + if (!borg_full_damage) p += 10; break; *************** *** 2262,2268 **** --- 3714,3727 ---- case 96+8: /* RF4_BR_ACID */ if (my_immune_acid) break; z = (hp / 3); + /* max damage */ + if (z > 1600) + z = 1600; if (my_resist_acid) z = (z + 2) / 3; + if (borg_temp_acid) z = (z + 2) / 3; + /* if looking at full damage, things that are just annoying */ + /* do not count.*/ + if (!borg_full_damage) p += 40; break; *************** *** 2269,2275 **** --- 3728,3741 ---- case 96+9: /* RF4_BR_ELEC */ if (my_immune_elec) break; z = (hp / 3); + /* max damage */ + if (z > 1600) + z = 1600; if (my_resist_elec) z = (z + 2) / 3; + if (borg_temp_elec) z = (z + 2) / 3; + /* if looking at full damage, things that are just annoying */ + /* do not count.*/ + if (!borg_full_damage) p += 20; break; *************** *** 2276,2282 **** --- 3742,3755 ---- case 96+10: /* RF4_BR_FIRE */ if (my_immune_fire) break; z = (hp / 3); + /* max damage */ + if (z > 1600) + z = 1600; if (my_resist_fire) z = (z + 2) / 3; + if (borg_temp_fire) z = (z + 2) / 3; + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 40; break; *************** *** 2283,2311 **** case 96+11: /* RF4_BR_COLD */ if (my_immune_cold) break; z = (hp / 3); if (my_resist_cold) z = (z + 2) / 3; p += 20; break; case 96+12: /* RF4_BR_POIS */ z = (hp / 3); if (my_resist_pois) z = (z + 2) / 3; if (my_resist_pois) break; p += 20; break; case 96+13: /* RF4_BR_NETH */ z = (hp / 6); ! if (my_resist_nethr) z = z / 2; ! if (my_resist_nethr) break; p += 50; if (my_hold_life) break; p += 150; break; case 96+14: /* RF4_BR_LITE */ z = (hp / 6); ! if (my_resist_lite) z = z / 2; if (my_resist_lite) break; if (my_resist_blind) break; p += 20; --- 3756,3813 ---- case 96+11: /* RF4_BR_COLD */ if (my_immune_cold) break; z = (hp / 3); + /* max damage */ + if (z > 1600) + z = 1600; if (my_resist_cold) z = (z + 2) / 3; + if (borg_temp_cold) z = (z + 2) / 3; + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 20; break; case 96+12: /* RF4_BR_POIS */ z = (hp / 3); + /* max damage */ + if (z > 800) + z = 800; if (my_resist_pois) z = (z + 2) / 3; + if (borg_temp_poison) z = (z + 2) / 3; + if (borg_temp_poison) break; if (my_resist_pois) break; + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 20; break; case 96+13: /* RF4_BR_NETH */ z = (hp / 6); ! /* max damage */ ! if (z > 550) ! z = 550; ! if (my_resist_neth) z = (z*6)/8; ! if (my_resist_neth) break; ! /* if looking at full damage, things that are just annoying */ ! /* do not count. */ ! if (!borg_full_damage) p += 50; if (my_hold_life) break; + /* do not worry about drain exp after level 50 */ + if (auto_level == 50) break; + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 150; break; case 96+14: /* RF4_BR_LITE */ z = (hp / 6); ! /* max damage */ ! if (z > 400) ! z = 400; ! if (my_resist_lite) z = (z*2)/3; if (my_resist_lite) break; if (my_resist_blind) break; p += 20; *************** *** 2313,2319 **** case 96+15: /* RF4_BR_DARK */ z = (hp / 6); ! if (my_resist_dark) z = z / 2; if (my_resist_dark) break; if (my_resist_blind) break; p += 20; --- 3815,3824 ---- case 96+15: /* RF4_BR_DARK */ z = (hp / 6); ! /* max damage */ ! if (z > 400) ! z = 400; ! if (my_resist_dark) z = (z*2)/ 3; if (my_resist_dark) break; if (my_resist_blind) break; p += 20; *************** *** 2321,2353 **** case 96+16: /* RF4_BR_CONF */ z = (hp / 6); ! if (my_resist_confu) z = z / 2; ! if (my_resist_confu) break; p += 100; break; case 96+17: /* RF4_BR_SOUN */ z = (hp / 6); ! if (my_resist_sound) z = z / 2; if (my_resist_sound) break; p += 50; break; case 96+18: /* RF4_BR_CHAO */ z = (hp / 6); ! if (my_resist_chaos) z = z / 2; if (my_resist_chaos) break; p += 200; ! if (my_resist_nethr) break; if (my_hold_life) break; p += 100; ! if (my_resist_confu) break; p += 50; break; case 96+19: /* RF4_BR_DISE */ z = (hp / 6); ! if (my_resist_disen) z = z / 2; if (my_resist_disen) break; p += 500; break; --- 3826,3881 ---- case 96+16: /* RF4_BR_CONF */ z = (hp / 6); ! /* max damage */ ! if (z > 400) ! z = 400; ! if (my_resist_conf) z = z / 2; ! if (my_resist_conf) break; ! /* if looking at full damage, things that are just annoying */ ! /* do not count. */ ! if (!borg_full_damage) p += 100; break; case 96+17: /* RF4_BR_SOUN */ z = (hp / 6); ! /* max damage */ ! if (z > 400) ! z = 400; ! if (my_resist_sound) z = (z*5)/8; if (my_resist_sound) break; + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 50; break; case 96+18: /* RF4_BR_CHAO */ z = (hp / 6); ! /* max damage */ ! if (z > 600) ! z = 600; ! if (my_resist_chaos) z = (z*6)/8; if (my_resist_chaos) break; p += 200; ! if (my_resist_neth) break; if (my_hold_life) break; + /* do not worry about drain exp after level 50 */ + if (auto_level == 50) break; + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 100; ! if (my_resist_conf) break; p += 50; break; case 96+19: /* RF4_BR_DISE */ z = (hp / 6); ! /* max damage */ ! if (z > 500) ! z = 500; ! if (my_resist_disen) z = (z*6)/8; if (my_resist_disen) break; p += 500; break; *************** *** 2354,2396 **** case 96+20: /* RF4_BR_NEXU */ z = (hp / 3); ! if (my_resist_nexus) z = z / 2; if (my_resist_nexus) break; p += 100; break; case 96+21: /* RF4_BR_TIME */ z = (hp / 3); ! p += 200; break; case 96+22: /* RF4_BR_INER */ z = (hp / 6); p += 50; break; case 96+23: /* RF4_BR_GRAV */ z = (hp / 3); p += 50; if (my_resist_sound) break; p += 50; break; case 96+24: /* RF4_BR_SHAR */ z = (hp / 6); ! if (my_resist_shard) z = z / 2; if (my_resist_shard) break; p += 50; break; case 96+25: /* RF4_BR_PLAS */ z = (hp / 6); if (my_resist_sound) break; ! p += 50; break; case 96+26: /* RF4_BR_WALL */ z = (hp / 6); if (my_resist_sound) break; p += 50; break; --- 3882,3963 ---- case 96+20: /* RF4_BR_NEXU */ z = (hp / 3); ! /* max damage */ ! if (z > 250) ! z = 250; ! if (my_resist_nexus) z = (z*6)/8; if (my_resist_nexus) break; + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 100; break; case 96+21: /* RF4_BR_TIME */ z = (hp / 3); ! /* max damage */ ! if (z > 150) ! z = 150; ! /* if looking at full damage, things that are just annoying */ ! /* do not count. */ ! if (!borg_full_damage) ! p += 250; break; case 96+22: /* RF4_BR_INER */ z = (hp / 6); + /* max damage */ + if (z > 200) + z = 200; + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 50; break; case 96+23: /* RF4_BR_GRAV */ z = (hp / 3); + /* max damage */ + if (z > 200) + z = 200; + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 50; if (my_resist_sound) break; + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 50; break; case 96+24: /* RF4_BR_SHAR */ z = (hp / 6); ! /* max damage */ ! if (z > 400) ! z = 400; ! if (my_resist_shard) z = (z*6)/8; if (my_resist_shard) break; + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 50; break; case 96+25: /* RF4_BR_PLAS */ z = (hp / 6); + /* max damage */ + if (z > 150) + z = 150; if (my_resist_sound) break; ! p += 100; break; case 96+26: /* RF4_BR_WALL */ z = (hp / 6); + /* max damage */ + if (z > 150) + z = 150; if (my_resist_sound) break; p += 50; break; *************** *** 2411,2422 **** case 96+31: /* RF4_XXX8X4 */ break; - - case 128+0: /* RF5_BA_ACID */ if (my_immune_acid) break; z = (lev * 3) + 15; if (my_resist_acid) z = (z + 2) / 3; p += 40; break; --- 3978,3991 ---- case 96+31: /* RF4_XXX8X4 */ break; case 128+0: /* RF5_BA_ACID */ if (my_immune_acid) break; z = (lev * 3) + 15; if (my_resist_acid) z = (z + 2) / 3; + if (borg_temp_acid) z = (z + 2) / 3; + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 40; break; *************** *** 2424,2429 **** --- 3993,4002 ---- if (my_immune_elec) break; z = (lev * 3) / 2 + 8; if (my_resist_elec) z = (z + 2) / 3; + if (borg_temp_elec) z = (z + 2) / 3; + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 20; break; *************** *** 2431,2436 **** --- 4004,4013 ---- if (my_immune_fire) break; z = (lev * 7) / 2 + 10; if (my_resist_fire) z = (z + 2) / 3; + if (borg_temp_fire) z = (z + 2) / 3; + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 40; break; *************** *** 2438,2443 **** --- 4015,4024 ---- if (my_immune_cold) break; z = (lev * 3) / 2 + 10; if (my_resist_cold) z = (z + 2) / 3; + if (borg_temp_cold) z = (z + 2) / 3; + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 20; break; *************** *** 2444,2462 **** case 128+4: /* RF5_BA_POIS */ z = (12 * 2); if (my_resist_pois) z = (z + 2) / 3; if (my_resist_pois) break; p += 20; break; case 128+5: /* RF5_BA_NETH */ z = (50 + (10 * 10) + lev); ! if (my_resist_nethr) z = z / 2; ! if (my_resist_nethr) break; p += 200; break; case 128+6: /* RF5_BA_WATE */ z = ((lev * 5) / 2) + 50; p += 50; break; --- 4025,4056 ---- case 128+4: /* RF5_BA_POIS */ z = (12 * 2); if (my_resist_pois) z = (z + 2) / 3; + if (borg_temp_poison) z = (z + 2) / 3; + if (borg_temp_poison) break; if (my_resist_pois) break; + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 20; break; case 128+5: /* RF5_BA_NETH */ z = (50 + (10 * 10) + lev); ! if (my_resist_neth) z = (z*6)/8; ! if (my_resist_neth) break; ! /* if looking at full damage, things that are just annoying */ ! /* do not count. */ ! if (!borg_full_damage) p += 200; break; case 128+6: /* RF5_BA_WATE */ z = ((lev * 5) / 2) + 50; + if (my_resist_sound) break; + if (my_resist_conf) break; + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 50; break; *************** *** 2469,2474 **** --- 4063,4071 ---- if (my_resist_dark) z = z / 2; if (my_resist_dark) break; if (my_resist_blind) break; + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 20; break; *************** *** 2477,2505 **** break; case 128+10: /* RF5_MIND_BLAST */ z = 20; break; case 128+11: /* RF5_BRAIN_SMASH */ z = (12 * 15); ! p += 100; break; case 128+12: /* RF5_CAUSE_1 */ z = (3 * 8); break; case 128+13: /* RF5_CAUSE_2 */ z = (8 * 8); break; case 128+14: /* RF5_CAUSE_3 */ z = (10 * 15); break; case 128+15: /* RF5_CAUSE_4 */ z = (15 * 15); ! p += 50; break; case 128+16: /* RF5_BO_ACID */ --- 4074,4131 ---- break; case 128+10: /* RF5_MIND_BLAST */ + if (my_skill_sav < 100) z = 20; break; case 128+11: /* RF5_BRAIN_SMASH */ z = (12 * 15); ! p += 200 - 2 * my_skill_sav; ! if (p < 0) p =0; break; case 128+12: /* RF5_CAUSE_1 */ + if (my_skill_sav >= 100) break; z = (3 * 8); + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) + /* reduce by % chance of save (add 20% for fudge) */ + z = z * (120 - my_skill_sav) / 100; break; case 128+13: /* RF5_CAUSE_2 */ + if (my_skill_sav >= 100) break; z = (8 * 8); + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) + /* reduce by % chance of save (add 20% for fudge) */ + z = z * (120 - my_skill_sav) / 100; break; case 128+14: /* RF5_CAUSE_3 */ + if (my_skill_sav >= 100) break; z = (10 * 15); + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) + /* reduce by % chance of save (add 20% for fudge) */ + z = z * (120 - my_skill_sav) / 100; break; case 128+15: /* RF5_CAUSE_4 */ + if (my_skill_sav >= 100) break; z = (15 * 15); ! /* if looking at full damage, things that are just annoying */ ! /* do not count. */ ! if (!borg_full_damage) ! p += 20; ! /* if looking at full damage, things that are just annoying */ ! /* do not count. */ ! if (!borg_full_damage) ! /* reduce by % chance of save (add 40% for fudge) */ ! z = z * (120 - my_skill_sav) / 100; break; case 128+16: /* RF5_BO_ACID */ *************** *** 2506,2511 **** --- 4132,4141 ---- if (my_immune_acid) break; z = ((7 * 8) + (lev / 3)); if (my_resist_acid) z = (z + 2) / 3; + if (borg_temp_acid) z = (z + 2) / 3; + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 40; break; *************** *** 2513,2518 **** --- 4143,4152 ---- if (my_immune_elec) break; z = ((4 * 8) + (lev / 3)); if (my_resist_elec) z = (z + 2) / 3; + if (borg_temp_elec) z = (z + 2) / 3; + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 20; break; *************** *** 2520,2525 **** --- 4154,4163 ---- if (my_immune_fire) break; z = ((9 * 8) + (lev / 3)); if (my_resist_fire) z = (z + 2) / 3; + if (borg_temp_fire) z = (z + 2) / 3; + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 40; break; *************** *** 2527,2532 **** --- 4165,4174 ---- if (my_immune_cold) break; z = ((6 * 8) + (lev / 3)); if (my_resist_cold) z = (z + 2) / 3; + if (borg_temp_cold) z = (z + 2) / 3; + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 20; break; *************** *** 2536,2548 **** case 128+21: /* RF5_BO_NETH */ z = (30 + (5 * 5) + (lev * 3) / 2); ! if (my_resist_nethr) z = z / 2; ! if (my_resist_nethr) break; p += 200; break; case 128+22: /* RF5_BO_WATE */ z = ((10 * 10) + (lev)); p += 20; break; --- 4178,4198 ---- case 128+21: /* RF5_BO_NETH */ z = (30 + (5 * 5) + (lev * 3) / 2); ! if (my_resist_neth) z = (z*6)/8; ! if (my_resist_neth) break; ! /* if looking at full damage, things that are just annoying */ ! /* do not count. */ ! if (!borg_full_damage) p += 200; break; case 128+22: /* RF5_BO_WATE */ z = ((10 * 10) + (lev)); + if (my_resist_sound) break; + if (my_resist_conf) break; + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 20; break; *************** *** 2552,2562 **** --- 4202,4218 ---- case 128+24: /* RF5_BO_PLAS */ z = (10 + (8 * 7) + (lev)); + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 20; break; case 128+25: /* RF5_BO_ICEE */ z = ((6 * 6) + (lev)); + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 20; break; *************** *** 2565,2592 **** break; case 128+27: /* RF5_SCARE */ p += 10; break; case 128+28: /* RF5_BLIND */ p += 10; break; case 128+29: /* RF5_CONF */ p += 10; break; case 128+30: /* RF5_SLOW */ p += 5; break; case 128+31: /* RF5_HOLD */ ! p += 20; break; - - case 160+0: /* RF6_HASTE */ p += 10; break; --- 4221,4268 ---- break; case 128+27: /* RF5_SCARE */ + if (my_skill_sav >= 100) break; + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 10; break; case 128+28: /* RF5_BLIND */ + if (my_skill_sav >= 100) break; + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 10; break; case 128+29: /* RF5_CONF */ + if (my_skill_sav >= 100) break; + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 10; break; case 128+30: /* RF5_SLOW */ + if (my_free_act) break; + if (my_skill_sav >= 100) break; + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 5; break; case 128+31: /* RF5_HOLD */ ! if (my_free_act) break; ! if (my_skill_sav >= 100) break; ! p += 150; break; case 160+0: /* RF6_HASTE */ + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 10; break; *************** *** 2594,2599 **** --- 4270,4278 ---- break; case 160+2: /* RF6_HEAL */ + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 10; break; *************** *** 2613,2626 **** --- 4292,4315 ---- break; case 160+8: /* RF6_TELE_TO */ + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 20; break; case 160+9: /* RF6_TELE_AWAY */ + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 10; break; case 160+10: /* RF6_TELE_LEVEL */ + if (my_skill_sav >= 100) break; + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 50; break; *************** *** 2628,2642 **** --- 4317,4346 ---- break; case 160+12: /* RF6_DARKNESS */ + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 5; break; case 160+13: /* RF6_TRAPS */ + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) p += 50; break; case 160+14: /* RF6_FORGET */ + if (my_skill_sav >= 100) break; + /* if looking at full damage, things that are just annoying */ + /* do not count. */ + if (!borg_full_damage) + /* if you have lots of cash (like you will at level 35) */ + /* this is not very scary... just re-ID. */ + if (auto_level < 35) p += 500; + else + p += 50; break; case 160+15: /* RF6_XXX6X6 */ *************** *** 2648,2711 **** --- 4352,4435 ---- case 160+17: /* RF6_XXX8X6 */ break; + /* Summoning is only as dangerious as the monster that is */ + /* actually summoned but the monsters that summon are a priority */ + /* to kill */ case 160+18: /* RF6_S_MONSTER */ + if (borg_attacking) p += (lev) * 10; break; case 160+19: /* RF6_S_MONSTERS */ + if (borg_attacking) p += (lev) * 20; break; case 160+20: /* RF6_S_ANT */ + if (borg_attacking) p += (lev) * 20; break; case 160+21: /* RF6_S_SPIDER */ + if (borg_attacking) p += (lev) * 20; break; case 160+22: /* RF6_S_HOUND */ + if (borg_attacking) p += (lev) * 20; break; case 160+23: /* RF6_S_HYDRA */ + if (borg_attacking) p += (lev) * 20; break; case 160+24: /* RF6_S_ANGEL */ + if (borg_attacking) p += (lev) * 30; break; case 160+25: /* RF6_S_DEMON */ + if (borg_attacking) p += (lev) * 30; break; case 160+26: /* RF6_S_UNDEAD */ + if (borg_attacking) p += (lev) * 30; break; case 160+27: /* RF6_S_DRAGON */ + if (borg_attacking) p += (lev) * 30; break; case 160+28: /* RF6_S_HI_UNDEAD */ + if (borg_attacking) p += (lev) * 50; break; case 160+29: /* RF6_S_HI_DRAGON */ + if (borg_attacking) p += (lev) * 50; break; case 160+30: /* RF6_S_WRAITH */ + if (borg_attacking) p += (lev) * 50; break; case 160+31: /* RF6_S_UNIQUE */ + if (borg_attacking) p += (lev) * 50; break; } /* Notice damage */ + + /* if invulnurable, no damage */ + if (!borg_goi || borg_attacking) p += z; /* Track most dangerous spell */ *************** *** 2743,2748 **** --- 4467,4475 ---- monster_race *r_ptr = &r_info[kill->r_idx]; + /* for debug. */ + char * race_name = r_name + r_ptr->name; + int x9 = kill->x; int y9 = kill->y; *************** *** 2768,2785 **** /* Minimal distance */ if (d > 20) return (0); ! /* Total energy */ q = c * kill->moves; /* Minimal energy */ if (q < 10) q = 10; - /* Hack -- reproducers are dangerous, boost speed */ ! if (r_ptr->flags2 & RF2_MULTIPLY) q = q * 2 + 40; /* No attacks for some monsters */ if (r_ptr->flags1 & RF1_NEVER_BLOW) { --- 4495,4554 ---- /* Minimal distance */ if (d > 20) return (0); ! if (!borg_speed) ! { /* Total energy */ q = c * kill->moves; + } + else + { + /* Ugly! we recalculate the moves */ + int t, e; + /* Player energy per game turn */ + e = extract_energy[(auto_speed + 10)]; + + /* Game turns per player move */ + t = (100 + (e - 1)) / e; + + /* Monster energy per game turn */ + e = extract_energy[kill->speed]; + + /* Monster moves */ + q = c * ((t * e) / 10); + + } + /* Minimal energy */ + /* allow partial hits when not caculating full possible damage */ + if (borg_full_damage) if (q < 10) q = 10; /* Hack -- reproducers are dangerous, boost speed */ ! /* Make this only happen for attacking, I am trying to make it so that */ ! /* multipiers are a priority to kill but not that scary. AJG */ ! if (borg_attacking) ! { ! if (r_ptr->flags2 & RF2_MULTIPLY) ! { ! q = q * 2 + 40; ! } + /* Uniques should be attacked first! */ + if (r_ptr->flags1 & RF1_UNIQUE) + { + q = q * 2 + 30; + } + } + else + { + if (r_ptr->flags2 & RF2_MULTIPLY) + { + q = q * 2; + } + } + /* No attacks for some monsters */ if (r_ptr->flags1 & RF1_NEVER_BLOW) { *************** *** 2847,2852 **** --- 4616,4623 ---- /* Danger from spell attacks */ else { + int chance; + /* Spell attacks */ v2 = borg_danger_aux2(i); *************** *** 2853,2858 **** --- 4624,4643 ---- /* Reduce danger from sleeping monsters */ if ((!kill->awake) && (d > 1)) v2 = v2 / d; + if (!borg_full_damage) + { + /* reduce for frequency. */ + chance = (r_ptr->freq_inate + r_ptr->freq_spell)/2; + if (chance < 11) + v2 = (v2 / 5); + else + if (chance < 26) + v2 = (v2 / 3); + else + if (chance < 51) + v2 = ((v2 * 3) / 4) ; + } + /* Danger */ if (v2) { *************** *** 2859,2871 **** /* Full power */ r = q; - /* XXX XXX XXX */ - if (c > 1) - { - /* Hack -- low frequency spells */ - if (r_ptr->freq_spell < 25) r -= (r / 4); - } - /* Total danger */ v2 = v2 * r / 10; } --- 4644,4649 ---- *************** *** 2904,2909 **** --- 4682,4692 ---- { int i, p; + /* do twice. Once to get full damage and once to get partial. */ + /* !FIX this is very slow. I need to find a better way of doing this */ + /* perhaps I should calc both at the same time and pass back */ + /* the right one. AJG */ + borg_full_damage = TRUE; /* Base danger (from fear) */ p = auto_fear_region[y/11][x/11] * c; *************** *** 2921,2927 **** --- 4704,4730 ---- p += borg_danger_aux(y, x, c, i); } + borg_full_damage = FALSE; + /* if I can't be killed in one round use probablilities */ + if (p < avoidance && p != 0) + { + /* Base danger (from fear) */ + p = auto_fear_region[y/11][x/11] * c; + + + /* Examine all the monsters */ + for (i = 1; i < auto_kills_nxt; i++) + { + auto_kill *kill = &auto_kills[i]; + + /* Skip dead monsters */ + if (!kill->r_idx) continue; + + /* Collect danger from monster */ + p += borg_danger_aux(y, x, c, i); + } + } /* Return the danger */ return (p); } *************** *** 2935,2944 **** * Note that we ignore "restock" issues for the first several turns * on each level, to prevent repeated "level bouncing". */ ! bool borg_restock(void) { /* Always ready for the town */ ! if (!auto_depth) return (FALSE); /* Always spend time on a level */ if (c_t - auto_began < 100) return (FALSE); --- 4738,4748 ---- * Note that we ignore "restock" issues for the first several turns * on each level, to prevent repeated "level bouncing". */ ! cptr borg_restock(int depth) { + /* Always ready for the town */ ! if (!depth) return (FALSE); /* Always spend time on a level */ if (c_t - auto_began < 100) return (FALSE); *************** *** 2947,2979 **** /*** Level 1 ***/ /* Must have some lite */ ! if (my_cur_lite < 1) return (TRUE); /* Must have "fuel" */ ! if (amt_fuel < 1) return (TRUE); /* Must have "food" */ ! if (amt_food < 1) return (TRUE); /* Assume happy at level 1 */ ! if (auto_depth <= 1) return (FALSE); ! /*** Level 2 and below ***/ /* Must have good lite */ ! if (my_cur_lite < 2) return (TRUE); /* Must have "fuel" */ ! if (amt_fuel < 3) return (TRUE); /* Must have "food" */ ! if (amt_food < 3) return (TRUE); /* Must have "recall" */ ! if (amt_recall < 2) return (TRUE); /* Assume happy */ return (FALSE); } --- 4751,4796 ---- /*** Level 1 ***/ /* Must have some lite */ ! if (my_cur_lite < 1) return ("rs my_cur_lite"); /* Must have "fuel" */ ! if (amt_fuel < 1) return ("rs amt_fuel"); /* Must have "food" */ ! if (amt_food < 1) return ("rs amt_food"); /* Assume happy at level 1 */ ! if (depth <= 1) return (FALSE); ! /*** Level 2 to 9 ***/ /* Must have good lite */ ! if (my_cur_lite < 2) return ("rs lite+1"); /* Must have "fuel" */ ! if (amt_fuel < 3) return ("rs fuel+2"); /* Must have "food" */ ! if (amt_food < 3) return ("rs food+2"); /* Must have "recall" */ ! if (amt_recall < 2) return ("rs recall"); + /* Assume happy at level 9 */ + if (depth <= 9) return (FALSE); + /*** Level 10 and lower ***/ + + /* Must have "phase" */ + if (amt_phase < 1) return ("rs phase"); + + /* Must have "cure" */ + if (amt_cure_serious + amt_cure_critical < 4) return ("rs cure4"); + + /* Must have "teleport" */ + if (amt_teleport < 2) return ("rs teleport"); + /* Assume happy */ return (FALSE); } *************** *** 2982,3126 **** /* * Determine if the Borg meets the "minimum" requirements for a level */ ! static bool borg_prepared_aux(int depth) { /* Always ready for the town */ ! if (!depth) return (TRUE); - /*** Essential Items for Level 1 ***/ /* Require lite (any) */ ! if (my_cur_lite < 1) return (FALSE); /* Require food */ ! if (amt_food < 5) return (FALSE); /* Usually ready for level 1 */ ! if (depth <= 1) return (TRUE); - /*** Essential Items for Level 2 ***/ /* Require lite (radius two) */ ! if (my_cur_lite < 2) return (FALSE); /* Require fuel */ ! if (amt_fuel < 5) return (FALSE); /* Require recall */ ! if (amt_recall < 2) return (FALSE); /* Scrolls of Identify (for identification) */ ! if (amt_ident < 5) return (FALSE); /* Usually ready for level 2 */ ! if (depth <= 2) return (TRUE); /*** Essential Items for Level 3 and 4 ***/ /* Scrolls of Word of Recall */ ! if (amt_recall < 3) return (FALSE); - /* Scrolls of Identify */ - if (amt_ident < 10) return (FALSE); - /* Potions of Cure Serious Wounds */ ! if (amt_cure_serious + amt_cure_critical < 2) return (FALSE); /* Usually ready for level 3 and 4 */ ! if (depth <= 4) return (TRUE); /*** Essential Items for Level 5 to 9 ***/ /* Scrolls of Word of Recall */ ! if (amt_recall < 4) return (FALSE); /* Scrolls of Identify */ ! if (amt_ident < 15) return (FALSE); /* Potions of Cure Serious/Critical Wounds */ ! if (amt_cure_serious + amt_cure_critical < 5) return (FALSE); /* Usually ready for level 5 to 9 */ ! if (depth <= 9) return (TRUE); /*** Essential Items for Level 10 to 19 ***/ /* Escape or Teleport */ ! if (amt_teleport + amt_escape < 2) return (FALSE); /* Identify */ ! if (amt_ident < 20) return (FALSE); /* Potions of Cure Critical Wounds */ ! if (amt_cure_critical < 5) return (FALSE); /* See invisible */ ! if (!my_see_inv) return (FALSE); /* Usually ready for level 10 to 19 */ ! if (depth <= 19) return (TRUE); /*** Essential Items for Level 20 to 39 ***/ /* Escape and Teleport */ ! if (amt_escape < 2) return (FALSE); ! if (amt_teleport < 2) return (FALSE); /* Cure Critical Wounds */ ! if (amt_cure_critical < 10) return (FALSE); ! /* Free action */ ! if (!my_free_act) return (FALSE); ! /* Basic resistance XXX XXX XXX */ ! if (!my_resist_acid) return (FALSE); ! if (!my_resist_fire) return (FALSE); ! /* Usually ready for level 20 to 39 */ ! if (depth <= 39) return (TRUE); /*** Essential Items for Level 40 to 99 ***/ /* Minimal level */ ! if (auto_level < 25) return (FALSE); /* Minimal hitpoints */ ! if (auto_mhp < 250) return (FALSE); /* High stats XXX XXX XXX */ ! if (auto_stat[A_STR] < 18+50) return (FALSE); ! if (auto_stat[A_INT] < 18+50) return (FALSE); ! if (auto_stat[A_WIS] < 18+50) return (FALSE); ! if (auto_stat[A_DEX] < 18+50) return (FALSE); ! if (auto_stat[A_CON] < 18+50) return (FALSE); ! if (auto_stat[A_CHR] < 18+50) return (FALSE); ! #if 0 ! /* XXX XXX XXX Hold Life */ ! if (!my_hold_life) return (FALSE); /* XXX XXX XXX Resist Disenchantment */ ! if (!my_resist_disen) return (FALSE); #endif /* Usually ready for level 40 to 99 */ ! if (depth <= 99) return (TRUE); /*** Essential Items for Level 100 ***/ ! /* Minimal level */ ! if (auto_level < 50) return (FALSE); /* Assume ready */ ! return (TRUE); } --- 4799,5081 ---- /* * Determine if the Borg meets the "minimum" requirements for a level */ ! static cptr borg_prepared_aux(int depth) { + if ( -1 == borg_ready_morgoth) + borg_ready_morgoth = 0; + /* Always ready for the town */ ! if (!depth) return ((cptr)NULL); /*** Essential Items for Level 1 ***/ /* Require lite (any) */ ! if (my_cur_lite < 1) return ("Lite"); /* Require food */ ! if (amt_food < 5) return ("Food"); /* Usually ready for level 1 */ ! if (depth <= 1) return ((cptr)NULL); /*** Essential Items for Level 2 ***/ /* Require lite (radius two) */ ! if (my_cur_lite < 2) return ("Lite2"); /* Require fuel */ ! if (amt_fuel < 5) return ("Fuel5"); /* Require recall */ ! if (amt_recall < 1) return ("amt_recall"); /* Scrolls of Identify (for identification) */ ! if (amt_ident < 2 && (auto_depth)) return ("ident"); /* Usually ready for level 2 */ ! if (depth <= 2) return ((cptr)NULL); /*** Essential Items for Level 3 and 4 ***/ /* Scrolls of Word of Recall */ ! if (amt_recall < 3) return ("recall3"); /* Potions of Cure Serious Wounds */ ! if (amt_cure_serious + amt_cure_critical < 2) return ("cure2"); + /* Scrolls of Identify */ + if (amt_ident < 5 && (auto_depth)) return ("ident5"); + /* Usually ready for level 3 and 4 */ ! if (depth <= 4) return ((cptr)NULL); /*** Essential Items for Level 5 to 9 ***/ + + /* class specific requirement */ + if (auto_depth) + { + switch (auto_class) + { + case CLASS_WARRIOR: + if (auto_mhp < 50) return ("hp"); + if (auto_level < 4) return ("level"); + break; + case CLASS_ROGUE: + if (auto_mhp < 50) return ("hp"); + if (auto_level < 8) return ("level"); + break; + case CLASS_PRIEST: + if (auto_mhp < 50) return ("hp"); + if (auto_level < 9) return ("level"); + break; + case CLASS_PALADIN: + if (auto_mhp < 50) return ("hp"); + if (auto_level < 4) return ("level"); + break; + case CLASS_RANGER: + if (auto_mhp < 50) return ("hp"); + if (auto_level < 4) return ("level"); + break; + case CLASS_MAGE: + if (auto_level < 11) return ("level"); + break; + } + } + /* Scrolls of Word of Recall */ ! if (amt_recall < 4) return ("recall4"); /* Scrolls of Identify */ ! if (amt_ident < 15 && (auto_depth)) return ("ident15"); /* Potions of Cure Serious/Critical Wounds */ ! if (amt_cure_serious + amt_cure_critical < 5) return ("cure5"); /* Usually ready for level 5 to 9 */ ! if (depth <= 9) return ((cptr)NULL); /*** Essential Items for Level 10 to 19 ***/ + /* Escape or Teleport */ ! if (amt_teleport + amt_escape < 2) return ("tell&esc2"); + /* at this point, from town, you are safe. */ + if (!auto_depth) + { + /* wait! one more check to force town scumming if */ + /* stats are drained! */ + if (depth <= 45) return ((cptr)NULL); + if (auto_stat[A_STR] < 18+50) return ("drained str"); + if (mb_ptr->spell_book == TV_MAGIC_BOOK) + { + if (auto_stat[A_INT] < 18+100) return ("drained int"); + } + if (mb_ptr->spell_book == TV_PRAYER_BOOK) + { + if (auto_stat[A_WIS] < 18+100) return ("drained wis"); + } + if (auto_stat[A_DEX] < 7) return ("drained dex"); + if (auto_stat[A_CON] < 18+60) return ("drained con"); + + return ((cptr)NULL); + } + + + /* class specific requirement */ + switch (auto_class) + { + case CLASS_WARRIOR: + if (auto_level < (depth - 4) && depth <= 19) + return ("level"); + break; + case CLASS_ROGUE: + if (auto_level < depth && depth <= 19) return ("level"); + break; + case CLASS_PRIEST: + if (auto_level < depth && depth <= 19) return ("level"); + break; + case CLASS_PALADIN: + if (auto_level < depth && depth <= 19) return ("level"); + break; + case CLASS_RANGER: + if (auto_level < depth && depth <= 19) return ("level"); + break; + case CLASS_MAGE: + if (auto_level < (depth + 5) && depth <= 19) + return ("level"); + break; + } + /* Identify */ ! if (amt_ident < 20) return ("ident20"); /* Potions of Cure Critical Wounds */ ! if (amt_cure_critical < 5) return ("cure crit5"); /* See invisible */ ! /* or telepathy */ ! if ((!my_see_inv && !my_telepathy)) return ("see inv : telepathy"); /* Usually ready for level 10 to 19 */ ! if (depth <= 19) return ((cptr)NULL); + /*** Essential Items for Level 20 ***/ + /* Free action */ + if (!my_free_act) return ("free act"); + + /* ready for level 20 */ + if (depth <= 20) return ((cptr)NULL); + + /*** Essential Items for Level 25 ***/ + + /* must have fire + 2 other basic resists */ + if (!my_resist_fire) return ("resist fire"); + { + int basics = my_resist_acid + my_resist_cold + my_resist_elec; + + if (basics < 2) return ("basic resist2"); + } + + if (depth <= 25) return ((cptr)NULL); + + /*** Essential Items for Level 20 to 39 ***/ /* Escape and Teleport */ ! if (amt_teleport < 2) return ("teleport2"); ! if (amt_teleport + amt_escape < 6) return ("tell&esc6"); /* Cure Critical Wounds */ ! if (amt_cure_critical < 10) return ("cure crit10"); ! /* Usually ready for level 20 to 39 */ ! if (depth <= 39) return ((cptr)NULL); ! /* Minimal level */ ! if (auto_level < 40) return ("level40"); ! /*** Essential Items for Level 40 ***/ ! /* All Basic resistance & poison*/ ! if (!my_resist_cold) return ("resist cold"); ! if (!my_resist_elec) return ("resist elec"); ! if (!my_resist_acid) return ("resist acid"); ! if (!my_resist_pois) return ("resist pois"); + if (depth <= 45) return ((cptr)NULL); /*** Essential Items for Level 40 to 99 ***/ /* Minimal level */ ! if (auto_level < 45) return ("level45"); /* Minimal hitpoints */ ! if (auto_mhp < 500) return ("hp500"); /* High stats XXX XXX XXX */ ! if (auto_stat[A_STR] < 18+60) return ("low str"); ! if (mb_ptr->spell_book == TV_MAGIC_BOOK) ! { ! if (auto_stat[A_INT] < 18+100) return ("low int"); ! } ! if (mb_ptr->spell_book == TV_PRAYER_BOOK) ! { ! if (auto_stat[A_WIS] < 18+100) return ("low wis"); ! } ! if (auto_stat[A_DEX] < 18+60) return ("low dex"); ! if (auto_stat[A_CON] < 18+60) return ("low con"); ! /* Usually ready for level 41 to 50 */ ! if (depth <= 50) return ((cptr)NULL); + /* Must have +5 speed after level 50 */ + if (auto_speed < 115) return ("speed5"); + + /* Minimal level */ + if (auto_level < 50) return ("level50"); + + /* Must have resist nether or 1000 hp after level 50 */ + /* or speed > +20 and 666 hp*/ + if (!(my_resist_neth || (auto_mhp < 1000) + || ((auto_speed > 130) && (auto_mhp < 666)))) + return ("nether"); + + /* Usually ready for level 51 to 60 */ + if (depth <= 60) return ((cptr)NULL); + + /* Must have +10 speed after level 60 */ + if (auto_speed < 120) return ("speed10"); + + #if 0 /* XXX XXX XXX Resist Disenchantment */ ! if (!my_resist_disen) return ("resist dis"); #endif /* Usually ready for level 40 to 99 */ ! if (depth <= 99) return ((cptr)NULL); /*** Essential Items for Level 100 ***/ ! /* Must have +20 speed to go after MORGOTH! */ ! if (auto_speed < 130) return ("speed20"); + /* must have lots of restore mana to go after MORGOTH */ + if ((auto_msp > 100) && (amt_mana < 15)) return ("rest mana"); + + /* must have lots of heal */ + if (amt_heal < 10) return ("heal"); + + /* Ready for morgoth! */ + borg_ready_morgoth = 1; + /* Assume ready */ ! return ((cptr)NULL); } *************** *** 3133,3161 **** * * Note that we ignore any "town fear", and we allow fear of one * level up to and including the relevant depth. */ ! bool borg_prepared(int depth) { ! int i, k = 0; /* Town and First level */ ! if (depth <= 1) return (TRUE); /* Must meet minimal requirements */ ! if (!borg_prepared_aux(depth)) return (FALSE); ! /* Check depth fear */ ! for (i = 1; i <= depth; i++) { ! /* Check fear */ ! if (auto_fear_depth[i]) k++; } ! /* Allow some fear */ ! if (k < 2) return (TRUE); /* Run away */ ! return (FALSE); } --- 5088,5157 ---- * * Note that we ignore any "town fear", and we allow fear of one * level up to and including the relevant depth. + * + * This now returns a string with the reason you are not prepared. + * */ ! cptr borg_prepared(int depth) { ! cptr reason; /* Town and First level */ ! if (depth <= 1) return ((cptr)NULL); + /* Not prepared if I need to restock */ + if (reason = borg_restock(depth)) return (reason); + /* Must meet minimal requirements */ ! if ((reason = borg_prepared_aux(depth))) return (reason); ! /* Always okay from town */ ! if (!auto_depth) return ((cptr)NULL); ! ! /* check fear of level. */ ! if (depth <= fear_depth) return ((cptr)NULL); ! ! /* check to make sure the borg does not go below where 2 living */ ! /* uniques are. */ { ! int numb_live_unique = 0, i; ! monster_race *r_ptr; ! ! /* BIG HACK, should check to make sure he has seen the unique. */ ! /* !FIX change this to use the 'list of uniques (|) command AJG */ ! for (i = 1; i < MAX_R_IDX-1; i++) ! { ! /* If any have been killed it is not a live unique */ ! if (auto_race_death[i] != 0) continue; ! ! r_ptr = &r_info[i]; ! ! /* Skip non-monsters */ ! if (!r_ptr->name) continue; ! ! /* Skip non-uniques */ ! if (!(r_ptr->flags1 & RF1_UNIQUE)) continue; ! ! /* skip if deeper than fear level */ ! if ( r_ptr->level > fear_depth ) break; ! ! numb_live_unique++; ! continue; } ! if (numb_live_unique < 3) ! { ! auto_fear_depth = 0; ! fear_depth++; + /* make sure we are not scumming if we are going deeper */ + auto_scum = FALSE; + return ((cptr)NULL); + } + } + /* Run away */ ! return ("Live Uniques >= 3"); } *************** *** 3170,3179 **** } #else #ifdef MACINTOSH static int HACK = 0; ! #endif /* MACINTOSH */ ! #endif /* ALLOW_BORG */ --- 5166,5176 ---- } + #else #ifdef MACINTOSH static int HACK = 0; ! #endif ! #endif diff -w -c -r Borg/borg4.h adamborg/borg4.h *** Borg/borg4.h Sun Apr 13 23:20:58 1997 --- adamborg/borg4.h Sun Apr 13 23:25:04 1997 *************** *** 25,33 **** extern void borg_notice(void); /* ! * Extract various bonuses from the home */ ! extern void borg_notice_home(void); /* --- 25,38 ---- extern void borg_notice(void); /* ! * Extract the bonuses for items in the home. ! * ! * in_item is passed in if you want to pretent that in_item is ! * the only item in the home. ! * no_items is passed in as TRUE if you want to pretend that the ! * home is empty. */ ! extern void borg_notice_home(auto_item *in_item, bool no_items); /* *************** *** 56,67 **** /* * Determine if the Borg is out of "crucial" supplies. */ ! extern bool borg_restock(void); /* * Determine if the Borg is "prepared" for the given level */ ! extern bool borg_prepared(int depth); /* --- 61,72 ---- /* * Determine if the Borg is out of "crucial" supplies. */ ! extern cptr borg_restock(int depth); /* * Determine if the Borg is "prepared" for the given level */ ! extern cptr borg_prepared(int depth); /* diff -w -c -r Borg/borg5.c adamborg/borg5.c *** Borg/borg5.c Sun Apr 13 23:21:24 1997 --- adamborg/borg5.c Sun Apr 13 23:25:36 1997 *************** *** 180,186 **** /* Hack -- Penalize CURSED items */ ! if (k_ptr->flags3 & TR3_LIGHT_CURSE) s = s - 5000; /* Hack -- Penalize BROKEN items */ if (k_ptr->cost <= 0) s = s - 5000; --- 180,186 ---- /* Hack -- Penalize CURSED items */ ! if (k_ptr->flags3 & TR3_CURSED) s = s - 5000; /* Hack -- Penalize BROKEN items */ if (k_ptr->cost <= 0) s = s - 5000; *************** *** 259,265 **** auto_take *take = &auto_takes[i]; - /* Access the grid */ ag = &auto_grids[y][x]; --- 259,264 ---- *************** *** 266,272 **** /* Not on-screen */ if (!(ag->info & BORG_OKAY)) return (FALSE); - /* Assume viewable */ return (TRUE); } --- 265,270 ---- *************** *** 1440,1453 **** case 96+12: /* RF4_BR_POIS */ z = ouch; if (my_resist_pois) break; p += 20; break; case 96+13: /* RF4_BR_NETH */ z = ouch; ! if (my_resist_nethr) break; p += 50; if (my_hold_life) break; p += 150; break; --- 1438,1454 ---- case 96+12: /* RF4_BR_POIS */ z = ouch; if (my_resist_pois) break; + if (borg_temp_poison) break; p += 20; break; case 96+13: /* RF4_BR_NETH */ z = ouch; ! if (my_resist_neth) break; p += 50; if (my_hold_life) break; + /* do not worry about drain exp after level 50 */ + if (auto_level == 50) break; p += 150; break; *************** *** 1467,1473 **** case 96+16: /* RF4_BR_CONF */ z = ouch; ! if (my_resist_confu) break; p += 100; break; --- 1468,1474 ---- case 96+16: /* RF4_BR_CONF */ z = ouch; ! if (my_resist_conf) break; p += 100; break; *************** *** 1481,1490 **** z = ouch; if (my_resist_chaos) break; p += 200; ! if (my_resist_nethr) break; if (my_hold_life) break; p += 100; ! if (my_resist_confu) break; p += 50; break; --- 1482,1493 ---- z = ouch; if (my_resist_chaos) break; p += 200; ! if (my_resist_neth) break; if (my_hold_life) break; + /* do not worry about drain exp after level 50 */ + if (auto_level == 50) break; p += 100; ! if (my_resist_conf) break; p += 50; break; *************** *** 1586,1592 **** case 128+5: /* RF5_BA_NETH */ z = ouch; ! if (my_resist_nethr) break; p += 200; break; --- 1589,1595 ---- case 128+5: /* RF5_BA_NETH */ z = ouch; ! if (my_resist_neth) break; p += 200; break; *************** *** 1666,1672 **** case 128+21: /* RF5_BO_NETH */ z = ouch; ! if (my_resist_nethr) break; p += 200; break; --- 1669,1675 ---- case 128+21: /* RF5_BO_NETH */ z = ouch; ! if (my_resist_neth) break; p += 200; break; *************** *** 1713,1720 **** p += 20; break; - - case 160+0: /* RF6_HASTE */ p += 10; break; --- 1716,1721 ---- *************** *** 1765,1771 **** --- 1766,1776 ---- break; case 160+14: /* RF6_FORGET */ + /* if you have lots of cash this is not very scary... just re-ID.*/ + if (auto_level < 35) p += 500; + else + p += 50; break; case 160+15: /* RF6_XXX6X6 */ *************** *** 1777,1836 **** case 160+17: /* RF6_XXX8X6 */ break; case 160+18: /* RF6_S_MONSTER */ - p += (auto_depth) * 10; break; case 160+19: /* RF6_S_MONSTERS */ - p += (auto_depth) * 20; break; case 160+20: /* RF6_S_ANT */ - p += (auto_depth) * 20; break; case 160+21: /* RF6_S_SPIDER */ - p += (auto_depth) * 20; break; case 160+22: /* RF6_S_HOUND */ - p += (auto_depth) * 20; break; case 160+23: /* RF6_S_HYDRA */ - p += (auto_depth) * 20; break; case 160+24: /* RF6_S_ANGEL */ - p += (auto_depth) * 30; break; case 160+25: /* RF6_S_DEMON */ - p += (auto_depth) * 30; break; case 160+26: /* RF6_S_UNDEAD */ - p += (auto_depth) * 30; break; case 160+27: /* RF6_S_DRAGON */ - p += (auto_depth) * 30; break; case 160+28: /* RF6_S_HI_UNDEAD */ - p += (auto_depth) * 50; break; case 160+29: /* RF6_S_HI_DRAGON */ - p += (auto_depth) * 50; break; case 160+30: /* RF6_S_WRAITH */ - p += (auto_depth) * 50; break; case 160+31: /* RF6_S_UNIQUE */ - p += (auto_depth) * 50; break; } --- 1782,1829 ---- case 160+17: /* RF6_XXX8X6 */ break; + /* Summoning is only as dangerious as the monster that is */ + /* attually summoned. This helps borgs kill summoners */ case 160+18: /* RF6_S_MONSTER */ break; case 160+19: /* RF6_S_MONSTERS */ break; case 160+20: /* RF6_S_ANT */ break; case 160+21: /* RF6_S_SPIDER */ break; case 160+22: /* RF6_S_HOUND */ break; case 160+23: /* RF6_S_HYDRA */ break; case 160+24: /* RF6_S_ANGEL */ break; case 160+25: /* RF6_S_DEMON */ break; case 160+26: /* RF6_S_UNDEAD */ break; case 160+27: /* RF6_S_DRAGON */ break; case 160+28: /* RF6_S_HI_UNDEAD */ break; case 160+29: /* RF6_S_HI_DRAGON */ break; case 160+30: /* RF6_S_WRAITH */ break; case 160+31: /* RF6_S_UNIQUE */ break; } *************** *** 1843,1857 **** /* * Increase the "region danger" */ ! static void borg_fear_grid(int y, int x, int k) { int x0, y0, x1, x2, y1, y2; - /* Message */ ! borg_note(format("# Fearing grid (%d,%d) value %d", x, y, k)); - /* Current region */ y0 = (y/11); x0 = (x/11); --- 1836,1849 ---- /* * Increase the "region danger" */ ! static void borg_fear_grid(cptr who, int y, int x, int k) { int x0, y0, x1, x2, y1, y2; /* Message */ ! borg_note(format("# Fearing grid (%d,%d) value %d because of a %s", ! x, y, k, who)); /* Current region */ y0 = (y/11); x0 = (x/11); *************** *** 1864,1882 **** /* Collect "fear", limit to 10000, spread around */ ! auto_fear_region[y0][x0] = MIN(auto_fear_region[y0][x0] + k * 3, 10000); ! auto_fear_region[y0][x1] = MIN(auto_fear_region[y0][x1] + k * 2, 10000); ! auto_fear_region[y0][x2] = MIN(auto_fear_region[y0][x2] + k * 2, 10000); ! auto_fear_region[y1][x0] = MIN(auto_fear_region[y1][x0] + k * 2, 10000); ! auto_fear_region[y2][x0] = MIN(auto_fear_region[y2][x0] + k * 2, 10000); ! auto_fear_region[y1][x1] = MIN(auto_fear_region[y1][x1] + k * 1, 10000); ! auto_fear_region[y1][x2] = MIN(auto_fear_region[y1][x2] + k * 1, 10000); ! auto_fear_region[y2][x1] = MIN(auto_fear_region[y2][x1] + k * 1, 10000); ! auto_fear_region[y2][x2] = MIN(auto_fear_region[y2][x1] + k * 1, 10000); } - /* * Attempt to locate a monster which could explain a message involving * the given monster name, near the given location, up to the given --- 1856,1873 ---- /* Collect "fear", limit to 10000, spread around */ ! auto_fear_region[y0][x0] = MIN(auto_fear_region[y0][x0] + k, 10000); ! auto_fear_region[y0][x1] = MIN(auto_fear_region[y0][x1] + k / 2, 10000); ! auto_fear_region[y0][x2] = MIN(auto_fear_region[y0][x2] + k / 2, 10000); ! auto_fear_region[y1][x0] = MIN(auto_fear_region[y1][x0] + k / 2, 10000); ! auto_fear_region[y2][x0] = MIN(auto_fear_region[y2][x0] + k / 2, 10000); ! auto_fear_region[y1][x1] = MIN(auto_fear_region[y1][x1] + k / 3, 10000); ! auto_fear_region[y1][x2] = MIN(auto_fear_region[y1][x2] + k / 3, 10000); ! auto_fear_region[y2][x1] = MIN(auto_fear_region[y2][x1] + k / 3, 10000); ! auto_fear_region[y2][x2] = MIN(auto_fear_region[y2][x1] + k / 3, 10000); } /* * Attempt to locate a monster which could explain a message involving * the given monster name, near the given location, up to the given *************** *** 1901,1907 **** * * XXX XXX XXX Currently, confusion may cause messages to be ignored. */ ! static bool borg_locate_kill(cptr who, int y, int x, int r) { int i, d, r_idx; --- 1892,1898 ---- * * XXX XXX XXX Currently, confusion may cause messages to be ignored. */ ! static int borg_locate_kill(cptr who, int y, int x, int r) { int i, d, r_idx; *************** *** 1914,1920 **** monster_race *r_ptr; - /* Handle invisible monsters */ if (streq(who, "It") || streq(who, "Someone") || --- 1905,1910 ---- *************** *** 2170,2176 **** x, y)); /* Oops */ ! return (0); } --- 2160,2168 ---- x, y)); /* Oops */ ! /* this is the case where we know the name of the monster */ ! /* but cannot locate it on the monster list. */ ! return (-1); } *************** *** 2814,2821 **** wank->is_take = auto_is_take[(byte)(t_c)]; wank->is_kill = auto_is_kill[(byte)(t_c)]; /* Mark old wall/door grids as probable floor grids */ ! if (!borg_cave_floor_grid(ag)) ag->feat = FEAT_INVIS; /* Done */ break; --- 2806,2818 ---- wank->is_take = auto_is_take[(byte)(t_c)]; wank->is_kill = auto_is_kill[(byte)(t_c)]; + /* mark old unknow squares as possible floor grids */ + if (ag->feat == FEAT_NONE) + ag->feat = FEAT_INVIS; + /* Mark old wall/door grids as probable floor grids */ ! if (!borg_cave_floor_grid(ag)) ! ag->feat = FEAT_INVIS; /* Done */ break; *************** *** 2900,2907 **** */ void borg_update(void) { ! int i, k, x, y, dx, dy; cptr msg; cptr what; --- 2897,2906 ---- */ void borg_update(void) { ! int i, k, x, y, dx, dy, n; + int hit_dist; + cptr msg; cptr what; *************** *** 2960,2966 **** borg_delete_take(i); } - /*** Handle messages ***/ /* Process messages */ --- 2959,2964 ---- *************** *** 3016,3022 **** if (prefix(msg, "HIT:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, g_y, g_x, 0)) != 0) { auto_msg_use[i] = 2; } --- 3014,3020 ---- if (prefix(msg, "HIT:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, g_y, g_x, 0)) > 0) { auto_msg_use[i] = 2; } *************** *** 3026,3032 **** else if (prefix(msg, "MISS:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, g_y, g_x, 0)) != 0) { auto_msg_use[i] = 2; } --- 3024,3030 ---- else if (prefix(msg, "MISS:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, g_y, g_x, 0)) > 0) { auto_msg_use[i] = 2; } *************** *** 3036,3042 **** else if (prefix(msg, "KILL:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, g_y, g_x, 0)) != 0) { borg_count_death(k); borg_delete_kill(k); --- 3034,3040 ---- else if (prefix(msg, "KILL:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, g_y, g_x, 0)) > 0) { borg_count_death(k); borg_delete_kill(k); *************** *** 3048,3054 **** else if (prefix(msg, "DIED:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, g_y, g_x, 3)) != 0) { borg_count_death(k); borg_delete_kill(k); --- 3046,3052 ---- else if (prefix(msg, "DIED:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, g_y, g_x, 3)) > 0) { borg_count_death(k); borg_delete_kill(k); *************** *** 3060,3066 **** else if (prefix(msg, "PAIN:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, g_y, g_x, 3)) != 0) { auto_msg_use[i] = 2; } --- 3058,3064 ---- else if (prefix(msg, "PAIN:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, g_y, g_x, 3)) > 0) { auto_msg_use[i] = 2; } *************** *** 3070,3076 **** else if (prefix(msg, "STATE__FEAR:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, g_y, g_x, 0)) != 0) { auto_msg_use[i] = 2; } --- 3068,3074 ---- else if (prefix(msg, "STATE__FEAR:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, g_y, g_x, 0)) > 0) { auto_msg_use[i] = 2; } *************** *** 3080,3086 **** else if (prefix(msg, "STATE__BOLD:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, g_y, g_x, 0)) != 0) { auto_msg_use[i] = 2; } --- 3078,3084 ---- else if (prefix(msg, "STATE__BOLD:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, g_y, g_x, 0)) > 0) { auto_msg_use[i] = 2; } *************** *** 3088,3093 **** --- 3086,3093 ---- } /* Process messages */ + /* getting distance to allow for 'hit's */ + hit_dist = 1; for (i = 0; i < auto_msg_num; i++) { /* Skip parsed messages */ *************** *** 3096,3101 **** --- 3096,3127 ---- /* Get the message */ msg = auto_msg_buf + auto_msg_pos[i]; + /* if you have moved than do not count the monsters as unknown */ + /* unless they are very far away */ + if (prefix(msg, "SPELL_168") || + prefix(msg, "SPELL_169")) + { + hit_dist = 100; + break; + } + + /* monsters move from earthquake */ + if (prefix(msg, "QUAKE")) + { + hit_dist = 3; + break; + } + } + + /* Process messages */ + for (i = 0; i < auto_msg_num; i++) + { + /* Skip parsed messages */ + if (auto_msg_use[i]) continue; + + /* Get the message */ + msg = auto_msg_buf + auto_msg_pos[i]; + /* Get the arguments */ what = strchr(msg, ':') + 1; *************** *** 3103,3109 **** if (prefix(msg, "HIT:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, g_y, g_x, 1)) != 0) { auto_msg_use[i] = 3; } --- 3129,3135 ---- if (prefix(msg, "HIT:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, g_y, g_x, hit_dist)) > 0) { auto_msg_use[i] = 3; } *************** *** 3113,3119 **** else if (prefix(msg, "MISS:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, g_y, g_x, 1)) != 0) { auto_msg_use[i] = 3; } --- 3139,3145 ---- else if (prefix(msg, "MISS:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, g_y, g_x, hit_dist)) > 0) { auto_msg_use[i] = 3; } *************** *** 3123,3129 **** else if (prefix(msg, "KILL:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, g_y, g_x, 1)) != 0) { borg_count_death(k); borg_delete_kill(k); --- 3149,3155 ---- else if (prefix(msg, "KILL:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, g_y, g_x, 1)) > 0) { borg_count_death(k); borg_delete_kill(k); *************** *** 3135,3141 **** else if (prefix(msg, "DIED:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, o_c_y, o_c_x, 20)) != 0) { borg_count_death(k); borg_delete_kill(k); --- 3161,3167 ---- else if (prefix(msg, "DIED:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, o_c_y, o_c_x, 20)) > 0) { borg_count_death(k); borg_delete_kill(k); *************** *** 3147,3153 **** else if (prefix(msg, "PAIN:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, o_c_y, o_c_x, 20)) != 0) { auto_msg_use[i] = 3; } --- 3173,3179 ---- else if (prefix(msg, "PAIN:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, o_c_y, o_c_x, 20)) > 0) { auto_msg_use[i] = 3; } *************** *** 3157,3163 **** else if (prefix(msg, "HIT_BY:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, o_c_y, o_c_x, 1)) != 0) { auto_msg_use[i] = 3; } --- 3183,3189 ---- else if (prefix(msg, "HIT_BY:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, o_c_y, o_c_x, 1)) > 0) { auto_msg_use[i] = 3; } *************** *** 3167,3173 **** else if (prefix(msg, "MISS_BY:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, o_c_y, o_c_x, 1)) != 0) { auto_msg_use[i] = 3; } --- 3193,3199 ---- else if (prefix(msg, "MISS_BY:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, o_c_y, o_c_x, 1)) > 0) { auto_msg_use[i] = 3; } *************** *** 3177,3183 **** else if (prefix(msg, "STATE_SLEEP:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, o_c_y, o_c_x, 20)) != 0) { auto_msg_use[i] = 3; } --- 3203,3209 ---- else if (prefix(msg, "STATE_SLEEP:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, o_c_y, o_c_x, 20)) > 0) { auto_msg_use[i] = 3; } *************** *** 3187,3193 **** else if (prefix(msg, "STATE_AWAKE:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, o_c_y, o_c_x, 20)) != 0) { auto_msg_use[i] = 3; } --- 3213,3219 ---- else if (prefix(msg, "STATE_AWAKE:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, o_c_y, o_c_x, 20)) > 0) { auto_msg_use[i] = 3; } *************** *** 3197,3203 **** else if (prefix(msg, "STATE__FEAR:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, o_c_y, o_c_x, 20)) != 0) { auto_msg_use[i] = 3; } --- 3223,3229 ---- else if (prefix(msg, "STATE__FEAR:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, o_c_y, o_c_x, 20)) > 0) { auto_msg_use[i] = 3; } *************** *** 3207,3213 **** else if (prefix(msg, "STATE__BOLD:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, o_c_y, o_c_x, 20)) != 0) { auto_msg_use[i] = 3; } --- 3233,3239 ---- else if (prefix(msg, "STATE__BOLD:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, o_c_y, o_c_x, 20)) > 0) { auto_msg_use[i] = 3; } *************** *** 3217,3223 **** else if (prefix(msg, "SPELL_")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, o_c_y, o_c_x, 20)) != 0) { auto_msg_use[i] = 3; } --- 3243,3249 ---- else if (prefix(msg, "SPELL_")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, o_c_y, o_c_x, 20)) > 0) { auto_msg_use[i] = 3; } *************** *** 3230,3235 **** --- 3256,3267 ---- /* Hack -- note new levels */ if (old_depth != auto_depth) { + /* if we are not leaving town increment time since town clock */ + if (!old_depth) + auto_time_town = 0; + else + auto_time_town += c_t - auto_began; + /* Hack -- Restart the clock */ c_t = 1000; *************** *** 3320,3325 **** --- 3352,3366 ---- /* Assume not ignoring monsters */ goal_ignoring = FALSE; + /* Went through entire level without running off level */ + finished_level = FALSE; + + /* assume not going after Morgoth */ + borg_collect_potions_morgoth = FALSE; + + /* -1 is unknown. */ + borg_ready_morgoth = -1; + /* No known stairs */ track_less_num = 0; track_more_num = 0; *************** *** 3347,3359 **** --- 3388,3417 ---- /* Reset */ reset = TRUE; + /* wipe out bad artifacts list */ + for (i = 0; i < 10; i++) + { + bad_obj_x[i] = -1; + bad_obj_y[i] = -1; + } + /* Save new depth */ old_depth = auto_depth; + + /* save once per level */ + if (auto_flag_save) borg_save = TRUE; + + borg_times_twitch = 0; } /* Handle old level */ else { + /* reduce GOI count. NOTE: do not reduse below 1. That is done */ + /* when the spell is cast. */ + /* !FIX need to take speed into account AJG */ + if (borg_goi > 1) borg_goi--; + /* Reduce fear over time */ if (!(c_t % 10)) { *************** *** 3599,3604 **** --- 3657,3663 ---- /* Attempt to find the monster */ if ((k = borg_locate_kill(what, c_y, c_x, 20)) != 0) { + if (k > 0) borg_count_death(k); borg_delete_kill(k); auto_msg_use[i] = 4; *************** *** 3619,3625 **** else if (prefix(msg, "HIT_BY:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, c_y, c_x, 1)) != 0) { auto_msg_use[i] = 4; } --- 3678,3684 ---- else if (prefix(msg, "HIT_BY:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, c_y, c_x, hit_dist)) != 0) { auto_msg_use[i] = 4; } *************** *** 3629,3635 **** else if (prefix(msg, "MISS_BY:")) { /* Attempt to find the monster */ ! if ((k = borg_locate_kill(what, c_y, c_x, 1)) != 0) { auto_msg_use[i] = 4; } --- 3688,3695 ---- else if (prefix(msg, "MISS_BY:")) { /* Attempt to find the monster */ ! ! if ((k = borg_locate_kill(what, c_y, c_x, hit_dist)) != 0) { auto_msg_use[i] = 4; } *************** *** 3701,3707 **** /* Handle "xxx hits you." */ if (prefix(msg, "HIT_BY:")) { ! borg_fear_grid(c_y, c_x, 4 * ((auto_depth / 5) + 1)); auto_msg_use[i] = 5; } --- 3761,3767 ---- /* Handle "xxx hits you." */ if (prefix(msg, "HIT_BY:")) { ! borg_fear_grid(what, c_y, c_x, 4 * ((auto_depth / 5) + 1)); auto_msg_use[i] = 5; } *************** *** 3708,3714 **** /* Handle "xxx misses you." */ else if (prefix(msg, "MISS_BY:")) { ! borg_fear_grid(c_y, c_x, 2 * ((auto_depth / 5) + 1)); auto_msg_use[i] = 5; } --- 3768,3774 ---- /* Handle "xxx misses you." */ else if (prefix(msg, "MISS_BY:")) { ! borg_fear_grid(what, c_y, c_x, 2 * ((auto_depth / 5) + 1)); auto_msg_use[i] = 5; } *************** *** 3715,3721 **** /* Hack -- Handle "spell" */ else if (prefix(msg, "SPELL_")) { ! borg_fear_grid(c_y, c_x, borg_fear_spell(atoi(msg+6))); auto_msg_use[i] = 5; } } --- 3775,3781 ---- /* Hack -- Handle "spell" */ else if (prefix(msg, "SPELL_")) { ! borg_fear_grid(what, c_y, c_x, borg_fear_spell(atoi(msg+6))); auto_msg_use[i] = 5; } } *************** *** 3896,3902 **** if (do_blind || do_confused || do_afraid || do_image) goal = 0; /* Forget goals while "bleeding" in any way */ ! if (do_weak || do_poisoned || do_cut || do_stun) goal = 0; /* Forget goals when HP or SP changes */ if ((auto_chp != old_chp) || (auto_csp != old_csp)) goal = 0; --- 3956,3962 ---- if (do_blind || do_confused || do_afraid || do_image) goal = 0; /* Forget goals while "bleeding" in any way */ ! if (do_weak || do_poisoned || do_cut || do_stun || do_heavy_stun) goal = 0; /* Forget goals when HP or SP changes */ if ((auto_chp != old_chp) || (auto_csp != old_csp)) goal = 0; *************** *** 4167,4176 **** } #else #ifdef MACINTOSH static int HACK = 0; ! #endif /* MACINTOSH */ ! #endif /* ALLOW_BORG */ --- 4227,4237 ---- } + #else #ifdef MACINTOSH static int HACK = 0; ! #endif ! #endif diff -w -c -r Borg/borg6.c adamborg/borg6.c *** Borg/borg6.c Sun Apr 13 23:22:10 1997 --- adamborg/borg6.c Sun Apr 13 23:26:26 1997 *************** *** 97,103 **** /* Adjacent location, use default */ ! if ((ay <= 1) && (ax <= 1)) return (e); /* Try south/north (primary) */ --- 97,103 ---- /* Adjacent location, use default */ ! if ((ay <= 1) && (ay <= 1)) return (e); /* Try south/north (primary) */ *************** *** 364,373 **** old_head = flow_head; /* Circular queue -- insert with wrap */ ! if (++flow_head == AUTO_FLOW_MAX) flow_head = 0; /* Circular queue -- handle overflow (badly) */ ! if (flow_head == flow_tail) flow_head = old_head; } } --- 364,375 ---- old_head = flow_head; /* Circular queue -- insert with wrap */ ! if (++flow_head == AUTO_FLOW_MAX) ! flow_head = 0; /* Circular queue -- handle overflow (badly) */ ! if (flow_head == flow_tail) ! flow_head = old_head; } } *************** *** 659,670 **** /* * Help determine if "phase door" seems like a good idea */ ! static bool borg_caution_phase(int dis) { int n, k, i, d, x, y, p; int min = dis / 2; auto_grid *ag; --- 661,719 ---- /* + * is there a unique nearby? (check auto_kills) + * This is used to keep us in fights and make us use all + * our 'spare' equiptment to kill uniques + * This only works for uniques we know about. If one of the + * monsters around is misidentified then it may be a unique + * and we wouldn't know. + */ + static bool borg_near_unique(int dist) + { + auto_kill *kill; + monster_race *r_ptr; + int x9, y9, ax, ay, d; + int i; + + /* make sure there is a unique around */ + for (i = 1; i < auto_kills_nxt; i++) + { + kill = &auto_kills[i]; + r_ptr = &r_info[kill->r_idx]; + + /* Skip dead monsters */ + if (!kill->r_idx) continue; + + x9 = kill->x; + y9 = kill->y; + + /* Distance components */ + ax = (x9 > c_x) ? (x9 - c_x) : (c_x - x9); + ay = (y9 > c_y) ? (y9 - c_y) : (c_y - y9); + + /* Distance */ + d = MAX(ax, ay); + + /* if the unique is too far then skip it. */ + if (d > dist) continue; + + /* found one. Done. */ + if (r_ptr->flags1 & RF1_UNIQUE) return (TRUE); + } + + /* no nearby uniques */ + return FALSE; + } + + + /* * Help determine if "phase door" seems like a good idea */ ! bool borg_caution_phase(bool emergency) { int n, k, i, d, x, y, p; + int dis = 10; int min = dis / 2; auto_grid *ag; *************** *** 708,731 **** } /* No location */ ! if (i >= 100) return (FALSE); /* Examine */ p = borg_danger(y, x, 2); ! /* Count "safe" locations */ ! if (p <= avoidance / 2) n++; } /* Too much danger */ ! if (n < 90) return (FALSE); /* Okay */ return (TRUE); } /* * Be "cautious" and attempt to prevent death or dishonor. * * Strategy: --- 757,1127 ---- } /* No location */ ! /* in the real code it would keep trying but here we should */ ! /* assume that there is unknown spots that you would be able */ ! /* to go but may be dangerious. */ ! if (i >= 100) ! { ! n++; ! continue; ! } /* Examine */ p = borg_danger(y, x, 2); ! /* if *very* scary, do not allow jumps at all */ ! if (p > auto_chp) n++; } /* Too much danger */ ! /* in an emergency try with extra danger allowed */ ! if (n > (emergency ? 20 : 5)) ! { ! borg_note(format("# No Phase. scary squares: %d", n)); ! return (FALSE); ! } ! /* note how scary it was */ ! if (emergency) ! borg_note(format("# Emergency Phase. scary squares: %d", n)); ! else ! borg_note(format("# Safe to Phase. scary squares: %d", n)); /* Okay */ return (TRUE); } + /* + * Try to phase door or teleport + * b_q is the danger of the least dangerious square around us. + */ + bool borg_escape(int b_q) + { + /* also run if stunned or it is scary here */ + if ((b_q > avoidance) || do_heavy_stun || + (b_q > ((auto_mhp*2)/5) && !borg_fighting_unique)) + { + /* only escape with spell if fail is low */ + int allow_fail = 2; + /* if very healthy, allow extra fail */ + if ((auto_chp*100)/auto_mhp > 90) + allow_fail = 20; + + /* very scary, do not allow fail */ + if ((b_q > avoidance) || do_heavy_stun) + allow_fail = 0; + + /* Phase door, if useful */ + if (amt_phase && borg_caution_phase(FALSE) && + (borg_spell_fail(0, 2, allow_fail) || + borg_prayer_fail(4, 0, allow_fail) || + borg_read_scroll(SV_SCROLL_PHASE_DOOR))) + { + /* Success */ + return (TRUE); + } + + /* Teleport via spell */ + if ( borg_spell_fail(1, 5, allow_fail) || + borg_prayer_fail(1, 1, allow_fail) || + borg_prayer_fail(4, 1, allow_fail)) + { + /* Success */ + return (TRUE); + } + + /* if low failure allowed, use scroll before staff */ + /* !FIX: should check for % fail use of staff AJG */ + if ( ((allow_fail > 1) && + (borg_use_staff(SV_STAFF_TELEPORTATION) || + borg_read_scroll(SV_SCROLL_TELEPORT))) || + ((allow_fail <= 1) && + (borg_read_scroll(SV_SCROLL_TELEPORT) || + borg_use_staff(SV_STAFF_TELEPORTATION)))) + { + /* Success */ + return (TRUE); + } + + /* if I fail to teleport, try phase again (better to */ + /* take a chance and phase out than stick around and die) */ + if ( amt_phase && borg_caution_phase(TRUE) && + (borg_spell_fail(0, 2, allow_fail) || + borg_prayer_fail(4, 0, allow_fail) || + borg_read_scroll(SV_SCROLL_PHASE_DOOR))) + { + /* Success */ + return (TRUE); + } + + /* if we got this far we tried to escape but couldn't... */ + /* time to flee */ + if (!goal_fleeing) + { + /* Note */ + borg_note("# Fleeing (failed to teleport)"); + + /* Start fleeing */ + goal_fleeing = TRUE; + } + + /* Flee now */ + if (!goal_leaving) + { + /* Flee! */ + borg_note("# Leaving (failed to teleport)"); + + /* Start leaving */ + goal_leaving = TRUE; + } + + } + + /* Attempt to teleport (usually) */ + /* do not escape from uniques so quick */ + if (((b_q > avoidance / 2) && !borg_fighting_unique ) || + (b_q > avoidance) || do_heavy_stun) + { + /* allow any fail beacuse this round is 'safe' */ + /* (next round may not be) */ + + /* XXX XXX XXX Count close calls */ + + /* Phase door, if useful */ + if (amt_phase && borg_caution_phase(FALSE) && + (borg_spell(0, 2) || + borg_prayer(4, 0) || + borg_read_scroll(SV_SCROLL_PHASE_DOOR))) + { + /* Success */ + return (TRUE); + } + + /* Try teleportation */ + if ((rand_int(100) < 50) && + (borg_spell(1, 5) || + borg_prayer(4, 1) || + borg_prayer(1, 1) || + borg_use_staff(SV_STAFF_TELEPORTATION) || + borg_read_scroll(SV_SCROLL_TELEPORT))) + { + /* Success */ + return (TRUE); + } + } + return (FALSE); + } + /* + * ** Try healing ** + * this function tries to heal the borg both before trying to flee (pre_flight) + * and after. Before the flight check, try to heal up enough to stay in the fight. + * after the flight check, we are no longer in immediate danger so heal up as a + * precaution. + */ + static bool borg_heal( bool pre_flight, int danger ) + { + int hp_down ; + int allow_fail = 20; + int chance; + + hp_down = auto_mhp - auto_chp; + + /* before the fight only do sure fire cures */ + if (pre_flight) + allow_fail = 0; + + /* if unhurt no healing needed */ + if (hp_down == 0) + return FALSE; + + /* Hack -- heal when wounded (prayers) */ + /* 4/5 hp 0% */ + /* 3/4 hp 5% */ + /* 2/3 hp 20% */ + /* 1/2 hp 50% */ + /* 1/3 hp 80% */ + /* 1/4 hp 100% */ + chance = rand_int(100); + + /* BIG HACK. get max damage that can be done. */ + if (!pre_flight) + { + if ( danger ) + { + s16b save_avoid; + + save_avoid = avoidance; + avoidance = 1; + danger = borg_danger(c_y, c_x, 1); + avoidance = save_avoid; + } + + /* if the next hit may make us run, heal now */ + if (((auto_chp - danger) / 2) < danger) + { + if (mb_ptr->spell_book == TV_PRAYER_BOOK) + chance -= 50; + else + chance -= 20; + } + + if (!(((auto_chp <= ((auto_mhp * 4) / 5)) && (chance < 0)) || + ((auto_chp <= ((auto_mhp * 3) / 4)) && (chance < 5)) || + ((auto_chp <= ((auto_mhp * 2) / 3)) && (chance < 20)) || + ((auto_chp <= (auto_mhp / 2)) && (chance < 50)) || + ((auto_chp <= (auto_mhp / 3)) && (chance < 80)) || + (auto_chp <= (auto_mhp / 4)) || + do_heavy_stun || do_stun)) + return FALSE; + } + + /* only heal before attempting to flee if the danger is */ + /* more than the avoidance and being healed will help */ + if ( pre_flight ) + { + if (danger < avoidance) + return (FALSE); + + if (danger > auto_mhp) + return (FALSE); + } + /* Cure light Wounds (2d10) */ + if ( hp_down < 10 && + (danger - (hp_down < 6 ? hp_down : 6) < avoidance) && + borg_prayer_fail(0, 1, allow_fail)) + { + return (TRUE); + } + /* Cure Serious Wounds (4d10) */ + if ( hp_down < 20 && + (danger - (hp_down < 12 ? hp_down : 12) < avoidance) && + borg_prayer_fail(1, 2, allow_fail)) + { + return (TRUE); + } + + /* Cure Critical Wounds (6d10) */ + if ( hp_down < 50 && + (danger - (hp_down < 18 ? hp_down : 18) < avoidance) && + (borg_prayer_fail(2, 2, allow_fail) || + borg_prayer_fail(6, 0, allow_fail))) + { + return (TRUE); + } + + /* Cure Mortal Wounds (8d10) */ + if ( hp_down < 120 && + (danger - (hp_down < 24 ? hp_down : 24) < avoidance) && + (borg_prayer_fail(2, 7, allow_fail) || + borg_prayer_fail(6, 1, allow_fail))) + { + return (TRUE); + } + + /* Heal (300hp) */ + if (hp_down < 350 && + (danger - (hp_down < 300 ? hp_down : 300) < avoidance) && + borg_prayer_fail(3, 2, allow_fail) ) + { + return (TRUE); + } + + /* Healing (2000hp) */ + if ((danger - (hp_down < 2000 ? hp_down : 2000) < avoidance) && + borg_prayer_fail(6, 2, allow_fail)) + { + return (TRUE); + } + + /* Try a lesser prayer again, just incase we tried a */ + /* higher spell and failed */ + /* (didn't have/not enough mana...) */ + if ( !pre_flight && + (borg_prayer_fail(3, 2, allow_fail) || + borg_prayer_fail(2, 7, allow_fail) || + borg_prayer_fail(2, 2, allow_fail) || + borg_prayer_fail(1, 2, allow_fail) || + borg_prayer_fail(0, 1, allow_fail))) + { + return (TRUE); + } + + /* very hurt, Big heal - reusable */ + if (hp_down > 150) + { + if (((danger - (hp_down < 500 ? hp_down : 500) < avoidance) || + !pre_flight) && borg_zap_rod(SV_ROD_HEALING)) /* 500hp */ + { + return TRUE; + } + + if (((danger - (hp_down < 300 ? hp_down : 300) < avoidance) || + !pre_flight) && borg_use_staff(SV_STAFF_HEALING)) /* 300hp */ + { + return TRUE; + } + } + + /* very hurt, use big potions. */ + if ((hp_down > 300) || ((hp_down > 150) && borg_fighting_unique)) + { + /* use life and *healing* before healing because they are less */ + /* common and clutter inventory. */ + if (((danger - (hp_down < 1200 ? hp_down : 1200) < avoidance) || + !pre_flight) && + (borg_quaff_potion(SV_POTION_LIFE) || + borg_quaff_potion(SV_POTION_STAR_HEALING)) ) + { + return TRUE; + } + + if ((((danger - (hp_down < 300 ? hp_down : 300)) < avoidance) || + !pre_flight) && + borg_quaff_potion(SV_POTION_HEALING)) /* 300hp */ + { + return TRUE; + } + } + + /* do not drink cure potions during a fight to heal. */ + if (!pre_flight) return (FALSE); + + /* use staff more librally, it will not last long. */ + if (auto_level > 25) + { + if (((danger - (hp_down < 300 ? hp_down : 300)) < avoidance) && + borg_use_staff(SV_STAFF_HEALING)) /* 300hp */ + { + return TRUE; + } + } + + /* Do not use up CSW/CCW on healing if high level */ + if (auto_level > 15) return (FALSE); + + /* not so hurt, use smaller potions. */ + /* (only use up cure crits if we have lots) */ + if (amt_cure_critical > 8) + { + if ((danger - (hp_down < 12 ? hp_down : 12) < avoidance) && + borg_quaff_potion(SV_POTION_CURE_CRITICAL)) + { + return (TRUE); + } + } + + if ((danger - (hp_down < 8 ? hp_down : 8) < avoidance) && + borg_quaff_potion(SV_POTION_CURE_SERIOUS)) + { + return (TRUE); + } + + return (FALSE); + } + + + /* * Be "cautious" and attempt to prevent death or dishonor. * * Strategy: *************** *** 732,737 **** --- 1128,1135 ---- * * (1) Caution * (1a) Analyze the situation + * (1a1) try to heal + * (1a2) try a defence * (1b) Teleport from danger * (1c) Handle critical stuff * (1d) Retreat to happy grids *************** *** 848,854 **** bool nasty = FALSE; - /*** Notice "nasty" situations ***/ /* About to run out of light is extremely nasty */ --- 1246,1251 ---- *************** *** 866,874 **** --- 1263,1290 ---- /* Hallucination is nasty */ if (do_image) nasty = TRUE; + /* if on level 100 and not ready for Morgoth, run */ + if (auto_depth == 100) + { + if (borg_ready_morgoth == 0) + { + /* Start leaving */ + if (!goal_leaving) + { + /* Note */ + borg_note("# Leaving (No Morgoth Yet)"); + /* Start leaving */ + goal_leaving = TRUE; + } + } + } + /*** Evaluate local danger ***/ + /* am I fighting a unique? */ + borg_fighting_unique = borg_near_unique(6); + /* Look around */ p = borg_danger(c_y, c_x, 1); *************** *** 916,941 **** if ((p > avoidance / 2) || (p > auto_fear_region[c_y/11][c_x/11])) { /* Describe (briefly) the current situation */ ! borg_note(format("# Loc:%d,%d Dep:%d Lev:%d HP:%d/%d SP:%d/%d Danger:%d/%d", c_x, c_y, auto_depth, auto_level, auto_chp, auto_mhp, auto_csp, auto_msp, b_q, p)); } /* No (good) retreat */ if ((b_q < 0) || (b_q > p)) b_q = p; /*** Danger ***/ /* Impending doom */ ! if (borg_restock()) { /* Start leaving */ if (!goal_leaving) { /* Note */ ! borg_note("# Leaving (restock)"); /* Start leaving */ goal_leaving = TRUE; --- 1332,1375 ---- if ((p > avoidance / 2) || (p > auto_fear_region[c_y/11][c_x/11])) { /* Describe (briefly) the current situation */ ! borg_note(format("# Loc:%d,%d Dep:%d Lev:%d HP:%d/%d SP:%d/%d Danger:b_q=%d/p=%d", c_x, c_y, auto_depth, auto_level, auto_chp, auto_mhp, auto_csp, auto_msp, b_q, p)); } + else + { + if (borg_goi) + borg_note(format("# Loc:%d,%d goi!", c_x, c_y)); + } /* No (good) retreat */ if ((b_q < 0) || (b_q > p)) b_q = p; + /* try healing before running away */ + if (borg_heal( TRUE, p )) + return TRUE; + + /* do some defence before running away! */ + if (borg_defend()) + return TRUE; + /*** Danger ***/ /* Impending doom */ ! /* don't take off in the middle of a fight */ ! /* just to restock and it is useless to restock */ ! /* if you have just left town. */ ! if (borg_restock(auto_depth) && ! !borg_fighting_unique && ! (auto_time_town + (c_t - auto_began)) > 200) { /* Start leaving */ if (!goal_leaving) { /* Note */ ! borg_note(format("# Leaving (restock) %s", borg_restock(auto_depth))); /* Start leaving */ goal_leaving = TRUE; *************** *** 945,951 **** if (!goal_fleeing) { /* Note */ ! borg_note("# Fleeing (restock)"); /* Start fleeing */ goal_fleeing = TRUE; --- 1379,1385 ---- if (!goal_fleeing) { /* Note */ ! borg_note(format("# Fleeing (restock) %s", borg_restock(auto_depth))); /* Start fleeing */ goal_fleeing = TRUE; *************** *** 953,972 **** } /* Excessive danger */ ! else if (b_q > auto_mhp) { - /* Start leaving */ - if (!goal_leaving) - { - /* Note */ - borg_note("# Leaving (excessive danger)"); - - /* Start leaving */ - goal_leaving = TRUE; - } - /* Start fleeing */ ! if (!goal_fleeing) { /* Note */ borg_note("# Fleeing (excessive danger)"); --- 1387,1398 ---- } /* Excessive danger */ ! else if ((b_q > auto_mhp) && (rand_int(100) > (auto_level+20))) { /* Start fleeing */ ! /* do not flee level if going after Morgoth or fighting a unique */ ! if (!goal_fleeing && !borg_fighting_unique && ! !((auto_depth == 100) && (borg_ready_morgoth == 1))) { /* Note */ borg_note("# Fleeing (excessive danger)"); *************** *** 973,998 **** /* Start fleeing */ goal_fleeing = TRUE; - - /* Fear this depth */ - auto_fear_depth[auto_depth] = TRUE; } } - - /* Moderate danger */ - else if (b_q > auto_mhp / 2) - { - /* Start leaving */ - if (!goal_leaving) - { - /* Flee! */ - borg_note("# Leaving (moderate danger)"); - - /* Start leaving */ - goal_leaving = TRUE; - } - } - /* Potential danger (near death) in town */ else if (!auto_depth && (p > auto_chp)) { --- 1399,1406 ---- *************** *** 1014,1020 **** if (goal_leaving || goal_fleeing) { /* Take next stairs */ ! stair_less = stair_more = TRUE; } /* Take stairs up */ --- 1422,1435 ---- if (goal_leaving || goal_fleeing) { /* Take next stairs */ ! stair_less = goal_fleeing; ! if (borg_ready_morgoth == 0) ! stair_less = TRUE; ! ! /* Only go down if fleeing or prepared. */ ! stair_more = goal_fleeing; ! if ((cptr)NULL == borg_prepared(auto_depth+1)) ! stair_more = TRUE; } /* Take stairs up */ *************** *** 1035,1041 **** } /* Take stairs down */ ! if (stair_more || (b_q > auto_chp / 2)) { /* Current grid */ auto_grid *ag = &auto_grids[c_y][c_x]; --- 1450,1456 ---- } /* Take stairs down */ ! if ((stair_more || (b_q > auto_chp / 2)) && !goal_recalling) { /* Current grid */ auto_grid *ag = &auto_grids[c_y][c_x]; *************** *** 1055,1070 **** /*** Escape if possible ***/ /* Attempt to escape */ ! if (b_q > avoidance) { - /* XXX XXX XXX Count close calls */ - - /* Phase door, if useful */ - if (borg_caution_phase(10) && - (borg_spell(0, 2) || - borg_prayer(4, 0) || - borg_read_scroll(SV_SCROLL_PHASE_DOOR))) - { /* Hack -- reset the "goal" location */ g_x = g_y = 0; --- 1470,1477 ---- /*** Escape if possible ***/ /* Attempt to escape */ ! if (borg_escape(b_q)) { /* Hack -- reset the "goal" location */ g_x = g_y = 0; *************** *** 1072,1126 **** return (TRUE); } - /* Teleport */ - if (TRUE && - (borg_spell(1, 5) || - borg_prayer(4, 1) || - borg_prayer(1, 1) || - borg_read_scroll(SV_SCROLL_TELEPORT) || - borg_use_staff(SV_STAFF_TELEPORTATION))) - { - /* Hack -- reset the "goal" location */ - g_x = g_y = 0; - - /* Success */ - return (TRUE); - } - } - - /* Attempt to teleport (usually) */ - if (b_q > avoidance / 2) - { - /* XXX XXX XXX Count close calls */ - - /* Phase door, if useful */ - if (borg_caution_phase(10) && - (borg_spell(0, 2) || - borg_prayer(4, 0) || - borg_read_scroll(SV_SCROLL_PHASE_DOOR))) - { - /* Hack -- reset the "goal" location */ - g_x = g_y = 0; - - /* Success */ - return (TRUE); - } - - /* Try teleportation */ - if ((rand_int(100) < 50) && - (borg_spell(1, 5) || - borg_prayer(4, 1) || - borg_prayer(1, 1))) - { - /* Hack -- reset the "goal" location */ - g_x = g_y = 0; - - /* Success */ - return (TRUE); - } - } - - /*** Deal with critical situations ***/ /* Hack -- require light */ --- 1479,1484 ---- *************** *** 1268,1274 **** /* Obtain the grid */ ag = &auto_grids[y1][x1]; - /* Require floor */ if (!borg_cave_floor_grid(ag)) break; --- 1626,1631 ---- *************** *** 1278,1283 **** --- 1635,1643 ---- /* Check danger (over time) */ if (borg_danger(y1, x1, r+1) > p) break; + /* !FIX AJG keep dying by colossus. Maybe this will help... */ + /* make sure it is not dangerous to take the first step. */ + if (r == 1 && borg_danger(y1, x1, 1) >= p) break; /* Skip monsters */ if (ag->kill) break; *************** *** 1400,1429 **** /*** Try healing ***/ ! /* Hack -- heal when wounded (prayers) */ ! if ((auto_chp <= auto_mhp / 2) && (rand_int(100) < 20)) ! { ! if (borg_prayer(2, 2) || ! borg_prayer(2, 7) || ! borg_prayer(6, 0) || ! borg_prayer(6, 1)) ! { ! return (TRUE); ! } ! } - /* Hack -- heal when wounded */ - if ((auto_chp <= auto_mhp / 2) && (rand_int(100) < 20)) - { - if (borg_quaff_potion(SV_POTION_CURE_CRITICAL) || - borg_quaff_potion(SV_POTION_CURE_SERIOUS)) - { - return (TRUE); - } - } - /* Hack -- heal when blind/confused */ ! if ((do_blind || do_confused) && (rand_int(100) < 20)) { if (borg_quaff_potion(SV_POTION_CURE_SERIOUS) || borg_quaff_potion(SV_POTION_CURE_CRITICAL)) --- 1760,1771 ---- /*** Try healing ***/ ! /* heal when wounded */ ! if (borg_heal(FALSE, p)) ! return TRUE; /* Hack -- heal when blind/confused */ ! if ((do_blind || do_confused) && (rand_int(100) < 70)) { if (borg_quaff_potion(SV_POTION_CURE_SERIOUS) || borg_quaff_potion(SV_POTION_CURE_CRITICAL)) *************** *** 1433,1439 **** } /* Hack -- cure wounds when bleeding */ ! if (do_cut && (rand_int(100) < 10)) { if (borg_quaff_potion(SV_POTION_CURE_SERIOUS) || borg_quaff_potion(SV_POTION_CURE_CRITICAL)) --- 1775,1781 ---- } /* Hack -- cure wounds when bleeding */ ! if (do_cut && (auto_chp < 2 || (rand_int(100) < 10))) { if (borg_quaff_potion(SV_POTION_CURE_SERIOUS) || borg_quaff_potion(SV_POTION_CURE_CRITICAL)) *************** *** 1443,1449 **** } /* Hack -- cure poison when poisoned */ ! if (do_poisoned && (rand_int(100) < 10)) { if (borg_spell(1, 4) || borg_prayer(2, 0) || --- 1785,1791 ---- } /* Hack -- cure poison when poisoned */ ! if (do_poisoned && (auto_chp < 2 || rand_int(100) < 10)) { if (borg_spell(1, 4) || borg_prayer(2, 0) || *************** *** 1455,1466 **** } /* Hack -- cure fear when afraid */ ! if (do_afraid && (rand_int(100) < 10)) { if (borg_prayer(0, 3) || borg_quaff_potion(SV_POTION_BOLDNESS) || borg_quaff_potion(SV_POTION_HEROISM) || ! borg_quaff_potion(SV_POTION_BESERK_STRENGTH)) { return (TRUE); } --- 1797,1810 ---- } /* Hack -- cure fear when afraid */ ! if (do_afraid && (rand_int(100) < 70)) { if (borg_prayer(0, 3) || borg_quaff_potion(SV_POTION_BOLDNESS) || borg_quaff_potion(SV_POTION_HEROISM) || ! borg_quaff_potion(SV_POTION_BESERK_STRENGTH) || ! borg_spell(7, 2) || ! borg_spell(7, 0)) { return (TRUE); } *************** *** 1467,1477 **** } /*** Note impending death XXX XXX XXX ***/ /* Flee from low hit-points */ ! if ((auto_chp < auto_mhp / 2) && ! (amt_cure_critical < 5)) { /* Flee from low hit-points */ if (auto_depth && (rand_int(100) < 25)) --- 1811,1863 ---- } + /* restore Mana */ + /* note, blow the staff charges easy because the staff will not last. */ + if (auto_csp < (auto_msp / 5) && (rand_int(100) < 50)) + { + if (borg_use_staff(SV_STAFF_THE_MAGI)) + { + borg_note("# Use Magi Staff"); + return (TRUE); + } + } + + /* blowing potions is harder */ + /* NOTE: must have enough mana to keep up GOI or do a HEAL */ + if (auto_csp < (auto_msp / 10) || + ((auto_depth > 95) && (auto_csp < 70) && (auto_msp > 0))) + { + /* If deep do not check, just use staff */ + if ((auto_depth > 95) || (rand_int(100) < 30)) + { + int num_mana = 5; + + if (auto_depth > 95) + { + /* stock up on mana to take out MORGOTH */ + num_mana = 20; + } + /* only use the potions if we have lots or */ + /* are battling a unique */ + if (amt_mana > num_mana || borg_fighting_unique) + { + if (borg_use_staff(SV_STAFF_THE_MAGI) || + borg_quaff_potion(SV_POTION_RESTORE_MANA)) + { + borg_note("# Restored My Mana"); + return (TRUE); + } + } + } + } + /*** Note impending death XXX XXX XXX ***/ /* Flee from low hit-points */ ! if (((auto_chp < auto_mhp / 3) || ! ((auto_chp < auto_mhp / 2) && auto_chp < 100)) && ! (amt_cure_critical < 3) && ! (amt_heal < 1)) { /* Flee from low hit-points */ if (auto_depth && (rand_int(100) < 25)) *************** *** 1494,1506 **** /* Start fleeing */ goal_fleeing = TRUE; - - /* Fear this depth */ - auto_fear_depth[auto_depth] = TRUE; } } } /* Hack -- use "recall" to flee if possible */ if (goal_fleeing && auto_depth && (borg_recall())) { --- 1880,1919 ---- /* Start fleeing */ goal_fleeing = TRUE; } } } + /* Try an emergency teleport (This will take us to negative mana but, */ + /* what the hell, I am about to die anyway. */ + if ((((p*2)/ 3) > avoidance) && (auto_msp > 1)) + { + int sv_mana = auto_csp; + + auto_csp = auto_msp; + if ( borg_spell_fail(1, 5, 15) || + borg_prayer_fail(1, 1, 15) || + borg_prayer_fail(4, 1, 15) || + borg_spell_fail(0, 2, 15) || + borg_prayer_fail(4, 0, 15) || + borg_spell_fail(5, 2, 15)) + { + /* verify use of spell */ + borg_keypress('y'); + + /* Flee! */ + borg_note("# Emergency Teleport! AHHHhhhh!!!...."); + + /* Hack -- reset the "goal" location */ + g_x = g_y = 0; + + goal_fleeing = TRUE; + + return (TRUE); + } + auto_csp = sv_mana; + } + /* Hack -- use "recall" to flee if possible */ if (goal_fleeing && auto_depth && (borg_recall())) { *************** *** 1511,1517 **** return (TRUE); } - /* Nothing */ return (FALSE); } --- 1924,1929 ---- *************** *** 1648,1659 **** /* * Guess how much damage a physical attack will do to a monster - * - * We ignore "brands" and such for now */ static int borg_thrust_damage_one(int i) { int dam; auto_kill *kill; --- 2060,2070 ---- /* * Guess how much damage a physical attack will do to a monster */ static int borg_thrust_damage_one(int i) { int dam; + int mult; auto_kill *kill; *************** *** 1661,1671 **** auto_item *item; /* Examine current weapon */ item = &auto_items[INVEN_WIELD]; - /* Monster record */ kill = &auto_kills[i]; --- 2072,2083 ---- auto_item *item; + int chance; + /* Examine current weapon */ item = &auto_items[INVEN_WIELD]; /* Monster record */ kill = &auto_kills[i]; *************** *** 1672,1684 **** /* Monster race */ r_ptr = &r_info[kill->r_idx]; - /* Damage */ dam = (item->dd * (item->ds + 1) / 2); dam = dam + item->to_d + my_to_dam; dam = dam * my_num_blow; /* Limit damage to twice maximal hitpoints */ if (dam > kill->power * 2) dam = kill->power * 2; --- 2084,2129 ---- /* Monster race */ r_ptr = &r_info[kill->r_idx]; /* Damage */ dam = (item->dd * (item->ds + 1) / 2); + + /* here is the place for slays and such */ + mult = 1; + if (((my_slay_animal) && (r_ptr->flags3 & RF3_ANIMAL)) || + ((my_slay_evil) && (r_ptr->flags3 & RF3_EVIL))) + mult = 2; + if (((my_slay_undead) && (r_ptr->flags3 & RF3_ANIMAL)) || + ((my_slay_demon) && (r_ptr->flags3 & RF3_DEMON)) || + ((my_slay_orc) && (r_ptr->flags3 & RF3_ORC)) || + ((my_slay_troll) && (r_ptr->flags3 & RF3_TROLL)) || + ((my_slay_giant) && (r_ptr->flags3 & RF3_GIANT)) || + ((my_slay_dragon) && (r_ptr->flags3 & RF3_DRAGON)) || + ((my_brand_acid) && !(r_ptr->flags3 & RF3_IM_ACID)) || + ((my_brand_fire) && !(r_ptr->flags3 & RF3_IM_FIRE)) || + ((my_brand_cold) && !(r_ptr->flags3 & RF3_IM_COLD)) || + ((my_brand_elec) && !(r_ptr->flags3 & RF3_IM_ELEC))) + mult = 3; + if ((my_kill_dragon) && (r_ptr->flags3 & RF3_DRAGON)) + mult = 5; + dam *= mult; + dam = dam + item->to_d + my_to_dam; dam = dam * my_num_blow; + /* reduce for % chance to hit (AC) */ + chance = (my_skill_thn + ((my_to_hit + item->to_h) * 3)); + if ((r_ptr->ac * 3 / 4) > 0) + chance = (chance * 100) / (r_ptr->ac * 3 / 4); + /* 5% automatic success/fail */ + if (chance > 95) chance = 95; + if (chance < 5) chance = 5; + + /* add 20% to chance to give a bit more wieght to weapons */ + chance += 20; + + dam = (dam * chance) / 100; + /* Limit damage to twice maximal hitpoints */ if (dam > kill->power * 2) dam = kill->power * 2; *************** *** 1696,1703 **** { int p, dir; - int num = 0; - int i, b_i = -1; int d, b_d = -1; --- 2141,2146 ---- *************** *** 1705,1711 **** auto_kill *kill; - /* Too afraid to attack */ if (do_afraid) return (0); --- 2148,2153 ---- *************** *** 1731,1742 **** /* Obtain the monster */ kill = &auto_kills[ag->kill]; /* Calculate danger */ p = borg_danger_aux(y, x, 1, ag->kill); ! /* Hack -- avoid waking most "hard" sleeping monsters */ ! if (!kill->awake && (p > avoidance / 2) && (d <= kill->power)) ! { continue; } --- 2173,2185 ---- /* Obtain the monster */ kill = &auto_kills[ag->kill]; + /* Hack -- avoid waking most "hard" sleeping monsters */ + if (!kill->awake && (d <= kill->power)) + { /* Calculate danger */ p = borg_danger_aux(y, x, 1, ag->kill); ! if (p > avoidance / 2) continue; } *************** *** 1752,1763 **** /* Ignore lower damage */ if ((b_i >= 0) && (d < b_d)) continue; - /* Hack -- reset chooser */ - if ((b_i >= 0) && (d > b_d)) num = 0; - - /* Apply the randomizer */ - if ((num > 1) && (rand_int(num) != 0)) continue; - /* Save the info */ b_i = i; b_d = d; --- 2195,2200 ---- *************** *** 1766,1781 **** /* Nothing to attack */ if (b_i < 0) return (0); - /* Simulation */ if (auto_simulate) return (b_d); - /* Save the location */ g_x = auto_temp_x[b_i]; g_y = auto_temp_y[b_i]; - /* Note */ borg_note(format("# Facing location (%d,%d)", g_x, g_y)); --- 2203,2215 ---- *************** *** 1787,1795 **** /* Get a direction for attacking */ dir = borg_extract_dir(c_y, c_x, g_y, g_x); - /* Attack */ - borg_keypress('+'); - /* Attack the grid */ borg_keypress('0' + dir); --- 2221,2226 ---- *************** *** 1873,1963 **** { /* Magic Missile */ case GF_MISSILE: - { break; - } /* Arrow */ case GF_ARROW: - { break; - } /* Pure damage */ case GF_MANA: ! { break; - } /* Meteor -- powerful magic missile */ case GF_METEOR: - { break; - } /* Acid */ case GF_ACID: - { if (r_ptr->flags3 & RF3_IM_ACID) dam /= 9; break; - } /* Electricity */ case GF_ELEC: - { if (r_ptr->flags3 & RF3_IM_ELEC) dam /= 9; break; - } /* Fire damage */ case GF_FIRE: - { if (r_ptr->flags3 & RF3_IM_FIRE) dam /= 9; break; - } /* Cold */ case GF_COLD: - { if (r_ptr->flags3 & RF3_IM_COLD) dam /= 9; break; - } /* Poison */ case GF_POIS: - { if (r_ptr->flags3 & RF3_IM_POIS) dam /= 9; break; - } /* Ice */ case GF_ICE: - { if (r_ptr->flags3 & RF3_IM_COLD) dam /= 9; break; - } /* Holy Orb */ case GF_HOLY_ORB: - { if (r_ptr->flags3 & RF3_EVIL) dam *= 2; break; - } /* Weak Lite */ case GF_LITE_WEAK: - { if (!(r_ptr->flags3 & RF3_HURT_LITE)) dam = 0; break; - } /* Drain Life */ case GF_OLD_DRAIN: - { if ((r_ptr->flags3 & RF3_UNDEAD) || (r_ptr->flags3 & RF3_DEMON) || (strchr("Egv", r_ptr->d_char))) --- 2304,2373 ---- { /* Magic Missile */ case GF_MISSILE: break; /* Arrow */ case GF_ARROW: break; /* Pure damage */ case GF_MANA: ! /* only use mana storm against uniques... this */ ! /* should cut down on some mana use. */ ! if (!borg_fighting_unique) ! dam = 0; break; /* Meteor -- powerful magic missile */ case GF_METEOR: break; /* Acid */ case GF_ACID: if (r_ptr->flags3 & RF3_IM_ACID) dam /= 9; break; /* Electricity */ case GF_ELEC: if (r_ptr->flags3 & RF3_IM_ELEC) dam /= 9; break; /* Fire damage */ case GF_FIRE: if (r_ptr->flags3 & RF3_IM_FIRE) dam /= 9; break; /* Cold */ case GF_COLD: if (r_ptr->flags3 & RF3_IM_COLD) dam /= 9; break; /* Poison */ case GF_POIS: if (r_ptr->flags3 & RF3_IM_POIS) dam /= 9; break; /* Ice */ case GF_ICE: if (r_ptr->flags3 & RF3_IM_COLD) dam /= 9; break; /* Holy Orb */ case GF_HOLY_ORB: if (r_ptr->flags3 & RF3_EVIL) dam *= 2; break; /* Weak Lite */ case GF_LITE_WEAK: if (!(r_ptr->flags3 & RF3_HURT_LITE)) dam = 0; break; /* Drain Life */ case GF_OLD_DRAIN: if ((r_ptr->flags3 & RF3_UNDEAD) || (r_ptr->flags3 & RF3_DEMON) || (strchr("Egv", r_ptr->d_char))) *************** *** 1965,1971 **** dam = 0; } break; - } /* Weird attacks */ --- 2375,2380 ---- *************** *** 1973,1979 **** case GF_NETHER: case GF_WATER: case GF_CHAOS: ! case GF_SHARD: case GF_SOUND: case GF_CONFUSION: case GF_DISENCHANT: --- 2382,2388 ---- case GF_NETHER: case GF_WATER: case GF_CHAOS: ! case GF_SHARDS: case GF_SOUND: case GF_CONFUSION: case GF_DISENCHANT: *************** *** 1984,1993 **** case GF_GRAVITY: case GF_LITE: case GF_DARK: - { dam /= 2; break; - } /* Various */ --- 2393,2400 ---- *************** *** 2007,2013 **** case GF_MAKE_TRAP: case GF_AWAY_UNDEAD: case GF_AWAY_EVIL: - case GF_AWAY_ALL: case GF_TURN_UNDEAD: case GF_TURN_EVIL: case GF_TURN_ALL: --- 2414,2419 ---- *************** *** 2014,2029 **** case GF_DISP_UNDEAD: case GF_DISP_EVIL: case GF_DISP_ALL: - { dam = 0; break; } - } /* Limit damage to twice maximal hitpoints */ if (dam > kill->power * 2) dam = kill->power * 2; /* Damage */ return (dam); --- 2420,2447 ---- case GF_DISP_UNDEAD: case GF_DISP_EVIL: case GF_DISP_ALL: dam = 0; break; + + /* pretend the monster just gets trashed when it is telleported away */ + case GF_AWAY_ALL: + dam = 999999; + /* never teleport away uniques. These are the guys you are trying */ + /* to kill! */ + if (r_ptr->flags1 & RF1_UNIQUE) + dam = -5000000; + + break; } /* Limit damage to twice maximal hitpoints */ if (dam > kill->power * 2) dam = kill->power * 2; + /* give a small bonus for whacking a unique */ + /* this should be just enough to give prefrence to wacking uniques */ + if (r_ptr->flags1 & RF1_UNIQUE) + dam++; /* Damage */ return (dam); *************** *** 2072,2090 **** d = borg_launch_damage_one(i, dam, typ); /* No damage */ ! if (d <= 0) return (0); /* Calculate danger */ p = borg_danger_aux(y, x, 1, i); /* Hack -- avoid waking most "hard" sleeping monsters */ ! if (!kill->awake && (p > avoidance / 2) && (d <= kill->power)) { return (-999); } /* Hack -- ignore "easy" / "sleeping" town monsters */ ! if (!auto_depth && (!kill->awake || (p <= 0))) { return (0); } --- 2490,2511 ---- d = borg_launch_damage_one(i, dam, typ); /* No damage */ ! if (d <= 0 && typ != GF_AWAY_ALL) return (0); /* Calculate danger */ p = borg_danger_aux(y, x, 1, i); /* Hack -- avoid waking most "hard" sleeping monsters */ ! if (!kill->awake && ! (p > avoidance / 2) && ! (d < kill->power) && ! typ != GF_AWAY_ALL) { return (-999); } /* Hack -- ignore "easy" / "sleeping" town monsters */ ! if (!auto_depth && !kill->awake) { return (0); } *************** *** 2093,2100 **** p = borg_danger_aux(c_y, c_x, 4, i); /* Reduce "bonus" of partial kills */ ! if (d <= kill->power) p = p / 10; /* Add in power */ d += p; --- 2514,2525 ---- p = borg_danger_aux(c_y, c_x, 4, i); /* Reduce "bonus" of partial kills */ ! if (d < kill->power) p = p / 10; + /* for telleport away, danger is the only factor */ + if (typ == GF_AWAY_ALL && d > 0) + d = 0; + /* Add in power */ d += p; *************** *** 2144,2165 **** ag = &auto_grids[y][x]; /* Stop at walls */ ! if (dist && !borg_cave_floor_grid(ag)) return (0); /* Collect damage (bolts/beams) */ if (rad <= 0) n += borg_launch_bolt_aux_hack(ag->kill, dam, typ); /* Check for arrival at "final target" */ ! if ((x == x2) && (y == y2)) break; ! /* Stop at monsters (bolts) */ if (!rad && ag->kill) return (0); /* Stop at unknown grids (see above) */ ! if (dist && (ag->feat == FEAT_NONE)) return (0); /* Stop at weird grids (see above) */ ! if (dist && (ag->feat == FEAT_INVIS)) return (0); /* Calculate the new location */ mmove2(&y, &x, y1, x1, y2, x2); --- 2569,2620 ---- ag = &auto_grids[y][x]; /* Stop at walls */ ! /* note: beams end at walls. */ ! if (dist) ! { ! /* Stop at walls */ ! /* note if beam, this is the end of the beam */ ! if (!borg_cave_floor_grid(ag)) ! { ! if (rad != -1) ! return (0); ! else ! return (n); ! } ! } /* Collect damage (bolts/beams) */ if (rad <= 0) n += borg_launch_bolt_aux_hack(ag->kill, dam, typ); /* Check for arrival at "final target" */ ! /* except beams, which keep going. */ ! if ((rad != -1) && ((x == x2) && (y == y2))) break; ! /* Stop bolts at monsters */ if (!rad && ag->kill) return (0); + if (dist) + { /* Stop at unknown grids (see above) */ ! /* note if beam, this is the end of the beam */ ! if (ag->feat == FEAT_NONE) ! { ! if (rad != -1) ! return (0); ! else ! return (n); ! } /* Stop at weird grids (see above) */ ! /* note if beam, this is the end of the beam */ ! if (ag->feat == FEAT_INVIS) ! { ! if (rad != -1) ! return (0); ! else ! return (n); ! } ! } /* Calculate the new location */ mmove2(&y, &x, y1, x1, y2, x2); *************** *** 2192,2199 **** --- 2647,2711 ---- /* Collect damage, lowered by distance */ n += borg_launch_bolt_aux_hack(ag->kill, dam / (r + 1), typ); + + /* check destroyed stuff. */ + if (ag->take) + { + auto_take *take = &auto_takes[ag->take]; + object_kind *k_ptr = &k_info[take->k_idx]; + + switch (typ) + { + case GF_ACID: + { + /* rings/boots cost extra (might be speed!) */ + if (k_ptr->tval == TV_BOOTS) + { + n -= 2000; } + break; + } + case GF_ELEC: + { + /* rings/boots cost extra (might be speed!) */ + if (k_ptr->tval == TV_RING) + { + n -= 2000; + } + break; + } + case GF_FIRE: + /* rings/boots cost extra (might be speed!) */ + if (k_ptr->tval == TV_BOOTS) + { + n -= 2000; + } + break; + + case GF_COLD: + { + if (k_ptr->tval == TV_POTION) + { + n -= 2000; + } + break; + } + case GF_MANA: + { + /* rings/boots cost extra (might be speed!) */ + if (k_ptr->tval == TV_RING || + k_ptr->tval == TV_BOOTS || + k_ptr->tval == TV_POTION) + { + n -= 2000; + } + break; + } + } + } + } + /* Result */ return (n); } *************** *** 2292,2297 **** --- 2804,2812 ---- d = d + item->to_d + bow->to_d; d = d * my_ammo_power * my_num_fire; + /* !FIX should do several things here; branded ammo, chance to hit, saving*/ + /* good ammo for big baddies. oh well... later. AJG */ + /* Paranoia */ if (d <= 0) continue; *************** *** 2455,2467 **** /* No firing while blind, confused, or hallucinating */ if (do_blind || do_confused || do_image) return (0); /* Paranoia */ if (auto_simulate && (rand_int(100) < 10)) return (0); - /* Require ability (right now) */ ! if (!borg_spell_okay(book, what)) return (0); /* Choose optimal location */ --- 2970,2985 ---- /* No firing while blind, confused, or hallucinating */ if (do_blind || do_confused || do_image) return (0); + /* make sure I am powerfull enough to do another goi if this one falls */ + if (borg_goi && ((auto_csp - as->power) < 70)) return (0); /* Paranoia */ if (auto_simulate && (rand_int(100) < 10)) return (0); /* Require ability (right now) */ ! /* !FIX AJG should check for %fail.... but what fail rate to use? */ ! /* 40% for now...*/ ! if (!borg_spell_okay_fail(book, what, 40)) return (0); /* Choose optimal location */ *************** *** 2471,2478 **** b_n = b_n - as->power; /* Penalize use of reserve mana */ ! if (auto_csp - as->power < auto_msp / 2) b_n = b_n - as->power * 10; /* Simulation */ if (auto_simulate) return (b_n); --- 2989,3001 ---- b_n = b_n - as->power; /* Penalize use of reserve mana */ ! if (auto_csp - as->power < auto_msp / 2) b_n = b_n - (as->power * 10); + /* Really penalize use of mana needed for final teleport */ + /* (6 pts for mage) */ + if ((auto_msp > 30) && (auto_csp - as->power) < 6) + b_n = b_n - (as->power * 50); + /* Simulation */ if (auto_simulate) return (b_n); *************** *** 2645,2962 **** { /* Physical attack */ case BF_THRUST: - { return (borg_attack_aux_thrust()); - } /* Missile attack */ case BF_LAUNCH: - { return (borg_attack_aux_launch()); - } /* Object attack */ case BF_OBJECT: - { return (borg_attack_aux_object()); - } /* Spell -- magic missile */ case BF_SPELL_MAGIC_MISSILE: - { dam = (3+((auto_level-1)/5))*(4+1)/2; return (borg_attack_aux_spell_bolt(0, 0, rad, dam, GF_MISSILE)); - } /* Spell -- electric bolt */ case BF_SPELL_ELEC_BOLT: - { dam = (3+((auto_level-5)/4))*(8+1)/2; return (borg_attack_aux_spell_bolt(1, 1, rad, dam, GF_ELEC)); - } /* Spell -- cold bolt */ case BF_SPELL_COLD_BOLT: - { dam = (5+((auto_level-5)/4))*(8+1)/2; return (borg_attack_aux_spell_bolt(1, 7, rad, dam, GF_COLD)); - } /* Spell -- fire bolt */ case BF_SPELL_FIRE_BOLT: - { dam = (8+((auto_level-5)/4))*(8+1)/2; return (borg_attack_aux_spell_bolt(2, 6, rad, dam, GF_FIRE)); - } /* Spell -- acid bolt */ case BF_SPELL_ACID_BOLT: - { dam = (6+((auto_level-5)/4))*(8+1)/2; return (borg_attack_aux_spell_bolt(8, 0, rad, dam, GF_ACID)); - } /* Spell -- light beam */ case BF_SPELL_LITE_BEAM: - { rad = -1; dam = (6*(8+1)/2); return (borg_attack_aux_spell_bolt(8, 0, rad, dam, GF_LITE_WEAK)); - } /* Spell -- stinking cloud */ case BF_SPELL_POISON_BALL: - { rad = 2; dam = (10 + (auto_level/2)); return (borg_attack_aux_spell_bolt(0, 8, rad, dam, GF_POIS)); - } /* Spell -- cold ball */ case BF_SPELL_COLD_BALL: - { rad = 2; dam = (30 + auto_level); return (borg_attack_aux_spell_bolt(3, 0, rad, dam, GF_COLD)); - } /* Spell -- acid ball */ case BF_SPELL_ACID_BALL: - { rad = 2; dam = (40 + (auto_level/2)); return (borg_attack_aux_spell_bolt(8, 2, rad, dam, GF_ACID)); - } /* Spell -- fire ball */ case BF_SPELL_FIRE_BALL: - { rad = 2; dam = (55 + auto_level); return (borg_attack_aux_spell_bolt(3, 4, rad, dam, GF_FIRE)); - } /* Spell -- poison storm */ case BF_SPELL_POISON_STORM: - { rad = 3; dam = (20 + (auto_level/2)); return (borg_attack_aux_spell_bolt(8, 1, rad, dam, GF_POIS)); - } /* Spell -- cold storm */ case BF_SPELL_COLD_STORM: - { rad = 3; dam = (70 + auto_level); return (borg_attack_aux_spell_bolt(8, 3, rad, dam, GF_COLD)); - } /* Spell -- meteor storm */ case BF_SPELL_METEOR_STORM: - { rad = 3; dam = (65 + auto_level); return (borg_attack_aux_spell_bolt(8, 4, rad, dam, GF_METEOR)); - } /* Spell -- mana storm */ case BF_SPELL_MANA_STORM: ! { rad = 3; dam = (300 + (auto_level * 2)); return (borg_attack_aux_spell_bolt(8, 5, rad, dam, GF_MANA)); - } /* Prayer -- orb of draining */ case BF_PRAYER_HOLY_ORB_BALL: - { rad = ((auto_level >= 30) ? 3 : 2); dam = ((auto_class == 2) ? 2 : 4); dam = (3*(8+1)/2 + auto_level + (auto_level/dam)); return (borg_attack_aux_prayer_bolt(2, 1, rad, dam, GF_HOLY_ORB)); - } /* Wand -- elec bolt */ case BF_ROD_ELEC_BOLT: - { dam = 3*(8+1)/2; return (borg_attack_aux_rod_bolt(SV_ROD_ELEC_BOLT, rad, dam, GF_ELEC)); - } /* Wand -- cold bolt */ case BF_ROD_COLD_BOLT: - { dam = 5*(8+1)/2; return (borg_attack_aux_rod_bolt(SV_ROD_COLD_BOLT, rad, dam, GF_COLD)); - } /* Wand -- acid bolt */ case BF_ROD_ACID_BOLT: - { dam = 6*(8+1)/2; return (borg_attack_aux_rod_bolt(SV_ROD_ACID_BOLT, rad, dam, GF_ACID)); - } /* Wand -- fire bolt */ case BF_ROD_FIRE_BOLT: - { dam = 8*(8+1)/2; return (borg_attack_aux_rod_bolt(SV_ROD_FIRE_BOLT, rad, dam, GF_FIRE)); - } /* Spell -- light beam */ case BF_ROD_LITE_BEAM: - { rad = -1; dam = (6*(8+1)/2); return (borg_attack_aux_rod_bolt(SV_ROD_LITE, rad, dam, GF_LITE_WEAK)); - } /* Wand -- elec ball */ case BF_ROD_ELEC_BALL: - { rad = 2; dam = 32; return (borg_attack_aux_rod_bolt(SV_ROD_ELEC_BALL, rad, dam, GF_ELEC)); - } /* Wand -- acid ball */ case BF_ROD_COLD_BALL: - { rad = 2; dam = 48; return (borg_attack_aux_rod_bolt(SV_ROD_COLD_BALL, rad, dam, GF_COLD)); - } /* Wand -- acid ball */ case BF_ROD_ACID_BALL: - { rad = 2; dam = 60; return (borg_attack_aux_rod_bolt(SV_ROD_ACID_BALL, rad, dam, GF_ACID)); - } /* Wand -- fire ball */ case BF_ROD_FIRE_BALL: - { rad = 2; dam = 72; return (borg_attack_aux_rod_bolt(SV_ROD_FIRE_BALL, rad, dam, GF_FIRE)); - } /* Wand -- magic missile */ case BF_WAND_MAGIC_MISSILE: - { dam = 2*(6+1)/2; return (borg_attack_aux_wand_bolt(SV_WAND_MAGIC_MISSILE, rad, dam, GF_MISSILE)); - } /* Wand -- elec bolt */ case BF_WAND_ELEC_BOLT: - { dam = 3*(8+1)/2; return (borg_attack_aux_wand_bolt(SV_WAND_ELEC_BOLT, rad, dam, GF_ELEC)); - } /* Wand -- cold bolt */ case BF_WAND_COLD_BOLT: - { dam = 3*(8+1)/2; return (borg_attack_aux_wand_bolt(SV_WAND_COLD_BOLT, rad, dam, GF_COLD)); - } /* Wand -- acid bolt */ case BF_WAND_ACID_BOLT: - { dam = 5*(8+1)/2; return (borg_attack_aux_wand_bolt(SV_WAND_ACID_BOLT, rad, dam, GF_ACID)); - } /* Wand -- fire bolt */ case BF_WAND_FIRE_BOLT: - { dam = 6*(8+1)/2; return (borg_attack_aux_wand_bolt(SV_WAND_FIRE_BOLT, rad, dam, GF_FIRE)); - } /* Spell -- light beam */ case BF_WAND_LITE_BEAM: - { rad = -1; dam = (6*(8+1)/2); return (borg_attack_aux_wand_bolt(SV_WAND_LITE, rad, dam, GF_LITE_WEAK)); - } /* Wand -- stinking cloud */ case BF_WAND_STINKING_CLOUD: - { rad = 2; dam = 12; return (borg_attack_aux_wand_bolt(SV_WAND_STINKING_CLOUD, rad, dam, GF_POIS)); - } /* Wand -- elec ball */ case BF_WAND_ELEC_BALL: - { rad = 2; dam = 32; return (borg_attack_aux_wand_bolt(SV_WAND_ELEC_BALL, rad, dam, GF_ELEC)); - } /* Wand -- acid ball */ case BF_WAND_COLD_BALL: - { rad = 2; dam = 48; return (borg_attack_aux_wand_bolt(SV_WAND_COLD_BALL, rad, dam, GF_COLD)); - } /* Wand -- acid ball */ case BF_WAND_ACID_BALL: - { rad = 2; dam = 60; return (borg_attack_aux_wand_bolt(SV_WAND_ACID_BALL, rad, dam, GF_ACID)); - } /* Wand -- fire ball */ case BF_WAND_FIRE_BALL: - { rad = 2; dam = 72; return (borg_attack_aux_wand_bolt(SV_WAND_FIRE_BALL, rad, dam, GF_FIRE)); - } /* Wand -- dragon cold */ case BF_WAND_DRAGON_COLD: - { rad = 3; dam = 80; return (borg_attack_aux_wand_bolt(SV_WAND_DRAGON_COLD, rad, dam, GF_COLD)); - } /* Wand -- dragon fire */ case BF_WAND_DRAGON_FIRE: - { rad = 3; dam = 100; return (borg_attack_aux_wand_bolt(SV_WAND_DRAGON_FIRE, rad, dam, GF_FIRE)); } - } /* Oops */ return (0); --- 3168,3406 ---- { /* Physical attack */ case BF_THRUST: return (borg_attack_aux_thrust()); /* Missile attack */ case BF_LAUNCH: return (borg_attack_aux_launch()); /* Object attack */ case BF_OBJECT: return (borg_attack_aux_object()); /* Spell -- magic missile */ case BF_SPELL_MAGIC_MISSILE: dam = (3+((auto_level-1)/5))*(4+1)/2; return (borg_attack_aux_spell_bolt(0, 0, rad, dam, GF_MISSILE)); /* Spell -- electric bolt */ case BF_SPELL_ELEC_BOLT: dam = (3+((auto_level-5)/4))*(8+1)/2; return (borg_attack_aux_spell_bolt(1, 1, rad, dam, GF_ELEC)); /* Spell -- cold bolt */ case BF_SPELL_COLD_BOLT: dam = (5+((auto_level-5)/4))*(8+1)/2; return (borg_attack_aux_spell_bolt(1, 7, rad, dam, GF_COLD)); /* Spell -- fire bolt */ case BF_SPELL_FIRE_BOLT: dam = (8+((auto_level-5)/4))*(8+1)/2; return (borg_attack_aux_spell_bolt(2, 6, rad, dam, GF_FIRE)); /* Spell -- acid bolt */ case BF_SPELL_ACID_BOLT: dam = (6+((auto_level-5)/4))*(8+1)/2; return (borg_attack_aux_spell_bolt(8, 0, rad, dam, GF_ACID)); /* Spell -- light beam */ case BF_SPELL_LITE_BEAM: rad = -1; dam = (6*(8+1)/2); return (borg_attack_aux_spell_bolt(8, 0, rad, dam, GF_LITE_WEAK)); /* Spell -- stinking cloud */ case BF_SPELL_POISON_BALL: rad = 2; dam = (10 + (auto_level/2)); return (borg_attack_aux_spell_bolt(0, 8, rad, dam, GF_POIS)); /* Spell -- cold ball */ case BF_SPELL_COLD_BALL: rad = 2; dam = (30 + auto_level); return (borg_attack_aux_spell_bolt(3, 0, rad, dam, GF_COLD)); /* Spell -- acid ball */ case BF_SPELL_ACID_BALL: rad = 2; dam = (40 + (auto_level/2)); return (borg_attack_aux_spell_bolt(8, 2, rad, dam, GF_ACID)); /* Spell -- fire ball */ case BF_SPELL_FIRE_BALL: rad = 2; dam = (55 + auto_level); return (borg_attack_aux_spell_bolt(3, 4, rad, dam, GF_FIRE)); /* Spell -- poison storm */ case BF_SPELL_POISON_STORM: rad = 3; dam = (20 + (auto_level/2)); return (borg_attack_aux_spell_bolt(8, 1, rad, dam, GF_POIS)); /* Spell -- cold storm */ case BF_SPELL_COLD_STORM: rad = 3; dam = (70 + auto_level); return (borg_attack_aux_spell_bolt(8, 3, rad, dam, GF_COLD)); /* Spell -- meteor storm */ case BF_SPELL_METEOR_STORM: rad = 3; dam = (65 + auto_level); return (borg_attack_aux_spell_bolt(8, 4, rad, dam, GF_METEOR)); /* Spell -- mana storm */ case BF_SPELL_MANA_STORM: ! rad = 3; dam = (300 + (auto_level * 2)); return (borg_attack_aux_spell_bolt(8, 5, rad, dam, GF_MANA)); /* Prayer -- orb of draining */ case BF_PRAYER_HOLY_ORB_BALL: rad = ((auto_level >= 30) ? 3 : 2); dam = ((auto_class == 2) ? 2 : 4); dam = (3*(8+1)/2 + auto_level + (auto_level/dam)); return (borg_attack_aux_prayer_bolt(2, 1, rad, dam, GF_HOLY_ORB)); /* Wand -- elec bolt */ case BF_ROD_ELEC_BOLT: dam = 3*(8+1)/2; return (borg_attack_aux_rod_bolt(SV_ROD_ELEC_BOLT, rad, dam, GF_ELEC)); /* Wand -- cold bolt */ case BF_ROD_COLD_BOLT: dam = 5*(8+1)/2; return (borg_attack_aux_rod_bolt(SV_ROD_COLD_BOLT, rad, dam, GF_COLD)); /* Wand -- acid bolt */ case BF_ROD_ACID_BOLT: dam = 6*(8+1)/2; return (borg_attack_aux_rod_bolt(SV_ROD_ACID_BOLT, rad, dam, GF_ACID)); /* Wand -- fire bolt */ case BF_ROD_FIRE_BOLT: dam = 8*(8+1)/2; return (borg_attack_aux_rod_bolt(SV_ROD_FIRE_BOLT, rad, dam, GF_FIRE)); /* Spell -- light beam */ case BF_ROD_LITE_BEAM: rad = -1; dam = (6*(8+1)/2); return (borg_attack_aux_rod_bolt(SV_ROD_LITE, rad, dam, GF_LITE_WEAK)); /* Wand -- elec ball */ case BF_ROD_ELEC_BALL: rad = 2; dam = 32; return (borg_attack_aux_rod_bolt(SV_ROD_ELEC_BALL, rad, dam, GF_ELEC)); /* Wand -- acid ball */ case BF_ROD_COLD_BALL: rad = 2; dam = 48; return (borg_attack_aux_rod_bolt(SV_ROD_COLD_BALL, rad, dam, GF_COLD)); /* Wand -- acid ball */ case BF_ROD_ACID_BALL: rad = 2; dam = 60; return (borg_attack_aux_rod_bolt(SV_ROD_ACID_BALL, rad, dam, GF_ACID)); /* Wand -- fire ball */ case BF_ROD_FIRE_BALL: rad = 2; dam = 72; return (borg_attack_aux_rod_bolt(SV_ROD_FIRE_BALL, rad, dam, GF_FIRE)); /* Wand -- magic missile */ case BF_WAND_MAGIC_MISSILE: dam = 2*(6+1)/2; return (borg_attack_aux_wand_bolt(SV_WAND_MAGIC_MISSILE, rad, dam, GF_MISSILE)); /* Wand -- elec bolt */ case BF_WAND_ELEC_BOLT: dam = 3*(8+1)/2; return (borg_attack_aux_wand_bolt(SV_WAND_ELEC_BOLT, rad, dam, GF_ELEC)); /* Wand -- cold bolt */ case BF_WAND_COLD_BOLT: dam = 3*(8+1)/2; return (borg_attack_aux_wand_bolt(SV_WAND_COLD_BOLT, rad, dam, GF_COLD)); /* Wand -- acid bolt */ case BF_WAND_ACID_BOLT: dam = 5*(8+1)/2; return (borg_attack_aux_wand_bolt(SV_WAND_ACID_BOLT, rad, dam, GF_ACID)); /* Wand -- fire bolt */ case BF_WAND_FIRE_BOLT: dam = 6*(8+1)/2; return (borg_attack_aux_wand_bolt(SV_WAND_FIRE_BOLT, rad, dam, GF_FIRE)); /* Spell -- light beam */ case BF_WAND_LITE_BEAM: rad = -1; dam = (6*(8+1)/2); return (borg_attack_aux_wand_bolt(SV_WAND_LITE, rad, dam, GF_LITE_WEAK)); /* Wand -- stinking cloud */ case BF_WAND_STINKING_CLOUD: rad = 2; dam = 12; return (borg_attack_aux_wand_bolt(SV_WAND_STINKING_CLOUD, rad, dam, GF_POIS)); /* Wand -- elec ball */ case BF_WAND_ELEC_BALL: rad = 2; dam = 32; return (borg_attack_aux_wand_bolt(SV_WAND_ELEC_BALL, rad, dam, GF_ELEC)); /* Wand -- acid ball */ case BF_WAND_COLD_BALL: rad = 2; dam = 48; return (borg_attack_aux_wand_bolt(SV_WAND_COLD_BALL, rad, dam, GF_COLD)); /* Wand -- acid ball */ case BF_WAND_ACID_BALL: rad = 2; dam = 60; return (borg_attack_aux_wand_bolt(SV_WAND_ACID_BALL, rad, dam, GF_ACID)); /* Wand -- fire ball */ case BF_WAND_FIRE_BALL: rad = 2; dam = 72; return (borg_attack_aux_wand_bolt(SV_WAND_FIRE_BALL, rad, dam, GF_FIRE)); /* Wand -- dragon cold */ case BF_WAND_DRAGON_COLD: rad = 3; dam = 80; return (borg_attack_aux_wand_bolt(SV_WAND_DRAGON_COLD, rad, dam, GF_COLD)); /* Wand -- dragon fire */ case BF_WAND_DRAGON_FIRE: rad = 3; dam = 100; return (borg_attack_aux_wand_bolt(SV_WAND_DRAGON_FIRE, rad, dam, GF_FIRE)); } /* Oops */ return (0); *************** *** 2994,3003 **** auto_grid *ag; - /* Nobody around */ if (!auto_kills_cnt) return (FALSE); /* Reset list */ auto_temp_n = 0; --- 3438,3449 ---- auto_grid *ag; /* Nobody around */ if (!auto_kills_cnt) return (FALSE); + /* Set the attacking flag so that danger is boosted for monsters */ + /* we want to attack first. */ + borg_attacking = TRUE; /* Reset list */ auto_temp_n = 0; *************** *** 3043,3051 **** } /* No destinations */ ! if (!auto_temp_n) return (FALSE); - /* Simulate */ auto_simulate = TRUE; --- 3489,3500 ---- } /* No destinations */ ! if (!auto_temp_n) ! { ! borg_attacking = FALSE; ! return (FALSE); ! } /* Simulate */ auto_simulate = TRUE; *************** *** 3064,3070 **** } /* Nothing good */ ! if (b_n <= 0) return (FALSE); /* Note */ --- 3513,3523 ---- } /* Nothing good */ ! if (b_n <= 0) ! { ! borg_attacking = FALSE; ! return (FALSE); ! } /* Note */ *************** *** 3076,3090 **** --- 3529,4457 ---- /* Instantiate */ (void)borg_attack_aux(b_g); + borg_attacking = FALSE; + /* Success */ return (TRUE); } + /* + * try to make this look like borg_attack stuff + * + * There are several types of seup moves: + * + * Temporary speed + * Protect From Evil + * Bless\Prayer + * Berserk\Heroism + * Temp Resist (either all or just cold/fire?) + * Shield + * teleport away + * + * + * * see inviso? + * * Glyph of Warding + * + * * some day! + * + */ + enum + { + BD_SPEED, + BD_PROT_FROM_EVIL, + BD_BLESS, + BD_BERSERK, + BD_HERO, + BD_RESIST1, + BD_RESIST2, + BD_RESIST3, + BD_RESIST4, + BD_RESIST5, + BD_RESIST6, + BD_SHIELD, + BD_GOI, + BD_TELL_AWAY, + BD_CREATE_DOOR, + BD_MAX + }; + /* + * Bless/Prayer to prepare for battle + */ + static int borg_defend_aux_bless( int p1 ) + { + int fail_allowed = 10; + /* already blessed */ + if (borg_bless) + return 0; + if ( !borg_prayer_okay_fail(0, 2, fail_allowed) && + !borg_prayer_okay_fail(3, 0, fail_allowed ) && + !borg_prayer_okay_fail(1, 3, fail_allowed )) + return 0; + + /* if we are in some danger but not much, go for a quick bless */ + if (p1 > avoidance/7 && p1 < avoidance/3) + { + /* Simulation */ + /* bless is a low priority */ + if (auto_simulate) return (1); + + /* do it! */ + if ( borg_prayer_fail( 3, 0, fail_allowed ) || + borg_prayer_fail( 1, 3, fail_allowed ) || + borg_prayer_fail( 0, 2, fail_allowed )) + return 1; + } + + return 0; + } + /* + * Speed to prepare for battle + */ + static int borg_defend_aux_speed( int p1 ) + { + int p2 = 0; + /* int i = 0; */ + bool good_speed = FALSE; + bool speed_spell = FALSE; + bool speed_staff = FALSE; + bool speed_rod = FALSE; + int fail_allowed = 20; + + /* already fast */ + if (borg_speed) + return 0; + + /* if very scary, do not allow for much chance of fail */ + if ( p1 > avoidance) + fail_allowed -= 19; + else + /* a little scary */ + if ( p1 > (avoidance*2)/3) + fail_allowed -= 10; + else + /* not very scary, allow lots of fail */ + if ( p1 < avoidance/3) + fail_allowed += 20; + + /* only cast defence spells if fail rate is not too high */ + if ( borg_spell_okay_fail( 3, 3, fail_allowed ) || + borg_spell_okay_fail( 7, 3, fail_allowed )) + speed_spell = TRUE; + + /* staff must have charges */ + if ( -1 != borg_slot(TV_STAFF, SV_STAFF_SPEED) && + auto_items[borg_slot(TV_STAFF, SV_STAFF_SPEED)].pval) + speed_staff = TRUE; + + /* rod can't be charging */ + if ( -1 != borg_slot(TV_ROD, SV_ROD_SPEED) && + auto_items[borg_slot(TV_ROD, SV_ROD_SPEED)].pval) + speed_rod = TRUE; + + if (0 > borg_slot(TV_POTION, SV_POTION_SPEED) && + !speed_staff && + !speed_rod && + !speed_spell) + return 0; + + /* if we have an infinite/large suppy of speed we can */ + /* be generious with our use */ + if (speed_rod || speed_spell || speed_staff) + good_speed = TRUE; + + /* pretend we are protected and look again */ + borg_speed = TRUE; + p2 = borg_danger(c_y, c_x, 1); + borg_speed = FALSE; + + /* if we just did GOI do a speed right after. */ + if (good_speed && borg_goi) + { + /* HACK pretend that it was scary and will be very safe */ + /* This is done because GOI messes up our calculations */ + p1 = 10000; + p2 = 1; + } + + /* if this is an improvement and we may not avoid monster now and */ + /* we may have before */ + if ( ((p1 > p2) && + p2 <= (borg_fighting_unique?((avoidance*2)/3): (avoidance/2)) && + (p1 > (avoidance/8)) && good_speed) || + ((p1 > p2) && + p2 <= (borg_fighting_unique?((avoidance*2)/3): (avoidance/3)) && + (p1 > (avoidance/2)))) + { + /* Simulation */ + if (auto_simulate) return (p1-p2 + borg_goi * 50); + + /* do it! */ + if (borg_spell_fail( 7, 3, fail_allowed)) + return (p1-p2); + + if (borg_spell_fail( 3, 3, fail_allowed)) + return (p1-p2); + + if ( borg_zap_rod( SV_ROD_SPEED ) || + borg_use_staff( SV_STAFF_SPEED) || + borg_quaff_potion(SV_POTION_SPEED) ) + /* Value */ + return (p1-p2 + borg_goi * 50); + } + + /* default to can't do it. */ + return 0; + } + + /* + * Globe of Invulnurability + */ + static int borg_defend_aux_goi(int p1) + { + int p2 = 0; + /* int i = 0; */ + int fail_allowed = 20; + + if (borg_goi) + return 0; + + /* if very scary, do not allow for much chance of fail */ + if ( p1 > avoidance) + fail_allowed -= 19; + else + /* a little scary */ + if ( p1 > (avoidance*2)/3) + fail_allowed -= 10; + else + /* a bit scary */ + if ( p1 > (avoidance/2)) + fail_allowed -= 5; + else + /* not very scary, allow lots of fail */ + if ( p1 < avoidance/4) + fail_allowed += 10; + + if (!borg_spell_okay_fail(7, 4, fail_allowed)) + return 0; + + /* pretend we are protected and look again */ + borg_goi = TRUE; + p2 = borg_danger(c_y, c_x, 1); + borg_goi = FALSE; + + /* if this is an improvement and we may not avoid monster now and */ + /* we may have before */ + if (p1 > p2 && + p2 <= (borg_fighting_unique?((avoidance*2)/3): (avoidance/2)) && + p1 > (avoidance/8)) + { + /* Simulation */ + if (auto_simulate) return (p1-p2); + + /* do it! */ + borg_spell(7, 4); + + /* Value */ + return (p1-p2); + } + + /* default to can't do it. */ + return 0; + } + + /* cold/fire */ + static int borg_defend_aux_resist1( p1 ) + { + int p2 = 0; + /* int i = 0; */ + int fail_allowed = 20; + bool save_fire, + save_cold; + + if (borg_temp_fire && + borg_temp_cold) + return 0; + + /* if very scary, do not allow for much chance of fail */ + if ( p1 > avoidance) + fail_allowed -= 19; + else + /* a little scary */ + if ( p1 > (avoidance*2)/3) + fail_allowed -= 10; + else + /* not very scary, allow lots of fail */ + if ( p1 < avoidance/3) + fail_allowed += 20; + + if (!borg_prayer_okay_fail(1, 7, fail_allowed)) + return 0; + + /* pretend we are protected and look again */ + save_fire = borg_temp_fire; + save_cold = borg_temp_cold; + borg_temp_fire = TRUE; + borg_temp_cold = TRUE; + p2 = borg_danger(c_y, c_x, 1); + borg_temp_fire = save_fire; + borg_temp_cold = save_cold; + + /* if this is an improvement and we may not avoid monster now and */ + /* we may have before */ + if (p1 > p2 && + p2 <= (borg_fighting_unique?((avoidance*2)/3): (avoidance/2)) && + p1 > (avoidance/8)) + { + /* Simulation */ + if (auto_simulate) return (p1-p2); + + /* do it! */ + borg_prayer(1, 7); + + /* Value */ + return (p1-p2); + } + + /* default to can't do it. */ + return 0; + } + + /* all resists */ + static int borg_defend_aux_resist2( int p1) + { + int p2 = 0; + /* int i = 0; */ + int fail_allowed = 20; + bool save_fire, + save_acid, + save_poison, + save_elec, + save_cold; + + if (borg_temp_fire && + borg_temp_acid && + borg_temp_poison && + borg_temp_elec && + borg_temp_cold) + return 0; + + /* if very scary, do not allow for much chance of fail */ + if ( p1 > avoidance) + fail_allowed -= 19; + else + /* a little scary */ + if ( p1 > (avoidance*2)/3) + fail_allowed -= 10; + else + /* not very scary, allow lots of fail */ + if ( p1 < avoidance/3) + fail_allowed += 20; + + if (!borg_spell_okay_fail(4, 4, fail_allowed)) + return 0; + + /* pretend we are protected and look again */ + save_fire = borg_temp_fire; + save_acid = borg_temp_acid; + save_poison = borg_temp_poison; + save_elec = borg_temp_elec; + save_cold = borg_temp_cold; + borg_temp_fire = TRUE; + borg_temp_cold = TRUE; + borg_temp_acid = TRUE; + borg_temp_poison = TRUE; + borg_temp_elec = TRUE; + p2 = borg_danger(c_y, c_x, 1); + borg_temp_fire = save_fire; + borg_temp_cold = save_cold; + borg_temp_acid = save_acid; + borg_temp_poison = save_poison; + borg_temp_elec = save_elec; + + /* if this is an improvement and we may not avoid monster now and */ + /* we may have before */ + if (p1 > p2 && + p2 <= (borg_fighting_unique?((avoidance*2)/3): (avoidance/2)) && + p1 > (avoidance/8)) + { + /* Simulation */ + if (auto_simulate) return ((p1-p2) -1); + + /* do it! */ + borg_spell(4, 4); + + /* Value */ + return ((p1-p2)-1); + } + + /* default to can't do it. */ + return 0; + } + + /* fire */ + static int borg_defend_aux_resist3( p1 ) + { + int p2 = 0; + /* int i = 0; */ + int fail_allowed = 20; + bool save_fire; + + if ( borg_temp_fire ) + return 0; + + /* if very scary, do not allow for much chance of fail */ + if ( p1 > avoidance) + fail_allowed -= 19; + else + /* a little scary */ + if ( p1 > (avoidance*2)/3) + fail_allowed -= 10; + else + /* not very scary, allow lots of fail */ + if ( p1 < avoidance/3) + fail_allowed += 20; + + if (!borg_spell_okay_fail(4, 0, fail_allowed)) + return 0; + + save_fire = borg_temp_fire; + /* pretend we are protected and look again */ + borg_temp_fire = TRUE; + p2 = borg_danger(c_y, c_x, 1); + borg_temp_fire = save_fire; + + /* if this is an improvement and we may not avoid monster now and */ + /* we may have before */ + if (p1 > p2 && + p2 <= (borg_fighting_unique?((avoidance*2)/3): (avoidance/2)) && + p1 > (avoidance/8)) + { + /* Simulation */ + if (auto_simulate) return (p1-p2); + + /* do it! */ + borg_spell(4, 0); + + /* Value */ + return (p1-p2); + } + + /* default to can't do it. */ + return 0; + } + + /* cold */ + static int borg_defend_aux_resist4( p1 ) + { + int p2 = 0; + /* int i = 0; */ + int fail_allowed = 20; + bool save_cold; + + if ( borg_temp_cold ) + return 0; + + /* if very scary, do not allow for much chance of fail */ + if ( p1 > avoidance) + fail_allowed -= 19; + else + /* a little scary */ + if ( p1 > (avoidance*2)/3) + fail_allowed -= 10; + else + /* not very scary, allow lots of fail */ + if ( p1 < avoidance/3) + fail_allowed += 20; + + if (!borg_spell_okay_fail(4, 1, fail_allowed)) + return 0; + + save_cold = borg_temp_cold; + /* pretend we are protected and look again */ + borg_temp_cold = TRUE; + p2 = borg_danger(c_y, c_x, 1); + borg_temp_cold = save_cold; + + /* if this is an improvement and we may not avoid monster now and */ + /* we may have before */ + if (p1 > p2 && + p2 <= (borg_fighting_unique?((avoidance*2)/3): (avoidance/2)) && + p1 > (avoidance/8)) + { + /* Simulation */ + if (auto_simulate) return (p1-p2); + + /* do it! */ + borg_spell(4, 1); + + /* Value */ + return (p1-p2); + } + + /* default to can't do it. */ + return 0; + } + + /* acid */ + static int borg_defend_aux_resist5( p1 ) + { + int p2 = 0; + /* int i = 0; */ + int fail_allowed = 20; + bool save_acid; + + if ( borg_temp_acid ) + return 0; + + /* if very scary, do not allow for much chance of fail */ + if ( p1 > avoidance) + fail_allowed -= 19; + else + /* a little scary */ + if ( p1 > (avoidance*2)/3) + fail_allowed -= 10; + else + /* not very scary, allow lots of fail */ + if ( p1 < avoidance/3) + fail_allowed += 20; + + if (!borg_spell_okay_fail(4, 2, fail_allowed)) + return 0; + + save_acid = borg_temp_acid; + /* pretend we are protected and look again */ + borg_temp_acid = TRUE; + p2 = borg_danger(c_y, c_x, 1); + borg_temp_acid = save_acid; + + /* if this is an improvement and we may not avoid monster now and */ + /* we may have before */ + if (p1 > p2 && + p2 <= (borg_fighting_unique?((avoidance*2)/3): (avoidance/2)) && + p1 > (avoidance/8)) + { + /* Simulation */ + if (auto_simulate) return (p1-p2); + + /* do it! */ + borg_spell(4, 2); + + /* Value */ + return (p1-p2); + } + + /* default to can't do it. */ + return 0; + } + + /* poison */ + static int borg_defend_aux_resist6( p1 ) + { + int p2 = 0; + /* int i = 0; */ + int fail_allowed = 20; + bool save_poison; + + if ( borg_temp_poison ) + return 0; + + /* if very scary, do not allow for much chance of fail */ + if ( p1 > avoidance) + fail_allowed -= 19; + else + /* a little scary */ + if ( p1 > (avoidance*2)/3) + fail_allowed -= 10; + else + /* not very scary, allow lots of fail */ + if ( p1 < avoidance/3) + fail_allowed += 20; + + if (!borg_spell_okay_fail(4, 3, fail_allowed)) + return 0; + + save_poison = borg_temp_poison; + /* pretend we are protected and look again */ + borg_temp_poison = TRUE; + p2 = borg_danger(c_y, c_x, 1); + borg_temp_poison = save_poison; + + /* if this is an improvement and we may not avoid monster now and */ + /* we may have before */ + if (p1 > p2 && + p2 <= (borg_fighting_unique?((avoidance*2)/3): (avoidance/2)) && + p1 > (avoidance/8)) + { + /* Simulation */ + if (auto_simulate) return (p1-p2); + + /* do it! */ + borg_spell(4, 3); + + /* Value */ + return (p1-p2); + } + + /* default to can't do it. */ + return 0; + } + + static int borg_defend_aux_prot_evil( int p1) + { + int p2 = 0; + int fail_allowed = 20; + + /* if already protected */ + if (borg_prot_from_evil) + return 0; + + /* if very scary, do not allow for much chance of fail */ + if ( p1 > avoidance) + fail_allowed -= 19; + else + /* a little scary */ + if ( p1 > (avoidance*2)/3) + fail_allowed -= 5; + else + /* not very scary, allow lots of fail */ + if ( p1 < avoidance/3) + fail_allowed += 20; + + if ((!borg_prayer_okay_fail(2, 4, fail_allowed)) && + (0 > borg_slot(TV_SCROLL, SV_SCROLL_PROTECTION_FROM_EVIL)) ) + return 0; + + /* pretend we are protected and look again */ + borg_prot_from_evil = TRUE; + p2 = borg_danger(c_y, c_x, 1); + borg_prot_from_evil = FALSE; + + /* if this is an improvement and we may not avoid monster now and */ + /* we may have before */ + if (p1 > p2 && + p2 <= (borg_fighting_unique?((avoidance*2)/3): (avoidance/2)) && + p1 > (avoidance/8)) + { + /* Simulation */ + if (auto_simulate) return (p1-p2); + + /* do it! */ + if (borg_prayer_fail(2, 4, fail_allowed)) + return (p1-p2); + + borg_read_scroll(SV_SCROLL_PROTECTION_FROM_EVIL); + + /* Value */ + return (p1-p2); + } + + /* default to can't do it. */ + return 0; + } + + static int borg_defend_aux_shield( int p1) + { + int p2 = 0; + int fail_allowed = 20; + + /* if already protected */ + if (borg_shield) + return 0; + + /* if very scary, do not allow for much chance of fail */ + if ( p1 > avoidance) + fail_allowed -= 19; + else + /* a little scary */ + if ( p1 > (avoidance*2)/3) + fail_allowed -= 5; + else + /* not very scary, allow lots of fail */ + if ( p1 < avoidance/3) + fail_allowed += 20; + + if (!borg_spell_okay_fail(7, 1, fail_allowed)) + return 0; + + /* pretend we are protected and look again */ + borg_shield = TRUE; + p2 = borg_danger(c_y, c_x, 1); + borg_shield = FALSE; + + /* if this is an improvement and we may not avoid monster now and */ + /* we may have before */ + if (p1 > p2 && + p2 <= (borg_fighting_unique?((avoidance*2)/3): (avoidance/2)) && + p1 > (avoidance/8)) + { + /* Simulation */ + if (auto_simulate) return (p1-p2); + + /* do it! */ + borg_spell_fail(7, 1, fail_allowed); + return (p1-p2); + } + + /* default to can't do it. */ + return 0; + } + + /* + * Try to get rid of all of the non-uniques around so you can go at it + * 'mano-e-mano' with the unique. + */ + static int borg_defend_aux_tell_away( int p1) + { + int b_n = 0; + + int fail_allowed = 1; + + /* This is not working. It keeps teleporting away the unique! */ + /* I will debug it later... */ + return -1; + + /* Only tell away if scared and there is a local unique */ + if ( p1 < avoidance/2) + return 0; + + if (!borg_spell_okay_fail(3, 2, fail_allowed)) + return 0; + + if (!borg_fighting_unique) return 0; + + /* Choose optimal location */ + b_n = borg_launch_bolt(-1, 0, GF_AWAY_ALL, MAX_RANGE); + + /* if this doesn't help enough, don't bother. */ + if ((p1 - b_n) > (avoidance*2)/3) return 0; + + /* Simulation */ + if (auto_simulate) return (b_n); + + /* Cast the spell */ + if (borg_spell(3, 2)) + { + /* Use target */ + borg_keypress('5'); + + /* Value */ + return (b_n); + } + + return 0; + } + + /* + * Simulate/Apply the optimal result of using the given "type" of defence + * p1 is the current danger level (passed in for effiency) + */ + static int borg_defend_aux(int what, int p1) + { + int dam = 0, rad = 0; + + /* Analyze */ + switch (what) + { + case BD_SPEED: + { + return (borg_defend_aux_speed(p1)); + } + + case BD_PROT_FROM_EVIL: + { + return (borg_defend_aux_prot_evil(p1)); + } + case BD_RESIST1: + { + return (borg_defend_aux_resist1(p1)); + } + case BD_RESIST2: + { + return (borg_defend_aux_resist2(p1)); + } + case BD_RESIST3: + { + return (borg_defend_aux_resist3(p1)); + } + case BD_RESIST4: + { + return (borg_defend_aux_resist4(p1)); + } + case BD_RESIST5: + { + return (borg_defend_aux_resist5(p1)); + } + case BD_RESIST6: + { + return (borg_defend_aux_resist6(p1)); + } + case BD_BLESS: + { + return (borg_defend_aux_bless(p1)); + } + case BD_HERO: + { + /*"You feel like a hero!"*/ + /*"The heroism wears off." */ + /* return (borg_defend_aux_hero(p1)); */ + break; + } + case BD_BERSERK: + { + /*"You feel like a killing machine!"*/ + /*"You feel less Berserk."*/ + /* return (borg_defend_aux_berserk(p1));*/ + break; + } + case BD_SHIELD: + { + return (borg_defend_aux_shield(p1)); + } + case BD_GOI: + { + return (borg_defend_aux_goi(p1)); + } + case BD_TELL_AWAY: + { + return (borg_defend_aux_tell_away(p1)); + } + case BD_CREATE_DOOR: + { + /* to avoid summoners */ + /* again, I have no formula... */ + /* return (borg_defend_aux_create_door(p1)); */ + break; + } + } + return 0; + } + + /* + * prepare to attack... this is setup for a battle. + */ + bool borg_defend(void) + { + int p1, n, b_n = 0; + int g, b_g = -1; + + /* Simulate */ + auto_simulate = TRUE; + + /* check danger level. (this is passed in for efficency) */ + p1 = borg_danger(c_y, c_x, 1); + + + /* if you have a globe up and it is about to drop, */ + /* refresh it (if you can) */ + if (borg_goi && borg_goi < 2) + { + int p; + + /* check 'true' danger. This will make sure we do not */ + /* refresh our GOI if no-one is around */ + borg_attacking = TRUE; + p = borg_danger(c_y, c_x, 1); + borg_attacking = FALSE; + if (p > auto_fear_region[c_y/11][c_x/11]) + { + if (borg_spell(7, 4)) + { + borg_note("# refreshing GOI "); + + borg_goi += 13; + return (TRUE); + } + } + } + + /* if no danger, no defence needed */ + /* HACK EXCEPT... if goi we will also do speed */ + if ((p1 <= auto_fear_region[c_y/11][c_x/11] && !borg_goi) || + (borg_goi && borg_speed)) + return FALSE; + + /* Analyze the possible setup moves */ + for (g = 0; g < BD_MAX; g++) + { + /* Simulate */ + n = borg_defend_aux(g, p1); + + /* Track "best" attack */ + if (n <= b_n) continue; + + /* Track best */ + b_g = g; + b_n = n; + } + + /* Nothing good */ + if (b_n <= 0) + { + return (FALSE); + } + + /* Note */ + borg_note(format("# Performing defence type %d with value %d", b_g, b_n)); + + /* Instantiate */ + auto_simulate = FALSE; + + /* Instantiate */ + (void)borg_defend_aux(b_g, p1); + + /* Success */ + return (TRUE); + + } + + /* + * check to make sure there are no monsters around + * that should prevent resting + */ + static bool borg_check_rest(void) + { + int i; + + /* Examine all the monsters */ + for (i = 1; i < auto_kills_nxt; i++) + { + auto_kill *kill = &auto_kills[i]; + monster_race *r_ptr = &r_info[kill->r_idx]; + + int x9 = kill->x; + int y9 = kill->y; + int ax, ay, d; + + /* Skip dead monsters */ + if (!kill->r_idx) continue; + + /* Distance components */ + ax = (x9 > c_x) ? (x9 - c_x) : (c_x - x9); + ay = (y9 > c_y) ? (y9 - c_y) : (c_y - y9); + + /* Distance */ + d = MAX(ax, ay); + + /* Minimal distance */ + if (d > 20) continue; + + /* if breeder, not safe */ + if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE; + + /* if absorbs mana, not safe */ + /* should check LOS... oh well. AJG !FIX */ + if ((r_ptr->flags5 & RF5_DRAIN_MANA) && (auto_msp > 1)) return FALSE; + } + + return TRUE; + } + + /* * Attempt to recover from damage and such after a battle * * Note that resting while in danger is counter-productive, unless *************** *** 3105,3113 **** */ bool borg_recover(void) { ! int p, q; - /*** Handle annoying situations ***/ /* Refuel current torch */ --- 4472,4479 ---- */ bool borg_recover(void) { ! int p, q, i; /*** Handle annoying situations ***/ /* Refuel current torch */ *************** *** 3118,3123 **** --- 4484,4492 ---- if (auto_items[INVEN_LITE].pval < 2500) { if (borg_refuel_torch()) return (TRUE); + + /* Take note */ + borg_note(format("# Need to refuel but cant!", p)); } } *************** *** 3129,3134 **** --- 4498,4506 ---- if (auto_items[INVEN_LITE].pval < 5000) { if (borg_refuel_lantern()) return (TRUE); + + /* Take note */ + borg_note(format("# Need to refuel but cant!", p)); } } *************** *** 3164,3173 **** --- 4536,4563 ---- borg_prayer(6, 1) || borg_prayer(6, 2)) { + /* Take note */ + borg_note(format("# Cure Stun", p)); + return (TRUE); } } + /* Hack -- cure stun */ + if (do_heavy_stun) + { + if (borg_prayer(2, 7) || + borg_prayer(3, 2) || + borg_prayer(6, 1) || + borg_prayer(6, 2)) + { + /* Take note */ + borg_note(format("# Cure Heavy Stun", p)); + + return (TRUE); + } + } + /* Hack -- cure cuts */ if (do_cut && (q < 75)) { *************** *** 3178,3183 **** --- 4568,4576 ---- borg_prayer(6, 1) || borg_prayer(6, 2)) { + /* Take note */ + borg_note(format("# Cure Cuts", p)); + return (TRUE); } } *************** *** 3188,3193 **** --- 4581,4589 ---- if (borg_spell(1, 4) || borg_prayer(2, 0)) { + /* Take note */ + borg_note(format("# Cure poison", p)); + return (TRUE); } } *************** *** 3199,3204 **** --- 4595,4603 ---- borg_spell(7, 0) || borg_prayer(0, 3)) { + /* Take note */ + borg_note(format("# Cure fear", p)); + return (TRUE); } } *************** *** 3214,3235 **** } /* Hack -- heal damage */ ! if ((auto_chp < auto_mhp / 2) && (q < 75)) { ! if (borg_spell(0, 5) || ! borg_prayer(3, 2) || borg_prayer(2, 7) || ! borg_prayer(2, 2) || ! borg_prayer(1, 2) || ! borg_prayer(6, 0) || ! borg_prayer(6, 1) || ! borg_prayer(6, 2)) { return (TRUE); } } /*** Use "expensive" cures ***/ /* Hack -- cure stun */ --- 4613,4648 ---- } /* Hack -- heal damage */ ! if ((auto_chp < auto_mhp / 2) && (q < 75) && p == 0 && ! (auto_csp > auto_msp /4)) { ! if (borg_prayer(3, 2) || ! borg_prayer(6, 2) || borg_prayer(2, 7) || ! borg_prayer(6, 1) ) { + /* Take note */ + borg_note(format("# heal damage (recovering)")); + return (TRUE); } } + /* cure experience loss with prayer */ + if (do_fix_exp && borg_prayer(6, 4)) + { + return (TRUE); + } + /* cure stat drain with prayer */ + for (i = 0; i < 6; i++) + { + if ( do_fix_stat[i] && borg_prayer(6, 3) ) + { + return (TRUE); + } + } + /*** Use "expensive" cures ***/ /* Hack -- cure stun */ *************** *** 3244,3249 **** --- 4657,4674 ---- } } + /* Hack -- cure heavy stun */ + if (do_heavy_stun && (q < 95)) + { + if (borg_quaff_potion(SV_POTION_CURE_CRITICAL) || + borg_use_staff(SV_STAFF_CURING) || + borg_zap_rod(SV_ROD_CURING) || + borg_zap_rod(SV_ROD_HEALING)) + { + return (TRUE); + } + } + /* Hack -- cure cuts */ if (do_cut && (q < 25)) { *************** *** 3337,3349 **** /* Hack -- rest until healed */ if ((do_blind || do_confused || do_image || ! do_poisoned || do_afraid || do_cut || do_stun || (auto_chp < auto_mhp) || (auto_csp < auto_msp)) && ! (!auto_depth || !auto_takes_cnt || !goal_recalling) && ! (rand_int(100) < 90)) { /* XXX XXX XXX */ ! /* Take note */ borg_note(format("# Resting (danger %d)...", p)); --- 4762,4776 ---- /* Hack -- rest until healed */ if ((do_blind || do_confused || do_image || ! do_poisoned || do_afraid || do_cut || do_stun || do_heavy_stun || (auto_chp < auto_mhp) || (auto_csp < auto_msp)) && ! (!auto_takes_cnt || !goal_recalling) && !borg_goi && ! (rand_int(100) < 90) && borg_check_rest( ) && ! p <= auto_fear_region[c_y/11][c_x/11]) { /* XXX XXX XXX */ ! if (!do_weak && !do_hungry) ! { /* Take note */ borg_note(format("# Resting (danger %d)...", p)); *************** *** 3355,3371 **** /* Done */ return (TRUE); } /* Nope */ return (FALSE); } - - - - - /* * Take one "step" towards the given location, return TRUE if possible */ --- 4782,4795 ---- /* Done */ return (TRUE); } + } + /* Nope */ return (FALSE); } /* * Take one "step" towards the given location, return TRUE if possible */ *************** *** 3401,3415 **** { auto_kill *kill = &auto_kills[ag->kill]; /* Message */ ! borg_note(format("# Attacking a '%s' at (%d,%d)", r_name + r_info[kill->r_idx].name, kill->x, kill->y)); ! /* Hack -- normally do a real attack */ ! if (rand_int(100) < 90) borg_keypress('+'); ! ! /* Attack */ borg_keypress('0' + dir); return (TRUE); } --- 4825,4840 ---- { auto_kill *kill = &auto_kills[ag->kill]; + /* can't attack someone if afraid! */ + if (do_afraid) + return (FALSE); + /* Message */ ! borg_note(format("# Walking into a '%s' at (%d,%d)", r_name + r_info[kill->r_idx].name, kill->x, kill->y)); ! /* Walk into it */ borg_keypress('0' + dir); return (TRUE); } *************** *** 3434,3443 **** /* Traps -- disarm */ if ((ag->feat >= FEAT_TRAP_HEAD) && (ag->feat <= FEAT_TRAP_TAIL)) { - /* Message */ - borg_note("# Disarming a trap"); - /* Disarm */ borg_keypress('D'); borg_keypress('0' + dir); return (TRUE); --- 4859,4866 ---- /* Traps -- disarm */ if ((ag->feat >= FEAT_TRAP_HEAD) && (ag->feat <= FEAT_TRAP_TAIL)) { /* Disarm */ + borg_note("# Disarming a trap"); borg_keypress('D'); borg_keypress('0' + dir); return (TRUE); *************** *** 3450,3459 **** /* Paranoia XXX XXX XXX */ if (!rand_int(100)) return (FALSE); - /* Message */ - borg_note("# Opening a door"); - /* Open */ borg_keypress('0'); borg_keypress('9'); borg_keypress('o'); --- 4873,4880 ---- /* Paranoia XXX XXX XXX */ if (!rand_int(100)) return (FALSE); /* Open */ + borg_note("# Opening a door"); borg_keypress('0'); borg_keypress('9'); borg_keypress('o'); *************** *** 3490,3499 **** return (TRUE); } - /* Message */ - borg_note("# Bashing a door"); - /* Bash */ borg_keypress('B'); borg_keypress('0' + dir); return (TRUE); --- 4911,4918 ---- return (TRUE); } /* Bash */ + borg_note("# Bashing a door"); borg_keypress('B'); borg_keypress('0' + dir); return (TRUE); *************** *** 3514,3523 **** return (TRUE); } - /* Message */ - borg_note("# Digging through wall/etc"); - /* Tunnel */ borg_keypress('0'); borg_keypress('9'); borg_keypress('9'); --- 4933,4940 ---- return (TRUE); } /* Tunnel */ + borg_note("# Digging through wall/etc"); borg_keypress('0'); borg_keypress('9'); borg_keypress('9'); *************** *** 3790,3795 **** --- 5207,5221 ---- /* None to flow to */ if (!track_more_num) return (FALSE); + /* if not fleeing do not go down unless safe */ + if (!goal_fleeing && (cptr)NULL != borg_prepared(auto_depth + 1)) + return (FALSE); + + /* don't head for the stairs if you are recalling, */ + /* even if you are fleeing. */ + if (goal_recalling) + return (FALSE); + /* Clear the flow codes */ borg_flow_clear(); *************** *** 3982,3990 **** } /* Spread the flow */ ! borg_flow_spread(250, TRUE, FALSE); - /* Attempt to Commit the flow */ if (!borg_flow_commit(NULL, GOAL_KILL)) return (FALSE); --- 5408,5418 ---- } /* Spread the flow */ ! /* if we are not flowing toward monsters that we can see, make sure they */ ! /* are at least easily reachable. The second flag is weather or not */ ! /* to avoid unkown squares. This was for performance when we have ESP. */ ! borg_flow_spread(250, TRUE, !viewable); /* Attempt to Commit the flow */ if (!borg_flow_commit(NULL, GOAL_KILL)) return (FALSE); *************** *** 4021,4026 **** --- 5449,5457 ---- { auto_take *take = &auto_takes[i]; + int a; + bool item_bad; + /* Skip dead objects */ if (!take->k_idx) continue; *************** *** 4028,4033 **** --- 5459,5475 ---- x = take->x; y = take->y; + /* look to see if this is on the bad items list */ + item_bad = FALSE; + for (a = 0; a < 10; a++) + { + if (x == bad_obj_x[a] && y == bad_obj_y[a]) + item_bad = TRUE; + } + + /* it is a bad item, do not track it */ + if (item_bad) continue; + /* Get the grid */ ag = &auto_grids[y][x]; *************** *** 4055,4061 **** } /* Spread the flow */ ! borg_flow_spread(250, TRUE, FALSE); /* Attempt to Commit the flow */ --- 5497,5506 ---- } /* Spread the flow */ ! /* if we are not flowing toward items that we can see, make sure they */ ! /* are at least easily reachable. The second flag is weather or not */ ! /* to avoid unkown squares. This was for performance. */ ! borg_flow_spread(250, TRUE, !viewable); /* Attempt to Commit the flow */ *************** *** 4771,4780 **** /* * Prepare to "flow" towards "interesting" grids * ! * The "exploration" routines are broken into "nearby" and "distant" * exploration, and each set is chosen via the flag below. */ ! bool borg_flow_dark(bool nearby) { /* Paranoia */ if (borg_flow_dark_interesting(c_y, c_x)) --- 6216,6225 ---- /* * Prepare to "flow" towards "interesting" grids * ! * The "exploration" routines are broken into "near" and "far" * exploration, and each set is chosen via the flag below. */ ! bool borg_flow_dark(bool neer) { /* Paranoia */ if (borg_flow_dark_interesting(c_y, c_x)) *************** *** 4784,4790 **** } /* Near */ ! if (nearby) { /* Method 1 */ if (borg_flow_dark_1()) return (TRUE); --- 6229,6235 ---- } /* Near */ ! if (neer) { /* Method 1 */ if (borg_flow_dark_1()) return (TRUE); *************** *** 5049,5058 **** } #else #ifdef MACINTOSH static int HACK = 0; ! #endif /* MACINTOSH */ ! #endif /* ALLOW_BORG */ --- 6494,6504 ---- } + #else #ifdef MACINTOSH static int HACK = 0; ! #endif ! #endif diff -w -c -r Borg/borg6.h adamborg/borg6.h *** Borg/borg6.h Sun Apr 13 23:22:12 1997 --- adamborg/borg6.h Sun Apr 13 23:26:28 1997 *************** *** 50,55 **** --- 50,57 ---- extern bool borg_attack(void); extern bool borg_recover(void); + extern bool borg_defend(void); + /* * Twitchy goals */ *************** *** 86,92 **** /* * Flow towards "interesting" grids */ ! extern bool borg_flow_dark(bool nearby); /* * Search for secret doors --- 88,94 ---- /* * Flow towards "interesting" grids */ ! extern bool borg_flow_dark(bool neer); /* * Search for secret doors diff -w -c -r Borg/borg7.c adamborg/borg7.c *** Borg/borg7.c Sun Apr 13 23:22:30 1997 --- adamborg/borg7.c Sun Apr 13 23:26:54 1997 *************** *** 168,175 **** - - /* * Use things in a useful, but non-essential, manner */ --- 168,173 ---- *************** *** 177,203 **** { int i; - /* Quaff experience restoration potion */ if (do_fix_exp && ! borg_quaff_potion(SV_POTION_RESTORE_EXP)) { return (TRUE); } ! ! /* Quaff potions of "increase" stat if "needed" */ ! if (((my_stat_cur[A_STR] < 18+100) && borg_quaff_potion(SV_POTION_INC_STR)) || ! ((my_stat_cur[A_INT] < 18+100) && borg_quaff_potion(SV_POTION_INC_INT)) || ! ((my_stat_cur[A_WIS] < 18+100) && borg_quaff_potion(SV_POTION_INC_WIS)) || ! ((my_stat_cur[A_DEX] < 18+100) && borg_quaff_potion(SV_POTION_INC_DEX)) || ! ((my_stat_cur[A_CON] < 18+100) && borg_quaff_potion(SV_POTION_INC_CON)) || ! ((my_stat_cur[A_CHR] < 18+100) && borg_quaff_potion(SV_POTION_INC_CHR))) { return (TRUE); --- 175,205 ---- { int i; /* Quaff experience restoration potion */ if (do_fix_exp && ! (borg_prayer(6,4) || ! borg_quaff_potion(SV_POTION_RESTORE_EXP))) { return (TRUE); } ! if ((my_stat_cur[A_STR] < (18+100 + 10 * p_ptr->maximize * ! (rp_ptr->r_adj[A_STR] + cp_ptr->c_adj[A_STR])) && borg_quaff_potion(SV_POTION_INC_STR)) || ! (my_stat_cur[A_INT] < (18+100 + 10 * p_ptr->maximize * ! (rp_ptr->r_adj[A_INT] + cp_ptr->c_adj[A_INT])) && borg_quaff_potion(SV_POTION_INC_INT)) || ! (my_stat_cur[A_WIS] < (18+100 + 10 * p_ptr->maximize * ! (rp_ptr->r_adj[A_WIS] + cp_ptr->c_adj[A_WIS])) && borg_quaff_potion(SV_POTION_INC_WIS)) || ! (my_stat_cur[A_DEX] < (18+100 + 10 * p_ptr->maximize * ! (rp_ptr->r_adj[A_DEX] + cp_ptr->c_adj[A_DEX])) && borg_quaff_potion(SV_POTION_INC_DEX)) || ! (my_stat_cur[A_CON] < (18+100 + 10 * p_ptr->maximize * ! (rp_ptr->r_adj[A_CON] + cp_ptr->c_adj[A_CON])) && borg_quaff_potion(SV_POTION_INC_CON)) || ! (my_stat_cur[A_CHR] < (18+100 + 10 * p_ptr->maximize * ! (rp_ptr->r_adj[A_CHR] + cp_ptr->c_adj[A_CHR])) && borg_quaff_potion(SV_POTION_INC_CHR)) ) { return (TRUE); *************** *** 204,221 **** } /* Quaff potions of "restore" stat if needed */ ! if (((do_fix_stat[A_STR]) && ! borg_quaff_potion(SV_POTION_RES_STR)) || ! ((do_fix_stat[A_INT]) && ! borg_quaff_potion(SV_POTION_RES_INT)) || ! ((do_fix_stat[A_WIS]) && ! borg_quaff_potion(SV_POTION_RES_WIS)) || ! ((do_fix_stat[A_DEX]) && ! borg_quaff_potion(SV_POTION_RES_DEX)) || ! ((do_fix_stat[A_CON]) && ! borg_quaff_potion(SV_POTION_RES_CON)) || ((do_fix_stat[A_CHR]) && ! borg_quaff_potion(SV_POTION_RES_CHR))) { return (TRUE); } --- 206,229 ---- } /* Quaff potions of "restore" stat if needed */ ! if ( (do_fix_stat[A_STR] && ! (borg_quaff_potion(SV_POTION_RES_STR) || ! borg_quaff_potion(SV_POTION_INC_STR))) || ! (do_fix_stat[A_INT] && ! (borg_quaff_potion(SV_POTION_RES_INT) || ! borg_quaff_potion(SV_POTION_INC_INT))) || ! (do_fix_stat[A_WIS] && ! (borg_quaff_potion(SV_POTION_RES_WIS) || ! borg_quaff_potion(SV_POTION_INC_WIS))) || ! (do_fix_stat[A_DEX] && ! (borg_quaff_potion(SV_POTION_RES_DEX) || ! borg_quaff_potion(SV_POTION_INC_DEX))) || ! (do_fix_stat[A_CON] && ! (borg_quaff_potion(SV_POTION_RES_CON) || ! borg_quaff_potion(SV_POTION_INC_CON))) || ((do_fix_stat[A_CHR]) && ! (borg_quaff_potion(SV_POTION_RES_CHR) || ! borg_quaff_potion(SV_POTION_INC_CHR)))) { return (TRUE); } *************** *** 233,239 **** switch (item->tval) { case TV_POTION: ! /* Check the scroll */ switch (item->sval) { --- 241,247 ---- switch (item->tval) { case TV_POTION: ! { /* Check the scroll */ switch (item->sval) { *************** *** 250,258 **** } break; ! case TV_SCROLL: ! /* Hack -- check Blind/Confused */ if (do_blind || do_confused) break; --- 258,266 ---- } break; ! } case TV_SCROLL: ! { /* Hack -- check Blind/Confused */ if (do_blind || do_confused) break; *************** *** 267,283 **** case SV_SCROLL_ACQUIREMENT: case SV_SCROLL_STAR_ACQUIREMENT: case SV_SCROLL_PROTECTION_FROM_EVIL: ! /* Never read these in town */ if (!auto_depth) break; /* Try reading the scroll */ if (borg_read_scroll(item->sval)) return (TRUE); } break; } } /* Eat food */ --- 275,294 ---- case SV_SCROLL_ACQUIREMENT: case SV_SCROLL_STAR_ACQUIREMENT: case SV_SCROLL_PROTECTION_FROM_EVIL: ! { /* Never read these in town */ if (!auto_depth) break; /* Try reading the scroll */ if (borg_read_scroll(item->sval)) return (TRUE); + break; } + } break; } } + } /* Eat food */ *************** *** 624,630 **** --- 635,648 ---- a = item->to_a; /* Skip "boring" items */ + if (borg_prayer_legal(7, 4) && !auto_depth) + { + if (a >= 15) continue; + } + else + { if (a >= 8) continue; + } /* Find the least enchanted item */ if ((b_i >= 0) && (b_a < a)) continue; *************** *** 655,661 **** } - /* * Enchant weapons to hit */ --- 673,678 ---- *************** *** 687,693 **** --- 704,717 ---- a = item->to_h; /* Skip "boring" items */ + if (borg_prayer_legal(7, 3) && !auto_depth) + { + if (a >= 12) continue; + } + else + { if (a >= 8) continue; + } /* Find the least enchanted item */ if ((b_i >= 0) && (b_a < a)) continue; *************** *** 696,701 **** --- 720,764 ---- b_i = i; b_a = a; } + /* Nothing, check ammo */ + if (b_i < 0) + { + /* look through inventory for ammo */ + for (i = 0; i < INVEN_PACK; i++) + { + auto_item *item = &auto_items[i]; + + /* Only enchant if qty >= 10 */ + if (item->iqty < 10) continue; + + /* Skip non-identified items */ + if (!item->able) continue; + + /* Make sure it is the right type if missile */ + if (item->tval != my_ammo_tval) continue; + + /* Obtain the bonus */ + a = item->to_h; + + /* Skip items that are already enchanted */ + if (borg_prayer_legal(7, 3) && !auto_depth) + { + if (a >= 10) continue; + } + else + { + if (a >= 8) continue; + } + + /* Find the least enchanted item */ + if ((b_i >= 0) && (b_a < a)) continue; + + /* Save the info */ + b_i = i; b_a = a; + + } + } + /* Nothing */ if (b_i < 0) return (FALSE); *************** *** 704,714 **** --- 767,785 ---- borg_read_scroll(SV_SCROLL_ENCHANT_WEAPON_TO_HIT)) { /* Choose from equipment */ + if (b_i >= INVEN_WIELD) + { borg_keypress('/'); /* Choose that item */ borg_keypress(I2A(b_i - INVEN_WIELD)); + } + else + { + borg_keypress(I2A(b_i)); + } + /* Success */ return (TRUE); } *************** *** 749,755 **** --- 820,833 ---- a = item->to_d; /* Skip "boring" items */ + if (borg_prayer_legal(7, 3) && !auto_depth) + { + if (a >= 12) continue; + } + else + { if (a >= 8) continue; + } /* Find the least enchanted item */ if ((b_i >= 0) && (b_a < a)) continue; *************** *** 758,763 **** --- 836,880 ---- b_i = i; b_a = a; } + /* Nothing, check ammo */ + if (b_i < 0) + { + /* look through inventory for ammo */ + for (i = 0; i < INVEN_PACK; i++) + { + auto_item *item = &auto_items[i]; + + /* Only enchant if qty >= 10 */ + if (item->iqty < 10) continue; + + /* Skip non-identified items */ + if (!item->able) continue; + + /* Make sure it is the right type if missile */ + if (item->tval != my_ammo_tval) continue; + + /* Obtain the bonus */ + a = item->to_d; + + /* Skip items that are already enchanted */ + if (borg_prayer_legal(7, 3) && !auto_depth) + { + if (a >= 10) continue; + } + else + { + if (a >= 8) continue; + } + + /* Find the least enchanted item */ + if ((b_i >= 0) && (b_a < a)) continue; + + /* Save the info */ + b_i = i; b_a = a; + + } + } + /* Nothing */ if (b_i < 0) return (FALSE); *************** *** 766,775 **** --- 883,900 ---- borg_read_scroll(SV_SCROLL_ENCHANT_WEAPON_TO_DAM)) { /* Choose from equipment */ + if (b_i >= INVEN_WIELD) + { borg_keypress('/'); /* Choose that item */ borg_keypress(I2A(b_i - INVEN_WIELD)); + } + else + { + /* Choose that item */ + borg_keypress(I2A(b_i)); + } /* Success */ return (TRUE); *************** *** 807,813 **** */ bool borg_recharging(void) { ! int i, b_i = -1; /* Forbid blind/confused */ --- 932,939 ---- */ bool borg_recharging(void) { ! int i = -1; ! bool charge = FALSE; /* Forbid blind/confused */ *************** *** 815,821 **** /* XXX XXX XXX Dark */ - /* Look for an item to recharge */ for (i = 0; i < INVEN_PACK; i++) { --- 941,946 ---- *************** *** 827,845 **** /* Skip non-identified items */ if (!item->able) continue; ! /* Skip non wands/staffs */ ! if ((item->tval != TV_STAFF) && (item->tval != TV_WAND)) continue; ! /* Skip charged items */ ! if (item->pval) continue; ! /* Save the info */ ! b_i = i; } ! /* Nope */ ! if (b_i < 0) return (FALSE); /* Attempt to recharge */ if (borg_spell(6, 2) || borg_spell(3, 1) || --- 952,994 ---- /* Skip non-identified items */ if (!item->able) continue; ! /* assume we can't charge it. */ ! charge = FALSE; ! /* Wands with no charges can be charged */ ! if ((item->tval == TV_WAND) && (item->pval < 1)) ! charge = TRUE; ! /* recharge staves sometimes */ ! if (item->tval == TV_STAFF) ! { ! /* allow staves to be recharged at 2 charges if */ ! /* the borg has the big recharge spell */ ! if ((item->pval < 3) && borg_spell_okay(6, 2)) ! charge = TRUE; ! ! /* recharge any staff at 0 charges */ ! if (item->pval < 1) ! charge = TRUE; ! ! /* Staves of teleport get recharged at 2 charges in town */ ! if ((item->sval == SV_STAFF_TELEPORTATION) && ! (item->pval < 3) && ! !auto_depth) ! charge = TRUE; } ! /* recharge rods that are 'charging' if we have the big recharge */ ! /* spell */ ! if ((item->tval == TV_ROD) && (!item->pval) && ! borg_spell_okay(6, 2)) ! { ! charge = TRUE; ! } + /* get the next item if we are not to charge this one */ + if (!charge) continue; + /* Attempt to recharge */ if (borg_spell(6, 2) || borg_spell(3, 1) || *************** *** 847,863 **** borg_prayer(7, 1) || borg_read_scroll(SV_SCROLL_RECHARGING)) { - auto_item *item = &auto_items[b_i]; - /* Message */ borg_note(format("Recharging %s", item->desc)); /* Recharge the item */ ! borg_keypress(I2A(b_i)); /* Success */ return (TRUE); } /* Nope */ return (FALSE); --- 996,1014 ---- borg_prayer(7, 1) || borg_read_scroll(SV_SCROLL_RECHARGING)) { /* Message */ borg_note(format("Recharging %s", item->desc)); /* Recharge the item */ ! borg_keypress(I2A(i)); /* Success */ return (TRUE); } + else + /* if we fail once, no need to try again. */ + break; + } /* Nope */ return (FALSE); *************** *** 980,991 **** bool borg_crush_junk(void) { int i; - /* Hack -- no need */ if (!auto_do_crush_junk) return (FALSE); - /* Destroy actual "junk" items */ for (i = 0; i < INVEN_PACK; i++) { --- 1131,1143 ---- bool borg_crush_junk(void) { int i; + bool fix = FALSE; + s32b p; + s32b value; /* Hack -- no need */ if (!auto_do_crush_junk) return (FALSE); /* Destroy actual "junk" items */ for (i = 0; i < INVEN_PACK; i++) { *************** *** 994,1008 **** /* Skip empty items */ if (!item->iqty) continue; /* Skip non "worthless" items */ ! if ((item->tval > TV_CHEST) && (item->value > 0)) continue; ! /* Hack -- Skip artifacts */ ! if (item->name1) continue; ! /* Hack -- skip "artifacts" */ if (streq(item->note, "{special}")) continue; - if (streq(item->note, "{terrible}")) continue; /* Message */ borg_note(format("# Junking junk (junk)")); --- 1146,1218 ---- /* Skip empty items */ if (!item->iqty) continue; + /* save the items value */ + value = item->value; + /* Skip non "worthless" items */ ! if (item->tval > TV_CHEST) ! { ! /* unknow and not worthless */ ! if (!item->able && !streq(item->note, "{average}") && ! value > 0) ! continue; ! /* skip items that are 'valuable'. This is level dependent */ ! /* try to make the borg junk +1,+1 dagger at level 40 */ ! /* if the item gives a bonus to a stat, boost its value */ ! if (((item->flags1 & TR1_STR) || ! (item->flags1 & TR1_INT) || ! (item->flags1 & TR1_WIS) || ! (item->flags1 & TR1_DEX) || ! (item->flags1 & TR1_CON)) && value > 0) ! { ! value += 20000L; ! } ! ! /* up to level 5, keep anything of any value */ ! if (auto_depth < 5 && value > 0) ! continue; ! /* up to level 15, keep anything of value 100 or better */ ! if (auto_depth < 15 && value > 100) ! continue; ! /* up to level 30, keep anything of value 500 or better */ ! if (auto_depth < 30 && value > 500) ! continue; ! /* up to level 40, keep anything of value 1000 or better */ ! if (auto_depth < 40 && value > 1000) ! continue; ! /* below level 40, keep anything of value 1200 or better */ ! if (auto_depth >= 40 && value > 1200) ! continue; ! ! /* Save the item */ ! COPY(&safe_items[i], &auto_items[i], auto_item); ! ! /* Destroy the item */ ! WIPE(&auto_items[i], auto_item); ! ! /* Fix later */ ! fix = TRUE; ! ! /* Examine the inventory */ ! borg_notice(); ! ! /* Evaluate the inventory */ ! p = borg_power(); ! ! /* Restore the item */ ! COPY(&auto_items[i], &safe_items[i], auto_item); ! ! /* skip things we are using */ ! if (p < my_power) continue; ! } ! ! /* re-examine the inventory */ ! if (fix) borg_notice(); ! ! /* Hack -- skip good un-id'd "artifacts" */ if (streq(item->note, "{special}")) continue; /* Message */ borg_note(format("# Junking junk (junk)")); *************** *** 1014,1020 **** --- 1224,1249 ---- borg_keypress('0'); /* Destroy that item */ + if (!item->name1 && !streq(item->note, "{terrible}")) borg_keypress('k'); + else + { + int a; + + /* worthless artifacts are dropped. */ + borg_keypress('d'); + + /* mark the spot that the object was dropped so that */ + /* it will not be picked up again. */ + for (a = 0; a < 10; a++) + { + if (bad_obj_x[a] != -1) continue; + if (bad_obj_y[a] != -1) continue; + + bad_obj_x[a] = c_x; + bad_obj_y[a] = c_y; + } + } borg_keypress(I2A(i)); /* Verify destruction */ *************** *** 1024,1029 **** --- 1253,1260 ---- return (TRUE); } + /* re-examine the inventory */ + if (fix) borg_notice(); /* Hack -- no need */ auto_do_crush_junk = FALSE; *************** *** 1056,1061 **** --- 1287,1294 ---- int i, b_i = -1; s32b p, b_p = 0L; + s32b value; + bool fix = FALSE; *************** *** 1066,1072 **** /* Do not destroy items unless we need the space */ if (!auto_items[INVEN_PACK-1].iqty) return (FALSE); - /* Scan the inventory */ for (i = 0; i < INVEN_PACK; i++) { --- 1299,1304 ---- *************** *** 1082,1087 **** --- 1314,1322 ---- if (streq(item->note, "{special}")) continue; if (streq(item->note, "{terrible}")) continue; + /* save the items value */ + value = item->value; + /* Save the item */ COPY(&safe_items[i], &auto_items[i], auto_item); *************** *** 1097,1110 **** /* Evaluate the inventory */ p = borg_power(); /* Restore the item */ COPY(&auto_items[i], &safe_items[i], auto_item); /* Penalize loss of "gold" */ - p -= (item->iqty * item->value); /* Hack -- try not to destroy "unaware" items */ ! if (!item->kind && (item->value > 0)) { /* Hack -- Reward "unaware" items */ switch (item->tval) --- 1332,1419 ---- /* Evaluate the inventory */ p = borg_power(); + /* power is much more important than gold. */ + p *= 100; + /* Restore the item */ COPY(&auto_items[i], &safe_items[i], auto_item); /* Penalize loss of "gold" */ + /* if the item gives a bonus to a stat, boost its value */ + if ((item->flags1 & TR1_STR) || + (item->flags1 & TR1_INT) || + (item->flags1 & TR1_WIS) || + (item->flags1 & TR1_DEX) || + (item->flags1 & TR1_CON)) + { + value += 20000L; + } + + /* Hack show prefrence for destroying things we will not use */ + /* if we are high enough level not to worry about gold. */ + if (auto_level > 35) + { + switch (item->tval) + { + /* rings are under valued. */ + case TV_RING: + p -= (item->iqty * value * 10); + break; + + case TV_AMULET: + case TV_BOW: + case TV_HAFTED: + case TV_POLEARM: + case TV_SWORD: + case TV_BOOTS: + case TV_GLOVES: + case TV_HELM: + case TV_CROWN: + case TV_SHIELD: + case TV_CLOAK: + case TV_SOFT_ARMOR: + case TV_HARD_ARMOR: + case TV_DRAG_ARMOR: + p -= (item->iqty * value * 5); + break; + + case TV_ROD: + p -= (item->iqty * value); + break; + + case TV_STAFF: + case TV_WAND: + p -= (item->iqty * (value/2)); + break; + + /* scrolls and potions crush easy */ + case TV_SCROLL: + p -= (item->iqty * (value/10)); + break; + + case TV_POTION: + /* BIG HACK! don't crush heal/mana potions. It could be */ + /* that we are in town and are collecting them. */ + if ((item->sval != SV_POTION_HEALING) || + (item->sval != SV_POTION_RESTORE_MANA)) + p -= (item->iqty * (30000L)); /* value at 30k */ + else + p -= (item->iqty * (value/10)); + break; + + default: + p -= (item->iqty * (value/3)); + break; + } + } + else + { + p -= (item->iqty * value); + } + /* Hack -- try not to destroy "unaware" items */ ! if (!item->kind && (value > 0)) { /* Hack -- Reward "unaware" items */ switch (item->tval) *************** *** 1136,1142 **** /* Hack -- try not to destroy "unknown" items (unless "icky") */ if (!item->able && !streq(item->note, "{average}") && ! (item->value > 0) && !borg_item_icky(item)) { /* Reward "unknown" items */ switch (item->tval) --- 1445,1451 ---- /* Hack -- try not to destroy "unknown" items (unless "icky") */ if (!item->able && !streq(item->note, "{average}") && ! (value > 0) && !borg_item_icky(item)) { /* Reward "unknown" items */ switch (item->tval) *************** *** 1204,1210 **** auto_item *item = &auto_items[b_i]; /* Debug */ ! borg_note(format("# Junking %ld gold (full)", my_power - b_p)); /* Try to consume the junk */ if (borg_consume(b_i)) return (TRUE); --- 1513,1519 ---- auto_item *item = &auto_items[b_i]; /* Debug */ ! borg_note(format("# Junking %ld gold (full)", my_power*100 - b_p)); /* Try to consume the junk */ if (borg_consume(b_i)) return (TRUE); *************** *** 1273,1279 **** greed = (auto_gold / 100L) + 100L; /* Minimal greed */ ! if (greed > 1000L) greed = 1000L; /* Scan for junk */ --- 1582,1589 ---- greed = (auto_gold / 100L) + 100L; /* Minimal greed */ ! if (greed < 500L && auto_level > 35) greed = 500L; ! if (greed > 25000L) greed = 25000L; /* Scan for junk */ *************** *** 1306,1311 **** --- 1616,1624 ---- /* Evaluate the inventory */ p = borg_power(); + /* power is much more important than gold. */ + p *= 100; + /* Restore the item */ COPY(&auto_items[i], &safe_items[i], auto_item); *************** *** 1322,1331 **** temp = item->weight; /* Reward */ ! p += temp; /* Ignore "bad" swaps */ ! if ((b_i >= 0) && (p < b_p)) continue; /* Maintain the "best" */ b_i = i; b_p = p; --- 1635,1644 ---- temp = item->weight; /* Reward */ ! p += (temp*10); /* Ignore "bad" swaps */ ! if (p < b_p) continue; /* Maintain the "best" */ b_i = i; b_p = p; *************** *** 1335,1346 **** if (fix) borg_notice(); /* Destroy "useless" things */ ! if ((b_i >= 0) && (b_p >= my_power)) { auto_item *item = &auto_items[b_i]; /* Message */ ! borg_note(format("# Junking %ld gold (slow)", my_power - b_p)); /* Attempt to consume it */ if (borg_consume(b_i)) return (TRUE); --- 1648,1659 ---- if (fix) borg_notice(); /* Destroy "useless" things */ ! if ((b_i >= 0) && (b_p >= (my_power*100))) { auto_item *item = &auto_items[b_i]; /* Message */ ! borg_note(format("# Junking %ld gold (slow)", (my_power*100) - b_p)); /* Attempt to consume it */ if (borg_consume(b_i)) return (TRUE); *************** *** 1370,1377 **** } - - /* * Identify items if possible * --- 1683,1688 ---- *************** *** 1401,1408 **** * pick a random item and identify it if necessary", which might lower * the preference for identifying items that appear early in the pack. * Also, preventing inventory motion would allow proper time-stamping. */ ! bool borg_test_stuff(void) { int i, b_i = -1; s32b v, b_v = -1; --- 1712,1722 ---- * pick a random item and identify it if necessary", which might lower * the preference for identifying items that appear early in the pack. * Also, preventing inventory motion would allow proper time-stamping. + * + * This function is also used to *ID* objects. Right now only objects + * with random high resist or random powers are *ID*'d */ ! bool borg_test_stuff(bool star_id) { int i, b_i = -1; s32b v, b_v = -1; *************** *** 1417,1427 **** if (!item->iqty) continue; /* Skip known items */ if (item->able) continue; - /* Hack -- never identify "average" things */ - /* if (streq(item->note, "{average}")) continue; */ - /* Get the value */ v = item->value + 100000L; --- 1731,1766 ---- if (!item->iqty) continue; /* Skip known items */ + if (!star_id) + { if (item->able) continue; + } + else + { + if (item->fully_identified) continue; + switch (item->name2) + { + /* Weapon (Blessed) */ + case EGO_BLESS_BLADE: + /* Robe of Permanance */ + case EGO_PERMANENCE: + /* Armor of Elvenkind */ + case EGO_ELVENKIND: + /* Crown of the Magi */ + case EGO_MAGI: + /* Cloak of Aman */ + case EGO_AMAN: + break; + /* Weapon (Holy Avenger) */ + case EGO_HA: + /* Weapon (Defender) */ + case EGO_DF: + /* anything else */ + default: + continue; + } + } /* Get the value */ v = item->value + 100000L; *************** *** 1441,1447 **** --- 1780,1814 ---- if (!item->iqty) continue; /* Skip known items */ + if (!star_id) + { if (item->able) continue; + } + else + { + if (item->fully_identified) continue; + switch (item->name2) + { + /* Weapon (Blessed) */ + case EGO_BLESS_BLADE: + /* Robe of Permanance */ + case EGO_PERMANENCE: + /* Armor of Elvenkind */ + case EGO_ELVENKIND: + /* Crown of the Magi */ + case EGO_MAGI: + /* Cloak of Aman */ + case EGO_AMAN: + break; + /* Weapon (Holy Avenger) */ + case EGO_HA: + /* Weapon (Defender) */ + case EGO_DF: + /* anything else */ + default: + continue; + } + } /* Assume nothing */ v = 0; *************** *** 1471,1477 **** --- 1838,1872 ---- if (!item->iqty) continue; /* Skip known items */ + if (!star_id) + { if (item->able) continue; + } + else + { + if (item->fully_identified) continue; + switch (item->name2) + { + /* Weapon (Blessed) */ + case EGO_BLESS_BLADE: + /* Robe of Permanance */ + case EGO_PERMANENCE: + /* Armor of Elvenkind */ + case EGO_ELVENKIND: + /* Crown of the Magi */ + case EGO_MAGI: + /* Cloak of Aman */ + case EGO_AMAN: + break; + /* Weapon (Holy Avenger) */ + case EGO_HA: + /* Weapon (Defender) */ + case EGO_DF: + /* anything else */ + default: + continue; + } + } /* Hack -- never identify "average" things */ if (streq(item->note, "{average}")) continue; *************** *** 1480,1486 **** v = 0; /* Hack -- reward "unaware" items */ ! if (!item->kind) { /* Analyze the type */ switch (item->tval) --- 1875,1881 ---- v = 0; /* Hack -- reward "unaware" items */ ! if (!item->kind && !star_id) { /* Analyze the type */ switch (item->tval) *************** *** 1624,1629 **** --- 2019,2074 ---- { auto_item *item = &auto_items[b_i]; + if (star_id) + { + if (borg_read_scroll(SV_SCROLL_STAR_IDENTIFY)) + { + /* Log -- may be cancelled */ + borg_note(format("# *IDENTIFY*ing %s.", item->desc)); + + /* we need to look at the screen next time through */ + auto_do_star_id = TRUE; + item->needs_I = TRUE; + item->fully_identified = TRUE; + + /* Equipment */ + if (b_i >= INVEN_WIELD) + { + /* Select the equipment */ + borg_keypress('/'); + + /* Select the item */ + borg_keypress(I2A(b_i - INVEN_WIELD)); + + /* HACK need to recheck stats if we id something on us. */ + for (i = 0;i < 6; i++) + { + my_need_stat_check[i] = TRUE; + my_stat_max[i] = 0; + } + } + + /* Inventory */ + else + { + /* Select the item */ + borg_keypress(I2A(b_i)); + } + + /* press enter a few time (get rid of display) */ + borg_keypress('\r'); + borg_keypress('\r'); + borg_keypress('\r'); + borg_keypress('\r'); + + /* Success */ + return (TRUE); + } + + } + else + { + /* Use a Spell/Prayer/Rod/Staff/Scroll of Identify */ if (borg_spell(2, 4) || borg_prayer(5, 2) || *************** *** 1642,1648 **** --- 2087,2100 ---- /* Select the item */ borg_keypress(I2A(b_i - INVEN_WIELD)); + + /* HACK need to recheck stats if we id something on us. */ + for (i = 0; i < 6; i++) + { + my_need_stat_check[i] = TRUE; + my_stat_max[i] = 0; } + } /* Inventory */ else *************** *** 1655,1660 **** --- 2107,2113 ---- return (TRUE); } } + } /* Nothing to do */ return (FALSE); *************** *** 2202,2208 **** /* Extract the slot */ slot = borg_best_stuff_order[n]; - /* All done */ if (slot == 255) { --- 2655,2660 ---- *************** *** 2217,2222 **** --- 2669,2685 ---- /* Track best */ if (p > *vp) { + + #if 0 + /* dump list and power... for debugging */ + borg_note(format("Trying Combo (best power %ld)", *vp)); + borg_note(format(" (borg_power %ld)", p)); + for (i = 0; i < INVEN_PACK; i++) + borg_note(format("inv %d %s.", i, auto_items[i].desc)); + for (i=0; borg_best_stuff_order[i] != 255; i++) + borg_note(format("stuff %s.", + auto_items[borg_best_stuff_order[i]].desc)); + #endif /* Save the results */ for (i = 0; i < n; i++) best[i] = test[i]; *************** *** 2237,2245 **** /* Try other possible objects */ ! for (i = 0; i < INVEN_PACK; i++) { ! auto_item *item = &auto_items[i]; /* Skip empty items */ if (!item->iqty) continue; --- 2700,2712 ---- /* Try other possible objects */ ! for (i = 0; i < ((shop_num == 7) ? (INVEN_PACK + STORE_INVEN_MAX) : INVEN_PACK); i++) { ! auto_item *item; ! if (i < INVEN_PACK) ! item = &auto_items[i]; ! else ! item = &auto_shops[7].ware[i - INVEN_PACK]; /* Skip empty items */ if (!item->iqty) continue; *************** *** 2261,2288 **** /* Make sure it goes in this slot */ if (slot != borg_wield_slot(item)) continue; - /* Take off old item */ - COPY(&auto_items[i], &safe_items[slot], auto_item); - /* Wear the new item */ ! COPY(&auto_items[slot], &safe_items[i], auto_item); /* Note the attempt */ test[n] = i; /* Evaluate the possible item */ borg_best_stuff_aux(n + 1, test, best, vp); /* Restore equipment */ COPY(&auto_items[slot], &safe_items[slot], auto_item); - - /* Restore inventory */ - COPY(&auto_items[i], &safe_items[i], auto_item); } } - /* * Attempt to instantiate the *best* possible equipment. */ --- 2728,2753 ---- /* Make sure it goes in this slot */ if (slot != borg_wield_slot(item)) continue; /* Wear the new item */ ! COPY(&auto_items[slot], item, auto_item); /* Note the attempt */ + if (i < INVEN_PACK) test[n] = i; + else + /* if in home, note by adding 100 to item number. */ + test[n] = (i - INVEN_PACK) + 100; + /* Evaluate the possible item */ borg_best_stuff_aux(n + 1, test, best, vp); /* Restore equipment */ COPY(&auto_items[slot], &safe_items[slot], auto_item); } } /* * Attempt to instantiate the *best* possible equipment. */ *************** *** 2290,2297 **** { int hole = INVEN_PACK - 1; - int slot; - int k; int n = 0; --- 2755,2760 ---- *************** *** 2299,2318 **** s32b value; int i, b_i = -1; ! s32b p, b_p = 0L; byte test[12]; byte best[12]; - auto_item *item; - bool fix = FALSE; - - /* Require an empty slot */ - if (auto_items[hole].iqty) return (FALSE); - - /* Hack -- Initialize */ for (k = 0; k < 12; k++) { --- 2762,2774 ---- s32b value; int i, b_i = -1; ! s32b b_p = 0L; byte test[12]; byte best[12]; bool fix = FALSE; /* Hack -- Initialize */ for (k = 0; k < 12; k++) { *************** *** 2327,2332 **** --- 2783,2797 ---- COPY(&safe_items[i], &auto_items[i], auto_item); } + if (shop_num == 7) + { + /* Hack -- Copy all the store slots */ + for (i = 0; i < STORE_INVEN_MAX; i++) + { + /* Save the item */ + COPY(&safe_home[i], &auto_shops[7].ware[i], auto_item); + } + } /* Evaluate the inventory */ value = my_power; *************** *** 2337,2344 **** /* Restore bonuses */ borg_notice(); ! ! /* Find "easiest" step */ for (k = 0; k < 12; k++) { /* Get choice */ --- 2802,2808 ---- /* Restore bonuses */ borg_notice(); ! /* Make first change. */ for (k = 0; k < 12; k++) { /* Get choice */ *************** *** 2345,2429 **** i = best[k]; /* Ignore non-changes */ ! if (i >= INVEN_WIELD) continue; ! /* Count changes */ ! n++; ! /* Access the item */ ! item = &auto_items[i]; ! /* Access the slot */ ! slot = borg_wield_slot(item); ! /* Save the old item */ ! COPY(&safe_items[slot], &auto_items[slot], auto_item); ! /* Save the new item */ ! COPY(&safe_items[i], &auto_items[i], auto_item); ! /* Save the hole */ ! COPY(&safe_items[hole], &auto_items[hole], auto_item); ! /* Take off old item */ ! COPY(&auto_items[hole], &safe_items[slot], auto_item); ! /* Wear new item */ ! COPY(&auto_items[slot], &safe_items[i], auto_item); ! ! /* Only a single item */ ! auto_items[slot].iqty = 1; ! ! /* Reduce the inventory quantity by one */ ! auto_items[i].iqty--; ! ! /* Fix later */ ! fix = TRUE; ! ! /* Examine the inventory */ ! borg_notice(); ! ! /* Evaluate the inventory */ ! p = borg_power(); ! ! /* Restore the old item */ ! COPY(&auto_items[slot], &safe_items[slot], auto_item); ! ! /* Restore the new item */ ! COPY(&auto_items[i], &safe_items[i], auto_item); ! ! /* Restore the hole */ ! COPY(&auto_items[hole], &safe_items[hole], auto_item); ! ! /* Track the "best" change */ ! if ((b_i >= 0) && (p < b_p)) continue; ! ! /* Maintain the "best" */ ! b_i = i; b_p = p; } ! /* Restore bonuses */ ! if (fix) borg_notice(); - /* Start changing */ - if (b_i >= 0) - { - /* Get the item */ - auto_item *item = &auto_items[b_i]; - - /* Log */ - borg_note(format("# Besting %s (1/%d).", item->desc, n)); - - /* Wear it */ - borg_keypress('w'); - borg_keypress(I2A(b_i)); - - /* Did something */ return (TRUE); } - /* Nope */ return (FALSE); } --- 2809,2862 ---- i = best[k]; /* Ignore non-changes */ ! if (i == borg_best_stuff_order[k] || 255 == i) continue; ! if (i < 100) ! { ! /* weild the item */ ! auto_item *item = &auto_items[i]; ! borg_note(format("# Best Combo %s.", item->desc)); ! borg_keypress('w'); ! borg_keypress(I2A(i)); ! return (TRUE); ! } ! else ! { ! auto_item *item; ! /* can't get an item if full. */ ! if (auto_items[hole].iqty) return (FALSE); ! i-=100; ! item = &auto_shops[7].ware[i]; ! /* Get the item */ ! borg_note(format("# Getting (Best Fit) %s.", item->desc)); ! /* Take the stuff from home and put in inv. and try again. */ ! /* make sure on right page */ ! /* Minor Hack -- Go to the correct page */ ! if ((i / 12) != auto_shops[7].page) ! { ! borg_keypress(' '); } ! borg_keypress('p'); ! borg_keypress(I2A(i % 12)); + /* press enter a few time (mulitple objects) */ + borg_keypress('\r'); + borg_keypress('\r'); + borg_keypress('\r'); + borg_keypress('\r'); return (TRUE); } + } /* Nope */ return (FALSE); } *************** *** 2595,2601 **** greed = (auto_gold / 100L) + 100L; /* Minimal greed */ ! if (greed > 1000L) greed = 1000L; /* Count "sellable" items */ --- 3028,3035 ---- greed = (auto_gold / 100L) + 100L; /* Minimal greed */ ! if (greed < 1000L) greed = 1000L; ! if (greed > 25000L) greed = 25000L; /* Count "sellable" items */ *************** *** 2631,2653 **** */ bool borg_leave_level(bool bored) { ! int i, k, g = 0; - /* Hack -- waiting for "recall" */ if (goal_recalling) return (FALSE); ! /* Hack -- Note level completion */ ! if (bored && borg_prepared(auto_depth - 1)) { ! /* Clear fear up to next level */ ! for (i = 0; i <= auto_depth + 1; i++) { ! /* Remove fear */ ! auto_fear_depth[i] = FALSE; } } /* Town */ --- 3065,3105 ---- */ bool borg_leave_level(bool bored) { ! int k, g = 0; /* Hack -- waiting for "recall" */ if (goal_recalling) return (FALSE); + if (bored) + { ! /* count this level as finished */ ! if (auto_depth >= fear_depth && !finished_level) { ! finished_level = TRUE; ! auto_fear_depth++; ! ! /* do not stay at the same level TOO long. This will */ ! /* only help if it is the death of a unique we are waiting */ ! /* for. If we are hanging out looking for an item then we */ ! /* still will not go lower than the depth we are prepaired for */ ! if (auto_fear_depth > 25 && fear_depth < 95) { ! /* go to the next level */ ! auto_fear_depth = 0; ! fear_depth++; } + + /* if we are hanging out for a while, start scumming. */ + /* NOTE: Do not scum for MORGOTH. That is just too scary! */ + if (auto_fear_depth > 15 && fear_depth < 95) + auto_scum = TRUE; + else + auto_scum = FALSE; + + } + } /* Town */ *************** *** 2662,2668 **** /* Hack -- Recall into dungeon */ if ((auto_max_depth >= 5) && (amt_recall > 4) && ! borg_prepared(auto_max_depth - 1) && borg_recall()) { /* Note */ --- 3114,3120 ---- /* Hack -- Recall into dungeon */ if ((auto_max_depth >= 5) && (amt_recall > 4) && ! ((cptr)NULL == borg_prepared(auto_max_depth)) && borg_recall()) { /* Note */ *************** *** 2671,2678 **** /* Give it a shot */ return (TRUE); } - /* Take next stairs */ stair_more = TRUE; /* Attempt to use those stairs */ --- 3123,3144 ---- /* Give it a shot */ return (TRUE); } + else + { + /* note why we didn't recall. */ + if (auto_max_depth < 5) + borg_note("# not deep enough to recall"); + else + if (amt_recall <= 4) + borg_note("# not enough recalls to recall"); + else + if ((cptr)NULL != borg_prepared(auto_max_depth)) + borg_note(format("# not prepared to recall: %s", + borg_prepared(auto_max_depth))); + else + borg_note("# failed to recall when I wanted to"); + } stair_more = TRUE; /* Attempt to use those stairs */ *************** *** 2682,2736 **** return (FALSE); } /* Count sellable items */ k = borg_count_sell(); - - /* Dive when bored */ - if (bored) g = 1; - - /* Hack -- Power-dive downwards when able */ - if (auto_level > auto_depth * 2 + 2) g = 1; - - - /* Do not enter dangerous depths */ - if (g && !borg_prepared(auto_depth + 1)) g = 0; - /* Do not dive when "full" of items */ ! if (g && (k >= 18)) g = 0; /* Do not dive when drained */ if (g && do_fix_exp) g = 0; - /* Hack -- Power-dive upwards when needed */ ! if (!borg_prepared(auto_depth)) g = -1; /* Hack -- Stay on each level for a minimal amount of time */ ! if (g && (c_t - auto_began < value_feeling[auto_feeling])) g = 0; ! /* Return to town when bored and unable to dive */ ! if (bored && !borg_prepared(auto_depth + 1)) goal_rising = TRUE; /* Return to town to sell stuff */ ! if (bored && (k >= 18)) goal_rising = TRUE; /* Return to town when level drained */ ! if (do_fix_lev) goal_rising = TRUE; /* Return to town to restore experience */ ! if (bored && do_fix_exp) goal_rising = TRUE; ! /* Return to town */ if (goal_rising) g = -1; /* Mega-Hack -- spend time on the first level to rotate shops */ if ((auto_depth == 1) && (c_t - auto_began < 100) && (g < 0)) g = 0; - /* Use random stairs when really bored */ if (bored && (c_t - auto_began >= 5000)) { --- 3148,3229 ---- return (FALSE); } + /* do not hangout on boring levels for *too* long */ + if ((cptr)NULL == borg_prepared(auto_depth + 1)) g = 1; /* Count sellable items */ k = borg_count_sell(); /* Do not dive when "full" of items */ ! if (g && (k >= 12)) g = 0; /* Do not dive when drained */ if (g && do_fix_exp) g = 0; /* Hack -- Power-dive upwards when needed */ ! if ((cptr)NULL != borg_prepared(auto_depth)) ! { ! borg_note(format("# heading up (too deep: %s)", ! borg_prepared(auto_depth))); ! g = -1; ! } /* Hack -- Stay on each level for a minimal amount of time */ ! if (0 != g && (c_t - auto_began < value_feeling[auto_feeling])) ! { ! g = 0; ! } + /* Rise a level if bored and unable to dive. */ + if (bored && ((cptr)NULL != borg_prepared(auto_depth + 1))) + { + g = -1; + borg_note(format("# heading up (bored and unable to dive: %s)", + borg_prepared(auto_depth + 1))); ! } /* Return to town to sell stuff */ ! if (bored && (k >= 12)) ! { ! borg_note("# Going to town (Sell Stuff)."); ! goal_rising = TRUE; ! } /* Return to town when level drained */ ! if (do_fix_lev) ! { ! borg_note("# Going to town (Fix Level)."); ! goal_rising = TRUE; ! } /* Return to town to restore experience */ ! if (bored && do_fix_exp) ! { ! borg_note("# Going to town (Fix Experience)."); ! goal_rising = TRUE; ! } + /* return to town if it has been a while */ + if (!goal_rising && bored && + ((auto_time_town + (c_t - auto_began)) > 8000)) + { + borg_note("# Going to town (I miss my home)."); + goal_rising = TRUE; + } ! /* if returning to town, try to go upstairs */ if (goal_rising) g = -1; + /* don't go back to town if we just left */ + if (goal_rising && (auto_time_town + (c_t - auto_began)) < 200) + { + goal_rising = FALSE; + } + /* Mega-Hack -- spend time on the first level to rotate shops */ if ((auto_depth == 1) && (c_t - auto_began < 100) && (g < 0)) g = 0; /* Use random stairs when really bored */ if (bored && (c_t - auto_began >= 5000)) { *************** *** 2741,2746 **** --- 3234,3245 ---- g = ((rand_int(100) < 50) ? -1 : 1); } + /* stay on level 100 if going after Morgoth and he isn't dead yet */ + if ((auto_depth == 100) && (borg_ready_morgoth == 1)) + { + goal_rising = FALSE; + g = 0; + } /* Go Up */ if (g < 0) *************** *** 2748,2760 **** /* Take next stairs */ stair_less = TRUE; ! /* Hack -- recall */ if (goal_rising && (auto_depth >= 5) && - (amt_recall > 3) && borg_recall()) { ! borg_note("# Recalling to town (for fun)"); return (TRUE); } --- 3247,3259 ---- /* Take next stairs */ stair_less = TRUE; ! /* Hack -- recall if going to town */ if (goal_rising && + ((auto_time_town + (c_t - auto_began)) > 200) && (auto_depth >= 5) && borg_recall()) { ! borg_note("# Recalling to town (goal rising)"); return (TRUE); } *************** *** 2762,2768 **** if (borg_flow_stair_less(GOAL_BORE)) return (TRUE); /* Cannot find any stairs */ ! if (goal_rising && bored) { if (borg_recall()) { --- 3261,3267 ---- if (borg_flow_stair_less(GOAL_BORE)) return (TRUE); /* Cannot find any stairs */ ! if (goal_rising && bored && (c_t - auto_began) >= 1000) { if (borg_recall()) { *************** *** 2801,2810 **** } #else #ifdef MACINTOSH static int HACK = 0; ! #endif /* MACINTOSH */ ! #endif /* ALLOW_BORG */ --- 3300,3310 ---- } + #else #ifdef MACINTOSH static int HACK = 0; ! #endif ! #endif diff -w -c -r Borg/borg7.h adamborg/borg7.h *** Borg/borg7.h Sun Apr 13 23:22:32 1997 --- adamborg/borg7.h Sun Apr 13 23:26:56 1997 *************** *** 33,39 **** extern bool borg_crush_junk(void); extern bool borg_crush_hole(void); extern bool borg_crush_slow(void); ! extern bool borg_test_stuff(void); extern bool borg_takeoff_stuff(void); extern bool borg_swap_rings(void); extern bool borg_wear_rings(void); --- 33,39 ---- extern bool borg_crush_junk(void); extern bool borg_crush_hole(void); extern bool borg_crush_slow(void); ! extern bool borg_test_stuff(bool star_id); extern bool borg_takeoff_stuff(void); extern bool borg_swap_rings(void); extern bool borg_wear_rings(void); diff -w -c -r Borg/borg8.c adamborg/borg8.c *** Borg/borg8.c Sun Apr 13 23:22:47 1997 --- adamborg/borg8.c Sun Apr 13 23:27:18 1997 *************** *** 15,27 **** --- 15,221 ---- #include "borg7.h" #include "borg8.h" + byte *test; + byte *best; + s32b *b_home_power; + /* + * Determine if an item can "absorb" a second item + * + * See "object_absorb()" for the actual "absorption" code. + * + * If permitted, we allow wands/staffs (if they are known to have equal + * charges) and rods (if fully charged) to combine. + * + * Note that rods/staffs/wands are then unstacked when they are used. + * + * If permitted, we allow weapons/armor to stack, if they both known. + * + * Food, potions, scrolls, and "easy know" items always stack. + * + * Chests never stack (for various reasons). + * + * We do NOT allow activatable items (artifacts or dragon scale mail) + * to stack, to keep the "activation" code clean. Artifacts may stack, + * but only with another identical artifact (which does not exist). + * + * Ego items may stack as long as they have the same ego-item type. + * This is primarily to allow ego-missiles to stack. + */ + static bool borg_object_similar(auto_item *o_ptr, auto_item *j_ptr) + { + /* NOTE: This assumes the giving of one item at a time */ + int total = o_ptr->iqty + 1; + + + /* Require identical object types */ + if (o_ptr->kind != j_ptr->kind) return (0); + + + /* Analyze the items */ + switch (o_ptr->tval) + { + /* Chests */ + case TV_CHEST: + { + /* Never okay */ + return (0); + } + + /* Food and Potions and Scrolls */ + case TV_FOOD: + case TV_POTION: + case TV_SCROLL: + { + /* Assume okay */ + break; + } + + /* Staffs and Wands */ + case TV_STAFF: + case TV_WAND: + { + /* Require knowledge */ + if ((!o_ptr->able) || (!j_ptr->able)) return (0); + + /* Fall through */ + } + + /* Staffs and Wands and Rods */ + case TV_ROD: + { + /* Require permission */ + if (!stack_allow_wands) return (0); + + /* Require identical charges */ + if (o_ptr->pval != j_ptr->pval) return (0); + + /* Probably okay */ + break; + } + + /* Weapons and Armor */ + case TV_BOW: + case TV_DIGGING: + case TV_HAFTED: + case TV_POLEARM: + case TV_SWORD: + case TV_BOOTS: + case TV_GLOVES: + case TV_HELM: + case TV_CROWN: + case TV_SHIELD: + case TV_CLOAK: + case TV_SOFT_ARMOR: + case TV_HARD_ARMOR: + case TV_DRAG_ARMOR: + { + /* Require permission */ + if (!stack_allow_items) return (0); + + /* XXX XXX XXX Require identical "sense" status */ + /* if ((o_ptr->ident & ID_SENSE) != */ + /* (j_ptr->ident & ID_SENSE)) return (0); */ + + /* Fall through */ + } + + /* Rings, Amulets, Lites */ + case TV_RING: + case TV_AMULET: + case TV_LITE: + { + /* Require full knowledge of both items */ + if ((!o_ptr->able) || (!j_ptr->able)) return (0); + + /* Fall through */ + } + + /* Missiles */ + case TV_BOLT: + case TV_ARROW: + case TV_SHOT: + { + /* Require identical "bonuses" */ + if (o_ptr->to_h != j_ptr->to_h) return (FALSE); + if (o_ptr->to_d != j_ptr->to_d) return (FALSE); + if (o_ptr->to_a != j_ptr->to_a) return (FALSE); + + /* Require identical "pval" code */ + if (o_ptr->pval != j_ptr->pval) return (FALSE); + + /* Require identical "artifact" names */ + if (o_ptr->name1 != j_ptr->name1) return (FALSE); + + /* Require identical "ego-item" names */ + if (o_ptr->name2 != j_ptr->name2) return (FALSE); + + /* Hack -- Never stack "powerful" items */ + if (o_ptr->flags1 || j_ptr->flags1) return (FALSE); + if (o_ptr->flags2 || j_ptr->flags2) return (FALSE); + if (o_ptr->flags3 || j_ptr->flags3) return (FALSE); + + /* Hack -- Never stack recharging items */ + if (o_ptr->timeout || j_ptr->timeout) return (FALSE); + + /* Require identical "values" */ + if (o_ptr->ac != j_ptr->ac) return (FALSE); + if (o_ptr->dd != j_ptr->dd) return (FALSE); + if (o_ptr->ds != j_ptr->ds) return (FALSE); + + /* Probably okay */ + break; + } + + /* Various */ + default: + { + /* Require knowledge */ + if ((!o_ptr->able) || (!j_ptr->able)) return (0); + + /* Probably okay */ + break; + } + } + + + /* Hack -- Require identical "broken" status */ + if ((o_ptr->fully_identified) != (j_ptr->fully_identified)) return (0); + + /* The stuff with 'note' is not right but it is close. I think it */ + /* has him assuming that he can't stack sometimes when he can. This */ + /* is alright, it just causes him to take a bit more time to do */ + /* some exchanges. */ + /* Hack -- require semi-matching "inscriptions" */ + if (o_ptr->note[0] && j_ptr->note[0] && + (!streq(o_ptr->note, j_ptr->note))) + return (0); + + /* Hack -- normally require matching "inscriptions" */ + if (!stack_force_notes && (!streq(o_ptr->note, j_ptr->note))) return (0); + + /* Hack -- normally require matching "discounts" */ + if (!stack_force_costs && (o_ptr->discount != j_ptr->discount)) return (0); + + + /* Maximal "stacking" limit */ + if (total >= MAX_STACK_SIZE) return (0); + + + /* They match, so they must be similar */ + return (TRUE); + } + + + /* * This file handles the highest level goals, and store interaction. * * Store interaction strategy * * (1) Sell items to the home (for later use) + ** optimize the stuff in the home... this involves buying and selling stuff + ** not in the 'best' list. * We sell anything we may need later (see step 4) * * (2) Sell items to the shops (for money) *************** *** 45,157 **** * attempt to use the home as a "stockpile", even though that is * not worth any money, since it may save us money eventually. */ /* ! * Step 1 -- sell "useful" things to the home (for later) */ ! static bool borg_think_home_sell_aux(void) { ! int icky = STORE_INVEN_MAX - 1; ! int i, b_i = -1; ! s32b p, b_p = 0L; ! s32b s, b_s = 0L; ! bool fix = FALSE; ! /* Hack -- the home is full */ ! if (auto_shops[7].ware[icky].iqty) return (FALSE); ! /* Base power */ ! b_p = my_power; /* Examine the home */ ! borg_notice_home(); /* Evaluate the home */ ! b_s = borg_power_home(); ! /* Save the store hole */ ! COPY(&safe_shops[7].ware[icky], &auto_shops[7].ware[icky], auto_item); ! /* Sell stuff */ for (i = 0; i < INVEN_PACK; i++) { ! auto_item *item = &auto_items[i]; ! /* Skip empty items */ ! if (!item->iqty) continue; /* Save the item */ COPY(&safe_items[i], &auto_items[i], auto_item); ! /* Give the item to the shop */ ! COPY(&auto_shops[7].ware[icky], &safe_items[i], auto_item); ! /* Give a single item */ ! auto_shops[7].ware[icky].iqty = 1; ! /* Lose a single item */ ! auto_items[i].iqty--; ! /* Fix later */ ! fix = TRUE; ! /* Examine the inventory */ ! borg_notice(); ! /* Evaluate the inventory */ ! p = borg_power(); ! /* Restore the item */ COPY(&auto_items[i], &safe_items[i], auto_item); ! /* Ignore "bad" sales */ ! if (p < b_p) continue; ! /* Examine the home */ ! borg_notice_home(); ! /* Evaluate the home */ ! s = borg_power_home(); ! /* Ignore "silly" sales */ ! if ((p == b_p) && (s <= b_s)) continue; ! /* Maintain the "best" */ ! b_i = i; b_p = p; b_s = s; } ! /* Restore the store hole */ ! COPY(&auto_shops[7].ware[icky], &safe_shops[7].ware[icky], auto_item); ! /* Examine the player */ ! if (fix) borg_notice(); ! /* Examine the home */ ! borg_notice_home(); ! /* Evaluate the home */ ! s = borg_power_home(); ! /* Stockpile */ ! if (b_i >= 0) { ! /* Visit the home */ goal_shop = 7; - /* Sell that item */ - goal_item = b_i; - - /* Success */ return (TRUE); } /* Assume not */ return (FALSE); --- 239,701 ---- * attempt to use the home as a "stockpile", even though that is * not worth any money, since it may save us money eventually. */ + #if 0 + /* this optimized the home storage by trying every combination... it was too slow.*/ + /* put this code back when running this on a Cray. */ + static void borg_think_home_sell_aux2( int n, int start_i ) + { + int i; + /* All done */ + if (n == STORE_INVEN_MAX) + { + s32b home_power; + /* Examine the home */ + borg_notice_home(NULL, FALSE); + /* Evaluate the home */ + home_power = borg_power_home(); + + /* Track best */ + if (home_power > *b_home_power) + { + /* Save the results */ + for (i = 0; i < STORE_INVEN_MAX; i++) best[i] = test[i]; + + #if 0 + /* dump, for debugging */ + borg_note(format("Trying Combo (best home power %ld)", + *b_home_power)); + borg_note(format(" (test home power %ld)",home_power)); + for (i = 0; i < STORE_INVEN_MAX; i++) + { + if (auto_shops[7].ware[i].iqty) + borg_note(format("store %d %s (qty-%d).", i, + auto_shops[7].ware[i].desc, + auto_shops[7].ware[i].iqty )); + else + borg_note(format("store %d (empty).", i)); + } + borg_note(" "); /* add a blank line */ + #endif + + /* Use it */ + *b_home_power = home_power; + } + + /* Success */ + return; + } + + /* Note the attempt */ + test[n] = n; + + /* Evaluate the default item */ + borg_think_home_sell_aux2(n + 1, start_i ); + + /* if this slot and the previous slot is empty, move on to previous slot*/ + /* this will prevent trying a thing in all the empty slots to see if */ + /* empty slot b is better than empty slot a.*/ + if ((n != 0) && !auto_shops[7].ware[n].iqty && !auto_shops[7].ware[n-1].iqty) + return; + + /* try other combinations */ + for (i = start_i; i < INVEN_PACK; i++) + { + auto_item *item; + auto_item *item2; + bool stacked = FALSE; + + item = &auto_items[i]; + item2= &auto_shops[7].ware[n]; + + /* Skip empty items */ + /* Require "aware" */ + /* Require "known" */ + if (!item->iqty || !item->kind || !item->able) + continue; + + /* Hack -- ignore "worthless" items */ + if (!item->value) continue; + + /* stacking? */ + if (borg_object_similar(item2, item)) + { + item2->iqty++; + item->iqty--; + stacked = TRUE; + } + else + { + int k; + bool found_match = FALSE; + + /* eliminate items that would stack else where in the list. */ + for (k = 0; k < STORE_INVEN_MAX; k++) + { + if (borg_object_similar(&safe_home[k], item)) + { + found_match = TRUE; + break; + } + } + if (found_match) + continue; + + /* replace current item with this item */ + COPY(item2, item, auto_item); + + /* only move one into a non-stack slot */ + item2->iqty = 1; + + /* remove item from pack */ + item->iqty--; + } + + /* Note the attempt */ + test[n] = i + STORE_INVEN_MAX; + + /* Evaluate the possible item */ + borg_think_home_sell_aux2( n + 1, i+1 ); + + /* restore stuff */ + COPY(item2, &safe_home[n], auto_item); + + /* put item back into pack */ + item->iqty++; + } + } + #endif + /* ! * this will see what single addition/substitution is best for the home. ! * The formula is not as nice as the one above because it will ! * not check all possible combinations of items. but it is MUCH faster. */ ! static void borg_think_home_sell_aux2( int n, int start_i ) { ! auto_item *item; ! auto_item *item2; ! s32b home_power; ! int i, k; ! bool stacked = FALSE; ! /* get the starting best (current) */ ! /* Examine the home */ ! borg_notice_home(NULL, FALSE); ! /* Evaluate the home */ ! *b_home_power = borg_power_home(); + /* try individual substitutions/additions. */ + for (n = 0; n < STORE_INVEN_MAX; n++) + { + item2 = &auto_shops[7].ware[n]; + for (i = 0; i < INVEN_PACK; i++) + { + item = &auto_items[i]; ! /* Skip empty items */ ! /* Require "aware" */ ! /* Require "known" */ ! if (!item->iqty || !item->kind || !item->able) ! continue; + /* Hack -- ignore "worthless" items */ + if (!item->value) continue; ! /* stacking? */ ! if (borg_object_similar(item2, item)) ! { ! /* if this stacks with what was previously here */ ! item2->iqty++; ! stacked = TRUE; ! } ! else ! { ! bool found_match = FALSE; + /* eliminate items that would stack else where in the list. */ + for (k = 0; k < STORE_INVEN_MAX; k++) + { + if (borg_object_similar(&safe_home[k], item)) + { + found_match = TRUE; + break; + } + } + if (found_match) + continue; + /* replace current item with this item */ + COPY(item2, item, auto_item); + + /* only move one into a non-stack slot */ + item2->iqty = 1; + } + + /* remove item from pack */ + item->iqty--; + + /* Note the attempt */ + test[n] = i + STORE_INVEN_MAX; + + /* Test to see if this is a good substitution. */ /* Examine the home */ ! borg_notice_home(NULL, FALSE); /* Evaluate the home */ ! home_power = borg_power_home(); + /* Track best */ + if (home_power > *b_home_power) + { + /* Save the results */ + for (k = 0; k < STORE_INVEN_MAX; k++) best[k] = test[k]; ! #if 0 ! /* dump, for debugging */ ! borg_note(format("Trying Combo (best home power %ld)", ! *b_home_power)); ! borg_note(format(" (test home power %ld)", ! home_power)); ! for (i = 0; i < STORE_INVEN_MAX; i++) ! if (auto_shops[7].ware[i].iqty) ! borg_note(format("store %d %s (qty-%d).", i, ! auto_shops[7].ware[i].desc, ! auto_shops[7].ware[i].iqty )); ! else ! borg_note(format("store %d (empty).", i)); ! borg_note(" "); /* add a blank line */ ! #endif ! ! /* Use it */ ! *b_home_power = home_power; ! } ! ! /* restore stuff */ ! COPY(item2, &safe_home[n], auto_item); ! ! /* put item back into pack */ ! item->iqty++; ! ! /* put the item back in the test array */ ! test[n] = n; ! } ! } ! } ! ! static void borg_think_home_sell_aux3( ) ! { ! int i; ! s32b borg_empty_home_power; ! s32b power; ! ! /* get the starting power */ ! borg_notice(); ! power = borg_power(); ! ! /* get what an empty home would have for power */ ! borg_notice_home( NULL, TRUE ); ! borg_empty_home_power = borg_power_home(); ! ! /* go through the inventory and eliminate items that either */ ! /* 1) will not increase the power of an empty house. */ ! /* 2) will reduce borg_power if given to home */ for (i = 0; i < INVEN_PACK; i++) { ! int num_items_given; ! num_items_given = 0; ! /* if there is no item here, go to next slot */ ! if (!auto_items[i].iqty) ! continue; + /* 1) eliminate garbage items (items that add nothing to an */ + /* empty house) */ + borg_notice_home( &auto_items[i], FALSE ); + if (borg_power_home() <= borg_empty_home_power) + { + safe_items[i].iqty = 0; + continue; + } + + /* 2) will reduce borg_power if given to home */ + while (auto_items[i].iqty) + { + /* reduce inventory by this item */ + num_items_given++; + auto_items[i].iqty--; + + /* Examine borg */ + borg_notice(); + + /* done if this reduces the borgs power */ + if (borg_power() < power) + { + /* we gave up one to many items */ + num_items_given--; + break; + } + } + + /* restore the qty */ + auto_items[i].iqty = safe_items[i].iqty; + + /* set the qty to number given without reducing borg power */ + safe_items[i].iqty = num_items_given; + } + } + + /* + * Step 1 -- sell "useful" things to the home (for later) + */ + static bool borg_think_home_sell_aux( bool save_best ) + { + int icky = STORE_INVEN_MAX - 1; + + s32b home_power = -1L; + + int i, b_i = -1; + + byte test_a[STORE_INVEN_MAX]; + byte best_a[STORE_INVEN_MAX]; + + bool fix = FALSE; + + /* if the best is being saved (see borg_think_shop_grab_aux) */ + /* !FIX THIS NEEDS TO BE COMMENTED BETTER */ + if (!save_best) + b_home_power = &home_power; + test = test_a; + best = best_a; + + /* if I have not been to home, do not try this yet. */ + if (!auto_shops[7].when) return FALSE; + + /* Hack -- the home is full */ + /* and pack is full */ + if (auto_shops[7].ware[icky].iqty && + auto_items[INVEN_PACK-1].iqty) + return (FALSE); + + /* Copy all the store slots */ + for (i = 0; i < STORE_INVEN_MAX; i++) + { /* Save the item */ + COPY(&safe_home[i], &auto_shops[7].ware[i], auto_item); + + /* clear test arrays (test[i] == i is no change) */ + best[i] = test[i] = i; + } + + /* Hack -- Copy all the slots */ + for (i = 0; i < INVEN_PACK; i++) + { + /* Save the item */ COPY(&safe_items[i], &auto_items[i], auto_item); + } ! /* get rid of useless items */ ! borg_think_home_sell_aux3(); ! /* Examine the borg once more with full inventory then swap in the */ ! /* safe_items for the home optimization */ ! borg_notice(); ! /* swap quantities (this should be all that is different) */ ! for (i = 0; i < INVEN_PACK; i++) ! { ! byte save_qty; ! save_qty = safe_items[i].iqty; ! safe_items[i].iqty = auto_items[i].iqty; ! auto_items[i].iqty = save_qty; ! } ! *b_home_power = -1; ! /* find best combo for home. */ ! borg_think_home_sell_aux2( 0, 0 ); ! /* restore bonuses and such */ ! for (i = 0; i < STORE_INVEN_MAX; i++) ! { ! COPY(&auto_shops[7].ware[i], &safe_home[i], auto_item); ! } ! ! for (i = 0; i < INVEN_TOTAL; i++) ! { COPY(&auto_items[i], &safe_items[i], auto_item); + } ! borg_notice(); ! borg_notice_home(NULL, FALSE); ! /* Drop stuff that will stack in the home */ ! for (i = 0; i < STORE_INVEN_MAX; i++) ! { ! /* if this is not the item that was there, */ ! /* drop off the item that replaces it. */ ! if (best[i] != i && best[i] != 255) ! { ! auto_item *item = &auto_items[best[i]-STORE_INVEN_MAX]; ! auto_item *item2 = &auto_shops[7].ware[i]; ! /* if this item is not the same as what was */ ! /* there before take it. */ ! if (!borg_object_similar(item2, item)) ! continue; ! goal_shop = 7; ! goal_item = best[i] - STORE_INVEN_MAX; ! return (TRUE); } + } ! /* Get rid of stuff in house but not in 'best' house if */ ! /* pack is not full */ ! if (!auto_items[INVEN_PACK-1].iqty) ! { ! for (i = 0; i < STORE_INVEN_MAX; i++) ! { ! /* if this is not the item that was there, */ ! /* get rid of the item that was there */ ! if ((best[i] != i) && ! (auto_shops[7].ware[i].iqty)) ! { ! auto_item *item = &auto_items[best[i]-STORE_INVEN_MAX]; ! auto_item *item2 = &auto_shops[7].ware[i]; ! /* if this item is not the same as what was */ ! /* there before take it. */ ! if (borg_object_similar(item, item2)) ! continue; ! goal_shop = 7; ! goal_ware = i; ! return TRUE; ! } ! } ! } ! /*/ Drop stuff that is in best house but currently in inventory */ ! for (i = 0; i < STORE_INVEN_MAX; i++) { ! /* if this is not the item that was there, */ ! /* drop off the item that replaces it. */ ! if (best[i] != i && best[i] != 255) ! { goal_shop = 7; + goal_item = best[i] - STORE_INVEN_MAX; return (TRUE); } + } /* Assume not */ return (FALSE); *************** *** 168,176 **** /* Never sell worthless items */ if (item->value <= 0) return (FALSE); - /* Hack -- never sell artifacts */ - if (item->name1) return (FALSE); - /* Analyze the type */ switch (item->tval) { --- 712,717 ---- *************** *** 191,196 **** --- 732,738 ---- /* Never sell if not "known" */ if (!item->able) return (FALSE); + break; case TV_BOW: *************** *** 212,221 **** --- 754,796 ---- if (!item->able && !streq(item->note, "{average}") && !borg_item_icky(item)) return (FALSE); + /* do not sell things that are good/excelent/special until they */ + /* have been ID'd */ + if (item->able && (streq(item->note, "{good}") || + streq(item->note, "{excellent}") || + streq(item->note, "{special}"))) + return (FALSE); break; } + /* Do not sell stuff that is not fully id'd and should be */ + if (!item->fully_identified) + { + switch (item->name2) + { + /* Weapon (Blessed) */ + case EGO_BLESS_BLADE: + /* Robe of Permanance */ + case EGO_PERMANENCE: + /* Armor of Elvenkind */ + case EGO_ELVENKIND: + /* Crown of the Magi */ + case EGO_MAGI: + /* Cloak of Aman */ + case EGO_AMAN: + return (FALSE); + + /* Weapon (Holy Avenger) */ + case EGO_HA: + /* Weapon (Defender) */ + case EGO_DF: + /* anything else */ + default: + break; + } + } + /* Switch on the store */ switch (who + 1) { *************** *** 353,359 **** int k, b_k = -1; int i, b_i = -1; s32b p, b_p = 0L; ! s32b c, b_c = 0L; bool fix = FALSE; --- 928,935 ---- int k, b_k = -1; int i, b_i = -1; s32b p, b_p = 0L; ! s32b c = 0L; ! s32b b_c = 30001L; bool fix = FALSE; *************** *** 412,419 **** /* Extract the "price" */ c = ((item->value < 30000L) ? item->value : 30000L); ! /* Ignore "cheaper" items */ ! if ((p == b_p) && (c <= b_c)) continue; /* Maintain the "best" */ b_k = k; b_i = i; b_p = p; b_c = c; --- 988,996 ---- /* Extract the "price" */ c = ((item->value < 30000L) ? item->value : 30000L); ! /* sell cheap items first. This is done because we may have to */ ! /* buy the item back in some very strange cercemstances. */ ! if ((p == b_p) && (c >= b_c)) continue; /* Maintain the "best" */ b_k = k; b_i = i; b_p = p; b_c = c; *************** *** 450,455 **** --- 1027,1033 ---- * * We prevent the purchase of enchanted (or expensive) ammo, * so we do not spend all our money on temporary power. + * if below level 35, who needs cash? buy the expecive ammo! * * We prevent the purchase of low level discounted books, * so we will not waste slots on cheap books. *************** *** 469,476 **** --- 1047,1057 ---- case TV_SHOT: case TV_ARROW: case TV_BOLT: + if (auto_depth < 35) + { if (item->to_h) return (FALSE); if (item->to_d) return (FALSE); + } if (who == 6) return (FALSE); break; *************** *** 775,801 **** int n, b_n = -1; s32b s, b_s = 0L; s32b c, b_c = 0L; ! /* Hack -- the home is full */ ! if (auto_shops[7].ware[icky].iqty) return (FALSE); - /* Require two empty slots */ if (auto_items[INVEN_PACK-1].iqty) return (FALSE); if (auto_items[INVEN_PACK-2].iqty) return (FALSE); - /* Examine the home */ ! borg_notice_home(); /* Evaluate the home */ b_s = borg_power_home(); - - /* Save the store hole */ - COPY(&safe_shops[7].ware[icky], &auto_shops[7].ware[icky], auto_item); - /* Check the shops */ for (k = 0; k < 7; k++) { --- 1356,1379 ---- int n, b_n = -1; s32b s, b_s = 0L; s32b c, b_c = 0L; + s32b borg_empty_home_power; + /* get what an empty home would have for power */ + borg_notice_home( NULL, TRUE ); + borg_empty_home_power = borg_power_home(); ! b_home_power = &s; /* Require two empty slots */ if (auto_items[INVEN_PACK-1].iqty) return (FALSE); if (auto_items[INVEN_PACK-2].iqty) return (FALSE); /* Examine the home */ ! borg_notice_home(NULL, FALSE); /* Evaluate the home */ b_s = borg_power_home(); /* Check the shops */ for (k = 0; k < 7; k++) { *************** *** 813,839 **** /* Hack -- Require some "extra" cash */ if (auto_gold < 1000L + item->cost * 5) continue; ! /* Save shop item */ ! COPY(&safe_shops[k].ware[n], &auto_shops[k].ware[n], auto_item); - /* Give the item to the shop */ - COPY(&auto_shops[7].ware[icky], &auto_shops[k].ware[n], auto_item); - /* Give a single item */ ! auto_shops[7].ware[icky].iqty = 1; ! /* Remove one item from shop */ ! auto_shops[k].ware[n].iqty--; ! /* Examine the home */ ! borg_notice_home(); - /* Evaluate the home */ - s = borg_power_home(); - - /* Restore shop item */ - COPY(&auto_shops[k].ware[n], &safe_shops[k].ware[n], auto_item); - /* Obtain the "cost" of the item */ c = item->cost; --- 1391,1411 ---- /* Hack -- Require some "extra" cash */ if (auto_gold < 1000L + item->cost * 5) continue; ! /* make this the next to last item that the player has */ ! /* (can't make it the last or it thinks that both player and */ ! /* home are full) */ ! COPY(&auto_items[INVEN_PACK-2], &auto_shops[k].ware[n], auto_item); /* Give a single item */ ! auto_items[INVEN_PACK-2].iqty = 1; ! /* make sure this item would help an empty home */ ! borg_notice_home( &auto_shops[k].ware[n], FALSE ); ! if (borg_empty_home_power >= borg_power_home()) continue; ! /* optimize the home inventory */ ! if (!borg_think_home_sell_aux( TRUE )) continue; /* Obtain the "cost" of the item */ c = item->cost; *************** *** 851,865 **** } } ! /* Restore the store hole */ ! COPY(&auto_shops[7].ware[icky], &safe_shops[7].ware[icky], auto_item); /* Examine the home */ ! borg_notice_home(); /* Evaluate the home */ s = borg_power_home(); /* Buy something */ if ((b_k >= 0) && (b_n >= 0)) { --- 1423,1441 ---- } } ! /* restore inventory hole (just make sure the last slot goes back to */ ! /* empty) */ ! auto_items[INVEN_PACK-2].iqty = 0; /* Examine the home */ ! borg_notice_home(NULL, FALSE); /* Evaluate the home */ s = borg_power_home(); + /* remove the target that optimizing the home gave */ + goal_shop = goal_ware = goal_item = -1; + /* Buy something */ if ((b_k >= 0) && (b_n >= 0)) { *************** *** 893,899 **** /* Examine the home */ ! borg_notice_home(); /* Evaluate the home */ b_s = borg_power_home(); --- 1469,1475 ---- /* Examine the home */ ! borg_notice_home(NULL, FALSE); /* Evaluate the home */ b_s = borg_power_home(); *************** *** 914,920 **** auto_shops[7].ware[n].iqty--; /* Examine the home */ ! borg_notice_home(); /* Evaluate the home */ s = borg_power_home(); --- 1490,1496 ---- auto_shops[7].ware[n].iqty--; /* Examine the home */ ! borg_notice_home(NULL, FALSE); /* Evaluate the home */ s = borg_power_home(); *************** *** 930,936 **** } /* Examine the home */ ! borg_notice_home(); /* Evaluate the home */ s = borg_power_home(); --- 1506,1512 ---- } /* Examine the home */ ! borg_notice_home(NULL, FALSE); /* Evaluate the home */ s = borg_power_home(); *************** *** 975,980 **** --- 1551,1559 ---- if (!shop->when) return (FALSE); } + /* if we are already flowing toward a shop do not check again... */ + if (goal_shop != -1) + return TRUE; /* Assume no important shop */ goal_shop = goal_ware = goal_item = -1; *************** *** 981,991 **** /* Step 1 -- Sell items to the home */ ! if (borg_think_home_sell_aux()) { /* Message */ borg_note(format("# Selling '%s' to the home", auto_items[goal_item].desc)); /* Success */ return (TRUE); --- 1560,1574 ---- /* Step 1 -- Sell items to the home */ ! if (borg_think_home_sell_aux( FALSE )) { /* Message */ + if (goal_item != -1) borg_note(format("# Selling '%s' to the home", auto_items[goal_item].desc)); + else + borg_note(format("# Buying '%s' from the home", + auto_shops[goal_shop].ware[goal_ware].desc)); /* Success */ return (TRUE); *************** *** 1009,1015 **** if (borg_think_shop_buy_aux()) { /* Message */ ! borg_note(format("# Buying '%s' at '%s'", auto_shops[goal_shop].ware[goal_ware].desc, (f_name + f_info[0x08+goal_shop].name))); --- 1592,1598 ---- if (borg_think_shop_buy_aux()) { /* Message */ ! borg_note(format("# Buying '%s' at '%s' (for player)", auto_shops[goal_shop].ware[goal_ware].desc, (f_name + f_info[0x08+goal_shop].name))); *************** *** 1029,1060 **** return (TRUE); } ! ! /* Step 5 -- Buy items from the shops (for the home) */ ! if (borg_think_shop_grab_aux()) { /* Message */ ! borg_note(format("# Grabbing '%s' at '%s'", ! auto_shops[goal_shop].ware[goal_ware].desc, ! (f_name + f_info[0x08+goal_shop].name))); /* Success */ return (TRUE); } ! ! /* Step 6 -- Grab items from the home (for the shops) */ ! if (borg_think_home_grab_aux()) { /* Message */ ! borg_note(format("# Grabbing '%s' from the home", ! auto_shops[goal_shop].ware[goal_ware].desc)); /* Success */ return (TRUE); } - /* Failure */ return (FALSE); } --- 1612,1644 ---- return (TRUE); } ! /* get rid of junk from home first. That way the home is 'uncluttered' */ ! /* before you buy stuff for it. This will prevent the problem where an */ ! /* item has become a negative value and swapping in a '0' gain item */ ! /* (like pottery) is better. */ ! /* Step 5 -- Grab items from the home (for the shops) */ ! if (borg_think_home_grab_aux()) { /* Message */ ! borg_note(format("# Grabbing (to sell) '%s' from the home", ! auto_shops[goal_shop].ware[goal_ware].desc)); /* Success */ return (TRUE); } ! /* Step 6 -- Buy items from the shops (for the home) */ ! if (borg_think_shop_grab_aux()) { /* Message */ ! borg_note(format("# Grabbing (for home) '%s' at '%s'", ! auto_shops[goal_shop].ware[goal_ware].desc, ! (f_name + f_info[0x08+goal_shop].name))); /* Success */ return (TRUE); } /* Failure */ return (FALSE); } *************** *** 1070,1081 **** /* Sell something if requested */ if ((goal_shop == shop_num) && (goal_item >= 0)) { - auto_item *item = &auto_items[goal_item]; - - #if 0 auto_shop *shop = &auto_shops[goal_shop]; - #endif /* Log */ borg_note(format("# Selling %s", item->desc)); --- 1654,1663 ---- /* Sell something if requested */ if ((goal_shop == shop_num) && (goal_item >= 0)) { auto_shop *shop = &auto_shops[goal_shop]; + auto_item *item = &auto_items[goal_item]; + /* Log */ borg_note(format("# Selling %s", item->desc)); *************** *** 1156,1161 **** --- 1738,1746 ---- */ bool borg_think_store(void) { + /* Stamp the shop with a time stamp */ + auto_shops[shop_num].when = c_t; + /* Remove "backwards" rings */ if (borg_swap_rings()) return (TRUE); *************** *** 1181,1189 **** if (borg_think_shop_buy()) return (TRUE); } - /* Stamp the shop with a time stamp */ - auto_shops[shop_num].when = c_t; - /* No shop */ shop_num = -1; --- 1766,1771 ---- *************** *** 1229,1236 **** if (goal_fleeing || goal_leaving) { /* Hack -- Take the next stairs */ ! stair_less = stair_more = TRUE; /* Continue fleeing the level */ if (borg_flow_old(GOAL_FLEE)) return (TRUE); --- 1811,1825 ---- if (goal_fleeing || goal_leaving) { /* Hack -- Take the next stairs */ ! stair_less = goal_fleeing; ! if (borg_ready_morgoth == 0) ! stair_less = TRUE; + /* Only go down if fleeing or prepared. */ + stair_more = goal_fleeing; + if ((cptr)NULL == borg_prepared(auto_depth+1)) + stair_more = TRUE; + /* Continue fleeing the level */ if (borg_flow_old(GOAL_FLEE)) return (TRUE); *************** *** 1287,1292 **** --- 1876,1972 ---- /* + * Check a 'hidden' stat + * + * if we need to check our stats still that is because the stat + * was above 18/220 so we need to take off some stuff to check + * what our *real* base stat is. + * + * If we do not have a free slot, this is dangerious because we may + * drop our stuff. It is better to drop the stuff than to take + * the chance that we would take off our ring of int +6 then crush it + * because we are full. + */ + static bool borg_check_stats() + { + int i, x; + int sv_p = -1, b_x = -1; + + /* check to make sure one stat needs checking */ + if (!my_need_stat_check[0] && + !my_need_stat_check[1] && + !my_need_stat_check[2] && + !my_need_stat_check[3] && + !my_need_stat_check[4] && + !my_need_stat_check[5]) return (FALSE); + + /* if in any danger, do this later. The guess that we */ + /* did for our stat will do for now.*/ + if (borg_danger(c_y, c_x, 3) > 0) return (FALSE); + + /* Check the equiptment for anything that is not ID'd yet. */ + /* do not check stats until everything you have on is ID'd */ + for (i = INVEN_WIELD; i < INVEN_TOTAL; i++) + { + auto_item *item = &auto_items[i]; + + /* Skip empty items */ + if (!item->iqty) continue; + + /* if we have on unidentified stuff we may have misguessed or */ + /* stats. */ + if (!item->able) return (FALSE); + } + + /* look for a stat that needs to be checked */ + for (i = 0; i < 6; i++) + { + if (!my_need_stat_check[i]) continue; + + /* look for an item that is giving that stat a bonus */ + for (x = INVEN_WIELD; x < INVEN_TOTAL; x ++) + { + auto_item *item = &auto_items[x]; + + /* Skip empty slots */ + if (!item->iqty) continue; + + /* If this item does not give a bonus to the stat we */ + /* are checking get the next item. */ + if (!(item->flags1 & TR1_STR) && i == 0) continue; + if (!(item->flags1 & TR1_INT) && i == 1) continue; + if (!(item->flags1 & TR1_WIS) && i == 2) continue; + if (!(item->flags1 & TR1_DEX) && i == 3) continue; + if (!(item->flags1 & TR1_CON) && i == 4) continue; + if (!(item->flags1 & TR1_CHR) && i == 5) continue; + + /* save the item with the highest bonus */ + if (item->pval > sv_p) + { + sv_p = item->pval; + b_x = x; + } + } + + /* Make sure we found an item */ + if (b_x == -1) return (FALSE); + + /* Log */ + borg_note(format("# Taking off %s. (to check stats)", + auto_items[b_x].desc)); + + /* Take the item off. When it is off our stat will be less than */ + /* 18/220 (hopefully) and borg_hidden will guess the right value. */ + borg_keypress('t'); + borg_keypress(I2A(b_x - INVEN_WIELD)); + + return (TRUE); + } + return (FALSE); + } + + + /* * Perform an action in the dungeon * * Return TRUE if a "meaningful" action was performed *************** *** 1353,1359 **** } /* Avoid annoying farming */ ! if (c_t - auto_began >= 5000) { /* Ignore monsters from boredom */ if (!goal_ignoring) --- 2033,2039 ---- } /* Avoid annoying farming */ ! if (c_t - auto_began >= 2000) { /* Ignore monsters from boredom */ if (!goal_ignoring) *************** *** 1435,1440 **** --- 2115,2123 ---- /* Try not to die */ if (borg_caution()) return (TRUE); + /* I may need to strip off some stuff to check my stats. */ + if (borg_check_stats()) return (TRUE); + /* Wear things that need to be worn */ if (borg_wear_stuff()) return (TRUE); *************** *** 1463,1470 **** if (borg_use_things()) return (TRUE); /* Identify unknown things */ ! if (borg_test_stuff()) return (TRUE); /* Enchant things */ if (borg_enchanting()) return (TRUE); --- 2146,2156 ---- if (borg_use_things()) return (TRUE); /* Identify unknown things */ ! if (borg_test_stuff(FALSE)) return (TRUE); + /* *Id* unknown things */ + if (borg_test_stuff(TRUE)) return (TRUE); + /* Enchant things */ if (borg_enchanting()) return (TRUE); *************** *** 1484,1490 **** /*** Flee the level XXX XXX XXX ***/ /* Flee the level */ ! if (goal_fleeing) { /* Hack -- Take the next stairs */ stair_less = stair_more = TRUE; --- 2170,2176 ---- /*** Flee the level XXX XXX XXX ***/ /* Flee the level */ ! if (goal_fleeing && !goal_recalling) { /* Hack -- Take the next stairs */ stair_less = stair_more = TRUE; *************** *** 1512,1522 **** /*** Leave the level XXX XXX XXX ***/ /* Leave the level */ ! if (goal_leaving) { /* Hack -- Take the next stairs */ ! stair_less = stair_more = TRUE; /* Continue leaving the level */ if (borg_flow_old(GOAL_FLEE)) return (TRUE); --- 2198,2213 ---- /*** Leave the level XXX XXX XXX ***/ /* Leave the level */ ! if (goal_leaving && !goal_recalling) { /* Hack -- Take the next stairs */ ! if (borg_ready_morgoth == 0) ! stair_less = TRUE; + /* Only go down if fleeing or prepared. */ + if ((cptr)NULL == borg_prepared(auto_depth+1)) + stair_more = TRUE; + /* Continue leaving the level */ if (borg_flow_old(GOAL_FLEE)) return (TRUE); *************** *** 1548,1559 **** /* Chase old monsters */ if (borg_flow_kill(FALSE)) return (TRUE); - /* Explore interesting grids */ - if (borg_flow_dark(TRUE)) return (TRUE); - /* Chase old objects */ if (borg_flow_take(FALSE)) return (TRUE); /* Leave the level (if needed) */ if (borg_leave_level(FALSE)) return (TRUE); --- 2239,2250 ---- /* Chase old monsters */ if (borg_flow_kill(FALSE)) return (TRUE); /* Chase old objects */ if (borg_flow_take(FALSE)) return (TRUE); + /* Explore interesting grids */ + if (borg_flow_dark(TRUE)) return (TRUE); + /* Leave the level (if needed) */ if (borg_leave_level(FALSE)) return (TRUE); *************** *** 1578,1584 **** /*** Leave the Level ***/ /* Study/Test boring spells/prayers */ ! if (borg_play_magic(FALSE)) return (TRUE); /* Search for secret doors */ if (borg_flow_spastic(FALSE)) return (TRUE); --- 2269,2275 ---- /*** Leave the Level ***/ /* Study/Test boring spells/prayers */ ! if (borg_play_magic(TRUE)) return (TRUE); /* Search for secret doors */ if (borg_flow_spastic(FALSE)) return (TRUE); *************** *** 1607,1615 **** return (TRUE); } - /*** Nothing to do ***/ /* Start leaving */ if (!goal_leaving) { --- 2298,2322 ---- return (TRUE); } /*** Nothing to do ***/ + borg_times_twitch++; + /* Teleport to get out of being twitchy up to 5 times per level. */ + if (borg_times_twitch < 5) + { + borg_note("# Teleport (twitchy)"); + + /* Teleport */ + if ( borg_spell(1, 5) || + borg_prayer(4, 1) || + borg_prayer(1, 1) || + borg_use_staff(SV_STAFF_TELEPORTATION)) + { + /* Success */ + return (TRUE); + } + } + /* Start leaving */ if (!goal_leaving) { *************** *** 1628,1636 **** /* Start fleeing */ goal_fleeing = TRUE; - - /* Fear this depth */ - auto_fear_depth[auto_depth] = TRUE; } /* Recall to town */ --- 2335,2340 ---- *************** *** 1755,1764 **** } #else #ifdef MACINTOSH static int HACK = 0; ! #endif /* MACINTOSH */ ! #endif /* ALLOW_BORG */ --- 2459,2469 ---- } + #else #ifdef MACINTOSH static int HACK = 0; ! #endif ! #endif diff -w -c -r Borg/borg9.c adamborg/borg9.c *** Borg/borg9.c Sun Apr 13 23:23:07 1997 --- adamborg/borg9.c Sun Apr 13 23:27:48 1997 *************** *** 18,32 **** #include "borg8.h" #include "borg9.h" /* ! * The "Angband Borg" is an automatic Angband player. * ! * Use of the Borg requires re-compilation with ALLOW_BORG defined, ! * and linking the various "borg source files" into the executable. * ! * The "borg source files" have been updated for use with Angband 2.8.2, ! * and will not work with any other version without (minor) modifications. * * Note that you can only use the Borg if your character has been marked * as a "Borg User". You can do this, if necessary, by responding "y" --- 18,32 ---- #include "borg8.h" #include "borg9.h" + bool borg_cheat_death; /* ! * This file implements the "Ben Borg", an "Automatic Angband Player". * ! * This version of the "Ben Borg" is designed for use with Angband 2.7.9v6. * ! * Use of the "Ben Borg" requires re-compilation with ALLOW_BORG defined, ! * and with the various "borg*.c" files linked into the executable. * * Note that you can only use the Borg if your character has been marked * as a "Borg User". You can do this, if necessary, by responding "y" *************** *** 34,164 **** * result in your character being inelligible for the high score list. * * The "do_cmd_borg()" function, called when the user hits "^Z", allows ! * the user to interact with the Borg, by entering a "borg-command" when ! * prompted. Any borg-command (except escape) will cause the Borg to be ! * initialized (if needed), and then the borg-command will be executed. * ! * The first time you enter any borg-command, the Borg is initialized. ! * This consists of three major steps, and requires at least 400K of ! * free memory. If enough memory is not available, the game may abort. ! * First, the various "borg" modules are initialized. Second, various ! * important "state" information is extracted, including the level and ! * race/class of the player, and this information is used to perform ! * more initialization. Third, some "historical" information (killed ! * uniques, maximum dungeon depth, etc) is "stolen" from the game. * ! * The simplest borg-command is "z", which "activates" the Borg, causing it ! * to take control of the character, and play the game, until you hit a key. ! * Other borg-commands, including "?", are described in "do_cmd_borg()". * ! * When the Borg is "activated", it uses the "Term_inkey_hook" to steal ! * control from the user. Later, if it detects any input from the user, ! * it gracefully relinquishes control by clearing the "Term_inkey_hook" ! * after any pending borg-key-sequences are complete. * ! * The Borg will abort if it detects any errors (such as bizarre screens), ! * strange situations (such as death), or panic situations (such as being ! * about to die), if the appropriate flags are set. * ! * The Borg is only supposed to "know" what a human playing the game could ! * know, that is, observe the information actually displayed on the screen, ! * and is only supposed to "do" the things that a human playing the game ! * could do, that is, send keypresses to the game. * ! * The Borg uses the "z-term.c" package to "look" at the screen, using ! * the screen access function "Term_what()", the cursor location function ! * "Term_locate()", and the cursor visibility function "Term_get_cursor()". ! * Actually, it uses inline versions of these functions (for efficiency). ! * This is very similar to what a human does, except that a human must ! * actually mentally convert visual impulses into colored symbols. * ! * The Borg uses a special hook in the "z-term.c" package to allow it to ! * "steal" control from the "Term_inkey()" and "Term_flush()" functions, ! * and to "send" keypress events as if it was a normal user. This is not ! * quite what a human does, in particular, by stealing control in such a ! * manner, the Borg is able to know exactly when the game is waiting for ! * a keypress, which allows it to know when the screen has finished ! * being refreshed. * ! * If the code wqs properly designed, that is, if the Borg actually acted ! * just like a real human player, then it could, in theory, be run as an ! * external process, which would actually examine a physical display and ! * send keypresses directly to a physical keyboard, or at least (to avoid ! * the need for a camera and a robotic arm), which would run the game in ! * a "pseudo-terminal", allowing it to examine the current screen image ! * and send keypress events to the underlying process (the Angband Game). * ! * Currently, the code is *not* properly designed, that is, there are a ! * few places in which it does things which a human would not be able to ! * do, such as examine (and even change) the values of certain variables ! * private to the game. However, there are very few of these places, so ! * with a little work, it should be possible for the Borg to actually ! * simulate a real human player. All known "problems" are listed below, ! * and note that almost all of them would disappear if the Borg was made ! * into a separate executable and taught to generate its own character, ! * and to determine when the game was ready for a keypress. * ! * A major problem is that the Borg "knows" when the game is waiting for ! * a keypress. There is no single solution for this problem, since even ! * humans sometimes get confused when playing over a very slow connection. ! * There are some heuristics which would probably be sufficient, including ! * waiting until the screen does not change for a full second, and assuming ! * that it is therefore waiting for input, or using clever choices of some ! * "free" commands, such as the "note" command, to allow the Borg to cause ! * special things to appear on the screen when the game is ready for the ! * next command. The hardest thing would actually be making sure that all ! * possible situations were accounted for. * ! * A minor problem is that the Borg must assume that a human has already ! * created a character, and set up various options and such so that the ! * Borg can function correctly. Currently, to avoid crashing if these ! * assumptions are incorrect, the code actually sets some options and ! * such to known values, and redraws the screen using the new options, ! * any time a human user asks the Borg to initialize or resume playing. ! * Since a human may, at any time, take over and perform arbitrary acts, ! * and since the Borg does not actually generate the character, currently, ! * when the Borg is initialized (or restarted) it "steals" some important ! * values directly from the game, including the deepest level which has ! * been explored, and which uniques are known to have been killed. Other ! * values which could be stolen are actually extracted from the screen, ! * such as the race and class of the character. All of these problems ! * would go away if the Borg generated the character and knew that nobody ! * else was going to use the character file. Note that certain options ! * cannot be changed by the Borg, including "preserve" mode and "maximize" ! * mode, which are determined when the character is created. If "preserve" ! * mode is not true, then the Borg may lose some artifacts. If "maximize" ! * mode is not false, then the Borg may break in unexpected ways. * ! * There are several things that the current Borg code is "able" to learn ! * without "cheating", such as the descriptions of all of the equipment ! * and inventory items, information about each available spell or prayer, ! * and the location of the current panel relative to the overall dungeon, ! * by actually sending various keypresses to the game and observing the ! * results, but this is *extremely* annoying to watch, so by default, this ! * code is not used, and the Borg uses special "cheat" code to obtain this ! * information directly from the game. * ! * There are several pieces of information about the game that are used ! * directly by the current Borg code, including some of the tables in the ! * "tables.c" file, and some of the static arrays of information which are ! * initialized in the "init1.c" and "init2.c" files, but note that this is ! * not cheating, since if the Borg was compiled into a separate executable, ! * it would simply use these files directly. * ! * Note that the Borg can play any race/class combination, that is, he can ! * make "effective" use of at least a few spells/prayers, and is not "broken" ! * by low strength, blind-ness, hallucination, etc. This does not, however, ! * mean that he plays all classes equally well, especially since he is so ! * dependant on a high strength for so many things. * ! * Note that the Borg understands the "cheat_live" flag, and if it is set, ! * he will automatically "cheat death" whenever he dies. If this flag is ! * not set, then the Borg will automatically stop playing as soon as the ! * special "You die." message appears, allowing the human user to observe ! * the tombstone screen if desired. Currently, the "cheat_live" flag is ! * pretty much required for low level mage characters, since they almost ! * always die once or twice before they become strong enough to survive. * * Note that the "c_t" parameter bears a close resemblance to the number of * "player turns" that have gone by. Except that occasionally, the Borg will * do something that he *thinks* will take time but which actually does not --- 34,127 ---- * result in your character being inelligible for the high score list. * * The "do_cmd_borg()" function, called when the user hits "^Z", allows ! * the user to interact with the Borg. You do so by typing "Borg Commands", ! * including 'z' to activate (or re-activate), 'K' to show monsters, 'T' to ! * show objects, 'd' to toggle "demo mode", 'f' to open/shut the "log file", ! * 'i' to display internal flags, etc. See "do_cmd_borg()" for more info. * ! * The first time you enter a Borg command, the Borg is initialized. This ! * consists of three major steps, and requires at least 400K of free memory, ! * if the memory is not available, the game may abort. * ! * (1) The various "borg" modules are initialized. * ! * (2) Some important "state" information is extracted, including the level ! * and race/class of the player, and some more initialization is done. * ! * (3) Some "historical" information (killed uniques, maximum dungeon depth) ! * is "stolen" from the game. * ! * When the Ben Borg is "activated", it uses the "Term_inkey_hook" to steal ! * control from the user. Later, if it detects any input from the real user, ! * it gracefully relinquishes control by clearing the "Term_inkey_hook" after ! * any pending key-sequences are complete. * ! * The Borg will abort if it detects any "errors", or if it detects any ! * "situations" such as "death", or if it detects any "panic" situations, ! * such as "imminent death", if the appropriate flags are set. * ! * The Ben Borg is only supposed to "know" what is visible on the screen, ! * which it learns by using the "term.c" screen access function "Term_what()", ! * the cursor location function "Term_locate()", and the cursor visibility ! * extraction function "Term_get_cursor()". * ! * The Ben Borg is only supposed to "send" keypresses when the "Term_inkey()" ! * function asks for a keypress, which is accomplished by using a special ! * function hook in the "z-term.c" file, which allows the Borg to "steal" ! * control from the "Term_inkey()" and "Term_flush()" functions. This ! * allows the Ben Borg to pretend to be a normal user. * ! * Note that if properly designed, the Ben Borg could be run as an external ! * process, which would actually examine the screen (or pseudo-terminal), ! * and send keypresses directly to the keyboard (or pseudo-terminal). Thus ! * it should never access any "game variables", unless it is able to extract ! * those variables for itself by code duplication or complex interactions, ! * or, in certain situations, if those variables are not actually "required". * ! * Currently, the Ben Borg is a few steps away from being able to be run as ! * an external process, primarily in the "low level" details, such as knowing ! * when the game is ready for a keypress. Also, the Ben Borg assumes that a ! * character has already been rolled, and maintains no state between saves, ! * which is partially offset by "cheating" to "acquire" the maximum dungeon ! * depth, without which equipment analysis will be faulty. * ! * The "theory" behind the Borg is that is should be able to run as a ! * separate process, playing Angband in a window just like a human, that ! * is, examining the screen for information, and sending keypresses to ! * the game. The current Borg does not actually do this, because it would ! * be very slow and would not run except on Unix machines, but as far as ! * possible, I have attempted to make sure that the Borg *could* run that ! * way. This involves "cheating" as little as possible, where "cheating" ! * means accessing information not available to a normal Angband player. ! * And whenever possible, this "cheating" should be optional, that is, ! * there should be software options to disable the cheating, and, if ! * necessary, to replace it with "complex" parsing of the screen. * ! * Thus, the Borg COULD be written as a separate process which runs Angband ! * in a pseudo-terminal and "examines" the "screen" and sends keypresses ! * directly (as with a terminal emulator), although it would then have ! * to explicitly "wait" to make sure that the game was completely done ! * sending information. * ! * The Borg is thus allowed to examine the screen directly (by efficient ! * direct access of the "Term->scr->a" and "Term->scr->c" arrays, which ! * could be replaced by calls to "Term_grab()"), and to access the cursor ! * location (via "Term_locate()") and visibility (via "Term_get_cursor()"), ! * and, as mentioned above, the Borg is allowed to send keypresses directly ! * to the game, and only when needed, using the "Term_inkey_hook" hook, and ! * uses the same hook to know when it should discard all pending keypresses. * ! * The Borg should not know when the game is ready for a keypress, and ! * should really do something nasty such as "pause" between turns for ! * some amount of time to ensure that the game is really waiting for ! * a keypress. * ! * Various other "cheats" (mostly optional) are described where they are ! * used, primarily in this file. * + * Note that any "user input" will be ignored, and will cancel the Borg, + * after the Borg has completed any key-sequences currently in progress. + * * Note that the "c_t" parameter bears a close resemblance to the number of * "player turns" that have gone by. Except that occasionally, the Borg will * do something that he *thinks* will take time but which actually does not *************** *** 168,202 **** * that the "c_t" variable is slightly lacking in "precision". Note that * we can store every time-stamp in a 's16b', since we reset the clock to * 1000 on each new level, and we refuse to stay on any level longer than ! * 30000 turns, unless we are totally stuck, in which case we abort. This ! * almost never happens unless the Borg is permanently paralyzed, or is in ! * a corner surrounded by lice with no means of escape, or runs out of light ! * in a dark hallway and cannot find the stairs. ! */ ! ! ! /* ! * Stat advantages: ! * High STR (attacks, to-dam, digging, weight limit) ! * High DEX (attacks, to-hit, armor class) ! * High CON (hitpoints, recovery) ! * High WIS (better prayers, saving throws) ! * High INT (better spells, disarming, device usage) ! * High CHR (better item costs) * ! * Class advantages: ! * Warrior (good fighting, sensing) ! * Mage (good spells) ! * Priest (good prayers, fighting) ! * Ranger (some spells, fighting) ! * Rogue (some spells, fighting, sensing) ! * Paladin (prayers, fighting, sensing) * ! * Race advantages: ! * Gnome (free action) ! * Dwarf (resist blindness) ! * High elf (see invisible) ! * Non-human (infravision) */ --- 131,150 ---- * that the "c_t" variable is slightly lacking in "precision". Note that * we can store every time-stamp in a 's16b', since we reset the clock to * 1000 on each new level, and we refuse to stay on any level longer than ! * 30000 turns, unless we are totally stuck, in which case we abort. * ! * Note that as of 2.7.9, the Borg can play any class, that is, he can make ! * "effective" use of at least a few spells/prayers, and is not "broken" ! * by low strength, blind-ness, hallucination, etc. This does not, however, ! * mean that he plays all classes equally well, especially since he is so ! * dependant on a high strength for so many things. The "demo" mode is useful ! * for many classes (especially Mage) since it allows the Borg to "die" a few ! * times, without being penalized. * ! * The Borg assumes that the "maximize" flag is off, and that the ! * "preserve" flag is on, since he cannot actually set those flags. ! * If the "maximize" flag is on, the Borg may not work correctly. ! * If the "preserve" flag is off, the Borg may miss artifacts. */ *************** *** 303,311 **** --- 251,317 ---- */ + /* + * Currently, the Borg "cheats" in a few situations... + * + * Cheats that are significant, and possibly unavoidable: + * Knowledge of when we are being asked for a keypress. + * Note that this could be avoided by LONG timeouts/delays + * + * Cheats "required" by implementation, but not signifant: + * Direct access to the "screen image" (parsing screen) + * Direct access to the "keypress queue" (sending keys) + * Direct access to the "cursor visibility" (game state) + * + * Cheats that could be avoided by simple (ugly) code: + * Direct modification of the "current options" + * + * Cheats that could be avoided by duplicating code: + * Use of the tables in "tables.c" + * Use of the arrays initialized in "init.c" + * + * Cheats that can be avoided by toggling a switch: + * Direct extraction of "panel" info (auto_cheat_panel) + * Direct extraction of "inven" info (auto_cheat_inven) + * Direct extraction of "equip" info (auto_cheat_equip) + * Direct extraction of "spell" info (auto_cheat_spell) + * + * Cheats that the Borg would love: + * Immunity to hallucination, blindness, confusion + * Unique attr/char codes for every monster and object + * Removal of the "mimic" and "trapper" monsters + * Removal of the "mushroom" and "gold" monsters + */ /* + * Stat advantages: + * High STR (attacks, to-dam, digging, weight limit) + * High DEX (attacks, to-hit, armor class) + * High CON (hitpoints, recovery) + * High WIS (better prayers, saving throws) + * High INT (better spells, disarming, device usage) + * High CHR (better item costs) + * + * Class advantages: + * Warrior (good fighting, sensing) + * Mage (good spells) + * Priest (good prayers, fighting) + * Ranger (some spells, fighting) + * Rogue (some spells, fighting, sensing) + * Paladin (prayers, fighting, sensing) + * + * Race advantages: + * Gnome (free action) + * Dwarf (resist blindness) + * High elf (see invisible) + * Non-human (infravision) + */ + + + + + /* * Some variables */ *************** *** 317,336 **** * Mega-Hack -- extract some "hidden" variables * * XXX XXX XXX This step would not be necessary if more info ! * was available on the screen. Perhaps we should track the ! * maximal value of "my_stat_cur" so we have "my_stat_max". */ static void borg_hidden(void) { int i; ! int stat_add[6]; ! ! /* Clear "stat_add[]" */ ! for (i = 0; i < 6; i++) stat_add[i] = 0; ! ! /* Scan the equipment */ for (i = INVEN_WIELD; i < INVEN_TOTAL; i++) { auto_item *item = &auto_items[i]; --- 323,339 ---- * Mega-Hack -- extract some "hidden" variables * * XXX XXX XXX This step would not be necessary if more info ! * was available on the screen. ! * */ static void borg_hidden(void) { int i; ! /* Clear the stat modifiers */ ! for (i = 0; i < 6; i++) my_stat_add[i] = 0; ! /* Scan the usable inventory */ for (i = INVEN_WIELD; i < INVEN_TOTAL; i++) { auto_item *item = &auto_items[i]; *************** *** 338,350 **** /* Skip empty items */ if (!item->iqty) continue; /* Affect stats */ ! if (item->flags1 & TR1_STR) stat_add[A_STR] += item->pval; ! if (item->flags1 & TR1_INT) stat_add[A_INT] += item->pval; ! if (item->flags1 & TR1_WIS) stat_add[A_WIS] += item->pval; ! if (item->flags1 & TR1_DEX) stat_add[A_DEX] += item->pval; ! if (item->flags1 & TR1_CON) stat_add[A_CON] += item->pval; ! if (item->flags1 & TR1_CHR) stat_add[A_CHR] += item->pval; } /* Mega-Hack -- Guess at "my_stat_cur[]" */ --- 341,366 ---- /* Skip empty items */ if (!item->iqty) continue; + /* if we have on unidentified stuff we may have misguessed our */ + /* stats. */ + if (!item->able) + { + my_need_stat_check[0] = TRUE; + my_need_stat_check[1] = TRUE; + my_need_stat_check[2] = TRUE; + my_need_stat_check[3] = TRUE; + my_need_stat_check[4] = TRUE; + my_need_stat_check[5] = TRUE; + break; + } + /* Affect stats */ ! if (item->flags1 & TR1_STR) my_stat_add[A_STR] += item->pval; ! if (item->flags1 & TR1_INT) my_stat_add[A_INT] += item->pval; ! if (item->flags1 & TR1_WIS) my_stat_add[A_WIS] += item->pval; ! if (item->flags1 & TR1_DEX) my_stat_add[A_DEX] += item->pval; ! if (item->flags1 & TR1_CON) my_stat_add[A_CON] += item->pval; ! if (item->flags1 & TR1_CHR) my_stat_add[A_CHR] += item->pval; } /* Mega-Hack -- Guess at "my_stat_cur[]" */ *************** *** 352,364 **** { int value; ! /* Hack -- reverse the known bonus */ ! value = modify_stat_value(auto_stat[i], -stat_add[i]); /* Hack -- save the maximum/current stats */ ! my_stat_max[i] = my_stat_cur[i] = value; } } --- 368,408 ---- { int value; ! if (!my_need_stat_check[i]) continue; + /* Reverse known bonuses to get the base stat value */ + value = modify_stat_value(auto_stat[i], -my_stat_add[i]); + + /* If the displayed stat is 18/220 this was just a guess. */ + /* The player still needs to take off some stuff to get the */ + /* real value. */ + if (auto_stat[i] < 238) + { + my_need_stat_check[i] = FALSE; + } + /* Hack -- save the maximum/current stats */ ! my_stat_cur[i] = value; ! ! /* Max stat is the max that the cur stat ever is. */ ! if (my_stat_cur[i] > my_stat_max[i]) ! my_stat_max[i] = my_stat_cur[i]; ! ! /* if this stat is not in need of fixing and */ ! /* it is less than the max it should be equal to the max */ ! /* and we are done. */ ! #if 0 ! /* there is a problem with this when you get drained but are above */ ! /* 18/220 and after you forget your stuff */ ! if (my_need_stat_check[i] && !do_fix_stat[i] && ! my_stat_max[i] > my_stat_cur[i]) ! { ! my_stat_cur[i] = my_stat_max[i]; ! my_need_stat_check[i] = FALSE; } + #endif } + } *************** *** 374,384 **** * on line one of the screen, near the left, next to a shield, of * the same color, and using --(-- the ")" symbol, directly to the * right of the ant. This is very rare, but perhaps not completely ! * impossible. I ignore this situation. * * The handling of stores is a complete and total hack, but seems ! * to work remarkably well, considering... Note that while in a ! * store, time does not pass, and most actions are not available, * and a few new commands are available ("sell" and "purchase"). * * Note the use of "cheat" functions to extract the current inventory, --- 418,428 ---- * on line one of the screen, near the left, next to a shield, of * the same color, and using --(-- the ")" symbol, directly to the * right of the ant. This is very rare, but perhaps not completely ! * impossible. I ignore this situation. :-) * * The handling of stores is a complete and total hack, but seems ! * to work remarkably well, considering... :-) Note that while in ! * a store, time does not pass, and most actions are not available, * and a few new commands are available ("sell" and "purchase"). * * Note the use of "cheat" functions to extract the current inventory, *************** *** 388,404 **** * * Technically, we should attempt to parse all the messages that * indicate that it is necessary to re-parse the equipment, the ! * inventory, or the books, and only set the appropriate flags at ! * that point. This would not only reduce the potential screen ! * flashing, but would also optimize the code a lot, since the ! * "cheat_inven()" and "cheat_equip()" functions are expensive. ! * For paranoia, we could always select items and spells using ! * capital letters, and keep a global verification buffer, and ! * induce failure and recheck the inventory/equipment any time we ! * get a mis-match. We could even do some of the state processing ! * by hand, for example, charge reduction and such. This might also ! * allow us to keep track of how long we have held objects, especially ! * if we attempt to do "item tracking" in the inventory extraction code. */ static bool borg_think(void) { --- 432,449 ---- * * Technically, we should attempt to parse all the messages that * indicate that it is necessary to re-parse the equipment, the ! * inventory, or the books, and only set the appropriate flags ! * at that point. This would not only reduce the potential ! * screen flashing, but would also optimize the code a lot, ! * since the "cheat_inven()" and "cheat_equip()" functions ! * are expensive. For paranoia, we could always select items ! * and spells using capital letters, and keep a global verification ! * buffer, and induce failure and recheck the inventory/equipment ! * any time we get a mis-match. We could even do some of the state ! * processing by hand, for example, charge reduction and such. This ! * might also allow us to keep track of how long we have held objects, ! * especially if we attempt to do "item tracking" in the inventory ! * extraction code. */ static bool borg_think(void) { *************** *** 437,443 **** --- 482,497 ---- return (FALSE); } + /* save now */ + if (borg_save && borg_save_game()) + { + /* Log */ + borg_note("# Auto Save!"); + borg_save = FALSE; + return (TRUE); + } + /* Parse "equip" mode */ if ((0 == borg_what_text(0, 0, 10, &t_a, buf)) && (streq(buf, "Equipment "))) *************** *** 593,599 **** --- 647,667 ---- return (FALSE); } + /* check for anything that needs *ID* */ + if ( auto_do_star_id ) + { + if (borg_object_star_id()) + return (TRUE); + auto_do_star_id = FALSE; + } + + /* if king and in town, retire. Let the player do this. */ + if (borg_king && !auto_depth) + { + borg_oops("retire"); + } + /*** Handle stores ***/ /* Hack -- Check for being in a store */ *************** *** 656,661 **** --- 724,730 ---- /* Save the new one */ auto_do_browse_more = auto_shops[shop_num].more; + auto_do_browse = auto_do_browse_more; } /* Extract the current gold (unless in home) */ *************** *** 712,717 **** --- 781,800 ---- /* Analyze the item */ borg_item_analyze(&auto_shops[shop_num].ware[n], desc); + /*need to be able to analize the home inventory to see if it was */ + /* *fully ID*d. */ + /* This is a BIG CHEAT! It will be less of a cheat if code is put*/ + /* in place to allow 'I' in stores. */ + #ifdef ID_MENTAL + if (store[shop_num].stock[n].ident & ID_MENTAL) + { + /* XXX XXX XXX for now, allways cheat to get info on items at */ + /* home. */ + borg_object_star_id_aux( &auto_shops[shop_num].ware[n], + &store[shop_num].stock[n]); + auto_shops[shop_num].ware[n].fully_identified = TRUE; + } + #endif /* Hack -- Save the declared cost */ auto_shops[shop_num].ware[n].cost = atol(cost); } *************** *** 839,847 **** /* Track best level */ if (auto_level > auto_max_level) auto_max_level = auto_level; ! if (auto_depth > auto_max_depth) auto_max_depth = auto_depth; - /*** Think about it ***/ /* Increment the clock */ --- 922,933 ---- /* Track best level */ if (auto_level > auto_max_level) auto_max_level = auto_level; ! if (auto_depth > auto_max_depth) ! { ! auto_max_depth = auto_depth; ! finished_level = FALSE; ! } /*** Think about it ***/ /* Increment the clock */ *************** *** 949,978 **** */ static cptr suffix_hit_by[] = { ! " hits you.", /* RBM_HIT */ ! " touches you.", /* RBM_TOUCH */ ! " punches you.", /* RBM_PUNCH */ ! " kicks you.", /* RBM_KICK */ ! " claws you.", /* RBM_CLAW */ ! " bites you.", /* RBM_BITE */ ! " stings you.", /* RBM_STING */ ! /* xxx */ /* RBM_XXX1 */ ! " butts you.", /* RBM_BUTT */ ! " crushes you.", /* RBM_CRUSH */ ! " engulfs you.", /* RBM_ENGULF */ ! /* xxx */ /* RBM_XXX2 */ ! " crawls on you.", /* RBM_CRAWL */ ! " drools on you.", /* RBM_DROOL */ ! " spits on you.", /* RBM_SPIT */ ! /* xxx */ /* RBM_XXX3 */ ! " gazes at you.", /* RBM_GAZE */ ! " wails at you.", /* RBM_WAIL */ ! " releases spores at you.", /* RBM_SPORE */ ! /* xxx */ /* RBM_XXX4 */ ! /* xxx */ /* RBM_BEG */ ! /* xxx */ /* RBM_INSULT */ ! /* xxx */ /* RBM_MOAN */ ! /* xxx */ /* RBM_XXX5 */ NULL }; --- 1035,1056 ---- */ static cptr suffix_hit_by[] = { ! " hits you.", ! " touches you.", ! " punches you.", ! " kicks you.", ! " claws you.", ! " bites you.", ! " stings you.", ! " butts you.", ! " crushes you.", ! " engulfs you.", ! " crawls on you.", ! " drools on you.", ! " spits on you.", ! " gazes at you.", ! " wails at you.", ! " releases spores at you.", NULL }; *************** *** 1089,1105 **** #if 0 - - /* - * These messages are not currently matched - */ - static void some_extra_messages() - { /* XXX XXX XXX */ msg_format("%^s looks healthier.", m_name); msg_format("%^s looks REALLY healthy!", m_name); - } - #endif --- 1167,1175 ---- *************** *** 1222,1228 **** --- 1292,1424 ---- /* Ignore dart traps */ if (prefix(msg, "A small dart ")) return; + if (prefix(msg, "The cave ")) + { + borg_react(msg, "QUAKE"); + return; + } + /* need to check stat */ + if (prefix(msg, "You feel very") || + prefix(msg, "You feel less") || + prefix(msg, "Wow! You feel very")) + { + /* need to check str */ + if (prefix(msg, "You feel very weak")) + { + my_need_stat_check[0] = TRUE; + } + if (prefix(msg, "You feel less weak")) + { + my_need_stat_check[0] = TRUE; + } + if (prefix(msg, "Wow! You feel very strong")) + { + my_need_stat_check[0] = TRUE; + } + + /* need to check int */ + if (prefix(msg, "You feel very stupid")) + { + my_need_stat_check[1] = TRUE; + } + if (prefix(msg, "You feel less stupid")) + { + my_need_stat_check[1] = TRUE; + } + if (prefix(msg, "Wow! You feel very smart")) + { + my_need_stat_check[1] = TRUE; + } + + /* need to check wis */ + if (prefix(msg, "You feel very naive")) + { + my_need_stat_check[2] = TRUE; + } + if (prefix(msg, "You feel less naive")) + { + my_need_stat_check[2] = TRUE; + } + if (prefix(msg, "Wow! You feel very wise")) + { + my_need_stat_check[2] = TRUE; + } + + /* need to check dex */ + if (prefix(msg, "You feel very clumsy")) + { + my_need_stat_check[3] = TRUE; + } + if (prefix(msg, "You feel less clumsy")) + { + my_need_stat_check[3] = TRUE; + } + if (prefix(msg, "Wow! You feel very dextrous")) + { + my_need_stat_check[3] = TRUE; + } + + /* need to check con */ + if (prefix(msg, "You feel very sickly")) + { + my_need_stat_check[4] = TRUE; + } + if (prefix(msg, "You feel less sickly")) + { + my_need_stat_check[4] = TRUE; + } + if (prefix(msg, "Wow! You feel very healthy")) + { + my_need_stat_check[4] = TRUE; + } + + /* need to check cha */ + if (prefix(msg, "You feel very ugly")) + { + my_need_stat_check[5] = TRUE; + } + if (prefix(msg, "You feel less ugly")) + { + my_need_stat_check[5] = TRUE; + } + if (prefix(msg, "Wow! You feel very cute")) + { + my_need_stat_check[5] = TRUE; + } + } + + /* time attacks, just do all stats. */ + if (prefix(msg, "You're not as")) + { + my_need_stat_check[0] = TRUE; + my_need_stat_check[1] = TRUE; + my_need_stat_check[2] = TRUE; + my_need_stat_check[3] = TRUE; + my_need_stat_check[4] = TRUE; + my_need_stat_check[5] = TRUE; + } + + /* Nexus attacks, need to check everything! */ + if (prefix(msg, "Your body starts to scramble...")) + { + my_need_stat_check[0] = TRUE; + my_need_stat_check[1] = TRUE; + my_need_stat_check[2] = TRUE; + my_need_stat_check[3] = TRUE; + my_need_stat_check[4] = TRUE; + my_need_stat_check[5] = TRUE; + + /* max stats may have lowered */ + my_stat_max[0] = 0; + my_stat_max[1] = 0; + my_stat_max[2] = 0; + my_stat_max[3] = 0; + my_stat_max[4] = 0; + my_stat_max[5] = 0; + + } + /* Hit somebody */ if (prefix(msg, "You hit ")) { *************** *** 1309,1314 **** --- 1505,1521 ---- return; } + /* "It is repelled.." */ + /* treat as a miss */ + if (suffix(msg, " is repelled.")) + { + tmp = strlen(" is repelled."); + strnfmt(who, 1 + len - tmp, "%s", msg); + strnfmt(buf, 256, "MISS_BY:%^s", who); + borg_react(msg, buf); + return; + } + /* "It hits you." (etc) */ for (i = 0; suffix_hit_by[i]; i++) { *************** *** 1537,1542 **** --- 1744,1750 ---- { /* Recall complete */ goal_recalling = FALSE; + finished_level = FALSE; return; } *************** *** 1548,1554 **** --- 1756,1873 ---- return; } + /* protect from evil */ + if (prefix(msg, "You feel safe from evil!")) + { + borg_prot_from_evil = TRUE; + return; + } + if (prefix(msg, "You no longer feel safe from evil.")) + { + borg_prot_from_evil = FALSE; + return; + } + /* haste self */ + if (prefix(msg, "You feel yourself moving faster!")) + { + borg_speed = TRUE; + return; + } + if (prefix(msg, "You feel yourself slow down.")) + { + borg_speed = FALSE; + return; + } + /* Bless */ + if (prefix(msg, "You feel righteous!")) + { + borg_bless = TRUE; + return; + } + if (prefix(msg, "The prayer has expired.")) + { + borg_bless = FALSE; + return; + } + /* resist acid */ + if (prefix(msg, "You feel resistant to acid!")) + { + borg_temp_acid = TRUE; + return; + } + if (prefix(msg, "You feel less resistant to acid.")) + { + borg_temp_acid = FALSE; + return; + } + /* resist electricity */ + if (prefix(msg, "You feel resistant to electricity!")) + { + borg_temp_elec = TRUE; + return; + } + if (prefix(msg, "You feel less resistant to electricity.")) + { + borg_temp_elec = FALSE; + return; + } + /* resist fire */ + if (prefix(msg, "You feel resistant to fire!")) + { + borg_temp_fire = TRUE; + return; + } + if (prefix(msg, "You feel less resistant to fire.")) + { + borg_temp_fire = FALSE; + return; + } + /* resist cold */ + if (prefix(msg, "You feel resistant to cold!")) + { + borg_temp_cold = TRUE; + return; + } + if (prefix(msg, "You feel less resistant to cold.")) + { + borg_temp_cold = FALSE; + return; + } + /* resist poison */ + if (prefix(msg, "You feel resistant to poison!")) + { + borg_temp_poison = TRUE; + return; + } + if (prefix(msg, "You feel less resistant to poison.")) + { + borg_temp_poison = FALSE; + return; + } + /* GOI! */ + if (prefix(msg, "You feel invulnerable!")) + { + borg_goi = 11; /* keep track of how long it has left (a guess) */ + return; + } + if (prefix(msg, "You feel vulnerable once more.")) + { + borg_goi = 0; + return; + } + /* Shield */ + if (prefix(msg, "A mystic shield forms around your body!")) + { + borg_shield = TRUE; + return; + } + if (prefix(msg, "Your mystic shield crumbles away.")) + { + borg_shield = FALSE; + return; + } + /* Feelings about the level */ for (i = 0; prefix_feeling[i]; i++) { *************** *** 1746,1754 **** --- 2065,2080 ---- /* Take note */ borg_note("# Cheating death..."); + if (borg_cheat_death) /* Cheat death */ (*ch) = 'n'; + else + /* This will allow the user to decide what to do next. */ + /* if it is used in combination with auto_save you can go back to */ + /* before the borg died and replay the dieing moves! */ + borg_oops("death"); + /* Success */ return (0); } *************** *** 1902,1916 **** /* ! * Initialize the game */ ! static void borg_prepare(void) { ! int book; ! /*** Options/Redraw ***/ /* We use the original keypress codes */ rogue_like_commands = FALSE; --- 2228,2267 ---- /* ! * Initialize the Borg */ ! void borg_init_9(void) { ! int i; + byte t_a; ! char buf[80]; + byte *test; + + + /*** Hack -- verify system ***/ + + /* Message */ + prt("Initializing the Borg... (memory)", 0, 0); + + /* Hack -- flush it */ + Term_fresh(); + + /* Mega-Hack -- verify memory */ + C_MAKE(test, 400 * 1024L, byte); + C_KILL(test, 400 * 1024L, byte); + + + /*** Hack -- initialize game options ***/ + + /* Message */ + prt("Initializing the Borg... (options)", 0, 0); + + /* Hack -- flush it */ + Term_fresh(); + /* We use the original keypress codes */ rogue_like_commands = FALSE; *************** *** 1930,1935 **** --- 2281,2289 ---- /* We do not haggle */ auto_haggle = TRUE; + /* do not start out auto-scumming. */ + auto_scum = FALSE; + /* We need space */ show_labels = FALSE; show_weights = FALSE; *************** *** 1946,1953 **** /* Allow wands to stack */ stack_allow_wands = TRUE; ! /* Do not ignore discounts */ ! stack_force_costs = FALSE; /* Ignore inscriptions */ stack_force_notes = TRUE; --- 2300,2307 ---- /* Allow wands to stack */ stack_allow_wands = TRUE; ! /* Ignore discounts */ ! stack_force_costs = TRUE; /* Ignore inscriptions */ stack_force_notes = TRUE; *************** *** 1961,2032 **** /* Hack -- notice "command" mode */ hilite_player = FALSE; ! /* Reset the visuals */ ! reset_visuals(FALSE); ! /* Redraw everything */ do_cmd_redraw(); ! /*** Race/Class/Spells ***/ - /* Extract the race */ - auto_race = p_ptr->prace; - - /* Extract the class */ - auto_class = p_ptr->pclass; - - /* Extract the race pointer */ - rb_ptr = &race_info[auto_race]; - - /* Extract the class pointer */ - cb_ptr = &class_info[auto_class]; - - /* Extract the magic pointer */ - mb_ptr = &magic_info[auto_class]; - - /* Initialize the books */ - for (book = 0; book < 9; book++) - { - borg_prepare_book(book); - } - } - - - - /* - * Initialize the Borg - * - * We should verify "legal" values for various things, since, - * for example, when the "wall" symbols have been redefined, - * the Borg may crash the machine. XXX XXX XXX - */ - void borg_init_9(void) - { - byte *test; - - - /*** Initialize (system) ***/ - /* Message */ ! prt("Initializing the Borg (system)...", 0, 0); ! /* Refresh */ Term_fresh(); - /* Mega-Hack -- verify memory */ - C_MAKE(test, 300 * 1024L, byte); - C_KILL(test, 300 * 1024L, byte); - /*** Initialize (internal) ***/ - - /* Message */ - prt("Initializing the Borg (internal)...", 0, 0); - - /* Refresh */ - Term_fresh(); - /* Mega-Hack -- Cheat a lot */ auto_cheat_inven = TRUE; auto_cheat_equip = TRUE; --- 2315,2338 ---- /* Hack -- notice "command" mode */ hilite_player = FALSE; ! /* Hack -- reset visuals */ ! reset_visuals(); ! /* Hack -- Redraw */ do_cmd_redraw(); ! /*** Various ***/ /* Message */ ! prt("Initializing the Borg... (various)", 0, 0); ! /* Hack -- flush it */ Term_fresh(); + /*** Cheat / Panic ***/ /* Mega-Hack -- Cheat a lot */ auto_cheat_inven = TRUE; auto_cheat_equip = TRUE; *************** *** 2037,2042 **** --- 2343,2353 ---- /* Mega-Hack -- Cheat a lot */ auto_cheat_panel = TRUE; + /* more cheating */ + borg_cheat_death = FALSE; + + /*** Initialize ***/ + /* Initialize */ borg_init_1(); borg_init_2(); *************** *** 2047,2061 **** borg_init_7(); borg_init_8(); - /* Clear line */ - prt("", 0, 0); ! /* Prepare */ ! borg_prepare(); ! /* Refresh */ ! Term_fresh(); /* Official message */ borg_note("# Ready..."); --- 2358,2425 ---- borg_init_7(); borg_init_8(); ! /*** Hack -- Extract race ***/ ! /* Check for textual race */ ! if (0 == borg_what_text(COL_RACE, ROW_RACE, -12, &t_a, buf)) ! { ! /* Scan the races */ ! for (i = 0; i < 10; i++) ! { ! /* Check the race */ ! if (prefix(buf, race_info[i].title)) ! { ! /* We got one */ ! auto_race = i; ! break; ! } ! } ! } + /* Extract the race pointer */ + rb_ptr = &race_info[auto_race]; + + + /*** Hack -- Extract class ***/ + + /* Check for textual class */ + if (0 == borg_what_text(COL_CLASS, ROW_CLASS, -12, &t_a, buf)) + { + /* Scan the classes */ + for (i = 0; i < 6; i++) + { + /* Check the race */ + if (prefix(buf, class_info[i].title)) + { + /* We got one */ + auto_class = i; + break; + } + } + } + + /* Extract the class pointer */ + cb_ptr = &class_info[auto_class]; + + /* Extract the magic pointer */ + mb_ptr = &magic_info[auto_class]; + + + /*** Hack -- react to race and class ***/ + + /* Notice the new race and class */ + prepare_race_class_info(); + + + /*** All done ***/ + + /* Done initialization */ + prt("Initializing the Borg... done.", 0, 0); + + /* Clear line */ + prt("", 0, 0); + /* Official message */ borg_note("# Ready..."); *************** *** 2067,2077 **** /* * Hack -- forward declare */ ! extern void do_cmd_borg(void); /* ! * Hack -- interact with the Borg */ void do_cmd_borg(void) { --- 2431,2441 ---- /* * Hack -- forward declare */ ! void do_cmd_borg(void); /* ! * Hack -- interact with the "Ben Borg". */ void do_cmd_borg(void) { *************** *** 2104,2115 **** Term_putstr(5, i++, -1, TERM_WHITE, "Command 'l' activates a log file."); Term_putstr(5, i++, -1, TERM_WHITE, "Command 's' activates search mode."); Term_putstr(5, i++, -1, TERM_WHITE, "Command 'i' displays grid info."); Term_putstr(5, i++, -1, TERM_WHITE, "Command 'a' displays avoidances."); Term_putstr(5, i++, -1, TERM_WHITE, "Command 'k' displays monster info."); Term_putstr(5, i++, -1, TERM_WHITE, "Command 't' displays object info."); /* Prompt for key */ ! msg_print("Available commands: ?,$,z,u,x,f,c,w,l,s,i,a,k,t."); msg_print(NULL); /* Restore the screen */ --- 2468,2484 ---- Term_putstr(5, i++, -1, TERM_WHITE, "Command 'l' activates a log file."); Term_putstr(5, i++, -1, TERM_WHITE, "Command 's' activates search mode."); Term_putstr(5, i++, -1, TERM_WHITE, "Command 'i' displays grid info."); + Term_putstr(5, i++, -1, TERM_WHITE, "Command 'g' displays grid feature."); Term_putstr(5, i++, -1, TERM_WHITE, "Command 'a' displays avoidances."); Term_putstr(5, i++, -1, TERM_WHITE, "Command 'k' displays monster info."); Term_putstr(5, i++, -1, TERM_WHITE, "Command 't' displays object info."); + Term_putstr(5, i++, -1, TERM_WHITE, "Command '%' displays current flow."); + Term_putstr(5, i++, -1, TERM_WHITE, "Command '#' displays danger grid."); + Term_putstr(5, i++, -1, TERM_WHITE, "Command '_' Depth info."); + Term_putstr(5, i++, -1, TERM_WHITE, "Command 'p' Borg Power."); /* Prompt for key */ ! msg_print("Available commands: ?,$,z,u,x,f,c,w,l,s,i,a,k,t,%,#,_,p."); msg_print(NULL); /* Restore the screen */ *************** *** 2123,2142 **** /* Hack -- force initialization */ if (!initialized) borg_init_9(); ! /* Command: Nothing */ ! if (cmd == '$') { ! /* Nothing */ } - - /* Command: Activate */ ! else if (cmd == 'z') { - /* Prepare */ - borg_prepare(); - /* Activate */ auto_active = TRUE; --- 2492,2508 ---- /* Hack -- force initialization */ if (!initialized) borg_init_9(); ! switch (cmd) ! { /* Command: Nothing */ ! case '$': { ! break; } /* Command: Activate */ ! case 'z': ! case 'Z': { /* Activate */ auto_active = TRUE; *************** *** 2146,2168 **** /* Step forever */ auto_step = 0; /* Allowable Cheat -- Obtain "recall" flag */ goal_recalling = (p_ptr->word_recall ? TRUE : FALSE); /* Message */ borg_note("# Installing keypress hook"); /* Activate the key stealer */ Term_inkey_hook = Term_inkey_borg; } - /* Command: Update */ ! else if (cmd == 'u') { - /* Prepare */ - borg_prepare(); - /* Activate */ auto_active = TRUE; --- 2512,2561 ---- /* Step forever */ auto_step = 0; + /* need to check all stats */ + my_need_stat_check[0] = TRUE; + my_need_stat_check[1] = TRUE; + my_need_stat_check[2] = TRUE; + my_need_stat_check[3] = TRUE; + my_need_stat_check[4] = TRUE; + my_need_stat_check[5] = TRUE; + /* Allowable Cheat -- Obtain "recall" flag */ goal_recalling = (p_ptr->word_recall ? TRUE : FALSE); + /* Allowable Cheat -- Obtain "prot_from_evil" flag */ + borg_prot_from_evil = (p_ptr->protevil ? TRUE : FALSE); + /* Allowable Cheat -- Obtain "speed" flag */ + borg_speed = (p_ptr->fast ? TRUE : FALSE); + /* Allowable Cheat -- Obtain "goi" flag */ + borg_goi = (p_ptr->invuln ? 9 : 0); + /* Allowable Cheat -- Obtain "resist" flags */ + borg_temp_acid = (p_ptr->oppose_acid ? TRUE : FALSE); + borg_temp_elec = (p_ptr->oppose_elec ? TRUE : FALSE); + borg_temp_fire = (p_ptr->oppose_fire ? TRUE : FALSE); + borg_temp_cold = (p_ptr->oppose_cold ? TRUE : FALSE); + borg_temp_poison = (p_ptr->oppose_pois ? TRUE : FALSE); + borg_bless = (p_ptr->blessed ? TRUE : FALSE); + borg_shield = (p_ptr->shield ? TRUE : FALSE); + #if 0 + /*!FIX AJG not coded yet */. + borg_hero = (p_ptr->hero ? TRUE : FALSE); + if (!borg_hero) + borg_hero = (p_ptr->shero ? TRUE : FALSE); + #endif /* Message */ borg_note("# Installing keypress hook"); /* Activate the key stealer */ Term_inkey_hook = Term_inkey_borg; + + break; } /* Command: Update */ ! case 'u': ! case 'U': { /* Activate */ auto_active = TRUE; *************** *** 2175,2194 **** /* Allowable Cheat -- Obtain "recall" flag */ goal_recalling = (p_ptr->word_recall ? TRUE : FALSE); /* Message */ borg_note("# Installing keypress hook"); /* Activate the key stealer */ Term_inkey_hook = Term_inkey_borg; } /* Command: Step */ ! else if (cmd == 'x') { - /* Prepare */ - borg_prepare(); - /* Activate */ auto_active = TRUE; --- 2568,2608 ---- /* Allowable Cheat -- Obtain "recall" flag */ goal_recalling = (p_ptr->word_recall ? TRUE : FALSE); + /* Allowable Cheat -- Obtain "prot_from_evil" flag */ + borg_prot_from_evil = (p_ptr->protevil ? TRUE : FALSE); + /* Allowable Cheat -- Obtain "speed" flag */ + borg_speed = (p_ptr->fast ? TRUE : FALSE); + /* Allowable Cheat -- Obtain "goi" flag */ + borg_goi = (p_ptr->invuln ? 9 : 0); + /* Allowable Cheat -- Obtain "resist" flags */ + borg_temp_acid = (p_ptr->oppose_acid ? TRUE : FALSE); + borg_temp_elec = (p_ptr->oppose_elec ? TRUE : FALSE); + borg_temp_fire = (p_ptr->oppose_fire ? TRUE : FALSE); + borg_temp_cold = (p_ptr->oppose_cold ? TRUE : FALSE); + borg_temp_poison = (p_ptr->oppose_pois ? TRUE : FALSE); + borg_bless = (p_ptr->blessed ? TRUE : FALSE); + borg_shield = (p_ptr->shield ? TRUE : FALSE); + #if 0 + /*!FIX AJG not coded yet */. + borg_hero = (p_ptr->hero ? TRUE : FALSE); + if (!borg_hero) + borg_hero = (p_ptr->shero ? TRUE : FALSE); + #endif + /* Message */ borg_note("# Installing keypress hook"); /* Activate the key stealer */ Term_inkey_hook = Term_inkey_borg; + + break; } /* Command: Step */ ! case 'x': ! case 'X': { /* Activate */ auto_active = TRUE; *************** *** 2198,2205 **** --- 2612,2647 ---- /* Step for one (or more) turns */ auto_step = (command_arg > 0) ? command_arg : 1; + /* need to check all stats */ + my_need_stat_check[0] = TRUE; + my_need_stat_check[1] = TRUE; + my_need_stat_check[2] = TRUE; + my_need_stat_check[3] = TRUE; + my_need_stat_check[4] = TRUE; + my_need_stat_check[5] = TRUE; + /* Allowable Cheat -- Obtain "recall" flag */ goal_recalling = (p_ptr->word_recall ? TRUE : FALSE); + /* Allowable Cheat -- Obtain "prot_from_evil" flag */ + borg_prot_from_evil = (p_ptr->protevil ? TRUE : FALSE); + /* Allowable Cheat -- Obtain "speed" flag */ + borg_speed = (p_ptr->fast ? TRUE : FALSE); + /* Allowable Cheat -- Obtain "goi" flag */ + borg_goi = (p_ptr->invuln ? 9 : 0); + /* Allowable Cheat -- Obtain "resist" flags */ + borg_temp_acid = (p_ptr->oppose_acid ? TRUE : FALSE); + borg_temp_elec = (p_ptr->oppose_elec ? TRUE : FALSE); + borg_temp_fire = (p_ptr->oppose_fire ? TRUE : FALSE); + borg_temp_cold = (p_ptr->oppose_cold ? TRUE : FALSE); + borg_temp_poison = (p_ptr->oppose_pois ? TRUE : FALSE); + borg_bless = (p_ptr->blessed ? TRUE : FALSE); + borg_shield = (p_ptr->shield ? TRUE : FALSE); + #if 0 + /*!FIX AJG not coded yet */. + borg_hero = (p_ptr->hero ? TRUE : FALSE); + if (!borg_hero) + borg_hero = (p_ptr->shero ? TRUE : FALSE); + #endif /* Message */ borg_note("# Installing keypress hook"); *************** *** 2206,2268 **** /* Activate the key stealer */ Term_inkey_hook = Term_inkey_borg; } - /* Command: toggle "flags" */ ! else if (cmd == 'f') { /* Get a "Borg command", or abort */ ! if (!get_com("Borg command: Toggle Flag: ", &cmd)) return; /* Dump savefile at each death */ ! if (cmd == 'd') { auto_flag_dump = !auto_flag_dump; ! msg_format("Borg -- auto_flag_dump is now %d.", auto_flag_dump); } /* Dump savefile at each level */ ! else if (cmd == 's') { auto_flag_save = !auto_flag_save; ! msg_format("Borg -- auto_flag_save is now %d.", auto_flag_save); } } /* Command: toggle "cheat" flags */ ! else if (cmd == 'c') { /* Get a "Borg command", or abort */ ! if (!get_com("Borg command: Toggle Cheat: ", &cmd)) return; ! /* Toggle */ ! if (cmd == 'i') { auto_cheat_inven = !auto_cheat_inven; ! msg_format("Borg -- auto_cheat_inven is now %d.", auto_cheat_inven); } ! else if (cmd == 'e') { auto_cheat_equip = !auto_cheat_equip; ! msg_format("Borg -- auto_cheat_equip is now %d.", auto_cheat_equip); } ! else if (cmd == 's') { auto_cheat_spell = !auto_cheat_spell; ! msg_format("Borg -- auto_cheat_spell is now %d.", auto_cheat_spell); } ! else if (cmd == 'p') { auto_cheat_panel = !auto_cheat_panel; ! msg_format("Borg -- auto_cheat_panel is now %d.", auto_cheat_panel); } } /* Start a new log file */ ! else if (cmd == 'l') { char buf[80]; --- 2648,2758 ---- /* Activate the key stealer */ Term_inkey_hook = Term_inkey_borg; + + break; } /* Command: toggle "flags" */ ! case 'f': ! case 'F': { /* Get a "Borg command", or abort */ ! if (!get_com("Borg command: Toggle Flag: (d/s/f) ", &cmd)) return; + switch (cmd) + { /* Dump savefile at each death */ ! case 'd': ! case 'D': { auto_flag_dump = !auto_flag_dump; ! msg_format("Borg -- auto_flag_dump is now %d.", ! auto_flag_dump); ! break; } /* Dump savefile at each level */ ! case 's': ! case 'S': { auto_flag_save = !auto_flag_save; ! msg_format("Borg -- auto_flag_save is now %d.", ! auto_flag_save); ! break; } + + /* clear 'fear' levels */ + case 'f': + case 'F': + { + msg_format("Command No Longer Usefull"); + break; } + } + break; + } + /* Command: toggle "cheat" flags */ ! case 'c': ! case 'C': { /* Get a "Borg command", or abort */ ! if (!get_com("Borg command: Toggle Cheat: (d/i/e/s/p)", &cmd)) ! return; ! switch (cmd) { + case 'd': + case 'D': + { + borg_cheat_death = !borg_cheat_death; + msg_format("Borg -- auto_cheat_death is now %d.", + borg_cheat_death); + break; + } + case 'i': + case 'I': + { auto_cheat_inven = !auto_cheat_inven; ! msg_format("Borg -- auto_cheat_inven is now %d.", ! auto_cheat_inven); ! break; } ! case 'e': ! case 'E': { auto_cheat_equip = !auto_cheat_equip; ! msg_format("Borg -- auto_cheat_equip is now %d.", ! auto_cheat_equip); ! break; } ! case 's': ! case 'S': { auto_cheat_spell = !auto_cheat_spell; ! msg_format("Borg -- auto_cheat_spell is now %d.", ! auto_cheat_spell); ! break; } ! case 'p': ! case 'P': { auto_cheat_panel = !auto_cheat_panel; ! msg_format("Borg -- auto_cheat_panel is now %d.", ! auto_cheat_panel); ! break; } } + break; + } + /* Start a new log file */ ! case 'l': ! case 'L': { char buf[80]; *************** *** 2291,2297 **** /* Activate a search string */ ! else if (cmd == 's') { /* Get the new search string (or cancel the matching) */ if (!get_string("Borg Match String: ", auto_match, 70)) --- 2781,2788 ---- /* Activate a search string */ ! case 's': ! case 'S': { /* Get the new search string (or cancel the matching) */ if (!get_string("Borg Match String: ", auto_match, 70)) *************** *** 2302,2312 **** /* Message */ msg_print("Borg Match String de-activated."); } } /* Command: check "info" flags */ ! else if (cmd == 'i') { int x, y; --- 2793,2890 ---- /* Message */ msg_print("Borg Match String de-activated."); } + break; } + /* Command: check Grid "feature" flags */ + case 'g': + case 'G': + { + int x, y; + + u16b low, high; + + /* Get a "Borg command", or abort */ + if (!get_com("Borg command: Show grids: ", &cmd)) return; + + /* Extract a flag */ + switch (cmd) + { + case '0': low = high = 1 << 0; break; + case '1': low = high = 1 << 1; break; + case '2': low = high = 1 << 2; break; + case '3': low = high = 1 << 3; break; + case '4': low = high = 1 << 4; break; + case '5': low = high = 1 << 5; break; + case '6': low = high = 1 << 6; break; + case '7': low = high = 1 << 7; break; + + case '.': low = high = FEAT_FLOOR; break; + case ' ': low = high = FEAT_NONE; break; + case 'i': low = high = FEAT_INVIS; break; + case ';': low = high = FEAT_GLYPH; break; + case ',': low = high = FEAT_OPEN; break; + case 'x': low = high = FEAT_BROKEN; break; + case '>': low = high = FEAT_LESS; break; + case '<': low = high = FEAT_MORE; break; + case '@': low = FEAT_SHOP_HEAD; + high = FEAT_SHOP_TAIL; + break; + case '^': low = FEAT_TRAP_HEAD; + high = FEAT_TRAP_TAIL; + break; + case '+': low = FEAT_DOOR_HEAD; break; + high = FEAT_DOOR_TAIL; break; + case 's': low = high = FEAT_SECRET; break; + case ':': low = high = FEAT_RUBBLE; break; + case 'm': low = high = FEAT_MAGMA; break; + case 'q': low = high = FEAT_QUARTZ; break; + case 'r': low = high = FEAT_QUARTZ_H; break; + case 'k': low = high = FEAT_MAGMA_K; break; + case '&': low = high = FEAT_QUARTZ_K; break; + case 'w': low = FEAT_WALL_EXTRA; + high = FEAT_WALL_SOLID; + break; + case 'p': low = FEAT_PERM_EXTRA; + high = FEAT_PERM_SOLID; + break; + + default: low = high = 0x00; break; + } + + /* Scan map */ + for (y = w_y; y < w_y + SCREEN_HGT; y++) + { + for (x = w_x; x < w_x + SCREEN_WID; x++) + { + byte a = TERM_RED; + + auto_grid *ag = &auto_grids[y][x]; + + /* show only those grids */ + if (!(ag->feat >= low && ag->feat <= high)) continue; + + /* Color */ + if (borg_cave_floor_bold(y, x)) a = TERM_YELLOW; + + /* Display */ + print_rel('*', a, y, x); + } + } + + /* Get keypress */ + msg_print("Press any key."); + msg_print(NULL); + + /* Redraw map */ + prt_map(); + break; + } + /* Command: check "info" flags */ ! case 'i': ! case 'I': { int x, y; *************** *** 2368,2378 **** /* Redraw map */ prt_map(); } - /* Command: check "avoidances" */ ! else if (cmd == 'a') { int x, y, p; --- 2946,2957 ---- /* Redraw map */ prt_map(); + break; } /* Command: check "avoidances" */ ! case 'a': ! case 'A': { int x, y, p; *************** *** 2403,2413 **** /* Redraw map */ prt_map(); } /* Command: show "monsters" */ ! else if (cmd == 'k') { int i, n = 0; --- 2982,2994 ---- /* Redraw map */ prt_map(); + break; } /* Command: show "monsters" */ ! case 'k': ! case 'K': { int i, n = 0; *************** *** 2436,2446 **** /* Redraw map */ prt_map(); } /* Command: show "objects" */ ! else if (cmd == 't') { int i, n = 0; --- 3017,3029 ---- /* Redraw map */ prt_map(); + break; } /* Command: show "objects" */ ! case 't': ! case 'T': { int i, n = 0; *************** *** 2469,2479 **** /* Redraw map */ prt_map(); } /* Command: debug -- current flow */ ! else if (cmd == '%') { int i, x, y; --- 3052,3063 ---- /* Redraw map */ prt_map(); + break; } /* Command: debug -- current flow */ ! case '%': { int i, x, y; *************** *** 2510,2520 **** /* Redraw map */ prt_map(); } } - /* Command: debug -- danger of grid */ ! else if (cmd == '#') { int n; --- 3094,3104 ---- /* Redraw map */ prt_map(); } + break; } /* Command: debug -- danger of grid */ ! case '#': { int n; *************** *** 2525,2563 **** msg_format("Danger(%d,%d,%d) is %d", target_col, target_row, n, borg_danger(target_row, target_col, n)); } - /* Command: debug -- fear of depth */ ! else if (cmd == '_') { - int i; - /* Max depth */ ! msg_format("Max depth %d:", auto_max_depth); /* Dump fear codes */ ! for (i = 0; i <= auto_max_depth; i++) { ! /* Dump fear code */ ! msg_format(" %d", auto_fear_depth[i]); } } /* Oops */ ! else { /* Message */ msg_print("That is not a legal Borg command."); } } #else #ifdef MACINTOSH static int HACK = 0; ! #endif /* MACINTOSH */ ! #endif /* ALLOW_BORG */ --- 3109,3200 ---- msg_format("Danger(%d,%d,%d) is %d", target_col, target_row, n, borg_danger(target_row, target_col, n)); + break; } /* Command: debug -- fear of depth */ ! case '_': { /* Max depth */ ! msg_format("Max depth %d, ", auto_max_depth); + /* Fear depth */ + msg_format("Fear depth %d, ", fear_depth); + /* Dump fear codes */ ! msg_format("times completed fear depth %d", auto_fear_depth); ! break; ! } ! ! /* Command: debug -- Power */ ! case 'p': ! case 'P': { ! s32b p; ! ! /* Examine the screen */ ! borg_update_frame(); ! ! /* Examine the screen */ ! borg_update(); ! ! /* Cheat the "equip" screen */ ! borg_cheat_equip(); ! ! /* Cheat the "inven" screen */ ! borg_cheat_inven(); ! ! /* Extract some "hidden" variables */ ! borg_hidden(); ! ! /* Examine the inventory */ ! borg_notice(); ! ! /* Evaluate */ ! p = borg_power(); ! ! /* Max depth */ ! msg_format("Current Borg Power %ld", p); ! ! break; } + + /* Command: Show time */ + case '!': + { + s32b time = c_t - auto_began; + msg_format("time: (%d) ", time); + time = (auto_time_town + (c_t - auto_began)); + msg_format("time from town (%d)", time); + break; } + /* Command: my Stats */ + case '@': + msg_format("str (m%d,c%d)", my_stat_max[0], my_stat_cur[0]); + msg_format("int (m%d,c%d)", my_stat_max[1], my_stat_cur[1]); + msg_format("wis (m%d,c%d)", my_stat_max[2], my_stat_cur[2]); + msg_format("dex (m%d,c%d)", my_stat_max[3], my_stat_cur[3]); + msg_format("con (m%d,c%d)", my_stat_max[4], my_stat_cur[4]); + msg_format("cha (m%d,c%d)", my_stat_max[5], my_stat_cur[5]); + break; /* Oops */ ! default: { /* Message */ msg_print("That is not a legal Borg command."); + break; } } + } + #else #ifdef MACINTOSH static int HACK = 0; ! #endif ! #endif