OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
weaputils.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// weaputils.h:
24//
25
26#pragma once
27
28#include "g_local.h"
29#include "animate.h"
30#include "beam.h"
31
32#define P_BOUNCE_TOUCH 0x00000001
33#define P_CHARGE_LIFE 0x00000002
34#define P_CHARGE_SPEED 0x00000004
35#define P_NO_TOUCH_DAMAGE 0x00000008
36#define P_FUSE 0x00000010
37
38extern Event EV_Projectile_Explode;
39extern Event EV_Projectile_UpdateBeam;
40
41class Weapon;
42class Sentient;
43
44class Projectile : public Animate
45{
46public:
47 CLASS_PROTOTYPE( Projectile );
48
49 int owner;
50 float speed;
51 float minspeed;
52 float damage;
53 float knockback;
54 float life;
55 float dmlife;
56 float minlife;
57 float dlight_radius;
58 float charge_fraction;
59
60 SafePtr<Weapon> weap;
61 Vector dlight_color;
62 Vector addvelocity;
63 meansOfDeath_t meansofdeath;
64 class FuncBeam *m_beam;
65 int projFlags;
66 str bouncesound;
67 str bouncesound_metal;
68 str bouncesound_hard;
69 str bouncesound_water;
70 float fLastBounceTime;
71 str impactmarkshader;
72 str impactmarkorientation;
73 float impactmarkradius;
74 str explosionmodel;
75 SafePtr<Entity> target;
76 float fDrunk;
77 float fDrunkRate;
78 bool addownervelocity;
79 bool can_hit_owner;
80 bool remove_when_stopped;
81 bool m_bExplodeOnTouch;
82 bool m_bHurtOwnerOnly;
83 int m_iSmashThroughGlass;
84 // Added in 2.0
85 bool m_bArcToTarget;
86 // Added in 2.30
87 bool m_bDieInWater;
88 // Added in 2.0
89 int m_iTeam;
90
91 //
92 // Added in OPM
93 //
94 bool m_bHadPlayerOwner;
95 SafePtr<Entity> m_pOwnerPtr;
96
97 Projectile();
98 void Archive( Archiver &arc ) override;
99 virtual void Touch( Event *ev );
100 virtual void Explode( Event *ev );
101 virtual void DoDecal( void );
102
103 void SetAvelocity( Event *ev );
104 void SetAddVelocity( Event *ev );
105 void SetDLight( Event *ev );
106 void SetLife( Event *ev );
107 void SetDMLife( Event *ev );
108 void SetMinLife( Event *ev );
109 void SetChargeLife( Event *ev );
110 void SetFuse( Event *ev ); // Added in 2.0
111 void SetSpeed( Event *ev );
112 void SetMinSpeed( Event *ev );
113 void SetChargeSpeed( Event *ev );
114 void SetDamage( Event *ev );
115 void SetKnockback( Event *ev );
116 void SetProjectileDLight( Event *ev );
117 void SetMeansOfDeath( Event *ev );
118 void SetBounceTouch( Event *ev );
119 void SetBounceSound( Event *ev );
120 void SetBounceSoundMetal( Event *ev );
121 void SetBounceSoundHard( Event *ev );
122 void SetBounceSoundWater( Event *ev );
123 void SetNoTouchDamage( Event *ev );
124 void SetImpactMarkShader( Event *ev );
125 void SetImpactMarkRadius( Event *ev );
126 void SetImpactMarkOrientation( Event *ev );
127 void SetExplosionModel( Event *ev );
128 void SetSmashThroughGlass( Event *ev );
129 void UpdateBeam( Event *ev );
130 void BeamCommand( Event *ev );
131 void HeatSeek( Event *ev );
132 void Drunk( Event *ev );
133 void SmashThroughGlassThink( Event *ev );
134 void SmashThroughGlassThink(); // Added in OPM
135 void AddOwnerVelocity( Event *ev );
136 void Prethink( Event *ev );
137 float ResolveMinimumDistance( Entity *potential_target, float currmin );
138 float AdjustAngle( float maxadjust, float currangle, float targetangle );
139 void SetCanHitOwner( Event *ev );
140 void ClearOwner( Event *ev );
141 void RemoveWhenStopped( Event *ev );
142 void ExplodeOnTouch( Event *ev );
143 void Stopped( Event *ev );
144 void Think() override;
145 Sentient *GetOwner( void );
146 void SetOwner(Entity* owner); // Added in 2.0
147 void SetMartyr( int entnum );
148 void ArcToTarget(Event* ev);
149 void BecomeBomb(Event* ev);
150 void DieInWater(Event* ev);
151 //
152 // Added in OPM
153 //
154 bool CheckTeams(void);
155};
156
157inline void Projectile::SetMartyr(int entnum)
158{
159 owner = entnum;
160 m_bHurtOwnerOnly = true;
161}
162
163inline void Projectile::Archive
164 (
165 Archiver &arc
166 )
167{
168 Animate::Archive( arc );
169
170 arc.ArchiveInteger( &owner );
171 arc.ArchiveFloat( &speed );
172 arc.ArchiveFloat( &minspeed );
173 arc.ArchiveFloat( &damage );
174 arc.ArchiveFloat( &knockback );
175 arc.ArchiveFloat( &life );
176 arc.ArchiveFloat( &dmlife );
177 arc.ArchiveFloat( &minlife );
178 arc.ArchiveFloat( &dlight_radius );
179 arc.ArchiveFloat( &charge_fraction );
180 arc.ArchiveVector( &dlight_color );
181 arc.ArchiveVector( &addvelocity );
182 ArchiveEnum( meansofdeath, meansOfDeath_t );
183 arc.ArchiveObjectPointer( ( Class ** )&m_beam );
184 arc.ArchiveInteger( &projFlags );
185 arc.ArchiveString( &bouncesound );
186 arc.ArchiveString( &bouncesound_metal );
187 arc.ArchiveString( &bouncesound_hard );
188 arc.ArchiveString( &bouncesound_water );
189 arc.ArchiveFloat( &fLastBounceTime );
190 arc.ArchiveString( &impactmarkshader );
191 arc.ArchiveString( &impactmarkorientation );
192 arc.ArchiveFloat( &impactmarkradius );
193 arc.ArchiveString( &explosionmodel );
194 arc.ArchiveFloat( &fDrunk );
195 arc.ArchiveFloat( &fDrunkRate );
196 arc.ArchiveBool( &addownervelocity );
197 arc.ArchiveBool( &can_hit_owner );
198 arc.ArchiveBool( &remove_when_stopped );
199 arc.ArchiveBool( &m_bExplodeOnTouch );
200 arc.ArchiveBool( &m_bHurtOwnerOnly );
201}
202
203class Explosion : public Projectile
204{
205 public:
206 float flash_r,
207 flash_g,
208 flash_b,
209 flash_a,
210 flash_radius,
211 flash_time;
212
213 int flash_type;
214 float radius_damage;
215 bool hurtOwnerOnly;
216
217 CLASS_PROTOTYPE( Explosion );
218
219 float radius;
220 qboolean constant_damage;
221 qboolean damage_every_frame;
222
223 Explosion();
224 void SetRadius( Event *ev );
225 void SetRadiusDamage( Event *ev );
226 void SetConstantDamage( Event *ev );
227 void SetDamageEveryFrame( Event *ev );
228 void SetFlash( Event *ev );
229 void MakeExplosionEffect( Event *ev );
230
231 void DamageAgain( Event *ev );
232
233 void Archive( Archiver &arc ) override;
234};
235
236inline void Explosion::Archive
237 (
238 Archiver &arc
239 )
240{
241 Projectile::Archive( arc );
242
243 arc.ArchiveFloat( &flash_r );
244 arc.ArchiveFloat( &flash_g );
245 arc.ArchiveFloat( &flash_b );
246 arc.ArchiveFloat( &flash_a );
247 arc.ArchiveFloat( &flash_radius );
248 arc.ArchiveFloat( &flash_time );
249 arc.ArchiveInteger( &flash_type );
250 arc.ArchiveFloat( &radius_damage );
251}
252
253qboolean MeleeAttack
254 (
255 Vector pos,
256 Vector end,
257 float damage,
258 Entity *attacker,
259 meansOfDeath_t means_of_death,
260 float attack_width,
261 float attack_min_height,
262 float attack_max_height,
263 float knockback = 0,
264 qboolean hit_dead = true,
265 Container<Entity *>*victimlist=NULL
266 );
267
268Projectile *ProjectileAttack
269 (
270 Vector start,
271 Vector dir,
272 Entity *owner,
273 str projectileModel,
274 float speedfraction,
275 float real_speed = 0,
276 Weapon *weap = NULL
277 );
278
279void ExplosionAttack
280(
281 Vector pos,
282 Entity *owner,
283 str projectileModel,
284 Vector dir = Vector( 0, 0, 0 ),
285 Entity *ignore = NULL,
286 float scale = 1.0f,
287 Weapon *weap = NULL,
288 bool hurtOwnerOnly = false
289);
290
291float BulletAttack
292 (
293 Vector start,
294 Vector vBarrel,
295 Vector dir,
296 Vector right,
297 Vector up,
298 float range,
299 float damage,
300 int bulletlarge,
301 float knockback,
302 int dflags,
303 int meansofdeath,
304 Vector spread,
305 int count,
306 Entity* owner,
307 int iTracerFrequency,
308 int* piTracerCount,
309 float bulletthroughwood,
310 float bulletthroughmetal,
311 Weapon* weap,
312 float tracerspeed
313 );
314
315void FakeBulletAttack
316 (
317 Vector start,
318 Vector vBarrel,
319 Vector dir,
320 Vector right,
321 Vector up,
322 float range,
323 float damage,
324 int large,
325 Vector spread,
326 int count,
327 Entity* owner,
328 int iTracerFrequency,
329 int* piTracerCount,
330 float tracerspeed
331 );
332
333void ClickItemAttack
334 (
335 Vector vStart,
336 Vector vForward,
337 float fRange,
338 Entity *pOwner
339 );
340
341Projectile *HeavyAttack
342 (
343 Vector start,
344 Vector dir,
345 str projectileModel,
346 float real_speed,
347 Entity *owner,
348 Weapon *weap
349 );
350
351void RadiusDamage
352 (
353 Vector origin,
354 Entity *inflictor,
355 Entity *attacker,
356 float damage,
357 Entity *ignore,
358 int mod,
359 float radius = 0,
360 float knockback = 0,
361 qboolean constant_damage = false,
362 Weapon *weap = NULL,
363 bool hurtOwnerOnly = false
364 );
365
366const char* G_LocationNumToDispString(int iLocation);
367Entity* FindDefusableObject(const Vector& dir, Entity* owner, float maxdist);
368void DefuseObject(const Vector& dir, Entity* owner, float maxdist);
369qboolean CanPlaceLandmine(const Vector& origin, Entity* owner);
370void PlaceLandmine(const Vector& origin, Entity* owner, const str& model, Weapon* weap);
Definition archive.h:86
Definition container.h:85
Definition entity.h:203
Definition listener.h:246
Definition beam.h:51
Definition weaputils.h:45
Definition safeptr.h:160
Definition sentient.h:95
Definition vector.h:61
Definition weapon.h:99
Definition str.h:77