SUBSIM Radio Room Forums



SUBSIM: The Web's #1 resource for all submarine & naval simulations since 1997

Go Back   SUBSIM Radio Room Forums > Silent Hunter 3 - 4 - 5 > SH5 Mods Workshop
Forget password? Reset here

Reply
 
Thread Tools Display Modes
Old 03-24-14, 03:38 AM   #3016
ReallyDedPoet
Canadian Wolf
 
ReallyDedPoet's Avatar
 
Join Date: Jul 2006
Location: The one and only East Coast
Posts: 10,775
Downloads: 946
Uploads: 5


Default [TEC] SH5.exe patches to fix bugs and add functionality

Was adjusting some of the patch stuff last night. The game has really gotten intricate, but in a good way. The above sounds incredible.
__________________

Back in the Day



ReallyDedPoet is offline   Reply With Quote
Old 03-24-14, 06:03 AM   #3017
Tonci87
Captain
 
Join Date: Jun 2012
Posts: 547
Downloads: 116
Uploads: 0


Default

Quote:
Originally Posted by TheDarkWraith View Post
Let's talk about our crew's ability to see visual targets. I've been looking over the game code for this and figured out how the game determines when our crew 'sees' a visual contact.

As you may or may not know the crew's ability to see is because of the AI_Visual sensor attached to the submarine. If we look at the data\Cfg\Sensors.cfg file we see no parameter for minimum signal strength as is found in \data\Cfg\Sim.cfg. The game does some lengthy computations using all the values in data\Cfg\Sensors.cfg's Visual parameters to come up with a derived minimum signal strength. The last thing the game does is check to see if it's nighttime.

Nighttime is an on/off thing - it's either nighttime or it's not. This does not model real life! The game has a hard coded value of 0.283 as the value for determining it's nighttime. If the current light amount value is < 0.283 then it's nighttime otherwise it's daytime.

The game has a memory address that stores the current light amount value. This value is in the range 0.0-1.0 with 1.0 being all available light is available (very bright daylight). Now here's where things get interesting. I've made some single missions where visually it's nighttime but the game thinks it's still daytime. The current light amount value was 0.385 with 0.283 being the value that the game uses for nighttime.

If it is nighttime then the game takes the derived minimum signal strength and multiplies it by 3. Then the signal strength of the visual sensor is compared to the minimum signal strength. If greater than then the contact is spotted.

You can now see why the crew is able to spot contacts at far away distances at supposedly nighttime.

I'm deriving a fix for this. What I have come up with so far is defining a value that defines start of nighttime. I have this value currently at 0.5. When the game checks to see if it's nighttime for the visual sensor and it reports back that it is daytime (but visually it appears to be nighttime) I have some new code doing the following:
- if game reports back it's daytime:
-- compare game's nighttime value (0.283) to start of nighttime value (0.5) - I do this comparison because it's possible someone may screw up and assign the start of nighttime value <= 0.283 since it's a variable in the patch file
-- if greater than or equal then jump to end of function
-- if less than then subtract game's nighttime value (0.283) from start of nighttime (0.5) - result is 0.217
-- take current light value (say it's 0.385) and subtract game's nighttime value (0.283) - result is 0.102
-- divide 0.102 by 0.217 - result is 0.47
-- subtract 0.47 from 1.0 - result is 0.53
-- multiply 0.53 by game's nighttime multiplier for player's crew (3.0) - result is 1.59
-- multiply 1.59 by derived minimum signal strength (let's say it's 0.1) - result is 0.159 - this is the new minimum signal strength

What this does is instead of making nighttime either an on/off state it makes it a progressive one. This is how it is in real life - as it gets darker out your ability to see objects diminishes.

I might have to change the nighttime multiplier also. This will be another variable in the patch file if I do. I'm thinking it's going to have to be raised to either 3.5 or 4 from it's current value of 3.



I'm also making another patch that will let the searchlights turn on at dusk. Currently the searchlights only turn on if the game says it's nighttime out (< 0.283 for light value). I'm going to raise this value to 0.40 which should have the searchlights turning on at start of dusk.
Dude that is...that is awesome! How do you do this almighty wizard?
Tonci87 is offline   Reply With Quote
Old 03-24-14, 06:40 AM   #3018
Sartoris
Captain
 
Join Date: May 2011
Posts: 489
Downloads: 106
Uploads: 0
Default

Amazing as always, TDW!
Sartoris is offline   Reply With Quote
Old 03-24-14, 07:09 AM   #3019
cherbert
Engineer
 
Join Date: Apr 2005
Posts: 210
Downloads: 86
Uploads: 0
Default

Just a small request Dark.. could you date stamp your changelog on the first post whenever you release a new version?

I never know when an update has released and because the number of fixes is growing quite vast I easily forget what I have and haven't got patched.
cherbert is offline   Reply With Quote
Old 03-24-14, 08:32 AM   #3020
volodya61
Ocean Warrior
 
volodya61's Avatar
 
Join Date: Feb 2012
Location: Rostov-on-Don, local time GMT+4
Posts: 3,300
Downloads: 374
Uploads: 0


Default

Quote:
Originally Posted by cherbert View Post
Just a small request Dark.. could you date stamp your changelog on the first post whenever you release a new version?
Yep.. that's very good idea .. I sometimes get confused also ..
__________________
.
Where does human stupidity end?

.


El sueño de la razón produce monstruos © - and for some people awakening will be cruel
volodya61 is offline   Reply With Quote
Old 03-24-14, 09:10 AM   #3021
gap
Navy Seal
 
Join Date: Jan 2011
Location: CJ8937
Posts: 8,214
Downloads: 793
Uploads: 10
Default

Quote:
Originally Posted by TheDarkWraith View Post
What I have come up with so far is defining a value that defines start of nighttime. I have this value currently at 0.5. When the game checks to see if it's nighttime for the visual sensor and it reports back that it is daytime (but visually it appears to be nighttime) I have some new code doing the following:
- if game reports back it's daytime:

...
brilliant idea, but let's say that we are at noon of a clear mid-summer day (current light value = 1, all other numbers as per your example):

-- take current light value (1) and subtract game's nighttime value (0.283) - result is 0.717
-- divide 0.717 by 0.217 (start of night time less game's night time value) - result is 3.304
-- subtract 3.304 from 1.0 - result is -2.304
-- multiply -2.304 by game's nighttime multiplier for player's crew (3.0) - result is -6.912
-- multiply -6.912 by derived minimum signal strength (0.1, from your example) - result is -0.691 - this would be the new minimum signal strength.

Do negative numbers make any sense here? Maybe you should add a routine checking if current light value isn't greater than or equal to start of night time

Quote:
Originally Posted by TheDarkWraith View Post
I might have to change the nighttime multiplier also. This will be another variable in the patch file if I do. I'm thinking it's going to have to be raised to either 3.5 or 4 from it's current value of 3.



Quote:
Originally Posted by TheDarkWraith View Post
I'm also making another patch that will let the searchlights turn on at dusk. Currently the searchlights only turn on if the game says it's nighttime out (< 0.283 for light value). I'm going to raise this value to 0.40 which should have the searchlights turning on at start of dusk.
__________________
_____________________
|May the Force be with you!|
...\/

Last edited by gap; 03-24-14 at 09:20 AM.
gap is offline   Reply With Quote
Old 03-24-14, 09:45 AM   #3022
gap
Navy Seal
 
Join Date: Jan 2011
Location: CJ8937
Posts: 8,214
Downloads: 793
Uploads: 10
Default

Quote:
Originally Posted by gap View Post
Maybe you should add a routine checking if current light value isn't greater than or equal to start of night time
this wouldn't be enough to prevent odd results yet
Let's say that current light value is 0.49

-- take current light value (0.49) and subtract game's nighttime value (0.283) - result is 0.207
-- divide 0.207 by 0.217 - result is 0.954
-- subtract 0.954 from 1.0 - result is 0.046
-- multiply 0.046 by game's nighttime multiplier for player's crew (3.0) - result is 0.138 (makes no sense, we should make sure that this number is always greater than or equal to 1)
-- multiply 0.138 by derived minimum signal strength (0.1, from your example) - result is 0.014 - this would be the new minimum signal strength (which is obviously smaller than day-time derived minimum signal strength, whereas it should be bigger).
__________________
_____________________
|May the Force be with you!|
...\/
gap is offline   Reply With Quote
Old 03-24-14, 11:13 AM   #3023
tonschk
Admiral
 
Join Date: Mar 2007
Posts: 2,200
Downloads: 172
Uploads: 0
Default

WOW

Quote:
Originally Posted by sober View Post
I really cannot think of anything to type other than WOW .
__________________
What we do in life echoes in Eternity
tonschk is offline   Reply With Quote
Old 03-24-14, 11:42 AM   #3024
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,962
Downloads: 147
Uploads: 5


Default

Quote:
Originally Posted by gap View Post
brilliant idea, but let's say that we are at noon of a clear mid-summer day (current light value = 1, all other numbers as per your example):
During testing I noticed that I wasn't checking to see if current light amount was > start of nighttime value. I have this check now in the code and if current light amount > start of nighttime value then minimum signal strength isn't adjusted
TheDarkWraith is offline   Reply With Quote
Old 03-24-14, 01:29 PM   #3025
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,962
Downloads: 147
Uploads: 5


Default

I added code so that the same thing was done to units other than the player's unit. Thus units other than the player's unit will have their ability to detect contacts visually impaired as available sunlight fades away
TheDarkWraith is offline   Reply With Quote
Old 03-24-14, 02:42 PM   #3026
Viktor_Prien
Navy Dude
 
Join Date: Jan 2010
Location: Italy
Posts: 178
Downloads: 313
Uploads: 0
Default

Quote:
I added code so that the same thing was done to units other than the player's unit. Thus units other than the player's unit will have their ability to detect contacts visually impaired as available sunlight fades away
Astonishing!Great work man!Now waiting for the new patch...every day you add great improvements to the game!Thanks for it!
Viktor_Prien is offline   Reply With Quote
Old 03-24-14, 03:15 PM   #3027
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,962
Downloads: 147
Uploads: 5


Default

Just tested out the Searchlights active at dusk patch and everything working as designed Something to keep in mind: the game has a hard coded max distance from contact for the searchlights of 2000m. If the contact is outside of the 2000m then the searchlight will turn off.
TheDarkWraith is offline   Reply With Quote
Old 03-24-14, 03:57 PM   #3028
gap
Navy Seal
 
Join Date: Jan 2011
Location: CJ8937
Posts: 8,214
Downloads: 793
Uploads: 10
Default

Quote:
Originally Posted by TheDarkWraith View Post
During testing I noticed that I wasn't checking to see if current light amount was > start of nighttime value. I have this check now in the code and if current light amount > start of nighttime value then minimum signal strength isn't adjusted
Good, but have you seen my other post (quoted below)?

Quote:
Originally Posted by gap View Post
this wouldn't be enough to prevent odd results yet
Let's say that current light value is 0.49

-- take current light value (0.49) and subtract game's nighttime value (0.283) - result is 0.207
-- divide 0.207 by 0.217 - result is 0.954
-- subtract 0.954 from 1.0 - result is 0.046
-- multiply 0.046 by game's nighttime multiplier for player's crew (3.0) - result is 0.138 (makes no sense, we should make sure that this number is always greater than or equal to 1)
-- multiply 0.138 by derived minimum signal strength (0.1, from your example) - result is 0.014 - this would be the new minimum signal strength (which is obviously smaller than day-time derived minimum signal strength, whereas it should be bigger).
See, the scheme below please:



If I got you correctly stock game applies no nighttime multiplier when current light value is greater than 0.283, and a constant multiplier (3), when current light value is equal or lesser than 0.283. What we want, is a "variable by light multiplier" to be applied when current light value is comprised between start of nighttime (0.5 in your example) and game's nighttime (0.283). The above multiplier should range in value between 1 and nighttime multiplier.

If you agree with the above, the new algorythm should look like this:

-- compare game's nighttime value (0.283) to start of nighttime value (0.5)
-- if greater than or equal then jump to end of function (prevents unmanaged errors due to wrong start of nighttime user settings)
-- check current light value
-- if equal or greater than start of nighttime go to end of function (no multiplier is applied, as per stock code);
-- if equal or lesser than game's nighttime value go to end of function (the full nighttime multiplier is applied, i.e. either the stock 3 value, or the new value patched by you);
-- subtract game's nighttime value (0.283) from start of nighttime (0.5) - result is 0.217
-- take current light value (say it's 0.385, as per your example) and subtract game's nighttime value (0.283) - result is 0.102
-- divide 0.102 by 0.217 - result is 0.47
-- subtract 0.47 from 1.0 - result is 0.53
-- calculate the reciprocal of nighttime multiplier (3.0) - result is 0.33
-- subtract 0.33 from 1.0 - result is 0.77
-- multiply 0.77 by 0.53 - result is 0.35
-- add 0.33 to 0.35 - result is 0.69

-- multiply 0.69 by game's nighttime multiplier for player's crew (3.0) - result is 2.06
-- multiply 2.06 by derived minimum signal strength (let's say it's 0.1) - result is 0.206 - this would be the new minimum signal strength

the part in bold ensures that the variable by light signal strenght multiplier is always within the range 1 - game's nighttime multiplier. The multiplier will increase linearly between the above extremes

Quote:
Originally Posted by TheDarkWraith View Post
I added code so that the same thing was done to units other than the player's unit. Thus units other than the player's unit will have their ability to detect contacts visually impaired as available sunlight fades away
Quote:
Originally Posted by TheDarkWraith View Post
Just tested out the Searchlights active at dusk patch and everything working as designed Something to keep in mind: the game has a hard coded max distance from contact for the searchlights of 2000m. If the contact is outside of the 2000m then the searchlight will turn off.
That's just great
__________________
_____________________
|May the Force be with you!|
...\/
gap is offline   Reply With Quote
Old 03-24-14, 04:11 PM   #3029
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,962
Downloads: 147
Uploads: 5


Default

Quote:
Originally Posted by gap View Post
Good, but have you seen my other post (quoted below)?



See, the scheme below please:



If I got you correctly stock game applies no nighttime multiplier when current light value is greater than 0.283, and a constant multiplier (3), when current light value is equal or lesser than 0.283. What we want, is a "variable by light multiplier" to be applied when current light value is comprised between start of nighttime (0.5 in your example) and game's nighttime (0.283). The above multiplier should range in value between 1 and nighttime multiplier.
That's exactly what this code is doing:
-- if less than then subtract game's nighttime value (0.283) from start of nighttime (0.5) - result is 0.217
-- take current light value (say it's 0.385) and subtract game's nighttime value (0.283) - result is 0.102
-- divide 0.102 by 0.217 - result is 0.47
-- subtract 0.47 from 1.0 - result is 0.53
-- multiply 0.53 by game's nighttime multiplier for player's crew (3.0) - result is 1.59
-- multiply 1.59 by derived minimum signal strength (let's say it's 0.1) - result is 0.159 - this is the new minimum signal strength

It first gets the range between start of nighttime and game's nighttime value. Then it gets the current light value in regards to game's nighttime value. Then it divides the current light value in regards to game's nighttime value by the range. Subtract that result from 1.0 to get % of range. Multiply % of range by nighttime multiplier. Multiply that result by minimum signal strength to get adjusted minimum signal strength based on available light
TheDarkWraith is offline   Reply With Quote
Old 03-24-14, 04:37 PM   #3030
gap
Navy Seal
 
Join Date: Jan 2011
Location: CJ8937
Posts: 8,214
Downloads: 793
Uploads: 10
Default

Quote:
Originally Posted by TheDarkWraith View Post
That's exactly what this code is doing:
-- if less than then subtract game's nighttime value (0.283) from start of nighttime (0.5) - result is 0.217
-- take current light value (say it's 0.385) and subtract game's nighttime value (0.283) - result is 0.102
-- divide 0.102 by 0.217 - result is 0.47
-- subtract 0.47 from 1.0 - result is 0.53
-- multiply 0.53 by game's nighttime multiplier for player's crew (3.0) - result is 1.59
-- multiply 1.59 by derived minimum signal strength (let's say it's 0.1) - result is 0.159 - this is the new minimum signal strength

It first gets the range between start of nighttime and game's nighttime value. Then it gets the current light value in regards to game's nighttime value. Then it divides the current light value in regards to game's nighttime value by the range. Subtract that result from 1.0 to get % of range. Multiply % of range by nighttime multiplier. Multiply that result by minimum signal strength to get adjusted minimum signal strength based on available light
yep, I know it, and I have copied your formulas in my proposed algorythm.
The few extra calculations I have added (in bold in my previous post), ensure that the value that minimum signal strength gets multiplied by, is alway within the range 1-3. Without them, detection during "twilight-almost-night" can be weaker than during night time (i.e. multiplier bigger than 3), which is wrong imo.
__________________
_____________________
|May the Force be with you!|
...\/

Last edited by gap; 03-24-14 at 04:48 PM.
gap is offline   Reply With Quote
Reply


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


All times are GMT -5. The time now is 12:48 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 1995- 2024 Subsim®
"Subsim" is a registered trademark, all rights reserved.