UFO: Alien Invasion
|
Artificial Intelligence for opponents or human controlled actors that are panicked. More...
#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_inventory.h"
#include "g_move.h"
#include "g_utils.h"
#include "g_vis.h"
#include "g_reaction.h"
Go to the source code of this file.
Data Structures | |
class | AiAction |
Functions | |
void | AI_Init (void) |
bool | AI_HasLineOfFire (const Actor *actor, const Edict *target) |
Check if actor has a line of fire to the target given. More... | |
static bool | AI_IsExposed (int team, Actor *check) |
Test if check is exposed to the enemy team . More... | |
static bool | AI_CheckFF (const Edict *ent, const vec3_t target, float spread, float radius) |
Check whether friendly units are in the line of fire when shooting. More... | |
bool | AI_FighterCheckShoot (const Actor *actor, const Edict *check, const fireDef_t *fd, float dist) |
Check whether the fighter should perform the shoot. More... | |
bool | AI_CheckUsingDoor (const Edict *ent, const Edict *door) |
Checks whether the AI controlled actor wants to use a door. More... | |
static bool | AI_CheckCrouch (const Actor *actor) |
Checks whether it would be smart to change the state to STATE_CROUCHED. More... | |
bool | AI_HideNeeded (const Actor *actor) |
Checks whether the given alien should try to hide because there are enemies close enough to shoot the alien. More... | |
static const Item * | AI_GetItemFromInventory (const Item *ic) |
Returns useable item from the given inventory list. That means that the 'weapon' has ammunition left or must not be reloaded. More... | |
const Item * | AI_GetItemForShootType (shoot_types_t shootType, const Edict *ent) |
int | AI_GetHidingTeam (const Edict *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 . More... | |
bool | AI_CheckPosition (const Actor *const actor, const pos3_t pos) |
Checks if the given position is safe to stand on. More... | |
bool | AI_FindHidingLocation (int team, Actor *actor, const pos3_t from, int tuLeft) |
Tries to search a hiding spot. More... | |
bool | AI_FindHerdLocation (Actor *actor, const pos3_t from, const vec3_t target, int tu, bool inverse) |
Tries to search a spot where actor will be more closer to the target and behind the target from enemy (ie hide behind target) More... | |
static Edict * | AI_SearchDestroyableObject (const Actor *actor, const fireDef_t *fd) |
bool | AI_CheckLineOfFire (const Actor *shooter, const Edict *target, const fireDef_t *fd, int shots) |
float | AI_CalcShotDamage (Actor *actor, const Actor *target, const fireDef_t *fd, shoot_types_t shotType) |
Calculate estimated damage per single shoot. More... | |
static void | AI_FindBestFiredef (AiAction *aia, Actor *actor, Actor *check, const Item *item, shoot_types_t shootType, int tu, float *maxDmg, int *bestTime, const fireDef_t *fdArray) |
bool | AI_IsHostile (const Actor *actor, const Edict *target) |
Check if actor perceives target as hostile. More... | |
const invDef_t * | AI_SearchGrenade (const Actor *actor, Item **ip) |
Search the edict's inventory for a grenade or other one-use weapon. More... | |
static bool | AI_IsHandForForShootTypeFree (shoot_types_t shootType, Actor *actor) |
Check if the hand for the given shoot type is free. More... | |
static int | AI_CheckForMissionTargets (Actor *actor, const pos3_t pos) |
Searches the map for mission edicts and try to get there. More... | |
static float | AI_FighterCalcActionScore (Actor *actor, const pos3_t to, AiAction *aia) |
static float | AI_CivilianCalcActionScore (Actor *actor, const pos3_t to, AiAction *aia) |
Calculates possible actions for a civilian. More... | |
static float | AI_PanicCalcActionScore (Actor *actor, const pos3_t to, AiAction *aia) |
Calculates possible actions for a panicking unit. More... | |
bool | AI_FindMissionLocation (Actor *actor, const pos3_t to, int tus, int radius) |
Try to go close to a mission edict. More... | |
static AiAction | AI_PrepBestAction (const Player &player, Actor *actor) |
Attempts to find the best action for an alien. Moves the alien into the starting position for that action and returns the action. More... | |
void | G_AddToWayPointList (Edict *ent) |
void | AI_TurnIntoDirection (Actor *actor, const pos3_t pos) |
This function will turn the AI actor into the direction that is needed to walk to the given location. More... | |
bool | AI_TryToReloadWeapon (Actor *actor, containerIndex_t containerID) |
if a weapon can be reloaded we attempt to do so if TUs permit, otherwise drop it More... | |
static void | AI_ActorThink (Player &player, Actor *actor) |
The think function for the ai controlled aliens or panicked humans. More... | |
void | AI_ActorRun (Player &player, Actor *actor) |
static bool | AI_TeamThink (Player &player) |
static void | AI_PlayerRun (Player &player) |
void | AI_Run (void) |
Every server frame one single actor is handled - always in the same order. More... | |
static void | AI_SetStats (Actor *actor, int team) |
Initializes the actor's stats like morals, strength and so on. More... | |
static void | AI_SetCharacterValues (Edict *ent, int team) |
Sets an actor's character values. More... | |
static void | AI_SetEquipment (Edict *ent, const equipDef_t *ed) |
Sets the actor's equipment. More... | |
static void | AI_InitPlayer (const Player &player, Actor *actor, const equipDef_t *ed) |
Initializes the actor. More... | |
static const equipDef_t * | G_GetEquipmentForAISpawn (int team) |
static Actor * | G_SpawnAIPlayer (const Player &player, const equipDef_t *ed) |
static void | G_SpawnAIPlayers (const Player &player, int numSpawn) |
Spawn civilians and aliens. More... | |
void | AI_CheckRespawn (int team) |
If the cvar g_endlessaliens is set we will endlessly respawn aliens. More... | |
Player * | AI_CreatePlayer (int team) |
Spawn civilians and aliens. More... | |
Variables | |
static pathing_t * | hidePathingTable |
static pathing_t * | herdPathingTable |
Artificial Intelligence for opponents or human controlled actors that are panicked.
Definition in file g_ai.cpp.
#define AI_ACTION_NOTHING_FOUND -10000.0f |
Definition at line 250 of file g_ai.cpp.
Referenced by AI_CheckForMissionTargets(), AI_CivilianCalcActionScore(), AI_FighterCalcActionScore(), AI_FindHidingLocation(), AI_PanicCalcActionScore(), and AI_PrepBestAction().
#define CALC_DAMAGE_SAMPLES 10.0f |
Definition at line 260 of file g_ai.cpp.
Referenced by AI_CalcShotDamage().
#define CLOSE_IN_DIST 1200.0f |
Definition at line 252 of file g_ai.cpp.
Referenced by AI_FighterCalcActionScore().
#define HERD_DIST 25 |
Definition at line 257 of file g_ai.cpp.
Referenced by AI_FindHerdLocation().
#define HERD_THRESHOLD 128.0f |
Definition at line 237 of file g_ai.cpp.
Referenced by AI_FighterCalcActionScore(), and AI_FindHerdLocation().
#define HIDE_DIST 25 |
distance for (ai) hiding in grid tiles
Definition at line 256 of file g_ai.cpp.
Referenced by AI_FindHidingLocation().
#define INVDEF_FOR_SHOOTTYPE | ( | st | ) | (IS_SHOT_RIGHT(st)?INVDEF(CID_RIGHT):IS_SHOT_LEFT(st)?INVDEF(CID_LEFT):IS_SHOT_HEADGEAR(st)?INVDEF(CID_HEADGEAR):nullptr) |
Definition at line 261 of file g_ai.cpp.
Referenced by AI_FighterCalcActionScore(), and AI_PrepBestAction().
#define LOF_CHECK_PARTITIONS 4 |
Definition at line 762 of file g_ai.cpp.
Referenced by AI_CheckLineOfFire().
#define RUN_AWAY_DIST 160 |
Definition at line 235 of file g_ai.cpp.
Referenced by AI_CheckForMissionTargets(), AI_CivilianCalcActionScore(), and AI_PanicCalcActionScore().
#define SCORE_CIV_FACTOR 0.25f |
Definition at line 228 of file g_ai.cpp.
Referenced by AI_FindBestFiredef().
#define SCORE_CIV_LAZINESS 5 |
Definition at line 234 of file g_ai.cpp.
Referenced by AI_CivilianCalcActionScore().
#define SCORE_CIV_RANDOM 10 |
Definition at line 232 of file g_ai.cpp.
Referenced by AI_CivilianCalcActionScore().
#define SCORE_CLOSE_IN 20 |
Definition at line 219 of file g_ai.cpp.
Referenced by AI_FighterCalcActionScore().
#define SCORE_DAMAGE 100.0f |
Definition at line 226 of file g_ai.cpp.
Referenced by AI_FindBestFiredef().
#define SCORE_DAMAGE_FACTOR 1.25f |
Definition at line 227 of file g_ai.cpp.
Referenced by AI_FindBestFiredef().
#define SCORE_DAMAGE_WORTH_FACTOR 0.1f |
Definition at line 230 of file g_ai.cpp.
Referenced by AI_FindBestFiredef().
#define SCORE_DISABLED_FACTOR 0.25f |
Definition at line 229 of file g_ai.cpp.
Referenced by AI_FindBestFiredef().
#define SCORE_HERDING_PENALTY 100 |
Definition at line 238 of file g_ai.cpp.
Referenced by AI_FighterCalcActionScore().
#define SCORE_HIDE 60 |
Definition at line 218 of file g_ai.cpp.
Referenced by AI_FighterCalcActionScore().
#define SCORE_KILL 30 |
Definition at line 220 of file g_ai.cpp.
Referenced by AI_FindBestFiredef().
#define SCORE_MISSION_OPPONENT_TARGET 50 |
Definition at line 241 of file g_ai.cpp.
Referenced by AI_CheckForMissionTargets().
#define SCORE_MISSION_TARGET 60 |
Definition at line 242 of file g_ai.cpp.
Referenced by AI_CheckForMissionTargets().
#define SCORE_NONHIDING_PLACE_PENALTY 25 |
Definition at line 224 of file g_ai.cpp.
Referenced by AI_CivilianCalcActionScore(), and AI_PanicCalcActionScore().
#define SCORE_NOSAFE_POSITION_PENALTY 500 |
Definition at line 239 of file g_ai.cpp.
Referenced by AI_CivilianCalcActionScore(), AI_FighterCalcActionScore(), and AI_PanicCalcActionScore().
#define SCORE_PANIC_FLEE_FROM_STRANGERS 500.0f |
Definition at line 247 of file g_ai.cpp.
Referenced by AI_PanicCalcActionScore().
#define SCORE_PANIC_RANDOM 25.0f |
Definition at line 248 of file g_ai.cpp.
Referenced by AI_PanicCalcActionScore().
#define SCORE_PANIC_RUN_TO_FRIENDS 300.0f |
Definition at line 246 of file g_ai.cpp.
Referenced by AI_PanicCalcActionScore().
#define SCORE_RAGE 40 |
Definition at line 225 of file g_ai.cpp.
Referenced by AI_FighterCalcActionScore().
#define SCORE_RANDOM 10 |
Definition at line 221 of file g_ai.cpp.
Referenced by AI_FighterCalcActionScore(), and AI_FindBestFiredef().
#define SCORE_REACTION_ERADICATION 30 |
Definition at line 222 of file g_ai.cpp.
Referenced by AI_FindBestFiredef().
#define SCORE_REACTION_FEAR_FACTOR 20 |
Definition at line 223 of file g_ai.cpp.
Referenced by AI_FighterCalcActionScore(), and AI_FindBestFiredef().
#define SCORE_RUN_AWAY 50 |
Definition at line 233 of file g_ai.cpp.
Referenced by AI_CheckForMissionTargets().
#define SPREAD_NORM | ( | x | ) | ((x) > 0 ? SPREAD_FACTOR/((x)*torad) : 0) |
#define WAYPOINT_CIV_DIST 768 |
Definition at line 236 of file g_ai.cpp.
Referenced by AI_CheckForMissionTargets().
Definition at line 1655 of file g_ai.cpp.
References AI_ActorThink(), AIL_ActorThink(), g_ailua, and cvar_s::integer.
Referenced by AI_PlayerRun(), G_MoralePanic(), and G_MoraleRage().
The think function for the ai controlled aliens or panicked humans.
[in] | player | The AI or human player object |
[in] | actor | The ai controlled edict or the human actor edict |
Definition at line 1592 of file g_ai.cpp.
References AI_CheckCrouch(), AI_PrepBestAction(), AI_TryToReloadWeapon(), AI_TurnIntoDirection(), CID_LEFT, CID_RIGHT, AiAction::fd, fireDef_s::fdIdx, G_ClientGetWeaponFromInventory(), G_ClientMove(), G_ClientShoot(), G_ClientStateChange(), G_IsDead, Edict::getLeftHandItem(), Edict::getRightHandItem(), Edict::getTeam(), Edict::hiding, Actor::isDead(), Actor::isPanicked(), Item::mustReload(), Edict::pos, AiAction::shootType, AiAction::shots, STATE_CROUCHED, AiAction::stop, AiAction::target, and AiAction::z_align.
Referenced by AI_ActorRun().
float AI_CalcShotDamage | ( | Actor * | actor, |
const Actor * | target, | ||
const fireDef_t * | fd, | ||
shoot_types_t | shotType | ||
) |
Calculate estimated damage per single shoot.
Definition at line 811 of file g_ai.cpp.
References CALC_DAMAGE_SAMPLES, shot_mock_s::civilian, shot_mock_s::damage, shot_mock_s::enemyCount, fireDef_s::fdIdx, shot_mock_s::friendCount, G_ClientShoot(), G_IsAlien, Edict::getPlayer(), fireDef_s::gravity, GROUND_DELTA, i, Actor::isInsane(), Actor::isStunned(), Edict::pos, fireDef_s::shots, and fireDef_s::splrad.
Referenced by AI_FindBestFiredef(), and AIL_GetBestShot().
|
static |
Checks whether it would be smart to change the state to STATE_CROUCHED.
[in] | actor | The AI controlled actor to chech the state change for |
Definition at line 452 of file g_ai.cpp.
References ACTOR_VIS_50, G_ActorVis(), G_EdictsGetNextLivingActor(), G_FrustumVis(), G_IsCivilian, G_IsCrouched, G_VisCheckDist(), Edict::isSameTeamAs(), Edict::origin, and VectorDist.
Referenced by AI_ActorThink().
|
static |
Check whether friendly units are in the line of fire when shooting.
[in] | ent | AI that is trying to shoot |
[in] | target | Shoot to this location |
[in] | spread | The spread of the weapon used (from fireDef) |
[in] | radius | The splash radius of the weapon |
Definition at line 322 of file g_ai.cpp.
References DotProduct, G_EdictsGetNextLivingActorOfTeam(), Edict::getTeam(), Edict::isSameAs(), Edict::origin, PLAYER_WIDTH, torad, UNIT_SIZE, VectorAdd, VectorDist, VectorNormalizeFast(), VectorScale, and VectorSubtract.
Referenced by AI_FighterCheckShoot().
Searches the map for mission edicts and try to get there.
Definition at line 1010 of file g_ai.cpp.
References AI_ACTION_NOTHING_FOUND, level_locals_s::ai_waypointList, Edict::count, ET_MISSION, G_ActorMoveLength(), G_EdictsGetNextInUse(), G_EdictsGetNextLivingActorOfTeam(), G_IsAlien, G_IsCivilian, Edict::getTeam(), Actor::getUsableTUs(), Edict::groupChain, i, Edict::inuse, length, level, oldPos, Edict::origin, level_locals_s::pathingMap, Edict::pos, Edict::radius, RUN_AWAY_DIST, SCORE_MISSION_OPPONENT_TARGET, SCORE_MISSION_TARGET, SCORE_RUN_AWAY, Edict::setOrigin(), TEAM_ALIEN, Edict::type, UNIT_SIZE, VectorCopy, VectorDist, and WAYPOINT_CIV_DIST.
Referenced by AI_CivilianCalcActionScore(), and AI_FighterCalcActionScore().
bool AI_CheckLineOfFire | ( | const Actor * | shooter, |
const Edict * | target, | ||
const fireDef_t * | fd, | ||
int | shots | ||
) |
Definition at line 763 of file g_ai.cpp.
References fireDef_s::bounce, fireDef_s::damage, trace_s::entNum, f, trace_s::fraction, G_EdictsGetByNum(), G_IsBreakable, G_IsBrushModel, G_Trace(), fireDef_s::getShotOrigin(), gi, fireDef_s::gravity, GRAVITY, GROUND_DELTA, Edict::HP, i, Actor::isCrouched(), fireDef_s::launched, LOF_CHECK_PARTITIONS, MASK_SHOT, Edict::origin, Edict::pos, fireDef_s::range, fireDef_s::rolled, fireDef_s::shots, fireDef_s::splrad, v, VectorAdd, VectorCompare, VectorCopy, VectorScale, and VectorSubtract.
Referenced by actorL_throwgrenade(), AI_FindBestFiredef(), AI_HasLineOfFire(), and AIL_GetBestShot().
Checks if the given position is safe to stand on.
true
if the actor's position is deemed safe. Definition at line 581 of file g_ai.cpp.
References Edict::dmg, Edict::dmgtype, G_ApplyProtection(), G_EdictsGetNextInUse(), Actor::isInsane(), and Edict::isSamePosAs().
Referenced by AI_CivilianCalcActionScore(), AI_FighterCalcActionScore(), AI_FindHerdLocation(), AI_FindHidingLocation(), AI_FindMissionLocation(), AI_PanicCalcActionScore(), AIL_findweapons(), AIL_positionapproach(), AIL_positionflee(), AIL_positionshoot(), and AIL_positionwander().
If the cvar g_endlessaliens is set we will endlessly respawn aliens.
Definition at line 1908 of file g_ai.cpp.
References G_AppearPerishEvent(), g_endlessaliens, G_EventActorAdd(), G_GetEquipmentForAISpawn(), G_GetPlayerForTeam(), G_SpawnAIPlayer(), G_VisToPM(), level_locals_s::initialAlienActorsSpawned, cvar_s::integer, level, level_locals_s::num_alive, PM_ALL, TEAM_ALIEN, and Edict::visflags.
Referenced by G_ClientEndRound().
Checks whether the AI controlled actor wants to use a door.
[in] | ent | The AI controlled actor |
[in] | door | The door edict |
Definition at line 396 of file g_ai.cpp.
References ACTOR_VIS_0, Edict::doorState, f, frand(), G_ActorVis(), G_EdictsGetNextLivingActor(), G_FrustumVis(), G_VisCheckDist(), Edict::getTeam(), gi, Edict::hiding, Edict::isSameTeamAs(), Edict::origin, STATE_OPENED, TEAM_ALIEN, TEAM_CIVILIAN, Edict::type, and VectorDist.
Referenced by Touch_DoorTrigger().
Calculates possible actions for a civilian.
[in] | actor | Pointer to an edict being civilian. |
[in] | to | The grid position to walk to. |
[in] | aia | Pointer to aiAction containing information about possible action. |
Definition at line 1231 of file g_ai.cpp.
References ACTOR_VIS_10, AI_ACTION_NOTHING_FOUND, AI_CheckForMissionTargets(), AI_CheckPosition(), AI_FighterCalcActionScore(), Edict::chr, frand(), G_ActorMoveLength(), G_ActorVis(), G_EdictsGetNextLivingActor(), G_IsAlien, Edict::getTeam(), Edict::getTus(), Actor::getUsableTUs(), gi, Actor::isInsane(), Actor::isPanicked(), level, Edict::origin, level_locals_s::pathingMap, Edict::pos, AiAction::reset(), ROUTING_NOT_REACHABLE, RUN_AWAY_DIST, SCORE_CIV_LAZINESS, SCORE_CIV_RANDOM, SCORE_NONHIDING_PLACE_PENALTY, SCORE_NOSAFE_POSITION_PENALTY, Edict::setOrigin(), AiAction::stop, TEAM_ALIEN, TEAM_CIVILIAN, TEAM_PHALANX, character_s::teamDef, AiAction::to, UNIT_SIZE, VectorCopy, VectorDist, and teamDef_s::weapons.
Referenced by AI_PrepBestAction().
Player* AI_CreatePlayer | ( | int | team | ) |
Spawn civilians and aliens.
[in] | team |
Definition at line 1944 of file g_ai.cpp.
References ai_multiplayeraliens, ai_numcivilians, ai_singleplayeraliens, G_IsSinglePlayer, G_PlayerGetNextAI(), G_SetTeamForPlayer(), G_SpawnAIPlayers(), game, gi, level_locals_s::initialAlienActorsSpawned, cvar_s::integer, level, level_locals_s::num_spawned, game_locals_s::players, sv_ai, and TEAM_CIVILIAN.
Referenced by G_SpawnEntities(), and SVCmd_AI_Add_f().
fill z_align values
optimize this
Definition at line 1089 of file g_ai.cpp.
References ACTOR_VIS_10, AI_ACTION_NOTHING_FOUND, AI_CheckForMissionTargets(), AI_CheckPosition(), AI_FindBestFiredef(), AI_FindHidingLocation(), AI_GetHidingTeam(), AI_GetItemForShootType(), AI_HideNeeded(), AI_IsHandForForShootTypeFree(), AI_IsHostile(), AI_SearchGrenade(), Edict::calcOrigin(), CLOSE_IN_DIST, frand(), G_ActorMoveLength(), G_ActorVis(), G_EdictsGetNextLivingActor(), G_EdictsGetNextLivingActorOfTeam(), G_IsVisibleForTeam, Item::getFiredefs(), Edict::getTeam(), Actor::getUsableTUs(), HERD_THRESHOLD, invDef_s::in, INVDEF_FOR_SHOOTTYPE, Actor::isRaged(), Edict::isSamePosAs(), Edict::isSameTeamAs(), level, Edict::origin, invDef_s::out, level_locals_s::pathingMap, Edict::pos, AiAction::reset(), ROUTING_NOT_REACHABLE, SCORE_CLOSE_IN, SCORE_HERDING_PENALTY, SCORE_HIDE, SCORE_NOSAFE_POSITION_PENALTY, SCORE_RAGE, SCORE_RANDOM, SCORE_REACTION_FEAR_FACTOR, Edict::setOrigin(), AiAction::shootType, AiAction::shots, ST_NUM_SHOOT_TYPES, ST_RIGHT, AiAction::stop, AiAction::target, AiAction::to, TU_MOVE_STRAIGHT, VectorCopy, and VectorDist.
Referenced by AI_CivilianCalcActionScore(), and AI_PrepBestAction().
bool AI_FighterCheckShoot | ( | const Actor * | actor, |
const Edict * | check, | ||
const fireDef_t * | fd, | ||
float | dist | ||
) |
Check whether the fighter should perform the shoot.
Check whether radius and power of fd are to to big for dist
Check whether the alien will die when shooting
Definition at line 364 of file g_ai.cpp.
References AI_CheckFF(), G_CalcEffectiveSpread(), Actor::isInsane(), Edict::origin, fireDef_s::range, and fireDef_s::splrad.
Referenced by actorL_throwgrenade(), AI_FindBestFiredef(), AI_SearchDestroyableObject(), and AIL_GetBestShot().
|
static |
Definition at line 831 of file g_ai.cpp.
References ACTOR_VIS_0, AI_CalcShotDamage(), AI_CheckLineOfFire(), AI_FighterCheckShoot(), AI_SearchDestroyableObject(), Item::ammoDef(), Edict::chr, CHRSH_IsTeamDefRobot(), game_import_s::csi, fireDef_s::damage, csi_s::damStunElectro, csi_s::damStunGas, Item::def(), objDef_s::dmgtype, AiAction::fd, frand(), G_ActorGetModifiedTimeForFiredef(), G_ActorVis(), G_IsCivilian, gi, fireDef_s::gravity, GROUND_DELTA, Edict::HP, Actor::isInsane(), Actor::isRaged(), Actor::isReaction(), Actor::isStunned(), fireDef_s::launched, NONE, objDef_s::numFiredefs, Edict::origin, fireDef_s::rolled, SCORE_CIV_FACTOR, SCORE_DAMAGE, SCORE_DAMAGE_FACTOR, SCORE_DAMAGE_WORTH_FACTOR, SCORE_DISABLED_FACTOR, SCORE_KILL, SCORE_RANDOM, SCORE_REACTION_ERADICATION, SCORE_REACTION_FEAR_FACTOR, AiAction::shootType, AiAction::shots, fireDef_s::spldmg, fireDef_s::splrad, AiAction::target, character_s::teamDef, VectorDist, fireDef_s::weapFdsIdx, and AiAction::z_align.
Referenced by AI_FighterCalcActionScore().
bool AI_FindHerdLocation | ( | Actor * | actor, |
const pos3_t | from, | ||
const vec3_t | target, | ||
int | tu, | ||
bool | inverse | ||
) |
Tries to search a spot where actor will be more closer to the target and behind the target from enemy (ie hide behind target)
[in] | actor | 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 |
[in] | inverse | Try to shield the target instead of using target as shield |
Definition at line 659 of file g_ai.cpp.
References AI_CheckPosition(), AI_GetHidingTeam(), Edict::calcOrigin(), DotProduct, f, G_ActorMoveLength(), G_EdictsGetNextLivingActor(), G_MoveCalcLocal(), G_TagMalloc, AiAreaSearch::getNext(), Edict::getTeam(), HERD_DIST, HERD_THRESHOLD, length, Edict::origin, PATHFINDING_HEIGHT, Edict::pos, ROUTING_NOT_REACHABLE, TAG_LEVEL, TU_MOVE_STRAIGHT, VectorCopy, VectorDistSqr, VectorNormalizeFast(), and VectorSubtract.
Referenced by AIL_positionherd().
Tries to search a hiding spot.
[out] | actor | 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 nullptr . |
[in] | team | The team from which actor tries to hide |
true
if hiding is possible, false
otherwise Definition at line 606 of file g_ai.cpp.
References AI_ACTION_NOTHING_FOUND, AI_CheckPosition(), AI_IsExposed(), Edict::calcOrigin(), G_ActorMoveLength(), G_MoveCalcLocal(), G_TagMalloc, AiAreaSearch::getNext(), HIDE_DIST, PATHFINDING_HEIGHT, Edict::pos, ROUTING_NOT_REACHABLE, TAG_LEVEL, TU_MOVE_STRAIGHT, and VectorCopy.
Referenced by AI_FighterCalcActionScore(), and AIL_positionhide().
Try to go close to a mission edict.
[in,out] | actor | The actor edict. |
[in] | to | The target position. |
[in] | tus | Available Time Units |
[in] | radius | Radius of the area to search |
true
if found a suitable position, false
otherwise Definition at line 1423 of file g_ai.cpp.
References AI_CheckPosition(), G_ActorMoveLength(), AiAreaSearch::getNext(), length, level, level_locals_s::pathingMap, Edict::pos, ROUTING_NOT_REACHABLE, VectorCompare, and VectorCopy.
Referenced by AIL_positionmission().
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 570 of file g_ai.cpp.
References G_IsCivilian, Edict::getTeam(), and TEAM_ALIEN.
Referenced by AI_FighterCalcActionScore(), AI_FindHerdLocation(), AI_HideNeeded(), AIL_positionapproach(), AIL_positionflee(), and AIL_positionhide().
const Item* AI_GetItemForShootType | ( | shoot_types_t | shootType, |
const Edict * | ent | ||
) |
Returns the item of the currently chosen shoot type of the ai actor.
shootType | The current selected shoot type |
ent | The ai actor |
nullptr
if no item was found. Definition at line 541 of file g_ai.cpp.
References AI_GetItemFromInventory(), Edict::getLeftHandItem(), Edict::getRightHandItem(), IS_SHOT_HEADGEAR, IS_SHOT_LEFT, IS_SHOT_REACTION, and IS_SHOT_RIGHT.
Referenced by AI_FighterCalcActionScore(), AI_HasLineOfFire(), AIL_GetBestShot(), and AIL_positionshoot().
Returns useable item from the given inventory list. That means that the 'weapon' has ammunition left or must not be reloaded.
ic | The inventory to search a useable weapon in. |
Definition at line 522 of file g_ai.cpp.
References Item::ammoDef(), Item::isWeapon(), and Item::mustReload().
Referenced by AI_GetItemForShootType().
Check if actor
has a line of fire to the target
given.
Definition at line 275 of file g_ai.cpp.
References AI_CheckLineOfFire(), AI_GetItemForShootType(), Item::ammoDef(), Item::getFiredefs(), objDef_s::numFiredefs, ST_NUM_SHOOT_TYPES, ST_RIGHT, and fireDef_s::weapFdsIdx.
Referenced by AI_HideNeeded(), and AI_IsExposed().
bool AI_HideNeeded | ( | const Actor * | actor | ) |
Checks whether the given alien should try to hide because there are enemies close enough to shoot the alien.
[in] | actor | The alien edict that should (maybe) hide |
true
if hide is needed or false
if the alien thinks that it is not needed Definition at line 484 of file g_ai.cpp.
References AI_GetHidingTeam(), AI_HasLineOfFire(), AI_IsHostile(), crand(), fireDef_s::damage, G_EdictsGetNextLivingActor(), G_Vis(), Item::getFiredefs(), Edict::getLeftHandItem(), Edict::getRightHandItem(), Edict::HP, cvar_s::integer, mor_brave, Edict::morale, Edict::origin, fireDef_s::range, fireDef_s::spldmg, VectorDistSqr, and VT_NOFRUSTUM.
Referenced by AI_FighterCalcActionScore(), and AIL_hideneeded().
|
static |
Initializes the actor.
[in] | player | Player to which this actor belongs. |
[in,out] | actor | Pointer to Edict representing actor. |
[in] | ed | Equipment definition for the new actor. Might be nullptr . |
Definition at line 1823 of file g_ai.cpp.
References AI_SetCharacterValues(), AI_SetEquipment(), AI_SetStats(), AIL_InitActor(), Edict::chr, CHRSH_CharGetBody(), CHRSH_CharGetHead(), frand(), G_ClientStateChange(), gi, Actor::setBody(), Actor::setHead(), and STATE_REACTION.
Referenced by G_SpawnAIPlayer().
Test if check
is exposed to the enemy team
.
Definition at line 298 of file g_ai.cpp.
References AI_HasLineOfFire(), G_EdictsGetNextLivingActor(), G_TestVis(), Edict::getTeam(), VS_YES, VT_NOFRUSTUM, and VT_PERISHCHK.
Referenced by AI_FindHidingLocation().
|
static |
Check if the hand for the given shoot type is free.
true
if shoot type uses a hand and it is free, false
if hand isn't free or shoot type doesn't use a hand. Definition at line 987 of file g_ai.cpp.
References Edict::getLeftHandItem(), Edict::getRightHandItem(), IS_SHOT_LEFT, IS_SHOT_REACTION, IS_SHOT_RIGHT, and Item::isHeldTwoHanded().
Referenced by AI_FighterCalcActionScore(), and AI_PrepBestAction().
Check if actor
perceives target
as hostile.
[in] | actor | The actor that checks for hostiles. |
[in] | target | The possible hostile actor. |
true
if actor perceives target as hostile Definition at line 933 of file g_ai.cpp.
References G_IsCivilian, G_IsMultiPlayer, Actor::isInsane(), and Edict::isOpponent().
Referenced by actorL_isvalidtarget(), actorL_throwgrenade(), AI_FighterCalcActionScore(), AI_HideNeeded(), AIL_positionflee(), and AIL_positionshoot().
Calculates possible actions for a panicking unit.
[in] | actor | Pointer to an edict which is panicking. |
[in] | to | The grid position to walk to. |
[in] | aia | Pointer to aiAction containing information about possible action. |
Definition at line 1351 of file g_ai.cpp.
References ACTOR_VIS_10, AI_ACTION_NOTHING_FOUND, AI_CheckPosition(), frand(), G_ActorMoveLength(), G_ActorVis(), G_EdictsGetNextLivingActor(), Actor::getUsableTUs(), Actor::isInsane(), Edict::isSameTeamAs(), level, Edict::origin, level_locals_s::pathingMap, Edict::pos, AiAction::reset(), ROUTING_NOT_REACHABLE, RUN_AWAY_DIST, SCORE_NONHIDING_PLACE_PENALTY, SCORE_NOSAFE_POSITION_PENALTY, SCORE_PANIC_FLEE_FROM_STRANGERS, SCORE_PANIC_RANDOM, SCORE_PANIC_RUN_TO_FRIENDS, Edict::setOrigin(), AiAction::stop, AiAction::to, UNIT_SIZE, VectorCopy, and VectorDist.
Referenced by AI_PrepBestAction().
|
static |
Duke's playground for a completely new AI. While in developement, it is only available to Phalanx
Definition at line 1672 of file g_ai.cpp.
References level_locals_s::activeTeam, AI_ActorRun(), AI_TeamThink(), AIL_TeamThink(), g_aihumans, g_ailua, G_ClientEndRound(), G_EdictsGetNextLivingActorOfTeam(), Edict::getTeam(), Edict::getTus(), cvar_s::integer, level, and TEAM_PHALANX.
Referenced by AI_Run().
Attempts to find the best action for an alien. Moves the alien into the starting position for that action and returns the action.
[in] | player | The AI player |
[in] | actor | The AI actor |
Definition at line 1458 of file g_ai.cpp.
References AI_ACTION_NOTHING_FOUND, AI_CivilianCalcActionScore(), AI_FighterCalcActionScore(), AI_IsHandForForShootTypeFree(), AI_PanicCalcActionScore(), AI_SearchGrenade(), Com_DPrintf(), DEBUG_ENGINE, G_ActorInvMove(), G_ActorMoveLength(), G_ClientMove(), G_IsCivilian, G_MoveCalc(), AiAreaSearch::getNext(), Actor::getUsableTUs(), gi, INVDEF_FOR_SHOOTTYPE, Actor::isDead(), Actor::isPanicked(), Edict::isSamePosAs(), length, level, NONE, oldPos, Edict::origin, level_locals_s::pathingMap, Edict::pos, AiAction::reset(), ROUTING_NOT_REACHABLE, AiAction::shootType, AiAction::target, AiAction::to, TU_MOVE_STRAIGHT, and VectorCopy.
Referenced by AI_ActorThink().
Every server frame one single actor is handled - always in the same order.
Definition at line 1713 of file g_ai.cpp.
References AI_PlayerRun(), level_locals_s::framenum, g_aihumans, G_PlayerGetNextActiveAI(), G_PlayerGetNextActiveHuman(), cvar_s::integer, and level.
Referenced by G_RunFrame().
Definition at line 737 of file g_ai.cpp.
References ACTOR_VIS_0, AI_FighterCheckShoot(), G_ActorVis(), G_EdictsGetNextInUse(), G_IsBreakable, and Edict::origin.
Referenced by AI_FindBestFiredef().
Search the edict's inventory for a grenade or other one-use weapon.
Definition at line 954 of file g_ai.cpp.
References Edict::chr, Item::def(), Container::def(), Inventory::getNextCont(), Container::getNextItem(), character_s::inv, Item::isWeapon(), Item::mustReload(), invDef_s::out, and Q_streq.
Referenced by actorL_throwgrenade(), AI_FighterCalcActionScore(), and AI_PrepBestAction().
Sets an actor's character values.
ent | Actor to set the model for. | |
[in] | team | Team to which actor belongs. |
Definition at line 1784 of file g_ai.cpp.
References csi_s::alienTeams, Edict::chr, game_import_s::csi, game_import_s::Cvar_String(), gi, teamDef_s::id, csi_s::numAlienTeams, TEAM_CIVILIAN, and character_s::teamDef.
Referenced by AI_InitPlayer().
|
static |
Sets the actor's equipment.
ent | Actor to give equipment to. | |
[in] | ed | Equipment definition for the new actor. |
Definition at line 1811 of file g_ai.cpp.
References ABILITY_POWER, Edict::chr, InventoryInterface::EquipActor(), game, game_locals_s::invi, teamDef_s::onlyWeapon, character_s::score, chrScoreGlobal_s::skills, and character_s::teamDef.
Referenced by AI_InitPlayer().
Initializes the actor's stats like morals, strength and so on.
actor | Actor to set the stats for. |
team | Phalanx, civilian or alien ? |
Definition at line 1738 of file g_ai.cpp.
References csi_s::alienChrTemplates, csi_s::alienTeams, BODYPART_MAXTYPE, teamDef_s::bodyTemplate, Edict::chr, CHRSH_CharGenAbilitySkills(), CHRSH_IsTeamDefAlien(), CHRSH_IsTeamDefRobot(), game_import_s::csi, f, frand(), G_ActorGiveTimeUnits(), G_IsMultiPlayer, BodyData::getRandomBodyPart(), gi, Edict::HP, character_s::HP, level_locals_s::hurtAliens, i, chrTemplate_s::id, level, character_s::morale, csi_s::numAlienTeams, BodyData::numBodyParts(), Edict::setMorale(), Edict::setStun(), TEAM_CIVILIAN, character_s::teamDef, woundInfo_s::treatmentLevel, and character_s::wounds.
Referenced by AI_InitPlayer().
|
static |
Definition at line 1666 of file g_ai.cpp.
Referenced by AI_PlayerRun().
bool AI_TryToReloadWeapon | ( | Actor * | actor, |
containerIndex_t | containerID | ||
) |
if a weapon can be reloaded we attempt to do so if TUs permit, otherwise drop it
Definition at line 1574 of file g_ai.cpp.
References Edict::chr, CID_FLOOR, G_ActorInvMove(), G_ActorReload(), G_ClientCanReload(), G_ReactionFireSettingsUpdate(), Edict::getContainer(), FiremodeSettings::getFmIdx(), FiremodeSettings::getHand(), FiremodeSettings::getWeapon(), INVDEF, NONE, and character_s::RFmode.
Referenced by AI_ActorThink(), and AIL_reload().
This function will turn the AI actor into the direction that is needed to walk to the given location.
[in] | actor | The actor to turn |
[in] | pos | The position to set the direction for |
Definition at line 1557 of file g_ai.cpp.
References CORE_DIRECTIONS, FLYING_DIRECTIONS, G_ActorDoTurn(), G_MoveCalc(), getDVdir, Edict::getTeam(), Actor::getUsableTUs(), gi, Actor::isCrouched(), level, level_locals_s::pathingMap, and ROUTING_UNREACHABLE.
Referenced by AI_ActorThink(), and pos3L_face().
Definition at line 1537 of file g_ai.cpp.
References level_locals_s::ai_waypointList, Edict::groupChain, and level.
Referenced by SP_civilian_target().
|
static |
Definition at line 1850 of file g_ai.cpp.
References game_import_s::csi, game_import_s::Cvar_String(), csi_s::eds, G_GetEquipDefByID(), gi, and TEAM_CIVILIAN.
Referenced by AI_CheckRespawn(), and G_SpawnAIPlayers().
|
static |
Definition at line 1863 of file g_ai.cpp.
References ACTOR_SIZE_NORMAL, AI_InitPlayer(), Edict::chr, G_CheckVis(), G_CheckVisTeamAll(), G_ClientGetFreeSpawnPointForActorSize(), G_TouchTriggers(), Edict::getIdNum(), Edict::getTeam(), gi, character_s::name, VT_NEW, and VT_PERISHCHK.
Referenced by AI_CheckRespawn(), and G_SpawnAIPlayers().
Spawn civilians and aliens.
[in] | player | |
[in] | numSpawn |
Definition at line 1889 of file g_ai.cpp.
References G_CheckVis(), G_GetEquipmentForAISpawn(), G_SpawnAIPlayer(), G_VisFlagsClear(), and i.
Referenced by AI_CreatePlayer().