View Full Version : [SOLVED] Timed NPC interactions

02-12-2016, 07:42 PM
I'm curious if there are any examples of timed actions between NPCs, where one will do or say something, then another will respond, and so on? I've looked into creature:RegisterEvent, but can't figure out how to send the event to the other NPC.
Basically I'm new, and trying to run before I can crawl. :smile:

02-12-2016, 08:10 PM
local Script = {
Lomax = 123,
Rochet = 321,

function Script.Talk(event, delay, repeats, lomax)
local rochet = lomax:GetNearestCreature( nil, Script.Rochet )
if rochet then
rochet:SendUnitSay("This is how it works", 0)

function Script.SomeHook(event, lomax)
lomax:SendUnitSay("How does this work?", 0)
lomax:RegisterEvent(Script.Talk, 3000, 1)

RegisterCreatureEvent(Script.Lomax, someeventid, Script.SomeHook)

Try that.

What happens: a creature (lomax) starts the conversation by asking a question. A timed event (with 3 second delay) is made to make rochet reply to the question.
When the timed event fires, the creature rochet is searched by his entry id and if found, he replies.

02-12-2016, 09:06 PM
Thanks for the quick response! This worked beautifully!