tscharlii |
10-07-13 04:11 PM |
I was trying to tell the sonarman to follow a contact. I went to the hydrophone station, moved the needle towards a reasonable close contact, but that deaf guy kept telling me, there is no near contact to follow.
I think, due to a small bug in TDC_NewUI (I use 7.1.0, but it's still present in 7.5.0 test version), the sonarman looks for the contact at bearing "sub heading plus hydrophone needle bearing" instead of just "hydrophone needle bearing". So it only works, if my sub's heading happens to be zero degrees.
After I changed the function HydrophoneFollowNearestContact in /data/Scripts/Stations/Hydrophone.py as follows, my follow contact orders are no longer ignored.
Code:
def getHydroBearing ( contact, sub ):
contactbearing = sub.HeadingDEGToContact(contact) - sub.HeadingDEG
while contactbearing > 360.0:
contactbearing -= 360.0
while contactbearing < 0.0:
contactbearing += 360.0
return contactbearing
# Modified by TheDarkWraith
def HydrophoneFollowNearestContact():
if GetHydroFollowContact() != None:
return
hydroangle = Menu.GuiDials.GetValue( GuiDialsWrapper.DialTypes.HYDROPHONE )
sweeprange = GetHydroFollowNearestContactSweepRange()
maxrange = GetHydroFollowNearestContactMaxRange()
try:
from PageDefaultHud import PageDefaultHud_MapGroup_Mapcontrol
sub = PageDefaultHud_MapGroup_Mapcontrol.SubmarineContact
contacts = PageDefaultHud_MapGroup_Mapcontrol.AllContacts
hydrocontact = None
for contact in contacts:
if getHydroBearing( contact, sub ) >= ( hydroangle - sweeprange ) and getHydroBearing( contact, sub ) <= ( hydroangle + sweeprange ) and sub.RangeToContact( contact ) <= maxrange:
if hydrocontact == None:
hydrocontact = contact
else:
if getHydroBearing( contact, sub ) <= getHydroBearing( hydrocontact, sub ) and sub.RangeToContact( contact ) < sub.RangeToContact( hydrocontact ):
hydrocontact = contact
if hydrocontact == None:
from PageDefaultHud import Game_NewPlayerLogMessageOutside
Game_NewPlayerLogMessageOutside( [ Menu.GetLocalizedText( IDSTR_HydroFollowTargetNoNearContact ), False ] )
return
SetHydroFollowContact( hydrocontact )
from Pageinterior import Pageinterior_Blocnotes_FollowTarget
Pageinterior_Blocnotes_FollowTarget.SetCheck( True, False )
from PageDefaultHud import Game_NewPlayerLogMessageOutside
Game_NewPlayerLogMessageOutside( [ Menu.GetLocalizedText( IDSTR_HydroFollowTargetNearest ), False ] )
except:
pass
|