From b9673a6acef6c9b2b6a1575758ed7f5ce13adb6b Mon Sep 17 00:00:00 2001 From: user Date: Tue, 29 Dec 2015 05:41:52 +0000 Subject: [PATCH] better deformation logic --- game/objfunc.c | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/game/objfunc.c b/game/objfunc.c index 5192f63..f7bd29b 100644 --- a/game/objfunc.c +++ b/game/objfunc.c @@ -37,10 +37,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "../math/vector.h" #include "../physics/bond.h" #include "../physics/particle.h" - void objectcycle(void) { - int count,count2,count3,count4; + int count,count2,count3; + float deformation; int x,y; float vec[3],vec2[3]; float veclength/*,bondlength*/; @@ -117,7 +117,7 @@ void objectcycle(void) for (count2=0;count26) { subtractvectors(vec,particle[object[count].particle[count3]].position,particle[object[count].particle[count2]].position); veclength=vectorlength(vec); - if (veclength<0.15f) - count4++; + deformation += (veclength-NORMALVECLENGTH) * + (veclength-NORMALVECLENGTH) * + SEVERITY / 2; //if (veclength<0.15f) // object[count].hitpoints-=(0.2f-veclength)*500.0f; } - /* Gish death by deformation (TODO: rename count4 etc.) */ - if (count4>=2) - object[count].hitpoints-=(count4-1)*50; - + /* Gish death by deformation */ + if(deformation > THRESHOLD) + object[count].hitpoints-=(deformation-1); +#undef THRESHOLD +#undef MINLENGTH +#undef SEVERITY if (object[count].numoforientations==0) copyvector(object[count].orientation[1],yaxis); else @@ -686,7 +701,7 @@ void objectcycle(void) subtractvectors(vec,particle[object[count].particle[count2]].position,object[count].position); crossproduct(vec2,zaxis,vec); normalizevector(vec2,vec2); - + scaleaddvectors(particle[object[count].particle[count2]].velocity,particle[object[count].particle[count2]].velocity,vec2,spin*0.003f); } }