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GEV3YOC7JYWEXCZDBFPLT4AUG4P227WVKVB72ZAC 6POB4N3ASH4YL2O5ZWCQ5X2RURGTC2KXX7R7IKCJT6ZV6VKQKJMQC BNTPYSO6ECZ76CHHLDP3ASSPDSEUH4Y3E3LETKNXVWAWJRFL3YEQC LW4N5EHKL776DURXZMAM6JEW3JPWWX5BSNP7TCZHTLCDOQTTGFCAC TINRWQCFVUGHD2QAQY2NCPBQCYWRAKVMHOYKZRY2MKNHQWKIJECAC VD4KDTGHVKCN35AWREYB4TEOUMCTW7SAUPAMTMF5ABC7VBHVKP4AC 7YSKYUNV34XIWRTJUHJV4QMQRTXXYDIXM5AZSPSDPAYDW4B4PU6QC YAAJ6PTN6QUSWE52URI5AENOGD366FIHOIFUOXFUJLVZYE4OG6HQC YHSVOROKPYS33Y4RYZRVZTE3G5LXOFX52HEDNLV6HIXOJYNOKH3QC GVCGKTH5IJ4VSQEIN4CRC7ZFVZW26JPIYNCPTO7GY66CSZZEW3ZQC NLSZ4SHFD6LN6AWB3HLLKQTCKQW55ZHEW3YM7XRAVAKIPD3C3Q3AC ODNAIEJW732NG7USKQKCIP4R4DAEYXXJQX6LY7TIN32NKE75454QC 5K2ANIEXD3CPJM4XNKNPZINP2G4NT7SJBKRN62WNBUKJXFERTILQC M47QBURKKRV2JFK6U7GQNVWK7RUTBVPBJ5FHURC55SKQSXAUFSBAC static int find_fire_item_matching(unsigned fire_type_flags, int start = 0)
static bool fire_item_okay(const item_def &item, unsigned flags){return (fire_item_matches(item, flags)&& check_warning_inscriptions(item, OPER_FIRE));}static int find_fire_item_matching(unsigned fire_type, int start,bool forward, bool check_quiver)
if (i < Options.fire_items_start)continue;if (fire_item_matches(you.inv[i], fire_type_flags)&& check_warning_inscriptions(you.inv[i], OPER_FIRE))return (i);
const int q = you.quiver;if (q >= 0 && q < ENDOFPACK && fire_item_okay(you.inv[q], fire_type))return (q);
}static void announce_ammo(int item){mesclr();mprf("Firing%s: %s",get_fire_item_index((item + 1) % ENDOFPACK, true, false) != item?" (^N/^P - change)" : "",you.inv[item].name(DESC_INVENTORY_EQUIP).c_str());}class fire_target_behaviour : public targeting_behaviour{public:fire_target_behaviour(int it) : item(it), need_prompt(false) { }command_type get_command(int key = -1);bool should_redraw();void announce_new_ammo(bool redraw = true);public:int item;bool need_prompt;private:void find_next_ammo();void find_prev_ammo();};bool fire_target_behaviour::should_redraw(){if (need_prompt){need_prompt = false;return (true);}return (false);}command_type fire_target_behaviour::get_command(int key){if (key == -1)key = get_key();switch (key){case CONTROL('N'):find_next_ammo();break;case CONTROL('P'):find_prev_ammo();break;case '?':show_targeting_help();redraw_screen();announce_new_ammo(item);need_prompt = true;return (CMD_NO_CMD);}return targeting_behaviour::get_command(key);}void fire_target_behaviour::announce_new_ammo(bool redraw){announce_ammo(item);need_prompt = redraw;}void fire_target_behaviour::find_next_ammo(){const int start = item == ENDOFPACK - 1? 0 : item + 1;const int next = get_fire_item_index(start, true, false);// We should never get back ENDOFPACK.if (next != item){item = next;announce_new_ammo();}}void fire_target_behaviour::find_prev_ammo(){const int start = item == 0? ENDOFPACK - 1 : item - 1;const int next = get_fire_item_index(start, false, false);// We should never get back ENDOFPACK.if (next != item){item = next;announce_new_ammo();}}static bool choose_fire_target(dist &target, int &item){announce_ammo(item);message_current_target();fire_target_behaviour beh(item);direction( target, DIR_NONE, TARG_ENEMY, false, NULL, &beh );if (!target.isValid){if (target.isCancel)canned_msg(MSG_OK);return (false);}// Okay, valid target; if the user chose different ammo, quiver it.if (beh.item != item){item = beh.item;if (you.inv[beh.item].quantity > 1)you.quiver = beh.item;}return (true);
// An object that modifies the behaviour of the direction prompt.class targeting_behaviour{public:targeting_behaviour(bool just_looking = false);virtual ~targeting_behaviour();// Returns a keystroke for the prompt.virtual int get_key();virtual command_type get_command(int key = -1);virtual bool should_redraw();public:bool just_looking;bool compass;};
flush_input_buffer( FLUSH_BEFORE_COMMAND );const int key =unmangle_direction_keys(getchm(KC_TARGETING), KC_TARGETING, false, false);switch ( key ){case ESCAPE: case 'x': return CMD_TARGET_CANCEL;#ifdef WIZARDcase 'F': return CMD_TARGET_WIZARD_MAKE_FRIENDLY;#endifcase 'v': return CMD_TARGET_DESCRIBE;case '?': return CMD_TARGET_HELP;case ' ': return just_looking? CMD_TARGET_CANCEL : CMD_TARGET_SELECT;#ifdef WIZARDcase CONTROL('C'): return CMD_TARGET_CYCLE_BEAM;#endifcase ':': return CMD_TARGET_HIDE_BEAM;case '\r': return CMD_TARGET_SELECT;case '.': return CMD_TARGET_SELECT;case '5': return CMD_TARGET_SELECT;case '!': return CMD_TARGET_SELECT_ENDPOINT;case '\\': case '\t': return CMD_TARGET_FIND_PORTAL;case '^': return CMD_TARGET_FIND_TRAP;case '_': return CMD_TARGET_FIND_ALTAR;case '<': return CMD_TARGET_FIND_UPSTAIR;case '>': return CMD_TARGET_FIND_DOWNSTAIR;case CONTROL('F'): return CMD_TARGET_CYCLE_TARGET_MODE;case 'p': return CMD_TARGET_PREV_TARGET;case 'f': case 't': return CMD_TARGET_MAYBE_PREV_TARGET;case '-': return CMD_TARGET_CYCLE_BACK;case '+': case '=': return CMD_TARGET_CYCLE_FORWARD;case ';': case '/': return CMD_TARGET_OBJ_CYCLE_BACK;case '*': case '\'': return CMD_TARGET_OBJ_CYCLE_FORWARD;case 'b': return CMD_TARGET_DOWN_LEFT;case 'h': return CMD_TARGET_LEFT;case 'j': return CMD_TARGET_DOWN;case 'k': return CMD_TARGET_UP;case 'l': return CMD_TARGET_RIGHT;case 'n': return CMD_TARGET_DOWN_RIGHT;case 'u': return CMD_TARGET_UP_RIGHT;case 'y': return CMD_TARGET_UP_LEFT;case 'B': return CMD_TARGET_DIR_DOWN_LEFT;case 'H': return CMD_TARGET_DIR_LEFT;case 'J': return CMD_TARGET_DIR_DOWN;case 'K': return CMD_TARGET_DIR_UP;case 'L': return CMD_TARGET_DIR_RIGHT;case 'N': return CMD_TARGET_DIR_DOWN_RIGHT;case 'U': return CMD_TARGET_DIR_UP_RIGHT;case 'Y': return CMD_TARGET_DIR_UP_LEFT;default: return CMD_NO_CMD;}}void direction_choose_compass( struct dist& moves ){
int targeting_behaviour::get_key(){flush_input_buffer(FLUSH_BEFORE_COMMAND);return unmangle_direction_keys(getchm(KC_TARGETING), KC_TARGETING, false, false);}command_type targeting_behaviour::get_command(int key){if (key == -1)key = get_key();switch ( key ){case ESCAPE: case 'x': return CMD_TARGET_CANCEL;#ifdef WIZARDcase 'F': return CMD_TARGET_WIZARD_MAKE_FRIENDLY;#endifcase 'v': return CMD_TARGET_DESCRIBE;case '?': return CMD_TARGET_HELP;case ' ': return just_looking? CMD_TARGET_CANCEL : CMD_TARGET_SELECT;#ifdef WIZARDcase CONTROL('C'): return CMD_TARGET_CYCLE_BEAM;#endifcase ':': return CMD_TARGET_HIDE_BEAM;case '\r': return CMD_TARGET_SELECT;case '.': return CMD_TARGET_SELECT;case '5': return CMD_TARGET_SELECT;case '!': return CMD_TARGET_SELECT_ENDPOINT;case '\\': case '\t': return CMD_TARGET_FIND_PORTAL;case '^': return CMD_TARGET_FIND_TRAP;case '_': return CMD_TARGET_FIND_ALTAR;case '<': return CMD_TARGET_FIND_UPSTAIR;case '>': return CMD_TARGET_FIND_DOWNSTAIR;case CONTROL('F'): return CMD_TARGET_CYCLE_TARGET_MODE;case 'p': return CMD_TARGET_PREV_TARGET;case 'f': case 't': return CMD_TARGET_MAYBE_PREV_TARGET;case '-': return CMD_TARGET_CYCLE_BACK;case '+': case '=': return CMD_TARGET_CYCLE_FORWARD;case ';': case '/': return CMD_TARGET_OBJ_CYCLE_BACK;case '*': case '\'': return CMD_TARGET_OBJ_CYCLE_FORWARD;case 'b': return CMD_TARGET_DOWN_LEFT;case 'h': return CMD_TARGET_LEFT;case 'j': return CMD_TARGET_DOWN;case 'k': return CMD_TARGET_UP;case 'l': return CMD_TARGET_RIGHT;case 'n': return CMD_TARGET_DOWN_RIGHT;case 'u': return CMD_TARGET_UP_RIGHT;case 'y': return CMD_TARGET_UP_LEFT;case 'B': return CMD_TARGET_DIR_DOWN_LEFT;case 'H': return CMD_TARGET_DIR_LEFT;case 'J': return CMD_TARGET_DIR_DOWN;case 'K': return CMD_TARGET_DIR_UP;case 'L': return CMD_TARGET_DIR_RIGHT;case 'N': return CMD_TARGET_DIR_DOWN_RIGHT;case 'U': return CMD_TARGET_DIR_UP_RIGHT;case 'Y': return CMD_TARGET_DIR_UP_LEFT;default: return CMD_NO_CMD;}}bool targeting_behaviour::should_redraw(){return (false);}
show_specific_help( targeting_help );
column_composer cols(2, 41);// Page size is number of lines - one line for --more-- prompt.cols.set_pagesize(get_number_of_lines() - 1);cols.add_formatted(0, targeting_help_1, true, true);cols.add_formatted(1, targeting_help_2, true, true);show_keyhelp_menu(cols.formatted_lines(), false, true);