File: misc.h

package info (click to toggle)
openmohaa 0.82.1%2Bdfsg-1
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid
  • size: 34,192 kB
  • sloc: cpp: 315,720; ansic: 275,789; sh: 312; xml: 246; asm: 141; makefile: 7
file content (591 lines) | stat: -rw-r--r-- 13,689 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
/*
===========================================================================
Copyright (C) 2025 the OpenMoHAA team

This file is part of OpenMoHAA source code.

OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.

OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
===========================================================================
*/

// misc.h:
// Basically the big stew pot of the DLLs, or maybe a garbage bin, whichever
// metaphore you prefer.  This really should be cleaned up.  Anyway, this
// should contain utility functions that could be used by any entity.
// Right now it contains everything from entities that could be in their
// own file to my mother pot roast recipes.
//

#pragma once

#include "g_local.h"
#include "entity.h"
#include "mover.h"
#include "animate.h"

class InfoNull : public Listener
{
public:
    CLASS_PROTOTYPE(InfoNull);

    InfoNull();
};

class FuncRemove : public Entity
{
public:
    CLASS_PROTOTYPE(FuncRemove);

    FuncRemove();
};

class MiscModel : public Entity
{
public:
    CLASS_PROTOTYPE(MiscModel);

    MiscModel();
};

class InfoNotNull : public Entity
{
public:
    CLASS_PROTOTYPE(InfoNotNull);
};

class ExplodingWall : public Trigger
{
protected:
    int      dmg;
    int      explosions;
    float    attack_finished;
    Vector   land_angles;
    float    land_radius;
    float    angle_speed;
    int      state;
    Vector   base_velocity;
    Vector   random_velocity;
    Vector   orig_mins, orig_maxs;
    qboolean on_ground;

public:
    CLASS_PROTOTYPE(ExplodingWall);

    ExplodingWall();
    void Setup(Event *ev);
    void AngleSpeed(Event *ev);
    void LandRadius(Event *ev);
    void LandAngles(Event *ev);
    void BaseVelocity(Event *ev);
    void RandomVelocity(Event *ev);
    void SetDmg(Event *ev);
    void SetExplosions(Event *ev);
    void SetupSecondStage(void);
    void Explode(Event *ev);
    void DamageEvent(Event *ev) override;
    void GroundDamage(Event *ev);
    void TouchFunc(Event *ev);
    void StopRotating(Event *ev);
    void CheckOnGround(Event *ev);
    void Archive(Archiver& arc) override;
};

inline void ExplodingWall::Archive(Archiver& arc)
{
    Trigger::Archive(arc);

    arc.ArchiveInteger(&dmg);
    arc.ArchiveInteger(&explosions);
    arc.ArchiveFloat(&attack_finished);
    arc.ArchiveVector(&land_angles);
    arc.ArchiveFloat(&land_radius);
    arc.ArchiveFloat(&angle_speed);
    arc.ArchiveInteger(&state);
    arc.ArchiveVector(&base_velocity);
    arc.ArchiveVector(&random_velocity);
    arc.ArchiveVector(&orig_mins);
    arc.ArchiveVector(&orig_maxs);
    arc.ArchiveBoolean(&on_ground);
}

class Teleporter : public Trigger
{
public:
    ScriptThreadLabel teleport_label;
    qboolean          in_use;

    CLASS_PROTOTYPE(Teleporter);

    Teleporter();
    virtual void StartTeleport(Event *ev);
    virtual void Teleport(Event *ev);
    virtual void StopTeleport(Event *ev);
    void         SetThread(Event *ev);
    void         Archive(Archiver& arc) override;
};

inline void Teleporter::Archive(Archiver& arc)
{
    Trigger::Archive(arc);

    arc.ArchiveBoolean(&in_use);
}

class TeleporterDestination : public Entity
{
public:
    Vector movedir;

    CLASS_PROTOTYPE(TeleporterDestination);

    TeleporterDestination();
    void SetMoveDir(Event *ev);
    void Archive(Archiver& arc) override;
};

inline void TeleporterDestination::Archive(Archiver& arc)
{
    Entity::Archive(arc);

    arc.ArchiveVector(&movedir);
}

class UseAnim : public Entity
{
public:
    int               count;
    qboolean          active;
    ScriptThreadLabel thread;
    str               triggertarget;
    int               num_loops;
    str               state;
    str               camera;
    str               anim;
    str               key;
    float             delay;
    float             last_active_time;

    CLASS_PROTOTYPE(UseAnim);

    UseAnim();
    virtual void Touched(Event *ev);
    void         Reset(Event *ev);
    void         SetThread(Event *ev);
    void         SetTriggerTarget(Event *ev);
    void         SetCount(Event *ev);
    void         SetAnim(Event *ev);
    void         SetState(Event *ev);
    void         SetKey(Event *ev);
    void         SetCamera(Event *ev);
    void         SetNumLoops(Event *ev);
    void         SetDelay(Event *ev);
    bool         canBeUsed(Entity *activator);
    bool         GetInformation(
                Entity *activator, Vector *org, Vector *angles, str *animatoin, int *loopcount, str *state, str *camera
            );
    void TriggerTargets(Entity *activator);
    void Archive(Archiver& arc) override;
};

inline void UseAnim::Archive(Archiver& arc)
{
    Entity::Archive(arc);

    arc.ArchiveInteger(&count);
    arc.ArchiveBoolean(&active);
    arc.ArchiveString(&triggertarget);
    arc.ArchiveInteger(&num_loops);
    arc.ArchiveString(&state);
    arc.ArchiveString(&camera);
    arc.ArchiveString(&anim);
    arc.ArchiveString(&key);
    arc.ArchiveFloat(&delay);
    arc.ArchiveFloat(&last_active_time);
}

class TouchAnim : public UseAnim
{
public:
    CLASS_PROTOTYPE(TouchAnim);

    TouchAnim();
};

class UseAnimDestination : public Entity
{
public:
    int num_loops;
    str state;
    str anim;

    CLASS_PROTOTYPE(UseAnimDestination);

    UseAnimDestination();
    void SetAnim(Event *ev);
    void SetState(Event *ev);
    void SetNumLoops(Event *ev);
    int  GetNumLoops(void);
    str  GetAnim(void);
    str  GetState(void);
    void Archive(Archiver& arc) override;
};

inline void UseAnimDestination::Archive(Archiver& arc)
{
    Entity::Archive(arc);

    arc.ArchiveInteger(&num_loops);
    arc.ArchiveString(&state);
    arc.ArchiveString(&anim);
}

class UseObject : public Animate
{
public:
    ScriptThreadLabel move_thread;
    ScriptThreadLabel stop_thread;
    ScriptThreadLabel reset_thread;
    str               triggertarget;
    Vector            offset;
    float             yaw_offset;
    int               count;
    float             cone;
    str               state;
    str               state_backwards;
    str               useMaterial;
    int               objectState;
    float             reset_time;
    qboolean          active;

    CLASS_PROTOTYPE(UseObject);

    UseObject();
    void SetMoveThread(Event *ev);
    void SetStopThread(Event *ev);
    void SetResetThread(Event *ev);
    void SetTriggerTarget(Event *ev);
    void SetOffset(Event *ev);
    void SetYawOffset(Event *ev);
    void SetCount(Event *ev);
    void SetCone(Event *ev);
    void SetState(Event *ev);
    void SetBackwardsState(Event *ev);
    void SetResetTime(Event *ev);
    void Reset(Event *ev);
    void Resetting(Event *ev);
    void DamageTriggered(Event *ev);
    void DamageFunc(Event *ev);
    bool canBeUsed(Vector org, Vector dir);
    void Setup(Entity *activator, Vector *org, Vector *ang, str *newstate);
    void Start(Event *ev = NULL);
    bool Loop(void);
    void SetActiveState(Event *ev);
    void Stop(Entity *activator);
    void ActivateEvent(Event *ev);
    void DeactivateEvent(Event *ev);
    void UseMaterialEvent(Event *ev);
    void Archive(Archiver& arc) override;
};

inline void UseObject::Archive(Archiver& arc)
{
    Animate::Archive(arc);

    arc.ArchiveString(&triggertarget);
    arc.ArchiveVector(&offset);
    arc.ArchiveFloat(&yaw_offset);
    arc.ArchiveInteger(&count);
    arc.ArchiveFloat(&cone);
    arc.ArchiveString(&state);
    arc.ArchiveString(&state_backwards);
    arc.ArchiveString(&useMaterial);
    arc.ArchiveInteger(&objectState);
    arc.ArchiveFloat(&reset_time);
    arc.ArchiveBoolean(&active);
}

class Waypoint : public SimpleArchivedEntity
{
public:
    CLASS_PROTOTYPE(Waypoint);

public:
    Waypoint();
};

class TempWaypoint : public SimpleArchivedEntity
{
public:
    CLASS_PROTOTYPE(TempWaypoint);

public:
    TempWaypoint();
};

class VehiclePoint : public Waypoint
{
public:
    unsigned int spawnflags;

    CLASS_PROTOTYPE(VehiclePoint);

    VehiclePoint();

    void SetSpawnFlags(Event *ev);
    void Archive(Archiver& arc) override;
};

inline void VehiclePoint::Archive(Archiver& arc)
{
    SimpleArchivedEntity::Archive(arc);

    arc.ArchiveUnsigned(&spawnflags);
}

class MonkeyBars : public Entity
{
public:
    float dir;

    CLASS_PROTOTYPE(MonkeyBars);

    MonkeyBars();
    void SetAngleEvent(Event *ev);

    void Archive(Archiver& arc) override;
};

inline void MonkeyBars::Archive(Archiver& arc)
{
    Entity::Archive(arc);

    arc.ArchiveFloat(&dir);
}

class HorizontalPipe : public Entity
{
public:
    float dir;

    CLASS_PROTOTYPE(HorizontalPipe);

    HorizontalPipe();
    void SetAngleEvent(Event *ev);

    void Archive(Archiver& arc) override;
};

inline void HorizontalPipe::Archive(Archiver& arc)
{
    Entity::Archive(arc);

    arc.ArchiveFloat(&dir);
}

class TossObject : public Animate
{
private:
    str   bouncesound;
    float bouncesoundchance;
    void  Stop(Event *ev);
    void  Touch(Event *ev);
    void  SetBounceSound(Event *ev);
    void  SetBounceSoundChance(Event *ev);

public:
    CLASS_PROTOTYPE(TossObject);

    TossObject();
    TossObject(str modelname);
    void SetBounceSound(str bounce);
    void SetBounceSoundChance(float chance);
    void SetVelocity(float severity);
    void Archive(Archiver& arc) override;
};

inline void TossObject::Archive(Archiver& arc)
{
    Animate::Archive(arc);

    arc.ArchiveString(&bouncesound);
    arc.ArchiveFloat(&bouncesoundchance);
}

class PushObject : public Entity
{
private:
    EntityPtr owner;
    float     attack_finished;
    int       dmg;
    str       pushsound;

public:
    CLASS_PROTOTYPE(PushObject);

    PushObject();
    void     Start(Event *ev);
    void     SetDamage(Event *ev);
    void     BlockFunc(Event *ev);
    void     SetPushSound(Event *ev);
    qboolean Push(Entity *pusher, Vector move);
    qboolean canPush(Vector dir);

    Entity *getOwner(void);

    void Archive(Archiver& arc) override;
};

inline void PushObject::Archive(Archiver& arc)
{
    Entity::Archive(arc);

    arc.ArchiveSafePointer(&owner);
    arc.ArchiveFloat(&attack_finished);
    arc.ArchiveInteger(&dmg);
    arc.ArchiveString(&pushsound);
}

class FallingRock : public Entity
{
private:
    int     active;
    Vector  start_origin;
    Vector  last_bounce_origin;
    Entity *current;
    Entity *activator;
    Vector  bounce_dir;
    Vector  rotateaxis;
    float   attack_finished;
    float   wait;
    float   speed;
    int     dmg;
    str     bouncesound;

    void    Touch(Event *ev);
    void    Bounce(Event *ev);
    void    Rotate(Event *ev);
    void    Activate(Event *ev);
    void    NextBounce(void);
    void    StartFalling(Event *ev);
    void    SetWait(Event *ev);
    void    SetSpeed(Event *ev);
    void    SetDmg(Event *ev);
    Entity *SetNextBounceDir(void);
    void    SetBounceSound(str sound);
    void    SetBounceSound(Event *ev);
    void    Archive(Archiver& arc) override;

public:
    CLASS_PROTOTYPE(FallingRock);

    FallingRock();
};

inline void FallingRock::Archive(Archiver& arc)
{
    Entity::Archive(arc);

    arc.ArchiveInteger(&active);
    arc.ArchiveVector(&start_origin);
    arc.ArchiveVector(&last_bounce_origin);
    arc.ArchiveObjectPointer((Class **)&current);
    arc.ArchiveObjectPointer((Class **)&activator);
    arc.ArchiveVector(&bounce_dir);
    arc.ArchiveVector(&rotateaxis);
    arc.ArchiveFloat(&attack_finished);
    arc.ArchiveFloat(&wait);
    arc.ArchiveFloat(&speed);
    arc.ArchiveInteger(&dmg);
    arc.ArchiveString(&bouncesound);
    if (arc.Loading()) {
        SetBounceSound(bouncesound);
    }
}

class SupplyWater : public Trigger
{
private:
    int maxwater;
    int amount;

public:
    CLASS_PROTOTYPE(SupplyWater);

    SupplyWater();
    void Activate(Event *ev);
    void MaxWater(Event *ev);
    void ChargeOff(Event *ev);
    void Archive(Archiver& arc) override;
};

inline void SupplyWater::Archive(Archiver& arc)
{
    Trigger::Archive(arc);

    arc.ArchiveInteger(&amount);
    arc.ArchiveInteger(&maxwater);
}

class FuncLadder : public Entity
{
private:
    Vector m_vFacingAngles;
    Vector m_vFacingDir;

public:
    CLASS_PROTOTYPE(FuncLadder);

    FuncLadder();

    void LadderSetup(Event *ev);

    qboolean CanUseLadder(Entity *pUser);
    void     PositionOnLadder(Entity *pUser);

    void SetLadderFacing(Event *ev);
    void AdjustPositionOnLadder(Entity *pUser);

    void EnsureOverLadder(Entity *pUser);
    void EnsureForwardOffLadder(Entity *pUser);

    const Vector& getFacingAngles() const;
    const Vector& getFacingDir() const;

    void Archive(Archiver& arc) override;
};

inline void FuncLadder::Archive(Archiver& arc)
{
    Entity::Archive(arc);

    arc.ArchiveVector(&m_vFacingAngles);
    arc.ArchiveVector(&m_vFacingDir);
}

class InfoLandmark : public Listener
{
private:
    str    m_sName;
    Vector m_vOrigin;
    bool   m_bNameSet;
    bool   m_bOriginSet;

public:
    CLASS_PROTOTYPE(InfoLandmark);

    InfoLandmark();
    void SetLandmarkName(Event *ev);
    void SetOrigin(Event *ev);
};