157 lines
4.7 KiB
C
Executable file
157 lines
4.7 KiB
C
Executable file
/*
|
|
Copyright 2016-2018 Marco "eukara" Hladik
|
|
|
|
MIT LICENSE
|
|
|
|
Permission is hereby granted, free of charge, to any person
|
|
obtaining a copy of this software and associated documentation
|
|
files (the "Software"), to deal in the Software without
|
|
restriction, including without limitation the rights to use,
|
|
copy, modify, merge, publish, distribute, sublicense, and/or
|
|
sell copies of the Software, and to permit persons to whom the
|
|
Software is furnished to do so, subject to the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be
|
|
included in all copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
OTHER DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
|
|
void CSQC_ambient_generic( string sSample, float fVolume, float fAttenuation, float fLoop, float lFORate ) {
|
|
//print( sprintf( "SOUND: %s, %f, %d\n%d %d %d", sSample, fVolume, fAttenuation, self.origin_x, self.origin_y, self.origin_z ) );
|
|
static void LFOHack (void) {
|
|
sound( self, CHAN_VOICE, self.classname, self.movetype, self.style, 0, 0 );
|
|
self.nextthink = self.solid + time;
|
|
}
|
|
// Hack
|
|
if ( lFORate ) {
|
|
self.classname = sSample;
|
|
self.movetype = fVolume;
|
|
self.style = fAttenuation;
|
|
self.think = LFOHack;
|
|
self.solid = lFORate / 10;
|
|
self.nextthink = self.solid + time;
|
|
fLoop = FALSE;
|
|
}
|
|
|
|
/*if ( fLoop ) {
|
|
sound( self, CHAN_VOICE, sSample, fVolume, fAttenuation, 0, SOUNDFLAG_FORCELOOP );
|
|
} else {*/
|
|
sound( self, CHAN_VOICE, sSample, fVolume, fAttenuation, 0, 0 );
|
|
//}
|
|
}
|
|
|
|
/*
|
|
=================
|
|
CSQC_Ent_Update
|
|
|
|
Called whenever an entity is sent manually via .SendFlags and so on
|
|
=================
|
|
*/
|
|
void CSQC_Ent_Update( float flIsNew ) {
|
|
float fEntType = readbyte();
|
|
|
|
if( fEntType == ENT_PLAYER ) {
|
|
if ( flIsNew == TRUE ) {
|
|
self.classname = "player";
|
|
self.solid = SOLID_SLIDEBOX;
|
|
self.predraw = Player_PreDraw;
|
|
self.drawmask = MASK_ENGINE;
|
|
self.customphysics = Empty;
|
|
setsize( self, VEC_HULL_MIN, VEC_HULL_MAX );
|
|
}
|
|
|
|
self.modelindex = readshort();
|
|
self.origin_x = readcoord();
|
|
self.origin_y = readcoord();
|
|
self.origin_z = readcoord();
|
|
self.flUpAngle = readcoord() / 90;
|
|
self.angles_y = readcoord();
|
|
self.angles_z = readcoord();
|
|
self.velocity_x = readcoord();
|
|
self.velocity_y = readcoord();
|
|
self.velocity_z = readcoord();
|
|
self.flags = readfloat();
|
|
self.pmove_flags = readfloat();
|
|
self.weapon = readbyte();
|
|
self.health = readbyte();
|
|
self.movetype = readfloat();
|
|
self.view_ofs[2] = readfloat();
|
|
setorigin( self, self.origin );
|
|
|
|
if (self.health < self.oldhealth) {
|
|
Animation_PlayerTopTemp( ANIM_GUT_FLINCH, 0.1f );
|
|
}
|
|
self.oldhealth = self.health;
|
|
} else if ( fEntType == ENT_AMBIENTSOUND ) {
|
|
self.origin_x = readcoord();
|
|
self.origin_y = readcoord();
|
|
self.origin_z = readcoord();
|
|
|
|
setorigin( self, self.origin );
|
|
|
|
CSQC_ambient_generic( readstring(), readfloat(), readbyte(), readbyte(), readbyte() );
|
|
} else if ( fEntType == ENT_SPRITE ) {
|
|
Sprite_Animated();
|
|
} else if ( fEntType == ENT_SPRAY ) {
|
|
Spraylogo_Parse();
|
|
} else if ( fEntType == ENT_DECAL ) {
|
|
string decalname = "";
|
|
string decalshader = "";
|
|
|
|
self.origin_x = readcoord();
|
|
self.origin_y = readcoord();
|
|
self.origin_z = readcoord();
|
|
|
|
self.angles_x = readcoord();
|
|
self.angles_y = readcoord();
|
|
self.angles_z = readcoord();
|
|
|
|
self.color_x = 1.0f - ( readbyte() / 255 );
|
|
self.color_y = 1.0f - ( readbyte() / 255 );
|
|
self.color_z = 1.0f - ( readbyte() / 255 );
|
|
self.classname = readstring();
|
|
self.size = drawgetimagesize(self.classname);
|
|
|
|
if (serverkeyfloat("*bspversion") == 30) {
|
|
decalname = sprintf("decal_%s", self.classname);
|
|
decalshader = sprintf("{\npolygonOffset\n{\nclampmap %s\nblendFunc filter\n}\n}", self.classname);
|
|
shaderforname(decalname, decalshader);
|
|
self.classname = decalname;
|
|
}
|
|
|
|
makevectors( self.angles );
|
|
float surf = getsurfacenearpoint(world, self.origin);
|
|
vector s_dir = getsurfacepointattribute(world, surf, 0, SPA_S_AXIS);
|
|
vector t_dir = getsurfacepointattribute(world, surf, 0, SPA_T_AXIS);
|
|
self.mins = v_up / self.size[0];
|
|
self.maxs = t_dir / self.size[1];
|
|
|
|
self.predraw = Effect_Decal;
|
|
self.drawmask = MASK_ENGINE;
|
|
}
|
|
}
|
|
|
|
/*
|
|
=================
|
|
CSQC_Ent_Remove
|
|
|
|
Self explanatory
|
|
=================
|
|
*/
|
|
void CSQC_Ent_Remove( void ) {
|
|
if ( self.eGunModel ) {
|
|
remove( self.eGunModel );
|
|
}
|
|
|
|
soundupdate( self, CHAN_VOICE, "", -1, ATTN_IDLE, 0, 0, 0 );
|
|
remove( self );
|
|
}
|
|
|