UFO: Alien Invasion
Loading...
Searching...
No Matches
g_ai.h
Go to the documentation of this file.
1
5
6/*
7Copyright (C) 2002-2025 UFO: Alien Invasion.
8
9This program is free software; you can redistribute it and/or
10modify it under the terms of the GNU General Public License
11as published by the Free Software Foundation; either version 2
12of the License, or (at your option) any later version.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
18See the GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
24*/
25
26#pragma once
27
28#include "g_local.h"
29
34public:
36 AiAreaSearch(const pos3_t origin, int radius, bool flat = false);
37 ~AiAreaSearch(void);
38 bool getNext(pos3_t pos);
39private:
43 class LQueue {
44 public:
49 ~LQueue(void);
50 void enqueue(const pos3_t data);
51 bool dequeue(pos3_t data);
55 int size(void) const { return _count; }
59 bool isEmpty(void) const { return size() < 1; }
60 void clear(void);
61 private:
68 int _count;
69 };
71 void plotArea(const pos3_t origin, int radius, bool flat = false);
72 void plotCircle(const pos3_t origin, int radius);
73 void plotPos(const pos3_t origin, int xOfs, int yOfs);
74};
75
76/*
77 * AI functions
78 */
79void AI_Init(void);
80void AI_CheckRespawn(int team);
82void G_AddToWayPointList(Edict* ent);
83void AI_Run(void);
84void AI_ActorRun(Player& player, Actor* actor);
85Player* AI_CreatePlayer(int team);
86bool AI_CheckUsingDoor(const Edict* ent, const Edict* door);
87
88/*
89 * Shared functions (between C AI and LUA AI)
90 */
91bool AI_HasLineOfFire (const Actor* actor, const Edict* target);
92void AI_TurnIntoDirection(Actor* actor, const pos3_t pos);
93bool AI_FindHidingLocation(int team, Actor* actor, const pos3_t from, int tuLeft);
94bool AI_FindHerdLocation(Actor* actor, const pos3_t from, const vec3_t target, int tu, bool inverse);
95int AI_GetHidingTeam(const Edict* ent);
96const Item* AI_GetItemForShootType(shoot_types_t shootType, const Edict* ent);
97bool AI_FighterCheckShoot(const Actor* actor, const Edict* check, const fireDef_t* fd, float dist);
98bool AI_CheckLineOfFire(const Actor* shooter, const Edict* target, const fireDef_t* fd, int shots);
99float AI_CalcShotDamage(Actor* actor, const Actor* target, const fireDef_t* fd, shoot_types_t shotType);
100bool AI_TryToReloadWeapon(Actor* actor, containerIndex_t containerID);
101bool AI_IsHostile(const Actor* actor, const Edict* target);
102const invDef_t* AI_SearchGrenade(const Actor* actor, Item** ip);
103bool AI_FindMissionLocation(Actor* actor, const pos3_t to, int tus, int radius = 0);
104bool AI_CheckPosition(const Actor* const ent, const pos3_t pos);
105bool AI_HideNeeded(const Actor* actor);
106
107/*
108 * LUA functions
109 */
110bool AIL_TeamThink(Player& player);
111void AIL_ActorThink(Player& player, Actor* actor);
112int AIL_InitActor(Actor* actor);
113void AIL_Cleanup(void);
114void AIL_Init(void);
115void AIL_Shutdown(void);
An Edict of type Actor.
Definition g_edict.h:348
A simple queue class.
Definition g_ai.h:43
bool isEmpty(void) const
Checks if the queue is empty.
Definition g_ai.h:59
qnode_s * _tail
Definition g_ai.h:67
void clear(void)
Remove all data from the queue.
Definition g_ai.cpp:127
int size(void) const
Gets the number of elements in the queue.
Definition g_ai.h:55
void enqueue(const pos3_t data)
Add an entry to the queue.
Definition g_ai.cpp:92
LQueue(void)
Initialize a LQueue object.
Definition g_ai.h:48
qnode_s * _head
Definition g_ai.h:66
~LQueue(void)
Clear LQueue internal data.
Definition g_ai.cpp:84
bool dequeue(pos3_t data)
Retrieve an entry form the queue.
Definition g_ai.cpp:111
LQueue _area
Definition g_ai.h:70
void plotArea(const pos3_t origin, int radius, bool flat=false)
Calculate the search area.
Definition g_ai.cpp:143
void plotCircle(const pos3_t origin, int radius)
Definition g_ai.cpp:165
void plotPos(const pos3_t origin, int xOfs, int yOfs)
Definition g_ai.cpp:203
AiAreaSearch()
Initializes an AiAreaSearch object to default values.
Definition g_ai.cpp:56
~AiAreaSearch(void)
Clear AiAreaSearch internal data.
Definition g_ai.cpp:70
bool getNext(pos3_t pos)
Get next position in the search area.
Definition g_ai.cpp:79
item instance data, with linked list capability
Definition inv_shared.h:402
#define nullptr
Definition cxx.h:53
bool AI_CheckLineOfFire(const Actor *shooter, const Edict *target, const fireDef_t *fd, int shots)
Definition g_ai.cpp:763
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 g_ai.cpp:1574
bool AI_CheckUsingDoor(const Edict *ent, const Edict *door)
Checks whether the AI controlled actor wants to use a door.
Definition g_ai.cpp:396
Edict * ai_waypointList
void AI_Init(void)
Definition g_ai.cpp:266
int AIL_InitActor(Actor *actor)
Initializes the lua AI for an actor.
void AI_ActorRun(Player &player, Actor *actor)
Definition g_ai.cpp:1655
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.
Definition g_ai.cpp:1557
bool AI_HideNeeded(const Actor *actor)
Checks whether the given alien should try to hide because there are enemies close enough to shoot the...
Definition g_ai.cpp:484
void G_AddToWayPointList(Edict *ent)
Definition g_ai.cpp:1537
void AIL_Init(void)
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...
Definition g_ai.cpp:659
const Item * AI_GetItemForShootType(shoot_types_t shootType, const Edict *ent)
Definition g_ai.cpp:541
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...
Definition g_ai.cpp:570
void AIL_Cleanup(void)
Closes the LUA AI.
bool AI_FindMissionLocation(Actor *actor, const pos3_t to, int tus, int radius=0)
Try to go close to a mission edict.
Definition g_ai.cpp:1423
float AI_CalcShotDamage(Actor *actor, const Actor *target, const fireDef_t *fd, shoot_types_t shotType)
Calculate estimated damage per single shoot.
Definition g_ai.cpp:811
void AIL_Shutdown(void)
bool AI_FighterCheckShoot(const Actor *actor, const Edict *check, const fireDef_t *fd, float dist)
Check whether the fighter should perform the shoot.
Definition g_ai.cpp:364
bool AI_FindHidingLocation(int team, Actor *actor, const pos3_t from, int tuLeft)
Tries to search a hiding spot.
Definition g_ai.cpp:606
bool AIL_TeamThink(Player &player)
The team think function for the ai controlled players.
bool AI_IsHostile(const Actor *actor, const Edict *target)
Check if actor perceives target as hostile.
Definition g_ai.cpp:933
bool AI_CheckPosition(const Actor *const ent, const pos3_t pos)
Checks if the given position is safe to stand on.
Definition g_ai.cpp:581
void AI_Run(void)
Every server frame one single actor is handled - always in the same order.
Definition g_ai.cpp:1713
const invDef_t * AI_SearchGrenade(const Actor *actor, Item **ip)
Search the edict's inventory for a grenade or other one-use weapon.
Definition g_ai.cpp:954
bool AI_HasLineOfFire(const Actor *actor, const Edict *target)
Check if actor has a line of fire to the target given.
Definition g_ai.cpp:275
void AIL_ActorThink(Player &player, Actor *actor)
The think function for the ai controlled players.
void AI_CheckRespawn(int team)
If the cvar g_endlessaliens is set we will endlessly respawn aliens.
Definition g_ai.cpp:1908
Player * AI_CreatePlayer(int team)
Spawn civilians and aliens.
Definition g_ai.cpp:1944
Local definitions for game module.
int32_t containerIndex_t
Definition inv_shared.h:46
voidpf uLong int origin
Definition ioapi.h:45
int32_t shoot_types_t
Available shoot types - also see the ST_ constants.
Definition q_shared.h:206
QGL_EXTERN GLsizei const GLvoid * data
Definition r_gl.h:89
this is a fire definition for our weapons/ammo
Definition inv_shared.h:110
inventory definition for our menus
Definition inv_shared.h:371
pos_t pos3_t[3]
Definition ufotypes.h:58
vec_t vec3_t[3]
Definition ufotypes.h:39