protected override void Setup() { //0.3秒間押しっぱなしなら発動 OnThinnedTickAsObservable .Select(_ => !this.GetPlayerVehicle().IsSafeExist() && !_isGriped && this.IsGamePadPressed(GameKey.Reload) ).Buffer(3, 1) .Where(x => x.All(v => v)) .Subscribe(_ => GripAction()); OnThinnedTickAsObservable .Where(_ => _isGriped) .Subscribe(_ => { Grip(PlayerPed, _vehicle, _ofsetPosition); }); OnThinnedTickAsObservable .Where(_ => _isGriped && (!this.IsGamePadPressed(GameKey.Reload) || PlayerPed.IsDead)) .Subscribe(_ => GripRemove()); this.OnAbortAsync.Subscribe(_ => { SetPlayerProof(false); }); }
protected override void Setup() { pPed.Add(PlayerPed); //キーワードが入力されたらON/OFFを切り替える CreateInputKeywordAsObservable(Keyword) .Subscribe(_ => { IsActive = !IsActive; DrawText("BombBat:" + IsActive, 3.0f); }); OnAllOnCommandObservable.Subscribe(_ => IsActive = true); //interval間隔で実行 OnThinnedTickAsObservable .Where(_ => IsActive) .Subscribe(p => { foreach (var ped in CachedPeds) { if (!ped.IsSafeExist()) { continue; } BomBatAction(ped); } BomBatAction(PlayerPed); }); }
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()); }
protected override void Setup() { conf = LoadConfig <EmergencyEscapeConf>(); OnThinnedTickAsObservable .Where(_ => this.IsGamePadPressed(GameKey.VehicleHorn) && this.IsGamePadPressed(GameKey.VehicleExit)) .Subscribe(_ => EscapeVehicle()); }
protected override void Setup() { filePaths = LoadWavFilePaths(@"scripts/SpecialAbilityBgm"); if (filePaths.Length <= 0) { return; } soundPlayer = new SoundPlayer { SoundLocation = filePaths[Random.Next(filePaths.Length)] }; CreateInputKeywordAsObservable("sbmg") .Subscribe(_ => { IsActive = !IsActive; DrawText("SpecialAbilityBGM:" + IsActive, 3.0f); }); OnAllOnCommandObservable.Subscribe(_ => IsActive = true); OnThinnedTickAsObservable .Where(_ => IsActive && (uint)PlayerPed.Model.Hash == (uint)PedHash.Trevor) .Select(_ => Game.Player.IsSpecialAbilityActive() && PlayerPed.IsAlive) .DistinctUntilChanged() .Subscribe(x => { if (x) { soundPlayer.Play(); } else { soundPlayer.Stop(); //次の音をセット soundPlayer.SoundLocation = filePaths[Random.Next(filePaths.Length)]; soundPlayer.LoadAsync(); } }); }
protected override void Setup() { config = LoadConfig <BondCarConfig>(); OnThinnedTickAsObservable .Where(_ => PlayerVehicle.Value.IsSafeExist() && this.IsGamePadPressed(GameKey.VehicleAim) && this.IsGamePadPressed(GameKey.VehicleAttack) && PlayerPed.Weapons.Current.Hash == WeaponHash.Unarmed ) .ThrottleFirst(TimeSpan.FromMilliseconds(CoolDownMillSeconds), InfernoScriptScheduler) .Subscribe(_ => { var v = PlayerVehicle.Value; //そこら辺の市民のせいにする var ped = CachedPeds.Where(x => x.IsSafeExist()).DefaultIfEmpty(PlayerPed).FirstOrDefault(); StartCoroutine(InvincibleVehicle(v, 2)); CreateRpgBullet(v, ped, 1.5f); CreateRpgBullet(v, ped, -1.5f); v.EngineHealth *= 0.9f; }); }
protected override void Setup() { CreateInputKeywordAsObservable("snax") .Subscribe(_ => IsActive = !IsActive); IsActiveAsObservable .Where(x => x) .Subscribe(x => { DrawText($"SpeedMax:{IsActive}[Type:{(currentSpeedType)}][Exclude:{excludeMissionVehicle}]"); vehicleHashSet.Clear(); }); IsActiveAsObservable .Skip(1) .Where(x => !x) .Subscribe(x => { DrawText($"SpeedMax:{IsActive}"); vehicleHashSet.Clear(); }); //ミッション開始直後に一瞬動作を止めるフラグ var suspednFlag = false; OnThinnedTickAsObservable .Where(_ => IsActive && !suspednFlag) .Subscribe(_ => { foreach (var v in CachedVehicles .Where(x => x.IsSafeExist() && x.IsInRangeOf(PlayerPed.Position, 100.0f) && !vehicleHashSet.Contains(x.Handle) && !(excludeMissionVehicle && x.IsPersistent) )) { vehicleHashSet.Add(v.Handle); if (currentSpeedType == SpeedType.Original) { StartCoroutine(OriginalSpeedMaxCoroutine(v)); } else { StartCoroutine(VehicleSpeedMaxCorutine(v)); } } }); var nextType = currentSpeedType; OnKeyDownAsObservable .Where(x => IsActive && x.KeyCode == Keys.F6) .Do(_ => { nextType = GetNextSpeedType(nextType); DrawText($"SpeedMax:[Type:{nextType}]", 1.0f); }) .Throttle(TimeSpan.FromSeconds(1)) .Subscribe(_ => { currentSpeedType = nextType; DrawText($"SpeedMax:[Type:{(currentSpeedType)}][OK]", 2.0f); StopAllCoroutine(); vehicleHashSet.Clear(); }); OnKeyDownAsObservable .Where(x => IsActive && x.KeyCode == Keys.F5) .Subscribe(_ => { excludeMissionVehicle = !excludeMissionVehicle; vehicleHashSet.Clear(); StopAllCoroutine(); DrawText($"SpeedMax:ExcludeMissionVehicles[{excludeMissionVehicle}]"); }); OnThinnedTickAsObservable .Where(_ => IsActive) .Select(_ => PlayerPed.IsAlive) .DistinctUntilChanged() .Where(x => x) .Subscribe(_ => vehicleHashSet.Clear()); //ミッションが始まった時にしばらく動作を止める OnThinnedTickAsObservable .Where(_ => IsActive) .Select(_ => Game.MissionFlag) .DistinctUntilChanged() .Where(x => x) .Do(_ => suspednFlag = true) .Delay(TimeSpan.FromSeconds(3)) .Subscribe(_ => suspednFlag = false); }
/// <summary> /// コンストラクタ /// </summary> protected InfernoScript() { Interval = 16; //初期化をちょっと遅延させる Observable.Interval(TimeSpan.FromMilliseconds(10)) .Where(_ => InfernoCore.Instance != null) .First() .Subscribe(_ => { InfernoCore.Instance.PedsNearPlayer.Subscribe(x => _cachedPeds = x); InfernoCore.Instance.VehicleNearPlayer.Subscribe(x => _cachedVehicles = x); InfernoCore.Instance.PlayerPed.Subscribe(x => cahcedPlayerPed = x); InfernoCore.Instance.PlayerVehicle.Subscribe(x => PlayerVehicle.Value = x); }); OnTickAsObservable = Observable.FromEventPattern <EventHandler, EventArgs>(h => h.Invoke, h => Tick += h, h => Tick -= h) .Select(_ => Unit.Default).Share(); //Subscribeされたらイベントハンドラを登録する OnThinnedTickAsObservable = OnTickAsObservable.ThrottleFirst(TimeSpan.FromMilliseconds(100), InfernoScriptScheduler) .Share(); OnDrawingTickAsObservable = DrawingCore.OnDrawingTickAsObservable; OnAllOnCommandObservable = CreateInputKeywordAsObservable("allon"); //スケジューラ実行 OnTickAsObservable.Subscribe(_ => infernoScheduler?.Run()); // SynchronizationContextの実行 OnTickAsObservable .Subscribe(_ => { if (SynchronizationContext.Current == null) { SynchronizationContext.SetSynchronizationContext(InfernoSynchronizationContext); } InfernoSynchronizationContext.Update(); }); //タイマのカウント OnThinnedTickAsObservable .Where(_ => _counterList.Any()) .Subscribe(_ => { foreach (var c in _counterList) { c.Update(100); } //完了状態にあるタイマを全て削除 _counterList.RemoveAll(x => x.IsCompleted); }); _coroutinePool = new CoroutinePool(5); //コルーチンを実行する CreateTickAsObservable(TimeSpan.FromMilliseconds(_coroutinePool.ExpectExecutionInterbalMillSeconds)) .Subscribe(_ => _coroutinePool.Run()); OnAbortAsync.Subscribe(_ => { IsActive = false; foreach (var e in _autoReleaseEntities.Where(x => x.IsSafeExist())) { e.MarkAsNoLongerNeeded(); } _autoReleaseEntities.Clear(); }); try { Setup(); } catch (Exception e) { LogWrite(e.ToString()); } }