-int Person::DrawSkeleton(){
- int oldplayerdetail;
- if((frustum.SphereInFrustum(coords.x,coords.y+scale*3,coords.z,scale*8)&&findDistancefast(&viewer,&coords)<viewdistance*viewdistance)||skeleton.free==3){
- if(onterrain&&(isIdle()||isCrouch()||wasIdle()||wasCrouch())&&!skeleton.free){
- calcrot=1;
- }
-
- if(headless){
- headmorphness=0;
- headmorphstart=6;
- headmorphend=6;
- }
-
- glAlphaFunc(GL_GREATER, 0.0001);
- XYZ terrainlight;
- float terrainheight;
- float distance;
- if(!isnormal(rotation))rotation=0;
- if(!isnormal(tilt))tilt=0;
- if(!isnormal(tilt2))tilt2=0;
- oldplayerdetail=playerdetail;
- playerdetail=0;
- if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/32&&detail==2){
- playerdetail=1;
- }
- if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/128&&detail==1){
- playerdetail=1;
- }
- if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/256&&(detail!=1&&detail!=2)){
- playerdetail=1;
- }
- if(id==0)
- playerdetail=1;
- if(playerdetail!=oldplayerdetail) {
- updatedelay=0;
- normalsupdatedelay=0;
- }
- static float updatedelaychange;
- static float morphness;
- static float framemult;
- if(calcrot){
- skeleton.FindForwards();
- if(howactive==typesittingwall){
- skeleton.specialforward[1]=0;
- skeleton.specialforward[1].z=1;
- }
- }
- static XYZ mid;
- static float M[16];
- static int i,j,k;
- static int weaponattachmuscle;
- static int weaponrotatemuscle,weaponrotatemuscle2;
- static XYZ weaponpoint;
- static int start,endthing;
- if((dead!=2||skeleton.free!=2)&&updatedelay<=0){
- if(!isSleeping()&&!isSitting()){
- if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
- XYZ point,newpoint,change,change2;
- point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
- heightleft=terrain.getHeight(point.x,point.z)+.04;
- point.y=heightleft;
- change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
- change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
- skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
- skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
- skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
-
- point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
- heightright=terrain.getHeight(point.x,point.z)+.04;
- point.y=heightright;
- change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
- change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
- skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
- skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
- skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
- skeleton.DoConstraints(&coords,&scale);
-
- if(creature==wolftype){
- point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
- heightleft=terrain.getHeight(point.x,point.z)+.04;
- point.y=heightleft;
- change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
- change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
- skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
- skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
- skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
-
- point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
- heightright=terrain.getHeight(point.x,point.z)+.04;
- point.y=heightright;
- change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
- change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
- skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
- skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
- skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
- skeleton.DoConstraints(&coords,&scale);
- }
- }
- if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&!(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
- XYZ point,newpoint,change,change2;
- point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
- heightleft=terrain.getHeight(point.x,point.z)+.04;
- point.y=heightleft;
- change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
- change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
- skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
- skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
- skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
-
- point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
- heightright=terrain.getHeight(point.x,point.z)+.04;
- point.y=heightright;
- change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
- change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
- skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
- skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
- skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
- skeleton.DoConstraints(&coords,&scale);
-
- if(creature==wolftype){
- point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
- heightleft=terrain.getHeight(point.x,point.z)+.04;
- point.y=heightleft;
- change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
- change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
- skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
- skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
- skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
-
- point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
- heightright=terrain.getHeight(point.x,point.z)+.04;
- point.y=heightright;
- change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
- change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
- skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
- skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
- skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
- skeleton.DoConstraints(&coords,&scale);
- }
- }
-
- if(onterrain&&(!(isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
- XYZ point,newpoint,change,change2;
- point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
- heightleft=terrain.getHeight(point.x,point.z)+.04;
- point.y=heightleft;
- change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
- change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
- skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
- skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
- skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
-
- point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
- heightright=terrain.getHeight(point.x,point.z)+.04;
- point.y=heightright;
- change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
- change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
- skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
- skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
- skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
- skeleton.DoConstraints(&coords,&scale);
-
- if(creature==wolftype){
- point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
- heightleft=terrain.getHeight(point.x,point.z)+.04;
- point.y=heightleft;
- change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
- change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
- skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
- skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
- skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
-
- point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
- heightright=terrain.getHeight(point.x,point.z)+.04;
- point.y=heightright;
- change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
- change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
- skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
- skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
- skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
- skeleton.DoConstraints(&coords,&scale);
- }
- }
- }
- if(!skeleton.free&&(!animation[targetanimation].attack&&targetanimation!=getupfrombackanim&&((targetanimation!=rollanim&&!isFlip())||animation[targetanimation].label[targetframe]==6)&&targetanimation!=getupfromfrontanim&&targetanimation!=wolfrunninganim&&targetanimation!=rabbitrunninganim&&targetanimation!=backhandspringanim&&targetanimation!=walljumpfrontanim&&targetanimation!=hurtidleanim&&!isLandhard()&&!isSleeping()))
- DoHead();
- else {
- targetheadrotation=-targetrotation;
- targetheadrotation2=0;
- if(animation[targetanimation].attack==3)targetheadrotation+=180;
- }
- for(i=0;i<skeleton.drawmodel.vertexNum;i++){
- skeleton.drawmodel.vertex[i]=0;
- skeleton.drawmodel.vertex[i].y=999;
- }
- for(i=0;i<skeleton.drawmodellow.vertexNum;i++){
- skeleton.drawmodellow.vertex[i]=0;
- skeleton.drawmodellow.vertex[i].y=999;
- }
- for(i=0;i<skeleton.drawmodelclothes.vertexNum;i++){
- skeleton.drawmodelclothes.vertex[i]=0;
- skeleton.drawmodelclothes.vertex[i].y=999;
- }
- for(i=0;i<skeleton.num_muscles;i++){
- if((skeleton.muscles[i].numvertices>0&&playerdetail)||(skeleton.muscles[i].numverticeslow>0&&!playerdetail)){
- morphness=0;
- start=0;
- endthing=0;
- if(skeleton.muscles[i].parent1->label==righthand||skeleton.muscles[i].parent2->label==righthand){
- morphness=righthandmorphness;
- start=righthandmorphstart;
- endthing=righthandmorphend;
- }
- if(skeleton.muscles[i].parent1->label==lefthand||skeleton.muscles[i].parent2->label==lefthand){
- morphness=lefthandmorphness;
- start=lefthandmorphstart;
- endthing=lefthandmorphend;
- }
- if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head){
- morphness=headmorphness;
- start=headmorphstart;
- endthing=headmorphend;
- }
- if((skeleton.muscles[i].parent1->label==neck&&skeleton.muscles[i].parent2->label==abdomen)||(skeleton.muscles[i].parent2->label==neck&&skeleton.muscles[i].parent1->label==abdomen)){
- morphness=chestmorphness;
- start=chestmorphstart;
- endthing=chestmorphend;
- }
- if((skeleton.muscles[i].parent1->label==groin&&skeleton.muscles[i].parent2->label==abdomen)||(skeleton.muscles[i].parent2->label==groin&&skeleton.muscles[i].parent1->label==abdomen)){
- morphness=tailmorphness;
- start=tailmorphstart;
- endthing=tailmorphend;
- }
- if(calcrot)skeleton.FindRotationMuscle(i,targetanimation);
- mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glPushMatrix();
- glLoadIdentity();
- if(!skeleton.free)glRotatef(tilt2,1,0,0);
- if(!skeleton.free)glRotatef(tilt,0,0,1);
-
-
- glTranslatef(mid.x,mid.y,mid.z);
-
- skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
- glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
-
- skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
- glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
-
- skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
- glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
- /*
- if(!isnormal(proportionbody.x)||!isnormal(proportionbody.y)||!isnormal(proportionbody.z)){
- proportionbody=1;
- proportionweird=1;
- }
- if(!isnormal(proportionarms.x)||!isnormal(proportionarms.y)||!isnormal(proportionarms.z)){
- proportionarms=1;
- proportionweird=1;
- }
- if(!isnormal(proportionhead.x)||!isnormal(proportionhead.y)||!isnormal(proportionhead.z)){
- proportionhead=1;
- proportionweird=1;
- }
- if(!isnormal(proportionlegs.x)||!isnormal(proportionlegs.y)||!isnormal(proportionlegs.z)){
- proportionlegs=1;
- proportionweird=1;
- }*/
-
- if(playerdetail||skeleton.free==3)
- {
- for(j=0;j<skeleton.muscles[i].numvertices;j++)
- {
- /*if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].x))vertexweird[0]=1;
- if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].y))vertexweird[1]=1;
- if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].z))vertexweird[2]=1;
- if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].x))vertexweird[3]=1;
- if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].y))vertexweird[4]=1;
- if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].z))vertexweird[5]=1;
- if(skeleton.muscles[i].vertices[j]<skeleton.model[start].vertexNum&&skeleton.muscles[i].vertices[j]>=0){*/
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glPushMatrix();
- if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
- glTranslatef((skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].x*(1-morphness)+skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].x*morphness)*proportionbody.x,
- (skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].y*(1-morphness)+skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].y*morphness)*proportionbody.y,
- (skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].z*(1-morphness)+skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].z*morphness)*proportionbody.z);
- if(skeleton.muscles[i].parent1->label==lefthand||skeleton.muscles[i].parent1->label==righthand||skeleton.muscles[i].parent1->label==leftwrist||skeleton.muscles[i].parent1->label==rightwrist||skeleton.muscles[i].parent1->label==leftelbow||skeleton.muscles[i].parent1->label==rightelbow||skeleton.muscles[i].parent2->label==leftelbow||skeleton.muscles[i].parent2->label==rightelbow)
- glTranslatef((skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].x*(1-morphness)+skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].x*morphness)*proportionarms.x,
- (skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].y*(1-morphness)+skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].y*morphness)*proportionarms.y,
- (skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].z*(1-morphness)+skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].z*morphness)*proportionarms.z);
- if(skeleton.muscles[i].parent1->label==leftfoot||skeleton.muscles[i].parent1->label==rightfoot||skeleton.muscles[i].parent1->label==leftankle||skeleton.muscles[i].parent1->label==rightankle||skeleton.muscles[i].parent1->label==leftknee||skeleton.muscles[i].parent1->label==rightknee||skeleton.muscles[i].parent2->label==leftknee||skeleton.muscles[i].parent2->label==rightknee)
- glTranslatef((skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].x*(1-morphness)+skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].x*morphness)*proportionlegs.x,
- (skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].y*(1-morphness)+skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].y*morphness)*proportionlegs.y,
- (skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].z*(1-morphness)+skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].z*morphness)*proportionlegs.z);
- if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
- glTranslatef((skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].x*(1-morphness)+skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].x*morphness)*proportionhead.x,
- (skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].y*(1-morphness)+skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].y*morphness)*proportionhead.y,
- (skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].z*(1-morphness)+skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].z*morphness)*proportionhead.z);
- glGetFloatv(GL_MODELVIEW_MATRIX,M);
- //if(!isnormal(M[12])||!isnormal(M[13])||!isnormal(M[14]))test=0;
- //if(!isnormal(scale))test=1;
- skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].x=M[12]*scale;
- skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].y=M[13]*scale;
- skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].z=M[14]*scale;
- //test=2;
- glPopMatrix();
- }
- }
- if(!playerdetail||skeleton.free==3)
- {
- for(j=0;j<skeleton.muscles[i].numverticeslow;j++)
- {
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glPushMatrix();
- if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
- glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionbody.x,
- (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionbody.y,
- (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionbody.z);
- if(skeleton.muscles[i].parent1->label==lefthand||skeleton.muscles[i].parent1->label==righthand||skeleton.muscles[i].parent1->label==leftwrist||skeleton.muscles[i].parent1->label==rightwrist||skeleton.muscles[i].parent1->label==leftelbow||skeleton.muscles[i].parent1->label==rightelbow||skeleton.muscles[i].parent2->label==leftelbow||skeleton.muscles[i].parent2->label==rightelbow)
- glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionarms.x,
- (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionarms.y,
- (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionarms.z);
- if(skeleton.muscles[i].parent1->label==leftfoot||skeleton.muscles[i].parent1->label==rightfoot||skeleton.muscles[i].parent1->label==leftankle||skeleton.muscles[i].parent1->label==rightankle||skeleton.muscles[i].parent1->label==leftknee||skeleton.muscles[i].parent1->label==rightknee||skeleton.muscles[i].parent2->label==leftknee||skeleton.muscles[i].parent2->label==rightknee)
- glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionlegs.x,
- (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionlegs.y,
- (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionlegs.z);
- if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
- glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionhead.x,
- (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionhead.y,
- (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionhead.z);
-
- glGetFloatv(GL_MODELVIEW_MATRIX,M);
- skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].x=M[12]*scale;
- skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].y=M[13]*scale;
- skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].z=M[14]*scale;
- glPopMatrix();
- }
- }
- glPopMatrix();
- }
- if(skeleton.clothes&&skeleton.muscles[i].numverticesclothes>0){
- mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
-
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glPushMatrix();
- glLoadIdentity();
- if(!skeleton.free)glRotatef(tilt2,1,0,0);
- if(!skeleton.free)glRotatef(tilt,0,0,1);
- glTranslatef(mid.x,mid.y,mid.z);
- skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
- glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
-
- skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
- glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
-
- skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
- glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
-
- for(j=0;j<skeleton.muscles[i].numverticesclothes;j++){
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glPushMatrix();
- if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
- glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionbody.x,
- (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionbody.y,
- (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionbody.z);
- if(skeleton.muscles[i].parent1->label==lefthand||skeleton.muscles[i].parent1->label==righthand||skeleton.muscles[i].parent1->label==leftwrist||skeleton.muscles[i].parent1->label==rightwrist||skeleton.muscles[i].parent1->label==leftelbow||skeleton.muscles[i].parent1->label==rightelbow||skeleton.muscles[i].parent2->label==leftelbow||skeleton.muscles[i].parent2->label==rightelbow)
- glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionarms.x,
- (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionarms.y,
- (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionarms.z);
- if(skeleton.muscles[i].parent1->label==leftfoot||skeleton.muscles[i].parent1->label==rightfoot||skeleton.muscles[i].parent1->label==leftankle||skeleton.muscles[i].parent1->label==rightankle||skeleton.muscles[i].parent1->label==leftknee||skeleton.muscles[i].parent1->label==rightknee||skeleton.muscles[i].parent2->label==leftknee||skeleton.muscles[i].parent2->label==rightknee)
- glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionlegs.x,
- (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionlegs.y,
- (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionlegs.z);
- if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
- glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionhead.x,
- (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionhead.y,
- (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionhead.z);
- glGetFloatv(GL_MODELVIEW_MATRIX,M);
- skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x=M[12]*scale;
- skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y=M[13]*scale;
- skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z=M[14]*scale;
- glPopMatrix();
- }
- glPopMatrix();
- }
- updatedelay=1+(float)(Random()%100)/1000;
- }
- if(skeleton.free!=2&&(skeleton.free==1||skeleton.free==3||id==0||(normalsupdatedelay<=0)||targetanimation==getupfromfrontanim||targetanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==getupfrombackanim)){
- normalsupdatedelay=1;
- if(playerdetail||skeleton.free==3)skeleton.drawmodel.CalculateNormals(0);
- if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.CalculateNormals(0);
- if(skeleton.clothes)skeleton.drawmodelclothes.CalculateNormals(0);
- }
- else
- {
- if(playerdetail||skeleton.free==3)skeleton.drawmodel.UpdateVertexArrayNoTexNoNorm();
- if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.UpdateVertexArrayNoTexNoNorm();
- if(skeleton.clothes){
- skeleton.drawmodelclothes.UpdateVertexArrayNoTexNoNorm();
- }
- }
- }
- framemult=.01;
- updatedelaychange=-framemult*4*(45-findDistance(&viewer,&coords)*1);
- if(updatedelaychange>-realmultiplier*30)updatedelaychange=-realmultiplier*30;
- if(updatedelaychange>-framemult*4)updatedelaychange=-framemult*4;
- if(skeleton.free==1)updatedelaychange*=6;
- if(id==0)updatedelaychange*=8;
- updatedelay+=updatedelaychange;
-
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glPushMatrix();
- if(!skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
- if(skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
- if(!skeleton.free)glTranslatef(offset.x*scale,offset.y*scale,offset.z*scale);
- if(!skeleton.free)glRotatef(rotation,0,1,0);
- if(showpoints){
- glPointSize(5);
- glColor4f(.4,1,.4,1);
- glDisable(GL_LIGHTING);
- glDisable(GL_TEXTURE_2D);
- glBegin(GL_POINTS);
- if(playerdetail)
- for(i=0;i<skeleton.drawmodel.vertexNum;i++){
- glVertex3f(skeleton.drawmodel.vertex[i].x,skeleton.drawmodel.vertex[i].y,skeleton.drawmodel.vertex[i].z);
- }
- glEnd();
- glBegin(GL_LINES);
-
- if(playerdetail)
- for(i=0;i<skeleton.drawmodel.TriangleNum;i++){
- glVertex3f(skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[0]].x,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[0]].y,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[0]].z);
- glVertex3f(skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[1]].x,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[1]].y,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[1]].z);
- glVertex3f(skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[1]].x,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[1]].y,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[1]].z);
- glVertex3f(skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[2]].x,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[2]].y,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[2]].z);
- glVertex3f(skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[2]].x,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[2]].y,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[2]].z);
- glVertex3f(skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[0]].x,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[0]].y,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[0]].z);
- }
-
- glEnd();
- }
-
- terrainlight=terrain.getLighting(coords.x,coords.z);
- distance=findDistancefast(&viewer,&coords);
- distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
- if(distance>1)distance=1;
- if(distance>0){
- terrainheight=(coords.y-terrain.getHeight(coords.x,coords.z))/3+1;
- if(terrainheight<1)terrainheight=1;
- if(terrainheight>1.7)terrainheight=1.7;
-
- //burnt=0;
- glColor4f((1-(1-terrainlight.x)/terrainheight)-burnt,(1-(1-terrainlight.y)/terrainheight)-burnt,(1-(1-terrainlight.z)/terrainheight)-burnt,distance);
- glDisable(GL_BLEND);
- glAlphaFunc(GL_GREATER, 0.0001);
- glEnable(GL_TEXTURE_2D);
- if(cellophane){
- glDisable(GL_TEXTURE_2D);
- glColor4f(.7,.35,0,.5);
- glDepthMask(0);
- glEnable(GL_LIGHTING);
- glEnable(GL_BLEND);
- }
- if(tutoriallevel&&id!=0){
- //glDisable(GL_TEXTURE_2D);
- glColor4f(.7,.7,.7,0.6);
- glDepthMask(0);
- glEnable(GL_LIGHTING);
- glEnable(GL_BLEND);
- if(canattack&&cananger)
- if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
- glDisable(GL_TEXTURE_2D);
- glColor4f(1,0,0,0.8);
- }
- glMatrixMode(GL_TEXTURE);
- glPushMatrix();
- glTranslatef(0,-smoketex,0);
- glTranslatef(-smoketex,0,0);
- }
- if(playerdetail){
- if(!showpoints){
- if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
- else skeleton.drawmodel.draw();
- }
- }
- if(!playerdetail){
- if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
- else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
- }
-
- if(!(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed))
- if(tutoriallevel&&id!=0){
- glPopMatrix();
- glMatrixMode(GL_MODELVIEW);
- glEnable(GL_TEXTURE_2D);
- glColor4f(.7,.7,.7,0.6);
- glDepthMask(0);
- glEnable(GL_LIGHTING);
- glEnable(GL_BLEND);
- if(canattack&&cananger)
- if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
- glDisable(GL_TEXTURE_2D);
- glColor4f(1,0,0,0.8);
- }
- glMatrixMode(GL_TEXTURE);
- glPushMatrix();
- glTranslatef(0,-smoketex*.6,0);
- glTranslatef(smoketex*.6,0,0);
- if(playerdetail){
- if(!showpoints){
- if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
- else skeleton.drawmodel.draw();
- }
- }
- if(!playerdetail){
- if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
- else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
- }
- }
-
-
- if(tutoriallevel&&id!=0){
- glPopMatrix();
- glMatrixMode(GL_MODELVIEW);
- glEnable(GL_TEXTURE_2D);
- }
- if(skeleton.clothes){
- glDepthMask(0);
- glEnable(GL_BLEND);
- if(!immediate)skeleton.drawmodelclothes.draw();
- if(immediate)skeleton.drawmodelclothes.drawimmediate();
- glDepthMask(1);
- }
- }
- glPopMatrix();
-
- if(num_weapons>0){
- for(k=0;k<num_weapons;k++){
- i=weaponids[k];
- if(weaponactive==k){
- if(weapons.type[i]!=staff){
- for(j=0;j<skeleton.num_muscles;j++){
- if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
- weaponattachmuscle=j;
- }
- }
- for(j=0;j<skeleton.num_muscles;j++){
- if((skeleton.muscles[j].parent1->label==rightwrist||skeleton.muscles[j].parent2->label==rightwrist)&&(skeleton.muscles[j].parent1->label!=righthand&&skeleton.muscles[j].parent2->label!=righthand)&&skeleton.muscles[j].numvertices>0){
- weaponrotatemuscle=j;
- }
- }
- weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
- if(creature==wolftype)weaponpoint=(skeleton.joints[skeleton.jointlabels[rightwrist]].position*.7+skeleton.joints[skeleton.jointlabels[righthand]].position*.3);
- }
- if(weapons.type[i]==staff){
- for(j=0;j<skeleton.num_muscles;j++){
- if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
- weaponattachmuscle=j;
- }
- }
- for(j=0;j<skeleton.num_muscles;j++){
- if((skeleton.muscles[j].parent1->label==rightelbow||skeleton.muscles[j].parent2->label==rightelbow)&&(skeleton.muscles[j].parent1->label!=rightshoulder&&skeleton.muscles[j].parent2->label!=rightshoulder)&&skeleton.muscles[j].numvertices>0){
- weaponrotatemuscle=j;
- }
- }
- //weaponpoint=skeleton.joints[skeleton.jointlabels[rightwrist]].position;
- weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
- //weaponpoint+=skeleton.specialforward[1]*.1+(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
- XYZ tempnormthing,vec1,vec2;
- vec1=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
- vec2=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightshoulder]].position);
- CrossProduct(&vec1,&vec2,&tempnormthing);
- Normalise(&tempnormthing);
- if(targetanimation!=staffhitanim&¤tanimation!=staffhitanim&&targetanimation!=staffgroundsmashanim&¤tanimation!=staffgroundsmashanim&&targetanimation!=staffspinhitanim&¤tanimation!=staffspinhitanim)weaponpoint+=tempnormthing*.1-skeleton.specialforward[1]*.3+(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
- /*if(targetanimation==staffhitanim||currentanimation==staffhitanim){
- XYZ weaptargnorm;
- weaptargnorm=DoRotation(weapons.tippoint[i]-weapons.position[i],0,-rotation,0);
- //weaptargnorm=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
- Normalise(&weaptargnorm);
- weaponpoint-=weaptargnorm*2;
- }*/
- }
- }
- if(weaponactive!=k&&weaponstuck!=k){
- if(weapons.type[i]==knife)weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position+(skeleton.joints[skeleton.jointlabels[righthip]].position-skeleton.joints[skeleton.jointlabels[lefthip]].position)*.1+(skeleton.joints[skeleton.jointlabels[rightshoulder]].position-skeleton.joints[skeleton.jointlabels[leftshoulder]].position)*.35;
- if(weapons.type[i]==sword)weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position+(skeleton.joints[skeleton.jointlabels[lefthip]].position-skeleton.joints[skeleton.jointlabels[righthip]].position)*.09+(skeleton.joints[skeleton.jointlabels[leftshoulder]].position-skeleton.joints[skeleton.jointlabels[rightshoulder]].position)*.33;
- if(weapons.type[i]==staff)weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position+(skeleton.joints[skeleton.jointlabels[lefthip]].position-skeleton.joints[skeleton.jointlabels[righthip]].position)*.09+(skeleton.joints[skeleton.jointlabels[leftshoulder]].position-skeleton.joints[skeleton.jointlabels[rightshoulder]].position)*.33;
- for(j=0;j<skeleton.num_muscles;j++){
- if((skeleton.muscles[j].parent1->label==abdomen||skeleton.muscles[j].parent2->label==abdomen)&&(skeleton.muscles[j].parent1->label==neck||skeleton.muscles[j].parent2->label==neck)&&skeleton.muscles[j].numvertices>0){
- weaponrotatemuscle=j;
- }
- }
- }
- if(weaponstuck==k){
- if(weaponstuckwhere==0)weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5-skeleton.forward*.8;
- else weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5+skeleton.forward*.8;
- for(j=0;j<skeleton.num_muscles;j++){
- if((skeleton.muscles[j].parent1->label==abdomen||skeleton.muscles[j].parent2->label==abdomen)&&(skeleton.muscles[j].parent1->label==neck||skeleton.muscles[j].parent2->label==neck)&&skeleton.muscles[j].numvertices>0){
- weaponrotatemuscle=j;
- }
- }
- }
- if(!skeleton.free){
- weapons.position[i]=DoRotation(DoRotation(DoRotation(weaponpoint,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords+currentoffset*(1-target)*scale+targetoffset*target*scale;
- weapons.bigrotation[i]=rotation;
- weapons.bigtilt[i]=tilt;
- weapons.bigtilt2[i]=tilt2;
- }
- if(skeleton.free){
- weapons.position[i]=weaponpoint*scale+coords;
- weapons.bigrotation[i]=0;
- weapons.bigtilt[i]=0;
- weapons.bigtilt2[i]=0;
- }
- weapons.rotation1[i]=skeleton.muscles[weaponrotatemuscle].lastrotate1;
- weapons.rotation2[i]=skeleton.muscles[weaponrotatemuscle].lastrotate2;
- weapons.rotation3[i]=skeleton.muscles[weaponrotatemuscle].lastrotate3;
- if(weaponactive==k){
- if(weapons.type[i]==knife){
- weapons.smallrotation[i]=180;
- weapons.smallrotation2[i]=0;
- if(isCrouch()||wasCrouch()){
- weapons.smallrotation2[i]=20;
- }
- if(targetanimation==hurtidleanim){
- weapons.smallrotation2[i]=50;
- }
- if((currentanimation==crouchstabanim&&targetanimation==crouchstabanim)||(currentanimation==backhandspringanim&&targetanimation==backhandspringanim)){
- XYZ temppoint1,temppoint2,tempforward;
- float distance;
-
- temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
- temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
- distance=findDistance(&temppoint1,&temppoint2);
- weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
- weapons.rotation2[i]*=360/6.28;
- temppoint1.y=0;
- temppoint2.y=0;
- weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
- weapons.rotation1[i]*=360/6.28;
- weapons.rotation3[i]=0;
- weapons.smallrotation[i]=-90;
- weapons.smallrotation2[i]=0;
- if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
- }
- if((currentanimation==knifeslashreversalanim&&targetanimation==knifeslashreversalanim)||(currentanimation==knifeslashreversedanim&&targetanimation==knifeslashreversedanim)){
- XYZ temppoint1,temppoint2,tempforward;
- float distance;
-
- temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
- temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
- distance=findDistance(&temppoint1,&temppoint2);
- weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
- weapons.rotation2[i]*=360/6.28;
- temppoint1.y=0;
- temppoint2.y=0;
- weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
- weapons.rotation1[i]*=360/6.28;
- weapons.rotation3[i]=0;
- weapons.smallrotation[i]=90;
- weapons.smallrotation2[i]=0;
- if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
- }
- if(targetanimation==knifethrowanim){
- weapons.smallrotation[i]=90;
- //weapons.smallrotation2[i]=-90;
- weapons.smallrotation2[i]=0;
- weapons.rotation1[i]=0;
- weapons.rotation2[i]=0;
- weapons.rotation3[i]=0;
- }
- if(targetanimation==knifesneakattackanim&&targetframe<5){
- weapons.smallrotation[i]=-90;
- weapons.rotation1[i]=0;
- weapons.rotation2[i]=0;
- weapons.rotation3[i]=0;
- }
- }
- if(weapons.type[i]==sword){
- weapons.smallrotation[i]=0;
- weapons.smallrotation2[i]=0;
- if(targetanimation==knifethrowanim){
- weapons.smallrotation[i]=-90;
- weapons.smallrotation2[i]=0;
- weapons.rotation1[i]=0;
- weapons.rotation2[i]=0;
- weapons.rotation3[i]=0;
- }
- if((targetanimation==swordgroundstabanim&¤tanimation==swordgroundstabanim)||(targetanimation==swordsneakattackanim&¤tanimation==swordsneakattackanim)||(targetanimation==swordslashparryanim&¤tanimation==swordslashparryanim)||(targetanimation==swordslashparriedanim&¤tanimation==swordslashparriedanim)||(targetanimation==swordslashreversalanim&¤tanimation==swordslashreversalanim)||(targetanimation==swordslashreversedanim&¤tanimation==swordslashreversedanim)||(targetanimation==knifeslashreversalanim&¤tanimation==knifeslashreversalanim)||(targetanimation==knifeslashreversedanim&¤tanimation==knifeslashreversedanim)||(targetanimation==swordslashanim&¤tanimation==swordslashanim)||(targetanimation==drawleftanim&¤tanimation==drawleftanim)||(currentanimation==backhandspringanim&&targetanimation==backhandspringanim)){
- XYZ temppoint1,temppoint2,tempforward;
- float distance;
-
- temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
- temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
- distance=findDistance(&temppoint1,&temppoint2);
- weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
- weapons.rotation2[i]*=360/6.28;
- temppoint1.y=0;
- temppoint2.y=0;
- weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
- weapons.rotation1[i]*=360/6.28;
- weapons.rotation3[i]=0;
- weapons.smallrotation[i]=90;
- weapons.smallrotation2[i]=0;
- if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
- }
- }
- if(weapons.type[i]==staff){
- weapons.smallrotation[i]=100;
- weapons.smallrotation2[i]=0;
- if((targetanimation==staffhitanim&¤tanimation==staffhitanim)||(targetanimation==staffhitreversedanim&¤tanimation==staffhitreversedanim)||(targetanimation==staffspinhitreversedanim&¤tanimation==staffspinhitreversedanim)||(targetanimation==staffgroundsmashanim&¤tanimation==staffgroundsmashanim)||(targetanimation==staffspinhitanim&¤tanimation==staffspinhitanim)){
- XYZ temppoint1,temppoint2,tempforward;
- float distance;
-
- temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
- temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
- distance=findDistance(&temppoint1,&temppoint2);
- weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
- weapons.rotation2[i]*=360/6.28;
- temppoint1.y=0;
- temppoint2.y=0;
- weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
- weapons.rotation1[i]*=360/6.28;
- weapons.rotation3[i]=0;
- weapons.smallrotation[i]=90;
- weapons.smallrotation2[i]=0;
- if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
- }
- }
- }
- if(weaponactive!=k&&weaponstuck!=k){
- if(weapons.type[i]==knife){
- weapons.smallrotation[i]=-70;
- weapons.smallrotation2[i]=10;
- }
- if(weapons.type[i]==sword){
- weapons.smallrotation[i]=-100;
- weapons.smallrotation2[i]=-8;
- }
- if(weapons.type[i]==staff){
- weapons.smallrotation[i]=-100;
- weapons.smallrotation2[i]=-8;
- }
- }
- if(weaponstuck==k){
- if(weaponstuckwhere==0)weapons.smallrotation[i]=180;
- else weapons.smallrotation[i]=0;
- weapons.smallrotation2[i]=10;
- }
- }
- }
- }
-
- calcrot=0;
- if(skeleton.free)calcrot=1;
- if(animation[targetanimation].attack||isRun()||targetanimation==staggerbackhardanim||isFlip()||targetanimation==climbanim||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim||targetanimation==backhandspringanim||isFlip()||isWallJump())calcrot=1;
- if(currentanimation!=targetanimation)calcrot=1;
- //if(id==0)calcrot=1;
- if(skeleton.free==2)calcrot=0;
-
- return 0;
+/* EFFECT
+ * MONSTER
+ * TODO: ???
+ */
+void Person::DoAnimations()
+{
+ if (!skeleton.free) {
+ int i = 0;
+ static float oldtarget;
+
+ if (isIdle() && animCurrent != getIdle())
+ normalsupdatedelay = 0;
+
+ if (animTarget == tempanim || animCurrent == tempanim) {
+ animation[tempanim] = tempanimation;
+ }
+ if (animTarget == jumpupanim || animTarget == jumpdownanim || isFlip()) {
+ float gLoc[3];
+ float vel[3];
+ gLoc[0] = coords.x;
+ gLoc[1] = coords.y;
+ gLoc[2] = coords.z;
+ vel[0] = velocity.x;
+ vel[1] = velocity.y;
+ vel[2] = velocity.z;
+
+ if (id == 0) {
+ OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
+ OPENAL_SetVolume(channels[whooshsound], 64 * findLength(&velocity) / 5);
+ }
+ if (((velocity.y < -15) || (crouchkeydown && velocity.y < -8)) && abs(velocity.y) * 4 > fast_sqrt(velocity.x * velocity.x * velocity.z * velocity.z))
+ landhard = 1;
+ if (!crouchkeydown && velocity.y >= -15)
+ landhard = 0;
+ }
+ if ((animCurrent == jumpupanim || animTarget == jumpdownanim)/*&&velocity.y<40*/ && !isFlip() && (!isLanding() && !isLandhard()) && ((crouchkeydown && !crouchtogglekeydown))) {
+ XYZ targfacing;
+ targfacing = 0;
+ targfacing.z = 1;
+
+ targfacing = DoRotation(targfacing, 0, targetyaw, 0);
+
+ if (normaldotproduct(targfacing, velocity) >= -.3)
+ animTarget = flipanim;
+ else
+ animTarget = backflipanim;
+ crouchtogglekeydown = 1;
+ frameTarget = 0;
+ target = 0;
+
+ if (id == 0)
+ numflipped++;
+ }
+
+ if (animation[animTarget].attack != reversed)
+ feint = 0;
+ if (!crouchkeydown || (isLanding() || isLandhard()) || (wasLanding() || wasLandhard())) {
+ crouchtogglekeydown = 0;
+ if (aitype == playercontrolled)
+ feint = 0;
+ } else {
+ if (!crouchtogglekeydown && animation[animTarget].attack == reversed && aitype == playercontrolled && (escapednum < 2 || reversaltrain))
+ feint = 1;
+ if (!isFlip())
+ crouchtogglekeydown = 1;
+ }
+
+
+ if (animation[animTarget].attack || animCurrent == getupfrombackanim || animCurrent == getupfromfrontanim) {
+ if (detail)
+ normalsupdatedelay = 0;
+ }
+
+ if (target >= 1) {
+ if (animTarget == rollanim && frameTarget == 3 && onfire) {
+ onfire = 0;
+ emit_sound_at(fireendsound, coords);
+ pause_sound(stream_firesound);
+ deathbleeding = 0;
+ }
+
+ if (animTarget == rabbittacklinganim && frameTarget == 1) {
+ //if(victim->aitype==attacktypecutoff&&Random()%2==0&&victim->stunned<=0&&animation[victim->animTarget].attack==neutral&&victim->id!=0)Reverse();
+ if (victim->aitype == attacktypecutoff && victim->stunned <= 0 && victim->surprised <= 0 && victim->id != 0)
+ Reverse();
+ if (animTarget == rabbittacklinganim && frameTarget == 1 && !victim->isCrouch() && victim->animTarget != backhandspringanim) {
+ if (normaldotproduct(victim->facing, facing) > 0)
+ victim->animTarget = rabbittackledbackanim;
+ else
+ victim->animTarget = rabbittackledfrontanim;
+ victim->frameTarget = 2;
+ victim->target = 0;
+ victim->yaw = yaw;
+ victim->targetyaw = yaw;
+ if (victim->aitype == gethelptype)
+ victim->DoDamage(victim->damagetolerance - victim->damage);
+ //victim->DoDamage(30);
+ if (creature == wolftype) {
+ DoBloodBig(0, 255);
+ emit_sound_at(clawslicesound, victim->coords);
+ victim->spurt = 1;
+ victim->DoBloodBig(1 / victim->armorhead, 210);
+ }
+ award_bonus(id, TackleBonus,
+ victim->aitype == gethelptype ? 50 : 0);
+ }
+ }
+
+ if (!drawtogglekeydown && drawkeydown && (weaponactive == -1 || num_weapons == 1) && (animation[animTarget].label[frameTarget] || (animTarget != animCurrent && animCurrent == rollanim)) && num_weapons > 0 && creature != wolftype) {
+ if (weapons[weaponids[0]].getType() == knife) {
+ if (weaponactive == -1)
+ weaponactive = 0;
+ else if (weaponactive == 0)
+ weaponactive = -1;
+
+ if (weaponactive == -1) {
+ emit_sound_at(knifesheathesound, coords);
+ }
+ if (weaponactive != -1) {
+ emit_sound_at(knifedrawsound, coords, 128);
+ }
+ }
+ drawtogglekeydown = 1;
+ }
+ //Footstep sounds
+ if (tutoriallevel != 1 || id == 0)
+ if ((animation[animTarget].label[frameTarget] && (animation[animTarget].label[frameTarget] < 5 || animation[animTarget].label[frameTarget] == 8))/*||(animTarget==rollanim&&frameTarget==animation[rollanim].numframes-1)*/) {
+ int whichsound;
+ if (onterrain) {
+ if (terrain.getOpacity(coords.x, coords.z) < .2) {
+ if (animation[animTarget].label[frameTarget] == 1)
+ whichsound = footstepsound;
+ else
+ whichsound = footstepsound2;
+ if (animation[animTarget].label[frameTarget] == 1)
+ FootLand(0, 1);
+ if (animation[animTarget].label[frameTarget] == 2)
+ FootLand(1, 1);
+ if (animation[animTarget].label[frameTarget] == 3 && isRun()) {
+ FootLand(1, 1);
+ FootLand(0, 1);
+ }
+
+ }
+ if (terrain.getOpacity(coords.x, coords.z) >= .2) {
+ if (animation[animTarget].label[frameTarget] == 1)
+ whichsound = footstepsound3;
+ else
+ whichsound = footstepsound4;
+ }
+ }
+ if (!onterrain) {
+ if (animation[animTarget].label[frameTarget] == 1)
+ whichsound = footstepsound3;
+ else
+ whichsound = footstepsound4;
+ }
+ if (animation[animTarget].label[frameTarget] == 4 && (weaponactive == -1 || (animTarget != knifeslashstartanim && animTarget != knifethrowanim && animTarget != crouchstabanim && animTarget != swordgroundstabanim && animTarget != knifefollowanim))) {
+ if (animation[animTarget].attack != neutral) {
+ i = abs(Random() % 3);
+ if (i == 0)
+ whichsound = lowwhooshsound;
+ if (i == 1)
+ whichsound = midwhooshsound;
+ if (i == 2)
+ whichsound = highwhooshsound;
+ }
+ if (animation[animTarget].attack == neutral)
+ whichsound = movewhooshsound;
+ } else if (animation[animTarget].label[frameTarget] == 4)
+ whichsound = knifeswishsound;
+ if (animation[animTarget].label[frameTarget] == 8 && tutoriallevel != 1)
+ whichsound = landsound2;
+
+ emit_sound_at(whichsound, coords, 256.);
+
+ if (id == 0)
+ if (whichsound == footstepsound || whichsound == footstepsound2 || whichsound == footstepsound3 || whichsound == footstepsound4) {
+ envsound[numenvsounds] = coords;
+ if (animTarget == wolfrunninganim || animTarget == rabbitrunninganim)
+ envsoundvol[numenvsounds] = 15;
+ else
+ envsoundvol[numenvsounds] = 6;
+ envsoundlife[numenvsounds] = .4;
+ numenvsounds++;
+ }
+
+ if (animation[animTarget].label[frameTarget] == 3) {
+ whichsound--;
+ emit_sound_at(whichsound, coords, 128.);
+ }
+ }
+
+ //Combat sounds
+ if (tutoriallevel != 1 || id == 0)
+ if (speechdelay <= 0)
+ if (animTarget != crouchstabanim && animTarget != swordgroundstabanim && animTarget != staffgroundsmashanim)
+ if ((animation[animTarget].label[frameTarget] && (animation[animTarget].label[frameTarget] < 5 || animation[animTarget].label[frameTarget] == 8))/*||(animTarget==rollanim&&frameTarget==animation[rollanim].numframes-1)*/) {
+ int whichsound = -1;
+ if (animation[animTarget].label[frameTarget] == 4 && aitype != playercontrolled) {
+ if (animation[animTarget].attack != neutral) {
+ i = abs(Random() % 4);
+ if (creature == rabbittype) {
+ if (i == 0) whichsound = rabbitattacksound;
+ if (i == 1) whichsound = rabbitattack2sound;
+ if (i == 2) whichsound = rabbitattack3sound;
+ if (i == 3) whichsound = rabbitattack4sound;
+ }
+ if (creature == wolftype) {
+ if (i == 0) whichsound = barksound;
+ if (i == 1) whichsound = bark2sound;
+ if (i == 2) whichsound = bark3sound;
+ if (i == 3) whichsound = barkgrowlsound;
+ }
+ speechdelay = .3;
+ }
+ //if(animation[animTarget].attack==neutral)whichsound=movewhooshsound;
+ }
+ //else if(animation[animTarget].label[frameTarget]==4)whichsound=knifeswishsound;
+ //if(animation[animTarget].label[frameTarget]==8)whichsound=landsound2;
+
+ if (whichsound != -1) {
+ emit_sound_at(whichsound, coords);
+ }
+ }
+
+
+
+ if ((!wasLanding() && !wasLandhard()) && animCurrent != getIdle() && (isLanding() || isLandhard())) {
+ FootLand(0, 1);
+ FootLand(1, 1);
+ }
+
+ transspeed = 0;
+ currentoffset = targetoffset;
+ frameTarget = frameCurrent;
+ animCurrent = animTarget;
+ frameTarget++;
+
+ if (animTarget == removeknifeanim && animation[animTarget].label[frameCurrent] == 5) {
+ for (i = 0; i < weapons.size(); i++) {
+ if (weapons[i].owner == -1)
+ if (distsqflat(&coords, &weapons[i].position) < 4 && weaponactive == -1) {
+ if (distsq(&coords, &weapons[i].position) >= 1) {
+ if (weapons[i].getType() != staff) {
+ emit_sound_at(knifedrawsound, coords, 128.);
+ }
+
+ weaponactive = 0;
+ weapons[i].owner = id;
+ if (num_weapons > 0) {
+ weaponids[num_weapons] = weaponids[0];
+ }
+ num_weapons++;
+ weaponids[0] = i;
+ }
+ }
+ }
+ }
+
+ if (animTarget == crouchremoveknifeanim && animation[animTarget].label[frameCurrent] == 5) {
+ for (i = 0; i < weapons.size(); i++) {
+ bool willwork = true;
+ if (weapons[i].owner != -1)
+ if (player[weapons[i].owner].weaponstuck != -1)
+ if (player[weapons[i].owner].weaponids[player[weapons[i].owner].weaponstuck] == i)
+ if (player[weapons[i].owner].num_weapons > 1)
+ willwork = 0;
+ if ((weapons[i].owner == -1) || (hasvictim && weapons[i].owner == victim->id && victim->skeleton.free))
+ if (willwork && distsqflat(&coords, &weapons[i].position) < 3 && weaponactive == -1) {
+ if (distsq(&coords, &weapons[i].position) < 1 || hasvictim) {
+ bool fleshstuck = false;
+ if (weapons[i].owner != -1)
+ if (victim->weaponstuck != -1) {
+ if (victim->weaponids[victim->weaponstuck] == i) {
+ fleshstuck = true;
+ }
+ }
+ if (fleshstuck) {
+ emit_sound_at(fleshstabremovesound, coords, 128.);
+ } else {
+ if (weapons[i].getType() != staff) {
+ emit_sound_at(knifedrawsound, coords, 128.);
+ }
+ }
+ weaponactive = 0;
+ if (weapons[i].owner != -1) {
+
+ victim = &player[weapons[i].owner];
+ if (victim->num_weapons == 1)
+ victim->num_weapons = 0;
+ else
+ victim->num_weapons = 1;
+
+ //victim->weaponactive=-1;
+ victim->skeleton.longdead = 0;
+ victim->skeleton.free = 1;
+ victim->skeleton.broken = 0;
+
+ for (int j = 0; j < victim->skeleton.num_joints; j++) {
+ victim->skeleton.joints[j].velchange = 0;
+ victim->skeleton.joints[j].locked = 0;
+ }
+
+ XYZ relative;
+ relative = 0;
+ relative.y = 10;
+ Normalise(&relative);
+ XYZ footvel, footpoint;
+ footvel = 0;
+ footpoint = weapons[i].position;
+ if (victim->weaponstuck != -1) {
+ if (victim->weaponids[victim->weaponstuck] == i) {
+ if (bloodtoggle)
+ Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 0, 0, .8, .3);
+ weapons[i].bloody = 2;
+ weapons[i].blooddrip = 5;
+ victim->weaponstuck = -1;
+ }
+ }
+ if (victim->num_weapons > 0) {
+ if (victim->weaponstuck != 0 && victim->weaponstuck != -1)
+ victim->weaponstuck = 0;
+ if (victim->weaponids[0] == i)
+ victim->weaponids[0] = victim->weaponids[victim->num_weapons];
+ }
+
+ victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity += relative * 6;
+ victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity += relative * 6;
+ victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity += relative * 6;
+ victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity += relative * 6;
+ }
+ weapons[i].owner = id;
+ if (num_weapons > 0) {
+ weaponids[num_weapons] = weaponids[0];
+ }
+ num_weapons++;
+ weaponids[0] = i;
+ }
+ }
+ }
+ }
+
+ if (animCurrent == drawleftanim && animation[animTarget].label[frameCurrent] == 5) {
+ if (weaponactive == -1)
+ weaponactive = 0;
+ else if (weaponactive == 0) {
+ weaponactive = -1;
+ if (num_weapons == 2) {
+ int buffer;
+ buffer = weaponids[0];
+ weaponids[0] = weaponids[1];
+ weaponids[1] = buffer;
+ }
+ }
+ if (weaponactive == -1) {
+ emit_sound_at(knifesheathesound, coords, 128.);
+ }
+ if (weaponactive != -1) {
+ emit_sound_at(knifedrawsound, coords, 128.);
+ }
+ }
+
+
+ if ((animCurrent == walljumprightkickanim && animTarget == walljumprightkickanim) || (animCurrent == walljumpleftkickanim && animTarget == walljumpleftkickanim)) {
+ XYZ rotatetarget = DoRotation(skeleton.forward, 0, yaw, 0);
+ Normalise(&rotatetarget);
+ targetyaw = -asin(0 - rotatetarget.x);
+ targetyaw *= 360 / 6.28;
+ if (rotatetarget.z < 0)
+ targetyaw = 180 - targetyaw;
+
+ if (animTarget == walljumprightkickanim)
+ targetyaw += 40;
+ if (animTarget == walljumpleftkickanim)
+ targetyaw -= 40;
+ }
+
+ bool dojumpattack;
+ dojumpattack = 0;
+ if ((animTarget == rabbitrunninganim || animTarget == wolfrunninganim) && frameTarget == 3 && (jumpkeydown || attackkeydown || id != 0))
+ dojumpattack = 1;
+ if (hasvictim)
+ if (distsq(&victim->coords, &/*player[i].*/coords) < 5 && victim->aitype == gethelptype && (attackkeydown) && !victim->skeleton.free && victim->isRun() && victim->runninghowlong >= 1)
+ dojumpattack = 1;
+ if (!hostile)
+ dojumpattack = 0;
+ if (dojumpattack) {
+ if ((animTarget == rabbitrunninganim || animTarget == wolfrunninganim) && id == 0) {
+ animTarget = rabbittackleanim;
+ frameTarget = 0;
+ emit_sound_at(jumpsound, coords);
+ }
+
+ float closestdist;
+ closestdist = 0;
+ int closestid;
+ closestid = -1;
+ XYZ targetloc;
+ targetloc = velocity;
+ Normalise(&targetloc);
+ targetloc += coords;
+ for (i = 0; i < numplayers; i++) {
+ if (i != id)
+ if (distsq(&targetloc, &player[i].coords) < closestdist || closestdist == 0) {
+ closestdist = distsq(&targetloc, &player[i].coords);
+ closestid = i;
+ }
+ }
+ if (closestid != -1)
+ if (closestdist < 5 && !player[closestid].dead && animation[player[closestid].animTarget].height != lowheight && player[closestid].animTarget != backhandspringanim) {
+ hasvictim = 1;
+ victim = &player[closestid];
+ coords = victim->coords;
+ animCurrent = rabbittacklinganim;
+ animTarget = rabbittacklinganim;
+ frameCurrent = 0;
+ frameTarget = 1;
+ XYZ rotatetarget;
+ if (coords.z != victim->coords.z || coords.x != victim->coords.x) {
+ rotatetarget = coords - victim->coords;
+ Normalise(&rotatetarget);
+ targetyaw = -asin(0 - rotatetarget.x);
+ targetyaw *= 360 / 6.28;
+ if (rotatetarget.z < 0)
+ targetyaw = 180 - targetyaw;
+ }
+ if (animTarget != rabbitrunninganim) {
+ emit_sound_at(jumpsound, coords, 128.);
+ }
+ }
+ }
+
+ //Move impacts
+ float damagemult = 1 * power;
+ if (creature == wolftype)
+ damagemult = 2.5 * power;
+ if (hasvictim) {
+ damagemult /= victim->damagetolerance / 200;
+ }
+ //if(onfire)damagemult=3;
+ if ((animation[animTarget].attack == normalattack || animTarget == walljumprightkickanim || animTarget == walljumpleftkickanim) && (!feint) && (victim->skeleton.free != 2 || animTarget == killanim || animTarget == dropkickanim || animTarget == crouchstabanim || animTarget == swordgroundstabanim || animTarget == staffgroundsmashanim)) {
+ if (animTarget == spinkickanim && animation[animTarget].label[frameCurrent] == 5) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && 3 && animation[victim->animTarget].height != lowheight) {
+ escapednum = 0;
+ if (id == 0)
+ camerashake += .4;
+ if (Random() % 2 || creature == wolftype) {
+ victim->spurt = 1;
+ DoBlood(.2, 250);
+ if (creature == wolftype)
+ DoBloodBig(0, 250);
+ }
+ if (tutoriallevel != 1) {
+ emit_sound_at(heavyimpactsound, victim->coords, 128.);
+ }
+ if (creature == wolftype) {
+ emit_sound_at(clawslicesound, victim->coords, 128.);
+ victim->spurt = 1;
+ victim->DoBloodBig(2 / victim->armorhead, 175);
+ }
+ victim->RagDoll(0);
+ XYZ relative;
+ relative = victim->coords - coords;
+ relative.y = 0;
+ Normalise(&relative);
+ relative = DoRotation(relative, 0, -90, 0);
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 40;
+ }
+ victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity += relative * damagemult * 200;
+ //FootLand(1,2);
+ victim->Puff(head);
+ victim->DoDamage(damagemult * 100 / victim->protectionhead);
+
+ SolidHitBonus(id);
+ }
+ }
+
+ if (animTarget == wolfslapanim && animation[animTarget].label[frameCurrent] == 5) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && 3 && animation[victim->animTarget].height != lowheight) {
+ escapednum = 0;
+ if (id == 0)
+ camerashake += .4;
+ if (Random() % 2 || creature == wolftype) {
+ victim->spurt = 1;
+ if (creature == wolftype)
+ DoBloodBig(0, 235);
+ }
+ emit_sound_at(whooshhitsound, victim->coords);
+ if (creature == wolftype) {
+ emit_sound_at(clawslicesound, victim->coords, 128.);
+ victim->spurt = 1;
+ victim->DoBloodBig(2, 175);
+ }
+ victim->RagDoll(0);
+ XYZ relative;
+ relative = victim->coords - coords;
+ relative.y = 0;
+ Normalise(&relative);
+ relative.y -= 1;
+ Normalise(&relative);
+ relative = DoRotation(relative, 0, 90, 0);
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 20;
+ }
+ victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity += relative * damagemult * 100;
+ //FootLand(1,2);
+ victim->Puff(head);
+ victim->DoDamage(damagemult * 50 / victim->protectionhead);
+ }
+ }
+
+ if (animTarget == walljumprightkickanim && animation[animTarget].label[frameCurrent] == 5) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && animation[victim->animTarget].height != lowheight) {
+ escapednum = 0;
+ if (id == 0)
+ camerashake += .4;
+ victim->spurt = 1;
+ DoBlood(.2, 250);
+ if (tutoriallevel != 1) {
+ emit_sound_at(heavyimpactsound, victim->coords, 160.);
+ }
+ if (creature == wolftype) {
+ emit_sound_at(clawslicesound, victim->coords, 128.);
+ victim->spurt = 1;
+ victim->DoBloodBig(2 / victim->armorhead, 175);
+ }
+ victim->RagDoll(0);
+ XYZ relative;
+ relative = facing;
+ relative.y = 0;
+ Normalise(&relative);
+ relative = DoRotation(relative, 0, -90, 0);
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 40;
+ }
+ victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity += relative * damagemult * 200;
+ //FootLand(1,2);
+ victim->Puff(head);
+ victim->DoDamage(damagemult * 150 / victim->protectionhead);
+
+ if (victim->damage > victim->damagetolerance)
+ award_bonus(id, style);
+ else
+ SolidHitBonus(id);
+ }
+ }
+
+ if (animTarget == walljumpleftkickanim && animation[animTarget].label[frameCurrent] == 5) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && animation[victim->animTarget].height != lowheight) {
+ escapednum = 0;
+ if (id == 0)
+ camerashake += .4;
+ victim->spurt = 1;
+ DoBlood(.2, 250);
+ if (tutoriallevel != 1) {
+ emit_sound_at(heavyimpactsound, victim->coords, 160.);
+ }
+ if (creature == wolftype) {
+ emit_sound_at(clawslicesound, victim->coords, 128.);
+ victim->spurt = 1;
+ victim->DoBloodBig(2 / victim->armorhead, 175);
+ }
+ victim->RagDoll(0);
+ XYZ relative;
+ relative = facing;
+ relative.y = 0;
+ Normalise(&relative);
+ relative = DoRotation(relative, 0, 90, 0);
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 40;
+ }
+ victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity += relative * damagemult * 200;
+ //FootLand(1,2);
+ victim->Puff(head);
+ victim->DoDamage(damagemult * 150 / victim->protectionhead);
+
+ if (victim->damage > victim->damagetolerance)
+ award_bonus(id, style);
+ else
+ SolidHitBonus(id);
+ }
+ }
+
+ if (animTarget == blockhighleftstrikeanim && animation[animTarget].label[frameCurrent] == 5) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && animation[victim->animTarget].height != lowheight) {
+ escapednum = 0;
+ if (id == 0)
+ camerashake += .4;
+ if (Random() % 2) {
+ victim->spurt = 1;
+ DoBlood(.2, 235);
+ }
+ emit_sound_at(whooshhitsound, victim->coords);
+ victim->RagDoll(0);
+ XYZ relative;
+ relative = victim->coords - coords;
+ relative.y = 0;
+ Normalise(&relative);
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 30;
+ }
+ victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity += relative * damagemult * 100;
+ //FootLand(1,2);
+ victim->Puff(head);
+ victim->DoDamage(damagemult * 50 / victim->protectionhead);
+ }
+ }
+
+ if (animTarget == killanim && animation[animTarget].label[frameCurrent] == 8) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && victim->dead) {
+ escapednum = 0;
+ if (id == 0)
+ camerashake += .2;
+ emit_sound_at(whooshhitsound, victim->coords, 128.);
+
+ victim->skeleton.longdead = 0;
+ victim->skeleton.free = 1;
+ victim->skeleton.broken = 0;
+ victim->skeleton.spinny = 1;
+
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velchange = 0;
+ victim->skeleton.joints[i].delay = 0;
+ victim->skeleton.joints[i].locked = 0;
+ //victim->skeleton.joints[i].velocity=0;
+ }
+
+ XYZ relative;
+ relative = 0;
+ relative.y = 1;
+ Normalise(&relative);
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velocity.y = relative.y * 10;
+ victim->skeleton.joints[i].position.y += relative.y * .3;
+ victim->skeleton.joints[i].oldposition.y += relative.y * .3;
+ victim->skeleton.joints[i].realoldposition.y += relative.y * .3;
+ }
+ victim->Puff(abdomen);
+ victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity.y = relative.y * 400;
+ }
+ }
+
+ if (animTarget == killanim && animation[animTarget].label[frameCurrent] == 5) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 9 && victim->dead) {
+ escapednum = 0;
+ if (id == 0)
+ camerashake += .4;
+ if (tutoriallevel != 1) {
+ emit_sound_at(heavyimpactsound, coords, 128.);
+ }
+ XYZ relative;
+ relative = victim->coords - coords;
+ relative.y = 0;
+ Normalise(&relative);
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 90;
+ }
+ victim->Puff(abdomen);
+ if (victim->dead != 2 && victim->permanentdamage > victim->damagetolerance - 250 && autoslomo) {
+ slomo = 1;
+ slomodelay = .2;
+ }
+ victim->DoDamage(damagemult * 500 / victim->protectionhigh);
+ victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity += relative * damagemult * 300;
+ }
+ }
+
+ if (animTarget == dropkickanim && animation[animTarget].label[frameCurrent] == 7) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 9 && victim->skeleton.free) {
+ escapednum = 0;
+ if (id == 0)
+ camerashake += .4;
+ if (tutoriallevel != 1) {
+ emit_sound_at(thudsound, coords);
+ }
+
+ victim->skeleton.longdead = 0;
+ victim->skeleton.free = 1;
+ victim->skeleton.broken = 0;
+ victim->skeleton.spinny = 1;
+
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velchange = 0;
+ //victim->skeleton.joints[i].delay=0;
+ victim->skeleton.joints[i].locked = 0;
+ }
+ XYZ relative;
+ relative = victim->coords - coords;
+ Normalise(&relative);
+ relative.y += .3;
+ Normalise(&relative);
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 20;
+ }
+ if (!victim->dead)
+ SolidHitBonus(id);
+
+ victim->Puff(abdomen);
+ victim->DoDamage(damagemult * 20 / victim->protectionhigh);
+ victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity += relative * damagemult * 200;
+ staggerdelay = .5;
+ if (!victim->dead)
+ staggerdelay = 1.2;
+
+
+ }
+ }
+
+ if ((animTarget == crouchstabanim || animTarget == swordgroundstabanim) && animation[animTarget].label[frameCurrent] == 5) {
+ //if(id==0)camerashake+=.4;
+
+ if (hasvictim)
+ if (!victim->skeleton.free)
+ hasvictim = 0;
+
+ if (!hasvictim) {
+ terrain.MakeDecal(blooddecalfast, (weapons[weaponids[weaponactive]].tippoint * .8 + weapons[weaponids[weaponactive]].position * .2), .08, .6, Random() % 360);
+ emit_sound_at(knifesheathesound, coords, 128.);
+ }
+
+ if (victim && hasvictim) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3) {
+
+ XYZ where, startpoint, endpoint, movepoint, colpoint;
+ float rotationpoint;
+ int whichtri;
+ if (weapons[weaponids[weaponactive]].getType() == knife) {
+ where = (weapons[weaponids[weaponactive]].tippoint * .6 + weapons[weaponids[weaponactive]].position * .4);
+ where -= victim->coords;
+ if (!victim->skeleton.free)
+ where = DoRotation(where, 0, -victim->yaw, 0);
+ //where=scale;
+ startpoint = where;
+ startpoint.y += 100;
+ endpoint = where;
+ endpoint.y -= 100;
+ }
+ if (weapons[weaponids[weaponactive]].getType() == sword) {
+ where = weapons[weaponids[weaponactive]].position;
+ where -= victim->coords;
+ if (!victim->skeleton.free)
+ where = DoRotation(where, 0, -victim->yaw, 0);
+ startpoint = where;
+ where = weapons[weaponids[weaponactive]].tippoint;
+ where -= victim->coords;
+ if (!victim->skeleton.free)
+ where = DoRotation(where, 0, -victim->yaw, 0);
+ endpoint = where;
+ }
+ if (weapons[weaponids[weaponactive]].getType() == staff) {
+ where = weapons[weaponids[weaponactive]].position;
+ where -= victim->coords;
+ if (!victim->skeleton.free)
+ where = DoRotation(where, 0, -victim->yaw, 0);
+ startpoint = where;
+ where = weapons[weaponids[weaponactive]].tippoint;
+ where -= victim->coords;
+ if (!victim->skeleton.free)
+ where = DoRotation(where, 0, -victim->yaw, 0);
+ endpoint = where;
+ }
+ movepoint = 0;
+ rotationpoint = 0;
+ whichtri = victim->skeleton.drawmodel.LineCheck(&startpoint, &endpoint, &colpoint, &movepoint, &rotationpoint);
+
+ if (whichtri != -1) {
+ if (victim->dead != 2) {
+ victim->DoDamage(abs((victim->damagetolerance - victim->permanentdamage) * 2));
+ if (!victim->dead)
+ award_bonus(id, FinishedBonus);
+ }
+ if (bloodtoggle)
+ weapons[weaponids[weaponactive]].bloody = 2;
+
+ victim->skeleton.longdead = 0;
+ victim->skeleton.free = 1;
+ victim->skeleton.broken = 0;
+
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velchange = 0;
+ victim->skeleton.joints[i].locked = 0;
+ //victim->skeleton.joints[i].velocity=0;
+ }
+ emit_sound_at(fleshstabsound, coords, 128);
+
+ }
+ if (whichtri != -1 || weapons[weaponids[weaponactive]].bloody) {
+ weapons[weaponids[weaponactive]].blooddrip += 5;
+ weapons[weaponids[weaponactive]].blooddripdelay = 0;
+ }
+ if (whichtri == -1) {
+ hasvictim = 0;
+ emit_sound_at(knifesheathesound, coords, 128.);
+ }
+ }
+ }
+ }
+
+ if ((animTarget == crouchstabanim || animTarget == swordgroundstabanim) && animation[animTarget].label[frameCurrent] == 6) {
+ if (!hasvictim) {
+ emit_sound_at(knifedrawsound, coords, 128);
+ }
+
+ if (victim && hasvictim) {
+ XYZ footvel, footpoint;
+
+ emit_sound_at(fleshstabremovesound, coords, 128.);
+
+ footvel = 0;
+ footpoint = (weapons[weaponids[weaponactive]].tippoint * .8 + weapons[weaponids[weaponactive]].position * .2);
+
+ if (weapons[weaponids[weaponactive]].getType() == sword) {
+ XYZ where, startpoint, endpoint, movepoint;
+ float rotationpoint;
+ int whichtri;
+
+ where = weapons[weaponids[weaponactive]].position;
+ where -= victim->coords;
+ if (!victim->skeleton.free)
+ where = DoRotation(where, 0, -victim->yaw, 0);
+ startpoint = where;
+ where = weapons[weaponids[weaponactive]].tippoint;
+ where -= victim->coords;
+ if (!victim->skeleton.free)
+ where = DoRotation(where, 0, -victim->yaw, 0);
+ endpoint = where;
+
+ movepoint = 0;
+ rotationpoint = 0;
+ whichtri = victim->skeleton.drawmodel.LineCheck(&startpoint, &endpoint, &footpoint, &movepoint, &rotationpoint);
+ footpoint += victim->coords;
+
+ if (whichtri == -1) {
+ footpoint = (weapons[weaponids[weaponactive]].tippoint * .8 + weapons[weaponids[weaponactive]].position * .2);
+ }
+ }
+ if (weapons[weaponids[weaponactive]].getType() == staff) {
+ XYZ where, startpoint, endpoint, movepoint;
+ float rotationpoint;
+ int whichtri;
+
+ where = weapons[weaponids[weaponactive]].position;
+ where -= victim->coords;
+ if (!victim->skeleton.free)
+ where = DoRotation(where, 0, -victim->yaw, 0);
+ startpoint = where;
+ where = weapons[weaponids[weaponactive]].tippoint;
+ where -= victim->coords;
+ if (!victim->skeleton.free)
+ where = DoRotation(where, 0, -victim->yaw, 0);
+ endpoint = where;
+
+ movepoint = 0;
+ rotationpoint = 0;
+ whichtri = victim->skeleton.drawmodel.LineCheck(&startpoint, &endpoint, &footpoint, &movepoint, &rotationpoint);
+ footpoint += victim->coords;
+
+ if (whichtri == -1) {
+ footpoint = (weapons[weaponids[weaponactive]].tippoint * .8 + weapons[weaponids[weaponactive]].position * .2);
+ }
+ }
+ hasvictim = victim->DoBloodBigWhere(2, 220, footpoint);
+ if (hasvictim) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3) {
+ victim->skeleton.longdead = 0;
+ victim->skeleton.free = 1;
+ victim->skeleton.broken = 0;
+
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velchange = 0;
+ victim->skeleton.joints[i].locked = 0;
+ //victim->skeleton.joints[i].velocity=0;
+ }
+
+ XYZ relative;
+ relative = 0;
+ relative.y = 10;
+ Normalise(&relative);
+ //victim->Puff(abdomen);
+ if (bloodtoggle)
+ Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 0, 0, .8, .3);
+
+ if (victim->bloodloss < victim->damagetolerance) {
+ victim->bloodloss += 1000;
+ victim->bled = 0;
+ }
+
+ victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity += relative * damagemult * 20;
+ }
+ }
+ }
+ if (!hasvictim && onterrain) {
+ weapons[weaponids[weaponactive]].bloody = 0;
+ weapons[weaponids[weaponactive]].blooddrip = 0;
+ }
+ }
+
+ if (animTarget == upunchanim && animation[animTarget].label[frameCurrent] == 5) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3) {
+ escapednum = 0;
+ if (id == 0)
+ camerashake += .4;
+ if (Random() % 2) {
+ victim->spurt = 1;
+ DoBlood(.2, 235);
+ }
+ if (tutoriallevel != 1) {
+ emit_sound_at(heavyimpactsound, victim->coords, 128);
+ }
+
+ victim->RagDoll(0);
+ XYZ relative;
+ relative = victim->coords - coords;
+ relative.y = 0;
+ Normalise(&relative);
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velocity = relative * 30;
+ }
+ victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity += relative * damagemult * 150;
+
+ victim->frameTarget = 0;
+ victim->animTarget = staggerbackhardanim;
+ victim->targetyaw = targetyaw + 180;
+ victim->target = 0;
+ victim->stunned = 1;
+
+ victim->Puff(head);
+ victim->Puff(abdomen);
+ victim->DoDamage(damagemult * 60 / victim->protectionhigh);
+
+ SolidHitBonus(id);
+ }
+ }
+
+
+ if (animTarget == winduppunchanim && animation[animTarget].label[frameCurrent] == 5) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 2) {
+ escapednum = 0;
+ if (id == 0)
+ camerashake += .4;
+ if (victim->damage <= victim->damagetolerance - 60 && normaldotproduct(victim->facing, victim->coords - coords) < (scale * 5) * (scale * 5) * 0 && animation[victim->animTarget].height != lowheight) {
+ if (tutoriallevel != 1) {
+ emit_sound_at(thudsound, victim->coords);
+ }
+ } else if (victim->damage <= victim->damagetolerance - 60 && normaldotproduct(victim->facing, victim->coords - coords) < (scale * 5) * (scale * 5) * 0 && animation[victim->animTarget].height == lowheight) {
+ if (tutoriallevel != 1) {
+ emit_sound_at(whooshhitsound, victim->coords);
+ }
+ } else {
+ if (tutoriallevel != 1) {
+ emit_sound_at(heavyimpactsound, victim->coords);
+ }
+ }
+
+ if (victim->damage > victim->damagetolerance - 60 || normaldotproduct(victim->facing, victim->coords - coords) > 0 || animation[victim->animTarget].height == lowheight)
+ victim->RagDoll(0);
+ XYZ relative;
+ relative = victim->coords - coords;
+ relative.y = 0;
+ Normalise(&relative);
+ relative.y = .3;
+ Normalise(&relative);
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velocity = relative * 5;
+ }
+ victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity += relative * damagemult * 400;
+
+ victim->frameTarget = 0;
+ victim->animTarget = staggerbackhardanim;
+ victim->targetyaw = targetyaw + 180;
+ victim->target = 0;
+ victim->stunned = 1;
+
+ victim->Puff(abdomen);
+ victim->DoDamage(damagemult * 60 / victim->protectionhigh);
+
+ SolidHitBonus(id);
+ }
+ }
+
+ if (animTarget == blockhighleftanim && animation[animTarget].label[frameCurrent] == 5) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 4) {
+ if (victim->id == 0)
+ camerashake += .4;
+ emit_sound_at(landsound2, victim->coords);
+
+ Puff(righthand);
+ }
+ }
+
+ if (animTarget == swordslashparryanim && animation[animTarget].label[frameCurrent] == 5) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 4) {
+ if (victim->id == 0)
+ camerashake += .4;
+
+ if (weaponactive != -1) {
+ if (weapons[victim->weaponids[0]].getType() == staff || weapons[weaponids[0]].getType() == staff) {
+ if (weapons[victim->weaponids[0]].getType() == staff)
+ weapons[victim->weaponids[0]].damage += .2 + float(abs(Random() % 100) - 50) / 250;
+ if (weapons[weaponids[0]].getType() == staff)
+ weapons[weaponids[0]].damage += .2 + float(abs(Random() % 100) - 50) / 250;
+
+ emit_sound_at(swordstaffsound, victim->coords);
+ } else {
+ emit_sound_at(metalhitsound, victim->coords);
+ }
+ }
+
+ //Puff(righthand);
+ }
+ }
+
+ if (animTarget == knifethrowanim && animation[animTarget].label[frameCurrent] == 5) {
+ if (weaponactive != -1) {
+ escapednum = 0;
+ XYZ aim;
+ weapons[weaponids[0]].owner = -1;
+ aim = victim->coords + DoRotation(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position, 0, victim->yaw, 0) * victim->scale + victim->velocity * findDistance(&victim->coords, &coords) / 50 - (coords + DoRotation(skeleton.joints[skeleton.jointlabels[righthand]].position, 0, yaw, 0) * scale);
+ Normalise(&aim);
+ /*if(victim->animTarget==jumpupanim||victim->animTarget==jumpdownanim){
+ aim=DoRotation(aim,(float)abs(Random()%15)-7,(float)abs(Random()%15)-7,0);
+ }*/
+ weapons[weaponids[0]].velocity = aim * 50;
+ weapons[weaponids[0]].tipvelocity = aim * 50;
+ weapons[weaponids[0]].missed = 0;
+ weapons[weaponids[0]].hitsomething = 0;
+ weapons[weaponids[0]].freetime = 0;
+ weapons[weaponids[0]].firstfree = 1;
+ weapons[weaponids[0]].physics = 0;
+ num_weapons--;
+ if (num_weapons) {
+ weaponids[0] = weaponids[num_weapons];
+ }
+ weaponactive = -1;
+ }
+ }
+
+ if (animTarget == knifeslashstartanim && animation[animTarget].label[frameCurrent] == 5) {
+ if (hasvictim)
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 4.5 &&/*animation[victim->animTarget].height!=lowheight&&*/victim->animTarget != dodgebackanim && victim->animTarget != rollanim) {
+ escapednum = 0;
+ if (tutoriallevel != 1)
+ victim->DoBloodBig(1.5 / victim->armorhigh, 225);
+
+ award_bonus(id, Slicebonus);
+ if (tutoriallevel != 1) {
+ emit_sound_at(knifeslicesound, victim->coords);
+ }
+ //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
+ if (animation[victim->animTarget].attack && (victim->aitype != playercontrolled || victim->animTarget == knifeslashstartanim) && (victim->creature == rabbittype || victim->deathbleeding <= 0)) {
+ if (victim->id != 0 || difficulty == 2) {
+ victim->frameTarget = 0;
+ victim->animTarget = staggerbackhardanim;
+ victim->targetyaw = targetyaw + 180;
+ victim->target = 0;
+ }
+ }
+ victim->lowreversaldelay = 0;
+ victim->highreversaldelay = 0;
+ if (aitype != playercontrolled)
+ weaponmissdelay = .6;
+
+ if (tutoriallevel != 1)
+ if (bloodtoggle && !weapons[weaponids[weaponactive]].bloody)
+ weapons[weaponids[weaponactive]].bloody = 1;
+ if (tutoriallevel != 1)
+ weapons[weaponids[weaponactive]].blooddrip += 3;
+
+ XYZ footvel, footpoint;
+ footvel = 0;
+ if (skeleton.free) {
+ footpoint = (victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position + victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position) / 2 * victim->scale + victim->coords;
+ }
+ if (!skeleton.free) {
+ footpoint = DoRotation((victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position + victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position) / 2, 0, victim->yaw, 0) * victim->scale + victim->coords;
+ }
+ if (tutoriallevel != 1) {
+ if (bloodtoggle)
+ Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 0, 0, .6, .3);
+ footvel = DoRotation(facing, 0, 90, 0) * .8;
+ //footvel.y-=.3;
+ Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 7, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
+ Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 3, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
+ Sprite::MakeSprite(bloodflamesprite, footpoint, footvel * 5, 1, 1, 1, .2, 1);
+ Sprite::MakeSprite(bloodflamesprite, footpoint, footvel * 2, 1, 1, 1, .2, 1);
+ }
+ if (tutoriallevel == 1) {
+ Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 1, 1, .6, .3);
+ }
+ victim->DoDamage(damagemult * 0);
+ }
+ }
+ if (animTarget == swordslashanim && animation[animTarget].label[frameCurrent] == 5 && victim->animTarget != rollanim) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 6.5 && victim->animTarget != dodgebackanim) {
+ if (victim->weaponactive == -1 || normaldotproduct(victim->facing, victim->coords - coords) > 0 || (Random() % 2 == 0)) {
+ award_bonus(id, Slashbonus);
+ escapednum = 0;
+ if (tutoriallevel != 1) {
+ if (normaldotproduct(victim->facing, victim->coords - coords) < 0)
+ victim->DoBloodBig(2 / victim->armorhigh, 190);
+ else
+ victim->DoBloodBig(2 / victim->armorhigh, 185);
+ victim->deathbleeding = 1;
+ emit_sound_at(swordslicesound, victim->coords);
+ }
+ //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
+ if (tutoriallevel != 1) {
+ victim->frameTarget = 0;
+ victim->animTarget = staggerbackhardanim;
+ victim->targetyaw = targetyaw + 180;
+ victim->target = 0;
+ }
+
+ if (tutoriallevel != 1) {
+ if (bloodtoggle && !weapons[weaponids[weaponactive]].bloody)
+ weapons[weaponids[weaponactive]].bloody = 1;
+ weapons[weaponids[weaponactive]].blooddrip += 3;
+
+ float bloodlossamount;
+ bloodlossamount = 200 + abs((float)(Random() % 40)) - 20;
+ victim->bloodloss += bloodlossamount / victim->armorhigh;
+ //victim->bloodloss+=100*(6.5-distsq(&coords,&victim->coords));
+ victim->DoDamage(damagemult * 0);
+
+ XYZ footvel, footpoint;
+ footvel = 0;
+ if (skeleton.free) {
+ footpoint = (victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position + victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position) / 2 * victim->scale + victim->coords;
+ }
+ if (!skeleton.free) {
+ footpoint = DoRotation((victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position + victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position) / 2, 0, victim->yaw, 0) * victim->scale + victim->coords;
+ }
+ if (bloodtoggle)
+ Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 0, 0, .9, .3);
+ footvel = DoRotation(facing, 0, 90, 0) * .8;
+ footvel.y -= .3;
+ Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 7, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
+ Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 3, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
+ Sprite::MakeSprite(bloodflamesprite, footpoint, footvel * 5, 1, 1, 1, .3, 1);
+ Sprite::MakeSprite(bloodflamesprite, footpoint, footvel * 2, 1, 1, 1, .3, 1);
+ }
+ } else {
+ if (victim->weaponactive != -1) {
+ if (weapons[victim->weaponids[0]].getType() == staff || weapons[weaponids[0]].getType() == staff) {
+ if (weapons[victim->weaponids[0]].getType() == staff)
+ weapons[victim->weaponids[0]].damage += .2 + float(abs(Random() % 100) - 50) / 250;
+ if (weapons[weaponids[0]].getType() == staff)
+ weapons[weaponids[0]].damage += .2 + float(abs(Random() % 100) - 50) / 250;
+
+ emit_sound_at(swordstaffsound, victim->coords);
+ } else {
+ emit_sound_at(metalhitsound, victim->coords);
+ }
+ }
+
+
+ XYZ aim;
+ victim->Puff(righthand);
+ victim->target = 0;
+ victim->frameTarget = 0;
+ victim->animTarget = staggerbackhighanim;
+ victim->targetyaw = targetyaw + 180;
+ victim->target = 0;
+ weapons[victim->weaponids[0]].owner = -1;
+ aim = DoRotation(facing, 0, 90, 0) * 21;
+ aim.y += 7;
+ weapons[victim->weaponids[0]].velocity = aim * -.2;
+ weapons[victim->weaponids[0]].tipvelocity = aim;
+ weapons[victim->weaponids[0]].missed = 1;
+ weapons[weaponids[0]].hitsomething = 0;
+ weapons[victim->weaponids[0]].freetime = 0;
+ weapons[victim->weaponids[0]].firstfree = 1;
+ weapons[victim->weaponids[0]].physics = 1;
+ victim->num_weapons--;
+ if (victim->num_weapons) {
+ victim->weaponids[0] = victim->weaponids[num_weapons];
+ if (victim->weaponstuck == victim->num_weapons)
+ victim->weaponstuck = 0;
+ }
+ victim->weaponactive = -1;
+ for (i = 0; i < numplayers; i++) {
+ player[i].wentforweapon = 0;
+ }
+
+ }
+ }
+ }
+
+ if (animTarget == staffhitanim && animation[animTarget].label[frameCurrent] == 5 && victim->animTarget != rollanim) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 6.5 && victim->animTarget != dodgebackanim && victim->animTarget != sweepanim) {
+ if (tutoriallevel != 1) {
+ weapons[weaponids[0]].damage += .4 + float(abs(Random() % 100) - 50) / 250;
+ escapednum = 0;
+ if (id == 0)
+ camerashake += .4;
+ if (Random() % 2 || creature == wolftype) {
+ victim->spurt = 1;
+ }
+ emit_sound_at(staffheadsound, victim->coords);
+ }
+ victim->RagDoll(0);
+ XYZ relative;
+ relative = victim->coords - coords;
+ relative.y = 0;
+ Normalise(&relative);
+ relative = DoRotation(relative, 0, 90, 0);
+ relative.y -= 1;
+ Normalise(&relative);
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 60;
+ }
+ victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity += relative * damagemult * 230;
+ victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity += relative * damagemult * 230;
+ //FootLand(1,2);
+ victim->Puff(head);
+ if (tutoriallevel != 1) {
+ victim->DoDamage(damagemult * 120 / victim->protectionhigh);
+
+ award_bonus(id, solidhit, 30);
+ }
+ }
+ }
+
+ if (animTarget == staffspinhitanim && animation[animTarget].label[frameCurrent] == 5 && victim->animTarget != rollanim) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 6.5 && victim->animTarget != dodgebackanim && victim->animTarget != sweepanim) {
+ if (tutoriallevel != 1) {
+ weapons[weaponids[0]].damage += .6 + float(abs(Random() % 100) - 50) / 250;
+ escapednum = 0;
+ if (id == 0)
+ camerashake += .4;
+ if (Random() % 2 || creature == wolftype) {
+ victim->spurt = 1;
+ }
+ emit_sound_at(staffheadsound, victim->coords);
+ }
+ victim->RagDoll(0);
+ XYZ relative;
+ relative = victim->coords - coords;
+ relative.y = 0;
+ Normalise(&relative);
+ relative = DoRotation(relative, 0, -90, 0);
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 40;
+ }
+ victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity += relative * damagemult * 220;
+ victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity += relative * damagemult * 220;
+ //FootLand(1,2);
+ victim->Puff(head);
+ if (tutoriallevel != 1) {
+ victim->DoDamage(damagemult * 350 / victim->protectionhead);
+
+ award_bonus(id, solidhit, 60);
+ }
+ }
+ }
+
+ if (animTarget == staffgroundsmashanim && animation[animTarget].label[frameCurrent] == 5) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 6.5) {
+ escapednum = 0;
+ if (tutoriallevel != 1) {
+ if (!victim->dead)
+ weapons[weaponids[0]].damage += .4 + float(abs(Random() % 100) - 50) / 500;
+ if (id == 0)
+ camerashake += .4;
+ if (Random() % 2 || creature == wolftype) {
+ victim->spurt = 1;
+ }
+ emit_sound_at(staffbodysound, victim->coords);
+ }
+ victim->skeleton.longdead = 0;
+ victim->skeleton.free = 1;
+ victim->skeleton.broken = 0;
+
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velchange = 0;
+ victim->skeleton.joints[i].locked = 0;
+ //victim->skeleton.joints[i].velocity=0;
+ }
+
+ victim->RagDoll(0);
+ XYZ relative;
+ relative = 0;
+ /*relative=victim->coords-coords;
+ relative.y=0;
+ Normalise(&relative);
+ relative=DoRotation(relative,0,90,0);*/
+ relative.y = -1;
+ Normalise(&relative);
+ if (!victim->dead) {
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velocity = relative * damagemult * 40;
+ }
+ //FootLand(1,2);
+ victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity += relative * damagemult * 40;
+ }
+ if (victim->dead) {
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velocity = relative * damagemult * abs(Random() % 20);
+ }
+ //FootLand(1,2);
+ //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
+ }
+ victim->Puff(abdomen);
+ if (tutoriallevel != 1) {
+ victim->DoDamage(damagemult * 100 / victim->protectionhigh);
+
+ if (!victim->dead) {
+ award_bonus(id, solidhit, 40);
+ }
+ }
+ }
+ }
+
+ if (animTarget == lowkickanim && animation[animTarget].label[frameCurrent] == 5) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && animation[victim->animTarget].height != highheight) {
+ escapednum = 0;
+ if (id == 0)
+ camerashake += .4;
+ XYZ relative;
+ relative = victim->coords - coords;
+ relative.y = 0;
+ Normalise(&relative);
+
+ SolidHitBonus(id);
+
+ if (animation[victim->animTarget].height == lowheight) {
+ if (Random() % 2) {
+ victim->spurt = 1;
+ DoBlood(.2, 250);
+ }
+ victim->RagDoll(0);
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 40;
+ }
+ victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity += relative * damagemult * 200;
+ if (tutoriallevel != 1) {
+ emit_sound_at(heavyimpactsound, victim->coords, 128.);
+ }
+ victim->Puff(head);
+ victim->DoDamage(damagemult * 100 / victim->protectionhead);
+ if (victim->howactive == typesleeping)
+ victim->DoDamage(damagemult * 150 / victim->protectionhead);
+ if (creature == wolftype) {
+ emit_sound_at(clawslicesound, victim->coords, 128.);
+ victim->spurt = 1;
+ victim->DoBloodBig(2 / victim->armorhead, 175);
+ }
+ } else {
+ if (victim->damage >= victim->damagetolerance)
+ victim->RagDoll(0);
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 10;
+ }
+ victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity += relative * damagemult * 200;
+ victim->frameTarget = 0;
+ victim->animTarget = staggerbackhighanim;
+ victim->targetyaw = targetyaw + 180;
+ victim->target = 0;
+ if (tutoriallevel != 1) {
+ emit_sound_at(landsound2, victim->coords, 128.);
+ }
+ victim->Puff(abdomen);
+ victim->DoDamage(damagemult * 30 / victim->protectionhigh);
+ if (creature == wolftype) {
+ emit_sound_at(clawslicesound, victim->coords, 128.);
+ victim->spurt = 1;
+ victim->DoBloodBig(2 / victim->armorhigh, 170);
+ }
+ }
+
+ }
+ }
+
+ if (animTarget == sweepanim && animation[animTarget].label[frameCurrent] == 5) {
+ if (victim->animTarget != jumpupanim && distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && victim != this) {
+ escapednum = 0;
+ if (id == 0)
+ camerashake += .2;
+ if (tutoriallevel != 1) {
+ emit_sound_at(landsound2, victim->coords, 128.);
+ }
+ XYZ relative;
+ relative = victim->coords - coords;
+ relative.y = 0;
+ Normalise(&relative);
+
+ if (animation[victim->animTarget].height == middleheight || animation[victim->animCurrent].height == middleheight || victim->damage >= victim->damagetolerance - 40) {
+ victim->RagDoll(0);
+
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 15;
+ }
+ relative = DoRotation(relative, 0, -90, 0);
+ relative.y += .1;
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ if (victim->skeleton.joints[i].label == leftfoot || victim->skeleton.joints[i].label == rightfoot || victim->skeleton.joints[i].label == leftankle || victim->skeleton.joints[i].label == rightankle)
+ victim->skeleton.joints[i].velocity = relative * 80;
+ }
+ victim->Puff(rightankle);
+ victim->Puff(leftankle);
+ victim->DoDamage(damagemult * 40 / victim->protectionlow);
+ } else {
+ if (victim->damage >= victim->damagetolerance)
+ victim->RagDoll(0);
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 10;
+ }
+ relative = DoRotation(relative, 0, -90, 0);
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ if (victim->skeleton.joints[i].label == leftfoot || victim->skeleton.joints[i].label == rightfoot || victim->skeleton.joints[i].label == leftankle || victim->skeleton.joints[i].label == rightankle)
+ victim->skeleton.joints[i].velocity += relative * damagemult * 80;
+ }
+ victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity += relative * damagemult * 200;
+ victim->frameTarget = 0;
+ victim->animTarget = staggerbackhighanim;
+ victim->targetyaw = targetyaw + 180;
+ victim->target = 0;
+ if (tutoriallevel != 1) {
+ emit_sound_at(landsound2, victim->coords, 128.);
+ }
+ victim->Puff(abdomen);
+ victim->DoDamage(damagemult * 30 / victim->protectionlow);
+ }
+
+ SolidHitBonus(id);
+
+ }
+ }
+ }
+ if (animation[animTarget].attack == reversal && (!victim->feint || (victim->lastattack == victim->lastattack2 && victim->lastattack2 == victim->lastattack3 && Random() % 2) || animTarget == knifefollowanim)) {
+ if (animTarget == spinkickreversalanim && animation[animTarget].label[frameCurrent] == 7) {
+ escapednum = 0;
+ if (id == 0)
+ camerashake += .4;
+ if (Random() % 2) {
+ victim->spurt = 1;
+ DoBlood(.2, 230);
+ }
+ if (tutoriallevel != 1) {
+ emit_sound_at(heavyimpactsound, victim->coords, 128.);
+ }
+ if (creature == wolftype) {
+ emit_sound_at(clawslicesound, victim->coords, 128);
+ victim->spurt = 1;
+ victim->DoBloodBig(2 / victim->armorhigh, 170);
+ }
+ victim->RagDoll(0);
+ XYZ relative;
+ relative = victim->coords - oldcoords;
+ relative.y = 0;
+ Normalise(&relative);
+ //relative=DoRotation(relative,0,-90,0);
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 40;
+ }
+ victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity += relative * damagemult * 200;
+ //FootLand(1,2);
+ victim->Puff(abdomen);
+ victim->DoDamage(damagemult * 150 / victim->protectionhigh);
+
+ award_bonus(id, Reversal);
+ }
+
+ if ((animTarget == swordslashreversalanim || animTarget == knifeslashreversalanim || animTarget == staffhitreversalanim || animTarget == staffspinhitreversalanim) && animation[animTarget].label[frameCurrent] == 5) {
+ if (victim->weaponactive != -1 && victim->num_weapons > 0) {
+ if (weapons[victim->weaponids[victim->weaponactive]].owner == victim->id) {
+ weapons[victim->weaponids[victim->weaponactive]].owner = id;
+ weaponactive = 0;
+ if (num_weapons > 0) {
+ weaponids[num_weapons] = weaponids[victim->weaponactive];
+ }
+ num_weapons++;
+ weaponids[0] = victim->weaponids[victim->weaponactive];
+ victim->num_weapons--;
+ if (victim->num_weapons > 0) {
+ victim->weaponids[victim->weaponactive] = victim->weaponids[victim->num_weapons];
+ //if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
+ }
+ victim->weaponactive = -1;
+ }
+ }
+ }
+
+ if (animTarget == staffhitreversalanim && animation[animTarget].label[frameCurrent] == 5) {
+ escapednum = 0;
+ if (id == 0)
+ camerashake += .4;
+ if (Random() % 2) {
+ victim->spurt = 1;
+ DoBlood(.2, 230);
+ }
+ emit_sound_at(whooshhitsound, victim->coords, 128.);
+ victim->RagDoll(0);
+ XYZ relative;
+ relative = victim->coords - oldcoords;
+ relative.y = 0;
+ Normalise(&relative);
+ //relative=DoRotation(relative,0,-90,0);
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 30;
+ }
+ victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity += relative * damagemult * 200;
+ //FootLand(1,2);
+ victim->Puff(head);
+ victim->DoDamage(damagemult * 70 / victim->protectionhigh);
+ }
+
+ if (animTarget == staffspinhitreversalanim && animation[animTarget].label[frameCurrent] == 7) {
+ escapednum = 0;
+ if (id == 0)
+ camerashake += .4;
+ if (Random() % 2) {
+ victim->spurt = 1;
+ DoBlood(.2, 230);
+ }
+
+ award_bonus(id, staffreversebonus);
+
+ if (tutoriallevel != 1) {
+ emit_sound_at(heavyimpactsound, victim->coords, 128.);
+ }
+ victim->RagDoll(0);
+ award_bonus(id, staffreversebonus); // Huh, again?
+
+ XYZ relative;
+ relative = victim->coords - oldcoords;
+ relative.y = 0;
+ Normalise(&relative);
+ //relative=DoRotation(relative,0,-90,0);
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 30;
+ }
+ victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity += relative * damagemult * 200;
+ //FootLand(1,2);
+ victim->Puff(head);
+ victim->DoDamage(damagemult * 70 / victim->protectionhigh);
+ }
+
+ if (animTarget == upunchreversalanim && animation[animTarget].label[frameCurrent] == 7) {
+ escapednum = 0;
+ victim->RagDoll(1);
+ XYZ relative;
+ relative = facing;
+ relative.y = 0;
+ Normalise(&relative);
+ //relative*=-1;
+ relative.y -= .1;
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 70;
+ }
+ victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity *= .1;
+ victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity *= .2;
+ victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity *= .5;
+ victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity *= .7;
+ victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity *= .1;
+ victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity *= .2;
+ victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity *= .5;
+ victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity *= .7;
+
+ victim->Puff(abdomen);
+ victim->DoDamage(damagemult * 90 / victim->protectionhigh);
+
+ award_bonus(id, Reversal);
+
+ bool doslice;
+ doslice = 0;
+ if (weaponactive != -1 || creature == wolftype)
+ doslice = 1;
+ if (creature == rabbittype && weaponactive != -1)
+ if (weapons[weaponids[0]].getType() == staff)
+ doslice = 0;
+ if (doslice) {
+ if (weaponactive != -1) {
+ victim->DoBloodBig(2 / victim->armorhigh, 225);
+ emit_sound_at(knifeslicesound, victim->coords);
+ if (bloodtoggle && !weapons[weaponids[weaponactive]].bloody)
+ weapons[weaponids[weaponactive]].bloody = 1;
+ weapons[weaponids[weaponactive]].blooddrip += 3;
+ }
+ if (weaponactive == -1 && creature == wolftype) {
+ ;
+ emit_sound_at(clawslicesound, victim->coords, 128.);
+ victim->spurt = 1;
+ victim->DoBloodBig(2 / victim->armorhigh, 175);
+ }
+ }
+ }
+
+
+
+ if (animTarget == swordslashreversalanim && animation[animTarget].label[frameCurrent] == 7) {
+ escapednum = 0;
+ victim->RagDoll(1);
+ XYZ relative;
+ relative = facing;
+ relative.y = 0;
+ Normalise(&relative);
+ //relative*=-1;
+ relative.y -= .1;
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 70;
+ }
+ victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity *= .1 - 1;
+ victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity *= .2 - 1;
+ victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity *= .5 - 1;
+ victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity *= .7 - 1;
+ victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity *= .1 - 1;
+ victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity *= .2 - 1;
+ victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity *= .5 - 1;
+ victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity *= .7 - 1;
+
+ award_bonus(id, swordreversebonus);
+ }
+
+ if (hasvictim && animTarget == knifeslashreversalanim && animation[animTarget].label[frameCurrent] == 7) {
+ escapednum = 0;
+ if (id == 0)
+ camerashake += .4;
+ if (Random() % 2) {
+ victim->spurt = 1;
+ DoBlood(.2, 230);
+ }
+ if (tutoriallevel != 1) {
+ emit_sound_at(heavyimpactsound, victim->coords, 128.);
+ }
+ victim->RagDoll(0);
+ XYZ relative;
+ relative = victim->coords - oldcoords;
+ relative.y = 0;
+ Normalise(&relative);
+ relative = DoRotation(relative, 0, -90, 0);
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 40;
+ }
+ victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity += relative * damagemult * 200;
+ //FootLand(1,2);
+ victim->Puff(abdomen);
+ victim->DoDamage(damagemult * 30 / victim->protectionhigh);
+
+ award_bonus(id, Reversal);
+ }
+
+ if (hasvictim && animTarget == sneakattackanim && animation[animTarget].label[frameCurrent] == 7) {
+ escapednum = 0;
+ victim->RagDoll(0);
+ victim->skeleton.spinny = 0;
+ XYZ relative;
+ relative = facing * -1;
+ relative.y = -3;
+ Normalise(&relative);
+ if (victim->id == 0)
+ relative /= 30;
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 40;
+ }
+ //victim->DoDamage(1000);
+ victim->damage = victim->damagetolerance;
+ victim->permanentdamage = victim->damagetolerance - 1;
+ bool doslice;
+ doslice = 0;
+ if (weaponactive != -1 || creature == wolftype)
+ doslice = 1;
+ if (creature == rabbittype && weaponactive != -1)
+ if (weapons[weaponids[0]].getType() == staff)
+ doslice = 0;
+ if (doslice) {
+ if (weaponactive != -1) {
+ victim->DoBloodBig(200, 225);
+ emit_sound_at(knifeslicesound, victim->coords);
+ if (bloodtoggle)
+ weapons[weaponids[weaponactive]].bloody = 2;
+ weapons[weaponids[weaponactive]].blooddrip += 5;
+ }
+
+ if (creature == wolftype && weaponactive == -1) {
+ emit_sound_at(clawslicesound, victim->coords, 128.);
+ victim->spurt = 1;
+ victim->DoBloodBig(2, 175);
+ }
+ }
+ award_bonus(id, spinecrusher);
+ }
+
+ if (hasvictim && (animTarget == knifefollowanim || animTarget == knifesneakattackanim) && animation[animTarget].label[frameCurrent] == 5) {
+ if (weaponactive != -1 && victim->bloodloss < victim->damagetolerance) {
+ escapednum = 0;
+ if (animTarget == knifefollowanim)
+ victim->DoBloodBig(200, 210);
+ if (animTarget == knifesneakattackanim) {
+ /*victim->DoBloodBig(200,195);
+ XYZ bloodvel;
+ bloodvel=0;
+ bloodvel.z=20;
+ bloodvel.y=5;
+ bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,yaw+((float)(Random()%100))/4,0)*scale;
+ Sprite::MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position,0,yaw,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
+ */
+ XYZ footvel, footpoint;
+ footvel = 0;
+ footpoint = weapons[weaponids[0]].tippoint;
+ if (bloodtoggle)
+ Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 0, 0, .9, .3);
+ footvel = (weapons[weaponids[0]].tippoint - weapons[weaponids[0]].position);
+ Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 7, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
+ Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 3, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
+ Sprite::MakeSprite(bloodflamesprite, footpoint, footvel * 5, 1, 1, 1, .3, 1);
+ Sprite::MakeSprite(bloodflamesprite, footpoint, footvel * 2, 1, 1, 1, .3, 1);
+ victim->DoBloodBig(200, 195);
+ award_bonus(id, tracheotomy);
+ }
+ if (animTarget == knifefollowanim) {
+ award_bonus(id, Stabbonus);
+ XYZ footvel, footpoint;
+ footvel = 0;
+ footpoint = weapons[weaponids[0]].tippoint;
+ if (bloodtoggle)
+ Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 0, 0, .9, .3);
+ footvel = (weapons[weaponids[0]].tippoint - weapons[weaponids[0]].position) * -1;
+ Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 7, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
+ Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 3, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
+ Sprite::MakeSprite(bloodflamesprite, footpoint, footvel * 5, 1, 1, 1, .2, 1);
+ Sprite::MakeSprite(bloodflamesprite, footpoint, footvel * 2, 1, 1, 1, .2, 1);
+
+ }
+ victim->bloodloss += 10000;
+ victim->velocity = 0;
+ emit_sound_at(fleshstabsound, victim->coords);
+ if (bloodtoggle)
+ weapons[weaponids[weaponactive]].bloody = 2;
+ weapons[weaponids[weaponactive]].blooddrip += 5;
+ }
+ }
+
+ if (hasvictim && (animTarget == knifefollowanim || animTarget == knifesneakattackanim) && animation[animTarget].label[frameCurrent] == 6) {
+ escapednum = 0;
+ victim->velocity = 0;
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velocity = 0;
+ }
+ if (animTarget == knifefollowanim) {
+ victim->RagDoll(0);
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velocity = 0;
+ }
+ }
+ if (weaponactive != -1 && animation[victim->animTarget].attack != reversal) {
+ emit_sound_at(fleshstabremovesound, victim->coords);
+ if (bloodtoggle)
+ weapons[weaponids[weaponactive]].bloody = 2;
+ weapons[weaponids[weaponactive]].blooddrip += 5;
+
+ XYZ footvel, footpoint;
+ footvel = 0;
+ footpoint = weapons[weaponids[0]].tippoint;
+ if (bloodtoggle)
+ Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 0, 0, .9, .3);
+ footvel = (weapons[weaponids[0]].tippoint - weapons[weaponids[0]].position) * -1;
+ Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 7, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
+ Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 3, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
+ Sprite::MakeSprite(bloodflamesprite, footpoint, footvel * 5, 1, 1, 1, .3, 1);
+ Sprite::MakeSprite(bloodflamesprite, footpoint, footvel * 2, 1, 1, 1, .3, 1);
+ }
+ }
+
+ if (hasvictim && (animTarget == swordsneakattackanim) && animation[animTarget].label[frameCurrent] == 5) {
+ if (weaponactive != -1 && victim->bloodloss < victim->damagetolerance) {
+ award_bonus(id, backstab);
+
+ escapednum = 0;
+
+ XYZ footvel, footpoint;
+ footvel = 0;
+ footpoint = (weapons[weaponids[0]].tippoint + weapons[weaponids[0]].position) / 2;
+ if (bloodtoggle)
+ Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 0, 0, .9, .3);
+ footvel = (weapons[weaponids[0]].tippoint - weapons[weaponids[0]].position);
+ Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 7, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
+ Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 3, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
+ Sprite::MakeSprite(bloodflamesprite, footpoint, DoRotation(footvel * 5, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .3, 1);
+ Sprite::MakeSprite(bloodflamesprite, footpoint, DoRotation(footvel * 3, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .3, 1);
+ victim->DoBloodBig(200, 180);
+ victim->DoBloodBig(200, 215);
+ victim->bloodloss += 10000;
+ victim->velocity = 0;
+ emit_sound_at(fleshstabsound, victim->coords);
+ if (bloodtoggle)
+ weapons[weaponids[weaponactive]].bloody = 2;
+ weapons[weaponids[weaponactive]].blooddrip += 5;
+ }
+ }
+
+ if (hasvictim && animTarget == swordsneakattackanim && animation[animTarget].label[frameCurrent] == 6) {
+ escapednum = 0;
+ victim->velocity = 0;
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velocity = 0;
+ }
+ if (weaponactive != -1) {
+ emit_sound_at(fleshstabremovesound, victim->coords);
+ if (bloodtoggle)
+ weapons[weaponids[weaponactive]].bloody = 2;
+ weapons[weaponids[weaponactive]].blooddrip += 5;
+
+ XYZ footvel, footpoint;
+ footvel = 0;
+ footpoint = weapons[weaponids[0]].tippoint;
+ if (bloodtoggle)
+ Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 0, 0, .9, .3);
+ footvel = (weapons[weaponids[0]].tippoint - weapons[weaponids[0]].position) * -1;
+ Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 7, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
+ Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 3, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
+ Sprite::MakeSprite(bloodflamesprite, footpoint, footvel * 5, 1, 1, 1, .3, 1);
+ Sprite::MakeSprite(bloodflamesprite, footpoint, footvel * 2, 1, 1, 1, .3, 1);
+ }
+ }
+
+ if (animTarget == sweepreversalanim && animation[animTarget].label[frameCurrent] == 7) {
+ escapednum = 0;
+ if (id == 0)
+ camerashake += .4;
+ if (Random() % 2) {
+ victim->spurt = 1;
+ DoBlood(.2, 240);
+ }
+ if (weaponactive == -1) {
+ if (tutoriallevel != 1) {
+ emit_sound_at(heavyimpactsound, victim->coords, 128.);
+ }
+ }
+ bool doslice;
+ doslice = 0;
+ if (weaponactive != -1 || creature == wolftype)
+ doslice = 1;
+ if (creature == rabbittype && weaponactive != -1)
+ if (weapons[weaponids[0]].getType() == staff)
+ doslice = 0;
+ if (doslice) {
+ if (weaponactive != -1) {
+ victim->DoBloodBig(2 / victim->armorhead, 225);
+ emit_sound_at(knifeslicesound, victim->coords);
+ if (bloodtoggle && !weapons[weaponids[weaponactive]].bloody)
+ weapons[weaponids[weaponactive]].bloody = 1;
+ weapons[weaponids[weaponactive]].blooddrip += 3;
+ }
+ if (weaponactive == -1 && creature == wolftype) {
+ emit_sound_at(clawslicesound, victim->coords, 128.);
+ victim->spurt = 1;
+ victim->DoBloodBig(2 / victim->armorhead, 175);
+ }
+ }
+
+ award_bonus(id, Reversal);
+
+ victim->Puff(neck);
+
+ XYZ relative;
+ //relative=victim->coords-oldcoords;
+ relative = facing * -1;
+ relative.y = 0;
+ Normalise(&relative);
+ relative = DoRotation(relative, 0, 90, 0);
+ relative.y = .5;
+ Normalise(&relative);
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 20;
+ }
+ victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity += relative * damagemult * 200;
+ if (victim->damage < victim->damagetolerance - 100)
+ victim->velocity = relative * 200;
+ victim->DoDamage(damagemult * 100 / victim->protectionhead);
+ victim->velocity = 0;
+ }
+
+ if (animTarget == sweepreversalanim && ((animation[animTarget].label[frameCurrent] == 9 && victim->damage < victim->damagetolerance) || (animation[animTarget].label[frameCurrent] == 7 && victim->damage > victim->damagetolerance))) {
+ escapednum = 0;
+ victim->RagDoll(0);
+ XYZ relative;
+ //relative=victim->coords-oldcoords;
+ relative = facing * -1;
+ relative.y = 0;
+ Normalise(&relative);
+ relative = DoRotation(relative, 0, 90, 0);
+ relative.y = .5;
+ Normalise(&relative);
+ for (i = 0; i < victim->skeleton.num_joints; i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 20;
+ }
+ victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity += relative * damagemult * 200;
+ }
+
+ if (hasvictim && (animTarget == spinkickreversalanim || animTarget == sweepreversalanim || animTarget == rabbitkickreversalanim || animTarget == upunchreversalanim || animTarget == jumpreversalanim || animTarget == swordslashreversalanim || animTarget == knifeslashreversalanim || animTarget == rabbittacklereversal || animTarget == wolftacklereversal || animTarget == staffhitreversalanim || animTarget == staffspinhitreversalanim))
+ if (victim->damage > victim->damagetolerance && bonus != reverseko) {
+ award_bonus(id, reverseko);
+ }
+ }
+
+
+ //Animation end
+ if (frameTarget > animation[animCurrent].numframes - 1) {
+ frameTarget = 0;
+ if (wasStop()) {
+ animTarget = getIdle();
+ FootLand(0, 1);
+ FootLand(1, 1);
+ }
+ if (animCurrent == rabbittackleanim || animCurrent == rabbittacklinganim) {
+ animTarget = rollanim;
+ frameTarget = 3;
+ emit_sound_at(movewhooshsound, coords, 128.);
+ }
+ if (animCurrent == staggerbackhighanim) {
+ animTarget = getIdle();
+ }
+ if (animCurrent == staggerbackhardanim) {
+ animTarget = getIdle();
+ }
+ if (animCurrent == removeknifeanim) {
+ animTarget = getIdle();
+ }
+ if (animCurrent == crouchremoveknifeanim) {
+ animTarget = getCrouch();
+ }
+ if (animCurrent == backhandspringanim) {
+ animTarget = getIdle();
+ }
+ if (animCurrent == dodgebackanim) {
+ animTarget = getIdle();
+ }
+ if (animCurrent == drawleftanim) {
+ animTarget = getIdle();
+ }
+ if (animCurrent == drawrightanim || animCurrent == crouchdrawrightanim) {
+ animTarget = getIdle();
+ if (animCurrent == crouchdrawrightanim) {
+ animTarget = getCrouch();
+ }
+ if (weaponactive == -1)
+ weaponactive = 0;
+ else if (weaponactive == 0) {
+ weaponactive = -1;
+ if (num_weapons == 2) {
+ int buffer;
+ buffer = weaponids[0];
+ weaponids[0] = weaponids[1];
+ weaponids[1] = buffer;
+ }
+ }
+
+ if (weaponactive == -1) {
+ emit_sound_at(knifesheathesound, coords, 128.);
+ }
+ if (weaponactive != -1) {
+ emit_sound_at(knifedrawsound, coords, 128.);
+ }
+ }
+ if (animCurrent == rollanim) {
+ animTarget = getCrouch();
+ FootLand(0, 1);
+ FootLand(1, 1);
+ }
+ if (isFlip()) {
+ if (animTarget == walljumprightkickanim) {
+ targetrot = -190;
+ }
+ if (animTarget == walljumpleftkickanim) {
+ targetrot = 190;
+ }
+ animTarget = jumpdownanim;
+ }
+ if (animCurrent == climbanim) {
+ animTarget = getCrouch();
+ frameTarget = 1;
+ coords += facing * .1;
+ if (!isnormal(coords.x))
+ coords = oldcoords;
+ oldcoords = coords;
+ collided = 0;
+ targetoffset = 0;
+ currentoffset = 0;
+ grabdelay = 1;
+ velocity = 0;
+ collided = 0;
+ avoidcollided = 0;
+ }
+ if (animTarget == rabbitkickreversalanim) {
+ animTarget = getCrouch();
+ lastfeint = 0;
+ }
+ if (animTarget == jumpreversalanim) {
+ animTarget = getCrouch();
+ lastfeint = 0;
+ }
+ if (animTarget == walljumprightanim || animTarget == walljumpbackanim || animTarget == walljumpfrontanim) {
+ if (attackkeydown && animTarget != walljumpfrontanim) {
+ int closest = -1;
+ float closestdist = -1;
+ float distance;
+ if (numplayers > 1)
+ for (i = 0; i < numplayers; i++) {
+ if (id != i && player[i].coords.y < coords.y && !player[i].skeleton.free) {
+ distance = distsq(&player[i].coords, &coords);
+ if (closestdist == -1 || distance < closestdist) {
+ closestdist = distance;
+ closest = i;
+ }
+ }
+ }
+ if (closestdist > 0 && closest >= 0 && closestdist < 16) {
+ victim = &player[closest];
+ animTarget = walljumprightkickanim;
+ frameTarget = 0;
+ XYZ rotatetarget = victim->coords - coords;
+ Normalise(&rotatetarget);
+ yaw = -asin(0 - rotatetarget.x);
+ yaw *= 360 / 6.28;
+ if (rotatetarget.z < 0)
+ yaw = 180 - yaw;
+ targettilt2 = -asin(rotatetarget.y) * 360 / 6.28;
+ velocity = (victim->coords - coords) * 4;
+ velocity.y += 2;
+ transspeed = 40;
+ }
+ }
+ if (animTarget == walljumpbackanim) {
+ animTarget = backflipanim;
+ frameTarget = 3;
+ velocity = facing * -8;
+ velocity.y = 4;
+ if (id == 0)
+ resume_stream(whooshsound);
+ }
+ if (animTarget == walljumprightanim) {
+ animTarget = rightflipanim;
+ frameTarget = 4;
+ targetyaw -= 90;
+ yaw -= 90;
+ velocity = DoRotation(facing, 0, 30, 0) * -8;
+ velocity.y = 4;
+ }
+ if (animTarget == walljumpfrontanim) {
+ animTarget = frontflipanim;
+ frameTarget = 2;
+ //targetyaw-=180;
+ ////yaw-=180;
+ velocity = facing * 8;
+ velocity.y = 4;
+ }
+ if (id == 0)
+ resume_stream(whooshsound);
+ }
+ if (animTarget == walljumpleftanim) {
+ if (attackkeydown) {
+ int closest = -1;
+ float closestdist = -1;
+ float distance;
+ if (numplayers > 1)
+ for (i = 0; i < numplayers; i++) {
+ if (id != i && player[i].coords.y < coords.y && !player[i].skeleton.free) {
+ distance = distsq(&player[i].coords, &coords);
+ if (closestdist == -1 || distance < closestdist) {
+ closestdist = distance;
+ closest = i;
+ }
+ }
+ }
+ if (closestdist > 0 && closest >= 0 && closestdist < 16) {
+ victim = &player[closest];
+ animTarget = walljumpleftkickanim;
+ frameTarget = 0;
+ XYZ rotatetarget = victim->coords - coords;
+ Normalise(&rotatetarget);
+ yaw = -asin(0 - rotatetarget.x);
+ yaw *= 360 / 6.28;
+ if (rotatetarget.z < 0)
+ yaw = 180 - yaw;
+ targettilt2 = -asin(rotatetarget.y) * 360 / 6.28;
+ velocity = (victim->coords - coords) * 4;
+ velocity.y += 2;
+ transspeed = 40;
+ }
+ }
+ if (animTarget != walljumpleftkickanim) {
+ animTarget = leftflipanim;
+ frameTarget = 4;
+ targetyaw += 90;
+ yaw += 90;
+ velocity = DoRotation(facing, 0, -30, 0) * -8;
+ velocity.y = 4;
+ }
+ if (id == 0)
+ resume_stream(whooshsound);
+ }
+ if (animTarget == sneakattackanim) {
+ animCurrent = getCrouch();
+ animTarget = getCrouch();
+ frameTarget = 1;
+ frameCurrent = 0;
+ targetyaw += 180;
+ yaw += 180;
+ targettilt2 *= -1;
+ tilt2 *= -1;
+ transspeed = 1000000;
+ targetheadyaw += 180;
+ coords -= facing * .7;
+ if (onterrain)
+ coords.y = terrain.getHeight(coords.x, coords.z);
+
+ lastfeint = 0;
+ }
+ if (animTarget == knifesneakattackanim || animTarget == swordsneakattackanim) {
+ animTarget = getIdle();
+ frameTarget = 0;
+ if (onterrain)
+ coords.y = terrain.getHeight(coords.x, coords.z);
+
+ lastfeint = 0;
+ }
+ if (animCurrent == knifefollowanim) {
+ animTarget = getIdle();
+ lastfeint = 0;
+ }
+ if (animation[animTarget].attack == reversal && animCurrent != sneakattackanim && animCurrent != knifesneakattackanim && animCurrent != swordsneakattackanim && animCurrent != knifefollowanim) {
+ float ycoords = oldcoords.y;
+ animTarget = getStop();
+ targetyaw += 180;
+ yaw += 180;
+ targettilt2 *= -1;
+ tilt2 *= -1;
+ transspeed = 1000000;
+ targetheadyaw += 180;
+ if (!isnormal(coords.x))
+ coords = oldcoords;
+ if (animCurrent == spinkickreversalanim || animCurrent == swordslashreversalanim)
+ oldcoords = coords + facing * .5;
+ else if (animCurrent == sweepreversalanim)
+ oldcoords = coords + facing * 1.1;
+ else if (animCurrent == upunchreversalanim) {
+ oldcoords = coords + facing * 1.5;
+ targetyaw += 180;
+ yaw += 180;
+ targetheadyaw += 180;
+ targettilt2 *= -1;
+ tilt2 *= -1;
+ } else if (animCurrent == knifeslashreversalanim) {
+ oldcoords = coords + facing * .5;
+ targetyaw += 90;
+ yaw += 90;
+ targetheadyaw += 90;
+ targettilt2 = 0;
+ tilt2 = 0;
+ } else if (animCurrent == staffspinhitreversalanim) {
+ targetyaw += 180;
+ yaw += 180;
+ targetheadyaw += 180;
+ targettilt2 = 0;
+ tilt2 = 0;
+ }
+ if (onterrain)
+ oldcoords.y = terrain.getHeight(oldcoords.x, oldcoords.z);
+ else
+ oldcoords.y = ycoords;
+ currentoffset = coords - oldcoords;
+ targetoffset = 0;
+ coords = oldcoords;
+
+ lastfeint = 0;
+ }
+ if (animCurrent == knifesneakattackedanim || animCurrent == swordsneakattackedanim) {
+ velocity = 0;
+ velocity.y = -5;
+ RagDoll(0);
+ }
+ if (animation[animTarget].attack == reversed) {
+ escapednum++;
+ if (animTarget == sweepreversedanim)
+ targetyaw += 90;
+ animTarget = backhandspringanim;
+ frameTarget = 2;
+ emit_sound_at(landsound, coords, 128);
+
+ if (animCurrent == upunchreversedanim || animCurrent == swordslashreversedanim) {
+ animTarget = rollanim;
+ frameTarget = 5;
+ oldcoords = coords;
+ coords += (DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position, 0, yaw, 0) + DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position, 0, yaw, 0)) / 2 * scale;
+ coords.y = oldcoords.y;
+ }
+ if (animCurrent == knifeslashreversedanim) {
+ animTarget = rollanim;
+ frameTarget = 0;
+ targetyaw += 90;
+ yaw += 90;
+ oldcoords = coords;
+ coords += (DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position, 0, yaw, 0) + DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position, 0, yaw, 0)) / 2 * scale;
+ coords.y = oldcoords.y;
+ }
+ }
+ if (wasFlip()) {
+ animTarget = jumpdownanim;
+ }
+ if (wasLanding())
+ animTarget = getIdle();
+ if (wasLandhard())
+ animTarget = getIdle();
+ if (animCurrent == spinkickanim || animCurrent == getupfrombackanim || animCurrent == getupfromfrontanim || animCurrent == lowkickanim) {
+ animTarget = getIdle();
+ oldcoords = coords;
+ coords += (DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position, 0, yaw, 0) + DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position, 0, yaw, 0)) / 2 * scale;
+ coords.y = oldcoords.y;
+ //coords+=DoRotation(animation[animCurrent].offset,0,yaw,0)*scale;
+ targetoffset.y = coords.y;
+ if (onterrain)
+ targetoffset.y = terrain.getHeight(coords.x, coords.z);
+ currentoffset = DoRotation(animation[animCurrent].offset * -1, 0, yaw, 0) * scale;
+ currentoffset.y -= (coords.y - targetoffset.y);
+ coords.y = targetoffset.y;
+ targetoffset = 0;
+ normalsupdatedelay = 0;
+ }
+ if (animCurrent == upunchanim) {
+ animTarget = getStop();
+ normalsupdatedelay = 0;
+ lastfeint = 0;
+ }
+ if (animCurrent == rabbitkickanim && animTarget != backflipanim) {
+ targetyaw = yaw;
+ bool hasstaff;
+ hasstaff = 0;
+ if (num_weapons > 0)
+ if (weapons[0].getType() == staff)
+ hasstaff = 1;
+ if (!hasstaff)
+ DoDamage(35);
+ RagDoll(0);
+ lastfeint = 0;
+ rabbitkickragdoll = 1;
+ }
+ if (animCurrent == rabbitkickreversedanim) {
+ if (!feint) {
+ velocity = 0;
+ velocity.y = -10;
+ //DoDamage(100);
+ RagDoll(0);
+ skeleton.spinny = 0;
+ SolidHitBonus(!id); // FIXME: tricky id
+ }
+ if (feint) {
+ escapednum++;
+ animTarget = rollanim;
+ coords += facing;
+ if (id == 0)
+ pause_sound(whooshsound);
+ }
+ lastfeint = 0;
+ }
+ if (animCurrent == rabbittackledbackanim || animCurrent == rabbittackledfrontanim) {
+ velocity = 0;
+ velocity.y = -10;
+ RagDoll(0);
+ skeleton.spinny = 0;
+ }
+ if (animCurrent == jumpreversedanim) {
+ if (!feint) {
+ velocity = 0;
+ velocity.y = -10;
+ //DoDamage(100);
+ RagDoll(0);
+ skeleton.spinny = 0;
+ SolidHitBonus(!id); // FIXME: tricky id
+ }
+ if (feint) {
+ escapednum++;
+ animTarget = rollanim;
+ coords += facing * 2;
+ if (id == 0)
+ pause_sound(whooshsound);
+ }
+ lastfeint = 0;
+ }
+
+ if (animation[animCurrent].attack == normalattack && !victim->skeleton.free && victim->animTarget != staggerbackhighanim && victim->animTarget != staggerbackhardanim && animTarget != winduppunchblockedanim && animTarget != blockhighleftanim && animTarget != swordslashparryanim && animTarget != swordslashparriedanim && animTarget != crouchstabanim && animTarget != swordgroundstabanim) {
+ animTarget = getupfromfrontanim;
+ lastfeint = 0;
+ } else if (animation[animCurrent].attack == normalattack) {
+ animTarget = getIdle();
+ lastfeint = 0;
+ }
+ if (animCurrent == blockhighleftanim && aitype != playercontrolled) {
+ animTarget = blockhighleftstrikeanim;
+ }
+ if (animCurrent == knifeslashstartanim || animCurrent == knifethrowanim || animCurrent == swordslashanim || animCurrent == staffhitanim || animCurrent == staffgroundsmashanim || animCurrent == staffspinhitanim) {
+ animTarget = getIdle();
+ lastfeint = 0;
+ }
+ if (animCurrent == spinkickanim && victim->skeleton.free) {
+ if (creature == rabbittype)
+ animTarget = fightidleanim;
+ }
+ }
+ target = 0;
+
+ if (isIdle() && !wasIdle())
+ normalsupdatedelay = 0;
+
+ if (animCurrent == jumpupanim && velocity.y < 0 && !isFlip()) {
+ animTarget = jumpdownanim;
+ }
+ }
+ if (!skeleton.free) {
+ oldtarget = target;
+ if (!transspeed && animation[animTarget].attack != 2 && animation[animTarget].attack != 3) {
+ if (!isRun() || !wasRun()) {
+ if (animation[animTarget].speed[frameTarget] > animation[animCurrent].speed[frameCurrent])
+ target += multiplier * animation[animTarget].speed[frameTarget] * speed * 2;
+ if (animation[animTarget].speed[frameTarget] <= animation[animCurrent].speed[frameCurrent])
+ target += multiplier * animation[animCurrent].speed[frameCurrent] * speed * 2;
+ }
+ if (isRun() && wasRun()) {
+ float tempspeed;
+ tempspeed = velspeed;
+ if (tempspeed < 10 * speedmult)
+ tempspeed = 10 * speedmult;
+ target += multiplier * animation[animTarget].speed[frameCurrent] * speed * 1.7 * tempspeed / (speed * 45 * scale);
+ }
+ } else if (transspeed)
+ target += multiplier * transspeed * speed * 2;
+ else {
+ if (!isRun() || !wasRun()) {
+ if (animation[animTarget].speed[frameTarget] > animation[animCurrent].speed[frameCurrent])
+ target += multiplier * animation[animTarget].speed[frameTarget] * 2;
+ if (animation[animTarget].speed[frameTarget] <= animation[animCurrent].speed[frameCurrent])
+ target += multiplier * animation[animCurrent].speed[frameCurrent] * 2;
+ }
+ }
+
+ if (animCurrent != animTarget)
+ target = (target + oldtarget) / 2;
+
+ if (target > 1) {
+ frameCurrent = frameTarget;
+ target = 1;
+ }
+ oldrot = rot;
+ rot = targetrot * target;
+ yaw += rot - oldrot;
+ if (target == 1) {
+ rot = 0;
+ oldrot = 0;
+ targetrot = 0;
+ }
+ if (animCurrent != oldanimCurrent || animTarget != oldanimTarget || ((frameCurrent != oldframeCurrent || frameTarget != oldframeTarget) && !calcrot)) {
+ //Old rotates
+ for (i = 0; i < skeleton.num_joints; i++) {
+ skeleton.joints[i].position = animation[animCurrent].position[i][frameCurrent];
+ }
+
+ skeleton.FindForwards();
+
+ for (i = 0; i < skeleton.num_muscles; i++) {
+ if (skeleton.muscles[i].visible) {
+ skeleton.FindRotationMuscle(i, animTarget);
+ }
+ }
+ for (i = 0; i < skeleton.num_muscles; i++) {
+ if (skeleton.muscles[i].visible) {
+ if (isnormal((float)((int)(skeleton.muscles[i].rotate1 * 100) % 36000) / 100))
+ skeleton.muscles[i].oldrotate1 = (float)((int)(skeleton.muscles[i].rotate1 * 100) % 36000) / 100;
+ if (isnormal((float)((int)(skeleton.muscles[i].rotate2 * 100) % 36000) / 100))
+ skeleton.muscles[i].oldrotate2 = (float)((int)(skeleton.muscles[i].rotate2 * 100) % 36000) / 100;
+ if (isnormal((float)((int)(skeleton.muscles[i].rotate3 * 100) % 36000) / 100))
+ skeleton.muscles[i].oldrotate3 = (float)((int)(skeleton.muscles[i].rotate3 * 100) % 36000) / 100;
+ }
+ }
+
+ //New rotates
+ for (i = 0; i < skeleton.num_joints; i++) {
+ skeleton.joints[i].position = animation[animTarget].position[i][frameTarget];
+ }
+
+ skeleton.FindForwards();
+
+ for (i = 0; i < skeleton.num_muscles; i++) {
+ if (skeleton.muscles[i].visible) {
+ skeleton.FindRotationMuscle(i, animTarget);
+ }
+ }
+ for (i = 0; i < skeleton.num_muscles; i++) {
+ if (skeleton.muscles[i].visible) {
+ if (isnormal((float)((int)(skeleton.muscles[i].rotate1 * 100) % 36000) / 100))
+ skeleton.muscles[i].newrotate1 = (float)((int)(skeleton.muscles[i].rotate1 * 100) % 36000) / 100;
+ if (isnormal((float)((int)(skeleton.muscles[i].rotate2 * 100) % 36000) / 100))
+ skeleton.muscles[i].newrotate2 = (float)((int)(skeleton.muscles[i].rotate2 * 100) % 36000) / 100;
+ if (isnormal((float)((int)(skeleton.muscles[i].rotate3 * 100) % 36000) / 100))
+ skeleton.muscles[i].newrotate3 = (float)((int)(skeleton.muscles[i].rotate3 * 100) % 36000) / 100;
+ if (skeleton.muscles[i].newrotate3 > skeleton.muscles[i].oldrotate3 + 180) skeleton.muscles[i].newrotate3 -= 360;
+ if (skeleton.muscles[i].newrotate3 < skeleton.muscles[i].oldrotate3 - 180) skeleton.muscles[i].newrotate3 += 360;
+ if (skeleton.muscles[i].newrotate2 > skeleton.muscles[i].oldrotate2 + 180) skeleton.muscles[i].newrotate2 -= 360;
+ if (skeleton.muscles[i].newrotate2 < skeleton.muscles[i].oldrotate2 - 180) skeleton.muscles[i].newrotate2 += 360;
+ if (skeleton.muscles[i].newrotate1 > skeleton.muscles[i].oldrotate1 + 180) skeleton.muscles[i].newrotate1 -= 360;
+ if (skeleton.muscles[i].newrotate1 < skeleton.muscles[i].oldrotate1 - 180) skeleton.muscles[i].newrotate1 += 360;
+ }
+ }
+ }
+ if (frameCurrent >= animation[animCurrent].numframes)
+ frameCurrent = animation[animCurrent].numframes - 1;
+
+ oldanimCurrent = animCurrent;
+ oldanimTarget = animTarget;
+ oldframeTarget = frameTarget;
+ oldframeCurrent = frameCurrent;
+
+ for (i = 0; i < skeleton.num_joints; i++) {
+ skeleton.joints[i].velocity = (animation[animCurrent].position[i][frameCurrent] * (1 - target) + animation[animTarget].position[i][frameTarget] * (target) - skeleton.joints[i].position) / multiplier;
+ skeleton.joints[i].position = animation[animCurrent].position[i][frameCurrent] * (1 - target) + animation[animTarget].position[i][frameTarget] * (target);
+ }
+ offset = currentoffset * (1 - target) + targetoffset * target;
+ for (i = 0; i < skeleton.num_muscles; i++) {
+ if (skeleton.muscles[i].visible) {
+ skeleton.muscles[i].rotate1 = skeleton.muscles[i].oldrotate1 * (1 - target) + skeleton.muscles[i].newrotate1 * (target);
+ skeleton.muscles[i].rotate2 = skeleton.muscles[i].oldrotate2 * (1 - target) + skeleton.muscles[i].newrotate2 * (target);
+ skeleton.muscles[i].rotate3 = skeleton.muscles[i].oldrotate3 * (1 - target) + skeleton.muscles[i].newrotate3 * (target);
+ }
+ }
+ }
+
+ if (isLanding() && landhard) {
+ if (id == 0)
+ camerashake += .4;
+ animTarget = getLandhard();
+ frameTarget = 0;
+ target = 0;
+ landhard = 0;
+ transspeed = 15;
+ }
+ }
+ //skeleton.DoConstraints();