public PedBoundingBox(Ped ped) { ped.Model.GetDimensions(out var rearBottomLeft, out var frontTopRight); float chestHeight = ped.Height * HeightScaleFactor; float chestWidth = ped.Width * WidthScaleFactor; float chestLength = ped.Length * LengthScaleFactor; Vector3 size = new Vector3(chestWidth, chestLength, chestHeight) * PedScaleFactor; Vector3 wireboxCenter = ped.GetBonePosition(PedBoneId.Pelvis) - 0.075f * ped.UpVector; Initialize(wireboxCenter, size, ped.Orientation, ped); }
public ChestBoundingBox(Ped ped) { Vector3 spineBonePosition = ped.GetBonePosition(PedBoneId.Spine3); Quaternion chestOrientation = ped.Orientation; float chestHeight = ped.Height * HeightScaleFactor; float chestWidth = ped.Width * WidthScaleFactor; float chestLength = ped.Length * LengthScaleFactor; Vector3 chestSize = new Vector3(chestWidth, chestLength, chestHeight) * ChestScaleFactor; Initialize(spineBonePosition, chestSize, chestOrientation, ped); }
public void Run() { foreach (int i in _peds) { Ped ped = _peds.Components1[i].ThisPed; if (!ped.Exists()) { continue; } PedBoneId?[] history = _peds.Components2[i].LastDamagedBones; for (int historyIndex = 0; historyIndex < history.Length; historyIndex++) { PedBoneId?boneId = history[historyIndex]; if (boneId == null || !ped.IsBoneValid(boneId.Value)) { continue; } Color color; float radius; switch (historyIndex) { case 0: color = Color.DarkOrange; radius = 0.15f; break; case 1: color = Color.Yellow; radius = 0.14f; break; case 2: color = Color.ForestGreen; radius = 0.13f; break; default: continue; } PedBoneId bone = boneId.Value; Vector3 position = ped.GetBonePosition(bone); Debug.DrawSphereDebug(position, radius, color); } } }
private void ProcessOrderOutOfVehicle(Vehicle v, Ped p) { if (v.IsBoat) { Functions.ForceEndCurrentPullover(); Vector3 pos = p.GetBonePosition(0); p.Tasks.Clear(); p.Position = pos; } else { Functions.ForceEndCurrentPullover(); p.Tasks.LeaveVehicle(LeaveVehicleFlags.None).WaitForCompletion(5000); PedBackIntoVehicleLogic(p, SuspectVehicle); } NativeFunction.Natives.RESET_PED_LAST_VEHICLE(p); API.Functions.OnPedOrderedOutOfVehicle(p); Functions.SetPedAsStopped(p, true); }
public HeadBoundingBox(Ped ped) { Vector3 headBonePosition = ped.GetBonePosition(PedBoneId.Head); Quaternion headOrientation = ped.GetBoneOrientation(PedBoneId.Head); //since there is no information about head size, i used average sizes of world population //todo: insert also data for women float headBreadth = 15.2f / 100; float headLength = 19.7f / 100; float headHeight = 23.2f / 100 * 1.1f; //account 10% more height for helmet Vector3 headSize = new Vector3(headHeight, headLength, headBreadth) * HeadScaleFactor; Vector3 offset = new Vector3(headHeight * 0.25f, headLength * 0.1f, 0); Vector3 rotatedOffset = offset.Rotate(headOrientation); Vector3 headCenter = rotatedOffset + headBonePosition; Initialize(headCenter, headSize, headOrientation, ped); }
public void Run() { if (_peds.IsEmpty()) { _screenPositionList = null; _radiusList = null; _colorList = null; return; } Vector3 playerPosition = Game.LocalPlayer.Character.Position; var screenPositionList = new List <Vector2>(); var radiusList = new List <float>(); var colorList = new List <Color>(); foreach (int i in _peds) { Ped ped = _peds.Components1[i].ThisPed; if (!ped.Exists()) { continue; } PedBoneId?[] history = _peds.Components2[i].LastDamagedBones; for (int historyIndex = 0; historyIndex < history.Length; historyIndex++) { PedBoneId?boneId = history[historyIndex]; if (boneId == null || !ped.IsBoneValid(boneId.Value)) { continue; } PedBoneId bone = boneId.Value; Vector3 position = ped.GetBonePosition(bone); float distance = Vector3.Distance(playerPosition, position); if (distance >= MAXIMAL_RANGE) { continue; } Color color; float radius; switch (historyIndex) { case 0: color = Color.DarkOrange; radius = 15f; break; case 1: color = Color.Yellow; radius = 10f; break; case 2: color = Color.ForestGreen; radius = 5f; break; default: continue; } Vector2 screenPosition = World.ConvertWorldPositionToScreenPosition(position); float ratio = 1 - distance / MAXIMAL_RANGE; radius *= ratio; screenPositionList.Add(screenPosition); radiusList.Add(radius); colorList.Add(color); } } _screenPositionList = screenPositionList; _radiusList = radiusList; _colorList = colorList; }