]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
electro lightning: make it look more electric
authorRudolf Polzer <divverent@alientrap.org>
Sat, 31 Jul 2010 12:48:34 +0000 (14:48 +0200)
committerRudolf Polzer <divverent@alientrap.org>
Sat, 31 Jul 2010 12:48:34 +0000 (14:48 +0200)
qcsrc/client/hook.qc
qcsrc/client/noise.qc [new file with mode: 0644]
qcsrc/client/noise.qh [new file with mode: 0644]
qcsrc/client/progs.src

index 2fe9a86dd9b0762f03724133d669bfa22e67e835..412d4a44e02890c3e46e830f8430c9c2671563a9 100644 (file)
@@ -41,9 +41,13 @@ void Draw_CylindricLine(vector from, vector to, float thickness, string texture,
 
 string Draw_GrapplingHook_trace_callback_tex;
 float Draw_GrapplingHook_trace_callback_rnd;
 
 string Draw_GrapplingHook_trace_callback_tex;
 float Draw_GrapplingHook_trace_callback_rnd;
+vector Draw_GrapplingHook_trace_callback_rgb;
+float Draw_GrapplingHook_trace_callback_a;
 void Draw_GrapplingHook_trace_callback(vector start, vector hit, vector end)
 {
 void Draw_GrapplingHook_trace_callback(vector start, vector hit, vector end)
 {
-       Draw_CylindricLine(hit, start, 8, Draw_GrapplingHook_trace_callback_tex, 0.25, Draw_GrapplingHook_trace_callback_rnd, '1 1 1', 1, DRAWFLAG_NORMAL);
+       float i;
+       for(i = 0; i < Draw_GrapplingHook_trace_callback_a; ++i)
+               Draw_CylindricLine(hit, start, 8, Draw_GrapplingHook_trace_callback_tex, 0.25, Draw_GrapplingHook_trace_callback_rnd, Draw_GrapplingHook_trace_callback_rgb, min(1, Draw_GrapplingHook_trace_callback_a - i), DRAWFLAG_NORMAL);
        Draw_GrapplingHook_trace_callback_rnd += 0.25 * vlen(hit - start) / 8;
 }
 
        Draw_GrapplingHook_trace_callback_rnd += 0.25 * vlen(hit - start) / 8;
 }
 
@@ -55,6 +59,7 @@ void Draw_GrapplingHook()
        float t;
        float s;
        vector vs;
        float t;
        float s;
        vector vs;
+       float intensity, offset;
 
        InterpolateOrigin_Do();
 
 
        InterpolateOrigin_Do();
 
@@ -120,6 +125,8 @@ void Draw_GrapplingHook()
        {
                default:
                case ENT_CLIENT_HOOK:
        {
                default:
                case ENT_CLIENT_HOOK:
+                       intensity = 1;
+                       offset = Noise_White(self, frametime);
                        if(t == COLOR_TEAM1)
                        {
                                tex = "particles/hook_red";
                        if(t == COLOR_TEAM1)
                        {
                                tex = "particles/hook_red";
@@ -147,17 +154,23 @@ void Draw_GrapplingHook()
                        }
                        break;
                case ENT_CLIENT_LGBEAM:
                        }
                        break;
                case ENT_CLIENT_LGBEAM:
+                       intensity = bound(0.2, 1 + Noise_Pink(self, frametime) * 1 + Noise_Burst(self, frametime, 0.03) * 0.3, 2);
+                       offset = Noise_Brown(self, frametime) * 10;
                        tex = "particles/lgbeam";
                        rgb = '1 1 1';
                        break;
                case ENT_CLIENT_GAUNTLET:
                        tex = "particles/lgbeam";
                        rgb = '1 1 1';
                        break;
                case ENT_CLIENT_GAUNTLET:
+                       intensity = 1;
+                       offset = Noise_White(self, frametime);
                        tex = "particles/gauntletbeam";
                        rgb = '1 1 1';
                        break;
        }
 
        Draw_GrapplingHook_trace_callback_tex = tex;
                        tex = "particles/gauntletbeam";
                        rgb = '1 1 1';
                        break;
        }
 
        Draw_GrapplingHook_trace_callback_tex = tex;
-       Draw_GrapplingHook_trace_callback_rnd = random();
+       Draw_GrapplingHook_trace_callback_rnd = offset;
+       Draw_GrapplingHook_trace_callback_rgb = rgb;
+       Draw_GrapplingHook_trace_callback_a = intensity;
        WarpZone_TraceBox_ThroughZone(a, '0 0 0', '0 0 0', b, ((self.HookType == ENT_CLIENT_HOOK) ? MOVE_NOTHING : MOVE_NORMAL), world, world, Draw_GrapplingHook_trace_callback);
        Draw_GrapplingHook_trace_callback_tex = string_null;
 
        WarpZone_TraceBox_ThroughZone(a, '0 0 0', '0 0 0', b, ((self.HookType == ENT_CLIENT_HOOK) ? MOVE_NOTHING : MOVE_NORMAL), world, world, Draw_GrapplingHook_trace_callback);
        Draw_GrapplingHook_trace_callback_tex = string_null;
 
@@ -182,10 +195,10 @@ void Draw_GrapplingHook()
                case ENT_CLIENT_HOOK:
                        break;
                case ENT_CLIENT_LGBEAM:
                case ENT_CLIENT_HOOK:
                        break;
                case ENT_CLIENT_LGBEAM:
-                       pointparticles(particleeffectnum("electro_lightning"), trace_endpos, normalize(atrans - trace_endpos), frametime);
+                       pointparticles(particleeffectnum("electro_lightning"), trace_endpos, normalize(atrans - trace_endpos), frametime * intensity);
                        break;
                case ENT_CLIENT_GAUNTLET:
                        break;
                case ENT_CLIENT_GAUNTLET:
-                       pointparticles(particleeffectnum("gauntlet_lightning"), b, normalize(a - b), frametime);
+                       pointparticles(particleeffectnum("gauntlet_lightning"), b, normalize(a - b), frametime * intensity);
                        break;
        }
 }
                        break;
        }
 }
diff --git a/qcsrc/client/noise.qc b/qcsrc/client/noise.qc
new file mode 100644 (file)
index 0000000..ef9b855
--- /dev/null
@@ -0,0 +1,33 @@
+.float noise_baccum;
+.float noise_paccum;
+.float noise_paccum2;
+.float noise_paccum3;
+.float noise_bstate;
+float Noise_Brown(entity e, float dt)
+{
+       e.noise_baccum += random() * sqrt(dt); // same stddev for all dt
+       return e.noise_baccum;
+}
+float Noise_Pink(entity e, float dt)
+{
+       float f;
+       f = dt * 60;
+       // http://home.earthlink.net/~ltrammell/tech/pinkalg.htm
+       if(random() > pow(0.3190, f))
+               e.noise_paccum = 0.34848 * (2 * random() - 1);
+       if(random() > pow(0.7756, f))
+               e.noise_paccum2 = 0.28768 * (2 * random() - 1);
+       if(random() > pow(0.9613, f))
+               e.noise_paccum3 = 0.43488 * (2 * random() - 1);
+       return e.noise_paccum + e.noise_paccum2 + e.noise_paccum3;
+}
+float Noise_White(entity e, float dt)
+{
+       return random() * 2 - 1;
+}
+float Noise_Burst(entity e, float dt, float p)
+{
+       if(random() > pow(p, dt))
+               e.noise_bstate = !e.noise_bstate;
+       return 2 * e.noise_bstate - 1;
+}
diff --git a/qcsrc/client/noise.qh b/qcsrc/client/noise.qh
new file mode 100644 (file)
index 0000000..30ce4d0
--- /dev/null
@@ -0,0 +1,5 @@
+// noises "usually" start in the range -1..1
+float Noise_Brown(entity e, float dt);
+float Noise_Pink(entity e, float dt);
+float Noise_White(entity e, float dt);
+float Noise_Burst(entity e, float dt, float p); // +1 or -1
index 5e94475ce23fbff63ae8831c0972bb469c990357..4569e497ce30dc1cffbf40f7ae2371f65836d4ee 100644 (file)
@@ -26,6 +26,7 @@ waypointsprites.qh
 movetypes.qh
 prandom.qh
 bgmscript.qh
 movetypes.qh
 prandom.qh
 bgmscript.qh
+noise.qh
 
 main.qh
 
 
 main.qh
 
@@ -62,6 +63,7 @@ waypointsprites.qc
 movetypes.qc
 prandom.qc
 bgmscript.qc
 movetypes.qc
 prandom.qc
 bgmscript.qc
+noise.qc
 
 ../common/util.qc
 ../common/gamecommand.qc
 
 ../common/util.qc
 ../common/gamecommand.qc