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