Changeset 1456 for trunk

Show
Ignore:
Timestamp:
06/29/09 13:13:34 (9 months ago)
Author:
ajps
Message:

Put checks for launchers and ammo being available when firing and throwing. Disable the repeat command in a couple more places where the inventory is reordered to stop wrong ammo, etc, being used (fixes #760).

Location:
trunk/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/attack.c

    r1417 r1456  
    491491        int msec = op_ptr->delay_factor * op_ptr->delay_factor; 
    492492 
     493        /* Get the "bow" */ 
     494        j_ptr = &inventory[INVEN_BOW]; 
     495 
     496        /* Require a usable launcher */ 
     497        if (!j_ptr->tval || !p_ptr->state.ammo_tval) 
     498        { 
     499                msg_print("You have nothing to fire with."); 
     500                return; 
     501        } 
     502 
    493503        /* Get item to fire and direction to fire in. */ 
    494504        item = args[0].item; 
    495505        dir = args[1].direction; 
    496506 
     507        /* Check the item being fired is usable by the player. */ 
     508        if (!item_is_available(item, NULL, (USE_INVEN | USE_FLOOR))) 
     509        { 
     510                msg_format("That item is not within your reach."); 
     511                return; 
     512        } 
     513 
    497514        /* Get the object for the ammo */ 
    498515        o_ptr = object_from_item_idx(item); 
    499516 
    500         /* Get the "bow" */ 
    501         j_ptr = &inventory[INVEN_BOW]; 
     517        /* Check the ammo can be used with the launcher */ 
     518        if (o_ptr->tval != p_ptr->state.ammo_tval) 
     519        { 
     520                msg_format("That ammo cannot be fired by your current weapon."); 
     521                return; 
     522        } 
    502523 
    503524        /* Base range XXX XXX */ 
     
    808829        dir = args[1].direction; 
    809830 
     831        /* Check the item being thrown is usable by the player. */ 
     832        if (!item_is_available(item, NULL, (USE_INVEN | USE_FLOOR))) 
     833        { 
     834                msg_format("That item is not within your reach."); 
     835                return; 
     836        } 
     837 
    810838        /* Get the object */ 
    811839        o_ptr = object_from_item_idx(item); 
  • trunk/src/object/obj-util.c

    r1448 r1456  
    23342334                /* Redraw stuff */ 
    23352335                p_ptr->redraw |= (PR_INVEN); 
     2336 
     2337                /* Inventory has changed, repeated command may use the wrong item */  
     2338                cmd_disable_repeat();            
    23362339        } 
    23372340 
     
    28932896 
    28942897        /* Message */ 
    2895         if (flag) msg_print("You combine some items in your pack."); 
     2898        if (flag) 
     2899        { 
     2900                msg_print("You combine some items in your pack."); 
     2901 
     2902                /* Stop "repeat last command" from working. */ 
     2903                cmd_disable_repeat(); 
     2904        } 
    28962905} 
    28972906