From 5bd9d45f463c232d76454244812d642edd2d605e Mon Sep 17 00:00:00 2001 From: Mircea Kitsune Date: Wed, 26 Oct 2011 19:19:44 +0300 Subject: [PATCH] Limit impact execution time to avoid sounds playing each frame. Impact sounds can still be triggered every 0.1 second... but to be honest, that sounds kinda cool B-) --- defaultXonotic.cfg | 2 +- qcsrc/server/mutators/sandbox.qc | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index 1415cd893..a5bf4d680 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -547,7 +547,7 @@ set g_sandbox_editor_distance_spawn 200 "distance at which objects spawn in fron set g_sandbox_editor_distance_edit 350 "distance at which players can edit or remove objects they are looking at" set g_sandbox_object_scale_min 0.1 "minimum scale that objects can be set to" set g_sandbox_object_scale_max 2 "maximum scale that objects can be set to" -set g_sandbox_object_matvel 50 "velocity objects must have while coliding for material effects to be applied" +set g_sandbox_object_matvel 200 "velocity objects must have while colliding for material effects to be applied" seta menu_sandbox_spawn_model "" // used to store the model in the input field seta menu_sandbox_edit_skin 0 diff --git a/qcsrc/server/mutators/sandbox.qc b/qcsrc/server/mutators/sandbox.qc index af39b1554..801594661 100644 --- a/qcsrc/server/mutators/sandbox.qc +++ b/qcsrc/server/mutators/sandbox.qc @@ -28,10 +28,16 @@ void sandbox_EditObject_Scale(entity e, float f) } } +.float touch_timer; void sandbox_Object_Touch() { + // apply material impact effects + + if(self.touch_timer > time) + return; // don't execute each frame + self.touch_timer = time + 0.1; if not(vlen(self.velocity) >= autocvar_g_sandbox_object_matvel || vlen(other.velocity) >= autocvar_g_sandbox_object_matvel) - return; + return; // impact not strong enough switch(self.material) { -- 2.39.2