/// <summary> /// Task the pilot with landing the heli near the <c>Ped</c> specified. /// </summary> /// <param name="p">Ped to land near</param> /// <param name="maxSpeed">max speed</param> /// <param name="targetRadius">how close the heli should be landed to the ped</param> public void landNearLeader(float maxSpeed = 100f, float targetRadius = 3f, bool verbose = true) { Vector3 pedPos = Helper.getVector3NearTarget(targetRadius, _leader.Position); const int missionFlag = 20; // 20 = LandNearPed const int landingFlag = 8225; // 32 = Land on destination /* void TASK_HELI_MISSION(Ped pilot, Vehicle aircraft, Vehicle targetVehicle, Ped targetPed, * float destinationX, float destinationY, float destinationZ, int missionFlag, float maxSpeed, * float landingRadius, float targetHeading, int unk1, int unk2, Hash unk3, int landingFlags) */ Function.Call(Hash.TASK_HELI_MISSION, pilot, heli, 0, 0, pedPos.X, pedPos.Y, pedPos.Z - 5f, missionFlag, maxSpeed, targetRadius, (pedPos - heli.Position).ToHeading(), -1, -1, -1, landingFlag); // update the pilot's task pilot.BlockPermanentEvents = true; _pilotTask = HeliPilotTask.Land; if (verbose) { GTA.UI.Notification.Show("Heli: landing near player"); } // mark the landing zone with a flare float gndHeight = World.GetGroundHeight((Vector2)pedPos); }
/// <summary> /// Fly to the destination. If no destination is specified, fly to waypoint. If no /// waypoint is set, hover above the ground in the current position. /// </summary> public void flyToDestination(Vector3?destination = null, float maxSpeed = 100f) { _pilotTask = HeliPilotTask.FlyToDestination; Vector3 target; // if a destination was specified, fly there if (destination != null) { target = destination ?? Vector3.Zero; } // if no destination was specified, but a waypoint is active, fly to waypoint else if (Game.IsWaypointActive) { target = World.WaypointPosition; GTA.UI.Notification.Show("Support Heli: flying to waypoint"); } // otherwise, set the target to some point above the current position else { target = heli.Position + Helper.getOffsetVector3(_height); GTA.UI.Notification.Show("Support Heli: hovering."); } int cruiseAltitude = Convert.ToInt32(cruiseAltitudeMultiplier * _height); /* void TASK_HELI_MISSION(Ped pilot, Vehicle aircraft, Vehicle targetVehicle, Ped targetPed, * float destinationX, float destinationY, float destinationZ, int missionFlag, float maxSpeed, * float landingRadius, float targetHeading, int unk1, int unk2, Hash unk3, int landingFlags) */ Function.Call(Hash.TASK_HELI_MISSION, pilot, heli, 0, 0, target.X, target.Y, target.Z, 4, maxSpeed, 10f, (target - heli.Position).ToHeading(), cruiseAltitude, cruiseAltitude, -1, 0); }
/// <summary> /// Call when targetedPedsStack is depleted /// </summary> /// <param name="nextTask">Optional; define next task for pilot</param> protected void exitChaseEngageMode(HeliPilotTask nextTask = HeliPilotTask.ChaseLeader) { // reset the attached blip back to normal heli.AttachedBlip.Color = defaultBlipColor; // request next pilot task pilotTasking(nextTask); // task all passengers (gunners) with fighting hated Peds foreach (Ped passenger in heli.Passengers) { passenger.Task.FightAgainstHatedTargets(9999f); } }
/// <summary> /// Task the heli's pilot with chasing the specified <c>Ped</c>, with some preset offset /// </summary> /// <param name="p">Ped to chase</param> protected void pilotTaskChasePed() { _pilotTask = HeliPilotTask.ChaseLeader; try { Vector3 playerPos = _leader.Position; pilot.Task.ChaseWithHelicopter(_leader, Helper.getOffsetVector3(_height, _radius)); pilot.AlwaysKeepTask = true; } catch { destructor(); throw; } }