public void Run() { #if DEBUG GunshotWound2.LastSystem = nameof(CheckSystem); #endif for (var i = 0; i < _events.EntitiesCount; i++) { var pedEntity = _events.Components1[i].Entity; if (!_ecsWorld.IsEntityExists(pedEntity)) { continue; } var woundedPed = _ecsWorld.GetComponent <WoundedPedComponent>(pedEntity); if (woundedPed == null) { continue; } ShowHealth(woundedPed); ShowArmor(woundedPed); ShowPain(woundedPed, pedEntity); ShowCrits(woundedPed); ShowBleedings(woundedPed, pedEntity); } _events.CleanFilter(); }
public void Run() { #if DEBUG GunshotWound2.LastSystem = nameof(HelmetRequestSystem); #endif if (_requests.EntitiesCount <= 0) { return; } var player = Game.Player; var ped = player.Character; if (ped.IsWearingHelmet) { ped.RemoveHelmet(false); } else if (!ped.IsRagdoll) { if (player.Money > _config.Data.PlayerConfig.MoneyForHelmet) { player.Money -= _config.Data.PlayerConfig.MoneyForHelmet; ped.GiveHelmet(false, Helmet.RegularMotorcycleHelmet, GunshotWound2.Random.Next(0, 15)); } else { var message = _ecsWorld.CreateEntityWith <ShowNotificationEvent>(); message.StringToShow = _locale.Data.DontHaveMoneyForHelmet; message.Level = NotifyLevels.COMMON; } } _requests.CleanFilter(); }
public void Run() { #if DEBUG GunshotWound2.LastSystem = nameof(BasePainStateSystem <TStateEvent>); #endif for (var i = 0; i < Events.EntitiesCount; i++) { var changeEvent = Events.Components1[i]; var pedEntity = changeEvent.Entity; if (!EcsWorld.IsEntityExists(pedEntity)) { continue; } var woundedPed = EcsWorld.GetComponent <WoundedPedComponent>(pedEntity); if (woundedPed == null || woundedPed.IsDead) { continue; } if (woundedPed.PainState == CurrentState && !changeEvent.ForceUpdate) { continue; } ExecuteState(woundedPed, pedEntity); woundedPed.PainState = CurrentState; } Events.CleanFilter(); }
public void Run() { #if DEBUG GunshotWound2.LastSystem = nameof(DebugInfoSystem); #endif for (var i = 0; i < _events.EntitiesCount; i++) { #if DEBUG var pedEntity = _events.Components1[i].Entity; if (!_ecsWorld.IsEntityExists(pedEntity)) { continue; } var woundedPed = _ecsWorld.GetComponent <WoundedPedComponent>(pedEntity); if (woundedPed == null) { continue; } SendDebug($"{woundedPed}"); _ecsWorld.CreateEntityWith <ShowHealthStateEvent>().Entity = pedEntity; #endif } _events.CleanFilter(); }
public void Run() { if (_events.EntitiesCount <= 0) { return; } Function.Call(Hash.SET_FLASH, 0, 0, 100, 500, 100); _events.CleanFilter(); }
public void Run() { #if DEBUG GunshotWound2.LastSystem = nameof(WoundSystem); #endif for (var i = 0; i < _components.EntitiesCount; i++) { var component = _components.Components1[i]; var pedEntity = component.Entity; if (!_ecsWorld.IsEntityExists(pedEntity)) { continue; } var woundedPed = _ecsWorld.GetComponent <WoundedPedComponent>(pedEntity); if (woundedPed == null) { continue; } var damageDeviation = component.Damage > 0 ? _config.Data.WoundConfig.DamageDeviation * component.Damage : 0; if (!woundedPed.IsDead) { woundedPed.Health -= _config.Data.WoundConfig.DamageMultiplier * component.Damage + GunshotWound2.Random.NextFloat(-damageDeviation, damageDeviation); woundedPed.PedHealth = woundedPed.Health; } var bleedingDeviation = component.BleedSeverity > 0 ? _config.Data.WoundConfig.BleedingDeviation * component.BleedSeverity : 0; var severity = component.BleedSeverity + GunshotWound2.Random.NextFloat(-bleedingDeviation, bleedingDeviation); CreateBleeding(woundedPed, pedEntity, severity, component.Name); CreatePain(pedEntity, component.Pain); CreateCritical(pedEntity, component.Crits); if (component.ArterySevered) { CreateBleeding(woundedPed, pedEntity, 1f, _locale.Data.SeveredArtery); } #if DEBUG _ecsWorld.CreateEntityWith <ShowDebugInfoEvent>().Entity = pedEntity; #endif SendWoundInfo(component, woundedPed); } _components.CleanFilter(); }
public void Run() { for (var i = 0; i < _events.EntitiesCount; i++) { if (Function.Call <bool>(Hash.IS_SPECIAL_ABILITY_ACTIVE, Game.Player)) { Function.Call(Hash.SPECIAL_ABILITY_DEACTIVATE_FAST, Game.Player); } Function.Call(_events.Components1[i].Lock ? Hash.SPECIAL_ABILITY_LOCK : Hash.SPECIAL_ABILITY_UNLOCK, Game.Player.Character.Model.Hash); } _events.CleanFilter(); }
public void Run() { for (var i = 0; i < _events.EntitiesCount; i++) { var newEvent = _events.Components1[i]; switch (newEvent.Length) { case CameraShakeLength.ONE_TIME: if (_config.Data.PlayerConfig.CameraIsShaking) { continue; } Function.Call(Hash._SET_CAM_EFFECT, 1); _config.Data.PlayerConfig.CameraIsShaking = false; break; case CameraShakeLength.PERMANENT: if (_config.Data.PlayerConfig.CameraIsShaking) { continue; } Function.Call(Hash._SET_CAM_EFFECT, 2); _config.Data.PlayerConfig.CameraIsShaking = true; break; case CameraShakeLength.CLEAR: if (!_config.Data.PlayerConfig.CameraIsShaking) { continue; } Function.Call(Hash._SET_CAM_EFFECT, 0); _config.Data.PlayerConfig.CameraIsShaking = false; break; default: throw new ArgumentOutOfRangeException(); } } _events.CleanFilter(); }
public void Run() { #if DEBUG GunshotWound2.LastSystem = nameof(SwitchAnimationSystem); #endif for (var i = 0; i < _events.EntitiesCount; i++) { var pedEntity = _events.Components1[i].Entity; if (!_ecsWorld.IsEntityExists(pedEntity)) { continue; } var woundedPed = _ecsWorld.GetComponent <WoundedPedComponent>(pedEntity); if (woundedPed == null || !woundedPed.ThisPed.IsAlive) { continue; } var animationName = _events.Components1[i].AnimationName; if (string.IsNullOrEmpty(animationName)) { Function.Call(Hash.RESET_PED_MOVEMENT_CLIPSET, woundedPed.ThisPed, 0f); continue; } _animRequestParams[0] = animationName; if (!Function.Call <bool>(Hash.HAS_ANIM_SET_LOADED, _animRequestParams)) { Function.Call(Hash.REQUEST_ANIM_SET, _animRequestParams); } _animSetParams[0] = woundedPed.ThisPed; _animSetParams[1] = animationName; _animSetParams[2] = 1.0f; Function.Call(Hash.SET_PED_MOVEMENT_CLIPSET, _animSetParams); } _events.CleanFilter(); }
public void Run() { for (var i = 0; i < _requestEvents.EntitiesCount; i++) { var pedEntity = _requestEvents.Components1[i].Entity; if (!_ecsWorld.IsEntityExists(pedEntity)) { continue; } var woundedPed = _ecsWorld.GetComponent <WoundedPedComponent>(pedEntity); if (woundedPed?.MostDangerBleedingEntity == null) { continue; } if (woundedPed.InPermanentRagdoll) { continue; } var progress = _ecsWorld.EnsureComponent <BandageInProgressComponent>(pedEntity, out var isNew); if (!isNew) { SendMessage(_localeConfig.Data.AlreadyBandaging, pedEntity); continue; } if (woundedPed.IsPlayer) { if (Game.Player.Money < _config.Data.WoundConfig.BandageCost) { SendMessage(_localeConfig.Data.DontHaveMoneyForBandage, pedEntity); continue; } Game.Player.Money -= _config.Data.WoundConfig.BandageCost; } var timeToBandage = _config.Data.WoundConfig.ApplyBandageTime; progress.EstimateTime = timeToBandage; SendMessage(string.Format(_localeConfig.Data.YouTryToBandage, timeToBandage.ToString("F1")), pedEntity); } _requestEvents.CleanFilter(); var frameTimeInSec = Game.LastFrameTime; for (var i = 0; i < _pedsWithBandageInProgress.EntitiesCount; i++) { var woundedPed = _pedsWithBandageInProgress.Components1[i]; var thisPed = woundedPed.ThisPed; var progress = _pedsWithBandageInProgress.Components2[i]; var pedEntity = _pedsWithBandageInProgress.Entities[i]; if (woundedPed.InPermanentRagdoll || thisPed.IsWalking || thisPed.IsRunning || thisPed.IsSprinting || thisPed.IsShooting || thisPed.IsRagdoll || thisPed.IsJumping || thisPed.IsReloading || thisPed.IsSwimming) { SendMessage($"~r~{_localeConfig.Data.BandageFailed}", pedEntity); _ecsWorld.RemoveComponent <BandageInProgressComponent>(pedEntity); continue; } progress.EstimateTime -= frameTimeInSec; if (progress.EstimateTime > 0) { continue; } _ecsWorld.RemoveComponent <BandageInProgressComponent>(pedEntity); _ecsWorld.CreateEntityWith <SuccessfulBandageEvent>().Entity = pedEntity; } for (var i = 0; i < _successfulEvents.EntitiesCount; i++) { var pedEntity = _successfulEvents.Components1[i].Entity; if (!_ecsWorld.IsEntityExists(pedEntity)) { continue; } var woundedPed = _ecsWorld.GetComponent <WoundedPedComponent>(pedEntity); if (woundedPed?.MostDangerBleedingEntity == null) { continue; } var bleedingEntity = woundedPed.MostDangerBleedingEntity.Value; if (!_ecsWorld.IsEntityExists(bleedingEntity)) { continue; } var bleeding = _ecsWorld.GetComponent <BleedingComponent>(woundedPed.MostDangerBleedingEntity.Value); if (bleeding == null) { continue; } bleeding.BleedSeverity = bleeding.BleedSeverity / 2; UpdateMostDangerWound(woundedPed, pedEntity); SendMessage(string.Format("~g~" + _localeConfig.Data.BandageSuccess, bleeding.Name), pedEntity); } _successfulEvents.CleanFilter(); }
public void Run() { #if DEBUG GunshotWound2.LastSystem = nameof(InstantHealSystem); #endif for (var i = 0; i < _events.EntitiesCount; i++) { var pedEntity = _events.Components1[i].Entity; if (!_ecsWorld.IsEntityExists(pedEntity)) { continue; } var woundedPed = _ecsWorld.GetComponent <WoundedPedComponent>(pedEntity); if (woundedPed != null) { if (woundedPed.IsPlayer) { _ecsWorld.CreateEntityWith <AddCameraShakeEvent>().Length = CameraShakeLength.CLEAR; Function.Call(Hash.SET_PLAYER_SPRINT, Game.Player, true); Function.Call(Hash._SET_CAM_EFFECT, 0); Function.Call(Hash.ANIMPOSTFX_STOP_ALL); woundedPed.Health = _mainConfig.Data.PlayerConfig.MaximalHealth; Game.Player.IgnoredByEveryone = false; } else { woundedPed.Health = GunshotWound2.Random.Next(50, _mainConfig.Data.NpcConfig.MaxStartHealth); woundedPed.ThisPed.Accuracy = woundedPed.DefaultAccuracy; } woundedPed.IsDead = false; woundedPed.Crits = 0; woundedPed.PedHealth = woundedPed.Health; woundedPed.Armor = woundedPed.ThisPed.Armor; woundedPed.BleedingCount = 0; woundedPed.MostDangerBleedingEntity = null; _ecsWorld.RemoveComponent <PainComponent>(pedEntity, true); Function.Call(Hash.CLEAR_PED_BLOOD_DAMAGE, woundedPed.ThisPed); Function.Call(Hash.SET_PED_MOVE_RATE_OVERRIDE, woundedPed.ThisPed, 1f); _ecsWorld.CreateEntityWith(out NoPainChangeStateEvent noPainEvent); noPainEvent.Entity = pedEntity; noPainEvent.ForceUpdate = true; } for (var bleedIndex = 0; bleedIndex < _bleedingComponents.EntitiesCount; bleedIndex++) { if (_bleedingComponents.Components1[bleedIndex].Entity != pedEntity) { continue; } _ecsWorld.RemoveEntity(_bleedingComponents.Entities[bleedIndex]); } } _events.CleanFilter(); }
private void FindPeds() { var addRange = _config.Data.NpcConfig.AddingPedRange; if (addRange <= GunshotWound2.MinimalRangeForWoundedPeds) { return; } var playerPed = Game.Player.Character; if (CheckNeedToUpdateWorldPeds()) { _config.Data.NpcConfig.WorldPeds = GTA.World.GetNearbyPeds(playerPed, addRange); _config.Data.NpcConfig.LastCheckedPedIndex = 0; _forceUpdates.CleanFilter(); } var allPeds = _config.Data.NpcConfig.WorldPeds; var pedsToAdd = new Queue <Ped>(); _stopwatch.Restart(); for (var worldPedIndex = _config.Data.NpcConfig.LastCheckedPedIndex; worldPedIndex < allPeds.Length; worldPedIndex++) { if (_stopwatch.ElapsedMilliseconds > _config.Data.NpcConfig.UpperBoundForFindInMs) { break; } _config.Data.NpcConfig.LastCheckedPedIndex = worldPedIndex; var pedToCheck = allPeds[worldPedIndex]; if (!pedToCheck.IsHuman || pedToCheck.IsDead || pedToCheck.IsPlayer) { continue; } if (!PedInTargetList(playerPed, pedToCheck)) { continue; } if (_config.Data.NpcConfig.ScanOnlyDamaged && !Function.Call <bool>(Hash.HAS_ENTITY_BEEN_DAMAGED_BY_ANY_PED, pedToCheck)) { continue; } if (CheckWoundedPedExist(pedToCheck)) { continue; } pedsToAdd.Enqueue(pedToCheck); } _stopwatch.Stop(); if (pedsToAdd.Count <= 0) { return; } _ecsWorld.CreateEntityWith <ConvertPedToNpcGswPedEvent>().PedsToAdd = pedsToAdd; }