-void Person::DoStuff(){
- static XYZ terrainnormal;
- static XYZ flatfacing;
- static XYZ flatvelocity;
- static float flatvelspeed;
- static int i,j,l;
- static XYZ average;
- static int howmany;
- static int bloodsize;
- static int startx,starty,endx,endy;
- static int texdetailint;
- static GLubyte color;
- static XYZ bloodvel;
-
- onfiredelay-=multiplier;
- if(onfiredelay<0&&onfire)
- {
- if(Random()%2==0){
- crouchkeydown=1;
- }
- onfiredelay=0.3;
- }
-
- crouchkeydowntime+=multiplier;
- if(!crouchkeydown)crouchkeydowntime=0;
- jumpkeydowntime+=multiplier;
- if(!jumpkeydown&&skeleton.free)jumpkeydowntime=0;
-
- if(hostile||damage>0||bloodloss>0)immobile=0;
-
- if(isIdle()||isRun())targetoffset=0;
-
- if(num_weapons==1&&weaponactive!=-1)weaponstuck=-1;
-
- if(id==0)blooddimamount-=multiplier*.3;
- speechdelay-=multiplier;
- texupdatedelay-=multiplier;
- interestdelay-=multiplier;
- flamedelay-=multiplier;
- parriedrecently-=multiplier;
- if(!victim){
- victim=this;
- hasvictim=0;
- }
-
- if(id==0)speed=1.1*speedmult;
- else speed=1.0*speedmult;
- if(!skeleton.free)rabbitkickragdoll=0;
-
- speed*=speedmult;
-
- if(id!=0&&(creature==rabbittype||difficulty!=2))superruntoggle=0;
- if(id!=0&&creature==wolftype&&difficulty==2){
- superruntoggle=0;
- if(aitype!=passivetype){
- superruntoggle=1;
- if(aitype==attacktypecutoff&&(player[0].isIdle()||player[0].isCrouch()||player[0].skeleton.free||player[0].targetanimation==getupfrombackanim||player[0].targetanimation==getupfromfrontanim||player[0].targetanimation==sneakanim)&&findDistancefast(&coords,&player[0].coords)<16){
- superruntoggle=0;
- }
- }
- if(scale<0.2)superruntoggle=0;
- if(targetanimation==wolfrunninganim&&!superruntoggle){
- targetanimation=getRun();
- targetframe=0;
- }
- }
- if(weaponactive==-1&&num_weapons>0){
- if(weapons.type[weaponids[0]]==staff){
- weaponactive=0;
- }
- }
-
- if(onfire){
- burnt+=multiplier;
- /*if(aitype!=playercontrolled)*///deathbleeding=5;
- /*if(aitype!=playercontrolled)*/
- deathbleeding=1;
- if(burnt>.6)burnt=.6;
- OPENAL_SetVolume(channels[stream_firesound], 256+256*findLength(&velocity)/3);
-
- if(targetanimation==jumpupanim||targetanimation==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);
- }
- }
- }
- while(flamedelay<0&&onfire){
- flamedelay+=.006;
- howmany=abs(Random()%(skeleton.num_joints));
- if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
- if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
- if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
- if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
- Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
- }
-
- while(flamedelay<0&&!onfire&&tutoriallevel==1&&id!=0){
- flamedelay+=.05;
- howmany=abs(Random()%(skeleton.num_joints));
- if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
- if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
- if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
- if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
- Sprite::MakeSprite(breathsprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, .3);
- }
-
- if(bleeding>0){
- bleeding-=multiplier*.3;
- if(bloodtoggle==2){
- glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
- if(bleeding<=0&&(detail!=2||osx))DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
- }
- }
-
- if(neckspurtamount>0){
- neckspurtamount-=multiplier;
- neckspurtdelay-=multiplier*3;
- neckspurtparticledelay-=multiplier*3;
- if(neckspurtparticledelay<0&&neckspurtdelay>2){
- spurt=0;
- bloodvel=0;
- if(!skeleton.free){
- bloodvel.z=5*neckspurtamount;
- bloodvel=DoRotation(bloodvel,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
- }
- if(skeleton.free){
- bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/40,((float)(Random()%100))/40,0);
- }
- if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
- if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/40,((float)(Random()%100))/40,0)*scale;
- if(skeleton.free)Sprite::MakeSprite(bloodsprite, (skeleton.joints[skeleton.jointlabels[neck]].position+(skeleton.joints[skeleton.jointlabels[neck]].position-skeleton.joints[skeleton.jointlabels[head]].position)/5)*scale+coords,bloodvel, 1,1,1, .05, .9);
- if(!skeleton.free)Sprite::MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position+(skeleton.joints[skeleton.jointlabels[neck]].position-skeleton.joints[skeleton.jointlabels[head]].position)/5,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, .9);
- neckspurtparticledelay=.05;
- }
- if(neckspurtdelay<0){
- neckspurtdelay=3;
- }
- }
-
- if(deathbleeding>0&&dead!=2){
- if(deathbleeding<5)bleeddelay-=deathbleeding*multiplier/4;
- else bleeddelay-=5*multiplier/4;
- if(bleeddelay<0&&bloodtoggle){
- bleeddelay=1;
- XYZ bloodvel;
- if(bloodtoggle){
- bloodvel=0;
- if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[abdomen]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
- if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
- if(skeleton.free)Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[abdomen]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
- if(!skeleton.free)Sprite::MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[abdomen]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
- }
- }
- bloodloss+=deathbleeding*multiplier*80;
- deathbleeding-=multiplier*1.6;
- //if(id==0)deathbleeding-=multiplier*.2;
- if(deathbleeding<0)deathbleeding=0;
- if(bloodloss>damagetolerance&&animation[targetanimation].attack==neutral){
- if(weaponactive!=-1){
- weapons.owner[weaponids[0]]=-1;
- weapons.velocity[weaponids[0]]=velocity*scale*-.3;
- weapons.velocity[weaponids[0]].x+=.01;
- weapons.tipvelocity[weaponids[0]]=velocity*scale;
- weapons.missed[weaponids[0]]=1;
- weapons.hitsomething[weaponids[0]]=0;
- weapons.freetime[weaponids[0]]=0;
- weapons.firstfree[weaponids[0]]=1;
- weapons.physics[weaponids[0]]=1;
- num_weapons--;
- if(num_weapons){
- weaponids[0]=weaponids[num_weapons];
- if(weaponstuck==num_weapons)weaponstuck=0;
- }
- weaponactive=-1;
- for(i=0;i<numplayers;i++){
- player[i].wentforweapon=0;
- }
-
- if(id==0){
- flashamount=.5;
- flashr=1;
- flashg=0;
- flashb=0;
- flashdelay=0;
- }
- }
-
- if(!dead&&creature==wolftype){
- award_bonus(0, Wolfbonus);
- }
- dead=2;
- if(targetanimation==knifefollowedanim&&!skeleton.free){
- for(i=0;i<skeleton.num_joints;i++){
- skeleton.joints[i].velocity=0;
- skeleton.joints[i].velocity.y=-2;
- }
- }
- if(id!=0&&unconscioustime>.1){
- numafterkill++;
- }
-
- RagDoll(0);
- }
- }
-
- if(texupdatedelay<0&&bleeding>0&&bloodtoggle==2&&findDistancefast(&viewer,&coords)<9){
- texupdatedelay=.12;
-
- bloodsize=5-realtexdetail;
-
- startx=0;
- starty=0;
- texdetailint=realtexdetail;
- startx=bleedy;//abs(Random()%(skeleton.skinsize-bloodsize-1));
- starty=bleedx;//abs(Random()%(skeleton.skinsize-bloodsize-1));
- endx=startx+bloodsize;
- endy=starty+bloodsize;
-
- if(startx<0){startx=0;bleeding=0;}
- if(starty<0){starty=0;bleeding=0;}
- if(endx>skeleton.skinsize-1){endx=skeleton.skinsize-1;bleeding=0;}
- if(endy>skeleton.skinsize-1){endy=skeleton.skinsize-1;bleeding=0;}
- if(endx<startx)endx=startx;
- if(endy<starty)endy=starty;
-
- for(i=startx;i<endx;i++){
- for(j=starty;j<endy;j++){
- if(Random()%2==0){
- color=Random()%85+170;
- if(skeleton.skinText[i*skeleton.skinsize*3+j*3+0]>color/2)skeleton.skinText[i*skeleton.skinsize*3+j*3+0]=color/2;
- skeleton.skinText[i*skeleton.skinsize*3+j*3+1]=0;
- skeleton.skinText[i*skeleton.skinsize*3+j*3+2]=0;
- }
- }
- }
- if(!osx&&detail>1){
- glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
- DoMipmaps(0,startx,endx,starty,endy);
- }
-
- if(!skeleton.free){
- bleedy-=4/realtexdetail;
- if(detail==2)bleedx+=(abs(Random()%3)-1)*2/realtexdetail;
- else bleedx+=(abs(Random()%3)-1)*4/realtexdetail;
- }
- if(skeleton.free){
- bleedx+=4*direction/realtexdetail;
- if(detail==2)bleedy+=(abs(Random()%3)-1)*2/realtexdetail;
- else bleedy+=(abs(Random()%3)-1)*4/realtexdetail;
- }
- }
-
- if(abs(righthandmorphness-targetrighthandmorphness)<multiplier*4){
- righthandmorphness=targetrighthandmorphness;
- righthandmorphstart=righthandmorphend;
- }
- else if(righthandmorphness>targetrighthandmorphness){
- righthandmorphness-=multiplier*4;
- }
- else if(righthandmorphness<targetrighthandmorphness){
- righthandmorphness+=multiplier*4;
- }
-
- if(abs(lefthandmorphness-targetlefthandmorphness)<multiplier*4){
- lefthandmorphness=targetlefthandmorphness;
- lefthandmorphstart=lefthandmorphend;
- }
- else if(lefthandmorphness>targetlefthandmorphness){
- lefthandmorphness-=multiplier*4;
- }
- else if(lefthandmorphness<targetlefthandmorphness){
- lefthandmorphness+=multiplier*4;
- }
-
- if(creature==rabbittype||targettailmorphness==5||targettailmorphness==0){
- if(abs(tailmorphness-targettailmorphness)<multiplier*10){
- tailmorphness=targettailmorphness;
- tailmorphstart=tailmorphend;
- }
- else if(tailmorphness>targettailmorphness){
- tailmorphness-=multiplier*10;
- }
- else if(tailmorphness<targettailmorphness){
- tailmorphness+=multiplier*10;
- }
- }
-
- if(creature==wolftype){
- if(abs(tailmorphness-targettailmorphness)<multiplier*4){
- tailmorphness=targettailmorphness;
- tailmorphstart=tailmorphend;
- }
- else if(tailmorphness>targettailmorphness){
- tailmorphness-=multiplier*2;
- }
- else if(tailmorphness<targettailmorphness){
- tailmorphness+=multiplier*2;
- }
- }
-
- if(headmorphend==3||headmorphstart==3){
- if(abs(headmorphness-targetheadmorphness)<multiplier*7){
- headmorphness=targetheadmorphness;
- headmorphstart=headmorphend;
- }
- else if(headmorphness>targetheadmorphness){
- headmorphness-=multiplier*7;
- }
- else if(headmorphness<targetheadmorphness){
- headmorphness+=multiplier*7;
- }
- }
- else if(headmorphend==5||headmorphstart==5){
- if(abs(headmorphness-targetheadmorphness)<multiplier*10){
- headmorphness=targetheadmorphness;
- headmorphstart=headmorphend;
- }
- else if(headmorphness>targetheadmorphness){
- headmorphness-=multiplier*10;
- }
- else if(headmorphness<targetheadmorphness){
- headmorphness+=multiplier*10;
- }
- }
- else{
- if(abs(headmorphness-targetheadmorphness)<multiplier*4){
- headmorphness=targetheadmorphness;
- headmorphstart=headmorphend;
- }
- else if(headmorphness>targetheadmorphness){
- headmorphness-=multiplier*4;
- }
- else if(headmorphness<targetheadmorphness){
- headmorphness+=multiplier*4;
- }
- }
-
- if(abs(chestmorphness-targetchestmorphness)<multiplier){
- chestmorphness=targetchestmorphness;
- chestmorphstart=chestmorphend;
- }
- else if(chestmorphness>targetchestmorphness){
- chestmorphness-=multiplier;
- }
- else if(chestmorphness<targetchestmorphness){
- chestmorphness+=multiplier;
- }
-
- if(dead!=2&&howactive<=typesleeping){
- if(chestmorphstart==0&&chestmorphend==0){
- chestmorphness=0;
- targetchestmorphness=1;
- chestmorphend=3;
- }
- if(chestmorphstart!=0&&chestmorphend!=0){
- chestmorphness=0;
- targetchestmorphness=1;
- chestmorphend=0;
- if(environment==snowyenvironment){
- XYZ footpoint;
- XYZ footvel;
- if(!skeleton.free)footvel=DoRotation(skeleton.specialforward[0],0,rotation,0)*-1;
- if(skeleton.free)footvel=skeleton.specialforward[0]*-1;
- if(!skeleton.free)footpoint=DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords;
- if(skeleton.free)footpoint=((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2)*scale+coords;
- if(targetanimation==sleepanim)footvel=DoRotation(footvel,0,90,0);
- Sprite::MakeSprite(breathsprite, footpoint+footvel*.2,footvel*.4, 1,1,1, .4, .3);
- }
- }
-
- if(!dead&&howactive<typesleeping){
- blinkdelay-=multiplier*2;
- if(headmorphstart==0&&headmorphend==0&&blinkdelay<=0){
- headmorphness=0;
- targetheadmorphness=1;
- headmorphend=3;
- blinkdelay=(float)(abs(Random()%40))/5;
- }
- if(headmorphstart==3&&headmorphend==3){
- headmorphness=0;
- targetheadmorphness=1;
- headmorphend=0;
- }
- }
- if(!dead){
- twitchdelay-=multiplier*1.5;
- if(targetanimation!=hurtidleanim){
- if(headmorphstart==0&&headmorphend==0&&twitchdelay<=0){
- headmorphness=0;
- targetheadmorphness=1;
- headmorphend=5;
- twitchdelay=(float)(abs(Random()%40))/5;
- }
- if(headmorphstart==5&&headmorphend==5){
- headmorphness=0;
- targetheadmorphness=1;
- headmorphend=0;
- }
- }
- if((isIdle()||isCrouch())&&targetanimation!=hurtidleanim){
- twitchdelay3-=multiplier*1;
- if(Random()%2==0){
- if(righthandmorphstart==0&&righthandmorphend==0&&twitchdelay3<=0){
- righthandmorphness=0;
- targetrighthandmorphness=1;
- righthandmorphend=1;
- if(Random()%2==0)twitchdelay3=(float)(abs(Random()%40))/5;
- }
- if(righthandmorphstart==1&&righthandmorphend==1){
- righthandmorphness=0;
- targetrighthandmorphness=1;
- righthandmorphend=0;
- }
- }
- if(Random()%2==0){
- if(lefthandmorphstart==0&&lefthandmorphend==0&&twitchdelay3<=0){
- lefthandmorphness=0;
- targetlefthandmorphness=1;
- lefthandmorphend=1;
- twitchdelay3=(float)(abs(Random()%40))/5;
- }
- if(lefthandmorphstart==1&&lefthandmorphend==1){
- lefthandmorphness=0;
- targetlefthandmorphness=1;
- lefthandmorphend=0;
- }
- }
- }
- }
- if(!dead){
- if(creature==rabbittype){
- if(howactive<typesleeping)twitchdelay2-=multiplier*1.5;
- else twitchdelay2-=multiplier*0.5;
- if(howactive<=typesleeping){
- if(tailmorphstart==0&&tailmorphend==0&&twitchdelay2<=0){
- tailmorphness=0;
- targettailmorphness=1;
- tailmorphend=1;
- twitchdelay2=(float)(abs(Random()%40))/5;
- }
- if(tailmorphstart==1&&tailmorphend==1){
- tailmorphness=0;
- targettailmorphness=1;
- tailmorphend=2;
- }
- if(tailmorphstart==2&&tailmorphend==2){
- tailmorphness=0;
- targettailmorphness=1;
- tailmorphend=0;
- }
- }
- }
- }
- }
- if(creature==wolftype){
- twitchdelay2-=multiplier*1.5;
- if(tailmorphend!=0)
- if((isRun()||targetanimation==jumpupanim||targetanimation==jumpdownanim||targetanimation==backflipanim)&&!skeleton.free){
- tailmorphness=0;
- targettailmorphness=1;
- tailmorphend=0;
- twitchdelay2=.1;
- }
- if(tailmorphend!=5)
- if(targetanimation==flipanim||targetanimation==frontflipanim||targetanimation==rollanim||skeleton.free){
- tailmorphness=0;
- targettailmorphness=1;
- tailmorphend=5;
- twitchdelay2=.1;
- }
- if(twitchdelay2<=0){
- if(((tailmorphstart==0&&tailmorphend==0)||(tailmorphstart==5&&tailmorphend==5))){
- tailmorphness=0;
- targettailmorphness=1;
- tailmorphend=1;
- }
- if(tailmorphstart==1&&tailmorphend==1){
- tailmorphness=0;
- targettailmorphness=1;
- tailmorphend=2;
- }
- if(tailmorphstart==2&&tailmorphend==2){
- tailmorphness=0;
- targettailmorphness=1;
- tailmorphend=3;
- }
- if(tailmorphstart==3&&tailmorphend==3){
- tailmorphness=0;
- targettailmorphness=1;
- tailmorphend=4;
- }
- if(tailmorphstart==4&&tailmorphend==4){
- tailmorphness=0;
- targettailmorphness=1;
- tailmorphend=1;
- }
- }
- }
-
- if(dead!=1)unconscioustime=0;
-
- if(dead==1||howactive==typesleeping){
- unconscioustime+=multiplier;
- //If unconscious, close eyes and mouth
- if(righthandmorphend!=0)righthandmorphness=0;
- righthandmorphend=0;
- targetrighthandmorphness=1;
-
- if(lefthandmorphend!=0)lefthandmorphness=0;
- lefthandmorphend=0;
- targetlefthandmorphness=1;
-
- if(headmorphend!=3&&headmorphend!=5)headmorphness=0;
- headmorphend=3;
- targetheadmorphness=1;
- }
-
-
- if(howactive>typesleeping){
- XYZ headpoint;
- headpoint=coords;
- if(bloodtoggle&&!bled){
- terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
- }
- if(bloodtoggle&&!bled)
- for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
- j=terrain.patchobjects[whichpatchx][whichpatchz][l];
- XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
- float size=.8;
- float opacity=.6;
- float rotation=0;
- objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
- }
- bled=1;
- }
-
- if(dead==2||howactive>typesleeping){
- //If dead, open mouth and hands
- if(righthandmorphend!=0)righthandmorphness=0;
- righthandmorphend=0;
- targetrighthandmorphness=1;
-
- if(lefthandmorphend!=0)lefthandmorphness=0;
- lefthandmorphend=0;
- targetlefthandmorphness=1;
-
- if(headmorphend!=2)headmorphness=0;
- headmorphend=2;
- targetheadmorphness=1;
- }
-
- if(stunned>0&&!dead&&headmorphend!=2){
- if(headmorphend!=4)headmorphness=0;
- headmorphend=4;
- targetheadmorphness=1;
- }
-
- if(damage>damagetolerance&&!dead){
-
- dead=1;
- unconscioustime=0;
-
- if(creature==wolftype){
- award_bonus(0, Wolfbonus);
- }
-
- RagDoll(0);
-
- if(weaponactive!=-1){
- weapons.owner[weaponids[0]]=-1;
- weapons.velocity[weaponids[0]]=velocity*scale*-.3;
- weapons.velocity[weaponids[0]].x+=.01;
- weapons.tipvelocity[weaponids[0]]=velocity*scale;
- weapons.missed[weaponids[0]]=1;
- weapons.hitsomething[weaponids[0]]=0;
- weapons.freetime[weaponids[0]]=0;
- weapons.firstfree[weaponids[0]]=1;
- weapons.physics[weaponids[0]]=1;
- num_weapons--;
- if(num_weapons){
- weaponids[0]=weaponids[num_weapons];
- if(weaponstuck==num_weapons)weaponstuck=0;
- }
- weaponactive=-1;
- for(i=0;i<numplayers;i++){
- player[i].wentforweapon=0;
- }
- }
-
-
-
- if((id==0||findDistancefast(&coords,&viewer)<50)&&autoslomo){
- slomo=1;
- slomodelay=.2;
- }
-
- damage+=20;
- }
-
- //if(dead)damage-=multiplier/4;
- if(!dead)damage-=multiplier*13;
- //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
- if(!dead)permanentdamage-=multiplier*4;
- if(isIdle()||isCrouch()){
- if(!dead)permanentdamage-=multiplier*4;
- //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
- }
- if(damage<0)damage=0;
- if(permanentdamage<0)permanentdamage=0;
- if(superpermanentdamage<0)superpermanentdamage=0;
- if(permanentdamage<superpermanentdamage){
- permanentdamage=superpermanentdamage;
- }
- if(damage<permanentdamage){
- damage=permanentdamage;
- }
- if(dead==1&&damage<damagetolerance){
- dead=0;
- skeleton.free=1;
- damage-=20;
- for(i=0;i<skeleton.num_joints;i++){
- skeleton.joints[i].velocity=0;
- }
- }
- if(permanentdamage>damagetolerance&&dead!=2){
- DoBlood(1,255);
-
- if(weaponactive!=-1){
- weapons.owner[weaponids[0]]=-1;
- weapons.velocity[weaponids[0]]=velocity*scale*-.3;
- weapons.velocity[weaponids[0]].x+=.01;
- weapons.tipvelocity[weaponids[0]]=velocity*scale;
- weapons.missed[weaponids[0]]=1;
- weapons.hitsomething[weaponids[0]]=0;
- weapons.freetime[weaponids[0]]=0;
- weapons.firstfree[weaponids[0]]=1;
- weapons.physics[weaponids[0]]=1;
- num_weapons--;
- if(num_weapons){
- weaponids[0]=weaponids[num_weapons];
- if(weaponstuck==num_weapons)weaponstuck=0;
- }
- weaponactive=-1;
- for(i=0;i<numplayers;i++){
- player[i].wentforweapon=0;
- }
- }
-
- bled=0;
-
- if(!dead&&creature==wolftype){
- award_bonus(0, Wolfbonus);
- }
-
- if(unconscioustime<.1&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=FinishedBonus||bonustime>1)&&bloodloss<damagetolerance)
- award_bonus(id, touchofdeath);
- if(id!=0&&unconscioustime>.1){
- numafterkill++;
- }
-
- dead=2;
-
- skeleton.free=1;
-
- emit_sound_at(breaksound, coords);
- /*if(id==0||findDistancefast(&coords,&viewer)<50){
- slomo=1;
- slomodelay=.2;
- }*/
- }
-
- if(skeleton.free==1){
- if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
-
- if(!dead){
- //If knocked over, open hands and close mouth
- if(righthandmorphend!=0)righthandmorphness=0;
- righthandmorphend=0;
- targetrighthandmorphness=1;
-
- if(lefthandmorphend!=0)lefthandmorphness=0;
- lefthandmorphend=0;
- targetlefthandmorphness=1;
-
- if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5){
- if(headmorphend!=0)headmorphness=0;
- headmorphend=0;
- targetheadmorphness=1;
- }
- }
-
- skeleton.DoGravity(&scale);
- float damageamount;
- damageamount=skeleton.DoConstraints(&coords,&scale)*5;
- if(damage>damagetolerance-damageamount&&!dead&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=style||bonustime>1)&&(bonus!=cannon||bonustime>1))
- award_bonus(id, deepimpact);
- DoDamage(damageamount/((protectionhigh+protectionhead+protectionlow)/3));
-
- average=0;
- howmany=0;
- for(j=0;j<skeleton.num_joints;j++){
- average+=skeleton.joints[j].position;
- howmany++;
- }
- average/=howmany;
- coords+=average*scale;
- for(j=0;j<skeleton.num_joints;j++){
- skeleton.joints[j].position-=average;
- }
- average/=multiplier;
-
- //velocity=skeleton.joints[skeleton.jointlabels[groin]].velocity*scale;
- velocity=0;
- for(i=0;i<skeleton.num_joints;i++){
- velocity+=skeleton.joints[i].velocity*scale;
- }
- velocity/=skeleton.num_joints;
-
- if(!isnormal(velocity.x)&&velocity.x){
- velocity=0;
- }
-
- 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(findLength(&average)<10&&dead&&skeleton.free){
- skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
- if(skeleton.longdead>2000){
- if(skeleton.longdead>6000){
- if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
- skeleton.free=3;
- DrawSkeleton();
- skeleton.free=2;
- }
- if(dead==2&&bloodloss<damagetolerance){
- XYZ headpoint;
- headpoint=(skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
- DoBlood(1,255);
- if(bloodtoggle&&!bled){
- terrain.MakeDecal(blooddecal,headpoint,.2*1.2,.5,0);
- }
- if(bloodtoggle&&!bled)
- for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
- j=terrain.patchobjects[whichpatchx][whichpatchz][l];
- XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
- float size=.2*1.2;
- float opacity=.6;
- float rotation=0;
- objects.model[j].MakeDecal(blooddecal,&point,&size,&opacity,&rotation);
- }
- bled=1;
- }
- if(dead==2&&bloodloss>=damagetolerance){
- XYZ headpoint;
- headpoint=(skeleton.joints[skeleton.jointlabels[abdomen]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
- if(bleeding<=0)DoBlood(1,255);
- if(bloodtoggle&&!bled){
- terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
- }
- if(bloodtoggle&&!bled)
- for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
- j=terrain.patchobjects[whichpatchx][whichpatchz][l];
- XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
- float size=.8;
- float opacity=.6;
- float rotation=0;
- objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
- }
- bled=1;
- }
- }
- }
-
- if(!dead&&crouchkeydown&&skeleton.freetime>.5&&id==0&&skeleton.free){
- bool canrecover=1;
- XYZ startpoint,endpoint,colpoint,colviewer,coltarget;
- startpoint=coords;
- endpoint=coords;
- endpoint.y-=.7;
- if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)canrecover=0;
- if(velocity.y<-30)canrecover=0;
- for(i=0;i<objects.numobjects;i++){
- if(objects.type[i]!=treeleavestype&&objects.type[i]!=bushtype&&objects.type[i]!=firetype){
- colviewer=startpoint;
- coltarget=endpoint;
- if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)canrecover=0;
- }
- }
- if(canrecover){
- skeleton.free=0;
- XYZ middle;
- middle=0;
-
- terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
- if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
- terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
- middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
- }
- if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
- terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
- middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
- }
- if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
- terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
- middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
- }
- Normalise(&terrainnormal);
-
- targetrotation=-asin(0-terrainnormal.x);
- targetrotation*=360/6.28;
- if(terrainnormal.z<0)targetrotation=180-targetrotation;
- rotation=targetrotation;
-
- targetframe=0;
- // targetframe=2;
- targetanimation=flipanim;
- crouchtogglekeydown=1;
- target=0;
- tilt2=0;
- targettilt2=0;
-
- currentanimation=tempanim;
- currentframe=0;
- target=0;
- //tilt2=targettilt2;
-
- //if(middle.y>0)targetoffset.y=middle.y+1;
-
- for(i=0;i<skeleton.num_joints;i++){
- tempanimation.position[i][0]=skeleton.joints[i].position;
- tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
- }
- }
- }
-
- if(findLength(&average)<10&&!dead&&skeleton.free){
- skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
- if(skeleton.longdead>(damage+500)*1.5){
- if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
- skeleton.free=0;
- velocity=0;
- XYZ middle;
- middle=0;
-
- terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
- if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
- terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
- middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
- }
- if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
- terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
- middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
- }
- if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
- terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
- middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
- }
- Normalise(&terrainnormal);
-
- targetrotation=-asin(0-terrainnormal.x);
- targetrotation*=360/6.28;
- if(terrainnormal.z<0)targetrotation=180-targetrotation;
- rotation=targetrotation;
-
- /*if(onterrain){
- terrainnormal=terrain.getNormal(coords.x,coords.z);
- targettilt2=asin(terrainnormal.y)*180/3.14*-1;
- }
- else*/
-
- /*XYZ otherterrainnormal;
- otherterrainnormal=terrain.getNormal(coords.x,coords.y);
- otherterrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
- if(abs(terrainnormal.y)<abs(otherterrainnormal.y))terrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
- targettilt2=asin(otherterrainnormal.y)*180/3.14;
- */
-
- targettilt2=asin(terrainnormal.y)*180/3.14*-1;
-
-
-
- if(skeleton.forward.y<0){
- targetanimation=getupfrombackanim;
- targetframe=0;
- targettilt2=0;
- }
- if(skeleton.forward.y>-.3){
- targetanimation=getupfromfrontanim;
- rotation+=180;
- targetrotation+=180;
- targettilt2*=-1;
- targetframe=0;
- targettilt2=0;
- }
-
- if((Random()%8==0&&id!=0&&creature==rabbittype)||(Random()%2==0&&id!=0&&creature==wolftype)||(id==0&&crouchkeydown&&(forwardkeydown||backkeydown||leftkeydown||rightkeydown))){
- targetanimation=rollanim;
- targetrotation=lookrotation;
- if(id==0){
- if(rightkeydown){
- targetrotation-=90;
- if(forwardkeydown)targetrotation+=45;
- if(backkeydown)targetrotation-=45;
- }
- if(leftkeydown){
- targetrotation+=90;
- if(forwardkeydown)targetrotation-=45;
- if(backkeydown)targetrotation+=45;
- }
- if(backkeydown){
- if ( !leftkeydown&&!rightkeydown)
- targetrotation+=180;
- }
- targetrotation+=180;
- }
- }
-
- if(abs(targettilt2)>50)targettilt2=0;
- currentanimation=tempanim;
- currentframe=0;
- target=0;
- tilt2=targettilt2;
-
- if(middle.y>0&&targetanimation!=rollanim)targetoffset.y=middle.y+1;
-
- for(i=0;i<skeleton.num_joints;i++){
- tempanimation.position[i][0]=skeleton.joints[i].position;
- tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
- }
- }
- }
-
- bool hasstaff;
- hasstaff=0;
- if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
- if(!skeleton.freefall&&freefall&&((jumpkeydown&&jumpkeydowntime<.2)||(hasstaff&&rabbitkickragdoll))&&!dead){
- if(velocity.y>-30){
- XYZ tempvelocity;
- tempvelocity=velocity;
- Normalise(&tempvelocity);
- targetrotation=-asin(0-tempvelocity.x);
- targetrotation*=360/6.28;
- if(velocity.z<0)targetrotation=180-targetrotation;
- //targetrotation+=180;
-
- skeleton.free=0;
- if(dotproduct(&skeleton.forward,&tempvelocity)<0){
- targetanimation=rollanim;
- targetframe=2;
- }
- else{
- targetanimation=backhandspringanim;
- targetrotation+=180;
- targetframe=6;
- }
- target=0;
-
- emit_sound_at(movewhooshsound, coords, 128.);
-
- currentanimation=targetanimation;
- currentframe=targetframe-1;
- target=0;
-
- velocity=0;
-
- rotation=targetrotation;
- tilt=0;
- targettilt=0;
- tilt2=0;
- targettilt2=0;
- }
- }
- if(skeleton.freefall==0)freefall=0;
-
- if(!isnormal(velocity.x)&&velocity.x){
- int xy=1;
- }
- }
-
- if(aitype!=passivetype||skeleton.free==1)
- if(findLengthfast(&velocity)>.1)
- for(i=0;i<objects.numobjects;i++){
- if(objects.type[i]==firetype)
- if(findDistancefastflat(&coords,&objects.position[i])<objects.scale[i]*objects.scale[i]*12&&findDistancefast(&coords,&objects.position[i])<objects.scale[i]*objects.scale[i]*49){
- if(onfire){
- if(!objects.onfire[i]){
- emit_sound_at(firestartsound, objects.position[i]);
- }
- objects.onfire[i]=1;
- }
- if(!onfire){
- if(objects.onfire[i]){
- CatchFire();
- }
- }
- }
- if(objects.type[i]==bushtype)
- if(findDistancefastflat(&coords,&objects.position[i])<objects.scale[i]*objects.scale[i]*12&&findDistancefast(&coords,&objects.position[i])<objects.scale[i]*objects.scale[i]*49){
- if(onfire){
- if(!objects.onfire[i]){
- emit_sound_at(firestartsound, objects.position[i]);
- }
- objects.onfire[i]=1;
- }
-
- if(!onfire){
- if(objects.onfire[i]){
- CatchFire();
- }
- }
- if(objects.messedwith[i]<=0){
- XYZ tempvel;
- XYZ pos;
-
- emit_sound_at(bushrustle, coords, 40*findLength(&velocity));
-
- if(id==0){
- envsound[numenvsounds]=coords;
- envsoundvol[numenvsounds]=4*findLength(&velocity);
- envsoundlife[numenvsounds]=.4;
- numenvsounds++;
- }
-
- int howmany;
- if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
- if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
- if(detail==2)
- if(environment!=desertenvironment)
- for(j=0;j<howmany;j++){
- tempvel.x=float(abs(Random()%100)-50)/20;
- tempvel.y=float(abs(Random()%100)-50)/20;
- tempvel.z=float(abs(Random()%100)-50)/20;
- pos=coords;
- pos.y+=1;
- pos.x+=float(abs(Random()%100)-50)/200;
- pos.y+=float(abs(Random()%100)-50)/200;
- pos.z+=float(abs(Random()%100)-50)/200;
- Sprite::MakeSprite(splintersprite, pos,tempvel*.5+velocity*float(abs(Random()%100))/100, 165/255+float(abs(Random()%100)-50)/400,0,0, .2+float(abs(Random()%100)-50)/1300, 1);
- Sprite::setLastSpriteSpecial(1);
- }
- howmany=findLength(&velocity)*4;
- if(detail==2)
- if(environment==snowyenvironment)
- for(j=0;j<howmany;j++){
- tempvel.x=float(abs(Random()%100)-50)/20;
- tempvel.y=float(abs(Random()%100)-50)/20;
- tempvel.z=float(abs(Random()%100)-50)/20;
- pos=coords;
- pos.y+=1;
- pos.x+=float(abs(Random()%100)-50)/200;
- pos.y+=float(abs(Random()%100)-50)/200;
- pos.z+=float(abs(Random()%100)-50)/200;
- Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
- Sprite::setLastSpriteSpecial(2);
- }
- }
- objects.rotx[i]+=velocity.x*multiplier*6;
- objects.roty[i]+=velocity.z*multiplier*6;
- objects.messedwith[i]=.5;
- }
- XYZ tempcoord;
- if(objects.type[i]==treeleavestype&&environment!=desertenvironment){
- if(objects.rotation2[i]==0)tempcoord=coords;
- else{
- tempcoord=coords-objects.position[i];
- tempcoord=DoRotation(tempcoord,0,-objects.rotation[i],0);
- tempcoord=DoRotation(tempcoord,-objects.rotation2[i],0,0);
- tempcoord+=objects.position[i];
- }
- if(findDistancefastflat(&tempcoord,&objects.position[i])<objects.scale[i]*objects.scale[i]*8&&findDistancefast(&tempcoord,&objects.position[i])<objects.scale[i]*objects.scale[i]*300&&tempcoord.y>objects.position[i].y+3*objects.scale[i]){
- if(objects.messedwith[i]<=0){
- XYZ tempvel;
- XYZ pos;
-
- emit_sound_at(bushrustle, coords, 40*findLength(&velocity));
-
- if(id==0){
- envsound[numenvsounds]=coords;
- envsoundvol[numenvsounds]=4*findLength(&velocity);
- envsoundlife[numenvsounds]=.4;
- numenvsounds++;
- }
-
- int howmany;
- if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
- if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
- if(detail==2)
- if(environment!=desertenvironment)
- for(j=0;j<howmany;j++){
- tempvel.x=float(abs(Random()%100)-50)/20;
- tempvel.y=float(abs(Random()%100)-50)/20;
- tempvel.z=float(abs(Random()%100)-50)/20;
- pos=coords;
- pos+=velocity*.1;
- pos.y+=1;
- pos.x+=float(abs(Random()%100)-50)/150;
- pos.y+=float(abs(Random()%100)-50)/150;
- pos.z+=float(abs(Random()%100)-50)/150;
- Sprite::MakeSprite(splintersprite, pos,tempvel*.5+velocity*float(abs(Random()%100))/100, 165/255+float(abs(Random()%100)-50)/400,0,0, .2+float(abs(Random()%100)-50)/1300, 1);
- Sprite::setLastSpriteSpecial(1);
- }
- howmany=findLength(&velocity)*4;
- if(detail==2)
- if(environment==snowyenvironment)
- for(j=0;j<howmany;j++){
- tempvel.x=float(abs(Random()%100)-50)/20;
- tempvel.y=float(abs(Random()%100)-50)/20;
- tempvel.z=float(abs(Random()%100)-50)/20;
- pos=coords;
- pos+=velocity*.1;
- pos.y+=1;
- pos.x+=float(abs(Random()%100)-50)/150;
- pos.y+=float(abs(Random()%100)-50)/150;
- pos.z+=float(abs(Random()%100)-50)/150;
- Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
- Sprite::setLastSpriteSpecial(2);
- }
- }
- objects.messedwith[i]=.5;
- }
- }
- }
-
- if(!skeleton.free){
- bool play;
- play=0;
- if((stunned>0||surprised>0)&&numplayers>2&&aitype!=passivetype)play=1;
- if(hasvictim)
- if(aitype!=passivetype&&victim->skeleton.free&&!victim->dead)play=1;
- if(tutoriallevel==1&&id!=0)play=0;
- if(play&&aitype!=playercontrolled){
- int whichsound=-1;
- i=abs(Random()%4);
- if(speechdelay<=0){
- if(creature==rabbittype){
- if(i==0)whichsound=rabbitchitter;
- if(i==1)whichsound=rabbitchitter2;
- }
- if(creature==wolftype){
- if(i==0)whichsound=growlsound;
- if(i==1)whichsound=growl2sound;
- }
- }
- speechdelay=.3;
-
- if(whichsound!=-1){
- emit_sound_at(whichsound, coords);
- }
- }
-
- if(targetanimation==staggerbackhighanim)staggerdelay=1;
- if(targetanimation==staggerbackhardanim)staggerdelay=1;
- staggerdelay-=multiplier;
- if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)hasvictim=1;
- if(velocity.y<-30&&targetanimation==jumpdownanim)RagDoll(0);
- if(currentanimation!=getIdle()&&wasIdle()&&targetanimation!=getIdle()&&isIdle()){
- targetanimation=getIdle();
- targetframe=0;
- target=0;
- }
- weaponmissdelay-=multiplier;
- highreversaldelay-=multiplier;
- lowreversaldelay-=multiplier;
- lastcollide-=multiplier;
- skiddelay-=multiplier;
- if(!isnormal(velocity.x)&&velocity.x){
- velocity=0;
- }
- if(!isnormal(targettilt)&&targettilt){
- targettilt=0;
- }
- if(!isnormal(targettilt2)&&targettilt2){
- targettilt2=0;
- }
- if(!isnormal(targetrotation)&&targetrotation){
- targetrotation=0;
- }
-
- if(targetanimation==bounceidleanim||targetanimation==wolfidle||targetanimation==walkanim||targetanimation==drawrightanim||targetanimation==crouchdrawrightanim||targetanimation==drawleftanim||targetanimation==fightidleanim||targetanimation==fightsidestep||targetanimation==hanganim||isCrouch()||targetanimation==backhandspringanim){
- //open hands and close mouth
- if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
- righthandmorphness=0;
- righthandmorphend=0;
- targetrighthandmorphness=1;
- }
-
- if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
- lefthandmorphness=0;
- lefthandmorphend=0;
- targetlefthandmorphness=1;
- }
-
- if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5&&headmorphend!=0&&headmorphness==targetheadmorphness){
- headmorphness=0;
- headmorphend=0;
- targetheadmorphness=1;
- }
- }
-
- if(targetanimation==rollanim||targetanimation==dodgebackanim||targetanimation==removeknifeanim||targetanimation==knifefightidleanim||targetanimation==swordfightidleanim||targetanimation==blockhighleftstrikeanim||targetanimation==crouchremoveknifeanim||targetanimation==sneakanim||targetanimation==sweepanim||targetanimation==spinkickreversedanim||targetanimation==jumpdownanim||isWallJump()||isFlip()||targetanimation==climbanim||isRun()||targetanimation==getupfrombackanim||targetanimation==getupfromfrontanim){
- //open hands and mouth
- if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
- righthandmorphness=0;
- righthandmorphend=0;
- targetrighthandmorphness=1;
- }
-
- if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
- lefthandmorphness=0;
- lefthandmorphend=0;
- targetlefthandmorphness=1;
- }
-
- if(headmorphend!=1&&headmorphness==targetheadmorphness){
- headmorphness=0;
- headmorphend=1;
- targetheadmorphness=1;
- }
- }
-
- if(targetanimation==jumpupanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==swordfightidlebothanim||targetanimation==blockhighleftanim||targetanimation==blockhighleftanim){
- //close hands and mouth
- if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
- righthandmorphness=0;
- righthandmorphend=1;
- targetrighthandmorphness=1;
- }
-
- if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
- lefthandmorphness=0;
- lefthandmorphend=1;
- targetlefthandmorphness=1;
- }
-
- if(headmorphend!=0&&headmorphness==targetheadmorphness){
- headmorphness=0;
- headmorphend=0;
- targetheadmorphness=1;
- }
- }
-
- if(targetanimation==spinkickanim||targetanimation==staffspinhitreversalanim||targetanimation==staffspinhitreversedanim||targetanimation==staffhitreversalanim||targetanimation==staffhitreversedanim||targetanimation==hurtidleanim||targetanimation==winduppunchanim||targetanimation==swordslashreversalanim||targetanimation==swordslashreversedanim||targetanimation==knifeslashreversalanim||targetanimation==knifeslashreversedanim||targetanimation==knifethrowanim||targetanimation==knifefollowanim||targetanimation==knifefollowedanim||targetanimation==killanim||targetanimation==dropkickanim||targetanimation==upunchanim||targetanimation==knifeslashstartanim||targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim||targetanimation==staffgroundsmashanim||targetanimation==spinkickreversalanim||targetanimation==sweepreversalanim||targetanimation==lowkickanim||targetanimation==sweepreversedanim||targetanimation==rabbitkickreversalanim||targetanimation==rabbitkickreversedanim||targetanimation==jumpreversalanim||targetanimation==jumpreversedanim){
- //close hands and yell
- if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
- righthandmorphness=0;
- righthandmorphend=1;
- targetrighthandmorphness=1;
- }
-
- if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
- lefthandmorphness=0;
- lefthandmorphend=1;
- targetlefthandmorphness=1;
- }
-
- if(headmorphend!=2&&headmorphness==targetheadmorphness){
- headmorphness=1;
- headmorphend=2;
- targetheadmorphness=1;
- }
- }
- /*
- if(speechdelay>.25){
- if(headmorphend!=2)headmorphness=0;
- headmorphend=2;
- targetheadmorphness=1;
- }
- */
- bool behind;
- behind=0;
- if(hasvictim){
- if(victim!=this&&!victim->dead&&victim->aitype!=passivetype&&victim->aitype!=searchtype&&aitype!=passivetype&&aitype!=searchtype&&victim->id<numplayers&&aitype!=passivetype){
- behind=(normaldotproduct(facing,coords-victim->coords)>0);
- }
- }
-
- if(!dead&&targetanimation!=hurtidleanim)
- if(behind||targetanimation==killanim||targetanimation==knifethrowanim||targetanimation==knifefollowanim||targetanimation==spinkickreversalanim||targetanimation==rabbitkickreversedanim||targetanimation==jumpreversedanim){
- if(headmorphend!=4||headmorphness==targetheadmorphness){
- headmorphend=4;
- //headmorphness=1;
- targetheadmorphness=1;
- }
- }
-
- if(weaponactive!=-1){
- if(weapons.type[weaponids[weaponactive]]!=staff){
- righthandmorphstart=1;
- righthandmorphend=1;
- }
- if(weapons.type[weaponids[weaponactive]]==staff){
- righthandmorphstart=2;
- righthandmorphend=2;
- }
- targetrighthandmorphness=1;
- }
-
- terrainnormal=terrain.getNormal(coords.x,coords.z);
-
- if(animation[targetanimation].attack!=reversal){
- if(!isnormal(coords.x))
- coords=oldcoords;
- oldcoords=coords;
- }
-
- flatfacing=0;
- flatfacing.z=1;
-
- flatfacing=DoRotation(flatfacing,0,rotation,0);
- facing=flatfacing;
- ReflectVector(&facing,terrainnormal);
- Normalise(&facing);
-
- if(isRun()||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim){
- if(onterrain)targettilt2=-facing.y*20;
- else targettilt2=0;
- }
- onterrain=0;
- if(!isRun()&&!animation[targetanimation].attack&&targetanimation!=getupfromfrontanim&&targetanimation!=getupfrombackanim&&targetanimation!=sneakanim)targettilt2=0;
- if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
- flatvelocity=velocity;
- flatvelocity.y=0;
- flatvelspeed=findLength(&flatvelocity);
- targettilt=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(DoRotation(flatfacing,0,-90,0),flatvelocity);
- targettilt2=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(flatfacing,flatvelocity);
- if(velocity.y<0)targettilt2*=-1;
- if(velocity.y<0)targettilt*=-1;
- if(targettilt>25)targettilt=25;
- if(targettilt<-25)targettilt=-25;
- }
-
- if(targettilt2>45)targettilt2=45;
- if(targettilt2<-45)targettilt2=-45;
- if(abs(tilt2-targettilt2)<multiplier*400)tilt2=targettilt2;
- else if(tilt2>targettilt2){
- tilt2-=multiplier*400;
- }
- else if(tilt2<targettilt2){
- tilt2+=multiplier*400;
- }
- if(!animation[targetanimation].attack&&targetanimation!=getupfrombackanim&&targetanimation!=getupfromfrontanim){
- if(tilt2>25)tilt2=25;
- if(tilt2<-25)tilt2=-25;
- }
-
- if(!isnormal(targettilt)&&targettilt){
- targettilt=0;
- }
- if(!isnormal(targettilt2)&&targettilt2){
- targettilt2=0;
- }
-
- //Running velocity
- //if(!creature==wolftype||targetanimation==rabbitkickanim)
- if(targetanimation==rabbittackleanim){
- velocity+=facing*multiplier*speed*700*scale;
- velspeed=findLength(&velocity);
- if(velspeed>speed*65*scale){
- velocity/=velspeed;
- velspeed=speed*65*scale;
- velocity*=velspeed;
- }
- velocity.y+=gravity*multiplier*20;
- ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
- velspeed=findLength(&velocity);
- velocity=flatfacing*velspeed;
- }
- if(targetanimation!=rabbitrunninganim&&targetanimation!=wolfrunninganim){
- if(isRun()||targetanimation==rabbitkickanim){
- velocity+=facing*multiplier*speed*700*scale;
- velspeed=findLength(&velocity);
- if(velspeed>speed*45*scale){
- velocity/=velspeed;
- velspeed=speed*45*scale;
- velocity*=velspeed;
- }
- velocity.y+=gravity*multiplier*20;
- ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
- velspeed=findLength(&velocity);
- if(velspeed<speed*30*scale)velspeed=speed*30*scale;
- velocity=flatfacing*velspeed;
- }
- }
- else if(isRun()){
- velocity+=facing*multiplier*speed*700*scale;
- velspeed=findLength(&velocity);
- if(creature==rabbittype){
- if(velspeed>speed*55*scale){
- velocity/=velspeed;
- velspeed=speed*55*scale;
- velocity*=velspeed;
- }
- }
- if(creature==wolftype){
- if(velspeed>speed*75*scale){
- velocity/=velspeed;
- velspeed=speed*75*scale;
- velocity*=velspeed;
- }
- }
- velocity.y+=gravity*multiplier*20;
- ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
- velspeed=findLength(&velocity);
- velocity=flatfacing*velspeed;
- }
-
- if(targetanimation==rollanim&&animation[targetanimation].label[targetframe]!=6){
- velocity+=facing*multiplier*speed*700*scale;
- velspeed=findLength(&velocity);
- if(velspeed>speed*45*scale){
- velocity/=velspeed;
- velspeed=speed*45*scale;
- velocity*=velspeed;
- }
- velocity.y+=gravity*multiplier*20;
- ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
- velspeed=findLength(&velocity);
- velocity=flatfacing*velspeed;
- }
-
-
- /*if(currentanimation==rollanim&&(isCrouch()||isIdle())){
- velocity+=facing*multiplier*speed*700*scale;
- velspeed=findLength(&velocity);
- if(velspeed>speed*25*scale){
- velocity/=velspeed;
- velspeed=speed*25*scale;
- velocity*=velspeed;
- }
- velocity.y+=gravity*multiplier*20;
- ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
- velspeed=findLength(&velocity);
- velocity=flatfacing*velspeed;
- }*/
-
- if(targetanimation==sneakanim||targetanimation==walkanim){
- velocity+=facing*multiplier*speed*700*scale;
- velspeed=findLength(&velocity);
- if(velspeed>speed*12*scale){
- velocity/=velspeed;
- velspeed=speed*12*scale;
- velocity*=velspeed;
- }
- velocity.y+=gravity*multiplier*20;
- ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
- velspeed=findLength(&velocity);
- velocity=flatfacing*velspeed;
- }
-
- if((targetanimation==fightidleanim||targetanimation==knifefightidleanim)&&(currentanimation==bounceidleanim||currentanimation==hurtidleanim)){
- velocity+=facing*multiplier*speed*700*scale;
- velspeed=findLength(&velocity);
- if(velspeed>speed*2*scale){
- velocity/=velspeed;
- velspeed=speed*2*scale;
- velocity*=velspeed;
- }
- velocity.y+=gravity*multiplier*20;
- ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
- velspeed=findLength(&velocity);
- velocity=flatfacing*velspeed;
- }
-
-
- if((targetanimation==bounceidleanim||currentanimation==hurtidleanim)&&(currentanimation==fightidleanim||currentanimation==knifefightidleanim)){
- velocity-=facing*multiplier*speed*700*scale;
- velspeed=findLength(&velocity);
- if(velspeed>speed*2*scale){
- velocity/=velspeed;
- velspeed=speed*2*scale;
- velocity*=velspeed;
- }
- velocity.y+=gravity*multiplier*20;
- ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
- velspeed=findLength(&velocity);
- velocity=flatfacing*velspeed*-1;
- }
-
- if(targetanimation==fightsidestep){
- velocity+=DoRotation(facing*multiplier*speed*700*scale,0,-90,0);
- velspeed=findLength(&velocity);
- if(velspeed>speed*12*scale){
- velocity/=velspeed;
- velspeed=speed*12*scale;
- velocity*=velspeed;
- }
- velocity.y+=gravity*multiplier*20;
- ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
- velspeed=findLength(&velocity);
- velocity=DoRotation(flatfacing*velspeed,0,-90,0);
- }
-
- if(targetanimation==staggerbackhighanim){
- coords-=facing*multiplier*speed*16*scale;
- velocity=0;
- }
- if(targetanimation==staggerbackhardanim&&animation[staggerbackhardanim].label[targetframe]!=6){
- coords-=facing*multiplier*speed*20*scale;
- velocity=0;
- }
-
- if(targetanimation==backhandspringanim){
- //coords-=facing*multiplier*50*scale;
- velocity+=facing*multiplier*speed*700*scale*-1;
- velspeed=findLength(&velocity);
- if(velspeed>speed*50*scale){
- velocity/=velspeed;
- velspeed=speed*50*scale;
- velocity*=velspeed;
- }
- velocity.y+=gravity*multiplier*20;
- ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
- velspeed=findLength(&velocity);
- velocity=flatfacing*velspeed*-1;
- }
- if(targetanimation==dodgebackanim){
- //coords-=facing*multiplier*50*scale;
- velocity+=facing*multiplier*speed*700*scale*-1;
- velspeed=findLength(&velocity);
- if(velspeed>speed*60*scale){
- velocity/=velspeed;
- velspeed=speed*60*scale;
- velocity*=velspeed;
- }
- velocity.y+=gravity*multiplier*20;
- ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
- velspeed=findLength(&velocity);
- velocity=flatfacing*velspeed*-1;
- }
-
- if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
- velspeed=findLength(&velocity);
- }
-
-
- if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
- velocity.y+=gravity*multiplier;
- }
-
- if(targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords+=velocity*multiplier;
-
- if(coords.y<terrain.getHeight(coords.x,coords.z)&&(targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
- if(isFlip()&&animation[targetanimation].label[targetframe]==7)RagDoll(0);
-
- if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
- target=0;
- targetframe=0;
- onterrain=1;
-
- if(id==0){
- OPENAL_SetPaused(channels[whooshsound], true);
- OPENAL_SetVolume(channels[whooshsound], 0);
- }
-
- if(targetanimation==jumpdownanim||isFlip()){
- if(isFlip())jumppower=-4;
- targetanimation=getLanding();
- emit_sound_at(landsound, coords, 128.);
-
- if(id==0){
- envsound[numenvsounds]=coords;
- envsoundvol[numenvsounds]=16;
- envsoundlife[numenvsounds]=.4;
- numenvsounds++;
- }
- }
- }
-
- if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords.y+=gravity*multiplier*2;
- if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&coords.y<terrain.getHeight(coords.x,coords.z)){
- coords.y=terrain.getHeight(coords.x,coords.z);
- onterrain=1;
- }
-
-
- if(isIdle()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||isStop()||targetanimation==removeknifeanim||targetanimation==crouchremoveknifeanim||isLanding()||isCrouch()||animation[targetanimation].attack||(targetanimation==rollanim&&animation[targetanimation].label[targetframe]==6)){
- velspeed=findLength(&velocity);
- velocity.y=0;
- if(velspeed<multiplier*300*scale){
- velocity=0;
- } else velocity-=velocity/velspeed*multiplier*300*scale;
- if(velspeed>5&&(isLanding()||isLandhard())){
- skiddingdelay+=multiplier;
- if(skiddelay<=0){
- FootLand(0,.5);
- FootLand(1,.5);
- skiddelay=.02;
- }
- }
- else skiddingdelay=0;
- }
-
- if(isLandhard()){
- velspeed=findLength(&velocity);
- velocity.y=0;
- if(velspeed<multiplier*600*scale){
- velocity=0;
- } else velocity-=velocity/velspeed*multiplier*600*scale;
- velocity=0;
- if(velspeed>5&&(isLanding()||isLandhard())){
- skiddingdelay+=multiplier;
- if(skiddelay<=0){
- FootLand(0,.5);
- FootLand(1,.5);
- skiddelay=.02;
- }
- }
- else skiddingdelay=0;
- }
-
- if(skiddingdelay<0)skiddingdelay+=multiplier;
- if(skiddingdelay>.02&&!forwardkeydown&&!backkeydown&&!leftkeydown&&!rightkeydown&&!jumpkeydown&&isLanding()&&!landhard){
- skiddingdelay=-1;
- if(!onterrain||environment==grassyenvironment){
- emit_sound_at(skidsound, coords, 128*velspeed/10);
- }
- else {
- emit_sound_at(snowskidsound, coords, 128*velspeed/10);
- }
- }
-
- if(animation[targetanimation].attack==normalattack&&targetanimation!=rabbitkickanim&&!victim->skeleton.free){
- terrainnormal=victim->coords-coords;
- Normalise(&terrainnormal);
- targetrotation=-asin(0-terrainnormal.x);
- targetrotation*=360/6.28;
- if(terrainnormal.z<0)targetrotation=180-targetrotation;
- targettilt2=-asin(terrainnormal.y)*360/6.28;//*-70;
- }
-
- if(animation[targetanimation].attack==reversal&&targetanimation!=rabbittacklinganim){
- targetrotation=victim->targetrotation;
- }
- if(targetanimation==rabbittacklinganim){
- coords=victim->coords;
- }
- }
- skeleton.oldfree=skeleton.free;
-
- XYZ midterrain;
- midterrain=0;
- midterrain.x=terrain.size*terrain.scale/2;
- midterrain.z=terrain.size*terrain.scale/2;
- if(findDistancefastflat(&coords,&midterrain)>(terrain.size*terrain.scale/2-viewdistance)*(terrain.size*terrain.scale/2-viewdistance)){
- XYZ tempposit;
- tempposit=coords-midterrain;
- tempposit.y=0;
- Normalise(&tempposit);
- tempposit*=(terrain.size*terrain.scale/2-viewdistance);
- coords.x=tempposit.x+midterrain.x;
- coords.z=tempposit.z+midterrain.z;
- }
+/* EFFECT
+ * MONSTER
+ * TODO: ???
+ */
+void Person::DoAnimations()
+{
+ if (!skeleton.free) {
+ static float oldtarget;
+
+ if (isIdle() && animCurrent != getIdle())
+ normalsupdatedelay = 0;
+
+ if (animTarget == tempanim || animCurrent == tempanim) {
+ Animation::animations[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::animations[animTarget].attack != reversed)
+ feint = 0;
+ if (!crouchkeydown || (isLanding() || isLandhard()) || (wasLanding() || wasLandhard())) {
+ crouchtogglekeydown = 0;
+ if (aitype == playercontrolled)
+ feint = 0;
+ } else {
+ if (!crouchtogglekeydown && Animation::animations[animTarget].attack == reversed && aitype == playercontrolled && (escapednum < 2 || reversaltrain))
+ feint = 1;
+ if (!isFlip())
+ crouchtogglekeydown = 1;
+ }
+
+
+ if (Animation::animations[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 && 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) && (targetFrame().label || (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 ((targetFrame().label && (targetFrame().label < 5 || targetFrame().label == 8))) {
+ int whichsound;
+ if (onterrain) {
+ if (terrain.getOpacity(coords.x, coords.z) < .2) {
+ if (targetFrame().label == 1)
+ whichsound = footstepsound;
+ else
+ whichsound = footstepsound2;
+ if (targetFrame().label == 1)
+ FootLand(leftfoot, 1);
+ if (targetFrame().label == 2)
+ FootLand(rightfoot, 1);
+ if (targetFrame().label == 3 && isRun()) {
+ FootLand(rightfoot, 1);
+ FootLand(leftfoot, 1);
+ }
+
+ }
+ if (terrain.getOpacity(coords.x, coords.z) >= .2) {
+ if (targetFrame().label == 1)
+ whichsound = footstepsound3;
+ else
+ whichsound = footstepsound4;
+ }
+ }
+ if (!onterrain) {
+ if (targetFrame().label == 1)
+ whichsound = footstepsound3;
+ else
+ whichsound = footstepsound4;
+ }
+ if (targetFrame().label == 4 && (weaponactive == -1 || (animTarget != knifeslashstartanim && animTarget != knifethrowanim && animTarget != crouchstabanim && animTarget != swordgroundstabanim && animTarget != knifefollowanim))) {
+ if (Animation::animations[animTarget].attack != neutral) {
+ unsigned r = abs(Random() % 3);
+ if (r == 0)
+ whichsound = lowwhooshsound;
+ if (r == 1)
+ whichsound = midwhooshsound;
+ if (r == 2)
+ whichsound = highwhooshsound;
+ }
+ if (Animation::animations[animTarget].attack == neutral)
+ whichsound = movewhooshsound;
+ } else if (targetFrame().label == 4)
+ whichsound = knifeswishsound;
+ if (targetFrame().label == 8 && tutoriallevel != 1)
+ whichsound = landsound2;
+
+ emit_sound_at(whichsound, coords, 256.);
+
+ if (id == 0)
+ if (whichsound == footstepsound || whichsound == footstepsound2 || whichsound == footstepsound3 || whichsound == footstepsound4) {
+ if (animTarget == wolfrunninganim || animTarget == rabbitrunninganim) {
+ addEnvSound(coords, 15);
+ } else {
+ addEnvSound(coords, 6);
+ }
+ }
+
+ if (targetFrame().label == 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 ((targetFrame().label && (targetFrame().label < 5 || targetFrame().label == 8))) {
+ int whichsound = -1;
+ if (targetFrame().label == 4 && aitype != playercontrolled) {
+ if (Animation::animations[animTarget].attack != neutral) {
+ unsigned r = abs(Random() % 4);
+ if (creature == rabbittype) {
+ if (r == 0) whichsound = rabbitattacksound;
+ if (r == 1) whichsound = rabbitattack2sound;
+ if (r == 2) whichsound = rabbitattack3sound;
+ if (r == 3) whichsound = rabbitattack4sound;
+ }
+ if (creature == wolftype) {
+ if (r == 0) whichsound = barksound;
+ if (r == 1) whichsound = bark2sound;
+ if (r == 2) whichsound = bark3sound;
+ if (r == 3) whichsound = barkgrowlsound;
+ }
+ speechdelay = .3;
+ }
+ }
+
+ if (whichsound != -1) {
+ emit_sound_at(whichsound, coords);
+ }
+ }
+
+
+
+ if ((!wasLanding() && !wasLandhard()) && animCurrent != getIdle() && (isLanding() || isLandhard())) {
+ FootLand(leftfoot, 1);
+ FootLand(rightfoot, 1);
+ }
+
+ transspeed = 0;
+ currentoffset = targetoffset;
+ frameTarget = frameCurrent;
+ animCurrent = animTarget;
+ frameTarget++;
+
+ if (animTarget == removeknifeanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+ for (unsigned 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.);
+ }
+
+ takeWeapon(i);
+ }
+ }
+ }
+ }
+
+ if (animTarget == crouchremoveknifeanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+ for (unsigned i = 0; i < weapons.size(); i++) {
+ bool willwork = true;
+ if (weapons[i].owner != -1)
+ if (Person::players[weapons[i].owner]->weaponstuck != -1)
+ if (Person::players[weapons[i].owner]->weaponids[Person::players[weapons[i].owner]->weaponstuck] == int(i))
+ if (Person::players[weapons[i].owner]->num_weapons > 1)
+ willwork = 0;
+ if ((weapons[i].owner == -1) || (hasvictim && (weapons[i].owner == int(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] == int(i)) {
+ fleshstuck = true;
+ }
+ }
+ if (fleshstuck) {
+ emit_sound_at(fleshstabremovesound, coords, 128.);
+ } else {
+ if (weapons[i].getType() != staff) {
+ emit_sound_at(knifedrawsound, coords, 128.);
+ }
+ }
+ if (weapons[i].owner != -1) {
+ victim = Person::players[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.joints.size(); 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] == int(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] == int(i))
+ victim->weaponids[0] = victim->weaponids[victim->num_weapons];
+ }
+
+ victim->jointVel(abdomen) += relative * 6;
+ victim->jointVel(neck) += relative * 6;
+ victim->jointVel(rightshoulder) += relative * 6;
+ victim->jointVel(leftshoulder) += relative * 6;
+ }
+ takeWeapon(i);
+ }
+ }
+ }
+ }
+
+ if (animCurrent == drawleftanim && Animation::animations[animTarget].frames[frameCurrent].label == 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, &/*Person::players[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 (unsigned i = 0; i < Person::players.size(); i++) {
+ if (i != id)
+ if (distsq(&targetloc, &Person::players[i]->coords) < closestdist || closestdist == 0) {
+ closestdist = distsq(&targetloc, &Person::players[i]->coords);
+ closestid = i;
+ }
+ }
+ if (closestid != -1)
+ if (closestdist < 5 && !Person::players[closestid]->dead && Animation::animations[Person::players[closestid]->animTarget].height != lowheight && Person::players[closestid]->animTarget != backhandspringanim) {
+ hasvictim = 1;
+ victim = Person::players[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 ((Animation::animations[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::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && 3 && Animation::animations[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 (int i = 0; i < victim->skeleton.joints.size(); i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 40;
+ }
+ victim->jointVel(head) += relative * damagemult * 200;
+ victim->Puff(head);
+ victim->DoDamage(damagemult * 100 / victim->protectionhead);
+
+ SolidHitBonus(id);
+ }
+ }
+
+ if (animTarget == wolfslapanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && 3 && Animation::animations[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 (int i = 0; i < victim->skeleton.joints.size(); i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 20;
+ }
+ victim->jointVel(head) += relative * damagemult * 100;
+ victim->Puff(head);
+ victim->DoDamage(damagemult * 50 / victim->protectionhead);
+ }
+ }
+
+ if (animTarget == walljumprightkickanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && Animation::animations[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 (int i = 0; i < victim->skeleton.joints.size(); i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 40;
+ }
+ victim->jointVel(head) += relative * damagemult * 200;
+ 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::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && Animation::animations[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 (int i = 0; i < victim->skeleton.joints.size(); i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 40;
+ }
+ victim->jointVel(head) += relative * damagemult * 200;
+ 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::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && Animation::animations[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 (int i = 0; i < victim->skeleton.joints.size(); i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 30;
+ }
+ victim->jointVel(head) += relative * damagemult * 100;
+ victim->Puff(head);
+ victim->DoDamage(damagemult * 50 / victim->protectionhead);
+ }
+ }
+
+ if (animTarget == killanim && Animation::animations[animTarget].frames[frameCurrent].label == 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 (int i = 0; i < victim->skeleton.joints.size(); 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 (int i = 0; i < victim->skeleton.joints.size(); 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->jointVel(abdomen).y = relative.y * 400;
+ }
+ }
+
+ if (animTarget == killanim && Animation::animations[animTarget].frames[frameCurrent].label == 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 (int i = 0; i < victim->skeleton.joints.size(); 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->jointVel(abdomen) += relative * damagemult * 300;
+ }
+ }
+
+ if (animTarget == dropkickanim && Animation::animations[animTarget].frames[frameCurrent].label == 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 (int i = 0; i < victim->skeleton.joints.size(); 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 (int i = 0; i < victim->skeleton.joints.size(); i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 20;
+ }
+ if (!victim->dead)
+ SolidHitBonus(id);
+
+ victim->Puff(abdomen);
+ victim->DoDamage(damagemult * 20 / victim->protectionhigh);
+ victim->jointVel(abdomen) += relative * damagemult * 200;
+ staggerdelay = .5;
+ if (!victim->dead)
+ staggerdelay = 1.2;
+
+
+ }
+ }
+
+ if ((animTarget == crouchstabanim || animTarget == swordgroundstabanim) && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+
+ 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 (int i = 0; i < victim->skeleton.joints.size(); 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::animations[animTarget].frames[frameCurrent].label == 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 (int i = 0; i < victim->skeleton.joints.size(); 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->jointVel(abdomen) += relative * damagemult * 20;
+ }
+ }
+ }
+ if (!hasvictim && onterrain) {
+ weapons[weaponids[weaponactive]].bloody = 0;
+ weapons[weaponids[weaponactive]].blooddrip = 0;
+ }
+ }
+
+ if (animTarget == upunchanim && Animation::animations[animTarget].frames[frameCurrent].label == 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 (int i = 0; i < victim->skeleton.joints.size(); i++) {
+ victim->skeleton.joints[i].velocity = relative * 30;
+ }
+ victim->jointVel(head) += 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::animations[animTarget].frames[frameCurrent].label == 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::animations[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::animations[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::animations[victim->animTarget].height == lowheight)
+ victim->RagDoll(0);
+ XYZ relative;
+ relative = victim->coords - coords;
+ relative.y = 0;
+ Normalise(&relative);
+ relative.y = .3;
+ Normalise(&relative);
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
+ victim->skeleton.joints[i].velocity = relative * 5;
+ }
+ victim->jointVel(abdomen) += 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::animations[animTarget].frames[frameCurrent].label == 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::animations[animTarget].frames[frameCurrent].label == 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::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (weaponactive != -1) {
+ escapednum = 0;
+ XYZ aim;
+ aim = victim->coords + DoRotation(victim->jointPos(abdomen), 0, victim->yaw, 0) * victim->scale + victim->velocity * findDistance(&victim->coords, &coords) / 50 - (coords + DoRotation(jointPos(righthand), 0, yaw, 0) * scale);
+ Normalise(&aim);
+ weapons[weaponids[0]].thrown(aim * 50);
+ num_weapons--;
+ if (num_weapons) {
+ weaponids[0] = weaponids[num_weapons];
+ }
+ weaponactive = -1;
+ }
+ }
+
+ if (animTarget == knifeslashstartanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (hasvictim)
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 4.5 &&/*Animation::animations[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->jointVel(abdomen)+=relative*damagemult*200;
+ if (Animation::animations[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->jointPos(abdomen) + victim->jointPos(neck)) / 2 * victim->scale + victim->coords;
+ } else {
+ footpoint = DoRotation((victim->jointPos(abdomen) + victim->jointPos(neck)) / 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::animations[animTarget].frames[frameCurrent].label == 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->jointVel(abdomen)+=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->jointPos(abdomen) + victim->jointPos(neck)) / 2 * victim->scale + victim->coords;
+ } else {
+ footpoint = DoRotation((victim->jointPos(abdomen) + victim->jointPos(neck)) / 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;
+ aim = DoRotation(facing, 0, 90, 0) * 21;
+ aim.y += 7;
+ weapons[victim->weaponids[0]].drop(aim * -.2, aim);
+ 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 (unsigned i = 0; i < Person::players.size(); i++) {
+ Person::players[i]->wentforweapon = 0;
+ }
+
+ }
+ }
+ }
+
+ if (animTarget == staffhitanim && Animation::animations[animTarget].frames[frameCurrent].label == 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 (int i = 0; i < victim->skeleton.joints.size(); i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 60;
+ }
+ victim->jointVel(head) += relative * damagemult * 230;
+ victim->jointVel(neck) += relative * damagemult * 230;
+ victim->Puff(head);
+ if (tutoriallevel != 1) {
+ victim->DoDamage(damagemult * 120 / victim->protectionhigh);
+
+ award_bonus(id, solidhit, 30);
+ }
+ }
+ }
+
+ if (animTarget == staffspinhitanim && Animation::animations[animTarget].frames[frameCurrent].label == 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 (int i = 0; i < victim->skeleton.joints.size(); i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 40;
+ }
+ victim->jointVel(head) += relative * damagemult * 220;
+ victim->jointVel(neck) += relative * damagemult * 220;
+ victim->Puff(head);
+ if (tutoriallevel != 1) {
+ victim->DoDamage(damagemult * 350 / victim->protectionhead);
+
+ award_bonus(id, solidhit, 60);
+ }
+ }
+ }
+
+ if (animTarget == staffgroundsmashanim && Animation::animations[animTarget].frames[frameCurrent].label == 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 (int i = 0; i < victim->skeleton.joints.size(); 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.y = -1;
+ Normalise(&relative);
+ if (!victim->dead) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
+ victim->skeleton.joints[i].velocity = relative * damagemult * 40;
+ }
+ victim->jointVel(abdomen) += relative * damagemult * 40;
+ }
+ if (victim->dead) {
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
+ victim->skeleton.joints[i].velocity = relative * damagemult * abs(Random() % 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::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && Animation::animations[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::animations[victim->animTarget].height == lowheight) {
+ if (Random() % 2) {
+ victim->spurt = 1;
+ DoBlood(.2, 250);
+ }
+ victim->RagDoll(0);
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 40;
+ }
+ victim->jointVel(head) += 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 (int i = 0; i < victim->skeleton.joints.size(); i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 10;
+ }
+ victim->jointVel(abdomen) += 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::animations[animTarget].frames[frameCurrent].label == 5) {
+ if ((victim->animTarget != jumpupanim) &&
+ (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3) &&
+ (victim != this->shared_from_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::animations[victim->animTarget].height == middleheight || Animation::animations[victim->animCurrent].height == middleheight || victim->damage >= victim->damagetolerance - 40) {
+ victim->RagDoll(0);
+
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 15;
+ }
+ relative = DoRotation(relative, 0, -90, 0);
+ relative.y += .1;
+ for (int i = 0; i < victim->skeleton.joints.size(); 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 (int i = 0; i < victim->skeleton.joints.size(); i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 10;
+ }
+ relative = DoRotation(relative, 0, -90, 0);
+ for (int i = 0; i < victim->skeleton.joints.size(); 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->jointVel(abdomen) += 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::animations[animTarget].attack == reversal && (!victim->feint || (victim->lastattack == victim->lastattack2 && victim->lastattack2 == victim->lastattack3 && Random() % 2) || animTarget == knifefollowanim)) {
+ if (animTarget == spinkickreversalanim && Animation::animations[animTarget].frames[frameCurrent].label == 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);
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 40;
+ }
+ victim->jointVel(abdomen) += relative * damagemult * 200;
+ victim->Puff(abdomen);
+ victim->DoDamage(damagemult * 150 / victim->protectionhigh);
+
+ award_bonus(id, Reversal);
+ }
+
+ if ((animTarget == swordslashreversalanim || animTarget == knifeslashreversalanim || animTarget == staffhitreversalanim || animTarget == staffspinhitreversalanim) && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (victim->weaponactive != -1 && victim->num_weapons > 0) {
+ if (weapons[victim->weaponids[victim->weaponactive]].owner == int(victim->id)) {
+ takeWeapon(victim->weaponids[victim->weaponactive]);
+ victim->num_weapons--;
+ if (victim->num_weapons > 0) {
+ victim->weaponids[victim->weaponactive] = victim->weaponids[victim->num_weapons];
+ }
+ victim->weaponactive = -1;
+ }
+ }
+ }
+
+ if (animTarget == staffhitreversalanim && Animation::animations[animTarget].frames[frameCurrent].label == 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);
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 30;
+ }
+ victim->jointVel(abdomen) += relative * damagemult * 200;
+ victim->Puff(head);
+ victim->DoDamage(damagemult * 70 / victim->protectionhigh);
+ }
+
+ if (animTarget == staffspinhitreversalanim && Animation::animations[animTarget].frames[frameCurrent].label == 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);
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 30;
+ }
+ victim->jointVel(abdomen) += relative * damagemult * 200;
+ victim->Puff(head);
+ victim->DoDamage(damagemult * 70 / victim->protectionhigh);
+ }
+
+ if (animTarget == upunchreversalanim && Animation::animations[animTarget].frames[frameCurrent].label == 7) {
+ escapednum = 0;
+ victim->RagDoll(1);
+ XYZ relative;
+ relative = facing;
+ relative.y = 0;
+ Normalise(&relative);
+ relative.y -= .1;
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 70;
+ }
+ victim->jointVel(lefthand) *= .1;
+ victim->jointVel(leftwrist) *= .2;
+ victim->jointVel(leftelbow) *= .5;
+ victim->jointVel(leftshoulder) *= .7;
+ victim->jointVel(righthand) *= .1;
+ victim->jointVel(rightwrist) *= .2;
+ victim->jointVel(rightelbow) *= .5;
+ victim->jointVel(rightshoulder) *= .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::animations[animTarget].frames[frameCurrent].label == 7) {
+ escapednum = 0;
+ victim->RagDoll(1);
+ XYZ relative;
+ relative = facing;
+ relative.y = 0;
+ Normalise(&relative);
+ relative.y -= .1;
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 70;
+ }
+ victim->jointVel(lefthand) *= .1 - 1;
+ victim->jointVel(leftwrist) *= .2 - 1;
+ victim->jointVel(leftelbow) *= .5 - 1;
+ victim->jointVel(leftshoulder) *= .7 - 1;
+ victim->jointVel(righthand) *= .1 - 1;
+ victim->jointVel(rightwrist) *= .2 - 1;
+ victim->jointVel(rightelbow) *= .5 - 1;
+ victim->jointVel(rightshoulder) *= .7 - 1;
+
+ award_bonus(id, swordreversebonus);
+ }
+
+ if (hasvictim && animTarget == knifeslashreversalanim && Animation::animations[animTarget].frames[frameCurrent].label == 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 (int i = 0; i < victim->skeleton.joints.size(); i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 40;
+ }
+ victim->jointVel(abdomen) += relative * damagemult * 200;
+ victim->Puff(abdomen);
+ victim->DoDamage(damagemult * 30 / victim->protectionhigh);
+
+ award_bonus(id, Reversal);
+ }
+
+ if (hasvictim && animTarget == sneakattackanim && Animation::animations[animTarget].frames[frameCurrent].label == 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 (int i = 0; i < victim->skeleton.joints.size(); i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 40;
+ }
+ 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::animations[animTarget].frames[frameCurrent].label == 5) {
+ if (weaponactive != -1 && victim->bloodloss < victim->damagetolerance) {
+ escapednum = 0;
+ if (animTarget == knifefollowanim)
+ victim->DoBloodBig(200, 210);
+ if (animTarget == knifesneakattackanim) {
+ 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::animations[animTarget].frames[frameCurrent].label == 6) {
+ escapednum = 0;
+ victim->velocity = 0;
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
+ victim->skeleton.joints[i].velocity = 0;
+ }
+ if (animTarget == knifefollowanim) {
+ victim->RagDoll(0);
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
+ victim->skeleton.joints[i].velocity = 0;
+ }
+ }
+ if (weaponactive != -1 && Animation::animations[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::animations[animTarget].frames[frameCurrent].label == 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::animations[animTarget].frames[frameCurrent].label == 6) {
+ escapednum = 0;
+ victim->velocity = 0;
+ for (int i = 0; i < victim->skeleton.joints.size(); 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::animations[animTarget].frames[frameCurrent].label == 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 = facing * -1;
+ relative.y = 0;
+ Normalise(&relative);
+ relative = DoRotation(relative, 0, 90, 0);
+ relative.y = .5;
+ Normalise(&relative);
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 20;
+ }
+ victim->jointVel(head) += 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::animations[animTarget].frames[frameCurrent].label == 9 && victim->damage < victim->damagetolerance) || (Animation::animations[animTarget].frames[frameCurrent].label == 7 && victim->damage > victim->damagetolerance))) {
+ escapednum = 0;
+ victim->RagDoll(0);
+ XYZ relative;
+ relative = facing * -1;
+ relative.y = 0;
+ Normalise(&relative);
+ relative = DoRotation(relative, 0, 90, 0);
+ relative.y = .5;
+ Normalise(&relative);
+ for (int i = 0; i < victim->skeleton.joints.size(); i++) {
+ victim->skeleton.joints[i].velocity += relative * damagemult * 20;
+ }
+ victim->jointVel(head) += 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::animations[animCurrent].frames.size() - 1) {
+ frameTarget = 0;
+ if (wasStop()) {
+ animTarget = getIdle();
+ FootLand(leftfoot, 1);
+ FootLand(rightfoot, 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(leftfoot, 1);
+ FootLand(rightfoot, 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 (Person::players.size() > 1)
+ for (unsigned i = 0; i < Person::players.size(); i++) {
+ if (id != i && Person::players[i]->coords.y < coords.y && !Person::players[i]->skeleton.free) {
+ distance = distsq(&Person::players[i]->coords, &coords);
+ if (closestdist == -1 || distance < closestdist) {
+ closestdist = distance;
+ closest = i;
+ }
+ }
+ }
+ if (closestdist > 0 && closest >= 0 && closestdist < 16) {
+ victim = Person::players[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 (Person::players.size() > 1)
+ for (unsigned i = 0; i < Person::players.size(); i++) {
+ if (id != i && Person::players[i]->coords.y < coords.y && !Person::players[i]->skeleton.free) {
+ distance = distsq(&Person::players[i]->coords, &coords);
+ if (closestdist == -1 || distance < closestdist) {
+ closestdist = distance;
+ closest = i;
+ }
+ }
+ }
+ if (closestdist > 0 && closest >= 0 && closestdist < 16) {
+ victim = Person::players[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::animations[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::animations[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(jointPos(leftfoot), 0, yaw, 0) + DoRotation(jointPos(rightfoot), 0, yaw, 0)) / 2 * scale;
+ coords.y = oldcoords.y;
+ }
+ if (animCurrent == knifeslashreversedanim) {
+ animTarget = rollanim;
+ frameTarget = 0;
+ targetyaw += 90;
+ yaw += 90;
+ oldcoords = coords;
+ coords += (DoRotation(jointPos(leftfoot), 0, yaw, 0) + DoRotation(jointPos(rightfoot), 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(jointPos(leftfoot), 0, yaw, 0) + DoRotation(jointPos(rightfoot), 0, yaw, 0)) / 2 * scale;
+ coords.y = oldcoords.y;
+ //coords+=DoRotation(Animation::animations[animCurrent].offset,0,yaw,0)*scale;
+ targetoffset.y = coords.y;
+ if (onterrain)
+ targetoffset.y = terrain.getHeight(coords.x, coords.z);
+ currentoffset = DoRotation(Animation::animations[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::animations[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::animations[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::animations[animTarget].attack != 2 && Animation::animations[animTarget].attack != 3) {
+ if (!isRun() || !wasRun()) {
+ if (targetFrame().speed > currentFrame().speed)
+ target += multiplier * targetFrame().speed * speed * 2;
+ if (targetFrame().speed <= currentFrame().speed)
+ target += multiplier * currentFrame().speed * speed * 2;
+ }
+ if (isRun() && wasRun()) {
+ float tempspeed;
+ tempspeed = velspeed;
+ if (tempspeed < 10 * speedmult)
+ tempspeed = 10 * speedmult;
+ /* FIXME - mixed of target and current here, is that intended? */
+ target += multiplier * Animation::animations[animTarget].frames[frameCurrent].speed * speed * 1.7 * tempspeed / (speed * 45 * scale);
+ }
+ } else if (transspeed)
+ target += multiplier * transspeed * speed * 2;
+ else {
+ if (!isRun() || !wasRun()) {
+ if (targetFrame().speed > currentFrame().speed)
+ target += multiplier * targetFrame().speed * 2;
+ if (targetFrame().speed <= currentFrame().speed)
+ target += multiplier * currentFrame().speed * 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 (frameCurrent >= Animation::animations[animCurrent].frames.size()) {
+ frameCurrent = Animation::animations[animCurrent].frames.size() - 1;
+ }
+ if (animCurrent != oldanimCurrent || animTarget != oldanimTarget || ((frameCurrent != oldframeCurrent || frameTarget != oldframeTarget) && !calcrot)) {
+ //Old rotates
+ for (int i = 0; i < skeleton.joints.size(); i++) {
+ skeleton.joints[i].position = currentFrame().joints[i].position;
+ }
+
+ skeleton.FindForwards();
+
+ for (int i = 0; i < skeleton.muscles.size(); i++) {
+ if (skeleton.muscles[i].visible) {
+ skeleton.FindRotationMuscle(i, animTarget);
+ }
+ }
+ for (int i = 0; i < skeleton.muscles.size(); 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 (int i = 0; i < skeleton.joints.size(); i++) {
+ skeleton.joints[i].position = targetFrame().joints[i].position;
+ }
+
+ skeleton.FindForwards();
+
+ for (int i = 0; i < skeleton.muscles.size(); i++) {
+ if (skeleton.muscles[i].visible) {
+ skeleton.FindRotationMuscle(i, animTarget);
+ }
+ }
+ for (int i = 0; i < skeleton.muscles.size(); 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;
+ }
+ }
+ }
+
+ oldanimCurrent = animCurrent;
+ oldanimTarget = animTarget;
+ oldframeTarget = frameTarget;
+ oldframeCurrent = frameCurrent;
+
+ for (int i = 0; i < skeleton.joints.size(); i++) {
+ skeleton.joints[i].velocity = (currentFrame().joints[i].position * (1 - target) + targetFrame().joints[i].position * (target) - skeleton.joints[i].position) / multiplier;
+ skeleton.joints[i].position = currentFrame().joints[i].position * (1 - target) + targetFrame().joints[i].position * (target);
+ }
+ offset = currentoffset * (1 - target) + targetoffset * target;
+ for (int i = 0; i < skeleton.muscles.size(); 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;
+ }
+ }