コード例 #1
0
        protected override void Setup()
        {
            config = LoadConfig <CitizenAttachVehicleConfig>();

            this.OnKeyDownAsObservable
            .Where(x => PlayerPed.IsInVehicle() && x.KeyCode.ToString() == EnableKeyCode)
            .Subscribe(_ =>
            {
                DrawText("GrabVehicle");
                StartAttachAction();
            });

            this.OnKeyDownAsObservable
            .Where(x => x.KeyCode.ToString() == DisableKeyCode)
            .Subscribe(_ =>
            {
                DrawText("ReleaseVehicle");
                ReleaseAll();
            });

            //車から降りたら終了
            this.OnThinnedTickAsObservable
            .Select(_ => PlayerPed.IsInVehicle())
            .DistinctUntilChanged()
            .Where(x => !x)
            .Subscribe(_ => ReleaseAll());

            this.OnAbortAsync
            .Subscribe(_ => ReleaseAll());
        }
コード例 #2
0
 public override void End()
 {
     CalloutRunning = false;
     NativeFunction.Natives.RESET_AI_MELEE_WEAPON_DAMAGE_MODIFIER();
     if (PlayerPed.Exists())
     {
         if (PlayerPed.IsDead)
         {
             GameFiber.Wait(1500);
             Functions.PlayScannerAudio("OFFICER HAS_BEEN_FATALLY_SHOT NOISE_SHORT OFFICER_NEEDS_IMMEDIATE_ASSISTANCE");
             GameFiber.Wait(3000);
         }
     }
     if (CalloutFinished)
     {
         if (Passenger.Exists())
         {
             Passenger.Dismiss();
         }
     }
     else
     {
         if (Passenger.Exists())
         {
             Passenger.Delete();
         }
     }
     base.End();
 }
コード例 #3
0
        /// <summary>
        /// カオス化時の攻撃対象を取得する
        /// </summary>
        /// <param name="ped"></param>
        /// <returns></returns>
        private Ped GetTargetPed(Ped ped)
        {
            if (!ped.IsSafeExist() || !PlayerPed.IsSafeExist())
            {
                return(null);
            }

            //プレイヤへの攻撃補正が設定されているならプレイヤを攻撃対象にする
            if (chaosModeSetting.IsAttackPlayerCorrectionEnabled &&
                Random.Next(0, 100) < chaosModeSetting.AttackPlayerCorrectionProbabillity)
            {
                return(PlayerPed);
            }

            //100m以内の市民
            var aroundPeds =
                CachedPeds.Concat(new[] { PlayerPed }).Where(
                    x => x.IsSafeExist() && !x.IsSameEntity(ped) && x.IsAlive && ped.IsInRangeOf(x.Position, 100))
                .ToArray();

            //100m以内の市民のうち、より近い人を選出
            var nearPeds = aroundPeds.OrderBy(x => (ped.Position - x.Position).Length()).Take(5).ToArray();

            if (nearPeds.Length == 0)
            {
                return(null);
            }
            var randomindex = Random.Next(nearPeds.Length);

            return(nearPeds[randomindex]);
        }
コード例 #4
0
        private void RunAway()
        {
            affectPeds.RemoveWhere(x => !x.IsSafeExist());
            if (!PlayerPed.IsSafeExist())
            {
                return;
            }

            var playerVehicle = PlayerPed.CurrentVehicle;

            //プレイヤ周辺の車
            var drivers = CachedVehicles.Where(x => x.IsSafeExist() &&
                                               (!playerVehicle.IsSafeExist() || !x.IsSameEntity(playerVehicle)) &&
                                               !x.IsRequiredForMission() &&
                                               (x.Position - PlayerPed.Position).Length() <= PlayerAroundDistance)
                          .Select(x => x.GetPedOnSeat(VehicleSeat.Driver))
                          .Where(x => x.IsSafeExist() && !affectPeds.Contains(x));

            foreach (var driver in drivers)
            {
                try
                {
                    driver.DrivingSpeed    = 100.0f;
                    driver.MaxDrivingSpeed = 100.0f;
                    driver.DrivingStyle    = DrivingStyle.AvoidTrafficExtremely;
                    driver.Task.VehicleChase(PlayerPed);
                    affectPeds.Add(driver);
                }
                catch (Exception e)
                {
                    LogWrite(e.ToString());
                }
            }
        }
コード例 #5
0
 public void Update()
 {
     if (!Entity.Exists(Shuttle))
     {
         return;
     }
     if (PlayerPed.IsInVehicle(new Vehicle(Shuttle.Handle)))
     {
         if (Game.IsControlJustPressed(2, Control.Jump))
         {
             Shuttle.Launch();
         }
     }
     else
     {
         EnterShuttle();
     }
     if (Shuttle.HeightAboveGround <= Settings.EnterOrbitHeight)
     {
         return;
     }
     Shuttle.RemoveAttachments();
     Shuttle.HasCollision = true;
     Shuttle = null;
 }
コード例 #6
0
        private void CreateParachutePed()
        {
            if (!PlayerPed.IsSafeExist())
            {
                return;
            }
            var playerPosition = PlayerPed.Position;

            var velocity = PlayerPed.Velocity;
            //プレイヤが移動中ならその進行先に生成する
            var ped =
                NativeFunctions.CreateRandomPed(playerPosition + 3 * velocity + new Vector3(0, 0, 50).AroundRandom2D(50));

            if (!ped.IsSafeExist())
            {
                return;
            }

            ped.MarkAsNoLongerNeeded();
            ped.Task.ClearAllImmediately();
            ped.TaskSetBlockingOfNonTemporaryEvents(true);
            ped.SetPedKeepTask(true);
            ped.AlwaysKeepTask = true;
            //プレイヤ周囲15mを目標に降下
            var targetPosition = playerPosition.AroundRandom2D(15);

            ped.ParachuteTo(targetPosition);

            //着地までカオス化させない
            StartCoroutine(PedOnGroundedCheck(ped));
        }
コード例 #7
0
        protected override void Setup()
        {
            CreateInputKeywordAsObservable("armor")
            .Subscribe(_ =>
            {
                IsActive = !IsActive;
                DrawText("SupplyArmorAndHealth:" + IsActive, 3.0f);
            });

            OnAllOnCommandObservable.Subscribe(_ => IsActive = true);

            //ミッションが始まった時
            OnThinnedTickAsObservable
            .Where(_ => IsActive)
            .Select(_ => Game.MissionFlag)
            .DistinctUntilChanged()
            .Where(x => x)
            .Subscribe(_ => SupplyArmorAndHealth());

            //プレイヤが復活した時
            OnThinnedTickAsObservable
            .Where(_ => IsActive && PlayerPed.IsSafeExist())
            .Select(_ => PlayerPed.IsAlive)
            .DistinctUntilChanged()
            .Skip(1)     //ONにした直後の判定結果は無視
            .Where(x => x)
            .Subscribe(_ => SupplyArmorAndHealth());
        }
コード例 #8
0
        private IEnumerable <Object> NitroAfterTreatment(Ped driver, Vehicle vehicle)
        {
            //カウンタ作成
            var counter = new ReduceCounter((int)(CoolDownSeconds * 1000));

            //カウンタを描画
            RegisterProgressBar(
                new ProgressBarData(counter, new Point(0, 30),
                                    Color.FromArgb(200, 0, 255, 125),
                                    Color.FromArgb(128, 0, 0, 0),
                                    DrawType.RightToLeft, 100, 10, 2));

            //カウンタを自動カウント
            RegisterCounter(counter);

            foreach (var s in WaitForSeconds(CoolDownSeconds))
            {
                if (!PlayerPed.IsInVehicle() || PlayerPed.IsDead)
                {
                    //死んだりクルマから降りたらリセット
                    counter.Finish();
                    _isNitroOk = true;
                    yield break;
                }
                yield return(s);
            }

            counter.Finish();
            _isNitroOk = true;
            DrawText("Nitro:OK", 2.0f);
        }
コード例 #9
0
        protected override void Setup()
        {
            CreateInputKeywordAsObservable("moveto")

            .Subscribe(_ =>
            {
                var blip = GTA.World.GetActiveBlips().FirstOrDefault(x => x.Exists());
                if (blip == null)
                {
                    return;
                }
                var targetHeight = GTA.World.GetGroundHeight(blip.Position);
                //地面ピッタリだと地面に埋まるので少し上空を指定する
                var targetPos = new Vector3(blip.Position.X, blip.Position.Y, targetHeight + 3);

                var targetEntity = default(Entity);

                if (PlayerPed.IsInVehicle())
                {
                    var vec = PlayerPed.CurrentVehicle;
                    if (!vec.IsSafeExist())
                    {
                        return;
                    }
                    targetEntity = vec;
                }
                else
                {
                    targetEntity = PlayerPed;
                }

                targetEntity.Position = targetPos;
                targetEntity.ApplyForce(new Vector3(0, 0, 10));
            });
        }
コード例 #10
0
        /// <summary>
        /// 現在ラペリング可能な状態であるか調べる
        /// </summary>
        /// <returns>trueでラペリング許可</returns>
        private bool CheckRapeling(Vehicle heli, VehicleSeat seat)
        {
            //ヘリが壊れていたり存在しないならラペリングできない
            if (!heli.IsSafeExist() || heli.IsDead)
            {
                return(false);
            }

            //ヘリが早過ぎる場合はラペリングしない
            if (heli.Velocity.Length() > 30)
            {
                return(false);
            }

            //助手席はラペリングできない
            if (seat == VehicleSeat.Passenger)
            {
                return(false);
            }
            //現在ラペリング中ならできない
            var ped = heli.GetPedOnSeat(seat);

            if (!ped.IsSafeExist() || !ped.IsHuman || !ped.IsAlive || !PlayerPed.IsSafeExist())
            {
                return(false);
            }

            var playerPosition = PlayerPed.Position;

            //プレイヤの近くならラペリングする
            return(heli.IsInRangeOf(playerPosition, 50.0f));
        }
コード例 #11
0
    /// <summary>
    /// Sets up all correctly configured PlayerPed
    /// </summary>
    private void SetupPlayerPeds()
    {
        foreach (UserIndex player in userIndices)
        {
            if (bool.Parse(PlayerSettings.GetValue(player, EnabledKey, false.ToString())))
            {
                string guid = PlayerSettings.GetValue(player, ControllerKey, "");

                foreach (InputManager input in InputManager.GetAvailableInputManagers())
                {
                    if (input.DeviceGuid.Equals(guid))
                    {
                        InputManager manager = input;
                        if (input is DirectInputManager)
                        {
                            manager = DirectInputManager.LoadConfig(((DirectInputManager)input).device, GetIniFile());
                        }

                        PedHash    characterHash = PlayerSettings.GetEnumValue <PedHash>(player, CharacterHashKey, PedHash.Trevor.ToString());
                        BlipSprite blipSprite    = PlayerSettings.GetEnumValue <BlipSprite>(player, BlipSpriteKey, BlipSprite.Standard.ToString());
                        BlipColor  blipColor     = PlayerSettings.GetEnumValue <BlipColor>(player, BlipColorKey, BlipColor.Green.ToString());

                        PlayerPed playerPed = new PlayerPed(player, characterHash, blipSprite, blipColor, player1, manager);
                        playerPeds.Add(playerPed);
                        break;
                    }
                }
            }
        }
    }
コード例 #12
0
    /// <summary>
    /// This will update the camera
    /// </summary>
    private void UpdateCamera()
    {
        // if all in same vehicle
        if (playerPeds.TrueForAll(p => { return(p.Ped.CurrentVehicle != null && p.Ped.CurrentVehicle == player1.CurrentVehicle); }))
        {
            World.RenderingCamera = null;
        }
        else if (customCamera)
        {
            PlayerPed furthestPlayer = playerPeds.OrderByDescending(playerPed => { return(player1.Position.DistanceTo(playerPed.Ped.Position)); }).FirstOrDefault();

            Vector3 center = CenterOfVectors(player1.Position, furthestPlayer.Ped.Position);

            World.RenderingCamera = camera;
            camera.PointAt(center);

            float dist = furthestPlayer.Ped.Position.DistanceTo(player1.Position);

            center.Y += 5f + (dist / 1.6f);
            center.Z += 2f + (dist / 1.4f);

            camera.Position = center;
        }
        else
        {
            World.RenderingCamera = null;
        }
    }
コード例 #13
0
        private IEnumerable <object> DelayParachute()
        {
            PlayerPed.IsInvincible = true;
            yield return(WaitForSeconds(OpenParachutoSeconds));

            PlayerPed.IsInvincible = false;
            PlayerPed.ParachuteTo(PlayerPed.Position);
        }
コード例 #14
0
 /// <summary>
 /// 車両から手を離す
 /// </summary>
 private void GripRemove()
 {
     SetPlayerProof(false);
     _isGriped = false;
     Function.Call(Hash.DETACH_ENTITY, PlayerPed, false, false);
     PlayerPed.Task.ClearAllImmediately();
     PlayerPed.SetToRagdoll();
 }
コード例 #15
0
 protected override void Setup()
 {
     this.CreateTickAsObservable(TimeSpan.FromMilliseconds(50))
     .Where(_ => this.IsGamePadPressed(GameKey.Sprint) && this.IsGamePadPressed(GameKey.Jump))
     .Subscribe(_ =>
     {
         PlayerPed.ApplyForce(Vector3.WorldUp * 1.1f);
     });
 }
コード例 #16
0
 private void SetPlayerProof(bool hasCollisionProof)
 {
     PlayerPed.SetProofs(
         PlayerPed.IsBulletProof,
         PlayerPed.IsFireProof,
         PlayerPed.IsExplosionProof,
         hasCollisionProof,
         PlayerPed.IsMeleeProof,
         false, false, false);
 }
コード例 #17
0
 /// <summary>
 /// ヘリが追いつけない状態になっていないか監視するコルーチン
 /// </summary>
 /// <returns></returns>
 private IEnumerable <object> ObserveHeliCoroutine()
 {
     while (IsActive)
     {
         if (PlayerPed.IsSafeExist() && !_heli.IsSafeExist() || _heli.IsDead || !_heli.IsInRangeOf(PlayerPed.Position, 200.0f))
         {
             ResetHeli();
         }
         yield return(WaitForSeconds(40));
     }
 }
コード例 #18
0
 /// <summary>
 /// プレイヤを監視するコルーチン
 /// </summary>
 /// <returns></returns>
 private IEnumerable <object> ObservePlayerCoroutine()
 {
     while (IsActive)
     {
         if (PlayerPed.IsSafeExist() && !PlayerPed.IsAlive)
         {
             ResetHeli();
         }
         yield return(WaitForSeconds(2));
     }
 }
コード例 #19
0
        private void RobberVehicle()
        {
            if (!PlayerPed.IsSafeExist())
            {
                return;
            }

            var playerVehicle = this.GetPlayerVehicle();

            //プレイヤの周辺の市民
            var targetPeds = CachedPeds.Where(x => x.IsSafeExist() &&
                                              x.IsAlive &&
                                              x.IsInRangeOf(PlayerPed.Position, PlayerAroundDistance) &&
                                              x != PlayerPed &&
                                              !x.IsRequiredForMission() &&
                                              !x.IsNotChaosPed());

            foreach (var targetPed in targetPeds)
            {
                try
                {
                    //確率で強盗する
                    if (Random.Next(0, 100) > probability)
                    {
                        continue;
                    }

                    //市民周辺の車が対象
                    var targetVehicle =
                        CachedVehicles
                        .FirstOrDefault(x => x.IsSafeExist() && x.IsInRangeOf(targetPed.Position, 40.0f) && x != targetPed.CurrentVehicle);

                    //30%の確率でプレイヤの車を盗むように変更
                    if (playerVehicle.IsSafeExist() && Random.Next(0, 100) < 30)
                    {
                        targetVehicle = playerVehicle;
                    }
                    if (!targetVehicle.IsSafeExist())
                    {
                        continue;
                    }
                    StartCoroutine(RobberVehicleCoroutine(targetPed, targetVehicle));
                }
                catch (Exception e)
                {
                    LogWrite(e.ToString());
                }
            }
        }
コード例 #20
0
 protected override void Setup()
 {
     CreateInputKeywordAsObservable("killme")
     .Subscribe(_ =>
     {
         World.AddExplosion(PlayerPed.Position, GTA.ExplosionType.Grenade, 10.0f, 0.1f);
         PlayerPed.Kill();
         //自殺コマンドで死んだときはランダムな方向にふっとばす
         var x            = Random.NextDouble() - 0.5;
         var y            = Random.NextDouble() - 0.5;
         var z            = Random.NextDouble() - 0.5;
         var randomVector = new Vector3((float)x, (float)y, (float)z);
         randomVector.Normalize();
         PlayerPed.ApplyForce(randomVector * 100);
     });
 }
コード例 #21
0
        protected override void Setup()
        {
            var screenResolution = NativeFunctions.GetScreenResolution();

            _screenHeight = (int)screenResolution.Y;
            _screenWidth  = (int)screenResolution.X;

            _mContainer = new UIContainer(
                new Point(0, 0), new Size(_screenWidth, _screenHeight));

            this.OnDrawingTickAsObservable
            .Where(_ => _mContainer.Items.Count > 0)
            .Subscribe(_ => _mContainer.Draw());

            CreateTickAsObservable(TimeSpan.FromSeconds(0.5f))
            .Where(_ => PlayerPed.IsSafeExist())
            .Select(x => PlayerPed.IsAlive)
            .DistinctUntilChanged()
            .Subscribe(isAlive =>
            {
                _mContainer.Items.Clear();
                if (isAlive)
                {
                    return;
                }

                //死んでいたら死因を出す
                var damageWeapon = PlayerPed.GetCauseOfDeath();
                if (damageWeapon == 0)
                {
                    return;
                }

                var damageName = damageWeapon.ToString();
                if (PlayerPed.GetKiller() == PlayerPed)
                {
                    damageName += "(SUICIDE)";
                }
                var text = new UIText(damageName,
                                      new Point((int)(_screenWidth * _textPositionScale.X), (int)(_screenHeight * _textPositionScale.Y)),
                                      1.0f, Color.White, 0, true, false, true);

                _mContainer.Items.Add(text);
            });
        }
コード例 #22
0
 private void OnTick(object sender, EventArgs eventArgs)
 {
     if (!PlayerPed.IsInVehicle() && !MenuConrtoller.MenuPool.IsAnyMenuOpen() && PlayerPed.CurrentPedGroup.MemberCount > 0)
     {
         Ped[] peds = World.GetNearbyPeds(PlayerPed, 1.5f);
         Ped   ped  = World.GetClosest <Ped>(PlayerPosition, peds);
         if (!(ped == null) && !ped.IsInVehicle() && !(ped.CurrentPedGroup != PlayerPed.CurrentPedGroup))
         {
             Game.DisableControlThisFrame(2, GTA.Control.Context);
             UiExtended.DisplayHelpTextThisFrame("Press ~INPUT_CONTEXT~ to configure this ped.", false);
             if (Game.IsDisabledControlJustPressed(2, GTA.Control.Context))
             {
                 _selectedPed     = ped;
                 _pedMenu.Visible = !_pedMenu.Visible;
             }
         }
     }
 }
コード例 #23
0
        private void CitizenChaos()
        {
            if (!PlayerPed.IsSafeExist())
            {
                return;
            }

            //まだ処理をしていない市民に対してコルーチンを回す
            var nearPeds =
                CachedPeds.Where(x => x.IsSafeExist() && x.IsInRangeOf(PlayerPed.Position, chaosModeSetting.Radius));

            foreach (var ped in nearPeds.Where(x => x.IsSafeExist() && !chaosedPedList.Contains(x.Handle)))
            {
                chaosedPedList.Add(ped.Handle);
                var id = StartCoroutine(ChaosPedAction(ped));
                coroutineIds.Add(id);
            }
        }
コード例 #24
0
        /// <summary>
        /// カオスヘリ生成
        /// </summary>
        private void CreateChaosHeli()
        {
            try
            {
                if (!PlayerPed.IsSafeExist())
                {
                    return;
                }
                var player            = PlayerPed;
                var playerPosition    = player.Position;
                var spawnHeliPosition = playerPosition + new Vector3(0, 0, 40);
                var heli = GTA.World.CreateVehicle(GTA.Native.VehicleHash.Maverick, spawnHeliPosition);
                if (!heli.IsSafeExist())
                {
                    return;
                }
                AutoReleaseOnGameEnd(heli);
                heli.SetProofs(false, false, true, true, false, false, false, false);
                heli.MaxHealth = 3000;
                heli.Health    = 3000;
                _heli          = heli;

                _heliDriver = _heli.CreateRandomPedAsDriver();
                if (_heliDriver.IsSafeExist() && _heliDriver.IsHuman)
                {
                    _heliDriver.SetProofs(true, true, true, true, true, true, true, true);
                    _heliDriver.SetNotChaosPed(true);
                }

                SpawnPassengersToEmptySeat();

                //カオスヘリのコルーチン開始
                var id = StartCoroutine(ChaosHeliCoroutine());
                coroutineIds.Add(id);
            }
            catch (Exception ex)
            {
                LogWrite(ex.ToString());
            }
        }
コード例 #25
0
        /// <summary>
        /// 掴む車両の選別
        /// </summary>
        private void GripAction()
        {
            var gripAvailableVeles = CachedVehicles
                                     .Where(x => x.IsSafeExist() && x.IsInRangeOf(PlayerPed.Position, 10.0f))
                                     .OrderBy(x => x.Position.DistanceTo(PlayerPed.Position))
                                     .FirstOrDefault();

            if (gripAvailableVeles == null || !gripAvailableVeles.IsTouching(PlayerPed))
            {
                return;
            }
            _isGriped = true;
            var playerRHandCoords = PlayerPed.GetBoneCoord(Bone.SKEL_R_Hand);

            var offsetPosition = Function.Call <Vector3>(Hash.GET_OFFSET_FROM_ENTITY_GIVEN_WORLD_COORDS,
                                                         gripAvailableVeles,
                                                         playerRHandCoords.X,
                                                         playerRHandCoords.Y,
                                                         playerRHandCoords.Z);

            Grip(PlayerPed, gripAvailableVeles, offsetPosition);
        }
コード例 #26
0
        protected override void Setup()
        {
            var screenResolution = NativeFunctions.GetScreenResolution();

            ScreenHeight = (int)screenResolution.Y;
            ScreenWidth  = (int)screenResolution.X;

            _mContainer = new UIContainer(
                new Point(0, 0), new Size(ScreenWidth, ScreenHeight));

            OnDrawingTickAsObservable
            .Subscribe(_ => _mContainer.Draw());

            var harlThinned = CreateTickAsObservable(TimeSpan.FromMilliseconds(50));

            harlThinned
            .Where(_ => PlayerPed.IsSafeExist() && PlayerPed.Health < alertHelthValue && PlayerPed.IsAlive)
            .Subscribe(_ =>
            {
                //体力が減ったら画面を点滅させる
                time     += 1;
                var alpha = offset + amplitude * Math.Abs(Math.Sin(omega * time));

                _mContainer.Items.Clear();
                var rect = new UIRectangle(new Point(0, 0), new Size(ScreenWidth, ScreenHeight),
                                           Color.FromArgb((int)alpha, 255, 0, 0));
                _mContainer.Items.Add(rect);
            });

            harlThinned
            .Select(_ => PlayerPed.IsSafeExist() && PlayerPed.Health < alertHelthValue)
            .DistinctUntilChanged()
            .Where(x => !x)
            .Subscribe(_ =>
            {
                time = 0;
                _mContainer.Items.Clear();
            });
        }
コード例 #27
0
        private IEnumerable <Object> ChaosHeliCoroutine()
        {
            yield return(RandomWait());

            //ヘリが存在かつMODが有効の間回り続けるコルーチン
            while (IsActive && _heli.IsSafeExist() && _heli.IsAlive)
            {
                if (!PlayerPed.IsSafeExist())
                {
                    break;
                }

                var targetPosition = PlayerPed.Position + new Vector3(0, 0, 10);

                //ヘリがプレイヤから離れすぎていた場合は追いかける
                MoveHeli(_heliDriver, targetPosition);

                SpawnPassengersToEmptySeat();

                yield return(WaitForSeconds(1));
            }
            ReleasePedAndHeli();
        }
コード例 #28
0
ファイル: Moon.cs プロジェクト: sollaholla/space-mod
        public void Update()
        {
            if (!_combatInitialized)
            {
                var lastShotCoord = PlayerPed.GetLastWeaponImpactCoords();
                var found         = _hostiles.Any(x => x.IsInCombatAgainst(PlayerPed));
                foreach (var hostile in _hostiles)
                {
                    var hPos = hostile.Position;
                    var dist = Function.Call <float>(Hash.VDIST2, hPos.X, hPos.Y, hPos.Z,
                                                     lastShotCoord.X,
                                                     lastShotCoord.Y,
                                                     lastShotCoord.Z);
                    const float maxDist = 125 * 125;
                    if (dist > maxDist)
                    {
                        continue;
                    }
                    found = true;
                }
                if (!found)
                {
                    return;
                }
                foreach (var hostile in _hostiles)
                {
                    if (!hostile.IsInCombat)
                    {
                        if (hostile.IsInVehicle())
                        {
                            hostile.Task.FightAgainst(PlayerPed);
                        }
                        else
                        {
                            hostile.Task.ShootAt(PlayerPed);
                        }
                    }
                }

                _combatInitialized = true;
            }
            else
            {
                foreach (var hostile in _hostiles)
                {
                    if (!Blip.Exists(hostile.CurrentBlip))
                    {
                        continue;
                    }
                    if (!hostile.IsDead)
                    {
                        continue;
                    }
                    hostile.CurrentBlip.Remove();
                }

                if (_hostiles.All(x => x.IsDead))
                {
                    EndScenario(true);
                }
            }
        }
コード例 #29
0
        private void HandleSearchForVehicleWithANPR()
        {
            float Radius = 220f;

            SearchArea       = new Blip(SuspectCar.Position.Around(25f), Radius);
            SearchArea.Color = Color.Yellow;
            SearchArea.Alpha = 0.5f;
            int  WaitCount       = 0;
            int  WaitCountTarget = 2200;
            bool RouteEnabled    = false;

            while (CalloutRunning)
            {
                GameFiber.Yield();
                WaitCount++;
                NativeFunction.Natives.SET_DRIVE_TASK_DRIVING_STYLE(Suspect, 786603);

                if (Vector3.Distance(PlayerPed.GetOffsetPosition(Vector3.RelativeFront * 9f), SuspectCar.Position) < 9f)
                {
                    GameFiber.Sleep(3000);
                    if (Vector3.Distance(PlayerPed.GetOffsetPosition(Vector3.RelativeFront * 9f), SuspectCar.Position) < 9f)
                    {
                        Game.DisplayNotification("Control, I have located the ~b~" + CarModelName + ".");
                        Game.DisplayNotification("I'm preparing to ~b~stop them,~s~ over.");
                        SuspectBlip = Suspect.AttachBlip();
                        if (SearchArea.Exists())
                        {
                            SearchArea.Delete();
                        }
                        Functions.PlayScannerAudio("DISPATCH_SUSPECT_LOCATED_ENGAGE");

                        break;
                    }
                }
                else if (((Vector3.Distance(SuspectCar.Position, SearchArea.Position) > Radius + 20f) && (WaitCount > 400)) || (WaitCount > WaitCountTarget))
                {
                    Game.DisplayNotification("~o~ANPR Hit ~s~on the ~b~" + CarColor + " " + CarModelName + ", ~s~plate ~b~" + SuspectCar.LicensePlate + ".");
                    Functions.PlayScannerAudioUsingPosition("WE_HAVE_01 CRIME_TRAFFIC_ALERT IN_OR_ON_POSITION", SuspectCar.Position);
                    SearchArea.Delete();
                    Radius -= 5f;
                    if (Radius < 120f)
                    {
                        Radius = 120f;
                    }
                    SearchArea       = new Blip(SuspectCar.Position.Around(5f, 15f), Radius);
                    SearchArea.Color = Color.Yellow;
                    SearchArea.Alpha = 0.5f;


                    RouteEnabled = false;
                    if (WaitCount > WaitCountTarget)
                    {
                        Game.LogTrivial("Updated for waitcount");
                    }
                    WaitCount = 0;

                    Suspect.Tasks.CruiseWithVehicle(SuspectCar, 20f, VehicleDrivingFlags.DriveAroundVehicles | VehicleDrivingFlags.DriveAroundObjects | VehicleDrivingFlags.DriveAroundPeds);
                    WaitCountTarget -= AssortedCalloutsHandler.rnd.Next(200, 400);
                    if (WaitCountTarget < 1200)
                    {
                        WaitCountTarget = 1900;
                    }
                    SuspectBlip       = Suspect.AttachBlip();
                    SuspectBlip.Color = Color.Red;
                    GameFiber.Wait(4000);
                    SuspectBlip.Delete();
                }
                if (Vector3.Distance(PlayerPed.Position, SearchArea.Position) > Radius + 90f)
                {
                    if (!RouteEnabled)
                    {
                        SearchArea.IsRouteEnabled = true;
                        RouteEnabled = true;
                    }
                }
                else
                {
                    if (RouteEnabled)
                    {
                        SearchArea.IsRouteEnabled = false;
                        RouteEnabled = false;
                    }
                }
            }
        }
コード例 #30
0
        private void WatchCameraFootage()
        {
            CCTVShowing = true;
            Game.LocalPlayer.HasControl = false;
            Game.FadeScreenOut(1500, true);
            NativeFunction.Natives.SET_TIMECYCLE_MODIFIER("CAMERA_BW");
            if (PlayerPed.LastVehicle.Exists())

            {
                OldLastVehiclePos = PlayerPed.LastVehicle.Position;
                PlayerPed.LastVehicle.IsVisible = false;
                PlayerPed.LastVehicle.SetPositionZ(PlayerPed.LastVehicle.Position.Z + 8f);
                PlayerPed.LastVehicle.IsPositionFrozen = true;
            }
            bool DateTimeChanged = false;

            try
            {
                OldDateTime    = World.DateTime;
                World.DateTime = DateTime.Now;
                //World.IsTimeOfDayFrozen = true;
                DateTimeChanged = true;
            }
            catch (Exception e) { }


            PlayerPed.IsVisible  = false;
            Shopkeeper.IsVisible = false;
            Vector3 suspectOldPosition = SuspectCar.Position;
            Rotator suspectOldRotator  = SuspectCar.Rotation;
            Vector3 PlayerOldPos       = PlayerPed.Position;
            Vector3 ShopkeeperOldPos   = Shopkeeper.Position;

            PlayerPed.SetPositionZ(PlayerPed.Position.Z + 8f);
            PlayerPed.IsPositionFrozen = true;
            Shopkeeper.SetPositionZ(Shopkeeper.Position.Z + 8f);
            Shopkeeper.IsPositionFrozen = true;

            SuspectCar.Position = SpawnPoint;
            Camera cam = new(true);

            cam.Position = SuspectCar.GetOffsetPosition(Vector3.RelativeFront * 4.4f);
            cam.SetPositionZ(cam.Position.Z + 3.6f);
            Vector3 directionFromShopkeeperToCar = (SuspectCar.Position - cam.Position);

            directionFromShopkeeperToCar.Normalize();
            cam.Rotation = directionFromShopkeeperToCar.ToRotator();
            Suspect.Tasks.PerformDrivingManeuver(VehicleManeuver.Wait);
            GameFiber.Wait(100);
            SuspectCar.IsPositionFrozen = true;

            GameFiber.Sleep(2000);

            Game.FadeScreenIn(1500, true);
            CCTVCamNumber     = AssortedCalloutsHandler.rnd.Next(1, 20);
            Game.FrameRender += DrawCCTVText;
            Game.DisplaySubtitle("~b~Shopkeeper~s~: There they are! Bastard!", 6600);
            GameFiber.Sleep(6500);
            Game.FadeScreenOut(1500, true);
            CCTVShowing         = false;
            PlayerPed.IsVisible = true;
            if (PlayerPed.LastVehicle.Exists())
            {
                PlayerPed.LastVehicle.Position         = OldLastVehiclePos;
                PlayerPed.LastVehicle.IsPositionFrozen = false;
                PlayerPed.LastVehicle.IsVisible        = true;
            }
            //World.IsTimeOfDayFrozen = false;
            if (DateTimeChanged)
            {
                World.DateTime = OldDateTime;
            }
            Shopkeeper.IsVisible        = true;
            PlayerPed.IsPositionFrozen  = false;
            Shopkeeper.IsPositionFrozen = false;
            PlayerPed.Position          = PlayerOldPos;
            Shopkeeper.Position         = ShopkeeperOldPos;


            SuspectCar.Position         = suspectOldPosition;
            SuspectCar.Rotation         = suspectOldRotator;
            SuspectCar.IsPositionFrozen = false;
            Game.LocalPlayer.HasControl = true;
            cam.Delete();
            Suspect.Tasks.CruiseWithVehicle(SuspectCar, 17f, VehicleDrivingFlags.DriveAroundVehicles | VehicleDrivingFlags.DriveAroundObjects | VehicleDrivingFlags.DriveAroundPeds);
            NativeFunction.Natives.SET_DRIVE_TASK_DRIVING_STYLE(Suspect, 786603);
            GameFiber.Sleep(2000);
            NativeFunction.Natives.CLEAR_TIMECYCLE_MODIFIER();
            Game.FadeScreenIn(1500, true);
        }