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 04-30-12, 02:22 PM   #1
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,959
Downloads: 147
Uploads: 5


Default

Quote:
Originally Posted by col_Kurtz View Post
The only thing I wish for this, it`s a set up torpedo a bit deeper (bigger tolerance ) - I don`t know is it possible - not sure about mechanism discribed by you above. It is really hard to set up by dragging the depth from 10.5 to 11m. 11.1m is to deep I`m affraid.

Anyway I appreciate your hard job and thank you so much,
Kurtz
I'll release a modifed torpedoes .sim file that increases the magnetic detonator range of the torpedoes to 4m here soon.
TheDarkWraith is offline   Reply With Quote
Old 04-30-12, 04:03 PM   #2
col_Kurtz
XO
 
Join Date: Mar 2008
Posts: 424
Downloads: 341
Uploads: 0
Default

Quote:
Originally Posted by TheDarkWraith View Post
I'll release a modifed torpedoes .sim file that increases the magnetic detonator range of the torpedoes to 4m here soon.
Ayey
__________________


DRM it`s a horror, horror... col. Kurtz Apocalypse Now
WinXP Pro SP3 2x1GB Geil 800Mhz DDR2, ATI 4850 Asus Top, E2160 1.80 Ghz overlocked to 2.79Ghz MoBo Asus P5b
col_Kurtz is offline   Reply With Quote
Old 04-30-12, 05:20 PM   #3
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,959
Downloads: 147
Uploads: 5


Default

Torpedo magnetic detonators set to 4m download can be found at bottom of post #1
TheDarkWraith is offline   Reply With Quote
Old 04-30-12, 05:31 PM   #4
volodya61
Ocean Warrior
 
volodya61's Avatar
 
Join Date: Feb 2012
Location: Rostov-on-Don, local time GMT+4
Posts: 3,292
Downloads: 374
Uploads: 0


Default

Good news, thanks

EDIT: FX update 0.19 has the same files, overwrite them?

EDIT: FX update that's why I thought that the patch for fixing broken magnetic detonator doesn't work for dat-models

PS: And now everything work great
__________________
.
Where does human stupidity end?

.


El sueño de la razón produce monstruos © - and for some people awakening will be cruel

Last edited by volodya61; 04-30-12 at 07:40 PM.
volodya61 is offline   Reply With Quote
Old 04-30-12, 09:00 PM   #5
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,959
Downloads: 147
Uploads: 5


Default

Today I finally narrowed down the routine that checks the torpedo impact angle when it collides with an object. I have to say my first reaction to the code was a huge WTF? I'm still trying to digest and figure out what the hell they were thinking. There's a lot of multiplication of fractions into the result that I can't for the life of me figure out why. It should be a simple test of:

for all min and max angles defined:
if max angle < torp impact angle < min angle then get random value. If random value < dud % chance torp is dud

But no, they have this complicated mess of multiplications and taking the cos value of something I have to try and figure out what this mess means.

For testing I set the dud % chance to 100% in the torpedo sim file for every angles defined. That way I know for sure I should have a dud on impact. But stepping through the debugger I always see the code say no dud So for fun I changed the code so that every torpedo impact was a dud. This is interesting: instead of 'dying' and sinking to the bottom it kept bouncing on the side of the ship until it could get by and then just kept going. I got the message that torpedo was a dud also. Not quite sure what to make of that

Maybe you all can help me figure this out:

So game says collision imminent! Code jumps to routine that checks for impact. Impact detected. Now it checks torpedo impact angle:

first thing it does is appears to store the torpedo impact angle on the floating point stack (-0.9527535438537597656 in this case)
next it stores 0.0174532923847436905 on the floating point stack (does this constant mean anything to anyone?)
then it loads the max angle allowed to the floating point stack (90.0 in this case)
then it multiplies these two values together (0.0174532923847436905 X 90.0). Why? Is this trying to convert to radians?
the result of that multiplication is 1.5707963146269321440 (looks like a radian value)
then it takes the COS of that value
result of that is 1.2167964475064260060E-08
then it swaps the torpedo impact angle ST2 (-0.9527535438537597656) with the result ST0 (1.2167964475064260060E-08) so that the torpedo impact angle is at top of floating point stack (result resides in ST2, torpedo impact angle in ST0)
then a floating point compare is performed of ST2 (1.2167964475064260060E-08) against the stack top ST0 (-0.9527535438537597656) and stores the results in the Integer FLAGS (EFLAGS) register
then ST2 is popped from the floating point stack
then if result of compare is below (CF=1 of EFLAGS register) then it increments a counter and loads pointers to the next set of angles. I see a problem here: the other angle of the set is never checked. The only time the second angle (which would be the min angle) is checked is if the floating compare is above (CF=0). Then if the result of that second angle is not below (CF=0) then jump to calculate dud % chance else torp explodes.

As you can see this will always jump to torpedo impact! Something is wacky here and I'm just not seeing it...

It needs to be coded so that it's checking the min and max angles before jumping to next set of angles. This way if the torp angle falls within the min and max angles then the dud % chance can be calculated. With the code as it is it never even checks the dud % chance thus we never get any duds

Last edited by TheDarkWraith; 04-30-12 at 09:52 PM.
TheDarkWraith is offline   Reply With Quote
Old 04-30-12, 10:11 PM   #6
gap
Navy Seal
 
Join Date: Jan 2011
Location: CJ8937
Posts: 8,160
Downloads: 793
Uploads: 10
Default

Quote:
Originally Posted by TheDarkWraith View Post
first thing it does is appears to store the torpedo impact angle on the floating point stack (-0.9527535438537597656 in this case)
next it stores 0.0174532923847436905 on the floating point stack (does this constant mean anything to anyone?)
then it loads the max angle allowed to the floating point stack (90.0 in this case)
then it multiplies these two values together (0.0174532923847436905 X 90.0). Why? Is this trying to convert to radians?
the result of that multiplication is 1.5707963146269321440 (looks like a radian value)
then it takes the COS of that value
result of that is 1.2167964475064260060E-08
then it swaps the torpedo impact angle ST2 (-0.9527535438537597656) with the result ST0 (1.2167964475064260060E-08) so that the torpedo impact angle is at top of floating point stack (result resides in ST2, torpedo impact angle in ST0)
then a floating point compare is performed of ST2 (1.2167964475064260060E-08) against the stack top ST0 (-0.9527535438537597656) and stores the results in the Integer FLAGS (EFLAGS) register
then ST2 is popped from the floating point stack
then if result of compare is below (CF=1 of EFLAGS register) then it increments a counter and loads pointers to the next set of angles. I see a problem here: the other angle of the set is never checked. The only time the second angle (which would be the min angle) is checked is if the floating compare is above (CF=0). Then if the result of that second angle is not below (CF=0) then jump to calculate dud % chance else torp explodes.

As you can see this will always jump to torpedo impact! Something is wacky here and I'm just not seeing it...
What the heck is that?

man, you are the Watson & Crick of hex code. Sometimes I wonder if even a single bit of devs code will be left, once you will get this game completely debugged...

anyway, trying to answer to one of your questions, 0.0174532923847436905 radians is almost 1 deg, so you could be right in stating that they wanted to convert the angle in radians. Don't ask me more, as I don't understand much of this mess.
gap is offline   Reply With Quote
Old 05-01-12, 01:17 PM   #7
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,959
Downloads: 147
Uploads: 5


Default

I think I understand the problem now with the no duds. We specify the torpedo angles (min and max) as first quadrant coordinates (between 0 and 90 degrees) in the torpedoes .sim file. The game calculates the torpedo impact angle as a true north angle. For example: I placed a NLL ship out 2000m due north from my sub. My sub was @ heading 0. The NLL was @ heading 90. I fired a torpedo at it. When the game said a collision happened the angle it reported for the torpedo impact angle was -0.992 or 172.75 degrees. This 172 degrees is being compared to the min and max torpedo angle values we specified. As we specify those min and max angles as first quadrant coordinates the result will always be torpedo impact (no duds). I have to somehow convert the torpedo angle the game computes into a first quadrant coordinate.

What I'm thinking of doing is taking the absolute value of the torpedo angle reported. This will ensure the angle is always somewhere in quadrant 1 or 4. Abs(-0.992) is 0.992 or 7.25 degrees. Then subtract that value from 90 to ensure value is always in first quadrant (90 - 7.25 = 82.75 degrees). Now that value can be compared to all the min and max torpedo angles specified in torpedoes .sim file.

Let's see what happens if torpedo angle is 260 degrees (glancing blow): 260 degrees * 0.0174532923847436905 = 4.54 radians. Cos(4.54) = -0.1715. So we'll say game reports impact angle as -0.1715. We take the abs of it and get 0.1715. COS-1(0.1715) = 1.3984 radians. 1.3984 / 0.0174532923847436905 = ~80 degrees. 90 - 80 degrees = 10 degrees. Thus the angle the torpedo makes with the plane of the ship's side is 10 degrees. Now we can check for duds

Does anyone see any probems in my thinking and/or math?
TheDarkWraith is offline   Reply With Quote
Old 05-01-12, 01:52 PM   #8
ETsd4
中国水兵
 
Join Date: Dec 2010
Posts: 278
Downloads: 91
Uploads: 0
Default

Quote:
Originally Posted by TheDarkWraith View Post
next it stores 0.0174532923847436905 on the floating point stack (does this constant mean anything to anyone?)
yes.
1°= pi/180 rad = 0.0174532923847436905
ETsd4 is offline   Reply With Quote
Old 05-01-12, 05:06 PM   #9
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,959
Downloads: 147
Uploads: 5


Default

alright I finally figured out the needed code to get the duds working It was close to what I posted above

Now there is something else odd for the duds. Once the game decides that the torpedo impact angle falls within a min, max defined set then it goes to calculate the dud % chance. Now how it does it makes no sense:

(these are notes from my debugger)
Gets a random value to compare with torpedo random chance of being a dud
Load the random % chance of being a dud (as defined in sim file) into XMM1
Multiply the % chance of being a dud (XMM1) by 0.4544053 (what is this constant and why is it needed?)
Multiply that result (XMM1) by 0.1507767 (what is this constant and why is it needed?)
Multiply that result (XMM1) by 1.0 (what is this constant and why is it needed?)
converts a signed doubleword from EAX to a single-precision FP value in the low doubleword of the destination operand. The upper 3 doublewords are left unchanged. Stores in XMM0
Multiplies XMM0 by a constant of 0.003051851 (what is this constant and why is it needed?)
compares the low-order single-precision FP values in XMM1 and XMM0. ZF, PF, and CF are set according to the result. OF, AF, and AF are cleared. The unordered result is returned if either source is a NaN (QNaN or SNaN).
Result of this check. If before then torpedo impact, if after then dud (always before thus torpedo impact instead of dud!)

So now I'm trying to figure out what these constants are and why they are needed. A dud should be a dud right? I mean if the game says torpedo impact angle falls within min,max values it should retrieve the % chance of dud and get a random value. Compare the two values. If % chance <= random value then dud, if not then torpedo impact
TheDarkWraith is offline   Reply With Quote
Old 05-01-12, 05:04 PM   #10
col_Kurtz
XO
 
Join Date: Mar 2008
Posts: 424
Downloads: 341
Uploads: 0
Default

Quote:
Originally Posted by TheDarkWraith View Post
Torpedo magnetic detonators set to 4m download can be found at bottom of post #1
Tested Historical mission with unfortunate Cimmaron. Depth max - 12meters 3 times in a row. I broke she in a half again Superb!
At first time each of three torps blowed up. Next time, two times blowed up. And the last test two times again All with external view.

Thanks a lot TDW!
__________________


DRM it`s a horror, horror... col. Kurtz Apocalypse Now
WinXP Pro SP3 2x1GB Geil 800Mhz DDR2, ATI 4850 Asus Top, E2160 1.80 Ghz overlocked to 2.79Ghz MoBo Asus P5b
col_Kurtz is offline   Reply With Quote
Reply

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


All times are GMT -5. The time now is 03:51 AM.


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