2022-07-20 17:50:01 +08:00
|
|
|
|
using GTA;
|
2022-05-22 15:55:26 +08:00
|
|
|
|
using GTA.Math;
|
2022-07-20 17:50:01 +08:00
|
|
|
|
using GTA.Native;
|
2022-05-22 15:55:26 +08:00
|
|
|
|
using LemonUI.Elements;
|
2022-07-20 17:50:01 +08:00
|
|
|
|
using RageCoop.Core;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
2022-05-22 15:55:26 +08:00
|
|
|
|
|
|
|
|
|
namespace RageCoop.Client
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// ?
|
|
|
|
|
/// </summary>
|
2022-08-14 19:06:51 +08:00
|
|
|
|
public partial class SyncedPed : SyncedEntity
|
2022-05-22 15:55:26 +08:00
|
|
|
|
{
|
|
|
|
|
#region CONSTRUCTORS
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Create a local entity (outgoing sync)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="p"></param>
|
2022-06-11 18:41:10 +08:00
|
|
|
|
internal SyncedPed(Ped p)
|
2022-05-22 15:55:26 +08:00
|
|
|
|
{
|
2022-05-25 10:09:59 +08:00
|
|
|
|
ID=EntityPool.RequestNewID();
|
2022-05-22 15:55:26 +08:00
|
|
|
|
p.CanWrithe=false;
|
|
|
|
|
p.IsOnlyDamagedByPlayer=false;
|
|
|
|
|
MainPed=p;
|
2022-05-23 16:59:49 +08:00
|
|
|
|
OwnerID=Main.LocalPlayerID;
|
2022-05-22 15:55:26 +08:00
|
|
|
|
|
2022-06-02 15:51:58 +08:00
|
|
|
|
Function.Call(Hash._SET_PED_CAN_PLAY_INJURED_ANIMS, false);
|
|
|
|
|
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_DisableHurt, true);
|
2022-07-09 19:32:11 +08:00
|
|
|
|
// MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_DisableMelee, true);
|
2022-06-02 15:51:58 +08:00
|
|
|
|
|
2022-05-22 15:55:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Create an empty character with ID
|
|
|
|
|
/// </summary>
|
2022-06-11 18:41:10 +08:00
|
|
|
|
internal SyncedPed(int id)
|
2022-05-22 15:55:26 +08:00
|
|
|
|
{
|
|
|
|
|
ID=id;
|
|
|
|
|
LastSynced=Main.Ticked;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
2022-06-11 18:41:10 +08:00
|
|
|
|
internal Blip PedBlip = null;
|
2022-07-03 10:46:24 +08:00
|
|
|
|
internal BlipColor BlipColor = (BlipColor)255;
|
2022-08-13 16:14:18 +08:00
|
|
|
|
internal BlipSprite BlipSprite = 0;
|
2022-07-20 17:50:01 +08:00
|
|
|
|
internal float BlipScale = 1;
|
2022-08-13 16:14:18 +08:00
|
|
|
|
internal int VehicleID
|
|
|
|
|
{
|
|
|
|
|
get => CurrentVehicle?.ID ?? 0;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (CurrentVehicle == null || value != CurrentVehicle?.ID)
|
|
|
|
|
{
|
|
|
|
|
CurrentVehicle=EntityPool.GetVehicleByID(value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
internal SyncedVehicle CurrentVehicle { get; private set; }
|
|
|
|
|
internal VehicleSeat Seat;
|
2022-08-11 14:48:19 +02:00
|
|
|
|
public bool IsPlayer { get => OwnerID == ID && ID != 0; }
|
2022-05-22 15:55:26 +08:00
|
|
|
|
public Ped MainPed { get; internal set; }
|
2022-06-11 18:41:10 +08:00
|
|
|
|
internal int Health { get; set; }
|
2022-07-17 18:44:16 +08:00
|
|
|
|
|
|
|
|
|
internal Vector3 HeadPosition { get; set; }
|
|
|
|
|
internal Vector3 RightFootPosition { get; set; }
|
|
|
|
|
internal Vector3 LeftFootPosition { get; set; }
|
|
|
|
|
|
2022-06-19 11:47:39 +08:00
|
|
|
|
internal byte WeaponTint { get; set; }
|
2022-08-13 16:14:18 +08:00
|
|
|
|
internal Vehicle _lastVehicle { get; set; }
|
|
|
|
|
internal int _lastVehicleID { get; set; }
|
2022-07-20 17:50:01 +08:00
|
|
|
|
private bool _lastRagdoll = false;
|
|
|
|
|
private ulong _lastRagdollTime = 0;
|
2022-05-22 15:55:26 +08:00
|
|
|
|
private bool _lastInCover = false;
|
2022-06-17 19:14:56 +08:00
|
|
|
|
private byte[] _lastClothes = null;
|
2022-07-01 14:39:43 +08:00
|
|
|
|
internal byte[] Clothes { get; set; }
|
2022-05-22 15:55:26 +08:00
|
|
|
|
|
2022-06-11 18:41:10 +08:00
|
|
|
|
internal float Heading { get; set; }
|
2022-08-13 16:14:18 +08:00
|
|
|
|
|
2022-08-14 23:35:36 +02:00
|
|
|
|
internal ulong LastSpeakingTime { get; set; } = 0;
|
|
|
|
|
internal bool IsSpeaking { get; set; } = false;
|
2022-08-13 16:14:18 +08:00
|
|
|
|
|
|
|
|
|
#region -- VARIABLES --
|
|
|
|
|
public byte Speed { get; set; }
|
|
|
|
|
private bool _lastIsJumping = false;
|
2022-08-14 19:06:51 +08:00
|
|
|
|
internal PedDataFlags Flags;
|
|
|
|
|
|
|
|
|
|
internal bool IsAiming => Flags.HasPedFlag(PedDataFlags.IsAiming);
|
2022-08-15 19:39:36 +08:00
|
|
|
|
internal bool _lastDriveBy;
|
2022-08-14 19:06:51 +08:00
|
|
|
|
internal bool IsReloading => Flags.HasPedFlag(PedDataFlags.IsReloading);
|
|
|
|
|
internal bool IsJumping => Flags.HasPedFlag(PedDataFlags.IsJumping);
|
|
|
|
|
internal bool IsRagdoll => Flags.HasPedFlag(PedDataFlags.IsRagdoll);
|
|
|
|
|
internal bool IsOnFire => Flags.HasPedFlag(PedDataFlags.IsOnFire);
|
|
|
|
|
internal bool IsInParachuteFreeFall => Flags.HasPedFlag(PedDataFlags.IsInParachuteFreeFall);
|
|
|
|
|
internal bool IsParachuteOpen => Flags.HasPedFlag(PedDataFlags.IsParachuteOpen);
|
|
|
|
|
internal bool IsOnLadder => Flags.HasPedFlag(PedDataFlags.IsOnLadder);
|
|
|
|
|
internal bool IsVaulting => Flags.HasPedFlag(PedDataFlags.IsVaulting);
|
|
|
|
|
internal bool IsInCover => Flags.HasPedFlag(PedDataFlags.IsInCover);
|
|
|
|
|
internal bool IsInLowCover => Flags.HasPedFlag(PedDataFlags.IsInLowCover);
|
|
|
|
|
internal bool IsInCoverFacingLeft => Flags.HasPedFlag(PedDataFlags.IsInCoverFacingLeft);
|
|
|
|
|
internal bool IsBlindFiring => Flags.HasPedFlag(PedDataFlags.IsBlindFiring);
|
|
|
|
|
internal bool IsInStealthMode => Flags.HasPedFlag(PedDataFlags.IsInStealthMode);
|
2022-08-13 16:14:18 +08:00
|
|
|
|
internal Prop ParachuteProp { get; set; } = null;
|
|
|
|
|
internal uint CurrentWeaponHash { get; set; }
|
|
|
|
|
private Dictionary<uint, bool> _lastWeaponComponents = null;
|
|
|
|
|
internal Dictionary<uint, bool> WeaponComponents { get; set; } = null;
|
|
|
|
|
private int _lastWeaponObj = 0;
|
|
|
|
|
#endregion
|
2022-06-11 18:41:10 +08:00
|
|
|
|
internal Vector3 AimCoords { get; set; }
|
2022-05-22 15:55:26 +08:00
|
|
|
|
|
2022-06-02 16:40:38 +08:00
|
|
|
|
private WeaponAsset WeaponAsset { get; set; }
|
2022-05-22 15:55:26 +08:00
|
|
|
|
|
2022-06-11 18:41:10 +08:00
|
|
|
|
internal override void Update()
|
2022-05-22 15:55:26 +08:00
|
|
|
|
{
|
2022-08-20 11:08:51 +08:00
|
|
|
|
if (Owner==null) { OwnerID=OwnerID;return; }
|
2022-06-06 17:37:11 +08:00
|
|
|
|
if (IsPlayer)
|
2022-05-22 15:55:26 +08:00
|
|
|
|
{
|
2022-07-03 10:46:24 +08:00
|
|
|
|
RenderNameTag();
|
|
|
|
|
}
|
2022-07-03 15:28:28 +08:00
|
|
|
|
|
|
|
|
|
// Check if all data avalible
|
|
|
|
|
if (!IsReady) { return; }
|
|
|
|
|
|
|
|
|
|
// Skip update if no new sync message has arrived.
|
2022-08-11 14:48:19 +02:00
|
|
|
|
if (!NeedUpdate) { return; }
|
2022-07-03 15:28:28 +08:00
|
|
|
|
|
2022-07-15 13:45:43 +08:00
|
|
|
|
if (MainPed == null || !MainPed.Exists())
|
2022-07-03 15:28:28 +08:00
|
|
|
|
{
|
2022-07-15 13:45:43 +08:00
|
|
|
|
if (!CreateCharacter())
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-07-03 15:28:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-22 15:55:26 +08:00
|
|
|
|
// Need to update state
|
2022-07-17 11:59:37 +08:00
|
|
|
|
if (LastFullSynced>=LastUpdated)
|
2022-05-22 15:55:26 +08:00
|
|
|
|
{
|
2022-07-15 13:45:43 +08:00
|
|
|
|
if (MainPed!=null&& (Model != MainPed.Model.Hash))
|
2022-05-22 15:55:26 +08:00
|
|
|
|
{
|
2022-07-15 13:45:43 +08:00
|
|
|
|
if (!CreateCharacter())
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-05-22 15:55:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-17 11:15:02 +08:00
|
|
|
|
if (((byte)BlipColor==255) && (PedBlip!=null))
|
2022-05-22 15:55:26 +08:00
|
|
|
|
{
|
2022-07-17 11:15:02 +08:00
|
|
|
|
PedBlip.Delete();
|
|
|
|
|
PedBlip=null;
|
2022-05-22 15:55:26 +08:00
|
|
|
|
}
|
2022-07-17 11:15:02 +08:00
|
|
|
|
else if (((byte)BlipColor != 255) && PedBlip==null)
|
2022-07-09 19:32:11 +08:00
|
|
|
|
{
|
|
|
|
|
PedBlip=MainPed.AddBlip();
|
2022-07-17 11:15:02 +08:00
|
|
|
|
|
2022-08-20 11:08:51 +08:00
|
|
|
|
|
2022-07-17 11:15:02 +08:00
|
|
|
|
PedBlip.Color=BlipColor;
|
|
|
|
|
PedBlip.Sprite=BlipSprite;
|
|
|
|
|
PedBlip.Scale=BlipScale;
|
|
|
|
|
}
|
|
|
|
|
if (PedBlip!=null)
|
|
|
|
|
{
|
|
|
|
|
if (PedBlip.Color!=BlipColor)
|
|
|
|
|
{
|
|
|
|
|
PedBlip.Color=BlipColor;
|
|
|
|
|
}
|
|
|
|
|
if (PedBlip.Sprite!=BlipSprite)
|
|
|
|
|
{
|
|
|
|
|
PedBlip.Sprite=BlipSprite;
|
2022-07-09 19:32:11 +08:00
|
|
|
|
}
|
2022-08-20 11:32:35 +08:00
|
|
|
|
if (IsPlayer)
|
2022-08-20 11:08:51 +08:00
|
|
|
|
{
|
|
|
|
|
PedBlip.Name = Owner.Username;
|
|
|
|
|
}
|
2022-07-09 19:32:11 +08:00
|
|
|
|
}
|
2022-05-25 10:09:59 +08:00
|
|
|
|
|
2022-07-17 11:15:02 +08:00
|
|
|
|
if (!Clothes.SequenceEqual(_lastClothes))
|
|
|
|
|
{
|
|
|
|
|
SetClothes();
|
|
|
|
|
}
|
2022-05-22 15:55:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (MainPed.IsDead)
|
|
|
|
|
{
|
|
|
|
|
if (Health>0)
|
|
|
|
|
{
|
|
|
|
|
if (IsPlayer)
|
|
|
|
|
{
|
|
|
|
|
MainPed.Resurrect();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SyncEvents.TriggerPedKilled(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (IsPlayer&&(MainPed.Health != Health))
|
|
|
|
|
{
|
|
|
|
|
MainPed.Health = Health;
|
|
|
|
|
|
|
|
|
|
if (Health <= 0 && !MainPed.IsDead)
|
|
|
|
|
{
|
|
|
|
|
MainPed.IsInvincible = false;
|
|
|
|
|
MainPed.Kill();
|
2022-05-23 16:59:49 +08:00
|
|
|
|
return;
|
2022-05-22 15:55:26 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-08-13 16:14:18 +08:00
|
|
|
|
if (Speed>=4)
|
2022-05-22 15:55:26 +08:00
|
|
|
|
{
|
|
|
|
|
DisplayInVehicle();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-08-13 16:14:18 +08:00
|
|
|
|
if (MainPed.IsInVehicle()) { MainPed.Task.LeaveVehicle(LeaveVehicleFlags.WarpOut); }
|
2022-05-22 15:55:26 +08:00
|
|
|
|
DisplayOnFoot();
|
|
|
|
|
}
|
2022-08-11 14:48:19 +02:00
|
|
|
|
|
2022-08-14 23:35:36 +02:00
|
|
|
|
if (IsSpeaking)
|
|
|
|
|
{
|
|
|
|
|
if (Main.Ticked - LastSpeakingTime < 10)
|
|
|
|
|
{
|
|
|
|
|
DisplaySpeaking(true);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DisplaySpeaking(false);
|
|
|
|
|
|
|
|
|
|
IsSpeaking = false;
|
|
|
|
|
LastSpeakingTime = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-22 15:55:26 +08:00
|
|
|
|
LastUpdated=Main.Ticked;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RenderNameTag()
|
|
|
|
|
{
|
2022-08-13 16:14:18 +08:00
|
|
|
|
if (!Owner.DisplayNameTag || (MainPed==null) || !MainPed.IsVisible || !MainPed.IsInRange(Main.PlayerPosition, 40f))
|
2022-05-22 15:55:26 +08:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-14 10:33:24 +08:00
|
|
|
|
Vector3 targetPos = MainPed.Bones[Bone.IKHead].Position;
|
2022-07-20 17:50:01 +08:00
|
|
|
|
Point toDraw = default;
|
2022-07-14 10:33:24 +08:00
|
|
|
|
if (Util.WorldToScreen(targetPos, ref toDraw))
|
2022-05-22 15:55:26 +08:00
|
|
|
|
{
|
2022-07-14 10:33:24 +08:00
|
|
|
|
toDraw.Y-=100;
|
2022-08-13 16:14:18 +08:00
|
|
|
|
new ScaledText(toDraw, Owner.Username, 0.4f, GTA.UI.Font.ChaletLondon)
|
2022-07-14 10:33:24 +08:00
|
|
|
|
{
|
|
|
|
|
Outline = true,
|
2022-08-10 20:42:47 +08:00
|
|
|
|
Alignment = GTA.UI.Alignment.Center,
|
|
|
|
|
Color=Owner.HasDirectConnection? Color.FromArgb(179, 229, 252) : Color.White,
|
2022-07-14 10:33:24 +08:00
|
|
|
|
}.Draw();
|
|
|
|
|
}
|
2022-05-22 15:55:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-15 13:45:43 +08:00
|
|
|
|
private bool CreateCharacter()
|
2022-05-22 15:55:26 +08:00
|
|
|
|
{
|
|
|
|
|
if (MainPed != null)
|
|
|
|
|
{
|
|
|
|
|
if (MainPed.Exists())
|
|
|
|
|
{
|
2022-08-08 17:03:41 +08:00
|
|
|
|
// Main.Logger.Debug($"Removing ped {ID}. Reason:CreateCharacter");
|
2022-05-22 15:55:26 +08:00
|
|
|
|
MainPed.Kill();
|
|
|
|
|
MainPed.MarkAsNoLongerNeeded();
|
|
|
|
|
MainPed.Delete();
|
|
|
|
|
}
|
2022-07-20 17:50:01 +08:00
|
|
|
|
|
2022-05-22 15:55:26 +08:00
|
|
|
|
MainPed = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (PedBlip != null && PedBlip.Exists())
|
|
|
|
|
{
|
|
|
|
|
PedBlip.Delete();
|
|
|
|
|
PedBlip = null;
|
|
|
|
|
}
|
2022-07-15 13:45:43 +08:00
|
|
|
|
if (!Model.IsLoaded)
|
2022-05-22 15:55:26 +08:00
|
|
|
|
{
|
2022-07-15 13:45:43 +08:00
|
|
|
|
Model.Request();
|
|
|
|
|
return false;
|
2022-05-22 15:55:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-15 13:45:43 +08:00
|
|
|
|
if ((MainPed = Util.CreatePed(Model, Position)) == null)
|
2022-05-22 15:55:26 +08:00
|
|
|
|
{
|
2022-07-15 13:45:43 +08:00
|
|
|
|
return false;
|
2022-05-22 15:55:26 +08:00
|
|
|
|
}
|
2022-07-15 13:45:43 +08:00
|
|
|
|
|
|
|
|
|
Model.MarkAsNoLongerNeeded();
|
2022-05-22 15:55:26 +08:00
|
|
|
|
|
|
|
|
|
MainPed.BlockPermanentEvents = true;
|
|
|
|
|
MainPed.CanWrithe=false;
|
|
|
|
|
MainPed.CanBeDraggedOutOfVehicle = true;
|
|
|
|
|
MainPed.IsOnlyDamagedByPlayer = false;
|
|
|
|
|
MainPed.RelationshipGroup=Main.SyncedPedsGroup;
|
2022-05-31 02:16:12 -08:00
|
|
|
|
MainPed.IsFireProof=false;
|
|
|
|
|
MainPed.IsExplosionProof=false;
|
2022-06-02 15:51:58 +08:00
|
|
|
|
|
2022-07-09 19:32:11 +08:00
|
|
|
|
Function.Call(Hash.SET_PED_DROPS_WEAPONS_WHEN_DEAD, MainPed.Handle, false);
|
|
|
|
|
Function.Call(Hash.SET_PED_CAN_BE_TARGETTED, MainPed.Handle, true);
|
|
|
|
|
Function.Call(Hash.SET_PED_CAN_BE_TARGETTED_BY_PLAYER, MainPed.Handle, Game.Player, true);
|
|
|
|
|
Function.Call(Hash.SET_PED_GET_OUT_UPSIDE_DOWN_VEHICLE, MainPed.Handle, false);
|
|
|
|
|
Function.Call(Hash.SET_CAN_ATTACK_FRIENDLY, MainPed.Handle, true, true);
|
|
|
|
|
Function.Call(Hash._SET_PED_CAN_PLAY_INJURED_ANIMS, false);
|
|
|
|
|
Function.Call(Hash.SET_PED_CAN_EVASIVE_DIVE, MainPed.Handle, false);
|
|
|
|
|
|
2022-07-20 17:50:01 +08:00
|
|
|
|
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_DrownsInWater, false);
|
2022-06-02 15:51:58 +08:00
|
|
|
|
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_DisableHurt, true);
|
|
|
|
|
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_DisableExplosionReactions, true);
|
|
|
|
|
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_AvoidTearGas, false);
|
2022-08-14 19:06:51 +08:00
|
|
|
|
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_IgnoreBeingOnFire, true);
|
|
|
|
|
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_DisableEvasiveDives, true);
|
|
|
|
|
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_DisablePanicInVehicle, true);
|
|
|
|
|
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_BlockNonTemporaryEvents, true);
|
2022-06-02 15:51:58 +08:00
|
|
|
|
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_DisableShockingEvents, true);
|
|
|
|
|
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_DisableHurt, true);
|
|
|
|
|
|
2022-05-22 15:55:26 +08:00
|
|
|
|
SetClothes();
|
|
|
|
|
|
2022-08-11 14:48:19 +02:00
|
|
|
|
if (IsPlayer) { MainPed.IsInvincible=true; }
|
2022-07-02 17:14:56 +08:00
|
|
|
|
if (IsInvincible) { MainPed.IsInvincible=true; }
|
2022-05-22 15:55:26 +08:00
|
|
|
|
|
2022-07-15 13:45:43 +08:00
|
|
|
|
lock (EntityPool.PedsLock)
|
|
|
|
|
{
|
|
|
|
|
// Add to EntityPool so this Character can be accessed by handle.
|
|
|
|
|
EntityPool.Add(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
2022-05-22 15:55:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetClothes()
|
|
|
|
|
{
|
2022-06-19 11:12:20 +08:00
|
|
|
|
for (byte i = 0; i < 12; i++)
|
2022-05-22 15:55:26 +08:00
|
|
|
|
{
|
2022-06-19 11:12:20 +08:00
|
|
|
|
Function.Call(Hash.SET_PED_COMPONENT_VARIATION, MainPed.Handle, i, (int)Clothes[i], (int)Clothes[i+12], (int)Clothes[i+24]);
|
2022-05-22 15:55:26 +08:00
|
|
|
|
}
|
|
|
|
|
_lastClothes = Clothes;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-13 16:14:18 +08:00
|
|
|
|
|
|
|
|
|
#region ONFOOT
|
2022-05-22 15:55:26 +08:00
|
|
|
|
private string[] _currentAnimation = new string[2] { "", "" };
|
|
|
|
|
|
|
|
|
|
private void DisplayOnFoot()
|
|
|
|
|
{
|
2022-08-14 19:06:51 +08:00
|
|
|
|
|
2022-08-08 17:29:15 +08:00
|
|
|
|
CheckCurrentWeapon();
|
2022-05-22 15:55:26 +08:00
|
|
|
|
if (IsInParachuteFreeFall)
|
|
|
|
|
{
|
2022-07-23 23:45:20 +08:00
|
|
|
|
MainPed.PositionNoOffset = Vector3.Lerp(MainPed.ReadPosition(), Position + Velocity, 0.5f);
|
2022-05-22 15:55:26 +08:00
|
|
|
|
MainPed.Quaternion = Rotation.ToQuaternion();
|
|
|
|
|
|
|
|
|
|
if (!Function.Call<bool>(Hash.IS_ENTITY_PLAYING_ANIM, MainPed.Handle, "skydive@base", "free_idle", 3))
|
|
|
|
|
{
|
|
|
|
|
Function.Call(Hash.TASK_PLAY_ANIM, MainPed.Handle, LoadAnim("skydive@base"), "free_idle", 8f, 10f, -1, 0, -8f, 1, 1, 1);
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (IsParachuteOpen)
|
|
|
|
|
{
|
|
|
|
|
if (ParachuteProp == null)
|
|
|
|
|
{
|
2022-07-15 13:45:43 +08:00
|
|
|
|
Model model = 1740193300;
|
|
|
|
|
model.Request(1000);
|
2022-05-22 15:55:26 +08:00
|
|
|
|
if (model != null)
|
|
|
|
|
{
|
2022-07-25 19:07:58 +08:00
|
|
|
|
ParachuteProp = World.CreateProp(model, MainPed.ReadPosition(), MainPed.ReadRotation(), false, false);
|
2022-05-22 15:55:26 +08:00
|
|
|
|
model.MarkAsNoLongerNeeded();
|
|
|
|
|
ParachuteProp.IsPositionFrozen = true;
|
|
|
|
|
ParachuteProp.IsCollisionEnabled = false;
|
|
|
|
|
|
|
|
|
|
ParachuteProp.AttachTo(MainPed.Bones[Bone.SkelSpine2], new Vector3(3.6f, 0f, 0f), new Vector3(0f, 90f, 0f));
|
|
|
|
|
}
|
|
|
|
|
MainPed.Task.ClearAllImmediately();
|
|
|
|
|
MainPed.Task.ClearSecondary();
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-23 23:45:20 +08:00
|
|
|
|
MainPed.PositionNoOffset = Vector3.Lerp(MainPed.ReadPosition(), Position + Velocity, 0.5f);
|
2022-05-22 15:55:26 +08:00
|
|
|
|
MainPed.Quaternion = Rotation.ToQuaternion();
|
|
|
|
|
|
|
|
|
|
if (!Function.Call<bool>(Hash.IS_ENTITY_PLAYING_ANIM, MainPed.Handle, "skydive@parachute@first_person", "chute_idle_right", 3))
|
|
|
|
|
{
|
|
|
|
|
Function.Call(Hash.TASK_PLAY_ANIM, MainPed, LoadAnim("skydive@parachute@first_person"), "chute_idle_right", 8f, 10f, -1, 0, -8f, 1, 1, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (ParachuteProp != null)
|
|
|
|
|
{
|
|
|
|
|
if (ParachuteProp.Exists())
|
|
|
|
|
{
|
|
|
|
|
ParachuteProp.Delete();
|
|
|
|
|
}
|
|
|
|
|
ParachuteProp = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (IsOnLadder)
|
|
|
|
|
{
|
|
|
|
|
if (Velocity.Z < 0)
|
|
|
|
|
{
|
|
|
|
|
string anim = Velocity.Z < -2f ? "slide_climb_down" : "climb_down";
|
|
|
|
|
if (_currentAnimation[1] != anim)
|
|
|
|
|
{
|
|
|
|
|
MainPed.Task.ClearAllImmediately();
|
|
|
|
|
_currentAnimation[1] = anim;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!Function.Call<bool>(Hash.IS_ENTITY_PLAYING_ANIM, MainPed.Handle, "laddersbase", anim, 3))
|
|
|
|
|
{
|
|
|
|
|
MainPed.Task.PlayAnimation("laddersbase", anim, 8f, -1, AnimationFlags.Loop);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (Math.Abs(Velocity.Z) < 0.5)
|
|
|
|
|
{
|
|
|
|
|
if (_currentAnimation[1] != "base_left_hand_up")
|
|
|
|
|
{
|
|
|
|
|
MainPed.Task.ClearAllImmediately();
|
|
|
|
|
_currentAnimation[1] = "base_left_hand_up";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!Function.Call<bool>(Hash.IS_ENTITY_PLAYING_ANIM, MainPed.Handle, "laddersbase", "base_left_hand_up", 3))
|
|
|
|
|
{
|
|
|
|
|
MainPed.Task.PlayAnimation("laddersbase", "base_left_hand_up", 8f, -1, AnimationFlags.Loop);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (_currentAnimation[1] != "climb_up")
|
|
|
|
|
{
|
|
|
|
|
MainPed.Task.ClearAllImmediately();
|
|
|
|
|
_currentAnimation[1] = "climb_up";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!Function.Call<bool>(Hash.IS_ENTITY_PLAYING_ANIM, MainPed.Handle, "laddersbase", "climb_up", 3))
|
|
|
|
|
{
|
|
|
|
|
MainPed.Task.PlayAnimation("laddersbase", "climb_up", 8f, -1, AnimationFlags.Loop);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SmoothTransition();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-08-14 19:06:51 +08:00
|
|
|
|
else if (MainPed.IsTaskActive(TaskType.CTaskGoToAndClimbLadder))
|
2022-05-22 15:55:26 +08:00
|
|
|
|
{
|
|
|
|
|
MainPed.Task.ClearAllImmediately();
|
|
|
|
|
_currentAnimation[1] = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (IsVaulting)
|
|
|
|
|
{
|
|
|
|
|
if (!MainPed.IsVaulting)
|
|
|
|
|
{
|
|
|
|
|
MainPed.Task.Climb();
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-23 19:19:56 +08:00
|
|
|
|
SmoothTransition();
|
2022-05-22 15:55:26 +08:00
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!IsVaulting && MainPed.IsVaulting)
|
|
|
|
|
{
|
|
|
|
|
MainPed.Task.ClearAllImmediately();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (IsOnFire && !MainPed.IsOnFire)
|
|
|
|
|
{
|
2022-07-17 20:12:25 +08:00
|
|
|
|
Function.Call(Hash.START_ENTITY_FIRE, MainPed);
|
2022-05-22 15:55:26 +08:00
|
|
|
|
}
|
|
|
|
|
else if (!IsOnFire && MainPed.IsOnFire)
|
|
|
|
|
{
|
2022-07-17 20:12:25 +08:00
|
|
|
|
Function.Call(Hash.STOP_ENTITY_FIRE, MainPed);
|
2022-05-22 15:55:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (IsJumping)
|
|
|
|
|
{
|
|
|
|
|
if (!_lastIsJumping)
|
|
|
|
|
{
|
|
|
|
|
_lastIsJumping = true;
|
|
|
|
|
MainPed.Task.Jump();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SmoothTransition();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
_lastIsJumping = false;
|
|
|
|
|
|
|
|
|
|
if (IsRagdoll || Health==0)
|
|
|
|
|
{
|
|
|
|
|
if (!MainPed.IsRagdoll)
|
|
|
|
|
{
|
|
|
|
|
MainPed.Ragdoll();
|
|
|
|
|
}
|
|
|
|
|
SmoothTransition();
|
|
|
|
|
if (!_lastRagdoll)
|
|
|
|
|
{
|
|
|
|
|
_lastRagdoll = true;
|
|
|
|
|
_lastRagdollTime=Main.Ticked;
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (MainPed.IsRagdoll)
|
|
|
|
|
{
|
|
|
|
|
if (Speed==0)
|
|
|
|
|
{
|
|
|
|
|
MainPed.CancelRagdoll();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MainPed.Task.ClearAllImmediately();
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-11 14:48:19 +02:00
|
|
|
|
_lastRagdoll = false;
|
|
|
|
|
}
|
2022-05-22 15:55:26 +08:00
|
|
|
|
|
|
|
|
|
if (IsReloading)
|
|
|
|
|
{
|
2022-05-25 21:54:25 +08:00
|
|
|
|
if (!MainPed.IsTaskActive(TaskType.CTaskReloadGun))
|
|
|
|
|
{
|
|
|
|
|
MainPed.Task.ReloadWeapon();
|
|
|
|
|
}
|
|
|
|
|
/*
|
2022-05-22 15:55:26 +08:00
|
|
|
|
if (!_isPlayingAnimation)
|
|
|
|
|
{
|
|
|
|
|
string[] reloadingAnim = MainPed.GetReloadingAnimation();
|
|
|
|
|
if (reloadingAnim != null)
|
|
|
|
|
{
|
|
|
|
|
_isPlayingAnimation = true;
|
|
|
|
|
_currentAnimation = reloadingAnim;
|
|
|
|
|
MainPed.Task.PlayAnimation(_currentAnimation[0], _currentAnimation[1], 8f, -1, AnimationFlags.AllowRotation | AnimationFlags.UpperBodyOnly);
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-05-25 21:54:25 +08:00
|
|
|
|
*/
|
2022-05-23 19:19:56 +08:00
|
|
|
|
SmoothTransition();
|
2022-05-22 15:55:26 +08:00
|
|
|
|
}
|
|
|
|
|
else if (IsInCover)
|
|
|
|
|
{
|
|
|
|
|
if (!_lastInCover)
|
|
|
|
|
{
|
|
|
|
|
Function.Call(Hash.TASK_STAY_IN_COVER, MainPed.Handle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_lastInCover=true;
|
|
|
|
|
if (IsAiming)
|
|
|
|
|
{
|
|
|
|
|
DisplayAiming();
|
|
|
|
|
_lastInCover=false;
|
|
|
|
|
}
|
|
|
|
|
else if (MainPed.IsInCover)
|
|
|
|
|
{
|
|
|
|
|
SmoothTransition();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (_lastInCover)
|
|
|
|
|
{
|
|
|
|
|
MainPed.Task.ClearAllImmediately();
|
|
|
|
|
_lastInCover=false;
|
|
|
|
|
}
|
|
|
|
|
else if (IsAiming)
|
|
|
|
|
{
|
|
|
|
|
DisplayAiming();
|
|
|
|
|
}
|
|
|
|
|
else if (MainPed.IsShooting)
|
|
|
|
|
{
|
|
|
|
|
MainPed.Task.ClearAllImmediately();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
WalkTo();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region WEAPON
|
|
|
|
|
private void CheckCurrentWeapon()
|
|
|
|
|
{
|
2022-08-08 17:29:15 +08:00
|
|
|
|
if (!WeaponAsset.IsLoaded) { WeaponAsset.Request(); }
|
2022-05-22 15:55:26 +08:00
|
|
|
|
if (MainPed.Weapons.Current.Hash != (WeaponHash)CurrentWeaponHash || !WeaponComponents.Compare(_lastWeaponComponents))
|
|
|
|
|
{
|
2022-06-02 16:40:38 +08:00
|
|
|
|
if (WeaponAsset!=null) { WeaponAsset.MarkAsNoLongerNeeded(); }
|
|
|
|
|
WeaponAsset=new WeaponAsset(CurrentWeaponHash);
|
2022-05-22 15:55:26 +08:00
|
|
|
|
MainPed.Weapons.RemoveAll();
|
2022-05-25 10:09:59 +08:00
|
|
|
|
_lastWeaponObj = Function.Call<int>(Hash.CREATE_WEAPON_OBJECT, CurrentWeaponHash, -1, Position.X, Position.Y, Position.Z, true, 0, 0);
|
|
|
|
|
|
2022-05-22 15:55:26 +08:00
|
|
|
|
if (CurrentWeaponHash != (uint)WeaponHash.Unarmed)
|
|
|
|
|
{
|
2022-05-25 10:09:59 +08:00
|
|
|
|
if (WeaponComponents != null && WeaponComponents.Count != 0)
|
2022-05-22 15:55:26 +08:00
|
|
|
|
{
|
|
|
|
|
foreach (KeyValuePair<uint, bool> comp in WeaponComponents)
|
|
|
|
|
{
|
|
|
|
|
if (comp.Value)
|
|
|
|
|
{
|
|
|
|
|
Function.Call(Hash.GIVE_WEAPON_COMPONENT_TO_WEAPON_OBJECT, _lastWeaponObj, comp.Key);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-05-25 10:09:59 +08:00
|
|
|
|
Function.Call(Hash.GIVE_WEAPON_OBJECT_TO_PED, _lastWeaponObj, MainPed.Handle);
|
2022-05-22 15:55:26 +08:00
|
|
|
|
}
|
|
|
|
|
_lastWeaponComponents = WeaponComponents;
|
|
|
|
|
}
|
2022-07-20 17:50:01 +08:00
|
|
|
|
if (Function.Call<int>(Hash.GET_PED_WEAPON_TINT_INDEX, MainPed, CurrentWeaponHash)!=WeaponTint)
|
2022-06-19 11:47:39 +08:00
|
|
|
|
{
|
|
|
|
|
Function.Call<int>(Hash.SET_PED_WEAPON_TINT_INDEX, MainPed, CurrentWeaponHash, WeaponTint);
|
|
|
|
|
}
|
2022-05-22 15:55:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DisplayAiming()
|
|
|
|
|
{
|
|
|
|
|
if (Velocity==default)
|
|
|
|
|
{
|
2022-07-20 17:50:01 +08:00
|
|
|
|
MainPed.Task.AimAt(AimCoords, 1000);
|
2022-05-22 15:55:26 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Function.Call(Hash.TASK_GO_TO_COORD_WHILE_AIMING_AT_COORD, MainPed.Handle,
|
|
|
|
|
Position.X+Velocity.X, Position.Y+Velocity.Y, Position.Z+Velocity.Z,
|
|
|
|
|
AimCoords.X, AimCoords.Y, AimCoords.Z, 3f, false, 0x3F000000, 0x40800000, false, 512, false, 0);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
SmoothTransition();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
private bool LastMoving;
|
|
|
|
|
private void WalkTo()
|
|
|
|
|
{
|
2022-08-15 18:25:43 +08:00
|
|
|
|
MainPed.Task.ClearAll();
|
2022-07-17 14:23:19 +08:00
|
|
|
|
Function.Call(Hash.SET_PED_STEALTH_MOVEMENT, MainPed, IsInStealthMode, 0);
|
2022-07-23 23:45:20 +08:00
|
|
|
|
Vector3 predictPosition = Position + (Position - MainPed.ReadPosition()) + Velocity * 0.5f;
|
|
|
|
|
float range = predictPosition.DistanceToSquared(MainPed.ReadPosition());
|
2022-05-22 15:55:26 +08:00
|
|
|
|
|
|
|
|
|
switch (Speed)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
if (!MainPed.IsWalking || range > 0.25f)
|
|
|
|
|
{
|
|
|
|
|
float nrange = range * 2;
|
|
|
|
|
if (nrange > 1.0f)
|
|
|
|
|
{
|
|
|
|
|
nrange = 1.0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MainPed.Task.GoStraightTo(predictPosition);
|
|
|
|
|
Function.Call(Hash.SET_PED_DESIRED_MOVE_BLEND_RATIO, MainPed.Handle, nrange);
|
|
|
|
|
}
|
|
|
|
|
LastMoving = true;
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
if (!MainPed.IsRunning || range > 0.50f)
|
|
|
|
|
{
|
|
|
|
|
MainPed.Task.RunTo(predictPosition, true);
|
|
|
|
|
Function.Call(Hash.SET_PED_DESIRED_MOVE_BLEND_RATIO, MainPed.Handle, 1.0f);
|
|
|
|
|
}
|
|
|
|
|
LastMoving = true;
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
if (!MainPed.IsSprinting || range > 0.75f)
|
|
|
|
|
{
|
|
|
|
|
Function.Call(Hash.TASK_GO_STRAIGHT_TO_COORD, MainPed.Handle, predictPosition.X, predictPosition.Y, predictPosition.Z, 3.0f, -1, 0.0f, 0.0f);
|
|
|
|
|
Function.Call(Hash.SET_RUN_SPRINT_MULTIPLIER_FOR_PLAYER, MainPed.Handle, 1.49f);
|
|
|
|
|
Function.Call(Hash.SET_PED_DESIRED_MOVE_BLEND_RATIO, MainPed.Handle, 1.0f);
|
|
|
|
|
}
|
|
|
|
|
LastMoving = true;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
if (LastMoving)
|
|
|
|
|
{
|
|
|
|
|
MainPed.Task.StandStill(2000);
|
|
|
|
|
LastMoving = false;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
SmoothTransition();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SmoothTransition()
|
|
|
|
|
{
|
|
|
|
|
var localRagdoll = MainPed.IsRagdoll;
|
2022-07-23 23:45:20 +08:00
|
|
|
|
var dist = Position.DistanceTo(MainPed.ReadPosition());
|
2022-05-22 15:55:26 +08:00
|
|
|
|
if (dist>3)
|
|
|
|
|
{
|
|
|
|
|
MainPed.PositionNoOffset=Position;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-08-14 17:08:43 +08:00
|
|
|
|
if (!(localRagdoll || MainPed.IsDead))
|
2022-05-22 15:55:26 +08:00
|
|
|
|
{
|
2022-08-15 20:04:08 +08:00
|
|
|
|
if (!IsAiming && !MainPed.IsGettingUp)
|
2022-08-14 17:08:43 +08:00
|
|
|
|
{
|
2022-08-20 12:33:55 +08:00
|
|
|
|
var cur=MainPed.Heading;
|
|
|
|
|
var diff=Heading-cur;
|
|
|
|
|
if (diff > 180) { diff = diff - 360; }
|
|
|
|
|
else if (diff < -180) { diff = 360 + diff; }
|
|
|
|
|
|
|
|
|
|
MainPed.Heading=cur+diff/2;
|
2022-08-14 17:08:43 +08:00
|
|
|
|
}
|
2022-07-23 23:45:20 +08:00
|
|
|
|
MainPed.Velocity=Velocity+5*dist*(Position-MainPed.ReadPosition());
|
2022-05-22 15:55:26 +08:00
|
|
|
|
}
|
2022-08-14 13:56:10 +08:00
|
|
|
|
else if (Main.Ticked-_lastRagdollTime<10)
|
2022-05-22 15:55:26 +08:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-07-17 18:44:16 +08:00
|
|
|
|
else if (IsRagdoll)
|
|
|
|
|
{
|
|
|
|
|
var helper = new GTA.NaturalMotion.ApplyImpulseHelper(MainPed);
|
|
|
|
|
var head = MainPed.Bones[Bone.SkelHead];
|
|
|
|
|
var rightFoot = MainPed.Bones[Bone.SkelRightFoot];
|
|
|
|
|
var leftFoot = MainPed.Bones[Bone.SkelLeftFoot];
|
|
|
|
|
|
|
|
|
|
// 20:head, 3:left foot, 6:right foot, 17:right hand,
|
|
|
|
|
|
|
|
|
|
helper.EqualizeAmount = 1;
|
|
|
|
|
helper.PartIndex=20;
|
|
|
|
|
helper.Impulse=20*(HeadPosition-head.Position);
|
|
|
|
|
helper.Start();
|
|
|
|
|
helper.Stop();
|
|
|
|
|
|
|
|
|
|
helper.EqualizeAmount = 1;
|
|
|
|
|
helper.PartIndex=6;
|
|
|
|
|
helper.Impulse=20*(RightFootPosition-rightFoot.Position);
|
|
|
|
|
helper.Start();
|
|
|
|
|
helper.Stop();
|
|
|
|
|
|
|
|
|
|
helper.EqualizeAmount = 1;
|
|
|
|
|
helper.PartIndex=3;
|
|
|
|
|
helper.Impulse=20*(LeftFootPosition-leftFoot.Position);
|
|
|
|
|
helper.Start();
|
|
|
|
|
helper.Stop();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-07-23 23:45:20 +08:00
|
|
|
|
MainPed.Velocity=Velocity+5*dist*(Position-MainPed.ReadPosition());
|
2022-07-17 18:44:16 +08:00
|
|
|
|
}
|
2022-05-22 15:55:26 +08:00
|
|
|
|
}
|
2022-07-17 14:23:19 +08:00
|
|
|
|
|
2022-05-22 15:55:26 +08:00
|
|
|
|
|
|
|
|
|
|
2022-08-14 19:06:51 +08:00
|
|
|
|
|
2022-05-22 15:55:26 +08:00
|
|
|
|
#endregion
|
2022-06-06 17:37:11 +08:00
|
|
|
|
private void DisplayInVehicle()
|
|
|
|
|
{
|
2022-08-21 14:22:41 +08:00
|
|
|
|
if (CurrentVehicle?.MainVehicle==null) { return; }
|
2022-08-13 16:14:18 +08:00
|
|
|
|
switch (Speed)
|
2022-08-08 17:29:15 +08:00
|
|
|
|
{
|
2022-08-13 16:14:18 +08:00
|
|
|
|
case 4:
|
2022-08-21 14:15:01 +08:00
|
|
|
|
if (MainPed.CurrentVehicle!=CurrentVehicle.MainVehicle || MainPed.SeatIndex!=Seat)
|
2022-08-13 16:14:18 +08:00
|
|
|
|
{
|
|
|
|
|
MainPed.SetIntoVehicle(CurrentVehicle.MainVehicle, Seat);
|
|
|
|
|
}
|
|
|
|
|
if (MainPed.IsOnTurretSeat())
|
|
|
|
|
{
|
|
|
|
|
// Function.Call(Hash.SET_VEHICLE_TURRET_SPEED_THIS_FRAME, MainPed.CurrentVehicle, 100);
|
|
|
|
|
Function.Call(Hash.TASK_VEHICLE_AIM_AT_COORD, MainPed.Handle, AimCoords.X, AimCoords.Y, AimCoords.Z);
|
|
|
|
|
}
|
2022-08-15 18:25:43 +08:00
|
|
|
|
if (MainPed.VehicleWeapon==VehicleWeaponHash.Invalid)
|
|
|
|
|
{
|
|
|
|
|
// World.DrawMarker(MarkerType.DebugSphere,AimCoords,default,default,new Vector3(0.2f,0.2f,0.2f),Color.AliceBlue);
|
|
|
|
|
CheckCurrentWeapon();
|
|
|
|
|
if (IsAiming)
|
|
|
|
|
{
|
2022-08-15 19:39:36 +08:00
|
|
|
|
Function.Call(Hash.SET_DRIVEBY_TASK_TARGET, MainPed, 0, 0, AimCoords.X, AimCoords.Y, AimCoords.Z);
|
|
|
|
|
if (!_lastDriveBy)
|
2022-08-15 18:25:43 +08:00
|
|
|
|
{
|
2022-08-15 19:39:36 +08:00
|
|
|
|
_lastDriveBy=true;
|
|
|
|
|
Function.Call(Hash.TASK_DRIVE_BY, MainPed, 0, 0, AimCoords.X, AimCoords.Y, AimCoords.Z, 1, 100, 1, FiringPattern.SingleShot);
|
2022-08-15 18:25:43 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-08-15 22:21:47 +08:00
|
|
|
|
else if (_lastDriveBy || MainPed.IsTaskActive(TaskType.CTaskAimGunVehicleDriveBy))
|
2022-08-15 18:25:43 +08:00
|
|
|
|
{
|
2022-08-15 22:21:47 +08:00
|
|
|
|
MainPed.Task.ClearAll();
|
2022-08-15 19:39:36 +08:00
|
|
|
|
_lastDriveBy=false;
|
2022-08-15 18:25:43 +08:00
|
|
|
|
}
|
2022-08-15 19:39:36 +08:00
|
|
|
|
|
2022-08-15 18:25:43 +08:00
|
|
|
|
}
|
|
|
|
|
else if (MainPed.VehicleWeapon!=(VehicleWeaponHash)CurrentWeaponHash)
|
2022-08-13 16:14:18 +08:00
|
|
|
|
{
|
|
|
|
|
MainPed.VehicleWeapon=(VehicleWeaponHash)CurrentWeaponHash;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
if (MainPed.VehicleTryingToEnter!=CurrentVehicle.MainVehicle || MainPed.GetSeatTryingToEnter()!=Seat)
|
|
|
|
|
{
|
2022-08-13 16:59:09 +08:00
|
|
|
|
MainPed.Task.EnterVehicle(CurrentVehicle.MainVehicle,Seat,-1,5,EnterVehicleFlags.AllowJacking);
|
2022-08-13 16:14:18 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 6:
|
|
|
|
|
if (!MainPed.IsTaskActive(TaskType.CTaskExitVehicle))
|
|
|
|
|
{
|
|
|
|
|
MainPed.Task.LeaveVehicle(CurrentVehicle.Velocity.Length() > 5f ? LeaveVehicleFlags.BailOut:LeaveVehicleFlags.None);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2022-08-08 17:29:15 +08:00
|
|
|
|
}
|
2022-08-13 16:14:18 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-06-20 10:27:45 +08:00
|
|
|
|
/*
|
|
|
|
|
Function.Call(Hash.SET_PED_STEALTH_MOVEMENT, P,true, 0);
|
|
|
|
|
return Function.Call<bool>(Hash.GET_PED_STEALTH_MOVEMENT, P);
|
|
|
|
|
*/
|
2022-06-06 17:37:11 +08:00
|
|
|
|
}
|
2022-05-22 15:55:26 +08:00
|
|
|
|
}
|
|
|
|
|
}
|