Nuclide
Software Development Kit for id Technology (BETA)
Actor.h
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
18#define ACTOR_LOG imageToConsole("gfx/icon16/eye", ICN_SIZE, "Actor Log")
19
20/* TODO: serverinfo based checks for prediction reasons */
21var bool autocvar_g_infiniteAmmo = false;
22var bool autocvar_ai_debugNav = false;
23
24void
25_ncActor_Log(string className, string functionName, float edictNum, string warnMessage)
26{
27 if (autocvar_g_logTimestamps)
28 printf("%s ^9%f ^5%s (%d) ^7: %s\n", ACTOR_LOG, time, functionName, edictNum, warnMessage);
29 else
30 printf("%s ^5%s (%d) ^7: %s\n", ACTOR_LOG, functionName, edictNum, warnMessage);
31}
32#define ncActor_Log(...) if (autocvar_g_logLevel >= LOGLEVEL_DEBUG) _ncActor_Log(classname, __FUNC__, num_for_edict(this), sprintf(__VA_ARGS__))
33
34/* for AI identification purposes */
35typedef enum
36{
37 WPNTYPE_INVALID, /* no logic */
38 WPNTYPE_RANGED, /* will want to keep their distance mostly */
39 WPNTYPE_THROW, /* has to keep some distance, but not too far */
40 WPNTYPE_CLOSE, /* have to get really close */
41 WPNTYPE_FULLAUTO, /* for things that need to be held down */
42 WPNTYPE_SEMI /* semi automatic */
43} weapontype_t;
44
91class
93{
94
95public:
96 void ncActor(void);
97
99 virtual bool CanSprint(void);
101 virtual bool CanProne(void);
103 virtual bool CanCrouch(void);
105 virtual bool CanLean(void);
106
108 virtual float GetForwardSpeed(void);
110 virtual float GetSideSpeed(void);
112 virtual float GetBackSpeed(void);
113
114
115 nonvirtual float GetStamina(void);
116
118 nonvirtual bool IsCrouching(void);
120 nonvirtual bool IsProne(void);
122 nonvirtual bool IsStanding(void);
124 nonvirtual bool IsSprinting(void);
126 nonvirtual bool IsLeaning(void);
127
128 /* ammo handling */
130 nonvirtual bool MaxAmmo(int);
132 nonvirtual bool GiveAmmo(int, int);
134 nonvirtual bool UseAmmo(int, int);
136 nonvirtual bool HasAmmo(int, int);
138 nonvirtual int GetReserveAmmo(int);
139
140 /* inventory handling */
142 nonvirtual bool GiveItem(string);
143 nonvirtual bool GiveExactItem(ncItem);
145 nonvirtual bool RemoveItem(string);
147 nonvirtual bool AddItem(ncItem);
149 nonvirtual ncItem GetItem(string);
151 nonvirtual bool HasItem(string);
153 nonvirtual bool HasExactItem(ncItem);
155 nonvirtual bool RemoveAllItems(bool);
157 nonvirtual bool RemoveAllWeapons(void);
159 nonvirtual string GetCurrentWeapon(void);
161 nonvirtual void SwitchToWeapon(string);
163 nonvirtual void SwitchToExactWeapon(ncWeapon);
164 nonvirtual void SwitchToBestWeapon(bool);
165
166 nonvirtual void LaunchProjectile(string, bool, float);
167 nonvirtual bool PlantCharge(string);
168
170 virtual ncWeapon SortWeaponChain(void);
172 nonvirtual ncWeapon GetNextWeapon(void);
174 nonvirtual ncWeapon GetPreviousWeapon(void);
176 nonvirtual ncWeapon GetLastWeapon(void);
177
178 virtual void AddedItemCallback(ncItem);
179 virtual void SpawnKey(string,string);
180 virtual void ReloadCachedAttributes(void);
181
182#ifdef CLIENT
183 virtual void ReceiveEvent(float eventID);
184#endif
185
186#ifdef SERVER
187 /* overrides */
188 virtual void Save(float);
189 virtual void Restore(string,string);
190 virtual void RestoreComplete(void);
191 virtual void Spawned(void);
192 virtual void Input(entity, string, string);
193 virtual void DebugDraw(void);
194
196 virtual void SelectNewSchedule(void);
197 nonvirtual void ThinkSchedules(void);
198
200 nonvirtual bool CancelSchedule(void);
201 nonvirtual void PerformSchedule(string);
202 nonvirtual void MessageSchedule(string);
203 nonvirtual bool IsPerforming(void);
204
205 nonvirtual int PathNodeCount(void);
206 nonvirtual int PathCurrentNode(void);
207 nonvirtual vector PathDestination(void);
208
210 nonvirtual void MakeCorpse(float deathSequence);
211
212 /* methods we'd like others to override */
214 virtual bool CanCrouch(void);
216 nonvirtual vector GetRouteMovevalues(void);
218 nonvirtual vector GetRouteDirection(void);
220 nonvirtual void SetMoveSpeedScale(float);
222 nonvirtual float GetMoveSpeedScale(void);
223
225 virtual void RouteEnded(void);
227 virtual void RouteClear(void);
229 virtual void CheckRouteProgression(void);
231 virtual void RouteToPosition(vector);
233 virtual void RouteToPositionDenyFlags(vector, int);
235 virtual void ChasePath(string startPath);
237 virtual void CheckRouteProgression_Path(void);
239 virtual void Physics_Run(void);
240#endif
241
242 virtual void FiredWeapon(string, string);
243 nonvirtual void __FiredWeapon(string, string);
244
245 virtual void Event_DrawWeapon(void);
246 virtual void Event_FireWeapon(void);
247 virtual void Event_ReloadWeaponStart(void);
248 virtual void Event_ReloadWeapon(void);
249 virtual void Event_ReloadWeaponEnd(void);
250 virtual void Event_HolsterWeapon(void);
251
252private:
253
254#ifdef SERVER
255 /* pathfinding */
256 int m_pathfindingNodeCount;
257 int m_pathfindingCurrentNode;
258 nodeslist_t *m_pathfindingGraph;
259 vector m_pathfindingDestination;
260 string m_pathTarget;
261 ncEntity m_pathEntity;
262 float m_timeUntilDroppingRoute;
263 vector m_pathfindingLastPos;
264 entity m_followingEntity;
265 float m_moveSpeedKey;
266 string m_mindset;
267 entity m_hook;
268#endif
269
270 /* These are defined in side defs\*.def, ammo_types and ammo_names */
271 int m_ammoTypes[MAX_AMMO_TYPES];
272 float activeweapon;
273 NETWORKED_FLOAT(m_itemStart)
274 NETWORKED_FLOAT(m_currentStamina)
275 float m_weaponCookingTime;
276
277 /* networking/prediction */
278 ncWeapon m_activeWeapon_net;
279
280 /* non-state heavy cached values, reloaded frequently. */
281 string m_sndStepLadderLeft;
282 string m_sndStepLadderRight;
283 string m_sndDeath;
284 string m_sndFall;
285 string m_sndPainSmall;
286 string m_sndPainMedium;
287 string m_sndPainLarge;
288 string m_sndPainHuge;
289 string m_sndLandSoft;
290 string m_sndLandHard;
291 string m_sndHitArmor;
292 string m_sndHitFlesh;
293 string m_sndAirGaspHeavy;
294 string m_sndAirGaspLight;
295 string m_sndNoAir;
296 string m_sndTeleportExit;
297 string m_sndTeleportStart;
298 string m_sndWaterExit;
299 string m_sndWaterEnter;
300 string m_sndWaterWade;
301 string m_sndWaterSwim;
302 string m_sndBurn;
303 string m_sndHealthtake;
304 string m_sndUseDeny;
305 string m_sndUseSuccess;
306
307 /* recalculate these */
308 float m_actIdle;
309 float m_actIdleCrouch;
310 float m_actIdleProne;
311 float m_actWalk;
312 float m_actWalkCrouch;
313 float m_actWalkProne;
314 float m_actRun;
315 float m_actJump;
316 float m_actAim;
317 float m_actDraw;
318 float m_actAttack;
319 float m_actReloadStart;
320 float m_actReload;
321 float m_actReloadEnd;
322 float m_actHolster;
323 int m_boneSpine;
324 int m_torsoFirst;
325 int m_torsoLast;
326};
327
328/* for now here to make debugging easier */
329.ncItem m_itemList;
330.ncWeapon m_activeWeapon;
331.ncWeapon m_firstWeapon;
332.bool _isActor;
333
334void ncActor_ListInventory(ncActor);
This entity class represents an object with choreographed/free-form movement.
Definition: Actor.h:93
virtual bool CanCrouch(void)
Returns if this class is capable of crouching.
ncEntity is the lowest of the user-accessible entity class.
Definition: Entity.h:75
This entity class represents inventory items, weapons.
Definition: Item.h:138
This entity represents an ncRenderableEntity with interactive surface properties.
Definition: SurfacePropEntity.h:70
This entity class represents weapon based items.
Definition: Weapon.h:300
void ncWeapon(void)
Definition: Weapon.qc:18