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;
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;
727 if(findLengthfast(&bounceness)>1){
731 if(terrain.getOpacity(tippoint[i].x,tippoint[i].z)>.2){
732 if(type[i]==staff)whichsound=footstepsound3+abs(Random()%2);
733 if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4);
735 else whichsound=footstepsound+abs(Random()%2);
736 gLoc[0]=tippoint[i].x;
737 gLoc[1]=tippoint[i].y;
738 gLoc[2]=tippoint[i].z;
742 PlaySoundEx( whichsound, samp[whichsound], NULL, TRUE);
743 FSOUND_3D_SetAttributes(channels[whichsound], gLoc, vel);
744 if(terrain.getOpacity(tippoint[i].x,tippoint[i].z)>.2)FSOUND_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness));
745 else FSOUND_SetVolume(channels[whichsound], 32*findLengthfast(&bounceness));
746 FSOUND_SetPaused(channels[whichsound], FALSE);
748 if(terrain.getOpacity(tippoint[i].x,tippoint[i].z)<.2){
750 terrainlight=terrain.getLighting(tippoint[i].x,tippoint[i].z);
751 if(environment==snowyenvironment){
752 if(findDistancefast(&tippoint[i],&viewer)<viewdistance*viewdistance/4)sprites.MakeSprite(cloudsprite, tippoint[i],tipvelocity[i], terrainlight.x,terrainlight.y,terrainlight.z, .5, .7);
754 else if(environment==grassyenvironment){
755 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);
757 else if(environment==desertenvironment){
758 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);
765 mid=position[i]+tippoint[i];
767 mid+=(position[i]-mid)/20;
769 if(mid.y<terrain.getHeight(mid.x,mid.z)){
771 mid.y=terrain.getHeight(mid.x,mid.z);
773 terrainnormal=terrain.getNormal(mid.x,mid.z);
774 ReflectVector(&velocity[i],&terrainnormal);
775 //mid+=terrainnormal*.002;
776 bounceness=terrainnormal*findLength(&velocity[i])*(abs(normaldotproduct(velocity[i],terrainnormal)));
777 if(findLengthfast(&velocity[i])<findLengthfast(&bounceness))bounceness=0;
778 frictionness=abs(normaldotproduct(velocity[i],terrainnormal));
779 velocity[i]-=bounceness;
780 if(1-friction*frictionness>0)velocity[i]*=1-friction*frictionness;
782 if(terrain.getOpacity(mid.x,mid.z)<.2)velocity[i]+=bounceness*elasticity*.3;
783 else velocity[i]+=bounceness*elasticity;
785 if(findLengthfast(&bounceness)>1){
789 if(terrain.getOpacity(mid.x,mid.z)>.2){
790 if(type[i]==staff)whichsound=footstepsound3+abs(Random()%2);
791 if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4);
793 else whichsound=footstepsound+abs(Random()%2);
800 PlaySoundEx( whichsound, samp[whichsound], NULL, TRUE);
801 FSOUND_3D_SetAttributes(channels[whichsound], gLoc, vel);
802 if(terrain.getOpacity(position[i].x,position[i].z)>.2)FSOUND_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness));
803 else FSOUND_SetVolume(channels[whichsound], 32*findLengthfast(&bounceness));
804 FSOUND_SetPaused(channels[whichsound], FALSE);
806 position[i]+=(mid-oldmid)*20;
809 mid=position[i]+tippoint[i];
811 mid+=(tippoint[i]-mid)/20;
813 if(mid.y<terrain.getHeight(mid.x,mid.z)){
815 mid.y=terrain.getHeight(mid.x,mid.z);
817 terrainnormal=terrain.getNormal(mid.x,mid.z);
818 ReflectVector(&tipvelocity[i],&terrainnormal);
819 //mid+=terrainnormal*.002;
820 bounceness=terrainnormal*findLength(&tipvelocity[i])*(abs(normaldotproduct(tipvelocity[i],terrainnormal)));
821 if(findLengthfast(&tipvelocity[i])<findLengthfast(&bounceness))bounceness=0;
822 frictionness=abs(normaldotproduct(tipvelocity[i],terrainnormal));
823 tipvelocity[i]-=bounceness;
824 if(1-friction*frictionness>0)tipvelocity[i]*=1-friction*frictionness;
825 else tipvelocity[i]=0;
826 if(terrain.getOpacity(mid.x,mid.z)<.2)tipvelocity[i]+=bounceness*elasticity*.3;
827 else tipvelocity[i]+=bounceness*elasticity;
829 if(findLengthfast(&bounceness)>1){
833 if(terrain.getOpacity(mid.x,mid.z)>.2){
834 if(type[i]==staff)whichsound=footstepsound3+abs(Random()%2);
835 if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4);
837 else whichsound=footstepsound+abs(Random()%2);
844 PlaySoundEx( whichsound, samp[whichsound], NULL, TRUE);
845 FSOUND_3D_SetAttributes(channels[whichsound], gLoc, vel);
846 if(terrain.getOpacity(position[i].x,position[i].z)>.2)FSOUND_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness));
847 else FSOUND_SetVolume(channels[whichsound], 32*findLengthfast(&bounceness));
848 FSOUND_SetPaused(channels[whichsound], FALSE);
850 tippoint[i]+=(mid-oldmid)*20;
853 mid=position[i]+tippoint[i];
855 if(position[i].y<terrain.getHeightExtrude(mid.x,mid.z,position[i].x,position[i].z)){
857 position[i].y=terrain.getHeightExtrude(mid.x,mid.z,position[i].x,position[i].z);
859 terrainnormal=terrain.getNormal(mid.x,mid.z);
860 ReflectVector(&velocity[i],&terrainnormal);
861 position[i]+=terrainnormal*.002;
862 bounceness=terrainnormal*findLength(&velocity[i])*(abs(normaldotproduct(velocity[i],terrainnormal)));
863 if(findLengthfast(&velocity[i])<findLengthfast(&bounceness))bounceness=0;
864 frictionness=abs(normaldotproduct(velocity[i],terrainnormal));
865 velocity[i]-=bounceness;
866 if(1-friction*frictionness>0)velocity[i]*=1-friction*frictionness;
868 if(terrain.getOpacity(mid.x,mid.z)<.2)velocity[i]+=bounceness*elasticity*.3;
869 else velocity[i]+=bounceness*elasticity;
871 if(findLengthfast(&bounceness)>1){
875 if(terrain.getOpacity(mid.x,mid.z)>.2){
876 if(type[i]==staff)whichsound=footstepsound3+abs(Random()%2);
877 if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4);
879 else whichsound=footstepsound+abs(Random()%2);
880 gLoc[0]=position[i].x;
881 gLoc[1]=position[i].y;
882 gLoc[2]=position[i].z;
886 PlaySoundEx( whichsound, samp[whichsound], NULL, TRUE);
887 FSOUND_3D_SetAttributes(channels[whichsound], gLoc, vel);
888 if(terrain.getOpacity(position[i].x,position[i].z)>.2)FSOUND_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness));
889 else FSOUND_SetVolume(channels[whichsound], 32*findLengthfast(&bounceness));
890 FSOUND_SetPaused(channels[whichsound], FALSE);
894 if(tippoint[i].y<terrain.getHeightExtrude(mid.x,mid.z,tippoint[i].x,tippoint[i].z)){
896 tippoint[i].y=terrain.getHeightExtrude(mid.x,mid.z,tippoint[i].x,tippoint[i].z);
898 terrainnormal=terrain.getNormal(mid.x,mid.z);
899 ReflectVector(&tipvelocity[i],&terrainnormal);
900 tippoint[i]+=terrainnormal*.002;
901 bounceness=terrainnormal*findLength(&tipvelocity[i])*(abs(normaldotproduct(tipvelocity[i],terrainnormal)));
902 if(findLengthfast(&tipvelocity[i])<findLengthfast(&bounceness))bounceness=0;
903 frictionness=abs(normaldotproduct(tipvelocity[i],terrainnormal));
904 tipvelocity[i]-=bounceness;
905 if(1-friction*frictionness>0)tipvelocity[i]*=1-friction*frictionness;
906 else tipvelocity[i]=0;
907 if(terrain.getOpacity(mid.x,mid.z)<.2)tipvelocity[i]+=bounceness*elasticity*.3;
908 else tipvelocity[i]+=bounceness*elasticity;
910 if(findLengthfast(&bounceness)>1){
914 if(terrain.getOpacity(mid.x,mid.z)>.2){
915 if(type[i]==staff)whichsound=footstepsound3+abs(Random()%2);
916 if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4);
918 else whichsound=footstepsound+abs(Random()%2);
919 gLoc[0]=tippoint[i].x;
920 gLoc[1]=tippoint[i].y;
921 gLoc[2]=tippoint[i].z;
925 PlaySoundEx( whichsound, samp[whichsound], NULL, TRUE);
926 FSOUND_3D_SetAttributes(channels[whichsound], gLoc, vel);
927 if(terrain.getOpacity(tippoint[i].x,tippoint[i].z)>.2)FSOUND_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness));
928 else FSOUND_SetVolume(channels[whichsound], 32*findLengthfast(&bounceness));
929 FSOUND_SetPaused(channels[whichsound], FALSE);
933 //Fix terrain edge collision
936 whichhit=terrain.lineTerrain(start,end,&colpoint);
947 tipvelocity[i].y+=.1;
950 whichhit=terrain.lineTerrain(start,end,&colpoint);
952 closestpoint=colpoint*terrain.scale;
957 tipvelocity[i].y-=.1;
960 whichhit=terrain.lineTerrain(start,end,&colpoint);
965 tipvelocity[i].y+=.01;
968 whichhit=terrain.lineTerrain(start,end,&colpoint);
970 closestpoint=colpoint*terrain.scale;
974 whichhit=terrain.lineTerrain(end,start,&closestswordpoint);
976 colpoint=(closestswordpoint*terrain.scale+colpoint*terrain.scale)/2;
977 proportion=findDistance(&tippoint[i],&colpoint)/findDistance(&position[i],&tippoint[i]);
980 position[i].y+=.1*proportion;
981 tippoint[i].y+=.1*(1-proportion);
982 velocity[i].y+=.1*proportion;
983 tipvelocity[i].y+=.1*(1-proportion);
986 whichhit=terrain.lineTerrain(start,end,&colpoint);
988 position[i].y-=.1*proportion;
989 tippoint[i].y-=.1*(1-proportion);
990 velocity[i].y-=.1*proportion;
991 tipvelocity[i].y-=.1*(1-proportion);
994 whichhit=terrain.lineTerrain(start,end,&colpoint);
996 position[i].y+=.01*proportion;
997 tippoint[i].y+=.01*(1-proportion);
998 velocity[i].y+=.01*proportion;
999 tipvelocity[i].y+=.01*(1-proportion);
1002 whichhit=terrain.lineTerrain(start,end,&colpoint);
1009 velocity[i].y+=gravity*multiplier;
1010 tipvelocity[i].y+=gravity*multiplier;
1011 //position[i].y+=gravity*multiplier*multiplier;
1012 //tippoint[i].y+=gravity*multiplier*multiplier;
1015 XYZ temppoint1,temppoint2,tempforward;
1018 temppoint1=position[i];
1019 temppoint2=tippoint[i];
1020 distance=findDistance(&temppoint1,&temppoint2);
1021 rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
1022 rotation2[i]*=360/6.28;
1025 rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
1026 rotation1[i]*=360/6.28;
1028 smallrotation[i]=90;
1029 smallrotation2[i]=0;
1033 if(temppoint1.x>temppoint2.x)rotation1[i]=360-rotation1[i];
1036 if(findLengthfast(&velocity[i])<.3&&findLengthfast(&tipvelocity[i])<.3&&hitsomething[i]){
1037 freetime[i]+=multiplier;
1040 //velocity[i]=(position[i]-oldposition[i])/multiplier;
1041 //tipvelocity[i]==(tippoint[i-+oldtippoint[i])/multiplier;
1049 multiplier=tempmult;
1050 if(blooddrip[i]&&bloody[i]){
1051 blooddripdelay[i]-=blooddrip[i]*multiplier/2;
1052 blooddrip[i]-=multiplier;
1053 if(blooddrip[i]<0)blooddrip[i]=0;
1054 if(blooddrip[i]>5)blooddrip[i]=5;
1055 if(blooddripdelay[i]<0&&bloodtoggle){
1056 blooddripdelay[i]=1;
1059 bloodloc=position[i]+(tippoint[i]-position[i])*.7;
1063 sprites.MakeSprite(bloodsprite, bloodloc,bloodvel, 1,1,1, .03, 1);
1068 flamedelay[i]-=multiplier;
1069 if(onfire[i]&&flamedelay[i]<=0){
1071 flamedelay[i]-=multiplier;
1074 normalrot=player[owner[i]].velocity;
1078 if(player[owner[i]].onterrain){
1082 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);
1083 sprites.speed[sprites.numsprites-1]=4;
1084 sprites.alivetime[sprites.numsprites-1]=.3;
1088 if(!onfire[i]&&owner[i]==-1&&type[i]!=staff){
1089 flamedelay[i]-=multiplier;
1090 if(flamedelay[i]<=0){
1092 flamedelay[i]-=multiplier;
1094 if(Random()%50==0&&findDistancefast(&position[i],&viewer)>80){
1096 shinepoint=position[i]+(tippoint[i]-position[i])*(((float)abs(Random()%100))/100);
1097 sprites.MakeSprite(weaponshinesprite, shinepoint,normalrot, 1,1,1, (.1+(float)abs(Random()%100)/200-.25)*1/3*fast_sqrt(findDistance(&shinepoint,&viewer)), 1);
1098 sprites.speed[sprites.numsprites-1]=4;
1099 sprites.alivetime[sprites.numsprites-1]=.3;
1109 static XYZ terrainlight;
1110 static GLfloat M[16];
1112 glAlphaFunc(GL_GREATER, 0.9);
1113 glEnable(GL_TEXTURE_2D);
1115 glEnable(GL_CULL_FACE);
1116 glCullFace(GL_FRONT);
1118 for(i=0;i<numweapons;i++)
1120 if((frustum.SphereInFrustum(position[i].x,position[i].y,position[i].z,1)&&findDistancefast(&viewer,&position[i])<viewdistance*viewdistance))
1126 if(velocity[i].x&&!physics[i])drawhowmany[i]=10;
1127 else drawhowmany[i]=1;
1131 if(player[owner[i]].occluded<25)
1132 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)
1134 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)
1138 else drawhowmany[i]=1;
1139 if(player[owner[i]].targetanimation==swordgroundstabanim)
1141 lastdrawnrotation1[i]=rotation1[i];
1142 lastdrawnrotation2[i]=rotation2[i];
1143 lastdrawnrotation3[i]=rotation3[i];
1144 lastdrawnbigrotation[i]=bigrotation[i];
1145 lastdrawnbigtilt[i]=bigtilt[i];
1146 lastdrawnbigtilt2[i]=bigtilt2[i];
1147 lastdrawnsmallrotation[i]=smallrotation[i];
1148 lastdrawnsmallrotation2[i]=smallrotation2[i];
1153 terrainlight=terrain.getLighting(position[i].x,position[i].z);
1154 if(drawhowmany[i]>0)
1156 glAlphaFunc(GL_GREATER, 0.01);
1158 for(j=drawhowmany[i];j>0;j--)
1160 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1162 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,j/drawhowmany[i]);
1163 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]));
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])+lastdrawnposition[i].y*(1-((float)(j))/drawhowmany[i]),position[i].z*(((float)(j))/drawhowmany[i])+lastdrawnposition[i].z*(1-((float)(j))/drawhowmany[i]));
1165 //glTranslatef(position[i].x,position[i].y-.02,position[i].z);
1166 glRotatef(bigrotation[i]*(((float)(j))/drawhowmany[i])+lastdrawnbigrotation[i]*(1-((float)(j))/drawhowmany[i]),0,1,0);
1167 glRotatef(bigtilt2[i]*(((float)(j))/drawhowmany[i])+lastdrawnbigtilt2[i]*(1-((float)(j))/drawhowmany[i]),1,0,0);
1168 glRotatef(bigtilt[i]*(((float)(j))/drawhowmany[i])+lastdrawnbigtilt[i]*(1-((float)(j))/drawhowmany[i]),0,0,1);
1169 glRotatef(-rotation1[i]*(((float)(j))/drawhowmany[i])-lastdrawnrotation1[i]*(1-((float)(j))/drawhowmany[i])+90,0,1,0);
1170 glRotatef(-rotation2[i]*(((float)(j))/drawhowmany[i])-lastdrawnrotation2[i]*(1-((float)(j))/drawhowmany[i])+90,0,0,1);
1171 glRotatef(-rotation3[i]*(((float)(j))/drawhowmany[i])-lastdrawnrotation3[i]*(1-((float)(j))/drawhowmany[i]),0,1,0);
1172 glRotatef(smallrotation[i]*(((float)(j))/drawhowmany[i])+lastdrawnsmallrotation[i]*(1-((float)(j))/drawhowmany[i]),1,0,0);
1173 glRotatef(smallrotation2[i]*(((float)(j))/drawhowmany[i])+lastdrawnsmallrotation2[i]*(1-((float)(j))/drawhowmany[i]),0,1,0);
1177 if(player[owner[i]].targetanimation==staffhitanim||player[owner[i]].currentanimation==staffhitanim||player[owner[i]].targetanimation==staffhitreversedanim||player[owner[i]].currentanimation==staffhitreversedanim)
1179 glTranslatef(0,0,-.3);
1181 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)
1183 glTranslatef(0,0,-.1);
1186 /*if(type[i]==knife){
1188 if(!physics[i]&&findDistance(&position[i],&oldposition[i])*5>1)glScalef(1,1,findDistance(&position[i],&oldposition[i])*5);
1194 glEnable(GL_LIGHTING);
1195 if(!bloody[i]||!bloodtoggle)throwingknifemodel.drawdifftex(knifetextureptr);
1198 if(bloody[i]==1)throwingknifemodel.drawdifftex(lightbloodknifetextureptr);
1199 if(bloody[i]==2)throwingknifemodel.drawdifftex(bloodknifetextureptr);
1204 glEnable(GL_LIGHTING);
1205 if(!bloody[i]||!bloodtoggle)swordmodel.drawdifftex(swordtextureptr);
1208 if(bloody[i]==1)swordmodel.drawdifftex(lightbloodswordtextureptr);
1209 if(bloody[i]==2)swordmodel.drawdifftex(bloodswordtextureptr);
1214 glEnable(GL_LIGHTING);
1215 staffmodel.drawdifftex(stafftextureptr);
1221 lastdrawnposition[i]=position[i];
1222 lastdrawntippoint[i]=tippoint[i];
1223 lastdrawnrotation1[i]=rotation1[i];
1224 lastdrawnrotation2[i]=rotation2[i];
1225 lastdrawnrotation3[i]=rotation3[i];
1226 lastdrawnbigrotation[i]=bigrotation[i];
1227 lastdrawnbigtilt[i]=bigtilt[i];
1228 lastdrawnbigtilt2[i]=bigtilt2[i];
1229 lastdrawnsmallrotation[i]=smallrotation[i];
1230 lastdrawnsmallrotation2[i]=smallrotation2[i];
1231 if(owner[i]!=-1)lastdrawnanim[i]=player[owner[i]].currentanimation;
1235 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1238 glTranslatef(position[i].x,position[i].y-.02,position[i].z);
1239 glRotatef(bigrotation[i],0,1,0);
1240 glRotatef(bigtilt2[i],1,0,0);
1241 glRotatef(bigtilt[i],0,0,1);
1242 glRotatef(-rotation1[i]+90,0,1,0);
1243 glRotatef(-rotation2[i]+90,0,0,1);
1244 glRotatef(-rotation3[i],0,1,0);
1245 glRotatef(smallrotation[i],1,0,0);
1246 glRotatef(smallrotation2[i],0,1,0);
1247 glTranslatef(0,0,length[i]);
1248 glGetFloatv(GL_MODELVIEW_MATRIX,M);
1249 tippoint[i].x=M[12];
1250 tippoint[i].y=M[13];
1251 tippoint[i].z=M[14];
1257 shinepoint=position[i];
1258 sprites.MakeSprite(weaponshinesprite, shinepoint,nothingpoint, 1,1,1,multiplier*2, 1);
1259 sprites.speed[sprites.numsprites-1]=4;
1260 sprites.alivetime[sprites.numsprites-1]=.3;
1261 shinepoint=tippoint[i];
1262 sprites.MakeSprite(weaponshinesprite, shinepoint,nothingpoint, 1,1,1,multiplier*2, 1);
1263 sprites.speed[sprites.numsprites-1]=4;
1264 sprites.alivetime[sprites.numsprites-1]=.3;*/
1272 rotation1.resize(max_weaponinstances);
1273 rotation2.resize(max_weaponinstances);
1274 rotation3.resize(max_weaponinstances);
1275 bigrotation.resize(max_weaponinstances);
1276 bigtilt.resize(max_weaponinstances);
1277 bigtilt2.resize(max_weaponinstances);
1278 smallrotation.resize(max_weaponinstances);
1279 smallrotation2.resize(max_weaponinstances);
1280 damage.resize(max_weaponinstances);
1283 tippoint.resize(max_weaponinstances);
1284 oldtippoint.resize(max_weaponinstances);
1285 position.resize(max_weaponinstances);
1286 lastmult.resize(max_weaponinstances);
1287 oldposition.resize(max_weaponinstances);
1288 velocity.resize(max_weaponinstances);
1289 tipvelocity.resize(max_weaponinstances);
1290 type.resize(max_weaponinstances);
1291 oldowner.resize(max_weaponinstances);
1292 owner.resize(max_weaponinstances);
1293 bloody.resize(max_weaponinstances);
1294 blooddrip.resize(max_weaponinstances);
1295 blooddripdelay.resize(max_weaponinstances);
1296 onfire.resize(max_weaponinstances);
1297 flamedelay.resize(max_weaponinstances);
1298 missed.resize(max_weaponinstances);
1299 mass.resize(max_weaponinstances);
1300 tipmass.resize(max_weaponinstances);
1301 length.resize(max_weaponinstances);
1302 freetime.resize(max_weaponinstances);
1303 firstfree.resize(max_weaponinstances);
1304 physics.resize(max_weaponinstances);
1305 drawhowmany.resize(max_weaponinstances);
1306 hitsomething.resize(max_weaponinstances);
1308 lastdrawnposition.resize(max_weaponinstances);
1309 lastdrawntippoint.resize(max_weaponinstances);
1310 lastdrawnrotation1.resize(max_weaponinstances);
1311 lastdrawnrotation2.resize(max_weaponinstances);
1312 lastdrawnrotation3.resize(max_weaponinstances);
1313 lastdrawnbigrotation.resize(max_weaponinstances);
1314 lastdrawnbigtilt.resize(max_weaponinstances);
1315 lastdrawnbigtilt2.resize(max_weaponinstances);
1316 lastdrawnsmallrotation.resize(max_weaponinstances);
1317 lastdrawnsmallrotation2.resize(max_weaponinstances);
1318 lastdrawnanim.resize(max_weaponinstances);
1320 // Model throwingknifemodel;
1321 knifetextureptr = 0;
1322 lightbloodknifetextureptr = 0;
1323 bloodknifetextureptr = 0;
1325 // Model swordmodel;
1326 swordtextureptr = 0;
1327 lightbloodswordtextureptr = 0;
1328 bloodswordtextureptr = 0;
1330 // Model staffmodel;
1331 stafftextureptr = 0;
1336 if (stafftextureptr) glDeleteTextures( 1, &stafftextureptr );
1337 if (knifetextureptr) glDeleteTextures( 1, &knifetextureptr );
1338 if (lightbloodknifetextureptr) glDeleteTextures( 1, &lightbloodknifetextureptr );
1339 if (bloodknifetextureptr) glDeleteTextures( 1, &bloodknifetextureptr );
1340 if (swordtextureptr) glDeleteTextures( 1, &swordtextureptr );
1341 if (lightbloodswordtextureptr) glDeleteTextures( 1, &lightbloodswordtextureptr );
1342 if (bloodswordtextureptr) glDeleteTextures( 1, &bloodswordtextureptr );