UFO: Alien Invasion
|
Artificial Intelligence. More...
#include "../shared/cxx.h"
#include "g_local.h"
#include "g_ai.h"
#include "g_actor.h"
#include "g_client.h"
#include "g_combat.h"
#include "g_edicts.h"
#include "g_health.h"
#include "g_move.h"
#include "g_utils.h"
#include "g_vis.h"
#include <lauxlib.h>
Go to the source code of this file.
Data Structures | |
struct | aiActor_s |
Wrapper around edict. More... | |
struct | AilSortTable< T > |
Macros | |
#define | POS3_METATABLE "pos3" |
#define | ACTOR_METATABLE "actor" |
#define | AI_METATABLE "ai" |
#define | luaL_dobuffer(L, b, n, s) (luaL_loadbuffer(L, b, n, s) || lua_pcall(L, 0, LUA_MULTRET, 0)) |
#define | AIL_invalidparameter(n) gi.DPrintf("AIL: Invalid parameter #%d in '%s'.\n", n, __func__) |
Typedefs | |
typedef struct aiActor_s | aiActor_t |
Wrapper around edict. More... | |
Enumerations | |
enum | ailVisType_t { AILVT_ALL, AILVT_SIGHT, AILVT_TEAM, AILVT_DIST } |
vis check types More... | |
enum | ailSortCritType_t { AILSC_DIST, AILSC_PATH, AILSC_HP } |
target sorting criteria (lowest first) More... | |
enum | ailShootPosType_t { AILSP_FAST, AILSP_NEAR, AILSP_FAR, AILSP_DMG } |
Shooting position types. More... | |
enum | ailWanderPosType { AILPW_RAND, AILPW_CW, AILPW_CCW } |
Functions | |
static const char * | AIL_toTeamString (const int team) |
Converts integer team representation into string. More... | |
static int | AIL_toTeamInt (const char *team, const int param) |
Converts team string into int representation. More... | |
static ailVisType_t | AIL_toVisInt (lua_State *L, const int index) |
Return visibility mode int representation from the string representation in the lua stack. More... | |
static ailSortCritType_t | AIL_toSortInt (lua_State *L, const int index) |
Return sort type int representation from the string representation in the lua stack. More... | |
static ailSortCritType_t | AIL_toDistInt (lua_State *L, const int index) |
Return distance type int representation from the string representation in the lua stack. More... | |
static ailShootPosType_t | AIL_toShotPInt (lua_State *L, const int index) |
Return shooting position type int representation from the string representation in the lua stack. More... | |
static ailWanderPosType | AIL_toWanderPInt (lua_State *L, const int index) |
Return wander position type int representation from the string representation in the lua stack. More... | |
template<typename T > | |
bool | operator< (AilSortTable< T > i, AilSortTable< T > j) |
static float | AIL_GetBestShot (const Actor &shooter, const Actor &target, const int tu, const float dist, shoot_types_t &bestType, fireDefIndex_t &bestFd, int &bestShots) |
static int | actorL_register (lua_State *L) |
Registers the actor metatable in the lua_State. More... | |
static int | lua_isactor (lua_State *L, int index) |
Checks to see if there is a actor metatable at index in the lua_State. More... | |
static aiActor_t * | lua_toactor (lua_State *L, int index) |
Returns the actor from the metatable at index. More... | |
static aiActor_t * | lua_pushactor (lua_State *L, aiActor_t *actor) |
Pushes a actor as a metatable at the top of the stack. More... | |
static int | actorL_tostring (lua_State *L) |
Pushes the actor as a string. More... | |
static int | actorL_pos (lua_State *L) |
Gets the actors position. More... | |
static int | actorL_shoot (lua_State *L) |
Shoots the actor. More... | |
static int | actorL_team (lua_State *L) |
Gets the actor's team. More... | |
static int | actorL_throwgrenade (lua_State *L) |
Throws a grenade to the actor. More... | |
static int | actorL_TU (lua_State *L) |
Gets the number of usable TU the actor has left. More... | |
static int | actorL_HP (lua_State *L) |
Gets the number of HP the actor has left. More... | |
static int | actorL_morale (lua_State *L) |
Gets the current morale of the actor onto the stack. More... | |
static int | actorL_isinjured (lua_State *L) |
Checks to see if the actor is seriously injured. More... | |
static int | actorL_isarmed (lua_State *L) |
Check if actor has weapons. More... | |
static int | actorL_isdead (lua_State *L) |
Check if the actor is dead. More... | |
static int | actorL_isvalidtarget (lua_State *L) |
Check if the actor is a valid target to attack. More... | |
static int | pos3L_register (lua_State *L) |
Registers the pos3 metatable in the lua_State. More... | |
static int | lua_ispos3 (lua_State *L, int index) |
Checks to see if there is a pos3 metatable at index in the lua_State. More... | |
static pos3_t * | lua_topos3 (lua_State *L, int index) |
Returns the pos3 from the metatable at index. More... | |
static pos3_t * | lua_pushpos3 (lua_State *L, pos3_t *pos) |
Pushes a pos3 as a metatable at the top of the stack. More... | |
static int | pos3L_tostring (lua_State *L) |
Puts the pos3 information in a string. More... | |
static int | pos3L_goto (lua_State *L) |
Makes the actor head to the position. More... | |
static int | pos3L_face (lua_State *L) |
Makes the actor face the position. More... | |
static int | pos3L_distance (lua_State *L) |
Return the distance the position an the AI actor. More... | |
static int | AIL_print (lua_State *L) |
Works more or less like Lua's builtin print. More... | |
static int | AIL_squad (lua_State *L) |
Returns a table with the actors in the current player's team. More... | |
static int | AIL_select (lua_State *L) |
Select an specific AI actor. More... | |
static int | AIL_see (lua_State *L) |
Returns what the actor can see. More... | |
static int | AIL_crouch (lua_State *L) |
Requests a crouch state (with true/false) and returns current crouch state. More... | |
static int | AIL_reactionfire (lua_State *L) |
Sets the actor's reaction fire mode. More... | |
static int | AIL_roundsleft (lua_State *L) |
Checks to see how many rounds the actor has left. More... | |
static int | AIL_canreload (lua_State *L) |
Checks to see if the actor can reload. More... | |
static int | AIL_reload (lua_State *L) |
Actor reloads his weapons. More... | |
static int | AIL_positionshoot (lua_State *L) |
Moves the actor into a position in which he can shoot his target. More... | |
static int | AIL_positionhide (lua_State *L) |
Moves the actor into a position in which he can hide. More... | |
static int | AIL_positionherd (lua_State *L) |
Determine the position where actor is closest to the target and with the target located between the actor and the nemy enemy. More... | |
static int | AIL_positionapproach (lua_State *L) |
Approach to a target actor. More... | |
static int | AIL_grabweapon (lua_State *L) |
Actor tries to grab a weapon from inventory. More... | |
static int | AIL_missiontargets (lua_State *L) |
Returns the positions of the available mission targets. More... | |
static int | AIL_waypoints (lua_State *L) |
Return the positions of the next waypoints. More... | |
static int | AIL_positionmission (lua_State *L) |
Try to find a position nearby to the given position. More... | |
static int | AIL_positionwander (lua_State *L) |
Return a new position to move to. More... | |
static int | AIL_findweapons (lua_State *L) |
Returns a table of the positions of nearby usable weapons on the floor. More... | |
static int | AIL_isfighter (lua_State *L) |
Whether the current AI actor is a fighter or not. More... | |
static int | AIL_setwaypoint (lua_State *L) |
Mark the current waypoint for a civ. More... | |
static int | AIL_difficulty (lua_State *L) |
Return the difficulty number (in case we want different AI for different ones) More... | |
static int | AIL_positionflee (lua_State *L) |
Return a position to flee to. More... | |
static int | AIL_weapontype (lua_State *L) |
Returns the type of the weapons in the actors hands. More... | |
static int | AIL_actor (lua_State *L) |
Returns the currently moving AI actor. More... | |
static int | AIL_tusforshooting (lua_State *L) |
Returns the min TUs the actor needs to fire. More... | |
static int | AIL_class (lua_State *L) |
Returns the AI actor's class. More... | |
static int | AIL_hideneeded (lua_State *L) |
Check if the actor needs wants to hide. More... | |
void | AIL_ActorThink (Player &player, Actor *actor) |
The think function for the ai controlled players. More... | |
static const char * | AIL_GetAIType (const int team) |
Return the AI type for the given team (the lua file the team actors should run) More... | |
bool | AIL_TeamThink (Player &player) |
The team think function for the ai controlled players. More... | |
static lua_State * | AIL_InitLua () |
int | AIL_InitActor (Actor *actor) |
Initializes the lua AI for an actor. More... | |
void | AIL_Init (void) |
void | AIL_Shutdown (void) |
void | AIL_Cleanup (void) |
Closes the LUA AI. More... | |
Variables | |
static lua_State * | ailState |
static Actor * | AIL_ent |
static Player * | AIL_player |
static const luaL_reg | actorL_methods [] |
static const luaL_reg | pos3L_methods [] |
static const luaL_reg | AIL_methods [] |
Artificial Intelligence.
Definition in file g_ai_lua.cpp.
#define ACTOR_METATABLE "actor" |
Actor Lua Metable name.
Definition at line 52 of file g_ai_lua.cpp.
Referenced by actorL_register(), lua_isactor(), lua_pushactor(), and lua_toactor().
#define AI_METATABLE "ai" |
#define AIL_invalidparameter | ( | n | ) | gi.DPrintf("AIL: Invalid parameter #%d in '%s'.\n", n, __func__) |
Definition at line 61 of file g_ai_lua.cpp.
Referenced by actorL_HP(), actorL_isarmed(), actorL_isdead(), actorL_isinjured(), actorL_morale(), actorL_throwgrenade(), actorL_TU(), AIL_crouch(), AIL_findweapons(), AIL_missiontargets(), AIL_positionapproach(), AIL_positionflee(), AIL_positionherd(), AIL_positionhide(), AIL_positionmission(), AIL_positionwander(), AIL_reactionfire(), AIL_reload(), AIL_see(), AIL_select(), AIL_toDistInt(), AIL_toShotPInt(), AIL_toSortInt(), AIL_toTeamInt(), AIL_toTeamString(), AIL_toVisInt(), AIL_toWanderPInt(), and AIL_waypoints().
#define luaL_dobuffer | ( | L, | |
b, | |||
n, | |||
s | |||
) | (luaL_loadbuffer(L, b, n, s) || lua_pcall(L, 0, LUA_MULTRET, 0)) |
Provides an api like luaL_dostring for buffers.
Definition at line 59 of file g_ai_lua.cpp.
Referenced by AIL_InitActor().
#define POS3_METATABLE "pos3" |
Pos3 Lua Metatable name.
Definition at line 51 of file g_ai_lua.cpp.
Referenced by lua_ispos3(), lua_pushpos3(), lua_topos3(), and pos3L_register().
enum ailShootPosType_t |
Shooting position types.
Enumerator | |
---|---|
AILSP_FAST | |
AILSP_NEAR | |
AILSP_FAR | |
AILSP_DMG |
Definition at line 80 of file g_ai_lua.cpp.
enum ailSortCritType_t |
target sorting criteria (lowest first)
Enumerator | |
---|---|
AILSC_DIST | |
AILSC_PATH | |
AILSC_HP |
Definition at line 73 of file g_ai_lua.cpp.
enum ailVisType_t |
vis check types
Enumerator | |
---|---|
AILVT_ALL | |
AILVT_SIGHT | |
AILVT_TEAM | |
AILVT_DIST |
Definition at line 65 of file g_ai_lua.cpp.
enum ailWanderPosType |
Enumerator | |
---|---|
AILPW_RAND | |
AILPW_CW | |
AILPW_CCW |
Definition at line 87 of file g_ai_lua.cpp.
|
static |
Gets the number of HP the actor has left.
Definition at line 715 of file g_ai_lua.cpp.
References aiActor_s::actor, AIL_invalidparameter, Edict::HP, lua_isactor(), and lua_toactor().
|
static |
Check if actor has weapons.
Definition at line 780 of file g_ai_lua.cpp.
References aiActor_s::actor, AIL_invalidparameter, Edict::getLeftHandItem(), Edict::getRightHandItem(), lua_isactor(), and lua_toactor().
|
static |
Check if the actor is dead.
Definition at line 799 of file g_ai_lua.cpp.
References aiActor_s::actor, AIL_invalidparameter, Actor::isDead(), lua_isactor(), and lua_toactor().
|
static |
Checks to see if the actor is seriously injured.
Definition at line 761 of file g_ai_lua.cpp.
References aiActor_s::actor, AIL_invalidparameter, Edict::chr, G_IsActorWounded(), Edict::HP, lua_isactor(), lua_toactor(), and character_s::maxHP.
|
static |
Check if the actor is a valid target to attack.
Definition at line 817 of file g_ai_lua.cpp.
References aiActor_s::actor, AI_IsHostile(), lua_isactor(), and lua_toactor().
|
static |
Gets the current morale of the actor onto the stack.
Definition at line 733 of file g_ai_lua.cpp.
References aiActor_s::actor, AIL_invalidparameter, Actor::getMorale(), cvar_s::integer, Actor::isInsane(), Actor::isPanicked(), Actor::isRaged(), lua_isactor(), lua_toactor(), and mor_brave.
|
static |
Gets the actors position.
Definition at line 511 of file g_ai_lua.cpp.
References aiActor_s::actor, lua_isactor(), lua_pushpos3(), lua_toactor(), and Edict::pos.
|
static |
Registers the actor metatable in the lua_State.
A C T O R L
[in,out] | L | State to register the metatable in. |
Definition at line 430 of file g_ai_lua.cpp.
References ACTOR_METATABLE, and actorL_methods.
Referenced by AIL_InitLua().
|
static |
Shoots the actor.
Definition at line 523 of file g_ai_lua.cpp.
References aiActor_s::actor, AIL_GetBestShot(), AIL_player, G_ClientShoot(), G_IsDead, Actor::getUsableTUs(), lua_isactor(), lua_toactor(), NONE, Edict::origin, Edict::pos, and VectorDist.
|
static |
Gets the actor's team.
Definition at line 566 of file g_ai_lua.cpp.
References aiActor_s::actor, AIL_toTeamString(), Edict::getTeam(), lua_isactor(), and lua_toactor().
|
static |
Throws a grenade to the actor.
Definition at line 580 of file g_ai_lua.cpp.
References aiActor_s::actor, AI_CheckLineOfFire(), AI_FighterCheckShoot(), AI_IsHostile(), AI_SearchGrenade(), AIL_invalidparameter, AIL_player, Item::ammoDef(), CID_LEFT, CID_MAX, CID_RIGHT, fireDef_s::fdIdx, G_ActorGetModifiedTimeForFiredef(), G_ActorInvMove(), G_ClientShoot(), G_EdictsGetNextLivingActor(), Item::getFiredefs(), Edict::getLeftHandItem(), Edict::getRightHandItem(), Actor::getUsableTUs(), INVDEF, Item::isHeldTwoHanded(), lua_isactor(), lua_toactor(), NONE, objDef_s::numFiredefs, Edict::origin, invDef_s::out, Edict::pos, fireDef_s::splrad, ST_LEFT, ST_RIGHT, UNIT_SIZE, VectorDist, and fireDef_s::weapFdsIdx.
|
static |
Pushes the actor as a string.
Definition at line 495 of file g_ai_lua.cpp.
References aiActor_s::actor, Edict::chr, Com_sprintf(), lua_isactor(), lua_toactor(), MAX_VAR, and character_s::name.
|
static |
Gets the number of usable TU the actor has left.
Definition at line 697 of file g_ai_lua.cpp.
References aiActor_s::actor, AIL_invalidparameter, Actor::getUsableTUs(), lua_isactor(), and lua_toactor().
|
static |
Returns the currently moving AI actor.
Definition at line 2053 of file g_ai_lua.cpp.
References lua_pushactor().
The think function for the ai controlled players.
[in] | player | |
[in] | actor |
Definition at line 2108 of file g_ai_lua.cpp.
References Edict::AI, AIL_player, ailState, gi, and AI_s::type.
Referenced by AI_ActorRun().
|
static |
Checks to see if the actor can reload.
Definition at line 1257 of file g_ai_lua.cpp.
References CID_LEFT, CID_RIGHT, and G_ClientCanReload().
|
static |
Returns the AI actor's class.
Definition at line 2088 of file g_ai_lua.cpp.
References Edict::AI, and AI_s::subtype.
Closes the LUA AI.
Definition at line 2308 of file g_ai_lua.cpp.
References ailState.
Referenced by G_MatchDoEnd().
|
static |
Requests a crouch state (with true/false) and returns current crouch state.
Definition at line 1191 of file g_ai_lua.cpp.
References AIL_invalidparameter, AIL_player, G_ClientStateChange(), Actor::isCrouched(), and STATE_CROUCHED.
|
static |
Return the difficulty number (in case we want different AI for different ones)
Definition at line 1969 of file g_ai_lua.cpp.
References g_difficulty, and cvar_s::value.
|
static |
Returns a table of the positions of nearby usable weapons on the floor.
Definition at line 1886 of file g_ai_lua.cpp.
References AI_CheckPosition(), AIL_invalidparameter, CID_FLOOR, CID_RIGHT, AilSortTable< T >::data, ET_ITEM, G_ActorMoveLength(), G_EdictsGetNextInUse(), G_FindPath(), Edict::getFloor(), Item::getNext(), i, INVDEF, Actor::isCrouched(), level, lua_pushpos3(), MAX_EDICTS, level_locals_s::pathingMap, Edict::pos, ROUTING_NOT_REACHABLE, AilSortTable< T >::sortLookup, and Edict::type.
|
static |
Return the AI type for the given team (the lua file the team actors should run)
Definition at line 2134 of file g_ai_lua.cpp.
References TEAM_ALIEN, TEAM_CIVILIAN, TEAM_PHALANX, and type.
Referenced by AIL_InitActor(), and AIL_TeamThink().
|
static |
Definition at line 241 of file g_ai_lua.cpp.
References AI_CalcShotDamage(), AI_CheckLineOfFire(), AI_FighterCheckShoot(), AI_GetItemForShootType(), Item::ammoDef(), G_ActorGetModifiedTimeForFiredef(), Item::getFiredefs(), fireDef_s::gravity, fireDef_s::launched, NONE, objDef_s::numFiredefs, fireDef_s::rolled, ST_NUM_SHOOT_TYPES, ST_RIGHT, and fireDef_s::weapFdsIdx.
Referenced by actorL_shoot(), and AIL_positionshoot().
|
static |
Actor tries to grab a weapon from inventory.
Definition at line 1296 of file g_ai_lua.cpp.
References G_ClientGetWeaponFromInventory().
|
static |
Check if the actor needs wants to hide.
Definition at line 2097 of file g_ai_lua.cpp.
References AI_HideNeeded().
Definition at line 2245 of file g_ai_lua.cpp.
References AILPW_CCW, AILPW_CW, AILPW_RAND, AILSC_DIST, AILSC_HP, AILSC_PATH, AILSP_DMG, AILSP_FAR, AILSP_FAST, AILSP_NEAR, ailState, AILVT_ALL, AILVT_DIST, AILVT_SIGHT, AILVT_TEAM, gi, TEAM_ALIEN, TEAM_ALL, TEAM_CIVILIAN, and TEAM_PHALANX.
Referenced by G_Init().
Initializes the lua AI for an actor.
[in] | actor | Pointer to actor to initialize AI for. |
0
on success. Definition at line 2203 of file g_ai_lua.cpp.
References Edict::AI, AIL_GetAIType(), AIL_InitLua(), ailState, Edict::chr, Com_sprintf(), Edict::getTeam(), gi, teamDef_s::id, luaL_dobuffer, MAX_VAR, Q_strncpyz(), AI_s::subtype, character_s::teamDef, and AI_s::type.
Referenced by AI_InitPlayer(), and G_ClientTeamInfo().
|
static |
Initializes a new ai lua state.
Definition at line 2185 of file g_ai_lua.cpp.
References actorL_register(), AI_METATABLE, AIL_methods, and pos3L_register().
Referenced by AIL_InitActor().
|
static |
Whether the current AI actor is a fighter or not.
Definition at line 1935 of file g_ai_lua.cpp.
References Edict::chr, teamDef_s::onlyWeapon, character_s::teamDef, and teamDef_s::weapons.
|
static |
Returns the positions of the available mission targets.
Definition at line 1595 of file g_ai_lua.cpp.
References AIL_invalidparameter, AIL_toDistInt(), AIL_toTeamInt(), AIL_toVisInt(), AILSC_DIST, AILSC_PATH, AILVT_ALL, AILVT_DIST, AILVT_SIGHT, AilSortTable< T >::data, ET_MISSION, G_EdictsGetNextInUse(), G_FindPath(), G_TestLineWithEnts(), G_VisCheckDist(), Edict::getTeam(), gi, i, level, lua_pushpos3(), MAX_EDICTS, Edict::origin, level_locals_s::pathingMap, Edict::pos, ROUTING_NOT_REACHABLE, AilSortTable< T >::sortLookup, TEAM_ALL, Edict::type, and VectorDistSqr.
|
static |
Approach to a target actor.
Definition at line 1531 of file g_ai_lua.cpp.
References AI_CheckPosition(), AI_GetHidingTeam(), AIL_invalidparameter, G_ActorMoveLength(), G_FindPath(), G_TestVis(), Actor::getUsableTUs(), gi, Actor::isCrouched(), Edict::isSamePosAs(), length, level, lua_ispos3(), lua_pushpos3(), lua_topos3(), level_locals_s::pathingMap, Edict::pos, PosSubDV, ROUTING_NOT_REACHABLE, ROUTING_UNREACHABLE, VectorCopy, VS_YES, VT_NOFRUSTUM, and VT_PERISHCHK.
|
static |
Return a position to flee to.
Definition at line 1978 of file g_ai_lua.cpp.
References AI_CheckPosition(), AI_GetHidingTeam(), AI_IsHostile(), AIL_invalidparameter, Edict::calcOrigin(), f, G_ActorMoveLength(), G_EdictsGetNextLivingActor(), G_MoveCalc(), G_TestVis(), AiAreaSearch::getNext(), Actor::getUsableTUs(), GRID_WIDTH, Actor::isPanicked(), Edict::isSameTeamAs(), level, lua_pushpos3(), oldPos, Edict::origin, PATHFINDING_HEIGHT, level_locals_s::pathingMap, Edict::pos, ROUTING_NOT_REACHABLE, Edict::setOrigin(), TU_MOVE_STRAIGHT, UNIT_SIZE, VectorCopy, VectorDist, VS_YES, VT_NOFRUSTUM, and VT_PERISHCHK.
|
static |
Determine the position where actor is closest to the target and with the target located between the actor and the nemy enemy.
target
(parameter is passed through the lua stack) The actor to which AI tries to become closer inverse
(passed through the lua stack) Try to shield the target instead of using it as shield Definition at line 1489 of file g_ai_lua.cpp.
References aiActor_s::actor, AI_FindHerdLocation(), AIL_invalidparameter, Actor::getUsableTUs(), lua_isactor(), lua_pushpos3(), lua_toactor(), Edict::origin, Edict::pos, Edict::setOrigin(), and VectorCopy.
|
static |
Moves the actor into a position in which he can hide.
team
(parameter is passed through the lua stack) means that the AI tries to find a hide position from the team
members, if parameter is empty - from any enemy Definition at line 1433 of file g_ai_lua.cpp.
References AI_FindHidingLocation(), AI_GetHidingTeam(), AIL_invalidparameter, AIL_toTeamInt(), Actor::getUsableTUs(), lua_pushpos3(), Edict::pos, Edict::setOrigin(), TEAM_ALL, and VectorCopy.
|
static |
Try to find a position nearby to the given position.
Definition at line 1761 of file g_ai_lua.cpp.
References AI_FindMissionLocation(), AIL_invalidparameter, ET_MISSION, G_GetEdictFromPos(), G_MoveCalc(), Actor::getUsableTUs(), gi, level, lua_ispos3(), lua_pushpos3(), lua_topos3(), oldPos, level_locals_s::pathingMap, Edict::pos, Edict::radius, Edict::setOrigin(), and VectorCopy.
|
static |
Moves the actor into a position in which he can shoot his target.
Definition at line 1305 of file g_ai_lua.cpp.
References aiActor_s::actor, ACTOR_VIS_10, AI_CheckPosition(), AI_GetItemForShootType(), AI_IsHostile(), AIL_ent, AIL_GetBestShot(), AIL_toShotPInt(), AILSP_DMG, AILSP_FAR, AILSP_FAST, AILSP_NEAR, G_ActorGetModifiedTimeForFiredef(), G_ActorMoveLength(), G_ActorVis(), G_IsVisibleForTeam, G_MoveCalc(), Item::getFastestFireDef(), AiAreaSearch::getNext(), Edict::getTeam(), Actor::getUsableTUs(), gi, level, lua_isactor(), lua_pushpos3(), lua_toactor(), NONE, oldPos, Edict::origin, PATHFINDING_HEIGHT, level_locals_s::pathingMap, Edict::pos, ROUTING_NOT_REACHABLE, Edict::setOrigin(), ST_LEFT, ST_RIGHT, TU_MOVE_STRAIGHT, VectorCopy, VectorDist, and VectorSet.
|
static |
Return a new position to move to.
Definition at line 1799 of file g_ai_lua.cpp.
References AI_CheckPosition(), AIL_invalidparameter, AIL_toWanderPInt(), AILPW_CCW, AILPW_CW, AILPW_RAND, AngleToDir(), Edict::dir, dvleft, dvright, f, G_ActorMoveLength(), G_MoveCalc(), AiAreaSearch::getNext(), Actor::getUsableTUs(), gi, level, lua_ispos3(), lua_pushpos3(), lua_topos3(), NONE, PATHFINDING_HEIGHT, level_locals_s::pathingMap, Edict::pos, ROUTING_NOT_REACHABLE, todeg, TU_MOVE_STRAIGHT, VectorCopy, VectorDistSqr, VectorEmpty, and VectorSubtract.
|
static |
Works more or less like Lua's builtin print.
General AI bindings.
A I L
Definition at line 1000 of file g_ai_lua.cpp.
|
static |
Sets the actor's reaction fire mode.
Definition at line 1210 of file g_ai_lua.cpp.
References AIL_invalidparameter, AIL_player, G_ClientStateChange(), Actor::isReaction(), Q_streq, and STATE_REACTION.
|
static |
Actor reloads his weapons.
Definition at line 1267 of file g_ai_lua.cpp.
References AI_TryToReloadWeapon(), AIL_invalidparameter, CID_LEFT, CID_RIGHT, and Q_streq.
|
static |
Checks to see how many rounds the actor has left.
Definition at line 1235 of file g_ai_lua.cpp.
References objDef_s::ammo, Item::def(), Item::getAmmoLeft(), Edict::getLeftHandItem(), and Edict::getRightHandItem().
|
static |
Returns what the actor can see.
Definition at line 1099 of file g_ai_lua.cpp.
References aiActor_s::actor, AIL_ent, AIL_invalidparameter, AIL_toSortInt(), AIL_toTeamInt(), AIL_toVisInt(), AILSC_DIST, AILSC_HP, AILSC_PATH, AILVT_ALL, AILVT_DIST, AILVT_SIGHT, AILVT_TEAM, AilSortTable< T >::data, G_CheckVisTeamAll(), G_EdictsGetNextLivingActor(), G_FindPath(), G_IsVisibleForTeam, G_Vis(), G_VisCheckDist(), Edict::getTeam(), gi, i, level, lua_pushactor(), MAX_EDICTS, level_locals_s::pathingMap, Edict::pos, ROUTING_NOT_REACHABLE, AilSortTable< T >::sortLookup, TEAM_ALL, VectorDistSqr, and VT_NOFRUSTUM.
|
static |
Select an specific AI actor.
Definition at line 1075 of file g_ai_lua.cpp.
References aiActor_s::actor, AIL_invalidparameter, AIL_player, g_ailua, Edict::getPlayerNum(), gi, cvar_s::integer, lua_isactor(), and lua_toactor().
|
static |
Mark the current waypoint for a civ.
Definition at line 1945 of file g_ai_lua.cpp.
References Edict::count, ET_CIVILIANTARGET, G_GetEdictFromPos(), and lua_ispos3().
|
static |
Returns a table with the actors in the current player's team.
Definition at line 1047 of file g_ai_lua.cpp.
References aiActor_s::actor, AIL_player, g_ailua, G_EdictsGetNextActor(), Edict::getPlayerNum(), gi, i, cvar_s::integer, and lua_pushactor().
bool AIL_TeamThink | ( | Player & | player | ) |
The team think function for the ai controlled players.
[in] | player |
Definition at line 2156 of file g_ai_lua.cpp.
References AIL_GetAIType(), AIL_player, AIL_toTeamString(), ailState, and gi.
Referenced by AI_PlayerRun().
|
static |
Return distance type int representation from the string representation in the lua stack.
L | The lua state to use |
index | Index on the lua stack where the string representation is stored |
Definition at line 167 of file g_ai_lua.cpp.
References AIL_invalidparameter, AILSC_DIST, and gi.
Referenced by AIL_missiontargets(), AIL_waypoints(), and pos3L_distance().
|
static |
Return shooting position type int representation from the string representation in the lua stack.
L | The lua state to use |
index | Index on the lua stack where the string representation is stored |
Definition at line 185 of file g_ai_lua.cpp.
References AIL_invalidparameter, AILSP_FAST, and gi.
Referenced by AIL_positionshoot().
|
static |
Return sort type int representation from the string representation in the lua stack.
L | The lua state to use |
index | Index on the lua stack where the string representation is stored |
Definition at line 149 of file g_ai_lua.cpp.
References AIL_invalidparameter, AILSC_DIST, and gi.
Referenced by AIL_see().
Converts team string into int representation.
team | The team to convert (alien, phalanx, civilian, ...) |
param | parameter index for the Lua error message |
Definition at line 117 of file g_ai_lua.cpp.
References AIL_invalidparameter, gi, and TEAM_DEFAULT.
Referenced by AIL_missiontargets(), AIL_positionhide(), and AIL_see().
|
static |
Converts integer team representation into string.
team | The team to convert to the string representation |
Definition at line 102 of file g_ai_lua.cpp.
References AIL_invalidparameter, game_import_s::GetConstVariable(), and gi.
Referenced by actorL_team(), and AIL_TeamThink().
|
static |
Return visibility mode int representation from the string representation in the lua stack.
L | The lua state to use |
index | Index on the lua stack where the string representation is stored |
Definition at line 131 of file g_ai_lua.cpp.
References AIL_invalidparameter, AILVT_ALL, and gi.
Referenced by AIL_missiontargets(), and AIL_see().
|
static |
Return wander position type int representation from the string representation in the lua stack.
L | The lua state to use |
index | Index on the lua stack where the string representation is stored |
Definition at line 203 of file g_ai_lua.cpp.
References AIL_invalidparameter, AILPW_RAND, and gi.
Referenced by AIL_positionwander().
|
static |
Returns the min TUs the actor needs to fire.
Definition at line 2062 of file g_ai_lua.cpp.
References Item::getFastestFireDef(), Edict::getLeftHandItem(), Edict::getRightHandItem(), and fireDef_s::time.
|
static |
Return the positions of the next waypoints.
Definition at line 1678 of file g_ai_lua.cpp.
References level_locals_s::ai_waypointList, AIL_invalidparameter, AIL_toDistInt(), AILSC_DIST, AILSC_PATH, Edict::count, AilSortTable< T >::data, G_EdictsGetNextLivingActorOfTeam(), G_FindPath(), Edict::getTeam(), gi, Edict::groupChain, i, level, lua_pushpos3(), MAX_EDICTS, Edict::origin, level_locals_s::pathingMap, Edict::pos, ROUTING_NOT_REACHABLE, AilSortTable< T >::sortLookup, TEAM_ALIEN, TU_MOVE_STRAIGHT, UNIT_SIZE, and VectorDist.
|
static |
Returns the type of the weapons in the actors hands.
Definition at line 2039 of file g_ai_lua.cpp.
References Item::def(), Edict::getLeftHandItem(), Edict::getRightHandItem(), and objDef_s::type.
Checks to see if there is a actor metatable at index in the lua_State.
[in,out] | L | Lua state to check. |
[in] | index | Index to check for a actor metatable. |
Definition at line 454 of file g_ai_lua.cpp.
References ACTOR_METATABLE.
Referenced by actorL_HP(), actorL_isarmed(), actorL_isdead(), actorL_isinjured(), actorL_isvalidtarget(), actorL_morale(), actorL_pos(), actorL_shoot(), actorL_team(), actorL_throwgrenade(), actorL_tostring(), actorL_TU(), AIL_positionherd(), AIL_positionshoot(), AIL_select(), and lua_toactor().
Checks to see if there is a pos3 metatable at index in the lua_State.
[in] | L | Lua state to check. |
[in] | index | Index to check for a pos3 metatable. |
Definition at line 861 of file g_ai_lua.cpp.
References POS3_METATABLE.
Referenced by AIL_positionapproach(), AIL_positionmission(), AIL_positionwander(), AIL_setwaypoint(), lua_topos3(), pos3L_distance(), pos3L_face(), pos3L_goto(), and pos3L_tostring().
Pushes a actor as a metatable at the top of the stack.
Definition at line 483 of file g_ai_lua.cpp.
References ACTOR_METATABLE.
Referenced by AIL_actor(), AIL_see(), and AIL_squad().
Pushes a pos3 as a metatable at the top of the stack.
Definition at line 890 of file g_ai_lua.cpp.
References POS3_METATABLE.
Referenced by actorL_pos(), AIL_findweapons(), AIL_missiontargets(), AIL_positionapproach(), AIL_positionflee(), AIL_positionherd(), AIL_positionhide(), AIL_positionmission(), AIL_positionshoot(), AIL_positionwander(), and AIL_waypoints().
Returns the actor from the metatable at index.
Definition at line 471 of file g_ai_lua.cpp.
References ACTOR_METATABLE, and lua_isactor().
Referenced by actorL_HP(), actorL_isarmed(), actorL_isdead(), actorL_isinjured(), actorL_isvalidtarget(), actorL_morale(), actorL_pos(), actorL_shoot(), actorL_team(), actorL_throwgrenade(), actorL_tostring(), actorL_TU(), AIL_positionherd(), AIL_positionshoot(), and AIL_select().
Returns the pos3 from the metatable at index.
Definition at line 878 of file g_ai_lua.cpp.
References lua_ispos3(), and POS3_METATABLE.
Referenced by AIL_positionapproach(), AIL_positionmission(), AIL_positionwander(), pos3L_distance(), pos3L_face(), pos3L_goto(), and pos3L_tostring().
bool operator< | ( | AilSortTable< T > | i, |
AilSortTable< T > | j | ||
) |
Definition at line 231 of file g_ai_lua.cpp.
References i.
|
static |
Return the distance the position an the AI actor.
Definition at line 961 of file g_ai_lua.cpp.
References AIL_toDistInt(), AILSC_DIST, AILSC_PATH, G_ActorMoveLength(), G_FindPath(), Actor::isCrouched(), level, lua_ispos3(), lua_topos3(), Edict::origin, level_locals_s::pathingMap, Edict::pos, PosToVec, ROUTING_NOT_REACHABLE, and VectorDist.
|
static |
Makes the actor face the position.
Definition at line 947 of file g_ai_lua.cpp.
References AI_TurnIntoDirection(), lua_ispos3(), and lua_topos3().
|
static |
Makes the actor head to the position.
Definition at line 918 of file g_ai_lua.cpp.
References AIL_player, G_ActorMoveLength(), G_ClientMove(), G_MoveCalc(), Actor::getUsableTUs(), gi, Actor::isDead(), Edict::isSamePosAs(), length, level, lua_ispos3(), lua_topos3(), level_locals_s::pathingMap, Edict::pos, and ROUTING_NOT_REACHABLE.
|
static |
Registers the pos3 metatable in the lua_State.
pos3 metatable.
P O S 3 L
[in] | L | State to register the metatable in. |
Definition at line 837 of file g_ai_lua.cpp.
References POS3_METATABLE, and pos3L_methods.
Referenced by AIL_InitLua().
|
static |
Puts the pos3 information in a string.
Definition at line 902 of file g_ai_lua.cpp.
References Com_sprintf(), lua_ispos3(), lua_topos3(), and MAX_VAR.
|
static |
Lua Actor metatable methods. http://www.lua.org/manual/5.1/manual.html#lua_CFunction
Definition at line 312 of file g_ai_lua.cpp.
Referenced by actorL_register().
|
static |
Actor currently running the Lua AI.
Definition at line 238 of file g_ai_lua.cpp.
Referenced by AIL_positionshoot(), and AIL_see().
|
static |
Lua AI module methods. http://www.lua.org/manual/5.1/manual.html#lua_CFunction
Definition at line 388 of file g_ai_lua.cpp.
Referenced by AIL_InitLua().
|
static |
Player currently running the Lua AI.
Definition at line 239 of file g_ai_lua.cpp.
Referenced by actorL_shoot(), actorL_throwgrenade(), AIL_ActorThink(), AIL_crouch(), AIL_reactionfire(), AIL_select(), AIL_squad(), AIL_TeamThink(), and pos3L_goto().
|
static |
Definition at line 55 of file g_ai_lua.cpp.
Referenced by AIL_ActorThink(), AIL_Cleanup(), AIL_Init(), AIL_InitActor(), and AIL_TeamThink().
|
static |
Lua Pos3 metatable methods. http://www.lua.org/manual/5.1/manual.html#lua_CFunction
Definition at line 344 of file g_ai_lua.cpp.
Referenced by pos3L_register().