2
// C++ Implementation: bot_waypoint.h
4
// Description: Containts all defintions for bot waypoint code
7
// Author: Rick Helmus <rickhelmus@gmail.com>
10
// Enable this for flood support
13
#ifndef BOT_WAYPOINT_H
14
#define BOT_WAYPOINT_H
16
#define WAYPOINT_VERSION 2
17
#define EXP_WP_VERSION 1
18
#define REACHABLE_RANGE 15.0f
19
#define MAX_MAP_GRIDS 64
20
#define SECTOR_SIZE 18
22
#define W_FL_TELEPORT (1<<1) // used if waypoint is at a teleporter
23
#define W_FL_TELEPORTDEST (1<<2) // used if waypoint is at a teleporter destination
24
#define W_FL_FLOOD (1<<3) // used if this waypoint is made by flooding the map
25
#define W_FL_JUMP (1<<4) // if set, bot jumps when reached this waypoint
26
#define W_FL_TRIGGER (1<<5) // used if this waypoint is at a trigger
27
#define W_FL_INTAG (1<<6) // used if this waypoint is in a tagged cube
29
#define MAX_FLOODWPCONNECTDIST 2
30
#define MAX_FLOODWPDIST 4.0f
32
struct waypoint_header_s
36
int iFileFlags; // not currently used
38
char szMapName[32]; // name of map for these waypoints
41
// Old waypoint structure, used for waypoint version 1
42
struct waypoint_version_1_s
46
TLinkedList<waypoint_version_1_s *> ConnectedWPs;
50
waypoint_version_1_s *pParent;
53
waypoint_version_1_s(void) : iFlags(0), f(0.0f), g(0.0f), pParent(NULL) { };
62
short sCost; // Base and static cost
63
TLinkedList<node_s *> ConnectedWPs;
64
TLinkedList<node_s *> ConnectedWPsWithMe;
66
TLinkedList<node_s *> FailedGoalList;
69
node_s(void) : iFlags(0), sTriggerNr(0), sYaw(-1), sCost(10) { };
70
node_s(const vec &o, const int &f, const short t=0, const short y=-1) : v_origin(o),
81
waypoint_s *pParent[2];
82
bool bIsOpen[2], bIsClosed[2];
85
waypoint_s(void) : pNode(NULL) { bIsOpen[0] = bIsOpen[1] = bIsClosed[0] =
86
bIsClosed[1] = false; pParent[0] = pParent[1] = NULL;
93
bool m_bDrawWaypoints;
96
bool m_bAutoPlacePaths;
99
float m_fPathDrawTime;
100
char m_szMapName[32];
103
bool m_bFlooding; // True if flooding map with waypoints
104
bool m_bFilteringNodes;
105
int m_iFloodStartTime;
106
int m_iCurFloodX, m_iCurFloodY;
108
int m_iFilteredNodes;
113
TLinkedList<node_s *> m_Waypoints[MAX_MAP_GRIDS][MAX_MAP_GRIDS];
114
int m_iWaypointCount; // number of waypoints currently in use
116
CWaypointClass(void);
117
virtual ~CWaypointClass(void) { Clear(); };
122
bool LoadWaypoints(void);
123
void SaveWaypoints(void);
124
bool LoadWPExpFile(void);
125
void SaveWPExpFile(void);
126
void SetMapName(const char *map) { strcpy(m_szMapName, map); };
128
void SetWaypointsVisible(bool Visible) { m_bDrawWaypoints = Visible; };
129
void SetPathsVisible(bool Visible) { m_bDrawWPPaths = Visible; };
130
void SetAutoWaypoint(bool On) { m_bAutoWaypoint = On; };
131
void SetWPInfo(bool on) { m_bDrawWPText = on; };
132
void SetWPFlags(node_s *wp, int iFlags) { wp->iFlags |= iFlags; };
133
void UnsetWPFlags(node_s *wp, int iFlags) { wp->iFlags &= ~iFlags; };
134
void SetWPTriggerNr(node_s *wp, short sTriggerNr) { wp->sTriggerNr = sTriggerNr; };
135
void SetWPYaw(node_s *wp, short sYaw) { wp->sYaw = sYaw; };
136
bool WaypointsAreVisible(void) { return m_bDrawWaypoints; };
137
node_s *AddWaypoint(vec o, bool connectwp);
138
void DeleteWaypoint(vec v_src);
139
void AddPath(node_s *pWP1, node_s *pWP2);
140
void DeletePath(node_s *pWP);
141
void DeletePath(node_s *pWP1, node_s *pWP2);
142
void ManuallyCreatePath(vec v_src, int iCmd, bool TwoWay);
143
void ManuallyDeletePath(vec v_src, int iCmd, bool TwoWay);
145
bool WPIsReachable(vec from, vec to);
146
//node_s *GetNearestWaypoint(vec v_src, float flRange, bool CheckVisible = true, bool SkipFloodWPs = true);
147
node_s *GetNearestWaypoint(vec v_src, float flRange);
148
node_s *GetNearestWaypoint(dynent *d, float flRange) { return GetNearestWaypoint(d->o, flRange); };
149
node_s *GetNearestTriggerWaypoint(vec v_src, float flRange);
150
node_s *GetWaypointFromVec(const vec &v_src);
151
void DrawNearWaypoints();
152
void GetNodeIndexes(const vec &v_origin, short *i, short *j);
153
void CalcCost(node_s *pNode);
154
void ReCalcCosts(void);
159
virtual void StartFlood(void);
160
void StopFlood(void);
161
void FloodThink(void);
162
bool CanPlaceNodeHere(const vec &from);
163
void ConnectFloodWP(node_s *pWP);
164
node_s *GetNearestFloodWP(vec v_origin, float flRange, node_s *pIgnore, bool SkipTags=false);
165
node_s *GetNearestFloodWP(dynent *d, float flRange) { return GetNearestFloodWP(d->o, flRange, NULL); };
166
node_s *GetNearestTriggerFloodWP(vec v_origin, float flRange);
170
class CACWaypointClass: public CWaypointClass
175
virtual void StartFlood(void);
179
class CCubeWaypointClass: public CWaypointClass
182
void CreateWPsAtTeleporters(void);
183
void CreateWPsAtTriggers(void);
187
virtual void StartFlood(void);
191
#endif // BOT_WAYPOINT_H