@M8T keep a reference to the ped when creating it.
Ped ped = World.CreatePed();
If(ped.isDead) doSomething();
@M8T keep a reference to the ped when creating it.
Ped ped = World.CreatePed();
If(ped.isDead) doSomething();
Looks like menyoos basic speedo
@josiewales don't use the notification system. Have a look under screen or ui and you will see you can draw text directly to the screen.
My script augmented peds was made to combine with zombie like scripts.. makes combat a lot more challenging.
@specialDude Alot of game like the sims would also fake it, give all tasks a time to complete, keep track of the last time the sim on screen and what that sim was doing, what that sim needs to do, then when they are next on screen. Use the information you have to put that sim where it should be by quickly simulating the time that has passed.
This way nothing is updated when it doesn't need to be on distant sims thus enabling you to handle alot more sims than having all sims running through all there tasks all the time.
This is also how games like terraria handle there map tile updates.
yeah visual range is about the limit for movment based tasks on foot. You can spawn a car in sandy and have it drive to the player in LS, but doing the same with a ped on foot will result in the ped doing nothing.
@JohnFromGWN My guess is reacting to events is a secondary task in its self. Some reactions are permanent. If your driver was unarmed she would run away and never come back.
Come to think of it i have seen this bevior in my script, i have peds that run a patrol task on foot. They have weapons and events are not blocked. They will attack if provoked and carry on with there assigned task after all enemies are dead. Just never thought to try it with driving.
Vehicle based tasks work at a much greater range from the player than a ped on foot. I suspect this is something to do with the nav map, maybe using movement tasks that ignore pathing could be a thing? I know i have seen such a parameter for one of the natives. Also there are ways to load distant regions of the map, might be something to look into.
Personally i would just fake it, have a position that moves over time to simulate the ped going somewhere, and then placing that ped on a path/ground near that position and start the movment task when the player is within range for the movement task to actually work. Then faking it again when the player is out of range.
@JohnFromGWN Indeed it was entertaining, Not behaviour i have seen yet as such a ped in any script i have made will not react to events happening around them Ped.BlockPermanentEvents = true;, from my understanding certain tasks can be layered ontop of each other with primary and secondary tasks. It would be interesting to know what else a ped can do while still keeping the underlying drive task.
Did the ped drive to the correct location? I wonder if the game gave the ped a new drive task or if the original task was still active.
Dynamically adjusting the drivers maximum speed based on the type of road node at the vehicles velocity position can improve the standard driving AI a hell of alot.
static void DriverSpeed(Ped p, Vehicle v) // This is run every tick
{
if (v != null && p != null && v.Driver.Handle == p.Handle)
{
float roadSpeed = GetRoadSpeed(v.Position + v.Velocity);
if (roadSpeed != Speed)
{
float increment = 0.01f;
Speed = roadSpeed;
if (v.Speed > Speed)
{
p.MaxDrivingSpeed = v.Speed - (increment * Game.LastFrameTime);
p.DrivingSpeed = v.Speed - (increment * Game.LastFrameTime);
}
else
{
p.MaxDrivingSpeed = Speed;
p.DrivingSpeed = Speed;
}
}
}
}
public static float GetRoadSpeed(Vector3 pos)
{
OutputArgument outArgA = new OutputArgument();
OutputArgument outArgB = new OutputArgument();
if (Function.Call<bool>(Hash.GET_VEHICLE_NODE_PROPERTIES, pos.X, pos.Y, pos.Z, outArgA, outArgB))
{
int busy = outArgA.GetResult<int>();
int flags = outArgB.GetResult<int>();
float speed = 8;
foreach (int flag in Enum.GetValues(typeof(PathnodeFlags)).Cast<PathnodeFlags>())
{
if ((flag & flags) != 0)
{
switch ((PathnodeFlags)flag)
{
case PathnodeFlags.Two:
speed = 16;
break;
case PathnodeFlags.Freeway:
speed = 35;
break;
case PathnodeFlags.Slow:
speed = 9;
break;
case PathnodeFlags.Eight:
speed = 16;
break;
case PathnodeFlags.SlowTraffic:
speed = 14;
break;
case PathnodeFlags.FourWayIntersection:
speed = 11;
break;
case PathnodeFlags.Intersection:
speed = 11;
break;
default:
speed = 8;
break;
}
}
}
int NodeID = Function.Call<int>(Hash.GET_NTH_CLOSEST_VEHICLE_NODE_ID, pos.X, pos.Y, pos.Z, 1, 1, 200f, 200f);
if (Function.Call<bool>(Hash._GET_IS_SLOW_ROAD_FLAG, NodeID))
{
if (speed > 9)
{
speed *= 0.7f;
}
}
return speed;
}
return 5;
}