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
|
/*
===========================================================================
Copyright (C) 2024 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
===========================================================================
*/
// weaputils.h:
//
#pragma once
#include "g_local.h"
#include "animate.h"
#include "beam.h"
#define P_BOUNCE_TOUCH 0x00000001
#define P_CHARGE_LIFE 0x00000002
#define P_CHARGE_SPEED 0x00000004
#define P_NO_TOUCH_DAMAGE 0x00000008
#define P_FUSE 0x00000010
extern Event EV_Projectile_Explode;
extern Event EV_Projectile_UpdateBeam;
class Weapon;
class Sentient;
class Projectile : public Animate
{
public:
CLASS_PROTOTYPE( Projectile );
int owner;
float speed;
float minspeed;
float damage;
float knockback;
float life;
float dmlife;
float minlife;
float dlight_radius;
float charge_fraction;
SafePtr<Weapon> weap;
Vector dlight_color;
Vector addvelocity;
meansOfDeath_t meansofdeath;
class FuncBeam *m_beam;
int projFlags;
str bouncesound;
str bouncesound_metal;
str bouncesound_hard;
str bouncesound_water;
float fLastBounceTime;
str impactmarkshader;
str impactmarkorientation;
float impactmarkradius;
str explosionmodel;
SafePtr<Entity> target;
float fDrunk;
float fDrunkRate;
bool addownervelocity;
bool can_hit_owner;
bool remove_when_stopped;
bool m_bExplodeOnTouch;
bool m_bHurtOwnerOnly;
int m_iSmashThroughGlass;
// Added in 2.0
bool m_bArcToTarget;
// Added in 2.30
bool m_bDieInWater;
// Added in 2.0
int m_iTeam;
bool m_bHadPlayerOwner;
SafePtr<Entity> m_pOwnerPtr;
Projectile();
void Archive( Archiver &arc ) override;
virtual void Touch( Event *ev );
virtual void Explode( Event *ev );
virtual void DoDecal( void );
void SetAvelocity( Event *ev );
void SetAddVelocity( Event *ev );
void SetDLight( Event *ev );
void SetLife( Event *ev );
void SetDMLife( Event *ev );
void SetMinLife( Event *ev );
void SetChargeLife( Event *ev );
void SetFuse( Event *ev ); // Added in 2.0
void SetSpeed( Event *ev );
void SetMinSpeed( Event *ev );
void SetChargeSpeed( Event *ev );
void SetDamage( Event *ev );
void SetKnockback( Event *ev );
void SetProjectileDLight( Event *ev );
void SetMeansOfDeath( Event *ev );
void SetBounceTouch( Event *ev );
void SetBounceSound( Event *ev );
void SetBounceSoundMetal( Event *ev );
void SetBounceSoundHard( Event *ev );
void SetBounceSoundWater( Event *ev );
void SetNoTouchDamage( Event *ev );
void SetImpactMarkShader( Event *ev );
void SetImpactMarkRadius( Event *ev );
void SetImpactMarkOrientation( Event *ev );
void SetExplosionModel( Event *ev );
void SetSmashThroughGlass( Event *ev );
void UpdateBeam( Event *ev );
void BeamCommand( Event *ev );
void HeatSeek( Event *ev );
void Drunk( Event *ev );
void SmashThroughGlassThink( Event *ev );
void AddOwnerVelocity( Event *ev );
void Prethink( Event *ev );
float ResolveMinimumDistance( Entity *potential_target, float currmin );
float AdjustAngle( float maxadjust, float currangle, float targetangle );
void SetCanHitOwner( Event *ev );
void ClearOwner( Event *ev );
void RemoveWhenStopped( Event *ev );
void ExplodeOnTouch( Event *ev );
void Stopped( Event *ev );
void Think() override;
Sentient *GetOwner( void );
void SetOwner(Entity* owner); // Added in 2.0
void SetMartyr( int entnum );
void ArcToTarget(Event* ev);
void BecomeBomb(Event* ev);
void DieInWater(Event* ev);
//
// Added in OPM
//
bool CheckTeams( void );
};
inline void Projectile::SetMartyr(int entnum)
{
owner = entnum;
m_bHurtOwnerOnly = true;
}
inline void Projectile::Archive
(
Archiver &arc
)
{
Animate::Archive( arc );
arc.ArchiveInteger( &owner );
arc.ArchiveFloat( &speed );
arc.ArchiveFloat( &minspeed );
arc.ArchiveFloat( &damage );
arc.ArchiveFloat( &knockback );
arc.ArchiveFloat( &life );
arc.ArchiveFloat( &dmlife );
arc.ArchiveFloat( &minlife );
arc.ArchiveFloat( &dlight_radius );
arc.ArchiveFloat( &charge_fraction );
arc.ArchiveVector( &dlight_color );
arc.ArchiveVector( &addvelocity );
ArchiveEnum( meansofdeath, meansOfDeath_t );
arc.ArchiveObjectPointer( ( Class ** )&m_beam );
arc.ArchiveInteger( &projFlags );
arc.ArchiveString( &bouncesound );
arc.ArchiveString( &bouncesound_metal );
arc.ArchiveString( &bouncesound_hard );
arc.ArchiveString( &bouncesound_water );
arc.ArchiveFloat( &fLastBounceTime );
arc.ArchiveString( &impactmarkshader );
arc.ArchiveString( &impactmarkorientation );
arc.ArchiveFloat( &impactmarkradius );
arc.ArchiveString( &explosionmodel );
arc.ArchiveFloat( &fDrunk );
arc.ArchiveFloat( &fDrunkRate );
arc.ArchiveBool( &addownervelocity );
arc.ArchiveBool( &can_hit_owner );
arc.ArchiveBool( &remove_when_stopped );
arc.ArchiveBool( &m_bExplodeOnTouch );
arc.ArchiveBool( &m_bHurtOwnerOnly );
}
class Explosion : public Projectile
{
public:
float flash_r,
flash_g,
flash_b,
flash_a,
flash_radius,
flash_time;
int flash_type;
float radius_damage;
bool hurtOwnerOnly;
CLASS_PROTOTYPE( Explosion );
float radius;
qboolean constant_damage;
qboolean damage_every_frame;
Explosion();
void SetRadius( Event *ev );
void SetRadiusDamage( Event *ev );
void SetConstantDamage( Event *ev );
void SetDamageEveryFrame( Event *ev );
void SetFlash( Event *ev );
void MakeExplosionEffect( Event *ev );
void DamageAgain( Event *ev );
void Archive( Archiver &arc ) override;
};
inline void Explosion::Archive
(
Archiver &arc
)
{
Projectile::Archive( arc );
arc.ArchiveFloat( &flash_r );
arc.ArchiveFloat( &flash_g );
arc.ArchiveFloat( &flash_b );
arc.ArchiveFloat( &flash_a );
arc.ArchiveFloat( &flash_radius );
arc.ArchiveFloat( &flash_time );
arc.ArchiveInteger( &flash_type );
arc.ArchiveFloat( &radius_damage );
}
qboolean MeleeAttack
(
Vector pos,
Vector end,
float damage,
Entity *attacker,
meansOfDeath_t means_of_death,
float attack_width,
float attack_min_height,
float attack_max_height,
float knockback = 0,
qboolean hit_dead = true,
Container<Entity *>*victimlist=NULL
);
Projectile *ProjectileAttack
(
Vector start,
Vector dir,
Entity *owner,
str projectileModel,
float speedfraction,
float real_speed = 0,
Weapon *weap = NULL
);
void ExplosionAttack
(
Vector pos,
Entity *owner,
str projectileModel,
Vector dir = Vector( 0, 0, 0 ),
Entity *ignore = NULL,
float scale = 1.0f,
Weapon *weap = NULL,
bool hurtOwnerOnly = false
);
float BulletAttack
(
Vector start,
Vector vBarrel,
Vector dir,
Vector right,
Vector up,
float range,
float damage,
int bulletlarge,
float knockback,
int dflags,
int meansofdeath,
Vector spread,
int count,
Entity* owner,
int iTracerFrequency,
int* piTracerCount,
float bulletthroughwood,
float bulletthroughmetal,
Weapon* weap,
float tracerspeed
);
void FakeBulletAttack
(
Vector start,
Vector vBarrel,
Vector dir,
Vector right,
Vector up,
float range,
float damage,
int large,
Vector spread,
int count,
Entity* owner,
int iTracerFrequency,
int* piTracerCount,
float tracerspeed
);
void ClickItemAttack
(
Vector vStart,
Vector vForward,
float fRange,
Entity *pOwner
);
Projectile *HeavyAttack
(
Vector start,
Vector dir,
str projectileModel,
float real_speed,
Entity *owner,
Weapon *weap
);
void RadiusDamage
(
Vector origin,
Entity *inflictor,
Entity *attacker,
float damage,
Entity *ignore,
int mod,
float radius = 0,
float knockback = 0,
qboolean constant_damage = false,
Weapon *weap = NULL,
bool hurtOwnerOnly = false
);
const char* G_LocationNumToDispString(int iLocation);
Entity* FindDefusableObject(const Vector& dir, Entity* owner, float maxdist);
void DefuseObject(const Vector& dir, Entity* owner, float maxdist);
qboolean CanPlaceLandmine(const Vector& origin, Entity* owner);
void PlaceLandmine(const Vector& origin, Entity* owner, const str& model, Weapon* weap);
|