Пример #1
0
        public void Attack(Ped player)
        {
            int x = random.Next(1, 100 + 1);

            TaskSequence sequence = new TaskSequence();

            /* 60% to attack the victim - 40 % to attack the player */
            if (x <= 60)
            {
                sequence.AddTask.FightAgainst(Victim);

                x = random.Next(1, 100 + 1);
                if (x <= 50)
                {
                    sequence.AddTask.FightAgainst(player);
                }
                else
                {
                    sequence.AddTask.FleeFrom(player);
                }
            }
            else
            {
                sequence.AddTask.FightAgainst(player);
                sequence.AddTask.FleeFrom(player);
            }
            sequence.Close();
            Attacker.Task.PerformSequence(sequence);
        }
Пример #2
0
        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();
        }
Пример #3
0
        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;
            }
        }
Пример #4
0
        private async Task ATMTick()
        {
            if (this.InAnim || Game.Player.Character.IsInVehicle())
            {
                return;
            }

            var atm = this.atms
                      .Select(a => new { atm = a, distance = new Vector3(a.Position.X, a.Position.Y, a.Position.Z).DistanceToSquared(Game.Player.Character.Position) })
                      .Where(a => a.distance < 5.0F)           // Nearby
                      .Select(a => new { a.atm, prop = new Prop(API.GetClosestObjectOfType(a.atm.Position.X, a.atm.Position.Y, a.atm.Position.Z, 1, (uint)a.atm.Hash, false, false, false)), a.distance })
                      .Where(p => p.prop.Model.IsValid)
                      .Where(a => Vector3.Dot(a.prop.ForwardVector, Vector3.Normalize(a.prop.Position - Game.Player.Character.Position)).IsBetween(0f, 1.0f))           // In front of
                      .OrderBy(a => a.distance)
                      .Select(a => new Tuple <BankATM, Prop>(a.atm, a.prop))
                      .FirstOrDefault();

            if (atm == null)
            {
                return;
            }

            new Text("Press Z to use ATM", new PointF(50, Screen.Height - 50), 0.4f, Color.FromArgb(255, 255, 255), Font.ChaletLondon, Alignment.Left, false, true).Draw();

            if (!this.interactKey.IsJustPressed())
            {
                return;
            }

            var atmModel = atm.Item2;

            var ts = new TaskSequence();

            ts.AddTask.LookAt(atmModel);
            var moveToPos = atmModel.Position.ToVector3().InFrontOf(atmModel.Heading + 180f, 0.5f);

            ts.AddTask.SlideTo(moveToPos.ToCitVector3(), atmModel.Heading);
            ts.AddTask.ClearLookAt();
            ts.Close();
            await Game.Player.Character.RunTaskSequence(ts);

            API.SetScenarioTypeEnabled("PROP_HUMAN_ATM", true);
            API.ResetScenarioTypesEnabled();
            API.TaskStartScenarioInPlace(Game.PlayerPed.Handle, "PROP_HUMAN_ATM", 0, true);
            this.InAnim = true;

            // Camera
            var atmCameraPos = atmModel.Position.ToVector3().ToPosition().TranslateDir(atmModel.Heading - 50f, 1.5f);

            this.Camera = World.CreateCamera(
                new Vector3(atmCameraPos.X, atmCameraPos.Y, atmCameraPos.Z) + (Vector3.UnitZ * 1.8f),
                GameplayCamera.Rotation,
                50
                );
            this.Camera.PointAt(new Vector3(atmModel.Position.X, atmModel.Position.Y, atmModel.Position.Z) + Vector3.UnitZ * 1f);
            World.RenderingCamera.InterpTo(this.Camera, 1000, true, true);
            API.RenderScriptCams(true, true, 1000, true, false);
        }
Пример #5
0
    void EngageCPR(Ped target, Ped victim)
    {
        Vector3 offset = new Vector3(
            (float)Math.Cos((double)target.Heading * 0.0174532925f + 70f),
            (float)Math.Sin((double)target.Heading * 0.0174532925f + 70f),
            0);

        target.Task.ClearAll();
        victim.Task.ClearAllImmediately();
        victim.Position  = target.Position + target.ForwardVector * 1.2f + offset * 0.06f;
        victim.Position -= new Vector3(0, 0, victim.HeightAboveGround + 0.2f);
        victim.Heading   = target.Heading + 70;

        Random rndGen = new Random();

        if (rndGen.Next(0, 11) >= 9)
        {
            _reanimationFailed = true;
        }
        else
        {
            _reanimationFailed = false;
        }

        //MEDIC
        TaskSequence seq = new TaskSequence();

        seq.AddTask.PlayAnimation("mini@cpr@char_a@cpr_def", "cpr_intro", 8f, 15000, true, 8f);
        seq.AddTask.PlayAnimation("mini@cpr@char_a@cpr_str", "cpr_pumpchest", 8f, 20000, true, 8f);
        if (_reanimationFailed)
        {
            seq.AddTask.PlayAnimation("mini@cpr@char_a@cpr_str", "cpr_fail", 8f, 20000, true, 8f);
        }
        else
        {
            seq.AddTask.PlayAnimation("mini@cpr@char_a@cpr_str", "cpr_success", 8f, 28000, true, 8f);
        }
        seq.Close();
        target.Task.PerformSequence(seq);

        //VICTIM
        TaskSequence seq2 = new TaskSequence();

        seq2.AddTask.PlayAnimation("mini@cpr@char_b@cpr_def", "cpr_intro", 8f, 15000, true, 8f);
        seq2.AddTask.PlayAnimation("mini@cpr@char_b@cpr_str", "cpr_pumpchest", 8f, 20000, true, 8f);
        if (_reanimationFailed)
        {
            seq2.AddTask.PlayAnimation("mini@cpr@char_b@cpr_str", "cpr_fail", 8f, 20000, true, 8f);
        }
        else
        {
            seq2.AddTask.PlayAnimation("mini@cpr@char_b@cpr_str", "cpr_success", 8f, 28000, true, 8f);
        }
        seq2.Close();
        victim.Task.PerformSequence(seq2);
    }
Пример #6
0
        public void Attack(Ped player)
        {
            TaskSequence sequence = new TaskSequence();

            sequence.AddTask.FightAgainst(player);
            sequence.AddTask.FleeFrom(player);

            sequence.Close();
            DrunkSuspect.Task.PerformSequence(sequence);
        }
Пример #7
0
        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.", "");
        }
Пример #8
0
        protected bool TaskIsSet()
        {
            if (ts == null)
            {
                ts = new TaskSequence();
                ts.AddTask.LeaveVehicle(spawnedVehicle, false);
                ts.AddTask.FightAgainstHatedTargets(400.0f);
                ts.Close();

                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #9
0
        public GangTeam() : base(EventManager.EventType.GangTeam)
        {
            this.members      = new List <Ped>();
            this.closeWeapons = new List <WeaponHash> {
                WeaponHash.Bat, WeaponHash.Hatchet, WeaponHash.Hammer, WeaponHash.Knife, WeaponHash.KnuckleDuster, WeaponHash.Machete, WeaponHash.Wrench, WeaponHash.BattleAxe, WeaponHash.Unarmed
            };
            this.standoffWeapons = new List <WeaponHash> {
                WeaponHash.MachinePistol, WeaponHash.SawnOffShotgun, WeaponHash.Pistol, WeaponHash.APPistol, WeaponHash.PumpShotgun, WeaponHash.Revolver
            };
            Util.CleanUp(this.relationship);

            ts = new TaskSequence();
            ts.AddTask.FightAgainstHatedTargets(200.0f);
            ts.AddTask.WanderAround();
            ts.Close();
            Logger.Write(true, "GangTeam event selected.", "");
        }
Пример #10
0
        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;
        }
Пример #11
0
        public async void Flee(Ped player)
        {
            this.DrunkSuspect.Task.FleeFrom(player);

            await BaseScript.Delay(random.Next(5500, 7500));

            int dice = random.Next(1, 100 + 1);

            TaskSequence sequence    = new TaskSequence();
            bool         changedTask = false;

            if (dice <= 30 && suspectActive)
            {
                /* 30 % to attack the closest ped */
                sequence.AddTask.FightAgainst(GetClosestPed(this.DrunkSuspect));
                ShowDialog("[Suspect] Get out of my f*****g way!", 5000, 30f);
                sequence.AddTask.FleeFrom(player);
                changedTask = true;
            }
            else if (dice > 30 && dice < 50 && suspectActive)
            {
                /* 20% to attack the player */
                sequence.AddTask.FightAgainst(player);
                ShowDialog("[Suspect] Why the f**k are you chasing me cop?!", 5000, 30f);
                sequence.AddTask.FleeFrom(player);
                changedTask = true;
            }
            sequence.Close();

            if (changedTask)
            {
                ClearPedTasks(this.DrunkSuspect.Handle);
                ClearPedTasksImmediately(this.DrunkSuspect.Handle);

                this.DrunkSuspect.Task.PerformSequence(sequence);
            }
            Tick += RandomBehaviour;
        }
Пример #12
0
        private void playerSitting()
        {
            if (isSitting)
            {
                Game.Player.Character.Task.PlayAnimation("amb@world_human_picnic@male@exit", "exit", 8f, -1, false, -1f);
                isSitting = false;
            }
            else
            {
                isSitting = true;

                Game.Player.Character.Heading = Game.Player.Character.Heading + 180;

                Game.Player.Character.Task.ClearAllImmediately();

                TaskSequence sitDown = new TaskSequence();
                sitDown.AddTask.PlayAnimation("amb@world_human_picnic@male@enter", "enter", 8f, -1, false, -1f);
                sitDown.AddTask.PlayAnimation("amb@world_human_picnic@male@base", "base", 8f, -1, true, -1f);
                sitDown.Close();

                Game.Player.Character.Task.PerformSequence(sitDown);
            }
        }
Пример #13
0
        public async void Flee(Ped player)
        {
            this.Attacker.Task.FleeFrom(player);

            await BaseScript.Delay(random.Next(5500, 7500));

            int x = random.Next(1, 100 + 1);

            TaskSequence sequence    = new TaskSequence();
            bool         changedTask = false;

            if (x <= 30)
            {
                /* 30 % the closest ped */
                sequence.AddTask.FightAgainst(GetClosestPed(this.Attacker));
                sequence.AddTask.FleeFrom(player);
                changedTask = true;
            }
            else if (x > 30 && x < 50)
            {
                /* 20% to attack the player */
                sequence.AddTask.FightAgainst(player);
                sequence.AddTask.FleeFrom(player);
                changedTask = true;
            }
            sequence.Close();

            if (changedTask)
            {
                ClearPedTasks(this.Attacker.Handle);
                ClearPedTasksImmediately(this.Attacker.Handle);

                this.Attacker.Task.PerformSequence(sequence);
            }
            Tick += RandomBehaviour;
        }
Пример #14
0
    void OnTick(object sender, EventArgs e)
    {
        //this._debug.Text = ;
        //this._debug.Draw();
        BigMessage.OnTick();
        Ped player = Game.Player.Character;

        if (_onMission)
        {
            Game.Player.WantedLevel = 0;
            if (_tick >= 60)
            {
                if (!_spotted)
                {
                    _seconds--;
                    _tick = 0;
                }
            }
            else
            {
                _tick++;
            }
            //FUTURE
            _headsup.Caption = "Level: ~b~" + _level;
            if (!_spotted)
            {
                _headsup.Caption += "~w~\nStart Chase: ~b~" + ParseTime(_seconds);
            }
            _headsup.Caption += "~w~\nKills: ~b~" + _kills;

            _headsup.Draw();
            _headsupRectangle.Draw();
            if (_seconds < 0)
            {
                UI.Notify("You ran out of time!\nThe ~r~criminals~w~ have escaped.");
                StopMissions();
            }
            else
            {
                for (int i = 0; i < _criminals.Count; i++)
                {
                    if (_criminals[i].IsDead)
                    {
                        _kills++;
                        SpookCriminal();
                        AddCash(20 * _level);
                        _criminals[i].MarkAsNoLongerNeeded();
                        _criminals.RemoveAt(i);
                        _criminalBlips[i].Remove();
                        _criminalBlips.RemoveAt(i);
                        if (_criminals.Count == 0)
                        {
                            _level++;
                            SpookCriminal();
                            //int secsadded = _rndGet.Next(60, 200);
                            //BigMessage.ShowMessage("~b~" + secsadded + " ~w~seconds added", 200, Color.White, 1.0f);
                            _seconds = 180;
                            UI.Notify("Good job officer! You've completed this level.");
                            StartMissions();
                        }
                    }
                    else
                    {
                        if (_criminals[i].IsInVehicle())
                        {
                            if (player.IsInVehicle())
                            {
                                if ((player.Position - _criminals[i].Position).Length() < 40.0f && (player.CurrentVehicle.SirenActive || _criminals[i].IsInCombat) && !_spotted)
                                {
                                    SpookCriminal(i);
                                }
                            }

                            if ((player.Position - _criminals[i].Position).Length() < 50.0f && _criminals[i].CurrentVehicle.Speed < 1.0f && _spotted)
                            {
                                if (!_fighting)
                                {
                                    _fighting = true;
                                    TaskSequence tasks = new TaskSequence();
                                    tasks.AddTask.LeaveVehicle();
                                    tasks.AddTask.FightAgainst(player, 100000);
                                    tasks.Close();
                                    _criminals[i].Task.PerformSequence(tasks);
                                }
                            }
                            else if (_fighting)
                            {
                                //this.Criminals[i].Task.ClearAll();
                                if (_criminals[i].IsInVehicle())
                                {
                                    _criminals[i].Task.CruiseWithVehicle(_criminals[i].CurrentVehicle, 60.0f, 6);
                                }
                                _fighting = false;
                            }
                        }
                        else
                        {
                            if ((player.Position - _criminals[i].Position).Length() < 60.0f)
                            {
                                if (!_fighting)
                                {
                                    _fighting = true;
                                    _criminals[i].Task.FightAgainst(player, 100000);
                                }
                            }
                            else
                            {
                                if (_fighting)
                                {
                                    TaskSequence tasks = new TaskSequence();
                                    tasks.AddTask.EnterVehicle();
                                    //tasks.AddTask.CruiseWithVehicle(this.Criminals[i].CurrentVehicle, 60.0f, 6);
                                    tasks.Close();
                                    _criminals[i].Task.PerformSequence(tasks);
                                    //this.Fighting = false;
                                }
                            }
                        }
                    }
                }
                if (player.IsDead)
                {
                    StopMissions();
                }
            }
        }
    }
Пример #15
0
        public void BoxLogic(int time)
        {
            if (Box != null)
            {
                if (time - BoxThrowTime >= Constants.PizzaBoxLifeTime)
                {
                    Box.Delete();
                    Box = null;

                    if (!LastThrowSuccessful)
                    {
                        Function.Call(Hash._PLAY_AMBIENT_SPEECH1, PlayerHandle, "GENERIC_CURSE_MED", "SPEECH_PARAMS_FORCE");
                    }

                    if (BoxCount < 1)
                    {
                        UI.ShowSubtitle(Localization.Get("RETURN_TO_STORE_OUT"), Constants.SubtitleTime);
                    }

                    if (Customers.Count < 1)
                    {
                        Main.StoreBlips[StoreID].IsShortRange = false;
                        UI.ShowSubtitle(Localization.Get("RETURN_TO_STORE_DONE"), Constants.SubtitleTime);
                    }
                }
                else
                {
                    for (int i = Customers.Count - 1; i >= 0; i--)
                    {
                        if (Box.Position.DistanceTo(Customers[i].Position) <= 3f)
                        {
                            Function.Call(Hash._PLAY_AMBIENT_SPEECH1, Customers[i].Handle, "GENERIC_THANKS", "SPEECH_PARAMS_FORCE");

                            Customers[i].CurrentBlip.Remove();
                            Customers[i].Task.ClearAllImmediately();

                            using (TaskSequence tasks = new TaskSequence())
                            {
                                tasks.AddTask.GoTo(Box.Position, true, Constants.PizzaBoxLifeTime);
                                tasks.AddTask.PlayAnimation("anim@mp_snowball", "pickup_snowball");
                                tasks.AddTask.WanderAround();
                                tasks.Close();

                                Customers[i].Task.PerformSequence(tasks);
                            }

                            Customers[i].IsInvincible = false;
                            Customers[i].MarkAsNoLongerNeeded();
                            LastThrowSuccessful = true;

                            int money = Main.RNG.Next(Main.RewardBase, Main.RewardMax + 1);
                            Game.Player.Money += money;

                            UI.ShowSubtitle(Localization.Get("DELIVERED", money), Constants.SubtitleTime);
                            Customers.RemoveAt(i);
                            break;
                        }
                    }
                }
            }
        }
Пример #16
0
    void intial1()
    {
        Game.Player.WantedLevel = 0;
        Game.Player.Character.Weapons.RemoveAll();

        Function.Call(Hash.DISABLE_ALL_CONTROL_ACTIONS, 1);
        Game.Player.CanControlCharacter = false;
        Function.Call(Hash.SET_ENABLE_HANDCUFFS, Game.Player.Character, true);
        Function.Call(Hash.SET_ENABLE_BOUND_ANKLES, Game.Player.Character, true);
        Game.Player.Character.Task.ClearAllImmediately();
        Game.Player.Character.Task.HandsUp(3000);
        Script.Wait(2500);

        Function.Call(Hash.CLEAR_RELATIONSHIP_BETWEEN_GROUPS, (int)Relationship.Hate, 2124571506, -183807561);
        Function.Call(Hash.CLEAR_RELATIONSHIP_BETWEEN_GROUPS, (int)Relationship.Hate, -183807561, 2124571506);

        Function.Call(Hash.SET_RELATIONSHIP_BETWEEN_GROUPS, (int)Relationship.Pedestrians, 2124571506, -183807561);
        Function.Call(Hash.SET_RELATIONSHIP_BETWEEN_GROUPS, (int)Relationship.Pedestrians, -183807561, 2124571506);

        escape_Ped = World.CreatePed(PedHash.Prisoner01, new Vector3(1625.474f, 2491.485f, 45.62026f));
        escape_Ped.Task.StandStill(-1);
        escape_Ped.AlwaysKeepTask = true;
        escape_Ped.Heading        = 320.5151f;



        Function.Call(Hash.SET_ENTITY_AS_MISSION_ENTITY, escape_Ped, true, true);
        Function.Call(Hash.SET_MAX_WANTED_LEVEL, 0);


        // get the closest policeman
        float dis = 35f;

        Ped[] test = World.GetNearbyPeds(Game.Player.Character, 30f);
        for (int i = 0; i < test.Length; i++)
        {
            if (test[i].RelationshipGroup == -1533126372)
            {
                if (Game.Player.Character.Position.DistanceTo(test[i].Position) < dis)
                {
                    dis    = Game.Player.Character.Position.DistanceTo(test[i].Position);
                    police = test[i];
                }
            }
        }
        //get the closest police vehicle
        dis = 55f;
        Vehicle[] test2 = World.GetNearbyVehicles(Game.Player.Character, 50f);
        for (int i = 0; i < test2.Length; i++)
        {
            int mod_hash = test2[i].Model.GetHashCode();
            if (mod_hash == VehicleHash.Police.GetHashCode() || mod_hash == VehicleHash.Police2.GetHashCode() ||
                mod_hash == VehicleHash.Police3.GetHashCode() || mod_hash == VehicleHash.Police4.GetHashCode() ||
                mod_hash == VehicleHash.Policeb.GetHashCode() || mod_hash == VehicleHash.PoliceOld1.GetHashCode() ||
                mod_hash == VehicleHash.PoliceOld2.GetHashCode())
            {
                if (Game.Player.Character.Position.DistanceTo(test2[i].Position) < dis)
                {
                    dis       = Game.Player.Character.Position.DistanceTo(test2[i].Position);
                    policecar = test2[i];
                }
            }
        }

        // make the player enter the vehicle
        Game.Player.Character.Task.ClearAllImmediately();
        Game.Player.Character.Task.EnterVehicle(policecar, VehicleSeat.LeftRear);

        while (!Game.Player.Character.IsInVehicle(policecar))
        {
            Script.Wait(0);
        }

        // disable the player control
        Function.Call(Hash.DISABLE_ALL_CONTROL_ACTIONS, 1);
        Game.Player.CanControlCharacter = false;
        Function.Call(Hash.SET_ENABLE_HANDCUFFS, Game.Player.Character, true);
        Function.Call(Hash.SET_ENABLE_BOUND_ANKLES, Game.Player.Character, true);

        police.Task.ClearAllImmediately();
        police.RelationshipGroup = Game.Player.Character.RelationshipGroup;
        police.Task.ClearAllImmediately();

        TaskSequence task = new TaskSequence();

        task.AddTask.EnterVehicle(policecar, VehicleSeat.Driver);
        task.AddTask.DriveTo(test_veh, new Vector3(1855.855f, 2606.756f, 45.9304f), 3f, 10f, (int)DrivingStyle.Normal);
        task.AddTask.StandStill(5000);
        task.AddTask.DriveTo(test_veh, new Vector3(1831.152f, 2606.738f, 45.83254f), 3f, 10f, (int)DrivingStyle.Normal);
        task.AddTask.StandStill(5000);
        task.AddTask.DriveTo(test_veh, new Vector3(1754.018f, 2604.271f, 45.82404f), 3f, 10f, (int)DrivingStyle.Normal);
        task.AddTask.StandStill(50000);
        police.Task.ClearAllImmediately();
        police.Task.PerformSequence(task);
        task.Close();


        testt = true;
    }
Пример #17
0
        public void Script_Tick(object sender, EventArgs e)
        {
            // Load labs
            #region Lab Loading
            if (!MethLabsLoaded && !Game.IsLoading && Game.Player.CanControlCharacter)
            {
                try
                {
                    string labsFile = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "mod_methoperation"), "methoperation_labs.xml");

                    if (!File.Exists(labsFile))
                    {
                        string backupLabsFile = Path.Combine("scripts", "methoperation_labs.xml");

                        Directory.CreateDirectory(Path.GetDirectoryName(labsFile));
                        File.Copy(backupLabsFile, labsFile);
                    }


                    if (File.Exists(labsFile))
                    {
                        MethLabs = XmlUtil.Deserialize <List <Lab> >(File.ReadAllText(labsFile));
                        foreach (Lab lab in MethLabs)
                        {
                            lab.CreateEntities();
                        }

                        ManagementBlip              = World.CreateBlip(Constants.MethLabLaptop);
                        ManagementBlip.Alpha        = 0;
                        ManagementBlip.Sprite       = BlipSprite.Laptop;
                        ManagementBlip.IsShortRange = true;
                        Function.Call(Hash.SET_BLIP_DISPLAY, ManagementBlip.Handle, 8);
                    }
                    else
                    {
                        UI.Notify($"~r~MethOperation labs file not found!");
                    }
                }
                catch (Exception ex)
                {
                    UI.Notify($"~r~MethOperation loading error: {ex.Message}");
                }

                MethLabsLoaded = true;
            }
            #endregion

            // process queued notifications
            if (!NotificationQueue.IsEmpty())
            {
                if (!Game.IsLoading)
                {
                    NotificationQueue.ProcessAll();
                }
            }

            // No need to go further if in a mission
            if (Mission.IsActive)
            {
                return;
            }

            // Update player position
            int gameTime = Game.GameTime;
            if (gameTime > NextUpdate)
            {
                NextUpdate     = gameTime + Constants.UpdateInterval;
                PlayerPosition = Game.Player.Character.Position;

                if (InsideMethLabIdx != -1)
                {
                    int interiorID = Function.Call <int>(Hash.GET_INTERIOR_AT_COORDS_WITH_TYPE, PlayerPosition.X, PlayerPosition.Y, PlayerPosition.Z, "bkr_biker_dlc_int_ware01");
                    if (interiorID != LabInteriorID)
                    {
                        LeftMethLab.Invoke(InsideMethLabIdx, LabExitReason.Teleport);
                        InsideMethLabIdx = -1;
                    }
                    else if (Game.Player.Character.Model.Hash != PlayerLabModel)
                    {
                        LeftMethLab.Invoke(InsideMethLabIdx, LabExitReason.CharacterChange);
                        InsideMethLabIdx = -1;
                    }
                }
            }

            // Draw markers & helptexts
            #region Drawing
            if (InsideMethLabIdx != -1)
            {
                // Handle NativeUI
                ManagementMenuPool.ProcessMenus();

                // Inside, draw interactable markers
                World.DrawMarker(MarkerType.VerticalCylinder, Constants.MethLabExit, Vector3.Zero, Vector3.Zero, Constants.MarkerScale, Constants.MarkerColor);
                World.DrawMarker(MarkerType.VerticalCylinder, Constants.MethLabLaptop, Vector3.Zero, Vector3.Zero, Constants.MarkerScale, Constants.MarkerColor);

                // Laptop screen
                if (LaptopRTID != -1)
                {
                    Function.Call(Hash.SET_TEXT_RENDER_ID, LaptopRTID);
                    Function.Call(Hash._SET_SCREEN_DRAW_POSITION, 73, 73);
                    Function.Call(Hash._SET_2D_LAYER, 4);
                    Function.Call(Hash._0xC6372ECD45D73BCD, true);
                    Function.Call((Hash)0x2BC54A8188768488, "prop_screen_biker_laptop", "prop_screen_biker_laptop_2", 0.5f, 0.5f, 1f, 1f, 0f, 255, 255, 255, 255);
                    Function.Call((Hash)0xE3A3DB414A373DAB);
                    Function.Call(Hash.SET_TEXT_RENDER_ID, 1);
                }

                if (PlayerPosition.DistanceTo(Constants.MethLabExit) <= Constants.MarkerInteractionDistance)
                {
                    CurrentInteractionType = InteractionType.ExitMethLab;
                    Util.DisplayHelpText($"Press {HelpTextKeys.Get(InteractionControl)} to leave the meth lab.");
                }
                else if (PlayerPosition.DistanceTo(Constants.MethLabLaptop) <= Constants.MarkerInteractionDistance)
                {
                    CurrentInteractionType = InteractionType.ManageMethLab;
                    Util.DisplayHelpText($"Press {HelpTextKeys.Get(InteractionControl)} to manage the meth lab.");
                }
                else
                {
                    ManagementMenuPool.CloseAllMenus();

                    if (IsLeaning)
                    {
                        CurrentInteractionType = InteractionType.CancelLean;
                        Util.DisplayHelpText($"Press {HelpTextKeys.Get(InteractionControl)} to stop leaning on the rail.");
                    }
                    else
                    {
                        if (Game.Player.Character.IsInArea(Constants.LeanAreaMin, Constants.LeanAreaMax))
                        {
                            CurrentInteractionType = InteractionType.Lean;
                            Util.DisplayHelpText($"Press {HelpTextKeys.Get(InteractionControl)} to lean on the rail.");
                        }
                    }
                }

                // Disable some controls inside the interior
                for (int i = 0; i < Constants.ControlsToDisable.Length; i++)
                {
                    Function.Call(Hash.DISABLE_CONTROL_ACTION, 2, Constants.ControlsToDisable[i], true);
                }
            }
            else
            {
                // Outside, draw lab markers
                for (int i = 0; i < MethLabs.Count; i++)
                {
                    DistanceToInteractable = PlayerPosition.DistanceTo(MethLabs[i].Position);

                    if (DistanceToInteractable <= Constants.MarkerDrawDistance)
                    {
                        World.DrawMarker(MarkerType.VerticalCylinder, MethLabs[i].Position, Vector3.Zero, Vector3.Zero, Constants.MarkerScale, Constants.MarkerColor);

                        if (DistanceToInteractable <= Constants.MarkerInteractionDistance)
                        {
                            InteractableLabIdx = i;

                            if (MethLabs[i].HasFlag(LabFlags.IsOwned))
                            {
                                CurrentInteractionType = InteractionType.EnterMethLab;
                                Util.DisplayHelpText($"Press {HelpTextKeys.Get(InteractionControl)} to enter the meth lab.");
                            }
                            else
                            {
                                CurrentInteractionType = InteractionType.BuyMethLab;
                                Util.DisplayHelpText($"Press {HelpTextKeys.Get(InteractionControl)} to buy the {MethLabs[i].Location} meth lab.~n~Price: ~g~${MethLabs[i].Price:N0}");
                            }

                            break;
                        }
                    }
                }
            }
            #endregion

            // Handle interactions
            #region Interaction Handling
            if (Game.IsControlJustPressed(2, (Control)InteractionControl))
            {
                int labIdx = InteractableLabIdx == -1 ? InsideMethLabIdx : InteractableLabIdx;
                if (labIdx == -1)
                {
                    return;
                }

                Character currentCharacter = Util.GetCharacterFromModel(Game.Player.Character.Model.Hash);
                if (currentCharacter == Character.Unknown)
                {
                    UI.Notify("Only Michael, Franklin and Trevor can interact with meth labs.");
                    return;
                }

                switch (CurrentInteractionType)
                {
                case InteractionType.BuyMethLab:
                    if (PlayerPosition.DistanceTo(MethLabs[labIdx].Position) > Constants.MarkerInteractionDistance)
                    {
                        return;
                    }

                    if (Game.Player.Money < MethLabs[labIdx].Price)
                    {
                        UI.Notify("You don't have enough money to buy this meth lab.");
                        return;
                    }

                    MethLabs[labIdx].Owner = currentCharacter;

                    MethLabs[labIdx].LastVisit = Util.GetGameDate();
                    MethLabs[labIdx].Flags     = LabFlags.None;
                    MethLabs[labIdx].AddFlag(LabFlags.IsOwned);

                    Game.Player.Money -= MethLabs[InteractableLabIdx].Price;
                    Save();

                    Util.NotifyWithPicture("LJT", $"{currentCharacter}, good call buying the {MethLabs[labIdx].Location} meth lab. Go inside and check the laptop to get started.", "CHAR_LJT", 1);
                    break;

                case InteractionType.EnterMethLab:
                    if (PlayerPosition.DistanceTo(MethLabs[labIdx].Position) > Constants.MarkerInteractionDistance)
                    {
                        return;
                    }

                    if (currentCharacter != MethLabs[labIdx].Owner)
                    {
                        UI.Notify($"Only the owner ({MethLabs[labIdx].Owner}) can enter this meth lab.");
                        return;
                    }

                    if (Game.MissionFlag)
                    {
                        UI.Notify("You can't enter meth labs while being in a mission.");
                        return;
                    }

                    if (Game.Player.WantedLevel > 0)
                    {
                        UI.Notify("You can't enter meth labs while being wanted by the police.");
                        return;
                    }

                    PlayerLabModel   = Game.Player.Character.Model.Hash;
                    InsideMethLabIdx = labIdx;
                    EnteredMethLab.Invoke(labIdx);

                    Game.Player.Character.Position = Constants.MethLabExit;
                    Game.Player.Character.Heading  = Constants.MethLabHeading;
                    Game.Player.Character.Weapons.Select(WeaponHash.Unarmed);
                    break;

                case InteractionType.ExitMethLab:
                    if (PlayerPosition.DistanceTo(Constants.MethLabExit) > Constants.MarkerInteractionDistance)
                    {
                        return;
                    }

                    Game.Player.Character.Position = MethLabs[labIdx].Position;

                    LeftMethLab.Invoke(labIdx, LabExitReason.Player);
                    InsideMethLabIdx = -1;
                    break;

                case InteractionType.ManageMethLab:
                    if (PlayerPosition.DistanceTo(Constants.MethLabLaptop) > Constants.MarkerInteractionDistance)
                    {
                        return;
                    }

                    ManagementMenuPool.RefreshIndex();
                    ManagementMain.Visible = true;
                    break;

                case InteractionType.Lean:
                    if (IsLeaning || !Game.Player.Character.IsInArea(Constants.LeanAreaMin, Constants.LeanAreaMax))
                    {
                        return;
                    }

                    Util.RequestAnimDict("anim@amb@yacht@rail@standing@male@variant_01@");
                    using (TaskSequence tseq = new TaskSequence())
                    {
                        Function.Call(Hash.TASK_GO_STRAIGHT_TO_COORD, 0, Constants.LeanPos.X, Constants.LeanPos.Y, Constants.LeanPos.Z, 1.0f, -1, Constants.LeanHeading, 0.0f);
                        tseq.AddTask.PlayAnimation("anim@amb@yacht@rail@standing@male@variant_01@", "enter");
                        tseq.AddTask.PlayAnimation("anim@amb@yacht@rail@standing@male@variant_01@", "base", 8.0f, -1, AnimationFlags.Loop);
                        tseq.Close();

                        Game.Player.Character.Task.PerformSequence(tseq);
                    }

                    IsLeaning = true;
                    break;

                case InteractionType.CancelLean:
                    if (!IsLeaning)
                    {
                        return;
                    }

                    Game.Player.Character.Task.PlayAnimation("anim@amb@yacht@rail@standing@male@variant_01@", "exit");
                    IsLeaning = false;
                    break;
                }
            }
            #endregion
        }
Пример #18
0
        public override async Task Tick()
        {
            if (this.InAnim && Input.Input.IsControlJustPressed(Control.MoveUpOnly))
            {
                Game.Player.Character.Task.ClearAllImmediately(); // Cancel animation
                this.InAnim = false;
            }
            if (Game.Player.Character.IsInVehicle() || this.InAnim)
            {
                return;
            }

            Tuple <BankAtm, Prop> atm = this.Atms
                                        .Select(a => new { atm = a, distance = a.Position.DistanceToSquared(Game.Player.Character.Position) })
                                        .Where(a => a.distance < 5.0F) // Nearby
                                        .Select(a => new { a.atm, prop = new Prop(API.GetClosestObjectOfType(a.atm.PosX, a.atm.PosY, a.atm.PosZ, 1, (uint)a.atm.Hash, false, false, false)), a.distance })
                                        .Where(p => p.prop.Model.IsValid)
                                        .Where(a => Vector3.Dot(a.prop.ForwardVector, Vector3.Normalize(a.prop.Position - Game.Player.Character.Position)).IsBetween(0f, 1.0f)) // In front of
                                        .OrderBy(a => a.distance)
                                        .Select(a => new Tuple <BankAtm, Prop>(a.atm, a.prop))
                                        .FirstOrDefault();

            //var i = 0;
            //foreach (var tatm in this.Atms)
            //{
            //    i++;
            //    var prop = new Prop(API.GetClosestObjectOfType(tatm.PosX, tatm.PosY, tatm.PosZ, 1, (uint)tatm.Hash, false, false, false));
            //    CitizenFX.Core.World.DrawMarker(MarkerType.HorizontalCircleSkinny, prop.Position - (prop.Position - prop.Position.TranslateDir(prop.Heading - 90, 0.4f)) + Vector3.Up * 0.1f, Vector3.Zero, Vector3.Zero, Vector3.One * 2, Color.FromArgb(50, 239, 239, 239));
            //}

            if (atm == null)
            {
                return;
            }


            new Text("Press M to use ATM", new PointF(50, Screen.Height - 50), 0.4f, Color.FromArgb(255, 255, 255), Font.ChaletLondon, Alignment.Left, false, true).Draw();

            if (!Input.Input.IsControlJustPressed(Control.InteractionMenu))
            {
                return;
            }

            TaskSequence ts = new TaskSequence();

            ts.AddTask.LookAt(atm.Item2);
            //ts.AddTask.GoTo(atm.Item2, atm.Item2.Position.TranslateDir(atm.Item2.Heading - 90, 0.4f) - atm.Item2.Position, 2000);
            ts.AddTask.GoTo(atm.Item2, Vector3.Zero, 2000);
            ts.AddTask.AchieveHeading(atm.Item2.Heading);
            ts.AddTask.ClearLookAt();
            ts.Close();
            Game.Player.Character.Task.PerformSequence(ts);
            while (Game.Player.Character.TaskSequenceProgress < 0)
            {
                await BaseScript.Delay(100);
            }
            while (Game.Player.Character.TaskSequenceProgress > 0)
            {
                await BaseScript.Delay(100);
            }

            API.SetScenarioTypeEnabled("PROP_HUMAN_ATM", true);
            API.ResetScenarioTypesEnabled();
            API.TaskStartScenarioInPlace(Game.PlayerPed.Handle, "PROP_HUMAN_ATM", 0, true);
            this.InAnim = true;

            bool result = await Rpc.Server.Request <Guid, Guid, double, bool>(
                RpcEvents.BankAtmWithdraw,
                atm.Item1.Id,
                Guid.Parse("e9286e6f-e74d-4510-855b-5318ef0f71af"),
                100
                );

            Client.Log($"ATM Withdraw response: {result}");


            // TODO: Better?
            //Game.Player.Character.Task.PlayAnimation("amb@prop_human_atm@male@enter", "enter");
            //Game.Player.Character.Task.PlayAnimation("amb@prop_human_atm@male@base", "base");
            //Game.Player.Character.Task.PlayAnimation("amb@prop_human_atm@male@idle_a", "idle_a");
            //Game.Player.Character.Task.PlayAnimation("amb@prop_human_atm@male@idle_a", "idle_b");
            //Game.Player.Character.Task.PlayAnimation("amb@prop_human_atm@male@exit", "exit");
        }
Пример #19
0
        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);
            }
        }
Пример #20
0
        /// <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
            }
        }
Пример #21
0
        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;
                }
            }
        }
Пример #22
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);
                    }
                }
            }
        }
Пример #23
0
        private async Task BranchTick()
        {
            // Ped spawning/tracking
            foreach (var bankBranch in this.branches)
            {
                var bankBranchPos = new Vector3(bankBranch.Position.X, bankBranch.Position.Y, bankBranch.Position.Z);
                if (this.tellers.ContainsKey(bankBranch) && this.tellers[bankBranch].Handle != 0)
                {
                    this.tellers[bankBranch].Position = bankBranchPos;
                    this.tellers[bankBranch].Heading  = bankBranch.Heading;
                    continue;
                }
                var tellerModel = new Model(PedHash.Bankman);
                await tellerModel.Request(-1);

                this.tellers[bankBranch] = await World.CreatePed(tellerModel, bankBranchPos, bankBranch.Heading);

                this.tellers[bankBranch].Task?.ClearAllImmediately();
                this.tellers[bankBranch].Task?.StandStill(1);
                this.tellers[bankBranch].AlwaysKeepTask       = true;
                this.tellers[bankBranch].IsInvincible         = true;
                this.tellers[bankBranch].IsPositionFrozen     = true;
                this.tellers[bankBranch].BlockPermanentEvents = true;
                this.tellers[bankBranch].IsCollisionProof     = false;
            }

            if (Game.Player.Character.IsInVehicle() || this.InAnim)
            {
                return;
            }

            // Get nearest ped
            var teller = this.tellers
                         .Select(t => new { teller = t, distance = t.Value?.Position.DistanceToSquared(Game.Player.Character.Position) ?? float.MaxValue })
                         .Where(t => t.distance < 5.0F) // Nearby
                                                        //.Where(a => Vector3.Dot(a.Item2.ForwardVector, Vector3.Normalize(a.Item2.Position - Game.Player.ActiveCharacter.Position)).IsBetween(0f, 1.0f)) // In front of
                         .OrderBy(t => t.distance)
                         .Select(t => t.teller)
                         .FirstOrDefault();

            if (teller.Value == null)
            {
                return;
            }

            // Add UI text
            new Text($"Press Z to use Branch {teller.Key.Name}", new PointF(50, Screen.Height - 50), 0.4f, Color.FromArgb(255, 255, 255), Font.ChaletLondon, Alignment.Left, false, true).Draw();

            if (!this.interactKey.IsJustPressed())
            {
                return;
            }

            // Initiate ped interaction
            this.InAnim = true;
            var bankTeller = teller.Value;
            var ts         = new TaskSequence();

            ts.AddTask.LookAt(bankTeller);
            var moveToPos = bankTeller.GetPositionInFront(1.5f);

            ts.AddTask.SlideTo(new Vector3(moveToPos.X, moveToPos.Y, moveToPos.Z), bankTeller.Heading - 180);
            ts.AddTask.AchieveHeading(bankTeller.Heading - 180);
            ts.Close();
            await Game.Player.Character.RunTaskSequence(ts);

            Game.Player.Character.Task.LookAt(bankTeller);
            Game.Player.Character.Task.StandStill(-1);

            // Camera
            var tellerFrontPos = teller.Value.Position.ToVector3().TranslateDir(bankTeller.Heading + 110, 2.2f);

            this.Camera = World.CreateCamera(
                new Vector3(tellerFrontPos.X, tellerFrontPos.Y, tellerFrontPos.Z) + (Vector3.UnitZ * 0.8f),
                GameplayCamera.Rotation,
                30
                );
            this.Camera.PointAt(new Vector3(bankTeller.Position.X, bankTeller.Position.Y, bankTeller.Position.Z) + Vector3.UnitZ * 0.4f);
            World.RenderingCamera.InterpTo(this.Camera, 1000, true, true);
            API.RenderScriptCams(true, true, 1000, true, false);
        }
Пример #24
0
        public async Task StartInteraction(Ped closest, Ped staff, Ped suspect)
        {
            this.staff.Task.ChatTo(closest);
            ShowDialog("[Transit Guard] Oh hello officer, I've stopped this guy for fare evading.", 3000, 20f);
            this.staff.Task.LookAt(suspect, 1000);
            await BaseScript.Delay(4000);

            this.suspect.Task.ChatTo(closest);
            ShowDialog("[Suspect] I've done nothing wrong, I have a ticket!", 3000, 20f);
            await BaseScript.Delay(4000);

            ShowDialog("[You] Ok, not to worry. Do you have a valid ticket?", 3000, 20f);
            await BaseScript.Delay(1500);

            int dice = random.Next(0, 100);

            if (dice <= 20)
            {
                TaskSequence sequence = new TaskSequence();

                ShowDialog("[Suspect] Get F****d!", 3000, 30f);
                sequence.AddTask.FightAgainst(staff, 5000);
                sequence.AddTask.FleeFrom(closest);
                sequence.Close();

                suspect.Task.PerformSequence(sequence);
                suspect.AttachBlip();
            }
            else if (dice > 20 && dice <= 75)
            {
                PedData data = new PedData();
                Item    Tix  = new Item();

                dice = random.Next(0, 100);
                if (dice <= 50)
                {
                    Tix.Name      = "Fraudulent Metro Ticket";
                    Tix.IsIllegal = true;
                }
                else
                {
                    Tix.Name      = "Valid Metro Ticket";
                    Tix.IsIllegal = false;
                }
                data.Items = new List <Item>();
                data.Items.Add(Tix);
                Utilities.SetPedData(suspect.NetworkId, data);

                await BaseScript.Delay(1500);

                ShowDialog("[Suspect] F*****g hell! Search me then!", 3000, 20f);
                suspect.Task.HandsUp(-1);
            }
            else
            {
                await BaseScript.Delay(1500);

                ShowDialog("[Suspect] Certainly officer, I just didn't like this guard's attitude.", 3000, 20f);
                ShowNetworkedNotification("The suspect shows a valid ticket to ride.", "CHAR_HUMANDEFAULT", "CHAR_HUMANDEFAULT", "Ticket Evader", " ", 20f);
            }
        }
Пример #25
0
        /// <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;
                }
            }
        }
Пример #26
0
    void Onkeyup(object sender, KeyEventArgs e)
    {
        if (e.KeyCode == Keys.F12 && Game.Player.WantedLevel > 1)
        {
            hours = 10 + Game.Player.WantedLevel * 10;
            Game.Player.WantedLevel = 0;
            intial1();
        }

        /*  if (e.KeyCode == Keys.F11)
         * {
         *    Ped[] test = World.GetNearbyPeds(Game.Player.Character, 100f);
         *    int player_group = Function.Call<int>(Hash.GET_PED_RELATIONSHIP_GROUP_HASH, test[0]);
         *    GTA.UI.ShowSubtitle(player_group + " ");
         * }
         */

        if (e.KeyCode == Keys.E && arrested)
        {
            if (Game.Player.Character.Position.DistanceTo(new Vector3(1691.709f, 2565.036f, 45.56487f)) < 2f)
            {
                // bail
                if (Game.Player.Money > 5000000)
                {
                    bail.Remove();
                    roit.Remove();
                    Game.Player.Character.Position = new Vector3(1849.555f, 2586.085f, 45.67202f);
                    Game.Player.Character.Heading  = 258.4564f;
                    Game.Player.Money -= 5000000;
                    Function.Call(Hash.SET_MAX_WANTED_LEVEL, 5);

                    Function.Call(Hash.SET_PED_DEFAULT_COMPONENT_VARIATION, Game.Player.Character);
                    arrested = false;

                    _headsup          = null;
                    _headsupRectangle = null;
                }
                else
                {
                }
            }

            if (Game.Player.Character.Position.DistanceTo(new Vector3(1625.474f, 2491.485f, 45.62026f)) < 4f && !escape)
            {
                Function.Call(Hash.TERMINATE_ALL_SCRIPTS_WITH_THIS_NAME, "respawn_controller");
                Function.Call(Hash.TERMINATE_ALL_SCRIPTS_WITH_THIS_NAME, "re_prison");
                bail.Remove();
                roit.Remove();
                Game.Player.Money -= 5000000;
                Function.Call(Hash.TERMINATE_ALL_SCRIPTS_WITH_THIS_NAME, "respawn_controller");
                Function.Call(Hash.TERMINATE_ALL_SCRIPTS_WITH_THIS_NAME, "re_prison");
                // 182.3307f , -885.7198f , 31.11671f :=> 51.15437f


                Function.Call(Hash.TERMINATE_ALL_SCRIPTS_WITH_THIS_NAME, "respawn_controller");
                Function.Call(Hash.TERMINATE_ALL_SCRIPTS_WITH_THIS_NAME, "re_prison");
                //  -1083,942 : -2915,736 : 13,23366 :=> 285,5021
                if (help_veh == null)
                {
                    help_veh = World.CreateVehicle(VehicleHash.Maverick, new Vector3(1649.463f, 2619.634f, 45.56486f));
                }
                else
                {
                    help_veh.Delete();
                    help_veh = World.CreateVehicle(VehicleHash.Maverick, new Vector3(1649.463f, 2619.634f, 45.56486f));
                }
                Function.Call(Hash.TERMINATE_ALL_SCRIPTS_WITH_THIS_NAME, "respawn_controller");
                Function.Call(Hash.TERMINATE_ALL_SCRIPTS_WITH_THIS_NAME, "re_prison");

                Function.Call(Hash.SET_ENTITY_AS_MISSION_ENTITY, help_veh, true, true);
                help_veh.Heading = 10.83339f;


                Function.Call(Hash.TERMINATE_ALL_SCRIPTS_WITH_THIS_NAME, "respawn_controller");
                Function.Call(Hash.TERMINATE_ALL_SCRIPTS_WITH_THIS_NAME, "re_prison");

                bail       = World.CreateBlip(help_veh.Position);
                bail.Color = BlipColor.Blue;

                Function.Call(Hash.TERMINATE_ALL_SCRIPTS_WITH_THIS_NAME, "respawn_controller");
                Function.Call(Hash.TERMINATE_ALL_SCRIPTS_WITH_THIS_NAME, "re_prison");


                GiveAllWeapons(Game.Player.Character);

                Function.Call(Hash.TERMINATE_ALL_SCRIPTS_WITH_THIS_NAME, "respawn_controller");
                Function.Call(Hash.TERMINATE_ALL_SCRIPTS_WITH_THIS_NAME, "re_prison");


                Function.Call(Hash.PAUSE_CLOCK, false);

                Function.Call(Hash.TERMINATE_ALL_SCRIPTS_WITH_THIS_NAME, "respawn_controller");
                Function.Call(Hash.TERMINATE_ALL_SCRIPTS_WITH_THIS_NAME, "re_prison");

                arrested          = false;
                _headsup          = null;
                _headsupRectangle = null;

                Function.Call(Hash.TERMINATE_ALL_SCRIPTS_WITH_THIS_NAME, "respawn_controller");
                Function.Call(Hash.TERMINATE_ALL_SCRIPTS_WITH_THIS_NAME, "re_prison");

                Function.Call(Hash.SET_CLOCK_TIME, 13, 00, 0);
                Function.Call(Hash.SET_MAX_WANTED_LEVEL, 5);
                Game.Player.WantedLevel = 4;



                escape = true;
            }
        }
        if (e.KeyCode == Keys.Y && arrested)
        {
            //  prisoner groupe   2124571506
            //  garde    groupe   -183807561
            if (Game.Player.Character.Position.DistanceTo(escape_Ped.Position) < 4f)
            {
                for (int i = 0; i < prisoner.Count; i++)
                {
                    GiveAllWeapons1(prisoner[i]);
                    prisoner[i].CanSwitchWeapons = true;
                }

                for (int i = 0; i < garde.Count; i++)
                {
                    GiveAllWeapons2(garde[i]);
                    garde[i].CanSwitchWeapons = true;
                }


                GiveAllWeapons1(Game.Player.Character);
                Game.Player.Money -= 5000000;

                Function.Call(Hash.SET_RELATIONSHIP_BETWEEN_GROUPS, (int)Relationship.Hate, 2124571506, -183807561);
                Function.Call(Hash.SET_RELATIONSHIP_BETWEEN_GROUPS, (int)Relationship.Hate, -183807561, 2124571506);
            }
        }
        if (e.KeyCode == Keys.U)
        {
            Function.Call(Hash.ENABLE_ALL_CONTROL_ACTIONS, 1);
            Game.Player.CanControlCharacter = true;
            Function.Call(Hash.SET_ENABLE_HANDCUFFS, Game.Player.Character, false);
            Function.Call(Hash.SET_ENABLE_BOUND_ANKLES, Game.Player.Character, false);
        }
        if (e.KeyCode == Keys.Y)
        {
            Function.Call(Hash.SET_MAX_WANTED_LEVEL, 5);
        }
        if (e.KeyCode == Keys.F6)
        {
            // PBUS
            // VehicleHash.PBus
            // 1971.267f , 2635.439f , 46.17389f :=> 120.792f
            // 1608.376f , 2685.54f , 45.32081f :=> 143.341f
            testt = true;
            if (test_veh == null)
            {
                test_veh         = World.CreateVehicle(VehicleHash.PBus, new Vector3(1971.267f, 2635.439f, 46.17389f));
                test_veh.Heading = 120.792f;
            }
            else
            {
                test_veh.Delete();
                test_veh         = World.CreateVehicle(VehicleHash.PBus, new Vector3(1971.267f, 2635.439f, 46.17389f));
                test_veh.Heading = 120.792f;
            }

            if (driver == null)
            {
                driver         = World.CreatePed(PedHash.Prisguard01SMM, new Vector3(1971.267f, 2635.439f, 46.17389f));
                driver.Heading = 120.792f;
            }
            else
            {
                driver.Delete();
                driver         = World.CreatePed(PedHash.Prisguard01SMM, new Vector3(1971.267f, 2635.439f, 46.17389f).Around(5f));
                driver.Heading = 120.792f;
            }
            driver.Task.WarpIntoVehicle(test_veh, VehicleSeat.Driver);

            //  Game.Player.CanControlCharacter = false;
            Game.Player.Character.Position = new Vector3(1971.267f, 2635.439f, 46.17389f).Around(10f);

            // Function.Call(Hash.DISABLE_ALL_CONTROL_ACTIONS, 1);


            Game.Player.Character.Task.WarpIntoVehicle(test_veh, VehicleSeat.Passenger);

            Function.Call(Hash.SET_PED_AS_GROUP_MEMBER, driver, -1533126372);
            Function.Call(Hash.SET_PED_AS_COP, driver, true);

            // 1   1858,746 : 2609,113 : 45,29342
            // 2   1831,064 : 2607,884 : 45,20006
            // 3   1754,864 : 2605,129 : 45,18484
            while (!Game.Player.Character.IsInVehicle(test_veh))
            {
                Script.Wait(0);
            }

            TaskSequence task = new TaskSequence();
            //     task.AddTask.DriveTo(test_veh, new Vector3(1900.457f, 2609.054f, 46.00166f), 3f, 10f, (int)DrivingStyle.Normal);
            //     task.AddTask.StandStill(5000);
            task.AddTask.DriveTo(test_veh, new Vector3(1855.855f, 2606.756f, 45.9304f), 3f, 10f, (int)DrivingStyle.Normal);
            task.AddTask.StandStill(5000);
            task.AddTask.DriveTo(test_veh, new Vector3(1831.152f, 2606.738f, 45.83254f), 3f, 10f, (int)DrivingStyle.Normal);
            task.AddTask.StandStill(5000);
            task.AddTask.DriveTo(test_veh, new Vector3(1754.018f, 2604.271f, 45.82404f), 3f, 10f, (int)DrivingStyle.Normal);
            task.AddTask.StandStill(50000);
            driver.Task.PerformSequence(task);
            task.Close();

            // new Vector3(1858.746f, 2609.113f, 45.29342f)
            // new Vector3(1831.064f, 2607.884f, 45.20006f)
            // new Vector3(1754.864f, 2605.129f, 45.18484f)


            //     int t = Function.Call<int>(Hash.GET_HASH_KEY,"prop_gate_prison_01");
            //     Function.Call(Hash._0x9B12F9A24FABEDB0, t, 1845.0f, 2605.0f, 45.0f, 0, 0.0f, 50.0f, 0f);
            //     Function.Call(Hash._0x9B12F9A24FABEDB0, t, 1819.27f, 2608.53f, 44.61f, 0, 0.0f, 50.0f, 0f);
        }
        if (e.KeyCode == Keys.O)
        {
            Function.Call(Hash.IGNORE_NEXT_RESTART, true);
        }

        /*  if (e.KeyCode == Keys.O)
         * {
         *     int t = Function.Call<int>(Hash.GET_HASH_KEY, "prop_gate_prison_01");
         *     Function.Call(Hash._0x9B12F9A24FABEDB0, t, 1845.0f, 2605.0f, 45.0f, 0, 0.0f, 50.0f, 0f);
         *     Function.Call(Hash._0x9B12F9A24FABEDB0, t, 1819.27f, 2608.53f, 44.61f, 0, 0.0f, 50.0f, 0f);
         * }
         *
         * if (e.KeyCode == Keys.P)
         * {
         *     int t = Function.Call<int>(Hash.GET_HASH_KEY, "prop_gate_prison_01");
         *     Function.Call(Hash._0x9B12F9A24FABEDB0, t, 1845.0f, 2605.0f, 45.0f, 1, 0.0f, 50.0f, 0f);
         *     Function.Call(Hash._0x9B12F9A24FABEDB0, t, 1819.27f, 2608.53f, 44.61f, 1, 0.0f, 50.0f, 0f);
         * }
         */
    }
Пример #27
0
        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;
            }
            }
        }
Пример #28
0
 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;
                         }
                     }
                 }
             }
         }
     }
 }
Пример #29
0
        public override async Task Tick()
        {
            if (!this.CharLoaded)
            {
                return;
            }
            if (this.InAnim && Input.Input.IsControlJustPressed(Control.MoveUpOnly))
            {
                Game.Player.Character.Task.ClearAllImmediately(); // Cancel animation
                this.InAnim = false;
            }
            if (Game.Player.Character.IsInVehicle() || this.InAnim)
            {
                return;
            }

            foreach (BankBranch bankBranch in this.Branches)
            {
                if (this.Tellers.ContainsKey(bankBranch) && this.Tellers[bankBranch].Handle != 0)
                {
                    continue;
                }
                var tellerModel = new Model(PedHash.Bankman);
                await tellerModel.Request(-1);

                this.Tellers[bankBranch] = await CitizenFX.Core.World.CreatePed(tellerModel, bankBranch.Position, bankBranch.Heading);

                this.Tellers[bankBranch].Task?.ClearAllImmediately();
                this.Tellers[bankBranch].Task?.StandStill(1);
                this.Tellers[bankBranch].AlwaysKeepTask       = true;
                this.Tellers[bankBranch].IsInvincible         = true;
                this.Tellers[bankBranch].IsPositionFrozen     = true;
                this.Tellers[bankBranch].BlockPermanentEvents = true;
            }

            //foreach (var banker in this.Tellers.Select(x=>x.Value))
            //{
            //    CitizenFX.Core.World.DrawMarker(MarkerType.HorizontalCircleSkinny, banker.GetPositionInFront(1.5f), Vector3.Zero, Vector3.Zero, Vector3.One * 2, Color.FromArgb(50, 239, 239, 239));
            //}

            KeyValuePair <BankBranch, Ped> teller = this.Tellers
                                                    .Select(t => new { teller = t, distance = t.Value?.Position.DistanceToSquared(Game.Player.Character.Position) ?? float.MaxValue })
                                                    .Where(t => t.distance < 5.0F) // Nearby
                                                                                   //.Where(a => Vector3.Dot(a.Item2.ForwardVector, Vector3.Normalize(a.Item2.Position - Game.Player.Character.Position)).IsBetween(0f, 1.0f)) // In front of
                                                    .OrderBy(t => t.distance)
                                                    .Select(t => t.teller)
                                                    .FirstOrDefault();

            if (teller.Value == null)
            {
                return;
            }

            new Text($"Press M to use Branch {teller.Key.Name}", new PointF(50, Screen.Height - 50), 0.4f, Color.FromArgb(255, 255, 255), Font.ChaletLondon, Alignment.Left, false, true).Draw();

            if (!Input.Input.IsControlJustPressed(Control.InteractionMenu))
            {
                return;
            }

            TaskSequence ts = new TaskSequence();

            ts.AddTask.LookAt(teller.Value);
            //ts.AddTask.GoTo(teller.Value, teller.Value.Position - teller.Value.Position.TranslateDir(teller.Value.Heading - 90, 1.5f), 2000);
            ts.AddTask.GoTo(teller.Value.GetPositionInFront(1.5f));
            ts.AddTask.AchieveHeading(teller.Value.Heading - 180);
            ts.AddTask.ClearLookAt();
            ts.Close();
            Game.Player.Character.Task.PerformSequence(ts);
        }
Пример #30
0
        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;
                }
            }
        }