[Gcblue-commits] gcb_wx/scripts AI.py,1.20,1.21 Menu.py,1.11,1.12 UnitCommands.py,1.15,1.16
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2005-03-29 00:13:04
|
Update of /cvsroot/gcblue/gcb_wx/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30838/scripts Modified Files: AI.py Menu.py UnitCommands.py Log Message: 0.7.0 release snapshot Index: AI.py =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/scripts/AI.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** AI.py 10 Mar 2005 03:28:27 -0000 1.20 --- AI.py 29 Mar 2005 00:12:25 -0000 1.21 *************** *** 195,199 **** --- 195,239 ---- + # warn if non-friendly missiles nearby + def MissileWarning(TI): + UI = TI.GetPlatformInterface() + BB = TI.GetBlackboardInterface() + + iteration = TI.GetMemoryValue(1) # will return 0 first time + if (iteration == 0): # do initialization + TI.SetMemoryText('Description', 'Warn if missiles nearby') + TI.SetMemoryValue(2, 0.0) # last warning time + + iteration = iteration + 1 + TI.SetMemoryValue(1, iteration) + + closest_id, closest_range = ClosestOfType(UI, 0x0040, 60) + + if (closest_id == -1): + BB.Erase('MissileWarning') + TI.SetUpdateInterval(30.0) + return + elif (closest_range > 40): + # missiles between 40 km and 60 km, increase update rate + BB.Erase('MissileWarning') + TI.SetUpdateInterval(5.0) + return + + TI.SetUpdateInterval(5.0) + + + BB.Write('MissileWarning', '%.0f' % closest_range) + + current_time = UI.GetTime() + last_warning = TI.GetMemoryValue(2) + + if (UI.IsPlayerControlled() and (current_time - last_warning > 30.0)): + TI.SetMemoryValue(2, current_time) + UI.PlaySound('Alarm') + UI.DisplayPopupMessage('Missile alert') + + + # shoot hostiles and unknowns within range, but do not intercept. *************** *** 221,225 **** if (engage_mode == 0): # searching - TI.SetUpdateInterval(30) best_target, best_launcher = GetImmediateTarget(UI) if (best_target != -1): --- 261,264 ---- *************** *** 236,241 **** else: TI.SetMemoryValue(2, 0) ! #else: ! #UI.DisplayMessage('%s: no targets' % UI.GetName()) if (engage_mode == 1): # turn to target --- 275,285 ---- else: TI.SetMemoryValue(2, 0) ! else: ! # check for nearby missiles ! closest_id, closest_range = ClosestOfType(UI, 0x0040, 60) ! if (closest_id == -1): ! TI.SetUpdateInterval(30) ! else: ! TI.SetUpdateInterval(5) if (engage_mode == 1): # turn to target *************** *** 267,271 **** --- 311,337 ---- + # gets info on closest (known) enemy or unknown platform within search range + def ClosestOfType(UI, class_mask, search_range_km): + track_list = UI.GetTrackList(class_mask, search_range_km, 3) + current_time = UI.GetTime() + nTracks = track_list.Size() + closest_range = 1e6 + closest_id = -1 + + for n in range(0, nTracks): + track_info = track_list.GetTrack(n) + track_id = track_info.ID + staleness = current_time - track_info.Time + range_km = UI.GetRangeToTrack(track_info) + + if ((staleness <= 15.0) and (range_km < closest_range)): + closest_range = range_km + closest_id = track_id + + return (closest_id, closest_range) + + + # returns id of closest target that is in-range, engageable, not already *************** *** 893,897 **** UI.Launch(launcher, launch_qty) UI.SetActionText('Datum launch') ! elif launch_mode == 1: # handoff to active seeker target_accepted = UI.HandoffTargetToLauncher(launcher) if (target_accepted): --- 959,963 ---- UI.Launch(launcher, launch_qty) UI.SetActionText('Datum launch') ! else: # handoff to active seeker target_accepted = UI.HandoffTargetToLauncher(launcher) if (target_accepted): Index: UnitCommands.py =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/scripts/UnitCommands.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** UnitCommands.py 10 Mar 2005 03:28:28 -0000 1.15 --- UnitCommands.py 29 Mar 2005 00:12:25 -0000 1.16 *************** *** 47,50 **** --- 47,53 ---- BB.Write('LandingTarget', dest_name) + def AddMissileWarnTask(UI): + UI.AddTask('MissileWarning', 0.0) + def ClearTasksGroup(GI): Index: Menu.py =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/scripts/Menu.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Menu.py 2 Mar 2005 22:28:41 -0000 1.11 --- Menu.py 29 Mar 2005 00:12:25 -0000 1.12 *************** *** 86,89 **** --- 86,90 ---- UnitMenu.AddItemUI('Add waypoint', 'AddWaypointOrder', 'Datum') UnitMenu.AddItem('EngageAll', 'AddEngageAllOrder') + UnitMenu.AddItem('Missile alert', 'AddMissileWarnTask') UnitMenu.AddItem('Clear waypoints','ClearWaypoints') UnitMenu.AddItem('Clear all tasks','ClearTasks') |