[Gcblue-commits] gcb_wx/scripts AI.py,1.23,1.24 HotKey.py,1.5,1.6 Menu.py,1.15,1.16 UnitCommands.py,
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2005-09-10 21:49:07
|
Update of /cvsroot/gcblue/gcb_wx/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1643/scripts Modified Files: AI.py HotKey.py Menu.py UnitCommands.py Log Message: GCB 0.8.0 release Index: HotKey.py =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/scripts/HotKey.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** HotKey.py 11 Jun 2005 21:01:44 -0000 1.5 --- HotKey.py 10 Sep 2005 21:48:58 -0000 1.6 *************** *** 9,15 **** else: # last argument set to 1 to print message ! SetFractionalSpeed(UnitInfo, 0.4, 1) elif (key == '2'): ! SetFractionalSpeed(UnitInfo, 0.75, 1) elif (key == '3'): SetFractionalSpeed(UnitInfo, 1.0, 1) --- 9,15 ---- else: # last argument set to 1 to print message ! SetFractionalSpeed(UnitInfo, 0.3, 1) elif (key == '2'): ! SetFractionalSpeed(UnitInfo, 0.80, 1) elif (key == '3'): SetFractionalSpeed(UnitInfo, 1.0, 1) Index: AI.py =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/scripts/AI.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** AI.py 20 Jul 2005 16:24:53 -0000 1.23 --- AI.py 10 Sep 2005 21:48:58 -0000 1.24 *************** *** 93,97 **** # activate all sensors can_radiate = GetSensorControl(BB) ! if (can_radiate): ActivateAllSensors(UI) else: --- 93,97 ---- # activate all sensors can_radiate = GetSensorControl(BB) ! if (can_radiate and not UI.IsSub()): ActivateAllSensors(UI) else: *************** *** 147,151 **** # activate all sensors can_radiate = GetSensorControl(BB) ! if (can_radiate): ActivateAllSensors(UI) else: --- 147,151 ---- # activate all sensors can_radiate = GetSensorControl(BB) ! if (can_radiate and not UI.IsSub()): ActivateAllSensors(UI) else: *************** *** 312,315 **** --- 312,316 ---- # for duration of engagement + # Adjust heading toward target, maintain altitude and speed to release point, # release ALL bombs at release point, and then reverse course *************** *** 332,339 **** return bomb_state = TI.GetMemoryValue(2) if (bomb_state == 2): ! DropAllBombs(UI) ! UI.SetHeading(UI.GetHeading() + 160) UI.SetActionText('') TI.EndTask() --- 333,349 ---- return + + track_info = UI.GetTargetTrackInfo() + tgt_lat = track_info.Lat + tgt_lon = track_info.Lon + tgt_alt = UI.GetMapTerrainElevation(tgt_lon, tgt_lat) # since we're bombing a ground target (does track have same altitude value?) + + bomb_state = TI.GetMemoryValue(2) + + if (bomb_state == 2): ! DropAllBombs(UI, tgt_lon, tgt_lat, tgt_alt) ! UI.SetHeading(UI.GetHeading() + 180) UI.SetActionText('') TI.EndTask() *************** *** 341,348 **** - track_info = UI.GetTargetTrackInfo() - tgt_lat = track_info.Lat - tgt_lon = track_info.Lon - tgt_alt = UI.GetMapTerrainElevation(tgt_lon, tgt_lat) # since we're bombing a ground target (does track have same altitude value?) # adjust heading to target --- 351,354 ---- *************** *** 351,354 **** --- 357,361 ---- tgt_range_m = 1000 * UI.GetRangeToTrack(track_info) # horizontal range in m + tgt_range_m = tgt_range_m - 10 # move in a little to spread bombs on either side own_speed_mps = 0.51444444 * UI.GetSpeed() # get speed in m/s own_alt_m = UI.GetAlt() *************** *** 382,385 **** --- 389,395 ---- BB = TI.GetBlackboardInterface() + if (UI.TaskExists('Nav')): + return + iteration = TI.GetMemoryValue(1) # will return 0 first time if (iteration == 0): # do initialization *************** *** 400,407 **** return bomb_state = TI.GetMemoryValue(2) if (bomb_state == 2): ! DropAllBombs(UI) ! UI.SetHeading(UI.GetHeading() + 160) UI.SetActionText('') TI.EndTask() --- 410,422 ---- return + tgt_lon = TI.GetMemoryValue(10) + tgt_lat = TI.GetMemoryValue(11) + tgt_alt = UI.GetMapTerrainElevation(tgt_lon, tgt_lat) # since we're bombing a ground target (does track have same altitude value?) + + bomb_state = TI.GetMemoryValue(2) if (bomb_state == 2): ! DropAllBombs(UI, tgt_lon, tgt_lat, tgt_alt) ! UI.SetHeading(UI.GetHeading() + 180) UI.SetActionText('') TI.EndTask() *************** *** 409,415 **** - tgt_lon = TI.GetMemoryValue(10) - tgt_lat = TI.GetMemoryValue(11) - tgt_alt = UI.GetMapTerrainElevation(tgt_lon, tgt_lat) # since we're bombing a ground target (does track have same altitude value?) # adjust heading to target --- 424,427 ---- *************** *** 418,421 **** --- 430,435 ---- tgt_range_m = 1000 * UI.GetRangeToDatum(tgt_lon, tgt_lat) # horizontal range in m + tgt_range_m = tgt_range_m - 10 # move in a little to spread bombs on either side + own_speed_mps = 0.51444444 * UI.GetSpeed() # get speed in m/s own_alt_m = UI.GetAlt() *************** *** 470,481 **** ! def DropAllBombs(UI): UI.DisplayMessage('Dropping all bombs') ! track_info = UI.GetTargetTrackInfo() ! ! tgt_lat = track_info.Lat ! tgt_lon = track_info.Lon ! tgt_alt = UI.GetMapTerrainElevation(tgt_lon, tgt_lat) nLaunchers = UI.GetLauncherCount() --- 484,491 ---- ! def DropAllBombs(UI, tgt_lon, tgt_lat, tgt_alt): UI.DisplayMessage('Dropping all bombs') ! nLaunchers = UI.GetLauncherCount() *************** *** 715,719 **** TI.SetMemoryText('Description', 'Land at designated airbase') TI.SetMemoryValue(2, 0) # 0 - init, 1 - distant, 2 - init approach, 3 - final approach ! dest_name = BB.ReadMessage('LandingTarget') dest_id = UI.LookupFriendlyId(dest_name) TI.SetMemoryValue(3, dest_id) --- 725,729 ---- TI.SetMemoryText('Description', 'Land at designated airbase') TI.SetMemoryValue(2, 0) # 0 - init, 1 - distant, 2 - init approach, 3 - final approach ! dest_name = BB.ReadMessage('Home') dest_id = UI.LookupFriendlyId(dest_name) TI.SetMemoryValue(3, dest_id) *************** *** 754,761 **** UI.SetAlt(400 + alt_m) UI.SetPitchLimit(15) elif (land_state == 3): UI.SetAlt(18 + alt_m) UI.SetPitchLimit(10) ! SetFractionalSpeed(UI,0.6) if(UI.GetLandingState()==0): UI.SetLandingState(1) # gear down --- 764,772 ---- UI.SetAlt(400 + alt_m) UI.SetPitchLimit(15) + SetFractionalSpeed(UI,0.5) elif (land_state == 3): UI.SetAlt(18 + alt_m) UI.SetPitchLimit(10) ! SetFractionalSpeed(UI,0.4) if(UI.GetLandingState()==0): UI.SetLandingState(1) # gear down *************** *** 786,790 **** TI.SetMemoryText('Description', 'Land at designated airbase') TI.SetMemoryValue(2, 0) # 0 - init, 1 - distant, 2 - init approach, 3 - final approach ! dest_name = BB.ReadMessage('LandingTarget') dest_id = UI.LookupFriendlyId(dest_name) TI.SetMemoryValue(3, dest_id) --- 797,801 ---- TI.SetMemoryText('Description', 'Land at designated airbase') TI.SetMemoryValue(2, 0) # 0 - init, 1 - distant, 2 - init approach, 3 - final approach ! dest_name = BB.ReadMessage('Home') dest_id = UI.LookupFriendlyId(dest_name) TI.SetMemoryValue(3, dest_id) *************** *** 964,968 **** return 0 engaged_count = target_info.GetEngagedCount() ! if (engaged_count > 4): return 0 --- 975,979 ---- return 0 engaged_count = target_info.GetEngagedCount() ! if (engaged_count > 2): return 0 *************** *** 1075,1082 **** if (not launcher_info.IsValid()): return ! launch_mode = launcher_info.LaunchMode # 0 - datum, 1 - seeker, 2 - bomb, 3 - other target_info = UI.GetTargetTrackInfo() ! if target_info.IsAir(): launch_qty = 1 --- 1086,1094 ---- if (not launcher_info.IsValid()): return ! launch_mode = launcher_info.LaunchMode # 0 - datum, 1 - seeker, 2 - bomb, 3 - other target_info = UI.GetTargetTrackInfo() ! ! if target_info.IsAir(): launch_qty = 1 *************** *** 1101,1104 **** --- 1113,1154 ---- UI.Launch(launcher, launch_qty) UI.SetActionText('Handoff launch') + else: + UI.DisplayMessage('Unrecognized launch mode: %d' % launch_mode) + + + # For aircraft, return to home base when at bingo fuel or after specified time + def ReturnToBase(TI): + UI = TI.GetPlatformInterface() + BB = TI.GetBlackboardInterface() + + iteration = TI.GetMemoryValue(1) # will return 0 first time + if (iteration == 0): # do initialization + bingo_fuel = GetMessageParam(BB, 'Bingo') + rtb_time = GetMessageParam(BB, 'RTBtime') + if (rtb_time <= 0): + rtb_time = 1e15 # effectively disable rtb_time if value hasn't been set + if (bingo_fuel < 0.2): + bingo_fuel = 0.2 # set min bingo_fuel to 20% + + TI.SetMemoryValue(11, bingo_fuel) + TI.SetMemoryValue(12, rtb_time) + TI.SetUpdateInterval(30) + + iteration = iteration + 1 + TI.SetMemoryValue(1, iteration) + + home_id = long(TI.GetMemoryValue(10)) + bingo_fuel = TI.GetMemoryValue(11) + rtb_time = TI.GetMemoryValue(12) + + fuel = UI.GetFuel() + time = UI.GetTime() + if ((fuel <= bingo_fuel) or (time >= rtb_time)): + UI.AddTask('Land', 2.0) + TI.EndTask() + + + + Index: UnitCommands.py =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/scripts/UnitCommands.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** UnitCommands.py 20 Jul 2005 16:24:53 -0000 1.21 --- UnitCommands.py 10 Sep 2005 21:48:58 -0000 1.22 *************** *** 1,4 **** --- 1,6 ---- + deg_to_rad = 0.01745329252 + def ActivateAllSensors(UI): UI.SetAllSensorState(1) *************** *** 47,50 **** --- 49,70 ---- UI.AddTask('BombDatum', 3.0) + def AddBombDatumTaskDeg(UI, lon, lat): + BB = UI.GetBlackboardInterface() + deg_to_rad = 0.01745329252 + BB.Write('DatumLongitude', '%f' % (deg_to_rad*lon)) + BB.Write('DatumLatitude', '%f' % (deg_to_rad*lat)) + UI.AddTask('BombDatum', 3.0) + + + # @param bingo_fuel return to base when fuel is less than this fuel fraction + # @param rtb_time return to base when indicated sim time has elapsed + def AddRTBtask(UI, home_name, bingo_fuel, rtb_time): + BB = UI.GetBlackboardInterface() + current_time = UI.GetTime() + BB.Write('Home', home_name) + BB.Write('Bingo', '%f' % bingo_fuel) + BB.Write('RTBtime', '%f' % (current_time + rtb_time)) + UI.AddTask('ReturnToBase', 2.0) + def AddWaypointOrderGroup(GI, lon, lat): *************** *** 80,83 **** --- 100,110 ---- BB.Write('StationAltitude', '%f' % UI.GetAlt()) + def AddPatrolStationDeg(UI, lon, lat): + UI.AddTask('PatrolCircle', 1.0) + BB = UI.GetBlackboardInterface() + BB.Write('StationLongitude', '%f' % (deg_to_rad*lon)) + BB.Write('StationLatitude', '%f' % (deg_to_rad*lat)) + BB.Write('StationAltitude', '%f' % UI.GetAlt()) + def AddLandingOrder(UI, dest_id): if (UI.IsHelo()): *************** *** 88,92 **** dest_name = UI.LookupFriendlyName(dest_id) BB = UI.GetBlackboardInterface() ! BB.Write('LandingTarget', dest_name) def AddMissileWarnTask(UI): --- 115,119 ---- dest_name = UI.LookupFriendlyName(dest_id) BB = UI.GetBlackboardInterface() ! BB.Write('Home', dest_name) def AddMissileWarnTask(UI): *************** *** 123,127 **** if (datum_alt < 5.0): datum_alt = 0.0 ! UI.SendDatumToLauncher(lon,lat,datum_alt + 5.0,launcher_num) UI.Launch(launcher_num, 1) --- 150,154 ---- if (datum_alt < 5.0): datum_alt = 0.0 ! UI.SendDatumToLauncher(lon,lat,datum_alt + 0.0,launcher_num) UI.Launch(launcher_num, 1) *************** *** 151,154 **** --- 178,182 ---- lat = predicted_track.Lat lon = predicted_track.Lon + #UI.DisplayMessage('tti: %.1f' % tti_s) UI.HandoffTargetToLauncher(launcher) # so that intended target is set LaunchDatum(UI, lon, lat, launcher) *************** *** 178,181 **** --- 206,212 ---- SetFractionalSpeed(UI, 0.5) + def Speed30(UI): + SetFractionalSpeed(UI, 0.3) + def GroupSpeed100(GI): *************** *** 319,323 **** def ShowStoresPanel(UI): ! UI.Sendcommand('ShowStoresPanel') def ToggleRadars(UI): --- 350,357 ---- def ShowStoresPanel(UI): ! UI.SendCommand('ShowStoresPanel') ! ! def ShowPlatformPanel(UI): ! UI.SendCommand('ShowPlatformPanel') def ToggleRadars(UI): Index: Menu.py =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/scripts/Menu.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Menu.py 10 Jul 2005 20:32:02 -0000 1.15 --- Menu.py 10 Sep 2005 21:48:58 -0000 1.16 *************** *** 73,83 **** ! UnitMenu.AddItemUI('Change heading','SetHeading','Heading') # Speed submenu UnitMenu.AddItem('Set speed','') UnitMenu.BeginSubMenu() ! UnitMenu.AddItem('50%','Speed50') ! UnitMenu.AddItem('80%','Speed80') ! UnitMenu.AddItem('Max','Speed100') UnitMenu.EndSubMenu() --- 73,83 ---- ! UnitMenu.AddItemUI('Change heading [h]','SetHeading','Heading') # Speed submenu UnitMenu.AddItem('Set speed','') UnitMenu.BeginSubMenu() ! UnitMenu.AddItem('30%','Speed30 [1]') ! UnitMenu.AddItem('80%','Speed80 [2]') ! UnitMenu.AddItem('Max','Speed100 [3]') UnitMenu.EndSubMenu() *************** *** 97,102 **** UnitMenu.AddItemUI('ZigZag patrol','AddPatrolOrder','Null') UnitMenu.AddItemUI('Patrol station','AddPatrolStation', 'Datum') ! UnitMenu.AddItemUI('Add waypoint', 'AddWaypointOrder', 'Datum') ! UnitMenu.AddItemUI('EngageAll', 'AddEngageAllOrder','Null') UnitMenu.AddItemUI('Missile alert', 'AddMissileWarnTask','Null') UnitMenu.AddItemUI('Clear waypoints','ClearWaypoints','Null') --- 97,102 ---- UnitMenu.AddItemUI('ZigZag patrol','AddPatrolOrder','Null') UnitMenu.AddItemUI('Patrol station','AddPatrolStation', 'Datum') ! UnitMenu.AddItemUI('Add waypoint [w]', 'AddWaypointOrder', 'Datum') ! UnitMenu.AddItemUI('EngageAll [e]', 'AddEngageAllOrder','Null') UnitMenu.AddItemUI('Missile alert', 'AddMissileWarnTask','Null') UnitMenu.AddItemUI('Clear waypoints','ClearWaypoints','Null') *************** *** 119,125 **** BuildSubmarineMenu(UnitMenu, UnitInfo) # Flight port panel if available if (UnitInfo.HasFlightPort()): ! UnitMenu.AddItem('Flight deck', 'ShowFlightPanel') if (UnitInfo.IsPlayerControlled()): --- 119,127 ---- BuildSubmarineMenu(UnitMenu, UnitInfo) + UnitMenu.AddItem('Platform panel [s]', 'ShowPlatformPanel') + # Flight port panel if available if (UnitInfo.HasFlightPort()): ! UnitMenu.AddItem('Flight deck [f]', 'ShowFlightPanel') if (UnitInfo.IsPlayerControlled()): |