Vector
From NWNWiki
A vector is a structure of three floats, useful for defining positions and orientation vectors. The dot operator is used to get the x, y, and z components of the vector. The default value of a vector is {0,0,0} (or x = 0, y = 0, z = 0).
Example:
vector v = GetPosition(OBJECT_SELF) - GetPosition(oidTargetObject); vector v2 = Vector(1.0f, 2.0f, 3.0f); PrintFloat(v2.x); float fDistanceToTarget = sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
[edit] Vector(float, float, float)
The function Vector(float, float, float) creates (and returns) a vector (position) from three coordinates.
vector Vector(
float fX = 0.0f, // x-coordinate of the triplet
float fY = 0.0f, // y-coordinate of the triplet
float fZ = 0.0f // z-coordinate of the triplet
);
A common use for this command is when creating a new location based on an object's location. Some knowledge of how vectors work is probably good for this purpose.
[edit] Version
1.61
[edit] See also
Datatype:
- Introduction to struct
- datatypes float and location
Functions:
(Based on the articles in the NWN Lexicon, author: Charles Feduke.)
