Git Repos / fte_dogmode / qc / func / particlefield.qc
Last update to this file was on 2024-06-15 at 19:50.
Show particlefield.qc
//==============================================================================
// func_particlefield -- Hipnotic Interactive, Jim Dose'
//==============================================================================
// Particle effects QuickC program
// By Jim Dose' 9/19/96
// Copyright (c)1996 Hipnotic Interactive, Inc.
// All rights reserved.
// Distributed (unsupported) on 3.12.97
//======================================================================
// constants
//======================================================================
#ifdef SSQC
// float PARTICLEFIELD_START_OFF = 1;
const float PARTICLEFIELD_USE_COUNT = 1;
#endif
//======================================================================
// forward declarations
//======================================================================
// func_particlefield
#ifdef SSQC
void() func_particlefield_xz;
void() func_particlefield_yz;
void() func_particlefield_xy;
void() func_particlefield_touch;
void(entity e) func_particlefield_init;
void() func_particlefield;
#endif
//------------------------------------------------------------------------------
/*QUAKED func_particlefield (0 .5 .8) ? USE_COUNT X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
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.
*/
//----------------------------------------------------------------------
// class func_particlefield: base_func
// {
#ifdef SSQC
//--------------------------------------------------------------
void() func_particlefield_xz =
{
if ((self.spawnflags & PARTICLEFIELD_USE_COUNT) &&
(func_counter_getcount(other) != self.cnt))
{
return;
}
local vector pos = '0 0 0';
local vector start;
local vector end;
/*
dprint ("func_particlefield_xz: entering\n");
*/
self.ltime = time + 0.25;
if (self.noise != "")
sound (self, CHAN_VOICE, self.noise,
VOL_HIGH, ATTN_NORM);
// Only show particles if client is visible.
// This helps to keep network traffic down to a minimum.
if (!checkclient())
return;
start = self.pos1 + self.origin;
end = self.pos2 + 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() func_particlefield_yz =
{
if ((self.spawnflags & PARTICLEFIELD_USE_COUNT) &&
(func_counter_getcount(other) != self.cnt))
{
return;
}
local vector pos = '0 0 0';
local vector start;
local vector end;
/*
dprint (sprintf("func_particlefield_yz: "
"entering, pos1 %v, pos2 %v\n", self.pos1, self.pos2));
*/
self.ltime = time + 0.25;
if (self.noise != "")
sound (self, CHAN_VOICE, self.noise,
VOL_HIGH, ATTN_NORM);
// Only show particles if client is visible.
// This helps to keep network traffic down to a minimum.
if (!checkclient())
return;
start = self.pos1 + self.origin;
end = self.pos2 + 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() func_particlefield_xy =
{
if ((self.spawnflags & PARTICLEFIELD_USE_COUNT) &&
(func_counter_getcount(other) != self.cnt))
{
return;
}
local vector pos;
local vector start;
local vector end;
/*
dprint ("func_particlefield_xy: entering\n");
*/
self.ltime = time + 0.25;
if (self.noise != "")
sound (self, CHAN_VOICE, self.noise,
VOL_HIGH, ATTN_NORM);
// Only show particles if client is visible.
// This helps to keep network traffic down to a minimum.
if (!checkclient())
return;
start = self.pos1 + self.origin;
end = self.pos2 + 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() func_particlefield_touch =
{
if (!self.dmg)
return;
if (time > self.ltime)
return;
if (time < self.attack_finished)
return;
self.attack_finished = time + 0.5;
t_damage2 (other, self, self, self.dmg);
};
//--------------------------------------------------------------
void(entity e) func_particlefield_init =
{
e.classname = "particlefield";
e.classtype = CT_FUNC_PARTICLEFIELD;
base_func_init (e);
if (!e.color)
e.color = 192;
if (e.count == 0)
e.count = 2;
e.solid = SOLID_NOT;
e.movetype = MOVETYPE_NONE;
setmodel (e, e.model);
e.model = __NULL__;
e.origin = (e.mins + e.maxs) * 0.5;
setorigin (e, e.origin);
e.finaldest = e.maxs - e.mins - '16 16 16';
e.pos1 = e.mins + '8 8 8' - e.origin;
e.pos2 = e.maxs + '7.9 7.9 7.9' - e.origin;
setsize (e, e.mins, e.maxs);
e.touch = func_particlefield_touch;
if (e.finaldest_x > e.finaldest_z)
{
if (e.finaldest_y > e.finaldest_z)
{
e.use = func_particlefield_xy;
e.pos1_z = (e.pos1_z + e.pos2_z) / 2;
}
else
{
e.use = func_particlefield_xz;
e.pos1_y = (e.pos1_y + e.pos2_y) / 2;
}
}
else
{
if (e.finaldest_y > e.finaldest_x)
{
e.use = func_particlefield_yz;
e.pos1_x = (e.pos1_x + e.pos2_x) / 2;
}
else
{
e.use = func_particlefield_xz;
e.pos1_y = (e.pos1_y + e.pos2_y) / 2;
}
}
if (e.noise != "")
precache_sound (e.noise);
e.ltime = time;
};
//--------------------------------------------------------------
void() func_particlefield =
{
// new spawnflags for all entities -- iw
if (SUB_Inhibit())
return;
func_particlefield_init (self);
};
#endif
// };
Return to the top of this page or return to the overview of this repo.
Log particlefield.qc
Date | Commit Message | Author | + | - |
---|---|---|---|---|
2024-06-15 | Major update, committing as-is, will have bugs | cev | +13 | -10 |
2024-03-24 | 2nd pass refactor, rework QC class structure | cev | +111 | -113 |
2024-02-18 | Client/player, projectiles, entrypoints refactor | cev | +1 | -1 |
2024-01-31 | Class based monster refactor & start projectiles | cev | +14 | |
2024-01-09 | Continue OO / Class-based refactor | cev | +199 | -196 |
2023-11-27 | Code reorg, minor movement changes, misc | cev | +258 |
Return to the top of this page or return to the overview of this repo.