private void Shock(Ped damagedPed) { var playerPos = PlayerPed.Position; GTA.World.AddExplosion(playerPos + Vector3.WorldUp * 10, GTA.ExplosionType.Grenade, 0.01f, 0.2f); #region Ped foreach (var p in CachedPeds.Where( x => x.IsSafeExist() && x.IsInRangeOf(damagedPed.Position, 10) && x.IsAlive && !x.IsCutsceneOnlyPed())) { p.SetToRagdoll(); p.ApplyForce(Vector3.WorldUp * 5f); } #endregion #region Vehicle foreach (var v in CachedVehicles.Where( x => x.IsSafeExist() && x.IsInRangeOf(damagedPed.Position, 10) && x.IsAlive)) { v.ApplyForce(Vector3.WorldUp * 5f, Vector3.RandomXYZ()); } #endregion }
private IEnumerable <object> RagdollCoroutine() { var peds = CachedPeds.Where( x => x.IsSafeExist() && x.IsInRangeOf(PlayerPed.Position, 100)).ToArray(); var vecs = CachedVehicles.Where( x => x.IsSafeExist() && x.IsInRangeOf(PlayerPed.Position, 100)).ToArray(); foreach (var ped in peds) { // if (!ped.IsSafeExist()) continue; ped.IsInvincible = true; //ped.SetToRagdoll(100); //ped.ApplyForce(new Vector3(0, 0, 2)); yield return(null); } foreach (var vec in vecs) { // if (!ped.IsSafeExist()) continue; vec.IsCollisionProof = true; //ped.SetToRagdoll(100); //ped.ApplyForce(new Vector3(0, 0, 2)); yield return(null); } }
/// <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]); }
private void FulutonUpdate() { foreach (var entity in CachedPeds.Concat(CachedVehicles.Cast <Entity>()).Where( x => x.IsSafeExist() && x.IsInRangeOf(PlayerPed.Position, 15.0f) && !fulutonedEntityList.Contains(x.Handle) && x.IsAlive )) { if (entity.HasBeenDamagedByPed(PlayerPed) && ( entity.HasBeenDamagedBy(Weapon.UNARMED) )) { fulutonedEntityList.Add(entity.Handle); StartCoroutine(FulutonCoroutine(entity)); if (entity is Vehicle) { soundPlayerVehicleSetup?.Play(); } else { //pedの時は遅延させてならす Observable.Timer(TimeSpan.FromSeconds(0.3f)) .Subscribe(_ => soundPlayerPedSetup?.Play()); } } } }
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()); } } }
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); } }
//キャッシュ市民から一人選出 private Entity GetRandomTarget() { var playerVehicle = PlayerPed.CurrentVehicle; //プレイヤの近くの市民 var targetPeds = CachedPeds .Where(x => x.IsSafeExist() && x.IsHuman && x.IsAlive && x.IsInRangeOf(PlayerPed.Position, 150) && (!x.IsInVehicle() || x.CurrentVehicle != playerVehicle)).Concat(new Ped[] { PlayerPed }); var targetVehicles = CachedVehicles .Where(x => x.IsSafeExist() && x.IsAlive && x.IsInRangeOf(PlayerPed.Position, 150) && playerVehicle != x); var targets = targetPeds.Concat(targetVehicles.Cast <Entity>()).ToArray(); //ターゲットが周りにいない場合は誰も攻撃しない return(targets.Length > 5 ? targets[Random.Next(targets.Length)] : null); }
/// <summary> /// 周辺市民を車にくっつける /// </summary> void StartAttachAction() { var playerVeh = PlayerVehicle.Value; //プレイヤ周辺市民 var peds = CachedPeds.Where(x => x.IsSafeExist() && x.IsAlive && !x.IsInVehicle() && x.IsInRangeOf(playerVeh.Position, 7) && !x.IsCutsceneOnlyPed()); foreach (var p in peds .Where(x => !processingPedIdSet.Contains(x.Handle)) .Where(p => playerVeh.IsSafeExist())) { processingPedIdSet.Add(p.Handle); StartCoroutine(PedAttachCoroutine(p, playerVeh)); } }
private IEnumerable <object> RagdollCoroutine() { var peds = CachedPeds.Where( x => x.IsSafeExist() && x.IsRequiredForMission() && x.CanRagdoll && x.IsInRangeOf(PlayerPed.Position, 15)).ToArray(); foreach (var ped in peds) { if (!ped.IsSafeExist()) { continue; } ped.SetToRagdoll(100); ped.ApplyForce(new Vector3(0, 0, 2)); yield return(null); } }
private void ShootMeteo() { try { var player = PlayerPed; if (!player.IsSafeExist()) { return; } var playerPosition = player.Position; var range = Radius; var addPosition = new Vector3(0, 0, 0).AroundRandom2D(range); if (IsPlayerMoveSlowly && addPosition.Length() < 10.0f) { addPosition.Normalize(); addPosition *= Random.Next(10, 20); } var targetPosition = playerPosition + addPosition; var direction = new Vector3(1, 0, 2); direction.Normalize(); var createPosition = targetPosition + direction * 100; //たまに花火 var weapon = Random.Next(0, 100) < 3 ? WeaponHash.Firework : WeaponHash.RPG; //ライト描画 StartCoroutine(CreateMeteoLight(targetPosition, 2.0f)); //そこら辺の市民のせいにする var ped = CachedPeds.Where(x => x.IsSafeExist()).DefaultIfEmpty(PlayerPed).FirstOrDefault(); NativeFunctions.ShootSingleBulletBetweenCoords( createPosition, targetPosition, 100, weapon, ped, 200); } catch (Exception ex) { LogWrite(ex.ToString()); } }
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; }); }