LUA function for random wanderings

Old feature requests stored here for reference.
Locked
User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

LUA function for random wanderings

Post by John Adams » Sun Aug 10, 2008 11:33 am

Is it possible to get a Move command for NPCs to wander within the confines of their area randomly? Like fish swimming in their ponds, deer wandering around the meadow. Maybe we can set up safe "bounds" that they can walk in, and they just randomly pick x,y,z,heading,delay themselves.
I still haven't figured out how to get "patrols" to stick together... I think we talked about it, but not sure if that got implemented yet.

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Post by John Adams » Tue Sep 02, 2008 4:34 pm

Random wanderings has been figured out by Scatman's patience, resolve, and sheer will power to make deer scatter in all directions. :)
Here's a sample, for anyone else looking for seemingly random wander paths:

Code: Select all

--[[
	Script Name	: circle_clockwise_small_01.lua
	Script Purpose	: Makes the spawn do a small circle in a clockwise fashion.
	Script Author	: Scatman
	Script Date	: 2008-08-26
	Script Notes	: If the coords are out of bounds then the spawn will still go there.
--]]
function spawn(NPC)
   x = GetX(NPC)
   y = GetY(NPC)
   z = GetZ(NPC)
   MovementLoopAddLocation(NPC, x + 7 , y, z - 8 , 2, math.random(5, 15))
   MovementLoopAddLocation(NPC, x - 5 , y, z - 10, 2, math.random(5, 15))
   MovementLoopAddLocation(NPC, x - 10, y, z + 9 , 2, math.random(5, 15))
   MovementLoopAddLocation(NPC, x + 5 , y, z + 8 , 2, math.random(5, 15))
end
function respawn(NPC)
   spawn(NPC)
end
function hailed(NPC, Spawn)
   FaceTarget(NPC, Spawn)
end
You can probably randomize x and z as well if you know your boundaries.
Thank you Scatman!

User avatar
Scatman
Retired
Posts: 1688
Joined: Wed Apr 16, 2008 5:44 am
EQ2Emu Server: Scatman's Word
Characters: Scatman
Location: New Jersey

Post by Scatman » Tue Sep 02, 2008 4:37 pm

Yah the only problem is if there is a wall in the way, the mob will grab their climbing gear and scale the mountain, no matter how steep it is! Not really a big deal right but maybe later on boundary detection will be put in?

Locked

Who is online

Users browsing this forum: No registered users and 0 guests