I don’t want to necro a 6-page thread, so I am starting fresh. The mechanics of scent have been discussed a fair bit in this thread: http://smf.cataclysmdda.com/index.php?topic=3811 and in this GitHub PR: https://github.com/CleverRaven/Cataclysm-DDA/pull/3818
As a summary, the goal of reworking scent is to make monster tracking less like a heat seeking missile and to slow down scent diffusion to support a sneaking mechanic. That means scent trails should be narrower and the cloud that surrounds the player should diffuse differently. Kevin summed up the roadmap for scent pretty well in his PR:
[ul][li]Making zombies (monsters with SMELLS, but not KEENNOSE) pause frequently when tracking by scent.[/li]
[li]Reduce sensitivity of scent ability when not KEENOSE[/li]
[li]Add upper threshold for scent intensity, if the area a monster is standing in is above it’s threshold, it can’t make a determination.[/li]
[li]Slow down scent diffusion.[/li][/ul]
He has rolled in #2 and #3. I have code locally that accomplishes #4 (and uses the discretized diffusion equation, which does better “conservation of mass” and should get rid of the wacky scents that occaisionally pop up). It’s about 50% slower than the current update_scent code, but I don’t notice a performance hit in my playtesting. I was going to do a PR, but… as I’ve been playing with the code a lot, I’ve noticed a couple of limitations that cannot be overcome in the current system.
[ol][li]scent only exists in a 40 x 40 window around the player. There is no way to extend this without exponentially increasing the amount of time it takes to compute scent.[/li]
[li]there is no good way to leave a “long lasting” scent trail. Partially because of the 40 x 40 window, but also because the player is the only source of scent. So dogs can’t smell the shirt you dropped, pick up your scent, and then follow the terrain that you walked on.[/li]
[li]adjusting diffusion affects everything, so to get a skinnier scent trail, you also get a proportionally smaller cloud around the player.[/li][/ol]
I have a proposal for changing how scent is represented that I think will be good, but I will need some help (or at least advice) in implementing it. Currently, scent is updated every turn as its own simulation, and this happens even if you are sleeping and there is absolutely no one near enough to smell you. I propose we instead keep track of the sources of scent that we leave (our tracks, but this could also include dropped items later), and then calculate the scent around a monster analytically if they are close enough to smell something. This would get rid of the 40 x 40 scent window, would allow us to make our footsteps leave traces of smell without them producing a big mushroom cloud, and boost game performance when there aren’t a bunch of nearby monsters smelling around for us. I think this also opens the door for adding wind. If implemented right, we could also account for z-levels (imagine zombies jumping out of apartment building windows because they smell you down below.) Also, you could set traps and drop used clothing on them to attract zombie dogs to their death.
I have the mechanics of what I want to implement pretty well hashed out. Deciding how to account for walls and windows is the hardest thing I have left. I’m struggling with decisions on the implementation side, like: do I give scent sources their own class? Do I add them to the map class or keep them separate? Do I search for scent sources over a grid around the monster, or do I just pass the monster coordinates to some scent function defined in the class description? Those are the things I will need some help with. I’ll go into more detail in the next post.