OpenMoHAA 0.82.1
Loading...
Searching...
No Matches
beam.h
1/*
2===========================================================================
3Copyright (C) 2024 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// beam.h: Beam
24
25#pragma once
26
27#include "g_local.h"
28#include "scriptslave.h"
29
30extern Event EV_FuncBeam_Activate;
31extern Event EV_FuncBeam_Deactivate;
32extern Event EV_FuncBeam_Diameter;
33extern Event EV_FuncBeam_Maxoffset;
34extern Event EV_FuncBeam_Minoffset;
35extern Event EV_FuncBeam_Overlap;
36extern Event EV_FuncBeam_Color;
37extern Event EV_FuncBeam_SetTarget;
38extern Event EV_FuncBeam_SetAngle;
39extern Event EV_FuncBeam_SetEndPoint;
40extern Event EV_FuncBeam_SetLife;
41extern Event EV_FuncBeam_Shader;
42extern Event EV_FuncBeam_Segments;
43extern Event EV_FuncBeam_Delay;
44extern Event EV_FuncBeam_NumSphereBeams;
45extern Event EV_FuncBeam_SphereRadius;
46extern Event EV_FuncBeam_ToggleDelay;
47extern Event EV_FuncBeam_FindEndpoint;
48extern Event EV_FuncBeam_EndAlpha;
49
50class FuncBeam : public ScriptSlave
51{
52protected:
53 SimpleEntityPtr end, origin_target;
54 float damage;
55 float life;
56 Vector end_point;
57 qboolean use_angles;
58 float shootradius;
59 str shader;
60
61 bool m_bIgnoreWalls;
62
63public:
64 CLASS_PROTOTYPE(FuncBeam);
65
66 FuncBeam();
67
68 void SetAngle(Event *ev);
69 void SetAngles(Event *ev);
70 void SetEndPoint(Event *ev);
71 void SetModel(Event *ev);
72 void SetDamage(Event *ev);
73 void SetOverlap(Event *ev);
74 void SetBeamStyle(Event *ev);
75 void SetLife(Event *ev);
76 void Activate(Event *ev);
77 void Deactivate(Event *ev);
78 void SetDiameter(Event *ev);
79 void SetMaxoffset(Event *ev);
80 void SetMinoffset(Event *ev);
81 void SetColor(Event *ev);
82 void SetSegments(Event *ev);
83 void SetBeamShader(str shader);
84 void SetBeamShader(Event *ev);
85 void SetBeamTileShader(Event *ev);
86 void SetDelay(Event *ev);
87 void SetToggleDelay(Event *ev);
88 void SetSphereRadius(Event *ev);
89 void SetNumSphereBeams(Event *ev);
90 void SetEndAlpha(Event *ev);
91 void SetShootRadius(Event *ev);
92 void SetPersist(Event *ev);
93 void FindEndpoint(Event *ev);
94 void UpdateEndpoint(Event *ev);
95 void UpdateOrigin(Event *ev);
96 void Shoot(Event *ev);
97 void SetIgnoreWalls(Event *ev);
98
99 void setAngles(Vector ang) override;
100 void Archive(Archiver& arc) override;
101
102 FuncBeam *CreateBeam(
103 const char *model,
104 const char *shader,
105 Vector start,
106 Vector end,
107 int numsegments = 4,
108 float scale = 1.0f,
109 float life = 1.0f,
110 float damage = 0.0f,
111 Entity *origin_target = NULL
112 );
113 friend FuncBeam *CreateBeam(
114 const char *model,
115 const char *shader,
116 Vector start,
117 Vector end,
118 int numsegments,
119 float scale,
120 float life,
121 float damage,
122 Entity *origin_target
123 );
124};
125
126inline void FuncBeam::Archive(Archiver& arc)
127{
128 ScriptSlave::Archive(arc);
129 arc.ArchiveSafePointer(&end);
130 arc.ArchiveSafePointer(&origin_target);
131 arc.ArchiveFloat(&damage);
132 arc.ArchiveFloat(&life);
133 arc.ArchiveVector(&end_point);
134 arc.ArchiveBoolean(&use_angles);
135 arc.ArchiveFloat(&shootradius);
136 arc.ArchiveString(&shader);
137 if (arc.Loading()) {
138 SetBeamShader(shader);
139 }
140}
Definition archive.h:86
Definition entity.h:203
Definition listener.h:246
Definition vector.h:61
Definition str.h:77