OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
cg_commands.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// DESCRIPTION:
24// client side entity commands
25
26/*
27The cg_command system is used for a variety of different functions, but mostly it is
28used for spawning client side temp models. Either through the use of emitters or
29commands that are tied to various frames of animation.
30
31The ctempmodel_t class is the data structure for all of the static tempmodels.
32These are updated every frame and refEntity and refSprite data is created and added
33to the renderer for drawing.
34
35The spawnthing_t is the intermediate data holder. When the TIKI file is processed
36the spawnthing_t is cleared out and values are assigned based on the commands issued.
37
38cg_common_data is a list of common data elements that are the same in the ctempmodel_t and
39the spawhthing_t
40
41After the m_spawnthing is filled in, 1 or more ctempmodel_t structures are spawned.
42
43The ClientCommandManager is the listener that process all of the commands in the
44TIKI file, similar to ScriptMaster in the server game dll.
45
46*/
47
48#pragma once
49
50#include "cg_local.h"
51#include "listener.h"
52#include "script.h"
53#include "vector.h"
54#include "../qcommon/qcommon.h"
55
56#define EMITTER_DEFAULT_LIFE 1000
57#define MAX_EMITTERS 32
58#define MAX_SWIPES 32
59
60#define T_RANDSCALE (1 << 0)
61#define T_SCALEANIM (1 << 1)
62#define T_SPHERE (1 << 2)
63#define T_INWARDSPHERE (1 << 3)
64#define T_CIRCLE (1 << 4)
65#define T_FADE (1 << 5)
66#define T_DIETOUCH (1 << 6)
67#define T_ANGLES (1 << 7)
68#define T_WAVE (1 << 8)
69#define T_SWARM (1 << 9)
70#define T_ALIGN (1 << 10)
71#define T_COLLISION (1 << 11)
72#define T_FLICKERALPHA (1 << 12)
73#define T_DLIGHT (1 << 13)
74#define T_FADEIN (1 << 14)
75#define T_GLOBALFADEIN (1 << 15)
76#define T_GLOBALFADEOUT (1 << 16)
77#define T_PARENTLINK (1 << 17)
78#define T_RANDOMROLL (1 << 18)
79#define T_HARDLINK (1 << 19)
80#define T_ANIMATEONCE (1 << 20)
81#define T_BEAMTHING (1 << 21)
82#define T_RANDVELAXIS (1 << 22)
83#define T_BOUNCESOUND (1 << 23)
84#define T_BOUNCESOUNDONCE (1 << 24)
85#define T_TWINKLE (1 << 25)
86#define T_TWINKLE_OFF (1 << 26)
87#define T_ALIGNONCE (1 << 27)
88#define T_SCALEUPDOWN (1 << 28)
89#define T_AUTOCALCLIFE (1 << 29)
90#define T_ASSIGNED_NUMBER (1 << 30)
91#define T_DETAIL (1 << 31)
92
93#define T2_MOVE (1 << 0)
94#define T2_AMOVE (1 << 1)
95#define T2_ACCEL (1 << 2)
96#define T2_TRAIL (1 << 3)
97#define T2_PHYSICS_EVERYFRAME (1 << 4)
98#define T2_TEMPORARY_DECAL (1 << 5)
99#define T2_BOUNCE_DECAL (1 << 6)
100#define T2_PARALLEL (1 << 7)
101#define T2_VOLUMETRIC (1 << 8)
102#define T2_COLOR_AVEL (1 << 9)
103#define T2_WIND_AFFECT (1 << 10)
104#define T2_SPRITEGRIDLIGHTING (1 << 11)
105#define T2_WATERONLY (1 << 12)
106#define T2_ALIGNSTRETCH (1 << 13)
107#define T2_ALWAYSDRAW (1 << 14)
108#define T2_CLAMP_VEL (1 << 15)
109#define T2_CLAMP_VEL_AXIS (1 << 16)
110#define T2_CONE (1 << 17)
111#define T2_RADIALVELOCITY (1 << 18)
112#define T2_FRICTION (1 << 19)
113#define T2_VARYCOLOR (1 << 20)
114#define T2_SPIN (1 << 21)
115#define T2_RELATIVEANGLES (1 << 22)
116#define T2_NOTAGAXIS (1 << 23)
117
118class spawnthing_t;
119class specialeffect_t;
120class MemArchiver;
121
122typedef enum {
123 NOT_RANDOM,
124 RANDOM,
125 CRANDOM
126} randtype_t;
127
128class cg_common_data : public Class
129{
130public:
131 cg_common_data();
132
133 int life;
134 int createTime;
135 Vector origin;
136 Vector oldorigin;
137 Vector accel;
138 Vector angles;
139 Vector velocity;
140 Vector avelocity;
141 Vector parentOrigin;
142 Vector parentMins;
143 Vector parentMaxs;
144 Vector minVel;
145 Vector maxVel;
146 float color[4];
147 float alpha;
148 float scaleRate;
149 float scalemin;
150 float scalemax;
151 float bouncefactor;
152 int bouncecount;
153 int maxbouncecount;
154 str bouncesound;
155 int bouncesound_delay;
156 int flags;
157 int flags2;
158 dtiki_t *tiki;
159 int swarmfreq;
160 float swarmmaxspeed;
161 float swarmdelta;
162 float lightIntensity;
163 int lightType;
164 int fadeintime;
165 int fadedelay;
166 int parent;
167 int collisionmask;
168 int min_twinkletimeoff;
169 int max_twinkletimeoff;
170 int min_twinkletimeon;
171 int max_twinkletimeon;
172 int lightstyle;
173 int physicsRate;
174 float scale;
175 float scale2;
176 str swipe_shader;
177 str swipe_tag_start;
178 str swipe_tag_end;
179 str shadername;
180 float swipe_life;
181 float friction;
182
183 float decal_orientation;
184 float decal_radius;
185 float spin_rotation;
186
187public:
188 void ArchiveToMemory(MemArchiver& archiver);
189};
190
191inline cg_common_data::cg_common_data()
192{
193 int i;
194
195 bouncesound_delay = 0;
196 life = 0;
197 createTime = 0;
198 alpha = 0;
199 fadedelay = 0;
200 lightIntensity = 0;
201 lightType = (dlighttype_t)0;
202 bouncefactor = 0;
203 bouncecount = 0;
204 maxbouncecount = 0;
205 scaleRate = 0;
206 scale = 1;
207 scalemin = 0;
208 scalemax = 0;
209 swarmfreq = 0;
210 swarmmaxspeed = 0;
211 swarmdelta = 0;
212 flags = 0;
213 flags2 = 0;
214 fadeintime = 0;
215 parent = 0;
216 tiki = nullptr;
217 collisionmask = 0;
218 min_twinkletimeoff = 0;
219 max_twinkletimeoff = 0;
220 min_twinkletimeon = 0;
221 max_twinkletimeoff = 0;
222 lightstyle = -1;
223 physicsRate = 10;
224
225 for (i = 0; i < 4; i++) {
226 color[i] = 0;
227 }
228}
229
230class ctempmodel_t : public Class
231{
232public:
233 ctempmodel_t();
234
235 class ctempmodel_t *next;
236 class ctempmodel_t *prev;
237
238 cg_common_data cgd;
239 str modelname;
240
241 refEntity_t lastEnt;
242 refEntity_t ent;
243
244 int number;
245 int lastAnimTime;
246 int lastPhysicsTime;
247 int killTime;
248 int next_bouncesound_time;
249 int seed;
250 int twinkleTime;
251 int aliveTime;
252 qboolean addedOnce;
253 qboolean lastEntValid;
254 spawnthing_t *m_spawnthing;
255
256 void (*touchfcn)(ctempmodel_t *ct, trace_t *trace);
257
258public:
259 void ArchiveToMemory(MemArchiver& archiver);
260};
261
262inline ctempmodel_t::ctempmodel_t()
263{
264 number = 0;
265 lastPhysicsTime = 0;
266 lastAnimTime = 0;
267 killTime = 0;
268 next_bouncesound_time = 0;
269 seed = 0;
270 twinkleTime = 0;
271 aliveTime = 0;
272 addedOnce = qfalse;
273 lastEntValid = qfalse;
274}
275
276enum class vsstypes_t : unsigned char {
277 VST_DEFAULT,
278 VST_GUN,
279 VST_IMPACT,
280 VST_DIRT,
281 VST_HEAVY,
282 VST_STEAM,
283 VST_MIST,
284 VST_SGREN,
285 VST_GRENADE,
286 VST_FIRE,
287 VST_GREASEFIRE,
288 VST_DEBRIS,
289 NUM_VSS_TYPES
290};
291
292class cvssource_t
293{
294public:
295 cvssource_t *next;
296 cvssource_t *prev;
297 cvssource_t *stnext;
298 int stindex;
299 Vector lastOrigin;
300 float lastRadius;
301 float lastDensity;
302 float lastColor[3];
303 float lastLighting[3];
304 Vector newOrigin;
305 float newRadius;
306 float newDensity;
307 float newColor[3];
308 float newLighting[3];
309 float ooRadius;
310 Vector velocity;
311 float startAlpha;
312 int roll;
313 Vector repulsion;
314 int lifeTime;
315 int collisionmask;
316 int parent;
317 int flags;
318 int flags2;
319 int smokeType;
320 float typeInfo;
321 float fadeMult;
322 float scaleMult;
323 int lastPhysicsTime;
324 int lastLightingTime;
325 qboolean lastValid;
326
327public:
328 cvssource_t();
329
330public:
331 void ArchiveToMemory(MemArchiver& archiver);
332};
333
334inline cvssource_t::cvssource_t()
335 : next(NULL)
336 , prev(NULL)
337 , stnext(NULL)
338 , stindex(0)
339 , lastRadius(0)
340 , lastDensity(0)
341 , lastColor {0}
342 , lastLighting {0}
343 , newRadius(0)
344 , newDensity(0)
345 , newColor {0}
346 , newLighting {0}
347 , ooRadius(0)
348 , startAlpha(0)
349 , roll(0)
350 , lifeTime(0)
351 , collisionmask(0)
352 , parent(0)
353 , flags(0)
354 , flags2(0)
355 , smokeType(0)
356 , typeInfo(0)
357 , fadeMult(0)
358 , scaleMult(0)
359 , lastPhysicsTime(0)
360 , lastLightingTime(0)
361 , lastValid(qfalse)
362{}
363
365{
366public:
367 Vector origin;
368 float color[3];
369 float radius;
370 float density;
371};
372
373#define LIFE_SWIPE 1
374#define MAX_SWIPE_POINTS 64
375
377 vec3_t points[2];
378 float time;
379};
380
381class swipething_t : public Class
382{
383public:
384 qboolean enabled;
385 str tagname_start;
386 str tagname_end;
387 int entitynum;
388 float startcolor[4];
389 float endcolor[4];
390 swipepoint_t swipepoints[MAX_SWIPE_POINTS];
391 swipepoint_t cntPoint;
392 int num_live_swipes;
393 int first_swipe;
394 float life;
395 qhandle_t shader;
396 void Init();
397};
398
399inline void swipething_t::Init()
400{
401 int i;
402
403 enabled = qfalse;
404 tagname_start = "";
405 tagname_end = "";
406 entitynum = -1;
407
408 for (i = 0; i < 4; i++) {
409 startcolor[i] = 1.f;
410 endcolor[i] = 0.f;
411 }
412
413 for (i = 0; i < MAX_SWIPE_POINTS; i++) {
414 VectorSet(swipepoints[i].points[0], 0.f, 0.f, 0.f);
415 VectorSet(swipepoints[i].points[1], 0.f, 0.f, 0.f);
416 swipepoints[i].time = 0.f;
417 }
418
419 num_live_swipes = 0;
420 first_swipe = 0;
421}
422
423// Enttracker is used to keep track of client side tempmodels. They are
424// assigned a number from a pool of 256.
425class enttracker_t : public Class
426{
427public:
428 enttracker_t();
429 int AssignNumber(void);
430
431protected:
432 qboolean usedNumbers[256];
433 virtual void RemoveEntity(int entnum);
434
435public:
436 void ArchiveToMemory(MemArchiver& archiver);
437};
438
439inline enttracker_t::enttracker_t()
440{
441 memset(usedNumbers, 0, sizeof(usedNumbers));
442}
443
444inline void enttracker_t::RemoveEntity(int entnum)
445{
446 // If the entnum is a magic number, then clear out the usedNumber field, so
447 // that it may be reused for this emitter.
448
449 if (entnum >= MAGIC_UNUSED_NUMBER) {
450 entnum -= MAGIC_UNUSED_NUMBER;
451
452 assert(entnum >= 0);
453 assert(entnum < 256);
454
455 usedNumbers[entnum] = qfalse;
456 }
457}
458
459inline int enttracker_t::AssignNumber(void)
460{
461 int i;
462
463 // These numbers are used for client side tempmodels that are emitters
464 // themselves. Since they don't have real entity_numbers, they must be
465 // assigned a MAGIC number so we can keep track of the last time that the
466 // model emitted something.
467
468 // Search for a number that is not used
469 for (i = 0; i < 256; i++) {
470 if (!usedNumbers[i]) {
471 usedNumbers[i] = qtrue;
472 return MAGIC_UNUSED_NUMBER + i;
473 }
474 }
475
476 return -1;
477}
478
479class emittertime_t : public Class
480{
481public:
482 int entity_number;
483 int last_emit_time;
484 Vector oldorigin;
485 qboolean active;
486 qboolean lerp_emitter;
487
488public:
489 void ArchiveToMemory(MemArchiver& archiver);
490};
491
492// emitterthing_t is used to keep track of the last time and emitter was updated
493// for a particular entity number. It inherits from the enttracker_t so it can
494// manage client side tempmodels
495class emitterthing_t : public enttracker_t
496{
497protected:
498 Container<emittertime_t> m_emittertimes; // A list of entity numbers and the
499 // last time they emitted
500
501public:
502 emittertime_t *GetEmitTime(int entnum);
503 virtual void RemoveEntity(int entnum);
504 qboolean startoff;
505
506public:
507 void ArchiveToMemory(MemArchiver& archiver);
508};
509
510inline void emitterthing_t::RemoveEntity(int entnum)
511{
512 int num, count;
513 emittertime_t *et;
514
515 if (entnum == -1) {
516 return;
517 }
518
519 count = m_emittertimes.NumObjects();
520
521 for (num = count; num >= 1; num--) {
522 et = &m_emittertimes.ObjectAt(num);
523 if (et->entity_number == entnum) {
524 m_emittertimes.RemoveObjectAt(num);
525 }
526 }
527
528 enttracker_t::RemoveEntity(entnum);
529}
530
531inline emittertime_t *emitterthing_t::GetEmitTime(int entnum)
532{
533 int num, count;
534 emittertime_t *et;
535
536 count = m_emittertimes.NumObjects();
537
538 for (num = 1; num <= count; num++) {
539 et = &m_emittertimes.ObjectAt(num);
540 if (et->entity_number == entnum) {
541 return et;
542 }
543 }
544
545 // Add a new entry if we didn't find it already
546 et = &m_emittertimes.ObjectAt(m_emittertimes.AddObject({}));
547 et->entity_number = entnum;
548 et->last_emit_time = cg.time;
549 et->lerp_emitter = qfalse;
550
551 if (this->startoff) {
552 et->active = qfalse;
553 } else {
554 et->active = qtrue;
555 }
556
557 return et;
558}
559
560class commandtime_t : public Class
561{
562public:
563 int entity_number;
564 int command_number;
565 int last_command_time;
566
567public:
568 void ArchiveToMemory(MemArchiver& archiver);
569};
570
571// This class is used for keeping track of the last time an entity executed a
572// particular command. A command number must be assigned externally by the user
573class commandthing_t : public enttracker_t
574{
575 Container<commandtime_t> m_commandtimes; // A list of entity numbers and the last time they
576 // executed a command
577
578public:
579 commandtime_t *GetLastCommandTime(int entnum, int commandnum);
580 virtual void RemoveEntity(int entnum);
581
582 void ArchiveToMemory(MemArchiver& archiver);
583};
584
585inline void commandthing_t::RemoveEntity(int entnum)
586{
587 int num, count;
588 commandtime_t *ct;
589
590 count = m_commandtimes.NumObjects();
591
592 for (num = count; num >= 1; num--) {
593 ct = &m_commandtimes.ObjectAt(num);
594 if (ct->entity_number == entnum) {
595 m_commandtimes.RemoveObjectAt(num);
596 }
597 }
598
599 enttracker_t::RemoveEntity(entnum);
600}
601
602inline commandtime_t *commandthing_t::GetLastCommandTime(int entnum, int commandnum)
603{
604 int num, count;
605
606 // Search for this entity number
607 count = m_commandtimes.NumObjects();
608
609 for (num = 1; num <= count; num++) {
610 commandtime_t *ct = &m_commandtimes.ObjectAt(num);
611 if ((ct->entity_number == entnum) && (ct->command_number == commandnum)) {
612 return ct;
613 }
614 }
615
616 // Add a new entry if we didn't find it
617 commandtime_t ct;
618 ct.entity_number = entnum;
619 ct.command_number = commandnum;
620 ct.last_command_time = 0;
621
622 m_commandtimes.AddObject(ct);
623
624 return &m_commandtimes.ObjectAt(m_commandtimes.NumObjects());
625}
626
628{
629public:
630 Container<str> m_modellist; // A list of models that should be spawned from the emitter
631 Container<str> m_taglist; // A list of tags to create beams
632
633 cg_common_data cgd;
634 int entnum;
635
636 Vector origin_offset_base;
637 Vector origin_offset_amplitude;
638 Vector axis_offset_base;
639 Vector axis_offset_amplitude;
640 Vector randvel_base;
641 Vector randvel_amplitude;
642 Vector avelocity_base;
643 Vector avelocity_amplitude;
644 Vector angles_amplitude;
645 vec3_t axis[3];
646 vec3_t tag_axis[3];
647 float life_random;
648 float forwardVelocity;
649 float sphereRadius;
650 float coneHeight;
651 float spawnRate;
652 int lastTime;
653 int count;
654 int tagnum;
655 str emittername;
656 str animName;
657 float dcolor[3];
658 qboolean dlight;
659 int numtempmodels;
660 float linked_origin[3];
661 float linked_axis[3][3];
662 float fMinRangeSquared;
663 float fMaxRangeSquared;
664
665 // beam stuff also impact trace stuff
666 str startTag;
667 str endTag;
668 float length;
669 float min_offset;
670 float max_offset;
671 float overlap;
672 float numSubdivisions;
673 float delay;
674 float toggledelay;
675 int beamflags;
676 int numspherebeams;
677 float endalpha;
678 float spreadx;
679 float spready;
680 qboolean use_last_trace_end;
681
682 void (*touchfcn)(ctempmodel_t *ct, trace_t *trace);
683 str GetModel(void);
684 void SetModel(str model);
685
686public:
687 void ArchiveToMemory(MemArchiver& archiver);
688};
689
690inline void spawnthing_t::SetModel(str model)
691{
692 m_modellist.ClearObjectList();
693 m_modellist.AddObject(model);
694}
695
696inline str spawnthing_t::GetModel(void)
697{
698 int num, index;
699
700 num = m_modellist.NumObjects();
701
702 if (!num) {
703 return "";
704 }
705
706 index = (num * random()) + 1;
707
708 if (index > num) {
709 index = num;
710 }
711
712 return m_modellist.ObjectAt(index);
713}
714
715// Keeps track of beams that are created by entities that need their positions
716// updated every frame
718{
719public:
720 str beamname;
721 str shadername;
722 str startTag;
723 str endTag;
724 int numSubdivisions;
725 dtiki_t *tiki;
726 float alpha;
727 float scale;
728 int flags;
729 float length;
730 int life;
731 float min_offset;
732 float max_offset;
733 float overlap;
734 int delay;
735 byte modulate[4];
736};
737
738#define MAX_TEMPMODELS 2048
739#define MAX_BEAMS 4096
740
741class ClientGameCommandManager : public Listener
742{
743private:
744 spawnthing_t m_localemitter; // local emitter used by animation commands
745 ctempmodel_t m_active_tempmodels;
746 ctempmodel_t *m_free_tempmodels;
747 ctempmodel_t m_tempmodels[MAX_TEMPMODELS];
748 cvssource_t m_active_vsssources;
749 cvssource_t *m_free_vsssources;
750 cvssource_t *m_vsssources;
751 int m_iAllocatedvsssources;
752 spawnthing_t *m_spawnthing;
753 Container<spawnthing_t *> m_emitters; // Global emitters set up by client commands
754 int m_seed;
755 commandthing_t m_command_time_manager; // Keeps track of entity numbers and the last
756 // time they executed particular commands
757 specialeffect_t *m_pCurrentSfx;
758 int m_iLastVSSRepulsionTime;
759 float m_fEventWait;
760
761 void (ClientGameCommandManager::*endblockfcn)(void);
762 cvssource_t *AllocateVSSSource();
763 void FreeVSSSource(cvssource_t *p);
764 void SpawnVSSSource(int count, int timealive);
765 void EventViewKick(Event *ev);
766 void Print(Event *ev);
767 void PrintDeathMsg(Event *ev); // Added in 2.0
768 void StartBlock(Event *ev);
769 void EndBlock(Event *ev);
770 void UpdateSpawnThing(spawnthing_t *ep);
771 void EmitterStartOff(Event *ev);
772 void SetAlpha(Event *ev);
773 void SetDieTouch(Event *ev);
774 void SetBounceFactor(Event *ev);
775 void SetBounceSound(Event *ev);
776 void SetBounceSoundOnce(Event *ev);
777 void SetModel(Event *ev);
778 void SetLife(Event *ev);
779 void SetColor(Event *ev);
780 void SetColorRange(Event *ev);
781 void SetLightstyle(Event *ev);
782 void SetRadialVelocity(Event *ev);
783 void SetVelocity(Event *ev);
784 void SetAngularVelocity(Event *ev);
785 void SetCount(Event *ev);
786 void SetScale(Event *ev);
787 void SetScaleUpDown(Event *ev);
788 void SetScaleMin(Event *ev);
789 void SetScaleMax(Event *ev);
790 void SetScaleRate(Event *ev);
791 void SetRandomVelocity(Event *ev);
792 void SetRandomVelocityAlongAxis(Event *ev);
793 void SetNoTagAxis(Event *ev); // Added in 2.0
794 void SetAccel(Event *ev);
795 void SetFriction(Event *ev);
796 void SetSpin(Event *ev);
797 void SetVaryColor(Event *ev);
798 void SetFade(Event *ev);
799 void SetFadeDelay(Event *ev);
800 void SetSpawnRange(Event *ev);
801 void SetSpawnRate(Event *ev);
802 void SetOriginOffset(Event *ev);
803 void SetOffsetAlongAxis(Event *ev);
804 void SetCone(Event *ev);
805 void SetCircle(Event *ev);
806 void SetSphere(Event *ev);
807 void SetInwardSphere(Event *ev);
808 void SetRandomRoll(Event *ev);
809 void SetVolumetric(Event *ev);
810 void SetSwarm(Event *ev);
811 void SetAlign(Event *ev);
812 void SetAlignOnce(Event *ev);
813 void SetCollision(Event *ev);
814 void SetFlickerAlpha(Event *ev);
815 void SetFadeIn(Event *ev);
816 void SetEntityColor(Event *ev);
817 void SetGlobalFade(Event *ev);
818 void SetRadius(Event *ev);
819 void SetParentLink(Event *ev);
820 void SetHardLink(Event *ev);
821 void SetAngles(Event *ev);
822 void SetRelativeAngles(Event *ev);
823 void ParentAngles(Event *ev);
824 void EmitterAngles(Event *ev);
825 void SetTwinkle(Event *ev);
826 void SetTrail(Event *ev);
827 void SetPhysicsRate(Event *ev);
828 void SetBounceDecal(Event *ev);
829 void UpdateSwarm(ctempmodel_t *p);
830 void BeginOriginSpawn(Event *ev);
831 void EndOriginSpawn(void);
832 void BeginOriginBeamSpawn(Event *ev);
833 void EndOriginBeamSpawn(void);
834 void BeginOriginBeamEmitter(Event *ev);
835 void EndOriginBeamEmitter(void);
836 void BeginTagSpawn(Event *ev);
837 void BeginTagSpawnLinked(Event *ev);
838 void EndTagSpawn(void);
839 void BeginTagBeamSpawn(Event *ev);
840 void EndTagBeamSpawn(void);
841 void BeginTagEmitter(Event *ev);
842 void EndTagEmitter(void);
843 void BeginOriginEmitter(Event *ev);
844 void EndOriginEmitter(void);
845 void BeginTagBeamEmitter(Event *ev);
846 void EndTagBeamEmitter(void);
847 void EmitterOn(Event *ev);
848 void EmitterOff(Event *ev);
849 void RainTouch(Event *ev);
850 void Sound(Event *ev);
851 void SetCurrentTiki(Event *ev);
852 void StopSound(Event *ev);
853 void StopAliasChannel(Event *ev);
854 void LoopSound(Event *ev);
855 void StopLoopSound(Event *ev); // Added in 2.0
856 void Cache(Event *ev);
857 void CacheImage(Event *ev);
858 void CacheFont(Event *ev);
859 void AliasCache(Event *ev);
860 void Alias(Event *ev);
861 void CacheAlias(Event *ev);
862 void Client(Event *ev);
863 void TagDynamicLight(Event *ev);
864 void OriginDynamicLight(Event *ev);
865 void DynamicLight(Event *ev);
866 void BlockDynamicLight(Event *ev);
867 void EndBlockDynamicLight();
868 void GetOrientation(int tagnum, spawnthing_t *sp);
869 void Swipe(Event *ev);
870 void SwipeOn(Event *ev);
871 void SwipeOff(Event *ev);
872 void AnimateOnce(Event *ev);
873 void SetAnim(Event *ev);
874 void SetDecalRadius(Event *ev);
875 void SetDecalOrientation(Event *ev);
876 void TagList(Event *ev);
877 void SetParallel(Event *ev);
878 void Footstep(Event *ev);
879 void LandingSound(Event *ev);
880 void BodyFallSound(Event *ev);
881 void SetAlwaysDraw(Event *ev);
882 void SetDetail(Event *ev);
883 void SetWindAffect(Event *ev);
884 void SpriteGridLighting(Event *ev);
885 void SetWaterOnly(Event *ev);
886 void SetAlignStretch(Event *ev);
887 void SetClampVel(Event *ev);
888 void SetClampVelAxis(Event *ev);
889 ctempmodel_t *AllocateTempModel(void);
890 qboolean TempModelPhysics(ctempmodel_t *p, float ftime, float scale);
891 qboolean TempModelRealtimeEffects(ctempmodel_t *p, float ftime, float scale);
892 qboolean LerpTempModel(refEntity_t *newEnt, ctempmodel_t *p, float frac);
893 void SpawnEffect(int count, int timealive);
894 void SpawnTempModel(int count);
895 void FreeTempModel(ctempmodel_t *le);
896 void AnimateTempModel(ctempmodel_t *ent, Vector origin, refEntity_t *newEnt);
897 void OtherTempModelEffects(ctempmodel_t *p, Vector origin, refEntity_t *newEnt);
898 qboolean IsBlockCommand(const str &name);
899 void SetBaseAndAmplitude(Event *ev, Vector &base, Vector &amplitude);
900
901 // Beam stuff
902 void SetSubdivisions(Event *ev);
903 void SetMinOffset(Event *ev);
904 void SetMaxOffset(Event *ev);
905 void SetShader(Event *ev);
906 void SetLength(Event *ev);
907 void SetBeamDelay(Event *ev);
908 void SetBeamToggleDelay(Event *ev);
909 void SetBeamPersist(Event *ev);
910 void SetBeamOffsetEndpoints(Event *ev);
911 void SetBeamSphere(Event *ev);
912 void SetSpread(Event *ev);
913 void SetUseLastTraceEnd(Event *ev);
914 void SetEndAlpha(Event *ev);
915 void SetEyeLimits(Event *ev);
916 void SetEyeMovement(Event *ev);
917 void StartSFX(Event *ev);
918 void StartSFXDelayed(Event *ev);
919 void StartSFXCommand(Event *ev, qboolean bDelayed);
920 void EndIgnoreSfxBlock();
921 void RandomChance(Event *ev);
922 void DelayedRepeat(Event *ev);
923 void CommandDelay(Event *ev);
924 void SpawnTreads(Event *ev);
925 void TreadsOff(Event *ev);
926 bool GetTagPositionAndOrientation(int tagnum, orientation_t *new_or);
927 bool GetTagPositionAndOrientation(str tagname, orientation_t *new_or);
928
929public:
930 CLASS_PROTOTYPE(ClientGameCommandManager);
931
932 ClientGameCommandManager();
933 void AddTempModels(void);
934 void UpdateEmitter(dtiki_t *tiki, vec3_t axis[3], int entity_number, int parent_number, Vector entity_origin);
935 void UpdateBeam(dtiki_t *tiki, int entity_number, spawnthing_t *beamthing);
936 void PlaySound(
937 str sound_name,
938 const vec3_t origin = NULL,
939 int channel = CHAN_AUTO,
940 float volume = -1,
941 float min_distance = -1,
942 float pitch = -1,
943 int argstype = 0
944 );
945
946 spawnthing_t *InitializeSpawnthing(spawnthing_t *ep);
947 void SpawnEffect(int count, spawnthing_t *sp);
948 void FreeAllTempModels(void);
949 void FreeSomeTempModels(void);
950 void RestartAllEmitters(void);
951
952 void InitializeTempModels(void);
953 void InitializeTempModelCvars(void);
954 void InitializeEmitters(void);
955 void RemoveClientEntity(int number, dtiki_t *tiki, centity_t *cent, ctempmodel_t *p = NULL);
956 void ClearSwipes(void);
957 void FreeSpawnthing(spawnthing_t *sp);
958 void ResetTempModels(void);
959 void SpawnTempModel(int count, spawnthing_t *sp);
960
961 inline void SetSpawnthing(spawnthing_t *st) { m_spawnthing = st; };
962
963 spawnthing_t *CreateNewEmitter(str emittername);
964 spawnthing_t *CreateNewEmitter(void);
965 spawnthing_t *GetEmitterByName(str emittername);
966 void DeleteEmitters(dtiki_t *tiki);
967 void CGEvent(centity_t *cent);
968
969 void ProcessPendingEventsForEntity();
970 qboolean PostEventForEntity(Event *ev, float fWait);
971 qboolean SelectProcessEvent(Event *ev);
972
973 void TestEffectEndFunc();
974 void AddVSSSources();
975 void InitializeVSSCvars();
976 void InitializeVSSSources();
977 void ResetVSSSources();
978 void ResetVSSSources(Event *ev);
979 void SetCurrentSFX(specialeffect_t *pSFX);
980 void ClearCurrentSFX();
981 void AddTreadMarkSources();
982 void InitializeTreadMarkCvars();
983 void InitializeTreadMarkSources();
984 void ResetTreadMarkSources();
985 void ResetTreadMarkSources(Event *ev);
986 void InitializeRainCvars();
987 void InitializeBeams();
988
989 //
990 // archive stuff
991 //
992 int IdForTempModel(const ctempmodel_t *model);
993 ctempmodel_t *TempModelForId(int id);
994 int IdForSpawnThing(const spawnthing_t *sp);
995 spawnthing_t *SpawnThingForId(int id);
996 int IdForVssSource(const cvssource_t *source);
997 cvssource_t *VssSourceForId(int id);
998
999 void ArchiveTempModelPointerToMemory(MemArchiver& archiver, ctempmodel_t **model);
1000 void ArchiveSpawnThingPointerToMemory(MemArchiver& archiver, spawnthing_t **sp);
1001 void ArchiveVssSourcePointerToMemory(MemArchiver& archiver, cvssource_t **source);
1002 void ArchiveToMemory(MemArchiver& archiver);
1003};
1004
1005class EmitterLoader : public Listener
1006{
1007private:
1008 bool emitterActive;
1009
1010public:
1011 CLASS_PROTOTYPE(EmitterLoader);
1012
1013 EmitterLoader();
1014 bool Load(Script&);
1015 void ProcessEmitter(Script&);
1016 void Emitter(Event *ev);
1017};
1018
1019class EffectsEventQueueNode
1020{
1021public:
1022 Event *event;
1023 int inttime;
1024 int flags;
1025 int entity_num;
1026
1027 EffectsEventQueueNode *prev;
1028 EffectsEventQueueNode *next;
1029
1030#ifdef _DEBUG
1031 str name;
1032#endif
1033
1034 EffectsEventQueueNode()
1035 {
1036 prev = this;
1037 next = this;
1038 }
1039
1040 EffectsEventQueueNode(Event *event, int inttime, int flags, int entity_num)
1041 {
1042 this->event = event;
1043 this->inttime = inttime;
1044 this->flags = flags;
1045 this->entity_num = entity_num;
1046 }
1047
1048 int GetEntityNum() { return entity_num; }
1049};
1050
1051extern ClientGameCommandManager commandManager;
Definition cg_commands.h:742
Definition container.h:85
Definition listener.h:246
Definition memarchiver.h:36
Definition script.h:60
Definition vector.h:61
Definition cg_commands.h:718
Definition cg_commands.h:129
Definition cg_commands.h:574
Definition cg_commands.h:561
Definition cg_commands.h:231
Definition cg_commands.h:293
Definition cg_commands.h:365
Definition cg_commands.h:496
Definition cg_commands.h:480
Definition cg_commands.h:628
Definition cg_specialfx.h:162
Definition str.h:77
Definition cg_commands.h:382
Definition q_shared.h:1524
Definition tr_types.h:95
Definition cg_commands.h:376
Definition q_shared.h:1452