From 1cd260807e21ddee904ca37b851a2288d0148ac2 Mon Sep 17 00:00:00 2001 From: Mircea Kitsune Date: Thu, 27 Oct 2011 13:48:31 +0300 Subject: [PATCH] Make particle count and intensity of impact sound depend on the impact speed --- defaultXonotic.cfg | 3 ++- effectinfo.txt | 16 ++++++++-------- qcsrc/server/autocvars.qh | 3 ++- qcsrc/server/mutators/sandbox.qc | 22 +++++++++++++--------- 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index 76be8f9cb1..d0de6f89b0 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -547,7 +547,8 @@ 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 200 "velocity objects must have while colliding for material effects to be applied" +set g_sandbox_object_material_velocity_min 200 "velocity objects must have while colliding for material effects to be applied" +set g_sandbox_object_material_velocity_factor 0.002 "velocity range which decides the intensity of material effects" seta menu_sandbox_spawn_model "" // used to store the model in the input field seta menu_sandbox_edit_skin 0 diff --git a/effectinfo.txt b/effectinfo.txt index 06e0973312..610ae1a239 100644 --- a/effectinfo.txt +++ b/effectinfo.txt @@ -6411,7 +6411,7 @@ rotate -180 180 -20 20 // metal impact effect // used in qcsrc/server/mutators/sandbox.qc: pointparticles(particleeffectnum("impact_metal"), self.origin, '0 0 0', 1); effect impact_metal -countabsolute 5 +countabsolute 1 type alphastatic tex 0 8 size 3 6 @@ -6422,7 +6422,7 @@ color 0x000000 0x886666 originjitter 20 20 5 // sparks effect impact_metal -count 10 +count 2 type spark tex 41 41 color 0xFFCC22 0xFF4422 @@ -6438,7 +6438,7 @@ gravity 1 // stone impact effect // used in qcsrc/server/mutators/sandbox.qc: pointparticles(particleeffectnum("impact_stone"), self.origin, '0 0 0', 1); effect impact_stone -countabsolute 5 +countabsolute 1 type alphastatic tex 0 8 size 3 6 @@ -6450,7 +6450,7 @@ originjitter 20 20 5 // debris effect impact_stone notunderwater -count 5 +count 2 type alphastatic tex 66 68 color 0x000000 0x886644 @@ -6465,7 +6465,7 @@ rotate -180 180 -1000 1000 // wood impact effect // used in qcsrc/server/mutators/sandbox.qc: pointparticles(particleeffectnum("impact_wood"), self.origin, '0 0 0', 1); effect impact_wood -countabsolute 5 +countabsolute 1 type alphastatic tex 0 8 size 3 6 @@ -6476,7 +6476,7 @@ color 0x000000 0xcc9966 originjitter 20 20 5 // sparks effect impact_wood -count 10 +count 2 type spark tex 41 41 color 0x221100 0x221100 @@ -6491,7 +6491,7 @@ gravity 1 // flesh impact effect // used in qcsrc/server/mutators/sandbox.qc: pointparticles(particleeffectnum("impact_flesh"), self.origin, '0 0 0', 1); effect impact_flesh -countabsolute 1 +countabsolute 0.5 type alphastatic tex 0 8 size 8 12 @@ -6500,7 +6500,7 @@ color 0x000000 0x420000 originjitter 11 11 11 // blood splash effect impact_flesh -count 3 +count 0.3 type blood tex 24 32 size 2 6 diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index 6a503d38c0..f764502b49 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -1204,4 +1204,5 @@ float autocvar_g_sandbox_editor_distance_spawn; float autocvar_g_sandbox_editor_distance_edit; float autocvar_g_sandbox_object_scale_min; float autocvar_g_sandbox_object_scale_max; -float autocvar_g_sandbox_object_matvel; +float autocvar_g_sandbox_object_material_velocity_min; +float autocvar_g_sandbox_object_material_velocity_factor; diff --git a/qcsrc/server/mutators/sandbox.qc b/qcsrc/server/mutators/sandbox.qc index 971b0ab3b1..1dab4fb2b8 100644 --- a/qcsrc/server/mutators/sandbox.qc +++ b/qcsrc/server/mutators/sandbox.qc @@ -15,26 +15,30 @@ void sandbox_Object_Touch() 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) + if not(vlen(self.velocity) > autocvar_g_sandbox_object_material_velocity_min || vlen(other.velocity) > autocvar_g_sandbox_object_material_velocity_min) return; // impact not strong enough + float intensity; + intensity = (vlen(self.velocity) + vlen(other.velocity)) / 2; + intensity = bound(0, intensity * autocvar_g_sandbox_object_material_velocity_factor, 1); + switch(self.material) { case MATERIAL_METAL: - sound(self, CH_TRIGGER, strcat("object/impact_metal_", ftos(ceil(random() * 5)) , ".ogg"), VOL_BASE, ATTN_NORM); - pointparticles(particleeffectnum("impact_metal"), self.origin, '0 0 0', 1); + sound(self, CH_TRIGGER, strcat("object/impact_metal_", ftos(ceil(random() * 5)) , ".ogg"), VOL_BASE * intensity, ATTN_NORM); + pointparticles(particleeffectnum("impact_metal"), self.origin, '0 0 0', intensity * 10); // allow a count from 1 to 10 break; case MATERIAL_STONE: - sound(self, CH_TRIGGER, strcat("object/impact_stone_", ftos(ceil(random() * 5)) , ".ogg"), VOL_BASE, ATTN_NORM); - pointparticles(particleeffectnum("impact_stone"), self.origin, '0 0 0', 1); + sound(self, CH_TRIGGER, strcat("object/impact_stone_", ftos(ceil(random() * 5)) , ".ogg"), VOL_BASE * intensity, ATTN_NORM); + pointparticles(particleeffectnum("impact_stone"), self.origin, '0 0 0', intensity * 10); // allow a count from 1 to 10 break; case MATERIAL_WOOD: - sound(self, CH_TRIGGER, strcat("object/impact_wood_", ftos(ceil(random() * 5)) , ".ogg"), VOL_BASE, ATTN_NORM); - pointparticles(particleeffectnum("impact_wood"), self.origin, '0 0 0', 1); + sound(self, CH_TRIGGER, strcat("object/impact_wood_", ftos(ceil(random() * 5)) , ".ogg"), VOL_BASE * intensity, ATTN_NORM); + pointparticles(particleeffectnum("impact_wood"), self.origin, '0 0 0', intensity * 10); // allow a count from 1 to 10 break; case MATERIAL_FLESH: - sound(self, CH_TRIGGER, strcat("object/impact_flesh_", ftos(ceil(random() * 5)) , ".ogg"), VOL_BASE, ATTN_NORM); - pointparticles(particleeffectnum("impact_flesh"), self.origin, '0 0 0', 1); + sound(self, CH_TRIGGER, strcat("object/impact_flesh_", ftos(ceil(random() * 5)) , ".ogg"), VOL_BASE * intensity, ATTN_NORM); + pointparticles(particleeffectnum("impact_flesh"), self.origin, '0 0 0', intensity * 10); // allow a count from 1 to 10 break; default: break; -- 2.39.2