1 /* 2 Copyright (C) 1997-2001 Id Software, Inc. 3 4 This program is free software; you can redistribute it and/or 5 modify it under the terms of the GNU General Public License 6 as published by the Free Software Foundation; either version 2 7 of the License, or (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 13 See the GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 */ 19 20 // 21 // cg_effects.h 22 // 23 24 /* 25 ============================================================================= 26 27 LIGHTING 28 29 ============================================================================= 30 */ 31 32 typedef struct cgDlight_s { 33 vec3_t origin; 34 vec3_t color; 35 36 int key; // so entities can reuse same entry 37 38 float radius; 39 float die; // stop lighting after this time 40 float decay; // drop this each second 41 float minlight; // don't add when contributing less 42 } cgDLight_t; 43 44 // 45 // cg_light.c 46 // 47 48 void CG_ClearLightStyles (void); 49 cgDLight_t *CG_AllocDLight (int key); 50 void CG_RunLightStyles (void); 51 void CG_SetLightstyle (int num); 52 void CG_AddLightStyles (void); 53 54 void CG_ClearDLights (void); 55 void CG_RunDLights (void); 56 void CG_AddDLights (void); 57 58 void CG_Flashlight (int ent, vec3_t pos); 59 void __fastcall CG_ColorFlash (vec3_t pos, int ent, float intensity, float r, float g, float b); 60 void CG_WeldingSparkFlash (vec3_t pos); 61 62 /* 63 ============================================================================= 64 65 EFFECTS 66 67 ============================================================================= 68 */ 69 70 enum { 71 // ----------- PARTICLES ---------- 72 PT_BFG_DOT, 73 74 PT_BLASTER_BLUE, 75 PT_BLASTER_GREEN, 76 PT_BLASTER_RED, 77 78 PT_IONTAIL, 79 PT_IONTIP, 80 PT_ITEMRESPAWN, 81 PT_ENGYREPAIR_DOT, 82 PT_PHALANXTIP, 83 84 PT_GENERIC, 85 PT_GENERIC_GLOW, 86 87 PT_SMOKE, 88 PT_SMOKE2, 89 90 PT_SMOKEGLOW, 91 PT_SMOKEGLOW2, 92 93 PT_BLUEFIRE, 94 PT_FIRE1, 95 PT_FIRE2, 96 PT_FIRE3, 97 PT_FIRE4, 98 PT_EMBERS1, 99 PT_EMBERS2, 100 PT_EMBERS3, 101 102 PT_BLOOD, 103 PT_BLOOD2, 104 PT_BLOOD3, 105 PT_BLOOD4, 106 PT_BLOOD5, 107 PT_BLOOD6, 108 109 PT_GRNBLOOD, 110 PT_GRNBLOOD2, 111 PT_GRNBLOOD3, 112 PT_GRNBLOOD4, 113 PT_GRNBLOOD5, 114 PT_GRNBLOOD6, 115 116 PT_BLDDRIP01, 117 PT_BLDDRIP02, 118 PT_BLDDRIP01_GRN, 119 PT_BLDDRIP02_GRN, 120 PT_BLDSPURT, 121 PT_BLDSPURT2, 122 123 PT_BEAM, 124 125 PT_EXPLOFLASH, 126 PT_EXPLOWAVE, 127 128 PT_FLARE, 129 PT_FLAREGLOW, 130 131 PT_FLY, 132 133 PT_RAIL_CORE, 134 PT_RAIL_WAVE, 135 PT_RAIL_SPIRAL, 136 137 PT_SPARK, 138 139 PT_WATERBUBBLE, 140 PT_WATERDROPLET, 141 PT_WATERIMPACT, 142 PT_WATERMIST, 143 PT_WATERMIST_GLOW, 144 PT_WATERPLUME, 145 PT_WATERPLUME_GLOW, 146 PT_WATERRING, 147 PT_WATERRIPPLE, 148 // ----------- ANIMATED ----------- 149 PT_EXPLO1, 150 PT_EXPLO2, 151 PT_EXPLO3, 152 PT_EXPLO4, 153 PT_EXPLO5, 154 PT_EXPLO6, 155 PT_EXPLO7, 156 157 PT_EXPLOEMBERS1, 158 PT_EXPLOEMBERS2, 159 160 // ------------- MAPFX ------------ 161 MFX_WHITE, 162 MFX_CORONA, 163 164 // ------------- TOTAL ------------ 165 PT_PICTOTAL 166 }; 167 168 enum { 169 // ------------ DECALS ------------ 170 DT_BFG_BURNMARK, 171 DT_BFG_GLOWMARK, 172 173 DT_BLASTER_BLUEMARK, 174 DT_BLASTER_BURNMARK, 175 DT_BLASTER_GREENMARK, 176 DT_BLASTER_REDMARK, 177 178 DT_DRONE_SPIT_GLOW, 179 180 DT_ENGYREPAIR_BURNMARK, 181 DT_ENGYREPAIR_GLOWMARK, 182 183 DT_BLOOD01, 184 DT_BLOOD02, 185 DT_BLOOD03, 186 DT_BLOOD04, 187 DT_BLOOD05, 188 DT_BLOOD06, 189 DT_BLOOD07, 190 DT_BLOOD08, 191 DT_BLOOD09, 192 DT_BLOOD10, 193 DT_BLOOD11, 194 DT_BLOOD12, 195 DT_BLOOD13, 196 DT_BLOOD14, 197 DT_BLOOD15, 198 DT_BLOOD16, 199 200 DT_BLOOD01_GRN, 201 DT_BLOOD02_GRN, 202 DT_BLOOD03_GRN, 203 DT_BLOOD04_GRN, 204 DT_BLOOD05_GRN, 205 DT_BLOOD06_GRN, 206 DT_BLOOD07_GRN, 207 DT_BLOOD08_GRN, 208 DT_BLOOD09_GRN, 209 DT_BLOOD10_GRN, 210 DT_BLOOD11_GRN, 211 DT_BLOOD12_GRN, 212 DT_BLOOD13_GRN, 213 DT_BLOOD14_GRN, 214 DT_BLOOD15_GRN, 215 DT_BLOOD16_GRN, 216 217 DT_BULLET, 218 219 DT_EXPLOMARK, 220 DT_EXPLOMARK2, 221 DT_EXPLOMARK3, 222 223 DT_RAIL_BURNMARK, 224 DT_RAIL_GLOWMARK, 225 DT_RAIL_WHITE, 226 227 DT_SLASH, 228 DT_SLASH2, 229 DT_SLASH3, 230 // ------------- TOTAL ------------ 231 DT_PICTOTAL 232 }; 233 234 extern vec3_t cg_randVels[NUMVERTEXNORMALS]; 235 236 /* 237 ============================================================================= 238 239 SCRIPTED MAP EFFECTS 240 241 ============================================================================= 242 */ 243 244 void CG_AddMapFXToList (void); 245 246 void CG_MapFXLoad (char *mapName); 247 void CG_MapFXClear (void); 248 249 void CG_MapFXInit (void); 250 void CG_MapFXShutdown (void); 251 252 /* 253 ============================================================================= 254 255 DECAL SYSTEM 256 257 ============================================================================= 258 */ 259 260 typedef struct cgDecal_s { 261 struct cgDecal_s *prev; 262 struct cgDecal_s *next; 263 264 refDecal_t refDecal; 265 266 float time; 267 268 vec4_t color; 269 vec4_t colorVel; 270 271 float size; 272 273 float lifeTime; 274 275 struct shader_s *shader; 276 uint32 flags; 277 278 void (*think)(struct cgDecal_s *d, vec4_t color, int *type, uint32 *flags); 279 qBool thinkNext; 280 } cgDecal_t; 281 282 enum { 283 DF_USE_BURNLIFE = 1 << 0, 284 DF_FIXED_LIFE = 1 << 1, 285 DF_ALPHACOLOR = 1 << 2, 286 }; 287 288 cgDecal_t *CG_SpawnDecal(float org0, float org1, float org2, 289 float dir0, float dir1, float dir2, 290 float red, float green, float blue, 291 float redVel, float greenVel, float blueVel, 292 float alpha, float alphaVel, 293 float size, 294 int type, uint32 flags, 295 void (*think)(struct cgDecal_s *d, vec4_t color, int *type, uint32 *flags), 296 qBool thinkNext, 297 float lifeTime, float angle); 298 299 // constants 300 #define DECAL_INSTANT -10000.0f 301 302 // random texturing 303 int dRandBloodMark (void); 304 int dRandGrnBloodMark (void); 305 int dRandExploMark (void); 306 int dRandSlashMark (void); 307 308 // management 309 void CG_ClearDecals (void); 310 void CG_AddDecals (void); 311 312 /* 313 ============================================================================= 314 315 PARTICLE SYSTEM 316 317 ============================================================================= 318 */ 319 320 enum { 321 PF_SCALED = 1 << 0, 322 323 PF_SHADE = 1 << 1, 324 PF_GRAVITY = 1 << 2, 325 PF_NOCLOSECULL = 1 << 3, 326 PF_NODECAL = 1 << 4, 327 PF_NOSFX = 1 << 5, 328 PF_ALPHACOLOR = 1 << 6, 329 330 PF_AIRONLY = 1 << 7, 331 PF_LAVAONLY = 1 << 8, 332 PF_SLIMEONLY = 1 << 9, 333 PF_WATERONLY = 1 << 10, 334 335 // Special 336 PF_GREENBLOOD = 1 << 11, 337 }; 338 339 enum { 340 PART_STYLE_QUAD, 341 342 PART_STYLE_ANGLED, 343 PART_STYLE_BEAM, 344 PART_STYLE_DIRECTION 345 }; 346 347 typedef struct cgParticle_s { 348 struct cgParticle_s *prev; 349 struct cgParticle_s *next; 350 351 float time; 352 353 vec3_t org; 354 vec3_t oldOrigin; 355 356 vec3_t angle; 357 vec3_t vel; 358 vec3_t accel; 359 360 vec4_t color; 361 vec4_t colorVel; 362 363 float size; 364 float sizeVel; 365 366 struct shader_s *shader; 367 byte style; 368 uint32 flags; 369 370 float orient; 371 372 void (*think)(struct cgParticle_s *p, vec3_t org, vec3_t angle, vec4_t color, float *size, float *orient, float *time); 373 qBool thinkNext; 374 375 // Passed to refresh 376 refPoly_t outPoly; 377 bvec4_t outColor[4]; 378 vec2_t outCoords[4]; 379 vec3_t outVertices[4]; 380 } cgParticle_t; 381 382 void CG_SpawnParticle (float org0, float org1, float org2, 383 float angle0, float angle1, float angle2, 384 float vel0, float vel1, float vel2, 385 float accel0, float accel1, float accel2, 386 float red, float green, float blue, 387 float redVel, float greenVel, float blueVel, 388 float alpha, float alphaVel, 389 float size, float sizeVel, 390 uint32 type, uint32 flags, 391 void (*think)(struct cgParticle_s *p, vec3_t org, vec3_t angle, vec4_t color, float *size, float *orient, float *time), 392 qBool thinkNext, 393 byte style, 394 float orient); 395 396 // constants 397 #define PMAXBLDDRIPLEN 3.25f 398 #define PMAXSPLASHLEN 2.0f 399 400 #define PART_GRAVITY 110 401 #define PART_INSTANT -1000.0f 402 403 #define BEAMLENGTH 16 404 405 // random texturing 406 int pRandBloodDrip (void); 407 int pRandGrnBloodDrip (void); 408 int pRandBloodMark (void); 409 int pRandGrnBloodMark (void); 410 int pRandSmoke (void); 411 int pRandGlowSmoke (void); 412 int pRandEmbers (void); 413 int pRandFire (void); 414 415 // management 416 void CG_ClearParticles (void); 417 void CG_AddParticles (void); 418 419 // 420 // GENERIC EFFECTS 421 // 422 423 void CG_BlasterBlueParticles (vec3_t org, vec3_t dir); 424 void CG_BlasterGoldParticles (vec3_t org, vec3_t dir); 425 void CG_BlasterGreenParticles (vec3_t org, vec3_t dir); 426 void CG_BlasterGreyParticles (vec3_t org, vec3_t dir); 427 void CG_BleedEffect (vec3_t org, vec3_t dir, int count); 428 void CG_BleedGreenEffect (vec3_t org, vec3_t dir, int count); 429 void CG_BubbleEffect (vec3_t origin); 430 void CG_ExplosionBFGEffect (vec3_t org); 431 void __fastcall CG_FlareEffect (vec3_t origin, int type, float orient, float size, float sizevel, int color, int colorvel, float alpha, float alphavel); 432 void CG_ItemRespawnEffect (vec3_t org); 433 void CG_LogoutEffect (vec3_t org, int type); 434 435 void __fastcall CG_ParticleEffect (vec3_t org, vec3_t dir, int color, int count); 436 void __fastcall CG_ParticleEffect2 (vec3_t org, vec3_t dir, int color, int count); 437 void __fastcall CG_ParticleEffect3 (vec3_t org, vec3_t dir, int color, int count); 438 void __fastcall CG_ParticleSmokeEffect (vec3_t org, vec3_t dir, int color, int count, int magnitude); 439 void __fastcall CG_RicochetEffect (vec3_t org, vec3_t dir, int count); 440 441 void CG_RocketFireParticles (vec3_t org, vec3_t dir); 442 443 void __fastcall CG_SparkEffect (vec3_t org, vec3_t dir, int color, int colorvel, int count, float smokeScale, float lifeScale); 444 void __fastcall CG_SplashParticles (vec3_t org, vec3_t dir, int color, int count, qBool glow); 445 void __fastcall CG_SplashEffect (vec3_t org, vec3_t dir, int color, int count); 446 447 void CG_BigTeleportParticles (vec3_t org); 448 void CG_BlasterTip (vec3_t start, vec3_t end); 449 void CG_ExplosionParticles (vec3_t org, float scale, qBool exploonly, qBool inwater); 450 void CG_ExplosionBFGParticles (vec3_t org); 451 void CG_ExplosionColorParticles (vec3_t org); 452 void CG_FlyEffect (cgEntity_t *ent, vec3_t origin); 453 void CG_ForceWall (vec3_t start, vec3_t end, int color); 454 void CG_MonsterPlasma_Shell (vec3_t origin); 455 void CG_PhalanxTip (vec3_t start, vec3_t end); 456 void CG_TeleportParticles (vec3_t org); 457 void CG_TeleporterParticles (entityState_t *ent); 458 void CG_TrackerShell (vec3_t origin); 459 void CG_TrapParticles (refEntity_t *ent); 460 void CG_WidowSplash (vec3_t org); 461 462 // 463 // GLOOM EFFECTS 464 // 465 466 void CG_GloomBlobTip (vec3_t start, vec3_t end); 467 void CG_GloomDroneEffect (vec3_t org, vec3_t dir); 468 void CG_GloomEmberTrail (vec3_t start, vec3_t end); 469 void CG_GloomFlareTrail (vec3_t start, vec3_t end); 470 void CG_GloomGasEffect (vec3_t origin); 471 void CG_GloomRepairEffect (vec3_t org, vec3_t dir, int count); 472 void CG_GloomStingerFire (vec3_t start, vec3_t end, float size, qBool light); 473 474 // 475 // SUSTAINED EFFECTS 476 // 477 478 void __fastcall CG_ParticleSteamEffect (vec3_t org, vec3_t dir, int color, int count, int magnitude); 479 480 void CG_ParseNuke (void); 481 void CG_ParseSteam (void); 482 void CG_ParseWidow (void); 483 484 void CG_ClearSustains (void); 485 void CG_AddSustains (void); 486 487 // 488 // TRAIL EFFECTS 489 // 490 491 void __fastcall CG_BeamTrail (vec3_t start, vec3_t end, int color, float size, float alpha, float alphaVel); 492 void CG_BfgTrail (refEntity_t *ent); 493 void CG_BlasterGoldTrail (vec3_t start, vec3_t end); 494 void CG_BlasterGreenTrail (vec3_t start, vec3_t end); 495 void CG_BubbleTrail (vec3_t start, vec3_t end); 496 void CG_BubbleTrail2 (vec3_t start, vec3_t end, int dist); 497 void CG_DebugTrail (vec3_t start, vec3_t end); 498 void CG_FlagTrail (vec3_t start, vec3_t end, int flags); 499 void CG_GibTrail (vec3_t start, vec3_t end, int flags); 500 void CG_GrenadeTrail (vec3_t start, vec3_t end); 501 void CG_Heatbeam (vec3_t start, vec3_t forward); 502 void CG_IonripperTrail (vec3_t start, vec3_t end); 503 void CG_QuadTrail (vec3_t start, vec3_t end); 504 void CG_RailTrail (vec3_t start, vec3_t end); 505 void CG_RocketTrail (vec3_t start, vec3_t end); 506 void CG_TagTrail (vec3_t start, vec3_t end); 507 void CG_TrackerTrail (vec3_t start, vec3_t end); 508 509 // 510 // PARTICLE THINK FUNCTIONS 511 // 512 513 void pBloodDripThink (struct cgParticle_s *p, vec3_t org, vec3_t angle, vec4_t color, float *size, float *orient, float *time); 514 void pBloodThink (struct cgParticle_s *p, vec3_t org, vec3_t angle, vec4_t color, float *size, float *orient, float *time); 515 void pBounceThink (struct cgParticle_s *p, vec3_t org, vec3_t angle, vec4_t color, float *size, float *orient, float *time); 516 void pDropletThink (struct cgParticle_s *p, vec3_t org, vec3_t angle, vec4_t color, float *size, float *orient, float *time); 517 void pExploAnimThink (struct cgParticle_s *p, vec3_t org, vec3_t angle, vec4_t color, float *size, float *orient, float *time); 518 void pFastSmokeThink (struct cgParticle_s *p, vec3_t org, vec3_t angle, vec4_t color, float *size, float *orient, float *time); 519 void pFireThink (struct cgParticle_s *p, vec3_t org, vec3_t angle, vec4_t color, float *size, float *orient, float *time); 520 void pFireTrailThink (struct cgParticle_s *p, vec3_t org, vec3_t angle, vec4_t color, float *size, float *orient, float *time); 521 void pFlareThink (struct cgParticle_s *p, vec3_t org, vec3_t angle, vec4_t color, float *size, float *orient, float *time); 522 void pRailSpiralThink (struct cgParticle_s *p, vec3_t org, vec3_t angle, vec4_t color, float *size, float *orient, float *time); 523 void pRicochetSparkThink (struct cgParticle_s *p, vec3_t org, vec3_t angle, vec4_t color, float *size, float *orient, float *time); 524 void pSlowFireThink (struct cgParticle_s *p, vec3_t org, vec3_t angle, vec4_t color, float *size, float *orient, float *time); 525 void pSmokeThink (struct cgParticle_s *p, vec3_t org, vec3_t angle, vec4_t color, float *size, float *orient, float *time); 526 void pSparkGrowThink (struct cgParticle_s *p, vec3_t org, vec3_t angle, vec4_t color, float *size, float *orient, float *time); 527 void pSplashThink (struct cgParticle_s *p, vec3_t org, vec3_t angle, vec4_t color, float *size, float *orient, float *time); 528 529 /* 530 ============================================================================= 531 532 SUSTAINED PARTICLE EFFECTS 533 534 ============================================================================= 535 */ 536 537 typedef struct cgSustainPfx_s { 538 vec3_t org; 539 vec3_t dir; 540 541 int id; 542 int type; 543 544 int endtime; 545 int nextthink; 546 int thinkinterval; 547 548 int color; 549 int count; 550 int magnitude; 551 552 void (*think)(struct cgSustainPfx_s *self); 553 } cgSustainPfx_t; 554