Hard Question , SNPC Moving randomly

(sorry for my easy english , im french ^^)

Hi , after posted a thread with a unidentified error , now i have repare and all work perfectly , now i have a question

Its possible to make a scripted npc , with randomly move to random position ?

I know spawn npc with ents.Create(“npc_citizen”) , but , i can test all script , nothing work :frowning:

Im not a hard scripter , and i request you (all)

Please help me :slight_smile:


Can you post your code please?

local ply = Entity(1) – The first entity is always the first player
local ent = ents.Create(“npc_citizen”) – This creates our zombie entity
ent:SetPos(Vector(-2553.04,-1576.31,164)) – This positions the zombie at the place our trace hit.

i have just this to make a npc :confused:

Oh for some reason I read it wrong the first time.

Do you want it to move towards a player or to a position?

It’s pretty simple, but is going to involve creating a custom schedule.

local wander = ai_schedule.New( "Wander" )
wander:EngTask( "TASK_WANDER", 1024 )
wander:EngTask( "TASK_WAIT_FOR_MOVEMENT", 0 )

Which would make the npc navigate to a random point up to 1024 units away if memory serves.

However, I think schedules are still broken, so this might not be possible at the moment.

I’m also pretty sure you need to use an SNPC to do this, so you might be able to do something like:

citizen:SetSchedule( SCHED_WANDER )

If that isn’t an option.

me i need a randomly moving citizen , he go in random position, or home , i need a full script beacause

local wander = ai_schedule.New( “Wander” )
wander:EngTask( “TASK_WANDER”, 1024 )
wander:EngTask( “TASK_WAIT_FOR_MOVEMENT”, 0 )

I dont know how to use it :x