Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign up[RDY] Rework hordes hearing signal calculation #19222
Conversation
This comment has been minimized.
This comment has been minimized.
|
Currently sound interval like [0,180] scaled to [0,8]; |
This comment has been minimized.
This comment has been minimized.
|
How much loudnsess at max player can produce? 200 or even potentially more? |
This comment has been minimized.
This comment has been minimized.
|
Excessive defines make the code harder to read. They don't help here at all. If you want all of it to be easy to read, configure and reuse, just wrap the "volume transformation" into a function that takes base noise and outputs range. |
Oskar636
referenced this pull request
Nov 11, 2016
Closed
Rifle caliber ammo needs a damage nerf #19042
This comment has been minimized.
This comment has been minimized.
|
Wraped extra code in functions. |
Coolthulhu
reviewed
Nov 11, 2016
| int min_vol_for_hordes = 61; | ||
| int max_vol_for_hordes = 200; | ||
| int min_sig_power_for_hordes = 4; | ||
| int max_sig_power_for_hordes = 8; |
This comment has been minimized.
This comment has been minimized.
Coolthulhu
Nov 11, 2016
Contributor
Those names are giant, which makes it pretty hard to read the function.
It would be better if you shortened them to shortest readable name and added a comment if it's ambiguous.
For example min_signal, max_vol, vol_signal_coeff etc.
Coolthulhu
reviewed
Nov 11, 2016
| void sounds::process_sounds() | ||
| { | ||
| std::vector<centroid> sound_clusters = cluster_sounds( recent_sounds ); | ||
| std::vector<centroid> sound_clusters = cluster_sounds( recent_sounds ); |
This comment has been minimized.
This comment has been minimized.
Coolthulhu
Nov 11, 2016
Contributor
Looks like your IDE changed spaces here to tabs.
You'll need to change all tabs to 4 spaces each. Most IDEs support automatic tab->spaces.
Coolthulhu
reviewed
Nov 11, 2016
| int max_sig_power_for_hordes = 8; | ||
| //Lower the level- lower the sound | ||
| int vol_hordes=( (g->get_levz() < 0 ) ? vol/(per_level_down_vol_reduce_coef_for_hordes*std::abs(g->get_levz())) : vol); | ||
| //debugmsg( "vol_hordes %d g->get_levz() %d ",vol_hordes, g->get_levz()); |
This comment has been minimized.
This comment has been minimized.
Coolthulhu
Nov 11, 2016
Contributor
It may be a good idea to leave it in, but not as debugmsg, but add_msg( m_debug, ... ).
add_msg( m_debug only prints messages when in debug mode.
This comment has been minimized.
This comment has been minimized.
Now there are 2 versions of calculation algorithm. One- with normalization. Easily tweakable to any requirement. It just rescales volume to overmap tiles using min-max normalization. May be good for further balancing. Second- simple and clear. It is just divide sound volume to overmap size in player tiles. So volume/22 gives as horde signal. Sound levels are manageable. Shotgun shot should be heard from 8 overmap tiles. It is almost natural way to calculate horde signal. |
This comment has been minimized.
This comment has been minimized.
|
What is the max volume that potentially can be produced ingame? |
This comment has been minimized.
This comment has been minimized.
It's 24 per overmap tile. However reality bubble isn't exactly 3 overmap tiles, it's between 5 and 6 submaps (2.5 to 3 overmap tiles), because it isn't actually centered on the player, but on the submap containing the player.
There is no real limit. Unless I'm missing something, ANFO charge explosion should produce 4500 units of sound volume.
The simple one looks good enough. We don't need precision here, but readability is always a plus. |
Coolthulhu
reviewed
Nov 11, 2016
| { | ||
| int min_vol_cap = 67;//Hordes can't hear volume lower than this | ||
| int per_level_down_coef= 2;//Coeffficient for volume reduction undeground | ||
| int coef_for_hordes = 22;//Divider coefficent for hordes |
This comment has been minimized.
This comment has been minimized.
Coolthulhu
Nov 11, 2016
•
Contributor
Those two lower comments don't really add much.
Would be better like
int undeground_div = 2; // Underground noise is divided by this times number of z-levels below 0
int overmap_tile_size = 2 * SEEX; // Signal is in overmap tiles, volume in map tiles
This comment has been minimized.
This comment has been minimized.
|
That underground noise thing needs to get the z-level of noise source, not global z-level. To do that, you should pass it to the signal function from |
This comment has been minimized.
This comment has been minimized.
|
Needs some styling:
|
This comment has been minimized.
This comment has been minimized.
|
Also is sound unit (vol in my case) in tiles exactly? |
This comment has been minimized.
This comment has been minimized.
Yes.
Cap around 150 would be fine. Alternatively, a soft cap, with everything above the cap going through some hardcore stepdown, like: |
This comment has been minimized.
This comment has been minimized.
|
Both functions now balanced to: |
This comment has been minimized.
This comment has been minimized.
|
Since the thread was used as justification of this, Im weighing in. 5 tiles for s pistol is ridiculously small. thats a 5 minute walk. Ive suggests the rule of thumb "sound/6" as a guide. Thats double [10 tiles] for the pistol, and easily conservative in what it would draw. there should be no 'max range' for signal promulgation. If its loud enough the entire overmap should respond. The is no reason to think the zombie up the same city block as you cant hear a pistol fired. The claim for this PR is that using guns or explosives outside of cities is untenable, but unless Ive been playing a different game thats not an issue. Primarily because there are no nearby locations to spawn hordes. |
This comment has been minimized.
This comment has been minimized.
|
Ok. Let's set my special coefficient to zero. |
This comment has been minimized.
This comment has been minimized.
Gives you 27 overmap tiles with glock 19 and JHP ammo. It sounds at 160. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Also you can see that actual sound from glock and autoshotgun almost similar. Now there is also soft cap on 8 overmap tiles. Signal for horde louder than 8 overmap tiles will be reduced significantly using logarithmic function. |
This comment has been minimized.
This comment has been minimized.
hmstanley
commented
Nov 12, 2016
|
Somewhat of an off topic question, Firestorm, what font are you using in game? I'd like to implement it. |
Firestorm01X2
added some commits
Nov 15, 2016
This comment has been minimized.
This comment has been minimized.
|
Looks like I figured that out. rl_dist returns result in submaps. 1 overmap = 2 submaps (or at least approximately). So now I calculate singal spower in submaps. Also added balance coefficients for "Simple" function. It will help to balance it later. |
This comment has been minimized.
This comment has been minimized.
|
Guns dont really need a rework per se. A mile is probably equatable to 12 tiles or so. What should be fixed is how hordes draw hordes to themselves -but only within the reality bubble i.e your location |
This comment has been minimized.
This comment has been minimized.
|
Tests show that with 7 overmap tiles you can still draw horde from city while shooting in starting shelter. It is even without no signal modifying at all - without reducing it or increasing it with coefficients . It is surprisingly good results. Almost like someone planning extension of reality bubble. |
This comment has been minimized.
This comment has been minimized.
|
Take notes that int get_signal_for_hordes_using_normalization is not in use now. Ok. I think that it is done. pisskop, look at the: Do not forget that now we calculate signal in submaps not overmaps. 1 overmap = 2 submaps (approximately?). Signal rounded to higher number. Ready. |
Firestorm01X2
changed the title
[CR] [WIP] Rework hordes hearing signal calculation
[RDY] Rework hordes hearing signal calculation
Nov 16, 2016
This comment has been minimized.
This comment has been minimized.
|
Removed unused method. Signal value connected with horde interest value. So signal is not so independent. Also I can implement that altrnative method later but only if it will be needed. For now usual method of calculation produce fluid results. Ready. |
Coolthulhu
reviewed
Nov 17, 2016
| const int roll = rng( 0, mg.interest ); | ||
| add_msg( m_debug, "horde roll % d_inter %d dist %d", roll, d_inter, dist); |
This comment has been minimized.
This comment has been minimized.
Coolthulhu
reviewed
Nov 17, 2016
| //Capping minimum horde hearing signal | ||
| sig_power = ( ( sig_power < min_sig_cap ) ? min_sig_cap : sig_power ); | ||
| //Capping extremely high signal to hordes | ||
| sig_power = ( ( sig_power > max_sig_cap ) ? max_sig_cap : sig_power ); |
This comment has been minimized.
This comment has been minimized.
Coolthulhu
Nov 17, 2016
Contributor
It's clearer with std::min and std::max, like sig_power = std::min( sig_power, max_sig_cap ).
Also, the comment above suggests that the cap is soft (ie. that sig can sometimes go above it). Does it still do that? If not, the comment should be changed.
Coolthulhu
reviewed
Nov 17, 2016
| const int max_sig_cap = 26;//Signal for hordes beyond this cap will be reduced heavily | ||
| //Balancing coefs: | ||
| const float sig_coef = 1;// To make player life easier - make it less than one. To make harder - more than one | ||
| const float sig_modifier = 0;// To make player life easier - make it less than zero. To make harder - more than zero |
This comment has been minimized.
This comment has been minimized.
Coolthulhu
Nov 17, 2016
•
Contributor
This doesn't look useful for anything.
EDIT: Same for the line above it. Modifiers like that are trivial to add later, no need to keep them around.
This comment has been minimized.
This comment has been minimized.
|
And again: formatting. Spaces in |
Firestorm01X2
added some commits
Nov 17, 2016
This comment has been minimized.
This comment has been minimized.
|
Now it is really ready. |
Coolthulhu
self-assigned this
Nov 19, 2016
Coolthulhu
merged commit fc22123
into
CleverRaven:master
Nov 19, 2016
This comment has been minimized.
This comment has been minimized.
|
this means most basements and science migoa wont be heard by hordes. does this affect player hearing or hearing spam |
This comment has been minimized.
This comment has been minimized.
About basements - before this PR hordes won't be able to hear sound from basement at all or from any level, different from surface. |
This comment has been minimized.
This comment has been minimized.
Actually worse than that - old horde hearing would mean that hordes could hear a mi-go in the lab just fine, but only as long as the player stayed on 0 z-level. |



Firestorm01X2 commentedNov 9, 2016
•
edited
Currently wander spawn (aka hordes) is hardcore mode for hardcore players. Actually even players who play Cataclysm for long time and who want to increase difficulty tend to avoid wander spawn.
The main reason of that - horde can hear gunshot from insane distance and have tricky and unfinished spawn and moving algorithms.
This PR tries to fix insane hearing distance and rework hearing formula for hordes.
Here what we have new:
Discussion is here:
http://smf.cataclysmdda.com/index.php?topic=13632.0