AngleToVector(float)

From NWN Lexicon

Converts an angle into a vector.

vector AngleToVector(
    float fAngle
);

Contents

[edit] Parameters

fAngle
The degrees of an angle to convert into a vector.

[edit] Description

Returns the value of fAngle converted into a vector.

[edit] Version

1.30

[edit] Example

// Stalker script (but in an NPC's OnHeartbeat script)
// Supplied by Cheiron
void main()
{
    object oTarget = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC);
 
    object oArea        = GetArea    (oTarget);
    vector vPosition    = GetPosition(oTarget);
    float  fOrientation = GetFacing  (oTarget);
 
    // This is where AngleToVector shows its powers!
    vector vNewPos = AngleToVector(fOrientation); 
 
    float vX = vPosition.x - vNewPos.x;
    float vY = vPosition.y - vNewPos.y;
    float vZ = vPosition.z;
 
    vNewPos = Vector(vX, vY, vZ);
 
    ClearAllActions();
 
    // Go stand right behind the PC (if he's still there)
    ActionMoveToLocation(Location(oArea, vNewPos, fOrientation));
 
    // Turn towards PC
    ActionDoCommand(SetFacing(fOrientation));
}

[edit] See Also

functions:  VectorToAngle


 author: Charles Feduke, editor: Lilac Soul, additional contributor(s): Cheiron, Lilac Soul

Personal tools
Categories