Ejemplo n.º 1
0
Archivo: cmd3.c Proyecto: fph/mortsil
/*
 * Use an item, a unified 'use' command.
 */
void do_cmd_use_item(void)
{
	int item;
	object_type *o_ptr;
	cptr q, s;
	
	/* Unrestricted choice */
	item_tester_tval = 0;
	
	/* Get an item */
	q = "Use which item? ";
	s = "You have no items use.";
	if (!get_item(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR))) return;
	
	/* Get the item (in the pack) */
	if (item >= 0)
	{
		o_ptr = &inventory[item];
	}
	
	/* Get the item (on the floor) */
	else
	{
		o_ptr = &o_list[0 - item];
	}
	
	// determine the action based on the item type
	switch (o_ptr->tval)
	{
		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_MAIL:
		case TV_LIGHT:
		case TV_AMULET:
		case TV_RING:
		case TV_ARROW:
		case TV_FLASK:
		{
			if (item < INVEN_WIELD)
			{
				object_type *l_ptr = &inventory[INVEN_LITE];
				bool try_to_wield = TRUE;
				
				// possibly refuel a light
				if ((o_ptr->tval == TV_FLASK) || 
				    ((l_ptr->tval == o_ptr->tval) && (l_ptr->sval == o_ptr->sval) && 
				     ((o_ptr->sval == SV_LIGHT_TORCH) || (o_ptr->sval == SV_LIGHT_LANTERN))))
				{
					if ((l_ptr->sval == SV_LIGHT_TORCH) && (o_ptr->tval != TV_FLASK))
					{
						if ((o_ptr->timeout + l_ptr->timeout <= FUEL_TORCH) || 
							 get_check("Refueling from this torch will waste some fuel. Proceed? "))
						{
							do_cmd_refuel_torch(o_ptr, item);
						}
						else
						{
							try_to_wield = FALSE;
						}
						break;
					}
					else if (l_ptr->sval == SV_LIGHT_LANTERN)
					{
						if (((o_ptr->tval == TV_FLASK) && ((l_ptr->timeout + o_ptr->pval <= FUEL_LAMP) || get_check("Refueling from this flask will waste some fuel. Proceed? "))) ||
						    ((o_ptr->tval == TV_LIGHT) && (o_ptr->sval == SV_LIGHT_LANTERN) && ((l_ptr->timeout + o_ptr->timeout <= FUEL_LAMP) || get_check("Refueling from this lantern will waste some fuel. Proceed? "))))
						{
							do_cmd_refuel_lamp(o_ptr, item);
						}
						else
						{
							try_to_wield = FALSE;
						}
						break;
					}
					else if (o_ptr->tval == TV_FLASK)
					{
						msg_print("That can only be used to refuel a wielded lantern.");
						break;
					}
				}
				
				if (!item_tester_hook_wear(o_ptr))
				{
					msg_print("It is far too large to be worn.");
				}
				else if (try_to_wield)
				{
					do_cmd_wield(o_ptr, item);
				}
			}
			else
			{
				do_cmd_takeoff(o_ptr, item);
			}
			break;
		}
		case TV_NOTE:
		{
			note_info_screen(o_ptr);
			break;
		}
		case TV_METAL:
		{
			msg_print("To melt down pieces of mithril, take them to a forge and type (,).");
			break;
		}
		case TV_CHEST:
		{
			msg_print("You would need to put it down to open it.");
			break;
		}
		case TV_STAFF:
		{
			do_cmd_activate_staff(o_ptr, item);
			break;
		}
		case TV_TRUMPET:
		{
			do_cmd_play_instrument(o_ptr, item);
			break;
		}
		case TV_POTION:
		{
			do_cmd_quaff_potion(o_ptr, item);
			break;
		}
		case TV_FOOD:
		{
			do_cmd_eat_food(o_ptr, item);
			break;
		}
		default:
		{
			msg_print("It has no use.");
			break;
		}
	}
}
Ejemplo n.º 2
0
void commands_angband_keyset(int key_press, bool shift_key, bool alt_key, bool ctrl_key, bool meta_key)
{
    bool using_mods = FALSE;
    if (shift_key || alt_key || ctrl_key || meta_key) using_mods = TRUE;

    // Normal mode
    switch (key_press)
    {
        // ESCAPE
        case Qt::Key_Escape:
        {
            ui_center(p_ptr->py, p_ptr->px);
            break;
        }

        // Move down
        case Qt::Key_2:
        case Qt::Key_Down:
        {
            process_move_key(2, shift_key, alt_key, ctrl_key, meta_key);
            break;
        }

        // Move up
        case Qt::Key_8:
        case Qt::Key_Up:
        {
            process_move_key(8, shift_key, alt_key, ctrl_key, meta_key);
            break;
        }

        // Move left
        case Qt::Key_4:
        case Qt::Key_Left:
        {
            process_move_key(4, shift_key, alt_key, ctrl_key, meta_key);
            break;
        }
        // Move right
        case Qt::Key_6:
        case Qt::Key_Right:
        {
            process_move_key(6, shift_key, alt_key, ctrl_key, meta_key);
            break;
        }
        // Move diagonally left and up
        case Qt::Key_7:
        case Qt::Key_Home:
        {
            process_move_key(7, shift_key, alt_key, ctrl_key, meta_key);
            break;
        }
        // Move diagonally right and up
        case Qt::Key_9:
        case Qt::Key_PageUp:
        {
            process_move_key(9, shift_key, alt_key, ctrl_key, meta_key);
            break;
        }
        // Move diagonally left and down
        case Qt::Key_1:
        case Qt::Key_End:
        {
            process_move_key(1, shift_key, alt_key, ctrl_key, meta_key);
            break;
        }
        // Move diagonally right and down
        case Qt::Key_3:
        case Qt::Key_PageDown:
        {
            process_move_key(3, shift_key, alt_key, ctrl_key, meta_key);
            break;
        }
        case Qt::Key_5:
        case Qt::Key_Clear:
        {
            do_cmd_hold();
            break;
        }
        case Qt::Key_A:
        {
            if (alt_key)           do_cmd_wizard_mode();
            else if (shift_key)          do_cmd_activate();
            else if (!using_mods)   do_cmd_aim_wand();
            break;
        }
        case Qt::Key_B:
        {
            if (shift_key)          do_cmd_bash(DIR_UNKNOWN);
            else if (!using_mods)   do_cmd_browse(-1);
            break;
        }
        case Qt::Key_C:
        {
            if (shift_key && alt_key) save_character_file();
            else if (shift_key)     do_cmd_character_screen();
            else if (!using_mods)   do_cmd_close(DIR_UNKNOWN);
            break;
        }
        case Qt::Key_D:
        {
            if (shift_key)          do_cmd_disarm(DIR_UNKNOWN);
            else if (!using_mods)   do_cmd_drop();
            break;
        }
        case Qt::Key_E:
        {
            if (shift_key)          do_cmd_eat_food();
            else if (!using_mods)   do_cmd_all_objects(TAB_EQUIP);
            break;
        }
        case Qt::Key_F:
        {
            if (ctrl_key)           do_cmd_feeling();
            else if (shift_key)     do_cmd_refuel();
            else if (!using_mods)   do_cmd_fire();
            break;
        }
        case Qt::Key_G:
        {
            if (shift_key)          do_cmd_study(-1);
            else if (!using_mods)   do_cmd_pickup_from_pile(FALSE, TRUE);
            break;
        }
        case Qt::Key_H:
        {
            if (!using_mods)        do_cmd_fire_at_nearest();
            break;
        }
        case Qt::Key_I:
        {
            if (shift_key)          do_cmd_examine();
            else if (!using_mods)   do_cmd_all_objects(TAB_INVEN);
            break;
        }
        case Qt::Key_J:
        {
            if (!using_mods)        do_cmd_spike(DIR_UNKNOWN);
            break;
        }
        case Qt::Key_K:
        {
            if (!using_mods)        do_cmd_destroy();
            break;
        }
        case Qt::Key_L:
        {
            if (shift_key)          ui_center(p_ptr->py, p_ptr->px);
            else if (!using_mods)   do_cmd_look();
            break;
        }
        case Qt::Key_M:
        {
            if (shift_key)          break; // TODO - MAP
            else if (!using_mods)   do_cmd_cast(-1);
            break;
        }
        case Qt::Key_N:
        case Qt::Key_0:
        case Qt::Key_Insert:
        {
            if (!using_mods)        do_cmd_repeat();
            break;
        }
        case Qt::Key_O:
        {
            if (shift_key)          do_cmd_make_trap(DIR_UNKNOWN);
            else if (!using_mods)   do_cmd_open(DIR_UNKNOWN);
            break;
        }
        case Qt::Key_P:
        {
            if (ctrl_key)           display_message_log();
            else if (!using_mods)   do_cmd_cast(-1);
            break;
        }
        case Qt::Key_Q:
        {
            if (alt_key)            do_cmd_quest_desc();
            else if (shift_key)     do_cmd_suicide();
            else if (!using_mods)   do_cmd_quaff_potion();
            break;
        }
        case Qt::Key_R:
        {
            if (ctrl_key)           ui_redraw_all();
            else if (shift_key)     do_cmd_rest();
            else if (!using_mods)   do_cmd_read_scroll();
            break;
        }
        case Qt::Key_S:
        {
            if (shift_key)          do_cmd_toggle_search();
            else if (!using_mods)   do_cmd_search();
            break;
        }
        case Qt::Key_T:
        {
            if (shift_key)          do_cmd_tunnel(DIR_UNKNOWN);
            else if (!using_mods)   do_cmd_takeoff();
            break;
        }
        case Qt::Key_U:
        {
            if (!using_mods)        do_cmd_use_staff();
            break;
        }
        case Qt::Key_V:
        {
            if (!using_mods)        do_cmd_throw();
            break;
        }
        case Qt::Key_W:
        {
            if (!using_mods)   do_cmd_wield();
            break;
        }
        case Qt::Key_X:
        {
            if (!using_mods)        do_cmd_swap_weapon();
            break;
        }
        case Qt::Key_Y:
        {
            break;
        }
        case Qt::Key_Z:
        {
            if (!using_mods)        do_cmd_zap_rod();
            break;
        }
        case Qt::Key_Apostrophe:
        case Qt::Key_Asterisk:
        {
            target_set_closest(TARGET_KILL);
            break;
        }
        case Qt::Key_BraceLeft:
        {
            do_cmd_inscribe();
            break;
        }
        case Qt::Key_BraceRight:
        {
            do_cmd_uninscribe();
            break;
        }
        case Qt::Key_Greater:
        {
            do_cmd_go_down();
            break;
        }
        case Qt::Key_Less:
        {
            do_cmd_go_up();
            break;
        }
        case Qt::Key_Period:
        {
            do_cmd_run(DIR_UNKNOWN);
            break;
        }
        case Qt::Key_Plus:
        {
            do_cmd_alter(DIR_UNKNOWN);
            break;
        }
        case Qt::Key_Minus:
        {
            do_cmd_walk(DIR_UNKNOWN, TRUE);
            break;
        }
        case Qt::Key_Underscore:
        case Qt::Key_Comma:
        {
            do_cmd_hold();
            break;
        }
        case Qt::Key_Semicolon:
        {
            do_cmd_walk(DIR_UNKNOWN, FALSE);
            break;
        }
        case Qt::Key_Colon:
        {
            do_cmd_write_note();
            break;
        }
        case Qt::Key_ParenRight:
        {
            save_screenshot(FALSE);
            break;
        }
        case Qt::Key_ParenLeft:
        {
            save_screenshot(TRUE);
            break;
        }
        case Qt::Key_AsciiTilde:
        {
            do_cmd_knowledge_screens();
            break;
        }
        default:
        {
            break;
        }
    }
}