OpenMoHAA ..
Loading...
Searching...
No Matches
entity.h
1/*
2===========================================================================
3Copyright (C) 2023 the OpenMoHAA team
4
5This file is part of OpenMoHAA source code.
6
7OpenMoHAA source code is free software; you can redistribute it
8and/or modify it under the terms of the GNU General Public License as
9published by the Free Software Foundation; either version 2 of the License,
10or (at your option) any later version.
11
12OpenMoHAA source code is distributed in the hope that it will be
13useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with OpenMoHAA source code; if not, write to the Free Software
19Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20===========================================================================
21*/
22
23// entity.h: Base class for all enities that are controlled by Sin. If you have any
24// object that should be called on a periodic basis and it is not an entity,
25// then you have to have an dummy entity that calls it.
26//
27// An entity in Sin is any object that is not part of the world-> Any non-world
28// object that is visible in Sin is an entity, although it is not required that
29// all entities be visible to the player. Some objects are basically just virtual
30// constructs that act as an instigator of certain actions, for example, some
31// triggers are invisible and cannot be touched, but when activated by other
32// objects can cause things to happen.
33//
34// All entities are capable of receiving messages from Sin or from other entities.
35// Messages received by an entity may be ignored, passed on to their superclass,
36// or acted upon by the entity itself. The programmer must decide on the proper
37// action for the entity to take to any message. There will be many messages
38// that are completely irrelevant to an entity and should be ignored. Some messages
39// may require certain states to exist and if they are received by an entity when
40// it these states don't exist may indicate a logic error on the part of the
41// programmer or map designer and should be reported as warnings (if the problem is
42// not severe enough for the game to be halted) or as errors (if the problem should
43// not be ignored at any cost).
44//
45
46#pragma once
47
48#include "g_local.h"
49#include "../corepp/class.h"
50#include "../corepp/vector.h"
51#include "../corepp/script.h"
52#include "../corepp/listener.h"
53#include "simpleentity.h"
54#include "../corepp/delegate.h"
55
56// modification flags
57#define FLAG_IGNORE 0
58#define FLAG_CLEAR 1
59#define FLAG_ADD 2
60
61typedef enum {
62 DAMAGE_NO,
63 DAMAGE_YES, // will take damage if hit
64 DAMAGE_AIM // auto targeting recognizes this
65} damage_t;
66
67typedef enum {
68 legs,
69 torso,
70} bodypart_t;
71
72enum eAIEvent {
73 AI_EVENT_NONE,
74 AI_EVENT_WEAPON_FIRE,
75 AI_EVENT_WEAPON_IMPACT,
76 AI_EVENT_EXPLOSION,
77 AI_EVENT_AMERICAN_VOICE,
78 AI_EVENT_GERMAN_VOICE,
79 AI_EVENT_AMERICAN_URGENT,
80 AI_EVENT_GERMAN_URGENT,
81 AI_EVENT_MISC,
82 AI_EVENT_MISC_LOUD,
83 AI_EVENT_FOOTSTEP,
84 AI_EVENT_GRENADE,
85 AI_EVENT_BADPLACE, // Added in 2.0
86 AI_EVENT_MAX
87};
88
89//deadflag
90#define DEAD_NO 0
91#define DEAD_DYING 1
92#define DEAD_DEAD 2
93#define DEAD_RESPAWNABLE 3
94
95// Generic entity events
96extern Event EV_SoundDone;
97extern Event EV_Classname;
98extern Event EV_Activate;
99extern Event EV_ForceActivate;
100extern Event EV_Use;
101extern Event EV_FadeNoRemove;
102extern Event EV_FadeOut;
103extern Event EV_FadeIn;
104extern Event EV_Fade;
105extern Event EV_Killed;
106extern Event EV_GotKill;
107extern Event EV_Pain;
108extern Event EV_Damage;
109extern Event EV_Stun;
110extern Event EV_Gib;
111extern Event EV_Kill;
112extern Event EV_DeathSinkStart;
113extern Event EV_Entity_AddImmunity;
114extern Event EV_Entity_RemoveImmunity;
115
116// Physics events
117extern Event EV_MoveDone;
118extern Event EV_Touch;
119extern Event EV_Blocked;
120extern Event EV_Attach;
121extern Event EV_AttachModel;
122extern Event EV_RemoveAttachedModel;
123extern Event EV_Detach;
124extern Event EV_DetachAllChildren;
125extern Event EV_UseBoundingBox;
126extern Event EV_IsTouching;
127
128// Animation events
129extern Event EV_NewAnim;
130extern Event EV_LastFrame;
131extern Event EV_TakeDamage;
132extern Event EV_NoDamage;
133
134// script stuff
135extern Event EV_Model;
136extern Event EV_GetModel;
137extern Event EV_Hide;
138extern Event EV_Show;
139extern Event EV_BecomeSolid;
140extern Event EV_BecomeNonSolid;
141extern Event EV_Sound;
142extern Event EV_StopSound;
143extern Event EV_Bind;
144extern Event EV_Unbind;
145extern Event EV_Glue;
146extern Event EV_Unglue;
147extern Event EV_JoinTeam;
148extern Event EV_QuitTeam;
149extern Event EV_SetHealth;
150extern Event EV_SetHealth2;
151extern Event EV_Entity_GetHealth;
152extern Event EV_SetSize;
153extern Event EV_SetAlpha;
154extern Event EV_SetTargetName;
155extern Event EV_SetTarget;
156extern Event EV_SetKillTarget;
157extern Event EV_StartAnimating;
158extern Event EV_SurfaceModelEvent;
159extern Event EV_Stop;
160extern Event EV_StopLoopSound;
161extern Event EV_SetControllerAngles;
162extern Event EV_CanSee;
163
164// dir is 1
165// power is 2
166// minsize is 3
167// maxsize is 4
168// percentage is 5
169// thickness 6
170// entity is 7
171// origin 8
172
173// AI sound events
174extern Event EV_BroadcastAIEvent;
175extern Event EV_Hurt;
176extern Event EV_Heal;
177
178// Define ScriptMaster
179class ScriptMaster;
180
181//
182// Spawn args
183//
184// "spawnflags"
185// "alpha" default 1.0
186// "model"
187// "origin"
188// "targetname"
189// "target"
190//
191
192// was 8, increased to 16
193#define MAX_MODEL_CHILDREN 16
194#define MAX_GLUE_CHILDREN 8
195
196#define GL_USEANGLES 1
197
198class Entity;
199
200typedef SafePtr<Entity> EntityPtr;
201
202class Entity : public SimpleEntity
203{
204public:
205 CLASS_PROTOTYPE(Entity);
206
207 // spawning variables
208 int entnum;
209 int radnum;
210 gentity_t *edict;
211 gclient_t *client;
212 int spawnflags;
213
214 // standard variables
215 str model;
216
217 // physics variables
218 Vector mins;
219 Vector maxs;
220 Vector absmin;
221 Vector absmax;
222 Vector velocity;
223 Vector accel;
224 Vector avelocity;
225 Vector aaccel;
226 Vector size;
227 int movetype;
228 int mass;
229 float gravity;
230 float orientation[3][3];
231 gentity_t *groundentity;
232 cplane_t groundplane;
233 int groundcontents;
234
235 // Model Binding variables
236 int numchildren;
237 int children[MAX_MODEL_CHILDREN];
238
239 // Light variables
240 float lightRadius;
241
242 // Team variables
243 str moveteam;
244 class Entity *teamchain;
245 class Entity *teammaster;
246
247 // Binding variables
248 class Entity *bindmaster;
249 qboolean bind_use_my_angles;
250 Vector localorigin;
251 Vector localangles;
252
253 // targeting variables
254 str killtarget;
255
256 // Character state
257 float health;
258 float max_health;
259 int deadflag;
260 int flags;
261
262 // underwater variables
263 int watertype;
264 int waterlevel;
265
266 // Pain and damage variables
267 damage_t takedamage;
268 EntityPtr enemy;
269 float pain_finished;
270 float damage_debounce_time;
271 int damage_type;
272
273 // Glue variables
274 int m_iNumGlues;
275 EntityPtr m_pGlues[MAX_GLUE_CHILDREN];
276 int m_pGluesFlags[MAX_GLUE_CHILDREN];
277 class Entity *m_pGlueMaster;
278 bool m_bGlueAngles;
279 bool m_bGlueDuckable;
280 qboolean detach_at_death;
281
282 // Path variables
283 float stealthMovementScale; // how much it will notify AIs
284 qboolean m_bMovementStealthScript;
285 class pathway_ref *m_BlockedPaths;
286 int m_iNumBlockedPaths;
287
288 // immune list
289 Container<int> immunities;
290
291#ifdef OPM_FEATURES
292 //
293 // Added in OPM
294 //====
295 // miscellaneous
296 bool m_bHintRequiresLookAt;
297 str m_HintString;
298 //====
299#endif
300
301 MulticastDelegate<void(const Event& ev)> delegate_damage;
302 MulticastDelegate<void(const Event& ev)> delegate_killed;
303 MulticastDelegate<void(const Event& ev)> delegate_gotKill;
304
305public:
306 Entity();
307 virtual ~Entity();
308
309 void EventGetNormalHealth(Event *ev);
310 void EventNormalDamage(Event *ev);
311 void ClassnameEvent(Event *ev);
312 void SpawnFlagsEvent(Event *ev);
313 void EventRevive(Event *ev);
314
315 virtual void ShowInfo(float fDot, float fDist);
316
317 qboolean DistanceTo(Vector pos) const;
318 qboolean DistanceTo(Entity *ent) const;
319 qboolean WithinDistance(Vector pos, float dist) const;
320 qboolean WithinDistance(Entity *ent, float dist) const;
321
322 Vector GetControllerAngles(int num);
323 void SetControllerAngles(int num, const vec3_t angles);
324 void SetControllerAngles(Event *ev);
325 void GetControllerAngles(Event *ev);
326 void SetControllerTag(int num, int tag_num);
327 int GetControllerTag(int num) const;
328 qboolean GetTagPositionAndOrientation(str tagname, orientation_t *new_or);
329 void GetTagPositionAndOrientation(int tagnum, orientation_t *new_or);
330 void GetTagPosition(Event *ev);
331 void GetTagAngles(Event *ev);
332
333 void EventTrace(Event *ev);
334 void EventSightTrace(Event *ev);
335 void EventInPVS(Event *ev);
336 void IsTouching(Event *ev);
337 void IsInside(Event *ev);
338 void CanSeeInternal(Event *ev, bool bNoEnts); // new in 2.0
339 void CanSee(Event *ev);
340 void CanSeeNoEnts(Event *ev);
341
342 void SetKillTarget(const char *killtarget);
343 const char *KillTarget(void);
344
345 void AlwaysDraw(Event *ev);
346 void NormalDraw(Event *ev);
347 void NeverDraw(Event *ev);
348
349 const char *getModel() const;
350 void GetModelEvent(Event *ev);
351 void GetBrushModelEvent(Event *ev);
352 virtual qboolean setModel(void);
353 void SetSize(void);
354 void setModel(const str& mdl);
355 void SetModelEvent(Event *ev);
356
357 void SetTeamEvent(Event *ev);
358 virtual void TriggerEvent(Event *ev);
359 void hideModel(void);
360 void EventHideModel(Event *ev);
361 virtual void showModel(void);
362 void EventShowModel(Event *ev);
363 qboolean hidden(void);
364 void ProcessInitCommands(void);
365
366 void setAlpha(float alpha);
367 float alpha(void);
368
369 void setMoveType(int type);
370 int getMoveType(void);
371
372 void setSolidType(solid_t type);
373 int getSolidType(void);
374
375 virtual void setContentsSolid(void);
376
377 virtual Vector getParentVector(Vector vec);
378 Vector getLocalVector(Vector vec);
379
380 virtual void setSize(Vector min, Vector max);
381 virtual void updateOrigin(void);
382 virtual void setLocalOrigin(Vector org);
383 void setOrigin(Vector org) override;
384 void setOriginEvent(Vector org) override;
385 virtual void setOrigin(void);
386 virtual void addOrigin(Vector org);
387
388 void GetRawTag(int tagnum, orientation_t *orient);
389 qboolean GetRawTag(const char *tagname, orientation_t *orient);
390
391 void GetTag(int tagnum, orientation_t *orient);
392 qboolean GetTag(const char *name, orientation_t *orient);
393 void GetTag(int tagnum, Vector *pos, Vector *forward = NULL, Vector *left = NULL, Vector *up = NULL);
394 qboolean GetTag(const char *name, Vector *pos, Vector *forward = NULL, Vector *left = NULL, Vector *up = NULL);
395
396 virtual int CurrentAnim(int slot = 0) const;
397 virtual float CurrentTime(int slot = 0) const;
398 void ClearAnimSlot(int slot);
399 void StartAnimSlot(int slot, int index, float weight);
400 void RestartAnimSlot(int slot);
401
402 void setAngles(Vector ang) override;
403 virtual void setAngles(void);
404
405 void link(void);
406 void unlink(void);
407
408 void setContents(int type);
409 int getContents(void);
410 void setScale(float scale);
411
412 qboolean droptofloor(float maxfall);
413 qboolean isClient(void);
414
415 virtual void SetDeltaAngles(void);
416 virtual void DamageEvent(Event *event);
417 void Damage(
418 Entity *inflictor,
419 Entity *attacker,
420 float damage,
421 Vector position,
422 Vector direction,
423 Vector normal,
424 int knockback,
425 int flags,
426 int meansofdeath,
427 int location = -1
428 );
429
430 void DamageType(Event *ev);
431 qboolean IsTouching(Entity *e1);
432 qboolean IsInside(Entity *e1);
433 qboolean FovCheck(float *delta, float fovdot);
434 // Added in 2.0:
435 // bNoEnts parameter
436 virtual bool CanSee(Entity *ent, float fov, float vision_distance, bool bNoEnts = false);
437 virtual bool CanSee(const Vector& org, float fov, float vision_distance, bool bNoEnts = false); // added in 2.0
438 bool AreasConnected(const Entity *other);
439 void FadeNoRemove(Event *ev);
440 void FadeOut(Event *ev);
441 void FadeIn(Event *ev);
442 void Fade(Event *ev);
443 void Sink(Event *ev);
444
445 virtual void CheckGround(void);
446 virtual qboolean HitSky(trace_t *trace);
447 virtual qboolean HitSky(void);
448
449 void SafeSolid(Event *ev); // new in 2.0
450 void BecomeSolid(Event *ev);
451 void BecomeNonSolid(Event *ev);
452 void SetSize(Event *ev);
453 void SetMins(Event *ev);
454 void SetMaxs(Event *ev);
455 //==
456 // added in 2.0
457 void GetMins(Event *ev);
458 void GetMaxs(Event *ev);
459 //==
460 void SetScale(Event *ev);
461 void GetScale(Event *ev);
462 void SetAlpha(Event *ev);
463 void SetKillTarget(Event *ev);
464 void TouchTriggersEvent(Event *ev);
465
466 str GetRandomAlias(str name, AliasListNode_t **ret);
467 void SetWaterType(void);
468
469 // model binding functions
470 qboolean
471 attach(int parent_entity_num, int tag_num, qboolean use_angles = qtrue, Vector attach_offset = Vector("0 0 0"));
472 void detach(void);
473
474 //
475 // Sound functions
476 //
477 void ProcessSoundEvent(Event *ev, qboolean checkSubtitle);
478 void Sound(Event *ev);
479 virtual void Sound(
480 str sound_name,
481 int channel = CHAN_BODY,
482 float volume = -1.0,
483 float min_dist = -1.0,
484 Vector *origin = NULL,
485 float pitch = -1.0f,
486 int argstype = 0,
487 int doCallback = 0,
488 int checkSubtitle = 1,
489 float max_dist = -1.0f
490 );
491 void StopSound(int channel);
492 void StopSound(Event *ev);
493 void LoopSound(Event *ev);
494 void
495 LoopSound(str sound_name, float volume = -1.0, float min_dist = -1.0, float max_dist = -1.0, float pitch = -1.0);
496 void StopLoopSound(Event *ev);
497 void StopLoopSound(void);
498 void StopAllSounds();
499
500 void SetLight(Event *ev);
501 void LightOn(Event *ev);
502 void LightOff(Event *ev);
503 void LightRed(Event *ev);
504 void LightGreen(Event *ev);
505 void LightBlue(Event *ev);
506 void LightRadius(Event *ev);
507 void LightStyle(Event *ev);
508 void Flags(Event *ev);
509 void Effects(Event *ev);
510 void RenderEffects(Event *ev);
511 void SVFlags(Event *ev);
512
513 void BroadcastAIEvent(int iType = AI_EVENT_MISC, float rad = SOUND_RADIUS);
514 void BroadcastAIEvent(Event *ev);
515 void Kill(Event *ev);
516 virtual void Killed(Event *ev);
517 void SurfaceModelEvent(Event *ev);
518 void SurfaceCommand(const char *surf_name, const char *token);
519 virtual void Postthink(void);
520 virtual void Think(void);
521
522 void DamageSkin(trace_t *trace, float damage);
523
524 void AttachEvent(Event *ev);
525 void AttachModelEvent(Event *ev);
526 void RemoveAttachedModelEvent(Event *ev);
527 void AttachedModelAnimEvent(Event *ev);
528 void DetachEvent(Event *ev);
529 void TakeDamageEvent(Event *ev);
530 void NoDamageEvent(Event *ev);
531 void Gravity(Event *ev);
532 void GiveOxygen(float time);
533 void UseBoundingBoxEvent(Event *ev);
534 void HurtEvent(Event *ev);
535 void HealEvent(Event *ev);
536 void SetMassEvent(Event *ev);
537 void Censor(Event *ev);
538 void Ghost(Event *ev);
539
540 void StationaryEvent(Event *ev);
541 void TossEvent(Event *ev);
542 void Explosion(Event *ev);
543
544 void Shader(Event *ev);
545
546 void KillAttach(Event *ev);
547 void SetBloodModel(Event *ev);
548
549 void DropToFloorEvent(Event *ev);
550
551 // Binding methods
552 void joinTeam(Entity *teammember);
553 void quitTeam(void);
554 qboolean isBoundTo(Entity *master);
555 virtual void bind(Entity *master, qboolean use_my_angles = qfalse);
556 virtual void unbind(void);
557 virtual void glue(Entity *master, qboolean use_my_angles = qtrue, qboolean can_duck = qfalse);
558 virtual void unglue(void);
559 void GlueEvent(Event *ev);
560 void DuckableGlueEvent(Event *ev);
561 void MakeClayPidgeon(Event *ev);
562 void EventUnglue(Event *ev);
563
564 void JoinTeam(Event *ev);
565 void EventQuitTeam(Event *ev);
566 void BindEvent(Event *ev);
567 void EventUnbind(Event *ev);
568 void AddToSoundManager(Event *ev);
569 void NoLerpThisFrame(void);
570
571 virtual void addAngles(Vector add);
572
573 void DeathSinkStart(Event *ev);
574 void DeathSink(Event *ev);
575
576 void DetachAllChildren(Event *ev);
577 void SetMovementStealth(float fStealthScale);
578 qboolean HasMovementStealthOverride(void) const;
579 void EventMovementStealth(Event *ev);
580
581 virtual void VelocityModified(void);
582
583 qboolean CheckEventFlags(Event *event);
584 void PusherEvent(Event *ev);
585 void SetShaderData(Event *ev);
586
587 void GetVelocity(Event *ev);
588 void SetVelocity(Event *ev);
589 void GetAVelocity(Event *ev);
590 void DoForceActivate(void);
591 void ForceActivate(Event *ev);
592
593 void ConnectPaths(void);
594 void DisconnectPaths(void);
595
596 void EventConnectPaths(Event *ev);
597 void EventDisconnectPaths(Event *ev);
598 virtual void Delete(void);
599 void Remove(Event *ev);
600 void EventSoundDone(Event *ev);
601
602 void VolumeDamage(float damage);
603 void EventVolumeDamage(Event *ev);
604
605 virtual qboolean IsDead() const;
606 virtual void AddImmunity(Event *ev);
607 virtual void RemoveImmunity(Event *ev);
608 qboolean Immune(int meansofdeath);
609
610 virtual void ClientThink(void);
611
612 virtual void EndFrame(void);
613 virtual void CalcBlend(void);
614 void Archive(Archiver& arc) override;
615 virtual bool AutoArchiveModel(void);
616 virtual void PathnodeClaimRevoked(class PathNode *node);
617 virtual qboolean BlocksAIMovement() const;
618 virtual qboolean AIDontFace(void) const;
619 void SetHealth(Event *ev);
620 void GetHealth(Event *ev);
621 void EventSetMaxHealth(Event *ev);
622 void EventGetMaxHealth(Event *ev);
623 void EventSetHealthOnly(Event *ev);
624 void GetYaw(Event *ev);
625
626 virtual void PreAnimate(void);
627 virtual void PostAnimate(void);
628 virtual bool HasVehicle(void) const;
629 void EventGetEntnum(Event *ev);
630 void EventGetClassname(Event *ev);
631 void EventSetRadnum(Event *ev);
632 void EventGetRadnum(Event *ev);
633 void EventSetRotatedBbox(Event *ev);
634 void EventGetRotatedBbox(Event *ev);
635 void MPrintf(const char *msg, ...);
636 void DrawBoundingBox(int showbboxes);
637
638 void EventSinglePlayerCommand(Event *ev);
639 void EventMultiPlayerCommand(Event *ev);
640 void EventRealismModeCommand(Event *ev);
641 void EventSPRealismModeCommand(Event *ev);
642 void EventDMRealismModeCommand(Event *ev);
643 void GetLocalYawFromVector(Event *ev);
644 void EventShootableOnly(Event *ev);
645 void SetShaderTime(Event *ev);
646 void NoTarget(Event *ev);
647
648 //
649 // Custom openmohaa features
650 //
651 void ProcessHint(gentity_t *client, bool bShow);
652 void GetZone(Event *ev);
653 void IsInZone(Event *ev);
654 void SetDepthHack(Event *ev);
655#ifdef OPM_FEATURES
656 void SetHintRequireLookAt(Event *ev);
657 void SetHintString(Event *ev);
658 void SetShader(Event *ev);
659#endif
660 void PlayNonPvsSound(const str& soundName, float volume = 1);
661};
662
663inline void Entity::PreAnimate(void) {}
664
665inline void Entity::PostAnimate(void) {}
666
667inline bool Entity::HasVehicle(void) const
668{
669 return false;
670}
671
672inline int Entity::getSolidType(void)
673{
674 return edict->solid;
675}
676
677inline qboolean Entity::DistanceTo(Vector pos) const
678{
679 Vector delta;
680
681 delta = origin - pos;
682 return delta.length() != 0 ? qtrue : qfalse;
683}
684
685inline qboolean Entity::DistanceTo(Entity *ent) const
686{
687 Vector delta;
688
689 assert(ent);
690
691 if (!ent) {
692 // "Infinite" distance
693 return 999999;
694 }
695
696 delta = origin - ent->origin;
697 return delta.length() != 0 ? qtrue : qfalse;
698}
699
700inline qboolean Entity::WithinDistance(Vector pos, float dist) const
701{
702 Vector delta;
703
704 delta = origin - pos;
705
706 // check squared distance
707 return ((delta * delta) < (dist * dist)) ? qtrue : qfalse;
708}
709
710inline qboolean Entity::WithinDistance(Entity *ent, float dist) const
711{
712 Vector delta;
713
714 assert(ent);
715
716 if (!ent) {
717 return false;
718 }
719
720 delta = origin - ent->origin;
721
722 // check squared distance
723 return ((delta * delta) < (dist * dist));
724}
725
726inline const char *Entity::KillTarget(void)
727{
728 return killtarget.c_str();
729}
730
731inline qboolean Entity::hidden(void)
732{
733 if (edict->s.renderfx & RF_DONTDRAW) {
734 return true;
735 }
736 return false;
737}
738
739inline void Entity::GetBrushModelEvent(Event *ev)
740{
741 ev->AddString(model);
742}
743
744inline void Entity::GetModelEvent(Event *ev)
745{
746 if (!edict->tiki) {
747 ev->AddNil();
748 return;
749 }
750
751 const char *name = gi.TIKI_NameForNum(edict->tiki);
752
753 if (!name) {
754 if (model != "") {
755 ev->AddString(model);
756 } else {
757 ev->AddNil();
758 return;
759 }
760 } else {
761 ev->AddString(name);
762 }
763}
764
765inline void Entity::hideModel(void)
766{
767 edict->s.renderfx |= RF_DONTDRAW;
768 if (getSolidType() <= SOLID_TRIGGER) {
769 edict->r.svFlags |= SVF_NOCLIENT;
770 }
771}
772
773inline void Entity::showModel(void)
774{
775 edict->s.renderfx &= ~RF_DONTDRAW;
776 edict->r.svFlags &= ~SVF_NOCLIENT;
777}
778
779inline float Entity::alpha(void)
780{
781 return edict->s.alpha;
782}
783
784inline void Entity::setMoveType(int type)
785{
786 movetype = type;
787}
788
789inline int Entity::getMoveType(void)
790{
791 return movetype;
792}
793
794inline void Entity::unlink(void)
795{
796 gi.unlinkentity(edict);
797}
798
799inline void Entity::setContents(int type)
800{
801 edict->r.contents = type;
802}
803
804inline int Entity::getContents(void)
805{
806 return edict->r.contents;
807}
808
809inline qboolean Entity::isClient(void)
810{
811 if (client) {
812 return true;
813 }
814 return false;
815}
816
817inline void Entity::SetDeltaAngles(void)
818{
819 int i;
820
821 if (client) {
822 for (i = 0; i < 3; i++) {
823 client->ps.delta_angles[i] = ANGLE2SHORT(client->ps.viewangles[i]);
824 }
825 }
826}
827
828inline str Entity::GetRandomAlias(str name, AliasListNode_t **ret)
829{
830 str realname;
831 const char *s;
832
833 if (edict->tiki) {
834 s = gi.Alias_FindRandom(edict->tiki, name.c_str(), ret);
835 } else {
836 s = NULL;
837 }
838
839 if (s) {
840 realname = s;
841 } else {
842 s = gi.GlobalAlias_FindRandom(name.c_str(), ret);
843 if (s) {
844 realname = s;
845 }
846 }
847
848 return realname;
849}
850
851inline bool Entity::AreasConnected(const Entity *other)
852{
853 return gi.AreasConnected(edict->r.areanum, other->edict->r.areanum) != 0;
854}
855
856#include "worldspawn.h"
Definition archive.h:87
Definition g_local.h:81
Definition entity.h:203
Definition navigate.h:153
Definition scriptmaster.h:42
Definition navigate.h:81
Definition q_shared.h:1526
Definition q_shared.h:1454