4 extern float multiplier;
5 extern Animation animation[animation_count];
6 extern FSOUND_SAMPLE *samp[100];
7 extern int channels[100];
8 extern Terrain terrain;
10 extern int environment;
11 extern Sprites sprites;
13 extern FRUSTUM frustum;
15 extern float realmultiplier;
17 extern float slomodelay;
18 extern bool cellophane;
19 extern float texdetail;
20 extern GLubyte bloodText[512*512*3];
21 extern int bloodtoggle;
22 extern Objects objects;
24 extern bool autoslomo;
25 extern float camerashake;
27 extern float terraindetail;
28 extern float viewdistance;
29 extern float blackout;
30 extern int difficulty;
31 extern Person player[maxplayers];
32 extern int numplayers;
35 extern float bonusvalue;
36 extern float bonustotal;
37 extern float bonustime;
38 extern int tutoriallevel;
39 extern int numthrowkill;
40 extern "C" void PlaySoundEx(int channel, FSOUND_SAMPLE *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused);
42 void Weapons::DoStuff(){
43 static int i,whichpatchx,whichpatchz,j,k,whichhit,m;
44 static XYZ start,end,colpoint,normalrot,footvel,footpoint;
45 static XYZ terrainnormal;
48 static XYZ newpoint1,newpoint2;
49 static float friction=3.5;
50 static float elasticity=.4;
51 static XYZ bounceness;
52 static float frictionness;
53 static float moveamount;
55 static float closestdistance;
56 static float distance;
58 static XYZ closestpoint;
59 static XYZ closestswordpoint;
61 static float proportion;
62 static float tempmult;
66 for(i=0;i<numweapons;i++){
70 if(damage[i]>=2&&type[i]==staff&&owner[i]!=-1){
73 gLoc[0]=tippoint[i].x;
74 gLoc[1]=tippoint[i].y;
75 gLoc[2]=tippoint[i].z;
79 PlaySoundEx( staffbreaksound, samp[staffbreaksound], NULL, TRUE);
80 FSOUND_3D_SetAttributes(channels[staffbreaksound], gLoc, vel);
81 FSOUND_SetVolume(channels[staffbreaksound], 256);
82 FSOUND_SetPaused(channels[staffbreaksound], FALSE);
85 //speed=(tippoint[i]-oldtippoint[i])/multiplier/6;
88 tempvel.x=float(abs(Random()%100)-50)/20;
89 tempvel.y=float(abs(Random()%100)-50)/20;
90 tempvel.z=float(abs(Random()%100)-50)/20;
92 sprites.MakeSprite(cloudimpactsprite, position[i]+(tippoint[i]-position[i])*((float)j-2)/8,tempvel*.5, 115/255,73/255,12/255, .15+float(abs(Random()%100)-50)/1000, .7);
95 tempvel.x=float(abs(Random()%100)-50)/20;
96 tempvel.y=float(abs(Random()%100)-50)/20;
97 tempvel.z=float(abs(Random()%100)-50)/20;
99 sprites.MakeSprite(splintersprite, position[i]+(tippoint[i]-position[i])*((float)j-8)/32,tempvel*.5, 115/255,73/255,12/255, .1, 1);
111 player[tempowner].num_weapons--;
112 if(player[tempowner].num_weapons){
113 player[tempowner].weaponids[0]=player[tempowner].weaponids[player[tempowner].num_weapons];
114 if(player[tempowner].weaponstuck==player[tempowner].num_weapons)player[tempowner].weaponstuck=0;
116 player[tempowner].weaponactive=-1;
119 oldposition[i]=position[i];
120 oldtippoint[i]=tippoint[i];
121 if(owner[i]==-1&&(velocity[i].x||velocity[i].y||velocity[i].z)&&!physics[i]){
122 position[i]+=velocity[i]*multiplier;
123 tippoint[i]+=velocity[i]*multiplier;
124 whichpatchx=position[i].x/(terrain.size/subdivision*terrain.scale*terraindetail);
125 whichpatchz=position[i].z/(terrain.size/subdivision*terrain.scale*terraindetail);
126 if(whichpatchx>0&&whichpatchz>0&&whichpatchx<subdivision&&whichpatchz<subdivision)
127 if(terrain.patchobjectnum[whichpatchx][whichpatchz]){
128 for(j=0;j<terrain.patchobjectnum[whichpatchx][whichpatchz];j++){
129 k=terrain.patchobjects[whichpatchx][whichpatchz][j];
130 start=oldtippoint[i];
132 whichhit=objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.rotation[k]);
134 if(objects.type[k]==treetrunktype){
135 objects.model[k].MakeDecal(breakdecal,DoRotation(colpoint-objects.position[k],0,-objects.rotation[k],0),.1,1,Random()%360);
136 normalrot=DoRotation(objects.model[k].facenormals[whichhit],0,objects.rotation[k],0);
138 if(type[i]==knife)position[i]=colpoint-normalrot*.1;
139 if(type[i]==sword)position[i]=colpoint-normalrot*.2;
140 if(type[i]==staff)position[i]=colpoint-normalrot*.2;
141 XYZ temppoint1,temppoint2,tempforward;
145 temppoint2=normalrot;
146 distance=findDistance(&temppoint1,&temppoint2);
147 rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
148 rotation2[i]*=360/6.28;
151 rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
152 rotation1[i]*=360/6.28;
153 if(temppoint1.x>temppoint2.x)rotation1[i]=360-rotation1[i];
164 gLoc[0]=position[i].x;
165 gLoc[1]=position[i].y;
166 gLoc[2]=position[i].z;
170 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, TRUE);
171 FSOUND_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
172 FSOUND_SetVolume(channels[knifesheathesound], 128);
173 FSOUND_SetPaused(channels[knifesheathesound], FALSE);
177 sprites.MakeSprite(cloudimpactsprite, position[i],velocity[i], 1,1,1, .8, .3);
182 position[i]-=velocity[i]*multiplier;
183 tippoint[i]-=velocity[i]*multiplier;
184 tipvelocity[i]=velocity[i];
189 if(velocity[i].x||velocity[i].y||velocity[i].z)
190 for(j=0;j<numplayers;j++){
192 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;
193 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]){
194 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]){
196 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)){
199 gLoc[0]=player[j].coords.x;
200 gLoc[1]=player[j].coords.y;
201 gLoc[2]=player[j].coords.z;
202 vel[0]=player[j].velocity.x;
203 vel[1]=player[j].velocity.y;
204 vel[2]=player[j].velocity.z;
205 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, TRUE);
206 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
207 FSOUND_SetVolume(channels[knifedrawsound], 128);
208 FSOUND_SetPaused(channels[knifedrawsound], FALSE);
210 player[j].weaponactive=0;
211 player[j].targetanimation=removeknifeanim;
212 player[j].targetframe=1;
214 owner[i]=player[j].id;
215 if(player[j].num_weapons>0){
216 player[j].weaponids[player[j].num_weapons]=player[j].weaponids[0];
218 player[j].num_weapons++;
219 player[j].weaponids[0]=i;
221 player[j].aitype=attacktypecutoff;
224 if(j!=0)numthrowkill++;
225 player[j].num_weapons++;
226 player[j].weaponstuck=player[j].num_weapons-1;
227 if(normaldotproduct(player[j].facing,velocity[i])>0)player[j].weaponstuckwhere=1;
228 else player[j].weaponstuckwhere=0;
230 player[j].weaponids[player[j].num_weapons-1]=i;
232 player[j].RagDoll(0);
233 player[j].skeleton.joints[player[j].skeleton.jointlabels[abdomen]].velocity+=velocity[i]*2;
234 player[j].skeleton.joints[player[j].skeleton.jointlabels[neck]].velocity+=velocity[i]*2;
235 player[j].skeleton.joints[player[j].skeleton.jointlabels[rightshoulder]].velocity+=velocity[i]*2;
236 player[j].skeleton.joints[player[j].skeleton.jointlabels[leftshoulder]].velocity+=velocity[i]*2;
237 //player[j].Puff(abdomen);
238 if(bloodtoggle&&tutoriallevel!=1)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
239 if(tutoriallevel==1)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .8, .3);
240 footvel=tippoint[i]-position[i];
242 if(bloodtoggle&&tutoriallevel!=1)sprites.MakeSprite(bloodflamesprite, footpoint,footvel*-1, 1,0,0, .6, 1);
244 if(tutoriallevel!=1){
245 if(player[j].weaponstuckwhere==0)player[j].DoBloodBig(2,205);
246 if(player[j].weaponstuckwhere==1)player[j].DoBloodBig(2,200);
247 player[j].damage+=200/player[j].armorhigh;
248 player[j].deathbleeding=1;
249 player[j].bloodloss+=(200+abs((float)(Random()%40))-20)/player[j].armorhigh;
257 gLoc[0]=position[i].x;
258 gLoc[1]=position[i].y;
259 gLoc[2]=position[i].z;
263 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, TRUE);
264 FSOUND_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
265 FSOUND_SetVolume(channels[fleshstabsound], 128);
266 FSOUND_SetPaused(channels[fleshstabsound], FALSE);
268 if(animation[player[0].targetanimation].height==highheight){
283 if(position[i].y<terrain.getHeight(position[i].x,position[i].z)){
284 if(terrain.getOpacity(position[i].x,position[i].z)<.2){
286 if(terrain.lineTerrain(oldposition[i],position[i],&colpoint)!=-1){
287 position[i]=colpoint*terrain.scale;
289 else position[i].y=terrain.getHeight(position[i].x,position[i].z);
291 terrain.MakeDecal(shadowdecalpermanent,position[i],.06,.5,0);
292 normalrot=terrain.getNormal(position[i].x,position[i].z)*-1;
294 //position[i]-=normalrot*.1;
295 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
299 glRotatef(bigrotation[i],0,1,0);
300 glRotatef(bigtilt2[i],1,0,0);
301 glRotatef(bigtilt[i],0,0,1);
302 glRotatef(-rotation1[i]+90,0,1,0);
303 glRotatef(-rotation2[i]+90,0,0,1);
304 glRotatef(-rotation3[i],0,1,0);
305 glRotatef(smallrotation[i],1,0,0);
306 glRotatef(smallrotation2[i],0,1,0);
308 glGetFloatv(GL_MODELVIEW_MATRIX,M);
313 position[i]-=tippoint[i]*.15;
314 XYZ temppoint1,temppoint2,tempforward;
326 gLoc[0]=position[i].x;
327 gLoc[1]=position[i].y;
328 gLoc[2]=position[i].z;
332 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, TRUE);
333 FSOUND_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
334 FSOUND_SetVolume(channels[knifesheathesound], 128);
335 FSOUND_SetPaused(channels[knifesheathesound], FALSE);
338 terrainlight=terrain.getLighting(position[i].x,position[i].z);
339 if(environment==snowyenvironment){
340 if(findDistancefast(&position[i],&viewer)<viewdistance*viewdistance/4)sprites.MakeSprite(cloudsprite, position[i],velocity[i], terrainlight.x,terrainlight.y,terrainlight.z, .5, .7);
342 else if(environment==grassyenvironment){
343 if(findDistancefast(&position[i],&viewer)<viewdistance*viewdistance/4)sprites.MakeSprite(cloudsprite, position[i],velocity[i], terrainlight.x*90/255,terrainlight.y*70/255,terrainlight.z*8/255, .5, .5);
345 else if(environment==desertenvironment){
346 if(findDistancefast(&position[i],&viewer)<viewdistance*viewdistance/4)sprites.MakeSprite(cloudsprite, position[i],velocity[i], terrainlight.x*190/255,terrainlight.y*170/255,terrainlight.z*108/255, .5, .7);
354 position[i]-=velocity[i]*multiplier;
355 tippoint[i]-=velocity[i]*multiplier;
356 tipvelocity[i]=velocity[i];
359 if(velocity[i].x!=0||velocity[i].z!=0||velocity[i].y!=0){
360 velocity[i].y+=gravity*multiplier;
362 XYZ temppoint1,temppoint2,tempforward;
366 temppoint2=velocity[i];
367 distance=findDistance(&temppoint1,&temppoint2);
368 rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
369 rotation2[i]*=360/6.28;
372 rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
373 rotation1[i]*=360/6.28;
380 if(temppoint1.x>temppoint2.x)rotation1[i]=360-rotation1[i];
390 for(int l=0;l<10;l++){
391 if(owner[i]==-1&&(velocity[i].x||velocity[i].y||velocity[i].z)&&physics[i]){
393 position[i]+=velocity[i]*multiplier;
394 tippoint[i]+=tipvelocity[i]*multiplier;
397 midp=(position[i]*mass[i]+tippoint[i]*tipmass[i])/(mass[i]+tipmass[i]);
398 vel=tippoint[i]-midp;
400 newpoint1=midp-vel*length[i]*(tipmass[i]/(mass[i]+tipmass[i]));
401 newpoint2=midp+vel*length[i]*(mass[i]/(mass[i]+tipmass[i]));
403 if(freetime[i]>.04)velocity[i]=velocity[i]+(newpoint1-position[i])/multiplier;
404 if(freetime[i]>.04)tipvelocity[i]=tipvelocity[i]+(newpoint2-tippoint[i])/multiplier;
406 position[i]=newpoint1;
407 tippoint[i]=newpoint2;
411 whichpatchx=(position[i].x)/(terrain.size/subdivision*terrain.scale*terraindetail);
412 whichpatchz=(position[i].z)/(terrain.size/subdivision*terrain.scale*terraindetail);
413 if(whichpatchx>0&&whichpatchz>0&&whichpatchx<subdivision&&whichpatchz<subdivision)
414 if(terrain.patchobjectnum[whichpatchx][whichpatchz]){
415 for(j=0;j<terrain.patchobjectnum[whichpatchx][whichpatchz];j++){
416 k=terrain.patchobjects[whichpatchx][whichpatchz][j];
420 start=position[i]-(tippoint[i]-position[i])/5;
421 end=tippoint[i]+(tippoint[i]-position[i])/30;
422 whichhit=objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.rotation[k]);
425 diff=(colpoint-tippoint[i]);
429 position[i]+=(colpoint-tippoint[i])+diff*.05;
430 tippoint[i]=colpoint+diff*.05;
431 oldposition[i]=position[i];
432 oldtippoint[i]=tippoint[i];
436 start=tippoint[i]-(position[i]-tippoint[i])/5;
437 end=position[i]+(position[i]-tippoint[i])/30;
438 whichhit=objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.rotation[k]);
441 diff=(colpoint-position[i]);
445 tippoint[i]+=(colpoint-position[i])+diff*.05;
446 position[i]=colpoint+diff*.05;
447 oldtippoint[i]=tippoint[i];
448 oldposition[i]=tippoint[i];
453 start=oldposition[i];
455 whichhit=objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.rotation[k]);
458 position[i]=colpoint;
459 terrainnormal=DoRotation(objects.model[k].facenormals[whichhit],0,objects.rotation[k],0)*-1;
460 ReflectVector(&velocity[i],&terrainnormal);
461 position[i]+=terrainnormal*.002;
463 bounceness=terrainnormal*findLength(&velocity[i])*(abs(normaldotproduct(velocity[i],terrainnormal)));
464 if(findLengthfast(&velocity[i])<findLengthfast(&bounceness))bounceness=0;
465 frictionness=abs(normaldotproduct(velocity[i],terrainnormal));
466 velocity[i]-=bounceness;
467 if(1-friction*frictionness>0)velocity[i]*=1-friction*frictionness;
469 velocity[i]+=bounceness*elasticity;
471 if(findLengthfast(&bounceness)>1){
474 //int whichsound=clank1sound+abs(Random()%4);
476 if(type[i]==staff)whichsound=footstepsound3+abs(Random()%2);
477 if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4);gLoc[0]=position[i].x;
478 gLoc[1]=position[i].y;
479 gLoc[2]=position[i].z;
483 PlaySoundEx( whichsound, samp[whichsound], NULL, TRUE);
484 FSOUND_3D_SetAttributes(channels[whichsound], gLoc, vel);
485 FSOUND_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness));
486 FSOUND_SetPaused(channels[whichsound], FALSE);
489 start=oldtippoint[i];
491 whichhit=objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.rotation[k]);
494 tippoint[i]=colpoint;
495 terrainnormal=DoRotation(objects.model[k].facenormals[whichhit],0,objects.rotation[k],0)*-1;
496 ReflectVector(&tipvelocity[i],&terrainnormal);
497 tippoint[i]+=terrainnormal*.002;
499 bounceness=terrainnormal*findLength(&tipvelocity[i])*(abs(normaldotproduct(tipvelocity[i],terrainnormal)));
500 if(findLengthfast(&tipvelocity[i])<findLengthfast(&bounceness))bounceness=0;
501 frictionness=abs(normaldotproduct(tipvelocity[i],terrainnormal));
502 tipvelocity[i]-=bounceness;
503 if(1-friction*frictionness>0)tipvelocity[i]*=1-friction*frictionness;
504 else tipvelocity[i]=0;
505 tipvelocity[i]+=bounceness*elasticity;
507 if(findLengthfast(&bounceness)>1){
510 //int whichsound=clank1sound+abs(Random()%4);
512 if(type[i]==staff)whichsound=footstepsound3+abs(Random()%2);
513 if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4);gLoc[0]=position[i].x;
514 gLoc[0]=position[i].x;
515 gLoc[1]=position[i].y;
516 gLoc[2]=position[i].z;
520 PlaySoundEx( whichsound, samp[whichsound], NULL, TRUE);
521 FSOUND_3D_SetAttributes(channels[whichsound], gLoc, vel);
522 FSOUND_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness));
523 FSOUND_SetPaused(channels[whichsound], FALSE);
527 if((objects.type[k]!=boxtype&&objects.type[k]!=platformtype&&objects.type[k]!=walltype&&objects.type[k]!=weirdtype)||objects.rotation2[k]!=0)
529 mid=(position[i]*(21+(float)m*10)+tippoint[i]*(19-(float)m*10))/40;
531 oldmid=(oldposition[i]*(21+(float)m*10)+oldtippoint[i]*(19-(float)m*10))/40;
535 whichhit=objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.rotation[k]);
539 terrainnormal=DoRotation(objects.model[k].facenormals[whichhit],0,objects.rotation[k],0)*-1;
540 ReflectVector(&velocity[i],&terrainnormal);
542 bounceness=terrainnormal*findLength(&velocity[i])*(abs(normaldotproduct(velocity[i],terrainnormal)));
543 if(findLengthfast(&velocity[i])<findLengthfast(&bounceness))bounceness=0;
544 frictionness=abs(normaldotproduct(velocity[i],terrainnormal));
545 velocity[i]-=bounceness;
546 if(1-friction*frictionness>0)velocity[i]*=1-friction*frictionness;
548 velocity[i]+=bounceness*elasticity;
550 if(findLengthfast(&bounceness)>1){
553 //int whichsound=clank1sound+abs(Random()%4);
555 if(type[i]==staff)whichsound=footstepsound3+abs(Random()%2);
556 if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4);gLoc[0]=mid.x;
562 PlaySoundEx( whichsound, samp[whichsound], NULL, TRUE);
563 FSOUND_3D_SetAttributes(channels[whichsound], gLoc, vel);
564 FSOUND_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness));
565 FSOUND_SetPaused(channels[whichsound], FALSE);
567 position[i]+=(mid-oldmid2)*(20/(1+(float)m*10));
570 mid=(position[i]*(19-(float)m*10)+tippoint[i]*(21+(float)m*10))/40;
572 oldmid=(oldposition[i]*(19-(float)m*10)+oldtippoint[i]*(21+(float)m*10))/40;
576 whichhit=objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.rotation[k]);
580 terrainnormal=DoRotation(objects.model[k].facenormals[whichhit],0,objects.rotation[k],0)*-1;
581 ReflectVector(&tipvelocity[i],&terrainnormal);
583 bounceness=terrainnormal*findLength(&tipvelocity[i])*(abs(normaldotproduct(tipvelocity[i],terrainnormal)));
584 if(findLengthfast(&tipvelocity[i])<findLengthfast(&bounceness))bounceness=0;
585 frictionness=abs(normaldotproduct(tipvelocity[i],terrainnormal));
586 tipvelocity[i]-=bounceness;
587 if(1-friction*frictionness>0)tipvelocity[i]*=1-friction*frictionness;
588 else tipvelocity[i]=0;
589 tipvelocity[i]+=bounceness*elasticity;
591 if(findLengthfast(&bounceness)>1){
594 //int whichsound=clank1sound+abs(Random()%4);
596 if(type[i]==staff)whichsound=footstepsound3+abs(Random()%2);
597 if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4);gLoc[0]=mid.x;
603 PlaySoundEx( whichsound, samp[whichsound], NULL, TRUE);
604 FSOUND_3D_SetAttributes(channels[whichsound], gLoc, vel);
605 FSOUND_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness));
606 FSOUND_SetPaused(channels[whichsound], FALSE);
608 tippoint[i]+=(mid-oldmid2)*(20/(1+(float)m*10));
615 whichhit=objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.rotation[k]);
619 closestswordpoint=colpoint;//(position[i]+tippoint[i])/2;
620 point[0]=DoRotation(objects.model[k].vertex[objects.model[k].Triangles[whichhit].vertex[0]],0,objects.rotation[k],0)+objects.position[k];
621 point[1]=DoRotation(objects.model[k].vertex[objects.model[k].Triangles[whichhit].vertex[1]],0,objects.rotation[k],0)+objects.position[k];
622 point[2]=DoRotation(objects.model[k].vertex[objects.model[k].Triangles[whichhit].vertex[2]],0,objects.rotation[k],0)+objects.position[k];
623 if(DistancePointLine(&closestswordpoint, &point[0], &point[1], &distance,&colpoint ))
624 if(distance<closestdistance||closestdistance==-1){
625 closestpoint=colpoint;
626 closestdistance=distance;
629 if(DistancePointLine(&closestswordpoint, &point[1], &point[2], &distance,&colpoint ))
630 if(distance<closestdistance||closestdistance==-1){
631 closestpoint=colpoint;
632 closestdistance=distance;
635 if(DistancePointLine(&closestswordpoint, &point[2], &point[0], &distance,&colpoint ))
636 if(distance<closestdistance||closestdistance==-1){
637 closestpoint=colpoint;
638 closestdistance=distance;
641 if(closestdistance!=-1&&isnormal(closestdistance)){
642 if(DistancePointLine(&closestpoint, &position[i], &tippoint[i], &distance,&colpoint )){
643 closestswordpoint=colpoint;
644 velocity[i]+=(closestpoint-closestswordpoint);
645 tipvelocity[i]+=(closestpoint-closestswordpoint);
646 position[i]+=(closestpoint-closestswordpoint);
647 tippoint[i]+=(closestpoint-closestswordpoint);
656 whichhit=terrain.lineTerrain(oldposition[i],position[i],&colpoint);
657 if(whichhit!=-1||position[i].y<terrain.getHeight(position[i].x,position[i].z)){
659 if(whichhit!=-1)position[i]=colpoint*terrain.scale;
660 else position[i].y=terrain.getHeight(position[i].x,position[i].z);
662 terrainnormal=terrain.getNormal(position[i].x,position[i].z);
663 ReflectVector(&velocity[i],&terrainnormal);
664 position[i]+=terrainnormal*.002;
665 bounceness=terrainnormal*findLength(&velocity[i])*(abs(normaldotproduct(velocity[i],terrainnormal)));
666 if(findLengthfast(&velocity[i])<findLengthfast(&bounceness))bounceness=0;
667 frictionness=abs(normaldotproduct(velocity[i],terrainnormal));
668 velocity[i]-=bounceness;
669 if(1-friction*frictionness>0)velocity[i]*=1-friction*frictionness;
671 if(terrain.getOpacity(position[i].x,position[i].z)<.2)velocity[i]+=bounceness*elasticity*.3;
672 else velocity[i]+=bounceness*elasticity;
673 //if (type[i]==knife) printf("velocity of knife %d now %f,%f,%f.\n", i, velocity[i].x, velocity[i].y, velocity[i].z);
674 if(findLengthfast(&bounceness)>1){
678 if(terrain.getOpacity(position[i].x,position[i].z)>.2){
679 if(type[i]==staff)whichsound=footstepsound3+abs(Random()%2);
680 if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4);
682 else whichsound=footstepsound+abs(Random()%2);
683 gLoc[0]=position[i].x;
684 gLoc[1]=position[i].y;
685 gLoc[2]=position[i].z;
689 PlaySoundEx( whichsound, samp[whichsound], NULL, TRUE);
690 FSOUND_3D_SetAttributes(channels[whichsound], gLoc, vel);
691 if(terrain.getOpacity(position[i].x,position[i].z)>.2)FSOUND_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness));
692 else FSOUND_SetVolume(channels[whichsound], 32*findLengthfast(&bounceness));
693 FSOUND_SetPaused(channels[whichsound], FALSE);
695 if(terrain.getOpacity(position[i].x,position[i].z)<.2){
697 terrainlight=terrain.getLighting(position[i].x,position[i].z);
698 if(environment==snowyenvironment){
699 if(findDistancefast(&position[i],&viewer)<viewdistance*viewdistance/4)sprites.MakeSprite(cloudsprite, position[i],velocity[i], terrainlight.x,terrainlight.y,terrainlight.z, .5, .7);
701 else if(environment==grassyenvironment){
702 if(findDistancefast(&position[i],&viewer)<viewdistance*viewdistance/4)sprites.MakeSprite(cloudsprite, position[i],velocity[i], terrainlight.x*90/255,terrainlight.y*70/255,terrainlight.z*8/255, .5, .5);
704 else if(environment==desertenvironment){
705 if(findDistancefast(&position[i],&viewer)<viewdistance*viewdistance/4)sprites.MakeSprite(cloudsprite, position[i],velocity[i], terrainlight.x*190/255,terrainlight.y*170/255,terrainlight.z*108/255, .5, .7);
710 whichhit=terrain.lineTerrain(oldtippoint[i],tippoint[i],&colpoint);
711 if(whichhit!=-1||tippoint[i].y<terrain.getHeight(tippoint[i].x,tippoint[i].z)){
712 if(whichhit!=-1)tippoint[i]=colpoint*terrain.scale;
713 else tippoint[i].y=terrain.getHeight(tippoint[i].x,tippoint[i].z);
715 terrainnormal=terrain.getNormal(tippoint[i].x,tippoint[i].z);
716 ReflectVector(&tipvelocity[i],&terrainnormal);
717 tippoint[i]+=terrainnormal*.002;
718 bounceness=terrainnormal*findLength(&tipvelocity[i])*(abs(normaldotproduct(tipvelocity[i],terrainnormal)));
719 if(findLengthfast(&tipvelocity[i])<findLengthfast(&bounceness))bounceness=0;
720 frictionness=abs(normaldotproduct(tipvelocity[i],terrainnormal));
721 tipvelocity[i]-=bounceness;
722 if(1-friction*frictionness>0)tipvelocity[i]*=1-friction*frictionness;
723 else tipvelocity[i]=0;
724 if(terrain.getOpacity(tippoint[i].x,tippoint[i].z)<.2)tipvelocity[i]+=bounceness*elasticity*.3;
725 else tipvelocity[i]+=bounceness*elasticity;
726 //if (type[i]==knife) printf("tipvelocity of knife %d now %f,%f,%f.\n", i, tipvelocity[i].x, tipvelocity[i].y, tipvelocity[i].z);
728 if(findLengthfast(&bounceness)>1){
732 if(terrain.getOpacity(tippoint[i].x,tippoint[i].z)>.2){
733 if(type[i]==staff)whichsound=footstepsound3+abs(Random()%2);
734 if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4);
736 else whichsound=footstepsound+abs(Random()%2);
737 gLoc[0]=tippoint[i].x;
738 gLoc[1]=tippoint[i].y;
739 gLoc[2]=tippoint[i].z;
743 PlaySoundEx( whichsound, samp[whichsound], NULL, TRUE);
744 FSOUND_3D_SetAttributes(channels[whichsound], gLoc, vel);
745 if(terrain.getOpacity(tippoint[i].x,tippoint[i].z)>.2)FSOUND_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness));
746 else FSOUND_SetVolume(channels[whichsound], 32*findLengthfast(&bounceness));
747 FSOUND_SetPaused(channels[whichsound], FALSE);
749 if(terrain.getOpacity(tippoint[i].x,tippoint[i].z)<.2){
751 terrainlight=terrain.getLighting(tippoint[i].x,tippoint[i].z);
752 if(environment==snowyenvironment){
753 if(findDistancefast(&tippoint[i],&viewer)<viewdistance*viewdistance/4)sprites.MakeSprite(cloudsprite, tippoint[i],tipvelocity[i], terrainlight.x,terrainlight.y,terrainlight.z, .5, .7);
755 else if(environment==grassyenvironment){
756 if(findDistancefast(&tippoint[i],&viewer)<viewdistance*viewdistance/4)sprites.MakeSprite(cloudsprite, tippoint[i],tipvelocity[i], terrainlight.x*90/255,terrainlight.y*70/255,terrainlight.z*8/255, .5, .5);
758 else if(environment==desertenvironment){
759 if(findDistancefast(&tippoint[i],&viewer)<viewdistance*viewdistance/4)sprites.MakeSprite(cloudsprite, tippoint[i],tipvelocity[i], terrainlight.x*190/255,terrainlight.y*170/255,terrainlight.z*108/255, .5, .7);
766 mid=position[i]+tippoint[i];
768 mid+=(position[i]-mid)/20;
770 if(mid.y<terrain.getHeight(mid.x,mid.z)){
772 mid.y=terrain.getHeight(mid.x,mid.z);
774 terrainnormal=terrain.getNormal(mid.x,mid.z);
775 ReflectVector(&velocity[i],&terrainnormal);
776 //mid+=terrainnormal*.002;
777 bounceness=terrainnormal*findLength(&velocity[i])*(abs(normaldotproduct(velocity[i],terrainnormal)));
778 if(findLengthfast(&velocity[i])<findLengthfast(&bounceness))bounceness=0;
779 frictionness=abs(normaldotproduct(velocity[i],terrainnormal));
780 velocity[i]-=bounceness;
781 if(1-friction*frictionness>0)velocity[i]*=1-friction*frictionness;
783 if(terrain.getOpacity(mid.x,mid.z)<.2)velocity[i]+=bounceness*elasticity*.3;
784 else velocity[i]+=bounceness*elasticity;
786 if(findLengthfast(&bounceness)>1){
790 if(terrain.getOpacity(mid.x,mid.z)>.2){
791 if(type[i]==staff)whichsound=footstepsound3+abs(Random()%2);
792 if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4);
794 else whichsound=footstepsound+abs(Random()%2);
801 PlaySoundEx( whichsound, samp[whichsound], NULL, TRUE);
802 FSOUND_3D_SetAttributes(channels[whichsound], gLoc, vel);
803 if(terrain.getOpacity(position[i].x,position[i].z)>.2)FSOUND_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness));
804 else FSOUND_SetVolume(channels[whichsound], 32*findLengthfast(&bounceness));
805 FSOUND_SetPaused(channels[whichsound], FALSE);
807 position[i]+=(mid-oldmid)*20;
810 mid=position[i]+tippoint[i];
812 mid+=(tippoint[i]-mid)/20;
814 if(mid.y<terrain.getHeight(mid.x,mid.z)){
816 mid.y=terrain.getHeight(mid.x,mid.z);
818 terrainnormal=terrain.getNormal(mid.x,mid.z);
819 ReflectVector(&tipvelocity[i],&terrainnormal);
820 //mid+=terrainnormal*.002;
821 bounceness=terrainnormal*findLength(&tipvelocity[i])*(abs(normaldotproduct(tipvelocity[i],terrainnormal)));
822 if(findLengthfast(&tipvelocity[i])<findLengthfast(&bounceness))bounceness=0;
823 frictionness=abs(normaldotproduct(tipvelocity[i],terrainnormal));
824 tipvelocity[i]-=bounceness;
825 if(1-friction*frictionness>0)tipvelocity[i]*=1-friction*frictionness;
826 else tipvelocity[i]=0;
827 if(terrain.getOpacity(mid.x,mid.z)<.2)tipvelocity[i]+=bounceness*elasticity*.3;
828 else tipvelocity[i]+=bounceness*elasticity;
830 if(findLengthfast(&bounceness)>1){
834 if(terrain.getOpacity(mid.x,mid.z)>.2){
835 if(type[i]==staff)whichsound=footstepsound3+abs(Random()%2);
836 if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4);
838 else whichsound=footstepsound+abs(Random()%2);
845 PlaySoundEx( whichsound, samp[whichsound], NULL, TRUE);
846 FSOUND_3D_SetAttributes(channels[whichsound], gLoc, vel);
847 if(terrain.getOpacity(position[i].x,position[i].z)>.2)FSOUND_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness));
848 else FSOUND_SetVolume(channels[whichsound], 32*findLengthfast(&bounceness));
849 FSOUND_SetPaused(channels[whichsound], FALSE);
851 tippoint[i]+=(mid-oldmid)*20;
854 mid=position[i]+tippoint[i];
856 if(position[i].y<terrain.getHeightExtrude(mid.x,mid.z,position[i].x,position[i].z)){
858 position[i].y=terrain.getHeightExtrude(mid.x,mid.z,position[i].x,position[i].z);
860 terrainnormal=terrain.getNormal(mid.x,mid.z);
861 ReflectVector(&velocity[i],&terrainnormal);
862 position[i]+=terrainnormal*.002;
863 bounceness=terrainnormal*findLength(&velocity[i])*(abs(normaldotproduct(velocity[i],terrainnormal)));
864 if(findLengthfast(&velocity[i])<findLengthfast(&bounceness))bounceness=0;
865 frictionness=abs(normaldotproduct(velocity[i],terrainnormal));
866 velocity[i]-=bounceness;
867 if(1-friction*frictionness>0)velocity[i]*=1-friction*frictionness;
869 if(terrain.getOpacity(mid.x,mid.z)<.2)velocity[i]+=bounceness*elasticity*.3;
870 else velocity[i]+=bounceness*elasticity;
872 if(findLengthfast(&bounceness)>1){
876 if(terrain.getOpacity(mid.x,mid.z)>.2){
877 if(type[i]==staff)whichsound=footstepsound3+abs(Random()%2);
878 if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4);
880 else whichsound=footstepsound+abs(Random()%2);
881 gLoc[0]=position[i].x;
882 gLoc[1]=position[i].y;
883 gLoc[2]=position[i].z;
887 PlaySoundEx( whichsound, samp[whichsound], NULL, TRUE);
888 FSOUND_3D_SetAttributes(channels[whichsound], gLoc, vel);
889 if(terrain.getOpacity(position[i].x,position[i].z)>.2)FSOUND_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness));
890 else FSOUND_SetVolume(channels[whichsound], 32*findLengthfast(&bounceness));
891 FSOUND_SetPaused(channels[whichsound], FALSE);
895 if(tippoint[i].y<terrain.getHeightExtrude(mid.x,mid.z,tippoint[i].x,tippoint[i].z)){
897 tippoint[i].y=terrain.getHeightExtrude(mid.x,mid.z,tippoint[i].x,tippoint[i].z);
899 terrainnormal=terrain.getNormal(mid.x,mid.z);
900 ReflectVector(&tipvelocity[i],&terrainnormal);
901 tippoint[i]+=terrainnormal*.002;
902 bounceness=terrainnormal*findLength(&tipvelocity[i])*(abs(normaldotproduct(tipvelocity[i],terrainnormal)));
903 if(findLengthfast(&tipvelocity[i])<findLengthfast(&bounceness))bounceness=0;
904 frictionness=abs(normaldotproduct(tipvelocity[i],terrainnormal));
905 tipvelocity[i]-=bounceness;
906 if(1-friction*frictionness>0)tipvelocity[i]*=1-friction*frictionness;
907 else tipvelocity[i]=0;
908 if(terrain.getOpacity(mid.x,mid.z)<.2)tipvelocity[i]+=bounceness*elasticity*.3;
909 else tipvelocity[i]+=bounceness*elasticity;
911 if(findLengthfast(&bounceness)>1){
915 if(terrain.getOpacity(mid.x,mid.z)>.2){
916 if(type[i]==staff)whichsound=footstepsound3+abs(Random()%2);
917 if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4);
919 else whichsound=footstepsound+abs(Random()%2);
920 gLoc[0]=tippoint[i].x;
921 gLoc[1]=tippoint[i].y;
922 gLoc[2]=tippoint[i].z;
926 PlaySoundEx( whichsound, samp[whichsound], NULL, TRUE);
927 FSOUND_3D_SetAttributes(channels[whichsound], gLoc, vel);
928 if(terrain.getOpacity(tippoint[i].x,tippoint[i].z)>.2)FSOUND_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness));
929 else FSOUND_SetVolume(channels[whichsound], 32*findLengthfast(&bounceness));
930 FSOUND_SetPaused(channels[whichsound], FALSE);
934 //Fix terrain edge collision
937 whichhit=terrain.lineTerrain(start,end,&colpoint);
948 tipvelocity[i].y+=.1;
951 whichhit=terrain.lineTerrain(start,end,&colpoint);
953 closestpoint=colpoint*terrain.scale;
958 tipvelocity[i].y-=.1;
961 whichhit=terrain.lineTerrain(start,end,&colpoint);
966 tipvelocity[i].y+=.01;
969 whichhit=terrain.lineTerrain(start,end,&colpoint);
971 closestpoint=colpoint*terrain.scale;
975 whichhit=terrain.lineTerrain(end,start,&closestswordpoint);
977 colpoint=(closestswordpoint*terrain.scale+colpoint*terrain.scale)/2;
978 proportion=findDistance(&tippoint[i],&colpoint)/findDistance(&position[i],&tippoint[i]);
981 position[i].y+=.1*proportion;
982 tippoint[i].y+=.1*(1-proportion);
983 velocity[i].y+=.1*proportion;
984 tipvelocity[i].y+=.1*(1-proportion);
987 whichhit=terrain.lineTerrain(start,end,&colpoint);
989 position[i].y-=.1*proportion;
990 tippoint[i].y-=.1*(1-proportion);
991 velocity[i].y-=.1*proportion;
992 tipvelocity[i].y-=.1*(1-proportion);
995 whichhit=terrain.lineTerrain(start,end,&colpoint);
997 position[i].y+=.01*proportion;
998 tippoint[i].y+=.01*(1-proportion);
999 velocity[i].y+=.01*proportion;
1000 tipvelocity[i].y+=.01*(1-proportion);
1003 whichhit=terrain.lineTerrain(start,end,&colpoint);
1010 velocity[i].y+=gravity*multiplier;
1011 tipvelocity[i].y+=gravity*multiplier;
1012 //position[i].y+=gravity*multiplier*multiplier;
1013 //tippoint[i].y+=gravity*multiplier*multiplier;
1016 XYZ temppoint1,temppoint2,tempforward;
1019 temppoint1=position[i];
1020 temppoint2=tippoint[i];
1021 distance=findDistance(&temppoint1,&temppoint2);
1022 rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
1023 rotation2[i]*=360/6.28;
1026 rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
1027 rotation1[i]*=360/6.28;
1029 smallrotation[i]=90;
1030 smallrotation2[i]=0;
1034 if(temppoint1.x>temppoint2.x)rotation1[i]=360-rotation1[i];
1037 if(findLengthfast(&velocity[i])<.3&&findLengthfast(&tipvelocity[i])<.3&&hitsomething[i]){
1038 freetime[i]+=multiplier;
1041 //velocity[i]=(position[i]-oldposition[i])/multiplier;
1042 //tipvelocity[i]==(tippoint[i-+oldtippoint[i])/multiplier;
1050 multiplier=tempmult;
1051 if(blooddrip[i]&&bloody[i]){
1052 blooddripdelay[i]-=blooddrip[i]*multiplier/2;
1053 blooddrip[i]-=multiplier;
1054 if(blooddrip[i]<0)blooddrip[i]=0;
1055 if(blooddrip[i]>5)blooddrip[i]=5;
1056 if(blooddripdelay[i]<0&&bloodtoggle){
1057 blooddripdelay[i]=1;
1060 bloodloc=position[i]+(tippoint[i]-position[i])*.7;
1064 sprites.MakeSprite(bloodsprite, bloodloc,bloodvel, 1,1,1, .03, 1);
1069 flamedelay[i]-=multiplier;
1070 if(onfire[i]&&flamedelay[i]<=0){
1072 flamedelay[i]-=multiplier;
1075 normalrot=player[owner[i]].velocity;
1079 if(player[owner[i]].onterrain){
1083 sprites.MakeSprite(weaponflamesprite, position[i]+tippoint[i]*(((float)abs(Random()%100))/600+.05),normalrot, 1,1,1, (.6+(float)abs(Random()%100)/200-.25)*1/3, 1);
1084 sprites.speed[sprites.numsprites-1]=4;
1085 sprites.alivetime[sprites.numsprites-1]=.3;
1089 if(!onfire[i]&&owner[i]==-1&&type[i]!=staff){
1090 flamedelay[i]-=multiplier;
1091 if(flamedelay[i]<=0){
1093 flamedelay[i]-=multiplier;
1095 if(Random()%50==0&&findDistancefast(&position[i],&viewer)>80){
1097 shinepoint=position[i]+(tippoint[i]-position[i])*(((float)abs(Random()%100))/100);
1098 sprites.MakeSprite(weaponshinesprite, shinepoint,normalrot, 1,1,1, (.1+(float)abs(Random()%100)/200-.25)*1/3*fast_sqrt(findDistance(&shinepoint,&viewer)), 1);
1099 sprites.speed[sprites.numsprites-1]=4;
1100 sprites.alivetime[sprites.numsprites-1]=.3;
1110 static XYZ terrainlight;
1111 static GLfloat M[16];
1113 glAlphaFunc(GL_GREATER, 0.9);
1114 glEnable(GL_TEXTURE_2D);
1116 glEnable(GL_CULL_FACE);
1117 glCullFace(GL_FRONT);
1119 for(i=0;i<numweapons;i++)
1121 if((frustum.SphereInFrustum(position[i].x,position[i].y,position[i].z,1)&&findDistancefast(&viewer,&position[i])<viewdistance*viewdistance))
1127 if(velocity[i].x&&!physics[i])drawhowmany[i]=10;
1128 else drawhowmany[i]=1;
1132 if(player[owner[i]].occluded<25)
1133 if((frustum.SphereInFrustum(player[owner[i]].coords.x,player[owner[i]].coords.y+player[owner[i]].scale*3,player[owner[i]].coords.z,player[owner[i]].scale*8)&&findDistancefast(&viewer,&player[owner[i]].coords)<viewdistance*viewdistance)||player[owner[i]].skeleton.free==3)
1135 if((player[owner[i]].targetanimation==knifeslashstartanim||player[owner[i]].targetanimation==swordsneakattackanim||(player[owner[i]].currentanimation==staffhitanim&&player[owner[i]].currentframe>1)||(player[owner[i]].currentanimation==staffhitreversedanim&&player[owner[i]].currentframe>1)||(player[owner[i]].currentanimation==staffspinhitanim&&player[owner[i]].currentframe>1)||(player[owner[i]].currentanimation==staffspinhitreversedanim&&player[owner[i]].currentframe>1)||(player[owner[i]].currentanimation==staffgroundsmashanim&&player[owner[i]].currentframe>1)||(player[owner[i]].targetanimation==swordslashanim&&player[owner[i]].targetframe<7)||player[owner[i]].targetanimation==crouchstabanim||player[owner[i]].targetanimation==swordslashreversalanim||player[owner[i]].targetanimation==swordslashreversedanim||player[owner[i]].targetanimation==knifefollowanim||player[owner[i]].targetanimation==swordgroundstabanim||player[owner[i]].targetanimation==knifethrowanim)&&player[owner[i]].targetanimation==lastdrawnanim[i]&&!player[owner[i]].skeleton.free)
1139 else drawhowmany[i]=1;
1140 if(player[owner[i]].targetanimation==swordgroundstabanim)
1142 lastdrawnrotation1[i]=rotation1[i];
1143 lastdrawnrotation2[i]=rotation2[i];
1144 lastdrawnrotation3[i]=rotation3[i];
1145 lastdrawnbigrotation[i]=bigrotation[i];
1146 lastdrawnbigtilt[i]=bigtilt[i];
1147 lastdrawnbigtilt2[i]=bigtilt2[i];
1148 lastdrawnsmallrotation[i]=smallrotation[i];
1149 lastdrawnsmallrotation2[i]=smallrotation2[i];
1154 terrainlight=terrain.getLighting(position[i].x,position[i].z);
1155 if(drawhowmany[i]>0)
1157 glAlphaFunc(GL_GREATER, 0.01);
1159 for(j=drawhowmany[i];j>0;j--)
1161 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1163 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,j/drawhowmany[i]);
1164 if(owner[i]!=-1)glTranslatef(position[i].x*(((float)(j))/drawhowmany[i])+lastdrawnposition[i].x*(1-((float)(j))/drawhowmany[i]),position[i].y*(((float)(j))/drawhowmany[i])-.02+lastdrawnposition[i].y*(1-((float)(j))/drawhowmany[i]),position[i].z*(((float)(j))/drawhowmany[i])+lastdrawnposition[i].z*(1-((float)(j))/drawhowmany[i]));
1165 if(owner[i]==-1)glTranslatef(position[i].x*(((float)(j))/drawhowmany[i])+lastdrawnposition[i].x*(1-((float)(j))/drawhowmany[i]),position[i].y*(((float)(j))/drawhowmany[i])+lastdrawnposition[i].y*(1-((float)(j))/drawhowmany[i]),position[i].z*(((float)(j))/drawhowmany[i])+lastdrawnposition[i].z*(1-((float)(j))/drawhowmany[i]));
1166 //glTranslatef(position[i].x,position[i].y-.02,position[i].z);
1167 glRotatef(bigrotation[i]*(((float)(j))/drawhowmany[i])+lastdrawnbigrotation[i]*(1-((float)(j))/drawhowmany[i]),0,1,0);
1168 glRotatef(bigtilt2[i]*(((float)(j))/drawhowmany[i])+lastdrawnbigtilt2[i]*(1-((float)(j))/drawhowmany[i]),1,0,0);
1169 glRotatef(bigtilt[i]*(((float)(j))/drawhowmany[i])+lastdrawnbigtilt[i]*(1-((float)(j))/drawhowmany[i]),0,0,1);
1170 glRotatef(-rotation1[i]*(((float)(j))/drawhowmany[i])-lastdrawnrotation1[i]*(1-((float)(j))/drawhowmany[i])+90,0,1,0);
1171 glRotatef(-rotation2[i]*(((float)(j))/drawhowmany[i])-lastdrawnrotation2[i]*(1-((float)(j))/drawhowmany[i])+90,0,0,1);
1172 glRotatef(-rotation3[i]*(((float)(j))/drawhowmany[i])-lastdrawnrotation3[i]*(1-((float)(j))/drawhowmany[i]),0,1,0);
1173 glRotatef(smallrotation[i]*(((float)(j))/drawhowmany[i])+lastdrawnsmallrotation[i]*(1-((float)(j))/drawhowmany[i]),1,0,0);
1174 glRotatef(smallrotation2[i]*(((float)(j))/drawhowmany[i])+lastdrawnsmallrotation2[i]*(1-((float)(j))/drawhowmany[i]),0,1,0);
1178 if(player[owner[i]].targetanimation==staffhitanim||player[owner[i]].currentanimation==staffhitanim||player[owner[i]].targetanimation==staffhitreversedanim||player[owner[i]].currentanimation==staffhitreversedanim)
1180 glTranslatef(0,0,-.3);
1182 if(player[owner[i]].targetanimation==staffgroundsmashanim||player[owner[i]].currentanimation==staffgroundsmashanim||player[owner[i]].targetanimation==staffspinhitreversedanim||player[owner[i]].currentanimation==staffspinhitreversedanim||player[owner[i]].targetanimation==staffspinhitanim||player[owner[i]].currentanimation==staffspinhitanim)
1184 glTranslatef(0,0,-.1);
1187 /*if(type[i]==knife){
1189 if(!physics[i]&&findDistance(&position[i],&oldposition[i])*5>1)glScalef(1,1,findDistance(&position[i],&oldposition[i])*5);
1195 glEnable(GL_LIGHTING);
1196 if(!bloody[i]||!bloodtoggle)throwingknifemodel.drawdifftex(knifetextureptr);
1199 if(bloody[i]==1)throwingknifemodel.drawdifftex(lightbloodknifetextureptr);
1200 if(bloody[i]==2)throwingknifemodel.drawdifftex(bloodknifetextureptr);
1205 glEnable(GL_LIGHTING);
1206 if(!bloody[i]||!bloodtoggle)swordmodel.drawdifftex(swordtextureptr);
1209 if(bloody[i]==1)swordmodel.drawdifftex(lightbloodswordtextureptr);
1210 if(bloody[i]==2)swordmodel.drawdifftex(bloodswordtextureptr);
1215 glEnable(GL_LIGHTING);
1216 staffmodel.drawdifftex(stafftextureptr);
1222 lastdrawnposition[i]=position[i];
1223 lastdrawntippoint[i]=tippoint[i];
1224 lastdrawnrotation1[i]=rotation1[i];
1225 lastdrawnrotation2[i]=rotation2[i];
1226 lastdrawnrotation3[i]=rotation3[i];
1227 lastdrawnbigrotation[i]=bigrotation[i];
1228 lastdrawnbigtilt[i]=bigtilt[i];
1229 lastdrawnbigtilt2[i]=bigtilt2[i];
1230 lastdrawnsmallrotation[i]=smallrotation[i];
1231 lastdrawnsmallrotation2[i]=smallrotation2[i];
1232 if(owner[i]!=-1)lastdrawnanim[i]=player[owner[i]].currentanimation;
1236 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1239 glTranslatef(position[i].x,position[i].y-.02,position[i].z);
1240 glRotatef(bigrotation[i],0,1,0);
1241 glRotatef(bigtilt2[i],1,0,0);
1242 glRotatef(bigtilt[i],0,0,1);
1243 glRotatef(-rotation1[i]+90,0,1,0);
1244 glRotatef(-rotation2[i]+90,0,0,1);
1245 glRotatef(-rotation3[i],0,1,0);
1246 glRotatef(smallrotation[i],1,0,0);
1247 glRotatef(smallrotation2[i],0,1,0);
1248 glTranslatef(0,0,length[i]);
1249 glGetFloatv(GL_MODELVIEW_MATRIX,M);
1250 tippoint[i].x=M[12];
1251 tippoint[i].y=M[13];
1252 tippoint[i].z=M[14];
1258 shinepoint=position[i];
1259 sprites.MakeSprite(weaponshinesprite, shinepoint,nothingpoint, 1,1,1,multiplier*2, 1);
1260 sprites.speed[sprites.numsprites-1]=4;
1261 sprites.alivetime[sprites.numsprites-1]=.3;
1262 shinepoint=tippoint[i];
1263 sprites.MakeSprite(weaponshinesprite, shinepoint,nothingpoint, 1,1,1,multiplier*2, 1);
1264 sprites.speed[sprites.numsprites-1]=4;
1265 sprites.alivetime[sprites.numsprites-1]=.3;*/
1275 // Model throwingknifemodel;
1276 knifetextureptr = 0;
1277 lightbloodknifetextureptr = 0;
1278 bloodknifetextureptr = 0;
1280 // Model swordmodel;
1281 swordtextureptr = 0;
1282 lightbloodswordtextureptr = 0;
1283 bloodswordtextureptr = 0;
1285 // Model staffmodel;
1286 stafftextureptr = 0;
1291 if (stafftextureptr) glDeleteTextures( 1, &stafftextureptr );
1292 if (knifetextureptr) glDeleteTextures( 1, &knifetextureptr );
1293 if (lightbloodknifetextureptr) glDeleteTextures( 1, &lightbloodknifetextureptr );
1294 if (bloodknifetextureptr) glDeleteTextures( 1, &bloodknifetextureptr );
1295 if (swordtextureptr) glDeleteTextures( 1, &swordtextureptr );
1296 if (lightbloodswordtextureptr) glDeleteTextures( 1, &lightbloodswordtextureptr );
1297 if (bloodswordtextureptr) glDeleteTextures( 1, &bloodswordtextureptr );