add command "enemy"

This commit is contained in:
in0finite 2021-09-13 00:08:06 +02:00
parent ed023bdcf7
commit 217bf12473
3 changed files with 29 additions and 0 deletions

View file

@ -468,6 +468,13 @@ namespace SanAndreasUnity.Behaviours
this.TargetPed = ped;
}
public void StartChasing(Ped ped)
{
this.Action = PedAIAction.Chasing;
this.TargetPed = ped;
_enemyPeds.AddIfNotPresent(ped);
}
public void Recruit(Ped recruiterPed)
{
if (this.Action == PedAIAction.Following)

View file

@ -52,6 +52,13 @@ namespace SanAndreasUnity.Behaviours
return ped.gameObject.GetOrAddComponent<PedAI>();
}
public static PedAI SpawnPedAI(int pedId, Transform nearbyTransform)
{
if (GetPositionForPedSpawn (out var pos, out var rot, nearbyTransform))
return SpawnPedAI(pedId, pos, rot);
return null;
}
public static PedAI SpawnPedStalker (int pedId, Vector3 pos, Quaternion rot, Ped targetPed)
{
var ped = SpawnPed (pedId, pos, rot, true);

View file

@ -44,6 +44,7 @@ namespace SanAndreasUnity.Commands
{
new CommandManager.CommandInfo("skin", "change skin", true, true, this.pedLimitInterval),
new CommandManager.CommandInfo("stalker", "spawn stalker ped", true, true, this.pedLimitInterval),
new CommandManager.CommandInfo("enemy", "spawn enemy ped", true, true, this.pedLimitInterval),
new CommandManager.CommandInfo("suicide", "commit suicide", true, true, this.pedLimitInterval),
new CommandManager.CommandInfo("teleport", "teleport", true, true, this.pedLimitInterval),
new CommandManager.CommandInfo("veh", "spawn a vehicle", true, true, this.vehicleLimitInterval),
@ -122,6 +123,20 @@ namespace SanAndreasUnity.Commands
return CommandManager.ProcessCommandResult.Success;
}
else if (arguments[0] == "enemy")
{
if (null == player.OwnedPed)
return pedNotAliveResult;
if (!GetPedModelId(arguments, 1, out int modelId))
return pedModelIdDoesNotExist;
var pedAI = Ped.SpawnPedAI(modelId, player.OwnedPed.transform);
// add weapon ...
pedAI.StartChasing(player.OwnedPed);
return CommandManager.ProcessCommandResult.Success;
}
else if (arguments[0] == "suicide")
{
if (null == player.OwnedPed)