129 for (
qnode_s* node = _head; node; node = next) {
133 _head = _tail =
nullptr;
145 for (
int i = 0;
i <= radius; ++
i) {
148 const int zOfsMax = std::min(std::max(static_cast<int>(origin[2]),
PATHFINDING_HEIGHT - origin[2] - 1),
i);
153 for (
int zOfs = 0; zOfs <= zOfsMax; ++zOfs) {
154 pos3_t center = {origin[0], origin[1],
static_cast<pos_t>(origin[2] + zOfs)};
158 center[2] = origin[2] - zOfs;
174 for (
int dy = 1, xOfs = 0, yOfs = radius; xOfs <= yOfs; ++xOfs, dy += 1, yOfs = radius - (dy >> 1)) {
184 if (xOfs != 0 && yOfs != 0) {
196 if (yOfs != 0 && xOfs != 0) {
206 if (origin[0] + xOfs < 0 || origin[0] + xOfs >=
PATHFINDING_WIDTH || origin[1] + dy < 0
209 const pos3_t pos = {
static_cast<pos_t>(origin[0] + xOfs), static_cast<pos_t>(origin[1] + dy), origin[2]};
213 if (!
gi.isOnMap(vec))
218 #define SCORE_HIDE 60
219 #define SCORE_CLOSE_IN 20
220 #define SCORE_KILL 30
221 #define SCORE_RANDOM 10
222 #define SCORE_REACTION_ERADICATION 30
223 #define SCORE_REACTION_FEAR_FACTOR 20
224 #define SCORE_NONHIDING_PLACE_PENALTY 25
225 #define SCORE_RAGE 40
226 #define SCORE_DAMAGE 100.0f
227 #define SCORE_DAMAGE_FACTOR 1.25f
228 #define SCORE_CIV_FACTOR 0.25f
229 #define SCORE_DISABLED_FACTOR 0.25f
230 #define SCORE_DAMAGE_WORTH_FACTOR 0.1f
232 #define SCORE_CIV_RANDOM 10
233 #define SCORE_RUN_AWAY 50
234 #define SCORE_CIV_LAZINESS 5
235 #define RUN_AWAY_DIST 160
236 #define WAYPOINT_CIV_DIST 768
237 #define HERD_THRESHOLD 128.0f
238 #define SCORE_HERDING_PENALTY 100
239 #define SCORE_NOSAFE_POSITION_PENALTY 500
241 #define SCORE_MISSION_OPPONENT_TARGET 50
242 #define SCORE_MISSION_TARGET 60
243 #define SCORE_MISSION_HOLD 25
244 #define MISSION_HOLD_DIST 96
246 #define SCORE_PANIC_RUN_TO_FRIENDS 300.0f
247 #define SCORE_PANIC_FLEE_FROM_STRANGERS 500.0f
248 #define SCORE_PANIC_RANDOM 25.0f
250 #define AI_ACTION_NOTHING_FOUND -10000.0f
252 #define CLOSE_IN_DIST 1200.0f
253 #define SPREAD_FACTOR 8.0f
254 #define SPREAD_NORM(x) ((x) > 0 ? SPREAD_FACTOR/((x)*torad) : 0)
260 #define CALC_DAMAGE_SAMPLES 10.0f
261 #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)
268 hidePathingTable =
nullptr;
269 herdPathingTable =
nullptr;
283 if (fdArray ==
nullptr)
303 Actor* from =
nullptr;
305 const int fromTeam = from->
getTeam();
306 if ((team >= 0 && fromTeam != team) || (team < 0 && fromTeam == -team))
330 const float cosSpread = cos(spread);
337 Actor* check =
nullptr;
367 if (dist > fd->
range)
375 if (dist < fd->splrad)
415 Actor* check =
nullptr;
429 const float actorVis =
G_ActorVis(check, ent,
true);
441 gi.DPrintf(
"Invalid team in AI_CheckUsingDoor: %i for ent type: %i\n", ent->
getTeam(), ent->
type);
457 Actor* check =
nullptr;
471 const float actorVis =
G_ActorVis(check, actor,
true);
489 Actor* from =
nullptr;
505 const int damage = std::max(0, damageRand);
506 if (!brave || damage >= actor->
HP / 3) {
527 const Item* item = ic;
587 Edict* check =
nullptr;
609 if (!hidePathingTable)
613 const int maxTUs = std::min(tuLeft,
HIDE_DIST * 2);
635 const int score = tuLeft - delta;
636 if (score > bestScore) {
661 if (!herdPathingTable)
665 vec_t bestLength = -1.0f;
666 Actor* next =
nullptr;
667 Actor* enemy =
nullptr;
669 const bool invTeam = team < 0;
670 team = std::abs(team);
672 if (next->
getTeam() == team ? invTeam : !invTeam)
675 if (length < bestLength || bestLength < 0.0
f) {
684 const int maxTUs = std::min(tu,
HERD_DIST * 2);
715 const float dotProd =
DotProduct(vfriend, venemy);
716 if ((inverse ? -dotProd : dotProd) > 0.5
f) {
741 Edict* check =
nullptr;
762 #define LOF_CHECK_PARTITIONS 4
773 const bool shotBreakable = hitBreakable && (fd->
shots > 1 || shots > 1)
793 at[2] += dt * (vz - 0.5f *
GRAVITY * dt);
802 if (i < LOF_CHECK_PARTITIONS)
816 for (
int i = 0;
i < shots; ++
i)
825 return mock.
damage * (
static_cast<float>(eCount) / totalCount) / shots;
833 bool hasLineOfFire =
false;
834 int shotChecked =
NONE;
841 const int shots = tu / time;
855 if (shotChecked != shotFlags) {
856 shotChecked = shotFlags;
871 else if (dmg > check->
HP)
898 *bestTime = time * shots;
916 *bestTime = time * shots;
958 const invDef_t* bestContainer =
nullptr;
959 Item* weapon =
nullptr;
962 if (cont->
def()->
out >= cost)
964 Item* item =
nullptr;
968 if (item->
isWeapon() && !item->
mustReload() && ((obj->thrown && obj->oneshot && obj->deplete)
969 ||
Q_streq(obj->type,
"grenade"))) {
971 bestContainer = cont->
def();
972 cost = bestContainer->
out;
979 return bestContainer;
992 return item ==
nullptr;
997 return left ==
nullptr && (right ==
nullptr || !right->
isHeldTwoHanded());
1013 int actionScore = 0;
1019 Edict* checkPoint =
nullptr;
1024 if (!checkPoint->
inuse)
1038 Actor* check =
nullptr;
1045 if (actionScore > bestActionScore) {
1046 bestActionScore = actionScore;
1057 Edict* mission =
nullptr;
1061 if (mission->
pos[2] != actor->
pos[2])
1064 const int distX = std::abs(actor->
pos[0] - mission->
pos[0]);
1065 const int distY = std::abs(actor->
pos[1] - mission->
pos[1]);
1066 const int dists = std::max(distX, distY);
1074 if (actionScore > bestActionScore) {
1075 bestActionScore = actionScore;
1107 Item* grenade =
nullptr;
1111 float maxDmg = 0.0f;
1112 float bestActionScore = 0.0f;
1114 Actor* check =
nullptr;
1131 if (fdArray ==
nullptr)
1135 const int invMoveCost = freeHand && grenade ? fromCont->
out + toCont->
in : 0;
1136 AI_FindBestFiredef(aia, actor, check, item, shootType, tu - invMoveCost, &maxDmg, &bestTime, fdArray);
1138 bestTime += invMoveCost;
1143 bestActionScore += maxDmg;
1144 assert(bestTime > 0);
1184 bestActionScore += move;
1190 }
else if (actor->
isRaged()) {
1197 minDist = std::min(dist, minDist);
1220 return bestActionScore;
1252 gi.DPrintf(
"AI_CivilianCalcActionScore: Error - civilian team with no teamdef\n");
1255 float minDist, minDistCivilian, minDistFighter;
1258 Actor* check =
nullptr;
1273 if (dist < minDistCivilian)
1274 minDistCivilian = dist;
1277 if (dist < minDistFighter)
1278 minDistFighter = dist;
1288 if (minDist < 8.0) {
1290 delta = 4.0 * minDist;
1291 }
else if (minDist < 16.0) {
1293 delta = 24.0 + minDist;
1294 }
else if (minDist < 24.0) {
1296 delta = 40.0 + (minDist - 16) / 4;
1301 if (minDistCivilian < 10.0)
1302 delta += (10.0 - minDistCivilian) / 3.0;
1304 if (minDistFighter < 15.0)
1305 delta += (15.0 - minDistFighter) / 5.0;
1307 if (minDistFighter < 2.0)
1311 float reactionTrap = 0.0;
1324 delta -= reactionTrap;
1325 float bestActionScore = delta;
1340 return bestActionScore;
1367 float minDistFriendly, minDistOthers;
1370 Actor* check =
nullptr;
1380 if (dist < minDistFriendly)
1381 minDistFriendly = dist;
1383 if (dist < minDistOthers)
1384 minDistOthers = dist;
1412 return bestActionScore;
1426 pos3_t bestPos = {to[0], to[1], to[2]};
1438 const int distX = std::abs(actor->
pos[0] - to[0]);
1439 const int distY = std::abs(actor->
pos[1] - to[1]);
1440 const int dist = std::max(distX, distY);
1441 if (dist < bestDist) {
1481 while (searchArea.
getNext(to)) {
1495 if (bestActionScore > best) {
1497 best = bestActionScore;
1506 bestAia.
target =
nullptr;
1527 Item* grenade =
nullptr;
1530 if (!grenade || !fromCont || !toCont || !
G_ActorInvMove(actor, fromCont, grenade, toCont,
NONE,
NONE,
true))
1531 bestAia.
target =
nullptr;
1616 while (bestAia.
shots) {
1664 #include "g_ai2.cpp"
1691 Actor* actor = player.pers.getLastActor();
1693 const int beforeTUs = actor->
getTus();
1694 if (beforeTUs > 0) {
1696 player.pers.setLastActor(actor);
1698 if (beforeTUs > actor->
getTus())
1706 player.pers.setLastActor(
nullptr);
1720 Player* player =
nullptr;
1740 const char* templateId =
"";
1758 const float random =
frand();
1759 int damage = 0, stun = 0;
1760 if (random <= 0.05
f) {
1761 damage = actor->
HP * 0.95f;
1762 }
else if (random <= 0.15
f) {
1763 stun = actor->
HP * 0.3f;
1764 damage = actor->
HP * 0.5f;
1765 }
else if (random <= 0.3
f) {
1766 stun = actor->
HP * 0.75f;
1768 actor->
HP -= damage;
1787 const char* teamDefinition;
1793 teamDefinition = td->
id;
1800 gi.GetCharacterValues(teamDefinition, &ent->
chr);
1802 gi.Error(
"Could not set teamDef for character: '%s'", teamDefinition);
1825 const int team = player.getTeam();
1842 if (
frand() < 0.75f) {
1867 gi.DPrintf(
"Not enough spawn points for team %i\n", player.getTeam());
1876 gi.DPrintf(
"Spawned ai player for team %i with entnum %i (%s)\n", actor->
getTeam(), actor->
getIdNum(), actor->
chr.
name);
1893 for (
int i = 0;
i < numSpawn;
i++) {
1918 int diff = spawned - alive;
1924 if (actor ==
nullptr)
1947 gi.DPrintf(
"AI deactivated - set sv_ai cvar to 1 to activate it\n");
1952 Player* p =
nullptr;
1972 gi.DPrintf(
"Created AI player (team %i)\n", p->getTeam());
#define SCORE_REACTION_ERADICATION
#define ST_RIGHT
The right hand should be used for shooting.
const objDef_t * onlyWeapon
bool AI_HideNeeded(const Actor *actor)
Checks whether the given alien should try to hide because there are enemies close enough to shoot the...
static void AI_SetStats(Actor *actor, int team)
Initializes the actor's stats like morals, strength and so on.
Edict * G_EdictsGetNextInUse(Edict *lastEnt)
Iterate through the entities that are in use.
float AI_CalcShotDamage(Actor *actor, const Actor *target, const fireDef_t *fd, shoot_types_t shotType)
Calculate estimated damage per single shoot.
int G_TouchTriggers(Edict *ent, const entity_type_t type)
Check the world against triggers for the current entity.
#define VectorCopy(src, dest)
const objDef_t * getWeapon() const
void G_AddToWayPointList(Edict *ent)
bool G_ClientGetWeaponFromInventory(Actor *actor)
Retrieve or collect a loaded weapon from any linked container for the actor's right hand...
void AI_Run(void)
Every server frame one single actor is handled - always in the same order.
bool isSameTeamAs(const Edict *other) const
#define SCORE_DAMAGE_WORTH_FACTOR
trace_t G_Trace(const Line &trLine, const Edict *passent, int contentmask)
collision detection - this version is more accurate and includes entity tests
#define IS_SHOT_REACTION(x)
Determine whether the selected shoot type is for reaction fire.
Player * G_PlayerGetNextActiveHuman(Player *lastPlayer)
Iterate through the list of players.
static float AI_FighterCalcActionScore(Actor *actor, const pos3_t to, AiAction *aia)
bool AIL_TeamThink(Player &player)
The team think function for the ai controlled players.
Actor * G_EdictsGetNextLivingActor(Actor *lastEnt)
Iterate through the living actor entities.
#define SCORE_MISSION_TARGET
static void AI_InitPlayer(const Player &player, Actor *actor, const equipDef_t *ed)
Initializes the actor.
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...
void getShotOrigin(const vec3_t from, const vec3_t dir, bool crouching, vec3_t shotOrigin) const
bool AI_FighterCheckShoot(const Actor *actor, const Edict *check, const fireDef_t *fd, float dist)
Check whether the fighter should perform the shoot.
void calcOrigin()
Calculate the edict's origin vector from it's grid position.
bool AI_FindHidingLocation(int team, Actor *actor, const pos3_t from, int tuLeft)
Tries to search a hiding spot.
static void G_SpawnAIPlayers(const Player &player, int numSpawn)
Spawn civilians and aliens.
#define SCORE_DISABLED_FACTOR
this is a fire definition for our weapons/ammo
void G_CheckVis(Edict *check, const vischeckflags_t visFlags)
Check if the edict appears/perishes for the other teams. If they appear for other teams...
int G_ActorDoTurn(Edict *ent, byte dir)
Turns an actor around.
const teamDef_t * teamDef
Artificial Intelligence functions.
Misc utility functions for game module.
weaponFireDefIndex_t weapFdsIdx
bool AI_CheckPosition(const Actor *const actor, const pos3_t pos)
Checks if the given position is safe to stand on.
static void AI_SetEquipment(Edict *ent, const equipDef_t *ed)
Sets the actor's equipment.
~AiAreaSearch(void)
Clear AiAreaSearch internal data.
void G_ClientStateChange(const Player &player, Actor *actor, int reqState, bool checkaction)
Changes the state of a player/soldier.
#define INVDEF_FOR_SHOOTTYPE(st)
unsigned int playermask_t
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 ac...
const fireDef_t * getFiredefs() const
Returns the firedefinitions for a given weapon/ammo.
Player * G_PlayerGetNextAI(Player *lastPlayer)
Iterate through the list of players.
bool G_SetTeamForPlayer(Player &player, const int team)
Set the used team for the given player.
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.
void G_ClientMove(const Player &player, int visTeam, Actor *actor, const pos3_t to)
Generates the client events that are send over the netchannel to move an actor.
void plotCircle(const pos3_t origin, int radius)
void G_ClientEndRound(Player &player)
const objDef_t * def(void) const
#define SCORE_HERDING_PENALTY
static pathing_t * hidePathingTable
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 invers...
bool G_ClientCanReload(Actor *actor, containerIndex_t containerID)
Returns true if actor can reload weapon.
bool AI_FindMissionLocation(Actor *actor, const pos3_t to, int tus, int radius)
Try to go close to a mission edict.
equipDef_t eds[MAX_EQUIPDEFS]
void clear(void)
Remove all data from the queue.
void setBody(unsigned int body_)
bool CHRSH_IsTeamDefAlien(const teamDef_t *const td)
Check if a team definition is alien.
bool AI_CheckUsingDoor(const Edict *ent, const Edict *door)
Checks whether the AI controlled actor wants to use a door.
#define G_IsCrouched(ent)
#define G_IsBrushModel(ent)
void VectorNormalizeFast(vec3_t v)
fast vector normalize routine that does not check to make sure that length != 0, nor does it return l...
const char * CHRSH_CharGetBody(const character_t *const chr)
Returns the body model for the soldiers for armoured and non armoured soldiers.
cvar_t * ai_singleplayeraliens
static Actor * G_SpawnAIPlayer(const Player &player, const equipDef_t *ed)
Defines all attributes of objects used in the inventory.
void G_AppearPerishEvent(playermask_t playerMask, bool appear, Edict &check, const Edict *ent)
Send the appear or perish event to the affected clients.
#define VectorScale(in, scale, out)
void G_ReactionFireSettingsUpdate(Actor *actor, fireDefIndex_t fmIdx, actorHands_t hand, const objDef_t *od)
Updates the reaction fire settings in case something was moved into a hand or from a hand that would ...
void G_VisFlagsClear(int team)
Reset the visflags for all edicts in the global list for the given team - and only for the given team...
float G_ActorVis(const Edict *ent, const Edict *check, bool full)
calculate how much check is "visible" by ent
Player & getPlayer() const
AiAreaSearch class, used to get an area of the map around a certain position for the AI to check poss...
#define SCORE_PANIC_FLEE_FROM_STRANGERS
Item * getContainer(const containerIndex_t idx) const
void G_ActorGiveTimeUnits(Actor *actor)
Set time units for the given edict. Based on speed skills.
Item * getRightHandItem() const
static int AI_CheckForMissionTargets(Actor *actor, const pos3_t pos)
Searches the map for mission edicts and try to get there.
static void AI_SetCharacterValues(Edict *ent, int team)
Sets an actor's character values.
const teamDef_t * alienTeams[MAX_TEAMS_PER_MISSION]
#define IS_SHOT_RIGHT(x)
Determine whether the selected shoot type is for the item in the right hand, either shooting or react...
#define SCORE_PANIC_RUN_TO_FRIENDS
int getUsableTUs() const
Calculates the amount of usable TUs. This is without the reserved TUs.
item instance data, with linked list capability
bool AI_CheckLineOfFire(const Actor *shooter, const Edict *target, const fireDef_t *fd, int shots)
static bool AI_CheckCrouch(const Actor *actor)
Checks whether it would be smart to change the state to STATE_CROUCHED.
~LQueue(void)
Clear LQueue internal data.
#define G_IsMultiPlayer()
void CHRSH_CharGenAbilitySkills(character_t *chr, bool multiplayer, const char *templateId)
Generates a skill and ability set for any character.
used in shot probability calculations (pseudo shots)
Player * G_PlayerGetNextActiveAI(Player *lastPlayer)
Iterate through the list of players.
#define PATHFINDING_WIDTH
absolute max
bool dequeue(pos3_t data)
Retrieve an entry form the queue.
static void AI_ActorThink(Player &player, Actor *actor)
The think function for the ai controlled aliens or panicked humans.
#define FLYING_DIRECTIONS
#define DotProduct(x, y)
Returns the distance between two 3-dimensional vectors.
Player * G_GetPlayerForTeam(int team)
Gets player for given team.
int treatmentLevel[BODYPART_MAXTYPE]
#define SCORE_REACTION_FEAR_FACTOR
#define SCORE_MISSION_OPPONENT_TARGET
fireDefIndex_t numFiredefs[MAX_WEAPONS_PER_OBJDEF]
void plotPos(const pos3_t origin, int xOfs, int yOfs)
int32_t shoot_types_t
Available shoot types - also see the ST_ constants.
QGL_EXTERN GLuint GLsizei GLsizei * length
void EquipActor(character_t *const chr, const equipDef_t *ed, const objDef_t *weapon, int maxWeight)
static Edict * AI_SearchDestroyableObject(const Actor *actor, const fireDef_t *fd)
#define G_IsCivilian(ent)
#define IS_SHOT_HEADGEAR(x)
Determine whether the selected shoot type is for the item in the headgear slot.
cvar_t * ai_multiplayeraliens
int AIL_InitActor(Actor *actor)
Initializes the lua AI for an actor.
All parts of the main game logic that are combat related.
#define IS_SHOT_LEFT(x)
Determine whether the selected shoot type is for the item in the left hand, either shooting or reacti...
const invDef_t * AI_SearchGrenade(const Actor *actor, Item **ip)
Search the edict's inventory for a grenade or other one-use weapon.
bool isOpponent(const Actor *actor) const
Check if given actor is an enemy.
static bool AI_IsExposed(int team, Actor *check)
Test if check is exposed to the enemy team.
bool isSamePosAs(const pos3_t cmpPos)
Check whether the edict is on the given position.
int G_ActorGetModifiedTimeForFiredef(const Edict *const ent, const fireDef_t *const fd, const bool reaction)
AiAreaSearch()
Initializes an AiAreaSearch object to default values.
#define G_TagMalloc(size, tag)
#define PosToVec(p, v)
Pos boundary size is +/- 128 - to get into the positive area we add the possible max negative value a...
static bool AI_TeamThink(Player &player)
byte num_alive[MAX_TEAMS]
bool CHRSH_IsTeamDefRobot(const teamDef_t *const td)
Check if a team definition is a robot.
pos_t G_ActorMoveLength(const Actor *actor, const pathing_t *path, const pos3_t to, bool stored)
Return the needed TUs to walk to a given position.
playermask_t G_VisToPM(teammask_t teamMask)
Converts vis mask to player mask.
void Com_DPrintf(int level, const char *fmt,...)
A Com_Printf that only shows up if the "developer" cvar is set.
bool AI_IsHostile(const Actor *actor, const Edict *target)
Check if actor perceives target as hostile.
const invDef_t * def() const
#define INVDEF(containerID)
const equipDef_t * G_GetEquipDefByID(const char *equipID)
Item * getNextItem(const Item *prev) const
const char * CHRSH_CharGetHead(const character_t *const chr)
Returns the head model for the soldiers for armoured and non armoured soldiers.
bool G_ActorInvMove(Actor *actor, const invDef_t *fromContType, Item *fItem, const invDef_t *toContType, int tx, int ty, bool checkaction)
Moves an item inside an inventory. Floors are handled special.
bool G_ActorReload(Actor *actor, const invDef_t *invDef)
Reload weapon with actor.
void setOrigin(const pos3_t newPos)
Set the edict's pos and origin vector to the given grid position.
#define VectorCompare(a, b)
int G_CheckVisTeamAll(const int team, const vischeckflags_t visFlags, const Edict *ent)
Do G_CheckVisTeam for all entities ent is the one that is looking at the others.
int G_TestVis(const int team, Edict *check, const vischeckflags_t flags)
test if check is visible by team (or if visibility changed?)
#define PATHFINDING_HEIGHT
15 max, adjusting above 8 will require a rewrite to the DV code
#define VectorAdd(a, b, dest)
#define G_IsSinglePlayer()
cvar_t *IMPORT const char *IMPORT * Cvar_String(const char *varName)
short numBodyParts(void) const
static float AI_PanicCalcActionScore(Actor *actor, const pos3_t to, AiAction *aia)
Calculates possible actions for a panicking unit.
#define LOF_CHECK_PARTITIONS
bool G_ClientShoot(const Player &player, Actor *actor, const pos3_t at, shoot_types_t shootType, fireDefIndex_t firemode, shot_mock_t *mock, bool allowReaction, int z_align)
Setup for shooting, either real or mock.
Actor * G_EdictsGetNextLivingActorOfTeam(Actor *lastEnt, const int team)
Iterate through the living actor entities of the given team.
float frand(void)
Return random values between 0 and 1.
#define HIDE_DIST
distance for (ai) hiding in grid tiles
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...
#define WAYPOINT_CIV_DIST
static pathing_t * herdPathingTable
const Container * getNextCont(const Container *prev, bool inclTemp=false) const
static const equipDef_t * G_GetEquipmentForAISpawn(int team)
void AI_CheckRespawn(int team)
If the cvar g_endlessaliens is set we will endlessly respawn aliens.
#define SCORE_DAMAGE_FACTOR
const BodyData * bodyTemplate
static float AI_CivilianCalcActionScore(Actor *actor, const pos3_t to, AiAction *aia)
Calculates possible actions for a civilian.
#define CALC_DAMAGE_SAMPLES
bool G_FrustumVis(const Edict *from, const vec3_t point)
Checks whether a point is "visible" from the edicts position.
functions to handle the storage and lifecycle of all edicts in the game module.
unsigned num_spawned[MAX_TEAMS]
bool G_Vis(const int team, const Edict *from, const Edict *check, const vischeckflags_t flags)
test if check is visible by from
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
bool isSameAs(const Edict *other) const
bool isHeldTwoHanded() const
float crand(void)
Return random values between -1 and 1.
const objDef_t * ammoDef(void) const
int initialAlienActorsSpawned
inventory definition for our menus
void G_EventActorAdd(playermask_t playerMask, const Edict &ent, const bool instant)
static bool AI_IsHandForForShootTypeFree(shoot_types_t shootType, Actor *actor)
Check if the hand for the given shoot type is free.
const Item * AI_GetItemForShootType(shoot_types_t shootType, const Edict *ent)
#define G_IsVisibleForTeam(ent, team)
Player * AI_CreatePlayer(int team)
Spawn civilians and aliens.
GLsizei const GLvoid * data
#define ROUTING_UNREACHABLE
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)
#define SCORE_CIV_LAZINESS
void G_MoveCalc(int team, const Actor *movingActor, const pos3_t from, int distance)
Precalculates a move table for a given team and a given starting position. This will calculate a rout...
Edict * G_EdictsGetByNum(const int num)
Get an entity by it's number.
const chrTemplate_t * alienChrTemplates[MAX_TEAMS_PER_MISSION]
actorHands_t getHand() const
void setHead(unsigned int head_)
void AI_ActorRun(Player &player, Actor *actor)
#define AI_ACTION_NOTHING_FOUND
void G_CalcEffectiveSpread(const Actor *shooter, const fireDef_t *fd, vec2_t effSpread)
Calculate the effective spread for the given actor and firemode.
#define ST_NUM_SHOOT_TYPES
Amount of shoottypes available.
void enqueue(const pos3_t data)
Add an entry to the queue.
Actor * G_ClientGetFreeSpawnPointForActorSize(const Player &player, const actorSizeEnum_t actorSize)
Searches a free spawning point for a given actor size and turns it into an actor. ...
short getRandomBodyPart(void) const
#define ACTOR_SIZE_NORMAL
#define ROUTING_NOT_REACHABLE
void plotArea(const pos3_t origin, int radius, bool flat=false)
Calculate the search area.
bool AI_HasLineOfFire(const Actor *actor, const Edict *target)
Check if actor has a line of fire to the target given.
Item * getLeftHandItem() const
QGL_EXTERN int GLboolean GLfloat * v
void AIL_ActorThink(Player &player, Actor *actor)
The think function for the ai controlled players.
static void AI_PlayerRun(Player &player)
#define VectorDistSqr(a, b)
#define SCORE_PANIC_RANDOM
int skills[SKILL_NUM_TYPES]
#define VectorSubtract(a, b, dest)
bool getNext(pos3_t pos)
Get next position in the search area.
int G_VisCheckDist(const Edict *const ent)
Interface for g_client.cpp.
static const Item * AI_GetItemFromInventory(const Item *ic)
Returns useable item from the given inventory list. That means that the 'weapon' has ammunition left ...
#define G_IsBreakable(ent)
void G_MoveCalcLocal(pathing_t *pt, int team, const Edict *movingActor, const pos3_t from, int distance)
Same as G_MoveCalc, except that it uses the pathing table passed as the first param.
int G_ApplyProtection(const Edict *target, const byte dmgWeight, int damage)
Reduces damage by armour and natural protection.
#define SCORE_NONHIDING_PLACE_PENALTY
#define SCORE_NOSAFE_POSITION_PENALTY