From 7e530bdcc6ef88a1174f3408a7b2fed4eff43222 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Gia=20Phong?= Date: Fri, 1 Oct 2021 16:13:41 +0700 Subject: Remove Skeleton.num_joints --- src/GameTick.cpp | 290 ++++++++++++++++++------------------------------------- 1 file changed, 95 insertions(+), 195 deletions(-) (limited to 'src/GameTick.cpp') diff --git a/src/GameTick.cpp b/src/GameTick.cpp index 9a79086..3b9cf5a 100644 --- a/src/GameTick.cpp +++ b/src/GameTick.cpp @@ -1570,14 +1570,14 @@ void Game::Tick() person[i].skeleton.free=1; person[i].longdead=1; - for(int j=0;j0)person[i].DrawSkeleton(i); if(findDistancefast(person[i].averageloc,person[i].oldaverageloc)<.2*multiplier)person[i].longdead-=multiplier/2; @@ -1623,9 +1622,9 @@ void Game::Tick() //Find playercoords person[i].playercoords=person[i].averageloc; - for(int j=0;jperson[i].playercoords.y)person[i].playercoords.y=person[i].skeleton.joints[j].position.y; - } + for (auto& joint : person[i].skeleton.joints) + if (joint.position.y > person[i].playercoords.y) + person[i].playercoords.y = joint.position.y; //Find orientation XYZ firsttop=person[i].skeleton.joints[person[i].skeleton.jointlabels[neck]].position-person[i].skeleton.joints[person[i].skeleton.jointlabels[groin]].position; @@ -1637,7 +1636,7 @@ void Game::Tick() person[i].playervelocity=0; if(person[i].targetanimation==getupfrontanim)person[i].playerrotation+=180; - for(int j=0;j0){ @@ -2281,43 +2259,23 @@ void Game::Tick() person[whichhit].skeleton.offset=1; - for(int j=0;j36){ - - Normalise(&person[whichhit].skeleton.joints[j].offset); - - person[whichhit].skeleton.joints[j].offset*=6; - + if (findLengthfast(joint.offset) > 36) { + Normalise(&joint.offset); + joint.offset *= 6; } - } - } if(hitstruct.joint1->modelnum==headmodel&&person[whichhit].health<=0){ - for(int j=0;jvelocity += sprites.velocity[i]; @@ -2930,52 +2886,24 @@ void Game::Tick() person[j].skeleton.offset=1; - for(int k=0;k9){ - - Normalise(&person[j].skeleton.joints[k].offset); - - person[j].skeleton.joints[k].offset*=3; - + if (findLengthfast(joint.offset) > 9) { + Normalise(&joint.offset); + joint.offset *= 3; } - } - }} - sprites.velocity[i]*=-.3; - } - } - } - } - sprites.oldlocation[i]=sprites.location[i]; - } //Explode @@ -3084,72 +3012,44 @@ void Game::Tick() person[k].bjoint1 = &person[k].skeleton.joints[person[k].skeleton.jointlabels[head]]; person[k].bjoint2 = &person[k].skeleton.joints[person[k].skeleton.jointlabels[neck]]; - for(int j=0;j1)person[k].skeleton.joints[j].velocity+=relation/findDistance(person[k].skeleton.joints[j].position,sprites.location[i])*300; - - else person[k].skeleton.joints[j].velocity+=relation*300; - - } - person[k].longdead=1; - - for(int j=0;j1500&&person[k].skeleton.joints[j].existing==1&&abs(Random()%3)!=1){ - - sprites.MakeSprite(bloodspritedown, .8, 1, .2, .2,person[k].skeleton.joints[j].position, person[k].skeleton.joints[j].velocity/3, 9); - - person[k].skeleton.DeleteJoint(j); - + for (auto& joint : person[k].skeleton.joints) { + relation = joint.position - sprites.location[i]; + Normalise(&relation); + auto distance = findDistance(joint.position, sprites.location[i]); + if (distance > 1) + joint.velocity += relation / distance * 300; + else + joint.velocity += relation * 300; + + // Sever stuff + if (findLengthfast(joint.velocity) > 1500 + && joint.existing && abs(Random() % 3) != 1) { + sprites.MakeSprite(bloodspritedown, 0.8, 1, 0.2, 0.2, joint.position, joint.velocity / 3, 9); + person[k].skeleton.DeleteJoint(&joint + - person[k].skeleton.joints); person[k].skeleton.broken=2; - person[k].health=-10000; - - person[k].skeleton.joints[j].existing=0; - + joint.existing = false; } - } - } - } - } - } - } - } - } //camera shake -- cgit v1.2.3