Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

Reply
 
Thread Tools Display Modes
Old May 29, 2022, 06:04   #1
ewert
Knight
 
Join Date: Jul 2009
Posts: 654
ewert is on a distinguished road
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 is offline   Reply With Quote
Old May 29, 2022, 06:08   #2
ewert
Knight
 
Join Date: Jul 2009
Posts: 654
ewert is on a distinguished road
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 ...
ewert is offline   Reply With Quote
Old June 4, 2022, 13:55   #3
backwardsEric
Swordsman
 
Join Date: Aug 2019
Posts: 295
backwardsEric is on a distinguished road
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.
backwardsEric is offline   Reply With Quote
Old June 5, 2022, 09:36   #4
ewert
Knight
 
Join Date: Jul 2009
Posts: 654
ewert is on a distinguished road
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.
ewert is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can anyone help me figure out why I am -8 speed? ehertlein Vanilla 16 March 4, 2021 15:38
[4.2.1] How to figure out why am I slow? Monk Vanilla 45 July 14, 2020 16:22
Gold and no_selling Sirridan Vanilla 120 January 19, 2011 21:48
Squelching for gold Nick Vanilla 31 August 14, 2009 16:14
V3.0.9 Negative gold? Dragonboneman Vanilla 7 February 2, 2008 14:10


All times are GMT +1. The time now is 14:42.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2022, vBulletin Solutions Inc.