UE3:Object static native functions (UT3)

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to navigation Jump to search
UT3 Object (static native functions)

Contents

Math functions

Int functions

Clamp

native(251) static final function int Clamp (int V, int A,int B)

Limits V to the interval of [A, B]. Exactly speaking, A will be returned if V is smaller than A, B will be returned if V is larger than B, otherwise V is returned.

This also applies if A is larger than B. So if V is larger than B, but smaller than A, the value of A is returned even though V is actually between the two values.


Max

native(250) static final function int Max (int A, int B)

Returns the larger of the two values. Note that when passing float parameters to this function, they are automatically typecasted to type int. If you don't want this, use the FMax() function instead.


Min

native(249) static final function int Min (int A, int B)

Returns the smaller of the two values. Note that when passing float parameters to this function, they are automatically typecasted to type int. If you don't want this, use the FMin() function instead.


ToHex

native static final function string ToHex (int A)

Converts the int value to its corresponding hexadecimal string representation. Values are treated as unsigned 32 bit integer values for conversion, so e.g. ToHex(-2) results in the string FFFFFFE.


Float functions

Abs

native(186) static final function float Abs (float A)

Returns the absolute value of A. That means, if A is greater than or equal to zero, it is returned unchanged. Otherwise, if A is less than zero, -A is returned.


Acos

native static final function float Acos (float A)

Calculates the arccos of A.


Asin

native static final function float Asin (float A)

Calculates the arcsin of A.


Atan

native(190) static final function float Atan (float A, float B)

Calculates atan2 for the arguments A and B.


Cos

native(188) static final function float Cos (float A)

Calculates the cosine of A.


Exp

native(191) static final function float Exp (float A)

Calculates e to the power of A, the exponential function.

FClamp

native(246) static final function float FClamp (float V, float A, float B)

Limits V to the interval of [A, B]. Exactly speaking, A will be returned if V is smaller than A, B will be returned if V is larger than B, otherwise V is returned.

FMax

native(245) static final function float FMax (float A, float B)

Returns the larger of the two values.

FMin

native(244) static final function float FMin (float A, float B)

Returns the smaller of the two values.

Loge

native(192) static final function float Loge (float A)

Calculates the logarithm of A to the base of e, the natural logarithm.

Round

native(199) static final function int Round (float A)

Rounds to the nearest integer value, using "round half to even" as tie-breaker.

Sin

native(187) static final function float Sin (float A)

Calculates the sine of A.

Sqrt

native(193) static final function float Sqrt (float A)

Calculates the square root of A.

Square

native(194) static final function float Square (float A)

Calculates A * A, i.e. A squared.

Tan

native(189) static final function float Tan (float A)

Calculates the tangent of A.

Vector and rotator functions

ClampLength

native static final function Vector ClampLength (Vector V, float MaxLength)

Clamps a vector to not be longer than MaxLength.

GetAngularDistance

native static final function bool GetAngularDistance (out Vector2D OutAngularDist, Vector Direction, Vector AxisX, Vector AxisY, Vector AxisZ)

Calculates the angular distance of vector 'Direction' to coordinate system O(AxisX,AxisY,AxisZ).

Orientation: (consider 'O' the first person view of the player, and 'Direction' a vector pointing to an enemy) - positive azimuth means enemy is on the right of crosshair. (negative means left). - positive elevation means enemy is on top of crosshair, negative means below.

Parameters:

  • out_AngularDist - X = Azimuth angle (in radians) of 'Direction' vector compared to plane (AxisX,AxisZ). .Y = Elevation angle (in radians) of 'Direction' vector compared to plane (AxisX,AxisY).
  • Direction - Direction of target.
  • AxisX - X component of reference system.
  • AxisY - Y component of reference system.
  • AxisZ - Z component of reference system.

Output: true if 'Direction' is facing AxisX (Direction dot AxisX >= 0.f)

GetAngularFromDotDist

native static final function GetAngularFromDotDist (out Vector2D OutAngDist, Vector2D DotDist)

Converts Dot distance to angular distance.

Parameters:

  • OutAngDist - Angular distance in radians.
  • DotDist - Dot distance.

See: GetAngularDistance() and GetDotDistance().

GetAxes

native(229) static final function GetAxes (Rotator A, out Vector X, out Vector Y, out Vector Z)

Determines the axis unit vectors of a coordinate system that is created by rotating the world coordinate system as specified by the rotator value. Note that the X value is identical to the rotator value typecasted to vector.

If you think of the rotator value as a camera view rotation, then X points in view direction, Y points to the right and Z points upwards.

GetDotDistance

native static final function bool GetDotDistance (out Vector2D OutDotDist, Vector Direction, Vector AxisX, Vector AxisY, Vector AxisZ)

Calculates the dotted distance of vector 'Direction' to coordinate system O(AxisX,AxisY,AxisZ).

Orientation: (consider 'O' the first person view of the player, and 'Direction' a vector pointing to an enemy) - positive azimuth means enemy is on the right of crosshair. (negative means left). - positive elevation means enemy is on top of crosshair, negative means below.

Parameters:

  • OutDotDist - X = 'Direction' dot AxisX relative to plane (AxisX,AxisZ). (== Cos(Azimuth)) .Y = 'Direction' dot AxisX relative to plane (AxisX,AxisY). (== Sin(Elevation))
  • Direction - direction of target.
  • AxisX - X component of reference system.
  • AxisY - Y component of reference system.
  • AxisZ - Z component of reference system.

Returns:

true if 'Direction' is facing AxisX (Direction dot AxisX >= 0.f)

Note: Azimuth' (.X) sign is changed to represent left/right and not front/behind. front/behind is the funtion's return value.

GetUnAxes

native(230) static final function GetUnAxes (Rotator A, out Vector X, out Vector Y, out Vector Z)

Determines the axis unit vectors of a coordinate system that can be transformed into the world coordinate system as specified by rotating it according to the rotator value.

The outputs of GetAxes() and GetUnAxes() for the same input relate to each other as follows: If the output of GetAxes() would be arranged as the column vectors of a 3x3 matrix from left to right, GetUnAxes() would return the row vectors of the same matrix from top to bottom. If the output of both functions would be arranged as column vectors of 3x3 matrices, then the result matrices of GetAxes() and GetUnAxes() are the transpose of each other.

IsZero

native(1501) static final function bool IsZero (Vector A)

Returns whether A is the null vector.

MirrorVectorByNormal

native(300) static final function Vector MirrorVectorByNormal (Vector InVect, Vector InNormal)

"Reflects" the input vector InVect off a surface with the normal vector InNormal and returns the result. The vector InNormal doesn't actually have to be a unit vector.

Normal

native(226) static final function Vector Normal (Vector A)

Returns a vector with the same direction as the input value, but a length of 1. The zero vector is just passed through by this function.

Normalize

native static final function Rotator Normalize (Rotator Rot)

Normalizes the components of a rotator to the range [-32768, 32767] so the rotator still represents the same orientation.

NormalizeRotAxis

native static final function int NormalizeRotAxis (int Angle)

Like Normalize(), but only for one component of a rotator value.

OrthoRotation

native static final function Rotator OrthoRotation (Vector X, Vector Y, Vector Z)

Returns a rotator value that represents the coordinate system specified by the three vector values. This is basically the inverse function of GetAxes(). Note that you can also typecast a single vector value to a rotator value with the Roll component being zero.

ProjectOnTo

native(1500) static final function Vector ProjectOnTo (Vector x, Vector y)

Projects vector X onto vector Y. The resulting vector will have the same orientation as Y, but most likely a different length and potentially point in the opposite direction if the angle between X and Y is more than 90 degrees.

RDiff

native static final function float RDiff (Rotator A, Rotator B)

Gives the rotation difference between two Rotators, taking the shortest route between them (in degrees).

VSize

native(225) static final function float VSize (Vector A)

Returns the length of the vector.

VSize2D

native static final function float VSize2D (Vector A)

Returns the length of the vector, assuming the Z component to be 0.

VSizeSq

native static final function float VSizeSq (Vector A)

Returns the squared length of the vector.

This may seem like a weird idea at first, but a vector's length is calculated via Sqrt(A dot A), so the squared length is actually easier to calculate. Comparing squared lengths always has the same result as comparing the actual lengths, so it's a valid replacement if used consistently.

VSizeSq2D

native static final function float VSizeSq2D (Vector A)

Returns the squared length of the vector, assuming the Z component to be 0.

Quaternion functions

Main article: Quaternions

QuatDot

native static final function float QuatDot (Quat A, Quat B)


QuatFindBetween

native static final function Quat QuatFindBetween (Vector A, Vector B)

Finds the quaternion that describes the smallest rotation that transforms vector A into vector B. The parameters should be unit vectors for this function to return meaningful results.

QuatFromAxisAndAngle

native static final function Quat QuatFromAxisAndAngle (Vector Axis, float Angle)

Creates a quaternion that describes a rotation of the specified angle around the given axis vector. The axis vector doesn't need to be normalized.

QuatFromRotator

native static final function Quat QuatFromRotator (Rotator A)

Converts a rotator to a quaternion so they describe the same rotation.

QuatInvert

native static final function Quat QuatInvert (Quat A)

Inverts the vector part of the quaternion, i.e. calculates the conjugate of the quaternion. This basically means the result represents a rotation of the same angle, but in the opposite direction.

QuatProduct

native static final function Quat QuatProduct (Quat A, Quat B)

Calculates the Hamilton product of the two quaternions.

Note: QuatProduct(Q1, Q2) == -QuatProduct(Q2, Q1)

QuatRotateVector

native static final function Vector QuatRotateVector (Quat A, Vector B)

Applies the rotation described by quaternion A to vector B.

QuatToRotator

native static final function Rotator QuatToRotator (Quat A)

Converts the quaternion into a rotator so they describe the same rotation.

Interpolation functions

FCubicInterp

native static final function float FCubicInterp (float P0, float T0, float P1, float T1, float A)

Cubic Spline interpolation.

Parameters:

  • P - end points
  • T - tangent directions at end points
  • Alpha - distance along spline

Returns:

evaluated value.

FInterpEaseInOut

native static final function float FInterpEaseInOut (float A, float B, float Alpha, float Exp)

Interpolates with both ease-in and ease-out (smoothly departs A, smoothly approaches B).

Parameters:

  • A - Value to interpolate from.
  • B - Value to interpolate to.
  • Alpha - Interpolant.
  • Exp - Exponent. Higher values result in more rapid acceleration adn deceleration.

Returns:

Interpolated value.

FInterpTo

native static final function float FInterpTo (float Current, float Target, float DeltaTime, float InterpSpeed)

Tries to reach Target based on distance from Current position, giving a nice smooth feeling when tracking a position. (Doesn't work well when target teleports)

Parameters:

  • Current - Actual position
  • Target - Target position
  • DeltaTime - time since last tick
  • InterpSpeed - Interpolation speed

Returns:

new interpolated position

Lerp

native(247) static final function float Lerp (float A, float B, float Alpha)

Performs linear interpolation between A and B.

QuatSlerp

native static final function Quat QuatSlerp (Quat A, Quat B, float Alpha, optional bool bShortestPath)

Performs spherical linear interpolation between the quaternions A and B.

RInterpTo

native static final function Rotator RInterpTo (Rotator Current, Rotator Target, float DeltaTime, float InterpSpeed)

Tries to reach Target based on distance from Current position, giving a nice smooth feeling when tracking a position. (Doesn't work well when target teleports)

Parameters:

  • Current - Actual position
  • Target - Target position
  • DeltaTime - time since last tick
  • InterpSpeed - Interpolation speed

Returns:

new interpolated position

RLerp

native static final function Rotator RLerp (Rotator A, Rotator B, float Alpha, optional bool bShortestPath)

Performs linear interpolation between A and B. bShortestPath should be omitted or False for interpolating rotation rates, while it should be True for interpolating orientations.

RSmerp

native static final function Rotator RSmerp (Rotator A, Rotator B, float Alpha, optional bool bShortestPath)

Performs smooth interpolation between A and B. bShortestPath should be omitted or False for interpolating rotation rates, while it should be True for interpolating orientations.

VInterpTo

native static final function Vector VInterpTo (Vector Current, Vector Target, float DeltaTime, float InterpSpeed)

Tries to reach Target based on distance from Current position, giving a nice smooth feeling when tracking a location. (Doesn't work well when target teleports)

Parameters:

  • Current - Actual location
  • Target - Target location
  • DeltaTime - time since last tick
  • InterpSpeed - Interpolation speed

Returns:

new interpolated position

VLerp

native static final function Vector VLerp (Vector A, Vector B, float Alpha)

Performs linear interpolation between A and B.

VSmerp

native static final function Vector VSmerp (Vector A, Vector B, float Alpha)

Performs smooth interpolation between A and B.

Random numbers

FRand

native(195) static final function float FRand ()

Returns a random float value between 0 and 1.

Rand

native(167) static final function int Rand (int Max)

Returns a random int value in the range 0 to Max-1. Note that the maximum effective value for Max is 0x7FFF or 32767.

RotRand

native(320) static final function Rotator RotRand (optional bool bRoll)

Returns a rotator value with random Pitch and Yaw components in the range 0 to 65535. If the parameter bRoll is True, the result's Roll component is also set to a random value in that range. Otherwise, the Roll component is set to zero.

VRand

native(252) static final function Vector VRand ()

Returns a unit vector with a random direction.

String functions

Asc

native(237) static final function int Asc (string S)

Returns the ASCII value of the first character in the specified string, or 0 if the empty string was specified.

  • Note: actually it's not ASCII value, but rather Unicode codepoint.

Caps

native(235) static final function string Caps (coerce string S)

Converts all letters in S to uppercase and returns the result.

Chr

native(236) static final function string Chr (int i)

Returns a string consisting only of the character with the specified ASCII value. Specifying 0 will result in an empty string.

  • Note: same as Asc.

InStr

native(126) static final function int InStr (coerce string S, coerce string t, optional bool bSearchFromRight)

Returns the position of the first (with bSearchFromRight specified as True: the last) occurrence of S in T or -1 if T does not contain S. This function is case-sensitive. The position of the first character is 0.

Left

native(128) static final function string Left (coerce string S, int i)

Returns the i left-most characters of S. If S has less than or equal to i characters, the entire value is returned.

Len

native(125) static final function int Len (coerce string S)

Returns the number of characters in S, i.e. the length of the string.

Localize

native static function string Localize (string SectionName, string KeyName, string PackageName)

Reads a localized string from the specified section of a localization file. The name of the localization file is given as PackageName, its extension is determined through the Language setting in the [Core.System] section of UTEngine.ini.

Locs

native(238) static final function string Locs (coerce string S)

Converts all letters in S to lowercase and returns the result.

Mid

native(127) static final function string Mid (coerce string S, int i, optional int j)

Returns up to j characters from string S, starting with the ith character. If j is omitted or greater than the number of characters after position i, all remaining characters are returned.

ParseStringIntoArray

native static final function ParseStringIntoArray (string BaseString, out array<stringPieces, string Delim, bool bCullEmpty)

Breaks up a delimited string into elements of a string array.

Parameters:

  • BaseString - The string to break up
  • Pieces - The array to fill with the string pieces
  • Delim - The string to delimit on
  • bCullEmpty - If true, empty strings are not added to the array

Repl

native(201) static final function string Repl (coerce string Src, coerce string Match, coerce string With, optional bool bCaseSensitive)

Replaces all occurrences of Match in Src with With and returns the result. Any occurrences created as a result of a replacement are ignored. By default Match is matched case-insensitively, unless bCaseSensitive is specified as True.

Right

native(234) static final function string Right (coerce string S, int i)

Returns the i right-most characters of S. If S has less than or equal to i characters, the entire value is returned.

Debugging

GetFuncName

native static final function name GetFuncName ()

Returns the current calling function's name, useful for debugging.

GetNetFuncName

native static final function name GetNetFuncName ()

Returns the name of the replicated function where script execution began, if the current script was remotely executed

IsNetScript

native static final function bool IsNetScript ()

Returns whether the current script was remotely executed (i.e. through a replicated function) NOTE: Mainly for debugging, not for general usage

IsUTracing

native static final function bool IsUTracing ()

Returns whether script function call trace logging is currently enabled.

ScriptTrace

native static final function ScriptTrace ()

Dumps the current script function stack to the log file, useful for debugging.

SetUTracing

native static final function SetUTracing (bool bShouldUTrace)

Enables/disables script function call trace logging.

Other static native functions

ClassIsChildOf

native(258) static final function bool ClassIsChildOf (Class TestClass, Class ParentClass)

Returns whether TestClass is equal to or a subclass of ParentClass. Returns False if either parameter is None.

DynamicLoadObject

native static final function Object DynamicLoadObject (string ObjectName, Class ObjectClass, optional bool MayFail)

Attempts to load an object of the specified class and with the specified name and returns it on success or Returns None on failure. If MayFail is omitted or False, a warning is logged on failure.

FindObject

native static final function Object FindObject (string ObjectName, Class ObjectClass)

Attempts to find an existing object of the specified name and class and returns it on success. Returns None if no object with that name was found or the found object has an incompatible class.

GetEnum

native static final function name GetEnum (Object E, coerce int i)

Returns the name of the ith constant in the enum E. Enums should be specified as an object literal for the first parameter. The second parameter can be any numeric or enum value. The result of this function is a name value.

This function is useful to create better log output for enum variables, because a direct typecast of the enum value to string would only result in the string representation of the enum value's index.

GetPerObjectConfigSections

native static final function bool GetPerObjectConfigSections (Class SearchClass, out array<stringout_SectionNames, optional Object ObjectOuter, optional int MaxResults)

Retrieve the names of sections which contain data for the specified PerObjectConfig class.

Parameters:

  • SearchClass - the PerObjectConfig class to retrieve sections for.
  • out_SectionNames - will receive the list of section names that correspond to PerObjectConfig sections of the specified class
  • ObjectOuter - the Outer to use for determining which file to look in. Specify the same object that is used when creating the PerObjectConfig objects that sections are being retrieved for. (PerObjectConfig data is generally stored in a file named after the Outer used when creating those objects, unless the PerObjectConfig class specifies a config file in its class declaration); specify None to use the transient package as the Outer.
  • MaxResults - the maximum number of section names to retrieve

Returns:

TRUE if the file specified was found and it contained at least 1 section for the specified class

LogInternal

native(231) final static function LogInternal (coerce string S, optional name Tag)

Writes a line to the main log file. The Tag defaults to 'ScriptLog' if omitted.

Note: You should use the `log macro instead of calling this function directly.

PathName

native static final function string PathName (Object CheckObject)

Returns the full path name of the specified object (including package and groups), ie CheckObject::GetPathName().

StaticClearConfig

native static final function StaticClearConfig (optional string PropertyName)

Deletes the config file section of this class and reloads the default values of all configurable properties. If a property name was specified, only that property's value is deleted from the config file section.

StaticSaveConfig

native static final function StaticSaveConfig ()

Writes the default values of all configurable properties of this class into the corresponding config file section. Values of properties defined as globalconfig are written to the config section of the class that originally declared that property.

TimeStamp

native static final function string TimeStamp ()

Returns a string containing a system timestamp

WarnInternal

native(232) final static function WarnInternal (coerce string S)

Writes a warning to the main log file. The warning text will have the tag "ScriptWarning" and include the object instance and function and/or state name of the WarnInternal() call.

Note: You should use the `warn macro instead of calling this function directly.