📄 specialfx.cpp
字号:
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/specialfx.cpp $
// $Revision:: 40 $
// $Author:: Markd $
// $Date:: 11/15/98 11:33p $
//
// Copyright (C) 1997 by Ritual Entertainment, Inc.
// All rights reserved.
//
// This source is may not be distributed and/or modified without
// expressly written permission by Ritual Entertainment, Inc.
//
// $Log:: /Quake 2 Engine/Sin/code/game/specialfx.cpp $
//
// 40 11/15/98 11:33p Markd
// Added FATPROJECTILE flag
//
// 39 11/14/98 11:15p Markd
// bullet proofed fire blowing up
//
// 38 11/08/98 11:02p Markd
// increased damage of firebarrel
//
// 37 11/07/98 10:15p Markd
// put in forcemusic support
//
// 36 10/24/98 12:42a Markd
// changed origins to worldorigins where appropriate
//
// 35 10/23/98 5:37a Jimdose
// Added SpawnBlastDamage
//
// 34 10/12/98 4:30p Aldie
// Added some more functionality to sprites
//
// 33 10/11/98 8:50p Jimdose
// Added sound to fire sprite
//
// 32 10/10/98 5:58p Aldie
// More quantumdestab fixes
//
// 31 10/09/98 7:38p Aldie
// Fix dir when doing trace to surfaces
//
// 30 10/08/98 7:25p Aldie
// Fixed a comment
//
// 29 10/08/98 4:28p Aldie
// Do a trace to surface to apply a sprite
//
// 28 10/07/98 2:32p Aldie
// Changed "model" to "sprite" for fx_sprite
//
// 27 9/29/98 4:25p Markd
// put in parallel fire support
//
// 26 9/29/98 4:15p Aldie
// Removed the sined section
//
// 25 9/25/98 3:00p Aldie
// Added lightstyle and type to tessellation
//
// 24 9/21/98 4:36p Aldie
// Added fx_sprite
//
// 23 9/20/98 9:09p Aldie
// Removed a no longer needed function
//
// 22 9/20/98 7:11p Aldie
// Added flags to particles
//
// 21 9/19/98 4:47p Markd
// fixed music stuff and added actionincrement to weapons
//
// 20 9/18/98 8:41p Aldie
// Added type to tesselate message
//
// 19 9/18/98 5:47p Aldie
// Remove the EV_Remove on func_beams
//
// 18 9/18/98 5:30p Aldie
// Removed func_beam for demo version
//
// 17 9/17/98 9:08p Aldie
// Don't use edict->s.parent for stuff :-)
//
// 16 9/16/98 4:06p Aldie
// Added a comment
//
// 15 9/16/98 4:03p Aldie
// Fixed targeting of beams
//
// 14 9/15/98 7:34p Markd
// Added ChangeMusic and ChangeSoundtrack
//
// 13 9/13/98 5:39p Aldie
// Changed a command
//
// 12 9/13/98 4:34p Aldie
// Added lots of beam stuff
//
// 11 9/12/98 11:10p Aldie
// Made func beam generic
//
// 10 9/11/98 11:36p Aldie
// Added activate and deactivate
//
// 9 9/11/98 5:45p Aldie
// Updated some flags for beam
//
// 8 9/10/98 8:38p Aldie
// Electrical beam effects
//
// 7 9/09/98 3:56p Aldie
// New lightning effect
//
// 6 9/01/98 6:17p Markd
// Added additonal sprite types to fire
//
// 5 9/01/98 3:05p Markd
// Rewrote explosion code
//
// 4 8/29/98 7:42p Markd
// Fixed flicker code for fx_fire
//
// 3 8/29/98 7:24p Markd
// put in light ability on fx_fire
//
// 2 8/29/98 5:27p Markd
// added specialfx, replaced misc with specialfx where appropriate
//
// 1 8/29/98 4:39p Markd
//
// DESCRIPTION:
// Special fx
//
#include "g_local.h"
#include "entity.h"
#include "trigger.h"
#include "explosion.h"
#include "misc.h"
#include "light.h"
#include "specialfx.h"
#include "player.h"
#include "g_utils.h"
#include "surface.h"
/*
================
SpawnBlastDamage
================
*/
void SpawnBlastDamage
(
trace_t *trace,
int damage,
Entity *attacker
)
{
Entity *blastmark;
Vector norm;
assert( trace );
assert( attacker );
if ( !trace )
{
return;
}
if ( !attacker )
{
attacker = world;
}
surfaceManager.DamageSurface( trace, damage, attacker );
if ( trace->ent && trace->ent->entity && trace->ent->entity->flags & FL_BLASTMARK )
{
blastmark = new Entity;
blastmark->setMoveType( MOVETYPE_NONE );
blastmark->setSolidType( SOLID_NOT );
blastmark->setModel( "sprites/blastmark.spr" );
blastmark->setSize( "0 0 0", "0 0 0" );
blastmark->edict->s.scale = G_Random() + 0.7;
norm = trace->plane.normal;
norm.x = -norm.x;
norm.y = -norm.y;
blastmark->angles = norm.toAngles();
blastmark->angles.z = G_Random( 360 );
blastmark->setAngles( blastmark->angles );
blastmark->setOrigin( Vector( trace->endpos ) + ( Vector( trace->plane.normal ) * 0.2 ) );
blastmark->PostEvent( EV_FadeOut, 5 );
}
}
/*
================
Particles
================
*/
void Particles
(
Vector org,
Vector norm,
int count,
int lightstyle,
int flags
)
{
if (count>255) count = 255;
gi.WriteByte( svc_temp_entity );
gi.WriteByte( TE_PARTICLES );
gi.WritePosition( org.vec3() );
gi.WriteDir( norm.vec3() );
gi.WriteByte( lightstyle );
gi.WriteByte( count );
gi.WriteByte( flags );
gi.multicast( org.vec3(), MULTICAST_PVS );
}
/*
================
SpawnBlood
================
*/
void SpawnBlood
(
Vector org,
Vector norm,
int damage
)
{
if (damage > 150) damage = 150;
Particles( org, norm, damage, 121, 0 );
}
/*
================
SpawnSparks
================
*/
void SpawnSparks
(
Vector org,
Vector norm,
int count
)
{
Particles( org, norm, count, 122, PARTICLE_OVERBRIGHT );
}
/*
==============
SpawnPulseBeam
==============
*/
void SpawnBeam
(
Vector start,
Vector end,
int parent_entnum,
int modelindex,
float alpha,
float life,
int flags
)
{
byte sendflags;
sendflags = 0;
if ( alpha != 1.0f )
sendflags |= BM_ALPHA;
if ( life != 30 )
sendflags |= BM_LIFE;
if ( flags )
sendflags |= BM_FLAGS;
gi.WriteByte( svc_temp_entity );
gi.WriteByte( TE_BEAM );
gi.WriteByte( sendflags );
gi.WritePosition( start.vec3() );
gi.WritePosition( end.vec3() );
gi.WriteShort( modelindex );
if ( sendflags & BM_ALPHA )
gi.WriteByte( alpha*255 );
if ( sendflags & BM_FLAGS )
gi.WriteByte( flags );
if ( sendflags & BM_LIFE )
gi.WriteShort( life );
gi.multicast( start.vec3(), MULTICAST_PVS );
}
/*
================
SpawnRocketExplosion
================
*/
void SpawnRocketExplosion
(
Vector org
)
{
gi.WriteByte( svc_temp_entity );
gi.WriteByte( TE_ROCKET_EXPLOSION );
gi.WritePosition( org.vec3() );
gi.multicast( org.vec3(), MULTICAST_PVS );
}
/*
================
SpawnScaledExplosion
================
*/
void SpawnScaledExplosion
(
Vector org,
float scale
)
{
scale *= 64;
if ( scale > 255 )
scale = 255;
else if ( scale < 0 )
return;
gi.WriteByte( svc_temp_entity );
gi.WriteByte( TE_SCALED_EXPLOSION );
gi.WritePosition( org.vec3() );
gi.WriteByte( scale );
gi.multicast( org.vec3(), MULTICAST_PVS );
}
/*
================
SpawnTempDlight
================
*/
void SpawnTempDlight
(
Vector org,
float r,
float g,
float b,
float radius,
float decay,
float life
)
{
gi.WriteByte( svc_temp_entity );
gi.WriteByte( TE_DLIGHT );
gi.WritePosition( org.vec3() );
gi.WriteByte( r*255.0f );
gi.WriteByte( g*255.0f );
gi.WriteByte( b*255.0f );
gi.WriteByte( radius/4 );
gi.WriteByte( decay*255.0f );
gi.WriteByte( life*25.5f );
gi.multicast( org.vec3(), MULTICAST_PVS );
}
/*
===================
SpawnTeleportEffect
===================
*/
void SpawnTeleportEffect
(
Vector org,
int lightstyle
)
{
gi.WriteByte( svc_temp_entity );
gi.WriteByte( TE_TELEPORT_EFFECT );
gi.WritePosition( org.vec3() );
gi.WriteByte( lightstyle );
gi.multicast( org.vec3(), MULTICAST_PVS );
}
/*
================
BurnWall
================
*/
void BurnWall
(
Vector org,
Vector end,
int amount
)
{
gi.WriteByte( svc_temp_entity );
gi.WriteByte( TE_BURNWALL );
gi.WritePosition( org.vec3() );
gi.WritePosition( end.vec3() );
gi.WriteByte( amount );
gi.multicast( org.vec3(), MULTICAST_ALL );
}
/*
================
TempModel
================
*/
void TempModel
(
Entity * parent,
Vector origin,
Vector angles,
const char * modelname,
int anim,
float scale,
float alpha,
int flags,
float life
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -