Skip to content

A script for a wandering NPC

chimericchimeric Member Posts: 1,163
I'd like an NPC to wander around the area, stopping every now and then (he's a beggar), but after a half-hour of doing this, game time, to walk to a certain spot and stand there for 60 seconds. After that he is to start making the rounds again.


IF
!GlobalTimerNotExpired("KAZAKER","GLOBAL")
THEN
RESPONSE #100
MoveToPoint([700.2090])
SetGlobalTimer("KAZAKER","GLOBAL",THIRTY_MINUTES)
Wait(60)
END

IF
GlobalTimerNotExpired("KAZAKER","GLOBAL")
THEN
RESPONSE #100
RandomWalk()
Wait(15)
END


This is the script I have, but I can't quite get it together. The random walk, there are no settings for it. I'd like to tell the NPC to walk around for 10 seconds, then stand, begging, i.e. doing nothing, for 15 seconds, and then repeat until the timer chimes. What's missing here?

Also strange is that when he goes to that spot where the timer points him, he does so resolutely - "appears busy" - and cannot be interrupted, though this is not the NoInterrupt version of the action.

Comments

  • ArdanisArdanis Member Posts: 1,736
    edited January 2017
    For starters, Wait(60) is twice the timer's length, so after you're done waiting, the timer will immediately reset anew. Nevermind, can't read what's written...
    I prefer to exclude Wait() from creature scripts altogether and use a dedicated timer for it instead.

    That said, timed random walk routines that are part of a larger sequence require some brain work to set up, so I don't remember off the top of my head the exact structure. BDSHOUT has an example of "search around for a while, then return" scripting, and neothelid uses its own custom version.
  • chimericchimeric Member Posts: 1,163
    Well, I'll look at them. I just don't understand what sets the length of RandomWalk(). It doesn't accept any arguments. Wait() happens afterwards, but when?
Sign In or Register to comment.