[Gcblue-commits] gcb_wx/scripts AI.py,1.5,1.6
Status: Alpha
Brought to you by:
ddcforge
From: <ddc...@us...> - 2004-01-05 02:48:06
|
Update of /cvsroot/gcblue/gcb_wx/scripts In directory sc8-pr-cvs1:/tmp/cvs-serv12807/scripts Modified Files: AI.py Log Message: Index: AI.py =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/scripts/AI.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** AI.py 3 Jan 2004 00:45:12 -0000 1.5 --- AI.py 5 Jan 2004 02:48:02 -0000 1.6 *************** *** 6,13 **** Order = UnitInfo.GetCurrentOrder() order_name = Order.order_name else: order_name = '--' ! UnitInfo.SetActionText(order_name) ! if (order_name == 'Patrol'): targetid = UnitInfo.GetTarget() if targetid != 0xFFFFFFFF: --- 6,18 ---- Order = UnitInfo.GetCurrentOrder() order_name = Order.order_name + UnitInfo.SetActionText(order_name) else: order_name = '--' ! UnitInfo.SetUpdate(4.0) ! UnitInfo.SetActionText(order_name) ! return ! if (EvadeMissiles(UnitInfo)): ! return ! elif (order_name == 'Patrol'): targetid = UnitInfo.GetTarget() if targetid != 0xFFFFFFFF: *************** *** 47,52 **** UnitInfo.CompletedOrder() AvoidGround(UnitInfo) # adjust altitude to avoid crashing into terrain ! else: ! UnitInfo.SetUpdate(4.0) def AvoidGround(UI): --- 52,56 ---- UnitInfo.CompletedOrder() AvoidGround(UnitInfo) # adjust altitude to avoid crashing into terrain ! def AvoidGround(UI): *************** *** 60,63 **** --- 64,87 ---- + # Run from hostile missiles (will run from antiship missiles too!) + # return 1 if evading, 0 otherwise + def EvadeMissiles(UI): + if (UI.IsAir()==0): + return 0 # only evade with air platforms + + threat_track = UI.GetClosestMissileTrack(100, 3) + if (threat_track.IsValid()): + print 'fleeing' + flee_heading = UI.GetInterceptHeadingToTrack(threat_track) + 3.14 + UI.SetHeadingRad(flee_heading) # run from missile + if (UI.GetFuel() > 0.2): + SetFractionalSpeed(UI, 1.1) + else: + SetFractionalSpeed(UI, 1.0) + UI.SetUpdate(4.0) + return 1 + else: + return 0 + def Land(UI,dest_id): # 0 - init, 1 - distant, 2 - init approach, 3 - final approach *************** *** 127,131 **** ! def InterceptTarget(UI): targetid = UI.GetTarget() if targetid == 0xFFFFFFFF: --- 151,155 ---- ! def InterceptTarget(UI): targetid = UI.GetTarget() if targetid == 0xFFFFFFFF: |