Trying to figure out why gold is not always autopicked up

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ewert
    Knight
    • Jul 2009
    • 702

    Trying to figure out why gold is not always autopicked up

    Okay, browsing through the game files, I have come to this conclusion:

    Gold is free to pickup energywise based on game files
    Moving on top of =g items manually seems to autopickup those (energy free?) even if monsters are visible, based on just playing the game. Does it cost extra energy? Not quire sure what the code means with that ...

    Player disturb flushes cmd queue
    If running (moving with shift down for me) on top of a gold pile, and the character moving causes a disturbance (new monster, monster moves, yadda yadda), it will trigger a disturb to flush cmd queue
    However, this ALSO flushes the autopickup command from the cmd queue
    Hence, gold will stay on ground, causing me to backtrack and be annoyed with QoL gameplay issues

    I guess my question at this point is:
    Does autopickup for ammo for example cost extra energy when moving on them?
    If so, that is causing me extra risk sometimes, ouch
    If not, then I could just adjust the code to re-insert the autopickup cmd to the cmdqueue after the disturb in the disturb code?


    Also, the 'obvious things' isn't that obvious to me, lol. If I understand it correctly, if the autopickup picks up more than move energy cost / 10 items the move action costs 0.1x items picked up, otherwise normal move cost? So without +Steps items, and move energy cost of 100, any movement that picks up more than 10 autopickup items will cost more energy?

    Here is the code ... Does ammo calculate as 1/40 items per item? So a full stack is just 1 item? Gah ...
    Code:
    /**
     * Pick up or look at objects on a square when the player steps onto it
     */
    void do_cmd_autopickup(struct command *cmd)
    {
    	/* Get the obvious things */
    	player->upkeep->energy_use = do_autopickup(player)
    		* z_info->move_energy / 10;
    	if (player->upkeep->energy_use > z_info->move_energy)
    		player->upkeep->energy_use = z_info->move_energy;
    
    	/* Look at or feel what's left */
    	event_signal(EVENT_SEEFLOOR);
    
    	/* Redraw the object list using the upkeep flag so that the update can be
    	 * somewhat coalesced. Use event_signal(EVENT_ITEMLIST to force update. */
    	player->upkeep->redraw |= (PR_ITEMLIST);
    }
    Sorry rambling questions. Initially, from what I understand, I can just re-insert autopickup into after the cmd queue flush in the player/moved/disturb code, and would fix this issue for me?
  • ewert
    Knight
    • Jul 2009
    • 702

    #2
    No wait, that is the other way around in the code ...
    Energy use would be items * move-energy / 10, maxed out at move-energy?
    But but but ... why the heck do we even then calculate this energy stuff on autopickup, since we already are moving and will be deducting the move-energy anyways? I am confused ...

    Comment

    • backwardsEric
      Knight
      • Aug 2019
      • 527

      #3
      After a walk or a run moves the player, this is a streamlined version of what will happen:
      1. Autopickup command is added to the command queue.
      2. Take away the energy for the move.
      3. Update the distances to monsters. This can disturb the player, flushing the autopickup command from the queue.
      4. Since energy was used, monsters may act. If they do, that can also disturb the player, flushing the autopickup command from the queue.
      5. Execute the next command in the command queue. If it's the autopickup command, each stack picked up will end using 1/10 of a full move's energy, but the total energy used is capped at a full move's energy.


      For fixing the annoyance of gold not being automatically picked up in some situations, a call to player_pickup_gold() gold could be added (would have to make it a public function as well) when the autopickup command is added to the command queue. That would slightly change the timing for the pickup of the gold but would avoid disturbances preventing the gold from being picked up.

      Comment

      • ewert
        Knight
        • Jul 2009
        • 702

        #4
        Yeah that was one thing I was thinking, that might need to create the gold pickup into those function definition files outside of pickup file ... the energy cost lines confuse me a bit, are the -> things calling for checks or for actually reducing energy.

        To be safer for doubledisturbance avoidance, I guess I need to make the gold pickup separate and have it called separately before checking for disturbances after a move.

        Comment

        Working...
        😀
        😂
        🥰
        😘
        🤢
        😎
        😞
        😡
        👍
        👎