Character Script External Code

From Wolfire Games Wiki
Jump to: navigation, search

This is a list of the external code that is only available to be used inside a character script - variables, functions, and classes that "magically" exist.

To see a list of external code that is available to all scripts, please see this page - Common Script External Code

This list is pulled from the ~/Documents/Wolfire/Overgrowth/aschar_docs.h file. That file is automatically generated by the game, so will always be up to date. This page is manually updated, so may be slightly out of date from time to time. TODO: Add character script page and link its docs section here, similar to the LevelScripts#Documentation page section, so people can find OS-specific instructions on how to find this file.

Global Variables

ASCollisions col;  // Access collision functions
ScriptParams params;  // Access the script parameters for the current character
ReactionScriptGetter reaction_getter;  // Access to the attack reaction animation data file for the character
SphereCollision sphere_col;  // Stores results of collision functions
MovementObject this_mo;  // The current character's MovementObject instance

Constants

Types in this section that specify the base type for the enum aren't actually exposed via enums. They are defined as const instances of the base type.

Functions that take those parameters will take the base type instead. E.g. _front is actually defined in your script as an "const int _front".

"Flags" enums can be combined using a bit-wise "or" operator, optionally using a temporary variable. E.g. _ANM_FROM_START | _ANM_MIRRORED

enum AnimationFlags : uint8 {
    _ANM_FROM_START,
    _ANM_MIRRORED,
    _ANM_MOBILE,
    _ANM_SUPER_MOBILE,
    _ANM_SWAP,
};
enum AttackerDirectionType : int {
    _front,
    _left,
    _right,
};
enum AttackerHeightType : int {
    _high,
    _low,
    _medium,
};
enum CollisionSides {
    DOUBLE_SIDED,
    SINGLE_SIDED,
};
enum NavPathFlag {
    DT_STRAIGHTPATH_START,
    DT_STRAIGHTPATH_END,
    DT_STRAIGHTPATH_OFFMESH_CONNECTION,
};
enum SamplePolyFlag {
    POLYFLAGS_NONE,
    POLYFLAGS_WALK,
    POLYFLAGS_SWIM,
    POLYFLAGS_DOOR,
    POLYFLAGS_JUMP1,
    POLYFLAGS_JUMP2,
    POLYFLAGS_JUMP3,
    POLYFLAGS_JUMP4,
    POLYFLAGS_JUMP5,
    POLYFLAGS_JUMP_ALL,
    POLYFLAGS_DISABLED,
    POLYFLAGS_ALL,
};

Global Functions

float GetAnimationEventTime( string &in anim_path, string &in event_label );  // Query the time an animation event occurs in an animation
NavPoint GetNavPoint(vec3 target_pos);  // Do a navigation query to the given position
vec3 GetNavPointPos(vec3 target_pos);
// Shortcut to GetNavPoint(target_pos).GetPos(), without checking if the resulting query resulted in a valid position - warning, might return the origin!
NavPath GetPath(vec3 start, vec3 end);  // Do a navigation query (including retrieving waypoints) to a given position
NavPath GetPath(vec3 start, vec3 end, uint16 include_poly_flags, uint16 exclude_poly_flags);
// Do a navigation query (including retrieving waypoints) to a given position, allowing certain navigation types to be filtered or excluded.
// Filtering and exclusion currently just used to filter out jump nodes for non-rabbits
vec3 LineLineIntersect(vec3 start_a, vec3 end_a, vec3 start_b, vec3 end_b);
// Get closest point between two line segments
// Useful for per-poly intersection tests, for example with weapon strikes to create blood lines and detect if metal was hit
vec3 NavRaycast(vec3 start, vec3 end);  // Used for path prediction - TODO: More detail
vec3 NavRaycastSlide(vec3 start, vec3 end, int depth);  // Used for path prediction - TODO: More detail,
 and difference between slide/not slide

Classes

ASCollisions class

class ASCollisions;

Invoke collision test queries. Results are stored in the global SphereCollision sphere_col object instance.

Methods

vec3 GetSlidingCapsuleCollision(vec3 start, vec3 end, float radius);
void GetSlidingSphereCollision(vec3 pos, float radius);
void GetSlidingSphereCollisionDoubleSided(vec3 pos, float radius);
void GetScaledSphereCollision(vec3 pos, float radius, vec3 scale);
void GetScaledSpherePlantCollision(vec3 pos, float radius, vec3 scale);
void GetSlidingScaledSphereCollision(vec3 pos, float radius, vec3 scale);
void GetCylinderCollision(vec3 pos, float radius, float height);
void GetCylinderCollisionDoubleSided(vec3 pos, float radius, float height);
void GetSweptSphereCollision(const vec3 &in start, const vec3 &in end, float radius);
void GetSweptSphereCollisionCharacters(vec3 start, vec3 end, float radius);
void GetSweptCylinderCollision(vec3 start, vec3 end, float radius, float height);
void GetSweptCylinderCollisionDoubleSided(vec3 start, vec3 end, float radius, float height);
void GetSweptBoxCollision(vec3 start, vec3 end, vec3 dimensions);
void CheckRayCollisionCharacters(vec3 start, vec3 end);
vec3 GetRayCollision(vec3 start, vec3 end);
void GetObjRayCollision(vec3 start, vec3 end);
void GetPlantRayCollision(vec3 start, vec3 end);
void GetObjectsInSphere(vec3 pos, float radius);

Related Global Variables

ASCollisions col;  // The global instance of this class
SphereCollision sphere_col;  // Results of the last invoked collision method are stored here

AttackScriptGetter class

class AttackScriptGetter;

Used to query information from an attack xml file

Methods

AttackScriptGetter();  // Default constructor (reference type)
void Load(const string &in path);  // Load an attack xml file into the attack script getter (e.g. "Data/Attacks/knifeslash.xml")
string GetPath();  // Get the current specified path for this attack XML file
string GetSpecial();
string GetUnblockedAnimPath();
string GetBlockedAnimPath();
string GetThrowAnimPath();
string GetThrownAnimPath();
string GetThrownCounterAnimPath();
int IsThrow();
int GetHeight();
vec3 GetCutPlane();
int GetCutPlaneType();
bool HasCutPlane();
vec3 GetStabDir();
int GetStabDirType();
bool HasStabDir();
int GetDirection();
int GetSwapStance();
int GetSwapStanceBlocked();
int GetUnblockable();
int GetFleshUnblockable();
int GetAsLayer();
string GetAlternate();
string GetReactionPath();
string GetMaterialEvent();
vec3 GetImpactDir();
float GetBlockDamage();
float GetSharpDamage();
float GetDamage();
float GetForce();
int GetMirrored();
int GetMobile();

CollisionPoint class

class CollisionPoint;

An contact point from a collision query. There may be multiple of these for a given collision.

Properties

vec3 position;  // The position where the intersection occurred
vec3 normal;  // The surface normal at the point of intersection
vec3 custom_normal;  // TODO: What is this? I assume a secondary normal for certain objects?
int id;  // The collision id - TODO: What is this good for?
int tri;  // The index of the triangle that was intersected with - TODO: What is this good for?

Related Global Variables

ASCollisions col;  // The global instance of a class you can use to perform these collision queries
SphereCollision sphere_col;  // The global instance of a class where you can get the list of these collision points from the last collision query

NavPath class

class NavPath;

The result of a navigation query, stating whether the navigation was successful, and showing the way-points along the determined route.

Properties

bool success;  // Was the navigation query successful?

Methods

NavPath();  // Default constructor, empty of points, success set to false
NavPath(const NavPath &in other);  // Copy constructor
NavPath& opAssign(const NavPath &in other);  // Assignment operator (nav_path = other_nav_path)
int NumPoints();  // Get the number of points returned from the navigation query
vec3 GetPoint(int index);  // Get a point by index from the navigation path returned by the query
uint8 GetFlag(int index);  // Get a point's flags by index from the navigation path returned by the query

Related Global Functions

NavPath GetPath(vec3 start, vec3 end);  // Do a navigation query (including retrieving waypoints) to a given position
NavPath GetPath(vec3 start, vec3 end, uint16 include_poly_flags, uint16 exclude_poly_flags);
// Do a navigation query (including retrieving waypoints) to a given position, allowing certain navigation types to be filtered or excluded.
// Filtering and exclusion currently just used to filter out jump nodes for non-rabbits

NavPoint class

class NavPoint;

The results of a simpler nav mesh reachability query, without way-points.

Methods

void NavPoint();  // Default constructor, point is at origin, success set to false
void NavPoint(const NavPoint &in other);  // Copy constructor
NavPoint& opAssign(const NavPoint &in other);  // Assignment operator (nav_point = other_nav_point)
bool IsSuccess();  // Was the navigation query successful?
vec3 GetPoint();  // Get the target point that this navigation query was done for

Related Global Functions

NavPoint GetNavPoint(vec3 target_pos);  // Do a navigation query to the given position

ReactionScriptGetter class

class ReactionScriptGetter;

Can load a reaction xml and provide access to its data

Methods

void Load(string path);  // Load a reaction xml file (e.g. "Data/Attacks/reaction_medfront.xml")
string GetAnimPath(float severity);  // Get the specified animation path, based on the severity of reaction warrented
int GetMirrored();  // Get whether the reaction is or is not mirrored. 0 == no, 1 == yes, 2 == maybe

Related Global Variables

ReactionScriptGetter reaction_getter;  // Global instance of this class

SphereCollision class

class SphereCollision;

Stored results for the last collision test query performed.

Properties

vec3 position;  // The origin passed when invoking the collision query
vec3 adjusted_position;  // TODO: What is this? Is this if it is adjusted to be out of initial contact?
float radius;  // The radius passed when invoking the collision query

Methods

int NumContacts();  // Get the count of contacts from the last collision test
CollisionPoint GetContact(int index);  // Get the contact point with a given index from the last collision test

Related Global Variables

ASCollisions col;  // The global instance of a class you can use to perform these collision queries
SphereCollision sphere_col;  // The global instance of this class