Synched gist at Thu May 9 02:24:51 PDT 2024
This commit is contained in:
parent
124f9bc4fd
commit
44eeb59368
1 changed files with 116 additions and 0 deletions
116
env_particle.qc
Normal file
116
env_particle.qc
Normal file
|
@ -0,0 +1,116 @@
|
|||
/*
|
||||
FGD Definition for env_particle:
|
||||
|
||||
@PointClass size(-16 -16 -16, 16 16 16) = env_particle : "Particle Emitter"
|
||||
[
|
||||
angles(string) : "Pitch Yaw Roll (Y Z X)" : "0 0 0" : "Sets the direction the particle is aiming at."
|
||||
targetname(target_source) : "Name"
|
||||
target(target_destination) : "Target" : : "When set, will aim at this entity."
|
||||
message(string) : "Particle effect to use."
|
||||
wait(integer) : "Delay between effects." : 1
|
||||
count(integer) : "Effect count." : 1
|
||||
speed(integer) : "Particle speed." : 100
|
||||
spawnflags(flags) =
|
||||
[
|
||||
1 : "Start on" : 0
|
||||
]
|
||||
]
|
||||
*/
|
||||
|
||||
/* required engine builtins */
|
||||
float(string effectname) particleeffectnum = #335;
|
||||
void(float effectnum, vector origin, optional vector dir, optional float count) pointparticles = #337;
|
||||
|
||||
static void() env_particle_emit =
|
||||
{
|
||||
/* continously update against our target */
|
||||
if (self.target) {
|
||||
entity targetEnt = find(world, ::targetname, self.target);
|
||||
|
||||
if (targetEnt) {
|
||||
makevectors(vectoangles(targetEnt.origin - self.origin));
|
||||
self.angles = v_forward;
|
||||
}
|
||||
}
|
||||
|
||||
pointparticles(self.sounds, self.origin, self.angles * self.speed, self.count);
|
||||
self.nextthink = time + self.wait;
|
||||
};
|
||||
|
||||
static void() env_particle_activate =
|
||||
{
|
||||
self.health = 1;
|
||||
self.think = env_particle_emit;
|
||||
self.nextthink = time + 0.0f;
|
||||
};
|
||||
|
||||
static void() env_particle_deactivate =
|
||||
{
|
||||
self.health = 0;
|
||||
self.think = __NULL__;
|
||||
self.nextthink = 0.0f;
|
||||
};
|
||||
|
||||
static void() env_particle_toggle =
|
||||
{
|
||||
if (!self.health) {
|
||||
env_particle_activate();
|
||||
} else {
|
||||
env_particle_deactivate();
|
||||
}
|
||||
};
|
||||
|
||||
/*QUAKED env_particle (0 0.5 0) (-4 -4 -4) (4 4 4) START_ON
|
||||
Particle emitter, requires engine that supports pointparticles().
|
||||
|
||||
# KEYS
|
||||
- "targetname" : Name used to identify itself.
|
||||
- "message" : Particle material to use.
|
||||
- "wait" : Delay between emits.
|
||||
- "target" : Name of target, like an info_notnull.
|
||||
- "speed" : Speed in units.
|
||||
- "count" : Number of particles to emit.
|
||||
|
||||
# SPAWNFLAGS
|
||||
- START_ON (1) : Start on. Only necessary when no targetname is set.
|
||||
|
||||
# TRIVIA
|
||||
This entity was introduced in The Wastes (2018).
|
||||
*/
|
||||
void() env_particle =
|
||||
{
|
||||
if (!self.message) {
|
||||
objerror("env_particle with no `message` key set");
|
||||
}
|
||||
|
||||
/* the particle handle */
|
||||
self.sounds = particleeffectnum(self.message);
|
||||
|
||||
/* used by triggers */
|
||||
self.use = env_particle_toggle;
|
||||
|
||||
/* start on check */
|
||||
if (!self.targetname || self.spawnflags & 1) {
|
||||
env_particle_activate();
|
||||
|
||||
/* needs some time to think on spawn*/
|
||||
self.nextthink = time + 0.25f;
|
||||
}
|
||||
|
||||
/* avoid bad values */
|
||||
if (self.wait <= 0) {
|
||||
self.wait = 1.0f;
|
||||
}
|
||||
if (self.count <= 0) {
|
||||
self.count = 1;
|
||||
}
|
||||
if (self.speed <= 0) {
|
||||
self.speed = 100.0f;
|
||||
}
|
||||
|
||||
/* use angles */
|
||||
if (!self.target) {
|
||||
makevectors(self.angles);
|
||||
self.angles = v_forward;
|
||||
}
|
||||
};
|
Loading…
Reference in a new issue