//select destination using map public PointF chooseDestination(PointF pos, MapComponent map, PointF destination, string team, float range, float throttle) { if (Enabled) { if (ConserveFuelmode) { //check current fuel consumption, if over max, enable retpoint target if (fuelcounter + throttle / 1000 > maxfueluse) { if (!ReturnToGuard) { Mode = TargetMode.Return; } else { Mode = TargetMode.GuardToPursue; } fuelcounter = 0; //reset fuel counter } if (Mode != TargetMode.Return) { //update fuel counter fuelcounter += throttle / 1000; } } switch (Mode) { case TargetMode.Closest: //find the closest enemy return(find_ClosestTarget(pos, map, destination, team, range)); case TargetMode.Furthest: return(find_FurthestTarget(pos, map, destination, team, range)); case TargetMode.Guard: return(guard_Scan(pos, map, team, range, false)); case TargetMode.GuardToPursue: return(guard_Scan(pos, map, team, range, true)); case TargetMode.Return: return(retpoint); default: return(destination); } } else { retpoint = pos; //constantly update the return to point, so that once a chase starts it knows where it was before it started return(destination); } }
/// <summary> /// Updates the planes map signatures /// </summary> /// <param name="map">The map to update</param> public virtual void update_MapSignature(MapComponent tempmap) { //update active and passive radars ActiveSignature.Location = Location; //eventually update based radar output PassiveSignature.Location = Location; //update heat signatures //HeatSignature.Location = Location; //HeatSignature.Temperature = calculate_EngineTemp(); //add to map tempmap.ActiveRadarMap.Add(ActiveSignature); tempmap.PassiveRadarMap.Add(PassiveSignature); tempmap.HeatMap.Add(new HeatSignature(Location, calculate_EngineTemp(), Team)); }
public PointF find_FurthestTarget(PointF pos, MapComponent map, PointF destination, string team, float range) { //see if there is an enemy //make sure that the enemy is withing radar range var querey = map.PassiveRadarMap.FindAll(p => p.Team != team && p.Location.getDistance(pos) <= range / 2); var target = querey.OrderBy(p => MathExtensions.getLength(pos, p.Location)); if (target.Count() > 0) { targetPassiveSignalStrength = target.Last().Strength; status = AutoEngageStatus.Tracking; return(target.Last().Location); } else { status = AutoEngageStatus.Scanning; return(destination); } }
public PointF guard_Scan(PointF pos, MapComponent map, string team, float range, bool chase = false) { //check if any enemy is within in the guard zone var querey = map.PassiveRadarMap.FindAll(p => p.Team != team && p.Location.getDistance(GuardPoint) <= GuardAreaRadius && p.Location.getDistance(pos) <= range / 2); //find first/last based on request var target = querey.OrderBy(p => MathExtensions.getLength(pos, p.Location)); PointF tp; if (target.Count() > 0) { if (GuardClosest) { targetPassiveSignalStrength = target.First().Strength; tp = target.First().Location; } else { targetPassiveSignalStrength = target.Last().Strength; tp = target.Last().Location; } //set destination to thier position //if in guard to pursue set mode to first/last as in request if (chase) { if (GuardClosest) { Mode = TargetMode.Closest; } else { Mode = TargetMode.Furthest; } } status = AutoEngageStatus.Tracking; return(tp); } status = AutoEngageStatus.Scanning; return(GuardPoint); }
/// <summary> /// Updates the plane /// </summary> /// <param name="map">The map containg universe data</param> public override void Update(ref List <Entity> EntityList, MapComponent map, ref MapComponent tempmap) { //update destination based on autotarget mode update_Destination(map); //update autoengage status from autotarget AIEngage.Status = AITarget.status; //have autopilot check if manuvers are required //update heading based on destination Orientation = update_Heading(); //calculate throttle Throttle = AITarget.maintainThrottle(Location, Destination, Throttle); //calculate the plane's current speed calculate_Speed(); //figure update location based on speed and destination Location = Location.CalculateNewPoint(Orientation, CurrentSpeed); //update trail update_Trail(); //update map signature update_MapSignature(tempmap); //update fuel calculate_Fuel(); //manage weapons and engagement manage_Weapons(EntityList, map, tempmap); }
public virtual void manage_Weapons(List <Entity> EntityList, MapComponent map, MapComponent tempmap) { //use autoengage to deal with missiles if (AIEngage.Enabled) { AIEngage.engage_Missiles(Missiles, Radar, Location, Orientation, Destination, EntityList); } //deal with guns }
public virtual void Update(ref List <Entity> EntityList, MapComponent map, ref MapComponent tempmap) { }
public override void Update(ref List <Entity> EntityList, MapComponent map, ref MapComponent tempmap) { base.Update(ref EntityList, map, ref tempmap); }