Difference between revisions of "ContentDesigner:Creating Movement"

Line 17: Line 17:
 
NPC, x, y, z, speed, delay (in seconds), function name (optional)
 
NPC, x, y, z, speed, delay (in seconds), function name (optional)
  
  function hailed(NPC, Spawn)
+
 
    FaceTarget(NPC, Spawn)
+
function spawn(NPC)
  end<br />function spawn(NPC)
+
  MovementLoopAddLocation(NPC, -407.46, -60.48, 174.23, 2, math.random(5, 15))
    MovementChoice(NPC)<br>
+
  MovementLoopAddLocation(NPC, -420.76, -60.86, 180.15, 2, math.random(5, 15))
 +
  MovementLoopAddLocation(NPC, -425.42, -61.32, 186.58, 2)
 +
  MovementLoopAddLocation(NPC, -424.20, -61.98, 190.47, 2, math.random(5, 15))
 +
  MovementLoopAddLocation(NPC, -410.19, -62.87, 189.81, 2, math.random(5, 15))
 +
  MovementLoopAddLocation(NPC, -406.82, -60.56, 174.38, 2, math.random(5, 15), "Comment")
 +
  end<br /><br />
 +
function Comment(NPC)
 +
  Say(NPC, "Nice day for a walk, isn't it?")
 
  end
 
  end
 +
 +
If we added the optional function name to the last MovementLoopAddLocation() it will call that function. Here is what that last MovementLoopAddLocation() would look like, and the function it would call.
 +
 +
  MovementLoopAddLocation(NPC, -406.82, -60.56, 174.38, 2, math.random(5, 15), "Comment")
  
 
|BackgroundColor=ffffff
 
|BackgroundColor=ffffff

Revision as of 14:51, 14 June 2016

ContentDesigner:SpawnScripts - Creating Movement

Return to: ContentDesigner:SpawnScripts | Tutorials | Portal | Forum | Project Manager | Bug Tracker


The Creating Movement guide will show you how to get your NPC's to walk and run around. With many different combinations you can make a specific path for the NPC to follow to walking in circles if you choose.


Movement Functions

There are two functions that can be used to make an NPC move. Below you will find examples of how to use both to make an NPC move around in Norrath.

The MovementLoopAddLocation() function will allow an NPC to move along a given set of coordinates. This can be along a path, in a circle, or random locations. The below example will show a simple movement script.


Syntax is NPC, x, y, z, speed, delay (in seconds), function name (optional)


function spawn(NPC)
  MovementLoopAddLocation(NPC, -407.46, -60.48, 174.23, 2, math.random(5, 15))
  MovementLoopAddLocation(NPC, -420.76, -60.86, 180.15, 2, math.random(5, 15))
  MovementLoopAddLocation(NPC, -425.42, -61.32, 186.58, 2)
  MovementLoopAddLocation(NPC, -424.20, -61.98, 190.47, 2, math.random(5, 15))
  MovementLoopAddLocation(NPC, -410.19, -62.87, 189.81, 2, math.random(5, 15))
  MovementLoopAddLocation(NPC, -406.82, -60.56, 174.38, 2, math.random(5, 15), "Comment")
end

function Comment(NPC) Say(NPC, "Nice day for a walk, isn't it?") end

If we added the optional function name to the last MovementLoopAddLocation() it will call that function. Here is what that last MovementLoopAddLocation() would look like, and the function it would call.

 MovementLoopAddLocation(NPC, -406.82, -60.56, 174.38, 2, math.random(5, 15), "Comment")



The second one MoveToLocation() will allow the NPC to move to a specific location then stop.