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
17/* TODO: serverinfo based checks for prediction reasons */
18var bool autocvar_g_infiniteAmmo = false;
19
20var bool autocvar_ai_debugNav = false;
21void
22_NSActor_Log(string className, string functionName, float edictNum, string warnMessage)
23{
25 printf("^9%f ^5%s (%d) ^7: %s\n", time, functionName, edictNum, warnMessage);
26 else
27 printf("^5%s (%d) ^7: %s\n", functionName, edictNum, warnMessage);
28}
29#define NSActor_Log(...) _NSActor_Log(classname, __FUNC__, num_for_edict(this), sprintf(__VA_ARGS__))
30
31/* for AI identification purposes */
32typedef enum
33{
34 WPNTYPE_INVALID, /* no logic */
35 WPNTYPE_RANGED, /* will want to keep their distance mostly */
36 WPNTYPE_THROW, /* has to keep some distance, but not too far */
37 WPNTYPE_CLOSE, /* have to get really close */
38 WPNTYPE_FULLAUTO, /* for things that need to be held down */
39 WPNTYPE_SEMI /* semi automatic */
41
48class
50{
51
52public:
53 void NSActor(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);
88 nonvirtual bool HasAmmo(int, int);
90 nonvirtual int GetReserveAmmo(int);
91
92 /* inventory handling */
94 nonvirtual bool GiveItem(string);
96 nonvirtual bool RemoveItem(string);
98 nonvirtual bool AddItem(NSItem);
100 nonvirtual bool HasItem(string);
102 nonvirtual bool HasExactItem(NSItem);
104 nonvirtual bool RemoveAllItems(bool);
106 nonvirtual bool RemoveAllWeapons(void);
108 nonvirtual string GetCurrentWeapon(void);
110 nonvirtual void SwitchToWeapon(string);
112 nonvirtual void SwitchToExactWeapon(NSWeapon);
113
114 nonvirtual void LaunchProjectile(string, bool, float);
115 nonvirtual bool PlantCharge(string);
116
117#ifdef SERVER
118 /* overrides */
119 virtual void Save(float);
120 virtual void Restore(string,string);
121 virtual void RestoreComplete(void);
122 virtual void DebugDraw(void);
123
124 /* methods we'd like others to override */
126 virtual bool CanCrouch(void);
128 nonvirtual vector GetRouteMovevalues(void);
130 nonvirtual vector GetRouteDirection(void);
132 nonvirtual void SetMoveSpeedScale(float);
134 nonvirtual float GetMoveSpeedScale(void);
135
137 virtual void RouteEnded(void);
139 virtual void RouteClear(void);
141 virtual void CheckRoute(void);
143 virtual void RouteToPosition(vector);
145 virtual void RouteToPositionDenyFlags(vector, int);
147 virtual void ChasePath(string startPath);
149 virtual void CheckRoute_Path(void);
151 virtual void Physics_Run(void);
152#endif
153
154private:
155#ifdef SERVER
156 /* pathfinding */
157 int m_iNodes;
158 int m_iCurNode;
159 nodeslist_t *m_pRoute;
160 vector m_vecLastNode;
161 vector m_vecTurnAngle;
162 string m_pathTarget;
163 NSEntity m_pathEntity;
164 float _m_flRouteGiveUp;
165 vector _m_vecRoutePrev;
166 vector m_vecRouteEntity;
167 entity m_eFollowing;
168 float m_flMoveSpeedKey;
169#endif
170
171 /* These are defined in side defs\*.def, ammo_types and ammo_names */
172 int m_iAmmoTypes[MAX_AMMO_TYPES];
173 NSItem m_itemList;
174 NSWeapon m_activeWeapon;
175 NSWeapon m_activeWeapon_net;
176 float activeweapon;
177 float m_flFirstInventoryItem;
178};
179
181
weapontype_t
Definition: NSNavAI.h:33
@ WPNTYPE_SEMI
Definition: NSNavAI.h:39
@ WPNTYPE_THROW
Definition: NSNavAI.h:36
@ WPNTYPE_RANGED
Definition: NSNavAI.h:35
@ WPNTYPE_FULLAUTO
Definition: NSNavAI.h:38
@ WPNTYPE_CLOSE
Definition: NSNavAI.h:37
@ WPNTYPE_INVALID
Definition: NSNavAI.h:34
void _NSActor_Log(string className, string functionName, float edictNum, string warnMessage)
Definition: NSNavAI.h:22
var bool autocvar_ai_debugNav
Definition: NSNavAI.h:20
var bool autocvar_g_infiniteAmmo
Definition: NSNavAI.h:18
void NSActor_ListInventory(NSActor)
Definition: NSNavAI.qc:946
This entity class represents an object with choreographed/free-form movement.
Definition: NSNavAI.h:50
virtual bool CanCrouch(void)
Returns if this class is capable of crouching.
NSEntity is the lowest of the user-accessible entity class.
Definition: NSEntity.h:54
This entity class represents inventory items, weapons.
Definition: NSItem.h:68
This entity represents an NSRenderableEntity with interactive surface properties.
Definition: NSSurfacePropEntity.h:52
This entity class represents weapon based items.
Definition: NSWeapon.h:86
var bool autocvar_g_logTimestamps
Definition: global.h:17
#define printf(...)
Definition: global.h:30
#define MAX_AMMO_TYPES
Definition: defs.h:69