📄 cl_fx.java
字号:
cparticle_t p; int dec; int left = 0; Math3D.VectorCopy(start, move); Math3D.VectorSubtract(ent, start, vec); len = Math3D.VectorNormalize(vec); dec = 5; Math3D.VectorScale(vec, 5, vec); while (len > 0) { len -= dec; if (free_particles == null) return; p = free_particles; free_particles = p.next; p.next = active_particles; active_particles = p; Math3D.VectorClear(p.accel); p.time = Globals.cl.time; p.alpha = 0.5f; p.alphavel = -1.0f / (0.3f + Globals.rnd.nextFloat() * 0.2f); p.color = 0xe4 + (Lib.rand() & 3); for (j = 0; j < 3; j++) { p.org[j] = move[j]; p.accel[j] = 0; } if (left != 0) { left = 0; p.vel[0] = 10; } else { left = 1; p.vel[0] = -10; } p.vel[1] = 0; p.vel[2] = 0; Math3D.VectorAdd(move, vec, move); } } // stack variable // move, vec /* * =============== CL_BubbleTrail * * =============== */ static void BubbleTrail(float[] start, float[] end) { float len; int i, j; cparticle_t p; float dec; Math3D.VectorCopy(start, move); Math3D.VectorSubtract(end, start, vec); len = Math3D.VectorNormalize(vec); dec = 32; Math3D.VectorScale(vec, dec, vec); for (i = 0; i < len; i += dec) { if (free_particles == null) return; p = free_particles; free_particles = p.next; p.next = active_particles; active_particles = p; Math3D.VectorClear(p.accel); p.time = Globals.cl.time; p.alpha = 1.0f; p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.2f); p.color = 4 + (Lib.rand() & 7); for (j = 0; j < 3; j++) { p.org[j] = move[j] + Lib.crand() * 2; p.vel[j] = Lib.crand() * 5; } p.vel[2] += 6; Math3D.VectorAdd(move, vec, move); } } // stack variable // forward /* * =============== CL_FlyParticles =============== */ static void FlyParticles(float[] origin, int count) { int i; cparticle_t p; float angle; float sp, sy, cp, cy; float dist = 64; float ltime; if (count > Defines.NUMVERTEXNORMALS) count = Defines.NUMVERTEXNORMALS; if (avelocities[0][0] == 0.0f) { for (i = 0; i < Defines.NUMVERTEXNORMALS; i++) { avelocities[i][0] = (Lib.rand() & 255) * 0.01f; avelocities[i][1] = (Lib.rand() & 255) * 0.01f; avelocities[i][2] = (Lib.rand() & 255) * 0.01f; } } ltime = Globals.cl.time / 1000.0f; for (i = 0; i < count; i += 2) { angle = ltime * avelocities[i][0]; sy = (float) Math.sin(angle); cy = (float) Math.cos(angle); angle = ltime * avelocities[i][1]; sp = (float) Math.sin(angle); cp = (float) Math.cos(angle); angle = ltime * avelocities[i][2]; forward[0] = cp * cy; forward[1] = cp * sy; forward[2] = -sp; if (free_particles == null) return; p = free_particles; free_particles = p.next; p.next = active_particles; active_particles = p; p.time = Globals.cl.time; dist = (float) Math.sin(ltime + i) * 64; p.org[0] = origin[0] + Globals.bytedirs[i][0] * dist + forward[0] * BEAMLENGTH; p.org[1] = origin[1] + Globals.bytedirs[i][1] * dist + forward[1] * BEAMLENGTH; p.org[2] = origin[2] + Globals.bytedirs[i][2] * dist + forward[2] * BEAMLENGTH; Math3D.VectorClear(p.vel); Math3D.VectorClear(p.accel); p.color = 0; //p.colorvel = 0; p.alpha = 1; p.alphavel = -100; } } static void FlyEffect(centity_t ent, float[] origin) { int n; int count; int starttime; if (ent.fly_stoptime < Globals.cl.time) { starttime = Globals.cl.time; ent.fly_stoptime = Globals.cl.time + 60000; } else { starttime = ent.fly_stoptime - 60000; } n = Globals.cl.time - starttime; if (n < 20000) count = (int) ((n * 162) / 20000.0); else { n = ent.fly_stoptime - Globals.cl.time; if (n < 20000) count = (int) ((n * 162) / 20000.0); else count = 162; } FlyParticles(origin, count); } // stack variable private static final float[] v = {0, 0, 0}; // forward /* * =============== CL_BfgParticles =============== */ //#define BEAMLENGTH 16 static void BfgParticles(entity_t ent) { int i; cparticle_t p; float angle; float sp, sy, cp, cy; float dist = 64; float ltime; if (avelocities[0][0] == 0.0f) { for (i = 0; i < Defines.NUMVERTEXNORMALS; i++) { avelocities[i][0] = (Lib.rand() & 255) * 0.01f; avelocities[i][1] = (Lib.rand() & 255) * 0.01f; avelocities[i][2] = (Lib.rand() & 255) * 0.01f; } } ltime = Globals.cl.time / 1000.0f; for (i = 0; i < Defines.NUMVERTEXNORMALS; i++) { angle = ltime * avelocities[i][0]; sy = (float) Math.sin(angle); cy = (float) Math.cos(angle); angle = ltime * avelocities[i][1]; sp = (float) Math.sin(angle); cp = (float) Math.cos(angle); angle = ltime * avelocities[i][2]; forward[0] = cp * cy; forward[1] = cp * sy; forward[2] = -sp; if (free_particles == null) return; p = free_particles; free_particles = p.next; p.next = active_particles; active_particles = p; p.time = Globals.cl.time; dist = (float) (Math.sin(ltime + i) * 64); p.org[0] = ent.origin[0] + Globals.bytedirs[i][0] * dist + forward[0] * BEAMLENGTH; p.org[1] = ent.origin[1] + Globals.bytedirs[i][1] * dist + forward[1] * BEAMLENGTH; p.org[2] = ent.origin[2] + Globals.bytedirs[i][2] * dist + forward[2] * BEAMLENGTH; Math3D.VectorClear(p.vel); Math3D.VectorClear(p.accel); Math3D.VectorSubtract(p.org, ent.origin, v); dist = Math3D.VectorLength(v) / 90.0f; p.color = (float) Math.floor(0xd0 + dist * 7); //p.colorvel = 0; p.alpha = 1.0f - dist; p.alphavel = -100; } } // stack variable // move, vec private static final float[] start = {0, 0, 0}; private static final float[] end = {0, 0, 0}; /* * =============== CL_TrapParticles =============== */ // RAFAEL static void TrapParticles(entity_t ent) { float len; int j; cparticle_t p; int dec; ent.origin[2] -= 14; Math3D.VectorCopy(ent.origin, start); Math3D.VectorCopy(ent.origin, end); end[2] += 64; Math3D.VectorCopy(start, move); Math3D.VectorSubtract(end, start, vec); len = Math3D.VectorNormalize(vec); dec = 5; Math3D.VectorScale(vec, 5, vec); // FIXME: this is a really silly way to have a loop while (len > 0) { len -= dec; if (free_particles == null) return; p = free_particles; free_particles = p.next; p.next = active_particles; active_particles = p; Math3D.VectorClear(p.accel); p.time = Globals.cl.time; p.alpha = 1.0f; p.alphavel = -1.0f / (0.3f + Globals.rnd.nextFloat() * 0.2f); p.color = 0xe0; for (j = 0; j < 3; j++) { p.org[j] = move[j] + Lib.crand(); p.vel[j] = Lib.crand() * 15; p.accel[j] = 0; } p.accel[2] = PARTICLE_GRAVITY; Math3D.VectorAdd(move, vec, move); } int i, k; //cparticle_t p; float vel; float[] dir = new float[3]; float[] org = new float[3]; ent.origin[2] += 14; Math3D.VectorCopy(ent.origin, org); for (i = -2; i <= 2; i += 4) for (j = -2; j <= 2; j += 4) for (k = -2; k <= 4; k += 4) { if (free_particles == null) return; p = free_particles; free_particles = p.next; p.next = active_particles; active_particles = p; p.time = Globals.cl.time; p.color = 0xe0 + (Lib.rand() & 3); p.alpha = 1.0f; p.alphavel = -1.0f / (0.3f + (Lib.rand() & 7) * 0.02f); p.org[0] = org[0] + i + ((Lib.rand() & 23) * Lib.crand()); p.org[1] = org[1] + j + ((Lib.rand() & 23) * Lib.crand()); p.org[2] = org[2] + k + ((Lib.rand() & 23) * Lib.crand()); dir[0] = j * 8; dir[1] = i * 8; dir[2] = k * 8; Math3D.VectorNormalize(dir); vel = 50 + Lib.rand() & 63; Math3D.VectorScale(dir, vel, p.vel); p.accel[0] = p.accel[1] = 0; p.accel[2] = -PARTICLE_GRAVITY; } } /* * =============== CL_BFGExplosionParticles =============== */ // FIXME combined with CL_ExplosionParticles static void BFGExplosionParticles(float[] org) { int j; cparticle_t p; for (int i = 0; i < 256; i++) { if (free_particles == null) return; p = free_particles; free_particles = p.next; p.next = active_particles; active_particles = p; p.time = Globals.cl.time; p.color = 0xd0 + (Lib.rand() & 7); for (j = 0; j < 3; j++) { p.org[j] = org[j] + ((Lib.rand() % 32) - 16); p.vel[j] = (Lib.rand() % 384) - 192; } p.accel[0] = p.accel[1] = 0; p.accel[2] = -PARTICLE_GRAVITY; p.alpha = 1.0f; p.alphavel = -0.8f / (0.5f + Globals.rnd.nextFloat() * 0.3f); } } // stack variable private static final float[] dir = {0, 0, 0}; /* * =============== CL_TeleportParticles * * =============== */ static void TeleportParticles(float[] org) { cparticle_t p; float vel; for (int i = -16; i <= 16; i += 4) for (int j = -16; j <= 16; j += 4) for (int k = -16; k <= 32; k += 4) { if (free_particles == null) return; p = free_particles; free_particles = p.next; p.next = active_particles; active_particles = p; p.time = Globals.cl.time; p.color = 7 + (Lib.rand() & 7); p.alpha = 1.0f; p.alphavel = -1.0f / (0.3f + (Lib.rand() & 7) * 0.02f); p.org[0] = org[0] + i + (Lib.rand() & 3); p.org[1] = org[1] + j + (Lib.rand() & 3); p.org[2] = org[2] + k + (Lib.rand() & 3); dir[0] = j * 8; dir[1] = i * 8; dir[2] = k * 8; Math3D.VectorNormalize(dir); vel = 50 + (Lib.rand() & 63); Math3D.VectorScale(dir, vel, p.vel); p.accel[0] = p.accel[1] = 0; p.accel[2] = -PARTICLE_GRAVITY; } } // stack variable private static final float[] org = {0, 0, 0}; /* * =============== CL_AddParticles =============== */ static void AddParticles() { cparticle_t p, next; float alpha; float time = 0.0f; float time2; int color; cparticle_t active, tail; active = null; tail = null; for (p = active_particles; p != null; p = next) { next = p.next; // PMM - added INSTANT_PARTICLE handling for heat beam if (p.alphavel != INSTANT_PARTICLE) { time = (Globals.cl.time - p.time) * 0.001f; alpha = p.alpha + time * p.alphavel; if (alpha <= 0) { // faded out p.next = free_particles; free_particles = p; continue; } } else { alpha = p.alpha; } p.next = null; if (tail == null) active = tail = p; else { tail.next = p; tail = p; } if (alpha > 1.0) alpha = 1; color = (int) 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) { p.alphavel = 0.0f; p.alpha = 0.0f; } } active_particles = active; } /* * ============== CL_EntityEvent * * An entity has just been parsed that has an event value * * the female events are there for backwards compatability ============== */ static void EntityEvent(entity_state_t ent) { switch (ent.event) { case Defines.EV_ITEM_RESPAWN: S.StartSound(null, ent.number, Defines.CHAN_WEAPON, S.RegisterSound("items/respawn1.wav"), 1, Defines.ATTN_IDLE, 0); ItemRespawnParticles(ent.origin); break; case Defines.EV_PLAYER_TELEPORT: S.StartSound(null, ent.number, Defines.CHAN_WEAPON, S.RegisterSound("misc/tele1.wav"), 1, Defines.ATTN_IDLE, 0); TeleportParticles(ent.origin); break; case Defines.EV_FOOTSTEP: if (Globals.cl_footsteps.value != 0.0f) S.StartSound(null, ent.number, Defines.CHAN_BODY, CL_tent.cl_sfx_footsteps[Lib.rand() & 3], 1, Defines.ATTN_NORM, 0); break; case Defines.EV_FALLSHORT: S.StartSound(null, ent.number, Defines.CHAN_AUTO, S.RegisterSound("player/land1.wav"), 1, Defines.ATTN_NORM, 0); break; case Defines.EV_FALL: S.StartSound(null, ent.number, Defines.CHAN_AUTO, S.RegisterSound("*fall2.wav"), 1, Defines.ATTN_NORM, 0); break; case Defines.EV_FALLFAR: S.StartSound(null, ent.number, Defines.CHAN_AUTO, S.RegisterSound("*fall1.wav"), 1, Defines.ATTN_NORM, 0); break; } } /* * ============== CL_ClearEffects * * ============== */ static void ClearEffects() { ClearParticles(); ClearDlights(); ClearLightStyles(); } /* * ============================================================== * * PARTICLE MANAGEMENT * * ============================================================== */ static final int PARTICLE_GRAVITY = 40; static cparticle_t active_particles, free_particles; /* * =============== CL_BigTeleportParticles =============== */ private static int[] colortable = { 2 * 8, 13 * 8, 21 * 8, 18 * 8 }; private static final int BEAMLENGTH = 16;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -