14 extern float multiplier;
16 extern int environment;
17 extern float texscale;
18 extern Terrain terrain;
19 extern FSOUND_SAMPLE *samp[100];
20 extern int channels[100];
21 extern Sprites sprites;
22 extern int kTextureSize;
23 extern float screenwidth,screenheight;
26 extern float texdetail;
27 extern Objects objects;
29 extern float slomodelay;
30 extern bool floatjump;
32 extern Animation animation[animation_count];
34 extern float texdetail;
35 extern GLubyte bloodText[512*512*3];
36 extern GLubyte wolfbloodText[512*512*3];
37 extern float terraindetail;
38 extern float camerashake;
40 extern float blackout;
41 extern bool cellophane;
42 extern bool musictoggle;
43 extern int difficulty;
44 extern Weapons weapons;
45 extern Person player[maxplayers];
46 extern int numplayers;
47 extern int bloodtoggle;
48 extern bool invertmouse;
50 extern float precipdelay;
51 extern XYZ viewerfacing;
52 extern bool ambientsound;
53 extern bool mousejump;
54 extern float viewdistance;
56 extern bool autoslomo;
57 extern int newnetmessages;
58 extern char netmessages[256];
59 extern bool keyboardfrozen;
60 extern int netdatanew;
61 extern bool loadingstuff;
62 extern char mapname[256];
63 extern XYZ windvector;
64 extern bool buttons[3];
65 extern bool debugmode;
68 extern int oldmainmenu;
69 extern bool visibleloading;
70 extern int loadscreencolor;
71 extern float flashamount,flashr,flashg,flashb;
72 extern int flashdelay;
73 extern XYZ envsound[30];
74 extern float envsoundvol[30];
75 extern int numenvsounds;
76 extern float envsoundlife[30];
77 extern float usermousesensitivity;
78 extern bool ismotionblur;
80 extern bool trilinear;
81 extern bool damageeffects;
82 extern bool showpoints;
83 extern bool texttoggle;
84 extern bool alwaysblur;
85 extern float gamespeed;
88 extern bool immediate;
89 extern bool velocityblur;
92 extern float bonusvalue;
93 extern float bonustotal;
94 extern float bonustime;
95 extern float startbonustotal;
96 extern float tintr,tintg,tintb;
97 extern float bonusnum[100];
98 extern bool skyboxtexture;
100 extern float skyboxg;
101 extern float skyboxb;
102 extern float skyboxlightr;
103 extern float skyboxlightg;
104 extern float skyboxlightb;
105 extern float fadestart;
106 extern float slomospeed;
107 extern float slomofreq;
108 extern int tutoriallevel;
109 extern float smoketex;
110 extern float tutorialstagetime;
111 extern int tutorialstage;
112 extern float tutorialmaxtime;
113 extern float tutorialsuccess;
114 extern bool againbonus;
115 extern bool reversaltrain;
116 extern bool canattack;
117 extern bool cananger;
118 extern float damagedealt;
119 extern float damagetaken;
121 extern int editoractive;
122 extern int editorpathtype;
123 extern bool oldbuttons[3];
125 extern float hostiletime;
127 extern bool gamestarted;
129 extern int numhotspots;
130 extern int winhotspot;
131 extern int windialogue;
132 extern int killhotspot;
133 extern XYZ hotspot[40];
134 extern int hotspottype[40];
135 extern float hotspotsize[40];
136 extern char hotspottext[40][256];
137 extern int currenthotspot;
139 extern int kBitsPerPixel;
142 extern int numaccounts;
143 extern int accountactive;
144 extern int accountdifficulty[10];
145 extern int accountprogress[10];
146 extern float accountpoints[10];
147 extern float accounthighscore[10][50];
148 extern float accountfasttime[10][50];
149 extern bool accountunlocked[10][60];
150 extern char accountname[10][256];
152 extern bool stillloading;
153 extern bool winfreeze;
156 extern int numflipfail;
158 extern int numstaffattack;
159 extern int numswordattack;
160 extern int numknifeattack;
161 extern int numunarmedattack;
162 extern int numescaped;
163 extern int numflipped;
164 extern int numwallflipped;
165 extern int numthrowkill;
166 extern int numafterkill;
167 extern int numreversals;
168 extern int numattacks;
169 extern int maxalarmed;
170 extern int numresponded;
172 extern int numdialogues;
173 extern int numdialogueboxes[max_dialogues];
174 extern int dialoguetype[max_dialogues];
175 extern int dialogueboxlocation[max_dialogues][max_dialoguelength];
176 extern float dialogueboxcolor[max_dialogues][max_dialoguelength][3];
177 extern int dialogueboxsound[max_dialogues][max_dialoguelength];
178 extern char dialoguetext[max_dialogues][max_dialoguelength][128];
179 extern char dialoguename[max_dialogues][max_dialoguelength][64];
180 extern XYZ dialoguecamera[max_dialogues][max_dialoguelength];
181 extern XYZ participantlocation[max_dialogues][10];
182 extern int participantfocus[max_dialogues][max_dialoguelength];
183 extern int participantaction[max_dialogues][max_dialoguelength];
184 extern float participantrotation[max_dialogues][10];
185 extern XYZ participantfacing[max_dialogues][max_dialoguelength][10];
186 extern float dialoguecamerarotation[max_dialogues][max_dialoguelength];
187 extern float dialoguecamerarotation2[max_dialogues][max_dialoguelength];
188 extern int indialogue;
189 extern int whichdialogue;
190 extern int directing;
191 extern float dialoguetime;
192 extern int dialoguegonethrough[20];
194 extern bool campaign;
196 extern float oldgamespeed;
198 extern float accountcampaignhighscore[10];
199 extern float accountcampaignfasttime[10];
200 extern float accountcampaignscore[10];
201 extern float accountcampaigntime[10];
203 extern int accountcampaignchoicesmade[10];
204 extern int accountcampaignchoices[10][5000];
205 /********************> Tick() <*****/
206 extern FSOUND_STREAM * strm[10];
207 extern "C" void PlaySoundEx(int channel, FSOUND_SAMPLE *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused);
208 extern "C" void PlayStreamEx(int chan, FSOUND_STREAM *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused);
210 extern void ScreenShot(const char * fname);
211 void Screenshot (void)
214 time_t t = time(NULL);
215 struct tm *tme = localtime(&t);
216 sprintf(temp, "Screenshots\\Screenshot_%04d_%02d_%02d--%02d_%02d_%02d.png", tme->tm_year + 1900, tme->tm_mon + 1, tme->tm_mday, tme->tm_hour, tme->tm_min, tme->tm_sec);
218 mkdir("Screenshots", S_IRWXU);
219 ScreenShot(temp/*"Screenshots\\Screenshot.png"*/);
222 GraphicsExportComponent QT_exporter;
223 OSErr MAC_error_code;
224 CGrafPtr MAC_currentPort;
225 GDHandle MAC_currentDevice;
226 unsigned char* MAC_pixels;
227 Rect MAC_picture_rectangle;
228 GWorldPtr MAC_offscreen_graphics_port;
230 static int numscreenshots=0;
233 static char buf[256];
234 if(numscreenshots==0){
265 FSMakeFSSpec(0, 0, (unsigned char*)buf, &MAC_file);
266 while(!FSpGetFInfo (&MAC_file, fndrInfo)){
267 FSMakeFSSpec(0, 0, (unsigned char*)buf, &MAC_file);
268 if(!FSpGetFInfo (&MAC_file, fndrInfo)){
289 GWorldPtr MAC_gWorld = (CGrafPtr) FrontWindow();
290 //assert(MAC_gWorld != NULL);
292 // Allocate memory for loading image
293 MAC_pixels = new unsigned char[(int)(screenheight * screenwidth * 4)];
294 if (MAC_pixels == NULL) {
295 //UTIL_Error("Could not create Texture data.");
300 ::GetGWorld(&MAC_currentPort, &MAC_currentDevice);
302 // Make a picture Rectangle
303 MAC_picture_rectangle.left = 0;
304 MAC_picture_rectangle.right = screenwidth;
305 MAC_picture_rectangle.top = 0;
306 MAC_picture_rectangle.bottom = screenheight;
308 // Create new offscreen GWorld
309 MAC_error_code = ::QTNewGWorldFromPtr (&MAC_offscreen_graphics_port, k32ARGBPixelFormat, &MAC_picture_rectangle, NULL, NULL, 0, (char *) MAC_pixels, screenwidth * 4);
310 if (MAC_error_code) {
311 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
313 //UTIL_Error("Could not create offscreen GWorld. ");
318 // Copy OpenGL Context to new GWorld
319 glReadBuffer(GL_FRONT);
320 glReadPixels(0,0,screenwidth,screenheight,GL_RGBA,GL_UNSIGNED_BYTE,MAC_pixels);
323 for (unsigned long byte = 0; byte < screenheight * screenwidth * 4; byte+=4) {
324 unsigned char temp = MAC_pixels[byte+0];
325 MAC_pixels[byte+0] = MAC_pixels[byte+3];
326 MAC_pixels[byte+3] = MAC_pixels[byte+2];
327 MAC_pixels[byte+2] = MAC_pixels[byte+1];
328 MAC_pixels[byte+1] = temp;
331 // Flip the image :( This could probably be optimized
336 for (int horz = 0; horz < screenwidth; ++horz)
337 for (vert = 0; vert < screenheight / 2; ++vert) {
338 src_index = (screenwidth * vert + horz) * 4;
339 dst_index = (screenwidth * (screenheight - vert - 1) + horz) * 4;
341 temp=MAC_pixels[src_index+0];
342 MAC_pixels[src_index+0]=MAC_pixels[dst_index+0];
343 MAC_pixels[dst_index+0]=temp;
345 temp=MAC_pixels[src_index+1];
346 MAC_pixels[src_index+1]=MAC_pixels[dst_index+1];
347 MAC_pixels[dst_index+1]=temp;
349 temp=MAC_pixels[src_index+2];
350 MAC_pixels[src_index+2]=MAC_pixels[dst_index+2];
351 MAC_pixels[dst_index+2]=temp;
353 temp=MAC_pixels[src_index+3];
354 MAC_pixels[src_index+3]=MAC_pixels[dst_index+3];
355 MAC_pixels[dst_index+3]=temp;
361 MAC_error_code = OpenADefaultComponent(GraphicsExporterComponentType, kQTFileTypeBMP, &QT_exporter);
362 if (MAC_error_code) {
363 //UTIL_Warning("Unable to export screenshot.");
364 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
365 ::DisposeGWorld(MAC_offscreen_graphics_port);
370 MAC_error_code = GraphicsExportSetInputGWorld(QT_exporter,MAC_offscreen_graphics_port);
371 if (MAC_error_code) {
372 ::CloseComponent(QT_exporter);
373 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
374 ::DisposeGWorld(MAC_offscreen_graphics_port);
376 //UTIL_Warning("Unable to export screenshot.");
380 MAC_error_code = GraphicsExportSetOutputFile(QT_exporter,&MAC_file);
381 if (MAC_error_code) {
382 ::CloseComponent(QT_exporter);
383 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
384 ::DisposeGWorld(MAC_offscreen_graphics_port);
386 //UTIL_Warning("Unable to export screenshot.");
390 MAC_error_code = GraphicsExportDoExport(QT_exporter,NULL);
391 if (MAC_error_code) {
392 ::CloseComponent(QT_exporter);
393 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
394 ::DisposeGWorld(MAC_offscreen_graphics_port);
396 //UTIL_Warning("Unable to export screenshot.");
400 ::CloseComponent(QT_exporter);
401 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
402 ::DisposeGWorld(MAC_offscreen_graphics_port);
409 void Game::SetUpLighting(){
410 if(environment==snowyenvironment){
416 light.ambient[2]=.44;
418 if(environment==desertenvironment){
423 light.ambient[1]=.35;
427 if(environment==grassyenvironment){
433 light.ambient[2]=.44;
444 average=(skyboxlightr+skyboxlightg+skyboxlightb)/3;
445 light.color[0]*=(skyboxlightr+average)/2;
446 light.color[1]*=(skyboxlightg+average)/2;
447 light.color[2]*=(skyboxlightb+average)/2;
448 light.ambient[0]=light.ambient[0]*(skyboxlightr+average)/2*1;
449 light.ambient[1]=light.ambient[1]*(skyboxlightg+average)/2*1;
450 light.ambient[2]=light.ambient[2]*(skyboxlightb+average)/2*1;
454 light.ambient[2]=0; */
457 int Game::findPathDist(int start,int end){
458 int i,j,k,smallestcount,count,connected;
459 int last,last2,last3,last4;
469 while(last!=end&&count<30){
471 for(j=0;j<numpathpoints;j++){
472 if(j!=last&&j!=last2&&j!=last3&&j!=last4)
475 if(numpathpointconnect[j])
476 for(k=0;k<numpathpointconnect[j];k++){
477 if(pathpointconnect[j][k]==last)connected=1;
480 if(numpathpointconnect[last])
481 for(k=0;k<numpathpointconnect[last];k++){
482 if(pathpointconnect[last][k]==j)connected=1;
485 if(closest==-1||Random()%2==0){
496 if(count<smallestcount)smallestcount=count;
498 return smallestcount;
501 int Game::checkcollide(XYZ startpoint,XYZ endpoint){
502 static XYZ colpoint,colviewer,coltarget;
503 static float minx,minz,maxx,maxz,miny,maxy;
512 if(minx>endpoint.x)minx=endpoint.x;
514 if(miny>endpoint.y)miny=endpoint.y;
516 if(minz>endpoint.z)minz=endpoint.z;
519 if(maxx<endpoint.x)maxx=endpoint.x;
521 if(maxy<endpoint.y)maxy=endpoint.y;
523 if(maxz<endpoint.z)maxz=endpoint.z;
532 for(i=0;i<objects.numobjects;i++){
533 if(objects.position[i].x>minx-objects.model[i].boundingsphereradius&&objects.position[i].x<maxx+objects.model[i].boundingsphereradius&&objects.position[i].y>miny-objects.model[i].boundingsphereradius&&objects.position[i].y<maxy+objects.model[i].boundingsphereradius&&objects.position[i].z>minz-objects.model[i].boundingsphereradius&&objects.position[i].z<maxz+objects.model[i].boundingsphereradius){
534 if(objects.type[i]!=treeleavestype&&objects.type[i]!=bushtype&&objects.type[i]!=firetype){
535 colviewer=startpoint;
537 if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)return i;
542 //if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)return 1000;
547 int Game::checkcollide(XYZ startpoint,XYZ endpoint,int what){
548 static XYZ colpoint,colviewer,coltarget;
549 static float minx,minz,maxx,maxz,miny,maxy;
558 if(minx>endpoint.x)minx=endpoint.x;
560 if(miny>endpoint.y)miny=endpoint.y;
562 if(minz>endpoint.z)minz=endpoint.z;
565 if(maxx<endpoint.x)maxx=endpoint.x;
567 if(maxy<endpoint.y)maxy=endpoint.y;
569 if(maxz<endpoint.z)maxz=endpoint.z;
579 if(objects.position[what].x>minx-objects.model[what].boundingsphereradius&&objects.position[what].x<maxx+objects.model[what].boundingsphereradius&&objects.position[what].y>miny-objects.model[what].boundingsphereradius&&objects.position[what].y<maxy+objects.model[what].boundingsphereradius&&objects.position[what].z>minz-objects.model[what].boundingsphereradius&&objects.position[what].z<maxz+objects.model[what].boundingsphereradius){
580 if(objects.type[what]!=treeleavestype&&objects.type[what]!=bushtype&&objects.type[what]!=firetype){
581 colviewer=startpoint;
583 if(objects.model[what].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[what],&objects.rotation[what])!=-1)return i;
588 if(what==1000)if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)return 1000;
593 void Game::Setenvironment(int which)
597 LOG(" Setting environment...");
602 FSOUND_SetPaused(channels[music1snow], TRUE);
603 FSOUND_SetPaused(channels[music1grass], TRUE);
604 FSOUND_SetPaused(channels[music1desert], TRUE);
605 FSOUND_SetPaused(channels[wind], TRUE);
606 FSOUND_SetPaused(channels[desertambient], TRUE);
608 FSOUND_SetPaused(channels[stream_music1snow], TRUE);
609 FSOUND_SetPaused(channels[stream_music1grass], TRUE);
610 FSOUND_SetPaused(channels[stream_music1desert], TRUE);
611 FSOUND_SetPaused(channels[stream_wind], TRUE);
612 FSOUND_SetPaused(channels[stream_desertambient], TRUE);
615 if(environment==snowyenvironment){
619 //PlaySoundEx( wind, samp[wind], NULL, TRUE);
620 PlayStreamEx(stream_wind, strm[stream_wind], 0, TRUE);
621 FSOUND_SetPaused(channels[stream_wind], FALSE);
622 FSOUND_SetVolume(channels[stream_wind], 256);
625 LoadTexture(":Data:Textures:snowtree.png",&objects.treetextureptr,0,1);
626 LoadTexture(":Data:Textures:bushsnow.png",&objects.bushtextureptr,0,1);
627 LoadTexture(":Data:Textures:bouldersnow.jpg",&objects.rocktextureptr,1,0);
628 LoadTexture(":Data:Textures:snowbox.jpg",&objects.boxtextureptr,1,0);
630 FSOUND_Sample_Free(samp[footstepsound]);
631 FSOUND_Sample_Free(samp[footstepsound2]);
632 FSOUND_Sample_Free(samp[footstepsound3]);
633 FSOUND_Sample_Free(samp[footstepsound4]);
634 samp[footstepsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow1.ogg", FSOUND_HW3D, 0, 0);
635 samp[footstepsound2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow2.ogg", FSOUND_HW3D, 0, 0);
636 samp[footstepsound3] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone1.ogg", FSOUND_HW3D, 0, 0);
637 samp[footstepsound4] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone2.ogg", FSOUND_HW3D, 0, 0);
638 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
639 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
640 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
641 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
643 LoadTexture(":Data:Textures:snow.jpg",&terraintexture,1,0);
645 LoadTexture(":Data:Textures:rock.jpg",&terraintexture2,1,0);
647 //LoadTexture(":Data:Textures:detailgrain.png",&terraintexture3,1);
652 temptexdetail=texdetail;
653 if(texdetail>1)texdetail=4;
654 skybox.load( ":Data:Textures:Skybox(snow):Front.jpg",
655 ":Data:Textures:Skybox(snow):Left.jpg",
656 ":Data:Textures:Skybox(snow):Back.jpg",
657 ":Data:Textures:Skybox(snow):Right.jpg",
658 ":Data:Textures:Skybox(snow):Up.jpg",
659 ":Data:Textures:Skybox(snow):Down.jpg",
660 ":Data:Textures:Skybox(snow):Cloud.jpg",
661 ":Data:Textures:Skybox(snow):Reflect.jpg");
666 texdetail=temptexdetail;
668 if(environment==desertenvironment){
671 LoadTexture(":Data:Textures:deserttree.png",&objects.treetextureptr,0,1);
672 LoadTexture(":Data:Textures:bushdesert.png",&objects.bushtextureptr,0,1);
673 LoadTexture(":Data:Textures:boulderdesert.jpg",&objects.rocktextureptr,1,0);
674 LoadTexture(":Data:Textures:desertbox.jpg",&objects.boxtextureptr,1,0);
678 //PlaySoundEx( desertambient, samp[desertambient], NULL, TRUE);
679 PlayStreamEx( stream_desertambient, strm[stream_desertambient], NULL, TRUE);
680 FSOUND_SetPaused(channels[stream_desertambient], FALSE);
681 FSOUND_SetVolume(channels[stream_desertambient], 256);
684 FSOUND_Sample_Free(samp[footstepsound]);
685 FSOUND_Sample_Free(samp[footstepsound2]);
686 FSOUND_Sample_Free(samp[footstepsound3]);
687 FSOUND_Sample_Free(samp[footstepsound4]);
688 samp[footstepsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow1.ogg", FSOUND_HW3D, 0, 0);
689 samp[footstepsound2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow2.ogg", FSOUND_HW3D, 0, 0);
690 samp[footstepsound3] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow1.ogg", FSOUND_HW3D, 0, 0);
691 samp[footstepsound4] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow2.ogg", FSOUND_HW3D, 0, 0);
692 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
693 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
694 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
695 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
697 LoadTexture(":Data:Textures:sand.jpg",&terraintexture,1,0);
699 LoadTexture(":Data:Textures:sandslope.jpg",&terraintexture2,1,0);
701 //LoadTexture(":Data:Textures:detailgrain.png",&terraintexture3,1);
705 temptexdetail=texdetail;
706 if(texdetail>1)texdetail=4;
707 skybox.load( ":Data:Textures:Skybox(sand):Front.jpg",
708 ":Data:Textures:Skybox(sand):Left.jpg",
709 ":Data:Textures:Skybox(sand):Back.jpg",
710 ":Data:Textures:Skybox(sand):Right.jpg",
711 ":Data:Textures:Skybox(sand):Up.jpg",
712 ":Data:Textures:Skybox(sand):Down.jpg",
713 ":Data:Textures:Skybox(sand):Cloud.jpg",
714 ":Data:Textures:Skybox(sand):Reflect.jpg");
719 texdetail=temptexdetail;
721 if(environment==grassyenvironment){
724 LoadTexture(":Data:Textures:tree.png",&objects.treetextureptr,0,1);
725 LoadTexture(":Data:Textures:bush.png",&objects.bushtextureptr,0,1);
726 LoadTexture(":Data:Textures:boulder.jpg",&objects.rocktextureptr,1,0);
727 LoadTexture(":Data:Textures:grassbox.jpg",&objects.boxtextureptr,1,0);
730 PlayStreamEx( stream_wind, strm[stream_wind], NULL, TRUE);
731 FSOUND_SetPaused(channels[stream_wind], FALSE);
732 FSOUND_SetVolume(channels[stream_wind], 100);
735 FSOUND_Sample_Free(samp[footstepsound]);
736 FSOUND_Sample_Free(samp[footstepsound2]);
737 FSOUND_Sample_Free(samp[footstepsound3]);
738 FSOUND_Sample_Free(samp[footstepsound4]);
739 samp[footstepsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepgrass1.ogg", FSOUND_HW3D, 0, 0);
740 samp[footstepsound2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepgrass2.ogg", FSOUND_HW3D, 0, 0);
741 samp[footstepsound3] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone1.ogg", FSOUND_HW3D, 0, 0);
742 samp[footstepsound4] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone2.ogg", FSOUND_HW3D, 0, 0);
743 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
744 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
745 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
746 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
748 LoadTexture(":Data:Textures:grassdirt.jpg",&terraintexture,1,0);
750 LoadTexture(":Data:Textures:mossrock.jpg",&terraintexture2,1,0);
752 //LoadTexture(":Data:Textures:detail.png",&terraintexture3,1);
756 temptexdetail=texdetail;
757 if(texdetail>1)texdetail=4;
758 skybox.load( ":Data:Textures:Skybox(grass):Front.jpg",
759 ":Data:Textures:Skybox(grass):Left.jpg",
760 ":Data:Textures:Skybox(grass):Back.jpg",
761 ":Data:Textures:Skybox(grass):Right.jpg",
762 ":Data:Textures:Skybox(grass):Up.jpg",
763 ":Data:Textures:Skybox(grass):Down.jpg",
764 ":Data:Textures:Skybox(grass):Cloud.jpg",
765 ":Data:Textures:Skybox(grass):Reflect.jpg");
769 texdetail=temptexdetail;
771 temptexdetail=texdetail;
773 terrain.load(":Data:Textures:heightmap.png");
775 texdetail=temptexdetail;
779 void Game::Loadlevel(int which){
782 if(which==0)Loadlevel((char *)":Data:Maps:map1");
783 else if(which==1)Loadlevel((char *)":Data:Maps:map2");
784 else if(which==2)Loadlevel((char *)":Data:Maps:map3");
785 else if(which==3)Loadlevel((char *)":Data:Maps:map4");
786 else if(which==4)Loadlevel((char *)":Data:Maps:map5");
787 else if(which==5)Loadlevel((char *)":Data:Maps:map6");
788 else if(which==6)Loadlevel((char *)":Data:Maps:map7");
789 else if(which==7)Loadlevel((char *)":Data:Maps:map8");
790 else if(which==8)Loadlevel((char *)":Data:Maps:map9");
791 else if(which==9)Loadlevel((char *)":Data:Maps:map10");
792 else if(which==10)Loadlevel((char *)":Data:Maps:map11");
793 else if(which==11)Loadlevel((char *)":Data:Maps:map12");
794 else if(which==12)Loadlevel((char *)":Data:Maps:map13");
795 else if(which==13)Loadlevel((char *)":Data:Maps:map14");
796 else if(which==14)Loadlevel((char *)":Data:Maps:map15");
797 else if(which==15)Loadlevel((char *)":Data:Maps:map16");
798 else if(which==-1){tutoriallevel=-1;Loadlevel((char *)":Data:Maps:tutorial");}
799 else Loadlevel((char *)":Data:Maps:mapsave");
804 /*char * Game::MD5_string (unsigned char *string){
808 strcpy(temp2,(const char *)string);
809 strcat((char *)temp2,(const char *)"Lugaru");
810 sprintf (temp, "%d",strlen((char *)temp2));
811 strcat((char *)temp2,temp);
814 unsigned int len = strlen ( (char *)temp2);
816 context.update ((unsigned char *)temp2, len);
819 return context.hex_digest();
824 void Game::Loadlevel(char *name){
831 float headprop,legprop,armprop,bodyprop;
835 LOG(std::string("Loading level...") + name);
837 if(!gameon)visibleloading=1;
839 if(stealthloading)visibleloading=0;
841 if(!stillloading)loadtime=0;
846 if(tutoriallevel!=-1)tutoriallevel=0;
847 else tutoriallevel=1;
849 if(tutoriallevel==1)tutorialstage=0;
850 if(tutorialstage==0){
858 FSOUND_SetPaused(channels[whooshsound], TRUE);
859 FSOUND_SetPaused(channels[stream_firesound], TRUE);
863 tfile=fopen( name, "rb" );
866 FSOUND_SetPaused(channels[stream_firesound], TRUE);
877 animation[bounceidleanim].Load((char *)":Data:Animations:Idle",middleheight,neutral);
883 dialoguegonethrough[i]=0;
892 if(accountactive!=-1)difficulty=accountdifficulty[accountactive];
894 if(difficulty!=2)minimap=1;
931 bonustotal=startbonustotal;
937 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
938 FSOUND_SetVolume(channels[consolesuccesssound], 256);
939 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
947 sprites.numsprites=0;
948 for(i=0;i<objects.numobjects;i++)
950 objects.model[i].numdecals=0;
953 j=objects.numobjects;
956 objects.DeleteObject(0);
957 if(visibleloading){loadscreencolor=4; LoadingScreen();}
960 for(i=0;i<subdivision;i++)
962 for(j=0;j<subdivision;j++)
964 terrain.patchobjectnum[i][j]=0;
967 if(visibleloading){loadscreencolor=4; LoadingScreen();}
970 weapons.numweapons=0;
972 funpackf(tfile, "Bi", &mapvers);
973 if(mapvers>=15)funpackf(tfile, "Bi", &indemo);
975 if(mapvers>=5)funpackf(tfile, "Bi", &maptype);
976 else maptype=mapkilleveryone;
977 if(mapvers>=6)funpackf(tfile, "Bi", &hostile);
979 if(mapvers>=4)funpackf(tfile, "Bf Bf", &viewdistance, &fadestart);
985 if(mapvers>=2)funpackf(tfile, "Bb Bf Bf Bf", &skyboxtexture, &skyboxr, &skyboxg, &skyboxb);
993 if(mapvers>=10)funpackf(tfile, "Bf Bf Bf", &skyboxlightr, &skyboxlightg, &skyboxlightb);
996 skyboxlightr=skyboxr;
997 skyboxlightg=skyboxg;
998 skyboxlightb=skyboxb;
1000 if(!stealthloading)funpackf(tfile, "Bf Bf Bf Bf Bf Bi", &player[0].coords.x,&player[0].coords.y,&player[0].coords.z,&player[0].rotation,&player[0].targetrotation, &player[0].num_weapons);
1001 if(stealthloading)funpackf(tfile, "Bf Bf Bf Bf Bf Bi", &lamefloat,&lamefloat,&lamefloat,&lamefloat,&lamefloat, &player[0].num_weapons);
1002 player[0].originalcoords=player[0].coords;
1003 if(player[0].num_weapons>0&&player[0].num_weapons<5)
1005 for(j=0;j<player[0].num_weapons;j++)
1007 player[0].weaponids[j]=weapons.numweapons;
1008 funpackf(tfile, "Bi", &weapons.type[weapons.numweapons]);
1009 weapons.owner[weapons.numweapons]=0;
1010 weapons.numweapons++;
1014 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1016 funpackf(tfile, "Bf Bf Bf", &player[0].armorhead, &player[0].armorhigh, &player[0].armorlow);
1017 funpackf(tfile, "Bf Bf Bf", &player[0].protectionhead, &player[0].protectionhigh, &player[0].protectionlow);
1018 funpackf(tfile, "Bf Bf Bf", &player[0].metalhead, &player[0].metalhigh, &player[0].metallow);
1019 funpackf(tfile, "Bf Bf", &player[0].power, &player[0].speedmult);
1021 funpackf(tfile, "Bi", &player[0].numclothes);
1025 funpackf(tfile, "Bi Bi", &player[0].whichskin, &player[0].creature);
1029 player[0].whichskin=0;
1030 player[0].creature=rabbittype;
1033 for(i=0;i<max_dialogues;i++)
1035 for(j=0;j<max_dialoguelength;j++)
1039 dialoguetext[i][j][k]='\0';
1043 dialoguename[i][j][k]='\0';
1048 player[0].lastattack=-1;
1049 player[0].lastattack2=-1;
1050 player[0].lastattack3=-1;
1054 funpackf(tfile, "Bi", &numdialogues);
1057 for(k=0;k<numdialogues;k++)
1059 funpackf(tfile, "Bi", &numdialogueboxes[k]);
1060 funpackf(tfile, "Bi", &dialoguetype[k]);
1063 funpackf(tfile, "Bf Bf Bf", &participantlocation[k][l].x, &participantlocation[k][l].y, &participantlocation[k][l].z);
1064 funpackf(tfile, "Bf", &participantrotation[k][l]);
1066 if(numdialogueboxes)
1068 for(l=0;l<numdialogueboxes[k];l++)
1070 funpackf(tfile, "Bi", &dialogueboxlocation[k][l]);
1071 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][0]);
1072 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][1]);
1073 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][2]);
1074 funpackf(tfile, "Bi", &dialogueboxsound[k][l]);
1078 funpackf(tfile, "Bi",&templength);
1079 if(templength>128||templength<=0)templength=128;
1080 for(m=0;m<templength;m++){
1081 funpackf(tfile, "Bb", &dialoguetext[k][l][m]);
1082 if(dialoguetext[k][l][m]=='\0')break;
1085 funpackf(tfile, "Bi",&templength);
1086 if(templength>64||templength<=0)templength=64;
1087 for(m=0;m<templength;m++){
1088 funpackf(tfile, "Bb", &dialoguename[k][l][m]);
1089 if(dialoguename[k][l][m]=='\0'){
1093 funpackf(tfile, "Bf Bf Bf", &dialoguecamera[k][l].x, &dialoguecamera[k][l].y, &dialoguecamera[k][l].z);
1094 funpackf(tfile, "Bi", &participantfocus[k][l]);
1095 funpackf(tfile, "Bi", &participantaction[k][l]);
1098 funpackf(tfile, "Bf Bf Bf", &participantfacing[k][l][m].x, &participantfacing[k][l][m].y, &participantfacing[k][l][m].z);
1100 funpackf(tfile, "Bf Bf",&dialoguecamerarotation[k][l],&dialoguecamerarotation2[k][l]);
1106 else numdialogues=0;
1108 if(player[0].numclothes)
1110 for(k=0;k<player[0].numclothes;k++)
1112 funpackf(tfile, "Bi", &templength);
1113 for(l=0;l<templength;l++)
1114 funpackf(tfile, "Bb", &player[0].clothes[k][l]);
1115 player[0].clothes[k][templength]='\0';
1116 funpackf(tfile, "Bf Bf Bf", &player[0].clothestintr[k], &player[0].clothestintg[k], &player[0].clothestintb[k]);
1120 funpackf(tfile, "Bi", &environment);
1122 funpackf(tfile, "Bi", &objects.numobjects);
1123 if(objects.numobjects)
1125 for(i=0;i<objects.numobjects;i++)
1127 funpackf(tfile, "Bi Bf Bf Bf Bf Bf Bf", &objects.type[i],&objects.rotation[i],&objects.rotation2[i], &objects.position[i].x, &objects.position[i].y, &objects.position[i].z,&objects.scale[i]);
1128 if(objects.type[i]==treeleavestype)objects.scale[i]=objects.scale[i-1];
1134 funpackf(tfile, "Bi", &numhotspots);
1137 for(i=0;i<numhotspots;i++)
1139 funpackf(tfile, "Bi Bf Bf Bf Bf", &hotspottype[i],&hotspotsize[i],&hotspot[i].x,&hotspot[i].y,&hotspot[i].z);
1140 funpackf(tfile, "Bi", &templength);
1142 for(l=0;l<templength;l++)
1143 funpackf(tfile, "Bb", &hotspottext[i][l]);
1144 hotspottext[i][templength]='\0';
1145 if(hotspottype[i]==-111)indemo=1;
1151 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1156 for(i=0;i<objects.numobjects;i++)
1158 objects.center+=objects.position[i];
1160 objects.center/=objects.numobjects;
1163 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1165 float maxdistance=0;
1168 for(i=0;i<objects.numobjects;i++)
1170 tempdist=findDistancefast(&objects.center,&objects.position[i]);
1171 if(tempdist>maxdistance)
1174 maxdistance=tempdist;
1177 objects.radius=fast_sqrt(maxdistance);
1180 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1181 //mapcenter=objects.center;
1182 //mapradius=objects.radius;
1184 funpackf(tfile, "Bi", &numplayers);
1185 int howmanyremoved=0;
1186 bool removeanother=0;
1187 if(numplayers>1&&numplayers<maxplayers)
1189 for(i=1;i<numplayers;i++)
1191 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1194 funpackf(tfile, "Bi Bi Bf Bf Bf Bi",&player[i-howmanyremoved].whichskin,&player[i-howmanyremoved].creature, &player[i-howmanyremoved].coords.x,&player[i-howmanyremoved].coords.y,&player[i-howmanyremoved].coords.z,&player[i-howmanyremoved].num_weapons);
1195 if(mapvers>=5)funpackf(tfile, "Bi", &player[i-howmanyremoved].howactive);
1196 else player[i-howmanyremoved].howactive=typeactive;
1197 if(mapvers>=3)funpackf(tfile, "Bf",&player[i-howmanyremoved].scale);
1198 else player[i-howmanyremoved].scale=-1;
1199 if(mapvers>=11)funpackf(tfile, "Bb",&player[i-howmanyremoved].immobile);
1200 else player[i-howmanyremoved].immobile=0;
1201 if(mapvers>=12)funpackf(tfile, "Bf",&player[i-howmanyremoved].rotation);
1202 else player[i-howmanyremoved].rotation=0;
1203 player[i-howmanyremoved].targetrotation=player[i-howmanyremoved].rotation;
1204 if(player[i-howmanyremoved].num_weapons<0||player[i-howmanyremoved].num_weapons>5){
1210 if(player[i-howmanyremoved].num_weapons>0&&player[i-howmanyremoved].num_weapons<5)
1212 for(j=0;j<player[i-howmanyremoved].num_weapons;j++)
1214 player[i-howmanyremoved].weaponids[j]=weapons.numweapons;
1215 funpackf(tfile, "Bi", &weapons.type[player[i-howmanyremoved].weaponids[j]]);
1216 weapons.owner[player[i-howmanyremoved].weaponids[j]]=i;
1217 weapons.numweapons++;
1220 funpackf(tfile, "Bi", &player[i-howmanyremoved].numwaypoints);
1221 //player[i-howmanyremoved].numwaypoints=10;
1222 for(j=0;j<player[i-howmanyremoved].numwaypoints;j++)
1224 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].x);
1225 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].y);
1226 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].z);
1227 if(mapvers>=5)funpackf(tfile, "Bi", &player[i-howmanyremoved].waypointtype[j]);
1228 else player[i-howmanyremoved].waypointtype[j] = wpkeepwalking;
1231 funpackf(tfile, "Bi", &player[i-howmanyremoved].waypoint);
1232 if(player[i-howmanyremoved].waypoint>player[i-howmanyremoved].numwaypoints-1)player[i-howmanyremoved].waypoint=0;
1234 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].armorhead, &player[i-howmanyremoved].armorhigh, &player[i-howmanyremoved].armorlow);
1235 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].protectionhead, &player[i-howmanyremoved].protectionhigh, &player[i-howmanyremoved].protectionlow);
1236 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].metalhead, &player[i-howmanyremoved].metalhigh, &player[i-howmanyremoved].metallow);
1237 funpackf(tfile, "Bf Bf", &player[i-howmanyremoved].power, &player[i-howmanyremoved].speedmult);
1239 if(mapvers>=4)funpackf(tfile, "Bf Bf Bf Bf", &headprop, &bodyprop, &armprop, &legprop);
1247 if(player[i-howmanyremoved].creature==wolftype)
1249 player[i-howmanyremoved].proportionhead=1.1*headprop;
1250 player[i-howmanyremoved].proportionbody=1.1*bodyprop;
1251 player[i-howmanyremoved].proportionarms=1.1*armprop;
1252 player[i-howmanyremoved].proportionlegs=1.1*legprop;
1255 if(player[i-howmanyremoved].creature==rabbittype)
1257 player[i-howmanyremoved].proportionhead=1.2*headprop;
1258 player[i-howmanyremoved].proportionbody=1.05*bodyprop;
1259 player[i-howmanyremoved].proportionarms=1.00*armprop;
1260 player[i-howmanyremoved].proportionlegs=1.1*legprop;
1261 player[i-howmanyremoved].proportionlegs.y=1.05*legprop;
1264 funpackf(tfile, "Bi", &player[i-howmanyremoved].numclothes);
1265 if(player[i-howmanyremoved].numclothes)
1267 for(k=0;k<player[i-howmanyremoved].numclothes;k++)
1270 funpackf(tfile, "Bi", &templength);
1271 for(l=0;l<templength;l++)
1272 funpackf(tfile, "Bb", &player[i-howmanyremoved].clothes[k][l]);
1273 player[i-howmanyremoved].clothes[k][templength]='\0';
1274 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].clothestintr[k], &player[i-howmanyremoved].clothestintg[k], &player[i-howmanyremoved].clothestintb[k]);
1280 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1282 numplayers-=howmanyremoved;
1283 funpackf(tfile, "Bi", &numpathpoints);
1284 if(numpathpoints>30||numpathpoints<0)
1288 for(j=0;j<numpathpoints;j++)
1290 funpackf(tfile, "Bf Bf Bf Bi", &pathpoint[j].x,&pathpoint[j].y,&pathpoint[j].z,&numpathpointconnect[j]);
1291 for(k=0;k<numpathpointconnect[j];k++){
1292 funpackf(tfile, "Bi", &pathpointconnect[j][k]);
1296 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1298 funpackf(tfile, "Bf Bf Bf Bf", &mapcenter.x,&mapcenter.y,&mapcenter.z,&mapradius);
1301 if(environment!=oldenvironment)Setenvironment(environment);
1302 oldenvironment=environment;
1306 j=objects.numobjects;
1307 objects.numobjects=0;
1310 //if(objects.type[i]!=spiketype)
1311 objects.MakeObject(objects.type[i],objects.position[i],objects.rotation[i],objects.rotation2[i],objects.scale[i]);
1312 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1315 //if(skyboxtexture){
1316 terrain.DoShadows();
1317 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1318 objects.DoShadows();
1319 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1321 else terrain.DoLighting();
1327 oldlevel=whichlevel;
1330 if(numplayers>maxplayers-1)numplayers=maxplayers-1;
1331 for(i=0;i<numplayers;i++)
1333 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1337 if(i==0||player[i].scale<0)player[i].scale=.2;
1338 player[i].skeleton.free=0;
1339 player[i].skeleton.id=i;
1340 //if(Random()%2==0)player[i].creature=wolftype;
1341 //else player[i].creature=rabbittype;
1342 if(i==0&&mapvers<9)player[i].creature=rabbittype;
1343 if(player[i].creature!=wolftype)player[i].skeleton.Load((char *)":Data:Skeleton:Basic Figure",(char *)":Data:Skeleton:Basic Figurelow",(char *)":Data:Skeleton:Rabbitbelt",(char *)":Data:Models:Body.solid",(char *)":Data:Models:Body2.solid",(char *)":Data:Models:Body3.solid",(char *)":Data:Models:Body4.solid",(char *)":Data:Models:Body5.solid",(char *)":Data:Models:Body6.solid",(char *)":Data:Models:Body7.solid",(char *)":Data:Models:Bodylow.solid",(char *)":Data:Models:Belt.solid",0);
1346 if(player[i].creature!=wolftype){
1347 player[i].skeleton.Load((char *)":Data:Skeleton:Basic Figure",(char *)":Data:Skeleton:Basic Figurelow",(char *)":Data:Skeleton:Rabbitbelt",(char *)":Data:Models:Body.solid",(char *)":Data:Models:Body2.solid",(char *)":Data:Models:Body3.solid",(char *)":Data:Models:Body4.solid",(char *)":Data:Models:Body5.solid",(char *)":Data:Models:Body6.solid",(char *)":Data:Models:Body7.solid",(char *)":Data:Models:Bodylow.solid",(char *)":Data:Models:Belt.solid",1);
1348 LoadTexture(":Data:Textures:Belt.png",&player[i].skeleton.drawmodelclothes.textureptr,1,1);
1350 if(player[i].creature==wolftype){
1351 player[i].skeleton.Load((char *)":Data:Skeleton:Basic Figure Wolf",(char *)":Data:Skeleton:Basic Figure Wolf Low",(char *)":Data:Skeleton:Rabbitbelt",(char *)":Data:Models:Wolf.solid",(char *)":Data:Models:Wolf2.solid",(char *)":Data:Models:Wolf3.solid",(char *)":Data:Models:Wolf4.solid",(char *)":Data:Models:Wolf5.solid",(char *)":Data:Models:Wolf6.solid",(char *)":Data:Models:Wolf7.solid",(char *)":Data:Models:Wolflow.solid",(char *)":Data:Models:Belt.solid",0);
1357 texsize=512*512*3/texdetail/texdetail;
1358 //if(!player[i].loaded)player[i].skeleton.skinText = new GLubyte[texsize];
1359 //player[i].skeleton.skinText.resize(texsize);
1361 if(player[i].creature==rabbittype)
1363 if(player[i].whichskin==0){
1364 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1366 else if(player[i].whichskin==1){
1367 LoadTextureSave(":Data:Textures:Fur.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1369 else if(player[i].whichskin==2){
1370 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1372 else if(player[i].whichskin==3){
1373 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1375 else if(player[i].whichskin==4){
1376 LoadTextureSave(":Data:Textures:Otter.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1378 else if(player[i].whichskin==5){
1379 LoadTextureSave(":Data:Textures:Opal.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1381 else if(player[i].whichskin==6){
1382 LoadTextureSave(":Data:Textures:Sable.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1384 else if(player[i].whichskin==7){
1385 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1387 else if(player[i].whichskin==8){
1388 LoadTextureSave(":Data:Textures:BW2.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1390 else if(player[i].whichskin==9){
1391 LoadTextureSave(":Data:Textures:WB2.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1394 if(player[i].creature==wolftype)
1396 //k=abs(Random()%3);
1397 if(player[i].whichskin==0){
1398 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1400 else if(player[i].whichskin==1){
1401 LoadTextureSave(":Data:Textures:Darkwolf.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1403 else if(player[i].whichskin==2){
1404 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1408 if(player[i].numclothes)
1410 for(j=0;j<player[i].numclothes;j++)
1412 tintr=player[i].clothestintr[j];
1413 tintg=player[i].clothestintg[j];
1414 tintb=player[i].clothestintb[j];
1415 AddClothes((char *)player[i].clothes[j],0,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1417 player[i].DoMipmaps(5,0,0,player[i].skeleton.skinsize,player[i].skeleton.skinsize);
1420 player[i].currentanimation=bounceidleanim;
1421 player[i].targetanimation=bounceidleanim;
1422 player[i].currentframe=0;
1423 player[i].targetframe=1;
1425 player[i].speed=1+(float)(Random()%100)/1000;
1426 if(difficulty==0)player[i].speed-=.2;
1427 if(difficulty==1)player[i].speed-=.1;
1429 player[i].velocity=0;
1430 player[i].oldcoords=player[i].coords;
1431 player[i].realoldcoords=player[i].coords;
1434 player[i].skeleton.id=i;
1435 player[i].updatedelay=0;
1436 player[i].normalsupdatedelay=0;
1438 player[i].aitype=passivetype;
1439 player[i].aitarget=0;
1440 player[i].madskills=0;
1444 player[i].proportionhead=1.2;
1445 player[i].proportionbody=1.05;
1446 player[i].proportionarms=1.00;
1447 player[i].proportionlegs=1.1;
1448 player[i].proportionlegs.y=1.05;
1450 player[i].headless=0;
1451 player[i].currentoffset=0;
1452 player[i].targetoffset=0;
1453 /*player[i].armorhead=1;
1454 player[i].armorhigh=1;
1455 player[i].armorlow=1;
1456 player[i].protectionhead=1;
1457 player[i].protectionhigh=1;
1458 player[i].protectionlow=1;
1459 player[i].metalhead=1;
1460 player[i].metalhigh=1;
1461 player[i].metallow=1;
1463 player[i].speedmult=1;*/
1465 player[i].damagetolerance=200;
1467 if(player[i].creature==wolftype)
1469 /*player[i].proportionhead=1.1;
1470 player[i].proportionbody=1.1;
1471 player[i].proportionarms=1.1;
1472 player[i].proportionlegs=1.1;
1473 player[i].proportionlegs.y=1.1;*/
1474 if(i==0||player[i].scale<0)player[i].scale=.23;
1476 player[i].damagetolerance=300;
1479 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1482 player[i].proportionhead.z=0;
1483 player[i].proportionbody.z=0;
1484 player[i].proportionarms.z=0;
1485 player[i].proportionlegs.z=0;
1488 player[i].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0);
1490 player[i].headmorphness=0;
1491 player[i].targetheadmorphness=1;
1492 player[i].headmorphstart=0;
1493 player[i].headmorphend=0;
1495 player[i].pausetime=0;
1498 player[i].jumppower=5;
1500 player[i].permanentdamage=0;
1501 player[i].superpermanentdamage=0;
1503 player[i].forwardkeydown=0;
1504 player[i].leftkeydown=0;
1505 player[i].backkeydown=0;
1506 player[i].rightkeydown=0;
1507 player[i].jumpkeydown=0;
1508 player[i].crouchkeydown=0;
1509 player[i].throwkeydown=0;
1511 player[i].collided=-10;
1513 player[i].bloodloss=0;
1514 player[i].weaponactive=-1;
1515 player[i].weaponstuck=-1;
1516 player[i].bleeding=0;
1517 player[i].deathbleeding=0;
1518 player[i].stunned=0;
1519 player[i].hasvictim=0;
1520 player[i].wentforweapon=0;
1523 player[0].aitype=playercontrolled;
1524 player[0].weaponactive=-1;
1528 //player[0].speedmult=1/.9;
1529 player[0].power=1/.9;
1534 //player[0].speedmult=1/.8;
1535 player[0].power=1/.8;
1538 //player[0].weaponstuck=1;
1540 if(difficulty==1)player[0].damagetolerance=250;
1541 if(difficulty==0)player[0].damagetolerance=300;
1542 if(difficulty==0)player[0].armorhead*=1.5;
1543 if(difficulty==0)player[0].armorhigh*=1.5;
1544 if(difficulty==0)player[0].armorlow*=1.5;
1545 cameraloc=player[0].coords;
1547 rotation=player[0].rotation;
1549 hawkcoords=player[0].coords;
1552 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1553 //weapons.numweapons=numplayers;
1554 for(i=0;i<weapons.numweapons;i++)
1556 weapons.bloody[i]=0;
1557 weapons.blooddrip[i]=0;
1558 weapons.blooddripdelay[i]=0;
1559 weapons.onfire[i]=0;
1560 weapons.flamedelay[i]=0;
1561 weapons.damage[i]=0;
1562 //weapons.type[i]=sword;
1563 if(weapons.type[i]==sword){
1564 weapons.mass[i]=1.5;
1565 weapons.tipmass[i]=1;
1566 weapons.length[i]=.8;
1568 if(weapons.type[i]==staff){
1570 weapons.tipmass[i]=1;
1571 weapons.length[i]=1.5;
1573 if(weapons.type[i]==knife){
1575 weapons.tipmass[i]=1.2;
1576 weapons.length[i]=.25;
1578 weapons.position[i]=-1000;
1579 weapons.tippoint[i]=-1000;
1582 /* for(i=0;i<32;i++){
1584 FSOUND_StopSound(i);
1587 LOG("Starting background music...");
1589 FSOUND_StopSound(FSOUND_ALL);
1590 if(environment==snowyenvironment)
1594 PlayStreamEx(stream_wind, strm[stream_wind], NULL, TRUE);
1595 FSOUND_SetPaused(channels[stream_wind], FALSE);
1596 FSOUND_SetVolume(channels[stream_wind], 256);
1599 else if(environment==desertenvironment)
1603 //PlaySoundEx(desertambient,
1604 // samp[desertambient], NULL, TRUE);
1605 PlayStreamEx(stream_desertambient,
1606 strm[stream_desertambient], NULL, TRUE);
1607 FSOUND_SetPaused(channels[stream_desertambient], FALSE);
1608 FSOUND_SetVolume(channels[stream_desertambient], 256);
1611 else if(environment==grassyenvironment)
1615 //PlaySoundEx(wind, samp[wind], NULL, TRUE);
1616 PlayStreamEx(stream_wind, strm[stream_wind], NULL, TRUE);
1617 FSOUND_SetPaused(channels[stream_wind], FALSE);
1618 FSOUND_SetVolume(channels[stream_wind], 100);
1621 oldmusicvolume[0]=0;
1622 oldmusicvolume[1]=0;
1623 oldmusicvolume[2]=0;
1624 oldmusicvolume[3]=0;
1627 /*LoadTexture(":Data:Textures:cloud.png",&sprites.cloudtexture,1,1);
1628 LoadTexture(":Data:Textures:cloudimpact.png",&sprites.cloudimpacttexture,1,1);
1629 LoadTexture(":Data:Textures:bloodparticle.png",&sprites.bloodtexture,1,1);
1630 LoadTexture(":Data:Textures:snowflake.png",&sprites.snowflaketexture,1,1);
1631 LoadTexture(":Data:Textures:flame.png",&sprites.flametexture,1,1);
1632 LoadTexture(":Data:Textures:bloodflame.png",&sprites.bloodflametexture,1,1);
1633 LoadTexture(":Data:Textures:smoke.png",&sprites.smoketexture,1,1);
1634 LoadTexture(":Data:Textures:shine.png",&sprites.shinetexture,1,0);
1649 static int i,k,j,l,m;
1650 static XYZ facing,flatfacing,absflatfacing;
1651 static XYZ rotatetarget;
1653 static float oldtargetrotation;
1654 static int target, numgood;
1655 static XYZ tempcoords1,tempcoords2;
1658 static XYZ lowpoint,lowpointtarget,lowpoint2,lowpointtarget2,lowpoint3,lowpointtarget3,lowpoint4,lowpointtarget4,lowpoint5,lowpointtarget5,lowpoint6,lowpointtarget6,lowpoint7,lowpointtarget7,colpoint,colpoint2;
1659 static int whichhit;
1660 static bool donesomething;
1661 static bool oldjumpkeydown;
1665 float headprop,bodyprop,armprop,legprop;
1669 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
1670 FSOUND_SetVolume(channels[consolesuccesssound], 256);
1671 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
1675 consoletext[k][j]=consoletext[k-1][j];
1677 consolechars[k]=consolechars[k-1];
1681 displaytext[k][j]=displaytext[k-1][j];
1683 displaychars[k]=displaychars[k-1];
1684 displaytime[k]=displaytime[k-1];
1687 consoletext[1][j]=' ';
1688 displaytext[1][j]=' ';
1690 sprintf (consoletext[1], netmessages);
1691 sprintf (displaytext[1], netmessages);
1692 consolechars[1]=255;
1693 displaychars[1]=255;
1698 displaytime[i]+=multiplier;
1701 static unsigned char theKeyMap[16];
1702 GetKeys( theKeyMap );
1707 static bool mainmenutogglekeydown;
1709 if(mainmenu&&endgame==1)mainmenu=10;
1710 if(IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)&&!mainmenutogglekeydown&&(mainmenu==7&&entername)){
1712 displaytext[0][j]=' ';
1717 mainmenutogglekeydown=1;
1719 if((IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)||(mainmenu==0&&((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY)||(campaign)))&&!oldjumpkeydown&&campaign&&winfreeze))&&!mainmenutogglekeydown&&(!mainmenu||gameon||mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||(mainmenu==7&&!entername)||mainmenu==9||mainmenu==11||(mainmenu==12&&!tryquit)||mainmenu==13||mainmenu==14||mainmenu==15||mainmenu==16||mainmenu==17||mainmenu==10)){
1721 if(mainmenu==1||mainmenu==2||mainmenu==0){
1722 if(mainmenu==0&&!winfreeze)mainmenu=2;
1723 else if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1)mainmenu=100;
1724 else if(mainmenu==0&&winfreeze){
1725 /* if(campaignchoosenext[campaignchoicewhich[whichchoice]]==2)
1727 else stealthloading=0;
1729 if(!stealthloading){
1730 float gLoc[3]={0,0,0};
1731 float vel[3]={0,0,0};
1732 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
1733 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
1734 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
1735 FSOUND_SetVolume(channels[firestartsound], 256);
1736 FSOUND_SetPaused(channels[firestartsound], FALSE);
1737 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
1748 for(i=0;i<campaignnumlevels;i++){
1750 levelhighlight[i]=0;
1755 if(accountcampaignchoicesmade[accountactive])
1756 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
1757 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
1758 levelvisible[levelorder[i+1]]=1;
1760 int whichlevelstart;
1761 whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
1762 if(whichlevelstart<0){
1763 campaignchoicenum=1;
1764 campaignchoicewhich[0]=0;
1768 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
1769 if(campaignchoicenum)
1770 for(i=0;i<campaignchoicenum;i++){
1771 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
1772 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
1773 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
1780 if(firstload)TickOnceAfter();
1781 if(!firstload)LoadStuff();
1798 //accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
1799 //accountcampaignchoicesmade[accountactive]++;
1802 strcat(mapname,campaignmapname[campaignchoicewhich[0]]);
1810 FSOUND_SetPaused(channels[music3], TRUE);
1814 else if(mainmenu==1||mainmenu==2)mainmenu=0;
1815 if(mainmenu&&musictoggle){
1816 if(mainmenu==1||mainmenu==2||mainmenu==100){
1817 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
1818 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
1819 FSOUND_SetPaused(channels[stream_music3], FALSE);
1820 FSOUND_SetVolume(channels[stream_music3], 256);
1821 FSOUND_SetPaused(channels[music1], TRUE);
1825 FSOUND_SetPaused(channels[stream_music3], TRUE);
1826 FSOUND_SetPaused(channels[music1], FALSE);
1830 float gLoc[3]={0,0,0};
1831 float vel[3]={0,0,0};
1832 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
1833 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
1834 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1835 FSOUND_SetVolume(channels[fireendsound], 256);
1836 FSOUND_SetPaused(channels[fireendsound], FALSE);
1837 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1845 if(newdetail>2)newdetail=detail;
1846 if(newdetail<0)newdetail=detail;
1847 if(newscreenwidth>3000)newscreenwidth=screenwidth;
1848 if(newscreenwidth<0)newscreenwidth=screenwidth;
1849 if(newscreenheight>3000)newscreenheight=screenheight;
1850 if(newscreenheight<0)newscreenheight=screenheight;
1852 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
1853 opstream << "Screenwidth:\n";
1854 opstream << newscreenwidth;
1855 opstream << "\nScreenheight:\n";
1856 opstream << newscreenheight;
1857 opstream << "\nMouse sensitivity:\n";
1858 opstream << usermousesensitivity;
1859 opstream << "\nBlur(0,1):\n";
1860 opstream << ismotionblur;
1861 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
1862 opstream << newdetail;
1863 opstream << "\nFloating jump:\n";
1864 opstream << floatjump;
1865 opstream << "\nMouse jump:\n";
1866 opstream << mousejump;
1867 opstream << "\nAmbient sound:\n";
1868 opstream << ambientsound;
1869 opstream << "\nBlood (0,1,2):\n";
1870 opstream << bloodtoggle;
1871 opstream << "\nAuto slomo:\n";
1872 opstream << autoslomo;
1873 opstream << "\nFoliage:\n";
1874 opstream << foliage;
1875 opstream << "\nMusic:\n";
1876 opstream << musictoggle;
1877 opstream << "\nTrilinear:\n";
1878 opstream << trilinear;
1879 opstream << "\nDecals(shadows,blood puddles,etc):\n";
1881 opstream << "\nInvert mouse:\n";
1882 opstream << invertmouse;
1883 opstream << "\nGamespeed:\n";
1884 if(oldgamespeed==0)oldgamespeed=1;
1885 opstream << oldgamespeed;
1886 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
1887 opstream << difficulty;
1888 opstream << "\nDamage effects(blackout, doublevision):\n";
1889 opstream << damageeffects;
1890 opstream << "\nText:\n";
1891 opstream << texttoggle;
1892 opstream << "\nDebug:\n";
1893 opstream << debugmode;
1894 opstream << "\nVBL Sync:\n";
1895 opstream << vblsync;
1896 opstream << "\nShow Points:\n";
1897 opstream << showpoints;
1898 opstream << "\nAlways Blur:\n";
1899 opstream << alwaysblur;
1900 opstream << "\nImmediate mode (turn on on G5):\n";
1901 opstream << immediate;
1902 opstream << "\nVelocity blur:\n";
1903 opstream << velocityblur;
1904 opstream << "\nVolume:\n";
1906 opstream << "\nForward key:\n";
1907 opstream << KeyToChar(forwardkey);
1908 opstream << "\nBack key:\n";
1909 opstream << KeyToChar(backkey);
1910 opstream << "\nLeft key:\n";
1911 opstream << KeyToChar(leftkey);
1912 opstream << "\nRight key:\n";
1913 opstream << KeyToChar(rightkey);
1914 opstream << "\nJump key:\n";
1915 opstream << KeyToChar(jumpkey);
1916 opstream << "\nCrouch key:\n";
1917 opstream << KeyToChar(crouchkey);
1918 opstream << "\nDraw key:\n";
1919 opstream << KeyToChar(drawkey);
1920 opstream << "\nThrow key:\n";
1921 opstream << KeyToChar(throwkey);
1922 opstream << "\nAttack key:\n";
1923 opstream << KeyToChar(attackkey);
1924 opstream << "\nChat key:\n";
1925 opstream << KeyToChar(chatkey);
1928 if(mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==9||mainmenu==12||mainmenu==13||mainmenu==14||mainmenu==10||mainmenu==11||mainmenu==100){
1929 float gLoc[3]={0,0,0};
1930 float vel[3]={0,0,0};
1931 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
1932 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
1933 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1934 FSOUND_SetVolume(channels[fireendsound], 256);
1935 FSOUND_SetPaused(channels[fireendsound], FALSE);
1936 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1944 if(mainmenu==3&&gameon)mainmenu=2;
1945 if(mainmenu==3&&!gameon)mainmenu=1;
1946 if(mainmenu==5&&gameon)mainmenu=2;
1947 if(mainmenu==5&&!gameon)mainmenu=1;
1948 if(mainmenu==4)mainmenu=3;
1949 if(mainmenu==6)mainmenu=5;
1950 if(mainmenu==7)mainmenu=1;
1951 if(mainmenu==9)mainmenu=5;
1952 if(mainmenu==11)mainmenu=5;
1953 if(mainmenu==12)mainmenu=5;
1954 if(mainmenu==13)mainmenu=12;
1955 if(mainmenu==14)mainmenu=13;
1956 if(mainmenu==10)mainmenu=5;
1962 mainmenutogglekeydown=1;
1964 if(!IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)){
1965 mainmenutogglekeydown=0;
1969 /*static bool minimaptogglekeydown;
1970 if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!minimaptogglekeydown){
1972 minimaptogglekeydown=1;
1974 if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)){
1975 minimaptogglekeydown=0;
1979 static bool minimaptogglekeydown;
1980 if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!minimaptogglekeydown&&tutoriallevel){
1981 if(tutorialstage!=51)
1982 tutorialstagetime=tutorialmaxtime;
1983 PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, TRUE);
1984 FSOUND_SetVolume(channels[consolefailsound], 128);
1985 FSOUND_SetPaused(channels[consolefailsound], FALSE);
1986 minimaptogglekeydown=1;
1988 if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)){
1989 minimaptogglekeydown=0;
1994 if(mainmenu==1||mainmenu==2){
1995 if(Button()&&!oldbutton&&selected==1){
1997 float gLoc[3]={0,0,0};
1998 float vel[3]={0,0,0};
1999 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2000 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2001 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2002 FSOUND_SetVolume(channels[firestartsound], 256);
2003 FSOUND_SetPaused(channels[firestartsound], FALSE);
2004 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2013 if(accountactive!=-1)mainmenu=5;
2020 if(firstload)TickOnceAfter();
2021 if(!firstload)LoadStuff();
2027 FSOUND_SetPaused(channels[music3], TRUE); */
2033 FSOUND_SetPaused(channels[stream_music3], TRUE);
2034 FSOUND_SetPaused(channels[music1], FALSE);
2038 if(Button()&&!oldbutton&&selected==2){
2039 float gLoc[3]={0,0,0};
2040 float vel[3]={0,0,0};
2041 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2042 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2043 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2044 FSOUND_SetVolume(channels[firestartsound], 256);
2045 FSOUND_SetPaused(channels[firestartsound], FALSE);
2046 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2058 if(newdetail>2)newdetail=detail;
2059 if(newdetail<0)newdetail=detail;
2060 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2061 if(newscreenwidth<0)newscreenwidth=screenwidth;
2062 if(newscreenheight>3000)newscreenheight=screenheight;
2063 if(newscreenheight<0)newscreenheight=screenheight;
2066 if(Button()&&!oldbutton&&selected==3){
2067 float gLoc[3]={0,0,0};
2068 float vel[3]={0,0,0};
2069 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2070 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2071 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2072 FSOUND_SetVolume(channels[fireendsound], 256);
2073 FSOUND_SetPaused(channels[fireendsound], FALSE);
2074 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2085 if(registered)FSOUND_SetPaused(channels[stream_music3], TRUE);
2093 if(Button())oldbutton=1;
2098 if(Button()&&!oldbutton&&selected!=-1){
2099 float gLoc[3]={0,0,0};
2100 float vel[3]={0,0,0};
2101 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2102 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2103 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2104 FSOUND_SetVolume(channels[firestartsound], 256);
2105 FSOUND_SetPaused(channels[firestartsound], FALSE);
2106 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2108 if(Button()&&!oldbutton&&selected==0){
2111 if(newscreenwidth==640&&newscreenheight==480)whichres=0;
2112 if(newscreenwidth==800&&newscreenheight==600)whichres=1;
2113 if(newscreenwidth==1024&&newscreenheight==768)whichres=2;
2114 if(newscreenwidth==1280&&newscreenheight==1024)whichres=3;
2115 if(newscreenwidth==1600&&newscreenheight==1200)whichres=4;
2116 if(newscreenwidth==840&&newscreenheight==524)whichres=5;
2117 if(newscreenwidth==1024&&newscreenheight==640)whichres=6;
2118 if(newscreenwidth==1344&&newscreenheight==840)whichres=7;
2120 if(whichres==-1||whichres==7){
2122 newscreenheight=480;
2126 newscreenheight=600;
2129 newscreenwidth=1024;
2130 newscreenheight=768;
2133 newscreenwidth=1280;
2134 newscreenheight=1024;
2137 newscreenwidth=1600;
2138 newscreenheight=1200;
2142 newscreenheight=524;
2145 newscreenwidth=1024;
2146 newscreenheight=640;
2149 newscreenwidth=1344;
2150 newscreenheight=840;
2153 if(Button()&&!oldbutton&&selected==1){
2155 if(newdetail>2)newdetail=0;
2157 if(Button()&&!oldbutton&&selected==2){
2159 if(bloodtoggle>2)bloodtoggle=0;
2161 if(Button()&&!oldbutton&&selected==3){
2163 if(difficulty>2)difficulty=0;
2165 if(Button()&&!oldbutton&&selected==4){
2166 ismotionblur=1-ismotionblur;
2168 if(Button()&&!oldbutton&&selected==5){
2171 if(Button()&&!oldbutton&&selected==6){
2172 musictoggle=1-musictoggle;
2175 FSOUND_SetPaused(channels[music1], TRUE);
2176 FSOUND_SetPaused(channels[stream_music2], TRUE);
2177 FSOUND_SetPaused(channels[stream_music3], TRUE);
2180 oldmusicvolume[i]=0;
2186 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
2187 FSOUND_SetPaused(channels[stream_music3], FALSE);
2188 FSOUND_SetVolume(channels[stream_music3], 256);
2191 if(Button()&&!oldbutton&&selected==9){
2192 invertmouse=1-invertmouse;
2194 if(Button()&&!oldbutton&&selected==10){
2195 usermousesensitivity+=.2;
2196 if(usermousesensitivity>2)usermousesensitivity=.2;
2198 if(Button()&&!oldbutton&&selected==11){
2200 if(volume>1.0001f)volume=0;
2201 FSOUND_SetSFXMasterVolume((int)(volume*255));
2203 if(Button()&&!oldbutton&&selected==7){
2204 /*float gLoc[3]={0,0,0};
2205 float vel[3]={0,0,0};
2206 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2207 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2208 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2209 FSOUND_SetVolume(channels[firestartsound], 256);
2210 FSOUND_SetPaused(channels[firestartsound], FALSE);
2211 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2224 if(Button()&&!oldbutton&&selected==8){
2225 float gLoc[3]={0,0,0};
2226 float vel[3]={0,0,0};
2227 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2228 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2229 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2230 FSOUND_SetVolume(channels[fireendsound], 256);
2231 FSOUND_SetPaused(channels[fireendsound], FALSE);
2232 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2240 if(newdetail>2)newdetail=detail;
2241 if(newdetail<0)newdetail=detail;
2242 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2243 if(newscreenwidth<0)newscreenwidth=screenwidth;
2244 if(newscreenheight>3000)newscreenheight=screenheight;
2245 if(newscreenheight<0)newscreenheight=screenheight;
2248 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
2249 opstream << "Screenwidth:\n";
2250 opstream << newscreenwidth;
2251 opstream << "\nScreenheight:\n";
2252 opstream << newscreenheight;
2253 opstream << "\nMouse sensitivity:\n";
2254 opstream << usermousesensitivity;
2255 opstream << "\nBlur(0,1):\n";
2256 opstream << ismotionblur;
2257 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
2258 opstream << newdetail;
2259 opstream << "\nFloating jump:\n";
2260 opstream << floatjump;
2261 opstream << "\nMouse jump:\n";
2262 opstream << mousejump;
2263 opstream << "\nAmbient sound:\n";
2264 opstream << ambientsound;
2265 opstream << "\nBlood (0,1,2):\n";
2266 opstream << bloodtoggle;
2267 opstream << "\nAuto slomo:\n";
2268 opstream << autoslomo;
2269 opstream << "\nFoliage:\n";
2270 opstream << foliage;
2271 opstream << "\nMusic:\n";
2272 opstream << musictoggle;
2273 opstream << "\nTrilinear:\n";
2274 opstream << trilinear;
2275 opstream << "\nDecals(shadows,blood puddles,etc):\n";
2277 opstream << "\nInvert mouse:\n";
2278 opstream << invertmouse;
2279 opstream << "\nGamespeed:\n";
2280 if(oldgamespeed==0)oldgamespeed=1;
2281 opstream << oldgamespeed;
2282 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
2283 opstream << difficulty;
2284 opstream << "\nDamage effects(blackout, doublevision):\n";
2285 opstream << damageeffects;
2286 opstream << "\nText:\n";
2287 opstream << texttoggle;
2288 opstream << "\nDebug:\n";
2289 opstream << debugmode;
2290 opstream << "\nVBL Sync:\n";
2291 opstream << vblsync;
2292 opstream << "\nShow Points:\n";
2293 opstream << showpoints;
2294 opstream << "\nAlways Blur:\n";
2295 opstream << alwaysblur;
2296 opstream << "\nImmediate mode (turn on on G5):\n";
2297 opstream << immediate;
2298 opstream << "\nVelocity blur:\n";
2299 opstream << velocityblur;
2300 opstream << "\nVolume:\n";
2302 opstream << "\nForward key:\n";
2303 opstream << KeyToChar(forwardkey);
2304 opstream << "\nBack key:\n";
2305 opstream << KeyToChar(backkey);
2306 opstream << "\nLeft key:\n";
2307 opstream << KeyToChar(leftkey);
2308 opstream << "\nRight key:\n";
2309 opstream << KeyToChar(rightkey);
2310 opstream << "\nJump key:\n";
2311 opstream << KeyToChar(jumpkey);
2312 opstream << "\nCrouch key:\n";
2313 opstream << KeyToChar(crouchkey);
2314 opstream << "\nDraw key:\n";
2315 opstream << KeyToChar(drawkey);
2316 opstream << "\nThrow key:\n";
2317 opstream << KeyToChar(throwkey);
2318 opstream << "\nAttack key:\n";
2319 opstream << KeyToChar(attackkey);
2320 opstream << "\nChat key:\n";
2321 opstream << KeyToChar(chatkey);
2324 if(mainmenu==3&&gameon)mainmenu=2;
2325 if(mainmenu==3&&!gameon)mainmenu=1;
2327 if(Button())oldbutton=1;
2331 if(Button()&&!oldbutton&&selected!=-1&&keyselect==-1){
2332 float gLoc[3]={0,0,0};
2333 float vel[3]={0,0,0};
2334 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2335 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2336 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2337 FSOUND_SetVolume(channels[firestartsound], 256);
2338 FSOUND_SetPaused(channels[firestartsound], FALSE);
2339 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2341 if(Button()&&!oldbutton&&selected<9&&keyselect==-1){
2349 if(!buttons[i]&&!oldbutton&&!Button())oldbuttons[i]=0;
2351 if((IsKeyDown(theKeyMap, i)||(buttons[0]&&!oldbuttons[0]&&!oldbutton)||(buttons[1]&&!oldbuttons[1]&&!oldbutton))&&keyselect!=-1){
2352 if(i!=MAC_ESCAPE_KEY&&(strcmp(KeyToChar(i),"unknown")||(buttons[0]&&!oldbuttons[0]&&!oldbutton)||(buttons[1]&&!oldbuttons[1]&&!oldbutton))){
2353 float gLoc[3]={0,0,0};
2354 float vel[3]={0,0,0};
2355 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2356 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2357 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2358 FSOUND_SetVolume(channels[fireendsound], 256);
2359 FSOUND_SetPaused(channels[fireendsound], FALSE);
2360 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2364 if(buttons[0]&&!oldbuttons[0])keynum=MAC_MOUSEBUTTON1;
2365 if(buttons[1]&&!oldbuttons[1])keynum=MAC_MOUSEBUTTON2;
2369 if(keyselect==0)forwardkey=keynum;
2370 if(keyselect==1)backkey=keynum;
2371 if(keyselect==2)leftkey=keynum;
2372 if(keyselect==3)rightkey=keynum;
2373 if(keyselect==4)crouchkey=keynum;
2374 if(keyselect==5)jumpkey=keynum;
2375 if(keyselect==6)drawkey=keynum;
2376 if(keyselect==7)throwkey=keynum;
2377 if(keyselect==8)attackkey=keynum;
2382 if(Button()&&!oldbutton&&selected==9){
2383 float gLoc[3]={0,0,0};
2384 float vel[3]={0,0,0};
2385 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2386 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2387 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2388 FSOUND_SetVolume(channels[fireendsound], 256);
2389 FSOUND_SetPaused(channels[fireendsound], FALSE);
2390 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2400 if(newdetail>2)newdetail=detail;
2401 if(newdetail<0)newdetail=detail;
2402 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2403 if(newscreenwidth<0)newscreenwidth=screenwidth;
2404 if(newscreenheight>3000)newscreenheight=screenheight;
2405 if(newscreenheight<0)newscreenheight=screenheight;
2410 if(accountcampaignchoicesmade[accountactive]>8&&!registered){
2411 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
2412 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
2413 FSOUND_SetPaused(channels[stream_music3], FALSE);
2414 FSOUND_SetVolume(channels[stream_music3], 256);
2418 accountcampaignchoicesmade[accountactive]=0;
2419 accountcampaignscore[accountactive]=0;
2420 accountcampaigntime[accountactive]=0;
2422 float gLoc[3]={0,0,0};
2423 float vel[3]={0,0,0};
2424 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2425 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2426 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2427 FSOUND_SetVolume(channels[fireendsound], 256);
2428 FSOUND_SetPaused(channels[fireendsound], FALSE);
2429 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2439 accountcampaignchoicesmade[accountactive]=0;
2440 accountcampaignscore[accountactive]=0;
2441 accountcampaigntime[accountactive]=0;
2445 if(Button()&&!oldbutton&&selected==1){
2446 float gLoc[3]={0,0,0};
2447 float vel[3]={0,0,0};
2448 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2449 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2450 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2451 FSOUND_SetVolume(channels[firestartsound], 256);
2452 FSOUND_SetPaused(channels[firestartsound], FALSE);
2453 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2466 if(firstload)TickOnceAfter();
2467 if(!firstload)LoadStuff();
2474 FSOUND_SetPaused(channels[stream_music3], TRUE);
2476 if(Button()&&!oldbutton&&selected-7>=accountcampaignchoicesmade[accountactive]){//selected>=7&&(selected-7<=campaignnumchoices)){
2477 float gLoc[3]={0,0,0};
2478 float vel[3]={0,0,0};
2479 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2480 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2481 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2482 FSOUND_SetVolume(channels[firestartsound], 256);
2483 FSOUND_SetPaused(channels[firestartsound], FALSE);
2484 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2497 if(firstload)TickOnceAfter();
2498 if(!firstload)LoadStuff();
2514 strcat(mapname,campaignmapname[campaignchoicewhich[selected-7-accountcampaignchoicesmade[accountactive]]]);
2515 whichchoice=selected-7-accountcampaignchoicesmade[accountactive];
2519 //Loadlevel(campaignmapname[levelorder[selected-7]]);
2524 FSOUND_SetPaused(channels[stream_music3], TRUE);
2526 if(Button()&&!oldbutton&&selected==4){
2527 float gLoc[3]={0,0,0};
2528 float vel[3]={0,0,0};
2529 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2530 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2531 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2532 FSOUND_SetVolume(channels[fireendsound], 256);
2533 FSOUND_SetPaused(channels[fireendsound], FALSE);
2534 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2542 if(mainmenu==5&&gameon)mainmenu=2;
2543 if(mainmenu==5&&!gameon)mainmenu=1;
2545 if(Button()&&!oldbutton&&selected==5){
2546 float gLoc[3]={0,0,0};
2547 float vel[3]={0,0,0};
2548 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2549 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2550 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2551 FSOUND_SetVolume(channels[fireendsound], 256);
2552 FSOUND_SetPaused(channels[fireendsound], FALSE);
2553 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2563 if(Button()&&!oldbutton&&selected==3){
2564 float gLoc[3]={0,0,0};
2565 float vel[3]={0,0,0};
2566 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2567 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2568 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2569 FSOUND_SetVolume(channels[firestartsound], 256);
2570 FSOUND_SetPaused(channels[firestartsound], FALSE);
2571 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2581 if(Button()&&!oldbutton&&selected==2){
2582 float gLoc[3]={0,0,0};
2583 float vel[3]={0,0,0};
2584 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2585 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2586 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2587 FSOUND_SetVolume(channels[firestartsound], 256);
2588 FSOUND_SetPaused(channels[firestartsound], FALSE);
2589 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2599 if(Button())oldbutton=1;
2603 if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountprogress[accountactive]){
2604 float gLoc[3]={0,0,0};
2605 float vel[3]={0,0,0};
2606 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2607 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2608 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2609 FSOUND_SetVolume(channels[firestartsound], 256);
2610 FSOUND_SetPaused(channels[firestartsound], FALSE);
2611 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2623 targetlevel=selected;
2624 if(firstload)TickOnceAfter();
2625 if(!firstload)LoadStuff();
2627 Loadlevel(selected);
2633 FSOUND_SetPaused(channels[stream_music3], TRUE);
2635 if(Button()&&!oldbutton&&selected==numchallengelevels){
2636 float gLoc[3]={0,0,0};
2637 float vel[3]={0,0,0};
2638 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2639 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2640 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2641 FSOUND_SetVolume(channels[fireendsound], 256);
2642 FSOUND_SetPaused(channels[fireendsound], FALSE);
2643 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2653 if(Button())oldbutton=1;
2657 if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountprogress[accountactive]){
2658 float gLoc[3]={0,0,0};
2659 float vel[3]={0,0,0};
2660 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2661 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2662 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2663 FSOUND_SetVolume(channels[firestartsound], 256);
2664 FSOUND_SetPaused(channels[firestartsound], FALSE);
2665 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2677 targetlevel=selected;
2678 if(firstload)TickOnceAfter();
2679 if(!firstload)LoadStuff();
2681 Loadlevel(selected);
2687 FSOUND_SetPaused(channels[stream_music3], TRUE);
2689 if(Button()&&!oldbutton&&selected==numchallengelevels){
2690 float gLoc[3]={0,0,0};
2691 float vel[3]={0,0,0};
2692 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2693 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2694 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2695 FSOUND_SetVolume(channels[fireendsound], 256);
2696 FSOUND_SetPaused(channels[fireendsound], FALSE);
2697 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2707 if(Button())oldbutton=1;
2712 if(Button()&&!oldbutton&&selected==3){
2713 float gLoc[3]={0,0,0};
2714 float vel[3]={0,0,0};
2715 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2716 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2717 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2718 FSOUND_SetVolume(channels[fireendsound], 256);
2719 FSOUND_SetPaused(channels[fireendsound], FALSE);
2720 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2730 if(Button())oldbutton=1;
2734 if(mainmenu==15||mainmenu==16){
2735 if(Button()&&!oldbutton&&selected==1){
2736 float gLoc[3]={0,0,0};
2737 float vel[3]={0,0,0};
2738 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2739 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2740 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2741 FSOUND_SetVolume(channels[fireendsound], 256);
2742 FSOUND_SetPaused(channels[fireendsound], FALSE);
2743 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2751 if(mainmenu==15)mainmenu=5;
2754 if(Button())oldbutton=1;
2760 if(Button()&&!oldbutton&&selected==3){
2762 float gLoc[3]={0,0,0};
2763 float vel[3]={0,0,0};
2764 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2765 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2766 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2767 FSOUND_SetVolume(channels[fireendsound], 256);
2768 FSOUND_SetPaused(channels[fireendsound], FALSE);
2769 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2780 if(Button()&&!oldbutton&&selected==4){
2783 float gLoc[3]={0,0,0};
2784 float vel[3]={0,0,0};
2785 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2786 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2787 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2788 FSOUND_SetVolume(channels[fireendsound], 256);
2789 FSOUND_SetPaused(channels[fireendsound], FALSE);
2790 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2800 if(Button()&&!oldbutton&&selected==5){
2802 float gLoc[3]={0,0,0};
2803 float vel[3]={0,0,0};
2804 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2805 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2806 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2807 FSOUND_SetVolume(channels[fireendsound], 256);
2808 FSOUND_SetPaused(channels[fireendsound], FALSE);
2809 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2819 if(Button())oldbutton=1;
2823 if(Button()&&!oldbutton&&selected!=-1){
2824 float gLoc[3]={0,0,0};
2825 float vel[3]={0,0,0};
2826 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2827 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2828 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2829 FSOUND_SetVolume(channels[firestartsound], 256);
2830 FSOUND_SetPaused(channels[firestartsound], FALSE);
2831 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2833 if(Button()&&!oldbutton&&selected==1){
2834 float gLoc[3]={0,0,0};
2835 float vel[3]={0,0,0};
2836 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2837 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2838 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2839 FSOUND_SetVolume(channels[fireendsound], 256);
2840 FSOUND_SetPaused(channels[fireendsound], FALSE);
2841 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2849 for(i=accountactive;i<numaccounts-1;i++){
2850 accountdifficulty[i]=accountdifficulty[i+1];
2851 accountcampaignchoicesmade[i]=accountcampaignchoicesmade[i+1];
2852 for(j=0;j<accountcampaignchoicesmade[i+1];j++){
2853 accountcampaignchoices[i][j]=accountcampaignchoices[i+1][j];
2855 accountpoints[i]=accountpoints[i+1];
2857 accounthighscore[i][j]=accounthighscore[i+1][j];
2858 accountfasttime[i][j]=accountfasttime[i+1][j];
2861 accountunlocked[i][j]=accountunlocked[i+1][j];
2864 accountname[i][j]=accountname[i+1][j];
2866 accountcampaignhighscore[i]=accountcampaignhighscore[i+1];
2867 accountprogress[i]=accountprogress[i+1];
2868 accountcampaignfasttime[i]=accountcampaignfasttime[i+1];
2869 accountcampaignscore[i]=accountcampaignscore[i+1];
2870 accountcampaigntime[i]=accountcampaigntime[i+1];
2879 if(Button()&&!oldbutton&&selected==2){
2880 float gLoc[3]={0,0,0};
2881 float vel[3]={0,0,0};
2882 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2883 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2884 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2885 FSOUND_SetVolume(channels[fireendsound], 256);
2886 FSOUND_SetPaused(channels[fireendsound], FALSE);
2887 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2897 if(Button())oldbutton=1;
2901 if(Button()&&!oldbutton&&selected!=-1){
2902 float gLoc[3]={0,0,0};
2903 float vel[3]={0,0,0};
2904 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2905 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2906 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2907 FSOUND_SetVolume(channels[firestartsound], 256);
2908 FSOUND_SetPaused(channels[firestartsound], FALSE);
2909 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2911 if(Button()&&!oldbutton&&selected==0&&numaccounts<8){
2914 if(Button()&&!oldbutton&&selected>0&&selected<numaccounts+1){
2915 accountactive=selected-1;
2923 if(Button()&&!oldbutton&&selected==numaccounts+1){
2924 float gLoc[3]={0,0,0};
2925 float vel[3]={0,0,0};
2926 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2927 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2928 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2929 FSOUND_SetVolume(channels[fireendsound], 256);
2930 FSOUND_SetPaused(channels[fireendsound], FALSE);
2931 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2942 displaytext[0][j]=' ';
2948 if(Button())oldbutton=1;
2952 if(Button()&&!oldbutton&&selected!=-1){
2953 float gLoc[3]={0,0,0};
2954 float vel[3]={0,0,0};
2955 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2956 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2957 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2958 FSOUND_SetVolume(channels[firestartsound], 256);
2959 FSOUND_SetPaused(channels[firestartsound], FALSE);
2960 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2962 if(selected==0)accountdifficulty[accountactive]=0;
2963 if(selected==1)accountdifficulty[accountactive]=1;
2964 if(selected==2)accountdifficulty[accountactive]=2;
2975 if(Button())oldbutton=1;
2980 if(Button())oldbutton=1;
2983 if(IsKeyDown(theKeyMap, MAC_Q_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)){
2986 if(newdetail>2)newdetail=detail;
2987 if(newdetail<0)newdetail=detail;
2988 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2989 if(newscreenwidth<0)newscreenwidth=screenwidth;
2990 if(newscreenheight>3000)newscreenheight=screenheight;
2991 if(newscreenheight<0)newscreenheight=screenheight;
2993 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
2994 opstream << "Screenwidth:\n";
2995 opstream << newscreenwidth;
2996 opstream << "\nScreenheight:\n";
2997 opstream << newscreenheight;
2998 opstream << "\nMouse sensitivity:\n";
2999 opstream << usermousesensitivity;
3000 opstream << "\nBlur(0,1):\n";
3001 opstream << ismotionblur;
3002 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
3003 opstream << newdetail;
3004 opstream << "\nFloating jump:\n";
3005 opstream << floatjump;
3006 opstream << "\nMouse jump:\n";
3007 opstream << mousejump;
3008 opstream << "\nAmbient sound:\n";
3009 opstream << ambientsound;
3010 opstream << "\nBlood (0,1,2):\n";
3011 opstream << bloodtoggle;
3012 opstream << "\nAuto slomo:\n";
3013 opstream << autoslomo;
3014 opstream << "\nFoliage:\n";
3015 opstream << foliage;
3016 opstream << "\nMusic:\n";
3017 opstream << musictoggle;
3018 opstream << "\nTrilinear:\n";
3019 opstream << trilinear;
3020 opstream << "\nDecals(shadows,blood puddles,etc):\n";
3022 opstream << "\nInvert mouse:\n";
3023 opstream << invertmouse;
3024 opstream << "\nGamespeed:\n";
3025 if(oldgamespeed==0)oldgamespeed=1;
3026 opstream << oldgamespeed;
3027 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
3028 opstream << difficulty;
3029 opstream << "\nDamage effects(blackout, doublevision):\n";
3030 opstream << damageeffects;
3031 opstream << "\nText:\n";
3032 opstream << texttoggle;
3033 opstream << "\nDebug:\n";
3034 opstream << debugmode;
3035 opstream << "\nVBL Sync:\n";
3036 opstream << vblsync;
3037 opstream << "\nShow Points:\n";
3038 opstream << showpoints;
3039 opstream << "\nAlways Blur:\n";
3040 opstream << alwaysblur;
3041 opstream << "\nImmediate mode (turn on on G5):\n";
3042 opstream << immediate;
3043 opstream << "\nVelocity blur:\n";
3044 opstream << velocityblur;
3045 opstream << "\nVolume:\n";
3047 opstream << "\nForward key:\n";
3048 opstream << KeyToChar(forwardkey);
3049 opstream << "\nBack key:\n";
3050 opstream << KeyToChar(backkey);
3051 opstream << "\nLeft key:\n";
3052 opstream << KeyToChar(leftkey);
3053 opstream << "\nRight key:\n";
3054 opstream << KeyToChar(rightkey);
3055 opstream << "\nJump key:\n";
3056 opstream << KeyToChar(jumpkey);
3057 opstream << "\nCrouch key:\n";
3058 opstream << KeyToChar(crouchkey);
3059 opstream << "\nDraw key:\n";
3060 opstream << KeyToChar(drawkey);
3061 opstream << "\nThrow key:\n";
3062 opstream << KeyToChar(throwkey);
3063 opstream << "\nAttack key:\n";
3064 opstream << KeyToChar(attackkey);
3065 opstream << "\nChat key:\n";
3066 opstream << KeyToChar(chatkey);
3071 if(mainmenu==1||mainmenu==2){
3072 if(loaddistrib>4)transition+=multiplier/8;
3080 FSOUND_SetFrequency(channels[stream_music3], 22050);
3082 if(entername||mainmenu==13||mainmenu==14){
3084 if(IsKeyDown(theKeyMap, i)){
3085 togglekeydelay[i]+=multiplier;
3086 if(togglekeydelay[i]>.4){
3088 togglekeydelay[i]=.36;
3091 if(KeyToSingleChar(i)!='\0'&&displaychars[0]<60){
3092 for(j=255;j>=displayselected+1;j--){
3093 displaytext[0][j]=displaytext[0][j-1];
3095 displaytext[0][displayselected]=KeyToSingleChar(i);
3096 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]);
3100 if(i==MAC_DELETE_KEY&&displayselected!=0){
3101 for(j=displayselected-1;j<255;j++){
3102 displaytext[0][j]=displaytext[0][j+1];
3104 displaytext[0][255]=' ';
3108 if(i==MAC_ARROW_LEFT_KEY&&displayselected!=0){
3111 if(i==MAC_ARROW_RIGHT_KEY&&displayselected<displaychars[0]){
3114 if(i==MAC_RETURN_KEY&&entername){
3115 if(displaychars[0]){
3117 strcpy(accountname[numaccounts-1],displaytext[0]);
3118 accountactive=numaccounts-1;
3119 accountdifficulty[accountactive]=1;
3120 accountprogress[accountactive]=0;
3121 accountpoints[accountactive]=0;
3122 accountcampaigntime[accountactive]=0;
3123 accountcampaignscore[accountactive]=0;
3124 accountcampaignfasttime[accountactive]=0;
3125 accountcampaignhighscore[accountactive]=0;
3127 accounthighscore[accountactive][j]=0;
3128 accountfasttime[accountactive][j]=0;
3131 accountunlocked[accountactive][j]=0;
3133 accountcampaignchoicesmade[accountactive]=0;
3136 displaytext[0][j]=' ';
3150 float gLoc[3]={0,0,0};
3151 float vel[3]={0,0,0};
3152 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3153 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
3154 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3155 FSOUND_SetVolume(channels[firestartsound], 256);
3156 FSOUND_SetPaused(channels[firestartsound], FALSE);
3157 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3160 displaytext[0][j]=' ';
3168 if(i==MAC_RETURN_KEY&&mainmenu==14){
3169 if(displaychars[0]){
3170 char serialstring[256];
3171 char tempstring[256];
3172 sprintf (tempstring, "%s-windows", registrationname);
3178 longnum = MD5_string ( tempstring);
3179 //longnum = 1111111111111111;
3180 num1 = longnum/100000000;
3181 num2 = longnum%100000000;
3182 sprintf (tempstring, "%d-%d-%d-%d\0\0\0\0\0", num1/10000, num1%10000, num2/10000, num2%10000);
3186 if(num1/10000>999)numchars+=4;
3187 else if(num1/10000>99)numchars+=3;
3188 else if(num1/10000>9)numchars+=2;
3190 if(num1%10000>999)numchars+=4;
3191 else if(num1%10000>99)numchars+=3;
3192 else if(num1%10000>9)numchars+=2;
3194 if(num2/10000>999)numchars+=4;
3195 else if(num2/10000>99)numchars+=3;
3196 else if(num2/10000>9)numchars+=2;
3198 if(num2%10000>999)numchars+=4;
3199 else if(num2%10000>99)numchars+=3;
3200 else if(num2%10000>9)numchars+=2;
3205 for(j=0;j<numchars;j++){
3206 if(displaytext[0][j]!=tempstring[j]&&tempstring[j]!=' '&&tempstring[j]!='\0')goodcode--;
3209 if(longnum==LONGLONGCONST(5077041556214789))goodcode=-1;
3211 if(goodcode<0)goodcode=0;
3218 tfile=fopen( ":Data:Sounds:flame.ogg", "wb" );
3222 numchars=strlen(registrationname);
3223 fpackf(tfile, "Bb", registered);
3224 fpackf(tfile, "Bi", numchars);
3227 for(j=0;j<numchars;j++)
3229 fpackf(tfile, "Bb", registrationname[j]);
3232 fpackf(tfile, "Bi", num1);
3233 fpackf(tfile, "Bi", num2);
3247 float gLoc[3]={0,0,0};
3248 float vel[3]={0,0,0};
3249 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3250 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
3251 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3252 FSOUND_SetVolume(channels[firestartsound], 256);
3253 FSOUND_SetPaused(channels[firestartsound], FALSE);
3254 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3257 displaytext[0][j]=' ';
3263 if(i==MAC_RETURN_KEY&&mainmenu==13){
3264 if(displaychars[0]){
3265 sprintf (registrationname, "%s", displaytext[0]);
3266 if(displaychars[0]<254)registrationname[displaychars[0]]='\0';
3276 float gLoc[3]={0,0,0};
3277 float vel[3]={0,0,0};
3278 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3279 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
3280 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3281 FSOUND_SetVolume(channels[firestartsound], 256);
3282 FSOUND_SetPaused(channels[firestartsound], FALSE);
3283 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3286 displaytext[0][j]=' ';
3290 /*char tempstring[50];
3291 sprintf (tempstring, registrationname);
3297 longnum = MD5_string ( tempstring);
3298 num1 = longnum/100000000;
3299 num2 = longnum%100000000;
3300 sprintf (displaytext[0], "%d-%d-%d-%d", num1/10000, num1%10000, num2/10000, num2%10000);
3302 displaychars[0]=strlen(displaytext[0]);
3311 togglekeydelay[i]=0;
3315 displayblinkdelay-=multiplier;
3316 if(displayblinkdelay<=0){
3317 displayblinkdelay=.3;
3318 displayblink=1-displayblink;
3324 if(hostile==1)hostiletime+=multiplier;
3326 if(!winfreeze)leveltime+=multiplier;
3327 if(IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)){
3334 if(IsKeyDown(theKeyMap, chatkey)&&!chattogglekeydown&&!console&&!chatting&&debugmode){
3336 chattogglekeydown=1;
3337 togglekey[chatkey]=1;
3338 togglekeydelay[chatkey]=-20;
3341 if(!IsKeyDown(theKeyMap, chatkey)){
3342 chattogglekeydown=0;
3347 if(IsKeyDown(theKeyMap, i)){
3348 togglekeydelay[i]+=multiplier;
3349 if(togglekeydelay[i]>.4){
3351 togglekeydelay[i]=.36;
3354 if(KeyToSingleChar(i)!='\0'&&displaychars[0]<60){
3355 for(j=255;j>=displayselected+1;j--){
3356 displaytext[0][j]=displaytext[0][j-1];
3358 displaytext[0][displayselected]=KeyToSingleChar(i);
3359 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]);
3363 if(i==MAC_DELETE_KEY&&displayselected!=0){
3364 for(j=displayselected-1;j<255;j++){
3365 displaytext[0][j]=displaytext[0][j+1];
3367 displaytext[0][255]=' ';
3371 if(i==MAC_ARROW_LEFT_KEY&&displayselected!=0){
3374 if(i==MAC_ARROW_RIGHT_KEY&&displayselected<displaychars[0]){
3377 if(i==MAC_RETURN_KEY){
3378 if(displaychars[0]){
3379 /*for(j=0;j<displaychars[0];j++){
3380 talkname[j]=displaytext[0][j];
3382 talkname[displaychars[0]]='\0';
3383 sprintf (chatname, "%s: %s",playerName,talkname);
3384 //NetworkSendInformation(chatname);
3387 displaytext[0][j]=' ';
3399 togglekeydelay[i]=0;
3403 displayblinkdelay-=multiplier;
3404 if(displayblinkdelay<=0){
3405 displayblinkdelay=.3;
3406 displayblink=1-displayblink;
3410 if(chatting)keyboardfrozen=1;
3412 if(IsKeyDown(theKeyMap, MAC_V_KEY)&&!freezetogglekeydown&&debugmode){
3415 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
3417 freezetogglekeydown=1;
3420 if(!IsKeyDown(theKeyMap, MAC_V_KEY)&&!IsKeyDown(theKeyMap, MAC_F1_KEY)){
3421 freezetogglekeydown=0;
3424 if(IsKeyDown(theKeyMap, MAC_TILDE_KEY)&&!consoletogglekeydown&&debugmode){
3426 if(!console)freeze=0;
3428 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
3430 consoletogglekeydown=1;
3433 if(!IsKeyDown(theKeyMap, MAC_TILDE_KEY)){
3434 consoletogglekeydown=0;
3437 if(console)freeze=1;
3439 if(console&&!IsKeyDown(theKeyMap,MAC_COMMAND_KEY)){
3441 if(IsKeyDown(theKeyMap, i)){
3442 togglekeydelay[i]+=multiplier;
3443 if(togglekeydelay[i]>.4){
3445 togglekeydelay[i]=.36;
3448 if(KeyToSingleChar(i)!='\0'&&consolechars[0]<255){
3449 for(j=255;j>=consoleselected+1;j--){
3450 consoletext[0][j]=consoletext[0][j-1];
3452 consoletext[0][consoleselected]=KeyToSingleChar(i);
3453 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))consoletext[0][consoleselected]=Shift(consoletext[0][consoleselected]);
3457 else if(i==MAC_ENTER_KEY){
3458 for(j=255;j>=consoleselected+1;j--){
3459 consoletext[0][j]=consoletext[0][j-1];
3461 consoletext[0][consoleselected]='\n';
3465 if(i==MAC_DELETE_KEY&&consoleselected!=0){
3466 for(j=consoleselected-1;j<255;j++){
3467 consoletext[0][j]=consoletext[0][j+1];
3469 consoletext[0][255]=' ';
3473 if(i==MAC_ARROW_UP_KEY){
3474 if(archiveselected<14)archiveselected++;
3476 consolechars[0]=consolechars[archiveselected];
3477 consoletext[0][j]=consoletext[archiveselected][j];
3478 consoleselected=consolechars[0];
3481 if(i==MAC_ARROW_DOWN_KEY){
3482 if(archiveselected>0)archiveselected--;
3484 consolechars[0]=consolechars[archiveselected];
3485 consoletext[0][j]=consoletext[archiveselected][j];
3486 consoleselected=consolechars[0];
3489 if(i==MAC_ARROW_LEFT_KEY&&consoleselected!=0){
3492 if(i==MAC_ARROW_RIGHT_KEY&&consoleselected<consolechars[0]){
3495 if(i==MAC_RETURN_KEY){
3498 if(Compare(consoletext[0],"quit ",0,4)||Compare(consoletext[0],"exit ",0,4)){
3499 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
3500 FSOUND_SetVolume(channels[consolesuccesssound], 256);
3501 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
3505 /*if(Compare(consoletext[0],"send ",0,4)){
3506 for(j=5;j<consolechars[0];j++){
3507 talkname[j-5]=consoletext[0][j];
3509 talkname[consolechars[0]-5]='\0';
3510 sprintf (chatname, "%s: %s",playerName,talkname);
3511 //NetworkSendInformation(chatname);
3514 if(Compare(consoletext[0],"name ",0,4)){
3516 numchars=consolechars[0]-5;
3517 if(numchars>32)numchars=32;
3518 for(j=5;j<numchars+5;j++){
3519 talkname[j-5]=consoletext[0][j];
3521 talkname[numchars]='\0';
3522 sprintf (chatname, "Player %s is now known as %s.",playerName,talkname);
3523 //NetworkSendInformation(chatname);
3524 sprintf (playerName, "%s",talkname);
3525 //NetworkSendName(playerName);
3528 if(Compare(consoletext[0],"map ",0,3)){
3540 for(j=4;j<consolechars[0];j++){
3541 mapname[j-4+11]=consoletext[0][j];
3543 mapname[consolechars[0]-4+11]='\0';
3549 /*if(Compare(consoletext[0],"connect ",0,7)&&!ishost){
3551 unsigned char playerNameStr[32];
3552 char theIPAddress[256];
3554 NMUInt32 port = 25710;
3556 strcpy(playerName, "Client");
3557 GameC2PStr( playerName, playerNameStr );
3559 for(j=0;j<consolechars[0]-8;j++){
3560 theIPAddress[j]=consoletext[0][j+8];
3562 theIPAddress[consolechars[0]-8]='\0';
3564 sprintf( thePort, "%li", port );
3565 v=NetworkStartClient( theIPAddress, thePort, playerNameStr );
3568 if(consolechars[0]>0){
3571 consoletext[k][j]=consoletext[k-1][j];
3573 consolechars[k]=consolechars[k-1];
3576 consoletext[0][j]=' ';
3578 if(v!=-4994)sprintf (consoletext[0], "Error #%d!!!",v);
3579 else sprintf (consoletext[0], "Could not open connection");
3581 consolechars[0]=255;
3588 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
3589 FSOUND_SetVolume(channels[consolesuccesssound], 256);
3590 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
3592 if(consolechars[0]>0){
3595 consoletext[k][j]=consoletext[k-1][j];
3597 consolechars[k]=consolechars[k-1];
3600 consoletext[0][j]=' ';
3602 sprintf (consoletext[0], "Connected to %s",theIPAddress);
3604 consolechars[0]=255;
3610 if(Compare(consoletext[0],"host ",0,4)){
3611 unsigned char gameNameStr[32], playerNameStr[32];
3612 char gameName[32];//, playerName[32];
3620 strcpy(gameName, "Host's game");
3621 strcpy(playerName, "Host");
3622 GameC2PStr( gameName, gameNameStr );
3623 GameC2PStr( playerName, playerNameStr );
3625 v=NetworkStartServer( (NMUInt16)port, players, gameNameStr, playerNameStr );
3628 if(consolechars[0]>0){
3631 consoletext[k][j]=consoletext[k-1][j];
3633 consolechars[k]=consolechars[k-1];
3636 consoletext[0][j]=' ';
3638 sprintf (consoletext[0], "Error #%d!!!",v);
3640 consolechars[0]=255;
3647 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
3648 FSOUND_SetVolume(channels[consolesuccesssound], 256);
3649 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
3651 if(consolechars[0]>0){
3654 consoletext[k][j]=consoletext[k-1][j];
3656 consolechars[k]=consolechars[k-1];
3659 consoletext[0][j]=' ';
3661 sprintf (consoletext[0], "Game hosted");
3663 consolechars[0]=255;
3669 if(Compare(consoletext[0],"save ",0,4)){
3681 for(j=5;j<consolechars[0];j++){
3682 mapname[j-5+11]=consoletext[0][j];
3684 mapname[consolechars[0]-5+11]='\0';
3686 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
3687 FSOUND_SetVolume(channels[consolesuccesssound], 256);
3688 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
3695 tfile=fopen( mapname, "wb" );
3696 fpackf(tfile, "Bi", mapvers);
3697 //fpackf(tfile, "Bi", indemo);
3698 fpackf(tfile, "Bi", maptype);
3699 fpackf(tfile, "Bi", hostile);
3700 fpackf(tfile, "Bf Bf", viewdistance, fadestart);
3701 fpackf(tfile, "Bb Bf Bf Bf", skyboxtexture, skyboxr, skyboxg, skyboxb);
3702 fpackf(tfile, "Bf Bf Bf", skyboxlightr, skyboxlightg, skyboxlightb);
3703 fpackf(tfile, "Bf Bf Bf Bf Bf Bi", player[0].coords.x, player[0].coords.y, player[0].coords.z, player[0].rotation, player[0].targetrotation, player[0].num_weapons);
3704 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3705 for(j=0;j<player[0].num_weapons;j++){
3706 fpackf(tfile, "Bi", weapons.type[player[0].weaponids[j]]);
3709 fpackf(tfile, "Bf Bf Bf", player[0].armorhead, player[0].armorhigh, player[0].armorlow);
3710 fpackf(tfile, "Bf Bf Bf", player[0].protectionhead, player[0].protectionhigh, player[0].protectionlow);
3711 fpackf(tfile, "Bf Bf Bf", player[0].metalhead, player[0].metalhigh, player[0].metallow);
3712 fpackf(tfile, "Bf Bf", player[0].power, player[0].speedmult);
3714 fpackf(tfile, "Bi", player[0].numclothes);
3716 fpackf(tfile, "Bi Bi", player[0].whichskin, player[0].creature);
3718 fpackf(tfile, "Bi", numdialogues);
3720 for(k=0;k<numdialogues;k++){
3721 fpackf(tfile, "Bi", numdialogueboxes[k]);
3722 fpackf(tfile, "Bi", dialoguetype[k]);
3724 fpackf(tfile, "Bf Bf Bf", participantlocation[k][l].x, participantlocation[k][l].y, participantlocation[k][l].z);
3725 fpackf(tfile, "Bf", participantrotation[k][l]);
3727 if(numdialogueboxes)
3728 for(l=0;l<numdialogueboxes[k];l++){
3729 fpackf(tfile, "Bi", dialogueboxlocation[k][l]);
3730 fpackf(tfile, "Bf", dialogueboxcolor[k][l][0]);
3731 fpackf(tfile, "Bf", dialogueboxcolor[k][l][1]);
3732 fpackf(tfile, "Bf", dialogueboxcolor[k][l][2]);
3733 fpackf(tfile, "Bi", dialogueboxsound[k][l]);
3735 templength=strlen(dialoguetext[k][l]);
3736 fpackf(tfile, "Bi",(templength));
3737 for(m=0;m<templength;m++){
3738 fpackf(tfile, "Bb", dialoguetext[k][l][m]);
3739 if(dialoguetext[k][l][m]=='\0')break;
3742 templength=strlen(dialoguename[k][l]);
3743 fpackf(tfile, "Bi",templength);
3744 for(m=0;m<templength;m++){
3745 fpackf(tfile, "Bb", dialoguename[k][l][m]);
3746 if(dialoguename[k][l][m]=='\0')break;
3749 fpackf(tfile, "Bf Bf Bf", dialoguecamera[k][l].x, dialoguecamera[k][l].y, dialoguecamera[k][l].z);
3750 fpackf(tfile, "Bi", participantfocus[k][l]);
3751 fpackf(tfile, "Bi", participantaction[k][l]);
3754 fpackf(tfile, "Bf Bf Bf", participantfacing[k][l][m].x, participantfacing[k][l][m].y, participantfacing[k][l][m].z);
3756 fpackf(tfile, "Bf Bf",dialoguecamerarotation[k][l],dialoguecamerarotation2[k][l]);
3760 if(player[0].numclothes)
3761 for(k=0;k<player[0].numclothes;k++){
3762 templength=strlen(player[0].clothes[k]);
3763 fpackf(tfile, "Bi", templength);
3764 for(l=0;l<templength;l++)
3765 fpackf(tfile, "Bb", player[0].clothes[k][l]);
3766 fpackf(tfile, "Bf Bf Bf", player[0].clothestintr[k], player[0].clothestintg[k], player[0].clothestintb[k]);
3769 fpackf(tfile, "Bi", environment);
3771 fpackf(tfile, "Bi", objects.numobjects);
3773 if(objects.numobjects)
3774 for(k=0;k<objects.numobjects;k++){
3775 fpackf(tfile, "Bi Bf Bf Bf Bf Bf Bf", objects.type[k], objects.rotation[k], objects.rotation2[k], objects.position[k].x, objects.position[k].y, objects.position[k].z, objects.scale[k]);
3778 fpackf(tfile, "Bi", numhotspots);
3780 for(i=0;i<numhotspots;i++){
3781 fpackf(tfile, "Bi Bf Bf Bf Bf", hotspottype[i],hotspotsize[i],hotspot[i].x,hotspot[i].y,hotspot[i].z);
3782 templength=strlen(hotspottext[i]);
3783 fpackf(tfile, "Bi",templength);
3784 for(l=0;l<templength;l++)
3785 fpackf(tfile, "Bb", hotspottext[i][l]);
3788 fpackf(tfile, "Bi", numplayers);
3789 if(numplayers>1&&numplayers<maxplayers)
3790 for(j=1;j<numplayers;j++){
3791 fpackf(tfile, "Bi Bi Bf Bf Bf Bi Bi Bf Bb Bf", player[j].whichskin, player[j].creature, player[j].coords.x, player[j].coords.y, player[j].coords.z, player[j].num_weapons, player[j].howactive, player[j].scale, player[j].immobile, player[j].rotation);
3792 if(player[j].num_weapons>0&&player[j].num_weapons<5)
3793 for(k=0;k<player[j].num_weapons;k++){
3794 fpackf(tfile, "Bi", weapons.type[player[j].weaponids[k]]);
3796 if(player[j].numwaypoints<30){
3797 fpackf(tfile, "Bi", player[j].numwaypoints);
3798 for(k=0;k<player[j].numwaypoints;k++){
3799 fpackf(tfile, "Bf", player[j].waypoints[k].x);
3800 fpackf(tfile, "Bf", player[j].waypoints[k].y);
3801 fpackf(tfile, "Bf", player[j].waypoints[k].z);
3802 fpackf(tfile, "Bi", player[j].waypointtype[k]);
3804 fpackf(tfile, "Bi", player[j].waypoint);
3807 player[j].numwaypoints=0;
3808 player[j].waypoint=0;
3809 fpackf(tfile, "Bi Bi Bi", player[j].numwaypoints, player[j].waypoint, player[j].waypoint);
3812 fpackf(tfile, "Bf Bf Bf", player[j].armorhead, player[j].armorhigh, player[j].armorlow);
3813 fpackf(tfile, "Bf Bf Bf", player[j].protectionhead, player[j].protectionhigh, player[j].protectionlow);
3814 fpackf(tfile, "Bf Bf Bf", player[j].metalhead, player[j].metalhigh, player[j].metallow);
3815 fpackf(tfile, "Bf Bf", player[j].power, player[j].speedmult);
3817 if(player[j].creature==wolftype){
3818 headprop=player[j].proportionhead.x/1.1;
3819 bodyprop=player[j].proportionbody.x/1.1;
3820 armprop=player[j].proportionarms.x/1.1;
3821 legprop=player[j].proportionlegs.x/1.1;
3824 if(player[j].creature==rabbittype){
3825 headprop=player[j].proportionhead.x/1.2;
3826 bodyprop=player[j].proportionbody.x/1.05;
3827 armprop=player[j].proportionarms.x/1.00;
3828 legprop=player[j].proportionlegs.x/1.1;
3831 fpackf(tfile, "Bf Bf Bf Bf", headprop, bodyprop, armprop, legprop);
3835 fpackf(tfile, "Bi", player[j].numclothes);
3836 if(player[j].numclothes)
3837 for(k=0;k<player[j].numclothes;k++){
3839 templength=strlen(player[j].clothes[k]);
3840 fpackf(tfile, "Bi", templength);
3841 for(l=0;l<templength;l++)
3842 fpackf(tfile, "Bb", player[j].clothes[k][l]);
3843 fpackf(tfile, "Bf Bf Bf", player[j].clothestintr[k], player[j].clothestintg[k], player[j].clothestintb[k]);
3847 fpackf(tfile, "Bi", numpathpoints);
3849 for(j=0;j<numpathpoints;j++){
3850 fpackf(tfile, "Bf Bf Bf Bi", pathpoint[j].x, pathpoint[j].y, pathpoint[j].z, numpathpointconnect[j]);
3851 for(k=0;k<numpathpointconnect[j];k++){
3852 fpackf(tfile, "Bi", pathpointconnect[j][k]);
3856 fpackf(tfile, "Bf Bf Bf Bf", mapcenter.x, mapcenter.y, mapcenter.z, mapradius);
3864 tfile=fopen( mapname, "wb" );
3865 fwrite( &mapvers, 1, sizeof(int), tfile );
3866 fwrite( &player[0].coords.x, 1, sizeof(float), tfile );
3867 fwrite( &player[0].coords.y, 1, sizeof(float), tfile );
3868 fwrite( &player[0].coords.z, 1, sizeof(float), tfile );
3869 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
3870 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
3871 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
3872 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3873 for(j=0;j<player[0].num_weapons;j++){
3874 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
3877 fwrite( &player[0].armorhead, 1, sizeof(int), tfile );
3878 fwrite( &player[0].armorhigh, 1, sizeof(int), tfile );
3879 fwrite( &player[0].armorlow, 1, sizeof(int), tfile );
3880 fwrite( &player[0].protectionhead, 1, sizeof(int), tfile );
3881 fwrite( &player[0].protectionhigh, 1, sizeof(int), tfile );
3882 fwrite( &player[0].protectionlow, 1, sizeof(int), tfile );
3883 fwrite( &player[0].metalhead, 1, sizeof(int), tfile );
3884 fwrite( &player[0].metalhigh, 1, sizeof(int), tfile );
3885 fwrite( &player[0].metallow, 1, sizeof(int), tfile );
3886 fwrite( &player[0].power, 1, sizeof(int), tfile );
3887 fwrite( &player[0].speedmult, 1, sizeof(int), tfile );
3889 fwrite( &player[0].numclothes, 1, sizeof(int), tfile );
3890 if(player[0].numclothes)
3891 for(k=0;k<player[0].numclothes;k++){
3893 templength=strlen(player[0].clothes[k]);
3894 fwrite( &templength,1,sizeof(int),tfile);
3895 for(l=0;l<templength;l++)
3896 fwrite( &player[0].clothes[k][l],1,sizeof(char),tfile);
3897 fwrite( &player[0].clothestintr[k],1,sizeof(float),tfile);
3898 fwrite( &player[0].clothestintg[k],1,sizeof(float),tfile);
3899 fwrite( &player[0].clothestintb[k],1,sizeof(float),tfile);
3902 fwrite( &environment, 1, sizeof(int), tfile );
3904 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
3906 for(k=0;k<objects.numobjects;k++){
3907 fwrite( &objects.type[k], 1, sizeof(int), tfile );
3908 fwrite( &objects.rotation[k], 1, sizeof(float), tfile );
3909 fwrite( &objects.rotation2[k], 1, sizeof(float), tfile );
3910 fwrite( &objects.position[k].x, 1, sizeof(float), tfile );
3911 fwrite( &objects.position[k].y, 1, sizeof(float), tfile );
3912 fwrite( &objects.position[k].z, 1, sizeof(float), tfile );
3913 fwrite( &objects.scale[k], 1, sizeof(float), tfile );
3916 fwrite( &numplayers, 1, sizeof(int), tfile );
3917 if(numplayers>1&&numplayers<maxplayers)
3918 for(j=1;j<numplayers;j++){
3919 fwrite( &player[j].whichskin, 1, sizeof(int), tfile );
3920 fwrite( &player[j].creature, 1, sizeof(int), tfile );
3921 fwrite( &player[j].coords.x, 1, sizeof(float), tfile );
3922 fwrite( &player[j].coords.y, 1, sizeof(float), tfile );
3923 fwrite( &player[j].coords.z, 1, sizeof(float), tfile );
3924 fwrite( &player[j].num_weapons, 1, sizeof(int), tfile );
3925 if(player[j].num_weapons>0&&player[j].num_weapons<5)
3926 for(k=0;k<player[j].num_weapons;k++){
3927 fwrite( &weapons.type[player[j].weaponids[k]], 1, sizeof(int), tfile );
3929 if(player[j].numwaypoints<30){
3930 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
3931 for(k=0;k<player[j].numwaypoints;k++){
3932 fwrite( &player[j].waypoints[k].x, 1, sizeof(float), tfile );
3933 fwrite( &player[j].waypoints[k].y, 1, sizeof(float), tfile );
3934 fwrite( &player[j].waypoints[k].z, 1, sizeof(float), tfile );
3936 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3937 //fwrite( &player[j].jumppath, 1, sizeof(bool), tfile );
3940 player[j].numwaypoints=0;
3941 player[j].waypoint=0;
3942 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
3943 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3944 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3946 fwrite( &player[j].armorhead, 1, sizeof(int), tfile );
3947 fwrite( &player[j].armorhigh, 1, sizeof(int), tfile );
3948 fwrite( &player[j].armorlow, 1, sizeof(int), tfile );
3949 fwrite( &player[j].protectionhead, 1, sizeof(int), tfile );
3950 fwrite( &player[j].protectionhigh, 1, sizeof(int), tfile );
3951 fwrite( &player[j].protectionlow, 1, sizeof(int), tfile );
3952 fwrite( &player[j].metalhead, 1, sizeof(int), tfile );
3953 fwrite( &player[j].metalhigh, 1, sizeof(int), tfile );
3954 fwrite( &player[j].metallow, 1, sizeof(int), tfile );
3955 fwrite( &player[j].power, 1, sizeof(int), tfile );
3956 fwrite( &player[j].speedmult, 1, sizeof(int), tfile );
3958 fwrite( &player[j].numclothes, 1, sizeof(int), tfile );
3959 if(player[j].numclothes)
3960 for(k=0;k<player[j].numclothes;k++){
3962 templength=strlen(player[j].clothes[k]);
3963 fwrite( &templength,1,sizeof(int),tfile);
3964 for(l=0;l<templength;l++)
3965 fwrite( &player[j].clothes[k][l],1,sizeof(char),tfile);
3966 fwrite( &player[j].clothestintr[k],1,sizeof(float),tfile);
3967 fwrite( &player[j].clothestintg[k],1,sizeof(float),tfile);
3968 fwrite( &player[j].clothestintb[k],1,sizeof(float),tfile);
3971 fwrite( &numpathpoints, 1, sizeof(int), tfile );
3973 for(j=0;j<numpathpoints;j++){
3974 fwrite( &pathpoint[j].x, 1, sizeof(float), tfile );
3975 fwrite( &pathpoint[j].y, 1, sizeof(float), tfile );
3976 fwrite( &pathpoint[j].z, 1, sizeof(float), tfile );
3977 fwrite( &numpathpointconnect[j], 1, sizeof(int), tfile );
3978 for(k=0;k<numpathpointconnect[j];k++){
3979 fwrite( &pathpointconnect[j][k], 1, sizeof(int), tfile );
3983 fwrite( &mapcenter.x, 1, sizeof(float), tfile );
3984 fwrite( &mapcenter.y, 1, sizeof(float), tfile );
3985 fwrite( &mapcenter.z, 1, sizeof(float), tfile );
3987 fwrite( &mapradius, 1, sizeof(float), tfile );
3993 if(Compare(consoletext[0],"save ",0,4)){
4005 for(j=5;j<consolechars[0];j++){
4006 mapname[j-5+11]=consoletext[0][j];
4008 mapname[consolechars[0]-5+11]='\0';
4010 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
4011 FSOUND_SetVolume(channels[consolesuccesssound], 256);
4012 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
4015 tfile=fopen( mapname, "wb" );
4016 fwrite( &player[0].coords, 1, sizeof(XYZ), tfile );
4017 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
4018 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
4019 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
4020 if(player[0].num_weapons>0&&player[0].num_weapons<5)
4021 for(j=0;j<player[0].num_weapons;j++){
4022 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
4024 fwrite( &environment, 1, sizeof(int), tfile );
4026 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
4027 fwrite( &objects.type, 1, sizeof(int)*objects.numobjects, tfile );
4028 fwrite( &objects.rotation, 1, sizeof(float)*objects.numobjects, tfile );
4029 fwrite( &objects.position, 1, sizeof(XYZ)*objects.numobjects, tfile );
4030 fwrite( &objects.scale, 1, sizeof(float)*objects.numobjects, tfile );
4032 fwrite( &numplayers, 1, sizeof(int), tfile );
4033 if(numplayers>1&&numplayers<maxplayers)
4034 for(j=1;j<numplayers;j++){
4035 fwrite( &player[j].coords, 1, sizeof(XYZ), tfile );
4036 fwrite( &player[j].num_weapons, 1, sizeof(int), tfile );
4037 if(player[j].num_weapons>0&&player[j].num_weapons<5)
4038 for(k=0;k<player[j].num_weapons;k++){
4039 fwrite( &weapons.type[player[j].weaponids[k]], 1, sizeof(int), tfile );
4041 if(player[j].numwaypoints<30){
4042 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
4043 fwrite( &player[j].waypoints, 1, sizeof(XYZ)*player[j].numwaypoints, tfile );
4044 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4045 //fwrite( &player[j].jumppath, 1, sizeof(bool), tfile );
4048 player[j].numwaypoints=0;
4049 player[j].waypoint=0;
4050 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
4051 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4052 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4055 fwrite( &numpathpoints, 1, sizeof(int), tfile );
4057 for(j=0;j<numpathpoints;j++){
4058 fwrite( &pathpoint[j], 1, sizeof(XYZ), tfile );
4059 fwrite( &numpathpointconnect[j], 1, sizeof(int), tfile );
4060 for(k=0;k<numpathpointconnect[j];k++){
4061 fwrite( &pathpointconnect[j][k], 1, sizeof(int), tfile );
4067 if(Compare(consoletext[0],"cellar door ",0,11)||Compare(consoletext[0],"cellardoor ",0,10)){
4068 LoadTextureSave(":Data:Textures:Furdarko.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4071 /*if(Compare(consoletext[0],"Pants ",0,5)){
4072 AddClothes(":Data:Textures:Pants.png",0,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
4073 player[i].DoMipmaps(5,0,0,player[i].skeleton.skinsize,player[i].skeleton.skinsize);
4077 if(Compare(consoletext[0],"tintr ",0,5)||Compare(consoletext[0],"Tintr ",0,5)){
4078 for(j=6;j<consolechars[0];j++){
4079 mapname[j-6]=consoletext[0][j];
4082 tintr=atof(mapname);
4087 if(Compare(consoletext[0],"speed ",0,5)||Compare(consoletext[0],"Speed ",0,5)){
4088 for(j=6;j<consolechars[0];j++){
4089 mapname[j-6]=consoletext[0][j];
4092 player[0].speedmult=atof(mapname);
4097 if(Compare(consoletext[0],"strength ",0,8)||Compare(consoletext[0],"Strength ",0,8)){
4098 for(j=9;j<consolechars[0];j++){
4099 mapname[j-9]=consoletext[0][j];
4102 player[0].power=atof(mapname);
4107 if(Compare(consoletext[0],"viewdistance ",0,12)||Compare(consoletext[0],"Viewdistance ",0,12)){
4108 for(j=13;j<consolechars[0];j++){
4109 mapname[j-13]=consoletext[0][j];
4112 viewdistance=atof(mapname)*100;
4117 if(Compare(consoletext[0],"fadestart ",0,9)||Compare(consoletext[0],"Fadestart ",0,9)){
4118 for(j=10;j<consolechars[0];j++){
4119 mapname[j-10]=consoletext[0][j];
4122 fadestart=atof(mapname);
4127 if(Compare(consoletext[0],"power ",0,5)||Compare(consoletext[0],"Power ",0,5)){
4128 for(j=6;j<consolechars[0];j++){
4129 mapname[j-6]=consoletext[0][j];
4132 player[0].power=atof(mapname);
4137 if(Compare(consoletext[0],"slomo ",0,5)||Compare(consoletext[0],"Slomo ",0,5)){
4138 for(j=6;j<consolechars[0];j++){
4139 mapname[j-6]=consoletext[0][j];
4142 slomospeed=atof(mapname);
4149 if(Compare(consoletext[0],"slofreq ",0,7)||Compare(consoletext[0],"Slofreq ",0,7)){
4150 for(j=8;j<consolechars[0];j++){
4151 mapname[j-8]=consoletext[0][j];
4154 slomofreq=atoi(mapname);
4159 if(Compare(consoletext[0],"size ",0,4)||Compare(consoletext[0],"Size ",0,4)){
4160 for(j=5;j<consolechars[0];j++){
4161 mapname[j-5]=consoletext[0][j];
4164 player[0].scale=atof(mapname)*.2;
4169 if(Compare(consoletext[0],"sizenear ",0,8)||Compare(consoletext[0],"Sizenear ",0,8)){
4171 float closestdist=-1;
4174 for(i=1;i<numplayers;i++){
4175 distance=findDistancefast(&player[i].coords,&player[0].coords);
4176 if(closestdist==-1||distance<closestdist){
4177 closestdist=distance;
4182 for(j=9;j<consolechars[0];j++){
4183 mapname[j-9]=consoletext[0][j];
4186 player[closest].scale=atof(mapname)*.2;
4191 if(Compare(consoletext[0],"proportionnear ",0,14)||Compare(consoletext[0],"Proportionnear ",0,14)){
4196 float closestdist=-1;
4199 for(i=1;i<numplayers;i++){
4200 distance=findDistancefast(&player[i].coords,&player[0].coords);
4201 if(closestdist==-1||distance<closestdist){
4202 closestdist=distance;
4210 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4211 mapname[j-startpoint]=consoletext[0][j];
4213 if(consoletext[0][j]=='\0')alldone=1;
4215 mapname[j-startpoint]='\0';
4217 headprop=atof(mapname);
4221 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4222 mapname[j-startpoint]=consoletext[0][j];
4224 if(consoletext[0][j]=='\0')alldone=1;
4226 mapname[j-startpoint]='\0';
4228 bodyprop=atof(mapname);
4232 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4233 mapname[j-startpoint]=consoletext[0][j];
4235 if(consoletext[0][j]=='\0')alldone=1;
4237 mapname[j-startpoint]='\0';
4239 armprop=atof(mapname);
4243 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4244 mapname[j-startpoint]=consoletext[0][j];
4246 if(consoletext[0][j]=='\0')alldone=1;
4248 mapname[j-startpoint]='\0';
4250 legprop=atof(mapname);
4252 if(player[closest].creature==wolftype){
4253 player[closest].proportionhead=1.1*headprop;
4254 player[closest].proportionbody=1.1*bodyprop;
4255 player[closest].proportionarms=1.1*armprop;
4256 player[closest].proportionlegs=1.1*legprop;
4259 if(player[closest].creature==rabbittype){
4260 player[closest].proportionhead=1.2*headprop;
4261 player[closest].proportionbody=1.05*bodyprop;
4262 player[closest].proportionarms=1.00*armprop;
4263 player[closest].proportionlegs=1.1*legprop;
4264 player[closest].proportionlegs.y=1.05*legprop;
4271 if(Compare(consoletext[0],"sizemin ",0,7)||Compare(consoletext[0],"Sizemin ",0,7)){
4272 for(i=1;i<numplayers;i++){
4273 if(player[i].scale<0.8*0.2)player[i].scale=0.8*0.2;
4279 if(Compare(consoletext[0],"tutorial ",0,8)||Compare(consoletext[0],"Tutorial ",0,8)){
4280 for(j=9;j<consolechars[0];j++){
4281 mapname[j-9]=consoletext[0][j];
4284 tutoriallevel=atoi(mapname);
4290 if(Compare(consoletext[0],"tintg ",0,5)||Compare(consoletext[0],"Tintg ",0,5)){
4291 for(j=6;j<consolechars[0];j++){
4292 mapname[j-6]=consoletext[0][j];
4295 tintg=atof(mapname);
4300 if(Compare(consoletext[0],"tintb ",0,5)||Compare(consoletext[0],"Tintb ",0,5)){
4301 for(j=6;j<consolechars[0];j++){
4302 mapname[j-6]=consoletext[0][j];
4305 tintb=atof(mapname);
4310 if(Compare(consoletext[0],"hostile ",0,7)){
4311 for(j=8;j<consolechars[0];j++){
4312 mapname[j-8]=consoletext[0][j];
4315 hostile=atoi(mapname);
4321 if(Compare(consoletext[0],"type active ",0,11)){
4322 editoractive=typeactive;
4327 if(Compare(consoletext[0],"indemo ",0,6)){
4329 hotspot[numhotspots]=player[0].coords;
4330 hotspotsize[numhotspots]=0;
4331 hotspottype[numhotspots]=-111;
4333 strcpy(hotspottext[numhotspots],"mapname");
4339 if(Compare(consoletext[0],"notindemo ",0,9)){
4346 if(Compare(consoletext[0],"type sitting ",0,12)){
4347 editoractive=typesitting;
4352 if(Compare(consoletext[0],"type sitting wall ",0,17)){
4353 editoractive=typesittingwall;
4358 if(Compare(consoletext[0],"type sleeping ",0,13)){
4359 editoractive=typesleeping;
4363 if(Compare(consoletext[0],"type dead1 ",0,10)){
4364 editoractive=typedead1;
4368 if(Compare(consoletext[0],"type dead2 ",0,10)){
4369 editoractive=typedead2;
4373 if(Compare(consoletext[0],"type dead3 ",0,10)){
4374 editoractive=typedead3;
4377 if(Compare(consoletext[0],"type dead4 ",0,10)){
4378 editoractive=typedead4;
4383 if(Compare(consoletext[0],"path keepwalking ",0,16)){
4384 editorpathtype=wpkeepwalking;
4389 if(Compare(consoletext[0],"path pause ",0,10)){
4390 editorpathtype=wppause;
4395 if(Compare(consoletext[0],"mapkilleveryone ",0,15)){
4396 maptype=mapkilleveryone;
4401 if(Compare(consoletext[0],"mapgosomewhere ",0,14)){
4402 maptype=mapgosomewhere;
4407 if(Compare(consoletext[0],"mapkillsomeone ",0,14)){
4408 maptype=mapkillsomeone;
4414 if(Compare(consoletext[0],"mapkillmost ",0,11)){
4415 maptype=mapkillmost;
4421 if(Compare(consoletext[0],"hs ",0,2)){
4425 hotspot[numhotspots]=player[0].coords;
4430 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4431 mapname[j-startpoint]=consoletext[0][j];
4433 if(consoletext[0][j]=='\0')alldone=1;
4435 mapname[j-startpoint]='\0';
4437 hotspotsize[numhotspots]=atof(mapname);
4441 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4442 mapname[j-startpoint]=consoletext[0][j];
4444 if(consoletext[0][j]=='\0')alldone=1;
4446 mapname[j-startpoint]='\0';
4448 hotspottype[numhotspots]=atoi(mapname);
4452 while(consoletext[0][j]!='\0'&&!alldone&&j<255){
4453 mapname[j-startpoint]=consoletext[0][j];
4455 if(consoletext[0][j]=='\0')alldone=1;
4457 mapname[j-startpoint]='\n';
4458 mapname[j-startpoint+1]='\0';
4460 strcpy(hotspottext[numhotspots],mapname);
4467 if(Compare(consoletext[0],"dialogue ",0,8)){
4474 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4475 mapname[j-startpoint]=consoletext[0][j];
4477 if(consoletext[0][j]=='\0')alldone=1;
4479 mapname[j-startpoint]='\0';
4482 dialoguetype[numdialogues]=atoi(mapname);
4500 for(j=startpoint;j<consolechars[0];j++){
4501 mapname[j-startpoint+16]=consoletext[0][j];
4503 mapname[consolechars[0]-startpoint+16]='.';
4504 mapname[consolechars[0]-startpoint+17]='t';
4505 mapname[consolechars[0]-startpoint+18]='x';
4506 mapname[consolechars[0]-startpoint+19]='t';
4507 mapname[consolechars[0]-startpoint+20]='\0';
4509 for(j=0;j<max_dialoguelength;j++){
4511 dialoguetext[numdialogues][j][k]='\0';
4514 dialoguename[numdialogues][j][k]='\0';
4518 ifstream ipstream(ConvertFileName(mapname));
4519 ipstream.ignore(256,':');
4520 ipstream >> numdialogueboxes[numdialogues];
4521 for(i=0;i<numdialogueboxes[numdialogues];i++){
4522 ipstream.ignore(256,':');
4523 ipstream.ignore(256,':');
4524 ipstream.ignore(256,' ');
4525 ipstream >> dialogueboxlocation[numdialogues][i];
4526 ipstream.ignore(256,':');
4527 ipstream >> dialogueboxcolor[numdialogues][i][0];
4528 ipstream >> dialogueboxcolor[numdialogues][i][1];
4529 ipstream >> dialogueboxcolor[numdialogues][i][2];
4530 ipstream.ignore(256,':');
4531 ipstream.getline(dialoguename[numdialogues][i],64);
4532 ipstream.ignore(256,':');
4533 ipstream.ignore(256,' ');
4534 ipstream.getline(dialoguetext[numdialogues][i],128);
4536 if(dialoguetext[numdialogues][i][j]=='\\')dialoguetext[numdialogues][i][j]='\n';
4538 ipstream.ignore(256,':');
4539 ipstream >> dialogueboxsound[numdialogues][i];
4542 for(i=0;i<numdialogueboxes[numdialogues];i++){
4543 for(j=0;j<numplayers;j++){
4544 participantfacing[numdialogues][i][j]=player[j].facing;
4551 whichdialogue=numdialogues;
4559 if(Compare(consoletext[0],"fixdialogue ",0,11)){
4567 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4568 mapname[j-startpoint]=consoletext[0][j];
4570 if(consoletext[0][j]=='\0')alldone=1;
4572 mapname[j-startpoint]='\0';
4575 whichdi=atoi(mapname);
4593 for(j=startpoint;j<consolechars[0];j++){
4594 mapname[j-startpoint+16]=consoletext[0][j];
4596 mapname[consolechars[0]-startpoint+16]='.';
4597 mapname[consolechars[0]-startpoint+17]='t';
4598 mapname[consolechars[0]-startpoint+18]='x';
4599 mapname[consolechars[0]-startpoint+19]='t';
4600 mapname[consolechars[0]-startpoint+20]='\0';
4602 for(j=0;j<max_dialoguelength;j++){
4604 dialoguetext[whichdi][j][k]='\0';
4607 dialoguename[whichdi][j][k]='\0';
4611 ifstream ipstream(ConvertFileName(mapname));
4612 ipstream.ignore(256,':');
4613 ipstream >> numdialogueboxes[whichdi];
4614 for(i=0;i<numdialogueboxes[whichdi];i++){
4615 ipstream.ignore(256,':');
4616 ipstream.ignore(256,':');
4617 ipstream.ignore(256,' ');
4618 ipstream >> dialogueboxlocation[whichdi][i];
4619 ipstream.ignore(256,':');
4620 ipstream >> dialogueboxcolor[whichdi][i][0];
4621 ipstream >> dialogueboxcolor[whichdi][i][1];
4622 ipstream >> dialogueboxcolor[whichdi][i][2];
4623 ipstream.ignore(256,':');
4624 ipstream.getline(dialoguename[whichdi][i],64);
4625 ipstream.ignore(256,':');
4626 ipstream.ignore(256,' ');
4627 ipstream.getline(dialoguetext[whichdi][i],128);
4629 if(dialoguetext[whichdi][i][j]=='\\')dialoguetext[whichdi][i][j]='\n';
4631 ipstream.ignore(256,':');
4632 ipstream >> dialogueboxsound[whichdi][i];
4640 if(Compare(consoletext[0],"fixtype ",0,7)){
4648 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4649 mapname[j-startpoint]=consoletext[0][j];
4651 if(consoletext[0][j]=='\0')alldone=1;
4653 mapname[j-startpoint]='\0';
4654 dialoguetype[0]=atoi(mapname);
4662 if(Compare(consoletext[0],"fixrotation ",0,11)){
4663 participantrotation[whichdialogue][participantfocus[whichdialogue][indialogue]]=player[participantfocus[whichdialogue][indialogue]].rotation;
4668 if(Compare(consoletext[0],"ddialogue ",0,9)){
4670 if(numdialogues<0)numdialogues=0;
4675 if(Compare(consoletext[0],"immobile ",0,8)){
4676 player[0].immobile=1;
4680 if(Compare(consoletext[0],"mobile ",0,6)){
4681 player[0].immobile=0;
4685 if(Compare(consoletext[0],"play ",0,4)){
4692 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4693 mapname[j-startpoint]=consoletext[0][j];
4695 if(consoletext[0][j]=='\0')alldone=1;
4697 mapname[j-startpoint]='\0';
4700 whichdialogue=atoi(mapname);
4702 if(numdialogues>whichdialogue){
4703 for(i=0;i<numdialogueboxes[whichdialogue];i++){
4704 player[participantfocus[whichdialogue][i]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][i]];
4705 player[participantfocus[whichdialogue][i]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
4706 player[participantfocus[whichdialogue][i]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
4707 player[participantfocus[whichdialogue][i]].velocity=0;
4708 player[participantfocus[whichdialogue][i]].targetanimation=player[participantfocus[whichdialogue][i]].getIdle();
4709 player[participantfocus[whichdialogue][i]].targetframe=0;
4717 //if(dialogueboxsound[whichdialogue][indialogue]!=0){
4721 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
4722 temppos=temppos-viewer;
4723 Normalise(&temppos);
4733 whichsoundplay=rabbitchitter;
4734 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
4735 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
4736 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
4737 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
4738 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
4739 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
4740 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
4741 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
4742 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
4743 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
4744 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
4745 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
4746 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
4747 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
4748 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
4749 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
4750 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
4751 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
4752 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
4753 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, TRUE);
4754 FSOUND_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
4755 FSOUND_SetVolume(channels[whichsoundplay], 256);
4756 FSOUND_SetPaused(channels[whichsoundplay], FALSE);
4764 if(Compare(consoletext[0],"dhs ",0,3)){
4766 if(numhotspots<0)numhotspots=0;
4771 if(Compare(consoletext[0],"proportion ",0,10)||Compare(consoletext[0],"Proportion ",0,4)){
4778 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4779 mapname[j-startpoint]=consoletext[0][j];
4781 if(consoletext[0][j]=='\0')alldone=1;
4783 mapname[j-startpoint]='\0';
4785 headprop=atof(mapname);
4789 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4790 mapname[j-startpoint]=consoletext[0][j];
4792 if(consoletext[0][j]=='\0')alldone=1;
4794 mapname[j-startpoint]='\0';
4796 bodyprop=atof(mapname);
4800 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4801 mapname[j-startpoint]=consoletext[0][j];
4803 if(consoletext[0][j]=='\0')alldone=1;
4805 mapname[j-startpoint]='\0';
4807 armprop=atof(mapname);
4811 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4812 mapname[j-startpoint]=consoletext[0][j];
4814 if(consoletext[0][j]=='\0')alldone=1;
4816 mapname[j-startpoint]='\0';
4818 legprop=atof(mapname);
4820 if(player[0].creature==wolftype){
4821 player[0].proportionhead=1.1*headprop;
4822 player[0].proportionbody=1.1*bodyprop;
4823 player[0].proportionarms=1.1*armprop;
4824 player[0].proportionlegs=1.1*legprop;
4827 if(player[0].creature==rabbittype){
4828 player[0].proportionhead=1.2*headprop;
4829 player[0].proportionbody=1.05*bodyprop;
4830 player[0].proportionarms=1.00*armprop;
4831 player[0].proportionlegs=1.1*legprop;
4832 player[0].proportionlegs.y=1.05*legprop;
4838 if(Compare(consoletext[0],"allimmobile ",0,11)||Compare(consoletext[0],"Allimmobile ",0,11)){
4839 for(i=0;i<numplayers;i++){
4840 if(i>0)player[i].immobile=1;
4846 if(Compare(consoletext[0],"default ",0,7)||Compare(consoletext[0],"Default ",0,7)){
4847 player[0].armorhead=1;
4848 player[0].armorhigh=1;
4849 player[0].armorlow=1;
4850 player[0].protectionhead=1;
4851 player[0].protectionhigh=1;
4852 player[0].protectionlow=1;
4853 player[0].metalhead=1;
4854 player[0].metalhigh=1;
4855 player[0].metallow=1;
4857 player[0].speedmult=1;
4860 if(player[0].creature==wolftype){
4861 player[0].proportionhead=1.1;
4862 player[0].proportionbody=1.1;
4863 player[0].proportionarms=1.1;
4864 player[0].proportionlegs=1.1;
4867 if(player[0].creature==rabbittype){
4868 player[0].proportionhead=1.2;
4869 player[0].proportionbody=1.05;
4870 player[0].proportionarms=1.00;
4871 player[0].proportionlegs=1.1;
4872 player[0].proportionlegs.y=1.05;
4875 player[0].numclothes=0;
4876 if(player[0].whichskin==0){
4877 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4879 else if(player[0].whichskin==1){
4880 LoadTextureSave(":Data:Textures:Fur.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4882 else if(player[0].whichskin==2){
4883 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4885 else if(player[0].whichskin==3){
4886 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4888 else if(player[0].whichskin==4){
4889 LoadTextureSave(":Data:Textures:Otter.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4891 else if(player[0].whichskin==5){
4892 LoadTextureSave(":Data:Textures:Opal.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4894 else if(player[0].whichskin==6){
4895 LoadTextureSave(":Data:Textures:Sable.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4897 else if(player[0].whichskin==7){
4898 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4900 else if(player[0].whichskin==8){
4901 LoadTextureSave(":Data:Textures:BW2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4903 else if(player[0].whichskin==9){
4904 LoadTextureSave(":Data:Textures:WB2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4907 editoractive=typeactive;
4908 player[0].immobile=0;
4915 if(Compare(consoletext[0],"tint ",0,4)||Compare(consoletext[0],"Tint ",0,4)){
4921 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4922 mapname[j-startpoint]=consoletext[0][j];
4924 if(consoletext[0][j]=='\0')alldone=1;
4926 mapname[j-startpoint]='\0';
4928 tintr=atof(mapname);
4932 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4933 mapname[j-startpoint]=consoletext[0][j];
4935 if(consoletext[0][j]=='\0')alldone=1;
4937 mapname[j-startpoint]='\0';
4939 tintg=atof(mapname);
4943 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4944 mapname[j-startpoint]=consoletext[0][j];
4946 if(consoletext[0][j]=='\0')alldone=1;
4948 mapname[j-startpoint]='\0';
4950 tintb=atof(mapname);
4955 if(Compare(consoletext[0],"sky tint ",0,8)||Compare(consoletext[0],"Sky Tint ",0,8)){
4961 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4962 mapname[j-startpoint]=consoletext[0][j];
4964 if(consoletext[0][j]=='\0')alldone=1;
4966 mapname[j-startpoint]='\0';
4968 skyboxr=atof(mapname);
4972 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4973 mapname[j-startpoint]=consoletext[0][j];
4975 if(consoletext[0][j]=='\0')alldone=1;
4977 mapname[j-startpoint]='\0';
4979 skyboxg=atof(mapname);
4983 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4984 mapname[j-startpoint]=consoletext[0][j];
4986 if(consoletext[0][j]=='\0')alldone=1;
4988 mapname[j-startpoint]='\0';
4990 skyboxb=atof(mapname);
4992 skyboxlightr=skyboxr;
4993 skyboxlightg=skyboxg;
4994 skyboxlightb=skyboxb;
4998 //if(skyboxtexture){
4999 terrain.DoShadows();
5000 objects.DoShadows();
5002 else terrain.DoLighting();
5007 if(Compare(consoletext[0],"sky light ",0,9)||Compare(consoletext[0],"Sky Light ",0,9)){
5013 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5014 mapname[j-startpoint]=consoletext[0][j];
5016 if(consoletext[0][j]=='\0')alldone=1;
5018 mapname[j-startpoint]='\0';
5020 skyboxlightr=atof(mapname);
5024 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5025 mapname[j-startpoint]=consoletext[0][j];
5027 if(consoletext[0][j]=='\0')alldone=1;
5029 mapname[j-startpoint]='\0';
5031 skyboxlightg=atof(mapname);
5035 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5036 mapname[j-startpoint]=consoletext[0][j];
5038 if(consoletext[0][j]=='\0')alldone=1;
5040 mapname[j-startpoint]='\0';
5042 skyboxlightb=atof(mapname);
5046 //if(skyboxtexture){
5047 terrain.DoShadows();
5048 objects.DoShadows();
5050 else terrain.DoLighting();
5055 if(Compare(consoletext[0],"skybox ",0,6)||Compare(consoletext[0],"Skybox ",0,6)){
5056 skyboxtexture=1-skyboxtexture;
5059 //if(skyboxtexture){
5060 terrain.DoShadows();
5061 objects.DoShadows();
5063 else terrain.DoLighting();
5068 if(Compare(consoletext[0],"protection ",0,10)||Compare(consoletext[0],"Protection ",0,10)){
5074 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5075 mapname[j-startpoint]=consoletext[0][j];
5077 if(consoletext[0][j]=='\0')alldone=1;
5079 mapname[j-startpoint]='\0';
5081 player[0].protectionhead=atof(mapname);
5085 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5086 mapname[j-startpoint]=consoletext[0][j];
5088 if(consoletext[0][j]=='\0')alldone=1;
5090 mapname[j-startpoint]='\0';
5092 player[0].protectionhigh=atof(mapname);
5096 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5097 mapname[j-startpoint]=consoletext[0][j];
5099 if(consoletext[0][j]=='\0')alldone=1;
5101 mapname[j-startpoint]='\0';
5103 player[0].protectionlow=atof(mapname);
5108 if(Compare(consoletext[0],"armor ",0,5)||Compare(consoletext[0],"Armor ",0,5)){
5114 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5115 mapname[j-startpoint]=consoletext[0][j];
5117 if(consoletext[0][j]=='\0')alldone=1;
5119 mapname[j-startpoint]='\0';
5121 player[0].armorhead=atof(mapname);
5125 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5126 mapname[j-startpoint]=consoletext[0][j];
5128 if(consoletext[0][j]=='\0')alldone=1;
5130 mapname[j-startpoint]='\0';
5132 player[0].armorhigh=atof(mapname);
5136 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5137 mapname[j-startpoint]=consoletext[0][j];
5139 if(consoletext[0][j]=='\0')alldone=1;
5141 mapname[j-startpoint]='\0';
5143 player[0].armorlow=atof(mapname);
5148 if(Compare(consoletext[0],"protectionreset ",0,15)||Compare(consoletext[0],"Protectionreset ",0,15)){
5149 for(i=0;i<numplayers;i++){
5150 player[i].protectionhead=1.0;
5151 player[i].protectionhigh=1.0;
5152 player[i].protectionlow=1.0;
5153 player[i].armorhead=1.0;
5154 player[i].armorhigh=1.0;
5155 player[i].armorlow=1.0;
5161 if(Compare(consoletext[0],"protectionnear ",0,14)||Compare(consoletext[0],"Protectionnear ",0,14)){
5163 float closestdist=-1;
5166 for(i=1;i<numplayers;i++){
5167 distance=findDistancefast(&player[i].coords,&player[0].coords);
5168 if(closestdist==-1||distance<closestdist){
5169 closestdist=distance;
5179 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5180 mapname[j-startpoint]=consoletext[0][j];
5182 if(consoletext[0][j]=='\0')alldone=1;
5184 mapname[j-startpoint]='\0';
5186 player[closest].protectionhead=atof(mapname);
5190 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5191 mapname[j-startpoint]=consoletext[0][j];
5193 if(consoletext[0][j]=='\0')alldone=1;
5195 mapname[j-startpoint]='\0';
5197 player[closest].protectionhigh=atof(mapname);
5201 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5202 mapname[j-startpoint]=consoletext[0][j];
5204 if(consoletext[0][j]=='\0')alldone=1;
5206 mapname[j-startpoint]='\0';
5208 player[closest].protectionlow=atof(mapname);
5213 if(Compare(consoletext[0],"armornear ",0,9)||Compare(consoletext[0],"Armornear ",0,9)){
5215 float closestdist=-1;
5218 for(i=1;i<numplayers;i++){
5219 distance=findDistancefast(&player[i].coords,&player[0].coords);
5220 if(closestdist==-1||distance<closestdist){
5221 closestdist=distance;
5230 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5231 mapname[j-startpoint]=consoletext[0][j];
5233 if(consoletext[0][j]=='\0')alldone=1;
5235 mapname[j-startpoint]='\0';
5237 player[closest].armorhead=atof(mapname);
5241 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5242 mapname[j-startpoint]=consoletext[0][j];
5244 if(consoletext[0][j]=='\0')alldone=1;
5246 mapname[j-startpoint]='\0';
5248 player[closest].armorhigh=atof(mapname);
5252 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5253 mapname[j-startpoint]=consoletext[0][j];
5255 if(consoletext[0][j]=='\0')alldone=1;
5257 mapname[j-startpoint]='\0';
5259 player[closest].armorlow=atof(mapname);
5265 if(Compare(consoletext[0],"metal ",0,5)||Compare(consoletext[0],"Metal ",0,5)){
5271 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5272 mapname[j-startpoint]=consoletext[0][j];
5274 if(consoletext[0][j]=='\0')alldone=1;
5276 mapname[j-startpoint]='\0';
5278 player[0].metalhead=atof(mapname);
5282 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5283 mapname[j-startpoint]=consoletext[0][j];
5285 if(consoletext[0][j]=='\0')alldone=1;
5287 mapname[j-startpoint]='\0';
5289 player[0].metalhigh=atof(mapname);
5293 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5294 mapname[j-startpoint]=consoletext[0][j];
5296 if(consoletext[0][j]=='\0')alldone=1;
5299 mapname[j-startpoint]='\0';
5301 player[0].metallow=atof(mapname);
5306 if(Compare(consoletext[0],"noclothesnear ",0,13)||Compare(consoletext[0],"Noclothesnear ",0,13)){
5308 float closestdist=-1;
5311 for(i=1;i<numplayers;i++){
5312 distance=findDistancefast(&player[i].coords,&player[0].coords);
5313 if(closestdist==-1||distance<closestdist){
5314 closestdist=distance;
5318 player[closest].numclothes=0;
5319 if(player[closest].whichskin==0){
5320 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5322 else if(player[closest].whichskin==1){
5323 LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5325 else if(player[closest].whichskin==2){
5326 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5328 else if(player[closest].whichskin==3){
5329 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5331 else if(player[closest].whichskin==4){
5332 LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5334 else if(player[closest].whichskin==5){
5335 LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5337 else if(player[closest].whichskin==6){
5338 LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5340 else if(player[closest].whichskin==7){
5341 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5343 else if(player[closest].whichskin==8){
5344 LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5346 else if(player[closest].whichskin==9){
5347 LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5353 if(Compare(consoletext[0],"noclothes ",0,9)||Compare(consoletext[0],"Noclothes ",0,9)){
5356 player[closest].numclothes=0;
5357 if(player[closest].whichskin==0){
5358 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5360 else if(player[closest].whichskin==1){
5361 LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5363 else if(player[closest].whichskin==2){
5364 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5366 else if(player[closest].whichskin==3){
5367 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5369 else if(player[closest].whichskin==4){
5370 LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5372 else if(player[closest].whichskin==5){
5373 LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5375 else if(player[closest].whichskin==6){
5376 LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5378 else if(player[closest].whichskin==7){
5379 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5381 else if(player[closest].whichskin==8){
5382 LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5384 else if(player[closest].whichskin==9){
5385 LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5391 if((Compare(consoletext[0],"Clothes ",0,7)||Compare(consoletext[0],"clothes ",0,7))){
5407 for(j=8;j<consolechars[0];j++){
5408 mapname[j-8+15]=consoletext[0][j];
5410 mapname[consolechars[0]-8+15]='.';
5411 mapname[consolechars[0]-8+16]='p';
5412 mapname[consolechars[0]-8+17]='n';
5413 mapname[consolechars[0]-8+18]='g';
5414 mapname[consolechars[0]-8+19]='\0';
5416 //:Data:Textures:Pants.png
5418 if(AddClothes((char *)mapname,0,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize)){
5419 player[0].DoMipmaps(5,0,0,player[0].skeleton.skinsize,player[0].skeleton.skinsize);
5420 strcpy(player[0].clothes[player[0].numclothes],mapname);
5421 player[0].clothestintr[player[0].numclothes]=tintr;
5422 player[0].clothestintg[player[0].numclothes]=tintg;
5423 player[0].clothestintb[player[0].numclothes]=tintb;
5424 player[0].numclothes++;
5430 if(Compare(consoletext[0],"belt ",0,4)||Compare(consoletext[0],"belt ",0,4)){
5431 player[0].skeleton.clothes = 1-player[0].skeleton.clothes;
5436 if(Compare(consoletext[0],"Cellophane ",0,10)||Compare(consoletext[0],"cellophane ",0,10)){
5437 cellophane=1-cellophane;
5440 for(i=0;i<numplayers;i++){
5441 player[i].proportionhead.z=0;
5442 player[i].proportionbody.z=0;
5443 player[i].proportionarms.z=0;
5444 player[i].proportionlegs.z=0;
5449 for(i=0;i<numplayers;i++){
5450 player[i].proportionhead.z=player[i].proportionhead.x;
5451 player[i].proportionbody.z=player[i].proportionbody.x;
5452 player[i].proportionarms.z=player[i].proportionarms.x;
5453 player[i].proportionlegs.z=player[i].proportionlegs.x;
5460 if((Compare(consoletext[0],"Clothesnear ",0,11)||Compare(consoletext[0],"clothesnear ",0,11))){
5476 for(j=12;j<consolechars[0];j++){
5477 mapname[j-12+15]=consoletext[0][j];
5479 mapname[consolechars[0]-12+15]='.';
5480 mapname[consolechars[0]-12+16]='p';
5481 mapname[consolechars[0]-12+17]='n';
5482 mapname[consolechars[0]-12+18]='g';
5483 mapname[consolechars[0]-12+19]='\0';
5485 //:Data:Textures:Pants.png
5487 float closestdist=-1;
5490 for(i=1;i<numplayers;i++){
5491 distance=findDistancefast(&player[i].coords,&player[0].coords);
5492 if(closestdist==-1||distance<closestdist){
5493 closestdist=distance;
5498 if(AddClothes((char *)mapname,0,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize)){
5499 player[closest].DoMipmaps(5,0,0,player[closest].skeleton.skinsize,player[closest].skeleton.skinsize);
5500 strcpy(player[closest].clothes[player[closest].numclothes],mapname);
5501 player[closest].clothestintr[player[closest].numclothes]=tintr;
5502 player[closest].clothestintg[player[closest].numclothes]=tintg;
5503 player[closest].clothestintb[player[closest].numclothes]=tintb;
5504 player[closest].numclothes++;
5510 if(Compare(consoletext[0],"funnybunny ",0,10)||Compare(consoletext[0],"funny bunny ",0,11)){
5511 player[0].skeleton.id=0;
5512 player[0].skeleton.Load((char *)":Data:Skeleton:Basic Figure",(char *)":Data:Skeleton:Basic Figurelow",(char *)":Data:Skeleton:Rabbitbelt",(char *)":Data:Models:Body.solid",(char *)":Data:Models:Body2.solid",(char *)":Data:Models:Body3.solid",(char *)":Data:Models:Body4.solid",(char *)":Data:Models:Body5.solid",(char *)":Data:Models:Body6.solid",(char *)":Data:Models:Body7.solid",(char *)":Data:Models:Bodylow.solid",(char *)":Data:Models:Belt.solid",1);
5513 LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5514 player[0].creature=rabbittype;
5517 player[0].proportionhead=1.2;
5518 player[0].proportionbody=1.05;
5519 player[0].proportionarms=1.00;
5520 player[0].proportionlegs=1.1;
5521 player[0].proportionlegs.y=1.05;
5522 player[0].headless=0;
5524 player[0].damagetolerance=200;
5528 if(Compare(consoletext[0],"wolfieisgod ",0,11)||Compare(consoletext[0],"wolfie is god ",0,12)){
5529 player[0].skeleton.id=0;
5530 player[0].skeleton.Load((char *)":Data:Skeleton:Basic Figure Wolf",(char *)":Data:Skeleton:Basic Figure Wolf Low",(char *)":Data:Skeleton:Rabbitbelt",(char *)":Data:Models:Wolf.solid",(char *)":Data:Models:Wolf2.solid",(char *)":Data:Models:Wolf3.solid",(char *)":Data:Models:Wolf4.solid",(char *)":Data:Models:Wolf5.solid",(char *)":Data:Models:Wolf6.solid",(char *)":Data:Models:Wolf7.solid",(char *)":Data:Models:Wolflow.solid",(char *)":Data:Models:Belt.solid",0);
5531 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5532 player[0].creature=wolftype;
5534 player[0].proportionhead=1.1;
5535 player[0].proportionbody=1.1;
5536 player[0].proportionarms=1.1;
5537 player[0].proportionlegs=1.1;
5538 player[0].proportionlegs.y=1.1;
5539 player[0].scale=.23;
5541 player[0].damagetolerance=300;
5545 /*if(Compare(consoletext[0],"kungfu ",0,6)||Compare(consoletext[0],"kung fu ",0,7)){
5546 LoadTextureSave(":Data:Textures:Kungfu.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5549 if(Compare(consoletext[0],"rambo ",0,5)){
5550 LoadTextureSave(":Data:Textures:Leather.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5553 if(Compare(consoletext[0],"david ",0,5)){
5554 LoadTextureSave(":Data:Textures:David.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5557 if(Compare(consoletext[0],"wolf ",0,4)){
5558 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5561 if(Compare(consoletext[0],"darkwolf ",0,8)){
5562 LoadTextureSave(":Data:Textures:DarkWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5565 if(Compare(consoletext[0],"snowwolf ",0,8)){
5566 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5569 if(Compare(consoletext[0],"lizardwolf ",0,10)){
5570 LoadTextureSave(":Data:Textures:Lizardwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5573 if(Compare(consoletext[0],"white ",0,5)){
5574 LoadTextureSave(":Data:Textures:fur.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5577 if(Compare(consoletext[0],"brown ",0,5)){
5578 LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5581 if(Compare(consoletext[0],"black ",0,5)){
5582 LoadTextureSave(":Data:Textures:fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5585 if(consolechars[0]>0){
5588 consoletext[k][j]=consoletext[k-1][j];
5590 consolechars[k]=consolechars[k-1];
5593 consoletext[0][j]=' ';
5599 PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, TRUE);
5600 FSOUND_SetVolume(channels[consolefailsound], 256);
5601 FSOUND_SetPaused(channels[consolefailsound], FALSE);
5610 togglekeydelay[i]=0;
5614 consoleblinkdelay-=multiplier;
5615 if(consoleblinkdelay<=0){
5616 consoleblinkdelay=.3;
5617 consoleblink=1-consoleblink;
5621 if(IsKeyDown(theKeyMap, MAC_Q_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)){
5624 if(newdetail>2)newdetail=detail;
5625 if(newdetail<0)newdetail=detail;
5626 if(newscreenwidth>3000)newscreenwidth=screenwidth;
5627 if(newscreenwidth<0)newscreenwidth=screenwidth;
5628 if(newscreenheight>3000)newscreenheight=screenheight;
5629 if(newscreenheight<0)newscreenheight=screenheight;
5631 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
5632 opstream << "Screenwidth:\n";
5633 opstream << newscreenwidth;
5634 opstream << "\nScreenheight:\n";
5635 opstream << newscreenheight;
5636 opstream << "\nMouse sensitivity:\n";
5637 opstream << usermousesensitivity;
5638 opstream << "\nBlur(0,1):\n";
5639 opstream << ismotionblur;
5640 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
5641 opstream << newdetail;
5642 opstream << "\nFloating jump:\n";
5643 opstream << floatjump;
5644 opstream << "\nMouse jump:\n";
5645 opstream << mousejump;
5646 opstream << "\nAmbient sound:\n";
5647 opstream << ambientsound;
5648 opstream << "\nBlood (0,1,2):\n";
5649 opstream << bloodtoggle;
5650 opstream << "\nAuto slomo:\n";
5651 opstream << autoslomo;
5652 opstream << "\nFoliage:\n";
5653 opstream << foliage;
5654 opstream << "\nMusic:\n";
5655 opstream << musictoggle;
5656 opstream << "\nTrilinear:\n";
5657 opstream << trilinear;
5658 opstream << "\nDecals(shadows,blood puddles,etc):\n";
5660 opstream << "\nInvert mouse:\n";
5661 opstream << invertmouse;
5662 opstream << "\nGamespeed:\n";
5663 if(oldgamespeed==0)oldgamespeed=1;
5664 opstream << oldgamespeed;
5665 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
5666 opstream << difficulty;
5667 opstream << "\nDamage effects(blackout, doublevision):\n";
5668 opstream << damageeffects;
5669 opstream << "\nText:\n";
5670 opstream << texttoggle;
5671 opstream << "\nDebug:\n";
5672 opstream << debugmode;
5673 opstream << "\nVBL Sync:\n";
5674 opstream << vblsync;
5675 opstream << "\nShow Points:\n";
5676 opstream << showpoints;
5677 opstream << "\nAlways Blur:\n";
5678 opstream << alwaysblur;
5679 opstream << "\nImmediate mode (turn on on G5):\n";
5680 opstream << immediate;
5681 opstream << "\nVelocity blur:\n";
5682 opstream << velocityblur;
5683 opstream << "\nVolume:\n";
5685 opstream << "\nForward key:\n";
5686 opstream << KeyToChar(forwardkey);
5687 opstream << "\nBack key:\n";
5688 opstream << KeyToChar(backkey);
5689 opstream << "\nLeft key:\n";
5690 opstream << KeyToChar(leftkey);
5691 opstream << "\nRight key:\n";
5692 opstream << KeyToChar(rightkey);
5693 opstream << "\nJump key:\n";
5694 opstream << KeyToChar(jumpkey);
5695 opstream << "\nCrouch key:\n";
5696 opstream << KeyToChar(crouchkey);
5697 opstream << "\nDraw key:\n";
5698 opstream << KeyToChar(drawkey);
5699 opstream << "\nThrow key:\n";
5700 opstream << KeyToChar(throwkey);
5701 opstream << "\nAttack key:\n";
5702 opstream << KeyToChar(attackkey);
5703 opstream << "\nChat key:\n";
5704 opstream << KeyToChar(chatkey);
5709 static int oldwinfreeze;
5710 if(winfreeze&&!oldwinfreeze){
5711 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
5712 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
5713 FSOUND_SetVolume(channels[consolesuccesssound], 256);
5714 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
5716 if(winfreeze==0)oldwinfreeze=winfreeze;
5717 else oldwinfreeze++;
5719 if((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY))&&!oldjumpkeydown&&!campaign){
5720 if(winfreeze)winfreeze=0;
5723 if((IsKeyDown(theKeyMap, MAC_ESCAPE_KEY))&&!campaign&&gameon){
5729 if((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY))){
5732 if(!IsKeyDown(theKeyMap, jumpkey)&&!IsKeyDown(theKeyMap, MAC_SPACE_KEY))oldjumpkeydown=0;
5734 if(!freeze&&!winfreeze&&!(mainmenu&&gameon)&&(gameon||!gamestarted)){
5736 static bool oldbuttondialogue;
5738 if(indialogue!=-1)talkdelay=1;
5739 talkdelay-=multiplier;
5742 if(indialogue==-1&&(animation[player[0].targetanimation].height!=highheight)/*&&!hostile*/)
5743 for(i=0;i<numdialogues;i++){
5744 int realdialoguetype;
5746 if(dialoguetype[i]>49){
5747 realdialoguetype=dialoguetype[i]-50;
5750 else if(dialoguetype[i]>39){
5751 realdialoguetype=dialoguetype[i]-40;
5754 else if(dialoguetype[i]>29){
5755 realdialoguetype=dialoguetype[i]-30;
5758 else if(dialoguetype[i]>19){
5759 realdialoguetype=dialoguetype[i]-20;
5762 else if(dialoguetype[i]>9){
5763 realdialoguetype=dialoguetype[i]-10;
5767 realdialoguetype=dialoguetype[i];
5770 if((!hostile||(dialoguetype[i]>40&&dialoguetype[i]<50))&&realdialoguetype<numplayers&&realdialoguetype>0&&(dialoguegonethrough[i]==0||!special)&&(special||(IsKeyDown(theKeyMap, attackkey)&&!oldbuttondialogue))){
5771 if(findDistancefast(&player[0].coords,&player[realdialoguetype].coords)<6||player[realdialoguetype].howactive>=typedead1||(dialoguetype[i]>40&&dialoguetype[i]<50)){
5773 for(j=0;j<numdialogueboxes[whichdialogue];j++){
5774 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
5775 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
5776 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
5777 player[participantfocus[whichdialogue][j]].velocity=0;
5778 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
5779 player[participantfocus[whichdialogue][j]].targetframe=0;
5784 dialoguegonethrough[i]++;
5785 if(dialogueboxsound[whichdialogue][indialogue]!=0){
5786 static float gLoc[3];
5787 static float vel[3];
5789 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
5790 temppos=temppos-viewer;
5791 Normalise(&temppos);
5796 gLoc[2]=temppos.z;vel[0]=0;
5800 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
5801 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
5802 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
5803 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
5804 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
5805 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
5806 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
5807 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
5808 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
5809 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
5810 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
5811 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
5812 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
5813 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
5814 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
5815 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
5816 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
5817 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
5818 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
5819 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
5820 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, TRUE);
5821 FSOUND_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
5822 FSOUND_SetVolume(channels[whichsoundplay], 256);
5823 FSOUND_SetPaused(channels[whichsoundplay], FALSE);
5825 if(IsKeyDown(theKeyMap, attackkey))oldbuttondialogue=1;
5830 windvar+=multiplier;
5831 smoketex+=multiplier;
5832 tutorialstagetime+=multiplier;
5834 static float hotspotvisual[40];
5838 for(i=0;i<numhotspots;i++)
5839 hotspotvisual[i]-=multiplier/320;
5841 for(i=0;i<numhotspots;i++){
5842 //if(hotspottype[i]<=10)
5843 while(hotspotvisual[i]<0){
5845 hotspotsprite.x=float(abs(Random()%100000))/100000*hotspotsize[i];
5846 hotspotsprite=DoRotation(hotspotsprite,0,0,Random()%360);
5847 hotspotsprite=DoRotation(hotspotsprite,0,Random()%360,0);
5848 hotspotsprite+=hotspot[i];
5849 sprites.MakeSprite(breathsprite, hotspotsprite, hotspotsprite*0, 1,0.5,0, 7, 0.4);
5850 hotspotvisual[i]+=0.1/hotspotsize[i]/hotspotsize[i]/hotspotsize[i];
5854 for(i=0;i<numhotspots;i++){
5855 if(hotspottype[i]<=10&&hotspottype[i]>0){
5856 hotspot[i]=player[hotspottype[i]].coords;
5862 if(tutoriallevel&&tutorialstagetime>tutorialmaxtime){
5865 if(tutorialstage<=1){
5870 if(tutorialstage==1){
5873 if(tutorialstage==2){
5876 if(tutorialstage==3){
5877 tutorialmaxtime=600;
5879 if(tutorialstage==4){
5880 tutorialmaxtime=1000;
5882 if(tutorialstage==5){
5883 tutorialmaxtime=600;
5885 if(tutorialstage==6){
5886 tutorialmaxtime=600;
5888 if(tutorialstage==7){
5889 tutorialmaxtime=600;
5891 if(tutorialstage==8){
5892 tutorialmaxtime=600;
5894 if(tutorialstage==9){
5895 tutorialmaxtime=600;
5897 if(tutorialstage==10){
5900 if(tutorialstage==11){
5901 tutorialmaxtime=1000;
5903 if(tutorialstage==12){
5904 tutorialmaxtime=1000;
5906 if(tutorialstage==13){
5909 if(tutorialstage==14){
5921 player[1].coords=(temp+temp2)/2;
5925 gLoc[0]=player[1].coords.x;
5926 gLoc[1]=player[1].coords.y;
5927 gLoc[2]=player[1].coords.z;
5931 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
5932 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
5933 FSOUND_SetVolume(channels[fireendsound], 256);
5934 FSOUND_SetPaused(channels[fireendsound], FALSE);
5936 for(i=0;i<player[1].skeleton.num_joints;i++){
5938 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
5939 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
5940 if(!player[1].skeleton.free)temp=DoRotation(DoRotation(DoRotation(player[1].skeleton.joints[i].position,0,0,player[1].tilt),player[1].tilt2,0,0),0,player[1].rotation,0)*player[1].scale+player[1].coords;
5941 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
5942 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
5947 if(tutorialstage==15){
5948 tutorialmaxtime=500;
5950 if(tutorialstage==16){
5951 tutorialmaxtime=500;
5953 if(tutorialstage==17){
5954 tutorialmaxtime=500;
5956 if(tutorialstage==18){
5957 tutorialmaxtime=500;
5959 if(tutorialstage==19){
5961 //tutorialmaxtime=500;
5963 if(tutorialstage==20){
5964 tutorialmaxtime=500;
5966 if(tutorialstage==21){
5967 tutorialmaxtime=500;
5974 if(tutorialstage==22){
5975 tutorialmaxtime=500;
5977 if(tutorialstage==23){
5978 tutorialmaxtime=500;
5980 if(tutorialstage==24){
5981 tutorialmaxtime=500;
5983 if(tutorialstage==25){
5984 tutorialmaxtime=500;
5986 if(tutorialstage==26){
5989 if(tutorialstage==27){
5993 player[1].aitype=attacktypecutoff;
5995 if(tutorialstage==28){
5996 tutorialmaxtime=400;
5998 if(tutorialstage==29){
5999 tutorialmaxtime=400;
6000 player[0].escapednum=0;
6002 if(tutorialstage==30){
6006 player[1].aitype=passivetype;
6008 if(tutorialstage==31){
6011 if(tutorialstage==32){
6014 if(tutorialstage==33){
6015 tutorialmaxtime=400;
6018 player[1].aitype=attacktypecutoff;
6020 if(tutorialstage==34){
6021 tutorialmaxtime=400;
6023 if(tutorialstage==35){
6024 tutorialmaxtime=400;
6026 if(tutorialstage==36){
6030 player[1].aitype=passivetype;
6032 if(tutorialstage==37){
6038 player[1].aitype=attacktypecutoff;
6040 if(tutorialstage==38){
6044 player[1].aitype=passivetype;
6046 if(tutorialstage==39){
6057 weapons.owner[weapons.numweapons]=-1;
6058 weapons.type[weapons.numweapons]=knife;
6059 weapons.damage[weapons.numweapons]=0;
6060 weapons.mass[weapons.numweapons]=1;
6061 weapons.tipmass[weapons.numweapons]=1.2;
6062 weapons.length[weapons.numweapons]=.25;
6063 weapons.position[weapons.numweapons]=(temp+temp2)/2;
6064 weapons.tippoint[weapons.numweapons]=(temp+temp2)/2;
6066 weapons.velocity[weapons.numweapons]=0.1;
6067 weapons.tipvelocity[weapons.numweapons]=0.1;
6068 weapons.missed[weapons.numweapons]=1;
6069 weapons.hitsomething[weapons.numweapons]=0;
6070 weapons.freetime[weapons.numweapons]=0;
6071 weapons.firstfree[weapons.numweapons]=1;
6072 weapons.physics[weapons.numweapons]=1;
6074 weapons.numweapons++;
6076 if(tutorialstage==40){
6077 tutorialmaxtime=300;
6079 if(tutorialstage==41){
6080 tutorialmaxtime=300;
6082 if(tutorialstage==42){
6085 if(tutorialstage==43){
6086 tutorialmaxtime=300;
6088 if(tutorialstage==44){
6090 player[0].weaponactive=-1;
6091 player[0].num_weapons=0;
6092 player[1].weaponactive=0;
6093 player[1].num_weapons=1;
6094 player[1].weaponids[0]=0;
6098 player[1].aitype=attacktypecutoff;
6100 tutorialmaxtime=300;
6102 if(tutorialstage==45){
6104 player[0].weaponactive=-1;
6105 player[0].num_weapons=0;
6106 player[1].weaponactive=0;
6107 player[1].num_weapons=1;
6108 player[1].weaponids[0]=0;
6110 tutorialmaxtime=300;
6112 if(tutorialstage==46){
6114 player[0].weaponactive=-1;
6115 player[0].num_weapons=0;
6116 player[1].weaponactive=0;
6117 player[1].num_weapons=1;
6118 player[1].weaponids[0]=0;
6120 weapons.type[0]=sword;
6122 tutorialmaxtime=300;
6125 if(tutorialstage==47){
6137 weapons.owner[weapons.numweapons]=-1;
6138 weapons.type[weapons.numweapons]=sword;
6139 weapons.damage[weapons.numweapons]=0;
6140 weapons.mass[weapons.numweapons]=1;
6141 weapons.tipmass[weapons.numweapons]=1.2;
6142 weapons.length[weapons.numweapons]=.25;
6143 weapons.position[weapons.numweapons]=(temp+temp2)/2;
6144 weapons.tippoint[weapons.numweapons]=(temp+temp2)/2;
6146 weapons.velocity[weapons.numweapons]=0.1;
6147 weapons.tipvelocity[weapons.numweapons]=0.1;
6148 weapons.missed[weapons.numweapons]=1;
6149 weapons.hitsomething[weapons.numweapons]=0;
6150 weapons.freetime[weapons.numweapons]=0;
6151 weapons.firstfree[weapons.numweapons]=1;
6152 weapons.physics[weapons.numweapons]=1;
6156 player[0].weaponactive=0;
6157 player[0].num_weapons=1;
6158 player[0].weaponids[0]=1;
6159 player[1].weaponactive=0;
6160 player[1].num_weapons=1;
6161 player[1].weaponids[0]=0;
6163 weapons.numweapons++;
6165 if(tutorialstage==48){
6168 player[1].aitype=passivetype;
6174 player[0].weaponactive=0;
6175 player[0].num_weapons=1;
6176 player[0].weaponids[0]=1;
6177 player[1].weaponactive=0;
6178 player[1].num_weapons=1;
6179 player[1].weaponids[0]=0;
6181 if(player[0].weaponactive!=-1)weapons.type[player[0].weaponids[player[0].weaponactive]]=staff;
6182 else weapons.type[0]=staff;
6184 weapons.numweapons++;
6186 if(tutorialstage==49){
6189 player[1].aitype=passivetype;
6191 tutorialmaxtime=200;
6193 weapons.position[1]=1000;
6194 weapons.tippoint[1]=1000;
6196 weapons.numweapons=1;
6198 player[1].weaponactive=-1;
6199 player[1].num_weapons=0;
6200 player[0].weaponactive=0;
6201 player[0].num_weapons=1;
6202 player[0].weaponids[0]=0;
6204 weapons.type[0]=knife;
6206 weapons.numweapons++;
6208 if(tutorialstage==50){
6214 gLoc[0]=player[1].coords.x;
6215 gLoc[1]=player[1].coords.y;
6216 gLoc[2]=player[1].coords.z;
6220 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
6221 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
6222 FSOUND_SetVolume(channels[fireendsound], 256);
6223 FSOUND_SetPaused(channels[fireendsound], FALSE);
6225 for(i=0;i<player[1].skeleton.num_joints;i++){
6227 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
6228 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
6229 if(!player[1].skeleton.free)temp=DoRotation(DoRotation(DoRotation(player[1].skeleton.joints[i].position,0,0,player[1].tilt),player[1].tilt2,0,0),0,player[1].rotation,0)*player[1].scale+player[1].coords;
6230 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
6231 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
6235 player[1].num_weapons=0;
6236 player[1].weaponstuck=-1;
6237 player[1].weaponactive=-1;
6239 weapons.numweapons=0;
6241 weapons.owner[0]=-1;
6242 weapons.velocity[0]=0.1;
6243 weapons.tipvelocity[0]=-0.1;
6244 weapons.missed[0]=1;
6245 weapons.hitsomething[0]=0;
6246 weapons.freetime[0]=0;
6247 weapons.firstfree[0]=1;
6248 weapons.physics[0]=1;
6250 if(tutorialstage==51){
6251 tutorialmaxtime=80000;
6253 if(tutorialstage<=51)tutorialstagetime=0;
6257 if(tutoriallevel&&tutorialstagetime<tutorialmaxtime-3){
6258 if(tutorialstage==3){
6259 if(deltah||deltav)tutorialsuccess+=multiplier;
6261 if(tutorialstage==4){
6262 if(player[0].forwardkeydown||player[0].backkeydown||player[0].leftkeydown||player[0].rightkeydown)tutorialsuccess+=multiplier;
6264 if(tutorialstage==5){
6265 if(player[0].jumpkeydown)tutorialsuccess=1;
6267 if(tutorialstage==6){
6268 if(player[0].isCrouch())tutorialsuccess=1;
6270 if(tutorialstage==7){
6271 if(player[0].targetanimation==rollanim)tutorialsuccess=1;
6273 if(tutorialstage==8){
6274 if(player[0].targetanimation==sneakanim)tutorialsuccess+=multiplier;
6276 if(tutorialstage==9){
6277 if(player[0].targetanimation==rabbitrunninganim||player[0].targetanimation==wolfrunninganim)tutorialsuccess+=multiplier;
6279 if(tutorialstage==11){
6280 if(player[0].isWallJump())tutorialsuccess=1;
6282 if(tutorialstage==12){
6283 if(player[0].targetanimation==flipanim)tutorialsuccess=1;
6285 if(tutorialstage==15){
6286 if(player[0].targetanimation==upunchanim||player[0].targetanimation==winduppunchanim)tutorialsuccess=1;
6288 if(tutorialstage==16){
6289 if(player[0].targetanimation==winduppunchanim)tutorialsuccess=1;
6291 if(tutorialstage==17){
6292 if(player[0].targetanimation==spinkickanim)tutorialsuccess=1;
6294 if(tutorialstage==18){
6295 if(player[0].targetanimation==sweepanim)tutorialsuccess=1;
6297 if(tutorialstage==19){
6298 if(player[0].targetanimation==dropkickanim)tutorialsuccess=1;
6300 if(tutorialstage==20){
6301 if(player[0].targetanimation==rabbitkickanim)tutorialsuccess=1;
6303 if(tutorialstage==21){
6304 if(bonus==cannon)tutorialsuccess=1;
6306 if(tutorialstage==22){
6307 if(bonus==spinecrusher)tutorialsuccess=1;
6309 if(tutorialstage==23){
6310 if(player[0].targetanimation==walljumprightkickanim||player[0].targetanimation==walljumpleftkickanim)tutorialsuccess=1;
6312 if(tutorialstage==24){
6313 if(player[0].targetanimation==rabbittacklinganim)tutorialsuccess=1;
6315 if(tutorialstage==25){
6316 if(player[0].targetanimation==backhandspringanim)tutorialsuccess=1;
6318 if(tutorialstage==28){
6319 if(animation[player[0].targetanimation].attack==reversed&&player[0].feint)tutorialsuccess=1;
6321 if(tutorialstage==29){
6322 if(player[0].escapednum==2){
6326 player[1].aitype=passivetype;
6329 if(tutorialstage==33){
6330 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6332 if(tutorialstage==34){
6333 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6335 if(tutorialstage==35){
6336 if(animation[player[0].targetanimation].attack==reversal){
6340 player[1].aitype=passivetype;
6343 if(tutorialstage==40){
6344 if(player[0].num_weapons>0)tutorialsuccess=1;
6346 if(tutorialstage==41){
6347 if(player[0].weaponactive==-1&&player[0].num_weapons>0)tutorialsuccess=1;
6349 if(tutorialstage==43){
6350 if(player[0].targetanimation==knifeslashstartanim)tutorialsuccess=1;
6352 if(tutorialstage==44){
6353 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6355 if(tutorialstage==45){
6356 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6358 if(tutorialstage==46){
6359 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6361 if(tutorialstage==49){
6362 if(player[1].weaponstuck!=-1)tutorialsuccess=1;
6364 if(tutorialsuccess>=1)tutorialstagetime=tutorialmaxtime-3;
6367 if(tutorialstagetime==tutorialmaxtime-3){
6368 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
6369 FSOUND_SetVolume(channels[consolesuccesssound], 256);
6370 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
6373 if(tutorialsuccess>=1){
6374 if(tutorialstage==34||tutorialstage==35)
6375 tutorialstagetime=tutorialmaxtime-1;
6380 if(tutorialstage<14||tutorialstage>=50){
6381 player[1].coords.y=300;
6382 player[1].velocity=0;
6386 if(tutoriallevel!=1){
6387 if(bonustime==0&&bonus!=solidhit&&bonus!=spinecrusher&&bonus!=tracheotomy&&bonus!=backstab&&bonusvalue>10){
6388 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
6389 FSOUND_SetVolume(channels[consolesuccesssound], 256);
6390 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
6395 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
6396 FSOUND_SetVolume(channels[fireendsound], 256);
6397 FSOUND_SetPaused(channels[fireendsound], FALSE);
6400 if(bonus!=solidhit&&bonus!=twoxcombo&&bonus!=threexcombo&&bonus!=fourxcombo&&bonus!=megacombo)bonusnum[bonus]++;
6401 else bonusnum[bonus]+=0.15;
6402 if(tutoriallevel)bonusvalue=0;
6403 bonusvalue/=bonusnum[bonus];
6404 bonustotal+=bonusvalue;
6406 bonustime+=multiplier;
6408 if(environment==snowyenvironment){
6409 precipdelay-=multiplier;
6410 while(precipdelay<0){
6412 if(!detail)precipdelay+=.04;
6413 XYZ footvel,footpoint;
6416 footpoint=viewer+viewerfacing*6;
6417 footpoint.y+=((float)abs(Random()%1200))/100-6;
6418 footpoint.x+=((float)abs(Random()%1200))/100-6;
6419 footpoint.z+=((float)abs(Random()%1200))/100-6;
6420 sprites.MakeSprite(snowsprite, footpoint,footvel, 1,1,1, .1, 1);
6423 for(k=0;k<numplayers;k++){
6424 if(player[k].aitype==playercontrolled)player[k].turnspeed=500;
6425 if(player[k].aitype!=playercontrolled)player[k].turnspeed=500;
6427 if((player[k].isRun()&&((player[k].targetrotation!=rabbitrunninganim&&player[k].targetrotation!=wolfrunninganim)||player[k].targetframe==4))||player[k].targetanimation==removeknifeanim||player[k].targetanimation==crouchremoveknifeanim||player[k].targetanimation==flipanim||player[k].targetanimation==fightsidestep||player[k].targetanimation==walkanim){
6428 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6429 else if(player[k].rotation>player[k].targetrotation){
6430 player[k].rotation-=multiplier*player[k].turnspeed;
6432 else if(player[k].rotation<player[k].targetrotation){
6433 player[k].rotation+=multiplier*player[k].turnspeed;
6438 if(player[k].isStop()||player[k].isLanding()||player[k].targetanimation==staggerbackhighanim||(player[k].targetanimation==sneakanim&&player[k].currentanimation==sneakanim)||player[k].targetanimation==staggerbackhardanim||player[k].targetanimation==backhandspringanim||player[k].targetanimation==dodgebackanim||player[k].targetanimation==rollanim||(animation[player[k].targetanimation].attack&&player[k].targetanimation!=rabbitkickanim&&(player[k].targetanimation!=crouchstabanim||player[k].hasvictim)&&(player[k].targetanimation!=swordgroundstabanim||player[k].hasvictim))){
6439 player[k].turnspeed*=2;
6440 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6441 else if(player[k].rotation>player[k].targetrotation){
6442 player[k].rotation-=multiplier*player[k].turnspeed;
6444 else if(player[k].rotation<player[k].targetrotation){
6445 player[k].rotation+=multiplier*player[k].turnspeed;
6447 player[k].turnspeed/=2;
6450 if(player[k].targetanimation==sneakanim&&player[k].currentanimation!=sneakanim){
6451 player[k].turnspeed*=4;
6452 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6453 else if(player[k].rotation>player[k].targetrotation){
6454 player[k].rotation-=multiplier*player[k].turnspeed;
6456 else if(player[k].rotation<player[k].targetrotation){
6457 player[k].rotation+=multiplier*player[k].turnspeed;
6459 player[k].turnspeed/=4;
6462 /*if(player[k].aitype!=passivetype||(findDistancefast(&player[k].coords,&viewer)<viewdistance*viewdistance))*/ player[k].DoStuff();
6463 if(player[k].immobile&&k!=0)player[k].coords=player[k].realoldcoords;
6465 if(findDistancefast(&player[k].coords,&player[k].realoldcoords)>0){
6466 if(!player[k].skeleton.free&&player[k].targetanimation!=climbanim&&player[k].targetanimation!=hanganim){
6469 if(player[k].collide<-.3)player[k].collide=-.3;
6470 if(player[k].collide>1)player[k].collide=1;
6471 player[k].collide-=multiplier*30;
6473 if(player[k].coords.y<terrain.getHeight(player[k].coords.x,player[k].coords.z)){
6474 player[k].coords.y=terrain.getHeight(player[k].coords.x,player[k].coords.z);
6476 if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
6477 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
6478 i=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
6479 if(objects.type[i]!=rocktype||(((objects.scale[i]>.5&&player[k].aitype==playercontrolled)||objects.position[i].y>player[k].coords.y))){
6480 lowpoint=player[k].coords;
6481 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&!player[k].isFlip())lowpoint.y+=1.25;
6482 else lowpoint.y+=1.3;
6483 if(player[k].coords.y<terrain.getHeight(player[k].coords.x,player[k].coords.z)&&player[k].coords.y>terrain.getHeight(player[k].coords.x,player[k].coords.z)-.1){
6484 player[k].coords.y=terrain.getHeight(player[k].coords.x,player[k].coords.z);
6486 /*while(player[k].coords.y<terrain.getHeight(player[k].coords.x,player[k].coords.z))
6487 player[k].coords+=terrain.getNormal(player[k].coords.x,player[k].coords.z)/50;
6489 if(player[k].SphereCheck(&lowpoint, 1.3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
6490 flatfacing=lowpoint-player[k].coords;
6491 player[k].coords=lowpoint;
6492 player[k].coords.y-=1.3;
6493 player[k].collide=1;
6495 if(player[k].aitype==playercontrolled&&(player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim||player[k].isFlip())&&!player[k].jumptogglekeydown&&player[k].jumpkeydown){
6496 lowpointtarget=lowpoint+DoRotation(player[k].facing,0,-90,0)*1.5;
6497 tempcoords1=lowpoint;
6498 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6499 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6501 player[k].targetanimation=walljumpleftanim;
6502 player[k].targetframe=0;
6505 gLoc[0]=player[k].coords.x;
6506 gLoc[1]=player[k].coords.y;
6507 gLoc[2]=player[k].coords.z;
6511 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, TRUE);
6512 FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6513 FSOUND_SetVolume(channels[movewhooshsound], 256);
6514 FSOUND_SetPaused(channels[movewhooshsound], FALSE);
6515 if(k==0)FSOUND_SetPaused(channels[whooshsound], TRUE);
6517 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6518 player[k].rotation=-asin(0-lowpointtarget.x);
6519 player[k].rotation*=360/6.28;
6520 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6521 player[k].targetrotation=player[k].rotation;
6522 player[k].lowrotation=player[k].rotation;
6523 if(k==0)numwallflipped++;
6527 lowpoint=tempcoords1;
6528 lowpointtarget=lowpoint+DoRotation(player[k].facing,0,90,0)*1.5;
6529 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6530 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6532 player[k].targetanimation=walljumprightanim;
6533 player[k].targetframe=0;
6536 gLoc[0]=player[k].coords.x;
6537 gLoc[1]=player[k].coords.y;
6538 gLoc[2]=player[k].coords.z;
6542 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, TRUE);
6543 FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6544 FSOUND_SetVolume(channels[movewhooshsound], 256);
6545 FSOUND_SetPaused(channels[movewhooshsound], FALSE);
6546 if(k==0)FSOUND_SetPaused(channels[whooshsound], TRUE);
6548 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6549 player[k].rotation=-asin(0-lowpointtarget.x);
6550 player[k].rotation*=360/6.28;
6551 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6552 player[k].targetrotation=player[k].rotation;
6553 player[k].lowrotation=player[k].rotation;
6554 if(k==0)numwallflipped++;
6558 lowpoint=tempcoords1;
6559 lowpointtarget=lowpoint+player[k].facing*2;
6560 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6561 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6563 player[k].targetanimation=walljumpbackanim;
6564 player[k].targetframe=0;
6567 gLoc[0]=player[k].coords.x;
6568 gLoc[1]=player[k].coords.y;
6569 gLoc[2]=player[k].coords.z;
6573 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, TRUE);
6574 FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6575 FSOUND_SetVolume(channels[movewhooshsound], 256);
6576 FSOUND_SetPaused(channels[movewhooshsound], FALSE);
6577 if(k==0)FSOUND_SetPaused(channels[whooshsound], TRUE);
6579 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6580 player[k].rotation=-asin(0-lowpointtarget.x);
6581 player[k].rotation*=360/6.28;
6582 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6583 player[k].targetrotation=player[k].rotation;
6584 player[k].lowrotation=player[k].rotation;
6585 if(k==0)numwallflipped++;
6589 lowpoint=tempcoords1;
6590 lowpointtarget=lowpoint-player[k].facing*2;
6591 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6592 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6594 player[k].targetanimation=walljumpfrontanim;
6595 player[k].targetframe=0;
6598 gLoc[0]=player[k].coords.x;
6599 gLoc[1]=player[k].coords.y;
6600 gLoc[2]=player[k].coords.z;
6604 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, TRUE);
6605 FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6606 FSOUND_SetVolume(channels[movewhooshsound], 256);
6607 FSOUND_SetPaused(channels[movewhooshsound], FALSE);
6608 if(k==0)FSOUND_SetPaused(channels[whooshsound], TRUE);
6610 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6611 player[k].rotation=-asin(0-lowpointtarget.x);
6612 player[k].rotation*=360/6.28;
6613 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6614 player[k].rotation+=180;
6615 player[k].targetrotation=player[k].rotation;
6616 player[k].lowrotation=player[k].rotation;
6617 if(k==0)numwallflipped++;
6625 else if(objects.type[i]==rocktype){
6626 lowpoint2=player[k].coords;
6627 lowpoint=player[k].coords;
6629 if(objects.model[i].LineCheck(&lowpoint,&lowpoint2,&colpoint,&objects.position[i],&objects.rotation[i])!=-1){
6630 player[k].coords=colpoint;
6631 player[k].collide=1;
6634 if((player[k].targetanimation==jumpdownanim||player[k].isFlip())){
6635 if(player[k].isFlip()&&animation[player[k].targetanimation].label[player[k].targetframe]==7)player[k].RagDoll(0);
6637 if(player[k].targetanimation==jumpupanim){player[k].jumppower=-4;player[k].targetanimation=player[k].getIdle();}
6639 player[k].targetframe=0;
6640 player[k].onterrain=1;
6642 if(player[k].id==0){
6643 FSOUND_SetPaused(channels[whooshsound], TRUE);
6644 FSOUND_SetVolume(channels[whooshsound], 0);
6647 if((player[k].targetanimation==jumpdownanim||player[k].isFlip())&&!player[k].wasLanding()){
6648 if(player[k].isFlip())player[k].jumppower=-4;
6649 player[k].targetanimation=player[k].getLanding();
6652 gLoc[0]=player[k].coords.x;
6653 gLoc[1]=player[k].coords.y;
6654 gLoc[2]=player[k].coords.z;
6655 vel[0]=player[k].velocity.x;
6656 vel[1]=player[k].velocity.y;
6657 vel[2]=player[k].velocity.z;
6658 PlaySoundEx( landsound, samp[landsound], NULL, TRUE);
6659 FSOUND_3D_SetAttributes(channels[landsound], gLoc, vel);
6660 FSOUND_SetVolume(channels[landsound], 128);
6661 FSOUND_SetPaused(channels[landsound], FALSE);
6663 envsound[numenvsounds]=player[k].coords;
6664 envsoundvol[numenvsounds]=16;
6665 envsoundlife[numenvsounds]=.4;
6674 if(tempcollide&&terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz]&&(/*player[k].jumptogglekeydown*/1==1||player[k].aitype!=playercontrolled))
6675 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
6676 i=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
6677 lowpoint=player[k].coords;
6679 if(objects.type[i]!=rocktype)
6680 if(player[k].SphereCheck(&lowpoint, 1.33, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
6681 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&player[k].onterrain)player[k].avoidcollided=1;
6682 player[k].coords=lowpoint;
6683 player[k].coords.y-=1.35;
6684 player[k].collide=1;
6686 if((player[k].grabdelay<=0||player[k].aitype!=playercontrolled)&&((/*(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)&&*/player[k].currentanimation!=climbanim&&player[k].currentanimation!=hanganim&&!player[k].isWallJump())||player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim)){
6687 lowpoint=player[k].coords;
6688 objects.model[i].SphereCheckPossible(&lowpoint, 1.5, &objects.position[i], &objects.rotation[i]);
6689 lowpoint=player[k].coords;
6693 facing=DoRotation(facing,0,player[k].targetrotation+180,0);
6694 lowpointtarget=lowpoint+facing*1.4;
6695 whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6697 lowpoint=player[k].coords;
6699 lowpointtarget=lowpoint+facing*1.4;
6701 lowpointtarget2=lowpointtarget;
6703 lowpointtarget3=lowpointtarget;
6705 lowpointtarget4=lowpointtarget;
6707 lowpointtarget5=lowpointtarget;
6709 lowpointtarget6=lowpointtarget;
6711 lowpointtarget7=lowpoint;
6713 lowpointtarget2.x+=.1;
6715 lowpointtarget3.z+=.1;
6717 lowpointtarget4.x-=.1;
6719 lowpointtarget5.z-=.1;
6721 lowpointtarget6.y+=45/13;
6722 lowpointtarget6+=facing*.6;
6723 lowpointtarget7.y+=90/13;
6724 whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6725 if(objects.friction[i]>.5)
6728 if(whichhit!=-1)if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim)player[k].collided=1;
6729 if(checkcollide(lowpoint7,lowpointtarget7)==-1)
6730 if(checkcollide(lowpoint6,lowpointtarget6)==-1)
6731 if(objects.model[i].LineCheckPossible(&lowpoint2,&lowpointtarget2,&colpoint,&objects.position[i],&objects.rotation[i])!=-1&&objects.model[i].LineCheckPossible(&lowpoint3,&lowpointtarget3,&colpoint,&objects.position[i],&objects.rotation[i])!=-1&&objects.model[i].LineCheckPossible(&lowpoint4,&lowpointtarget4,&colpoint,&objects.position[i],&objects.rotation[i])!=-1&&objects.model[i].LineCheckPossible(&lowpoint5,&lowpointtarget5,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)
6733 lowpoint=player[k].coords;
6734 lowpoint.y+=(float)j/13;
6735 lowpointtarget=lowpoint+facing*1.4;
6736 if(objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint2,&objects.position[i],&objects.rotation[i])==-1){
6740 /*if(j>=25&&(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)){
6743 if(j<=25&&player[k].targetanimation==jumpdownanim){
6746 if(j!=100&&(/*j>25||(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)||*/player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim)){
6747 lowpoint=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0);
6748 if(1==1/*dotproduct(&player[k].velocity,&lowpoint)>0||player[k].aitype!=playercontrolled||(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim||player[k].targetanimation==jumpupanim)*/){
6749 lowpoint=player[k].coords;
6750 lowpoint.y+=(float)j/13;
6751 lowpointtarget=lowpoint+facing*1.3;
6752 flatfacing=player[k].coords;
6753 player[k].coords=colpoint-DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0)*.01;
6754 player[k].coords.y=lowpointtarget.y-.07;
6755 player[k].currentoffset=(flatfacing-player[k].coords)/player[k].scale;
6757 if(j>10||!player[k].isRun()){
6758 if(player[k].targetanimation==jumpdownanim||player[k].targetanimation==jumpupanim){
6759 if(k==0)FSOUND_SetPaused(channels[whooshsound], TRUE);
6763 gLoc[0]=player[k].coords.x;
6764 gLoc[1]=player[k].coords.y;
6765 gLoc[2]=player[k].coords.z;
6766 vel[0]=player[k].velocity.x;
6767 vel[1]=player[k].velocity.y;
6768 vel[2]=player[k].velocity.z;
6769 PlaySoundEx( jumpsound, samp[jumpsound], NULL, TRUE);
6770 FSOUND_3D_SetAttributes(channels[jumpsound], gLoc, vel);
6771 FSOUND_SetVolume(channels[jumpsound], 128);
6772 FSOUND_SetPaused(channels[jumpsound], FALSE);
6774 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6775 player[k].rotation=-asin(0-lowpointtarget.x);
6776 player[k].rotation*=360/6.28;
6777 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6778 player[k].targetrotation=player[k].rotation;
6779 player[k].lowrotation=player[k].rotation;
6781 //player[k].velocity=lowpointtarget*.03;
6782 player[k].velocity=0;
6784 if(/*(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)||*/player[k].targetanimation==jumpupanim){
6785 //player[k].currentanimation=climbanim;
6786 player[k].targetanimation=climbanim;
6787 player[k].jumppower=0;
6788 player[k].jumpclimb=1;
6790 player[k].transspeed=6;
6793 //player[k].currentframe=1;
6794 player[k].targetframe=1;
6796 //player[k].currentframe=0;
6797 player[k].targetframe=0;
6798 //player[k].currentanimation=hanganim;
6799 player[k].targetanimation=hanganim;
6800 player[k].jumppower=0;
6814 if(player[k].collide<=0){
6815 if(!player[k].onterrain&&player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&player[k].targetanimation!=climbanim&&player[k].targetanimation!=hanganim&&!player[k].isWallJump()&&!player[k].isFlip()){
6816 if(player[k].currentanimation!=climbanim&&player[k].currentanimation!=tempanim&&player[k].targetanimation!=backhandspringanim&&(player[k].targetanimation!=rollanim||player[k].targetframe<2||player[k].targetframe>6)){
6817 if(player[k].targetanimation==staggerbackhighanim||player[k].targetanimation==staggerbackhardanim)player[k].RagDoll(0);
6818 player[k].targetanimation=jumpdownanim;
6819 player[k].targetframe=0;
6824 gLoc[0]=player[k].coords.x;
6825 gLoc[1]=player[k].coords.y;
6826 gLoc[2]=player[k].coords.z;
6827 vel[0]=player[k].velocity.x;
6828 vel[1]=player[k].velocity.y;
6829 vel[2]=player[k].velocity.z;
6831 PlaySoundEx( whooshsound, samp[whooshsound], NULL, TRUE);
6832 FSOUND_3D_SetAttributes(channels[whooshsound], gLoc, vel);
6833 FSOUND_SetVolume(channels[whooshsound], 128);
6834 FSOUND_SetPaused(channels[whooshsound], FALSE);
6837 player[k].velocity.y+=gravity;
6842 player[k].realoldcoords=player[k].coords;
6845 static XYZ oldviewer;
6848 player[0].forwardkeydown=IsKeyDown(theKeyMap, forwardkey);
6849 player[0].leftkeydown=IsKeyDown(theKeyMap, leftkey);
6850 player[0].backkeydown=IsKeyDown(theKeyMap, backkey);
6851 player[0].rightkeydown=IsKeyDown(theKeyMap, rightkey);
6852 player[0].jumpkeydown=IsKeyDown(theKeyMap, jumpkey);
6853 player[0].crouchkeydown=IsKeyDown(theKeyMap, crouchkey);
6854 player[0].drawkeydown=IsKeyDown(theKeyMap, drawkey);
6855 player[0].throwkeydown=IsKeyDown(theKeyMap, throwkey);
6859 player[0].forwardkeydown=0;
6860 player[0].leftkeydown=0;
6861 player[0].backkeydown=0;
6862 player[0].rightkeydown=0;
6863 player[0].jumpkeydown=0;
6864 player[0].crouchkeydown=0;
6865 player[0].drawkeydown=0;
6866 player[0].throwkeydown=0;
6869 if(!player[0].jumpkeydown)player[0].jumpclimb=0;
6872 static bool endkeydown;
6879 facing=DoRotation(facing,-rotation2,0,0);
6880 facing=DoRotation(facing,0,0-rotation,0);
6885 flatfacing=DoRotation(flatfacing,0,-rotation,0);
6887 if(IsKeyDown(theKeyMap, forwardkey))viewer+=facing*multiplier*4;
6888 if(IsKeyDown(theKeyMap, backkey))viewer-=facing*multiplier*4;
6889 if(IsKeyDown(theKeyMap, leftkey))viewer+=DoRotation(flatfacing*multiplier,0,90,0)*4;
6890 if(IsKeyDown(theKeyMap, rightkey))viewer+=DoRotation(flatfacing*multiplier,0,-90,0)*4;
6891 if(IsKeyDown(theKeyMap, jumpkey))viewer.y+=multiplier*4;
6892 if(IsKeyDown(theKeyMap, crouchkey))viewer.y-=multiplier*4;
6893 if(!endkeydown&&(IsKeyDown(theKeyMap, MAC_1_KEY)||IsKeyDown(theKeyMap, MAC_2_KEY)||IsKeyDown(theKeyMap, MAC_3_KEY)||IsKeyDown(theKeyMap, MAC_4_KEY)||IsKeyDown(theKeyMap, MAC_5_KEY)
6894 ||IsKeyDown(theKeyMap, MAC_6_KEY)||IsKeyDown(theKeyMap, MAC_7_KEY)||IsKeyDown(theKeyMap, MAC_8_KEY)||IsKeyDown(theKeyMap, MAC_9_KEY)||IsKeyDown(theKeyMap, MAC_0_KEY)
6895 ||IsKeyDown(theKeyMap, MAC_MINUS_KEY))){
6897 if(IsKeyDown(theKeyMap, MAC_1_KEY))whichend=1;
6898 if(IsKeyDown(theKeyMap, MAC_2_KEY))whichend=2;
6899 if(IsKeyDown(theKeyMap, MAC_3_KEY))whichend=3;
6900 if(IsKeyDown(theKeyMap, MAC_4_KEY))whichend=4;
6901 if(IsKeyDown(theKeyMap, MAC_5_KEY))whichend=5;
6902 if(IsKeyDown(theKeyMap, MAC_6_KEY))whichend=6;
6903 if(IsKeyDown(theKeyMap, MAC_7_KEY))whichend=7;
6904 if(IsKeyDown(theKeyMap, MAC_8_KEY))whichend=8;
6905 if(IsKeyDown(theKeyMap, MAC_9_KEY))whichend=9;
6906 if(IsKeyDown(theKeyMap, MAC_0_KEY))whichend=0;
6907 if(IsKeyDown(theKeyMap, MAC_MINUS_KEY))whichend=-1;
6909 participantfocus[whichdialogue][indialogue]=whichend;
6910 participantlocation[whichdialogue][whichend]=player[whichend].coords;
6911 participantrotation[whichdialogue][whichend]=player[whichend].rotation;
6914 participantfocus[whichdialogue][indialogue]=-1;
6916 if(player[participantfocus[whichdialogue][indialogue]].dead){
6921 dialoguecamera[whichdialogue][indialogue]=viewer;
6922 dialoguecamerarotation[whichdialogue][indialogue]=rotation;
6923 dialoguecamerarotation2[whichdialogue][indialogue]=rotation2;
6925 if(indialogue<numdialogueboxes[whichdialogue]){
6926 if(dialogueboxsound[whichdialogue][indialogue]!=0){
6927 static float gLoc[3];
6928 static float vel[3];
6930 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
6931 temppos=temppos-viewer;
6932 Normalise(&temppos);
6937 gLoc[2]=temppos.z;vel[0]=0;
6941 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
6942 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
6943 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
6944 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
6945 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
6946 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
6947 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
6948 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
6949 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
6950 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
6951 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
6952 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
6953 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
6954 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
6955 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
6956 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
6957 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
6958 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
6959 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
6960 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
6961 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, TRUE);
6962 FSOUND_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
6963 FSOUND_SetVolume(channels[whichsoundplay], 256);
6964 FSOUND_SetPaused(channels[whichsoundplay], FALSE);
6968 for(j=0;j<numplayers;j++){
6969 participantfacing[whichdialogue][indialogue][j]=participantfacing[whichdialogue][indialogue-1][j];
6974 if((IsKeyDown(theKeyMap, MAC_NUMPAD_1_KEY)||IsKeyDown(theKeyMap, MAC_NUMPAD_2_KEY)||IsKeyDown(theKeyMap, MAC_NUMPAD_3_KEY)||IsKeyDown(theKeyMap, MAC_NUMPAD_4_KEY)||IsKeyDown(theKeyMap, MAC_NUMPAD_5_KEY)
6975 ||IsKeyDown(theKeyMap, MAC_NUMPAD_6_KEY)||IsKeyDown(theKeyMap, MAC_NUMPAD_7_KEY)||IsKeyDown(theKeyMap, MAC_NUMPAD_8_KEY)||IsKeyDown(theKeyMap, MAC_NUMPAD_9_KEY)||IsKeyDown(theKeyMap, MAC_NUMPAD_0_KEY)
6978 if(IsKeyDown(theKeyMap, MAC_NUMPAD_1_KEY))whichend=1;
6979 if(IsKeyDown(theKeyMap, MAC_NUMPAD_2_KEY))whichend=2;
6980 if(IsKeyDown(theKeyMap, MAC_NUMPAD_3_KEY))whichend=3;
6981 if(IsKeyDown(theKeyMap, MAC_NUMPAD_4_KEY))whichend=4;
6982 if(IsKeyDown(theKeyMap, MAC_NUMPAD_5_KEY))whichend=5;
6983 if(IsKeyDown(theKeyMap, MAC_NUMPAD_6_KEY))whichend=6;
6984 if(IsKeyDown(theKeyMap, MAC_NUMPAD_7_KEY))whichend=7;
6985 if(IsKeyDown(theKeyMap, MAC_NUMPAD_8_KEY))whichend=8;
6986 if(IsKeyDown(theKeyMap, MAC_NUMPAD_9_KEY))whichend=9;
6987 if(IsKeyDown(theKeyMap, MAC_NUMPAD_0_KEY))whichend=0;
6988 participantfacing[whichdialogue][indialogue][whichend]=facing;
6990 if(!IsKeyDown(theKeyMap, MAC_1_KEY)&&!IsKeyDown(theKeyMap, MAC_2_KEY)&&!IsKeyDown(theKeyMap, MAC_3_KEY)&&!IsKeyDown(theKeyMap, MAC_4_KEY)&&!IsKeyDown(theKeyMap, MAC_5_KEY)
6991 &&!IsKeyDown(theKeyMap, MAC_6_KEY)&&!IsKeyDown(theKeyMap, MAC_7_KEY)&&!IsKeyDown(theKeyMap, MAC_8_KEY)&&!IsKeyDown(theKeyMap, MAC_9_KEY)&&!IsKeyDown(theKeyMap, MAC_0_KEY)
6992 &&!IsKeyDown(theKeyMap, MAC_MINUS_KEY)){
6995 if(indialogue>=numdialogueboxes[whichdialogue]){
7002 FSOUND_SetPaused(channels[whooshsound], TRUE);
7003 viewer=dialoguecamera[whichdialogue][indialogue];
7004 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.1){
7005 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.1;
7007 rotation=dialoguecamerarotation[whichdialogue][indialogue];
7008 rotation2=dialoguecamerarotation2[whichdialogue][indialogue];
7009 if(dialoguetime>0.5)
7010 if((!endkeydown&&(IsKeyDown(theKeyMap, MAC_1_KEY)||IsKeyDown(theKeyMap, MAC_2_KEY)||IsKeyDown(theKeyMap, MAC_3_KEY)||IsKeyDown(theKeyMap, MAC_4_KEY)||IsKeyDown(theKeyMap, MAC_5_KEY)
7011 ||IsKeyDown(theKeyMap, MAC_6_KEY)||IsKeyDown(theKeyMap, MAC_7_KEY)||IsKeyDown(theKeyMap, MAC_8_KEY)||IsKeyDown(theKeyMap, MAC_9_KEY)||IsKeyDown(theKeyMap, MAC_0_KEY)
7012 ||IsKeyDown(theKeyMap, MAC_MINUS_KEY)))||(IsKeyDown(theKeyMap, attackkey)&&!oldbuttondialogue)){
7015 if(indialogue<numdialogueboxes[whichdialogue]){
7016 if(dialogueboxsound[whichdialogue][indialogue]!=0){
7017 static float gLoc[3];
7018 static float vel[3];
7020 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
7021 temppos=temppos-viewer;
7022 Normalise(&temppos);
7027 gLoc[2]=temppos.z;vel[0]=0;
7031 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
7032 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
7033 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
7034 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
7035 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
7036 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
7037 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
7038 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
7039 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
7040 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
7041 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
7042 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
7043 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
7044 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
7045 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
7046 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
7047 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
7048 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
7049 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
7050 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
7051 if(dialogueboxsound[whichdialogue][indialogue]==-6)whichsoundplay=alarmsound;
7052 if(dialogueboxsound[whichdialogue][indialogue]!=-5){
7053 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, TRUE);
7054 FSOUND_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
7055 FSOUND_SetVolume(channels[whichsoundplay], 256);
7056 FSOUND_SetPaused(channels[whichsoundplay], FALSE);
7058 if(dialogueboxsound[whichdialogue][indialogue]==-5){
7059 hotspot[numhotspots]=player[0].coords;
7060 hotspotsize[numhotspots]=10;
7061 hotspottype[numhotspots]=-1;
7065 if(dialogueboxsound[whichdialogue][indialogue]==-6){
7069 if(player[participantfocus[whichdialogue][indialogue]].dead){
7077 if(!IsKeyDown(theKeyMap, MAC_1_KEY)&&!IsKeyDown(theKeyMap, MAC_2_KEY)&&!IsKeyDown(theKeyMap, MAC_3_KEY)&&!IsKeyDown(theKeyMap, MAC_4_KEY)&&!IsKeyDown(theKeyMap, MAC_5_KEY)
7078 &&!IsKeyDown(theKeyMap, MAC_6_KEY)&&!IsKeyDown(theKeyMap, MAC_7_KEY)&&!IsKeyDown(theKeyMap, MAC_8_KEY)&&!IsKeyDown(theKeyMap, MAC_9_KEY)&&!IsKeyDown(theKeyMap, MAC_0_KEY)
7079 &&!IsKeyDown(theKeyMap, MAC_MINUS_KEY)){
7082 if(indialogue>=numdialogueboxes[whichdialogue]){
7086 if(dialoguetype[whichdialogue]>19&&dialoguetype[whichdialogue]<30){
7089 if(dialoguetype[whichdialogue]>29&&dialoguetype[whichdialogue]<40){
7092 if(dialoguetype[whichdialogue]>49&&dialoguetype[whichdialogue]<60){
7094 for(i=1;i<numplayers;i++){
7095 player[i].aitype = attacktypecutoff;
7102 if(!IsKeyDown(theKeyMap, attackkey))oldbuttondialogue=0;
7103 else oldbuttondialogue=1;
7105 static float keyrefreshdelay=0,bigrefreshdelay=0;
7109 /*keyrefreshdelay-=multiplier;
7110 bigrefreshdelay-=multiplier;
7112 if(keyrefreshdelay<=0){
7113 static int concat[4];
7115 concat[0]=player[0].forwardkeydown;
7116 concat[0]=concat[0]*2+player[0].forwardstogglekeydown;
7117 concat[0]=concat[0]*2+player[0].rightkeydown;
7118 concat[0]=concat[0]*2+player[0].leftkeydown;
7119 concat[0]=concat[0]*2+player[0].backkeydown;
7120 concat[0]=concat[0]*2+player[0].jumpkeydown;
7121 concat[0]=concat[0]*2+player[0].jumptogglekeydown;
7122 concat[0]=concat[0]*2+player[0].crouchkeydown;
7124 concat[1]=player[0].crouchtogglekeydown;
7125 concat[1]=concat[1]*2+player[0].drawkeydown;
7126 concat[1]=concat[1]*2+player[0].drawtogglekeydown;
7127 concat[1]=concat[1]*2+player[0].throwkeydown;
7128 concat[1]=concat[1]*2+player[0].throwtogglekeydown;
7129 concat[1]=concat[1]*2+player[0].attackkeydown;
7131 //concat[2]=(char)((int)(rotation/2)%180);
7133 //concat[3]=(char)((int)(rotation2/2)%180);
7135 chatname[0]=concat[0]-128;
7136 chatname[1]=concat[1]-128;
7137 //chatname[2]=concat[2]-128;
7138 //chatname[3]=concat[3]-128;
7140 memcpy(chatname+temppoint,&rotation,sizeof(float));
7141 temppoint+=sizeof(float);
7142 memcpy(chatname+temppoint,&rotation2,sizeof(float));
7143 temppoint+=sizeof(float);
7145 chatname[temppoint]='\0';
7147 //if(!ishost)NetworkSendPlayerMessage( chatname, kMessageType_Keys );
7148 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_Keys );
7149 //keyrefreshdelay=.01;
7150 keyrefreshdelay=.03;
7153 if(bigrefreshdelay<=0){
7156 memcpy(chatname+temppoint,&i,sizeof(int));
7157 temppoint+=sizeof(int);
7158 memcpy(chatname+temppoint,&player[i].coords.x,sizeof(float));
7159 temppoint+=sizeof(float);
7160 memcpy(chatname+temppoint,&player[i].coords.y,sizeof(float));
7161 temppoint+=sizeof(float);
7162 memcpy(chatname+temppoint,&player[i].coords.z,sizeof(float));
7163 temppoint+=sizeof(float);
7164 memcpy(chatname+temppoint,&player[i].damage,sizeof(float));
7165 temppoint+=sizeof(float);
7166 memcpy(chatname+temppoint,&player[i].target,sizeof(float));
7167 temppoint+=sizeof(float);
7168 memcpy(chatname+temppoint,&player[i].targetanimation,sizeof(int));
7169 temppoint+=sizeof(int);
7170 memcpy(chatname+temppoint,&player[i].currentanimation,sizeof(int));
7171 temppoint+=sizeof(int);
7172 memcpy(chatname+temppoint,&player[i].velocity.x,sizeof(float));
7173 temppoint+=sizeof(float);
7174 memcpy(chatname+temppoint,&player[i].velocity.y,sizeof(float));
7175 temppoint+=sizeof(float);
7176 memcpy(chatname+temppoint,&player[i].velocity.z,sizeof(float));
7177 temppoint+=sizeof(float);
7178 memcpy(chatname+temppoint,&player[i].targetframe,sizeof(int));
7179 temppoint+=sizeof(int);
7180 memcpy(chatname+temppoint,&player[i].currentframe,sizeof(int));
7181 temppoint+=sizeof(int);
7182 memcpy(chatname+temppoint,&player[i].rotation,sizeof(float));
7183 temppoint+=sizeof(float);
7184 memcpy(chatname+temppoint,&player[i].targetrotation,sizeof(float));
7185 temppoint+=sizeof(float);
7186 memcpy(chatname+temppoint,&player[i].bloodloss,sizeof(float));
7187 temppoint+=sizeof(float);
7188 memcpy(chatname+temppoint,&player[i].weaponactive,sizeof(int));
7189 temppoint+=sizeof(int);
7190 memcpy(chatname+temppoint,&player[i].num_weapons,sizeof(int));
7191 temppoint+=sizeof(int);
7192 memcpy(chatname+temppoint,&player[i].weaponids[0],sizeof(int));
7193 temppoint+=sizeof(int);
7194 memcpy(chatname+temppoint,&player[i].weaponids[1],sizeof(int));
7195 temppoint+=sizeof(int);
7196 memcpy(chatname+temppoint,&player[i].weaponids[2],sizeof(int));
7197 temppoint+=sizeof(int);
7198 memcpy(chatname+temppoint,&player[i].weaponids[3],sizeof(int));
7199 temppoint+=sizeof(int);
7200 chatname[temppoint]='\0';
7202 sprintf (chatname, "%d %f %f %f %f %f %d %d %f %f %f %d %d %f %f %f",i,player[i].coords.x,player[i].coords.y,player[i].coords.z,player[i].damage,player[i].target, player[i].targetanimation, player[i].currentanimation, player[i].velocity.x, player[i].velocity.y, player[i].velocity.z, player[i].targetframe, player[i].currentframe, player[i].rotation, player[i].targetrotation);
7203 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_PlayerState );
7204 //else NetworkSendPlayerMessage( chatname, kMessageType_PlayerState );
7206 sprintf (chatname, "%d %f %d %d %d %d %d %d %d %d %f",i,player[i].bloodloss, player[i].weaponactive, player[i].num_weapons, player[i].weaponids[0], player[i].weaponids[1], player[i].weaponids[2], player[i].weaponids[3],player[i].dead,player[i].skeleton.free,player[i].permanentdamage);
7208 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_PlayerStateMisc );
7209 //else NetworkSendPlayerMessage( chatname, kMessageType_PlayerStateMisc );
7211 //bigrefreshdelay=.02;
7216 if(!player[0].jumpkeydown){
7217 player[0].jumptogglekeydown=0;
7219 if(player[0].jumpkeydown&&player[0].targetanimation!=jumpupanim&&player[0].targetanimation!=jumpdownanim&&!player[0].isFlip())player[0].jumptogglekeydown=1;
7222 dialoguetime+=multiplier;
7223 skybox.cloudmove+=multiplier;
7224 hawkrotation+=multiplier*25;
7226 realhawkcoords.x=25;
7227 realhawkcoords=DoRotation(realhawkcoords,0,hawkrotation,0)+hawkcoords;
7228 hawkcalldelay-=multiplier/2;
7230 if(hawkcalldelay<=0)
7232 static float gLoc[3];
7233 static float vel[3];
7234 gLoc[0]=realhawkcoords.x;
7235 gLoc[1]=realhawkcoords.y;
7236 gLoc[2]=realhawkcoords.z;
7240 PlaySoundEx( hawksound, samp[hawksound], NULL, TRUE);
7241 FSOUND_3D_SetAttributes(channels[hawksound], gLoc, vel);
7242 FSOUND_SetVolume(channels[hawksound], 128);
7243 FSOUND_SetPaused(channels[hawksound], FALSE);
7245 hawkcalldelay=16+abs(Random()%8);
7247 static float temptexdetail;
7250 if(IsKeyDown(theKeyMap, MAC_H_KEY)&&debugmode){
7251 player[0].damagetolerance=200000;
7254 player[0].permanentdamage=0;
7255 player[0].superpermanentdamage=0;
7258 whichchar = abs(Random()%7);
7259 registrationname[whichchar]+=1;
7263 if(IsKeyDown(theKeyMap, MAC_J_KEY)&&!envtogglekeydown&&debugmode){
7265 if(environment>2)environment=0;
7266 Setenvironment(environment);
7272 if(!IsKeyDown(theKeyMap, MAC_J_KEY)){
7276 if(IsKeyDown(theKeyMap, MAC_C_KEY)&&!cameratogglekeydown&&debugmode){
7277 cameramode=1-cameramode;
7278 cameratogglekeydown=1;
7281 if(!IsKeyDown(theKeyMap, MAC_C_KEY)){
7282 cameratogglekeydown=0;
7285 if(IsKeyDown(theKeyMap, MAC_X_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!detailtogglekeydown&&debugmode){
7286 if(player[0].num_weapons>0){
7287 if(weapons.type[player[0].weaponids[0]]==sword)weapons.type[player[0].weaponids[0]]=staff;
7288 else if(weapons.type[player[0].weaponids[0]]==staff)weapons.type[player[0].weaponids[0]]=knife;
7289 else weapons.type[player[0].weaponids[0]]=sword;
7290 if(weapons.type[player[0].weaponids[0]]==sword){
7291 weapons.mass[player[0].weaponids[0]]=1.5;
7292 weapons.tipmass[player[0].weaponids[0]]=1;
7293 weapons.length[player[0].weaponids[0]]=.8;
7295 if(weapons.type[player[0].weaponids[0]]==staff){
7296 weapons.mass[player[0].weaponids[0]]=2;
7297 weapons.tipmass[player[0].weaponids[0]]=1;
7298 weapons.length[player[0].weaponids[0]]=1.5;
7301 if(weapons.type[player[0].weaponids[0]]==knife){
7302 weapons.mass[player[0].weaponids[0]]=1;
7303 weapons.tipmass[player[0].weaponids[0]]=1.2;
7304 weapons.length[player[0].weaponids[0]]=.25;
7308 /*for(i=0;i<objects.numobjects;i++){
7309 if(objects.type[i]==treeleavestype){
7310 for(j=0;j<objects.numobjects;j++){
7311 if(objects.type[j]==treetrunktype)
7312 if(findDistancefast(&objects.position[i],&objects.position[j])<.5)
7313 objects.scale[i]=objects.scale[j];
7317 detailtogglekeydown=1;
7320 if(IsKeyDown(theKeyMap, MAC_X_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!detailtogglekeydown&&debugmode){
7322 float closestdist=-1;
7325 for(i=1;i<numplayers;i++){
7326 distance=findDistancefast(&player[i].coords,&player[0].coords);
7327 if(closestdist==-1||distance<closestdist){
7328 closestdist=distance;
7333 if(player[closest].num_weapons)
7335 if(weapons.type[player[closest].weaponids[0]]==sword)weapons.type[player[closest].weaponids[0]]=staff;
7336 else if(weapons.type[player[closest].weaponids[0]]==staff)weapons.type[player[closest].weaponids[0]]=knife;
7337 else weapons.type[player[closest].weaponids[0]]=sword;
7338 if(weapons.type[player[closest].weaponids[0]]==sword){
7339 weapons.mass[player[closest].weaponids[0]]=1.5;
7340 weapons.tipmass[player[closest].weaponids[0]]=1;
7341 weapons.length[player[closest].weaponids[0]]=.8;
7343 if(weapons.type[player[0].weaponids[0]]==staff){
7344 weapons.mass[player[0].weaponids[0]]=2;
7345 weapons.tipmass[player[0].weaponids[0]]=1;
7346 weapons.length[player[0].weaponids[0]]=1.5;
7348 if(weapons.type[player[closest].weaponids[0]]==knife){
7349 weapons.mass[player[closest].weaponids[0]]=1;
7350 weapons.tipmass[player[closest].weaponids[0]]=1.2;
7351 weapons.length[player[closest].weaponids[0]]=.25;
7354 if(!player[closest].num_weapons)
7356 player[closest].weaponids[0]=weapons.numweapons;
7357 weapons.owner[weapons.numweapons]=closest;
7358 weapons.type[weapons.numweapons]=knife;
7359 weapons.damage[weapons.numweapons]=0;
7360 weapons.numweapons++;
7361 player[closest].num_weapons=1;
7362 if(weapons.type[player[closest].weaponids[0]]==sword){
7363 weapons.mass[player[closest].weaponids[0]]=1.5;
7364 weapons.tipmass[player[closest].weaponids[0]]=1;
7365 weapons.length[player[closest].weaponids[0]]=.8;
7367 if(weapons.type[player[closest].weaponids[0]]==knife){
7368 weapons.mass[player[closest].weaponids[0]]=1;
7369 weapons.tipmass[player[closest].weaponids[0]]=1.2;
7370 weapons.length[player[closest].weaponids[0]]=.25;
7374 detailtogglekeydown=1;
7377 if(IsKeyDown(theKeyMap, MAC_U_KEY)&&debugmode){
7379 float closestdist=-1;
7382 for(i=1;i<numplayers;i++){
7383 distance=findDistancefast(&player[i].coords,&player[0].coords);
7384 if(closestdist==-1||distance<closestdist){
7385 closestdist=distance;
7390 player[closest].rotation+=multiplier*50;
7391 player[closest].targetrotation=player[closest].rotation;
7395 if(IsKeyDown(theKeyMap, MAC_O_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7397 float closestdist=-1;
7400 for(i=1;i<numplayers;i++){
7401 distance=findDistancefast(&player[i].coords,&player[0].coords);
7402 if(closestdist==-1||distance<closestdist){
7403 closestdist=distance;
7407 if(IsKeyDown(theKeyMap, MAC_CONTROL_KEY))closest=0;
7410 player[closest].whichskin++;
7411 if(player[closest].whichskin>9)player[closest].whichskin=0;
7412 if(player[closest].whichskin>2&&player[closest].creature==wolftype)player[closest].whichskin=0;
7414 if(player[closest].creature==rabbittype){
7415 if(player[closest].whichskin==0){
7416 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7418 else if(player[closest].whichskin==1){
7419 LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7421 else if(player[closest].whichskin==2){
7422 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7424 else if(player[closest].whichskin==3){
7425 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7427 else if(player[closest].whichskin==4){
7428 LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7430 else if(player[closest].whichskin==5){
7431 LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7433 else if(player[closest].whichskin==6){
7434 LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7436 else if(player[closest].whichskin==7){
7437 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7439 else if(player[closest].whichskin==8){
7440 LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7442 else if(player[closest].whichskin==9){
7443 LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7446 if(player[closest].creature==wolftype){
7448 if(player[closest].whichskin==0){
7449 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7451 else if(player[closest].whichskin==1){
7452 LoadTextureSave(":Data:Textures:Darkwolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7454 else if(player[closest].whichskin==2){
7455 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7460 if(player[closest].numclothes){
7461 for(i=0;i<player[closest].numclothes;i++){
7462 tintr=player[closest].clothestintr[i];
7463 tintg=player[closest].clothestintg[i];
7464 tintb=player[closest].clothestintb[i];
7465 AddClothes((char *)player[closest].clothes[i],0,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7467 player[closest].DoMipmaps(5,0,0,player[closest].skeleton.skinsize,player[closest].skeleton.skinsize);
7470 detailtogglekeydown=1;
7473 if(IsKeyDown(theKeyMap, MAC_O_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7475 float closestdist=-1;
7478 for(i=1;i<numplayers;i++){
7479 distance=findDistancefast(&player[i].coords,&player[0].coords);
7480 if(closestdist==-1||distance<closestdist){
7481 closestdist=distance;
7486 if(player[closest].creature==wolftype){
7487 headprop=player[closest].proportionhead.x/1.1;
7488 bodyprop=player[closest].proportionbody.x/1.1;
7489 armprop=player[closest].proportionarms.x/1.1;
7490 legprop=player[closest].proportionlegs.x/1.1;
7493 if(player[closest].creature==rabbittype){
7494 headprop=player[closest].proportionhead.x/1.2;
7495 bodyprop=player[closest].proportionbody.x/1.05;
7496 armprop=player[closest].proportionarms.x/1.00;
7497 legprop=player[closest].proportionlegs.x/1.1;
7501 if(player[closest].creature==rabbittype){
7502 player[closest].skeleton.id=closest;
7503 player[closest].skeleton.Load((char *)":Data:Skeleton:Basic Figure Wolf",(char *)":Data:Skeleton:Basic Figure Wolf Low",(char *)":Data:Skeleton:Rabbitbelt",(char *)":Data:Models:Wolf.solid",(char *)":Data:Models:Wolf2.solid",(char *)":Data:Models:Wolf3.solid",(char *)":Data:Models:Wolf4.solid",(char *)":Data:Models:Wolf5.solid",(char *)":Data:Models:Wolf6.solid",(char *)":Data:Models:Wolf7.solid",(char *)":Data:Models:Wolflow.solid",(char *)":Data:Models:Belt.solid",0);
7504 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[closest],&player[closest].skeleton.skinsize);
7505 player[closest].whichskin=0;
7506 player[closest].creature=wolftype;
7508 player[closest].proportionhead=1.1;
7509 player[closest].proportionbody=1.1;
7510 player[closest].proportionarms=1.1;
7511 player[closest].proportionlegs=1.1;
7512 player[closest].proportionlegs.y=1.1;
7513 player[closest].scale=.23*5*player[0].scale;
7515 player[closest].damagetolerance=300;
7519 player[closest].skeleton.id=closest;
7520 player[closest].skeleton.Load((char *)":Data:Skeleton:Basic Figure",(char *)":Data:Skeleton:Basic Figurelow",(char *)":Data:Skeleton:Rabbitbelt",(char *)":Data:Models:Body.solid",(char *)":Data:Models:Body2.solid",(char *)":Data:Models:Body3.solid",(char *)":Data:Models:Body4.solid",(char *)":Data:Models:Body5.solid",(char *)":Data:Models:Body6.solid",(char *)":Data:Models:Body7.solid",(char *)":Data:Models:Bodylow.solid",(char *)":Data:Models:Belt.solid",1);
7521 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7522 player[closest].whichskin=0;
7523 player[closest].creature=rabbittype;
7525 player[closest].proportionhead=1.2;
7526 player[closest].proportionbody=1.05;
7527 player[closest].proportionarms=1.00;
7528 player[closest].proportionlegs=1.1;
7529 player[closest].proportionlegs.y=1.05;
7530 player[closest].scale=.2*5*player[0].scale;
7532 player[closest].damagetolerance=200;
7535 if(player[closest].creature==wolftype){
7536 player[closest].proportionhead=1.1*headprop;
7537 player[closest].proportionbody=1.1*bodyprop;
7538 player[closest].proportionarms=1.1*armprop;
7539 player[closest].proportionlegs=1.1*legprop;
7542 if(player[closest].creature==rabbittype){
7543 player[closest].proportionhead=1.2*headprop;
7544 player[closest].proportionbody=1.05*bodyprop;
7545 player[closest].proportionarms=1.00*armprop;
7546 player[closest].proportionlegs=1.1*legprop;
7547 player[closest].proportionlegs.y=1.05*legprop;
7551 detailtogglekeydown=1;
7554 if(!IsKeyDown(theKeyMap, MAC_X_KEY)){
7555 detailtogglekeydown=0;
7558 if(IsKeyDown(theKeyMap, MAC_B_KEY)&&!slomotogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7561 slomotogglekeydown=1;
7565 if(((IsKeyDown(theKeyMap, MAC_I_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY))/*||buttons[1]*/)&&!explodetogglekeydown&&debugmode){
7567 float closestdist=-1;
7569 XYZ flatfacing2,flatvelocity2;
7572 for(i=1;i<numplayers;i++){
7573 distance=findDistancefast(&player[i].coords,&player[0].coords);
7574 if(distance<144&&!player[i].headless)
7575 if(closestdist==-1||distance<closestdist){
7576 closestdist=distance;
7578 blah = player[i].coords;
7583 XYZ headspurtdirection;
7584 int i = player[closest].skeleton.jointlabels[head];
7585 for(k=0;k<player[closest].skeleton.num_joints; k++){
7586 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7587 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7588 if(!player[closest].skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(player[closest].skeleton.joints[i].position,0,0,player[closest].tilt),player[closest].tilt2,0,0),0,player[closest].rotation,0)*player[closest].scale+player[closest].coords;
7589 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7590 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7591 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7592 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7593 headspurtdirection=player[closest].skeleton.joints[player[closest].skeleton.jointlabels[head]].position-player[closest].skeleton.joints[player[closest].skeleton.jointlabels[neck]].position;
7594 Normalise(&headspurtdirection);
7595 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, .6, 1);
7596 flatvelocity2+=headspurtdirection*8;
7597 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2/2, 1,1,1, .16, 1);
7599 sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
7609 PlaySoundEx( splattersound, samp[splattersound], NULL, TRUE);
7610 FSOUND_3D_SetAttributes(channels[splattersound], gLoc, vel);
7611 FSOUND_SetVolume(channels[splattersound], 256);
7612 FSOUND_SetPaused(channels[splattersound], FALSE);
7614 PlaySoundEx( breaksound2, samp[breaksound2], NULL, TRUE);
7615 FSOUND_3D_SetAttributes(channels[breaksound2], gLoc, vel);
7616 FSOUND_SetVolume(channels[breaksound2], 100);
7617 FSOUND_SetPaused(channels[breaksound2], FALSE);
7619 if(player[closest].skeleton.free==2)player[closest].skeleton.free=0;
7620 player[closest].RagDoll(0);
7621 player[closest].dead=2;
7622 player[closest].headless=1;
7623 player[closest].DoBloodBig(3,165);
7628 explodetogglekeydown=1;
7631 if(((IsKeyDown(theKeyMap, MAC_I_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY))/*||buttons[2]*/)&&!explodetogglekeydown&&debugmode){
7633 float closestdist=-1;
7635 XYZ flatfacing2,flatvelocity2;
7638 for(i=1;i<numplayers;i++){
7639 distance=findDistancefast(&player[i].coords,&player[0].coords);
7641 if(closestdist==-1||distance<closestdist){
7642 closestdist=distance;
7644 blah=player[i].coords;
7658 PlaySoundEx( splattersound, samp[splattersound], NULL, TRUE);
7659 FSOUND_3D_SetAttributes(channels[splattersound], gLoc, vel);
7660 FSOUND_SetVolume(channels[splattersound], 256);
7661 FSOUND_SetPaused(channels[splattersound], FALSE);
7663 PlaySoundEx( breaksound2, samp[breaksound2], NULL, TRUE);
7664 FSOUND_3D_SetAttributes(channels[breaksound2], gLoc, vel);
7665 FSOUND_SetVolume(channels[breaksound2], 600);
7666 FSOUND_SetPaused(channels[breaksound2], FALSE);
7668 for(i=0;i<player[closest].skeleton.num_joints; i++){
7669 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7670 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7671 if(!player[closest].skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(player[closest].skeleton.joints[i].position,0,0,player[closest].tilt),player[closest].tilt2,0,0),0,player[closest].rotation,0)*player[closest].scale+player[closest].coords;
7672 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7673 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7674 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7675 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7676 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
7677 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .3, 1);
7678 sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
7681 for(i=0;i<player[closest].skeleton.num_joints; i++){
7682 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7683 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7684 if(!player[closest].skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(player[closest].skeleton.joints[i].position,0,0,player[closest].tilt),player[closest].tilt2,0,0),0,player[closest].rotation,0)*player[closest].scale+player[closest].coords;
7685 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7686 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7687 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7688 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7689 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
7690 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
7693 for(i=0;i<player[closest].skeleton.num_joints; i++){
7694 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7695 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7696 if(!player[closest].skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(player[closest].skeleton.joints[i].position,0,0,player[closest].tilt),player[closest].tilt2,0,0),0,player[closest].rotation,0)*player[closest].scale+player[closest].coords;
7697 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7698 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7699 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7700 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7701 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
7702 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
7705 for(i=0;i<player[closest].skeleton.num_joints; i++){
7706 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7707 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7708 if(!player[closest].skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(player[closest].skeleton.joints[i].position,0,0,player[closest].tilt),player[closest].tilt2,0,0),0,player[closest].rotation,0)*player[closest].scale+player[closest].coords;
7709 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7710 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7711 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7712 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7713 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
7714 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
7718 for(j=0;j<numplayers; j++){
7720 if(findDistancefast(&player[j].coords,&player[closest].coords)<25){
7721 player[j].DoDamage((25-findDistancefast(&player[j].coords,&player[closest].coords))*60);
7722 if(player[j].skeleton.free==2)player[j].skeleton.free=1;
7723 player[j].skeleton.longdead=0;
7724 player[j].RagDoll(0);
7725 for(i=0;i<player[j].skeleton.num_joints; i++){
7726 temppos=player[j].skeleton.joints[i].position+player[j].coords;
7727 if(findDistancefast(&temppos,&player[closest].coords)<25){
7728 flatvelocity2=temppos-player[closest].coords;
7729 Normalise(&flatvelocity2);
7730 player[j].skeleton.joints[i].velocity+=flatvelocity2*((20-findDistancefast(&temppos,&player[closest].coords))*20);
7737 player[closest].DoDamage(10000);
7738 player[closest].RagDoll(0);
7739 player[closest].dead=2;
7740 player[closest].coords=20;
7741 player[closest].skeleton.free=2;
7747 explodetogglekeydown=1;
7750 if(!IsKeyDown(theKeyMap, MAC_I_KEY)){
7751 explodetogglekeydown=0;
7755 if(IsKeyDown(theKeyMap, MAC_S_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)&&!slomotogglekeydown){
7757 //tfile=fopen( ":Data:Maps:mapsave", "wb" );
7758 if(whichlevel==0)tfile=fopen( ":Data:Maps:map1", "wb" );
7759 else if(whichlevel==1)tfile=fopen( ":Data:Maps:map2", "wb" );
7760 else if(whichlevel==2)tfile=fopen( ":Data:Maps:map3", "wb" );
7761 else if(whichlevel==3)tfile=fopen( ":Data:Maps:map4", "wb" );
7762 else if(whichlevel==4)tfile=fopen( ":Data:Maps:map5", "wb" );
7763 else tfile=fopen( ":Data:Maps:mapsave", "wb" );
7765 fwrite( &player[0].coords, 1, sizeof(XYZ), tfile );
7766 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
7767 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
7768 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
7769 for(j=0;j<player[0].num_weapons;j++){
7770 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
7772 fwrite( &environment, 1, sizeof(int), tfile );
7774 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
7775 fwrite( &objects.type, 1, sizeof(int)*objects.numobjects, tfile );
7776 fwrite( &objects.rotation, 1, sizeof(float)*objects.numobjects, tfile );
7777 fwrite( &objects.position, 1, sizeof(XYZ)*objects.numobjects, tfile );
7778 fwrite( &objects.scale, 1, sizeof(float)*objects.numobjects, tfile );
7780 fwrite( &numplayers, 1, sizeof(int), tfile );
7781 if(numplayers>1&&numplayers<maxplayers)
7782 for(i=1;i<numplayers;i++){
7783 fwrite( &player[i].coords, 1, sizeof(XYZ), tfile );
7784 fwrite( &player[i].num_weapons, 1, sizeof(int), tfile );
7785 for(j=0;j<player[i].num_weapons;j++){
7786 fwrite( &weapons.type[player[i].weaponids[j]], 1, sizeof(int), tfile );
7788 if(player[i].numwaypoints<30){
7789 fwrite( &player[i].numwaypoints, 1, sizeof(int), tfile );
7790 fwrite( &player[i].waypoints, 1, sizeof(XYZ)*player[i].numwaypoints, tfile );
7791 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7792 //fwrite( &player[i].jumppath, 1, sizeof(bool), tfile );
7795 player[i].numwaypoints=0;
7796 player[i].waypoint=0;
7797 fwrite( &player[i].numwaypoints, 1, sizeof(int), tfile );
7798 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7799 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7805 slomotogglekeydown=1;
7808 if(!IsKeyDown(theKeyMap, MAC_B_KEY)&&!IsKeyDown(theKeyMap, MAC_F_KEY)&&!IsKeyDown(theKeyMap, MAC_K_KEY)&&!IsKeyDown(theKeyMap, MAC_S_KEY)){
7809 slomotogglekeydown=0;
7813 if(IsKeyDown(theKeyMap, MAC_F_KEY)&&!slomotogglekeydown&&debugmode){
7814 player[0].onfire=1-player[0].onfire;
7815 if(player[0].onfire){
7816 player[0].CatchFire();
7818 if(!player[0].onfire){
7821 gLoc[0]=player[0].coords.x;
7822 gLoc[1]=player[0].coords.y;
7823 gLoc[2]=player[0].coords.z;
7827 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
7828 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
7829 FSOUND_SetVolume(channels[fireendsound], 256);
7830 FSOUND_SetPaused(channels[fireendsound], FALSE);
7831 FSOUND_SetPaused(channels[stream_firesound], TRUE);
7833 slomotogglekeydown=1;
7836 if(IsKeyDown(theKeyMap, MAC_L_KEY)){
7837 if(player[0].bleeding<=0)
7838 player[0].DoBlood(1,255);
7842 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)){
7844 float closestdist=-1;
7847 for(i=1;i<numplayers;i++){
7848 distance=findDistancefast(&player[i].coords,&player[0].coords);
7849 if(closestdist==-1||distance<closestdist){
7850 closestdist=distance;
7854 if(closestdist>0&&closest>=0){
7855 //player[closest]=player[numplayers-1];
7856 //player[closest].skeleton=player[numplayers-1].skeleton;
7859 drawmodetogglekeydown=1;
7862 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7864 float closestdist=-1;
7867 for(i=1;i<max_objects;i++){
7868 distance=findDistancefast(&objects.position[i],&player[0].coords);
7869 if(closestdist==-1||distance<closestdist){
7870 closestdist=distance;
7874 if(closestdist>0&&closest>=0){
7875 objects.position[closest].y-=500;
7877 drawmodetogglekeydown=1;
7880 if(IsKeyDown(theKeyMap, MAC_M_KEY)&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&editorenabled&&debugmode){
7882 //if(drawmode>2)drawmode=0;
7883 if(objects.numobjects<max_objects-1){
7885 boxcoords.x=player[0].coords.x;
7886 boxcoords.z=player[0].coords.z;
7887 boxcoords.y=player[0].coords.y-3;
7888 if(editortype==bushtype)boxcoords.y=player[0].coords.y-.5;
7889 if(editortype==firetype)boxcoords.y=player[0].coords.y-.5;
7890 //objects.MakeObject(abs(Random()%3),boxcoords,Random()%360);
7891 float temprotat,temprotat2;
7892 temprotat=editorrotation;
7893 temprotat2=editorrotation2;
7894 if(temprotat<0||editortype==bushtype)temprotat=Random()%360;
7895 if(temprotat2<0)temprotat2=Random()%360;
7897 objects.MakeObject(editortype,boxcoords,(int)temprotat-((int)temprotat)%30,(int)temprotat2,editorsize);
7898 if(editortype==treetrunktype)
7899 objects.MakeObject(treeleavestype,boxcoords,Random()%360*(temprotat2<2)+(int)editorrotation-((int)editorrotation)%30,editorrotation2,editorsize);
7902 drawmodetogglekeydown=1;
7905 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&editorenabled){
7906 if(numplayers<maxplayers-1){
7907 player[numplayers].scale=.2*5*player[0].scale;
7908 player[numplayers].creature=rabbittype;
7909 player[numplayers].howactive=editoractive;
7910 player[numplayers].skeleton.id=numplayers;
7911 player[numplayers].skeleton.Load((char *)":Data:Skeleton:Basic Figure",(char *)":Data:Skeleton:Basic Figurelow",(char *)":Data:Skeleton:Rabbitbelt",(char *)":Data:Models:Body.solid",(char *)":Data:Models:Body2.solid",(char *)":Data:Models:Body3.solid",(char *)":Data:Models:Body4.solid",(char *)":Data:Models:Body5.solid",(char *)":Data:Models:Body6.solid",(char *)":Data:Models:Body7.solid",(char *)":Data:Models:Bodylow.solid",(char *)":Data:Models:Belt.solid",1);
7913 //texsize=512*512*3/texdetail/texdetail;
7914 //if(!player[numplayers].loaded)player[numplayers].skeleton.skinText = new GLubyte[texsize];
7915 //player[numplayers].skeleton.skinText.resize(texsize);
7917 k=abs(Random()%2)+1;
7919 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7920 player[numplayers].whichskin=0;
7923 LoadTextureSave(":Data:Textures:Fur.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7924 player[numplayers].whichskin=1;
7927 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7928 player[numplayers].whichskin=2;
7931 LoadTexture(":Data:Textures:Belt.png",&player[numplayers].skeleton.drawmodelclothes.textureptr,1,1);
7932 player[numplayers].power=1;
7933 player[numplayers].speedmult=1;
7934 player[numplayers].currentanimation=bounceidleanim;
7935 player[numplayers].targetanimation=bounceidleanim;
7936 player[numplayers].currentframe=0;
7937 player[numplayers].targetframe=1;
7938 player[numplayers].target=0;
7939 player[numplayers].bled=0;
7940 player[numplayers].speed=1+(float)(Random()%100)/1000;
7942 player[numplayers].targetrotation=player[0].targetrotation;
7943 player[numplayers].rotation=player[0].rotation;
7945 player[numplayers].velocity=0;
7946 player[numplayers].coords=player[0].coords;
7947 player[numplayers].oldcoords=player[numplayers].coords;
7948 player[numplayers].realoldcoords=player[numplayers].coords;
7950 player[numplayers].id=numplayers;
7951 player[numplayers].skeleton.id=numplayers;
7952 player[numplayers].updatedelay=0;
7953 player[numplayers].normalsupdatedelay=0;
7955 player[numplayers].aitype=passivetype;
7956 player[numplayers].aitarget=0;
7958 if(player[0].creature==wolftype){
7959 headprop=player[0].proportionhead.x/1.1;
7960 bodyprop=player[0].proportionbody.x/1.1;
7961 armprop=player[0].proportionarms.x/1.1;
7962 legprop=player[0].proportionlegs.x/1.1;
7965 if(player[0].creature==rabbittype){
7966 headprop=player[0].proportionhead.x/1.2;
7967 bodyprop=player[0].proportionbody.x/1.05;
7968 armprop=player[0].proportionarms.x/1.00;
7969 legprop=player[0].proportionlegs.x/1.1;
7972 if(player[numplayers].creature==wolftype){
7973 player[numplayers].proportionhead=1.1*headprop;
7974 player[numplayers].proportionbody=1.1*bodyprop;
7975 player[numplayers].proportionarms=1.1*armprop;
7976 player[numplayers].proportionlegs=1.1*legprop;
7979 if(player[numplayers].creature==rabbittype){
7980 player[numplayers].proportionhead=1.2*headprop;
7981 player[numplayers].proportionbody=1.05*bodyprop;
7982 player[numplayers].proportionarms=1.00*armprop;
7983 player[numplayers].proportionlegs=1.1*legprop;
7984 player[numplayers].proportionlegs.y=1.05*legprop;
7987 player[numplayers].headless=0;
7988 player[numplayers].onfire=0;
7991 player[numplayers].proportionhead.z=0;
7992 player[numplayers].proportionbody.z=0;
7993 player[numplayers].proportionarms.z=0;
7994 player[numplayers].proportionlegs.z=0;
7997 player[numplayers].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0);
7999 player[numplayers].damagetolerance=200;
8001 player[numplayers].protectionhead=player[0].protectionhead;
8002 player[numplayers].protectionhigh=player[0].protectionhigh;
8003 player[numplayers].protectionlow=player[0].protectionlow;
8004 player[numplayers].armorhead=player[0].armorhead;
8005 player[numplayers].armorhigh=player[0].armorhigh;
8006 player[numplayers].armorlow=player[0].armorlow;
8007 player[numplayers].metalhead=player[0].metalhead;
8008 player[numplayers].metalhigh=player[0].metalhigh;
8009 player[numplayers].metallow=player[0].metallow;
8011 player[numplayers].immobile=player[0].immobile;
8013 player[numplayers].numclothes=player[0].numclothes;
8014 if(player[numplayers].numclothes)
8015 for(i=0;i<player[numplayers].numclothes;i++){
8016 strcpy(player[numplayers].clothes[i], player[0].clothes[i]);
8017 player[numplayers].clothestintr[i]=player[0].clothestintr[i];
8018 player[numplayers].clothestintg[i]=player[0].clothestintg[i];
8019 player[numplayers].clothestintb[i]=player[0].clothestintb[i];
8020 tintr=player[numplayers].clothestintr[i];
8021 tintg=player[numplayers].clothestintg[i];
8022 tintb=player[numplayers].clothestintb[i];
8023 AddClothes((char *)player[numplayers].clothes[i],0,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
8025 if(player[numplayers].numclothes){
8026 player[numplayers].DoMipmaps(5,0,0,player[numplayers].skeleton.skinsize,player[numplayers].skeleton.skinsize);
8029 player[numplayers].power=player[0].power;
8030 player[numplayers].speedmult=player[0].speedmult;
8032 player[numplayers].damage=0;
8033 player[numplayers].permanentdamage=0;
8034 player[numplayers].superpermanentdamage=0;
8035 player[numplayers].deathbleeding=0;
8036 player[numplayers].bleeding=0;
8037 player[numplayers].numwaypoints=0;
8038 player[numplayers].waypoint=0;
8039 player[numplayers].jumppath=0;
8040 player[numplayers].weaponstuck=-1;
8041 player[numplayers].weaponactive=-1;
8042 player[numplayers].num_weapons=0;
8043 player[numplayers].bloodloss=0;
8044 player[numplayers].dead=0;
8046 player[numplayers].loaded=1;
8050 drawmodetogglekeydown=1;
8053 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&editorenabled){
8054 if(player[numplayers-1].numwaypoints<90){
8055 player[numplayers-1].waypoints[player[numplayers-1].numwaypoints]=player[0].coords;
8056 player[numplayers-1].waypointtype[player[numplayers-1].numwaypoints]=editorpathtype;
8057 player[numplayers-1].numwaypoints++;
8059 drawmodetogglekeydown=1;
8062 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&editorenabled){
8063 if(numpathpoints<30){
8064 bool connected,alreadyconnected;
8067 for(i=0;i<numpathpoints;i++){
8068 if(findDistancefast(&pathpoint[i],&player[0].coords)<.5&&i!=pathpointselected&&!connected){
8070 for(j=0;j<numpathpointconnect[pathpointselected];j++){
8071 if(pathpointconnect[pathpointselected][j]==i)alreadyconnected=1;
8073 if(!alreadyconnected){
8074 numpathpointconnect[pathpointselected]++;
8076 pathpointconnect[pathpointselected][numpathpointconnect[pathpointselected]-1]=i;
8082 pathpoint[numpathpoints-1]=player[0].coords;
8083 numpathpointconnect[numpathpoints-1]=0;
8084 if(numpathpoints>1&&pathpointselected!=-1){
8085 numpathpointconnect[pathpointselected]++;
8086 pathpointconnect[pathpointselected][numpathpointconnect[pathpointselected]-1]=numpathpoints-1;
8088 pathpointselected=numpathpoints-1;
8091 drawmodetogglekeydown=1;
8094 if(IsKeyDown(theKeyMap, MAC_PERIOD_KEY)&&!drawmodetogglekeydown&&editorenabled){
8095 pathpointselected++;
8096 if(pathpointselected>=numpathpoints)pathpointselected=-1;
8097 drawmodetogglekeydown=1;
8099 if(IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!drawmodetogglekeydown&&editorenabled){
8100 pathpointselected--;
8101 if(pathpointselected<=-2)pathpointselected=numpathpoints-1;
8102 drawmodetogglekeydown=1;
8104 if(IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!drawmodetogglekeydown&&editorenabled){
8105 if(pathpointselected!=-1){
8107 pathpoint[pathpointselected]=pathpoint[numpathpoints];
8108 numpathpointconnect[pathpointselected]=numpathpointconnect[numpathpoints];
8109 for(i=0;i<numpathpointconnect[pathpointselected];i++){
8110 pathpointconnect[pathpointselected][i]=pathpointconnect[numpathpoints][i];
8112 for(i=0;i<numpathpoints;i++){
8113 for(j=0;j<numpathpointconnect[i];j++){
8114 if(pathpointconnect[i][j]==pathpointselected){
8115 pathpointconnect[i][j]=pathpointconnect[i][numpathpointconnect[i]-1];
8116 numpathpointconnect[i]--;
8118 if(pathpointconnect[i][j]==numpathpoints){
8119 pathpointconnect[i][j]=pathpointselected;
8123 pathpointselected=numpathpoints-1;
8125 drawmodetogglekeydown=1;
8128 if(IsKeyDown(theKeyMap, MAC_M_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
8129 editorenabled=1-editorenabled;
8131 player[0].damagetolerance=100000;
8133 player[0].superpermanentdamage=0;
8134 player[0].bloodloss=0;
8135 player[0].deathbleeding=0;
8138 player[0].damagetolerance=200;
8140 player[0].permanentdamage=0;
8141 player[0].superpermanentdamage=0;
8142 player[0].bloodloss=0;
8143 player[0].deathbleeding=0;
8145 drawmodetogglekeydown=1;
8148 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8150 if(editortype==treeleavestype||editortype==10)editortype--;
8151 if(editortype<0)editortype=firetype;
8152 drawmodetogglekeydown=1;
8155 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8157 if(editortype==treeleavestype||editortype==10)editortype++;
8158 if(editortype>firetype)editortype=0;
8159 drawmodetogglekeydown=1;
8162 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8163 editorrotation-=multiplier*100;
8164 if(editorrotation<-.01)editorrotation=-.01;
8165 drawmodetogglekeydown=1;
8168 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8169 editorrotation+=multiplier*100;
8170 drawmodetogglekeydown=1;
8173 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8174 editorsize+=multiplier;
8175 drawmodetogglekeydown=1;
8178 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8179 editorsize-=multiplier;
8180 if(editorsize<.1)editorsize=.1;
8181 drawmodetogglekeydown=1;
8185 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8186 mapradius-=multiplier*10;
8189 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8190 mapradius+=multiplier*10;
8193 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8194 mapcenter.x+=multiplier*20;
8197 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8198 mapcenter.x-=multiplier*20;
8201 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8202 mapcenter.z+=multiplier*20;
8205 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8206 mapcenter.z-=multiplier*20;
8209 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8210 editorrotation2+=multiplier*100;
8213 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8214 editorrotation2-=multiplier*100;
8215 if(editorrotation2<-.01)editorrotation2=-.01;
8217 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&objects.numobjects&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)){
8219 float closestdist=-1;
8221 for(i=0;i<objects.numobjects;i++){
8222 distance=findDistancefast(&objects.position[i],&player[0].coords);
8223 if(closestdist==-1||distance<closestdist){
8224 closestdist=distance;
8228 if(closestdist>0&&closest>=0)objects.DeleteObject(closest);
8229 drawmodetogglekeydown=1;
8233 if(!IsKeyDown(theKeyMap, MAC_M_KEY)&&!IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&!IsKeyDown(theKeyMap, MAC_PERIOD_KEY)&&!IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&!IsKeyDown(theKeyMap, MAC_P_KEY)){
8234 drawmodetogglekeydown=0;
8237 if(IsKeyDown(theKeyMap, MAC_N_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&!texturesizetogglekeydown&&debugmode){
8238 //if(!player[0].skeleton.free)player[0].damage+=500;
8239 player[0].RagDoll(0);
8240 //player[0].spurt=1;
8241 //player[0].DoDamage(1000);
8245 gLoc[0]=player[0].coords.x;
8246 gLoc[1]=player[0].coords.y;
8247 gLoc[2]=player[0].coords.z;
8248 vel[0]=player[0].velocity.x;
8249 vel[1]=player[0].velocity.y;
8250 vel[2]=player[0].velocity.z;
8251 PlaySoundEx( whooshsound, samp[whooshsound], NULL, TRUE);
8252 FSOUND_3D_SetAttributes(channels[whooshsound], gLoc, vel);
8253 FSOUND_SetVolume(channels[whooshsound], 128);
8254 FSOUND_SetPaused(channels[whooshsound], FALSE);
8255 //FSOUND_SetPaused(channels[whooshsound], TRUE);
8257 texturesizetogglekeydown=1;
8260 if(IsKeyDown(theKeyMap, MAC_N_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&!texturesizetogglekeydown&&debugmode){
8263 float closestdist=-1;
8265 for(i=0;i<objects.numobjects;i++){
8266 if(objects.type[i]==treeleavestype){
8267 objects.scale[i]*=.9;
8270 texturesizetogglekeydown=1;
8273 static XYZ relative;
8274 static int randattack;
8276 static bool playerrealattackkeydown=0;
8278 if(!buttons[0])oldbutton=0;
8279 if(!IsKeyDown(theKeyMap, attackkey))oldattackkey=0;
8280 if(oldattackkey)player[0].attackkeydown=0;
8281 if(oldattackkey)playerrealattackkeydown=0;
8282 if(!oldattackkey)playerrealattackkeydown=IsKeyDown(theKeyMap, attackkey);
8283 if((player[0].parriedrecently<=0||player[0].weaponactive==-1)&&(!oldattackkey||(realthreat&&player[0].lastattack!=swordslashanim&&player[0].lastattack!=knifeslashstartanim&&player[0].lastattack!=staffhitanim&&player[0].lastattack!=staffspinhitanim)))player[0].attackkeydown=IsKeyDown(theKeyMap, attackkey);
8284 if(IsKeyDown(theKeyMap, attackkey)&&!oldattackkey&&!player[0].backkeydown){
8285 for(k=0;k<numplayers;k++){
8286 if((player[k].targetanimation==swordslashanim||player[k].targetanimation==staffhitanim||player[k].targetanimation==staffspinhitanim)&&player[0].currentanimation!=dodgebackanim&&!player[k].skeleton.free)
8287 player[k].Reverse();
8291 if(!hostile||indialogue!=-1)player[0].attackkeydown=0;
8293 for(k=0;k<numplayers;k++){
8294 if(indialogue!=-1)player[k].attackkeydown=0;
8295 if(player[k].targetanimation!=rabbitrunninganim&&player[k].targetanimation!=wolfrunninganim){
8296 if(player[k].aitype!=playercontrolled)player[k].victim=&player[0];
8297 if(player[k].attackkeydown&&player[k].jumppower<=1&&player[k].backkeydown&&player[k].targetanimation!=backhandspringanim&&(player[k].isIdle()||player[k].isStop()||player[k].isRun()||player[k].targetanimation==walkanim)){
8298 player[k].jumppower-=2;
8300 if(player[k].attackkeydown&&player[k].jumppower>1&&player[k].backkeydown&&player[k].targetanimation!=backhandspringanim&&(player[k].isIdle()||player[k].isStop()||player[k].isRun()||player[k].targetanimation==walkanim)){
8301 for(i=0;i<numplayers;i++){
8303 if(player[i].targetanimation==swordslashanim||player[i].targetanimation==knifeslashstartanim||player[i].targetanimation==staffhitanim||player[i].targetanimation==staffspinhitanim)
8304 if(findDistancefast(&player[k].coords,&player[i].coords)<6.5&&!player[i].skeleton.free){
8305 player[k].targetanimation=dodgebackanim;
8307 player[k].targetframe=0;
8308 rotatetarget=player[i].coords-player[k].coords;
8309 Normalise(&rotatetarget);
8310 player[k].targetrotation=-asin(0-rotatetarget.x);
8311 player[k].targetrotation*=360/6.28;
8312 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8314 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;
8317 if(player[k].targetanimation!=dodgebackanim){
8318 if(k==0)numflipped++;
8319 player[k].targetanimation=backhandspringanim;
8321 player[k].targetframe=0;
8322 player[k].targetrotation=-rotation+180;
8323 if(player[k].leftkeydown)player[k].targetrotation-=45;
8324 if(player[k].rightkeydown)player[k].targetrotation+=45;
8325 player[k].rotation=player[k].targetrotation;
8326 player[k].jumppower-=2;
8329 if(player[k].attackkeydown&&!animation[player[k].targetanimation].attack&&!player[k].backkeydown&&(player[k].isIdle()||player[k].isRun()||player[k].targetanimation==walkanim||player[k].targetanimation==sneakanim||player[k].isCrouch())){
8330 player[k].hasvictim=0;
8332 for(i=0;i<numplayers;i++){
8334 if(!player[k].hasvictim)
8335 if((k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack!=reversal){
8336 if(findDistancefast(&player[k].coords,&player[i].coords)<4.5&&!player[i].skeleton.free&&player[i].howactive<typedead1&&player[i].targetanimation!=jumpreversedanim&&player[i].targetanimation!=rabbitkickreversedanim&&player[i].targetanimation!=rabbitkickanim&&player[k].targetanimation!=rabbitkickanim&&player[i].targetanimation!=getupfrombackanim&&(player[i].targetanimation!=staggerbackhighanim&&(player[i].targetanimation!=staggerbackhardanim||animation[staggerbackhardanim].label[player[i].targetframe]==6))&&player[i].targetanimation!=jumpdownanim&&player[i].targetanimation!=jumpupanim&&player[i].targetanimation!=getupfromfrontanim){
8337 player[k].victim=&player[i];
8338 player[k].hasvictim=1;
8339 if(player[k].aitype==playercontrolled){
8340 if(findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)&&player[k].crouchkeydown&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=sweepanim;
8341 else if(findDistancefast(&player[k].coords,&player[i].coords)<1.5*(player[k].scale*5)*(player[k].scale*5)&&animation[player[i].targetanimation].height!=lowheight&&!player[k].forwardkeydown&&!player[k].leftkeydown&&!player[k].rightkeydown&&!player[k].crouchkeydown&&player[k].weaponactive==-1&&!reversaltrain)player[k].targetanimation=winduppunchanim;
8342 else if(findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)&&animation[player[i].targetanimation].height!=lowheight&&!player[k].forwardkeydown&&!player[k].leftkeydown&&!player[k].rightkeydown&&!player[k].crouchkeydown&&player[k].weaponactive==-1)player[k].targetanimation=upunchanim;
8343 else if(findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)&&player[k].weaponactive!=-1&&player[i].staggerdelay>0&&weapons.type[player[k].weaponids[player[k].weaponactive]]==knife&&player[i].bloodloss>player[i].damagetolerance/2)player[k].targetanimation=knifefollowanim;
8344 else if(findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)&&animation[player[i].targetanimation].height!=lowheight&&!player[k].forwardkeydown&&!player[k].leftkeydown&&!player[k].rightkeydown&&!player[k].crouchkeydown&&player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==knife&&player[k].weaponmissdelay<=0)player[k].targetanimation=knifeslashstartanim;
8345 else if(findDistancefast(&player[k].coords,&player[i].coords)<4.5*(player[k].scale*5)*(player[k].scale*5)&&animation[player[i].targetanimation].height!=lowheight&&!player[k].crouchkeydown&&player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==sword&&player[k].weaponmissdelay<=0)player[k].targetanimation=swordslashanim;
8346 else if(findDistancefast(&player[k].coords,&player[i].coords)<4.5*(player[k].scale*5)*(player[k].scale*5)&&animation[player[i].targetanimation].height!=lowheight&&!player[k].crouchkeydown&&player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==staff&&player[k].weaponmissdelay<=0&&!player[k].leftkeydown&&!player[k].rightkeydown&&!player[k].forwardkeydown)player[k].targetanimation=staffhitanim;
8347 else if(findDistancefast(&player[k].coords,&player[i].coords)<4.5*(player[k].scale*5)*(player[k].scale*5)&&animation[player[i].targetanimation].height!=lowheight&&!player[k].crouchkeydown&&player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==staff&&player[k].weaponmissdelay<=0)player[k].targetanimation=staffspinhitanim;
8348 else if(findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=spinkickanim;
8349 else if(findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)&&animation[player[i].targetanimation].height==lowheight&&animation[player[k].targetanimation].attack!=normalattack)player[k].targetanimation=lowkickanim;
8352 if(findDistancefast(&player[k].coords,&player[i].coords)<4.5*(player[k].scale*5)*(player[k].scale*5)){
8353 if(player[k].weaponactive==-1)randattack=abs(Random()%5);
8354 else randattack=abs(Random()%5);
8355 if(player[k].weaponactive==-1&&findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)){
8356 if(randattack==0&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=sweepanim;
8357 else if(randattack==1&&animation[player[i].targetanimation].height!=lowheight&&player[k].weaponactive==-1)player[k].targetanimation=upunchanim;
8358 else if(randattack==2&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=spinkickanim;
8359 else if(animation[player[i].targetanimation].height==lowheight)player[k].targetanimation=lowkickanim;
8361 if(player[k].weaponactive!=-1){
8362 if((tutoriallevel!=1||player[k].weaponactive==-1)&&findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)&&randattack==0&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=sweepanim;
8363 else if(findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)/*&&animation[player[i].targetanimation].height!=lowheight*/&&weapons.type[player[k].weaponids[player[k].weaponactive]]==knife&&player[k].weaponmissdelay<=0)player[k].targetanimation=knifeslashstartanim;
8364 //else if(findDistancefast(&player[k].coords,&player[i].coords)<2.5&&player[k].weaponactive!=-1&&player[i].staggerdelay>0&&weapons.type[player[k].weaponids[player[k].weaponactive]]==knife)player[k].targetanimation=knifefollowanim;
8365 else if(!(player[0].victim==&player[i]&&player[0].hasvictim&&player[0].targetanimation==swordslashanim)&&weapons.type[player[k].weaponids[player[k].weaponactive]]==sword&&player[k].weaponmissdelay<=0)player[k].targetanimation=swordslashanim;
8366 else if(!(player[0].victim==&player[i]&&player[0].hasvictim&&player[0].targetanimation==swordslashanim)&&weapons.type[player[k].weaponids[player[k].weaponactive]]==staff&&player[k].weaponmissdelay<=0&&randattack<3)player[k].targetanimation=staffhitanim;
8367 else if(!(player[0].victim==&player[i]&&player[0].hasvictim&&player[0].targetanimation==swordslashanim)&&weapons.type[player[k].weaponids[player[k].weaponactive]]==staff&&player[k].weaponmissdelay<=0&&randattack>=3)player[k].targetanimation=staffspinhitanim;
8368 else if((tutoriallevel!=1||player[k].weaponactive==-1)&&findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)&&randattack==1&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=spinkickanim;
8369 else if(findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)&&animation[player[i].targetanimation].height==lowheight&&animation[player[k].targetanimation].attack!=normalattack)player[k].targetanimation=lowkickanim;
8373 if(player[k].targetanimation==upunchanim&&player[k].creature==wolftype)player[k].targetanimation=wolfslapanim;
8375 if((tutoriallevel!=1||tutorialstage==22)&&player[i].howactive<typedead1&&findDistancefast(&player[k].coords,&player[i].coords)<1.5*(player[k].scale*5)*(player[k].scale*5)&&!player[i].skeleton.free&&player[i].targetanimation!=getupfrombackanim&&player[i].targetanimation!=getupfromfrontanim&&(((player[i].stunned>0&&player[k].madskills)||(player[i].surprised>0)||player[i].aitype==passivetype)||(player[k].weaponactive!=-1&&player[i].stunned>0))&&normaldotproduct(player[i].facing,player[i].coords-player[k].coords)>0&&(k==0)){
8376 if(player[k].weaponactive==-1){
8377 player[i].targetanimation=sneakattackedanim;
8378 player[i].currentanimation=sneakattackedanim;
8379 player[k].currentanimation=sneakattackanim;
8380 player[k].targetanimation=sneakattackanim;
8381 player[k].oldcoords=player[k].coords;
8382 player[k].coords=player[i].coords;
8384 if(player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==knife){
8385 player[i].targetanimation=knifesneakattackedanim;
8386 player[i].currentanimation=knifesneakattackedanim;
8387 player[k].currentanimation=knifesneakattackanim;
8388 player[k].targetanimation=knifesneakattackanim;
8389 player[i].oldcoords=player[i].coords;
8390 player[i].coords=player[k].coords;
8392 if(player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==sword){
8393 player[i].targetanimation=swordsneakattackedanim;
8394 player[i].currentanimation=swordsneakattackedanim;
8395 player[k].currentanimation=swordsneakattackanim;
8396 player[k].targetanimation=swordsneakattackanim;
8397 player[i].oldcoords=player[i].coords;
8398 player[i].coords=player[k].coords;
8400 if(player[k].weaponactive==-1||weapons.type[player[k].weaponids[player[k].weaponactive]]!=staff){
8401 player[k].victim=&player[i];
8402 player[k].hasvictim=1;
8403 player[i].targettilt2=0;
8404 player[i].targetframe=1;
8405 player[i].currentframe=0;
8407 player[i].velocity=0;
8408 player[k].targettilt2=player[i].targettilt2;
8409 player[k].currentframe=player[i].currentframe;
8410 player[k].targetframe=player[i].targetframe;
8411 player[k].target=player[i].target;
8412 player[k].velocity=0;
8413 player[k].targetrotation=player[i].rotation;
8414 player[k].rotation=player[i].rotation;
8415 player[i].targetrotation=player[i].rotation;
8418 if(animation[player[k].targetanimation].attack==normalattack&&player[k].victim==&player[i]&&(!player[i].skeleton.free)){
8420 player[k].targetframe=0;
8422 //player[k].velocity=0;
8424 rotatetarget=player[i].coords-player[k].coords;
8425 Normalise(&rotatetarget);
8426 player[k].targetrotation=-asin(0-rotatetarget.x);
8427 player[k].targetrotation*=360/6.28;
8428 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8430 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8432 player[k].lastattack3=player[k].lastattack2;
8433 player[k].lastattack2=player[k].lastattack;
8434 player[k].lastattack=player[k].targetanimation;
8435 //player[k].targettilt2=0;
8439 if(player[k].targetanimation==knifefollowanim&&player[k].victim==&player[i]){
8440 rotatetarget=player[i].coords-player[k].coords;
8441 Normalise(&rotatetarget);
8442 player[k].targetrotation=-asin(0-rotatetarget.x);
8443 player[k].targetrotation*=360/6.28;
8444 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8445 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8447 player[k].victim=&player[i];
8448 player[k].hasvictim=1;
8449 player[i].targetanimation=knifefollowedanim;
8450 player[i].currentanimation=knifefollowedanim;
8451 player[i].targettilt2=0;
8452 player[i].targettilt2=player[k].targettilt2;
8453 player[i].targetframe=1;
8454 player[i].currentframe=0;
8456 player[i].velocity=0;
8457 player[k].currentanimation=knifefollowanim;
8458 player[k].targetanimation=knifefollowanim;
8459 player[k].targettilt2=player[i].targettilt2;
8460 player[k].currentframe=player[i].currentframe;
8461 player[k].targetframe=player[i].targetframe;
8462 player[k].target=player[i].target;
8463 player[k].velocity=0;
8464 player[k].oldcoords=player[k].coords;
8465 player[i].coords=player[k].coords;
8466 player[i].targetrotation=player[k].targetrotation;
8467 player[i].rotation=player[k].targetrotation;
8468 player[k].rotation=player[k].targetrotation;
8469 player[i].rotation=player[k].targetrotation;
8474 if(player[k].weaponactive!=-1){
8475 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==staff)hasstaff=1;
8478 for(i=0;i<numplayers;i++){
8480 if((playerrealattackkeydown||player[i].dead||!hasstaff)&&(k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack==neutral&&k==0){
8481 if(!player[i].dead||!realthreat||(player[k].weaponactive==-1&&player[k].crouchkeydown))
8482 if(player[i].skeleton.free)
8483 if(findDistancefast(&player[k].coords,&player[i].coords)<3.5*(player[k].scale*5)*(player[k].scale*5)&&(player[i].dead||player[i].skeleton.longdead>1000||player[k].isRun()||(hasstaff)||(player[k].weaponactive!=-1&&player[i].skeleton.free&&(player[i].skeleton.longdead>2000||player[i].damage>player[i].damagetolerance/8||player[i].bloodloss>player[i].damagetolerance/2)&&findDistancefast(&player[k].coords,&player[i].coords)<1.5*(player[k].scale*5)*(player[k].scale*5)))){
8484 player[k].victim=&player[i];
8485 player[k].hasvictim=1;
8486 if(player[k].weaponactive!=-1&&tutoriallevel!=1){
8487 if(player[k].crouchkeydown&&player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==knife&&findDistancefast(&player[k].coords,&player[i].coords)<1.5*(player[k].scale*5)*(player[k].scale*5))player[k].targetanimation=crouchstabanim;
8488 if(player[k].crouchkeydown&&findDistancefast(&player[k].coords,&player[i].coords)<1.5*(player[k].scale*5)*(player[k].scale*5)/*&&player[i].dead!=2*/&&weapons.type[player[k].weaponids[player[k].weaponactive]]==sword)player[k].targetanimation=swordgroundstabanim;
8489 if(/*(player[k].crouchkeydown||!player[i].dead)&&*/findDistancefast(&player[k].coords,&player[i].coords)<3.5*(player[k].scale*5)*(player[k].scale*5)/*&&player[i].dead!=2*/&&weapons.type[player[k].weaponids[player[k].weaponactive]]==staff)player[k].targetanimation=staffgroundsmashanim;
8491 if(findDistancefast(&player[k].coords,&player[i].coords)<2.5&&player[k].crouchkeydown&&player[k].targetanimation!=crouchstabanim&&(player[k].weaponactive==-1)&&player[i].dead&&player[i].skeleton.free&&player[i].skeleton.longdead>1000){
8492 player[k].targetanimation=killanim;
8493 for(j=0;j<terrain.numdecals;j++){
8494 if((terrain.decaltype[j]==blooddecal||terrain.decaltype[j]==blooddecalslow)&&terrain.decalalivetime[j]<2){
8495 terrain.DeleteDecal(j);
8498 for(l=0;l<objects.numobjects;l++){
8499 if(objects.model[l].type==decalstype)
8500 for(j=0;j<objects.model[l].numdecals;j++){
8501 if((objects.model[l].decaltype[j]==blooddecal||objects.model[l].decaltype[j]==blooddecalslow)&&objects.model[l].decalalivetime[j]<2){
8502 objects.model[l].DeleteDecal(j);
8507 if(!player[i].dead||musictype!=2)
8508 if(findDistancefast(&player[k].coords,&player[i].coords)<3.5&&(player[k].isRun()||(player[k].isIdle()&&player[k].attackkeydown))&&(player[k].staggerdelay<=0&&(player[i].dead||(player[i].skeleton.longdead<300&&player[k].lastattack!=spinkickanim&&player[i].skeleton.free)))&&(!player[i].dead||musictype!=stream_music2)){
8509 player[k].targetanimation=dropkickanim;
8510 for(j=0;j<terrain.numdecals;j++){
8511 if((terrain.decaltype[j]==blooddecal||terrain.decaltype[j]==blooddecalslow)&&terrain.decalalivetime[j]<2){
8512 terrain.DeleteDecal(j);
8515 for(l=0;l<objects.numobjects;l++){
8516 if(objects.model[l].type==decalstype)
8517 for(j=0;j<objects.model[l].numdecals;j++){
8518 if((objects.model[l].decaltype[j]==blooddecal||objects.model[l].decaltype[j]==blooddecalslow)&&objects.model[l].decalalivetime[j]<2){
8519 objects.model[l].DeleteDecal(j);
8525 if(animation[player[k].targetanimation].attack==normalattack&&player[k].victim==&player[i]&&(!player[i].skeleton.free||player[k].targetanimation==killanim||player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim||player[k].targetanimation==staffgroundsmashanim||player[k].targetanimation==dropkickanim)){
8527 player[k].targetframe=0;
8529 //player[k].velocity=0;
8531 rotatetarget=player[i].coords-player[k].coords;
8532 if(player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim||player[k].targetanimation==staffgroundsmashanim){
8533 rotatetarget=(player[i].coords+(player[i].skeleton.joints[player[i].skeleton.jointlabels[abdomen]].position+player[i].skeleton.joints[player[i].skeleton.jointlabels[neck]].position)/2*player[i].scale)-player[k].coords;
8535 Normalise(&rotatetarget);
8536 player[k].targetrotation=-asin(0-rotatetarget.x);
8537 player[k].targetrotation*=360/6.28;
8538 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8540 if(player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim){
8541 player[k].targetrotation+=(float)(abs(Random()%100)-50)/4;
8544 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8545 if(player[k].targetanimation==staffgroundsmashanim)player[k].targettilt2+=10;
8547 player[k].lastattack3=player[k].lastattack2;
8548 player[k].lastattack2=player[k].lastattack;
8549 player[k].lastattack=player[k].targetanimation;
8551 if(player[k].targetanimation==swordgroundstabanim){
8552 player[k].targetrotation+=30;
8554 //player[k].targettilt2=0;
8560 if(!player[k].hasvictim){
8561 for(i=0;i<numplayers;i++){
8562 if((player[k].hasvictim==0)&&i!=k&&(i==0||k==0)&&!player[i].skeleton.free){
8563 player[k].victim=&player[i];
8564 player[k].hasvictim=1;
8566 if(player[k].hasvictim&&!player[i].skeleton.free)
8567 if(findDistancefast(&player[k].coords,&player[i].coords)<findDistancefast(&player[k].coords,&player[k].victim->coords)&&i!=k&&(i==0||k==0)){
8568 player[k].victim=&player[i];
8572 if(player[k].aitype==playercontrolled)
8573 if(player[k].attackkeydown&&(player[k].isRun())&&player[k].wasRun()&&((player[k].hasvictim&&findDistancefast(&player[k].coords,&player[k].victim->coords)<12*(player[k].scale*5)*(player[k].scale*5)&&findDistancefast(&player[k].coords,&player[k].victim->coords)>7*(player[k].scale*5)*(player[k].scale*5)&&!player[k].victim->skeleton.free&&player[k].victim->targetanimation!=getupfrombackanim&&player[k].victim->targetanimation!=getupfromfrontanim&&animation[player[k].victim->targetanimation].height!=lowheight&&player[k].aitype!=playercontrolled&&normaldotproduct(player[k].facing,player[k].victim->coords-player[k].coords)>0&&player[k].rabbitkickenabled)||player[k].jumpkeydown)){
8575 player[k].targetanimation=rabbitkickanim;
8576 player[k].targetframe=0;
8579 if(animation[player[k].targetanimation].attack&&k==0){
8582 if(player[k].weaponactive!=-1){
8583 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==staff)armedstaff=1;
8586 if(player[k].weaponactive!=-1){
8587 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==sword)armedsword=1;
8590 if(player[k].weaponactive!=-1){
8591 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==knife)armedknife=1;
8593 if(armedstaff)numstaffattack++;
8594 else if(armedsword)numswordattack++;
8595 else if(armedknife)numknifeattack++;
8596 else numunarmedattack++;
8603 static float collisionradius;
8605 for(k=0;k<numplayers;k++){
8606 for(i=k;i<numplayers;i++){
8609 if((animation[player[i].targetanimation].attack!=reversed&&animation[player[i].targetanimation].attack!=reversal&&animation[player[k].targetanimation].attack!=reversed&&animation[player[k].targetanimation].attack!=reversal)||(i!=0&&k!=0))
8610 if((animation[player[i].currentanimation].attack!=reversed&&animation[player[i].currentanimation].attack!=reversal&&animation[player[k].currentanimation].attack!=reversed&&animation[player[k].currentanimation].attack!=reversal)||(i!=0&&k!=0))
8611 if(player[i].howactive<=typesleeping&&player[k].howactive<=typesleeping)
8612 if(player[i].howactive!=typesittingwall&&player[k].howactive!=typesittingwall)
8613 if(i!=k&&player[i].whichpatchx==player[k].whichpatchx&&player[i].whichpatchz==player[k].whichpatchz&&player[k].skeleton.oldfree==player[k].skeleton.free&&player[i].skeleton.oldfree==player[i].skeleton.free&&player[i].targetanimation!=climbanim&&player[i].targetanimation!=hanganim&&player[k].targetanimation!=climbanim&&player[k].targetanimation!=hanganim)
8614 if(player[i].coords.y>player[k].coords.y-3)
8615 if(player[i].coords.y<player[k].coords.y+3)
8616 if(player[i].coords.x>player[k].coords.x-3)
8617 if(player[i].coords.x<player[k].coords.x+3)
8618 if(player[i].coords.z>player[k].coords.z-3)
8619 if(player[i].coords.z<player[k].coords.z+3){
8620 if(findDistancefast(&player[i].coords,&player[k].coords)<3*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5)){
8621 if(player[i].onfire||player[k].onfire){
8622 if(!player[i].onfire)player[i].CatchFire();
8623 if(!player[k].onfire)player[k].CatchFire();
8627 tempcoords1=player[i].coords;
8628 tempcoords2=player[k].coords;
8629 if(!player[i].skeleton.oldfree)tempcoords1.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[abdomen]].position.y*player[i].scale;
8630 if(!player[k].skeleton.oldfree)tempcoords2.y+=player[k].skeleton.joints[player[k].skeleton.jointlabels[abdomen]].position.y*player[k].scale;
8631 collisionradius=1.2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5);
8632 if(player[0].hasvictim)
8633 if(player[0].targetanimation==rabbitkickanim&&(k==0||i==0)&&!player[0].victim->skeleton.free)collisionradius=3;
8634 if((!player[i].skeleton.oldfree||!player[k].skeleton.oldfree)&&(findDistancefast(&tempcoords1,&tempcoords2)<collisionradius||findDistancefast(&player[i].coords,&player[k].coords)<collisionradius)){
8636 if(player[k].targetanimation==jumpdownanim&&!player[k].skeleton.oldfree&&!player[k].skeleton.free&&player[i].skeleton.oldfree&&player[i].skeleton.free&&player[i].dead&&player[k].lastcollide<=0&&abs(player[i].coords.y-player[k].coords.y)<.2&&findDistancefast(&player[k].coords,&player[i].coords)<.7*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5)){
8637 player[k].coords.y=player[i].coords.y;
8638 player[i].velocity=player[k].velocity;
8639 player[i].skeleton.free=0;
8640 player[i].rotation=0;
8641 player[i].RagDoll(0);
8642 player[i].DoDamage(20);
8643 if(k==0)camerashake+=.3;
8644 player[i].skeleton.longdead=0;
8645 player[k].lastcollide=1;
8648 if(player[i].targetanimation==jumpdownanim&&!player[i].skeleton.oldfree&&!player[i].skeleton.free&&player[k].skeleton.oldfree&&player[k].skeleton.free&&player[k].dead&&player[i].lastcollide<=0&&abs(player[i].coords.y-player[k].coords.y)<.2&&findDistancefast(&player[k].coords,&player[i].coords)<.7*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5)){
8649 player[i].coords.y=player[k].coords.y;
8650 player[k].velocity=player[i].velocity;
8651 player[k].skeleton.free=0;
8652 player[k].rotation=0;
8653 player[k].RagDoll(0);
8654 player[k].DoDamage(20);
8655 if(i==0)camerashake+=.3;
8656 player[k].skeleton.longdead=0;
8657 player[i].lastcollide=1;
8660 if((player[i].skeleton.oldfree==1&&findLengthfast(&player[i].velocity)>1)||(player[k].skeleton.oldfree==1&&findLengthfast(&player[k].velocity)>1)||(player[i].skeleton.oldfree==0&&player[k].skeleton.oldfree==0)){
8661 rotatetarget=player[k].velocity-player[i].velocity;
8662 if(((player[i].targetanimation!=getupfrombackanim&&player[i].targetanimation!=getupfromfrontanim)||player[i].skeleton.free)&&((player[k].targetanimation!=getupfrombackanim&&player[k].targetanimation!=getupfromfrontanim)||player[k].skeleton.free))
8663 if(((((findLengthfast(&rotatetarget)>150&&(i!=0&&k!=0))||(findLengthfast(&rotatetarget)>50&&player[0].rabbitkickragdoll/*currentanimation==rabbitkickanim*/&&(i==0||k==0)))&&normaldotproduct(rotatetarget,player[k].coords-player[i].coords)>0)&&((i==0||k==0)||((player[i].skeleton.oldfree==1&&k!=0&&animation[player[k].currentanimation].attack==neutral)||(player[k].skeleton.oldfree==1&&i!=0&&animation[player[i].currentanimation].attack==neutral)||(player[i].isFlip()&&!player[i].skeleton.oldfree&&(i==0||k==0))||(player[k].isFlip()&&!player[k].skeleton.oldfree&&(i==0||k==0))||(i==0||k==0))))||((player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip())&&(player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim||player[k].isFlip())&&(i==0||k==0)&&(!player[i].skeleton.oldfree&&!player[k].skeleton.oldfree))){
8665 if((i!=0||player[i].skeleton.free)&&(k!=0||player[k].skeleton.free)||(animation[player[i].targetanimation].height==highheight&&animation[player[k].targetanimation].height==highheight)){
8666 static float gLoc[3];
8667 static float vel[3];
8668 gLoc[0]=player[i].coords.x;
8669 gLoc[1]=player[i].coords.y;
8670 gLoc[2]=player[i].coords.z;
8671 vel[0]=player[i].velocity.x;
8672 vel[1]=player[i].velocity.y;
8673 vel[2]=player[i].velocity.z;
8674 if(tutoriallevel!=1){
8675 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, TRUE);
8676 FSOUND_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
8677 FSOUND_SetVolume(channels[heavyimpactsound], 256);
8678 FSOUND_SetPaused(channels[heavyimpactsound], FALSE);
8680 //player[i].velocity=player[k].velocity;
8681 //player[k].velocity=player[i].velocity;
8683 player[i].RagDoll(0);
8684 if(player[i].damage>player[i].damagetolerance-findLengthfast(&rotatetarget)/4&&!player[i].dead){
8689 player[i].DoDamage(findLengthfast(&rotatetarget)/4);
8690 player[k].RagDoll(0);
8691 if(player[k].damage>player[k].damagetolerance-findLengthfast(&rotatetarget)/4&&!player[k].dead){
8696 player[k].DoDamage(findLengthfast(&rotatetarget)/4);
8698 //if(player[i].skeleton.oldfree){
8699 for(j=0;j<player[i].skeleton.num_joints;j++){
8700 player[i].skeleton.joints[j].velocity=player[i].skeleton.joints[j].velocity/5+player[k].velocity;
8703 //if(player[k].skeleton.oldfree){
8704 for(j=0;j<player[k].skeleton.num_joints;j++){
8705 player[k].skeleton.joints[j].velocity=player[k].skeleton.joints[j].velocity/5+player[i].velocity;
8711 if((animation[player[i].targetanimation].attack==neutral||animation[player[i].targetanimation].attack==normalattack)&&(animation[player[k].targetanimation].attack==neutral||animation[player[k].targetanimation].attack==normalattack)){
8713 if(player[i].skeleton.oldfree==0&&player[k].skeleton.oldfree==0){
8714 if(findDistancefast(&player[k].coords,&player[i].coords)<.5*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5)){
8715 rotatetarget=player[k].coords-player[i].coords;
8716 Normalise(&rotatetarget);
8717 player[k].coords=(player[k].coords+player[i].coords)/2;
8718 player[i].coords=player[k].coords-rotatetarget*fast_sqrt(.6)/2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5);
8719 player[k].coords+=rotatetarget*fast_sqrt(.6)/2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5);
8720 if(player[k].howactive==typeactive||hostile)
8721 if(player[k].isIdle()){
8722 if(player[k].howactive<typesleeping){
8723 player[k].targetanimation=player[k].getStop();
8724 player[k].targetframe=0;
8727 else if(player[k].howactive==typesleeping)
8729 player[k].targetanimation=getupfromfrontanim;
8730 player[k].targetframe=0;
8733 if(!editorenabled)player[k].howactive=typeactive;
8735 if(player[i].howactive==typeactive||hostile)
8736 if(player[i].isIdle()){
8737 if(player[i].howactive<typesleeping){
8738 player[i].targetanimation=player[i].getStop();
8739 player[i].targetframe=0;
8744 player[i].targetanimation=getupfromfrontanim;
8745 player[i].targetframe=0;
8748 if(!editorenabled)player[i].howactive=typeactive;
8752 if(k==0&&i!=0&&player[k].targetanimation==jumpdownanim&&!player[i].isCrouch()&&player[i].targetanimation!=rollanim&&!player[k].skeleton.oldfree&&!player[k].skeleton.free&&player[k].lastcollide<=0&&player[k].velocity.y<-10){
8753 player[i].velocity=player[k].velocity;
8754 player[k].velocity=player[k].velocity*-.5;
8755 //player[i].velocity.y-=10;
8756 player[k].velocity.y=player[i].velocity.y;
8757 player[i].DoDamage(20);
8758 player[i].RagDoll(0);
8759 player[k].lastcollide=1;
8766 if(i==0&&k!=0&&player[i].targetanimation==jumpdownanim&&!player[k].isCrouch()&&player[k].targetanimation!=rollanim&&!player[i].skeleton.oldfree&&!player[i].skeleton.free&&player[i].lastcollide<=0&&player[i].velocity.y<-10){
8767 player[k].velocity=player[i].velocity;
8768 player[i].velocity=player[i].velocity*-.3;
8769 //player[k].velocity.y-=10;
8770 player[i].velocity.y=player[k].velocity.y;
8771 player[k].DoDamage(20);
8772 player[k].RagDoll(0);
8773 player[i].lastcollide=1;
8784 player[i].CheckKick();
8785 player[k].CheckKick();
8791 for(k=0;k<numplayers;k++){
8792 for(i=k;i<numplayers;i++){
8794 if(i<numplayers&&i!=k&&player[k].skeleton.free==0&&player[i].skeleton.oldfree==0&&(player[i].targetanimation==jumpupanim||player[k].targetanimation==jumpupanim)&&(player[i].aitype==playercontrolled||player[k].aitype==playercontrolled)&&((player[i].aitype==attacktypecutoff&&player[i].stunned<=0)||(player[k].aitype==attacktypecutoff&&player[k].stunned<=0))){
8795 if(findDistancefast(&player[i].coords,&player[k].coords)<10*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5)&&findDistancefastflat(&player[i].coords,&player[k].coords)<2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5)){
8796 if(player[i].targetanimation==jumpupanim&&player[k].targetanimation!=getupfrombackanim&&player[k].targetanimation!=getupfromfrontanim&&animation[player[k].targetanimation].height==middleheight&&normaldotproduct(player[i].velocity,player[k].coords-player[i].coords)<0&&((player[k].aitype==playercontrolled&&player[k].attackkeydown)||player[k].aitype!=playercontrolled)){
8797 player[i].victim=&player[k];
8798 player[i].targetanimation=jumpreversedanim;
8799 player[i].currentanimation=jumpreversedanim;
8800 player[k].currentanimation=jumpreversalanim;
8801 player[k].targetanimation=jumpreversalanim;
8802 player[i].targettilt2=0;
8803 player[i].currentframe=0;
8804 player[i].targetframe=1;
8805 player[k].currentframe=0;
8806 player[k].targetframe=1;
8807 if(player[i].coords.y<player[k].coords.y+1){
8808 player[i].targetanimation=rabbitkickreversedanim;
8809 player[i].currentanimation=rabbitkickreversedanim;
8810 player[k].currentanimation=rabbitkickreversalanim;
8811 player[k].targetanimation=rabbitkickreversalanim;
8812 player[k].currentframe=1;
8813 player[k].targetframe=2;
8814 player[i].currentframe=1;
8815 player[i].targetframe=2;
8817 player[k].targettilt2=0;
8819 player[i].velocity=0;
8820 player[k].velocity=0;
8821 player[k].oldcoords=player[k].coords;
8822 player[i].coords=player[k].coords;
8823 player[k].targetrotation=player[i].targetrotation;
8824 player[k].rotation=player[i].targetrotation;
8825 player[k].victim=&player[i];
8826 if(player[k].aitype==attacktypecutoff)player[k].stunned=.5;
8828 if(player[k].targetanimation==jumpupanim&&player[i].targetanimation!=getupfrombackanim&&player[i].targetanimation!=getupfromfrontanim&&animation[player[i].targetanimation].height==middleheight&&normaldotproduct(player[k].velocity,player[i].coords-player[k].coords)<0&&((player[i].aitype==playercontrolled&&player[i].attackkeydown)||player[i].aitype!=playercontrolled)){
8829 player[k].victim=&player[i];
8830 player[k].targetanimation=jumpreversedanim;
8831 player[k].currentanimation=jumpreversedanim;
8832 player[i].currentanimation=jumpreversalanim;
8833 player[i].targetanimation=jumpreversalanim;
8834 player[k].targettilt2=0;
8835 player[i].targettilt2=0;
8836 player[k].currentframe=0;
8837 player[k].targetframe=1;
8838 player[i].currentframe=0;
8839 player[i].targetframe=1;
8840 if(player[k].coords.y<player[i].coords.y+1){
8841 player[k].targetanimation=rabbitkickreversedanim;
8842 player[k].currentanimation=rabbitkickreversedanim;
8843 player[i].currentanimation=rabbitkickreversalanim;
8844 player[i].targetanimation=rabbitkickreversalanim;
8845 player[k].currentframe=1;
8846 player[k].targetframe=2;
8847 player[i].currentframe=1;
8848 player[i].targetframe=2;
8851 player[k].velocity=0;
8852 player[i].velocity=0;
8853 player[i].oldcoords=player[i].coords;
8854 player[k].coords=player[i].coords;
8855 player[i].targetrotation=player[k].targetrotation;
8856 player[i].rotation=player[k].targetrotation;
8857 player[i].victim=&player[k];
8858 if(player[i].aitype==attacktypecutoff)player[i].stunned=.5;
8865 for(k=0;k<numplayers;k++)
8866 if(player[k].immobile&&k!=0)player[k].coords=player[k].realoldcoords;
8875 static float checkdelay;
8876 checkdelay-=multiplier;
8878 static bool checkedcoll[maxplayers][maxplayers];
8879 static bool above[maxplayers];
8881 for(i=0;i<maxplayers;i++){
8882 for(j=0;j<maxplayers;j++){
8883 checkedcoll[i][j]=0;
8887 if(numplayers>1&&checkdelay<=0){
8889 for(k=0;k<numplayers;k++){
8890 if(player[k].skeleton.free!=2)above[k]=-1;
8892 for(i=k;i<numplayers;i++){
8895 if(!checkedcoll[i][k]){
8896 checkedcoll[i][k]=1;
8897 checkedcoll[k][i]=1;
8898 if(player[i].skeleton.free&&player[k].skeleton.free)
8899 if(player[i].skeleton.free!=2||player[k].skeleton.free!=2)
8900 if(i!=k&&player[i].whichpatchx==player[k].whichpatchx&&player[i].whichpatchz==player[k].whichpatchz)
8901 if(player[i].coords.y>player[k].coords.y-3)
8902 if(player[i].coords.y<player[k].coords.y+3)
8903 if(player[i].coords.x>player[k].coords.x-3)
8904 if(player[i].coords.x<player[k].coords.x+3)
8905 if(player[i].coords.z>player[k].coords.z-3)
8906 if(player[i].coords.z<player[k].coords.z+3)
8907 if(findDistancefast(&player[i].coords,&player[k].coords)<3*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5)){
8909 if((player[i].skeleton.longdead>player[k].skeleton.longdead&&player[k].skeleton.free!=2)||player[i].skeleton.free==2){
8921 above[moving]=stuck;
8922 for(l=0;l<player[moving].skeleton.num_joints;l++){
8923 for(m=0;m<player[stuck].skeleton.num_joints;m++){
8924 while(findDistancefast(player[moving].skeleton.joints[l].position+player[moving].coords,player[stuck].skeleton.joints[m].position+player[stuck].coords)<.25)
8926 player[moving].skeleton.joints[l].position.y+=.003;
8927 if(player[moving].skeleton.joints[l].velocity.y<-.05)player[moving].skeleton.joints[l].velocity.y+=.003/.015/2;
8941 if(!IsKeyDown(theKeyMap, MAC_N_KEY)){
8942 texturesizetogglekeydown=0;
8945 for(k=0;k<numplayers;k++){
8946 if(!isnormal(player[k].coords.x)||!isnormal(player[k].coords.y)||!isnormal(player[k].coords.z)){
8947 if(!isnormal(player[k].coords.x)||!isnormal(player[k].coords.y)||!isnormal(player[k].coords.z)){
8948 player[k].DoDamage(1000);
8953 static bool respawnkeydown;
8954 if(!editorenabled&&(whichlevel!=-2&&(IsKeyDown(theKeyMap, MAC_Z_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)&&debugmode&&!editorenabled)||(IsKeyDown(theKeyMap, jumpkey)&&!respawnkeydown&&!oldattackkey&&player[0].dead))){
8955 targetlevel=whichlevel;
8959 if(!IsKeyDown(theKeyMap, jumpkey))respawnkeydown=0;
8960 if(IsKeyDown(theKeyMap, jumpkey))respawnkeydown=1;
8965 if(whichlevel!=-2&&IsKeyDown(theKeyMap, MAC_K_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!slomotogglekeydown&&debugmode&&!editorenabled){
8967 if(targetlevel>numchallengelevels-1)targetlevel=0;
8970 slomotogglekeydown=1;
8974 if(IsKeyDown(theKeyMap, MAC_Z_KEY)){
8976 FSOUND_SetPaused(channels[whooshsound], TRUE);
8978 for(k=0;k<numplayers;k++){
8981 player[k].permanentdamage=0;
8982 if(player[k].skeleton.free==2)player[k].skeleton.free=1;
8983 player[k].aitype=passivetype;
8985 player[0].aitype=playercontrolled;
8989 static bool movekey;
8990 static bool connected;
8991 /*player[0].forwardkeydown=IsKeyDown(theKeyMap, MAC_W_KEY);
8992 player[0].leftkeydown=IsKeyDown(theKeyMap, MAC_A_KEY);
8993 player[0].backkeydown=IsKeyDown(theKeyMap, MAC_S_KEY);
8994 player[0].rightkeydown=IsKeyDown(theKeyMap, MAC_D_KEY);
8995 player[0].jumpkeydown=IsKeyDown(theKeyMap, MAC_SPACE_KEY);
8996 player[0].crouchkeydown=IsKeyDown(theKeyMap, MAC_SHIFT_KEY);*/
8998 //if(!player[0].crouchkeydown)player[0].crouchkeydown=IsKeyDown(theKeyMap, MAC_CONTROL_KEY);
9000 for(int i=0;i<numplayers;i++){
9001 if(!player[i].skeleton.free){
9002 oldtargetrotation=player[i].targetrotation;
9003 if(i==0&&indialogue==-1){
9004 if(!animation[player[0].targetanimation].attack&&player[0].targetanimation!=staggerbackhighanim&&player[0].targetanimation!=staggerbackhardanim&&player[0].targetanimation!=crouchremoveknifeanim&&player[0].targetanimation!=removeknifeanim&&player[0].targetanimation!=backhandspringanim&&player[0].targetanimation!=dodgebackanim&&player[0].targetanimation!=walljumprightkickanim&&player[0].targetanimation!=walljumpleftkickanim){
9005 if(!cameramode)player[0].targetrotation=-rotation+180;
9006 if(cameramode)player[0].targetrotation=0;
9012 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
9013 if(cameramode){facing=flatfacing;}
9015 facing=DoRotation(facing,-rotation2,0,0);
9016 facing=DoRotation(facing,0,0-rotation,0);
9019 player[0].lookrotation=-rotation;
9021 player[i].targetheadrotation=rotation;
9022 player[i].targetheadrotation2=rotation2;
9024 if(i!=0&&player[i].aitype==playercontrolled&&indialogue==-1){
9025 if(!animation[player[i].targetanimation].attack&&player[i].targetanimation!=staggerbackhighanim&&player[i].targetanimation!=staggerbackhardanim&&player[i].targetanimation!=crouchremoveknifeanim&&player[i].targetanimation!=removeknifeanim&&player[i].targetanimation!=backhandspringanim&&player[i].targetanimation!=dodgebackanim&&player[i].targetanimation!=walljumprightkickanim&&player[i].targetanimation!=walljumpleftkickanim){
9026 player[i].targetrotation=-player[i].lookrotation+180;
9032 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
9034 facing=DoRotation(facing,-player[i].lookrotation2,0,0);
9035 facing=DoRotation(facing,0,0-player[i].lookrotation,0);
9037 player[i].targetheadrotation=player[i].lookrotation;
9038 player[i].targetheadrotation2=player[i].lookrotation2;
9041 rotatetarget=participantfacing[whichdialogue][indialogue][i];
9042 Normalise(&rotatetarget);
9043 player[i].targetheadrotation=-asin(0-rotatetarget.x);
9044 player[i].targetheadrotation*=360/6.28;
9045 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
9047 player[i].targetheadrotation*=-1;
9048 player[i].targetheadrotation+=180;
9049 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
9057 player[i].avoidsomething=0;
9059 for(j=0;j<objects.numobjects;j++){
9060 if(objects.onfire[j]){
9061 if(findDistancefast(&objects.position[j],&player[i].coords)<objects.scale[j]*objects.scale[j]*200)
9063 if(findDistancefast(&player[i].coords,&objects.position[j])<findDistancefast(&player[i].coords,&player[0].coords)){
9064 player[i].collided=0;
9065 player[i].avoidcollided=1;
9066 if(player[i].avoidsomething==0||findDistancefast(&objects.position[j],&player[i].coords)<findDistancefast(&player[i].coords,&player[i].avoidwhere))
9067 player[i].avoidwhere=objects.position[j];
9073 //Add avoidwhere to players
9075 for(j=0;j<numplayers;j++){
9076 if(player[j].onfire){
9077 if(findDistancefast(&player[j].coords,&player[i].coords)<0.3*0.3*200)
9079 if(findDistancefast(&player[i].coords,&player[j].coords)<findDistancefast(&player[i].coords,&player[0].coords)){
9080 player[i].collided=0;
9081 player[i].avoidcollided=1;
9082 if(player[i].avoidsomething==0||findDistancefast(&player[j].coords,&player[i].coords)<findDistancefast(&player[i].coords,&player[i].avoidwhere))
9083 player[i].avoidwhere=objects.position[j];
9089 if(player[i].collided>.8)player[i].avoidcollided=0;
9090 if(player[i].aitype!=playercontrolled&&indialogue==-1){
9091 player[i].jumpclimb=0;
9093 if(editorenabled)player[i].stunned=1;
9096 //if(findDistancefastflat(&player[i].coords,&player[0].coords)<3/*&&player[0].coords.y>player[i].coords.y+.1*/)player[i].pause=1;
9097 if(findDistancefastflat(&player[0].coords,&player[i].coords)<30&&player[0].coords.y>player[i].coords.y+2&&!player[0].onterrain)player[i].pause=1;
9099 /*if(player[i].aitype==passivetype&&player[i].numwaypoints<=1){
9100 player[i].forwardkeydown=0;
9101 player[i].leftkeydown=0;
9102 player[i].backkeydown=0;
9103 player[i].rightkeydown=0;
9104 player[i].crouchkeydown=0;
9105 player[i].attackkeydown=0;
9106 player[i].jumpkeydown=0;
9107 player[i].throwkeydown=0;
9110 if(player[i].aitype==pathfindtype){
9111 if(player[i].finalpathfindpoint==-1){
9112 float closestdistance;
9118 for(j=0;j<numpathpoints;j++){
9119 if(closest==-1||findDistancefast(&player[i].finalfinaltarget,&pathpoint[j])<closestdistance){
9120 closestdistance=findDistancefast(&player[i].finalfinaltarget,&pathpoint[j]);
9122 player[i].finaltarget=pathpoint[j];
9125 player[i].finalpathfindpoint=closest;
9126 for(j=0;j<numpathpoints;j++){
9127 if(numpathpointconnect[j])
9128 for(k=0;k<numpathpointconnect[j];k++){
9129 DistancePointLine(&player[i].finalfinaltarget, &pathpoint[j], &pathpoint[pathpointconnect[j][k]], &tempdist,&colpoint );
9130 if(tempdist*tempdist<closestdistance){
9131 if(findDistance(&colpoint,&pathpoint[j])+findDistance(&colpoint,&pathpoint[pathpointconnect[j][k]])<findDistance(&pathpoint[j],&pathpoint[pathpointconnect[j][k]])+.1){
9132 closestdistance=tempdist*tempdist;
9134 player[i].finaltarget=colpoint;
9139 player[i].finalpathfindpoint=closest;
9142 if(player[i].targetpathfindpoint==-1){
9143 float closestdistance;
9149 if(player[i].lastpathfindpoint==-1){
9150 for(j=0;j<numpathpoints;j++){
9151 if(j!=player[i].lastpathfindpoint)
9152 if(closest==-1||(findDistancefast(&player[i].coords,&pathpoint[j])<closestdistance/*&&findDistancefast(&player[i].finaltarget,&pathpoint[j])<findDistancefast(&player[i].finaltarget,&player[i].coords)*/)){
9153 closestdistance=findDistancefast(&player[i].coords,&pathpoint[j]);
9157 player[i].targetpathfindpoint=closest;
9158 for(j=0;j<numpathpoints;j++){
9159 if(j!=player[i].lastpathfindpoint)
9160 if(numpathpointconnect[j])
9161 for(k=0;k<numpathpointconnect[j];k++){
9162 DistancePointLine(&player[i].coords, &pathpoint[j], &pathpoint[pathpointconnect[j][k]], &tempdist,&colpoint );
9163 if(tempdist*tempdist<closestdistance){
9164 if(findDistance(&colpoint,&pathpoint[j])+findDistance(&colpoint,&pathpoint[pathpointconnect[j][k]])<findDistance(&pathpoint[j],&pathpoint[pathpointconnect[j][k]])+.1){
9165 //if(findDistancefast(&player[i].finaltarget,&colpoint)<findDistancefast(&player[i].finaltarget,&player[i].coords)){
9166 closestdistance=tempdist*tempdist;
9173 player[i].targetpathfindpoint=closest;
9177 for(j=0;j<numpathpoints;j++){
9178 if(j!=player[i].lastpathfindpoint&&j!=player[i].lastpathfindpoint2&&j!=player[i].lastpathfindpoint3&&j!=player[i].lastpathfindpoint4)
9181 if(numpathpointconnect[j])
9182 for(k=0;k<numpathpointconnect[j];k++){
9183 if(pathpointconnect[j][k]==player[i].lastpathfindpoint)connected=1;
9186 if(numpathpointconnect[player[i].lastpathfindpoint])
9187 for(k=0;k<numpathpointconnect[player[i].lastpathfindpoint];k++){
9188 if(pathpointconnect[player[i].lastpathfindpoint][k]==j)connected=1;
9191 tempdist=findPathDist(j,player[i].finalpathfindpoint);
9192 if(closest==-1||tempdist<closestdistance){
9193 closestdistance=tempdist;
9199 player[i].targetpathfindpoint=closest;
9202 player[i].losupdatedelay-=multiplier;
9204 rotatetarget=pathpoint[player[i].targetpathfindpoint]-player[i].coords;
9205 Normalise(&rotatetarget);
9206 player[i].targetrotation=-asin(0-rotatetarget.x);
9207 player[i].targetrotation*=360/6.28;
9208 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9209 player[i].lookrotation=player[i].targetrotation;
9210 //player[i].aiupdatedelay=.05;
9212 if(findDistancefastflat(&player[i].coords,&pathpoint[player[i].targetpathfindpoint])<.6){
9213 player[i].lastpathfindpoint4=player[i].lastpathfindpoint3;
9214 player[i].lastpathfindpoint3=player[i].lastpathfindpoint2;
9215 player[i].lastpathfindpoint2=player[i].lastpathfindpoint;
9216 player[i].lastpathfindpoint=player[i].targetpathfindpoint;
9217 if(player[i].lastpathfindpoint2==-1)player[i].lastpathfindpoint2=player[i].lastpathfindpoint;
9218 if(player[i].lastpathfindpoint3==-1)player[i].lastpathfindpoint3=player[i].lastpathfindpoint2;
9219 if(player[i].lastpathfindpoint4==-1)player[i].lastpathfindpoint4=player[i].lastpathfindpoint3;
9220 player[i].targetpathfindpoint=-1;
9222 if(findDistancefastflat(&player[i].coords,&player[i].finalfinaltarget)<findDistancefastflat(&player[i].coords,&player[i].finaltarget)||findDistancefastflat(&player[i].coords,&player[i].finaltarget)<.6*(player[i].scale*5)*(player[i].scale*5)||player[i].lastpathfindpoint==player[i].finalpathfindpoint){
9223 player[i].aitype=passivetype;
9226 player[i].forwardkeydown=1;
9227 player[i].leftkeydown=0;
9228 player[i].backkeydown=0;
9229 player[i].rightkeydown=0;
9230 player[i].crouchkeydown=0;
9231 player[i].attackkeydown=0;
9232 player[i].throwkeydown=0;
9234 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9236 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9237 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9239 if((tutoriallevel!=1||cananger)&&hostile&&!player[0].dead&&findDistancefast(&player[i].coords,&player[0].coords)<400&&player[i].occluded<25){
9240 if(findDistancefast(&player[i].coords,&player[0].coords)<12&&animation[player[0].targetanimation].height!=lowheight&&!editorenabled&&(player[0].coords.y<player[i].coords.y+5||player[0].onterrain))
9241 player[i].aitype=attacktypecutoff;
9242 if(findDistancefast(&player[i].coords,&player[0].coords)<30&&animation[player[0].targetanimation].height==highheight&&!editorenabled)
9243 player[i].aitype=attacktypecutoff;
9245 if(player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2){
9246 player[i].losupdatedelay=.2;
9247 for(j=0;j<numplayers;j++){
9248 if(j==0||player[j].skeleton.free||player[j].aitype!=passivetype){
9249 if(abs(Random()%2)||animation[player[j].targetanimation].height!=lowheight||j!=0)
9250 if(findDistancefast(&player[i].coords,&player[j].coords)<400)
9251 if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0)
9252 if(player[j].coords.y<player[i].coords.y+5||player[j].onterrain)
9253 if((-1==checkcollide(DoRotation(player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position,0,player[i].rotation,0)*player[i].scale+player[i].coords,DoRotation(player[j].skeleton.joints[player[j].skeleton.jointlabels[head]].position,0,player[j].rotation,0)*player[j].scale+player[j].coords)&&!player[j].isWallJump())||(player[j].targetanimation==hanganim&&normaldotproduct(player[j].facing,player[i].coords-player[j].coords)<0)){
9254 player[i].aitype=searchtype;
9255 player[i].lastchecktime=12;
9256 player[i].lastseen=player[j].coords;
9257 player[i].lastseentime=12;
9263 if(player[i].aitype==attacktypecutoff&&musictype!=2){
9264 if(player[i].creature!=wolftype){
9265 player[i].stunned=.6;
9266 player[i].surprised=.6;
9271 if(player[i].aitype!=passivetype&&leveltime>.5){
9272 player[i].howactive=typeactive;
9275 if(player[i].aitype==passivetype){
9276 player[i].aiupdatedelay-=multiplier;
9277 player[i].losupdatedelay-=multiplier;
9278 player[i].lastseentime+=multiplier;
9279 player[i].pausetime-=multiplier;
9280 if(player[i].lastseentime>1)player[i].lastseentime=1;
9282 if(player[i].aiupdatedelay<0){
9283 if(player[i].numwaypoints>1&&player[i].howactive==typeactive&&player[i].pausetime<=0){
9284 rotatetarget=player[i].waypoints[player[i].waypoint]-player[i].coords;
9285 Normalise(&rotatetarget);
9286 player[i].targetrotation=-asin(0-rotatetarget.x);
9287 player[i].targetrotation*=360/6.28;
9288 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9289 player[i].lookrotation=player[i].targetrotation;
9290 player[i].aiupdatedelay=.05;
9292 if(findDistancefastflat(&player[i].coords,&player[i].waypoints[player[i].waypoint])<1){
9293 if(player[i].waypointtype[player[i].waypoint]==wppause)player[i].pausetime=4;
9294 player[i].waypoint++;
9295 if(player[i].waypoint>player[i].numwaypoints-1)player[i].waypoint=0;
9300 if(player[i].numwaypoints>1&&player[i].howactive==typeactive&&player[i].pausetime<=0)player[i].forwardkeydown=1;
9301 else player[i].forwardkeydown=0;
9302 player[i].leftkeydown=0;
9303 player[i].backkeydown=0;
9304 player[i].rightkeydown=0;
9305 player[i].crouchkeydown=0;
9306 player[i].attackkeydown=0;
9307 player[i].throwkeydown=0;
9309 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9310 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9312 XYZ leftpos,rightpos;
9313 float leftdist,rightdist;
9314 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9315 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9316 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9317 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9318 if(leftdist<rightdist)player[i].targetrotation+=90;
9319 else player[i].targetrotation-=90;
9323 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9324 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9328 if(player[i].howactive<typesleeping)
9329 if(numenvsounds>0&&(tutoriallevel!=1||cananger)&&hostile)
9330 for(j=0;j<numenvsounds;j++){
9331 if(findDistancefast(&player[i].coords,&envsound[j])<2*(envsoundvol[j]+envsoundvol[j]*(player[i].creature==rabbittype)*3)){
9332 player[i].aitype=attacktypecutoff;
9336 if(player[i].howactive==typesleeping)
9337 if(numenvsounds>0&&(tutoriallevel!=1||cananger)&&hostile)
9338 for(j=0;j<numenvsounds;j++){
9339 if(envsoundvol[j]>14)
9340 if(findDistancefast(&player[i].coords,&envsound[j])<2*((envsoundvol[j]-14)+(envsoundvol[j]-14)*(player[i].creature==rabbittype)*3)){
9341 player[i].aitype=attacktypecutoff;
9345 if(player[i].aitype!=passivetype){
9346 if(player[i].howactive==typesleeping){
9347 player[i].targetanimation=getupfromfrontanim;
9348 player[i].targetframe=0;
9352 player[i].howactive=typeactive;
9356 if(player[i].howactive<typesleeping&&((tutoriallevel!=1||cananger)&&hostile)&&!player[0].dead&&findDistancefast(&player[i].coords,&player[0].coords)<400&&player[i].occluded<25){
9357 if(findDistancefast(&player[i].coords,&player[0].coords)<12&&animation[player[0].targetanimation].height!=lowheight&&!editorenabled)
9358 player[i].aitype=attacktypecutoff;
9359 if(findDistancefast(&player[i].coords,&player[0].coords)<30&&animation[player[0].targetanimation].height==highheight&&!editorenabled)
9360 player[i].aitype=attacktypecutoff;
9362 if(player[i].creature==wolftype){
9364 float smelldistance;
9366 for(j=0;j<numplayers;j++){
9367 if(j==0||(player[j].dead&&player[j].bloodloss>0)){
9368 if(j==0&&player[j].num_weapons>0){
9369 if(weapons.bloody[player[j].weaponids[0]])smelldistance=100;
9370 if(player[j].num_weapons==2)
9371 if(weapons.bloody[player[j].weaponids[1]])smelldistance=100;
9376 windsmell=windvector;
9377 Normalise(&windsmell);
9378 windsmell=windsmell*2+player[j].coords;
9379 if(findDistancefast(&player[i].coords,&windsmell)<smelldistance&&!editorenabled)
9380 player[i].aitype=attacktypecutoff;
9385 if(player[i].howactive<typesleeping&&player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2){
9386 player[i].losupdatedelay=.2;
9387 for(j=0;j<numplayers;j++){
9388 if(j==0||player[j].skeleton.free||player[j].aitype!=passivetype){
9389 if(abs(Random()%2)||animation[player[j].targetanimation].height!=lowheight||j!=0)
9390 if(findDistancefast(&player[i].coords,&player[j].coords)<400)
9391 if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0)
9392 if((-1==checkcollide(DoRotation(player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position,0,player[i].rotation,0)*player[i].scale+player[i].coords,DoRotation(player[j].skeleton.joints[player[j].skeleton.jointlabels[head]].position,0,player[j].rotation,0)*player[j].scale+player[j].coords)&&!player[j].isWallJump())||(player[j].targetanimation==hanganim&&normaldotproduct(player[j].facing,player[i].coords-player[j].coords)<0)){
9393 player[i].lastseentime-=.2;
9394 if(j==0&&animation[player[j].targetanimation].height==lowheight)player[i].lastseentime-=.4;
9395 else player[i].lastseentime-=.6;
9397 if(player[i].lastseentime<=0){
9398 player[i].aitype=searchtype;
9399 player[i].lastchecktime=12;
9400 player[i].lastseen=player[j].coords;
9401 player[i].lastseentime=12;
9407 if(player[i].aitype==attacktypecutoff&&musictype!=2){
9408 if(player[i].creature!=wolftype){
9409 player[i].stunned=.6;
9410 player[i].surprised=.6;
9412 if(player[i].creature==wolftype){
9413 player[i].stunned=.47;
9414 player[i].surprised=.47;
9420 if(player[i].aitype==searchtype){
9421 player[i].aiupdatedelay-=multiplier;
9422 player[i].losupdatedelay-=multiplier;
9423 if(!player[i].pause)player[i].lastseentime-=multiplier;
9424 player[i].lastchecktime-=multiplier;
9426 if(player[i].isRun()&&!player[i].onground){
9427 if(player[i].coords.y>terrain.getHeight(player[i].coords.x,player[i].coords.z)+10){
9428 test2=player[i].coords+player[i].facing;
9430 test=player[i].coords+player[i].facing;
9432 j=checkcollide(test2,test,player[i].laststanding);
9433 if(j==-1)j=checkcollide(test2,test);
9435 player[i].velocity=0;
9436 player[i].targetanimation=player[i].getStop();
9437 player[i].targetframe=0;
9439 player[i].targetrotation+=180;
9440 player[i].stunned=.5;
9441 //player[i].aitype=passivetype;
9442 player[i].aitype=pathfindtype;
9443 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9444 player[i].finalpathfindpoint=-1;
9445 player[i].targetpathfindpoint=-1;
9446 player[i].lastpathfindpoint=-1;
9447 player[i].lastpathfindpoint2=-1;
9448 player[i].lastpathfindpoint3=-1;
9449 player[i].lastpathfindpoint4=-1;
9451 else player[i].laststanding=j;
9454 if(player[i].aiupdatedelay<0){
9455 rotatetarget=player[i].lastseen-player[i].coords;
9456 Normalise(&rotatetarget);
9457 player[i].targetrotation=-asin(0-rotatetarget.x);
9458 player[i].targetrotation*=360/6.28;
9459 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9460 player[i].lookrotation=player[i].targetrotation;
9461 player[i].aiupdatedelay=.05;
9462 player[i].forwardkeydown=1;
9464 if(findDistancefastflat(&player[i].coords,&player[i].lastseen)<1*(player[i].scale*5)*(player[i].scale*5)||player[i].lastchecktime<0){
9465 player[i].forwardkeydown=0;
9466 player[i].aiupdatedelay=1;
9467 player[i].lastseen.x+=(float(Random()%100)-50)/25;
9468 player[i].lastseen.z+=(float(Random()%100)-50)/25;
9469 player[i].lastchecktime=3;
9472 player[i].leftkeydown=0;
9473 player[i].backkeydown=0;
9474 player[i].rightkeydown=0;
9475 player[i].crouchkeydown=0;
9476 player[i].attackkeydown=0;
9477 player[i].throwkeydown=0;
9479 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9480 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9482 XYZ leftpos,rightpos;
9483 float leftdist,rightdist;
9484 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9485 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9486 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9487 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9488 if(leftdist<rightdist)player[i].targetrotation+=90;
9489 else player[i].targetrotation-=90;
9493 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9494 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9496 if(numenvsounds>0&&((tutoriallevel!=1||cananger)&&hostile))
9497 for(j=0;j<numenvsounds;j++){
9498 if(findDistancefast(&player[i].coords,&envsound[j])<2*(envsoundvol[j]+envsoundvol[j]*(player[i].creature==rabbittype)*3)){
9499 player[i].aitype=attacktypecutoff;
9503 if(!player[0].dead&&player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2&&((tutoriallevel!=1||cananger)&&hostile)){
9504 player[i].losupdatedelay=.2;
9505 if(findDistancefast(&player[i].coords,&player[0].coords)<4&&animation[player[i].targetanimation].height!=lowheight)
9506 {player[i].aitype=attacktypecutoff;
9507 player[i].lastseentime=1;}
9508 if(abs(Random()%2)||animation[player[i].targetanimation].height!=lowheight)
9509 if(findDistancefast(&player[i].coords,&player[0].coords)<400)
9510 if(normaldotproduct(player[i].facing,player[0].coords-player[i].coords)>0)
9511 if((-1==checkcollide(DoRotation(player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position,0,player[i].rotation,0)*player[i].scale+player[i].coords,DoRotation(player[0].skeleton.joints[player[0].skeleton.jointlabels[head]].position,0,player[0].rotation,0)*player[0].scale+player[0].coords))||(player[j].targetanimation==hanganim&&normaldotproduct(player[j].facing,player[i].coords-player[j].coords)<0)){
9512 player[i].aitype=attacktypecutoff;
9513 player[i].lastseentime=1;
9516 if(player[i].lastseentime<0){
9517 //player[i].aitype=passivetype;
9519 player[i].aitype=pathfindtype;
9520 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9521 player[i].finalpathfindpoint=-1;
9522 player[i].targetpathfindpoint=-1;
9523 player[i].lastpathfindpoint=-1;
9524 player[i].lastpathfindpoint2=-1;
9525 player[i].lastpathfindpoint3=-1;
9526 player[i].lastpathfindpoint4=-1;
9530 if(player[i].aitype!=gethelptype){
9531 player[i].runninghowlong=0;
9534 if(player[i].aitype==gethelptype){
9535 player[i].runninghowlong+=multiplier;
9536 player[i].aiupdatedelay-=multiplier;
9538 if(player[i].aiupdatedelay<0||player[i].ally==0){
9539 player[i].aiupdatedelay=.2;
9547 if(!player[i].ally){
9548 for(j=0;j<numplayers;j++){
9549 if(j!=i&&j!=0&&!player[j].dead&&player[j].howactive<typedead1&&!player[j].skeleton.free&&player[j].aitype==passivetype){
9550 distance=findDistancefast(&player[i].coords,&player[j].coords);
9551 if(closestdist==-1||distance<closestdist){
9552 closestdist=distance;
9558 if(closest!=-1)player[i].ally=closest;
9559 else player[i].ally=0;
9560 player[i].lastseen=player[0].coords;
9561 player[i].lastseentime=12;
9565 player[i].lastchecktime=12;
9566 //player[i].lastseentime-=.5;
9568 facing=player[i].coords;
9569 flatfacing=player[player[i].ally].coords;
9570 facing.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position.y*player[i].scale;
9571 flatfacing.y+=player[player[i].ally].skeleton.joints[player[player[i].ally].skeleton.jointlabels[head]].position.y*player[player[i].ally].scale;
9572 if(-1!=checkcollide(facing,flatfacing))
9573 player[i].lastseentime-=.1;
9575 if(player[i].ally<=0||player[player[i].ally].skeleton.free||player[player[i].ally].aitype!=passivetype||player[i].lastseentime<=0){
9576 player[i].aitype=searchtype;
9577 player[i].lastseentime=12;
9580 if(player[i].ally>0){
9581 rotatetarget=player[player[i].ally].coords-player[i].coords;
9582 Normalise(&rotatetarget);
9583 player[i].targetrotation=-asin(0-rotatetarget.x);
9584 player[i].targetrotation*=360/6.28;
9585 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9586 player[i].lookrotation=player[i].targetrotation;
9587 player[i].aiupdatedelay=.05;
9588 player[i].forwardkeydown=1;
9590 if(findDistancefastflat(&player[i].coords,&player[player[i].ally].coords)<3){
9591 player[i].aitype=searchtype;
9592 player[i].lastseentime=12;
9593 player[player[i].ally].aitype=searchtype;
9594 if(player[player[i].ally].lastseentime<player[i].lastseentime){
9595 player[player[i].ally].lastseen=player[i].lastseen;
9596 player[player[i].ally].lastseentime=player[i].lastseentime;
9597 player[player[i].ally].lastchecktime=player[i].lastchecktime;
9601 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9602 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9604 XYZ leftpos,rightpos;
9605 float leftdist,rightdist;
9606 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9607 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9608 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9609 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9610 if(leftdist<rightdist)player[i].targetrotation+=90;
9611 else player[i].targetrotation-=90;
9616 player[i].leftkeydown=0;
9617 player[i].backkeydown=0;
9618 player[i].rightkeydown=0;
9619 player[i].crouchkeydown=0;
9620 player[i].attackkeydown=0;
9622 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9623 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9626 if(player[i].aitype==getweapontype){
9627 player[i].aiupdatedelay-=multiplier;
9628 player[i].lastchecktime-=multiplier;
9630 if(player[i].aiupdatedelay<0){
9631 player[i].aiupdatedelay=.2;
9639 if(player[i].ally<0){
9640 for(j=0;j<weapons.numweapons;j++){
9641 if(weapons.owner[j]==-1){
9642 distance=findDistancefast(&player[i].coords,&weapons.position[j]);
9643 if(closestdist==-1||distance<closestdist){
9644 closestdist=distance;
9650 if(closest!=-1)player[i].ally=closest;
9651 else player[i].ally=-1;
9654 player[i].lastseentime=12;
9656 if(!player[0].dead&&((tutoriallevel!=1||cananger)&&hostile))
9657 if(player[i].ally<0||player[i].weaponactive!=-1||player[i].lastchecktime<=0){
9658 player[i].aitype=attacktypecutoff;
9659 player[i].lastseentime=1;
9662 if(player[i].ally>=0){
9663 if(weapons.owner[player[i].ally]!=-1||findDistancefast(&player[i].coords,&weapons.position[player[i].ally])>16){
9664 player[i].aitype=attacktypecutoff;
9665 player[i].lastseentime=1;
9667 rotatetarget=weapons.position[player[i].ally]-player[i].coords;
9668 Normalise(&rotatetarget);
9669 player[i].targetrotation=-asin(0-rotatetarget.x);
9670 player[i].targetrotation*=360/6.28;
9671 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9672 player[i].lookrotation=player[i].targetrotation;
9673 player[i].aiupdatedelay=.05;
9674 player[i].forwardkeydown=1;
9677 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9678 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9680 XYZ leftpos,rightpos;
9681 float leftdist,rightdist;
9682 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9683 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9684 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9685 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9686 if(leftdist<rightdist)player[i].targetrotation+=90;
9687 else player[i].targetrotation-=90;
9690 /*if(findDistancefast(&player[i].coords,&weapons.position[player[i].ally])<3){
9691 if(abs(Random()%6)){
9692 player[i].crouchkeydown=1;
9693 if(!findDistancefast(&player[i].coords,&weapons.position[player[i].ally])<1){
9694 if(player[i].isRun()){
9695 player[i].targetframe=0;
9697 player[i].targetanimation=sneakanim;
9700 else player[i].forwardkeydown=0;
9702 else player[i].crouchkeydown=0;
9704 else player[i].crouchkeydown=0;*/
9707 player[i].leftkeydown=0;
9708 player[i].backkeydown=0;
9709 player[i].rightkeydown=0;
9710 player[i].attackkeydown=0;
9711 player[i].throwkeydown=1;
9712 player[i].crouchkeydown=0;
9713 if(player[i].targetanimation!=crouchremoveknifeanim&&player[i].targetanimation!=removeknifeanim)player[i].throwtogglekeydown=0;
9714 player[i].drawkeydown=0;
9716 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9717 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9720 if(player[i].aitype==attacktypecutoff){
9721 player[i].aiupdatedelay-=multiplier;
9722 if(player[i].damage<player[i].damagetolerance*2/3)
9723 if((player[0].targetanimation==rabbitkickanim||player[0].targetanimation==knifethrowanim||(player[0].isFlip()&&normaldotproduct(player[0].facing,player[0].coords-player[i].coords)<0))&&!player[0].skeleton.free&&(player[i].aiupdatedelay<.1)){
9724 player[i].attackkeydown=0;
9725 if(player[i].isIdle())player[i].crouchkeydown=1;
9726 if(player[0].targetanimation!=rabbitkickanim&&player[0].weaponactive!=-1){
9727 if(weapons.type[player[0].weaponids[0]]==knife){
9728 if(player[i].isIdle()||player[i].isCrouch()||player[i].isRun()||player[i].isFlip()){
9729 if(abs(Random()%2==0))player[i].targetanimation=backhandspringanim;
9730 else player[i].targetanimation=rollanim;
9732 player[i].targetframe=0;
9733 player[i].targetrotation+=90*(abs(Random()%2)*2-1);
9734 player[i].wentforweapon=0;
9736 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim){
9737 player[i].targetanimation=flipanim;
9739 player[i].targetframe=0;
9743 player[i].forwardkeydown=0;
9744 player[i].aiupdatedelay=.02;
9746 if(player[0].isFlip()&&!player[0].skeleton.free&&player[0].targetanimation!=walljumprightkickanim&&player[0].targetanimation!=walljumpleftkickanim){
9747 if(findDistancefast(&player[0].coords,&player[i].coords)<25)
9748 if((1-player[i].damage/player[i].damagetolerance)>.5)player[i].stunned=1;
9750 if(player[i].wentforweapon<3)
9751 for(j=0;j<weapons.numweapons;j++){
9752 if(player[i].creature!=wolftype)
9753 if(player[i].num_weapons==0&&weapons.owner[j]==-1&&weapons.velocity[i].x==0&&weapons.velocity[i].z==0&&weapons.velocity[i].y==0){
9754 if(findDistancefast(&player[i].coords,&weapons.position[j])<16){
9755 player[i].wentforweapon++;
9756 player[i].lastchecktime=6;
9757 player[i].aitype=getweapontype;
9762 if(player[i].damage<player[i].damagetolerance/2)
9763 if(animation[player[i].targetanimation].height!=highheight)
9764 if(player[i].damage<player[i].damagetolerance*.5&&((player[0].targetanimation==walljumprightkickanim||player[0].targetanimation==walljumpleftkickanim)&&((player[i].aiupdatedelay<.15&&difficulty==2)||(player[i].aiupdatedelay<.08&&difficulty!=2)))){
9765 player[i].crouchkeydown=1;
9767 if(player[i].isRun()&&!player[i].onground){
9768 if(player[i].coords.y>terrain.getHeight(player[i].coords.x,player[i].coords.z)+10){
9769 test2=player[i].coords+player[i].facing;
9771 test=player[i].coords+player[i].facing;
9773 j=checkcollide(test2,test,player[i].laststanding);
9774 if(j==-1)j=checkcollide(test2,test);
9776 player[i].velocity=0;
9777 player[i].targetanimation=player[i].getStop();
9778 player[i].targetframe=0;
9780 player[i].targetrotation+=180;
9781 player[i].stunned=.5;
9782 //player[i].aitype=passivetype;
9783 player[i].aitype=pathfindtype;
9784 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9785 player[i].finalpathfindpoint=-1;
9786 player[i].targetpathfindpoint=-1;
9787 player[i].lastpathfindpoint=-1;
9788 player[i].lastpathfindpoint2=-1;
9789 player[i].lastpathfindpoint3=-1;
9790 player[i].lastpathfindpoint4=-1;
9792 else player[i].laststanding=j;
9795 if(player[0].coords.y>player[i].coords.y+5&&animation[player[0].targetanimation].height!=highheight&&!player[0].onterrain){
9796 player[i].aitype=pathfindtype;
9797 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9798 player[i].finalpathfindpoint=-1;
9799 player[i].targetpathfindpoint=-1;
9800 player[i].lastpathfindpoint=-1;
9801 player[i].lastpathfindpoint2=-1;
9802 player[i].lastpathfindpoint3=-1;
9803 player[i].lastpathfindpoint4=-1;
9805 if(player[i].aiupdatedelay<0&&!animation[player[i].targetanimation].attack&&player[i].targetanimation!=staggerbackhighanim&&player[i].targetanimation!=staggerbackhardanim&&player[i].targetanimation!=backhandspringanim&&player[i].targetanimation!=dodgebackanim){
9806 if(player[i].weaponactive==-1&&player[i].num_weapons>0)player[i].drawkeydown=Random()%2;
9807 else player[i].drawkeydown=0;
9808 player[i].rabbitkickenabled=Random()%2;
9809 rotatetarget=player[player[i].aitarget].coords+player[player[i].aitarget].velocity;
9810 if(findDistancefast(&player[player[i].aitarget].coords,&player[i].coords)<findDistancefast(&rotatetarget,&player[i].coords))
9811 rotatetarget=player[player[i].aitarget].coords+player[player[i].aitarget].velocity*findDistance(&player[player[i].aitarget].coords,&player[i].coords)/findLength(&player[i].velocity)-player[i].coords;
9812 else rotatetarget=player[player[i].aitarget].coords-player[i].coords;
9813 Normalise(&rotatetarget);
9814 player[i].targetrotation=-asin(0-rotatetarget.x);
9815 player[i].targetrotation*=360/6.28;
9816 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9817 player[i].lookrotation=player[i].targetrotation;
9818 player[i].aiupdatedelay=.2+abs((float)(Random()%100)/1000);
9820 oldkey=player[i].forwardkeydown;
9821 if(findDistancefast(&player[i].coords,&player[0].coords)>5&&(player[0].weaponactive==-1||player[i].weaponactive!=-1))player[i].forwardkeydown=1;
9822 else if((findDistancefast(&player[i].coords,&player[0].coords)>16||findDistancefast(&player[i].coords,&player[0].coords)<9)&&player[0].weaponactive!=-1)player[i].forwardkeydown=1;
9823 else if(Random()%6==0||(player[i].creature==wolftype&&Random()%3==0))player[i].forwardkeydown=1;
9824 else player[i].forwardkeydown=0;
9826 player[i].forwardkeydown=0;
9827 if(Random()%10==0)player[i].forwardkeydown=1;
9828 if(Random()%100==0){
9829 player[i].aitype=pathfindtype;
9830 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9831 player[i].finalpathfindpoint=-1;
9832 player[i].targetpathfindpoint=-1;
9833 player[i].lastpathfindpoint=-1;
9834 player[i].lastpathfindpoint2=-1;
9835 player[i].lastpathfindpoint3=-1;
9836 player[i].lastpathfindpoint4=-1;
9839 player[i].leftkeydown=0;
9840 player[i].backkeydown=0;
9841 player[i].rightkeydown=0;
9842 player[i].crouchkeydown=0;
9843 player[i].throwkeydown=0;
9845 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9846 /*for(j=0;j<numplayers;j++){
9847 if(player[j].victim->id==i&&(player[j].targetanimation==spinkickanim&&player[j].targetframe<3)){
9848 player[i].crouchkeydown=1;
9851 if(Random()%2==0/*||player[0].weaponactive!=-1*/||player[i].weaponactive!=-1||player[i].creature==wolftype)player[i].attackkeydown=1;
9852 else player[i].attackkeydown=0;
9853 if((player[i].isRun())&&Random()%6&&findDistancefast(&player[i].coords,&player[0].coords)>7)player[i].attackkeydown=0;
9854 //if(player[i].attackkeydown&&findDistancefast(&player[i].coords,&player[0].coords)<3&&player[i].targetanimation!=runanim&&!player[0].skeleton.free)player[i].crouchkeydown=1;
9855 /*if(player[0].targetanimation==rabbitkickanim&&!player[0].skeleton.free){
9856 player[i].attackkeydown=0;
9857 if(player[i].isIdle())player[i].crouchkeydown=1;
9858 player[i].forwardkeydown=0;
9859 player[i].aiupdatedelay=.02;
9862 if(player[i].aitype!=playercontrolled&&(player[i].isIdle()||player[i].isCrouch()||player[i].isRun())){
9864 for(j=0;j<numplayers;j++){
9865 if(j!=i&&!player[j].skeleton.free&&player[j].hasvictim&&((tutoriallevel==1&&reversaltrain)||(Random()%2==0&&difficulty==2)||(Random()%4==0&&difficulty==1)||(Random()%8==0&&difficulty==0)||(player[j].lastattack2==player[j].targetanimation&&player[j].lastattack3==player[j].targetanimation&&(Random()%2==0||difficulty==2))||((player[i].isIdle()||player[i].isRun())&&player[j].weaponactive!=-1)||(player[j].targetanimation==swordslashanim&&player[i].weaponactive!=-1)||player[j].targetanimation==staffhitanim||player[j].targetanimation==staffspinhitanim)){
9866 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<4&&player[j].victim==&player[i]&&(player[j].targetanimation==sweepanim||player[j].targetanimation==spinkickanim||player[j].targetanimation==staffhitanim||player[j].targetanimation==staffspinhitanim||player[j].targetanimation==winduppunchanim||player[j].targetanimation==upunchanim||player[j].targetanimation==wolfslapanim||player[j].targetanimation==knifeslashstartanim||((player[j].targetanimation==swordslashanim)&&(findDistancefast(&player[j].coords,&player[i].coords)<2||(player[i].weaponactive!=-1))))){
9867 if(target>=0)target=-1;
9872 if(target>=0)player[target].Reverse();
9875 if(player[i].collided<1)player[i].jumpkeydown=0;
9876 if((player[i].collided>.8&&player[i].jumppower>=5)||(findDistancefast(&player[i].coords,&player[0].coords)>400&&player[i].onterrain&&player[i].creature==rabbittype))player[i].jumpkeydown=1;
9877 if(normaldotproduct(player[i].facing,player[0].coords-player[i].coords)>0)
9878 player[0].jumpkeydown=0;
9879 if(player[0].targetanimation==jumpdownanim&&findDistancefast(&player[0].coords,&player[i].coords)<40)player[i].crouchkeydown=1;
9880 if(player[i].jumpkeydown)player[i].attackkeydown=0;
9881 //if(animation[player[i].targetanimation].attack==reversed)player[i].crouchkeydown=1;
9883 if(tutoriallevel==1){
9884 if(!canattack)player[i].attackkeydown=0;
9888 facing=player[i].coords;
9889 flatfacing=player[0].coords;
9890 facing.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position.y*player[i].scale;
9891 flatfacing.y+=player[0].skeleton.joints[player[0].skeleton.jointlabels[head]].position.y*player[0].scale;
9892 if(player[i].occluded>=2)
9893 if(-1!=checkcollide(facing,flatfacing)){
9894 if(!player[i].pause)player[i].lastseentime-=.2;
9895 if(player[i].lastseentime<=0&&(player[i].creature!=wolftype||player[i].weaponstuck==-1)){
9896 player[i].aitype=searchtype;
9897 player[i].lastchecktime=12;
9898 player[i].lastseen=player[0].coords;
9899 player[i].lastseentime=12;
9902 else player[i].lastseentime=1;
9905 if(animation[player[0].targetanimation].height==highheight&&(player[i].aitype==attacktypecutoff||player[i].aitype==searchtype)){
9906 if(player[0].coords.y>terrain.getHeight(player[0].coords.x,player[0].coords.z)+10){
9907 test=player[0].coords;
9909 if(-1==checkcollide(player[0].coords,test))player[i].stunned=1;
9912 // NOTE: Ask about logic of this call : NOTE
9913 if((player[i].aitype==passivetype && !(player[i].numwaypoints>1)) ||
9914 player[i].stunned>0 ||
9915 (player[i].pause && (player[i].damage > player[i].superpermanentdamage)))
9917 if(/*player[i].aitype==attacktypecutoff&&*/player[i].pause)player[i].lastseentime=1;
9918 player[i].targetrotation=player[i].rotation;
9919 player[i].forwardkeydown=0;
9920 player[i].leftkeydown=0;
9921 player[i].backkeydown=0;
9922 player[i].rightkeydown=0;
9923 player[i].jumpkeydown=0;
9924 player[i].attackkeydown=0;
9925 player[i].crouchkeydown=0;
9926 player[i].throwkeydown=0;
9933 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
9936 if(player[i].aitype==attacktypecutoff){
9937 rotatetarget=player[0].coords-player[i].coords;
9938 Normalise(&rotatetarget);
9939 player[i].targetheadrotation=-asin(0-rotatetarget.x);
9940 player[i].targetheadrotation*=360/6.28;
9941 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
9943 player[i].targetheadrotation*=-1;
9944 player[i].targetheadrotation+=180;
9945 //player[i].targetheadrotation2=0;
9946 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
9948 else if(player[i].howactive>=typesleeping){
9949 player[i].targetheadrotation=player[i].targetrotation;
9950 player[i].targetheadrotation2=0;
9953 if(player[i].interestdelay<=0){
9954 player[i].interestdelay=.7+(float)(abs(Random()%100))/100;
9955 player[i].headtarget=player[i].coords;
9956 player[i].headtarget.x+=(float)(abs(Random()%200)-100)/100;
9957 player[i].headtarget.z+=(float)(abs(Random()%200)-100)/100;
9958 player[i].headtarget.y+=(float)(abs(Random()%200)-100)/300;
9959 player[i].headtarget+=player[i].facing*1.5;
9961 rotatetarget=player[i].headtarget-player[i].coords;
9962 Normalise(&rotatetarget);
9963 player[i].targetheadrotation=-asin(0-rotatetarget.x);
9964 player[i].targetheadrotation*=360/6.28;
9965 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
9967 player[i].targetheadrotation*=-1;
9968 player[i].targetheadrotation+=180;
9969 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
9971 //if(whichlevel==2)player[i].jumpkeydown=0;
9973 if(animation[player[i].targetanimation].attack==reversed){
9974 //player[i].targetrotation=player[i].rotation;
9975 player[i].forwardkeydown=0;
9976 player[i].leftkeydown=0;
9977 player[i].backkeydown=0;
9978 player[i].rightkeydown=0;
9979 player[i].jumpkeydown=0;
9980 player[i].attackkeydown=0;
9981 //player[i].crouchkeydown=0;
9982 player[i].throwkeydown=0;
9986 player[i].forwardkeydown=0;
9987 player[i].leftkeydown=0;
9988 player[i].backkeydown=0;
9989 player[i].rightkeydown=0;
9990 player[i].jumpkeydown=0;
9991 player[i].crouchkeydown=0;
9992 player[i].drawkeydown=0;
9993 player[i].throwkeydown=0;
9996 if(player[i].collided<-.3)player[i].collided=-.3;
9997 if(player[i].collided>1)player[i].collided=1;
9998 player[i].collided-=multiplier*4;
9999 player[i].whichdirectiondelay-=multiplier;
10000 if(player[i].avoidcollided<-.3||player[i].whichdirectiondelay<=0){
10001 player[i].avoidcollided=-.3;
10002 player[i].whichdirection=abs(Random()%2);
10003 player[i].whichdirectiondelay=.4;
10005 if(player[i].avoidcollided>1)player[i].avoidcollided=1;
10006 player[i].avoidcollided-=multiplier/4;
10007 if(!player[i].skeleton.free)player[i].stunned-=multiplier;
10008 if(!player[i].skeleton.free)player[i].surprised-=multiplier;
10009 if(player[i].surprised<=0&&player[i].aitype==attacktypecutoff&&i!=0&&!player[i].dead&&!player[i].skeleton.free&&animation[player[i].targetanimation].attack==neutral)numresponded=1;
10011 if(!player[i].throwkeydown){
10012 player[i].throwtogglekeydown=0;
10014 if(player[i].throwkeydown&&!player[i].throwtogglekeydown){
10015 if(player[i].weaponactive==-1&&player[i].num_weapons<2&&(player[i].isIdle()||player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim||player[i].isFlip()||player[i].isFlip()||player[i].aitype!=playercontrolled)){
10016 for(j=0;j<weapons.numweapons;j++){
10017 if(((weapons.velocity[j].x==0&&weapons.velocity[j].y==0&&weapons.velocity[j].z==0)||player[i].aitype==playercontrolled)&&weapons.owner[j]==-1&&player[i].weaponactive==-1)
10018 if(findDistancefastflat(&player[i].coords,&weapons.position[j])<2){
10019 if(findDistancefast(&player[i].coords,&weapons.position[j])<2){
10020 if(player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isRun()||player[i].isIdle()||player[i].aitype!=playercontrolled){
10021 player[i].throwtogglekeydown=1;
10022 player[i].targetanimation=crouchremoveknifeanim;
10023 player[i].target=0;
10024 player[i].targetframe=0;
10025 rotatetarget=weapons.position[j]-player[i].coords;
10026 Normalise(&rotatetarget);
10027 player[i].targetrotation=-asin(0-rotatetarget.x);
10028 player[i].targetrotation*=360/6.28;
10029 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10030 player[i].hasvictim=0;
10032 if(player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
10033 player[i].throwtogglekeydown=1;
10034 player[i].hasvictim=0;
10036 //for(i=0;i<weapons.numweapons;i++){
10037 if((((weapons.velocity[j].x==0&&weapons.velocity[j].y==0&&weapons.velocity[j].z==0)||player[i].aitype==playercontrolled)&&weapons.owner[j]==-1)||(player[i].victim&&weapons.owner[j]==player[i].victim->id))
10038 if(findDistancefastflat(&player[i].coords,&weapons.position[j])<2&&player[i].weaponactive==-1){
10039 if(findDistancefast(&player[i].coords,&weapons.position[j])<1||player[i].victim){
10042 gLoc[0]=player[i].coords.x;
10043 gLoc[1]=player[i].coords.y;
10044 gLoc[2]=player[i].coords.z;
10045 vel[0]=player[i].velocity.x;
10046 vel[1]=player[i].velocity.y;
10047 vel[2]=player[i].velocity.z;
10048 if(weapons.type[j]!=staff){
10049 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, TRUE);
10050 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
10051 FSOUND_SetVolume(channels[knifedrawsound], 128);
10052 FSOUND_SetPaused(channels[knifedrawsound], FALSE);
10055 player[i].weaponactive=0;
10056 weapons.owner[j]=player[i].id;
10057 if(player[i].num_weapons>0){
10058 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
10060 player[i].num_weapons++;
10061 player[i].weaponids[0]=j;
10067 else if ((player[i].isIdle()||player[i].isFlip()||player[i].aitype!=playercontrolled)&&findDistancefast(&player[i].coords,&weapons.position[j])<5&&player[i].coords.y<weapons.position[j].y){
10068 if(!player[i].isFlip()){
10069 player[i].throwtogglekeydown=1;
10070 player[i].targetanimation=removeknifeanim;
10071 player[i].target=0;
10072 player[i].targetframe=0;
10073 rotatetarget=weapons.position[j]-player[i].coords;
10074 Normalise(&rotatetarget);
10075 player[i].targetrotation=-asin(0-rotatetarget.x);
10076 player[i].targetrotation*=360/6.28;
10077 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10079 if(player[i].isFlip()){
10080 player[i].throwtogglekeydown=1;
10081 player[i].hasvictim=0;
10083 for(k=0;k<weapons.numweapons;k++){
10084 if(player[i].weaponactive==-1)
10085 if((((weapons.velocity[k].x==0&&weapons.velocity[k].y==0&&weapons.velocity[k].z==0)||player[i].aitype==playercontrolled)&&weapons.owner[k]==-1)||(player[i].victim&&weapons.owner[k]==player[i].victim->id))
10086 if(findDistancefastflat(&player[i].coords,&weapons.position[k])<3&&player[i].weaponactive==-1){
10089 gLoc[0]=player[i].coords.x;
10090 gLoc[1]=player[i].coords.y;
10091 gLoc[2]=player[i].coords.z;
10092 vel[0]=player[i].velocity.x;
10093 vel[1]=player[i].velocity.y;
10094 vel[2]=player[i].velocity.z;
10095 if(weapons.type[k]!=staff){
10096 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, TRUE);
10097 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
10098 FSOUND_SetVolume(channels[knifedrawsound], 128);
10099 FSOUND_SetPaused(channels[knifedrawsound], FALSE);
10102 player[i].weaponactive=0;
10103 weapons.owner[k]=player[i].id;
10104 if(player[i].num_weapons>0){
10105 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
10107 player[i].num_weapons++;
10108 player[i].weaponids[0]=k;
10115 if(player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isRun()||player[i].isIdle()||player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
10117 for(j=0;j<numplayers;j++){
10118 if(player[i].weaponactive==-1)
10120 if(player[j].num_weapons&&player[j].skeleton.free&&findDistancefast(&player[i].coords,&player[j].coords)<2/*&&player[j].dead*/&&(((player[j].skeleton.forward.y<0&&player[j].weaponstuckwhere==0)||(player[j].skeleton.forward.y>0&&player[j].weaponstuckwhere==1))||player[j].weaponstuck==-1||player[j].num_weapons>1)){
10121 if(player[i].targetanimation!=rollanim&&player[i].targetanimation!=backhandspringanim){
10122 player[i].throwtogglekeydown=1;
10123 player[i].victim=&player[j];
10124 player[i].hasvictim=1;
10125 player[i].targetanimation=crouchremoveknifeanim;
10126 player[i].target=0;
10127 player[i].targetframe=0;
10128 rotatetarget=player[j].coords-player[i].coords;
10129 Normalise(&rotatetarget);
10130 player[i].targetrotation=-asin(0-rotatetarget.x);
10131 player[i].targetrotation*=360/6.28;
10132 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10134 if(player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
10135 player[i].throwtogglekeydown=1;
10136 player[i].victim=&player[j];
10137 player[i].hasvictim=1;
10138 int k = player[j].weaponids[0];
10139 if(player[i].hasvictim){
10142 gLoc[0]=player[i].coords.x;
10143 gLoc[1]=player[i].coords.y;
10144 gLoc[2]=player[i].coords.z;
10145 vel[0]=player[i].velocity.x;
10146 vel[1]=player[i].velocity.y;
10147 vel[2]=player[i].velocity.z;
10150 if(player[i].victim->weaponstuck!=-1){
10151 if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){
10156 if(weapons.type[k]!=staff){
10157 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, TRUE);
10158 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
10159 FSOUND_SetVolume(channels[knifedrawsound], 128);
10160 FSOUND_SetPaused(channels[knifedrawsound], FALSE);
10164 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, TRUE);
10165 FSOUND_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
10166 FSOUND_SetVolume(channels[fleshstabremovesound], 128);
10167 FSOUND_SetPaused(channels[fleshstabremovesound], FALSE);
10170 player[i].weaponactive=0;
10171 if(weapons.owner[k]!=-1){
10172 if(player[i].victim->num_weapons==1)player[i].victim->num_weapons=0;
10173 else player[i].victim->num_weapons=1;
10175 player[i].victim->skeleton.longdead=0;
10176 player[i].victim->skeleton.free=1;
10177 player[i].victim->skeleton.broken=0;
10179 for(int l=0;l<player[i].victim->skeleton.num_joints;l++){
10180 player[i].victim->skeleton.joints[l].velchange=0;
10181 player[i].victim->skeleton.joints[l].locked=0;
10187 Normalise(&relative);
10188 XYZ footvel,footpoint;
10190 footpoint=weapons.position[k];
10191 if(player[i].victim->weaponstuck!=-1){
10192 if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){
10193 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
10194 weapons.bloody[k]=2;
10195 weapons.blooddrip[k]=5;
10196 player[i].victim->weaponstuck=-1;
10197 player[i].victim->bloodloss+=2000;
10198 player[i].victim->DoDamage(2000);
10201 if(player[i].victim->num_weapons>0){
10202 if(player[i].victim->weaponstuck!=0&&player[i].victim->weaponstuck!=-1)player[i].victim->weaponstuck=0;
10203 if(player[i].victim->weaponids[0]==k)
10204 player[i].victim->weaponids[0]=player[i].victim->weaponids[player[i].victim->num_weapons];
10207 player[i].victim->weaponactive=-1;
10209 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[abdomen]].velocity+=relative*6;
10210 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[neck]].velocity+=relative*6;
10211 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6;
10212 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6;
10214 weapons.owner[k]=i;
10215 if(player[i].num_weapons>0){
10216 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
10218 player[i].num_weapons++;
10219 player[i].weaponids[0]=k;
10226 if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){
10227 if(weapons.type[player[i].weaponids[0]]==knife){
10228 if(player[i].isIdle()||player[i].isRun()||player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isFlip())
10230 for(j=0;j<numplayers;j++){
10232 if(tutoriallevel!=1||tutorialstage==49)
10234 if(normaldotproduct(player[i].facing,player[i].coords-player[j].coords)<0&&findDistancefast(&player[i].coords,&player[j].coords)<100&&findDistancefast(&player[i].coords,&player[j].coords)>1.5&&!player[j].skeleton.free&&-1==checkcollide(DoRotation(player[j].skeleton.joints[player[j].skeleton.jointlabels[head]].position,0,player[j].rotation,0)*player[j].scale+player[j].coords,DoRotation(player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position,0,player[i].rotation,0)*player[i].scale+player[i].coords)){
10235 if(!player[i].isFlip()){
10236 player[i].throwtogglekeydown=1;
10237 player[i].victim=&player[j];
10238 player[i].targetanimation=knifethrowanim;
10239 player[i].target=0;
10240 player[i].targetframe=0;
10241 rotatetarget=player[j].coords-player[i].coords;
10242 Normalise(&rotatetarget);
10243 player[i].targetrotation=-asin(0-rotatetarget.x);
10244 player[i].targetrotation*=360/6.28;
10245 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10247 player[i].targettilt2=-asin(rotatetarget.y)*360/6.28;
10249 if(player[i].isFlip()){
10250 if(player[i].weaponactive!=-1){
10251 player[i].throwtogglekeydown=1;
10252 player[i].victim=&player[j];
10254 weapons.owner[player[i].weaponids[0]]=-1;
10255 aim=player[i].victim->coords+DoRotation(player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[abdomen]].position,0,player[i].victim->rotation,0)*player[i].victim->scale+player[i].victim->velocity*findDistance(&player[i].victim->coords,&player[i].coords)/50-(player[i].coords+DoRotation(player[i].skeleton.joints[player[i].skeleton.jointlabels[righthand]].position,0,player[i].rotation,0)*player[i].scale);
10258 aim=DoRotation(aim,(float)abs(Random()%30)-15,(float)abs(Random()%30)-15,0);
10260 weapons.velocity[player[i].weaponids[0]]=aim*50;
10261 weapons.tipvelocity[player[i].weaponids[0]]=aim*50;
10262 weapons.missed[player[i].weaponids[0]]=0;
10263 weapons.freetime[player[i].weaponids[0]]=0;
10264 weapons.firstfree[player[i].weaponids[0]]=1;
10265 weapons.physics[player[i].weaponids[0]]=0;
10266 player[i].num_weapons--;
10267 if(player[i].num_weapons){
10268 player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons];
10270 player[i].weaponactive=-1;
10277 if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){
10278 if(player[i].isCrouch()||player[i].targetanimation==sneakanim)
10280 player[i].throwtogglekeydown=1;
10281 weapons.owner[player[i].weaponids[0]]=-1;
10282 weapons.velocity[player[i].weaponids[0]]=player[i].velocity*.2;
10283 if(weapons.velocity[player[i].weaponids[0]].x==0)weapons.velocity[player[i].weaponids[0]].x=.1;
10284 weapons.tipvelocity[player[i].weaponids[0]]=weapons.velocity[player[i].weaponids[0]];
10285 weapons.missed[player[i].weaponids[0]]=1;
10286 weapons.freetime[player[i].weaponids[0]]=0;
10287 weapons.firstfree[player[i].weaponids[0]]=1;
10288 weapons.physics[player[i].weaponids[0]]=1;
10289 player[i].num_weapons--;
10290 if(player[i].num_weapons){
10291 player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons];
10292 if(player[i].weaponstuck==player[i].num_weapons)player[i].weaponstuck=0;
10295 player[i].weaponactive=-1;
10296 for(j=0;j<numplayers;j++){
10297 player[j].wentforweapon=0;
10304 if(i==0||!player[0].dead||player[i].weaponactive!=-1)
10305 if((player[i].drawkeydown&&!player[i].drawtogglekeydown)||(player[i].num_weapons==2&&player[i].weaponactive==-1&&player[i].isIdle())||(player[0].dead&&player[i].weaponactive!=-1&&i!=0)){
10306 //Setenvironment(1-environment);
10309 if(player[i].weaponactive!=-1){
10310 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==staff)isgood=0;
10312 if(/*(player[i].weaponactive==-1||player[i].num_weapons==1)&&*/isgood&&player[i].creature!=wolftype){
10313 if(player[i].isIdle()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){
10314 player[i].targetanimation=drawrightanim;
10315 player[i].targetframe=0;
10316 player[i].target=0;
10317 player[i].drawtogglekeydown=1;
10319 if((player[i].isIdle()||(player[i].aitype!=playercontrolled&&player[0].weaponactive!=-1&&player[i].isRun()))&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==sword){
10320 player[i].targetanimation=drawleftanim;
10321 player[i].targetframe=0;
10322 player[i].target=0;
10323 player[i].drawtogglekeydown=1;
10325 if(player[i].isCrouch()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){
10326 player[i].targetanimation=crouchdrawrightanim;
10327 player[i].targetframe=0;
10328 player[i].target=0;
10329 player[i].drawtogglekeydown=1;
10333 if(player[i].isCrouch()&&weapons.bloody[player[i].weaponids[player[i].weaponactive]]&&bloodtoggle&&player[i].onterrain&&player[i].num_weapons&&player[i].weaponactive!=-1&&player[i].attackkeydown){
10334 if(weapons.bloody[player[i].weaponids[player[i].weaponactive]]&&player[i].onterrain&&bloodtoggle&&musictype!=stream_music2){
10335 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==knife)player[i].targetanimation=crouchstabanim;
10336 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==sword)player[i].targetanimation=swordgroundstabanim;
10337 player[i].targetframe=0;
10338 player[i].target=0;
10339 player[i].hasvictim=0;
10340 //player[i].attacktogglekeydown=1;
10344 if(!player[i].drawkeydown){
10345 player[i].drawtogglekeydown=0;
10350 absflatfacing.z=-1;
10352 absflatfacing=DoRotation(absflatfacing,0,-rotation,0);
10354 else absflatfacing=flatfacing;
10356 if(indialogue!=-1){
10357 player[i].forwardkeydown=0;
10358 player[i].leftkeydown=0;
10359 player[i].backkeydown=0;
10360 player[i].rightkeydown=0;
10361 player[i].jumpkeydown=0;
10362 player[i].crouchkeydown=0;
10363 player[i].drawkeydown=0;
10364 player[i].throwkeydown=0;
10368 if(!animation[player[i].targetanimation].attack&&player[i].targetanimation!=staggerbackhighanim&&player[i].targetanimation!=staggerbackhardanim&&player[i].targetanimation!=backhandspringanim&&player[i].targetanimation!=dodgebackanim){
10369 if(!player[i].forwardkeydown){
10370 player[i].forwardstogglekeydown=0;
10372 if(player[i].crouchkeydown){
10376 player[i].superruntoggle=1;
10378 for(j=0;j<numplayers;j++){
10379 if(j!=i&&!player[j].skeleton.free&&player[j].aitype==passivetype){
10380 if(findDistancefast(&player[j].coords,&player[i].coords)<16){
10381 player[i].superruntoggle=0;
10388 for(j=0;j<numplayers;j++){
10389 if(j!=i&&!player[j].skeleton.free&&player[j].victim&&player[i].lowreversaldelay<=0){
10390 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<3&&player[j].victim==&player[i]&&(player[j].targetanimation==sweepanim||player[j].targetanimation==upunchanim||player[j].targetanimation==wolfslapanim||((player[j].targetanimation==swordslashanim||player[j].targetanimation==knifeslashstartanim||player[j].targetanimation==staffhitanim||player[j].targetanimation==staffspinhitanim)&&findDistancefast(&player[j].coords,&player[i].coords)<2))){
10391 if(target>=0)target=-1;
10396 if(target>=0)player[target].Reverse();
10397 player[i].lowreversaldelay=.5;
10399 if(player[i].isIdle()){
10400 player[i].targetanimation=player[i].getCrouch();
10401 player[i].target=0;
10402 player[i].targetframe=0;
10403 player[i].transspeed=10;
10405 if(player[i].isRun()||(player[i].isStop()&&(player[i].leftkeydown||player[i].rightkeydown||player[i].forwardkeydown||player[i].backkeydown))){
10406 player[i].targetanimation=rollanim;
10407 player[i].target=0;
10408 player[i].targetframe=0;
10409 player[i].transspeed=20;
10412 if(!player[i].crouchkeydown){
10414 if(!player[i].isRun()&&player[i].targetanimation!=sneakanim&&i==0)player[i].superruntoggle=0;
10416 if(player[i].isCrouch()){
10418 for(j=0;j<numplayers;j++){
10419 if(j!=i&&!player[j].skeleton.free&&player[j].victim&&player[i].highreversaldelay<=0){
10420 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<3&&player[j].victim==&player[i]&&(player[j].targetanimation==spinkickanim)&&player[i].isCrouch()){
10421 if(target>=0)target=-1;
10426 if(target>=0)player[target].Reverse();
10427 player[i].highreversaldelay=.5;
10429 if(player[i].isCrouch()){
10430 if(!player[i].wasCrouch()){
10431 player[i].currentanimation=player[i].getCrouch();
10432 player[i].currentframe=0;
10434 player[i].target=0;
10435 player[i].targetanimation=player[i].getIdle();
10436 player[i].targetframe=0;
10437 player[i].transspeed=10;
10440 if(player[i].targetanimation==sneakanim){
10441 player[i].targetanimation=player[i].getIdle();
10442 player[i].target=0;
10443 player[i].targetframe=0;
10444 player[i].transspeed=10;
10447 if(player[i].forwardkeydown){
10448 if(player[i].isIdle()||(player[i].isStop()&&player[i].targetrotation==player[i].rotation)||(player[i].isLanding()&&player[i].targetframe>0&&!player[i].jumpkeydown)||(player[i].isLandhard()&&player[i].targetframe>0&&!player[i].jumpkeydown&&player[i].crouchkeydown)){
10449 if(player[i].aitype==passivetype)player[i].targetanimation=walkanim;
10450 else player[i].targetanimation=player[i].getRun();
10451 player[i].target=0;
10452 player[i].targetframe=0;
10454 if(player[i].isCrouch()){
10455 player[i].targetanimation=sneakanim;
10456 if(player[i].wasCrouch())player[i].target=0;
10457 player[i].targetframe=0;
10459 if(player[i].targetanimation==hanganim/*&&(!player[i].forwardstogglekeydown||player[i].aitype!=playercontrolled)*/){
10460 player[i].targetanimation=climbanim;
10461 player[i].target=0;
10462 player[i].targetframe=1;
10463 player[i].jumpclimb=1;
10465 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10466 player[i].velocity+=absflatfacing*5*multiplier;
10468 player[i].forwardstogglekeydown=1;
10471 if (player[i].rightkeydown){
10472 if(player[i].isIdle()||(player[i].isStop()&&player[i].targetrotation==player[i].rotation)||(player[i].isLanding()&&player[i].targetframe>0&&!player[i].jumpkeydown)||(player[i].isLandhard()&&player[i].targetframe>0&&!player[i].jumpkeydown&&player[i].crouchkeydown)){
10473 player[i].targetanimation=player[i].getRun();
10474 player[i].target=0;
10475 player[i].targetframe=0;
10477 if(player[i].isCrouch()){
10478 player[i].targetanimation=sneakanim;
10479 if(player[i].wasCrouch()) player[i].target=0;
10480 player[i].targetframe=0;
10482 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10483 player[i].velocity+=DoRotation(absflatfacing*5*multiplier,0,-90,0);
10485 player[i].targetrotation-=90;
10486 if(player[i].forwardkeydown)player[i].targetrotation+=45;
10487 if(player[i].backkeydown)player[i].targetrotation-=45;
10490 if ( player[i].leftkeydown){
10491 if(player[i].isIdle()||(player[i].isStop()&&player[i].targetrotation==player[i].rotation)||(player[i].isLanding()&&player[i].targetframe>0&&!player[i].jumpkeydown)||(player[i].isLandhard()&&player[i].targetframe>0&&!player[i].jumpkeydown&&player[i].crouchkeydown)){
10492 player[i].targetanimation=player[i].getRun();
10493 player[i].target=0;
10494 player[i].targetframe=0;
10496 if(player[i].isCrouch()){
10497 player[i].targetanimation=sneakanim;
10498 if(player[i].wasCrouch())player[i].target=0;
10499 player[i].targetframe=0;
10501 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10502 player[i].velocity-=DoRotation(absflatfacing*5*multiplier,0,-90,0);
10504 player[i].targetrotation+=90;
10505 if(player[i].forwardkeydown)player[i].targetrotation-=45;
10506 if(player[i].backkeydown)player[i].targetrotation+=45;
10509 if(player[i].backkeydown){
10510 if(player[i].isIdle()||(player[i].isStop()&&player[i].targetrotation==player[i].rotation)||(player[i].isLanding()&&player[i].targetframe>0&&!player[i].jumpkeydown)||(player[i].isLandhard()&&player[i].targetframe>0&&!player[i].jumpkeydown&&player[i].crouchkeydown)){
10511 player[i].targetanimation=player[i].getRun();
10512 player[i].target=0;
10513 player[i].targetframe=0;
10515 if(player[i].isCrouch()){
10516 player[i].targetanimation=sneakanim;
10517 if(player[i].wasCrouch())player[i].target=0;
10518 player[i].targetframe=0;
10520 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10521 player[i].velocity-=absflatfacing*5*multiplier;
10523 if(player[i].targetanimation==hanganim){
10524 player[i].currentanimation=jumpdownanim;
10525 player[i].targetanimation=jumpdownanim;
10526 player[i].target=0;
10527 player[i].currentframe=0;
10528 player[i].targetframe=1;
10529 player[i].velocity=0;
10530 player[i].velocity.y+=gravity;
10531 player[i].coords.y-=1.4;
10532 player[i].grabdelay=1;
10534 if ( !player[i].leftkeydown&&!player[i].rightkeydown)
10535 player[i].targetrotation+=180;
10538 if((player[i].jumpkeydown&&!player[i].jumpclimb)||player[i].jumpstart){
10539 if((((player[i].isLanding()&&player[i].targetframe>=3)||player[i].isRun()||player[i].targetanimation==walkanim||player[i].isCrouch()||player[i].targetanimation==sneakanim)&&player[i].jumppower>1)&&((player[i].targetanimation!=rabbitrunninganim&&player[i].targetanimation!=wolfrunninganim)||i!=0)){
10540 player[i].jumpstart=0;
10541 player[i].targetanimation=jumpupanim;
10542 player[i].target=0;
10543 player[i].targetframe=0;
10544 player[i].rotation=player[i].targetrotation;
10545 player[i].transspeed=20;
10546 player[i].FootLand(0,1);
10547 player[i].FootLand(1,1);
10551 flatfacing=DoRotation(facing,0,player[i].targetrotation+180,0);
10553 if(movekey)player[i].velocity=flatfacing*player[i].speed*45*player[i].scale;
10554 if(!movekey)player[i].velocity=0;
10559 for(j=0;j<numplayers;j++){
10560 if(j!=i&&!player[j].skeleton.free&&player[j].victim){
10561 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<3&&player[j].victim==&player[i]&&(player[j].targetanimation==sweepanim)){
10562 if(target>=0)target=-1;
10567 if(target>=0)player[i].velocity.y=1;
10568 else if(player[i].crouchkeydown||player[i].aitype!=playercontrolled){
10569 player[i].velocity.y=7;
10570 player[i].crouchtogglekeydown=1;
10572 else player[i].velocity.y=5;
10574 if(mousejump&&i==0&&debugmode){
10575 if(!player[i].isLanding())player[i].tempdeltav=deltav;
10576 if(player[i].tempdeltav<0)player[i].velocity.y-=(float)(player[i].tempdeltav)/multiplier/1000;
10579 player[i].coords.y+=.2;
10580 player[i].jumppower-=1;
10582 static float gLoc[3];
10583 static float vel[3];
10584 gLoc[0]=player[i].coords.x;
10585 gLoc[1]=player[i].coords.y;
10586 gLoc[2]=player[i].coords.z;
10587 vel[0]=player[i].velocity.x;
10588 vel[1]=player[i].velocity.y;
10589 vel[2]=player[i].velocity.z;
10592 PlaySoundEx( whooshsound, samp[whooshsound], NULL, TRUE);
10593 FSOUND_3D_SetAttributes(channels[whooshsound], gLoc, vel);
10594 FSOUND_SetVolume(channels[whooshsound], 128);
10595 FSOUND_SetPaused(channels[whooshsound], FALSE);
10598 PlaySoundEx( jumpsound, samp[jumpsound], NULL, TRUE);
10599 FSOUND_3D_SetAttributes(channels[jumpsound], gLoc, vel);
10600 FSOUND_SetVolume(channels[jumpsound], 128);
10601 FSOUND_SetPaused(channels[jumpsound], FALSE);
10603 if((player[i].isIdle())&&player[i].jumppower>1){
10604 player[i].targetanimation=player[i].getLanding();
10605 player[i].landhard=0;
10606 player[i].target=0;
10607 player[i].targetframe=2;
10608 player[i].jumpstart=1;
10609 player[i].tempdeltav=deltav;
10611 if(player[i].targetanimation==jumpupanim&&(((!floatjump&&!editorenabled)||!debugmode)||player[i].aitype!=playercontrolled)){
10612 if(player[i].jumppower>multiplier*6){
10613 player[i].velocity.y+=multiplier*6;
10614 player[i].jumppower-=multiplier*6;
10616 if(player[i].jumppower<=multiplier*6){
10617 player[i].velocity.y+=player[i].jumppower;
10618 player[i].jumppower=0;
10621 if(((floatjump||editorenabled)&&debugmode)&&i==0)player[i].velocity.y+=multiplier*30;
10625 if(player[i].isRun()||player[i].targetanimation==walkanim){
10626 player[i].targetanimation=player[i].getStop();
10627 player[i].target=0;
10628 player[i].targetframe=0;
10630 if(player[i].targetanimation==sneakanim){
10631 player[i].targetanimation=player[i].getCrouch();
10632 if(player[i].currentanimation==sneakanim)player[i].target=0;
10633 player[i].targetframe=0;
10636 if(player[i].targetanimation==walkanim&&(player[i].aitype==attacktypecutoff||player[i].aitype==searchtype||(player[i].aitype==passivetype&&player[i].numwaypoints<=1))){
10637 player[i].targetanimation=player[i].getStop();
10638 player[i].target=0;
10639 player[i].targetframe=0;
10641 if(player[i].isRun()&&(player[i].aitype==passivetype)){
10642 player[i].targetanimation=player[i].getStop();
10643 player[i].target=0;
10644 player[i].targetframe=0;
10648 if(player[i].targetanimation==rollanim)player[i].targetrotation=oldtargetrotation;
10652 for(k=0;k<numplayers;k++){
10653 if(abs(player[k].rotation-player[k].targetrotation)>180){
10654 if(player[k].rotation>player[k].targetrotation)player[k].rotation-=360;
10655 else player[k].rotation+=360;
10658 if(abs(player[k].rotation-player[k].targetrotation)>90&&(player[k].isRun()||player[k].targetanimation==walkanim)){
10659 player[k].targetanimation=player[k].getStop();
10660 player[k].targetframe=0;
10661 player[k].target=0;
10664 if(player[k].targetanimation==backhandspringanim||player[k].targetanimation==dodgebackanim){
10665 player[k].targettilt=0;
10667 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=backhandspringanim&&player[k].targetanimation!=jumpdownanim&&!player[k].isFlip()){
10668 player[k].targettilt=0;
10669 if(player[k].jumppower<0&&!player[k].jumpkeydown)player[k].jumppower=0;
10670 player[k].jumppower+=multiplier*7;
10671 if(player[k].isCrouch())player[k].jumppower+=multiplier*7;
10672 //*(1-(player[k].damage/player[k].damagetolerance))
10673 if(player[k].jumppower>5)player[k].jumppower=5;
10676 if(player[k].isRun()){
10677 player[k].targettilt=(player[k].rotation-player[k].targetrotation)/4;
10680 if(abs(player[k].tilt-player[k].targettilt)<multiplier*150)player[k].tilt=player[k].targettilt;
10681 else if(player[k].tilt>player[k].targettilt){
10682 player[k].tilt-=multiplier*150;
10684 else if(player[k].tilt<player[k].targettilt){
10685 player[k].tilt+=multiplier*150;
10688 player[k].grabdelay-=multiplier;
10691 for(k=0;k<numplayers;k++){
10692 player[k].DoAnimations();
10693 player[k].whichpatchx=player[k].coords.x/(terrain.size/subdivision*terrain.scale*terraindetail);
10694 player[k].whichpatchz=player[k].coords.z/(terrain.size/subdivision*terrain.scale*terraindetail);
10699 player[0].righthandmorphstart=0;
10700 player[0].righthandmorphend=1;
10701 player[0].lefthandmorphstart=0;
10702 player[0].lefthandmorphend=1;
10703 player[0].headmorphstart=0;
10704 player[0].headmorphend=2;*/
10707 if(IsKeyDown( theKeyMap, MAC_P_KEY )){
10708 if(player[0].righthandmorphend!=1)player[0].righthandmorphness=0;
10709 player[0].righthandmorphend=1;
10710 player[0].targetrighthandmorphness=1;
10712 if(player[0].lefthandmorphend!=0)player[0].lefthandmorphness=0;
10713 player[0].lefthandmorphend=0;
10714 player[0].targetlefthandmorphness=1;
10716 if(player[0].headmorphend!=2)player[0].headmorphness=0;
10717 player[0].headmorphend=2;
10718 player[0].targetheadmorphness=1;
10720 if(IsKeyDown( theKeyMap, MAC_L_KEY )){
10721 if(player[0].righthandmorphend!=0)player[0].righthandmorphness=0;
10722 player[0].righthandmorphend=0;
10723 player[0].targetrighthandmorphness=1;
10725 if(player[0].lefthandmorphend!=1)player[0].lefthandmorphness=0;
10726 player[0].lefthandmorphend=1;
10727 player[0].targetlefthandmorphness=1;
10729 if(player[0].headmorphend!=0)player[0].headmorphness=0;
10730 player[0].headmorphend=0;
10731 player[0].targetheadmorphness=1;
10734 if(numenvsounds!=0)
10735 for(j=numenvsounds-1;j>=0;j--){
10736 envsoundlife[j]-=multiplier;
10737 if(envsoundlife[j]<0){
10739 envsoundlife[j]=envsoundlife[numenvsounds];
10740 envsound[j]=envsound[numenvsounds];
10743 if(!slomo)FSOUND_SetFrequency(FSOUND_ALL, 22050);
10744 if(slomo)FSOUND_SetFrequency(FSOUND_ALL, slomofreq);
10746 if(tutoriallevel==1){
10763 if(tutorialstage>=51)
10764 if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
10765 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
10767 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
10768 FSOUND_SetPaused(channels[stream_music3], FALSE);
10769 FSOUND_SetVolume(channels[stream_music3], 256);
10774 float gLoc[3]={0,0,0};
10775 float vel[3]={0,0,0};
10776 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10777 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
10778 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10779 FSOUND_SetVolume(channels[fireendsound], 256);
10780 FSOUND_SetPaused(channels[fireendsound], FALSE);
10781 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
10789 if(tutorialstage<51)
10790 if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
10793 gLoc[0]=player[0].coords.x;
10794 gLoc[1]=player[0].coords.y;
10795 gLoc[2]=player[0].coords.z;
10799 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
10800 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10801 FSOUND_SetVolume(channels[fireendsound], 256);
10802 FSOUND_SetPaused(channels[fireendsound], FALSE);
10804 player[0].coords=(oldtemp+oldtemp2)/2;
10812 if(tutorialstage>=14&&tutorialstage<50)
10813 if(findDistancefast(&temp,&player[1].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[1].coords)<4){
10816 gLoc[0]=player[1].coords.x;
10817 gLoc[1]=player[1].coords.y;
10818 gLoc[2]=player[1].coords.z;
10822 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
10823 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10824 FSOUND_SetVolume(channels[fireendsound], 256);
10825 FSOUND_SetPaused(channels[fireendsound], FALSE);
10827 for(int i=0;i<player[1].skeleton.num_joints;i++){
10829 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
10830 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
10831 if(!player[1].skeleton.free)temp=DoRotation(DoRotation(DoRotation(player[1].skeleton.joints[i].position,0,0,player[1].tilt),player[1].tilt2,0,0),0,player[1].rotation,0)*player[1].scale+player[1].coords;
10832 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
10833 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
10837 player[1].coords=(oldtemp+oldtemp2)/2;
10838 for(int i=0;i<player[1].skeleton.num_joints;i++){
10839 player[1].skeleton.joints[i].velocity=0;
10841 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
10842 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
10843 if(!player[1].skeleton.free)temp=DoRotation(DoRotation(DoRotation(player[1].skeleton.joints[i].position,0,0,player[1].tilt),player[1].tilt2,0,0),0,player[1].rotation,0)*player[1].scale+player[1].coords;
10844 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
10845 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
10853 static float gLoc[3];
10857 static float vel[3];
10858 vel[0]=(viewer.x-oldviewer.x)/multiplier;
10859 vel[1]=(viewer.y-oldviewer.y)/multiplier;
10860 vel[2]=(viewer.z-oldviewer.z)/multiplier;
10862 //Set orientation with forward and up vectors
10863 static XYZ upvector;
10867 upvector=DoRotation(upvector,-rotation2+90,0,0);
10868 upvector=DoRotation(upvector,0,0-rotation,0);
10873 facing=DoRotation(facing,-rotation2,0,0);
10874 facing=DoRotation(facing,0,0-rotation,0);
10877 static float ori[6];
10878 ori[0] = -facing.x;
10880 ori[2] = -facing.z;
10881 ori[3] = -upvector.x;
10882 ori[4] = upvector.y;
10883 ori[5] = -upvector.z;
10885 FSOUND_3D_Listener_SetAttributes(&gLoc[0], &vel[0], ori[0], ori[1], ori[2], ori[3], ori[4], ori[5]);
10892 if(IsKeyDown(theKeyMap, MAC_F1_KEY)&&!freezetogglekeydown){
10894 freezetogglekeydown=1;
10898 void Game::TickOnce(){
10901 if(directing||indialogue==-1){
10902 rotation+=deltah*.7;
10903 if(!invertmouse)rotation2+=deltav*.7;
10904 if(invertmouse)rotation2-=deltav*.7;
10905 if(rotation2>90)rotation2=90;
10906 if(rotation2<-70)rotation2=-70;
10908 if(mainmenu)rotation+=multiplier*5;
10909 if(!mainmenu&&!indemo&&!registered){
10910 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
10911 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
10912 FSOUND_SetPaused(channels[stream_music3], FALSE);
10913 FSOUND_SetVolume(channels[stream_music3], 256);
10918 float gLoc[3]={0,0,0};
10919 float vel[3]={0,0,0};
10920 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10921 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
10922 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10923 FSOUND_SetVolume(channels[fireendsound], 256);
10924 FSOUND_SetPaused(channels[fireendsound], FALSE);
10925 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
10934 if(tryquit==1&&!registered&&mainmenu!=12){
10935 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
10936 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
10937 FSOUND_SetPaused(channels[stream_music3], FALSE);
10938 FSOUND_SetVolume(channels[stream_music3], 256);
10943 float gLoc[3]={0,0,0};
10944 float vel[3]={0,0,0};
10945 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10946 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
10947 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10948 FSOUND_SetVolume(channels[fireendsound], 256);
10949 FSOUND_SetPaused(channels[fireendsound], FALSE);
10950 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
10961 void Game::TickOnceAfter(){
10962 static XYZ colviewer;
10963 static XYZ coltarget;
10966 static float brotate;
10969 static float changedelay;
10970 static bool alldead;
10971 static float unseendelay;
10972 static float cameraspeed;
10976 if(environment==snowyenvironment)music1=stream_music1snow;
10977 if(environment==grassyenvironment)music1=stream_music1grass;
10978 if(environment==desertenvironment)music1=stream_music1desert;
10983 for(i=0;i<numplayers;i++){
10984 if((player[i].aitype==attacktypecutoff||player[i].aitype==getweapontype||player[i].aitype==gethelptype||player[i].aitype==searchtype)&&!player[i].dead/*&&player[i].surprised<=0*/&&(player[i].targetanimation!=sneakattackedanim&&player[i].targetanimation!=knifesneakattackedanim&&player[i].targetanimation!=swordsneakattackedanim)){
10985 musictype=stream_music2;
10989 if(player[0].dead)musictype=stream_music3;
10992 if(musictype==stream_music2){
10996 if(oldmusictype==stream_music2&&musictype!=stream_music2){
10997 unseendelay-=multiplier;
10999 musictype=stream_music2;
11005 musictype=stream_music3;
11006 musicvolume[2]=512;
11013 if(musictype!=oldmusictype&&musictype==stream_music2){
11014 static float gLoc[3];
11015 static float vel[3];
11016 gLoc[0]=cameraloc.x;
11017 gLoc[1]=cameraloc.y;
11018 gLoc[2]=cameraloc.z;
11022 PlaySoundEx( alarmsound, samp[alarmsound], NULL, TRUE);
11023 FSOUND_SetVolume(channels[alarmsound], 512);
11024 FSOUND_SetPaused(channels[alarmsound], FALSE);
11028 musicselected=musictype;
11030 if(musicselected==music1)musicvolume[0]+=multiplier*450;
11031 else musicvolume[0]-=multiplier*450;
11032 if(musicselected==stream_music2)musicvolume[1]+=multiplier*450;
11033 else musicvolume[1]-=multiplier*450;
11034 if(musicselected==stream_music3)musicvolume[2]+=multiplier*450;
11035 else musicvolume[2]-=multiplier*450;
11037 if(musicselected==music1)musicvolume[0]+=multiplier*100;
11038 else musicvolume[0]-=multiplier*450;
11039 if(musicselected==music2)musicvolume[1]+=multiplier*150;
11040 else if(player[0].dead)musicvolume[1]-=multiplier*450;
11041 else musicvolume[1]-=multiplier*100;
11042 if(musicselected==music3)musicvolume[2]+=multiplier*450;
11043 else musicvolume[2]-=multiplier*450;*/
11046 if(musicvolume[i]<0)musicvolume[i]=0;
11047 if(musicvolume[i]>512)musicvolume[i]=512;
11050 if(musicvolume[2]>128&&!loading&&!mainmenu)musicvolume[2]=128;
11053 if(musicvolume[0]>0&&oldmusicvolume[0]<=0){
11054 PlayStreamEx( music1, strm[music1], NULL, TRUE);
11055 FSOUND_SetPaused(channels[music1], FALSE);
11057 if(musicvolume[1]>0&&oldmusicvolume[1]<=0){
11058 PlayStreamEx( stream_music2, strm[stream_music2], NULL, TRUE);
11059 FSOUND_SetPaused(channels[stream_music2], FALSE);
11061 if(musicvolume[2]>0&&oldmusicvolume[2]<=0){
11062 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
11063 FSOUND_SetPaused(channels[stream_music3], FALSE);
11068 FSOUND_SetPaused(channels[music1], TRUE);
11069 FSOUND_SetPaused(channels[stream_music2], TRUE);
11070 FSOUND_SetPaused(channels[stream_music3], TRUE);
11073 oldmusicvolume[i]=0;
11079 if(musicvolume[0]<=0&&oldmusicvolume[0]>0){
11080 FSOUND_SetPaused(channels[music1], TRUE);
11082 if(musicvolume[1]<=0&&oldmusicvolume[1]>0){
11083 FSOUND_SetPaused(channels[stream_music2], TRUE);
11085 if(musicvolume[2]<=0&&oldmusicvolume[2]>0){
11086 FSOUND_SetPaused(channels[stream_music3], TRUE);
11089 if(musicvolume[0]!=oldmusicvolume[0]){
11090 FSOUND_SetVolume(channels[music1], musicvolume[0]);
11092 if(musicvolume[1]!=oldmusicvolume[1]){
11093 FSOUND_SetVolume(channels[stream_music2], musicvolume[1]);
11095 if(musicvolume[2]!=oldmusicvolume[2]){
11096 FSOUND_SetVolume(channels[stream_music3], musicvolume[2]);
11100 oldmusicvolume[i]=musicvolume[i];
11106 for(i=0;i<numhotspots;i++){
11107 if(hotspottype[i]>10&&hotspottype[i]<20){
11108 if(player[hotspottype[i]-10].dead==0){
11111 else if(killhotspot==2)
11115 if(killhotspot==2)killhotspot=0;
11120 for(i=0;i<numhotspots;i++){
11121 if(hotspottype[i]==-1){
11122 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i])
11129 for(i=1;i<numplayers;i++){
11130 if(!player[i].dead&&player[i].aitype==attacktypecutoff&&player[i].surprised<=0)numalarmed++;
11132 if(numalarmed>maxalarmed)maxalarmed=numalarmed;
11134 if(changedelay<=0&&!loading&&!editorenabled&&gameon&&!tutoriallevel&&changedelay!=-999&&!won){
11135 if(player[0].dead&&changedelay<=0){
11137 targetlevel=whichlevel;
11141 for(i=1;i<numplayers;i++){
11142 if(!player[i].dead&&player[i].howactive<typedead1)alldead=0;
11146 if(alldead&&!player[0].dead&&maptype==mapkilleveryone){
11148 targetlevel=whichlevel+1;
11149 if(targetlevel>numchallengelevels-1)targetlevel=0;
11151 if(winhotspot||windialogue){
11153 targetlevel=whichlevel+1;
11154 if(targetlevel>numchallengelevels-1)targetlevel=0;
11160 targetlevel=whichlevel+1;
11161 if(targetlevel>numchallengelevels-1)targetlevel=0;
11164 if(changedelay>0&&!player[0].dead&&!won){
11165 //high scores, awards, win
11168 accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
11169 accountcampaignchoicesmade[accountactive]++;
11170 accountcampaignscore[accountactive]+=bonustotal;
11172 accountcampaigntime[accountactive]+=leveltime;
11173 if(accountcampaignscore[accountactive]>accountcampaignhighscore[accountactive])accountcampaignhighscore[accountactive]=accountcampaignscore[accountactive];
11175 //if(accountprogress[accountactive]<whichlevel+1)accountprogress[accountactive]=whichlevel+1;
11181 if(bonustotal-startbonustotal>accounthighscore[accountactive][whichlevel])accounthighscore[accountactive][whichlevel]=bonustotal-startbonustotal;
11182 if(accountfasttime[accountactive][whichlevel]==0||leveltime<accountfasttime[accountactive][whichlevel])accountfasttime[accountactive][whichlevel]=leveltime;
11184 if(accountprogress[accountactive]<whichlevel+1)accountprogress[accountactive]=whichlevel+1;
11200 if(!editorenabled&&gameon&&!mainmenu){
11201 if(changedelay!=-999)changedelay-=multiplier/7;
11202 if(player[0].dead)targetlevel=whichlevel;
11203 if(loading==2&&!campaign){
11211 float gLoc[3]={0,0,0};
11212 float vel[3]={0,0,0};
11213 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
11214 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
11215 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
11216 FSOUND_SetVolume(channels[firestartsound], 256);
11217 FSOUND_SetPaused(channels[firestartsound], FALSE);
11218 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
11220 if(!player[0].dead&&targetlevel!=whichlevel){
11221 startbonustotal=bonustotal;
11223 if(!player[0].dead)Loadlevel(targetlevel);
11224 if(player[0].dead)Loadlevel(whichlevel);
11226 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
11227 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
11228 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
11229 FSOUND_SetVolume(channels[fireendsound], 256);
11230 FSOUND_SetPaused(channels[fireendsound], FALSE);
11231 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
11235 if(loading==2&&targetlevel==whichlevel){
11243 float gLoc[3]={0,0,0};
11244 float vel[3]={0,0,0};
11245 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
11246 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
11247 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
11248 FSOUND_SetVolume(channels[firestartsound], 256);
11249 FSOUND_SetPaused(channels[firestartsound], FALSE);
11250 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
11252 for(i=0;i<255;i++){
11266 strcat(mapname,campaignmapname[levelorder[accountcampaignchoicesmade[accountactive]]]);//[campaignchoicewhich[whichchoice]]);
11267 Loadlevel(mapname);
11269 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
11270 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
11271 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
11272 FSOUND_SetVolume(channels[fireendsound], 256);
11273 FSOUND_SetPaused(channels[fireendsound], FALSE);
11274 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
11278 if(changedelay<=-999&&whichlevel!=-2&&!loading&&(player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(killhotspot))&&!winfreeze)loading=1;
11279 if((player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(windialogue)||(killhotspot))&&changedelay<=0){
11280 if(accountprogress[accountactive]>3&&!registered){
11281 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
11282 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
11283 FSOUND_SetPaused(channels[stream_music3], FALSE);
11284 FSOUND_SetVolume(channels[stream_music3], 256);
11288 accountprogress[accountactive]=3;
11290 float gLoc[3]={0,0,0};
11291 float vel[3]={0,0,0};
11292 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
11293 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
11294 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
11295 FSOUND_SetVolume(channels[fireendsound], 256);
11296 FSOUND_SetPaused(channels[fireendsound], FALSE);
11297 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
11306 if(whichlevel!=-2&&!loading&&!player[0].dead){
11310 if(player[0].dead)loading=1;
11316 if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1){
11317 if(campaignnumnext[campaignchoicewhich[whichchoice]]==0){
11321 else if(mainmenu==0&&winfreeze){
11322 if(campaignchoosenext[campaignchoicewhich[whichchoice]]==2)
11324 else stealthloading=0;
11326 if(!stealthloading){
11327 float gLoc[3]={0,0,0};
11328 float vel[3]={0,0,0};
11329 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
11330 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
11331 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
11332 FSOUND_SetVolume(channels[firestartsound], 256);
11333 FSOUND_SetPaused(channels[firestartsound], FALSE);
11334 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
11345 ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
11346 //campaignnumlevels=0;
11347 //accountcampaignchoicesmade[accountactive]=0;
11348 ipstream.ignore(256,':');
11349 ipstream >> campaignnumlevels;
11350 for(i=0;i<campaignnumlevels;i++){
11351 ipstream.ignore(256,':');
11352 ipstream.ignore(256,':');
11353 ipstream.ignore(256,' ');
11354 ipstream >> campaignmapname[i];
11355 ipstream.ignore(256,':');
11356 ipstream >> campaigndescription[i];
11357 for(j=0;j<256;j++){
11358 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
11360 ipstream.ignore(256,':');
11361 ipstream >> campaignchoosenext[i];
11362 ipstream.ignore(256,':');
11363 ipstream >> campaignnumnext[i];
11364 if(campaignnumnext[i])
11365 for(j=0;j<campaignnumnext[i];j++){
11366 ipstream.ignore(256,':');
11367 ipstream >> campaignnextlevel[i][j];
11368 campaignnextlevel[i][j]-=1;
11370 ipstream.ignore(256,':');
11371 ipstream >> campaignlocationx[i];
11372 ipstream.ignore(256,':');
11373 ipstream >> campaignlocationy[i];
11377 for(i=0;i<campaignnumlevels;i++){
11379 levelhighlight[i]=0;
11383 for(i=0;i<campaignnumlevels;i++){
11385 levelhighlight[i]=0;
11390 if(accountcampaignchoicesmade[accountactive])
11391 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
11392 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
11393 levelvisible[levelorder[i+1]]=1;
11395 int whichlevelstart;
11396 whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
11397 if(whichlevelstart<0){
11398 campaignchoicenum=1;
11399 campaignchoicewhich[0]=0;
11403 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
11404 if(campaignchoicenum)
11405 for(i=0;i<campaignchoicenum;i++){
11406 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
11407 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
11408 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
11415 //if(firstload)TickOnceAfter();
11416 if(!firstload)LoadStuff();
11418 for(i=0;i<255;i++){
11433 //accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
11434 //accountcampaignchoicesmade[accountactive]++;
11437 strcat(mapname,campaignmapname[campaignchoicewhich[0]]);
11441 Loadlevel(mapname);
11445 FSOUND_SetPaused(channels[stream_music3], TRUE);
11450 if(loading==3)loading=0;
11454 oldmusictype=musictype;
11460 facing=DoRotation(facing,-rotation2,0,0);
11461 facing=DoRotation(facing,0,0-rotation,0);
11462 viewerfacing=facing;
11466 if((animation[player[0].targetanimation].attack!=3&&animation[player[0].currentanimation].attack!=3)||player[0].skeleton.free)target=player[0].coords+player[0].currentoffset*(1-player[0].target)*player[0].scale+player[0].targetoffset*player[0].target*player[0].scale-player[0].facing*.05;
11467 else target=player[0].oldcoords+player[0].currentoffset*(1-player[0].target)*player[0].scale+player[0].targetoffset*player[0].target*player[0].scale-player[0].facing*.05;
11469 if(player[0].skeleton.free){
11470 for(i=0;i<player[0].skeleton.num_joints;i++){
11471 if(player[0].skeleton.joints[i].position.y*player[0].scale+player[0].coords.y>target.y)
11472 target.y=player[0].skeleton.joints[i].position.y*player[0].scale+player[0].coords.y;
11476 if(player[0].skeleton.free!=2&&!autocam){
11478 if(findLengthfast(&player[0].velocity)>400){
11479 cameraspeed=20+(findLength(&player[0].velocity)-20)*.96;
11481 if(player[0].skeleton.free==0&&player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim)target.y+=1.4;
11482 coltarget=target-cameraloc;
11483 if(findLengthfast(&coltarget)<multiplier*multiplier*400)cameraloc=target;
11485 Normalise(&coltarget);
11486 if(player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim&&player[0].currentanimation!=climbanim&&player[0].currentoffset.x==0)cameraloc=cameraloc+coltarget*multiplier*cameraspeed;
11487 else cameraloc=cameraloc+coltarget*multiplier*8;
11489 if(editorenabled)cameraloc=target;
11490 cameradist+=multiplier*5;
11491 if(cameradist>2.3)cameradist=2.3;
11492 viewer=cameraloc-facing*cameradist;
11494 coltarget=cameraloc;
11495 objects.SphereCheckPossible(&colviewer, findDistance(&colviewer,&coltarget));
11496 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11497 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11498 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11500 coltarget=cameraloc;
11501 if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;
11503 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11504 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11505 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11507 if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.rotation[i])!=-1){
11511 cameradist=findDistance(&viewer,&target);
11512 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.6){
11513 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.6;
11515 if(cameraloc.y<terrain.getHeight(cameraloc.x,cameraloc.z)){
11516 cameraloc.y=terrain.getHeight(cameraloc.x,cameraloc.z);
11519 if(player[0].skeleton.free!=2&&autocam){
11521 if(findLengthfast(&player[0].velocity)>400){
11522 cameraspeed=20+(findLength(&player[0].velocity)-20)*.96;
11524 if(player[0].skeleton.free==0&&player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim)target.y+=1.4;
11525 cameradist+=multiplier*5;
11526 if(cameradist>3.3)cameradist=3.3;
11527 coltarget=target-cameraloc;
11528 if(findLengthfast(&coltarget)<multiplier*multiplier*400)cameraloc=target;
11529 else if(findLengthfast(&coltarget)>1)
11531 Normalise(&coltarget);
11532 if(player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim&&player[0].currentanimation!=climbanim&&player[0].currentoffset.x==0)cameraloc=cameraloc+coltarget*multiplier*cameraspeed;
11533 else cameraloc=cameraloc+coltarget*multiplier*8;
11535 if(editorenabled)cameraloc=target;
11538 coltarget=cameraloc;
11539 objects.SphereCheckPossible(&colviewer, findDistance(&colviewer,&coltarget));
11540 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11541 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11542 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11544 coltarget=cameraloc;
11545 if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;
11547 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11548 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11549 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11551 if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.rotation[i])!=-1){
11555 cameradist=findDistance(&viewer,&target);
11556 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.6){
11557 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.6;
11559 if(cameraloc.y<terrain.getHeight(cameraloc.x,cameraloc.z)){
11560 cameraloc.y=terrain.getHeight(cameraloc.x,cameraloc.z);
11563 if(camerashake>.8)camerashake=.8;
11564 //if(woozy>10)woozy=10;
11565 //woozy+=multiplier;
11567 if(player[0].dead)camerashake=0;
11568 if(player[0].dead)woozy=0;
11569 camerashake-=multiplier*2;
11570 blackout-=multiplier*2;
11571 //if(player[0].isCrouch())woozy-=multiplier*8;
11572 if(camerashake<0)camerashake=0;
11573 if(blackout<0)blackout=0;
11574 //if(woozy<0)woozy=0;
11576 viewer.x+=(float)(Random()%100)*.0005*camerashake;
11577 viewer.y+=(float)(Random()%100)*.0005*camerashake;
11578 viewer.z+=(float)(Random()%100)*.0005*camerashake;