Nuclide
Software Development Kit for id Tech
NSNavAI.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016-2024 Vera Visions LLC.
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
13 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
14 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15*/
16
17var bool autocvar_ai_debugNav = false;
18void
19_NSNavAI_Log(string className, string functionName, float edictNum, string warnMessage)
20{
22 printf("^9%f ^5%s (%d) ^7: %s\n", time, functionName, edictNum, warnMessage);
23 else
24 printf("^5%s (%d) ^7: %s\n", functionName, edictNum, warnMessage);
25}
26#define NSNavAI_Log(...) _NSNavAI_Log(classname, __FUNC__, num_for_edict(this), sprintf(__VA_ARGS__))
27
28#ifndef MAX_AMMO_TYPES
29#define MAX_AMMO_TYPES 16
30#endif
31
32
33/* for AI identification purposes */
34typedef enum
35{
36 WPNTYPE_INVALID, /* no logic */
37 WPNTYPE_RANGED, /* will want to keep their distance mostly */
38 WPNTYPE_THROW, /* has to keep some distance, but not too far */
39 WPNTYPE_CLOSE, /* have to get really close */
40 WPNTYPE_FULLAUTO, /* for things that need to be held down */
41 WPNTYPE_SEMI /* semi automatic */
43
48class
50{
51
52public:
53 void NSNavAI(void);
54
56 virtual bool CanSprint(void);
58 virtual bool CanProne(void);
60 virtual bool CanCrouch(void);
62 virtual bool CanLean(void);
63
65 virtual float GetForwardSpeed(void);
67 virtual float GetSideSpeed(void);
69 virtual float GetBackSpeed(void);
70
72 nonvirtual bool IsCrouching(void);
74 nonvirtual bool IsProne(void);
76 nonvirtual bool IsStanding(void);
78 nonvirtual bool IsSprinting(void);
80 nonvirtual bool IsLeaning(void);
81
82 /* ammo handling */
84 nonvirtual bool GiveAmmo(int, int);
86 nonvirtual bool UseAmmo(int, int);
87
88 /* inventory handling */
90 nonvirtual bool GiveItem(string);
92 nonvirtual bool RemoveItem(string);
94 nonvirtual bool AddItem(NSItem);
96 nonvirtual bool HasItem(string);
97
98#ifdef SERVER
99 /* overrides */
100 virtual void Save(float);
101 virtual void Restore(string,string);
102 virtual void RestoreComplete(void);
103 virtual void DebugDraw(void);
104
105 /* methods we'd like others to override */
107 virtual bool CanCrouch(void);
109 nonvirtual vector GetRouteMovevalues(void);
111 nonvirtual vector GetRouteDirection(void);
113 nonvirtual void SetMoveSpeedScale(float);
115 nonvirtual float GetMoveSpeedScale(void);
116
118 virtual void RouteEnded(void);
120 virtual void RouteClear(void);
122 virtual void CheckRoute(void);
124 virtual void RouteToPosition(vector);
126 virtual void RouteToPositionDenyFlags(vector, int);
128 virtual void ChasePath(string startPath);
130 virtual void CheckRoute_Path(void);
132 virtual void Physics_Run(void);
133#endif
134
135private:
136#ifdef SERVER
137 /* pathfinding */
138 int m_iNodes;
139 int m_iCurNode;
140 nodeslist_t *m_pRoute;
141 vector m_vecLastNode;
142 vector m_vecTurnAngle;
143 string m_pathTarget;
144 NSEntity m_pathEntity;
145 float _m_flRouteGiveUp;
146 vector _m_vecRoutePrev;
147 vector m_vecRouteEntity;
148 entity m_eFollowing;
149 float m_flMoveSpeedKey;
150#endif
151
152 /* These are defined in side defs\*.def, ammo_types and ammo_names */
153 int m_iAmmoTypes[MAX_AMMO_TYPES];
154 NSItem m_itemList;
155 float activeweapon;
156};
weapontype_t
Definition: NSNavAI.h:35
@ WPNTYPE_SEMI
Definition: NSNavAI.h:41
@ WPNTYPE_THROW
Definition: NSNavAI.h:38
@ WPNTYPE_RANGED
Definition: NSNavAI.h:37
@ WPNTYPE_FULLAUTO
Definition: NSNavAI.h:40
@ WPNTYPE_CLOSE
Definition: NSNavAI.h:39
@ WPNTYPE_INVALID
Definition: NSNavAI.h:36
#define MAX_AMMO_TYPES
Definition: NSNavAI.h:29
void _NSNavAI_Log(string className, string functionName, float edictNum, string warnMessage)
Definition: NSNavAI.h:19
var bool autocvar_ai_debugNav
Definition: NSNavAI.h:17
NSEntity is the lowest of the user-accessible entity class.
Definition: NSEntity.h:52
id Tech 4 keys to support:
Definition: NSItem.h:55
This entity class represents a moving/pathfinding object.
Definition: NSNavAI.h:50
virtual bool CanCrouch(void)
Returns if this class is capable of crouching.
This entity represents an NSRenderableEntity with interactive surface properties.
Definition: NSSurfacePropEntity.h:49
float time
Definition: fteextensions.qc:509
vector(vector) normalize
entity() spawn
#define printf(...)
Definition: global.h:20
var bool autocvar_g_developerTimestamps
Definition: global.h:18