📄 cl_fx.pas
字号:
const
BEAMLENGTH = 16;
procedure CL_FlyParticles(const origin: vec3_t; count: integer);
var
i: integer;
p: cparticle_p;
angle: single;
// Sly 27-Jun-2002 These variables are not used
// sr, cr,
sp, sy, cp, cy: single;
forward_: vec3_t;
dist: single;
ltime: single;
begin
// Sly 27-Jun-2002 These values are not used
dist := 64;
if (count > NUMVERTEXNORMALS) then
count := NUMVERTEXNORMALS;
if (avelocities[0][0] = 0) then
begin
for i := 0 to NUMVERTEXNORMALS * 3 - 1 do
avelocities[0][i] := (rand() and 255) * 0.01;
end;
ltime := cl.time / 1000.0;
i := 0;
while (i < count) do
begin
angle := ltime * avelocities[i][0];
sy := sin(angle);
cy := cos(angle);
angle := ltime * avelocities[i][1];
sp := sin(angle);
cp := cos(angle);
// Sly 27-Jun-2002 These values are not used
// angle := ltime * avelocities[i][2];
// sr := sin(angle);
// cr := cos(angle);
forward_[0] := cp * cy;
forward_[1] := cp * sy;
forward_[2] := -sp;
if (free_particles = nil) then
exit;
p := free_particles;
free_particles := p.next;
p.next := active_particles;
active_particles := p;
p.time := cl.time;
dist := sin(ltime + i) * 64;
p.org[0] := origin[0] + bytedirs[i][0] * dist + forward_[0] * BEAMLENGTH;
p.org[1] := origin[1] + bytedirs[i][1] * dist + forward_[1] * BEAMLENGTH;
p.org[2] := origin[2] + bytedirs[i][2] * dist + forward_[2] * BEAMLENGTH;
VectorClear(p.vel);
VectorClear(p.accel);
p.color := 0;
p.colorvel := 0;
p.alpha := 1;
p.alphavel := -100;
i := i + 2;
end;
end;
procedure CL_FlyEffect(ent: centity_p; const origin: vec3_t);
var
n: integer;
count: integer;
starttime: integer;
begin
if (ent.fly_stoptime < cl.time) then
begin
starttime := cl.time;
ent.fly_stoptime := cl.time + 60000;
end
else
begin
starttime := ent.fly_stoptime - 60000;
end;
n := cl.time - starttime;
if (n < 20000) then
count := Round(n * 162 / 20000.0)
else
begin
n := ent.fly_stoptime - cl.time;
if (n < 20000) then
count := Round(n * 162 / 20000.0)
else
count := 162;
end;
CL_FlyParticles(origin, count);
end;
(*
===============
CL_BfgParticles
===============
*)
procedure CL_BfgParticles(ent: entity_p);
var
i: integer;
p: cparticle_p;
angle: single;
// Sly 27-Jun-2002 These variables are not used
// sr, cr,
sp, sy, cp, cy: single;
forward_: vec3_t;
dist: single;
v: vec3_t;
ltime: single;
begin
// Sly 27-Jun-2002 These values are not used
dist := 64;
if (avelocities[0][0] = 0) then
begin
for i := 0 to NUMVERTEXNORMALS * 3 - 1 do
avelocities[0][i] := (rand() and 255) * 0.01;
end;
ltime := cl.time / 1000.0;
for i := 0 to NUMVERTEXNORMALS - 1 do
begin
angle := ltime * avelocities[i][0];
sy := sin(angle);
cy := cos(angle);
angle := ltime * avelocities[i][1];
sp := sin(angle);
cp := cos(angle);
// Sly 27-Jun-2002 These values are not used
// angle := ltime * avelocities[i][2];
// sr := sin(angle);
// cr := cos(angle);
forward_[0] := cp * cy;
forward_[1] := cp * sy;
forward_[2] := -sp;
if (free_particles = nil) then
exit;
p := free_particles;
free_particles := p.next;
p.next := active_particles;
active_particles := p;
p.time := cl.time;
dist := sin(ltime + i) * 64;
p.org[0] := ent.origin[0] + bytedirs[i][0] * dist + forward_[0] * BEAMLENGTH;
p.org[1] := ent.origin[1] + bytedirs[i][1] * dist + forward_[1] * BEAMLENGTH;
p.org[2] := ent.origin[2] + bytedirs[i][2] * dist + forward_[2] * BEAMLENGTH;
VectorClear(p.vel);
VectorClear(p.accel);
VectorSubtract(p.org, vec3_t(ent.origin), v);
dist := VectorLength(v) / 90.0;
p.color := floor($D0 + dist * 7);
p.colorvel := 0;
p.alpha := 1.0 - dist;
p.alphavel := -100;
end;
end;
(*
===============
CL_TrapParticles
===============
*)
// RAFAEL
procedure CL_TrapParticles(ent: entity_p);
var
move, vec: vec3_t;
start, end_: vec3_t;
len: single;
i, j, k: integer;
p: cparticle_p;
dec: integer;
vel: single;
dir, org: vec3_t;
begin
ent.origin[2] := ent.origin[2] - 14;
VectorCopy(vec3_t(ent.origin), start);
VectorCopy(vec3_t(ent.origin), end_);
end_[2] := end_[2] + 64;
VectorCopy(start, move);
VectorSubtract(end_, start, vec);
len := VectorNormalize(vec);
dec := 5;
VectorScale(vec, 5, vec);
// FIXME: this is a really silly way to have a loop
while (len > 0) do
begin
len := len - dec;
if (free_particles = nil) then
exit;
p := free_particles;
free_particles := p.next;
p.next := active_particles;
active_particles := p;
VectorClear(p.accel);
p.time := cl.time;
p.alpha := 1.0;
p.alphavel := -1.0 / (0.3 + frand() * 0.2);
p.color := $E0;
for j := 0 to 2 do
begin
p.org[j] := move[j] + crand();
p.vel[j] := crand() * 15;
p.accel[j] := 0;
end;
p.accel[2] := PARTICLE_GRAVITY;
VectorAdd(move, vec, move);
end;
ent.origin[2] := ent.origin[2] + 14;
VectorCopy(vec3_t(ent.origin), org);
i := -2;
while (i <= 2) do
begin
j := -2;
while (j <= 2) do
begin
k := -2;
while (k <= 4) do
begin
if (free_particles = nil) then
exit;
p := free_particles;
free_particles := p.next;
p.next := active_particles;
active_particles := p;
p.time := cl.time;
p.color := $E0 + (rand() and 3);
p.alpha := 1.0;
p.alphavel := -1.0 / (0.3 + (rand() and 7) * 0.02);
p.org[0] := org[0] + i + ((rand() and 23) * crand());
p.org[1] := org[1] + j + ((rand() and 23) * crand());
p.org[2] := org[2] + k + ((rand() and 23) * crand());
dir[0] := j * 8;
dir[1] := i * 8;
dir[2] := k * 8;
VectorNormalize(dir);
vel := 50 + rand() and 63;
VectorScale(dir, vel, p.vel);
p.accel[0] := 0;
p.accel[1] := 0;
p.accel[2] := -PARTICLE_GRAVITY;
k := k + 4;
end;
j := j + 4;
end;
i := i + 4;
end;
end;
(*
===============
CL_BFGExplosionParticles
===============
*)
//FIXME combined with CL_ExplosionParticles
procedure CL_BFGExplosionParticles(const org: vec3_t);
var
i, j: integer;
p: cparticle_p;
begin
for i := 0 to 256 - 1 do
begin
if (free_particles = nil) then
exit;
p := free_particles;
free_particles := p.next;
p.next := active_particles;
active_particles := p;
p.time := cl.time;
p.color := $D0 + (rand() and 7);
for j := 0 to 2 do
begin
p.org[j] := org[j] + ((rand() mod 32) - 16);
p.vel[j] := (rand() mod 384) - 192;
end;
p.accel[0] := 0;
p.accel[1] := 0;
p.accel[2] := -PARTICLE_GRAVITY;
p.alpha := 1.0;
p.alphavel := -0.8 / (0.5 + frand() * 0.3);
end;
end;
(*
===============
CL_TeleportParticles
===============
*)
procedure CL_TeleportParticles(const org: vec3_t);
var
i, j, k: integer;
p: cparticle_p;
vel: single;
dir: vec3_t;
begin
i := -16;
while (i <= 16) do
begin
j := -16;
while (j <= 16) do
begin
k := -16;
while (k <= 32) do
begin
if (free_particles = nil) then
exit;
p := free_particles;
free_particles := p.next;
p.next := active_particles;
active_particles := p;
p.time := cl.time;
p.color := 7 + (rand() and 7);
p.alpha := 1.0;
p.alphavel := -1.0 / (0.3 + (rand() and 7) * 0.02);
p.org[0] := org[0] + i + (rand() and 3);
p.org[1] := org[1] + j + (rand() and 3);
p.org[2] := org[2] + k + (rand() and 3);
dir[0] := j * 8;
dir[1] := i * 8;
dir[2] := k * 8;
VectorNormalize(dir);
vel := 50 + (rand() and 63);
VectorScale(dir, vel, p.vel);
p.accel[0] := 0;
p.accel[1] := 0;
p.accel[2] := -PARTICLE_GRAVITY;
k := k + 4;
end;
j := j + 4;
end;
i := i + 4;
end;
end;
(*
===============
CL_AddParticles
===============
*)
procedure CL_AddParticles;
var
p, next: cparticle_p;
alpha: single;
time, time2: single;
org: vec3_t;
color: integer;
active, tail: cparticle_p;
label
continue_;
begin
active := nil;
tail := nil;
// Sly 27-Jun-2002 If time does not get assigned, then the calculation of time2 later on may be undefined
time := 0.0;
p := active_particles;
while (p <> nil) do
begin
next := p.next;
// PMM - added INSTANT_PARTICLE handling for heat beam
if (p.alphavel <> INSTANT_PARTICLE) then
begin
time := (cl.time - p.time) * 0.001;
alpha := p.alpha + time * p.alphavel;
if (alpha <= 0) then
begin
// faded out
p.next := free_particles;
free_particles := p;
goto continue_;
end;
end
else
begin
alpha := p.alpha;
end;
p.next := nil;
if (tail = nil) then
begin
active := p;
tail := p;
end
else
begin
tail.next := p;
tail := p;
end;
if (alpha > 1.0) then
alpha := 1;
color := Round(p.color);
time2 := time * time;
org[0] := p.org[0] + p.vel[0] * time + p.accel[0] * time2;
org[1] := p.org[1] + p.vel[1] * time + p.accel[1] * time2;
org[2] := p.org[2] + p.vel[2] * time + p.accel[2] * time2;
V_AddParticle(org, color, alpha);
// PMM
if (p.alphavel = INSTANT_PARTICLE) then
begin
p.alphavel := 0.0;
p.alpha := 0.0;
end;
continue_:
p := next;
end;
active_particles := active;
end;
(*
==============
CL_EntityEvent
An entity has just been parsed that has an event value
the female events are there for backwards compatability
==============
*)
procedure CL_EntityEvent(ent: entity_state_p);
begin
case ent.event of
EV_ITEM_RESPAWN:
begin
S_StartSound(nil, ent.number, CHAN_WEAPON, S_RegisterSound('items/respawn1.wav'), 1, ATTN_IDLE, 0);
CL_ItemRespawnParticles(ent.origin);
end;
EV_PLAYER_TELEPORT:
begin
S_StartSound(nil, ent.number, CHAN_WEAPON, S_RegisterSound('misc/tele1.wav'), 1, ATTN_IDLE, 0);
CL_TeleportParticles(ent.origin);
end;
EV_FOOTSTEP:
if (cl_footsteps.value <> 0) then
S_StartSound(nil, ent.number, CHAN_BODY, cl_sfx_footsteps[rand() and 3], 1, ATTN_NORM, 0)
;
EV_FALLSHORT:
S_StartSound(nil, ent.number, CHAN_AUTO, S_RegisterSound('player/land1.wav'), 1, ATTN_NORM, 0);
EV_FALL:
S_StartSound(nil, ent.number, CHAN_AUTO, S_RegisterSound('*fall2.wav'), 1, ATTN_NORM, 0);
EV_FALLFAR:
S_StartSound(nil, ent.number, CHAN_AUTO, S_RegisterSound('*fall1.wav'), 1, ATTN_NORM, 0);
end;
end;
(*
==============
CL_ClearEffects
==============
*)
procedure CL_ClearEffects;
begin
CL_ClearParticles();
CL_ClearDlights();
CL_ClearLightStyles();
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -