118 lines
2.7 KiB
C++
118 lines
2.7 KiB
C++
/*
|
|
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);
|
|
|
|
/* TODO: if MOVETYPE_PUSH, get the absmins/maxs center */
|
|
if (targetEnt) {
|
|
makevectors(vectoangles(targetEnt.origin - self.origin));
|
|
self.angles = v_forward;
|
|
}
|
|
}
|
|
|
|
/* TODO: add sound sfx? */
|
|
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;
|
|
}
|
|
};
|