Page 4 of 9
Posted: Fri Sep 19, 2008 12:11 am
by John Adams
Another LUA function we might need, unless MovementLoop() allows this;
Watching Courier Dirvel in Graystone yard - he walks to specific coordinates, and when he gets there, he stops, and says/animates/emotes a phrase before moving on to the next spot.
I am assuming the movement loop just sets coords, and is not a line-by-line execution... so I didn't think to insert the Say() commands in between the loop entries. Figured I'd just ask rather than waste time thinking I'm not doing it right.
Thanks
Posted: Fri Sep 19, 2008 5:49 am
by LethalEncounter
Yah you are right, the movement loop doesn't currently allow you to perform any actions when the NPC stops. Would adding a custom function name to call on the end of the function help? That way when a NPC stops, it will call your custom function (in the same file) and do whatever you want.
Posted: Fri Sep 19, 2008 10:48 am
by John Adams
I was getting pretty tired last night and wasn't feeling creative heh, but let me visually display it, you tell me if this is how movement script works:
Code: Select all
function spawn(NPC)
x = GetX(NPC)
y = GetY(NPC)
z = GetZ(NPC)
MovementLoopAddLocation(NPC, x + 7 , y, z - 8 , 2, math.random(5, 15))
say_1(NPC)
MovementLoopAddLocation(NPC, x - 5 , y, z - 10, 2, math.random(5, 15))
say_2(NPC)
MovementLoopAddLocation(NPC, x - 10, y, z + 9 , 2, math.random(5, 15))
say_3(NPC)
MovementLoopAddLocation(NPC, x + 5 , y, z + 8 , 2, math.random(5, 15))
say_4(NPC)
end
function say_1(NPC)
Say("I am at the first spot!")
end
function say_2(NPC)
Say("I am at the second spot!")
end
function say_3(NPC)
Say("I am at the third spot!")
end
function say_4(NPC)
Say("I am at the fourth spot!")
end
See, I assumed that when the LUA function read the "MovementLoopAddLocation()", it did them all at once and now they were all in memory in some array that were cycled through sequentially. But if that means a Function can be called between them, then that is the solution. And I like it.

Posted: Fri Sep 19, 2008 11:09 am
by LethalEncounter
I assumed that when the LUA function read the "MovementLoopAddLocation()", it did them all at once and now they were all in memory in some array that were cycled through sequentially
That is exactly how it works. My change would add an additional argument to MovementLoopAddLocation that would tell it a custom LUA spawn script function to call after it gets to that particular location.
Posted: Fri Sep 19, 2008 11:21 am
by John Adams
I'll take it!
Posted: Fri Sep 19, 2008 11:44 am
by LethalEncounter
Could you test this when you get a sec? It should work once you get the latest.
Posted: Fri Sep 19, 2008 11:57 am
by John Adams
Give me a few hours, got a repair guy here fixing the Maytag.

Guess he's not so lonely today.
Posted: Fri Sep 19, 2008 12:25 pm
by Scatman
I just tested this and it seems to be doing the same thing that would happen if you just put the Say function in the spawn(). Here's what I'm doing:
Code: Select all
function spawn(NPC)
MovementLoopAddLocation(NPC, 22.19, -6.86, 183.95, 2, 30, say1(NPC))
MovementLoopAddLocation(NPC, 30.76, -6.33, 196.28, 2, 30, say2(NPC))
MovementLoopAddLocation(NPC, 20.70, -6.85, 206.43, 2, 30, say3(NPC))
end
function respawn(NPC)
spawn(NPC)
end
function say1(NPC)
Say(NPC, "1")
end
function say2(NPC, Spawn)
Say(NPC, "2")
end
function say3(NPC, Spawn)
Say(NPC, "3")
end
When I do a /reload spawnscripts and /repop, the NPC is saying "1", "2", "3", right when she is spawned then starts moving and never says "1", "2", "3" again.
This script is for Gethe Huggs in the Outpost of the Overlord (paula marx counter-part).
Posted: Fri Sep 19, 2008 12:29 pm
by LethalEncounter
heh no, change MovementLoopAddLocation(NPC, 22.19, -6.86, 183.95, 2, 30, say1(NPC)) to
MovementLoopAddLocation(NPC, 22.19, -6.86, 183.95, 2, 30, "say1")
Posted: Fri Sep 19, 2008 12:32 pm
by Scatman
Doh, I've been programming in C++ too much recently. I still find myself adding parenthesis in if statements

I'll get right back to you with that.
Posted: Fri Sep 19, 2008 12:36 pm
by Scatman
She moves now, but doesn't say anything at all. I have the function looking exactly how it should from your example.
Posted: Fri Sep 19, 2008 12:38 pm
by John Adams
Scat, I do not think this is on the public SVN yet. Tess is still set up as Public. Do you need me to run the Dev code, or are you doing this on your own server?
Posted: Fri Sep 19, 2008 12:43 pm
by LethalEncounter
I just uploaded it to public SVN if either of you wants to grab it.
Posted: Fri Sep 19, 2008 12:45 pm
by Scatman
Doh, there's my second brainfart today. I was doing it on your server. If you just want to test it on dev or upload it to public I'll do it. I don't have any spawns in my db at the moment but I could parse some if you're busy.
Posted: Fri Sep 19, 2008 12:50 pm
by John Adams
Since LE committed it, give me 5 mins, I'll have Tess updated.