quake-hipnotic-sdk/progs/hip_part.qc
1997-03-11 00:00:00 +00:00

307 lines
7 KiB
C++

/* particle effects quickc program
by jim dose' 9/19/96
copyright (c)1996 hipnotic interactive, inc.
all rights reserved.
do not distribute.
*/
//float start_off = 1;
float use_count = 1;
void () particlefield_xz =
{
local vector pos;
local vector start;
local vector end;
if ( ( self.spawnflags & use_count ) &&
( counter_getcount( other ) != self.cnt ) )
{
return;
}
// dprint( "xz\n" );
self.ltime = time + 0.25;
if ( self.noise )
{
sound(self, chan_voice, self.noise, 1, attn_norm);
}
// only show particles if client is visible.
// this helps to keep network traffic down to a minimum.
if (!checkclient() )
return;
start = self.dest1 + self.origin;
end = self.dest2 + self.origin;
pos_y = start_y;
pos_z = start_z;
while( pos_z <= end_z )
{
pos_x = start_x;
while( pos_x <= end_x )
{
particle ( pos, '0 0 0', self.color, self.count );
pos_x = pos_x + 16;
}
pos_z = pos_z + 16;
}
};
void () particlefield_yz =
{
local vector pos;
local vector start;
local vector end;
if ( ( self.spawnflags & use_count ) &&
( counter_getcount( other ) != self.cnt ) )
{
return;
}
// dprint( "yz: " );
// dprint( vtos( self.dest1 ) );
// dprint( " - " );
// dprint( vtos( self.dest2 ) );
// dprint( "\n" );
self.ltime = time + 0.25;
if ( self.noise )
{
sound(self, chan_voice, self.noise, 1, attn_norm);
}
// only show particles if client is visible.
// this helps to keep network traffic down to a minimum.
if (!checkclient() )
return;
start = self.dest1 + self.origin;
end = self.dest2 + self.origin;
pos_x = start_x;
pos_z = start_z;
while( pos_z < end_z )
{
pos_y = start_y;
while( pos_y < end_y )
{
particle ( pos, '0 0 0', self.color, self.count );
pos_y = pos_y + 16;
}
pos_z = pos_z + 16;
}
};
void () particlefield_xy =
{
local vector pos;
local vector start;
local vector end;
if ( ( self.spawnflags & use_count ) &&
( counter_getcount( other ) != self.cnt ) )
{
return;
}
// dprint( "xy\n" );
self.ltime = time + 0.25;
if ( self.noise )
{
sound(self, chan_voice, self.noise, 1, attn_norm);
}
// only show particles if client is visible.
// this helps to keep network traffic down to a minimum.
if (!checkclient() )
return;
start = self.dest1 + self.origin;
end = self.dest2 + self.origin;
pos_x = start_x;
pos_z = start_z;
while( pos_x < end_x )
{
pos_y = start_y;
while( pos_y < end_y )
{
particle ( pos, '0 0 0', self.color, self.count );
pos_y = pos_y + 16;
}
pos_x = pos_x + 16;
}
};
void () particlefield_touch =
{
if ( !self.dmg )
return;
if ( time > self.ltime)
return;
if (time < self.attack_finished)
return;
self.attack_finished = time + 0.5;
t_damage (other, self, self, self.dmg);
};
/*quaked func_particlefield (0 .5 .8) ? use_count
creates a brief particle flash roughly the size of the defining
brush each time it is triggered.
use_count when the activator is a func_counter, the field will only
activate when count is equal to "cnt". same as using a func_oncount
to trigger.
"cnt" is the count to activate on when use_count is set.
"color" is the color of the particles. default is 192 (yellow).
"count" is the density of the particles. default is 2.
"noise" is the sound to play when triggered. do not use a looping sound here.
"dmg" is the amount of damage to cause when touched.
*/
void() func_particlefield =
{
if ( !self.color )
{
self.color = 192;
}
if ( self.count == 0 )
{
self.count = 2;
}
self.classname = "particlefield";
self.solid = solid_not;
self.movetype = movetype_none;
setmodel (self, self.model);
self.model = string_null;
self.origin = ( self.mins + self.maxs ) * 0.5;
setorigin (self, self.origin);
self.dest = self.maxs - self.mins - '16 16 16';
self.dest1 = self.mins + '8 8 8' - self.origin;
self.dest2 = self.maxs + '7.9 7.9 7.9' - self.origin;
setsize (self, self.mins, self.maxs);
self.touch = particlefield_touch;
// dprint( vtos( self.dest ) );
// dprint( " " );
if ( self.dest_x > self.dest_z )
{
if ( self.dest_y > self.dest_z )
{
// dprint( "xy1 - " );
// dprint( ftos( self.cnt ) );
// dprint( "\n" );
self.use = particlefield_xy;
self.dest1_z = ( self.dest1_z + self.dest2_z ) / 2;
}
else
{
// dprint( "xz1 - " );
// dprint( ftos( self.cnt ) );
// dprint( "\n" );
self.use = particlefield_xz;
self.dest1_y = ( self.dest1_y + self.dest2_y ) / 2;
}
}
else
{
if ( self.dest_y > self.dest_x )
{
// dprint( "yz2 - " );
// dprint( ftos( self.cnt ) );
// dprint( "\n" );
self.use = particlefield_yz;
self.dest1_x = ( self.dest1_x + self.dest2_x ) / 2;
}
else
{
// dprint( "xz2 - " );
// dprint( ftos( self.cnt ) );
// dprint( "\n" );
self.use = particlefield_xz;
self.dest1_y = ( self.dest1_y + self.dest2_y ) / 2;
}
}
if ( self.noise )
{
precache_sound( self.noise );
}
self.ltime = time;
};
void () blocker_touch =
{
if ( !self.dmg )
return;
if (time < self.attack_finished)
return;
self.attack_finished = time + 0.5;
t_damage (other, self, self, self.dmg);
};
void () blocker_use =
{
if ( !self.state )
{
self.state = 1;
setorigin( self, self.origin - '8000 8000 8000' );
sound(self, chan_voice, self.noise1, 1, attn_norm);
}
else
{
self.state = 0;
setorigin( self, self.origin + '8000 8000 8000' );
sound(self, chan_voice, self.noise, 1, attn_norm);
}
};
/*quaked func_togglewall (0 .5 .8) ? start_off
creates a invisible wall that can be toggled on and off.
start_off wall doesn't block until triggered.
"noise" is the sound to play when wall is turned off.
"noise1" is the sound to play when wall is blocking.
"dmg" is the amount of damage to cause when touched.
*/
void() func_togglewall =
{
self.classname = "togglewall";
self.movetype = movetype_push;
self.mdl = self.model;
setmodel (self, self.model);
setsize (self, self.mins, self.maxs);
setorigin (self, self.origin);
self.touch = blocker_touch;
self.use = blocker_use;
if ( !self.noise )
{
self.noise = ("misc/null.wav");
}
if ( !self.noise1 )
{
self.noise1 = ("misc/null.wav");
}
precache_sound( self.noise );
precache_sound( self.noise1 );
self.solid = solid_bsp;
self.model = string_null;
if ( self.spawnflags & start_off )
{
self.state = 0;
setorigin( self, self.origin + '8000 8000 8000' );
}
else
{
self.state = 1;
sound(self, chan_voice, self.noise1, 1, attn_norm);
}
};