Artificial Intelligence structures. More...
Go to the source code of this file.
Data Structures | |
struct | aiAction_t |
Defines | |
#define | GUETE_HIDE 60 |
#define | GUETE_CLOSE_IN 20 |
#define | GUETE_KILL 30 |
#define | GUETE_RANDOM 10 |
#define | GUETE_REACTION_ERADICATION 30 |
#define | GUETE_REACTION_FEAR_FACTOR 20 |
#define | GUETE_CIV_FACTOR 0.25 |
#define | GUETE_CIV_RANDOM 10 |
#define | GUETE_RUN_AWAY 50 |
#define | GUETE_CIV_LAZINESS 5 |
#define | RUN_AWAY_DIST 160 |
#define | WAYPOINT_CIV_DIST 768 |
#define | GUETE_MISSION_OPPONENT_TARGET 50 |
#define | GUETE_MISSION_TARGET 60 |
#define | AI_ACTION_NOTHING_FOUND -10000.0 |
#define | CLOSE_IN_DIST 1200.0 |
#define | SPREAD_FACTOR 8.0 |
#define | SPREAD_NORM(x) (x > 0 ? SPREAD_FACTOR/(x*torad) : 0) |
#define | HIDE_DIST 7 |
distance for (ai) hiding in grid tiles | |
#define | HERD_DIST 7 |
Functions | |
void | AI_TurnIntoDirection (edict_t *ent, const pos3_t pos) |
This function will turn the AI actor into the direction that is needed to walk to the given location. | |
qboolean | AI_FindHidingLocation (int team, edict_t *ent, const pos3_t from, int *tuLeft) |
Tries to search a hiding spot. | |
qboolean | AI_FindHerdLocation (edict_t *ent, const pos3_t from, const vec3_t target, int tu) |
Tries to search a spot where actor will be more closer to the target and behind the target from enemy. | |
int | AI_GetHidingTeam (const edict_t *ent) |
Returns the value for the vis check whenever an ai actor tries to hide. For aliens this is the inverse team - see the vis check code for the inverse team rules to see how this works. For civilians we have to specify the alien team and can't use the inverse team rules. This is needed because the inverse team rules aren't working for the civilian team - see TEAM_CIVILIAN . | |
const item_t * | AI_GetItemForShootType (shoot_types_t shootType, const edict_t *ent) |
void | AIL_ActorThink (player_t *player, edict_t *ent) |
The think function for the ai controlled aliens. | |
int | AIL_InitActor (edict_t *ent, char *type, char *subtype) |
Initializes the AI. | |
void | AIL_Cleanup (void) |
Purges all the AI from the entities. | |
void | AIL_Init (void) |
void | AIL_Shutdown (void) |
Artificial Intelligence structures.
Definition in file g_ai.h.
#define AI_ACTION_NOTHING_FOUND -10000.0 |
Definition at line 56 of file g_ai.h.
Referenced by AI_CheckForMissionTargets(), AI_CivilianCalcBestAction(), AI_FighterCalcBestAction(), and AI_PrepBestAction().
#define CLOSE_IN_DIST 1200.0 |
Definition at line 58 of file g_ai.h.
Referenced by AI_FighterCalcBestAction().
#define GUETE_CIV_FACTOR 0.25 |
Definition at line 45 of file g_ai.h.
Referenced by AI_SearchBestTarget().
#define GUETE_CIV_LAZINESS 5 |
Definition at line 49 of file g_ai.h.
Referenced by AI_CivilianCalcBestAction().
#define GUETE_CIV_RANDOM 10 |
Definition at line 47 of file g_ai.h.
Referenced by AI_CivilianCalcBestAction().
#define GUETE_CLOSE_IN 20 |
Definition at line 40 of file g_ai.h.
Referenced by AI_FighterCalcBestAction().
#define GUETE_HIDE 60 |
Definition at line 39 of file g_ai.h.
Referenced by AI_FighterCalcBestAction().
#define GUETE_KILL 30 |
Definition at line 41 of file g_ai.h.
Referenced by AI_SearchBestTarget().
#define GUETE_MISSION_OPPONENT_TARGET 50 |
Definition at line 53 of file g_ai.h.
Referenced by AI_CheckForMissionTargets().
#define GUETE_MISSION_TARGET 60 |
Definition at line 54 of file g_ai.h.
Referenced by AI_CheckForMissionTargets().
#define GUETE_RANDOM 10 |
Definition at line 42 of file g_ai.h.
Referenced by AI_SearchBestTarget().
#define GUETE_REACTION_ERADICATION 30 |
Definition at line 43 of file g_ai.h.
Referenced by AI_SearchBestTarget().
#define HERD_DIST 7 |
Definition at line 63 of file g_ai.h.
Referenced by AI_FindHerdLocation().
#define HIDE_DIST 7 |
distance for (ai) hiding in grid tiles
Definition at line 62 of file g_ai.h.
Referenced by AI_FindHidingLocation().
#define RUN_AWAY_DIST 160 |
Definition at line 50 of file g_ai.h.
Referenced by AI_CivilianCalcBestAction().
#define SPREAD_NORM | ( | x | ) | (x > 0 ? SPREAD_FACTOR/(x*torad) : 0) |
Definition at line 60 of file g_ai.h.
Referenced by AI_SearchBestTarget().
#define WAYPOINT_CIV_DIST 768 |
Definition at line 51 of file g_ai.h.
Referenced by AI_CheckForMissionTargets().
Tries to search a spot where actor will be more closer to the target and behind the target from enemy.
[in] | ent | The actor edict. |
[in] | from | The grid position the actor is (theoretically) standing at and searching the nearest location from |
[in] | target | Tries to find the nearest position to this location |
[in] | tu | The available TUs of the actor |
Definition at line 340 of file g_ai.c.
References AI_GetHidingTeam(), byte, DotProduct, G_EdictCalcOrigin(), G_EdictsGetNextLivingActorOfTeam(), G_IsCrouched, G_MoveCalcLocal(), gi, HERD_DIST, next, edict_s::origin, PATHFINDING_WIDTH, edict_s::pos, qfalse, qtrue, ROUTING_NOT_REACHABLE, VectorCompare, VectorCopy, VectorDistSqr, VectorNormalize(), and VectorSubtract.
Referenced by AIL_positionherd().
Tries to search a hiding spot.
[out] | ent | The actor edict. The position of the actor is updated here to perform visibility checks |
[in] | from | The grid position the actor is (theoretically) standing at and searching a hiding location from |
[in,out] | tuLeft | The amount of left TUs to find a hiding spot. The TUs needed to walk to the grid position is subtracted. May not be NULL . |
[in] | team | The team from which actor tries to hide |
true
if hiding is possible, false
otherwise Definition at line 295 of file g_ai.c.
References byte, G_EdictCalcOrigin(), G_IsCrouched, G_MoveCalcLocal(), G_TestVis(), gi, HIDE_DIST, PATHFINDING_WIDTH, edict_s::pos, qfalse, qtrue, ROUTING_NOT_REACHABLE, VIS_YES, VT_NOFRUSTUM, and VT_PERISH.
Referenced by AI_FighterCalcBestAction(), and AIL_positionhide().
int AI_GetHidingTeam | ( | const edict_t * | ent | ) |
Returns the value for the vis check whenever an ai actor tries to hide. For aliens this is the inverse team - see the vis check code for the inverse team rules to see how this works. For civilians we have to specify the alien team and can't use the inverse team rules. This is needed because the inverse team rules aren't working for the civilian team - see TEAM_CIVILIAN
.
Definition at line 279 of file g_ai.c.
References G_IsCivilian, edict_s::team, and TEAM_ALIEN.
Referenced by AI_FighterCalcBestAction(), AI_FindHerdLocation(), AI_HideNeeded(), and AIL_positionhide().
const item_t* AI_GetItemForShootType | ( | shoot_types_t | shootType, | |
const edict_t * | ent | |||
) |
Returns the item of the currently chosen shoot type of the ai actor.
shootType | The current selected shoot type | |
ent | The ai actor |
NULL
if no item was found. Definition at line 250 of file g_ai.c.
References AI_GetItemFromInventory(), IS_SHOT_HEADGEAR, IS_SHOT_LEFT, IS_SHOT_REACTION, IS_SHOT_RIGHT, LEFT, and RIGHT.
Referenced by actorL_shoot(), and AI_FighterCalcBestAction().
This function will turn the AI actor into the direction that is needed to walk to the given location.
[in] | aiActor | The actor to turn |
[in] | pos | The position to set the direction for |
Definition at line 927 of file g_ai.c.
References byte, CORE_DIRECTIONS, FLYING_DIRECTIONS, G_ActorDoTurn(), G_IsCrouched, G_MoveCalc(), getDVdir, gi, level, level_locals_t::pathingMap, ROUTING_UNREACHABLE, edict_s::team, and edict_s::TU.
Referenced by actorL_face(), AI_ActorThink(), and pos3L_face().
The think function for the ai controlled aliens.
[in] | player | |
[in] | ent |
Definition at line 968 of file g_ai_lua.c.
References edict_s::AI, gi, AI_s::L, lua_getglobal, lua_isstring(), lua_pcall(), and lua_tostring.
Referenced by AI_Run().
void AIL_Cleanup | ( | void | ) |
Purges all the AI from the entities.
Definition at line 1076 of file g_ai_lua.c.
References AIL_CleanupActor(), and G_EdictsGetNextActor().
Referenced by G_MatchSendResults().
void AIL_Init | ( | void | ) |
Definition at line 1057 of file g_ai_lua.c.
References gi, TEAM_ALIEN, TEAM_ALL, TEAM_CIVILIAN, and TEAM_PHALANX.
Referenced by G_Init().
int AIL_InitActor | ( | edict_t * | ent, | |
char * | type, | |||
char * | subtype | |||
) |
Initializes the AI.
[in] | ent | Pointer to actor to initialize AI for. |
[in] | type | Type of AI (Lua file name without .lua). |
[in] | subtype | Subtype of the AI. |
Definition at line 999 of file g_ai_lua.c.
References actorL_register(), edict_s::AI, AI_METATABLE, AIL_methods, byte, Com_sprintf(), gi, AI_s::L, luaL_dobuffer, luaL_newstate(), luaL_register(), MAX_VAR, pos3L_register(), Q_strncpyz(), AI_s::subtype, and AI_s::type.
Referenced by AI_InitPlayer().
void AIL_Shutdown | ( | void | ) |