Changeset 119

Show
Ignore:
Timestamp:
05/07/07 06:06:43 (1 year ago)
Author:
takkaria
Message:

Commit Sangband-style object handling. This comes with the reduction of yet another option. :) (Leon Marrick)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/help/command.txt

    r80 r119  
    132132        may take a count, and takes some energy. 
    133133 
    134 Stay still (flip pickup) (g) 
    135         Stays in the same square for one move.  If you normally pick up 
    136         objects you encounter, you will not pick up whatever you are 
    137         standing on.  If you normally do not pick up objects, you will 
    138         pick up what you are standing on.  This command is normally only 
    139         used when the "always_pickup" option is false.  This command may 
    140         take a count, and takes some energy. 
     134Get objects (g) 
     135        Pick up objects and gold on the floor beneath you.  Picking up 
     136        gold takes no time, and objects take 1/10th of a normal turn each 
     137        (maximum time cost is a full turn).  You may pick up objects until 
     138        the floor is empty or your backpack is full. 
    141139 
    142140Rest (R) 
  • trunk/lib/help/option.txt

    r1 r119  
    3030    "[y/n]" prompt. 
    3131 
    32 ***** <floor_query_flag> 
    33 Prompt for floor item selection    [floor_query_flag] 
    34     Allows the user to select objects from the center of stacks.  Without 
    35     this option, the uppermost appropriate object will always be selected. 
    36  
    37 ***** <carry_query_flag> 
    38 Prompt before picking things up    [carry_query_flag] 
    39     Forces the game to ask your permission before allowing you to pick up 
    40     any object. 
    41  
    4232***** <use_old_target> 
    4333Use old target by default    [use_old_target] 
     
    4737 
    4838***** <always_pickup> 
    49 Pick things up by default    [always_pickup] 
    50     Tells the game that walking onto an item should attempt to pick it up. 
    51     Picking up objects in the manner takes no additional energy.  Note the 
    52     "g" and "-" commands, which can be used to "reverse" this option for a 
    53     single turn. 
     39***** <query_floor> 
     40Pick things up by default                     [always_pickup] 
     41Display things before picking them up         [query_floor] 
     42     When "always_pickup" is on, the game assumes you want to pick up 
     43     any object you encounter.  If "query_floor" is off, you pick up objects 
     44     automatically.  Otherwise, you are shown a list and prompted to pick up. 
     45 
     46     When "always_pickup" is off, the game assumes you want to pick 
     47     things up selectively.  If "query_floor" is off, you get a one-line 
     48     description of the object or pile.  If "query_floor" is on, you see a 
     49     full list, including weights.  In either case, you can start picking 
     50     things up by typing "g". 
     51 
     52     When standing still, you are never charged extra time for picking 
     53     up objects.  When walking, you always take a second partial turn to 
     54     pick up objects; each object picked up takes 1/10th of a turn. 
    5455 
    5556***** <always_repeat> 
  • trunk/lib/help/playing.txt

    r1 r119  
    8787 e  Equipment list                       E  Eat some food 
    8888 f  Fire an item                         F  Fuel your lantern/torch 
    89  g  Stay still (flip pickup)             G  Gain new spells/prayers 
     89 g  Get objects on floor                 G  Gain new spells/prayers 
    9090 h  (unused)                             H  (unused) 
    9191 i  Inventory list                       I  Observe an item 
     
    147147 e  Equipment list                       E  Eat some food 
    148148 f  Bash a door (force)                  F  Fuel your lantern/torch 
    149  g  Stay still (flip pickup)             G  Gain new spells/prayers 
     149 g  Get objects on floor                 G  Gain new spells/prayers 
    150150 h  (walk - west)                        H  (run - west) 
    151151 i  Inventory list                       I  Observe an item 
  • trunk/src/cmd1.c

    r112 r119  
    493493 * Determine if the object can be picked up, and has "=g" in its inscription. 
    494494 */ 
    495 static bool auto_pickup_okay(const object_type *o_ptr
     495static bool auto_pickup_okay(const object_type *o_ptr, bool check_pack
    496496{ 
    497497        cptr s; 
     
    508508                object_aware_p(o_ptr)) return (TRUE); 
    509509 
    510         /* No inscription */ 
    511         if (!o_ptr->note) return (FALSE); 
    512  
    513         /* Find a '=' */ 
    514         s = strchr(quark_str(o_ptr->note), '='); 
    515  
    516         /* Process inscription */ 
    517         while (s) 
    518         { 
    519                 /* Auto-pickup on "=g" */ 
    520                 if (s[1] == 'g') return (TRUE); 
    521  
    522                 /* Find another '=' */ 
    523                 s = strchr(s + 1, '='); 
     510        /* Option to vacuum up things on the floor (not recommended) */ 
     511        if ((always_pickup) && (!query_floor)) return (TRUE); 
     512 
     513        /* Check inscription */ 
     514        if (o_ptr->note) 
     515        { 
     516                /* Find a '=' */ 
     517                s = strchr(quark_str(o_ptr->note), '='); 
     518 
     519                /* Process permissions */ 
     520                while (s) 
     521                { 
     522                        /* =g ('g'et) means auto pickup */ 
     523                        if (s[1] == 'g') return (TRUE); 
     524 
     525                        /* Find another '=' */ 
     526                        s = strchr(s + 1, '='); 
     527                } 
     528        } 
     529 
     530        /* Optionally, check the backpack */ 
     531        if (check_pack) 
     532        { 
     533                int j; 
     534 
     535                /* Look for similar and inscribed */ 
     536                for (j = 0; j < INVEN_PACK; j++) 
     537                { 
     538                        object_type *j_ptr = &inventory[j]; 
     539 
     540                        /* Skip non-objects */ 
     541                        if (!j_ptr->k_idx) continue; 
     542 
     543                        /* The two items must be able to combine */ 
     544                        if (!object_similar(j_ptr, o_ptr)) continue; 
     545 
     546                        /* The backpack item must be inscribed */ 
     547                        if (!j_ptr->note) continue; 
     548 
     549                        /* Find a '=' */ 
     550                        s = strchr(quark_str(j_ptr->note), '='); 
     551 
     552                        /* Process permissions */ 
     553                        while (s) 
     554                        { 
     555                                /* =g ('g'et) means auto pickup */ 
     556                                if (s[1] == 'g') return (TRUE); 
     557 
     558                                /* Find another '=' */ 
     559                                s = strchr(s + 1, '='); 
     560                        } 
     561                } 
    524562        } 
    525563 
     
    530568 
    531569/* 
    532  * Helper routine for py_pickup() and py_pickup_floor(). 
    533  * 
    534  * Add the given dungeon object to the character's inventory. 
    535  * 
    536  * Delete the object afterwards. 
     570 * Carry an object and delete it. 
    537571 */ 
    538 static void py_pickup_aux(int o_idx
     572static void py_pickup_aux(int o_idx, bool msg
    539573{ 
    540574        int slot; 
    541575 
    542576        char o_name[80]; 
    543         object_type *o_ptr; 
    544  
    545         o_ptr = &o_list[o_idx]; 
     577        object_type *o_ptr = &o_list[o_idx]; 
    546578 
    547579        /* Carry the object */ 
    548580        slot = inven_carry(o_ptr); 
    549581 
    550         /* Get the object again */ 
     582        /* Handle errors (paranoia) */ 
     583        if (slot < 0) return; 
     584 
     585        /* Get the new object */ 
    551586        o_ptr = &inventory[slot]; 
    552587 
    553         /* Describe the object */ 
    554         object_desc(o_name, sizeof(o_name), o_ptr, TRUE, 3); 
    555  
    556         /* Message */ 
    557         msg_format("You have %s (%c).", o_name, index_to_label(slot)); 
     588        /* Optionally, display a message */ 
     589        if (msg) 
     590        { 
     591                /* Describe the object */ 
     592                object_desc(o_name, sizeof(o_name), o_ptr, TRUE, 3); 
     593 
     594                /* Message */ 
     595                msg_format("You have %s (%c).", o_name, index_to_label(slot)); 
     596        } 
    558597 
    559598        /* Delete the object */ 
     
    563602 
    564603/* 
    565  * Make the player carry everything in a grid. 
    566  * 
    567  * If "pickup" is FALSE then only gold will be picked up. 
     604 * Pick up objects and treasure on the floor.  -LM- 
     605 * 
     606 * Called with pickup: 
     607 * 0 to grab gold and describe non-gold objects. 
     608 * 1 to pick up objects either with or without displaying a menu. 
     609 * 2 to pick up objects, allowing cancel and quick pickup of single objects. 
     610 * 3 to pick up objects, forcing a menu for any number of objects. 
     611 * 
     612 * Use the "p_ptr->auto_pickup_okay" variable to allow or dis-allow 
     613 * automatically picking things up that take time.  (NOT INCLUDED) 
     614 * 
     615 * Scan the list of objects in that floor grid.   Pick up gold automatically. 
     616 * Pick up objects automatically until pile or backpack space is full if 
     617 * auto-pickup option is on, carry_query_floor option is not, and menus are 
     618 * not forced (which the "get" command does). Otherwise, store objects on 
     619 * floor in an array, and tally both how many there are and can be picked up. 
     620 * 
     621 * If not picking up anything, indicate objects on the floor.  Show more 
     622 * details if the "query_floor" option is set.  Do the same thing if we 
     623 * don't have room for anything. 
     624 * 
     625 * If we are picking up objects automatically, and have room for at least 
     626 * one, allow the "query_floor" option to display information about objects 
     627 * and prompt the player.  Otherwise, automatically pick up a single object 
     628 * or use a menu for more than one (this "blind" autopickup option is 
     629 * deprecated). 
     630 * 
     631 * Pick up multiple objects using Tim Baker's menu system.   Recursively 
     632 * call this function (forcing menus for any number of objects) until 
     633 * objects are gone, backpack is full, or player is satisfied. 
     634 * 
     635 * We keep track of number of objects picked up to calculate time spent. 
     636 * This tally is incremented even for automatic pickup, so we are careful 
     637 * (in "dungeon.c" and elsewhere) to handle pickup as either a separate 
     638 * automated move or a no-cost part of the stay still or 'g'et command. 
     639 * 
     640 * Note the lack of chance for the character to be disturbed by unmarked 
     641 * objects.  They are truly "unknown". 
    568642 */ 
    569 void py_pickup(int pickup) 
     643byte py_pickup(int pickup) 
    570644{ 
    571645        int py = p_ptr->py; 
    572646        int px = p_ptr->px; 
    573647 
     648        char o_name[80]; 
     649        char ch; 
     650 
    574651        s16b this_o_idx, next_o_idx = 0; 
    575652 
    576653        object_type *o_ptr; 
    577654 
    578         char o_name[80]; 
    579  
     655        /* Objects picked up.  Used to determine time cost of command. */ 
     656        byte objs_picked_up = 0; 
     657 
     658        int floor_num = 0, floor_list[MAX_FLOOR_STACK + 1], floor_o_idx = 0; 
     659 
     660        int can_pickup = 0; 
     661        bool call_function_again = FALSE; 
    580662        int sound_msg; 
    581         int last_o_idx = 0; 
    582  
    583         int can_pickup = 0; 
    584         int not_pickup = 0; 
     663 
     664        bool blind = ((p_ptr->timed[TMD_BLIND]) || (no_lite())); 
     665 
     666        bool force_display_list = FALSE; 
     667        bool msg = TRUE; 
     668 
     669 
     670        /* Nothing to pick up -- return */ 
     671        if (!cave_o_idx[py][px]) return (0); 
    585672 
    586673        /* Automatically destroy squelched items in pile if necessary */ 
    587674        squelch_pile(py, px); 
    588675 
    589         /* Scan the pile of objects */ 
     676 
     677        /* Scan the objects */ 
    590678        for (this_o_idx = cave_o_idx[py][px]; this_o_idx; this_o_idx = next_o_idx) 
    591679        { 
    592                 bool do_not_pickup = FALSE; 
    593  
    594680                /* Get the object */ 
    595681                o_ptr = &o_list[this_o_idx]; 
    596682 
    597                 /* Describe the object */ 
    598                 object_desc(o_name, sizeof(o_name), o_ptr, TRUE, 3); 
    599  
    600683                /* Get the next object */ 
    601684                next_o_idx = o_ptr->next_o_idx; 
    602685 
     686                /* Ignore all hidden objects */ 
     687                if (!o_ptr->marked) continue; 
     688 
     689                /* Paranoia -- ignore all dead objects  XXX */ 
     690                if (!o_ptr->k_idx) continue; 
     691 
    603692                /* Hack -- disturb */ 
    604693                disturb(0, 0); 
    605694 
    606 #if 0 
    607                 /* 
    608                  * I'm pretty sure this chunk of code is pointless, because 
    609                  * squelch_pile() should already have removed anything that is both 
    610                  * known and SQUELCH_ALWAYS.  OTOH, I didn't write it, so I leave it 
    611                  * here just in case.  -AS- 
    612                  */ 
    613  
    614                 /* End loop if squelched stuff reached */ 
    615                 if ((k_info[o_ptr->k_idx].squelch == SQUELCH_ALWAYS) && 
    616                         (k_info[o_ptr->k_idx].aware)) 
    617                 { 
    618                         next_o_idx = 0; 
    619                         continue; 
    620                 } 
    621 #endif 
    622695 
    623696                /* Pick up gold */ 
     
    630703 
    631704                        /* Message */ 
    632                         message_format(sound_msg, 0, "You have found %ld gold pieces worth of %s.", 
    633                                        (long)o_ptr->pval, o_name); 
     705                        message_format(sound_msg, 0, "You have found %s worth %ld gold pieces.", 
     706                               o_name, (long)o_ptr->pval); 
    634707 
    635708                        /* Collect the gold */ 
     
    649722                } 
    650723 
    651                 /*some items are marked to never pickup*/ 
    652                 if ((k_info[o_ptr->k_idx].squelch == NO_SQUELCH_NEVER_PICKUP) 
    653                         && object_aware_p(o_ptr)) 
    654                 { 
    655                         do_not_pickup = TRUE; 
    656                 } 
    657  
    658  
    659                 /* Test for auto-pickup */ 
    660                 if (auto_pickup_okay(o_ptr)) 
    661                 { 
    662                         /* Pick up the object */ 
    663                         py_pickup_aux(this_o_idx); 
    664  
    665                         /* Check the next object */ 
     724                /* Automatically pick up items into the backpack */ 
     725                if ((pickup) && (auto_pickup_okay(o_ptr, TRUE))) 
     726                { 
     727                        /* Pick up the object (with a message) */ 
     728                        py_pickup_aux(this_o_idx, TRUE); 
     729 
     730                        /* Take a small amount of time */ 
     731                        objs_picked_up++; 
    666732                        continue; 
    667733                } 
    668734 
    669                 /* Easy Floor */ 
    670                 if (easy_floor && !do_not_pickup) 
    671                 { 
    672                         /* Pickup if possible */ 
    673                         if (pickup && inven_carry_okay(o_ptr)) 
    674                         { 
    675                                 /* Pick up if allowed */ 
    676                                 if (!carry_query_flag) 
    677                                 { 
    678                                         /* Pick up the object */ 
    679                                         py_pickup_aux(this_o_idx); 
    680                                 } 
    681  
    682                                 /* Else count */ 
    683                                 else 
    684                                 { 
    685                                         /* Remember */ 
    686                                         last_o_idx = this_o_idx; 
    687  
    688                                         /* Count */ 
    689                                         ++can_pickup; 
    690                                 } 
    691                         } 
    692  
    693                         /* Else count */ 
     735                /* Tally objects and store them in an array. */ 
     736 
     737                /* Remember this object index */ 
     738                floor_list[floor_num] = this_o_idx; 
     739 
     740                /* Count non-gold objects that remain on the floor. */ 
     741                floor_num++; 
     742 
     743                /* Remember this index */ 
     744                floor_o_idx = this_o_idx; 
     745 
     746                /* Tally objects that can be picked up.*/ 
     747                if (inven_carry_okay(o_ptr)) 
     748                { 
     749                        can_pickup++; 
     750                } 
     751 
     752                /* XXX Hack -- Enforce limit */ 
     753                if (floor_num == MAX_FLOOR_STACK) break; 
     754        } 
     755 
     756        /* There are no objects left */ 
     757        if (!floor_num) return (objs_picked_up); 
     758 
     759 
     760        /* Mention the objects if player is not picking them up. */ 
     761        if (!pickup) 
     762        { 
     763                /* Optionally, display more information about floor items */ 
     764                if (query_floor) 
     765                { 
     766                        /* Scan all marked objects in the grid */ 
     767                        (void)scan_floor(floor_list, &floor_num, py, px, 0x03); 
     768 
     769                        /* Save screen */ 
     770                        screen_save(); 
     771 
     772                        /* Display objects on the floor */ 
     773                        show_floor(floor_list, floor_num, FALSE); 
     774 
     775                        /* Display prompt */ 
     776                        prt(format("You %s: ", 
     777                            (blind ? "feel something on the floor" : "see")), 0, 0); 
     778 
     779                        /* Move cursor back to character, if needed */ 
     780                        if (hilite_player) move_cursor_relative(p_ptr->py, p_ptr->px); 
     781 
     782                        /* Wait for it.  Use key as next command. */ 
     783                        p_ptr->command_new = inkey(); 
     784 
     785                        /* Restore screen */ 
     786                        screen_load(); 
     787                } 
     788 
     789                /* Display compact information */ 
     790                else 
     791                { 
     792                        /* One object */ 
     793                        if (floor_num == 1) 
     794                        { 
     795                                /* Get the object */ 
     796                                o_ptr = &o_list[floor_o_idx]; 
     797 
     798                                /* Describe the object.  Less detail if blind. */ 
     799                                if (blind) object_desc(o_name, sizeof(o_name), o_ptr, TRUE, 0); 
     800                                else       object_desc(o_name, sizeof(o_name), o_ptr, TRUE, 3); 
     801 
     802                                message_flush(); 
     803 
     804                                /* Message */ 
     805                                msg_format("You %s %s.", (blind ? "feel" : "see"), 
     806                                        o_name); 
     807                        } 
     808 
     809                        /* Several objects */ 
    694810                        else 
    695811                        { 
    696                                 /* Remember */ 
    697                                 last_o_idx = this_o_idx; 
    698  
    699                                 /* Count */ 
    700                                 ++not_pickup; 
    701                         } 
    702  
    703                         /* Check the next object */ 
    704                         continue; 
    705                 } 
    706  
    707                 /* Describe the object */ 
    708                 if (!pickup || do_not_pickup) 
    709                 { 
    710                         msg_format("You see %s.", o_name); 
    711  
    712                         /* Check the next object */ 
    713                         continue; 
    714                 } 
    715  
    716                 /* Note that the pack is too full */ 
    717                 if (!inven_carry_okay(o_ptr)) 
    718                 { 
     812                                message_flush(); 
     813 
     814                                /* Message */ 
     815                                msg_format("You %s a pile of %d items.", 
     816                                        (blind ? "feel" : "see"), floor_num); 
     817                        } 
     818                } 
     819 
     820                /* Done */ 
     821                return (objs_picked_up); 
     822        } 
     823 
     824 
     825        /* The player has no room for anything on the floor. */ 
     826        if (!can_pickup) 
     827        { 
     828                /* 
     829                 * One object -- Always display compact information.  This 
     830                 * should change if more information would actually be helpful. 
     831                 */ 
     832                if (floor_num == 1) 
     833                { 
     834                        /* Get the object */ 
     835                        o_ptr = &o_list[floor_o_idx]; 
     836 
     837                        /* Describe the object.  Less detail if blind. */ 
     838                        if (blind) object_desc(o_name, sizeof(o_name), o_ptr, TRUE, 0); 
     839                        else       object_desc(o_name, sizeof(o_name), o_ptr, TRUE, 3); 
     840 
     841                        /* Message */ 
     842                        message_flush(); 
    719843                        msg_format("You have no room for %s.", o_name); 
    720  
    721                         /* Check the next object */ 
    722                         continue; 
    723                 } 
    724  
    725                 /* Query before picking up */ 
    726                 if (carry_query_flag) 
    727                 { 
    728                         char out_val[160]; 
    729                         strnfmt(out_val, sizeof(out_val), "Pick up %s? ", o_name); 
    730                         if (!get_check(out_val)) continue; 
    731                 } 
    732  
     844                } 
     845 
     846                /* Several items */ 
     847                else 
     848                { 
     849                        /* Optionally, display more information about floor items */ 
     850                        if ((query_floor) || (force_display_list)) 
     851                        { 
     852                                /* Scan all marked objects in the grid */ 
     853                                (void)scan_floor(floor_list, &floor_num, py, px, 0x03); 
     854 
     855                                /* Save screen */ 
     856                                screen_save(); 
     857 
     858                                /* Display objects on the floor */ 
     859                                show_floor(floor_list, floor_num, FALSE); 
     860 
     861                                /* Display prompt */ 
     862                                prt("You have no room for the following objects: ", 0, 0); 
     863 
     864                                /* Move cursor back to character, if needed */ 
     865                                if (hilite_player) move_cursor_relative(p_ptr->py, p_ptr->px); 
     866 
     867                                /* Wait for it.  Use key as next command. */ 
     868                                p_ptr->command_new = inkey(); 
     869 
     870                                /* Restore screen */ 
     871                                screen_load(); 
     872                        } 
     873 
     874                        /* Display compact information */ 
     875                        else 
     876                        { 
     877                                /* Message -- not very informative */ 
     878                                message_flush(); 
     879                                msg_print("You have no room for any of the items on the floor."); 
     880                        } 
     881                } 
     882 
     883                /* Done */ 
     884                return (objs_picked_up); 
     885        } 
     886 
     887 
     888        /* We can pick up objects.  Menus are not requested (yet). */ 
     889        if (pickup != 3) 
     890        { 
     891                /* Scan all marked objects in the grid (again) */ 
     892                (void)scan_floor(floor_list, &floor_num, py, px, 0x03); 
     893 
     894                /* 
     895                 * If not deliberately picking up objects, and if requested or 
     896                 * potentially unsafe, ask the player to confirm all pickups. 
     897                 */ 
     898                if ((query_floor) && (pickup <= 1)) 
     899                { 
     900                        /* Save screen */ 
     901                        screen_save(); 
     902 
     903                        /* Display objects on the floor */ 
     904                        show_floor(floor_list, floor_num, FALSE); 
     905 
     906                        /* Display prompt */ 
     907                        if (floor_num == 1) 
     908                        { 
     909                                prt("Press Return to pick up this object: ", 0, 0); 
     910                        } 
     911                        else 
     912                        { 
     913                                prt("Press Return to pick up any of the following objects: ", 
     914                                        0, 0); 
     915                        } 
     916 
     917                        /* Move cursor back to character, if needed */ 
     918                        if (hilite_player) move_cursor_relative(p_ptr->py, p_ptr->px); 
     919 
     920                        /* Get response */ 
     921                        ch = inkey(); 
     922 
     923                        /* Restore screen */ 
     924                        screen_load(); 
     925 
     926                        /* We don't want to pick up this item */ 
     927                        if ((ch != '\r') && (ch != '\n') && (ch != 'g')) 
     928                        { 
     929                                /* Attempt to turn this command into a direction */ 
     930                                int dir = target_dir(ch); 
     931 
     932                                /* We used a movement command */ 
     933                                if (dir) 
     934                                { 
     935                                        /* Save as a new command; move later */ 
     936                                        p_ptr->command_new = ch; 
     937                                } 
     938 
     939                                /* Done */ 
     940                                return (objs_picked_up); 
     941                        } 
     942                } 
     943 
     944                /* Use a menu interface for multiple objects */ 
     945                if (floor_num > 1) 
     946                { 
     947                        pickup = 3; 
     948                } 
     949 
     950                /* Automatically pick up a single object */ 
     951                else 
     952                { 
     953                        /* Remember the object to pick up */ 
     954                        this_o_idx = floor_o_idx; 
     955                } 
     956        } 
     957 
     958        /* Display a list if requested. */ 
     959        if (pickup == 3) 
     960        { 
     961                cptr q, s; 
     962 
     963                int item; 
     964 
     965                /* Restrict the choices */ 
     966                item_tester_hook = inven_carry_okay; 
     967 
     968                /* Request a list */ 
     969                p_ptr->command_see = TRUE; 
     970 
     971                /* Get an object or exit. */ 
     972                q = "Get which item?"; 
     973                s = "You see nothing there."; 
     974                if (get_item(&item, q, s, (USE_FLOOR))) 
     975                { 
     976                        this_o_idx = 0 - item; 
     977                        call_function_again = TRUE; 
     978                } 
     979                else 
     980                { 
     981                        return (objs_picked_up); 
     982                } 
     983 
     984                /* With a list, we do not need explicit pickup messages */ 
     985                msg = FALSE; 
     986        } 
     987 
     988        /* Pick up object, if legal */ 
     989        if (this_o_idx) 
     990        { 
    733991                /* Pick up the object */ 
    734                 py_pickup_aux(this_o_idx); 
    735         } 
    736  
    737         /* Easy floor, objects left */ 
    738         if (easy_floor && (can_pickup + not_pickup > 0)) 
    739         { 
    740                 /* Not picking up */ 
    741                 if (!pickup) 
    742                 { 
    743                         /* One object */ 
    744                         if (not_pickup == 1) 
    745                         { 
    746                                 /* Get the object */ 
    747                                 o_ptr = &o_list[last_o_idx]; 
    748  
    749                                 /* Describe the object */ 
    750                                 object_desc(o_name, sizeof(o_name), o_ptr, TRUE, 3); 
    751  
    752                                 /* Message */ 
    753                                 msg_format("You see %s.", o_name); 
    754                         } 
    755  
    756                         /* Multiple objects */ 
    757                         else 
    758                         { 
    759                                 /* Message */ 
    760                                 msg_format("You see a pile of %d objects.", not_pickup); 
    761                         } 
    762  
    763                         /* Done */ 
    764                         return; 
    765                 } 
    766  
    767                 /* No room */ 
    768                 if (!can_pickup) 
    769                 { 
    770                         /* One object */ 
    771                         if (not_pickup == 1) 
    772                         { 
    773                                 /* Get the object */ 
    774                                 o_ptr = &o_list[last_o_idx]; 
    775  
    776                                 /* Describe the object */ 
    777                                 object_desc(o_name, sizeof(o_name), o_ptr, TRUE, 3); 
    778  
    779                                 /* Message */ 
    780                                 msg_format("You have no room for %s.", o_name); 
    781                         } 
    782  
    783                         /* Multiple objects */ 
    784                         else 
    785                         { 
    786                                 /* Message */ 
    787                                 msg_print("You have no room for any of the objects on the floor."); 
    788                         } 
    789  
    790                         /* Done */ 
    791                         return; 
    792                 } 
    793  
    794                 /* Pick up objects */ 
    795                 while (1) 
    796                 { 
    797                         cptr q, s; 
    798  
    799                         int item; 
    800  
    801                         /* Restrict the choices */ 
    802                         item_tester_hook = inven_carry_okay; 
    803  
    804                         /* Get an object*/ 
    805                         q = "Get which item? "; 
    806                         s = NULL; 
    807                         if (!get_item(&item, q, s, (USE_FLOOR))) break; 
    808  
    809                         /* Pick up the object */ 
    810                         py_pickup_aux(0 - item); 
    811                 } 
    812         } 
     992                py_pickup_aux(this_o_idx, msg); 
     993 
     994                /* Indicate an object picked up. */ 
     995                objs_picked_up = 1; 
     996        } 
     997 
     998        /* 
     999         * If requested, call this function recursively.  Count objects picked 
     1000         * up.  Force the display of a menu in all cases. 
     1001         */ 
     1002        if (call_function_again) objs_picked_up += py_pickup(3); 
     1003 
     1004        /* Indicate how many objects have been picked up. */ 
     1005        return (objs_picked_up); 
    8131006} 
     1007 
    8141008 
    8151009 
     
    12611455 * and also handles attempting to move into walls/doors/rubble/etc. 
    12621456 */ 
    1263 void move_player(int dir, int jumping
     1457void move_player(int dir, int do_pickup
    12641458{ 
    12651459        int py = p_ptr->py; 
     
    12811475        } 
    12821476 
    1283         /* Optionally alter known traps/doors on (non-jumping) movement */ 
    1284         else if (easy_alter && !jumping && 
     1477        /* Optionally alter known traps/doors on movement */ 
     1478        else if (easy_alter && 
    12851479                 (cave_info[y][x] & (CAVE_MARK)) && 
    12861480                 (cave_feat[y][x] >= FEAT_TRAP_HEAD) && 
    12871481                 (cave_feat[y][x] <= FEAT_DOOR_TAIL)) 
    12881482        { 
     1483                /* 
     1484                 * There should always be an explicit confirmation made before fiddling 
     1485                 * with traps.  XXX XXX 
     1486                 */ 
     1487 
    12891488                /* Not already repeating */ 
    12901489                if (!p_ptr->command_rep) 
     
    13891588                } 
    13901589 
    1391                 /* Handle "objects" */ 
    1392                 py_pickup(jumping != always_pickup); 
     1590                /* Handle objects now.  XXX XXX XXX */ 
     1591                p_ptr->energy_use += py_pickup(do_pickup) * 10; 
     1592 
     1593                /* 
     1594                 * The correct thing to do is to pick up objects *after* the map 
     1595                 * display updates post-move.  This involves about 30 lines of code 
     1596                 * and will be done on request.  -LM- 
     1597                 */ 
     1598 
    13931599 
    13941600                /* Handle "store doors" */ 
     
    21622368        p_ptr->energy_use = 100; 
    21632369 
    2164         /* Move the player */ 
     2370        /* Move the player.  Never pick up objects */ 
    21652371        move_player(p_ptr->run_cur_dir, FALSE); 
    21662372} 
    21672373 
     2374 
  • trunk/src/cmd2.c

    r112 r119  
    20512051 * Helper function for the "walk" and "jump" commands. 
    20522052 */ 
    2053 static void do_cmd_walk_or_jump(int jumping
     2053static void do_cmd_walk_or_jump(int do_pickup
    20542054{ 
    20552055        int y, x, dir; 
     
    20982098 
    20992099        /* Move the player */ 
    2100         move_player(dir, jumping); 
    2101 } 
    2102  
    2103  
    2104 /* 
    2105  * Walk into a grid. 
     2100        move_player(dir, do_pickup); 
     2101} 
     2102 
     2103 
     2104/* 
     2105 * Walk into a grid (pick up objects as set by the auto-pickup option) 
    21062106 */ 
    21072107void do_cmd_walk(void) 
    21082108{ 
    2109         /* Move (normal) */ 
    2110         do_cmd_walk_or_jump(FALSE); 
    2111 } 
    2112  
    2113  
    2114 /* 
    2115  * Jump into a grid. 
     2109        /* Move (usually pickup) */ 
     2110        do_cmd_walk_or_jump(always_pickup); 
     2111} 
     2112 
     2113 
     2114/* 
     2115 * Jump into a grid (flip pickup mode) 
    21162116 */ 
    21172117void do_cmd_jump(void) 
    21182118{ 
    2119         /* Move (jump) */ 
    2120         do_cmd_walk_or_jump(TRUE); 
     2119        /* Move (usually do not pickup) */ 
     2120        do_cmd_walk_or_jump(!always_pickup); 
    21212121} 
    21222122 
     
    22162216        } 
    22172217 
    2218         /* Handle "objects" */ 
    2219         py_pickup(pickup)
     2218        /* Handle objects now.  XXX XXX XXX */ 
     2219        p_ptr->energy_use += py_pickup(pickup) * 10
    22202220 
    22212221        /* Hack -- enter a store if we are on one */ 
     
    22452245 
    22462246 
    2247 /* 
    2248  * Stay still (usually do not pickup) 
    2249  */ 
    2250 void do_cmd_stay(void) 
    2251 
    2252         /* Stay still (usually do not pickup) */ 
    2253         do_cmd_hold_or_stay(!always_pickup); 
    2254 
     2247 
     2248/* 
     2249 * Pick up objects on the floor beneath you.  -LM- 
     2250 */ 
     2251void do_cmd_pickup(void) 
     2252
     2253        int energy_cost; 
     2254 
     2255        /* Pick up floor objects, forcing a menu for multiple objects. */ 
     2256        energy_cost = py_pickup(2) * 10; 
     2257 
     2258        /* Maximum time expenditure is a full turn. */ 
     2259        if (energy_cost > 100) energy_cost = 100; 
     2260 
     2261&