Portable Half-Life SDK. GoldSource and Xash3D. Crossplatform.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

329 lines
7.2 KiB

9 years ago
/***
*
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
#pragma once
9 years ago
#ifndef EFFECTS_H
#define EFFECTS_H
#define SF_BEAM_STARTON 0x0001
#define SF_BEAM_TOGGLE 0x0002
#define SF_BEAM_RANDOM 0x0004
#define SF_BEAM_RING 0x0008
#define SF_BEAM_SPARKSTART 0x0010
#define SF_BEAM_SPARKEND 0x0020
#define SF_BEAM_DECALS 0x0040
#define SF_BEAM_SHADEIN 0x0080
#define SF_BEAM_SHADEOUT 0x0100
#define SF_BEAM_TEMPORARY 0x8000
#define SF_SPRITE_STARTON 0x0001
#define SF_SPRITE_ONCE 0x0002
#define SF_SPRITE_TEMPORARY 0x8000
class CSprite : public CPointEntity
{
public:
void Spawn( void );
void Precache( void );
9 years ago
int ObjectCaps( void )
9 years ago
{
int flags = 0;
9 years ago
if( pev->spawnflags & SF_SPRITE_TEMPORARY )
9 years ago
flags = FCAP_DONT_SAVE;
9 years ago
return ( CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION ) | flags;
9 years ago
}
void EXPORT AnimateThink( void );
void EXPORT ExpandThink( void );
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
void Animate( float frames );
void Expand( float scaleSpeed, float fadeSpeed );
void SpriteInit( const char *pSpriteName, const Vector &origin );
inline void SetAttachment( edict_t *pEntity, int attachment )
{
9 years ago
if( pEntity )
9 years ago
{
9 years ago
pev->skin = ENTINDEX( pEntity );
9 years ago
pev->body = attachment;
pev->aiment = pEntity;
pev->movetype = MOVETYPE_FOLLOW;
}
}
void TurnOff( void );
void TurnOn( void );
9 years ago
inline float Frames( void )
{
return m_maxFrame;
}
9 years ago
inline void SetTransparency( int rendermode, int r, int g, int b, int a, int fx )
{
pev->rendermode = rendermode;
pev->rendercolor.x = r;
pev->rendercolor.y = g;
pev->rendercolor.z = b;
pev->renderamt = a;
pev->renderfx = fx;
}
9 years ago
inline void SetTexture( int spriteIndex )
{
pev->modelindex = spriteIndex;
}
inline void SetScale( float scale )
{
pev->scale = scale;
}
inline void SetColor( int r, int g, int b )
{
pev->rendercolor.x = r;
pev->rendercolor.y = g;
pev->rendercolor.z = b;
}
inline void SetBrightness( int brightness )
{
pev->renderamt = brightness;
}
9 years ago
inline void AnimateAndDie( float framerate )
{
9 years ago
SetThink( &CSprite::AnimateUntilDead );
9 years ago
pev->framerate = framerate;
9 years ago
pev->dmgtime = gpGlobals->time + ( m_maxFrame / framerate );
9 years ago
pev->nextthink = gpGlobals->time;
}
void EXPORT AnimateUntilDead( void );
9 years ago
virtual int Save( CSave &save );
virtual int Restore( CRestore &restore );
static TYPEDESCRIPTION m_SaveData[];
9 years ago
static CSprite *SpriteCreate( const char *pSpriteName, const Vector &origin, BOOL animate );
private:
9 years ago
float m_lastTime;
float m_maxFrame;
9 years ago
};
class CBeam : public CBaseEntity
{
public:
9 years ago
void Spawn( void );
void Precache( void );
int ObjectCaps( void )
9 years ago
{
int flags = 0;
9 years ago
if( pev->spawnflags & SF_BEAM_TEMPORARY )
9 years ago
flags = FCAP_DONT_SAVE;
9 years ago
return ( CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION ) | flags;
9 years ago
}
void EXPORT TriggerTouch( CBaseEntity *pOther );
// These functions are here to show the way beams are encoded as entities.
// Encoding beams as entities simplifies their management in the client/server architecture
9 years ago
inline void SetType( int type )
{
pev->rendermode = ( pev->rendermode & 0xF0 ) | ( type & 0x0F );
}
inline void SetFlags( int flags )
{
pev->rendermode = ( pev->rendermode & 0x0F ) | ( flags & 0xF0 );
}
inline void SetStartPos( const Vector& pos )
{
pev->origin = pos;
}
inline void SetEndPos( const Vector& pos )
{
pev->angles = pos;
}
9 years ago
void SetStartEntity( int entityIndex );
void SetEndEntity( int entityIndex );
9 years ago
inline void SetStartAttachment( int attachment )
{
pev->sequence = ( pev->sequence & 0x0FFF ) | ( ( attachment & 0xF ) << 12 );
}
inline void SetEndAttachment( int attachment )
{
pev->skin = ( pev->skin & 0x0FFF ) | ( ( attachment & 0xF ) << 12 );
}
inline void SetTexture( int spriteIndex )
{
pev->modelindex = spriteIndex;
}
inline void SetWidth( int width )
{
pev->scale = width;
}
inline void SetNoise( int amplitude )
{
pev->body = amplitude;
}
inline void SetColor( int r, int g, int b )
{
pev->rendercolor.x = r;
pev->rendercolor.y = g;
pev->rendercolor.z = b;
}
inline void SetBrightness( int brightness )
{
pev->renderamt = brightness;
}
9 years ago
9 years ago
inline void SetFrame( float frame )
{
pev->frame = frame;
}
9 years ago
9 years ago
inline void SetScrollRate( int speed )
{
pev->animtime = speed;
}
inline int GetType( void )
{
return pev->rendermode & 0x0F;
}
inline int GetFlags( void )
{
return pev->rendermode & 0xF0;
}
inline int GetStartEntity( void )
{
return pev->sequence & 0xFFF;
}
inline int GetEndEntity( void )
{
return pev->skin & 0xFFF;
}
9 years ago
const Vector &GetStartPos( void );
const Vector &GetEndPos( void );
Vector Center( void ) { return (GetStartPos() + GetEndPos()) * 0.5; }; // center point of beam
9 years ago
inline int GetTexture( void )
{
return pev->modelindex;
}
inline int GetWidth( void )
{
return (int)pev->scale;
9 years ago
}
inline int GetNoise( void )
{
return pev->body;
}
/* inline void GetColor( int r, int g, int b )
{
pev->rendercolor.x = r;
pev->rendercolor.y = g;
pev->rendercolor.z = b;
}*/
inline int GetBrightness( void )
{
return (int)pev->renderamt;
9 years ago
}
inline int GetFrame( void )
{
return (int)pev->frame;
9 years ago
}
inline int GetScrollRate( void )
{
return (int)pev->animtime;
9 years ago
}
9 years ago
// Call after you change start/end positions
void RelinkBeam( void );
9 years ago
//void SetObjectCollisionBox( void );
9 years ago
void DoSparks( const Vector &start, const Vector &end );
CBaseEntity *RandomTargetname( const char *szName );
void BeamDamage( TraceResult *ptr );
// Init after BeamCreate()
void BeamInit( const char *pSpriteName, int width );
void PointsInit( const Vector &start, const Vector &end );
void PointEntInit( const Vector &start, int endIndex );
void EntsInit( int startIndex, int endIndex );
void HoseInit( const Vector &start, const Vector &direction );
static CBeam *BeamCreate( const char *pSpriteName, int width );
9 years ago
inline void LiveForTime( float time )
{
SetThink( &CBaseEntity::SUB_Remove );
pev->nextthink = gpGlobals->time + time;
}
inline void BeamDamageInstant( TraceResult *ptr, float damage )
9 years ago
{
pev->dmg = damage;
pev->dmgtime = gpGlobals->time - 1;
9 years ago
BeamDamage( ptr );
9 years ago
}
};
#define SF_MESSAGE_ONCE 0x0001 // Fade in, not out
#define SF_MESSAGE_ALL 0x0002 // Send to all clients
class CLaser : public CBeam
{
public:
void Spawn( void );
void Precache( void );
void KeyValue( KeyValueData *pkvd );
void TurnOn( void );
void TurnOff( void );
9 years ago
int IsOn( void );
9 years ago
void FireAtPoint( TraceResult &point );
void EXPORT StrikeThink( void );
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
virtual int Save( CSave &save );
virtual int Restore( CRestore &restore );
static TYPEDESCRIPTION m_SaveData[];
CSprite *m_pSprite;
string_t m_iszSpriteName;
9 years ago
Vector m_firePosition;
9 years ago
};
#endif //EFFECTS_H