Page 1 of 1

NPC movement speed adjustments

Posted: Thu Dec 04, 2008 3:19 pm
by John Adams
LE, couple things:
Adjusting NPC speed does not seem to synch with adjusting player movement speed. Ie., MovementLoop LUA for NPCs, each whole number dramatically increases the speed of the NPC - whereas the /speed {#} command for players seems more finely tuned.
With this info, I'm trying to use a spell script to slow an NPC's movement by using SetSpeed(Target), but I am failing. If this is not supported, you can stop reading and reply "not supported yet" heh. If it should work, continue please :)
Here's my spell script for handling DD/Snare:

Code: Select all

--[[
	Script Name	: dd_snare.lua
	Script Purpose	: Generic damage + Snare effect script
	Script Author	: John Adams
	Script Date	: 2008.12.04
--]]
function cast(Caster, Target, DDType, MinDDVal, MaxDDVal, SnareAmount, DispelChance)
	-- DD component
	if MaxDDVal ~= nil and MinDDVal < MaxDDVal then
		SpellDamage(Target, DDType, math.random(MinDDVal, MaxDDVal))
	else
		SpellDamage(Target, DDType, MinDDVal)
	end
	-- Snare component
	OriginalSpeed = GetSpeed(Target)
	newSpeed = OriginalSpeed - (OriginalSpeed * (SnareAmount / 100))
	if OriginalSpeed > newSpeed then
		SetSpeed(Target, newSpeed)
	end
end
function tick(Caster, Target, DDType, MinDDVal, MaxDDVal, SnareAmount, DispelChance)
	SetSpeed(Target, newSpeed)
end
Question: How long should SetSpeed(Target, newSpeed) last once it's cast? I noticed in our Sprint.lua, we have a call_frequency of 3 seconds, and a duration of 60. That makes me think that SetSpeed() lasts at least 3 seconds, yes? So I set up my Snare the same way - 3 second ticks for 10 seconds, yet my NPC does not slow down.
I've also tried duplicating Snare component calcs in the tick() function itself with no luck.
Any advice?

Re: NPC movement speed adjustments

Posted: Thu Dec 04, 2008 3:53 pm
by LethalEncounter
John Adams wrote:LE, couple things:
Adjusting NPC speed does not seem to synch with adjusting player movement speed. Ie., MovementLoop LUA for NPCs, each whole number dramatically increases the speed of the NPC - whereas the /speed {#} command for players seems more finely tuned.
With this info, I'm trying to use a spell script to slow an NPC's movement by using SetSpeed(Target), but I am failing. If this is not supported, you can stop reading and reply "not supported yet" heh. If it should work, continue please :)
Here's my spell script for handling DD/Snare:

Code: Select all

--[[
	Script Name	: dd_snare.lua
	Script Purpose	: Generic damage + Snare effect script
	Script Author	: John Adams
	Script Date	: 2008.12.04
--]]
function cast(Caster, Target, DDType, MinDDVal, MaxDDVal, SnareAmount, DispelChance)
	-- DD component
	if MaxDDVal ~= nil and MinDDVal < MaxDDVal then
		SpellDamage(Target, DDType, math.random(MinDDVal, MaxDDVal))
	else
		SpellDamage(Target, DDType, MinDDVal)
	end
	-- Snare component
	OriginalSpeed = GetSpeed(Target)
	newSpeed = OriginalSpeed - (OriginalSpeed * (SnareAmount / 100))
	if OriginalSpeed > newSpeed then
		SetSpeed(Target, newSpeed)
	end
end
function tick(Caster, Target, DDType, MinDDVal, MaxDDVal, SnareAmount, DispelChance)
	SetSpeed(Target, newSpeed)
end
Question: How long should SetSpeed(Target, newSpeed) last once it's cast? I noticed in our Sprint.lua, we have a call_frequency of 3 seconds, and a duration of 60. That makes me think that SetSpeed() lasts at least 3 seconds, yes? So I set up my Snare the same way - 3 second ticks for 10 seconds, yet my NPC does not slow down.
I've also tried duplicating Snare component calcs in the tick() function itself with no luck.
Any advice?
Speed for players is different that that of spawns. Players use a percentage increase of the original speed while the spawn's speed is based on the total distanced traveled. I believe that a walking value is 3 to 4 while a sprint is 8-10. It is on my list of things to tweek so that the numbers are similar I just havent had a chance yet. The SetSpeed function does not have a timeout. The value sticks until modified.

Posted: Thu Dec 04, 2008 4:20 pm
by John Adams
Ok, so right now I cannot use GetSpeed(Target) to get an NPCs speed and SetSpeed(Target, value) to alter that NPCs speed?
If not, that's cool. The scripts can be written, they just won't work yet.

Posted: Thu Dec 04, 2008 4:53 pm
by Scatman
In the remove() function, try doing SetSpeed(original speed)? It probably doesn't automatically set the NPCs speed back to the original value on it's own maybe?

Posted: Thu Dec 04, 2008 7:23 pm
by John Adams
See, therein lies the dilemma. How do I know what the NPCs original speed was? I cannot use a GetSpeed(Target) in the remove(), since that will show me what it's current speed is - enhanced. I cannot GetSpeed(Target) in cast() and send that value to tick() or remove() since I think they are all called separately.
So this kind of functionality is likely going to have to happen in the code, not the script. But I'll wait for LE to straighten me out on it, again ;)

Posted: Fri Dec 05, 2008 3:22 pm
by LethalEncounter
Huh? What are you trying to do? You shouldn't have to do anything crazy

Posted: Fri Dec 05, 2008 3:26 pm
by John Adams
I am trying to snare an NPC - slow it's movement down by a percent of it's native speed. And keep it slowed only for a duration.
So how do I determine what the current speed of an NPC is (even ones not on a movement loop) and then determine 30% of that speed to remove (I know how to do the math, it's the initial speed I am having trouble determining)...
And then when the spell expires (duration 12 seconds for instance), how do I tell that NPC to return to it's normal speed? Or does the fact that the snare wore off, the server automatically returns the mob to it's original speed setting?
In short: I wanna fookin snare a mob, damnit. ;)

Posted: Fri Dec 05, 2008 3:36 pm
by LethalEncounter
John Adams wrote:I am trying to snare an NPC - slow it's movement down by a percent of it's native speed. And keep it slowed only for a duration.
So how do I determine what the current speed of an NPC is (even ones not on a movement loop) and then determine 30% of that speed to remove (I know how to do the math, it's the initial speed I am having trouble determining)...
And then when the spell expires (duration 12 seconds for instance), how do I tell that NPC to return to it's normal speed? Or does the fact that the snare wore off, the server automatically returns the mob to it's original speed setting?
In short: I wanna fookin snare a mob, damnit. ;)
lol, then why not SetSpeed(GetSpeed()*.7) to set its speed at 70% normal and then SetSpeed(GetSpeed()/.7) to set it's speed back to normal?
You might need to test how fast the NPC moves at 70% of normal since it might be faster or slower than you intented, but the above should work for slowing the mob and then returning it's speed to normal.

Posted: Fri Dec 05, 2008 4:16 pm
by John Adams
Right, I have tried using SetSpeed and GetSpeed on mobs, but it didn't appear to work. I'll put more dramatic values in. Maybe my 30% wasn't visibly slower to me. :/