From: Mircea Kitsune Date: Sat, 14 Jan 2012 12:09:24 +0000 (+0200) Subject: Simplify the bone detection code for damage effects X-Git-Tag: xonotic-v0.6.0~110^2^2~16 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=fa2f3a303732240c29248af4cf0a845936b29123;p=xonotic%2Fxonotic-data.pk3dir.git Simplify the bone detection code for damage effects --- diff --git a/qcsrc/client/damage.qc b/qcsrc/client/damage.qc index 33e0ab05e..1199f5022 100644 --- a/qcsrc/client/damage.qc +++ b/qcsrc/client/damage.qc @@ -35,7 +35,7 @@ void DamageEffect(vector hitorg, float dmg, float type, float specnum) { // particle effects for players and objects damaged by weapons (eg: flames coming out of victims shot with rockets) - float life, skeletal; + float life, nearestbone; string specstr, effectnum; entity e; @@ -47,7 +47,6 @@ void DamageEffect(vector hitorg, float dmg, float type, float specnum) // if this is a rigged mesh, the effect will show on the bone where damage was dealt // we do this by choosing the skeletal bone closest to the impact, and attaching our entity to it // if there's no skeleton, object origin will automatically be selected - float closest; FOR_EACH_TAG(self) { // blacklist bones positioned outside the mesh, or the effect will be floating @@ -58,16 +57,13 @@ void DamageEffect(vector hitorg, float dmg, float type, float specnum) continue; // skip empty bones // now choose the bone closest to impact origin - if(!closest || vlen(hitorg - gettaginfo(self, tagnum)) <= vlen(hitorg - gettaginfo(self, closest))) - { - closest = tagnum; - skeletal = TRUE; // a bone was found, so this model is rigged - } + if(!nearestbone || vlen(hitorg - gettaginfo(self, tagnum)) <= vlen(hitorg - gettaginfo(self, nearestbone))) + nearestbone = tagnum; } - gettaginfo(self, closest); // set gettaginfo_name + gettaginfo(self, nearestbone); // set gettaginfo_name // return if we reached our damage effect limit or damages are disabled - if(skeletal) + if(nearestbone) { if(autocvar_cl_damageeffect < 1 || self.total_damages >= autocvar_cl_damageeffect_bones) return; // allow multiple damages on skeletal models