New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RDY] Rework hordes hearing signal calculation #19222

Merged
merged 19 commits into from Nov 19, 2016

Conversation

Projects
None yet
4 participants
@Firestorm01X2
Contributor

Firestorm01X2 commented Nov 9, 2016

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:

  • New method of calculation that calculates overmap distance hearing for hordes "naturally". Just like if normal volume in tiles reach it. With certain modification;
  • New formula that normalizes hearing sounds to overmap without coefficient. It can be easily tweaked further. Actually it scales sound interval like [X1,Y1] to overmap interval [X2,Y2] (http://stackoverflow.com/questions/929103/convert-a-number-range-to-another-range-maintaining-ratio) (not in use now. may be useful in future) (removed from code for now. upper is better);
  • Reduced hearing for hordes. Now city hordes should not hear you if you are deep in wilderness;
  • Hordes will hear only really loud sound that can leave reality bubble;
  • Hordes can actually hear you underground and above ground. However if you stay under ground then ground cover sound partially. The lower you are - less sound you produce for hordes.

Discussion is here:
http://smf.cataclysmdda.com/index.php?topic=13632.0

@Firestorm01X2

This comment has been minimized.

Show comment
Hide comment
@Firestorm01X2

Firestorm01X2 Nov 9, 2016

Contributor

Currently sound interval like [0,180] scaled to [0,8];

Contributor

Firestorm01X2 commented Nov 9, 2016

Currently sound interval like [0,180] scaled to [0,8];

[61,200]=>[4,9]
Min cap volume 61
@Firestorm01X2

This comment has been minimized.

Show comment
Hide comment
@Firestorm01X2

Firestorm01X2 Nov 10, 2016

Contributor

How much loudnsess at max player can produce? 200 or even potentially more?

Contributor

Firestorm01X2 commented Nov 10, 2016

How much loudnsess at max player can produce? 200 or even potentially more?

@Coolthulhu

This comment has been minimized.

Show comment
Hide comment
@Coolthulhu

Coolthulhu Nov 10, 2016

Contributor

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.

Contributor

Coolthulhu commented Nov 10, 2016

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.

Extra code placed in funtions.
Added alternate simple solution.
@Firestorm01X2

This comment has been minimized.

Show comment
Hide comment
@Firestorm01X2

Firestorm01X2 Nov 11, 2016

Contributor

Wraped extra code in functions.
Also alternate simple solution added. Just divide volume/30+1 .30 - is overmap tile (almost). Pretty straightforward and logical solution. This way is connected with normal volume calculation.
New method still in place. But maybe more simplier and natural method should be preffered?

Contributor

Firestorm01X2 commented Nov 11, 2016

Wraped extra code in functions.
Also alternate simple solution added. Just divide volume/30+1 .30 - is overmap tile (almost). Pretty straightforward and logical solution. This way is connected with normal volume calculation.
New method still in place. But maybe more simplier and natural method should be preffered?

Show outdated Hide outdated src/sounds.cpp Outdated
Show outdated Hide outdated src/sounds.cpp Outdated
Show outdated Hide outdated src/sounds.cpp Outdated
Removed tabs
Refactored vars name
Limit to horde hearing correcly set to reality bubble (22*3)
Changes simple version of alghoritm to match overmap tile size
@Firestorm01X2

This comment has been minimized.

Show comment
Hide comment
@Firestorm01X2

Firestorm01X2 Nov 11, 2016

Contributor
  • Removed tabs
  • Refactored vars name
  • Limit to horde hearing correctly set to reality bubble (22*3)
  • Changes simple version of algorithm to match overmap tile size

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.

Contributor

Firestorm01X2 commented Nov 11, 2016

  • Removed tabs
  • Refactored vars name
  • Limit to horde hearing correctly set to reality bubble (22*3)
  • Changes simple version of algorithm to match overmap tile size

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.

@Firestorm01X2

This comment has been minimized.

Show comment
Hide comment
@Firestorm01X2

Firestorm01X2 Nov 11, 2016

Contributor

What is the max volume that potentially can be produced ingame?

Contributor

Firestorm01X2 commented Nov 11, 2016

What is the max volume that potentially can be produced ingame?

@Coolthulhu

This comment has been minimized.

Show comment
Hide comment
@Coolthulhu

Coolthulhu Nov 11, 2016

Contributor

Limit to horde hearing correctly set to reality bubble (22*3)

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.

What is the max volume that potentially can be produced ingame?

There is no real limit. Unless I'm missing something, ANFO charge explosion should produce 4500 units of sound volume.

Now there are 2 versions of calculation algorithm.

The simple one looks good enough. We don't need precision here, but readability is always a plus.

Contributor

Coolthulhu commented Nov 11, 2016

Limit to horde hearing correctly set to reality bubble (22*3)

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.

What is the max volume that potentially can be produced ingame?

There is no real limit. Unless I'm missing something, ANFO charge explosion should produce 4500 units of sound volume.

Now there are 2 versions of calculation algorithm.

The simple one looks good enough. We don't need precision here, but readability is always a plus.

Show outdated Hide outdated src/sounds.cpp Outdated
@Coolthulhu

This comment has been minimized.

Show comment
Hide comment
@Coolthulhu

Coolthulhu Nov 11, 2016

Contributor

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 process_sounds. Currently it will stop signaling hordes if the player gets underground, even if the noise sources (NPC with a shotgun, turrets etc.) are on the surface.

Contributor

Coolthulhu commented Nov 11, 2016

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 process_sounds. Currently it will stop signaling hordes if the player gets underground, even if the noise sources (NPC with a shotgun, turrets etc.) are on the surface.

@Coolthulhu

This comment has been minimized.

Show comment
Hide comment
@Coolthulhu

Coolthulhu Nov 11, 2016

Contributor

Needs some styling:

  • Spaces within parentheses: if( x ), not if( x), if(x) or if(x )
  • Tabs to spaces (there are still some tabs in the diff)
  • Spaces around operators: int x = a, not int x=a
Contributor

Coolthulhu commented Nov 11, 2016

Needs some styling:

  • Spaces within parentheses: if( x ), not if( x), if(x) or if(x )
  • Tabs to spaces (there are still some tabs in the diff)
  • Spaces around operators: int x = a, not int x=a
@Firestorm01X2

This comment has been minimized.

Show comment
Hide comment
@Firestorm01X2

Firestorm01X2 Nov 12, 2016

Contributor

Also is sound unit (vol in my case) in tiles exactly?
An abot that explosion of 4500 - top capped is needed in this case.

Contributor

Firestorm01X2 commented Nov 12, 2016

Also is sound unit (vol in my case) in tiles exactly?
An abot that explosion of 4500 - top capped is needed in this case.

@Coolthulhu

This comment has been minimized.

Show comment
Hide comment
@Coolthulhu

Coolthulhu Nov 12, 2016

Contributor

Also is sound unit (vol in my case) in tiles exactly?

Yes.

An abot that explosion of 4500 - top capped is needed in this case.

Cap around 150 would be fine. Alternatively, a soft cap, with everything above the cap going through some hardcore stepdown, like: if( sig > 8 ) sig = 8 + log( sig - 8 ).

Contributor

Coolthulhu commented Nov 12, 2016

Also is sound unit (vol in my case) in tiles exactly?

Yes.

An abot that explosion of 4500 - top capped is needed in this case.

Cap around 150 would be fine. Alternatively, a soft cap, with everything above the cap going through some hardcore stepdown, like: if( sig > 8 ) sig = 8 + log( sig - 8 ).

* z-level now getting from sound position
* Added soft cap to get_signal_for_hordes_simple function
* Divider in get_signal_for_hordes_simple  now equal to tiles in overmap tiles 2 * SEEX
* Refactored code
* Added bunch of coefficients to correct signal value
* Both funtions balanced to:
      glock 19 shot - 5  overmaptiles
      autoshotgun shot  - 6  overmaptiles
      amininuke explosive  - 11-12  overmaptiles
@Firestorm01X2

This comment has been minimized.

Show comment
Hide comment
@Firestorm01X2

Firestorm01X2 Nov 12, 2016

Contributor

Both functions now balanced to:
glock 19 shot - 5 overmaptiles,
autoshotgun shot - 6 overmaptiles,
mininuke explosive - 11-12 overmaptiles.

Contributor

Firestorm01X2 commented Nov 12, 2016

Both functions now balanced to:
glock 19 shot - 5 overmaptiles,
autoshotgun shot - 6 overmaptiles,
mininuke explosive - 11-12 overmaptiles.

@pisskop

This comment has been minimized.

Show comment
Hide comment
@pisskop

pisskop Nov 12, 2016

Contributor

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.

Contributor

pisskop commented Nov 12, 2016

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.

@Firestorm01X2

This comment has been minimized.

Show comment
Hide comment
@Firestorm01X2

Firestorm01X2 Nov 12, 2016

Contributor

Ok. Let's set my special coefficient to zero.

Contributor

Firestorm01X2 commented Nov 12, 2016

Ok. Let's set my special coefficient to zero.

@Firestorm01X2

This comment has been minimized.

Show comment
Hide comment
@Firestorm01X2

Firestorm01X2 Nov 12, 2016

Contributor

"sound/6"

Gives you 27 overmap tiles with glock 19 and JHP ammo. It sounds at 160.
Before that PR it was sound/5.

Contributor

Firestorm01X2 commented Nov 12, 2016

"sound/6"

Gives you 27 overmap tiles with glock 19 and JHP ammo. It sounds at 160.
Before that PR it was sound/5.

@Firestorm01X2

This comment has been minimized.

Show comment
Hide comment
@Firestorm01X2

Firestorm01X2 Nov 12, 2016

Contributor

Now (last is mininuke. sig_power- disnance for horde in overmap tiles):
2016-11-12 21-54-18
2016-11-12 21-55-26
2016-11-12 21-56-10_m

Contributor

Firestorm01X2 commented Nov 12, 2016

Now (last is mininuke. sig_power- disnance for horde in overmap tiles):
2016-11-12 21-54-18
2016-11-12 21-55-26
2016-11-12 21-56-10_m

@Firestorm01X2

This comment has been minimized.

Show comment
Hide comment
@Firestorm01X2

Firestorm01X2 Nov 12, 2016

Contributor

Also you can see that actual sound from glock and autoshotgun almost similar.
So generally the most important question - from what distance horde should be able to hear gunshot?

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.

Contributor

Firestorm01X2 commented Nov 12, 2016

Also you can see that actual sound from glock and autoshotgun almost similar.
So generally the most important question - from what distance horde should be able to hear gunshot?

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.

@hmstanley

This comment has been minimized.

Show comment
Hide comment
@hmstanley

hmstanley Nov 12, 2016

Somewhat of an off topic question, Firestorm, what font are you using in game? I'd like to implement it.

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

This comment has been minimized.

Show comment
Hide comment
@Firestorm01X2

Firestorm01X2 Nov 15, 2016

Contributor

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.
Currently hordes react to shot from 6-7 tiles. Also it is matching rule: if you see horde - than it may then it will hear your shoot.

Also added balance coefficients for "Simple" function. It will help to balance it later.

Contributor

Firestorm01X2 commented Nov 15, 2016

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.
Currently hordes react to shot from 6-7 tiles. Also it is matching rule: if you see horde - than it may then it will hear your shoot.

Also added balance coefficients for "Simple" function. It will help to balance it later.

@pisskop

This comment has been minimized.

Show comment
Hide comment
@pisskop

pisskop Nov 16, 2016

Contributor

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

Contributor

pisskop commented Nov 16, 2016

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

horde signal roll changed. Now horde can hear sound that just reach i…
…t not only that overlap it

Slightly refactored code
@Firestorm01X2

This comment has been minimized.

Show comment
Hide comment
@Firestorm01X2

Firestorm01X2 Nov 16, 2016

Contributor

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.

Contributor

Firestorm01X2 commented Nov 16, 2016

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.

Renaming methods
Balancing coefs for standadrt method now floats as it should be
@Firestorm01X2

This comment has been minimized.

Show comment
Hide comment
@Firestorm01X2

Firestorm01X2 Nov 16, 2016

Contributor

Take notes that int get_signal_for_hordes_using_normalization is not in use now.
I use int get_signal_for_hordes( const centroid &centr ). Other method may be useful for future balancing.

Ok. I think that it is done.

pisskop, look at the:
int get_signal_for_hordes( const centroid &centr )
in sounds.cpp
There are coefficients for balancing. You can easily tweak them in your PR. To achieve 10 overmap tiles for pistol shot. Just set:
float sig_coef = 1.3;
instead of 1.

Do not forget that now we calculate signal in submaps not overmaps. 1 overmap = 2 submaps (approximately?). Signal rounded to higher number.

Ready.

Contributor

Firestorm01X2 commented Nov 16, 2016

Take notes that int get_signal_for_hordes_using_normalization is not in use now.
I use int get_signal_for_hordes( const centroid &centr ). Other method may be useful for future balancing.

Ok. I think that it is done.

pisskop, look at the:
int get_signal_for_hordes( const centroid &centr )
in sounds.cpp
There are coefficients for balancing. You can easily tweak them in your PR. To achieve 10 overmap tiles for pistol shot. Just set:
float sig_coef = 1.3;
instead of 1.

Do not forget that now we calculate signal in submaps not overmaps. 1 overmap = 2 submaps (approximately?). Signal rounded to higher number.

Ready.

@Firestorm01X2 Firestorm01X2 changed the title from [CR] [WIP] Rework hordes hearing signal calculation to [RDY] Rework hordes hearing signal calculation Nov 16, 2016

@Firestorm01X2

This comment has been minimized.

Show comment
Hide comment
@Firestorm01X2

Firestorm01X2 Nov 17, 2016

Contributor

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.

Contributor

Firestorm01X2 commented Nov 17, 2016

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.

Show outdated Hide outdated src/overmap.cpp Outdated
Show outdated Hide outdated src/sounds.cpp Outdated
Show outdated Hide outdated src/sounds.cpp Outdated
@Coolthulhu

This comment has been minimized.

Show comment
Hide comment
@Coolthulhu

Coolthulhu Nov 17, 2016

Contributor

And again: formatting. Spaces in ifs and no tabs.

Contributor

Coolthulhu commented Nov 17, 2016

And again: formatting. Spaces in ifs and no tabs.

@Firestorm01X2

This comment has been minimized.

Show comment
Hide comment
@Firestorm01X2

Firestorm01X2 Nov 17, 2016

Contributor

Now it is really ready.

Contributor

Firestorm01X2 commented Nov 17, 2016

Now it is really ready.

@Coolthulhu Coolthulhu self-assigned this Nov 19, 2016

@Coolthulhu Coolthulhu merged commit fc22123 into CleverRaven:master Nov 19, 2016

@pisskop

This comment has been minimized.

Show comment
Hide comment
@pisskop

pisskop Nov 19, 2016

Contributor

this means most basements and science migoa wont be heard by hordes.

does this affect player hearing or hearing spam

Contributor

pisskop commented Nov 19, 2016

this means most basements and science migoa wont be heard by hordes.

does this affect player hearing or hearing spam

@Firestorm01X2

This comment has been minimized.

Show comment
Hide comment
@Firestorm01X2

Firestorm01X2 Nov 19, 2016

Contributor

this means most basements and science migoa wont be heard by hordes.

About basements - before this PR hordes won't be able to hear sound from basement at all or from any level, different from surface.

Contributor

Firestorm01X2 commented Nov 19, 2016

this means most basements and science migoa wont be heard by hordes.

About basements - before this PR hordes won't be able to hear sound from basement at all or from any level, different from surface.

@Coolthulhu

This comment has been minimized.

Show comment
Hide comment
@Coolthulhu

Coolthulhu Nov 19, 2016

Contributor

About basements - before this PR hordes won't be able to hear sound from basement at all or from any level, different from surface at all.

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.

Contributor

Coolthulhu commented Nov 19, 2016

About basements - before this PR hordes won't be able to hear sound from basement at all or from any level, different from surface at all.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment