- oldposition[i]=position[i];
- oldtippoint[i]=tippoint[i];
- if(owner[i]==-1&&(velocity[i].x||velocity[i].y||velocity[i].z)&&!physics[i]){
- position[i]+=velocity[i]*multiplier;
- tippoint[i]+=velocity[i]*multiplier;
- whichpatchx=position[i].x/(terrain.size/subdivision*terrain.scale*terraindetail);
- whichpatchz=position[i].z/(terrain.size/subdivision*terrain.scale*terraindetail);
- if(whichpatchx>0&&whichpatchz>0&&whichpatchx<subdivision&&whichpatchz<subdivision)
- if(terrain.patchobjectnum[whichpatchx][whichpatchz]){
- for(j=0;j<terrain.patchobjectnum[whichpatchx][whichpatchz];j++){
- k=terrain.patchobjects[whichpatchx][whichpatchz][j];
- start=oldtippoint[i];
- end=tippoint[i];
- whichhit=objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.rotation[k]);
- if(whichhit!=-1){
- if(objects.type[k]==treetrunktype){
- objects.model[k].MakeDecal(breakdecal,DoRotation(colpoint-objects.position[k],0,-objects.rotation[k],0),.1,1,Random()%360);
- normalrot=DoRotation(objects.model[k].facenormals[whichhit],0,objects.rotation[k],0);
- velocity[i]=0;
- if(type[i]==knife)position[i]=colpoint-normalrot*.1;
- if(type[i]==sword)position[i]=colpoint-normalrot*.2;
- if(type[i]==staff)position[i]=colpoint-normalrot*.2;
- XYZ temppoint1,temppoint2,tempforward;
- float distance;
-
- temppoint1=0;
- temppoint2=normalrot;
- distance=findDistance(&temppoint1,&temppoint2);
- rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
- rotation2[i]*=360/6.28;
- temppoint1.y=0;
- temppoint2.y=0;
- rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
- rotation1[i]*=360/6.28;
- if(temppoint1.x>temppoint2.x)rotation1[i]=360-rotation1[i];
-
- rotation3[i]=0;
- smallrotation[i]=90;
- smallrotation2[i]=0;
- bigtilt[i]=0;
- bigtilt2[i]=0;
- bigrotation[i]=0;
-
- float gLoc[3];
- float vel[3];
- gLoc[0]=position[i].x;
- gLoc[1]=position[i].y;
- gLoc[2]=position[i].z;
- vel[0]=0;
- vel[1]=0;
- vel[2]=0;
- PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, TRUE);
- FSOUND_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
- FSOUND_SetVolume(channels[knifesheathesound], 128);
- FSOUND_SetPaused(channels[knifesheathesound], FALSE);
-
- bloody[i]=0;
-
- sprites.MakeSprite(cloudimpactsprite, position[i],velocity[i], 1,1,1, .8, .3);
- }
- else {
- physics[i]=1;
- firstfree[i]=1;
- position[i]-=velocity[i]*multiplier;
- tippoint[i]-=velocity[i]*multiplier;
- tipvelocity[i]=velocity[i];
- }
- }
- }
- }
- if(velocity[i].x||velocity[i].y||velocity[i].z)
- for(j=0;j<numplayers;j++){
- footvel=0;
- footpoint=DoRotation((player[j].skeleton.joints[player[j].skeleton.jointlabels[abdomen]].position+player[j].skeleton.joints[player[j].skeleton.jointlabels[neck]].position)/2,0,player[j].rotation,0)*player[j].scale+player[j].coords;
- if(owner[i]==-1&&findDistancefastflat(&position[i],&player[j].coords)<1.5&&findDistancefast(&position[i],&player[j].coords)<4&&player[j].weaponstuck==-1&&!player[j].skeleton.free&&j!=oldowner[i]){
- if((player[j].aitype!=attacktypecutoff||abs(Random()%6)==0||(player[j].targetanimation!=backhandspringanim&&player[j].targetanimation!=rollanim&&player[j].targetanimation!=flipanim&&Random()%2==0))&&!missed[i]){
- bool caught=0;
- if((player[j].creature==wolftype&&Random()%3!=0&&player[j].weaponactive==-1&&(player[j].isIdle()||player[j].isRun()||player[j].targetanimation==walkanim))||(player[j].creature==rabbittype&&Random()%2==0&&player[j].aitype==attacktypecutoff&&player[j].weaponactive==-1)){
- float gLoc[3];
- float vel[3];
- gLoc[0]=player[j].coords.x;
- gLoc[1]=player[j].coords.y;
- gLoc[2]=player[j].coords.z;
- vel[0]=player[j].velocity.x;
- vel[1]=player[j].velocity.y;
- vel[2]=player[j].velocity.z;
- PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, TRUE);
- FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
- FSOUND_SetVolume(channels[knifedrawsound], 128);
- FSOUND_SetPaused(channels[knifedrawsound], FALSE);
-
- player[j].weaponactive=0;
- player[j].targetanimation=removeknifeanim;
- player[j].targetframe=1;
- player[j].target=1;
- owner[i]=player[j].id;
- if(player[j].num_weapons>0){
- player[j].weaponids[player[j].num_weapons]=player[j].weaponids[0];
- }
- player[j].num_weapons++;
- player[j].weaponids[0]=i;
-
- player[j].aitype=attacktypecutoff;
- }
- else {
- if(j!=0)numthrowkill++;
- player[j].num_weapons++;
- player[j].weaponstuck=player[j].num_weapons-1;
- if(normaldotproduct(player[j].facing,velocity[i])>0)player[j].weaponstuckwhere=1;
- else player[j].weaponstuckwhere=0;
-
- player[j].weaponids[player[j].num_weapons-1]=i;
-
- player[j].RagDoll(0);
- player[j].skeleton.joints[player[j].skeleton.jointlabels[abdomen]].velocity+=velocity[i]*2;
- player[j].skeleton.joints[player[j].skeleton.jointlabels[neck]].velocity+=velocity[i]*2;
- player[j].skeleton.joints[player[j].skeleton.jointlabels[rightshoulder]].velocity+=velocity[i]*2;
- player[j].skeleton.joints[player[j].skeleton.jointlabels[leftshoulder]].velocity+=velocity[i]*2;
- //player[j].Puff(abdomen);
- if(bloodtoggle&&tutoriallevel!=1)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
- if(tutoriallevel==1)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .8, .3);
- footvel=tippoint[i]-position[i];
- Normalise(&footvel);
- if(bloodtoggle&&tutoriallevel!=1)sprites.MakeSprite(bloodflamesprite, footpoint,footvel*-1, 1,0,0, .6, 1);
-
- if(tutoriallevel!=1){
- if(player[j].weaponstuckwhere==0)player[j].DoBloodBig(2,205);
- if(player[j].weaponstuckwhere==1)player[j].DoBloodBig(2,200);
- player[j].damage+=200/player[j].armorhigh;
- player[j].deathbleeding=1;
- player[j].bloodloss+=(200+abs((float)(Random()%40))-20)/player[j].armorhigh;
- owner[i]=j;
- bloody[i]=2;
- blooddrip[i]=5;
- }
-
- float gLoc[3];
- float vel[3];
- gLoc[0]=position[i].x;
- gLoc[1]=position[i].y;
- gLoc[2]=position[i].z;
- vel[0]=0;
- vel[1]=0;
- vel[2]=0;
- PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, TRUE);
- FSOUND_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
- FSOUND_SetVolume(channels[fleshstabsound], 128);
- FSOUND_SetPaused(channels[fleshstabsound], FALSE);
-
- if(animation[player[0].targetanimation].height==highheight){
- bonus=ninja;
- bonustime=0;
- bonusvalue=60;
- }
- else{
- bonus=Bullseyebonus;
- bonustime=0;
- bonusvalue=30;
- }
- }
- }
- else missed[i]=1;
- }
- }
- if(position[i].y<terrain.getHeight(position[i].x,position[i].z)){
- if(terrain.getOpacity(position[i].x,position[i].z)<.2){
- velocity[i]=0;
- if(terrain.lineTerrain(oldposition[i],position[i],&colpoint)!=-1){
- position[i]=colpoint*terrain.scale;
- }
- else position[i].y=terrain.getHeight(position[i].x,position[i].z);
-
- terrain.MakeDecal(shadowdecalpermanent,position[i],.06,.5,0);
- normalrot=terrain.getNormal(position[i].x,position[i].z)*-1;
- velocity[i]=0;
- //position[i]-=normalrot*.1;
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glPushMatrix();
- GLfloat M[16];
- glLoadIdentity();
- glRotatef(bigrotation[i],0,1,0);
- glRotatef(bigtilt2[i],1,0,0);
- glRotatef(bigtilt[i],0,0,1);
- glRotatef(-rotation1[i]+90,0,1,0);
- glRotatef(-rotation2[i]+90,0,0,1);
- glRotatef(-rotation3[i],0,1,0);
- glRotatef(smallrotation[i],1,0,0);
- glRotatef(smallrotation2[i],0,1,0);
- glTranslatef(0,0,1);
- glGetFloatv(GL_MODELVIEW_MATRIX,M);
- tippoint[i].x=M[12];
- tippoint[i].y=M[13];
- tippoint[i].z=M[14];
- glPopMatrix();
- position[i]-=tippoint[i]*.15;