Page 1 of 2
Spawn movement
Posted: Fri Jan 26, 2018 12:05 am
by Plague
After a lively discussion on discord I still have questions.
Was discussed for some time but is there a way to make the Spawn Stop Movement and FaceTarget, like when hailed, when it is in a MovementLoop?
I'm also having trouble getting 2 spawns to follow a primary spawn around without wandering off if the primary is stopped for whatever reason ,attacked in this case. The Spawn in question is Baron Dracious and his 2 guard dogs.
And lastly ,at least for now, I have around thirt spawns wandering around East Freeport now and every time they run into each other they start jumping around eventually pathing off, is there a way to make a MovementLoop path to an approximint destinition?
Code: Select all
function spawn(NPC)
MovementLoopAddLocation(NPC, -202.57, -56.07, 32.62, 1, math.random(5, 15))
MovementLoopAddLocation(NPC, -212.03, -56.07, -3.67, 1, math.random(5, 15))
end
Can make the pause time random can you do it for x/y/z too? that would give their walking around a truly random appearance.
Code: Select all
function spawn(NPC)
MovementLoopAddLocation(NPC, math.random(-200.01, -202.57), math.random(-50.02, -56.07), math.random(30.05, 32.62), 1, math.random(5, 15))
end
Wish I were not at work and could test this and other things.
Re: Spawn movement
Posted: Fri Jan 26, 2018 6:19 am
by tyrbo
The random calculation would only happen once.
Otherwise, the Lua function I provided in Discord can be used to stop a mobs pathing.
Re: Spawn movement
Posted: Fri Jan 26, 2018 5:37 pm
by Cynnar
Plague wrote: Fri Jan 26, 2018 12:05 am
Can make the pause time random can you do it for x/y/z too?
Are you talking about making the path random like the movement_circle_small.lua script?
Code: Select all
local x = GetX(NPC)
local y = GetY(NPC)
local z = GetZ(NPC)
local random = math.random(2, 12))
MovementLoopAddLocation(NPC, x + random , y, z - random , 2, math.random(5, 15))
I didn't test this, but it should be close.
tyrbo wrote: Fri Jan 26, 2018 6:19 am
The random calculation would only happen once
That is correct. You will need to add a MovementLoopAddLocation() for each waypoint you want.
Re: Spawn movement
Posted: Fri Jan 26, 2018 6:55 pm
by Plague
Oh I like that, solves one problem I'm having.
Code: Select all
local effect = math.random(2, 4)
function spawn(NPC)
MovementLoopAddLocation(NPC, -98.41+effect, -37.71, -2.44+effect, 1, math.random(5, 15))
MovementLoopAddLocation(NPC, -101.38+effect, -37.71, 3.20+effect, 1, math.random(5, 15))
end
Re: Spawn movement
Posted: Wed Feb 07, 2018 6:39 pm
by Plague
So how do you keep your spawns from walking in the air or underground?
Re: Spawn movement
Posted: Wed Feb 07, 2018 6:50 pm
by tyrbo
That's a work in process. Same with preventing mobs from walking through walls.
[mention]Jabantiz[/mention] had a work in progress bit of code (re: parsing the zone geo data from an uncompressed EQ2 install) that would allow us to eventually handle pathing better, but I'm not sure what the status of that is.
[mention]Jabantiz[/mention], any chance you're willing to open source the map generator yet so others can make some progress with it?
Re: Spawn movement
Posted: Thu Feb 08, 2018 4:09 pm
by Plague
So the game knows when a player character is walking, swimming, etc and does not let us walk under the ground on in the air. I take it PCs and NPC movements are handled differently.
Re: Spawn movement
Posted: Thu Feb 08, 2018 5:50 pm
by tyrbo
Right. That type of detection for players is handled by the server, and then the player position is sent by the client to the server.
NPC movement is entirely controlled by the server. Until the server is able to take advantage of zone geometry information, it can't determine whether a mob is in a valid position or not.
Re: Spawn movement
Posted: Thu Feb 15, 2018 6:21 pm
by Plague
So I noticed today that some of my spawns are walking backwards, not all the time but about half the time. Any good suggestions to make them walk forwards?
Re: Spawn movement
Posted: Thu Feb 15, 2018 6:33 pm
by Cynnar
Never seen that. Is there a movement loop function in the script?
Re: Spawn movement
Posted: Thu Feb 15, 2018 6:42 pm
by tyrbo
Can't say I've seen that before either.
Re: Spawn movement
Posted: Thu Feb 15, 2018 6:46 pm
by Cynnar
Maybe it's trying to do the moonwalk!
Re: Spawn movement
Posted: Thu Feb 15, 2018 6:59 pm
by Plague
Not much to the script. Just to keep them moving about in a small area.
Code: Select all
function hailed(NPC, Spawn)
FaceTarget(NPC, Spawn)
end
function spawn(NPC)
local x = GetX(NPC)
local y = GetY(NPC)
local z = GetZ(NPC)
MovementLoopAddLocation(NPC, x + 1 , y, z - 1 , 1, math.random(5, 15))
MovementLoopAddLocation(NPC, x - 1 , y, z - 1 , 1, math.random(5, 15))
MovementLoopAddLocation(NPC, x - 1 , y, z + 1 , 1, math.random(5, 15))
MovementLoopAddLocation(NPC, x + 1 , y, z + 1 , 1, math.random(5, 15))
end
function respawn(NPC)
spawn(NPC)
local x = GetX(NPC)
local y = GetY(NPC)
local z = GetZ(NPC)
MovementLoopAddLocation(NPC, x + 1 , y, z - 1 , 1, math.random(5, 15))
MovementLoopAddLocation(NPC, x - 1 , y, z - 1 , 1, math.random(5, 15))
MovementLoopAddLocation(NPC, x - 1 , y, z + 1 , 1, math.random(5, 15))
MovementLoopAddLocation(NPC, x + 1 , y, z + 1 , 1, math.random(5, 15))
end
Re: Spawn movement
Posted: Thu Feb 15, 2018 7:09 pm
by Cynnar
You don't need to put it all in the function respawn()
Code: Select all
function respawn(NPC)
spawn(NPC)
end
This line will call the function spawn(NPC) when the npc respawns.
Re: Spawn movement
Posted: Thu Feb 15, 2018 7:40 pm
by Plague
Thanks, tho my wolves are still moonwalking. I dunno why.