|
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 HIDE_DIST 25 |
| #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) |
| #define SPREAD_NORM | ( | x | ) | ((x) > 0 ? SPREAD_FACTOR/((x)*torad) : 0) |
Definition at line 1655 of file g_ai.cpp.
References AI_ActorThink(), AIL_ActorThink(), g_ailua, and cvar_t::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_t::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_t::civilian, shot_mock_t::damage, shot_mock_t::enemyCount, fireDef_t::fdIdx, shot_mock_t::friendCount, G_ClientShoot(), G_IsAlien, Edict::getPlayer(), fireDef_t::gravity, GROUND_DELTA, i, Actor::isInsane(), Actor::isStunned(), Edict::pos, fireDef_t::shots, and fireDef_t::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_t::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_t::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_t::bounce, fireDef_t::damage, trace_t::entNum, trace_t::fraction, G_EdictsGetByNum(), G_IsBreakable, G_IsBrushModel, G_Trace(), fireDef_t::getShotOrigin(), gi, fireDef_t::gravity, GRAVITY, GROUND_DELTA, Edict::HP, i, Actor::isCrouched(), fireDef_t::launched, LOF_CHECK_PARTITIONS, MASK_SHOT, Edict::origin, Edict::pos, fireDef_t::range, fireDef_t::rolled, fireDef_t::shots, fireDef_t::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_t::initialAlienActorsSpawned, cvar_t::integer, level, level_locals_t::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, 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_t::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_t::teamDef, AiAction::to, UNIT_SIZE, VectorCopy, VectorDist, and teamDef_t::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_t::initialAlienActorsSpawned, cvar_t::integer, level, level_locals_t::num_spawned, game_locals_t::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_t::in, INVDEF_FOR_SHOOTTYPE, Actor::isRaged(), Edict::isSamePosAs(), Edict::isSameTeamAs(), level, Edict::origin, invDef_t::out, level_locals_t::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_t::range, and fireDef_t::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_t::csi, fireDef_t::damage, csi_t::damStunElectro, csi_t::damStunGas, Item::def(), objDef_t::dmgtype, AiAction::fd, frand(), G_ActorGetModifiedTimeForFiredef(), G_ActorVis(), G_IsCivilian, gi, fireDef_t::gravity, GROUND_DELTA, Edict::HP, Actor::isInsane(), Actor::isRaged(), Actor::isReaction(), Actor::isStunned(), fireDef_t::launched, NONE, Edict::origin, fireDef_t::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_t::spldmg, fireDef_t::splrad, AiAction::target, character_t::teamDef, VectorDist, fireDef_t::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, G_ActorMoveLength(), G_EdictsGetNextLivingActor(), G_MoveCalcLocal(), G_TagMalloc, AiAreaSearch::getNext(), Edict::getTeam(), HERD_DIST, HERD_THRESHOLD, herdPathingTable, 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, hidePathingTable, 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_t::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(), ST_NUM_SHOOT_TYPES, ST_RIGHT, and fireDef_t::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_t::damage, G_EdictsGetNextLivingActor(), G_Vis(), Item::getFiredefs(), Edict::getLeftHandItem(), Edict::getRightHandItem(), Edict::HP, cvar_t::integer, mor_brave, Edict::morale, Edict::origin, fireDef_t::range, fireDef_t::spldmg, VectorDistSqr, and VT_NOFRUSTUM.
Referenced by AI_FighterCalcActionScore(), and AIL_hideneeded().
Definition at line 266 of file g_ai.cpp.
References herdPathingTable, and hidePathingTable.
Referenced by G_Init().
|
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_t::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_t::activeTeam, AI_ActorRun(), AI_TeamThink(), AIL_TeamThink(), g_aihumans, g_ailua, G_ClientEndRound(), G_EdictsGetNextLivingActorOfTeam(), Edict::getTeam(), Edict::getTus(), cvar_t::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_t::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_t::framenum, g_aihumans, G_PlayerGetNextActiveAI(), G_PlayerGetNextActiveHuman(), cvar_t::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, Container::def(), Item::def(), objDef_t::deplete, Inventory::getNextCont(), Container::getNextItem(), character_t::inv, Item::isWeapon(), Item::mustReload(), objDef_t::oneshot, invDef_t::out, Q_streq, objDef_t::thrown, and objDef_t::type.
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_t::alienTeams, Edict::chr, game_import_t::csi, game_import_t::Cvar_String(), gi, teamDef_t::id, csi_t::numAlienTeams, TEAM_CIVILIAN, and character_t::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_t::invi, teamDef_t::onlyWeapon, character_t::score, chrScoreGlobal_t::skills, and character_t::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_t::alienChrTemplates, csi_t::alienTeams, BODYPART_MAXTYPE, teamDef_t::bodyTemplate, Edict::chr, CHRSH_CharGenAbilitySkills(), CHRSH_IsTeamDefAlien(), CHRSH_IsTeamDefRobot(), game_import_t::csi, frand(), G_ActorGiveTimeUnits(), G_IsMultiPlayer, BodyData::getRandomBodyPart(), gi, character_t::HP, Edict::HP, level_locals_t::hurtAliens, i, chrTemplate_t::id, level, character_t::morale, csi_t::numAlienTeams, BodyData::numBodyParts(), Edict::setMorale(), Edict::setStun(), TEAM_CIVILIAN, character_t::teamDef, woundInfo_t::treatmentLevel, and character_t::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_t::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_t::pathingMap, and ROUTING_UNREACHABLE.
Referenced by AI_ActorThink(), and pos3L_face().
Definition at line 1537 of file g_ai.cpp.
References level_locals_t::ai_waypointList, Edict::groupChain, and level.
Referenced by SP_civilian_target().
|
static |
Definition at line 1850 of file g_ai.cpp.
References game_import_t::csi, game_import_t::Cvar_String(), csi_t::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_t::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().
|
static |
Definition at line 264 of file g_ai.cpp.
Referenced by AI_FindHerdLocation(), and AI_Init().
|
static |
Definition at line 263 of file g_ai.cpp.
Referenced by AI_FindHidingLocation(), and AI_Init().