public override void Restore(bool instantly) { if (instantly) { Logger.Write(false, "GangTeam: Restore instanly.", ""); foreach (Ped p in members.FindAll(m => Util.ThereIs(m))) { p.Delete(); } } else { Logger.Write(false, "GangTeam: Restore naturally.", ""); foreach (Ped p in members) { Util.NaturallyRemove(p); } } if (relationship != 0) { Util.CleanUp(relationship); } if (ts != null) { ts.Dispose(); } members.Clear(); }
public void Tick() { if (driver.IsPlayer) { return; } if (car.Speed > 40 && Math.Abs(car.SteeringAngle) > 20) { UI.Notify(car.FriendlyName + " is freaking out."); Vector3 pos = car.Position; TaskSequence TempSequence = new TaskSequence(); Function.Call(Hash.TASK_VEHICLE_TEMP_ACTION, 0, car, 1, 2000); Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGE, 0, car, pos.X, pos.Y, pos.Z, 200f, 4194304, 250f); TempSequence.Close(); driver.Task.PerformSequence(TempSequence); TempSequence.Dispose(); } if (car.IsOnAllWheels && Function.Call <bool>(Hash.HAS_ENTITY_COLLIDED_WITH_ANYTHING, car)) { NitroSafety = 0; } if (LetOffTheGas && HoldBrakeTime > Game.GameTime && car.Speed > 4f) { car.EngineTorqueMultiplier = 0f; } HandleNitro(); }
public void Clear() { if (LivelyWorld.CanWeUse(HunterPed)) { HunterPed.RelationshipGroup = Game.GenerateHash("CIVMALE"); if (HunterPed.CurrentBlip.Exists()) { HunterPed.CurrentBlip.Color = BlipColor.White; } Function.Call(Hash.RESET_PED_MOVEMENT_CLIPSET, HunterPed, 0.0f); Function.Call(Hash.RESET_PED_STRAFE_CLIPSET, HunterPed); HunterPed.IsPersistent = false; if (LivelyWorld.CanWeUse(HunterCar)) { LivelyWorld.TemporalPersistence.Add(HunterCar); TaskSequence seq = new TaskSequence(); Function.Call(Hash.TASK_PAUSE, 0, LivelyWorld.RandomInt(2, 4) * 1000); Function.Call(Hash.TASK_ENTER_VEHICLE, 0, HunterCar, 20000, -1, 1f, 1, 0); Function.Call(Hash.TASK_PAUSE, 0, LivelyWorld.RandomInt(2, 4) * 1000); Function.Call(Hash.TASK_VEHICLE_DRIVE_WANDER, 0, HunterCar, 30f, 1 + 2 + 4 + 8 + 16 + 32); seq.Close(); HunterPed.Task.PerformSequence(seq); seq.Dispose(); HunterCar.IsPersistent = false; } } if (LivelyWorld.CanWeUse(HunterDog)) { HunterDog.IsPersistent = false; } }
/// <summary> /// Execute this algorithm. /// </summary> public virtual void Execute() { try { sequence.RunAndMaybeStats(true); } finally { sequence.Dispose(); } }
public override void Restore(bool instantly) { if (instantly) { Logger.Write(false, blipName + ": Restore instantly.", name); foreach (Ped p in members.FindAll(m => Util.ThereIs(m))) { p.Delete(); } if (Util.ThereIs(spawnedVehicle)) { spawnedVehicle.Delete(); } } else { Logger.Write(false, blipName + ": Restore naturally.", name); foreach (Ped p in members) { Util.NaturallyRemove(p); } if (Util.ThereIs(spawnedVehicle) && spawnedVehicle.HasSiren && spawnedVehicle.SirenActive) { spawnedVehicle.SirenActive = false; } Util.NaturallyRemove(spawnedVehicle); } if (ts != null) { ts.Dispose(); } if (relationship != 0) { if (emergencyType == "ARMY") { Util.CleanUp(relationship, DispatchManager.DispatchType.ArmyGround); } else { Util.CleanUp(relationship, DispatchManager.DispatchType.CopGround); } } members.Clear(); }
private void FindNewVehicle() { Logger.Write(false, "Carjacker: Finding new vehicle to jack.", ""); trycount++; Util.NaturallyRemove(spawnedVehicle); spawnedVehicle = null; Logger.Write(false, "Carjacker: Unset previous vehicle.", ""); Vehicle[] nearbyVehicles = World.GetNearbyVehicles(spawnedPed.Position, radius / 2); if (nearbyVehicles.Length < 1) { Logger.Write(false, "Carjacker: Couldn't find vehicles nearby. Abort finding.", ""); return; } for (int cnt = 0; cnt < 5; cnt++) { Vehicle v = nearbyVehicles[Util.GetRandomIntBelow(nearbyVehicles.Length)]; if (Util.WeCanEnter(v) && !spawnedPed.IsInVehicle(v) && v.Handle != lastVehicle && (Main.CriminalsCanFightWithPlayer || !Game.Player.Character.IsInVehicle(v))) { Logger.Write(false, "Carjacker: Found proper vehicle.", ""); spawnedVehicle = v; break; } } if (!Util.ThereIs(spawnedVehicle) || !Util.WeCanGiveTaskTo(spawnedPed)) { Logger.Write(false, "Carjacker: Couldn't find proper vehicle. Abort finding.", ""); return; } spawnedVehicle.IsPersistent = true; TaskSequence ts = new TaskSequence(); ts.AddTask.EnterVehicle(spawnedVehicle, VehicleSeat.Driver, -1, 2.0f, 1); ts.AddTask.CruiseWithVehicle(spawnedVehicle, 100.0f, 262692); // 4 + 32 + 512 + 262144 ts.Close(); spawnedPed.Task.PerformSequence(ts); ts.Dispose(); Logger.Write(false, "Carjacker: Jack new vehicle.", ""); }
private static void DeliverPersonalVehicle() { Logger.Log("DeliverPersonalVehicle()"); //int myDrivingStyle = 4 + 8 + 16 + 32 + 256 + 512 + 262144; int myDrivingStyle = 4 + 8 + 16 + 32 + 256 + 512; _personalDriver = _personalVehicle.CreateRandomPedOnSeat(VehicleSeat.Driver); _personalDriver.Alpha = 0; //Vector3 targetPos = World.GetNextPositionOnStreet(Game.Player.Character.Position); Function.Call(Hash.SET_DRIVER_ABILITY, _personalDriver, 100.0f); TaskSequence deliverySequence = new TaskSequence(); Function.Call(Hash.TASK_VEHICLE_MISSION_PED_TARGET, 0, _personalVehicle, Game.Player.Character, 4, 30.0f, myDrivingStyle, 90.0f, 0.0f, true); Function.Call(Hash.TASK_VEHICLE_MISSION_PED_TARGET, 0, _personalVehicle, Game.Player.Character, 4, 20.0f, myDrivingStyle, 30.0f, 0.0f, true); Function.Call(Hash.TASK_VEHICLE_MISSION_PED_TARGET, 0, _personalVehicle, Game.Player.Character, 4, 10.0f, myDrivingStyle, 15.0f, 0.0f, true); Function.Call(Hash.TASK_VEHICLE_MISSION_PED_TARGET, 0, _personalVehicle, Game.Player.Character, 4, 5.0f, myDrivingStyle, 5.0f, 0.0f, true); deliverySequence.Close(); _personalDriver.Task.PerformSequence(deliverySequence); deliverySequence.Dispose(); _deliveryIsInProgress = true; }
//Paramedic tick private void paramedic_Tick(object sender, EventArgs e) { switch (EMSStatus) { case State.Responding: if (GTA.Native.Function.Call <bool>("IS_CAR_STUCK", new GTA.Native.Parameter[] { (Vehicle)ambulance }) || ambulance.IsUpsideDown) { ambulance.Position = World.GetNextPositionOnStreet(ambulance.Position.Around(10f)); ambulance.PlaceOnNextStreetProperly(); } if (para1.Position.DistanceTo2D(LPlayer.LocalPlayer.Ped.Position) <= 35f) { paramedicCanCancel = false; para1.Task.DriveTo(LPlayer.LocalPlayer.Ped.Position, 10f, false, true); if (para1.Position.DistanceTo2D(LPlayer.LocalPlayer.Ped.Position) <= 15f) { ambulance.AttachBlip().Delete(); para1.Task.LeaveVehicle(ambulance, true); Ped[] peds = World.GetAllPeds(); foreach (Ped p in peds) { if (p.Exists()) { if (!p.isAliveAndWell || p.isDead || p.isInjured || p.Health < main.ParamedicPlayerHealthBelow) { victims.Add(p); } } } EMSStatus = State.OnScene; } } break; case State.OnScene: currentVictim = victims.FirstOrDefault(); //Functions.PrintText("Victims: " + victims.Count, 4000); if (currentVictim == null) { //Log.Warning("No elements were found in the array so the script could not continue. The ambulance was set to no longer needed and will return to a normal ped.", this); Functions.PrintHelp("There was no victim in the area, the ambulance will be detached."); para1.Task.CruiseWithVehicle(ambulance, 20f, true); ambulance.SirenActive = false; EMSStatus = State.Leave; break; } else { EMSStatus = State.RunToObject; break; } case State.RunToObject: if (currentVictim.Exists() == false) { Functions.PrintText("There is no injured ped here", 4000); para1.Task.CruiseWithVehicle(ambulance, 20f, true); EMSStatus = State.Leave; break; } else //they must exist { if (EMSTaskSeq == null) { currentVictim.AttachBlip(); EMSTaskSeq = new TaskSequence(); EMSTaskSeq.AddTask.RunTo(currentVictim.Position); EMSTaskSeq.Perform(para1); } if (para1.Position.DistanceTo2D(currentVictim.Position) <= 5f) { EMSTaskSeq.Dispose(); EMSTaskSeq = null; EMSStatus = State.PerformDuty; break; } break; } case State.PerformDuty: if (EMSTaskSeq == null) { EMSTaskSeq = new TaskSequence(); EMSTaskSeq.AddTask.TurnTo(currentVictim); EMSTaskSeq.AddTask.PlayAnimation(medic, "medic_cpr_in", 2f); EMSTaskSeq.AddTask.PlayAnimation(medic, "medic_cpr_loop", 2f); EMSTaskSeq.AddTask.PlayAnimation(medic, "medic_cpr_out", 2f); EMSTaskSeq.Perform(para1); } if (para1.Animation.isPlaying(medic, "medic_cpr_out")) { EMSTaskSeq.Dispose(); EMSTaskSeq = null; EMSStatus = State.EndDuty; break; } break; case State.EndDuty: if (currentVictim.isDead) { para1.DrawTextAboveHead("They're dead. We'll take him to the morgue for you", 4000); } else if (currentVictim == LPlayer.LocalPlayer.Ped) { para1.DrawTextAboveHead("I've patched you up, you're good to go", 4000); } else { para1.DrawTextAboveHead("They need to go to hospital immediately!", 4000); } if (currentVictim != null && currentVictim.Exists()) { if (currentVictim != LPlayer.LocalPlayer.Ped) { currentVictim.AttachBlip().Delete(); currentVictim.Delete(); currentVictim = null; } else { currentVictim.AttachBlip().Delete(); } victims.RemoveAt(0); victims.Sort(delegate(Ped a, Ped b) { if (a == null && b == null) { return(0); } else if (a == null) { return(-1); } else if (b == null) { return(1); } else { return (a.Position.DistanceTo2D(para1.Position) .CompareTo(b.Position.DistanceTo2D(para1.Position))); } }); } if (victims.Count > 0) { EMSStatus = State.OnScene; break; } else { para1.Task.CruiseWithVehicle(ambulance, 20f, true); para1.Task.AlwaysKeepTask = true; EMSStatus = State.Leave; break; } case State.Leave: para1.NoLongerNeeded(); ambulance.NoLongerNeeded(); paramedicCalledOut = false; EMSStatus = State.None; break; case State.None: paramedicTimer.Stop(); break; } }
public void HandleRacing() { if (Offroading && !driver.IsPlayer) { if (TemporaryLocal == 0 && Util.CheckForObstaclesAhead(car)) { TemporaryLocal = Game.GameTime + 2000; driver.DrivingStyle = (DrivingStyle)StreetRaces.BaseDrivingStyle + 4194304; if (StreetRaces.Debug) { UI.Notify(car.FriendlyName + " set to temporary local"); } NitroSafety = 0; } if (TemporaryLocal != 0 && TemporaryLocal < Game.GameTime && car.Speed > 20f) { if (Util.CheckForObstaclesAhead(car)) { TemporaryLocal = Game.GameTime + 2000; } else { if (StreetRaces.Debug) { UI.Notify(car.FriendlyName + " returned to fast"); } TemporaryLocal = 0; driver.DrivingStyle = (DrivingStyle)StreetRaces.BaseDrivingStyle + 16777216; } } } //Debug notifications bool shouldnotify = false; if (StreetRaces.Debug && car.IsNearEntity(Game.Player.Character, new Vector3(30, 30, 30))) { shouldnotify = true; } string notification = "Lap: " + CurrentLap + "/" + StreetRaces.Laps + " | Waypoint: " + CurrentWaypoint; if (!driver.IsPlayer) { if (!car.Model.IsHelicopter && !car.Model.IsPlane) { if (car.IsInRangeOf(Game.Player.Character.Position, 200)) { HandleBrakes(); } if (StreetRaces.AICatchup.Checked) { Vector3 playerpos = Game.Player.Character.Position; if (!driver.IsPlayer && !car.IsOnScreen && Util.IsPlayerParticipating() && PositionInRace > 1 && Function.Call <Vector3>(Hash.GET_OFFSET_FROM_ENTITY_GIVEN_WORLD_COORDS, driver, playerpos.X, playerpos.Y, playerpos.Z).Y > 20f) // { if (!car.IsInvincible) { car.IsInvincible = true; } Util.HandleAICatchUp(car); } else if (car.IsInvincible) { car.IsInvincible = false; } } //Vehicle stuck handler if (car.IsUpsideDown && car.IsStopped) { car.PlaceOnGround(); } } if (StreetRaces.UseNitro.Checked) { if (NitroTimeLimit > Game.GameTime) { //Calculate safety when nitroing if (Util.SlidingTreshold(car, 3f) || Math.Abs(car.SteeringAngle) > 10) { if (NitroSafety > 40) { NitroSafety = NitroSafety - 5; } } //Nitro cancel conditions if (NitroSafety < 50 || (NitroBar <= 0)) { NitroTimeLimit = Game.GameTime - 1; } if (car.Acceleration > 0) { if (NitroBar >= 0 && NitroSafety > 50) { //notification = notification + "~n~Nitroing"; NitroBar -= 2f; } } else if (NitroSafety > 0) { NitroSafety -= 1; } } else { //Calculate safety when not nitroing if (Util.SlidingTreshold(car, 20f)) { if (NitroSafety > 40) { NitroSafety = NitroSafety - 5; } } else if (NitroSafety < 100 && car.Acceleration > 0) { if (Util.SlidingTreshold(car, 4f) || Math.Abs(car.SteeringAngle) > 5) { if (NitroSafety < 50) { NitroSafety += 1; } } else { if (car.CurrentGear < 3) { NitroSafety = NitroSafety + 5; } else { NitroSafety += 2; } } } //Nitro recharge if (NitroBar < 100) { NitroBar = NitroBar + 1f; } //Generate next nitro session if (NitroSafety > 60 && NitroTimeLimit + IntervalBetweenNitros < Game.GameTime && NitroBar > 30) { int d = (Util.GetRandomInt(2, 5) * 1000); NitroTimeLimit = Game.GameTime + d; // if (Game.Player.Character.IsSittingInVehicle(car)) UI.Notify("~g~Nitro time limit updated, +" + d / 1000 + "s"); } } if (NitroSafety < 50 && Function.Call <bool>((Hash)0x3D34E80EED4AE3BE, car)) { Function.Call((Hash)0x81E1552E35DC3839, car, false); } //dev info if (shouldnotify && World.RenderingCamera.IsActive) { notification = notification + "~n~Nitro bar: " + NitroBar + "%"; string safety = "~r~" + NitroSafety + "%"; if (NitroSafety > 10) { safety = "~y~" + NitroSafety + "%"; } if (NitroSafety > 50) { safety = "~g~" + NitroSafety + "%"; } notification = notification + "~n~Nitro Safety: " + safety + "~w~"; notification = notification + "~n~StrAng:" + Math.Round(car.SteeringAngle).ToString(); } //Apply the nitro if (NitroTimeLimit > Game.GameTime && car.Acceleration > 0) { if (Function.Call <bool>((Hash)0x36D782F68B309BDA, car)) { if (Math.Abs(Function.Call <Vector3>(Hash.GET_ENTITY_SPEED_VECTOR, car, true).Y) > 10f) { // notification = notification + "~n~Nitroing (rocket)"; /* * if(!Function.Call<bool>((Hash)0x3D34E80EED4AE3BE, car)) * { * if (!Nitroing) Nitroing = true; * } * else * { * if (Nitroing) Nitroing =false; * }*/ //Function.Call((Hash)0xFEB2DDED3509562E, car, 100f); } } else { } } if (Game.Player.Character.IsSittingInVehicle(car) && StreetRaces.DebugMode.Checked) { UI.ShowSubtitle("~g~b " + NitroBar + "- s " + NitroSafety); } if (NitroBar < 0) { NitroBar = 0; } } else { shouldnotify = false; } } //Waypoint following if (driver.IsAlive && car.EngineHealth > 0) { if (StreetRaces.RaceWaypoints.Count > 0 && CurrentLap <= StreetRaces.Laps) { if ((!driver.IsPlayer && !Util.IsDriving(driver)) || (driver.IsPlayer && driver.Position.DistanceTo(StreetRaces.RaceWaypoints[CurrentWaypoint]) < 20f)) { being_careful = false; //Reset dangerous area braking Offroading = false; //Reset offroading behavior Flat = false; int DrivingStyle = StreetRaces.BaseDrivingStyle; //float speed = 120f; if (driver.IsPlayer) { StreetRaces.RaceWaypointBlips[CurrentCheckpoint].Scale = 0.7f; } CurrentCheckpoint++; if (CurrentWaypoint == StreetRaces.RaceWaypoints.Count - 1) { CurrentWaypoint = 0; if (!driver.IsPlayer) { Vector3 pos = StreetRaces.RaceWaypoints[CurrentWaypoint]; //driver.Task.DriveTo(car, pos, 15f, speed, DrivingStyle); //Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGE, driver, car, pos.X, pos.Y, pos.Z, speed, DrivingStyle, 15f); TaskSequence TempSequence = new TaskSequence(); if (car.IsStopped) { Function.Call(Hash.TASK_VEHICLE_TEMP_ACTION, 0, car, 1, Util.GetRandomInt(1, 8) * 100); } Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD, 0, car, pos.X, pos.Y, pos.Z, MaxSpeed, 0, car.Model.Hash, DrivingStyle, 14f, 13f); Function.Call(Hash.TASK_VEHICLE_TEMP_ACTION, 0, car, 1, 3000); TempSequence.Close(); driver.Task.PerformSequence(TempSequence); TempSequence.Dispose(); } else { StreetRaces.RaceWaypointBlips[CurrentWaypoint].Scale = 1f; StreetRaces.RaceWaypointBlips[StreetRaces.RaceWaypointBlips.Count - 1].Scale = 0.7f; } } else { if ((driver.Position.DistanceTo(StreetRaces.RaceWaypoints[CurrentWaypoint]) < 20f || (CurrentLap == 0 && CurrentWaypoint == 0))) { //Add a lap if (CurrentWaypoint == 0) { CurrentCheckpoint = 0; CurrentLap++; if (CurrentLap > StreetRaces.Laps) { StreetRaces.RacersFinished++; finished = true; UI.Notify("~b~" + Name + "~w~ finished ~g~" + StreetRaces.RacersFinished + "º~w~."); if (StreetRaces.Winner == null) { StreetRaces.Winner = this; } //Function.Call(Hash.TASK_VEHICLE_DRIVE_WANDER, driver, car, 0f, DrivingStyle); return; } else if (driver.IsPlayer && CurrentLap > 1) { BigMessageThread.MessageInstance.ShowColoredShard(CurrentLap.ToString(), "", HudColor.HUD_COLOUR_BLACK, HudColor.HUD_COLOUR_MENU_YELLOW, 800); } } CurrentWaypoint++; //Check if its offroad and apply offroad driving style if (CurrentWaypoint > 0 && StreetRaces.RaceOffroadWaypoints.Count > 0) { int Max = StreetRaces.RaceOffroadWaypoints.Count; int Current = CurrentWaypoint; if (Max > Current && StreetRaces.RaceOffroadWaypoints.Contains(StreetRaces.RaceWaypoints[CurrentWaypoint])) { DrivingStyle = StreetRaces.BaseDrivingStyle + 16777216;//4194304 Offroading = true; } } //Check if car can see waypoint directly, if so make it drive straight to it if (car.Position.DistanceTo(StreetRaces.RaceWaypoints[CurrentWaypoint]) < 50f || StreetRaces.RaceFlatWaypoints.Contains(StreetRaces.RaceWaypoints[CurrentWaypoint])) { Flat = true; DrivingStyle = StreetRaces.BaseDrivingStyle + 16777216; Offroading = true; } //if (Util.ForwardSpeed(car) > 25f && StreetRaces.RaceDangerousWaypoints.Contains(StreetRaces.RaceWaypoints[CurrentWaypoint])) MaxSpeed = car.Speed / 1.5f; else MaxSpeed = 120f;// speed = car.Speed / 1.5f; if (!driver.IsPlayer) { Vector3 pos = StreetRaces.RaceWaypoints[CurrentWaypoint]; //driver.Task.DriveTo(car, pos, 15f, speed, DrivingStyle); destination = pos; //if (CurrentLap == 1 && CurrentWaypoint < 3 && PositionInRace > 5) DrivingStyle += 1; TaskSequence TempSequence = new TaskSequence(); //if (car.IsStopped) Function.Call(Hash.TASK_VEHICLE_TEMP_ACTION, 0, car, 1, Util.GetRandomInt(1, 8) * 100); Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD, 0, car, pos.X, pos.Y, pos.Z, MaxSpeed, 0, car.Model.Hash, DrivingStyle, 14f, 13f); Function.Call(Hash.TASK_VEHICLE_TEMP_ACTION, 0, car, 1, 3000); TempSequence.Close(); driver.Task.PerformSequence(TempSequence); TempSequence.Dispose(); //Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGE, driver, car, pos.X, pos.Y, pos.Z, speed, DrivingStyle, 15f); } else { StreetRaces.RaceWaypointBlips[CurrentWaypoint].Scale = 1f; StreetRaces.RaceWaypointBlips[CurrentWaypoint].IsShortRange = false; if (CurrentCheckpoint > 0) { StreetRaces.RaceWaypointBlips[CurrentWaypoint - 1].Scale = 0.7f; StreetRaces.RaceWaypointBlips[CurrentWaypoint - 1].IsShortRange = true; } else { StreetRaces.RaceWaypointBlips[StreetRaces.RaceWaypointBlips.Count - 1].Scale = 0.7f; StreetRaces.RaceWaypointBlips[StreetRaces.RaceWaypointBlips.Count - 1].IsShortRange = true; } } } } //if(driver.IsPlayer) Util.FlareUpNextCheckpoint(StreetRaces.RaceWaypoints[CurrentWaypoint]); } } } else { if (!OutOfRace) { car.LeftIndicatorLightOn = true; car.RightIndicatorLightOn = true; Util.WarnPlayer(StreetRaces.ScriptName, "RACER OUT", Name + " is out of the race."); StreetRaces.RacersFinishedTreshold--; OutOfRace = true; } } DistanceToWaypoint = (float)Math.Round(car.Position.DistanceTo(StreetRaces.RaceWaypoints[CurrentWaypoint])); if (driver.IsPlayer) { StreetRaces.RaceWaypointBlips[CurrentCheckpoint].Scale = 1f; shouldnotify = false; } if (shouldnotify && GameplayCamera.Position.DistanceTo(Game.Player.Character.Position) < 10f) { Util.DisplayHelpTextThisFrame(notification); } else if (driver.IsPlayer && !driver.IsOnFoot && !StreetRaces.Debug || (StreetRaces.BetFromPlayer != null && StreetRaces.BetFromPlayer == this)) { Util.DisplayHelpTextThisFrame("Lap: " + CurrentLap + "/" + StreetRaces.Laps + " | Waypoint: " + CurrentWaypoint + " | Pos: " + PositionInRace); } }
public void ProcessRace() { switch (StreetRaces.RaceStatus) { case RacePhase.NotRacing: { break; } case RacePhase.RaceSetup: { if (!driver.IsPlayer) { if (driver.TaskSequenceProgress == -1) { Vector3 pos = car.Position; //int d = Util.GetRandomInt(2, 5) * 1000; TaskSequence TempSequence = new TaskSequence(); Function.Call(Hash.TASK_VEHICLE_TEMP_ACTION, 0, car, 30, 4000); Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGE, 0, car, pos.X, pos.Y, pos.Z, 200f, 4194304, 250f); // Function.Call(Hash.TASK_PAUSE, 0, 1000); TempSequence.Close(); driver.Task.PerformSequence(TempSequence); TempSequence.Dispose(); UI.Notify(car.FriendlyName + " burnouts"); } } break; } case RacePhase.RaceCountDown: { if (!driver.IsPlayer) { if (driver.TaskSequenceProgress == -1) { Vector3 pos = car.Position; // int d = Util.GetRandomInt(2, 5)*1000; TaskSequence TempSequence = new TaskSequence(); Function.Call(Hash.TASK_VEHICLE_TEMP_ACTION, 0, car, 30, 4000); Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGE, 0, car, pos.X, pos.Y, pos.Z, 200f, 4194304, 250f); // Function.Call(Hash.TASK_PAUSE, 0, 1000); TempSequence.Close(); driver.Task.PerformSequence(TempSequence); TempSequence.Dispose(); UI.Notify(car.FriendlyName + " burnouts"); } if (car.IsConvertible) { if (Util.IsRaining() && car.RoofState == VehicleRoofState.Opened) { car.RoofState = VehicleRoofState.Closing; } else if (car.RoofState == VehicleRoofState.Closed) { car.RoofState = VehicleRoofState.Opening; } } } break; } case RacePhase.RaceInProgress: { if (!finished) { if (!OutOfRace) { HandleStuck(); } HandleRacing(); } break; } } }
protected override void SetPedsOnDuty(bool onVehicleDuty) { if (!Util.ThereIs(target) || !target.Model.IsPed) { target = null; targetPosition = Vector3.Zero; return; } if (onVehicleDuty) { if (ReadyToGoWith(members)) { if (Util.WeCanGiveTaskTo(spawnedVehicle.Driver)) { Logger.Write(false, blipName + ": Time to go with vehicle.", name); if (spawnedVehicle.HasSiren && !spawnedVehicle.SirenActive) { spawnedVehicle.SirenActive = true; } spawnedVehicle.Driver.Task.DriveTo(spawnedVehicle, targetPosition, 10.0f, 100.0f, 262708); // 4 + 16 + 32 + 512 + 262144 } else { Logger.Write(false, blipName + ": There is no driver when on duty. Re-enter everyone.", name); foreach (Ped p in members.FindAll(m => Util.WeCanGiveTaskTo(m) && m.IsSittingInVehicle(spawnedVehicle))) { p.Task.LeaveVehicle(spawnedVehicle, false); } } } else { if (VehicleSeatsCanBeSeatedBy(members)) { Logger.Write(false, blipName + ": Assigned seats successfully when on duty.", name); } else { Logger.Write(false, blipName + ": Something wrong with assigning seats when on duty. Re-enter everyone.", name); foreach (Ped p in members.FindAll(m => Util.WeCanGiveTaskTo(m) && m.IsSittingInVehicle(spawnedVehicle))) { p.Task.LeaveVehicle(spawnedVehicle, false); } } } } else { if (spawnedVehicle.Speed < 1) { if ((!Util.ThereIs(members.Find(p => Util.ThereIs(p) && p.TaskSequenceProgress < 2)) || Util.ThereIs(members.Find(p => Util.ThereIs(p) && p.TaskSequenceProgress == 3))) && !checkedPeds.Contains(target.Handle)) { Logger.Write(false, blipName + ": A dead body is checked.", name); checkedPeds.Add(target.Handle); } else { Logger.Write(false, blipName + ": Time to investigate dead bodies.", name); foreach (Ped p in members.FindAll(m => Util.WeCanGiveTaskTo(m))) { if (p.IsSittingInVehicle(spawnedVehicle)) { p.Task.LeaveVehicle(spawnedVehicle, false); } if (p.TaskSequenceProgress < 0) { Vector3 dest = targetPosition.Around(1.0f); TaskSequence ts = new TaskSequence(); ts.AddTask.RunTo(dest); ts.AddTask.AchieveHeading((targetPosition - dest).ToHeading()); Function.Call(Hash.TASK_START_SCENARIO_IN_PLACE, 0, scenarios[Util.GetRandomIntBelow(scenarios.Count)], 0, 1); ts.AddTask.Wait(1000); ts.Close(); p.Task.PerformSequence(ts); ts.Dispose(); } } } } else { Logger.Write(false, blipName + ": Near dead bodies. Time to brake.", name); if (Util.WeCanGiveTaskTo(spawnedVehicle.Driver)) { Function.Call(Hash.TASK_VEHICLE_TEMP_ACTION, spawnedVehicle.Driver, spawnedVehicle, 1, 1000); } } } }
/// <summary> /// This function is going to handle arresting the peds whom have their hands already up. /// Earlier we added peds to a list so that we can keep track of who already has their hands up, /// this is going to be really useful at this point, because now we can get the closest ped in that /// list and actually arrest him/her. /// </summary> private void ArrestPedsWithTheirHandsUp() { // 1. Get the closest ped whom is contained in the peds list. // 2. GTA doesn't allow the "Player" to arrest other peds, so we're going to need to make our own sequence, using // task sequences and the advanced animation native. // 3. Once we have the ped under arrest, we want to make this ped follow us, as a "bodyguard". (get in our vehicle, go where we go etc.) // 4. We have a settings value for the prop name of the prison cell, and we also have a settings value for the props attachment offset. // We need this to get the correct position in the "cell" and make sure that the cell we want to get is actually our desired prop. // 5. Once the ped is in the cell, we'll give him/her a random scenario from a list of previously selected scenarios. This is also a toggelable setting // which the user can choose to use or not. // lets get the closest ped in our peds list. Ped closestPedWithHandsUp = World.GetClosest(Player.Character.Position, PedsArrestedByPlayer.ToArray()); // lets keep a constant here that will be used as the text that we display on screen when we are about to arrest the ped in question. const string textLabel = "Press ~INPUT_ARREST~ to begin arrest."; // now lets check to make sure this ped is not null, and make sure the player is in proper range of the ped. // to check for "range" we're using a vector to make sure the direction we're approaching the ped is from behind. // we also want to make sure that this ped is not part of our ped group already. if (Entity.Exists(closestPedWithHandsUp) && Player.Character.IsInRangeOf(closestPedWithHandsUp.Position, 1.5f) && !IsPedInPlayerGroup(closestPedWithHandsUp)) { // then we're going to wait for a button press. we're using the arrest action, because that just makes more sense. Game.DisableControlThisFrame(2, Control.Arrest); // let's make sure that the player is not trying to enter any vehicle at this time. Function.Call(Hash.SET_PLAYER_MAY_NOT_ENTER_ANY_VEHICLE, Player.Handle); // first before we display the help text, let's make sure it's not visible already. if (!HelpText.IsActive()) { _removedHelp1 = false; // now lets display some help text on screen to show the player what he needs to do to arrest this ped. HelpText.Display(textLabel); } // check to see if we've pressed the arrest button if (Game.IsDisabledControlJustPressed(2, Control.Arrest)) { // The animation will work like this: // 1. the player will wait for the peds animation to finish. // 2. the ped will play the get on floor animation (at the players position). // 3. the player will play the cop animation. // 4. the ped will play the crook animation. // 5. then we set the peds movement clipset to be the cuffed movement clipset. // 6. then we make the ped follow us by setting him/her in our relationship group. // We're going to need to disable collision or freeze position of our peds until while they're playing the arrest anims. // cop animation is: arrest_on_floor_front_left_a // ped animation is: arrest_on_floor_front_left_b // we wait the duration of the first animation played by the ped in question. TaskSequence copArrestPedSequence = new TaskSequence(); copArrestPedSequence.AddTask.ClearAllImmediately(); copArrestPedSequence.AddTask.LookAt(closestPedWithHandsUp); copArrestPedSequence.AddTask.TurnTo(closestPedWithHandsUp, (int)(Function.Call <float>(Hash._GET_ANIM_DURATION, "random@arrests", "idle_2_hands_up") * 1000)); copArrestPedSequence.AddTask.ClearLookAt(); Vector3 copPos = Player.Character.Position; var copDuration = (int)(Function.Call <float>(Hash._GET_ANIM_DURATION, "mp_arresting", "arrest_on_floor_front_left_a") * 1000); Function.Call(Hash.TASK_PLAY_ANIM_ADVANCED, 0, "mp_arresting", "arrest_on_floor_front_left_a", copPos.X, copPos.Y, copPos.Z, 0, 0, Player.Character.Rotation.Z, 1.0f, 1.0f, copDuration, 0, 0f, 0, 0); copArrestPedSequence.Close(false); // there's no FULL documentation on TASK_PLAY_ANIM_ADVANCED so some the params I'm just guessing at. Seems to work just fine though. TaskSequence crookGetArrestedSequence = new TaskSequence(); crookGetArrestedSequence.AddTask.ClearAllImmediately(); Vector3 arrestPos = Player.Character.Position + (closestPedWithHandsUp.Position - Player.Character.Position).Normalized * .8f + (Player.Character.RightVector * 0.5f); crookGetArrestedSequence.AddTask.PlayAnimation("random@arrests", "idle_2_hands_up"); var crookDuration = (int)(Function.Call <float>(Hash._GET_ANIM_DURATION, "mp_arresting", "arrest_on_floor_front_left_b") * 1000); Function.Call(Hash.TASK_PLAY_ANIM_ADVANCED, 0, "mp_arresting", "arrest_on_floor_front_left_b", arrestPos.X, arrestPos.Y, arrestPos.Z, 0, 0, Player.Character.Rotation.Z - 45, 1.0f, 1.0f, crookDuration, 0, 0f, 0, 0); crookGetArrestedSequence.AddTask.PlayAnimation("mp_arresting", "idle", 4.0f, -4.0f, -1, (AnimationFlags)49, 0.0f); crookGetArrestedSequence.Close(false); // tell the peds to perform their sequences Player.Character.Task.PerformSequence(copArrestPedSequence); closestPedWithHandsUp.Task.PerformSequence(crookGetArrestedSequence); // We HAVE to dispose of these, because there's a limit to the amount of task sequences you can // have during the current game. They stay in memory until you dispose of them, so this // again, mgiht help someone with a low-end pc or heavily modded game copArrestPedSequence.Dispose(); crookGetArrestedSequence.Dispose(); // lets set some of the arrested peds properties, so that he doesn't lose the mp_arresting/idle animation closestPedWithHandsUp.CanRagdoll = false; closestPedWithHandsUp.CanPlayGestures = false; // now we want to add the ped to our ped group Player.Character.CurrentPedGroup.Add(closestPedWithHandsUp, false); // then let's yield the script since we're using this same control action somewhere else. Yield(); } } else { // now that there's no entity to arrest, let's remove the help text we had displayed previously. if (!_removedHelp1 && HelpText.IsActive()) { // remove all help text, since we can't target one specifically. HelpText.RemoveAll(); _removedHelp1 = true; } } }
/// <summary> /// This functions purpose is to allow the player to do a sort of "arrest stop" action. /// This way the peds we are aiming at, put their hands up and give us the oppertunity to arrest them. /// </summary> private void MakePedsPutTheirHandsUp() { // We're going to get the ped that the player is targetting, // and with that ped, we're going to give them a task sequence // so that they: // 1. Put hands up for (some seconds???) // 2. Run away from player. // We probably don't want to do it "auto-magically" maybe we press a button while aiming at the ped, and then // the player says something, and there's some random chance that the ped will either run away or fight the player. // If the ped has a weapon and is shooting the player we might not want the ped to put their hands up, because // it's more realistic. // we want to make sure the players currentPedGroup isn't over 7 if (Player.Character.CurrentPedGroup.MemberCount >= 7) { return; } // get the ped Ped targettedPed = Player.GetTargetedEntity() as Ped; if (!Entity.Exists(targettedPed)) { targettedPed = Player.Character.GetMeleeTarget(); } // make sure this ped is not null // we also want to make sure this ped doesn't already have his/her hands up. // AND we want to check to see if this ped isn't already in the players ped group. if (Entity.Exists(targettedPed) && Player.Character.IsInRangeOf(targettedPed.Position, 15) && !PedsArrestedByPlayer.Contains(targettedPed) && !IsPedInPlayerGroup(targettedPed) && !targettedPed.IsDead && !targettedPed.IsAttached()) { // check if the ped is carrying a weapon (making sure we're not in a fire fight too) if (!targettedPed.IsInCombatAgainst(Player.Character) || targettedPed.Weapons.Current.Hash == WeaponHash.Unarmed) { // draw a marker over the ped. World.DrawMarker(MarkerType.UpsideDownCone, targettedPed.Position + Vector3.WorldUp, new Vector3(0, 1, 0), Vector3.Zero, new Vector3(0.25f, 0.25f, 0.25f), Color.Blue, true, false, 9, true, string.Empty, string.Empty, false); // disable the talking controls Game.DisableControlThisFrame(2, Control.Talk); // it makes sense to use the "talk" button (imo) if (Game.IsDisabledControlJustPressed(2, Control.Talk)) { // make the player do some audio queing. Function.Call(Hash._PLAY_AMBIENT_SPEECH1, Player.Character.Handle, "Generic_Insult_High", "Speech_Params_Force"); // initialize the arrest sequence TaskSequence arrestedPedSequence = new TaskSequence(); if (!targettedPed.IsInVehicle()) { arrestedPedSequence.AddTask.ClearAllImmediately(); } else { arrestedPedSequence.AddTask.ClearAll(); } arrestedPedSequence.AddTask.LookAt(Player.Character, _timeUntilPedDecidesToRunAway); arrestedPedSequence.AddTask.HandsUp(_timeUntilPedDecidesToRunAway); arrestedPedSequence.AddTask.FleeFrom(Player.Character); arrestedPedSequence.AddTask.ClearLookAt(); arrestedPedSequence.Close(false); // make the ped perform the sequence. targettedPed.Task.PerformSequence(arrestedPedSequence); var timeout = DateTime.UtcNow + new TimeSpan(0, 0, 0, 5); while (targettedPed.TaskSequenceProgress == -1) { if (DateTime.UtcNow > timeout) { break; } Yield(); } // make sure to dispose of this sequence. arrestedPedSequence.Dispose(); // now we keep track of this one so we can do some operations with this ped later on. PedsArrestedByPlayer.Add(targettedPed); } } // draw a marker over the ped // check if we pressed a button } }
private void doIndexAndSearchTestWithRepeats(FileInfo file, Type lineParserClass, int numAdds, String storedField) { IndexReader reader = null; IndexSearcher searcher = null; PerfRunData runData = null; try { Dictionary <string, string> props = new Dictionary <string, string>(); // LineDocSource specific settings. props["docs.file"] = file.FullName; if (lineParserClass != null) { props["line.parser"] = lineParserClass.AssemblyQualifiedName; } // Indexing configuration. props["analyzer"] = typeof(WhitespaceAnalyzer).AssemblyQualifiedName; props["content.source"] = typeof(LineDocSource).AssemblyQualifiedName; props["directory"] = "RAMDirectory"; props["doc.stored"] = "true"; props["doc.index.props"] = "true"; // Create PerfRunData Config config = new Config(props); runData = new PerfRunData(config); TaskSequence tasks = new TaskSequence(runData, "testBzip2", null, false); tasks.AddTask(new CreateIndexTask(runData)); for (int i = 0; i < numAdds; i++) { tasks.AddTask(new AddDocTask(runData)); } tasks.AddTask(new CloseIndexTask(runData)); try { tasks.DoLogic(); } finally { tasks.Dispose(); } reader = DirectoryReader.Open(runData.Directory); searcher = NewSearcher(reader); TopDocs td = searcher.Search(new TermQuery(new Term("body", "body")), 10); assertEquals(numAdds, td.TotalHits); assertNotNull(td.ScoreDocs[0]); if (storedField is null) { storedField = DocMaker.BODY_FIELD; // added to all docs and satisfies field-name == value } assertEquals("Wrong field value", storedField, searcher.Doc(0).Get(storedField)); } finally { IOUtils.Dispose(reader, runData); } }
public bool IsCreatedIn(float radius, Road road) { if (relationship == 0 || road.Position.Equals(Vector3.Zero)) { return(false); } spawnedVehicle = Util.Create(name, road.Position, road.Heading, true); if (!Util.ThereIs(spawnedVehicle)) { Logger.Error("Racer: Couldn't create vehicle. Abort.", name); return(false); } spawnedPed = spawnedVehicle.CreateRandomPedOnSeat(VehicleSeat.Driver); if (!Util.ThereIs(spawnedPed)) { Logger.Error("Racer: Couldn't create driver. Abort.", name); spawnedVehicle.Delete(); return(false); } Logger.Write(false, "Racer: Created vehicle and driver successfully.", name); Script.Wait(50); Function.Call(Hash.SET_DRIVER_ABILITY, spawnedPed, 1.0f); Function.Call(Hash.SET_DRIVER_AGGRESSIVENESS, spawnedPed, 1.0f); SetExhausts(); Util.Tune(spawnedVehicle, true, true, true); Logger.Write(false, "Racer: Tuned racer vehicle.", name); spawnedPed.RelationshipGroup = relationship; spawnedPed.IsPriorityTargetForEnemies = true; spawnedPed.AlwaysKeepTask = true; spawnedPed.BlockPermanentEvents = true; Logger.Write(false, "Racer: Characteristics are set.", name); if (Util.BlipIsOn(spawnedPed)) { Logger.Error("Racer: Blip is already on racer. Abort.", name); Restore(true); return(false); } else { if (!spawnedVehicle.Model.IsCar && !spawnedPed.IsWearingHelmet) { spawnedPed.GiveHelmet(false, HelmetType.RegularMotorcycleHelmet, 4096); } TaskSequence ts = new TaskSequence(); ts.AddTask.DriveTo(spawnedVehicle, goal, 10.0f, 100.0f, 262692); // 4 + 32 + 512 + 262144 ts.AddTask.Wait(10000); ts.AddTask.CruiseWithVehicle(spawnedVehicle, 100.0f, 262692); // 4 + 32 + 512 + 262144 ts.Close(); spawnedPed.Task.PerformSequence(ts); ts.Dispose(); Logger.Write(false, "Racer: Created racer successfully.", name); blipName += VehicleInfo.GetNameOf(spawnedVehicle.Model.Hash); return(true); } }
private void OnTick(object sender, EventArgs e) { if (!Database.PlayerInVehicle) { Vehicle vehicle = World.GetClosestVehicle(Database.PlayerPosition, 20f); if (_item == null) { _item = PlayerInventory.Instance.ItemFromName("Vehicle Repair Kit"); } if (_selectedVehicle != null) { Game.DisableControlThisFrame(2, GTA.Control.Attack); UiExtended.DisplayHelpTextThisFrame("Press ~INPUT_ATTACK~ to cancel.", false); if (Game.IsDisabledControlJustPressed(2, GTA.Control.Attack)) { PlayerPed.Task.ClearAllImmediately(); _selectedVehicle.CloseDoor(GTA.VehicleDoor.Hood, false); _selectedVehicle = null; } else if (PlayerPed.TaskSequenceProgress == -1) { _selectedVehicle.EngineHealth = 1000f; _selectedVehicle.CloseDoor(GTA.VehicleDoor.Hood, false); _selectedVehicle = null; PlayerInventory.Instance.AddItem(_item, -1, ItemType.Item); UI.Notify("Items: -~r~1"); } } else if (vehicle != null) { Model model = vehicle.Model; if (model.IsCar && vehicle.EngineHealth < 1000f && !MenuConrtoller.MenuPool.IsAnyMenuOpen() && !vehicle.IsUpsideDown && vehicle.HasBone("engine")) { Vector3 pos = vehicle.GetBoneCoord(vehicle.GetBoneIndex("engine")); if (!(pos == Vector3.Zero) && PlayerPed.IsInRangeOf(pos, 1.5f)) { if (!PlayerInventory.Instance.HasItem(_item, ItemType.Item)) { UiExtended.DisplayHelpTextThisFrame("You need a vehicle repair kit to fix this engine.", false); } else { Game.DisableControlThisFrame(2, GTA.Control.Context); UiExtended.DisplayHelpTextThisFrame("Press ~INPUT_CONTEXT~ to repair engine.", false); if (Game.IsDisabledControlJustPressed(2, GTA.Control.Context)) { vehicle.OpenDoor(GTA.VehicleDoor.Hood, false, false); PlayerPed.Weapons.Select(GTA.Native.WeaponHash.Wrench, true); Vector3 position = pos + vehicle.ForwardVector; Vector3 val = vehicle.Position - Database.PlayerPosition; float heading = val.ToHeading(); TaskSequence sequence = new TaskSequence(); sequence.AddTask.ClearAllImmediately(); sequence.AddTask.GoTo(position, false, 1500); sequence.AddTask.AchieveHeading(heading, 2000); sequence.AddTask.PlayAnimation("mp_intro_seq@", "mp_mech_fix", 8f, -8f, _repairTimeMs, GTA.AnimationFlags.Loop, 1f); sequence.AddTask.ClearAll(); sequence.Close(); PlayerPed.Task.PerformSequence(sequence); sequence.Dispose(); _selectedVehicle = vehicle; } } } } } } }
public void Process() { if (!StoleCar && Game.Player.Character.IsInVehicle(car)) { StoleCar = true; if (GangDeal) { Game.Player.Character.Weapons.Give(WeaponHash.SawnOffShotgun, 50, false, true); Game.Player.Character.Weapons.Give(WeaponHash.AssaultRifle, 250, false, true); Game.Player.Character.Weapons.Give(WeaponHash.Molotov, 8, false, true); LivelyWorld.DisplayHelpTextThisFrame("You found some weapons inside the van."); } else { int money = LivelyWorld.RandomInt(200, 1000); Game.Player.Money += money; LivelyWorld.DisplayHelpTextThisFrame("You found some money in the glove compartment."); } } if (!Ruined) { if (TimeAlive < Game.GameTime) { TaskSequence seq = new TaskSequence(); Function.Call(Hash.TASK_ENTER_VEHICLE, 0, car, 20000, -1, 1f, 1, 0); Function.Call(Hash.TASK_VEHICLE_DRIVE_WANDER, 0, car, 15f, 1 + 2 + 8 + 32 + 128 + 256); seq.Close(); Dealer.Task.PerformSequence(seq); seq.Dispose(); if (LivelyWorld.CanWeUse(car)) { car.CloseDoor(VehicleDoor.Trunk, false); } Finished = true; } if (LivelyWorld.isCopInRange(Dealer.Position, 40) || LivelyWorld.isCopVehicleRange(Dealer.Position, 40)) { Dealer.Task.FightAgainst(Game.Player.Character); } if (Game.Player.Character.IsInRangeOf(Dealer.Position, 40f) && Dealer.IsOnScreen && World.GetRelationshipBetweenGroups(DealerRLGroup, Game.Player.Character.RelationshipGroup) != Relationship.Hate) { World.SetRelationshipBetweenGroups(Relationship.Hate, DealerRLGroup, Function.Call <int>(GTA.Native.Hash.GET_HASH_KEY, "PLAYER")); World.SetRelationshipBetweenGroups(Relationship.Hate, Function.Call <int>(GTA.Native.Hash.GET_HASH_KEY, "PLAYER"), DealerRLGroup); } if (Dealer.IsInCombat) { if (!Buyer.IsFleeing) { Buyer.Task.ReactAndFlee(Dealer); } Ruined = true; if (Goons.Count > 0 && LivelyWorld.CanWeUse(car)) { TaskSequence seq = new TaskSequence(); Function.Call(Hash.TASK_VEHICLE_DRIVE_WANDER, 0, car, 30f, 4 + 8 + 16 + 32); seq.Close(); Dealer.Task.PerformSequence(seq); seq.Dispose(); } } if (!Game.Player.Character.IsInRangeOf(car.Position, Distance * 1.5f) || (!car.IsAlive || StoleCar)) { Finished = true; } } else if (!Game.Player.Character.IsInRangeOf(car.Position, 100f) || (!car.IsAlive || StoleCar)) { Finished = true; } }
public void Process() { if ((!Game.Player.Character.IsInRangeOf(HunterPed.Position, DespawnRange) || !HunterPed.IsAlive) && !Finished) { Finished = true; } if (LivelyWorld.CanWeUse(HunterDog) && !HunterDog.IsInRangeOf(HunterPed.Position, 5f) && HunterDog.IsStopped) { Function.Call(Hash.TASK_GO_TO_ENTITY, HunterDog, HunterPed, -1, 2f, 1f, 0f, 0); } if (!Notified && Game.Player.Character.IsStopped && Game.Player.Character.IsInRangeOf(HunterPed.Position, 8f)) { Notified = true; LivelyWorld.AddQueuedConversation("~b~[Hunter]~w~: Hey man wandering alone in the woods, why don't you give me a hand here. If you spot any animal, tell me, ok?"); LivelyWorld.AddQueuedHelpText("If you spot prey, press ~INPUT_CONTEXT~ to tell the ~b~Hunter~w~."); World.SetRelationshipBetweenGroups(Relationship.Like, HunterRLGroup, Game.GenerateHash("PLAYER")); World.SetRelationshipBetweenGroups(Relationship.Like, Game.GenerateHash("PLAYER"), HunterRLGroup); } if (!HunterPed.IsInCombat && HunterPed.IsStopped) { patience++; if (!PlayedCall && LivelyWorld.RandomInt(0, 10) <= 5) { Function.Call(Hash.PLAY_SOUND_FROM_ENTITY, -1, "PLAYER_CALLS_ELK_MASTER", HunterPed, 0, 0, 0); PlayedCall = true; } } else if (PlayedCall) { PlayedCall = false; } if (HunterPed.IsInCombat) { foreach (Ped ped in World.GetAllPeds()) { if (ped.HeightAboveGround < 3f && !ped.IsHuman && !ped.IsAlive && HunterPed.IsInCombatAgainst(ped)) { Function.Call(Hash._0x0DC7CABAB1E9B67E, ped, true); //Load Collision //target = ped; TaskSequence seq = new TaskSequence(); //Function.Call(Hash._PLAY_AMBIENT_SPEECH1, 0, "KILLED_ALL", "SPEECH_PARAMS_FORCE"); Function.Call(Hash.TASK_GO_TO_ENTITY, 0, ped, -1, 1f, 3f, 0f, 0); Function.Call(Hash.SET_BLOCKING_OF_NON_TEMPORARY_EVENTS, 0, false); seq.Close(); HunterPed.Task.PerformSequence(seq); seq.Dispose(); if (TimesTold > 0) { LivelyWorld.AddQueuedConversation("~b~[Hunter]~w~: Thanks, man.~n~~g~$10~w~ for your help."); Game.Player.Money += 10; TimesTold = 0; } break; } } } else { if (patience > 5) { //HunterPed.RelationshipGroup = HunterRLGroup; foreach (Ped ped in World.GetNearbyPeds(HunterPed, 5f)) { if (ped.IsDead) { if (Game.Player.Character.IsInRangeOf(HunterPed.Position, 20f)) { Kills++; LivelyWorld.AddQueuedConversation("~b~[Hunter]~w~: That's one for the pot!"); if (Kills > 4 && LivelyWorld.CanWeUse(HunterCar)) { LivelyWorld.AddQueuedConversation("~b~[Hunter]~w~:That's enough for today."); Finished = true; } else if (Kills > 1) { LivelyWorld.AddQueuedConversation("~b~[Hunter]~w~: " + Kills + " already!"); } } if (LivelyWorld.CanWeUse(HunterCar)) { Function.Call(GTA.Native.Hash.SET_ENTITY_LOAD_COLLISION_FLAG, ped, true); //Load Collision Function.Call(Hash.SET_ENTITY_RECORDS_COLLISIONS, ped, true); //Load Collision ped.IsPersistent = true; LivelyWorld.TemporalPersistence.Add(ped); ped.Position = HunterCar.Position + (HunterCar.ForwardVector * -2) + (HunterCar.UpVector * 2); Function.Call(Hash.SET_PED_TO_RAGDOLL, ped, 2000, 2000, 3, true, true, false); Function.Call(Hash.CREATE_NM_MESSAGE, 1151); Function.Call(Hash.GIVE_PED_NM_MESSAGE, ped, true); } else { ped.Delete(); } break; } } HunterPed.BlockPermanentEvents = false; Vector3 pos = HunterPed.Position; Function.Call(Hash.TASK_WANDER_IN_AREA, HunterPed, pos.X, pos.Y, pos.Z, 100f, 2f, 3f); patience = 0; TimesTold = 0; } } }
protected override void SetPedsOnDuty(bool onVehicleDuty) { if (targetPosition.Equals(Vector3.Zero)) { return; } if (onVehicleDuty) { if (ReadyToGoWith(members)) { if (Util.WeCanGiveTaskTo(spawnedVehicle.Driver)) { Logger.Write(false, blipName + ": Time to go with vehicle.", name); if (spawnedVehicle.HasSiren && !spawnedVehicle.SirenActive) { spawnedVehicle.SirenActive = true; } spawnedVehicle.Driver.Task.DriveTo(spawnedVehicle, targetPosition, 10.0f, 100.0f, 262708); // 4 + 16 + 32 + 512 + 262144 } else { Logger.Write(false, blipName + ": There is no driver when on duty. Re-enter everyone.", name); foreach (Ped p in members.FindAll(m => Util.WeCanGiveTaskTo(m) && m.IsSittingInVehicle(spawnedVehicle))) { p.Task.LeaveVehicle(spawnedVehicle, false); } } } else { if (VehicleSeatsCanBeSeatedBy(members)) { Logger.Write(false, blipName + ": Assigned seats successfully when on duty.", name); } else { Logger.Write(false, blipName + ": Something wrong with assigning seats when on duty. Re-enter everyone.", name); foreach (Ped p in members.FindAll(m => Util.WeCanGiveTaskTo(m) && m.IsSittingInVehicle(spawnedVehicle))) { p.Task.LeaveVehicle(spawnedVehicle, false); } } } } else { if (spawnedVehicle.Speed < 1) { if (Util.ThereIs(members.Find(p => Util.WeCanGiveTaskTo(p) && p.IsOnFoot && !p.Weapons.Current.Hash.Equals(WeaponHash.FireExtinguisher)))) { foreach (Ped p in members.FindAll(p => Util.WeCanGiveTaskTo(p) && p.IsOnFoot && !p.Weapons.Current.Hash.Equals(WeaponHash.FireExtinguisher))) { p.Weapons.Select(WeaponHash.FireExtinguisher, true); } } else { Logger.Write(false, blipName + ": Time to put off fires.", name); foreach (Ped p in members.FindAll(m => Util.WeCanGiveTaskTo(m))) { if (p.IsSittingInVehicle(spawnedVehicle)) { p.Task.LeaveVehicle(spawnedVehicle, false); } if (p.TaskSequenceProgress < 0) { TaskSequence ts = new TaskSequence(); ts.AddTask.RunTo(targetPosition.Around(3.0f)); ts.AddTask.ShootAt(targetPosition, 10000, FiringPattern.FullAuto); ts.Close(); p.Task.PerformSequence(ts); ts.Dispose(); } } } if (Util.ThereIs(members.Find(p => Util.ThereIs(p) && p.TaskSequenceProgress == 1))) { Function.Call(Hash.STOP_FIRE_IN_RANGE, targetPosition.X, targetPosition.Y, targetPosition.Z, 3.0f); } } else { Logger.Write(false, blipName + ": Near fires. Time to brake.", name); if (Util.WeCanGiveTaskTo(spawnedVehicle.Driver)) { Function.Call(Hash.TASK_VEHICLE_TEMP_ACTION, spawnedVehicle.Driver, spawnedVehicle, 1, 1000); } } } }
private void OnTick(object sender, EventArgs e) { if (Database.PlayerInVehicle) { return; } Vehicle closestVehicle = World.GetClosestVehicle(Database.PlayerPosition, 20f); if (this._item == null) { this._item = PlayerInventory.Instance.ItemFromName("Vehicle Repair Kit"); } if (Entity.op_Inequality((Entity)this._selectedVehicle, (Entity)null)) { Game.DisableControlThisFrame(2, (Control)24); UiExtended.DisplayHelpTextThisFrame("Press ~INPUT_ATTACK~ to cancel.", false); if (Game.IsDisabledControlJustPressed(2, (Control)24)) { VehicleRepair.PlayerPed.get_Task().ClearAllImmediately(); this._selectedVehicle.CloseDoor((VehicleDoor)4, false); this._selectedVehicle = (Vehicle)null; } else { if (VehicleRepair.PlayerPed.get_TaskSequenceProgress() != -1) { return; } this._selectedVehicle.set_EngineHealth(1000f); this._selectedVehicle.CloseDoor((VehicleDoor)4, false); this._selectedVehicle = (Vehicle)null; PlayerInventory.Instance.AddItem(this._item, -1, ItemType.Item); UI.Notify("Items: -~r~1"); } } else { if (!Entity.op_Inequality((Entity)closestVehicle, (Entity)null)) { return; } Model model = ((Entity)closestVehicle).get_Model(); if (!((Model) ref model).get_IsCar() || (double)closestVehicle.get_EngineHealth() >= 1000.0 || MenuConrtoller.MenuPool.IsAnyMenuOpen() || ((Entity)closestVehicle).get_IsUpsideDown() || !((Entity)closestVehicle).HasBone("engine")) { return; } Vector3 boneCoord = ((Entity)closestVehicle).GetBoneCoord(((Entity)closestVehicle).GetBoneIndex("engine")); if (Vector3.op_Equality(boneCoord, Vector3.get_Zero()) || !((Entity)VehicleRepair.PlayerPed).IsInRangeOf(boneCoord, 1.5f)) { return; } if (!PlayerInventory.Instance.HasItem(this._item, ItemType.Item)) { UiExtended.DisplayHelpTextThisFrame("You need a vehicle repair kit to fix this engine.", false); } else { Game.DisableControlThisFrame(2, (Control)51); UiExtended.DisplayHelpTextThisFrame("Press ~INPUT_CONTEXT~ to repair engine.", false); if (!Game.IsDisabledControlJustPressed(2, (Control)51)) { return; } closestVehicle.OpenDoor((VehicleDoor)4, false, false); VehicleRepair.PlayerPed.get_Weapons().Select((WeaponHash) - 1569615261, true); Vector3 vector3_1 = Vector3.op_Addition(boneCoord, ((Entity)closestVehicle).get_ForwardVector()); Vector3 vector3_2 = Vector3.op_Subtraction(((Entity)closestVehicle).get_Position(), Database.PlayerPosition); float heading = ((Vector3) ref vector3_2).ToHeading(); TaskSequence taskSequence = new TaskSequence(); taskSequence.get_AddTask().ClearAllImmediately(); taskSequence.get_AddTask().GoTo(vector3_1, false, 1500); taskSequence.get_AddTask().AchieveHeading(heading, 2000); taskSequence.get_AddTask().PlayAnimation("mp_intro_seq@", "mp_mech_fix", 8f, -8f, this._repairTimeMs, (AnimationFlags)1, 1f); taskSequence.get_AddTask().ClearAll(); taskSequence.Close(); VehicleRepair.PlayerPed.get_Task().PerformSequence(taskSequence); taskSequence.Dispose(); this._selectedVehicle = closestVehicle; } } }