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[20];
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 !USE_SDL // we'll take anything that works.
1848 if(newscreenwidth>3000)newscreenwidth=screenwidth;
1849 if(newscreenheight>3000)newscreenheight=screenheight;
1851 if(newscreenwidth<0)newscreenwidth=screenwidth;
1852 if(newscreenheight<0)newscreenheight=screenheight;
1854 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
1855 opstream << "Screenwidth:\n";
1856 opstream << newscreenwidth;
1857 opstream << "\nScreenheight:\n";
1858 opstream << newscreenheight;
1859 opstream << "\nMouse sensitivity:\n";
1860 opstream << usermousesensitivity;
1861 opstream << "\nBlur(0,1):\n";
1862 opstream << ismotionblur;
1863 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
1864 opstream << newdetail;
1865 opstream << "\nFloating jump:\n";
1866 opstream << floatjump;
1867 opstream << "\nMouse jump:\n";
1868 opstream << mousejump;
1869 opstream << "\nAmbient sound:\n";
1870 opstream << ambientsound;
1871 opstream << "\nBlood (0,1,2):\n";
1872 opstream << bloodtoggle;
1873 opstream << "\nAuto slomo:\n";
1874 opstream << autoslomo;
1875 opstream << "\nFoliage:\n";
1876 opstream << foliage;
1877 opstream << "\nMusic:\n";
1878 opstream << musictoggle;
1879 opstream << "\nTrilinear:\n";
1880 opstream << trilinear;
1881 opstream << "\nDecals(shadows,blood puddles,etc):\n";
1883 opstream << "\nInvert mouse:\n";
1884 opstream << invertmouse;
1885 opstream << "\nGamespeed:\n";
1886 if(oldgamespeed==0)oldgamespeed=1;
1887 opstream << oldgamespeed;
1888 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
1889 opstream << difficulty;
1890 opstream << "\nDamage effects(blackout, doublevision):\n";
1891 opstream << damageeffects;
1892 opstream << "\nText:\n";
1893 opstream << texttoggle;
1894 opstream << "\nDebug:\n";
1895 opstream << debugmode;
1896 opstream << "\nVBL Sync:\n";
1897 opstream << vblsync;
1898 opstream << "\nShow Points:\n";
1899 opstream << showpoints;
1900 opstream << "\nAlways Blur:\n";
1901 opstream << alwaysblur;
1902 opstream << "\nImmediate mode (turn on on G5):\n";
1903 opstream << immediate;
1904 opstream << "\nVelocity blur:\n";
1905 opstream << velocityblur;
1906 opstream << "\nVolume:\n";
1908 opstream << "\nForward key:\n";
1909 opstream << KeyToChar(forwardkey);
1910 opstream << "\nBack key:\n";
1911 opstream << KeyToChar(backkey);
1912 opstream << "\nLeft key:\n";
1913 opstream << KeyToChar(leftkey);
1914 opstream << "\nRight key:\n";
1915 opstream << KeyToChar(rightkey);
1916 opstream << "\nJump key:\n";
1917 opstream << KeyToChar(jumpkey);
1918 opstream << "\nCrouch key:\n";
1919 opstream << KeyToChar(crouchkey);
1920 opstream << "\nDraw key:\n";
1921 opstream << KeyToChar(drawkey);
1922 opstream << "\nThrow key:\n";
1923 opstream << KeyToChar(throwkey);
1924 opstream << "\nAttack key:\n";
1925 opstream << KeyToChar(attackkey);
1926 opstream << "\nChat key:\n";
1927 opstream << KeyToChar(chatkey);
1930 if(mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==9||mainmenu==12||mainmenu==13||mainmenu==14||mainmenu==10||mainmenu==11||mainmenu==100){
1931 float gLoc[3]={0,0,0};
1932 float vel[3]={0,0,0};
1933 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
1934 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
1935 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1936 FSOUND_SetVolume(channels[fireendsound], 256);
1937 FSOUND_SetPaused(channels[fireendsound], FALSE);
1938 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1946 if(mainmenu==3&&gameon)mainmenu=2;
1947 if(mainmenu==3&&!gameon)mainmenu=1;
1948 if(mainmenu==5&&gameon)mainmenu=2;
1949 if(mainmenu==5&&!gameon)mainmenu=1;
1950 if(mainmenu==4)mainmenu=3;
1951 if(mainmenu==6)mainmenu=5;
1952 if(mainmenu==7)mainmenu=1;
1953 if(mainmenu==9)mainmenu=5;
1954 if(mainmenu==11)mainmenu=5;
1955 if(mainmenu==12)mainmenu=5;
1956 if(mainmenu==13)mainmenu=12;
1957 if(mainmenu==14)mainmenu=13;
1958 if(mainmenu==10)mainmenu=5;
1964 mainmenutogglekeydown=1;
1966 if(!IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)){
1967 mainmenutogglekeydown=0;
1971 /*static bool minimaptogglekeydown;
1972 if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!minimaptogglekeydown){
1974 minimaptogglekeydown=1;
1976 if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)){
1977 minimaptogglekeydown=0;
1981 static bool minimaptogglekeydown;
1982 if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!minimaptogglekeydown&&tutoriallevel){
1983 if(tutorialstage!=51)
1984 tutorialstagetime=tutorialmaxtime;
1985 PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, TRUE);
1986 FSOUND_SetVolume(channels[consolefailsound], 128);
1987 FSOUND_SetPaused(channels[consolefailsound], FALSE);
1988 minimaptogglekeydown=1;
1990 if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)){
1991 minimaptogglekeydown=0;
1996 if(mainmenu==1||mainmenu==2){
1997 if(Button()&&!oldbutton&&selected==1){
1999 float gLoc[3]={0,0,0};
2000 float vel[3]={0,0,0};
2001 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2002 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2003 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2004 FSOUND_SetVolume(channels[firestartsound], 256);
2005 FSOUND_SetPaused(channels[firestartsound], FALSE);
2006 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2015 if(accountactive!=-1)mainmenu=5;
2022 if(firstload)TickOnceAfter();
2023 if(!firstload)LoadStuff();
2029 FSOUND_SetPaused(channels[music3], TRUE); */
2035 FSOUND_SetPaused(channels[stream_music3], TRUE);
2036 FSOUND_SetPaused(channels[music1], FALSE);
2040 if(Button()&&!oldbutton&&selected==2){
2041 float gLoc[3]={0,0,0};
2042 float vel[3]={0,0,0};
2043 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2044 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2045 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2046 FSOUND_SetVolume(channels[firestartsound], 256);
2047 FSOUND_SetPaused(channels[firestartsound], FALSE);
2048 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2060 if(newdetail>2)newdetail=detail;
2061 if(newdetail<0)newdetail=detail;
2062 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2063 if(newscreenwidth<0)newscreenwidth=screenwidth;
2064 if(newscreenheight>3000)newscreenheight=screenheight;
2065 if(newscreenheight<0)newscreenheight=screenheight;
2068 if(Button()&&!oldbutton&&selected==3){
2069 float gLoc[3]={0,0,0};
2070 float vel[3]={0,0,0};
2071 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2072 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2073 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2074 FSOUND_SetVolume(channels[fireendsound], 256);
2075 FSOUND_SetPaused(channels[fireendsound], FALSE);
2076 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2087 if(registered)FSOUND_SetPaused(channels[stream_music3], TRUE);
2095 if(Button())oldbutton=1;
2100 if(Button()&&!oldbutton&&selected!=-1){
2101 float gLoc[3]={0,0,0};
2102 float vel[3]={0,0,0};
2103 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2104 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2105 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2106 FSOUND_SetVolume(channels[firestartsound], 256);
2107 FSOUND_SetPaused(channels[firestartsound], FALSE);
2108 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2110 if(Button()&&!oldbutton&&selected==0){
2112 extern SDL_Rect **resolutions;
2113 bool isCustomResolution = true;
2115 for (int i = 0; (!found) && (resolutions[i]); i++)
2117 if ((resolutions[i]->w == screenwidth) && (resolutions[i]->h == screenwidth))
2118 isCustomResolution = false;
2120 if ((resolutions[i]->w == newscreenwidth) && (resolutions[i]->h == newscreenheight))
2123 if (resolutions[i] != NULL)
2125 newscreenwidth = (int) resolutions[i]->w;
2126 newscreenheight = (int) resolutions[i]->h;
2128 else if (isCustomResolution)
2130 if ((screenwidth == newscreenwidth) && (screenheight == newscreenheight))
2132 newscreenwidth = (int) resolutions[0]->w;
2133 newscreenheight = (int) resolutions[0]->h;
2137 newscreenwidth = screenwidth;
2138 newscreenheight = screenheight;
2143 newscreenwidth = (int) resolutions[0]->w;
2144 newscreenheight = (int) resolutions[0]->h;
2152 newscreenwidth = (int) resolutions[0]->w;
2153 newscreenheight = (int) resolutions[0]->h;
2159 if(newscreenwidth==640&&newscreenheight==480)whichres=0;
2160 if(newscreenwidth==800&&newscreenheight==600)whichres=1;
2161 if(newscreenwidth==1024&&newscreenheight==768)whichres=2;
2162 if(newscreenwidth==1280&&newscreenheight==1024)whichres=3;
2163 if(newscreenwidth==1600&&newscreenheight==1200)whichres=4;
2164 if(newscreenwidth==840&&newscreenheight==524)whichres=5;
2165 if(newscreenwidth==1024&&newscreenheight==640)whichres=6;
2166 if(newscreenwidth==1344&&newscreenheight==840)whichres=7;
2167 if(newscreenwidth==1920&&newscreenheight==1200)whichres=8;
2169 if(whichres==-1||whichres==8){
2171 newscreenheight=480;
2175 newscreenheight=600;
2178 newscreenwidth=1024;
2179 newscreenheight=768;
2182 newscreenwidth=1280;
2183 newscreenheight=1024;
2186 newscreenwidth=1600;
2187 newscreenheight=1200;
2191 newscreenheight=524;
2194 newscreenwidth=1024;
2195 newscreenheight=640;
2198 newscreenwidth=1344;
2199 newscreenheight=840;
2202 newscreenwidth=1920;
2203 newscreenheight=1200;
2207 if(Button()&&!oldbutton&&selected==1){
2209 if(newdetail>2)newdetail=0;
2211 if(Button()&&!oldbutton&&selected==2){
2213 if(bloodtoggle>2)bloodtoggle=0;
2215 if(Button()&&!oldbutton&&selected==3){
2217 if(difficulty>2)difficulty=0;
2219 if(Button()&&!oldbutton&&selected==4){
2220 ismotionblur=1-ismotionblur;
2222 if(Button()&&!oldbutton&&selected==5){
2225 if(Button()&&!oldbutton&&selected==6){
2226 musictoggle=1-musictoggle;
2229 FSOUND_SetPaused(channels[music1], TRUE);
2230 FSOUND_SetPaused(channels[stream_music2], TRUE);
2231 FSOUND_SetPaused(channels[stream_music3], TRUE);
2234 oldmusicvolume[i]=0;
2240 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
2241 FSOUND_SetPaused(channels[stream_music3], FALSE);
2242 FSOUND_SetVolume(channels[stream_music3], 256);
2245 if(Button()&&!oldbutton&&selected==9){
2246 invertmouse=1-invertmouse;
2248 if(Button()&&!oldbutton&&selected==10){
2249 usermousesensitivity+=.2;
2250 if(usermousesensitivity>2)usermousesensitivity=.2;
2252 if(Button()&&!oldbutton&&selected==11){
2254 if(volume>1.0001f)volume=0;
2255 FSOUND_SetSFXMasterVolume((int)(volume*255));
2257 if(Button()&&!oldbutton&&selected==7){
2258 /*float gLoc[3]={0,0,0};
2259 float vel[3]={0,0,0};
2260 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2261 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2262 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2263 FSOUND_SetVolume(channels[firestartsound], 256);
2264 FSOUND_SetPaused(channels[firestartsound], FALSE);
2265 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2278 if(Button()&&!oldbutton&&selected==8){
2279 float gLoc[3]={0,0,0};
2280 float vel[3]={0,0,0};
2281 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2282 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2283 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2284 FSOUND_SetVolume(channels[fireendsound], 256);
2285 FSOUND_SetPaused(channels[fireendsound], FALSE);
2286 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2294 if(newdetail>2)newdetail=detail;
2295 if(newdetail<0)newdetail=detail;
2296 #if !USE_SDL // we'll take anything that works.
2297 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2298 if(newscreenheight>3000)newscreenheight=screenheight;
2300 if(newscreenwidth<0)newscreenwidth=screenwidth;
2301 if(newscreenheight<0)newscreenheight=screenheight;
2304 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
2305 opstream << "Screenwidth:\n";
2306 opstream << newscreenwidth;
2307 opstream << "\nScreenheight:\n";
2308 opstream << newscreenheight;
2309 opstream << "\nMouse sensitivity:\n";
2310 opstream << usermousesensitivity;
2311 opstream << "\nBlur(0,1):\n";
2312 opstream << ismotionblur;
2313 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
2314 opstream << newdetail;
2315 opstream << "\nFloating jump:\n";
2316 opstream << floatjump;
2317 opstream << "\nMouse jump:\n";
2318 opstream << mousejump;
2319 opstream << "\nAmbient sound:\n";
2320 opstream << ambientsound;
2321 opstream << "\nBlood (0,1,2):\n";
2322 opstream << bloodtoggle;
2323 opstream << "\nAuto slomo:\n";
2324 opstream << autoslomo;
2325 opstream << "\nFoliage:\n";
2326 opstream << foliage;
2327 opstream << "\nMusic:\n";
2328 opstream << musictoggle;
2329 opstream << "\nTrilinear:\n";
2330 opstream << trilinear;
2331 opstream << "\nDecals(shadows,blood puddles,etc):\n";
2333 opstream << "\nInvert mouse:\n";
2334 opstream << invertmouse;
2335 opstream << "\nGamespeed:\n";
2336 if(oldgamespeed==0)oldgamespeed=1;
2337 opstream << oldgamespeed;
2338 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
2339 opstream << difficulty;
2340 opstream << "\nDamage effects(blackout, doublevision):\n";
2341 opstream << damageeffects;
2342 opstream << "\nText:\n";
2343 opstream << texttoggle;
2344 opstream << "\nDebug:\n";
2345 opstream << debugmode;
2346 opstream << "\nVBL Sync:\n";
2347 opstream << vblsync;
2348 opstream << "\nShow Points:\n";
2349 opstream << showpoints;
2350 opstream << "\nAlways Blur:\n";
2351 opstream << alwaysblur;
2352 opstream << "\nImmediate mode (turn on on G5):\n";
2353 opstream << immediate;
2354 opstream << "\nVelocity blur:\n";
2355 opstream << velocityblur;
2356 opstream << "\nVolume:\n";
2358 opstream << "\nForward key:\n";
2359 opstream << KeyToChar(forwardkey);
2360 opstream << "\nBack key:\n";
2361 opstream << KeyToChar(backkey);
2362 opstream << "\nLeft key:\n";
2363 opstream << KeyToChar(leftkey);
2364 opstream << "\nRight key:\n";
2365 opstream << KeyToChar(rightkey);
2366 opstream << "\nJump key:\n";
2367 opstream << KeyToChar(jumpkey);
2368 opstream << "\nCrouch key:\n";
2369 opstream << KeyToChar(crouchkey);
2370 opstream << "\nDraw key:\n";
2371 opstream << KeyToChar(drawkey);
2372 opstream << "\nThrow key:\n";
2373 opstream << KeyToChar(throwkey);
2374 opstream << "\nAttack key:\n";
2375 opstream << KeyToChar(attackkey);
2376 opstream << "\nChat key:\n";
2377 opstream << KeyToChar(chatkey);
2380 if(mainmenu==3&&gameon)mainmenu=2;
2381 if(mainmenu==3&&!gameon)mainmenu=1;
2383 if(Button())oldbutton=1;
2387 if(Button()&&!oldbutton&&selected!=-1&&keyselect==-1){
2388 float gLoc[3]={0,0,0};
2389 float vel[3]={0,0,0};
2390 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2391 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2392 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2393 FSOUND_SetVolume(channels[firestartsound], 256);
2394 FSOUND_SetPaused(channels[firestartsound], FALSE);
2395 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2397 if(Button()&&!oldbutton&&selected<9&&keyselect==-1){
2405 if(!buttons[i]&&!oldbutton&&!Button())oldbuttons[i]=0;
2407 if((IsKeyDown(theKeyMap, i)||(buttons[0]&&!oldbuttons[0]&&!oldbutton)||(buttons[1]&&!oldbuttons[1]&&!oldbutton))&&keyselect!=-1){
2408 if(i!=MAC_ESCAPE_KEY&&(strcmp(KeyToChar(i),"unknown")||(buttons[0]&&!oldbuttons[0]&&!oldbutton)||(buttons[1]&&!oldbuttons[1]&&!oldbutton))){
2409 float gLoc[3]={0,0,0};
2410 float vel[3]={0,0,0};
2411 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2412 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2413 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2414 FSOUND_SetVolume(channels[fireendsound], 256);
2415 FSOUND_SetPaused(channels[fireendsound], FALSE);
2416 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2420 if(buttons[0]&&!oldbuttons[0])keynum=MAC_MOUSEBUTTON1;
2421 if(buttons[1]&&!oldbuttons[1])keynum=MAC_MOUSEBUTTON2;
2425 if(keyselect==0)forwardkey=keynum;
2426 if(keyselect==1)backkey=keynum;
2427 if(keyselect==2)leftkey=keynum;
2428 if(keyselect==3)rightkey=keynum;
2429 if(keyselect==4)crouchkey=keynum;
2430 if(keyselect==5)jumpkey=keynum;
2431 if(keyselect==6)drawkey=keynum;
2432 if(keyselect==7)throwkey=keynum;
2433 if(keyselect==8)attackkey=keynum;
2438 if(Button()&&!oldbutton&&selected==9){
2439 float gLoc[3]={0,0,0};
2440 float vel[3]={0,0,0};
2441 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2442 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2443 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2444 FSOUND_SetVolume(channels[fireendsound], 256);
2445 FSOUND_SetPaused(channels[fireendsound], FALSE);
2446 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2456 if(newdetail>2)newdetail=detail;
2457 if(newdetail<0)newdetail=detail;
2458 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2459 if(newscreenwidth<0)newscreenwidth=screenwidth;
2460 if(newscreenheight>3000)newscreenheight=screenheight;
2461 if(newscreenheight<0)newscreenheight=screenheight;
2466 if(accountcampaignchoicesmade[accountactive]>8&&!registered){
2467 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
2468 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
2469 FSOUND_SetPaused(channels[stream_music3], FALSE);
2470 FSOUND_SetVolume(channels[stream_music3], 256);
2474 accountcampaignchoicesmade[accountactive]=0;
2475 accountcampaignscore[accountactive]=0;
2476 accountcampaigntime[accountactive]=0;
2478 float gLoc[3]={0,0,0};
2479 float vel[3]={0,0,0};
2480 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2481 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2482 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2483 FSOUND_SetVolume(channels[fireendsound], 256);
2484 FSOUND_SetPaused(channels[fireendsound], FALSE);
2485 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2495 accountcampaignchoicesmade[accountactive]=0;
2496 accountcampaignscore[accountactive]=0;
2497 accountcampaigntime[accountactive]=0;
2501 if(Button()&&!oldbutton&&selected==1){
2502 float gLoc[3]={0,0,0};
2503 float vel[3]={0,0,0};
2504 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2505 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2506 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2507 FSOUND_SetVolume(channels[firestartsound], 256);
2508 FSOUND_SetPaused(channels[firestartsound], FALSE);
2509 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2522 if(firstload)TickOnceAfter();
2523 if(!firstload)LoadStuff();
2530 FSOUND_SetPaused(channels[stream_music3], TRUE);
2532 if(Button()&&!oldbutton&&selected-7>=accountcampaignchoicesmade[accountactive]){//selected>=7&&(selected-7<=campaignnumchoices)){
2533 float gLoc[3]={0,0,0};
2534 float vel[3]={0,0,0};
2535 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2536 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2537 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2538 FSOUND_SetVolume(channels[firestartsound], 256);
2539 FSOUND_SetPaused(channels[firestartsound], FALSE);
2540 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2553 if(firstload)TickOnceAfter();
2554 if(!firstload)LoadStuff();
2570 strcat(mapname,campaignmapname[campaignchoicewhich[selected-7-accountcampaignchoicesmade[accountactive]]]);
2571 whichchoice=selected-7-accountcampaignchoicesmade[accountactive];
2575 //Loadlevel(campaignmapname[levelorder[selected-7]]);
2580 FSOUND_SetPaused(channels[stream_music3], TRUE);
2582 if(Button()&&!oldbutton&&selected==4){
2583 float gLoc[3]={0,0,0};
2584 float vel[3]={0,0,0};
2585 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2586 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2587 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2588 FSOUND_SetVolume(channels[fireendsound], 256);
2589 FSOUND_SetPaused(channels[fireendsound], FALSE);
2590 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2598 if(mainmenu==5&&gameon)mainmenu=2;
2599 if(mainmenu==5&&!gameon)mainmenu=1;
2601 if(Button()&&!oldbutton&&selected==5){
2602 float gLoc[3]={0,0,0};
2603 float vel[3]={0,0,0};
2604 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2605 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2606 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2607 FSOUND_SetVolume(channels[fireendsound], 256);
2608 FSOUND_SetPaused(channels[fireendsound], FALSE);
2609 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2619 if(Button()&&!oldbutton&&selected==3){
2620 float gLoc[3]={0,0,0};
2621 float vel[3]={0,0,0};
2622 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2623 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2624 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2625 FSOUND_SetVolume(channels[firestartsound], 256);
2626 FSOUND_SetPaused(channels[firestartsound], FALSE);
2627 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2637 if(Button()&&!oldbutton&&selected==2){
2638 float gLoc[3]={0,0,0};
2639 float vel[3]={0,0,0};
2640 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2641 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2642 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2643 FSOUND_SetVolume(channels[firestartsound], 256);
2644 FSOUND_SetPaused(channels[firestartsound], FALSE);
2645 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2655 if(Button())oldbutton=1;
2659 if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountprogress[accountactive]){
2660 float gLoc[3]={0,0,0};
2661 float vel[3]={0,0,0};
2662 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2663 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2664 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2665 FSOUND_SetVolume(channels[firestartsound], 256);
2666 FSOUND_SetPaused(channels[firestartsound], FALSE);
2667 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2679 targetlevel=selected;
2680 if(firstload)TickOnceAfter();
2681 if(!firstload)LoadStuff();
2683 Loadlevel(selected);
2689 FSOUND_SetPaused(channels[stream_music3], TRUE);
2691 if(Button()&&!oldbutton&&selected==numchallengelevels){
2692 float gLoc[3]={0,0,0};
2693 float vel[3]={0,0,0};
2694 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2695 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2696 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2697 FSOUND_SetVolume(channels[fireendsound], 256);
2698 FSOUND_SetPaused(channels[fireendsound], FALSE);
2699 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2709 if(Button())oldbutton=1;
2713 if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountprogress[accountactive]){
2714 float gLoc[3]={0,0,0};
2715 float vel[3]={0,0,0};
2716 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2717 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2718 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2719 FSOUND_SetVolume(channels[firestartsound], 256);
2720 FSOUND_SetPaused(channels[firestartsound], FALSE);
2721 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2733 targetlevel=selected;
2734 if(firstload)TickOnceAfter();
2735 if(!firstload)LoadStuff();
2737 Loadlevel(selected);
2743 FSOUND_SetPaused(channels[stream_music3], TRUE);
2745 if(Button()&&!oldbutton&&selected==numchallengelevels){
2746 float gLoc[3]={0,0,0};
2747 float vel[3]={0,0,0};
2748 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2749 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2750 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2751 FSOUND_SetVolume(channels[fireendsound], 256);
2752 FSOUND_SetPaused(channels[fireendsound], FALSE);
2753 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2763 if(Button())oldbutton=1;
2768 if(Button()&&!oldbutton&&selected==3){
2769 float gLoc[3]={0,0,0};
2770 float vel[3]={0,0,0};
2771 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2772 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2773 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2774 FSOUND_SetVolume(channels[fireendsound], 256);
2775 FSOUND_SetPaused(channels[fireendsound], FALSE);
2776 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2786 if(Button())oldbutton=1;
2790 if(mainmenu==15||mainmenu==16){
2791 if(Button()&&!oldbutton&&selected==1){
2792 float gLoc[3]={0,0,0};
2793 float vel[3]={0,0,0};
2794 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2795 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2796 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2797 FSOUND_SetVolume(channels[fireendsound], 256);
2798 FSOUND_SetPaused(channels[fireendsound], FALSE);
2799 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2807 if(mainmenu==15)mainmenu=5;
2810 if(Button())oldbutton=1;
2816 if(Button()&&!oldbutton&&selected==3){
2818 float gLoc[3]={0,0,0};
2819 float vel[3]={0,0,0};
2820 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2821 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2822 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2823 FSOUND_SetVolume(channels[fireendsound], 256);
2824 FSOUND_SetPaused(channels[fireendsound], FALSE);
2825 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2836 if(Button()&&!oldbutton&&selected==4){
2839 float gLoc[3]={0,0,0};
2840 float vel[3]={0,0,0};
2841 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2842 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2843 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2844 FSOUND_SetVolume(channels[fireendsound], 256);
2845 FSOUND_SetPaused(channels[fireendsound], FALSE);
2846 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2856 if(Button()&&!oldbutton&&selected==5){
2858 float gLoc[3]={0,0,0};
2859 float vel[3]={0,0,0};
2860 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2861 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2862 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2863 FSOUND_SetVolume(channels[fireendsound], 256);
2864 FSOUND_SetPaused(channels[fireendsound], FALSE);
2865 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2875 if(Button())oldbutton=1;
2879 if(Button()&&!oldbutton&&selected!=-1){
2880 float gLoc[3]={0,0,0};
2881 float vel[3]={0,0,0};
2882 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2883 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2884 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2885 FSOUND_SetVolume(channels[firestartsound], 256);
2886 FSOUND_SetPaused(channels[firestartsound], FALSE);
2887 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2889 if(Button()&&!oldbutton&&selected==1){
2890 float gLoc[3]={0,0,0};
2891 float vel[3]={0,0,0};
2892 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2893 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2894 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2895 FSOUND_SetVolume(channels[fireendsound], 256);
2896 FSOUND_SetPaused(channels[fireendsound], FALSE);
2897 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2905 for(i=accountactive;i<numaccounts-1;i++){
2906 accountdifficulty[i]=accountdifficulty[i+1];
2907 accountcampaignchoicesmade[i]=accountcampaignchoicesmade[i+1];
2908 for(j=0;j<accountcampaignchoicesmade[i+1];j++){
2909 accountcampaignchoices[i][j]=accountcampaignchoices[i+1][j];
2911 accountpoints[i]=accountpoints[i+1];
2913 accounthighscore[i][j]=accounthighscore[i+1][j];
2914 accountfasttime[i][j]=accountfasttime[i+1][j];
2917 accountunlocked[i][j]=accountunlocked[i+1][j];
2920 accountname[i][j]=accountname[i+1][j];
2922 accountcampaignhighscore[i]=accountcampaignhighscore[i+1];
2923 accountprogress[i]=accountprogress[i+1];
2924 accountcampaignfasttime[i]=accountcampaignfasttime[i+1];
2925 accountcampaignscore[i]=accountcampaignscore[i+1];
2926 accountcampaigntime[i]=accountcampaigntime[i+1];
2935 if(Button()&&!oldbutton&&selected==2){
2936 float gLoc[3]={0,0,0};
2937 float vel[3]={0,0,0};
2938 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2939 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2940 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2941 FSOUND_SetVolume(channels[fireendsound], 256);
2942 FSOUND_SetPaused(channels[fireendsound], FALSE);
2943 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2953 if(Button())oldbutton=1;
2957 if(Button()&&!oldbutton&&selected!=-1){
2958 float gLoc[3]={0,0,0};
2959 float vel[3]={0,0,0};
2960 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2961 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2962 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2963 FSOUND_SetVolume(channels[firestartsound], 256);
2964 FSOUND_SetPaused(channels[firestartsound], FALSE);
2965 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2967 if(Button()&&!oldbutton&&selected==0&&numaccounts<8){
2970 if(Button()&&!oldbutton&&selected>0&&selected<numaccounts+1){
2971 accountactive=selected-1;
2979 if(Button()&&!oldbutton&&selected==numaccounts+1){
2980 float gLoc[3]={0,0,0};
2981 float vel[3]={0,0,0};
2982 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2983 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2984 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2985 FSOUND_SetVolume(channels[fireendsound], 256);
2986 FSOUND_SetPaused(channels[fireendsound], FALSE);
2987 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2998 displaytext[0][j]=' ';
3004 if(Button())oldbutton=1;
3008 if(Button()&&!oldbutton&&selected!=-1){
3009 float gLoc[3]={0,0,0};
3010 float vel[3]={0,0,0};
3011 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3012 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
3013 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3014 FSOUND_SetVolume(channels[firestartsound], 256);
3015 FSOUND_SetPaused(channels[firestartsound], FALSE);
3016 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3018 if(selected==0)accountdifficulty[accountactive]=0;
3019 if(selected==1)accountdifficulty[accountactive]=1;
3020 if(selected==2)accountdifficulty[accountactive]=2;
3031 if(Button())oldbutton=1;
3036 if(Button())oldbutton=1;
3039 if(IsKeyDown(theKeyMap, MAC_Q_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)){
3042 if(newdetail>2)newdetail=detail;
3043 if(newdetail<0)newdetail=detail;
3044 #if !USE_SDL // we'll take anything that works.
3045 if(newscreenwidth>3000)newscreenwidth=screenwidth;
3046 if(newscreenheight>3000)newscreenheight=screenheight;
3048 if(newscreenwidth<0)newscreenwidth=screenwidth;
3049 if(newscreenheight<0)newscreenheight=screenheight;
3051 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
3052 opstream << "Screenwidth:\n";
3053 opstream << newscreenwidth;
3054 opstream << "\nScreenheight:\n";
3055 opstream << newscreenheight;
3056 opstream << "\nMouse sensitivity:\n";
3057 opstream << usermousesensitivity;
3058 opstream << "\nBlur(0,1):\n";
3059 opstream << ismotionblur;
3060 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
3061 opstream << newdetail;
3062 opstream << "\nFloating jump:\n";
3063 opstream << floatjump;
3064 opstream << "\nMouse jump:\n";
3065 opstream << mousejump;
3066 opstream << "\nAmbient sound:\n";
3067 opstream << ambientsound;
3068 opstream << "\nBlood (0,1,2):\n";
3069 opstream << bloodtoggle;
3070 opstream << "\nAuto slomo:\n";
3071 opstream << autoslomo;
3072 opstream << "\nFoliage:\n";
3073 opstream << foliage;
3074 opstream << "\nMusic:\n";
3075 opstream << musictoggle;
3076 opstream << "\nTrilinear:\n";
3077 opstream << trilinear;
3078 opstream << "\nDecals(shadows,blood puddles,etc):\n";
3080 opstream << "\nInvert mouse:\n";
3081 opstream << invertmouse;
3082 opstream << "\nGamespeed:\n";
3083 if(oldgamespeed==0)oldgamespeed=1;
3084 opstream << oldgamespeed;
3085 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
3086 opstream << difficulty;
3087 opstream << "\nDamage effects(blackout, doublevision):\n";
3088 opstream << damageeffects;
3089 opstream << "\nText:\n";
3090 opstream << texttoggle;
3091 opstream << "\nDebug:\n";
3092 opstream << debugmode;
3093 opstream << "\nVBL Sync:\n";
3094 opstream << vblsync;
3095 opstream << "\nShow Points:\n";
3096 opstream << showpoints;
3097 opstream << "\nAlways Blur:\n";
3098 opstream << alwaysblur;
3099 opstream << "\nImmediate mode (turn on on G5):\n";
3100 opstream << immediate;
3101 opstream << "\nVelocity blur:\n";
3102 opstream << velocityblur;
3103 opstream << "\nVolume:\n";
3105 opstream << "\nForward key:\n";
3106 opstream << KeyToChar(forwardkey);
3107 opstream << "\nBack key:\n";
3108 opstream << KeyToChar(backkey);
3109 opstream << "\nLeft key:\n";
3110 opstream << KeyToChar(leftkey);
3111 opstream << "\nRight key:\n";
3112 opstream << KeyToChar(rightkey);
3113 opstream << "\nJump key:\n";
3114 opstream << KeyToChar(jumpkey);
3115 opstream << "\nCrouch key:\n";
3116 opstream << KeyToChar(crouchkey);
3117 opstream << "\nDraw key:\n";
3118 opstream << KeyToChar(drawkey);
3119 opstream << "\nThrow key:\n";
3120 opstream << KeyToChar(throwkey);
3121 opstream << "\nAttack key:\n";
3122 opstream << KeyToChar(attackkey);
3123 opstream << "\nChat key:\n";
3124 opstream << KeyToChar(chatkey);
3129 if(mainmenu==1||mainmenu==2){
3130 if(loaddistrib>4)transition+=multiplier/8;
3138 FSOUND_SetFrequency(channels[stream_music3], 22050);
3140 if(entername||mainmenu==13||mainmenu==14){
3142 if(IsKeyDown(theKeyMap, i)){
3143 togglekeydelay[i]+=multiplier;
3144 if(togglekeydelay[i]>.4){
3146 togglekeydelay[i]=.36;
3149 if(KeyToSingleChar(i)!='\0'&&displaychars[0]<60){
3150 for(j=255;j>=displayselected+1;j--){
3151 displaytext[0][j]=displaytext[0][j-1];
3153 displaytext[0][displayselected]=KeyToSingleChar(i);
3154 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]);
3158 if(i==MAC_DELETE_KEY&&displayselected!=0){
3159 for(j=displayselected-1;j<255;j++){
3160 displaytext[0][j]=displaytext[0][j+1];
3162 displaytext[0][255]=' ';
3166 if(i==MAC_ARROW_LEFT_KEY&&displayselected!=0){
3169 if(i==MAC_ARROW_RIGHT_KEY&&displayselected<displaychars[0]){
3172 if(i==MAC_RETURN_KEY&&entername){
3173 if(displaychars[0]){
3175 strcpy(accountname[numaccounts-1],displaytext[0]);
3176 accountactive=numaccounts-1;
3177 accountdifficulty[accountactive]=1;
3178 accountprogress[accountactive]=0;
3179 accountpoints[accountactive]=0;
3180 accountcampaigntime[accountactive]=0;
3181 accountcampaignscore[accountactive]=0;
3182 accountcampaignfasttime[accountactive]=0;
3183 accountcampaignhighscore[accountactive]=0;
3185 accounthighscore[accountactive][j]=0;
3186 accountfasttime[accountactive][j]=0;
3189 accountunlocked[accountactive][j]=0;
3191 accountcampaignchoicesmade[accountactive]=0;
3194 displaytext[0][j]=' ';
3208 float gLoc[3]={0,0,0};
3209 float vel[3]={0,0,0};
3210 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3211 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
3212 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3213 FSOUND_SetVolume(channels[firestartsound], 256);
3214 FSOUND_SetPaused(channels[firestartsound], FALSE);
3215 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3218 displaytext[0][j]=' ';
3226 if(i==MAC_RETURN_KEY&&mainmenu==14){
3227 if(displaychars[0]){
3228 char serialstring[256];
3229 char tempstring[256];
3230 #if defined(__APPLE__)
3231 sprintf (tempstring, "%s", registrationname);
3232 #elif defined(_MSC_VER) || defined(__linux__)
3233 sprintf (tempstring, "%s-windows", registrationname);
3235 #error Please make sure you have the right registration key stuff here!
3242 longnum = MD5_string ( tempstring);
3243 //longnum = 1111111111111111;
3244 num1 = longnum/100000000;
3245 num2 = longnum%100000000;
3246 sprintf (tempstring, "%d-%d-%d-%d\0\0\0\0\0", num1/10000, num1%10000, num2/10000, num2%10000);
3250 if(num1/10000>999)numchars+=4;
3251 else if(num1/10000>99)numchars+=3;
3252 else if(num1/10000>9)numchars+=2;
3254 if(num1%10000>999)numchars+=4;
3255 else if(num1%10000>99)numchars+=3;
3256 else if(num1%10000>9)numchars+=2;
3258 if(num2/10000>999)numchars+=4;
3259 else if(num2/10000>99)numchars+=3;
3260 else if(num2/10000>9)numchars+=2;
3262 if(num2%10000>999)numchars+=4;
3263 else if(num2%10000>99)numchars+=3;
3264 else if(num2%10000>9)numchars+=2;
3269 for(j=0;j<numchars;j++){
3270 if(displaytext[0][j]!=tempstring[j]&&tempstring[j]!=' '&&tempstring[j]!='\0')goodcode--;
3273 if(longnum==LONGLONGCONST(5077041556214789))goodcode=-1;
3275 if(goodcode<0)goodcode=0;
3282 tfile=fopen( ":Data:Sounds:flame.ogg", "wb" );
3286 numchars=strlen(registrationname);
3287 fpackf(tfile, "Bb", registered);
3288 fpackf(tfile, "Bi", numchars);
3291 for(j=0;j<numchars;j++)
3293 fpackf(tfile, "Bb", registrationname[j]);
3296 fpackf(tfile, "Bi", num1);
3297 fpackf(tfile, "Bi", num2);
3311 float gLoc[3]={0,0,0};
3312 float vel[3]={0,0,0};
3313 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3314 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
3315 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3316 FSOUND_SetVolume(channels[firestartsound], 256);
3317 FSOUND_SetPaused(channels[firestartsound], FALSE);
3318 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3321 displaytext[0][j]=' ';
3327 if(i==MAC_RETURN_KEY&&mainmenu==13){
3328 if(displaychars[0]){
3329 sprintf (registrationname, "%s", displaytext[0]);
3330 if(displaychars[0]<254)registrationname[displaychars[0]]='\0';
3340 float gLoc[3]={0,0,0};
3341 float vel[3]={0,0,0};
3342 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3343 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
3344 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3345 FSOUND_SetVolume(channels[firestartsound], 256);
3346 FSOUND_SetPaused(channels[firestartsound], FALSE);
3347 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3350 displaytext[0][j]=' ';
3354 /*char tempstring[50];
3355 sprintf (tempstring, registrationname);
3361 longnum = MD5_string ( tempstring);
3362 num1 = longnum/100000000;
3363 num2 = longnum%100000000;
3364 sprintf (displaytext[0], "%d-%d-%d-%d", num1/10000, num1%10000, num2/10000, num2%10000);
3366 displaychars[0]=strlen(displaytext[0]);
3375 togglekeydelay[i]=0;
3379 displayblinkdelay-=multiplier;
3380 if(displayblinkdelay<=0){
3381 displayblinkdelay=.3;
3382 displayblink=1-displayblink;
3388 if(hostile==1)hostiletime+=multiplier;
3390 if(!winfreeze)leveltime+=multiplier;
3391 if(IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)){
3398 if(IsKeyDown(theKeyMap, chatkey)&&!chattogglekeydown&&!console&&!chatting&&debugmode){
3400 chattogglekeydown=1;
3401 togglekey[chatkey]=1;
3402 togglekeydelay[chatkey]=-20;
3405 if(!IsKeyDown(theKeyMap, chatkey)){
3406 chattogglekeydown=0;
3411 if(IsKeyDown(theKeyMap, i)){
3412 togglekeydelay[i]+=multiplier;
3413 if(togglekeydelay[i]>.4){
3415 togglekeydelay[i]=.36;
3418 if(KeyToSingleChar(i)!='\0'&&displaychars[0]<60){
3419 for(j=255;j>=displayselected+1;j--){
3420 displaytext[0][j]=displaytext[0][j-1];
3422 displaytext[0][displayselected]=KeyToSingleChar(i);
3423 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]);
3427 if(i==MAC_DELETE_KEY&&displayselected!=0){
3428 for(j=displayselected-1;j<255;j++){
3429 displaytext[0][j]=displaytext[0][j+1];
3431 displaytext[0][255]=' ';
3435 if(i==MAC_ARROW_LEFT_KEY&&displayselected!=0){
3438 if(i==MAC_ARROW_RIGHT_KEY&&displayselected<displaychars[0]){
3441 if(i==MAC_RETURN_KEY){
3442 if(displaychars[0]){
3443 /*for(j=0;j<displaychars[0];j++){
3444 talkname[j]=displaytext[0][j];
3446 talkname[displaychars[0]]='\0';
3447 sprintf (chatname, "%s: %s",playerName,talkname);
3448 //NetworkSendInformation(chatname);
3451 displaytext[0][j]=' ';
3463 togglekeydelay[i]=0;
3467 displayblinkdelay-=multiplier;
3468 if(displayblinkdelay<=0){
3469 displayblinkdelay=.3;
3470 displayblink=1-displayblink;
3474 if(chatting)keyboardfrozen=1;
3476 if(IsKeyDown(theKeyMap, MAC_V_KEY)&&!freezetogglekeydown&&debugmode){
3479 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
3481 freezetogglekeydown=1;
3484 if(!IsKeyDown(theKeyMap, MAC_V_KEY)&&!IsKeyDown(theKeyMap, MAC_F1_KEY)){
3485 freezetogglekeydown=0;
3488 if(IsKeyDown(theKeyMap, MAC_TILDE_KEY)&&!consoletogglekeydown&&debugmode){
3490 if(!console)freeze=0;
3492 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
3494 consoletogglekeydown=1;
3497 if(!IsKeyDown(theKeyMap, MAC_TILDE_KEY)){
3498 consoletogglekeydown=0;
3501 if(console)freeze=1;
3503 if(console&&!IsKeyDown(theKeyMap,MAC_COMMAND_KEY)){
3505 if(IsKeyDown(theKeyMap, i)){
3506 togglekeydelay[i]+=multiplier;
3507 if(togglekeydelay[i]>.4){
3509 togglekeydelay[i]=.36;
3512 if(KeyToSingleChar(i)!='\0'&&consolechars[0]<255){
3513 for(j=255;j>=consoleselected+1;j--){
3514 consoletext[0][j]=consoletext[0][j-1];
3516 consoletext[0][consoleselected]=KeyToSingleChar(i);
3517 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))consoletext[0][consoleselected]=Shift(consoletext[0][consoleselected]);
3521 else if(i==MAC_ENTER_KEY){
3522 for(j=255;j>=consoleselected+1;j--){
3523 consoletext[0][j]=consoletext[0][j-1];
3525 consoletext[0][consoleselected]='\n';
3529 if(i==MAC_DELETE_KEY&&consoleselected!=0){
3530 for(j=consoleselected-1;j<255;j++){
3531 consoletext[0][j]=consoletext[0][j+1];
3533 consoletext[0][255]=' ';
3537 if(i==MAC_ARROW_UP_KEY){
3538 if(archiveselected<14)archiveselected++;
3540 consolechars[0]=consolechars[archiveselected];
3541 consoletext[0][j]=consoletext[archiveselected][j];
3542 consoleselected=consolechars[0];
3545 if(i==MAC_ARROW_DOWN_KEY){
3546 if(archiveselected>0)archiveselected--;
3548 consolechars[0]=consolechars[archiveselected];
3549 consoletext[0][j]=consoletext[archiveselected][j];
3550 consoleselected=consolechars[0];
3553 if(i==MAC_ARROW_LEFT_KEY&&consoleselected!=0){
3556 if(i==MAC_ARROW_RIGHT_KEY&&consoleselected<consolechars[0]){
3559 if(i==MAC_RETURN_KEY){
3562 if(Compare(consoletext[0],"quit ",0,4)||Compare(consoletext[0],"exit ",0,4)){
3563 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
3564 FSOUND_SetVolume(channels[consolesuccesssound], 256);
3565 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
3569 /*if(Compare(consoletext[0],"send ",0,4)){
3570 for(j=5;j<consolechars[0];j++){
3571 talkname[j-5]=consoletext[0][j];
3573 talkname[consolechars[0]-5]='\0';
3574 sprintf (chatname, "%s: %s",playerName,talkname);
3575 //NetworkSendInformation(chatname);
3578 if(Compare(consoletext[0],"name ",0,4)){
3580 numchars=consolechars[0]-5;
3581 if(numchars>32)numchars=32;
3582 for(j=5;j<numchars+5;j++){
3583 talkname[j-5]=consoletext[0][j];
3585 talkname[numchars]='\0';
3586 sprintf (chatname, "Player %s is now known as %s.",playerName,talkname);
3587 //NetworkSendInformation(chatname);
3588 sprintf (playerName, "%s",talkname);
3589 //NetworkSendName(playerName);
3592 if(Compare(consoletext[0],"map ",0,3)){
3604 for(j=4;j<consolechars[0];j++){
3605 mapname[j-4+11]=consoletext[0][j];
3607 mapname[consolechars[0]-4+11]='\0';
3613 /*if(Compare(consoletext[0],"connect ",0,7)&&!ishost){
3615 unsigned char playerNameStr[32];
3616 char theIPAddress[256];
3618 NMUInt32 port = 25710;
3620 strcpy(playerName, "Client");
3621 GameC2PStr( playerName, playerNameStr );
3623 for(j=0;j<consolechars[0]-8;j++){
3624 theIPAddress[j]=consoletext[0][j+8];
3626 theIPAddress[consolechars[0]-8]='\0';
3628 sprintf( thePort, "%li", port );
3629 v=NetworkStartClient( theIPAddress, thePort, playerNameStr );
3632 if(consolechars[0]>0){
3635 consoletext[k][j]=consoletext[k-1][j];
3637 consolechars[k]=consolechars[k-1];
3640 consoletext[0][j]=' ';
3642 if(v!=-4994)sprintf (consoletext[0], "Error #%d!!!",v);
3643 else sprintf (consoletext[0], "Could not open connection");
3645 consolechars[0]=255;
3652 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
3653 FSOUND_SetVolume(channels[consolesuccesssound], 256);
3654 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
3656 if(consolechars[0]>0){
3659 consoletext[k][j]=consoletext[k-1][j];
3661 consolechars[k]=consolechars[k-1];
3664 consoletext[0][j]=' ';
3666 sprintf (consoletext[0], "Connected to %s",theIPAddress);
3668 consolechars[0]=255;
3674 if(Compare(consoletext[0],"host ",0,4)){
3675 unsigned char gameNameStr[32], playerNameStr[32];
3676 char gameName[32];//, playerName[32];
3684 strcpy(gameName, "Host's game");
3685 strcpy(playerName, "Host");
3686 GameC2PStr( gameName, gameNameStr );
3687 GameC2PStr( playerName, playerNameStr );
3689 v=NetworkStartServer( (NMUInt16)port, players, gameNameStr, playerNameStr );
3692 if(consolechars[0]>0){
3695 consoletext[k][j]=consoletext[k-1][j];
3697 consolechars[k]=consolechars[k-1];
3700 consoletext[0][j]=' ';
3702 sprintf (consoletext[0], "Error #%d!!!",v);
3704 consolechars[0]=255;
3711 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
3712 FSOUND_SetVolume(channels[consolesuccesssound], 256);
3713 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
3715 if(consolechars[0]>0){
3718 consoletext[k][j]=consoletext[k-1][j];
3720 consolechars[k]=consolechars[k-1];
3723 consoletext[0][j]=' ';
3725 sprintf (consoletext[0], "Game hosted");
3727 consolechars[0]=255;
3733 if(Compare(consoletext[0],"save ",0,4)){
3745 for(j=5;j<consolechars[0];j++){
3746 mapname[j-5+11]=consoletext[0][j];
3748 mapname[consolechars[0]-5+11]='\0';
3750 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
3751 FSOUND_SetVolume(channels[consolesuccesssound], 256);
3752 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
3759 tfile=fopen( mapname, "wb" );
3760 fpackf(tfile, "Bi", mapvers);
3761 //fpackf(tfile, "Bi", indemo);
3762 fpackf(tfile, "Bi", maptype);
3763 fpackf(tfile, "Bi", hostile);
3764 fpackf(tfile, "Bf Bf", viewdistance, fadestart);
3765 fpackf(tfile, "Bb Bf Bf Bf", skyboxtexture, skyboxr, skyboxg, skyboxb);
3766 fpackf(tfile, "Bf Bf Bf", skyboxlightr, skyboxlightg, skyboxlightb);
3767 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);
3768 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3769 for(j=0;j<player[0].num_weapons;j++){
3770 fpackf(tfile, "Bi", weapons.type[player[0].weaponids[j]]);
3773 fpackf(tfile, "Bf Bf Bf", player[0].armorhead, player[0].armorhigh, player[0].armorlow);
3774 fpackf(tfile, "Bf Bf Bf", player[0].protectionhead, player[0].protectionhigh, player[0].protectionlow);
3775 fpackf(tfile, "Bf Bf Bf", player[0].metalhead, player[0].metalhigh, player[0].metallow);
3776 fpackf(tfile, "Bf Bf", player[0].power, player[0].speedmult);
3778 fpackf(tfile, "Bi", player[0].numclothes);
3780 fpackf(tfile, "Bi Bi", player[0].whichskin, player[0].creature);
3782 fpackf(tfile, "Bi", numdialogues);
3784 for(k=0;k<numdialogues;k++){
3785 fpackf(tfile, "Bi", numdialogueboxes[k]);
3786 fpackf(tfile, "Bi", dialoguetype[k]);
3788 fpackf(tfile, "Bf Bf Bf", participantlocation[k][l].x, participantlocation[k][l].y, participantlocation[k][l].z);
3789 fpackf(tfile, "Bf", participantrotation[k][l]);
3791 if(numdialogueboxes)
3792 for(l=0;l<numdialogueboxes[k];l++){
3793 fpackf(tfile, "Bi", dialogueboxlocation[k][l]);
3794 fpackf(tfile, "Bf", dialogueboxcolor[k][l][0]);
3795 fpackf(tfile, "Bf", dialogueboxcolor[k][l][1]);
3796 fpackf(tfile, "Bf", dialogueboxcolor[k][l][2]);
3797 fpackf(tfile, "Bi", dialogueboxsound[k][l]);
3799 templength=strlen(dialoguetext[k][l]);
3800 fpackf(tfile, "Bi",(templength));
3801 for(m=0;m<templength;m++){
3802 fpackf(tfile, "Bb", dialoguetext[k][l][m]);
3803 if(dialoguetext[k][l][m]=='\0')break;
3806 templength=strlen(dialoguename[k][l]);
3807 fpackf(tfile, "Bi",templength);
3808 for(m=0;m<templength;m++){
3809 fpackf(tfile, "Bb", dialoguename[k][l][m]);
3810 if(dialoguename[k][l][m]=='\0')break;
3813 fpackf(tfile, "Bf Bf Bf", dialoguecamera[k][l].x, dialoguecamera[k][l].y, dialoguecamera[k][l].z);
3814 fpackf(tfile, "Bi", participantfocus[k][l]);
3815 fpackf(tfile, "Bi", participantaction[k][l]);
3818 fpackf(tfile, "Bf Bf Bf", participantfacing[k][l][m].x, participantfacing[k][l][m].y, participantfacing[k][l][m].z);
3820 fpackf(tfile, "Bf Bf",dialoguecamerarotation[k][l],dialoguecamerarotation2[k][l]);
3824 if(player[0].numclothes)
3825 for(k=0;k<player[0].numclothes;k++){
3826 templength=strlen(player[0].clothes[k]);
3827 fpackf(tfile, "Bi", templength);
3828 for(l=0;l<templength;l++)
3829 fpackf(tfile, "Bb", player[0].clothes[k][l]);
3830 fpackf(tfile, "Bf Bf Bf", player[0].clothestintr[k], player[0].clothestintg[k], player[0].clothestintb[k]);
3833 fpackf(tfile, "Bi", environment);
3835 fpackf(tfile, "Bi", objects.numobjects);
3837 if(objects.numobjects)
3838 for(k=0;k<objects.numobjects;k++){
3839 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]);
3842 fpackf(tfile, "Bi", numhotspots);
3844 for(i=0;i<numhotspots;i++){
3845 fpackf(tfile, "Bi Bf Bf Bf Bf", hotspottype[i],hotspotsize[i],hotspot[i].x,hotspot[i].y,hotspot[i].z);
3846 templength=strlen(hotspottext[i]);
3847 fpackf(tfile, "Bi",templength);
3848 for(l=0;l<templength;l++)
3849 fpackf(tfile, "Bb", hotspottext[i][l]);
3852 fpackf(tfile, "Bi", numplayers);
3853 if(numplayers>1&&numplayers<maxplayers)
3854 for(j=1;j<numplayers;j++){
3855 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);
3856 if(player[j].num_weapons>0&&player[j].num_weapons<5)
3857 for(k=0;k<player[j].num_weapons;k++){
3858 fpackf(tfile, "Bi", weapons.type[player[j].weaponids[k]]);
3860 if(player[j].numwaypoints<30){
3861 fpackf(tfile, "Bi", player[j].numwaypoints);
3862 for(k=0;k<player[j].numwaypoints;k++){
3863 fpackf(tfile, "Bf", player[j].waypoints[k].x);
3864 fpackf(tfile, "Bf", player[j].waypoints[k].y);
3865 fpackf(tfile, "Bf", player[j].waypoints[k].z);
3866 fpackf(tfile, "Bi", player[j].waypointtype[k]);
3868 fpackf(tfile, "Bi", player[j].waypoint);
3871 player[j].numwaypoints=0;
3872 player[j].waypoint=0;
3873 fpackf(tfile, "Bi Bi Bi", player[j].numwaypoints, player[j].waypoint, player[j].waypoint);
3876 fpackf(tfile, "Bf Bf Bf", player[j].armorhead, player[j].armorhigh, player[j].armorlow);
3877 fpackf(tfile, "Bf Bf Bf", player[j].protectionhead, player[j].protectionhigh, player[j].protectionlow);
3878 fpackf(tfile, "Bf Bf Bf", player[j].metalhead, player[j].metalhigh, player[j].metallow);
3879 fpackf(tfile, "Bf Bf", player[j].power, player[j].speedmult);
3881 if(player[j].creature==wolftype){
3882 headprop=player[j].proportionhead.x/1.1;
3883 bodyprop=player[j].proportionbody.x/1.1;
3884 armprop=player[j].proportionarms.x/1.1;
3885 legprop=player[j].proportionlegs.x/1.1;
3888 if(player[j].creature==rabbittype){
3889 headprop=player[j].proportionhead.x/1.2;
3890 bodyprop=player[j].proportionbody.x/1.05;
3891 armprop=player[j].proportionarms.x/1.00;
3892 legprop=player[j].proportionlegs.x/1.1;
3895 fpackf(tfile, "Bf Bf Bf Bf", headprop, bodyprop, armprop, legprop);
3899 fpackf(tfile, "Bi", player[j].numclothes);
3900 if(player[j].numclothes)
3901 for(k=0;k<player[j].numclothes;k++){
3903 templength=strlen(player[j].clothes[k]);
3904 fpackf(tfile, "Bi", templength);
3905 for(l=0;l<templength;l++)
3906 fpackf(tfile, "Bb", player[j].clothes[k][l]);
3907 fpackf(tfile, "Bf Bf Bf", player[j].clothestintr[k], player[j].clothestintg[k], player[j].clothestintb[k]);
3911 fpackf(tfile, "Bi", numpathpoints);
3913 for(j=0;j<numpathpoints;j++){
3914 fpackf(tfile, "Bf Bf Bf Bi", pathpoint[j].x, pathpoint[j].y, pathpoint[j].z, numpathpointconnect[j]);
3915 for(k=0;k<numpathpointconnect[j];k++){
3916 fpackf(tfile, "Bi", pathpointconnect[j][k]);
3920 fpackf(tfile, "Bf Bf Bf Bf", mapcenter.x, mapcenter.y, mapcenter.z, mapradius);
3928 tfile=fopen( mapname, "wb" );
3929 fwrite( &mapvers, 1, sizeof(int), tfile );
3930 fwrite( &player[0].coords.x, 1, sizeof(float), tfile );
3931 fwrite( &player[0].coords.y, 1, sizeof(float), tfile );
3932 fwrite( &player[0].coords.z, 1, sizeof(float), tfile );
3933 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
3934 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
3935 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
3936 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3937 for(j=0;j<player[0].num_weapons;j++){
3938 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
3941 fwrite( &player[0].armorhead, 1, sizeof(int), tfile );
3942 fwrite( &player[0].armorhigh, 1, sizeof(int), tfile );
3943 fwrite( &player[0].armorlow, 1, sizeof(int), tfile );
3944 fwrite( &player[0].protectionhead, 1, sizeof(int), tfile );
3945 fwrite( &player[0].protectionhigh, 1, sizeof(int), tfile );
3946 fwrite( &player[0].protectionlow, 1, sizeof(int), tfile );
3947 fwrite( &player[0].metalhead, 1, sizeof(int), tfile );
3948 fwrite( &player[0].metalhigh, 1, sizeof(int), tfile );
3949 fwrite( &player[0].metallow, 1, sizeof(int), tfile );
3950 fwrite( &player[0].power, 1, sizeof(int), tfile );
3951 fwrite( &player[0].speedmult, 1, sizeof(int), tfile );
3953 fwrite( &player[0].numclothes, 1, sizeof(int), tfile );
3954 if(player[0].numclothes)
3955 for(k=0;k<player[0].numclothes;k++){
3957 templength=strlen(player[0].clothes[k]);
3958 fwrite( &templength,1,sizeof(int),tfile);
3959 for(l=0;l<templength;l++)
3960 fwrite( &player[0].clothes[k][l],1,sizeof(char),tfile);
3961 fwrite( &player[0].clothestintr[k],1,sizeof(float),tfile);
3962 fwrite( &player[0].clothestintg[k],1,sizeof(float),tfile);
3963 fwrite( &player[0].clothestintb[k],1,sizeof(float),tfile);
3966 fwrite( &environment, 1, sizeof(int), tfile );
3968 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
3970 for(k=0;k<objects.numobjects;k++){
3971 fwrite( &objects.type[k], 1, sizeof(int), tfile );
3972 fwrite( &objects.rotation[k], 1, sizeof(float), tfile );
3973 fwrite( &objects.rotation2[k], 1, sizeof(float), tfile );
3974 fwrite( &objects.position[k].x, 1, sizeof(float), tfile );
3975 fwrite( &objects.position[k].y, 1, sizeof(float), tfile );
3976 fwrite( &objects.position[k].z, 1, sizeof(float), tfile );
3977 fwrite( &objects.scale[k], 1, sizeof(float), tfile );
3980 fwrite( &numplayers, 1, sizeof(int), tfile );
3981 if(numplayers>1&&numplayers<maxplayers)
3982 for(j=1;j<numplayers;j++){
3983 fwrite( &player[j].whichskin, 1, sizeof(int), tfile );
3984 fwrite( &player[j].creature, 1, sizeof(int), tfile );
3985 fwrite( &player[j].coords.x, 1, sizeof(float), tfile );
3986 fwrite( &player[j].coords.y, 1, sizeof(float), tfile );
3987 fwrite( &player[j].coords.z, 1, sizeof(float), tfile );
3988 fwrite( &player[j].num_weapons, 1, sizeof(int), tfile );
3989 if(player[j].num_weapons>0&&player[j].num_weapons<5)
3990 for(k=0;k<player[j].num_weapons;k++){
3991 fwrite( &weapons.type[player[j].weaponids[k]], 1, sizeof(int), tfile );
3993 if(player[j].numwaypoints<30){
3994 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
3995 for(k=0;k<player[j].numwaypoints;k++){
3996 fwrite( &player[j].waypoints[k].x, 1, sizeof(float), tfile );
3997 fwrite( &player[j].waypoints[k].y, 1, sizeof(float), tfile );
3998 fwrite( &player[j].waypoints[k].z, 1, sizeof(float), tfile );
4000 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4001 //fwrite( &player[j].jumppath, 1, sizeof(bool), tfile );
4004 player[j].numwaypoints=0;
4005 player[j].waypoint=0;
4006 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
4007 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4008 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4010 fwrite( &player[j].armorhead, 1, sizeof(int), tfile );
4011 fwrite( &player[j].armorhigh, 1, sizeof(int), tfile );
4012 fwrite( &player[j].armorlow, 1, sizeof(int), tfile );
4013 fwrite( &player[j].protectionhead, 1, sizeof(int), tfile );
4014 fwrite( &player[j].protectionhigh, 1, sizeof(int), tfile );
4015 fwrite( &player[j].protectionlow, 1, sizeof(int), tfile );
4016 fwrite( &player[j].metalhead, 1, sizeof(int), tfile );
4017 fwrite( &player[j].metalhigh, 1, sizeof(int), tfile );
4018 fwrite( &player[j].metallow, 1, sizeof(int), tfile );
4019 fwrite( &player[j].power, 1, sizeof(int), tfile );
4020 fwrite( &player[j].speedmult, 1, sizeof(int), tfile );
4022 fwrite( &player[j].numclothes, 1, sizeof(int), tfile );
4023 if(player[j].numclothes)
4024 for(k=0;k<player[j].numclothes;k++){
4026 templength=strlen(player[j].clothes[k]);
4027 fwrite( &templength,1,sizeof(int),tfile);
4028 for(l=0;l<templength;l++)
4029 fwrite( &player[j].clothes[k][l],1,sizeof(char),tfile);
4030 fwrite( &player[j].clothestintr[k],1,sizeof(float),tfile);
4031 fwrite( &player[j].clothestintg[k],1,sizeof(float),tfile);
4032 fwrite( &player[j].clothestintb[k],1,sizeof(float),tfile);
4035 fwrite( &numpathpoints, 1, sizeof(int), tfile );
4037 for(j=0;j<numpathpoints;j++){
4038 fwrite( &pathpoint[j].x, 1, sizeof(float), tfile );
4039 fwrite( &pathpoint[j].y, 1, sizeof(float), tfile );
4040 fwrite( &pathpoint[j].z, 1, sizeof(float), tfile );
4041 fwrite( &numpathpointconnect[j], 1, sizeof(int), tfile );
4042 for(k=0;k<numpathpointconnect[j];k++){
4043 fwrite( &pathpointconnect[j][k], 1, sizeof(int), tfile );
4047 fwrite( &mapcenter.x, 1, sizeof(float), tfile );
4048 fwrite( &mapcenter.y, 1, sizeof(float), tfile );
4049 fwrite( &mapcenter.z, 1, sizeof(float), tfile );
4051 fwrite( &mapradius, 1, sizeof(float), tfile );
4057 if(Compare(consoletext[0],"save ",0,4)){
4069 for(j=5;j<consolechars[0];j++){
4070 mapname[j-5+11]=consoletext[0][j];
4072 mapname[consolechars[0]-5+11]='\0';
4074 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
4075 FSOUND_SetVolume(channels[consolesuccesssound], 256);
4076 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
4079 tfile=fopen( mapname, "wb" );
4080 fwrite( &player[0].coords, 1, sizeof(XYZ), tfile );
4081 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
4082 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
4083 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
4084 if(player[0].num_weapons>0&&player[0].num_weapons<5)
4085 for(j=0;j<player[0].num_weapons;j++){
4086 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
4088 fwrite( &environment, 1, sizeof(int), tfile );
4090 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
4091 fwrite( &objects.type, 1, sizeof(int)*objects.numobjects, tfile );
4092 fwrite( &objects.rotation, 1, sizeof(float)*objects.numobjects, tfile );
4093 fwrite( &objects.position, 1, sizeof(XYZ)*objects.numobjects, tfile );
4094 fwrite( &objects.scale, 1, sizeof(float)*objects.numobjects, tfile );
4096 fwrite( &numplayers, 1, sizeof(int), tfile );
4097 if(numplayers>1&&numplayers<maxplayers)
4098 for(j=1;j<numplayers;j++){
4099 fwrite( &player[j].coords, 1, sizeof(XYZ), tfile );
4100 fwrite( &player[j].num_weapons, 1, sizeof(int), tfile );
4101 if(player[j].num_weapons>0&&player[j].num_weapons<5)
4102 for(k=0;k<player[j].num_weapons;k++){
4103 fwrite( &weapons.type[player[j].weaponids[k]], 1, sizeof(int), tfile );
4105 if(player[j].numwaypoints<30){
4106 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
4107 fwrite( &player[j].waypoints, 1, sizeof(XYZ)*player[j].numwaypoints, tfile );
4108 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4109 //fwrite( &player[j].jumppath, 1, sizeof(bool), tfile );
4112 player[j].numwaypoints=0;
4113 player[j].waypoint=0;
4114 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
4115 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4116 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4119 fwrite( &numpathpoints, 1, sizeof(int), tfile );
4121 for(j=0;j<numpathpoints;j++){
4122 fwrite( &pathpoint[j], 1, sizeof(XYZ), tfile );
4123 fwrite( &numpathpointconnect[j], 1, sizeof(int), tfile );
4124 for(k=0;k<numpathpointconnect[j];k++){
4125 fwrite( &pathpointconnect[j][k], 1, sizeof(int), tfile );
4131 if(Compare(consoletext[0],"cellar door ",0,11)||Compare(consoletext[0],"cellardoor ",0,10)){
4132 LoadTextureSave(":Data:Textures:Furdarko.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4135 /*if(Compare(consoletext[0],"Pants ",0,5)){
4136 AddClothes(":Data:Textures:Pants.png",0,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
4137 player[i].DoMipmaps(5,0,0,player[i].skeleton.skinsize,player[i].skeleton.skinsize);
4141 if(Compare(consoletext[0],"tintr ",0,5)||Compare(consoletext[0],"Tintr ",0,5)){
4142 for(j=6;j<consolechars[0];j++){
4143 mapname[j-6]=consoletext[0][j];
4146 tintr=atof(mapname);
4151 if(Compare(consoletext[0],"speed ",0,5)||Compare(consoletext[0],"Speed ",0,5)){
4152 for(j=6;j<consolechars[0];j++){
4153 mapname[j-6]=consoletext[0][j];
4156 player[0].speedmult=atof(mapname);
4161 if(Compare(consoletext[0],"strength ",0,8)||Compare(consoletext[0],"Strength ",0,8)){
4162 for(j=9;j<consolechars[0];j++){
4163 mapname[j-9]=consoletext[0][j];
4166 player[0].power=atof(mapname);
4171 if(Compare(consoletext[0],"viewdistance ",0,12)||Compare(consoletext[0],"Viewdistance ",0,12)){
4172 for(j=13;j<consolechars[0];j++){
4173 mapname[j-13]=consoletext[0][j];
4176 viewdistance=atof(mapname)*100;
4181 if(Compare(consoletext[0],"fadestart ",0,9)||Compare(consoletext[0],"Fadestart ",0,9)){
4182 for(j=10;j<consolechars[0];j++){
4183 mapname[j-10]=consoletext[0][j];
4186 fadestart=atof(mapname);
4191 if(Compare(consoletext[0],"power ",0,5)||Compare(consoletext[0],"Power ",0,5)){
4192 for(j=6;j<consolechars[0];j++){
4193 mapname[j-6]=consoletext[0][j];
4196 player[0].power=atof(mapname);
4201 if(Compare(consoletext[0],"slomo ",0,5)||Compare(consoletext[0],"Slomo ",0,5)){
4202 for(j=6;j<consolechars[0];j++){
4203 mapname[j-6]=consoletext[0][j];
4206 slomospeed=atof(mapname);
4213 if(Compare(consoletext[0],"slofreq ",0,7)||Compare(consoletext[0],"Slofreq ",0,7)){
4214 for(j=8;j<consolechars[0];j++){
4215 mapname[j-8]=consoletext[0][j];
4218 slomofreq=atoi(mapname);
4223 if(Compare(consoletext[0],"size ",0,4)||Compare(consoletext[0],"Size ",0,4)){
4224 for(j=5;j<consolechars[0];j++){
4225 mapname[j-5]=consoletext[0][j];
4228 player[0].scale=atof(mapname)*.2;
4233 if(Compare(consoletext[0],"sizenear ",0,8)||Compare(consoletext[0],"Sizenear ",0,8)){
4235 float closestdist=-1;
4238 for(i=1;i<numplayers;i++){
4239 distance=findDistancefast(&player[i].coords,&player[0].coords);
4240 if(closestdist==-1||distance<closestdist){
4241 closestdist=distance;
4246 for(j=9;j<consolechars[0];j++){
4247 mapname[j-9]=consoletext[0][j];
4250 player[closest].scale=atof(mapname)*.2;
4255 if(Compare(consoletext[0],"proportionnear ",0,14)||Compare(consoletext[0],"Proportionnear ",0,14)){
4260 float closestdist=-1;
4263 for(i=1;i<numplayers;i++){
4264 distance=findDistancefast(&player[i].coords,&player[0].coords);
4265 if(closestdist==-1||distance<closestdist){
4266 closestdist=distance;
4274 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4275 mapname[j-startpoint]=consoletext[0][j];
4277 if(consoletext[0][j]=='\0')alldone=1;
4279 mapname[j-startpoint]='\0';
4281 headprop=atof(mapname);
4285 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4286 mapname[j-startpoint]=consoletext[0][j];
4288 if(consoletext[0][j]=='\0')alldone=1;
4290 mapname[j-startpoint]='\0';
4292 bodyprop=atof(mapname);
4296 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4297 mapname[j-startpoint]=consoletext[0][j];
4299 if(consoletext[0][j]=='\0')alldone=1;
4301 mapname[j-startpoint]='\0';
4303 armprop=atof(mapname);
4307 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4308 mapname[j-startpoint]=consoletext[0][j];
4310 if(consoletext[0][j]=='\0')alldone=1;
4312 mapname[j-startpoint]='\0';
4314 legprop=atof(mapname);
4316 if(player[closest].creature==wolftype){
4317 player[closest].proportionhead=1.1*headprop;
4318 player[closest].proportionbody=1.1*bodyprop;
4319 player[closest].proportionarms=1.1*armprop;
4320 player[closest].proportionlegs=1.1*legprop;
4323 if(player[closest].creature==rabbittype){
4324 player[closest].proportionhead=1.2*headprop;
4325 player[closest].proportionbody=1.05*bodyprop;
4326 player[closest].proportionarms=1.00*armprop;
4327 player[closest].proportionlegs=1.1*legprop;
4328 player[closest].proportionlegs.y=1.05*legprop;
4335 if(Compare(consoletext[0],"sizemin ",0,7)||Compare(consoletext[0],"Sizemin ",0,7)){
4336 for(i=1;i<numplayers;i++){
4337 if(player[i].scale<0.8*0.2)player[i].scale=0.8*0.2;
4343 if(Compare(consoletext[0],"tutorial ",0,8)||Compare(consoletext[0],"Tutorial ",0,8)){
4344 for(j=9;j<consolechars[0];j++){
4345 mapname[j-9]=consoletext[0][j];
4348 tutoriallevel=atoi(mapname);
4354 if(Compare(consoletext[0],"tintg ",0,5)||Compare(consoletext[0],"Tintg ",0,5)){
4355 for(j=6;j<consolechars[0];j++){
4356 mapname[j-6]=consoletext[0][j];
4359 tintg=atof(mapname);
4364 if(Compare(consoletext[0],"tintb ",0,5)||Compare(consoletext[0],"Tintb ",0,5)){
4365 for(j=6;j<consolechars[0];j++){
4366 mapname[j-6]=consoletext[0][j];
4369 tintb=atof(mapname);
4374 if(Compare(consoletext[0],"hostile ",0,7)){
4375 for(j=8;j<consolechars[0];j++){
4376 mapname[j-8]=consoletext[0][j];
4379 hostile=atoi(mapname);
4385 if(Compare(consoletext[0],"type active ",0,11)){
4386 editoractive=typeactive;
4391 if(Compare(consoletext[0],"indemo ",0,6)){
4393 hotspot[numhotspots]=player[0].coords;
4394 hotspotsize[numhotspots]=0;
4395 hotspottype[numhotspots]=-111;
4397 strcpy(hotspottext[numhotspots],"mapname");
4403 if(Compare(consoletext[0],"notindemo ",0,9)){
4410 if(Compare(consoletext[0],"type sitting ",0,12)){
4411 editoractive=typesitting;
4416 if(Compare(consoletext[0],"type sitting wall ",0,17)){
4417 editoractive=typesittingwall;
4422 if(Compare(consoletext[0],"type sleeping ",0,13)){
4423 editoractive=typesleeping;
4427 if(Compare(consoletext[0],"type dead1 ",0,10)){
4428 editoractive=typedead1;
4432 if(Compare(consoletext[0],"type dead2 ",0,10)){
4433 editoractive=typedead2;
4437 if(Compare(consoletext[0],"type dead3 ",0,10)){
4438 editoractive=typedead3;
4441 if(Compare(consoletext[0],"type dead4 ",0,10)){
4442 editoractive=typedead4;
4447 if(Compare(consoletext[0],"path keepwalking ",0,16)){
4448 editorpathtype=wpkeepwalking;
4453 if(Compare(consoletext[0],"path pause ",0,10)){
4454 editorpathtype=wppause;
4459 if(Compare(consoletext[0],"mapkilleveryone ",0,15)){
4460 maptype=mapkilleveryone;
4465 if(Compare(consoletext[0],"mapgosomewhere ",0,14)){
4466 maptype=mapgosomewhere;
4471 if(Compare(consoletext[0],"mapkillsomeone ",0,14)){
4472 maptype=mapkillsomeone;
4478 if(Compare(consoletext[0],"mapkillmost ",0,11)){
4479 maptype=mapkillmost;
4485 if(Compare(consoletext[0],"hs ",0,2)){
4489 hotspot[numhotspots]=player[0].coords;
4494 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4495 mapname[j-startpoint]=consoletext[0][j];
4497 if(consoletext[0][j]=='\0')alldone=1;
4499 mapname[j-startpoint]='\0';
4501 hotspotsize[numhotspots]=atof(mapname);
4505 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4506 mapname[j-startpoint]=consoletext[0][j];
4508 if(consoletext[0][j]=='\0')alldone=1;
4510 mapname[j-startpoint]='\0';
4512 hotspottype[numhotspots]=atoi(mapname);
4516 while(consoletext[0][j]!='\0'&&!alldone&&j<255){
4517 mapname[j-startpoint]=consoletext[0][j];
4519 if(consoletext[0][j]=='\0')alldone=1;
4521 mapname[j-startpoint]='\n';
4522 mapname[j-startpoint+1]='\0';
4524 strcpy(hotspottext[numhotspots],mapname);
4531 if(Compare(consoletext[0],"dialogue ",0,8)){
4538 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4539 mapname[j-startpoint]=consoletext[0][j];
4541 if(consoletext[0][j]=='\0')alldone=1;
4543 mapname[j-startpoint]='\0';
4546 dialoguetype[numdialogues]=atoi(mapname);
4564 for(j=startpoint;j<consolechars[0];j++){
4565 mapname[j-startpoint+16]=consoletext[0][j];
4567 mapname[consolechars[0]-startpoint+16]='.';
4568 mapname[consolechars[0]-startpoint+17]='t';
4569 mapname[consolechars[0]-startpoint+18]='x';
4570 mapname[consolechars[0]-startpoint+19]='t';
4571 mapname[consolechars[0]-startpoint+20]='\0';
4573 for(j=0;j<max_dialoguelength;j++){
4575 dialoguetext[numdialogues][j][k]='\0';
4578 dialoguename[numdialogues][j][k]='\0';
4582 ifstream ipstream(ConvertFileName(mapname));
4583 ipstream.ignore(256,':');
4584 ipstream >> numdialogueboxes[numdialogues];
4585 for(i=0;i<numdialogueboxes[numdialogues];i++){
4586 ipstream.ignore(256,':');
4587 ipstream.ignore(256,':');
4588 ipstream.ignore(256,' ');
4589 ipstream >> dialogueboxlocation[numdialogues][i];
4590 ipstream.ignore(256,':');
4591 ipstream >> dialogueboxcolor[numdialogues][i][0];
4592 ipstream >> dialogueboxcolor[numdialogues][i][1];
4593 ipstream >> dialogueboxcolor[numdialogues][i][2];
4594 ipstream.ignore(256,':');
4595 ipstream.getline(dialoguename[numdialogues][i],64);
4596 ipstream.ignore(256,':');
4597 ipstream.ignore(256,' ');
4598 ipstream.getline(dialoguetext[numdialogues][i],128);
4600 if(dialoguetext[numdialogues][i][j]=='\\')dialoguetext[numdialogues][i][j]='\n';
4602 ipstream.ignore(256,':');
4603 ipstream >> dialogueboxsound[numdialogues][i];
4606 for(i=0;i<numdialogueboxes[numdialogues];i++){
4607 for(j=0;j<numplayers;j++){
4608 participantfacing[numdialogues][i][j]=player[j].facing;
4615 whichdialogue=numdialogues;
4623 if(Compare(consoletext[0],"fixdialogue ",0,11)){
4631 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4632 mapname[j-startpoint]=consoletext[0][j];
4634 if(consoletext[0][j]=='\0')alldone=1;
4636 mapname[j-startpoint]='\0';
4639 whichdi=atoi(mapname);
4657 for(j=startpoint;j<consolechars[0];j++){
4658 mapname[j-startpoint+16]=consoletext[0][j];
4660 mapname[consolechars[0]-startpoint+16]='.';
4661 mapname[consolechars[0]-startpoint+17]='t';
4662 mapname[consolechars[0]-startpoint+18]='x';
4663 mapname[consolechars[0]-startpoint+19]='t';
4664 mapname[consolechars[0]-startpoint+20]='\0';
4666 for(j=0;j<max_dialoguelength;j++){
4668 dialoguetext[whichdi][j][k]='\0';
4671 dialoguename[whichdi][j][k]='\0';
4675 ifstream ipstream(ConvertFileName(mapname));
4676 ipstream.ignore(256,':');
4677 ipstream >> numdialogueboxes[whichdi];
4678 for(i=0;i<numdialogueboxes[whichdi];i++){
4679 ipstream.ignore(256,':');
4680 ipstream.ignore(256,':');
4681 ipstream.ignore(256,' ');
4682 ipstream >> dialogueboxlocation[whichdi][i];
4683 ipstream.ignore(256,':');
4684 ipstream >> dialogueboxcolor[whichdi][i][0];
4685 ipstream >> dialogueboxcolor[whichdi][i][1];
4686 ipstream >> dialogueboxcolor[whichdi][i][2];
4687 ipstream.ignore(256,':');
4688 ipstream.getline(dialoguename[whichdi][i],64);
4689 ipstream.ignore(256,':');
4690 ipstream.ignore(256,' ');
4691 ipstream.getline(dialoguetext[whichdi][i],128);
4693 if(dialoguetext[whichdi][i][j]=='\\')dialoguetext[whichdi][i][j]='\n';
4695 ipstream.ignore(256,':');
4696 ipstream >> dialogueboxsound[whichdi][i];
4704 if(Compare(consoletext[0],"fixtype ",0,7)){
4712 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4713 mapname[j-startpoint]=consoletext[0][j];
4715 if(consoletext[0][j]=='\0')alldone=1;
4717 mapname[j-startpoint]='\0';
4718 dialoguetype[0]=atoi(mapname);
4726 if(Compare(consoletext[0],"fixrotation ",0,11)){
4727 participantrotation[whichdialogue][participantfocus[whichdialogue][indialogue]]=player[participantfocus[whichdialogue][indialogue]].rotation;
4732 if(Compare(consoletext[0],"ddialogue ",0,9)){
4734 if(numdialogues<0)numdialogues=0;
4739 if(Compare(consoletext[0],"immobile ",0,8)){
4740 player[0].immobile=1;
4744 if(Compare(consoletext[0],"mobile ",0,6)){
4745 player[0].immobile=0;
4749 if(Compare(consoletext[0],"play ",0,4)){
4756 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4757 mapname[j-startpoint]=consoletext[0][j];
4759 if(consoletext[0][j]=='\0')alldone=1;
4761 mapname[j-startpoint]='\0';
4764 whichdialogue=atoi(mapname);
4766 if(numdialogues>whichdialogue){
4767 for(i=0;i<numdialogueboxes[whichdialogue];i++){
4768 player[participantfocus[whichdialogue][i]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][i]];
4769 player[participantfocus[whichdialogue][i]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
4770 player[participantfocus[whichdialogue][i]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
4771 player[participantfocus[whichdialogue][i]].velocity=0;
4772 player[participantfocus[whichdialogue][i]].targetanimation=player[participantfocus[whichdialogue][i]].getIdle();
4773 player[participantfocus[whichdialogue][i]].targetframe=0;
4781 //if(dialogueboxsound[whichdialogue][indialogue]!=0){
4785 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
4786 temppos=temppos-viewer;
4787 Normalise(&temppos);
4797 whichsoundplay=rabbitchitter;
4798 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
4799 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
4800 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
4801 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
4802 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
4803 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
4804 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
4805 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
4806 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
4807 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
4808 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
4809 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
4810 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
4811 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
4812 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
4813 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
4814 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
4815 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
4816 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
4817 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, TRUE);
4818 FSOUND_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
4819 FSOUND_SetVolume(channels[whichsoundplay], 256);
4820 FSOUND_SetPaused(channels[whichsoundplay], FALSE);
4828 if(Compare(consoletext[0],"dhs ",0,3)){
4830 if(numhotspots<0)numhotspots=0;
4835 if(Compare(consoletext[0],"proportion ",0,10)||Compare(consoletext[0],"Proportion ",0,4)){
4842 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4843 mapname[j-startpoint]=consoletext[0][j];
4845 if(consoletext[0][j]=='\0')alldone=1;
4847 mapname[j-startpoint]='\0';
4849 headprop=atof(mapname);
4853 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4854 mapname[j-startpoint]=consoletext[0][j];
4856 if(consoletext[0][j]=='\0')alldone=1;
4858 mapname[j-startpoint]='\0';
4860 bodyprop=atof(mapname);
4864 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4865 mapname[j-startpoint]=consoletext[0][j];
4867 if(consoletext[0][j]=='\0')alldone=1;
4869 mapname[j-startpoint]='\0';
4871 armprop=atof(mapname);
4875 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4876 mapname[j-startpoint]=consoletext[0][j];
4878 if(consoletext[0][j]=='\0')alldone=1;
4880 mapname[j-startpoint]='\0';
4882 legprop=atof(mapname);
4884 if(player[0].creature==wolftype){
4885 player[0].proportionhead=1.1*headprop;
4886 player[0].proportionbody=1.1*bodyprop;
4887 player[0].proportionarms=1.1*armprop;
4888 player[0].proportionlegs=1.1*legprop;
4891 if(player[0].creature==rabbittype){
4892 player[0].proportionhead=1.2*headprop;
4893 player[0].proportionbody=1.05*bodyprop;
4894 player[0].proportionarms=1.00*armprop;
4895 player[0].proportionlegs=1.1*legprop;
4896 player[0].proportionlegs.y=1.05*legprop;
4902 if(Compare(consoletext[0],"allimmobile ",0,11)||Compare(consoletext[0],"Allimmobile ",0,11)){
4903 for(i=0;i<numplayers;i++){
4904 if(i>0)player[i].immobile=1;
4910 if(Compare(consoletext[0],"default ",0,7)||Compare(consoletext[0],"Default ",0,7)){
4911 player[0].armorhead=1;
4912 player[0].armorhigh=1;
4913 player[0].armorlow=1;
4914 player[0].protectionhead=1;
4915 player[0].protectionhigh=1;
4916 player[0].protectionlow=1;
4917 player[0].metalhead=1;
4918 player[0].metalhigh=1;
4919 player[0].metallow=1;
4921 player[0].speedmult=1;
4924 if(player[0].creature==wolftype){
4925 player[0].proportionhead=1.1;
4926 player[0].proportionbody=1.1;
4927 player[0].proportionarms=1.1;
4928 player[0].proportionlegs=1.1;
4931 if(player[0].creature==rabbittype){
4932 player[0].proportionhead=1.2;
4933 player[0].proportionbody=1.05;
4934 player[0].proportionarms=1.00;
4935 player[0].proportionlegs=1.1;
4936 player[0].proportionlegs.y=1.05;
4939 player[0].numclothes=0;
4940 if(player[0].whichskin==0){
4941 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4943 else if(player[0].whichskin==1){
4944 LoadTextureSave(":Data:Textures:Fur.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4946 else if(player[0].whichskin==2){
4947 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4949 else if(player[0].whichskin==3){
4950 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4952 else if(player[0].whichskin==4){
4953 LoadTextureSave(":Data:Textures:Otter.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4955 else if(player[0].whichskin==5){
4956 LoadTextureSave(":Data:Textures:Opal.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4958 else if(player[0].whichskin==6){
4959 LoadTextureSave(":Data:Textures:Sable.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4961 else if(player[0].whichskin==7){
4962 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4964 else if(player[0].whichskin==8){
4965 LoadTextureSave(":Data:Textures:BW2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4967 else if(player[0].whichskin==9){
4968 LoadTextureSave(":Data:Textures:WB2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4971 editoractive=typeactive;
4972 player[0].immobile=0;
4979 if(Compare(consoletext[0],"tint ",0,4)||Compare(consoletext[0],"Tint ",0,4)){
4985 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4986 mapname[j-startpoint]=consoletext[0][j];
4988 if(consoletext[0][j]=='\0')alldone=1;
4990 mapname[j-startpoint]='\0';
4992 tintr=atof(mapname);
4996 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4997 mapname[j-startpoint]=consoletext[0][j];
4999 if(consoletext[0][j]=='\0')alldone=1;
5001 mapname[j-startpoint]='\0';
5003 tintg=atof(mapname);
5007 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5008 mapname[j-startpoint]=consoletext[0][j];
5010 if(consoletext[0][j]=='\0')alldone=1;
5012 mapname[j-startpoint]='\0';
5014 tintb=atof(mapname);
5019 if(Compare(consoletext[0],"sky tint ",0,8)||Compare(consoletext[0],"Sky Tint ",0,8)){
5025 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5026 mapname[j-startpoint]=consoletext[0][j];
5028 if(consoletext[0][j]=='\0')alldone=1;
5030 mapname[j-startpoint]='\0';
5032 skyboxr=atof(mapname);
5036 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5037 mapname[j-startpoint]=consoletext[0][j];
5039 if(consoletext[0][j]=='\0')alldone=1;
5041 mapname[j-startpoint]='\0';
5043 skyboxg=atof(mapname);
5047 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5048 mapname[j-startpoint]=consoletext[0][j];
5050 if(consoletext[0][j]=='\0')alldone=1;
5052 mapname[j-startpoint]='\0';
5054 skyboxb=atof(mapname);
5056 skyboxlightr=skyboxr;
5057 skyboxlightg=skyboxg;
5058 skyboxlightb=skyboxb;
5062 //if(skyboxtexture){
5063 terrain.DoShadows();
5064 objects.DoShadows();
5066 else terrain.DoLighting();
5071 if(Compare(consoletext[0],"sky light ",0,9)||Compare(consoletext[0],"Sky Light ",0,9)){
5077 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5078 mapname[j-startpoint]=consoletext[0][j];
5080 if(consoletext[0][j]=='\0')alldone=1;
5082 mapname[j-startpoint]='\0';
5084 skyboxlightr=atof(mapname);
5088 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5089 mapname[j-startpoint]=consoletext[0][j];
5091 if(consoletext[0][j]=='\0')alldone=1;
5093 mapname[j-startpoint]='\0';
5095 skyboxlightg=atof(mapname);
5099 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5100 mapname[j-startpoint]=consoletext[0][j];
5102 if(consoletext[0][j]=='\0')alldone=1;
5104 mapname[j-startpoint]='\0';
5106 skyboxlightb=atof(mapname);
5110 //if(skyboxtexture){
5111 terrain.DoShadows();
5112 objects.DoShadows();
5114 else terrain.DoLighting();
5119 if(Compare(consoletext[0],"skybox ",0,6)||Compare(consoletext[0],"Skybox ",0,6)){
5120 skyboxtexture=1-skyboxtexture;
5123 //if(skyboxtexture){
5124 terrain.DoShadows();
5125 objects.DoShadows();
5127 else terrain.DoLighting();
5132 if(Compare(consoletext[0],"protection ",0,10)||Compare(consoletext[0],"Protection ",0,10)){
5138 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5139 mapname[j-startpoint]=consoletext[0][j];
5141 if(consoletext[0][j]=='\0')alldone=1;
5143 mapname[j-startpoint]='\0';
5145 player[0].protectionhead=atof(mapname);
5149 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5150 mapname[j-startpoint]=consoletext[0][j];
5152 if(consoletext[0][j]=='\0')alldone=1;
5154 mapname[j-startpoint]='\0';
5156 player[0].protectionhigh=atof(mapname);
5160 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5161 mapname[j-startpoint]=consoletext[0][j];
5163 if(consoletext[0][j]=='\0')alldone=1;
5165 mapname[j-startpoint]='\0';
5167 player[0].protectionlow=atof(mapname);
5172 if(Compare(consoletext[0],"armor ",0,5)||Compare(consoletext[0],"Armor ",0,5)){
5178 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5179 mapname[j-startpoint]=consoletext[0][j];
5181 if(consoletext[0][j]=='\0')alldone=1;
5183 mapname[j-startpoint]='\0';
5185 player[0].armorhead=atof(mapname);
5189 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5190 mapname[j-startpoint]=consoletext[0][j];
5192 if(consoletext[0][j]=='\0')alldone=1;
5194 mapname[j-startpoint]='\0';
5196 player[0].armorhigh=atof(mapname);
5200 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5201 mapname[j-startpoint]=consoletext[0][j];
5203 if(consoletext[0][j]=='\0')alldone=1;
5205 mapname[j-startpoint]='\0';
5207 player[0].armorlow=atof(mapname);
5212 if(Compare(consoletext[0],"protectionreset ",0,15)||Compare(consoletext[0],"Protectionreset ",0,15)){
5213 for(i=0;i<numplayers;i++){
5214 player[i].protectionhead=1.0;
5215 player[i].protectionhigh=1.0;
5216 player[i].protectionlow=1.0;
5217 player[i].armorhead=1.0;
5218 player[i].armorhigh=1.0;
5219 player[i].armorlow=1.0;
5225 if(Compare(consoletext[0],"protectionnear ",0,14)||Compare(consoletext[0],"Protectionnear ",0,14)){
5227 float closestdist=-1;
5230 for(i=1;i<numplayers;i++){
5231 distance=findDistancefast(&player[i].coords,&player[0].coords);
5232 if(closestdist==-1||distance<closestdist){
5233 closestdist=distance;
5243 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5244 mapname[j-startpoint]=consoletext[0][j];
5246 if(consoletext[0][j]=='\0')alldone=1;
5248 mapname[j-startpoint]='\0';
5250 player[closest].protectionhead=atof(mapname);
5254 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5255 mapname[j-startpoint]=consoletext[0][j];
5257 if(consoletext[0][j]=='\0')alldone=1;
5259 mapname[j-startpoint]='\0';
5261 player[closest].protectionhigh=atof(mapname);
5265 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5266 mapname[j-startpoint]=consoletext[0][j];
5268 if(consoletext[0][j]=='\0')alldone=1;
5270 mapname[j-startpoint]='\0';
5272 player[closest].protectionlow=atof(mapname);
5277 if(Compare(consoletext[0],"armornear ",0,9)||Compare(consoletext[0],"Armornear ",0,9)){
5279 float closestdist=-1;
5282 for(i=1;i<numplayers;i++){
5283 distance=findDistancefast(&player[i].coords,&player[0].coords);
5284 if(closestdist==-1||distance<closestdist){
5285 closestdist=distance;
5294 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5295 mapname[j-startpoint]=consoletext[0][j];
5297 if(consoletext[0][j]=='\0')alldone=1;
5299 mapname[j-startpoint]='\0';
5301 player[closest].armorhead=atof(mapname);
5305 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5306 mapname[j-startpoint]=consoletext[0][j];
5308 if(consoletext[0][j]=='\0')alldone=1;
5310 mapname[j-startpoint]='\0';
5312 player[closest].armorhigh=atof(mapname);
5316 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5317 mapname[j-startpoint]=consoletext[0][j];
5319 if(consoletext[0][j]=='\0')alldone=1;
5321 mapname[j-startpoint]='\0';
5323 player[closest].armorlow=atof(mapname);
5329 if(Compare(consoletext[0],"metal ",0,5)||Compare(consoletext[0],"Metal ",0,5)){
5335 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5336 mapname[j-startpoint]=consoletext[0][j];
5338 if(consoletext[0][j]=='\0')alldone=1;
5340 mapname[j-startpoint]='\0';
5342 player[0].metalhead=atof(mapname);
5346 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5347 mapname[j-startpoint]=consoletext[0][j];
5349 if(consoletext[0][j]=='\0')alldone=1;
5351 mapname[j-startpoint]='\0';
5353 player[0].metalhigh=atof(mapname);
5357 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5358 mapname[j-startpoint]=consoletext[0][j];
5360 if(consoletext[0][j]=='\0')alldone=1;
5363 mapname[j-startpoint]='\0';
5365 player[0].metallow=atof(mapname);
5370 if(Compare(consoletext[0],"noclothesnear ",0,13)||Compare(consoletext[0],"Noclothesnear ",0,13)){
5372 float closestdist=-1;
5375 for(i=1;i<numplayers;i++){
5376 distance=findDistancefast(&player[i].coords,&player[0].coords);
5377 if(closestdist==-1||distance<closestdist){
5378 closestdist=distance;
5382 player[closest].numclothes=0;
5383 if(player[closest].whichskin==0){
5384 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5386 else if(player[closest].whichskin==1){
5387 LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5389 else if(player[closest].whichskin==2){
5390 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5392 else if(player[closest].whichskin==3){
5393 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5395 else if(player[closest].whichskin==4){
5396 LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5398 else if(player[closest].whichskin==5){
5399 LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5401 else if(player[closest].whichskin==6){
5402 LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5404 else if(player[closest].whichskin==7){
5405 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5407 else if(player[closest].whichskin==8){
5408 LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5410 else if(player[closest].whichskin==9){
5411 LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5417 if(Compare(consoletext[0],"noclothes ",0,9)||Compare(consoletext[0],"Noclothes ",0,9)){
5420 player[closest].numclothes=0;
5421 if(player[closest].whichskin==0){
5422 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5424 else if(player[closest].whichskin==1){
5425 LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5427 else if(player[closest].whichskin==2){
5428 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5430 else if(player[closest].whichskin==3){
5431 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5433 else if(player[closest].whichskin==4){
5434 LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5436 else if(player[closest].whichskin==5){
5437 LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5439 else if(player[closest].whichskin==6){
5440 LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5442 else if(player[closest].whichskin==7){
5443 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5445 else if(player[closest].whichskin==8){
5446 LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5448 else if(player[closest].whichskin==9){
5449 LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5455 if((Compare(consoletext[0],"Clothes ",0,7)||Compare(consoletext[0],"clothes ",0,7))){
5471 for(j=8;j<consolechars[0];j++){
5472 mapname[j-8+15]=consoletext[0][j];
5474 mapname[consolechars[0]-8+15]='.';
5475 mapname[consolechars[0]-8+16]='p';
5476 mapname[consolechars[0]-8+17]='n';
5477 mapname[consolechars[0]-8+18]='g';
5478 mapname[consolechars[0]-8+19]='\0';
5480 //:Data:Textures:Pants.png
5482 if(AddClothes((char *)mapname,0,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize)){
5483 player[0].DoMipmaps(5,0,0,player[0].skeleton.skinsize,player[0].skeleton.skinsize);
5484 strcpy(player[0].clothes[player[0].numclothes],mapname);
5485 player[0].clothestintr[player[0].numclothes]=tintr;
5486 player[0].clothestintg[player[0].numclothes]=tintg;
5487 player[0].clothestintb[player[0].numclothes]=tintb;
5488 player[0].numclothes++;
5494 if(Compare(consoletext[0],"belt ",0,4)||Compare(consoletext[0],"belt ",0,4)){
5495 player[0].skeleton.clothes = 1-player[0].skeleton.clothes;
5500 if(Compare(consoletext[0],"Cellophane ",0,10)||Compare(consoletext[0],"cellophane ",0,10)){
5501 cellophane=1-cellophane;
5504 for(i=0;i<numplayers;i++){
5505 player[i].proportionhead.z=0;
5506 player[i].proportionbody.z=0;
5507 player[i].proportionarms.z=0;
5508 player[i].proportionlegs.z=0;
5513 for(i=0;i<numplayers;i++){
5514 player[i].proportionhead.z=player[i].proportionhead.x;
5515 player[i].proportionbody.z=player[i].proportionbody.x;
5516 player[i].proportionarms.z=player[i].proportionarms.x;
5517 player[i].proportionlegs.z=player[i].proportionlegs.x;
5524 if((Compare(consoletext[0],"Clothesnear ",0,11)||Compare(consoletext[0],"clothesnear ",0,11))){
5540 for(j=12;j<consolechars[0];j++){
5541 mapname[j-12+15]=consoletext[0][j];
5543 mapname[consolechars[0]-12+15]='.';
5544 mapname[consolechars[0]-12+16]='p';
5545 mapname[consolechars[0]-12+17]='n';
5546 mapname[consolechars[0]-12+18]='g';
5547 mapname[consolechars[0]-12+19]='\0';
5549 //:Data:Textures:Pants.png
5551 float closestdist=-1;
5554 for(i=1;i<numplayers;i++){
5555 distance=findDistancefast(&player[i].coords,&player[0].coords);
5556 if(closestdist==-1||distance<closestdist){
5557 closestdist=distance;
5562 if(AddClothes((char *)mapname,0,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize)){
5563 player[closest].DoMipmaps(5,0,0,player[closest].skeleton.skinsize,player[closest].skeleton.skinsize);
5564 strcpy(player[closest].clothes[player[closest].numclothes],mapname);
5565 player[closest].clothestintr[player[closest].numclothes]=tintr;
5566 player[closest].clothestintg[player[closest].numclothes]=tintg;
5567 player[closest].clothestintb[player[closest].numclothes]=tintb;
5568 player[closest].numclothes++;
5574 if(Compare(consoletext[0],"funnybunny ",0,10)||Compare(consoletext[0],"funny bunny ",0,11)){
5575 player[0].skeleton.id=0;
5576 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);
5577 LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5578 player[0].creature=rabbittype;
5581 player[0].proportionhead=1.2;
5582 player[0].proportionbody=1.05;
5583 player[0].proportionarms=1.00;
5584 player[0].proportionlegs=1.1;
5585 player[0].proportionlegs.y=1.05;
5586 player[0].headless=0;
5588 player[0].damagetolerance=200;
5592 if(Compare(consoletext[0],"wolfieisgod ",0,11)||Compare(consoletext[0],"wolfie is god ",0,12)){
5593 player[0].skeleton.id=0;
5594 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);
5595 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5596 player[0].creature=wolftype;
5598 player[0].proportionhead=1.1;
5599 player[0].proportionbody=1.1;
5600 player[0].proportionarms=1.1;
5601 player[0].proportionlegs=1.1;
5602 player[0].proportionlegs.y=1.1;
5603 player[0].scale=.23;
5605 player[0].damagetolerance=300;
5609 /*if(Compare(consoletext[0],"kungfu ",0,6)||Compare(consoletext[0],"kung fu ",0,7)){
5610 LoadTextureSave(":Data:Textures:Kungfu.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5613 if(Compare(consoletext[0],"rambo ",0,5)){
5614 LoadTextureSave(":Data:Textures:Leather.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5617 if(Compare(consoletext[0],"david ",0,5)){
5618 LoadTextureSave(":Data:Textures:David.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5621 if(Compare(consoletext[0],"wolf ",0,4)){
5622 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5625 if(Compare(consoletext[0],"darkwolf ",0,8)){
5626 LoadTextureSave(":Data:Textures:DarkWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5629 if(Compare(consoletext[0],"snowwolf ",0,8)){
5630 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5633 if(Compare(consoletext[0],"lizardwolf ",0,10)){
5634 LoadTextureSave(":Data:Textures:Lizardwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5637 if(Compare(consoletext[0],"white ",0,5)){
5638 LoadTextureSave(":Data:Textures:fur.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5641 if(Compare(consoletext[0],"brown ",0,5)){
5642 LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5645 if(Compare(consoletext[0],"black ",0,5)){
5646 LoadTextureSave(":Data:Textures:fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5649 if(consolechars[0]>0){
5652 consoletext[k][j]=consoletext[k-1][j];
5654 consolechars[k]=consolechars[k-1];
5657 consoletext[0][j]=' ';
5663 PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, TRUE);
5664 FSOUND_SetVolume(channels[consolefailsound], 256);
5665 FSOUND_SetPaused(channels[consolefailsound], FALSE);
5674 togglekeydelay[i]=0;
5678 consoleblinkdelay-=multiplier;
5679 if(consoleblinkdelay<=0){
5680 consoleblinkdelay=.3;
5681 consoleblink=1-consoleblink;
5685 if(IsKeyDown(theKeyMap, MAC_Q_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)){
5688 if(newdetail>2)newdetail=detail;
5689 if(newdetail<0)newdetail=detail;
5690 #if !USE_SDL // we'll take anything that works.
5691 if(newscreenwidth>3000)newscreenwidth=screenwidth;
5692 if(newscreenheight>3000)newscreenheight=screenheight;
5694 if(newscreenwidth<0)newscreenwidth=screenwidth;
5695 if(newscreenheight<0)newscreenheight=screenheight;
5697 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
5698 opstream << "Screenwidth:\n";
5699 opstream << newscreenwidth;
5700 opstream << "\nScreenheight:\n";
5701 opstream << newscreenheight;
5702 opstream << "\nMouse sensitivity:\n";
5703 opstream << usermousesensitivity;
5704 opstream << "\nBlur(0,1):\n";
5705 opstream << ismotionblur;
5706 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
5707 opstream << newdetail;
5708 opstream << "\nFloating jump:\n";
5709 opstream << floatjump;
5710 opstream << "\nMouse jump:\n";
5711 opstream << mousejump;
5712 opstream << "\nAmbient sound:\n";
5713 opstream << ambientsound;
5714 opstream << "\nBlood (0,1,2):\n";
5715 opstream << bloodtoggle;
5716 opstream << "\nAuto slomo:\n";
5717 opstream << autoslomo;
5718 opstream << "\nFoliage:\n";
5719 opstream << foliage;
5720 opstream << "\nMusic:\n";
5721 opstream << musictoggle;
5722 opstream << "\nTrilinear:\n";
5723 opstream << trilinear;
5724 opstream << "\nDecals(shadows,blood puddles,etc):\n";
5726 opstream << "\nInvert mouse:\n";
5727 opstream << invertmouse;
5728 opstream << "\nGamespeed:\n";
5729 if(oldgamespeed==0)oldgamespeed=1;
5730 opstream << oldgamespeed;
5731 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
5732 opstream << difficulty;
5733 opstream << "\nDamage effects(blackout, doublevision):\n";
5734 opstream << damageeffects;
5735 opstream << "\nText:\n";
5736 opstream << texttoggle;
5737 opstream << "\nDebug:\n";
5738 opstream << debugmode;
5739 opstream << "\nVBL Sync:\n";
5740 opstream << vblsync;
5741 opstream << "\nShow Points:\n";
5742 opstream << showpoints;
5743 opstream << "\nAlways Blur:\n";
5744 opstream << alwaysblur;
5745 opstream << "\nImmediate mode (turn on on G5):\n";
5746 opstream << immediate;
5747 opstream << "\nVelocity blur:\n";
5748 opstream << velocityblur;
5749 opstream << "\nVolume:\n";
5751 opstream << "\nForward key:\n";
5752 opstream << KeyToChar(forwardkey);
5753 opstream << "\nBack key:\n";
5754 opstream << KeyToChar(backkey);
5755 opstream << "\nLeft key:\n";
5756 opstream << KeyToChar(leftkey);
5757 opstream << "\nRight key:\n";
5758 opstream << KeyToChar(rightkey);
5759 opstream << "\nJump key:\n";
5760 opstream << KeyToChar(jumpkey);
5761 opstream << "\nCrouch key:\n";
5762 opstream << KeyToChar(crouchkey);
5763 opstream << "\nDraw key:\n";
5764 opstream << KeyToChar(drawkey);
5765 opstream << "\nThrow key:\n";
5766 opstream << KeyToChar(throwkey);
5767 opstream << "\nAttack key:\n";
5768 opstream << KeyToChar(attackkey);
5769 opstream << "\nChat key:\n";
5770 opstream << KeyToChar(chatkey);
5775 static int oldwinfreeze;
5776 if(winfreeze&&!oldwinfreeze){
5777 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
5778 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
5779 FSOUND_SetVolume(channels[consolesuccesssound], 256);
5780 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
5782 if(winfreeze==0)oldwinfreeze=winfreeze;
5783 else oldwinfreeze++;
5785 if((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY))&&!oldjumpkeydown&&!campaign){
5786 if(winfreeze)winfreeze=0;
5789 if((IsKeyDown(theKeyMap, MAC_ESCAPE_KEY))&&!campaign&&gameon){
5795 if((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY))){
5798 if(!IsKeyDown(theKeyMap, jumpkey)&&!IsKeyDown(theKeyMap, MAC_SPACE_KEY))oldjumpkeydown=0;
5800 if(!freeze&&!winfreeze&&!(mainmenu&&gameon)&&(gameon||!gamestarted)){
5802 static bool oldbuttondialogue;
5804 if(indialogue!=-1)talkdelay=1;
5805 talkdelay-=multiplier;
5808 if(indialogue==-1&&(animation[player[0].targetanimation].height!=highheight)/*&&!hostile*/)
5809 for(i=0;i<numdialogues;i++){
5810 int realdialoguetype;
5812 if(dialoguetype[i]>49){
5813 realdialoguetype=dialoguetype[i]-50;
5816 else if(dialoguetype[i]>39){
5817 realdialoguetype=dialoguetype[i]-40;
5820 else if(dialoguetype[i]>29){
5821 realdialoguetype=dialoguetype[i]-30;
5824 else if(dialoguetype[i]>19){
5825 realdialoguetype=dialoguetype[i]-20;
5828 else if(dialoguetype[i]>9){
5829 realdialoguetype=dialoguetype[i]-10;
5833 realdialoguetype=dialoguetype[i];
5836 if((!hostile||(dialoguetype[i]>40&&dialoguetype[i]<50))&&realdialoguetype<numplayers&&realdialoguetype>0&&(dialoguegonethrough[i]==0||!special)&&(special||(IsKeyDown(theKeyMap, attackkey)&&!oldbuttondialogue))){
5837 if(findDistancefast(&player[0].coords,&player[realdialoguetype].coords)<6||player[realdialoguetype].howactive>=typedead1||(dialoguetype[i]>40&&dialoguetype[i]<50)){
5839 for(j=0;j<numdialogueboxes[whichdialogue];j++){
5840 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
5841 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
5842 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
5843 player[participantfocus[whichdialogue][j]].velocity=0;
5844 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
5845 player[participantfocus[whichdialogue][j]].targetframe=0;
5850 dialoguegonethrough[i]++;
5851 if(dialogueboxsound[whichdialogue][indialogue]!=0){
5852 static float gLoc[3];
5853 static float vel[3];
5855 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
5856 temppos=temppos-viewer;
5857 Normalise(&temppos);
5862 gLoc[2]=temppos.z;vel[0]=0;
5866 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
5867 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
5868 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
5869 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
5870 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
5871 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
5872 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
5873 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
5874 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
5875 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
5876 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
5877 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
5878 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
5879 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
5880 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
5881 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
5882 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
5883 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
5884 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
5885 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
5886 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, TRUE);
5887 FSOUND_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
5888 FSOUND_SetVolume(channels[whichsoundplay], 256);
5889 FSOUND_SetPaused(channels[whichsoundplay], FALSE);
5891 if(IsKeyDown(theKeyMap, attackkey))oldbuttondialogue=1;
5896 windvar+=multiplier;
5897 smoketex+=multiplier;
5898 tutorialstagetime+=multiplier;
5900 static float hotspotvisual[40];
5904 for(i=0;i<numhotspots;i++)
5905 hotspotvisual[i]-=multiplier/320;
5907 for(i=0;i<numhotspots;i++){
5908 //if(hotspottype[i]<=10)
5909 while(hotspotvisual[i]<0){
5911 hotspotsprite.x=float(abs(Random()%100000))/100000*hotspotsize[i];
5912 hotspotsprite=DoRotation(hotspotsprite,0,0,Random()%360);
5913 hotspotsprite=DoRotation(hotspotsprite,0,Random()%360,0);
5914 hotspotsprite+=hotspot[i];
5915 sprites.MakeSprite(breathsprite, hotspotsprite, hotspotsprite*0, 1,0.5,0, 7, 0.4);
5916 hotspotvisual[i]+=0.1/hotspotsize[i]/hotspotsize[i]/hotspotsize[i];
5920 for(i=0;i<numhotspots;i++){
5921 if(hotspottype[i]<=10&&hotspottype[i]>0){
5922 hotspot[i]=player[hotspottype[i]].coords;
5928 if(tutoriallevel&&tutorialstagetime>tutorialmaxtime){
5931 if(tutorialstage<=1){
5936 if(tutorialstage==1){
5939 if(tutorialstage==2){
5942 if(tutorialstage==3){
5943 tutorialmaxtime=600;
5945 if(tutorialstage==4){
5946 tutorialmaxtime=1000;
5948 if(tutorialstage==5){
5949 tutorialmaxtime=600;
5951 if(tutorialstage==6){
5952 tutorialmaxtime=600;
5954 if(tutorialstage==7){
5955 tutorialmaxtime=600;
5957 if(tutorialstage==8){
5958 tutorialmaxtime=600;
5960 if(tutorialstage==9){
5961 tutorialmaxtime=600;
5963 if(tutorialstage==10){
5966 if(tutorialstage==11){
5967 tutorialmaxtime=1000;
5969 if(tutorialstage==12){
5970 tutorialmaxtime=1000;
5972 if(tutorialstage==13){
5975 if(tutorialstage==14){
5987 player[1].coords=(temp+temp2)/2;
5991 gLoc[0]=player[1].coords.x;
5992 gLoc[1]=player[1].coords.y;
5993 gLoc[2]=player[1].coords.z;
5997 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
5998 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
5999 FSOUND_SetVolume(channels[fireendsound], 256);
6000 FSOUND_SetPaused(channels[fireendsound], FALSE);
6002 for(i=0;i<player[1].skeleton.num_joints;i++){
6004 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
6005 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
6006 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;
6007 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
6008 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
6013 if(tutorialstage==15){
6014 tutorialmaxtime=500;
6016 if(tutorialstage==16){
6017 tutorialmaxtime=500;
6019 if(tutorialstage==17){
6020 tutorialmaxtime=500;
6022 if(tutorialstage==18){
6023 tutorialmaxtime=500;
6025 if(tutorialstage==19){
6027 //tutorialmaxtime=500;
6029 if(tutorialstage==20){
6030 tutorialmaxtime=500;
6032 if(tutorialstage==21){
6033 tutorialmaxtime=500;
6040 if(tutorialstage==22){
6041 tutorialmaxtime=500;
6043 if(tutorialstage==23){
6044 tutorialmaxtime=500;
6046 if(tutorialstage==24){
6047 tutorialmaxtime=500;
6049 if(tutorialstage==25){
6050 tutorialmaxtime=500;
6052 if(tutorialstage==26){
6055 if(tutorialstage==27){
6059 player[1].aitype=attacktypecutoff;
6061 if(tutorialstage==28){
6062 tutorialmaxtime=400;
6064 if(tutorialstage==29){
6065 tutorialmaxtime=400;
6066 player[0].escapednum=0;
6068 if(tutorialstage==30){
6072 player[1].aitype=passivetype;
6074 if(tutorialstage==31){
6077 if(tutorialstage==32){
6080 if(tutorialstage==33){
6081 tutorialmaxtime=400;
6084 player[1].aitype=attacktypecutoff;
6086 if(tutorialstage==34){
6087 tutorialmaxtime=400;
6089 if(tutorialstage==35){
6090 tutorialmaxtime=400;
6092 if(tutorialstage==36){
6096 player[1].aitype=passivetype;
6098 if(tutorialstage==37){
6104 player[1].aitype=attacktypecutoff;
6106 if(tutorialstage==38){
6110 player[1].aitype=passivetype;
6112 if(tutorialstage==39){
6123 weapons.owner[weapons.numweapons]=-1;
6124 weapons.type[weapons.numweapons]=knife;
6125 weapons.damage[weapons.numweapons]=0;
6126 weapons.mass[weapons.numweapons]=1;
6127 weapons.tipmass[weapons.numweapons]=1.2;
6128 weapons.length[weapons.numweapons]=.25;
6129 weapons.position[weapons.numweapons]=(temp+temp2)/2;
6130 weapons.tippoint[weapons.numweapons]=(temp+temp2)/2;
6132 weapons.velocity[weapons.numweapons]=0.1;
6133 weapons.tipvelocity[weapons.numweapons]=0.1;
6134 weapons.missed[weapons.numweapons]=1;
6135 weapons.hitsomething[weapons.numweapons]=0;
6136 weapons.freetime[weapons.numweapons]=0;
6137 weapons.firstfree[weapons.numweapons]=1;
6138 weapons.physics[weapons.numweapons]=1;
6140 weapons.numweapons++;
6142 if(tutorialstage==40){
6143 tutorialmaxtime=300;
6145 if(tutorialstage==41){
6146 tutorialmaxtime=300;
6148 if(tutorialstage==42){
6151 if(tutorialstage==43){
6152 tutorialmaxtime=300;
6154 if(tutorialstage==44){
6156 player[0].weaponactive=-1;
6157 player[0].num_weapons=0;
6158 player[1].weaponactive=0;
6159 player[1].num_weapons=1;
6160 player[1].weaponids[0]=0;
6164 player[1].aitype=attacktypecutoff;
6166 tutorialmaxtime=300;
6168 if(tutorialstage==45){
6170 player[0].weaponactive=-1;
6171 player[0].num_weapons=0;
6172 player[1].weaponactive=0;
6173 player[1].num_weapons=1;
6174 player[1].weaponids[0]=0;
6176 tutorialmaxtime=300;
6178 if(tutorialstage==46){
6180 player[0].weaponactive=-1;
6181 player[0].num_weapons=0;
6182 player[1].weaponactive=0;
6183 player[1].num_weapons=1;
6184 player[1].weaponids[0]=0;
6186 weapons.type[0]=sword;
6188 tutorialmaxtime=300;
6191 if(tutorialstage==47){
6203 weapons.owner[weapons.numweapons]=-1;
6204 weapons.type[weapons.numweapons]=sword;
6205 weapons.damage[weapons.numweapons]=0;
6206 weapons.mass[weapons.numweapons]=1;
6207 weapons.tipmass[weapons.numweapons]=1.2;
6208 weapons.length[weapons.numweapons]=.25;
6209 weapons.position[weapons.numweapons]=(temp+temp2)/2;
6210 weapons.tippoint[weapons.numweapons]=(temp+temp2)/2;
6212 weapons.velocity[weapons.numweapons]=0.1;
6213 weapons.tipvelocity[weapons.numweapons]=0.1;
6214 weapons.missed[weapons.numweapons]=1;
6215 weapons.hitsomething[weapons.numweapons]=0;
6216 weapons.freetime[weapons.numweapons]=0;
6217 weapons.firstfree[weapons.numweapons]=1;
6218 weapons.physics[weapons.numweapons]=1;
6222 player[0].weaponactive=0;
6223 player[0].num_weapons=1;
6224 player[0].weaponids[0]=1;
6225 player[1].weaponactive=0;
6226 player[1].num_weapons=1;
6227 player[1].weaponids[0]=0;
6229 weapons.numweapons++;
6231 if(tutorialstage==48){
6234 player[1].aitype=passivetype;
6240 player[0].weaponactive=0;
6241 player[0].num_weapons=1;
6242 player[0].weaponids[0]=1;
6243 player[1].weaponactive=0;
6244 player[1].num_weapons=1;
6245 player[1].weaponids[0]=0;
6247 if(player[0].weaponactive!=-1)weapons.type[player[0].weaponids[player[0].weaponactive]]=staff;
6248 else weapons.type[0]=staff;
6250 weapons.numweapons++;
6252 if(tutorialstage==49){
6255 player[1].aitype=passivetype;
6257 tutorialmaxtime=200;
6259 weapons.position[1]=1000;
6260 weapons.tippoint[1]=1000;
6262 weapons.numweapons=1;
6264 player[1].weaponactive=-1;
6265 player[1].num_weapons=0;
6266 player[0].weaponactive=0;
6267 player[0].num_weapons=1;
6268 player[0].weaponids[0]=0;
6270 weapons.type[0]=knife;
6272 weapons.numweapons++;
6274 if(tutorialstage==50){
6280 gLoc[0]=player[1].coords.x;
6281 gLoc[1]=player[1].coords.y;
6282 gLoc[2]=player[1].coords.z;
6286 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
6287 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
6288 FSOUND_SetVolume(channels[fireendsound], 256);
6289 FSOUND_SetPaused(channels[fireendsound], FALSE);
6291 for(i=0;i<player[1].skeleton.num_joints;i++){
6293 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
6294 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
6295 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;
6296 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
6297 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
6301 player[1].num_weapons=0;
6302 player[1].weaponstuck=-1;
6303 player[1].weaponactive=-1;
6305 weapons.numweapons=0;
6307 weapons.owner[0]=-1;
6308 weapons.velocity[0]=0.1;
6309 weapons.tipvelocity[0]=-0.1;
6310 weapons.missed[0]=1;
6311 weapons.hitsomething[0]=0;
6312 weapons.freetime[0]=0;
6313 weapons.firstfree[0]=1;
6314 weapons.physics[0]=1;
6316 if(tutorialstage==51){
6317 tutorialmaxtime=80000;
6319 if(tutorialstage<=51)tutorialstagetime=0;
6323 if(tutoriallevel&&tutorialstagetime<tutorialmaxtime-3){
6324 if(tutorialstage==3){
6325 if(deltah||deltav)tutorialsuccess+=multiplier;
6327 if(tutorialstage==4){
6328 if(player[0].forwardkeydown||player[0].backkeydown||player[0].leftkeydown||player[0].rightkeydown)tutorialsuccess+=multiplier;
6330 if(tutorialstage==5){
6331 if(player[0].jumpkeydown)tutorialsuccess=1;
6333 if(tutorialstage==6){
6334 if(player[0].isCrouch())tutorialsuccess=1;
6336 if(tutorialstage==7){
6337 if(player[0].targetanimation==rollanim)tutorialsuccess=1;
6339 if(tutorialstage==8){
6340 if(player[0].targetanimation==sneakanim)tutorialsuccess+=multiplier;
6342 if(tutorialstage==9){
6343 if(player[0].targetanimation==rabbitrunninganim||player[0].targetanimation==wolfrunninganim)tutorialsuccess+=multiplier;
6345 if(tutorialstage==11){
6346 if(player[0].isWallJump())tutorialsuccess=1;
6348 if(tutorialstage==12){
6349 if(player[0].targetanimation==flipanim)tutorialsuccess=1;
6351 if(tutorialstage==15){
6352 if(player[0].targetanimation==upunchanim||player[0].targetanimation==winduppunchanim)tutorialsuccess=1;
6354 if(tutorialstage==16){
6355 if(player[0].targetanimation==winduppunchanim)tutorialsuccess=1;
6357 if(tutorialstage==17){
6358 if(player[0].targetanimation==spinkickanim)tutorialsuccess=1;
6360 if(tutorialstage==18){
6361 if(player[0].targetanimation==sweepanim)tutorialsuccess=1;
6363 if(tutorialstage==19){
6364 if(player[0].targetanimation==dropkickanim)tutorialsuccess=1;
6366 if(tutorialstage==20){
6367 if(player[0].targetanimation==rabbitkickanim)tutorialsuccess=1;
6369 if(tutorialstage==21){
6370 if(bonus==cannon)tutorialsuccess=1;
6372 if(tutorialstage==22){
6373 if(bonus==spinecrusher)tutorialsuccess=1;
6375 if(tutorialstage==23){
6376 if(player[0].targetanimation==walljumprightkickanim||player[0].targetanimation==walljumpleftkickanim)tutorialsuccess=1;
6378 if(tutorialstage==24){
6379 if(player[0].targetanimation==rabbittacklinganim)tutorialsuccess=1;
6381 if(tutorialstage==25){
6382 if(player[0].targetanimation==backhandspringanim)tutorialsuccess=1;
6384 if(tutorialstage==28){
6385 if(animation[player[0].targetanimation].attack==reversed&&player[0].feint)tutorialsuccess=1;
6387 if(tutorialstage==29){
6388 if(player[0].escapednum==2){
6392 player[1].aitype=passivetype;
6395 if(tutorialstage==33){
6396 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6398 if(tutorialstage==34){
6399 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6401 if(tutorialstage==35){
6402 if(animation[player[0].targetanimation].attack==reversal){
6406 player[1].aitype=passivetype;
6409 if(tutorialstage==40){
6410 if(player[0].num_weapons>0)tutorialsuccess=1;
6412 if(tutorialstage==41){
6413 if(player[0].weaponactive==-1&&player[0].num_weapons>0)tutorialsuccess=1;
6415 if(tutorialstage==43){
6416 if(player[0].targetanimation==knifeslashstartanim)tutorialsuccess=1;
6418 if(tutorialstage==44){
6419 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6421 if(tutorialstage==45){
6422 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6424 if(tutorialstage==46){
6425 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6427 if(tutorialstage==49){
6428 if(player[1].weaponstuck!=-1)tutorialsuccess=1;
6430 if(tutorialsuccess>=1)tutorialstagetime=tutorialmaxtime-3;
6433 if(tutorialstagetime==tutorialmaxtime-3){
6434 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
6435 FSOUND_SetVolume(channels[consolesuccesssound], 256);
6436 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
6439 if(tutorialsuccess>=1){
6440 if(tutorialstage==34||tutorialstage==35)
6441 tutorialstagetime=tutorialmaxtime-1;
6446 if(tutorialstage<14||tutorialstage>=50){
6447 player[1].coords.y=300;
6448 player[1].velocity=0;
6452 if(tutoriallevel!=1){
6453 if(bonustime==0&&bonus!=solidhit&&bonus!=spinecrusher&&bonus!=tracheotomy&&bonus!=backstab&&bonusvalue>10){
6454 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
6455 FSOUND_SetVolume(channels[consolesuccesssound], 256);
6456 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
6461 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
6462 FSOUND_SetVolume(channels[fireendsound], 256);
6463 FSOUND_SetPaused(channels[fireendsound], FALSE);
6466 if(bonus!=solidhit&&bonus!=twoxcombo&&bonus!=threexcombo&&bonus!=fourxcombo&&bonus!=megacombo)bonusnum[bonus]++;
6467 else bonusnum[bonus]+=0.15;
6468 if(tutoriallevel)bonusvalue=0;
6469 bonusvalue/=bonusnum[bonus];
6470 bonustotal+=bonusvalue;
6472 bonustime+=multiplier;
6474 if(environment==snowyenvironment){
6475 precipdelay-=multiplier;
6476 while(precipdelay<0){
6478 if(!detail)precipdelay+=.04;
6479 XYZ footvel,footpoint;
6482 footpoint=viewer+viewerfacing*6;
6483 footpoint.y+=((float)abs(Random()%1200))/100-6;
6484 footpoint.x+=((float)abs(Random()%1200))/100-6;
6485 footpoint.z+=((float)abs(Random()%1200))/100-6;
6486 sprites.MakeSprite(snowsprite, footpoint,footvel, 1,1,1, .1, 1);
6489 for(k=0;k<numplayers;k++){
6490 if(player[k].aitype==playercontrolled)player[k].turnspeed=500;
6491 if(player[k].aitype!=playercontrolled)player[k].turnspeed=500;
6493 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){
6494 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6495 else if(player[k].rotation>player[k].targetrotation){
6496 player[k].rotation-=multiplier*player[k].turnspeed;
6498 else if(player[k].rotation<player[k].targetrotation){
6499 player[k].rotation+=multiplier*player[k].turnspeed;
6504 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))){
6505 player[k].turnspeed*=2;
6506 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6507 else if(player[k].rotation>player[k].targetrotation){
6508 player[k].rotation-=multiplier*player[k].turnspeed;
6510 else if(player[k].rotation<player[k].targetrotation){
6511 player[k].rotation+=multiplier*player[k].turnspeed;
6513 player[k].turnspeed/=2;
6516 if(player[k].targetanimation==sneakanim&&player[k].currentanimation!=sneakanim){
6517 player[k].turnspeed*=4;
6518 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6519 else if(player[k].rotation>player[k].targetrotation){
6520 player[k].rotation-=multiplier*player[k].turnspeed;
6522 else if(player[k].rotation<player[k].targetrotation){
6523 player[k].rotation+=multiplier*player[k].turnspeed;
6525 player[k].turnspeed/=4;
6528 /*if(player[k].aitype!=passivetype||(findDistancefast(&player[k].coords,&viewer)<viewdistance*viewdistance))*/ player[k].DoStuff();
6529 if(player[k].immobile&&k!=0)player[k].coords=player[k].realoldcoords;
6531 if(findDistancefast(&player[k].coords,&player[k].realoldcoords)>0){
6532 if(!player[k].skeleton.free&&player[k].targetanimation!=climbanim&&player[k].targetanimation!=hanganim){
6535 if(player[k].collide<-.3)player[k].collide=-.3;
6536 if(player[k].collide>1)player[k].collide=1;
6537 player[k].collide-=multiplier*30;
6539 if(player[k].coords.y<terrain.getHeight(player[k].coords.x,player[k].coords.z)){
6540 player[k].coords.y=terrain.getHeight(player[k].coords.x,player[k].coords.z);
6542 if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
6543 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
6544 i=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
6545 if(objects.type[i]!=rocktype||(((objects.scale[i]>.5&&player[k].aitype==playercontrolled)||objects.position[i].y>player[k].coords.y))){
6546 lowpoint=player[k].coords;
6547 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&!player[k].isFlip())lowpoint.y+=1.25;
6548 else lowpoint.y+=1.3;
6549 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){
6550 player[k].coords.y=terrain.getHeight(player[k].coords.x,player[k].coords.z);
6552 /*while(player[k].coords.y<terrain.getHeight(player[k].coords.x,player[k].coords.z))
6553 player[k].coords+=terrain.getNormal(player[k].coords.x,player[k].coords.z)/50;
6555 if(player[k].SphereCheck(&lowpoint, 1.3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
6556 flatfacing=lowpoint-player[k].coords;
6557 player[k].coords=lowpoint;
6558 player[k].coords.y-=1.3;
6559 player[k].collide=1;
6561 if(player[k].aitype==playercontrolled&&(player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim||player[k].isFlip())&&!player[k].jumptogglekeydown&&player[k].jumpkeydown){
6562 lowpointtarget=lowpoint+DoRotation(player[k].facing,0,-90,0)*1.5;
6563 tempcoords1=lowpoint;
6564 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6565 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6567 player[k].targetanimation=walljumpleftanim;
6568 player[k].targetframe=0;
6571 gLoc[0]=player[k].coords.x;
6572 gLoc[1]=player[k].coords.y;
6573 gLoc[2]=player[k].coords.z;
6577 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, TRUE);
6578 FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6579 FSOUND_SetVolume(channels[movewhooshsound], 256);
6580 FSOUND_SetPaused(channels[movewhooshsound], FALSE);
6581 if(k==0)FSOUND_SetPaused(channels[whooshsound], TRUE);
6583 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6584 player[k].rotation=-asin(0-lowpointtarget.x);
6585 player[k].rotation*=360/6.28;
6586 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6587 player[k].targetrotation=player[k].rotation;
6588 player[k].lowrotation=player[k].rotation;
6589 if(k==0)numwallflipped++;
6593 lowpoint=tempcoords1;
6594 lowpointtarget=lowpoint+DoRotation(player[k].facing,0,90,0)*1.5;
6595 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6596 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6598 player[k].targetanimation=walljumprightanim;
6599 player[k].targetframe=0;
6602 gLoc[0]=player[k].coords.x;
6603 gLoc[1]=player[k].coords.y;
6604 gLoc[2]=player[k].coords.z;
6608 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, TRUE);
6609 FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6610 FSOUND_SetVolume(channels[movewhooshsound], 256);
6611 FSOUND_SetPaused(channels[movewhooshsound], FALSE);
6612 if(k==0)FSOUND_SetPaused(channels[whooshsound], TRUE);
6614 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6615 player[k].rotation=-asin(0-lowpointtarget.x);
6616 player[k].rotation*=360/6.28;
6617 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6618 player[k].targetrotation=player[k].rotation;
6619 player[k].lowrotation=player[k].rotation;
6620 if(k==0)numwallflipped++;
6624 lowpoint=tempcoords1;
6625 lowpointtarget=lowpoint+player[k].facing*2;
6626 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6627 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6629 player[k].targetanimation=walljumpbackanim;
6630 player[k].targetframe=0;
6633 gLoc[0]=player[k].coords.x;
6634 gLoc[1]=player[k].coords.y;
6635 gLoc[2]=player[k].coords.z;
6639 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, TRUE);
6640 FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6641 FSOUND_SetVolume(channels[movewhooshsound], 256);
6642 FSOUND_SetPaused(channels[movewhooshsound], FALSE);
6643 if(k==0)FSOUND_SetPaused(channels[whooshsound], TRUE);
6645 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6646 player[k].rotation=-asin(0-lowpointtarget.x);
6647 player[k].rotation*=360/6.28;
6648 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6649 player[k].targetrotation=player[k].rotation;
6650 player[k].lowrotation=player[k].rotation;
6651 if(k==0)numwallflipped++;
6655 lowpoint=tempcoords1;
6656 lowpointtarget=lowpoint-player[k].facing*2;
6657 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6658 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6660 player[k].targetanimation=walljumpfrontanim;
6661 player[k].targetframe=0;
6664 gLoc[0]=player[k].coords.x;
6665 gLoc[1]=player[k].coords.y;
6666 gLoc[2]=player[k].coords.z;
6670 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, TRUE);
6671 FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6672 FSOUND_SetVolume(channels[movewhooshsound], 256);
6673 FSOUND_SetPaused(channels[movewhooshsound], FALSE);
6674 if(k==0)FSOUND_SetPaused(channels[whooshsound], TRUE);
6676 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6677 player[k].rotation=-asin(0-lowpointtarget.x);
6678 player[k].rotation*=360/6.28;
6679 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6680 player[k].rotation+=180;
6681 player[k].targetrotation=player[k].rotation;
6682 player[k].lowrotation=player[k].rotation;
6683 if(k==0)numwallflipped++;
6691 else if(objects.type[i]==rocktype){
6692 lowpoint2=player[k].coords;
6693 lowpoint=player[k].coords;
6695 if(objects.model[i].LineCheck(&lowpoint,&lowpoint2,&colpoint,&objects.position[i],&objects.rotation[i])!=-1){
6696 player[k].coords=colpoint;
6697 player[k].collide=1;
6700 if((player[k].targetanimation==jumpdownanim||player[k].isFlip())){
6701 if(player[k].isFlip()&&animation[player[k].targetanimation].label[player[k].targetframe]==7)player[k].RagDoll(0);
6703 if(player[k].targetanimation==jumpupanim){player[k].jumppower=-4;player[k].targetanimation=player[k].getIdle();}
6705 player[k].targetframe=0;
6706 player[k].onterrain=1;
6708 if(player[k].id==0){
6709 FSOUND_SetPaused(channels[whooshsound], TRUE);
6710 FSOUND_SetVolume(channels[whooshsound], 0);
6713 if((player[k].targetanimation==jumpdownanim||player[k].isFlip())&&!player[k].wasLanding()){
6714 if(player[k].isFlip())player[k].jumppower=-4;
6715 player[k].targetanimation=player[k].getLanding();
6718 gLoc[0]=player[k].coords.x;
6719 gLoc[1]=player[k].coords.y;
6720 gLoc[2]=player[k].coords.z;
6721 vel[0]=player[k].velocity.x;
6722 vel[1]=player[k].velocity.y;
6723 vel[2]=player[k].velocity.z;
6724 PlaySoundEx( landsound, samp[landsound], NULL, TRUE);
6725 FSOUND_3D_SetAttributes(channels[landsound], gLoc, vel);
6726 FSOUND_SetVolume(channels[landsound], 128);
6727 FSOUND_SetPaused(channels[landsound], FALSE);
6729 envsound[numenvsounds]=player[k].coords;
6730 envsoundvol[numenvsounds]=16;
6731 envsoundlife[numenvsounds]=.4;
6740 if(tempcollide&&terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz]&&(/*player[k].jumptogglekeydown*/1==1||player[k].aitype!=playercontrolled))
6741 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
6742 i=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
6743 lowpoint=player[k].coords;
6745 if(objects.type[i]!=rocktype)
6746 if(player[k].SphereCheck(&lowpoint, 1.33, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
6747 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&player[k].onterrain)player[k].avoidcollided=1;
6748 player[k].coords=lowpoint;
6749 player[k].coords.y-=1.35;
6750 player[k].collide=1;
6752 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)){
6753 lowpoint=player[k].coords;
6754 objects.model[i].SphereCheckPossible(&lowpoint, 1.5, &objects.position[i], &objects.rotation[i]);
6755 lowpoint=player[k].coords;
6759 facing=DoRotation(facing,0,player[k].targetrotation+180,0);
6760 lowpointtarget=lowpoint+facing*1.4;
6761 whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6763 lowpoint=player[k].coords;
6765 lowpointtarget=lowpoint+facing*1.4;
6767 lowpointtarget2=lowpointtarget;
6769 lowpointtarget3=lowpointtarget;
6771 lowpointtarget4=lowpointtarget;
6773 lowpointtarget5=lowpointtarget;
6775 lowpointtarget6=lowpointtarget;
6777 lowpointtarget7=lowpoint;
6779 lowpointtarget2.x+=.1;
6781 lowpointtarget3.z+=.1;
6783 lowpointtarget4.x-=.1;
6785 lowpointtarget5.z-=.1;
6787 lowpointtarget6.y+=45/13;
6788 lowpointtarget6+=facing*.6;
6789 lowpointtarget7.y+=90/13;
6790 whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6791 if(objects.friction[i]>.5)
6794 if(whichhit!=-1)if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim)player[k].collided=1;
6795 if(checkcollide(lowpoint7,lowpointtarget7)==-1)
6796 if(checkcollide(lowpoint6,lowpointtarget6)==-1)
6797 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)
6799 lowpoint=player[k].coords;
6800 lowpoint.y+=(float)j/13;
6801 lowpointtarget=lowpoint+facing*1.4;
6802 if(objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint2,&objects.position[i],&objects.rotation[i])==-1){
6806 /*if(j>=25&&(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)){
6809 if(j<=25&&player[k].targetanimation==jumpdownanim){
6812 if(j!=100&&(/*j>25||(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)||*/player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim)){
6813 lowpoint=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0);
6814 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)*/){
6815 lowpoint=player[k].coords;
6816 lowpoint.y+=(float)j/13;
6817 lowpointtarget=lowpoint+facing*1.3;
6818 flatfacing=player[k].coords;
6819 player[k].coords=colpoint-DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0)*.01;
6820 player[k].coords.y=lowpointtarget.y-.07;
6821 player[k].currentoffset=(flatfacing-player[k].coords)/player[k].scale;
6823 if(j>10||!player[k].isRun()){
6824 if(player[k].targetanimation==jumpdownanim||player[k].targetanimation==jumpupanim){
6825 if(k==0)FSOUND_SetPaused(channels[whooshsound], TRUE);
6829 gLoc[0]=player[k].coords.x;
6830 gLoc[1]=player[k].coords.y;
6831 gLoc[2]=player[k].coords.z;
6832 vel[0]=player[k].velocity.x;
6833 vel[1]=player[k].velocity.y;
6834 vel[2]=player[k].velocity.z;
6835 PlaySoundEx( jumpsound, samp[jumpsound], NULL, TRUE);
6836 FSOUND_3D_SetAttributes(channels[jumpsound], gLoc, vel);
6837 FSOUND_SetVolume(channels[jumpsound], 128);
6838 FSOUND_SetPaused(channels[jumpsound], FALSE);
6840 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6841 player[k].rotation=-asin(0-lowpointtarget.x);
6842 player[k].rotation*=360/6.28;
6843 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6844 player[k].targetrotation=player[k].rotation;
6845 player[k].lowrotation=player[k].rotation;
6847 //player[k].velocity=lowpointtarget*.03;
6848 player[k].velocity=0;
6850 if(/*(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)||*/player[k].targetanimation==jumpupanim){
6851 //player[k].currentanimation=climbanim;
6852 player[k].targetanimation=climbanim;
6853 player[k].jumppower=0;
6854 player[k].jumpclimb=1;
6856 player[k].transspeed=6;
6859 //player[k].currentframe=1;
6860 player[k].targetframe=1;
6862 //player[k].currentframe=0;
6863 player[k].targetframe=0;
6864 //player[k].currentanimation=hanganim;
6865 player[k].targetanimation=hanganim;
6866 player[k].jumppower=0;
6880 if(player[k].collide<=0){
6881 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()){
6882 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)){
6883 if(player[k].targetanimation==staggerbackhighanim||player[k].targetanimation==staggerbackhardanim)player[k].RagDoll(0);
6884 player[k].targetanimation=jumpdownanim;
6885 player[k].targetframe=0;
6890 gLoc[0]=player[k].coords.x;
6891 gLoc[1]=player[k].coords.y;
6892 gLoc[2]=player[k].coords.z;
6893 vel[0]=player[k].velocity.x;
6894 vel[1]=player[k].velocity.y;
6895 vel[2]=player[k].velocity.z;
6897 PlaySoundEx( whooshsound, samp[whooshsound], NULL, TRUE);
6898 FSOUND_3D_SetAttributes(channels[whooshsound], gLoc, vel);
6899 FSOUND_SetVolume(channels[whooshsound], 128);
6900 FSOUND_SetPaused(channels[whooshsound], FALSE);
6903 player[k].velocity.y+=gravity;
6908 player[k].realoldcoords=player[k].coords;
6911 static XYZ oldviewer;
6914 player[0].forwardkeydown=IsKeyDown(theKeyMap, forwardkey);
6915 player[0].leftkeydown=IsKeyDown(theKeyMap, leftkey);
6916 player[0].backkeydown=IsKeyDown(theKeyMap, backkey);
6917 player[0].rightkeydown=IsKeyDown(theKeyMap, rightkey);
6918 player[0].jumpkeydown=IsKeyDown(theKeyMap, jumpkey);
6919 player[0].crouchkeydown=IsKeyDown(theKeyMap, crouchkey);
6920 player[0].drawkeydown=IsKeyDown(theKeyMap, drawkey);
6921 player[0].throwkeydown=IsKeyDown(theKeyMap, throwkey);
6925 player[0].forwardkeydown=0;
6926 player[0].leftkeydown=0;
6927 player[0].backkeydown=0;
6928 player[0].rightkeydown=0;
6929 player[0].jumpkeydown=0;
6930 player[0].crouchkeydown=0;
6931 player[0].drawkeydown=0;
6932 player[0].throwkeydown=0;
6935 if(!player[0].jumpkeydown)player[0].jumpclimb=0;
6938 static bool endkeydown;
6945 facing=DoRotation(facing,-rotation2,0,0);
6946 facing=DoRotation(facing,0,0-rotation,0);
6951 flatfacing=DoRotation(flatfacing,0,-rotation,0);
6953 if(IsKeyDown(theKeyMap, forwardkey))viewer+=facing*multiplier*4;
6954 if(IsKeyDown(theKeyMap, backkey))viewer-=facing*multiplier*4;
6955 if(IsKeyDown(theKeyMap, leftkey))viewer+=DoRotation(flatfacing*multiplier,0,90,0)*4;
6956 if(IsKeyDown(theKeyMap, rightkey))viewer+=DoRotation(flatfacing*multiplier,0,-90,0)*4;
6957 if(IsKeyDown(theKeyMap, jumpkey))viewer.y+=multiplier*4;
6958 if(IsKeyDown(theKeyMap, crouchkey))viewer.y-=multiplier*4;
6959 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)
6960 ||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)
6961 ||IsKeyDown(theKeyMap, MAC_MINUS_KEY))){
6963 if(IsKeyDown(theKeyMap, MAC_1_KEY))whichend=1;
6964 if(IsKeyDown(theKeyMap, MAC_2_KEY))whichend=2;
6965 if(IsKeyDown(theKeyMap, MAC_3_KEY))whichend=3;
6966 if(IsKeyDown(theKeyMap, MAC_4_KEY))whichend=4;
6967 if(IsKeyDown(theKeyMap, MAC_5_KEY))whichend=5;
6968 if(IsKeyDown(theKeyMap, MAC_6_KEY))whichend=6;
6969 if(IsKeyDown(theKeyMap, MAC_7_KEY))whichend=7;
6970 if(IsKeyDown(theKeyMap, MAC_8_KEY))whichend=8;
6971 if(IsKeyDown(theKeyMap, MAC_9_KEY))whichend=9;
6972 if(IsKeyDown(theKeyMap, MAC_0_KEY))whichend=0;
6973 if(IsKeyDown(theKeyMap, MAC_MINUS_KEY))whichend=-1;
6975 participantfocus[whichdialogue][indialogue]=whichend;
6976 participantlocation[whichdialogue][whichend]=player[whichend].coords;
6977 participantrotation[whichdialogue][whichend]=player[whichend].rotation;
6980 participantfocus[whichdialogue][indialogue]=-1;
6982 if(player[participantfocus[whichdialogue][indialogue]].dead){
6987 dialoguecamera[whichdialogue][indialogue]=viewer;
6988 dialoguecamerarotation[whichdialogue][indialogue]=rotation;
6989 dialoguecamerarotation2[whichdialogue][indialogue]=rotation2;
6991 if(indialogue<numdialogueboxes[whichdialogue]){
6992 if(dialogueboxsound[whichdialogue][indialogue]!=0){
6993 static float gLoc[3];
6994 static float vel[3];
6996 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
6997 temppos=temppos-viewer;
6998 Normalise(&temppos);
7003 gLoc[2]=temppos.z;vel[0]=0;
7007 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
7008 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
7009 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
7010 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
7011 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
7012 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
7013 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
7014 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
7015 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
7016 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
7017 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
7018 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
7019 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
7020 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
7021 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
7022 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
7023 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
7024 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
7025 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
7026 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
7027 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, TRUE);
7028 FSOUND_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
7029 FSOUND_SetVolume(channels[whichsoundplay], 256);
7030 FSOUND_SetPaused(channels[whichsoundplay], FALSE);
7034 for(j=0;j<numplayers;j++){
7035 participantfacing[whichdialogue][indialogue][j]=participantfacing[whichdialogue][indialogue-1][j];
7040 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)
7041 ||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)
7044 if(IsKeyDown(theKeyMap, MAC_NUMPAD_1_KEY))whichend=1;
7045 if(IsKeyDown(theKeyMap, MAC_NUMPAD_2_KEY))whichend=2;
7046 if(IsKeyDown(theKeyMap, MAC_NUMPAD_3_KEY))whichend=3;
7047 if(IsKeyDown(theKeyMap, MAC_NUMPAD_4_KEY))whichend=4;
7048 if(IsKeyDown(theKeyMap, MAC_NUMPAD_5_KEY))whichend=5;
7049 if(IsKeyDown(theKeyMap, MAC_NUMPAD_6_KEY))whichend=6;
7050 if(IsKeyDown(theKeyMap, MAC_NUMPAD_7_KEY))whichend=7;
7051 if(IsKeyDown(theKeyMap, MAC_NUMPAD_8_KEY))whichend=8;
7052 if(IsKeyDown(theKeyMap, MAC_NUMPAD_9_KEY))whichend=9;
7053 if(IsKeyDown(theKeyMap, MAC_NUMPAD_0_KEY))whichend=0;
7054 participantfacing[whichdialogue][indialogue][whichend]=facing;
7056 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)
7057 &&!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)
7058 &&!IsKeyDown(theKeyMap, MAC_MINUS_KEY)){
7061 if(indialogue>=numdialogueboxes[whichdialogue]){
7068 FSOUND_SetPaused(channels[whooshsound], TRUE);
7069 viewer=dialoguecamera[whichdialogue][indialogue];
7070 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.1){
7071 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.1;
7073 rotation=dialoguecamerarotation[whichdialogue][indialogue];
7074 rotation2=dialoguecamerarotation2[whichdialogue][indialogue];
7075 if(dialoguetime>0.5)
7076 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)
7077 ||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)
7078 ||IsKeyDown(theKeyMap, MAC_MINUS_KEY)))||(IsKeyDown(theKeyMap, attackkey)&&!oldbuttondialogue)){
7081 if(indialogue<numdialogueboxes[whichdialogue]){
7082 if(dialogueboxsound[whichdialogue][indialogue]!=0){
7083 static float gLoc[3];
7084 static float vel[3];
7086 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
7087 temppos=temppos-viewer;
7088 Normalise(&temppos);
7093 gLoc[2]=temppos.z;vel[0]=0;
7097 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
7098 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
7099 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
7100 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
7101 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
7102 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
7103 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
7104 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
7105 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
7106 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
7107 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
7108 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
7109 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
7110 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
7111 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
7112 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
7113 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
7114 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
7115 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
7116 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
7117 if(dialogueboxsound[whichdialogue][indialogue]==-6)whichsoundplay=alarmsound;
7118 if(dialogueboxsound[whichdialogue][indialogue]!=-5){
7119 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, TRUE);
7120 FSOUND_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
7121 FSOUND_SetVolume(channels[whichsoundplay], 256);
7122 FSOUND_SetPaused(channels[whichsoundplay], FALSE);
7124 if(dialogueboxsound[whichdialogue][indialogue]==-5){
7125 hotspot[numhotspots]=player[0].coords;
7126 hotspotsize[numhotspots]=10;
7127 hotspottype[numhotspots]=-1;
7131 if(dialogueboxsound[whichdialogue][indialogue]==-6){
7135 if(player[participantfocus[whichdialogue][indialogue]].dead){
7143 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)
7144 &&!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)
7145 &&!IsKeyDown(theKeyMap, MAC_MINUS_KEY)){
7148 if(indialogue>=numdialogueboxes[whichdialogue]){
7152 if(dialoguetype[whichdialogue]>19&&dialoguetype[whichdialogue]<30){
7155 if(dialoguetype[whichdialogue]>29&&dialoguetype[whichdialogue]<40){
7158 if(dialoguetype[whichdialogue]>49&&dialoguetype[whichdialogue]<60){
7160 for(i=1;i<numplayers;i++){
7161 player[i].aitype = attacktypecutoff;
7168 if(!IsKeyDown(theKeyMap, attackkey))oldbuttondialogue=0;
7169 else oldbuttondialogue=1;
7171 static float keyrefreshdelay=0,bigrefreshdelay=0;
7175 /*keyrefreshdelay-=multiplier;
7176 bigrefreshdelay-=multiplier;
7178 if(keyrefreshdelay<=0){
7179 static int concat[4];
7181 concat[0]=player[0].forwardkeydown;
7182 concat[0]=concat[0]*2+player[0].forwardstogglekeydown;
7183 concat[0]=concat[0]*2+player[0].rightkeydown;
7184 concat[0]=concat[0]*2+player[0].leftkeydown;
7185 concat[0]=concat[0]*2+player[0].backkeydown;
7186 concat[0]=concat[0]*2+player[0].jumpkeydown;
7187 concat[0]=concat[0]*2+player[0].jumptogglekeydown;
7188 concat[0]=concat[0]*2+player[0].crouchkeydown;
7190 concat[1]=player[0].crouchtogglekeydown;
7191 concat[1]=concat[1]*2+player[0].drawkeydown;
7192 concat[1]=concat[1]*2+player[0].drawtogglekeydown;
7193 concat[1]=concat[1]*2+player[0].throwkeydown;
7194 concat[1]=concat[1]*2+player[0].throwtogglekeydown;
7195 concat[1]=concat[1]*2+player[0].attackkeydown;
7197 //concat[2]=(char)((int)(rotation/2)%180);
7199 //concat[3]=(char)((int)(rotation2/2)%180);
7201 chatname[0]=concat[0]-128;
7202 chatname[1]=concat[1]-128;
7203 //chatname[2]=concat[2]-128;
7204 //chatname[3]=concat[3]-128;
7206 memcpy(chatname+temppoint,&rotation,sizeof(float));
7207 temppoint+=sizeof(float);
7208 memcpy(chatname+temppoint,&rotation2,sizeof(float));
7209 temppoint+=sizeof(float);
7211 chatname[temppoint]='\0';
7213 //if(!ishost)NetworkSendPlayerMessage( chatname, kMessageType_Keys );
7214 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_Keys );
7215 //keyrefreshdelay=.01;
7216 keyrefreshdelay=.03;
7219 if(bigrefreshdelay<=0){
7222 memcpy(chatname+temppoint,&i,sizeof(int));
7223 temppoint+=sizeof(int);
7224 memcpy(chatname+temppoint,&player[i].coords.x,sizeof(float));
7225 temppoint+=sizeof(float);
7226 memcpy(chatname+temppoint,&player[i].coords.y,sizeof(float));
7227 temppoint+=sizeof(float);
7228 memcpy(chatname+temppoint,&player[i].coords.z,sizeof(float));
7229 temppoint+=sizeof(float);
7230 memcpy(chatname+temppoint,&player[i].damage,sizeof(float));
7231 temppoint+=sizeof(float);
7232 memcpy(chatname+temppoint,&player[i].target,sizeof(float));
7233 temppoint+=sizeof(float);
7234 memcpy(chatname+temppoint,&player[i].targetanimation,sizeof(int));
7235 temppoint+=sizeof(int);
7236 memcpy(chatname+temppoint,&player[i].currentanimation,sizeof(int));
7237 temppoint+=sizeof(int);
7238 memcpy(chatname+temppoint,&player[i].velocity.x,sizeof(float));
7239 temppoint+=sizeof(float);
7240 memcpy(chatname+temppoint,&player[i].velocity.y,sizeof(float));
7241 temppoint+=sizeof(float);
7242 memcpy(chatname+temppoint,&player[i].velocity.z,sizeof(float));
7243 temppoint+=sizeof(float);
7244 memcpy(chatname+temppoint,&player[i].targetframe,sizeof(int));
7245 temppoint+=sizeof(int);
7246 memcpy(chatname+temppoint,&player[i].currentframe,sizeof(int));
7247 temppoint+=sizeof(int);
7248 memcpy(chatname+temppoint,&player[i].rotation,sizeof(float));
7249 temppoint+=sizeof(float);
7250 memcpy(chatname+temppoint,&player[i].targetrotation,sizeof(float));
7251 temppoint+=sizeof(float);
7252 memcpy(chatname+temppoint,&player[i].bloodloss,sizeof(float));
7253 temppoint+=sizeof(float);
7254 memcpy(chatname+temppoint,&player[i].weaponactive,sizeof(int));
7255 temppoint+=sizeof(int);
7256 memcpy(chatname+temppoint,&player[i].num_weapons,sizeof(int));
7257 temppoint+=sizeof(int);
7258 memcpy(chatname+temppoint,&player[i].weaponids[0],sizeof(int));
7259 temppoint+=sizeof(int);
7260 memcpy(chatname+temppoint,&player[i].weaponids[1],sizeof(int));
7261 temppoint+=sizeof(int);
7262 memcpy(chatname+temppoint,&player[i].weaponids[2],sizeof(int));
7263 temppoint+=sizeof(int);
7264 memcpy(chatname+temppoint,&player[i].weaponids[3],sizeof(int));
7265 temppoint+=sizeof(int);
7266 chatname[temppoint]='\0';
7268 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);
7269 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_PlayerState );
7270 //else NetworkSendPlayerMessage( chatname, kMessageType_PlayerState );
7272 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);
7274 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_PlayerStateMisc );
7275 //else NetworkSendPlayerMessage( chatname, kMessageType_PlayerStateMisc );
7277 //bigrefreshdelay=.02;
7282 if(!player[0].jumpkeydown){
7283 player[0].jumptogglekeydown=0;
7285 if(player[0].jumpkeydown&&player[0].targetanimation!=jumpupanim&&player[0].targetanimation!=jumpdownanim&&!player[0].isFlip())player[0].jumptogglekeydown=1;
7288 dialoguetime+=multiplier;
7289 skybox.cloudmove+=multiplier;
7290 hawkrotation+=multiplier*25;
7292 realhawkcoords.x=25;
7293 realhawkcoords=DoRotation(realhawkcoords,0,hawkrotation,0)+hawkcoords;
7294 hawkcalldelay-=multiplier/2;
7296 if(hawkcalldelay<=0)
7298 static float gLoc[3];
7299 static float vel[3];
7300 gLoc[0]=realhawkcoords.x;
7301 gLoc[1]=realhawkcoords.y;
7302 gLoc[2]=realhawkcoords.z;
7306 PlaySoundEx( hawksound, samp[hawksound], NULL, TRUE);
7307 FSOUND_3D_SetAttributes(channels[hawksound], gLoc, vel);
7308 FSOUND_SetVolume(channels[hawksound], 128);
7309 FSOUND_SetPaused(channels[hawksound], FALSE);
7311 hawkcalldelay=16+abs(Random()%8);
7313 static float temptexdetail;
7316 if(IsKeyDown(theKeyMap, MAC_H_KEY)&&debugmode){
7317 player[0].damagetolerance=200000;
7320 player[0].permanentdamage=0;
7321 player[0].superpermanentdamage=0;
7324 whichchar = abs(Random()%7);
7325 registrationname[whichchar]+=1;
7329 if(IsKeyDown(theKeyMap, MAC_J_KEY)&&!envtogglekeydown&&debugmode){
7331 if(environment>2)environment=0;
7332 Setenvironment(environment);
7338 if(!IsKeyDown(theKeyMap, MAC_J_KEY)){
7342 if(IsKeyDown(theKeyMap, MAC_C_KEY)&&!cameratogglekeydown&&debugmode){
7343 cameramode=1-cameramode;
7344 cameratogglekeydown=1;
7347 if(!IsKeyDown(theKeyMap, MAC_C_KEY)){
7348 cameratogglekeydown=0;
7351 if(IsKeyDown(theKeyMap, MAC_X_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!detailtogglekeydown&&debugmode){
7352 if(player[0].num_weapons>0){
7353 if(weapons.type[player[0].weaponids[0]]==sword)weapons.type[player[0].weaponids[0]]=staff;
7354 else if(weapons.type[player[0].weaponids[0]]==staff)weapons.type[player[0].weaponids[0]]=knife;
7355 else weapons.type[player[0].weaponids[0]]=sword;
7356 if(weapons.type[player[0].weaponids[0]]==sword){
7357 weapons.mass[player[0].weaponids[0]]=1.5;
7358 weapons.tipmass[player[0].weaponids[0]]=1;
7359 weapons.length[player[0].weaponids[0]]=.8;
7361 if(weapons.type[player[0].weaponids[0]]==staff){
7362 weapons.mass[player[0].weaponids[0]]=2;
7363 weapons.tipmass[player[0].weaponids[0]]=1;
7364 weapons.length[player[0].weaponids[0]]=1.5;
7367 if(weapons.type[player[0].weaponids[0]]==knife){
7368 weapons.mass[player[0].weaponids[0]]=1;
7369 weapons.tipmass[player[0].weaponids[0]]=1.2;
7370 weapons.length[player[0].weaponids[0]]=.25;
7374 /*for(i=0;i<objects.numobjects;i++){
7375 if(objects.type[i]==treeleavestype){
7376 for(j=0;j<objects.numobjects;j++){
7377 if(objects.type[j]==treetrunktype)
7378 if(findDistancefast(&objects.position[i],&objects.position[j])<.5)
7379 objects.scale[i]=objects.scale[j];
7383 detailtogglekeydown=1;
7386 if(IsKeyDown(theKeyMap, MAC_X_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!detailtogglekeydown&&debugmode){
7388 float closestdist=-1;
7391 for(i=1;i<numplayers;i++){
7392 distance=findDistancefast(&player[i].coords,&player[0].coords);
7393 if(closestdist==-1||distance<closestdist){
7394 closestdist=distance;
7399 if(player[closest].num_weapons)
7401 if(weapons.type[player[closest].weaponids[0]]==sword)weapons.type[player[closest].weaponids[0]]=staff;
7402 else if(weapons.type[player[closest].weaponids[0]]==staff)weapons.type[player[closest].weaponids[0]]=knife;
7403 else weapons.type[player[closest].weaponids[0]]=sword;
7404 if(weapons.type[player[closest].weaponids[0]]==sword){
7405 weapons.mass[player[closest].weaponids[0]]=1.5;
7406 weapons.tipmass[player[closest].weaponids[0]]=1;
7407 weapons.length[player[closest].weaponids[0]]=.8;
7409 if(weapons.type[player[0].weaponids[0]]==staff){
7410 weapons.mass[player[0].weaponids[0]]=2;
7411 weapons.tipmass[player[0].weaponids[0]]=1;
7412 weapons.length[player[0].weaponids[0]]=1.5;
7414 if(weapons.type[player[closest].weaponids[0]]==knife){
7415 weapons.mass[player[closest].weaponids[0]]=1;
7416 weapons.tipmass[player[closest].weaponids[0]]=1.2;
7417 weapons.length[player[closest].weaponids[0]]=.25;
7420 if(!player[closest].num_weapons)
7422 player[closest].weaponids[0]=weapons.numweapons;
7423 weapons.owner[weapons.numweapons]=closest;
7424 weapons.type[weapons.numweapons]=knife;
7425 weapons.damage[weapons.numweapons]=0;
7426 weapons.numweapons++;
7427 player[closest].num_weapons=1;
7428 if(weapons.type[player[closest].weaponids[0]]==sword){
7429 weapons.mass[player[closest].weaponids[0]]=1.5;
7430 weapons.tipmass[player[closest].weaponids[0]]=1;
7431 weapons.length[player[closest].weaponids[0]]=.8;
7433 if(weapons.type[player[closest].weaponids[0]]==knife){
7434 weapons.mass[player[closest].weaponids[0]]=1;
7435 weapons.tipmass[player[closest].weaponids[0]]=1.2;
7436 weapons.length[player[closest].weaponids[0]]=.25;
7440 detailtogglekeydown=1;
7443 if(IsKeyDown(theKeyMap, MAC_U_KEY)&&debugmode){
7445 float closestdist=-1;
7448 for(i=1;i<numplayers;i++){
7449 distance=findDistancefast(&player[i].coords,&player[0].coords);
7450 if(closestdist==-1||distance<closestdist){
7451 closestdist=distance;
7456 player[closest].rotation+=multiplier*50;
7457 player[closest].targetrotation=player[closest].rotation;
7461 if(IsKeyDown(theKeyMap, MAC_O_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7463 float closestdist=-1;
7466 for(i=1;i<numplayers;i++){
7467 distance=findDistancefast(&player[i].coords,&player[0].coords);
7468 if(closestdist==-1||distance<closestdist){
7469 closestdist=distance;
7473 if(IsKeyDown(theKeyMap, MAC_CONTROL_KEY))closest=0;
7476 player[closest].whichskin++;
7477 if(player[closest].whichskin>9)player[closest].whichskin=0;
7478 if(player[closest].whichskin>2&&player[closest].creature==wolftype)player[closest].whichskin=0;
7480 if(player[closest].creature==rabbittype){
7481 if(player[closest].whichskin==0){
7482 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7484 else if(player[closest].whichskin==1){
7485 LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7487 else if(player[closest].whichskin==2){
7488 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7490 else if(player[closest].whichskin==3){
7491 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7493 else if(player[closest].whichskin==4){
7494 LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7496 else if(player[closest].whichskin==5){
7497 LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7499 else if(player[closest].whichskin==6){
7500 LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7502 else if(player[closest].whichskin==7){
7503 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7505 else if(player[closest].whichskin==8){
7506 LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7508 else if(player[closest].whichskin==9){
7509 LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7512 if(player[closest].creature==wolftype){
7514 if(player[closest].whichskin==0){
7515 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7517 else if(player[closest].whichskin==1){
7518 LoadTextureSave(":Data:Textures:Darkwolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7520 else if(player[closest].whichskin==2){
7521 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7526 if(player[closest].numclothes){
7527 for(i=0;i<player[closest].numclothes;i++){
7528 tintr=player[closest].clothestintr[i];
7529 tintg=player[closest].clothestintg[i];
7530 tintb=player[closest].clothestintb[i];
7531 AddClothes((char *)player[closest].clothes[i],0,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7533 player[closest].DoMipmaps(5,0,0,player[closest].skeleton.skinsize,player[closest].skeleton.skinsize);
7536 detailtogglekeydown=1;
7539 if(IsKeyDown(theKeyMap, MAC_O_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7541 float closestdist=-1;
7544 for(i=1;i<numplayers;i++){
7545 distance=findDistancefast(&player[i].coords,&player[0].coords);
7546 if(closestdist==-1||distance<closestdist){
7547 closestdist=distance;
7552 if(player[closest].creature==wolftype){
7553 headprop=player[closest].proportionhead.x/1.1;
7554 bodyprop=player[closest].proportionbody.x/1.1;
7555 armprop=player[closest].proportionarms.x/1.1;
7556 legprop=player[closest].proportionlegs.x/1.1;
7559 if(player[closest].creature==rabbittype){
7560 headprop=player[closest].proportionhead.x/1.2;
7561 bodyprop=player[closest].proportionbody.x/1.05;
7562 armprop=player[closest].proportionarms.x/1.00;
7563 legprop=player[closest].proportionlegs.x/1.1;
7567 if(player[closest].creature==rabbittype){
7568 player[closest].skeleton.id=closest;
7569 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);
7570 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[closest],&player[closest].skeleton.skinsize);
7571 player[closest].whichskin=0;
7572 player[closest].creature=wolftype;
7574 player[closest].proportionhead=1.1;
7575 player[closest].proportionbody=1.1;
7576 player[closest].proportionarms=1.1;
7577 player[closest].proportionlegs=1.1;
7578 player[closest].proportionlegs.y=1.1;
7579 player[closest].scale=.23*5*player[0].scale;
7581 player[closest].damagetolerance=300;
7585 player[closest].skeleton.id=closest;
7586 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);
7587 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7588 player[closest].whichskin=0;
7589 player[closest].creature=rabbittype;
7591 player[closest].proportionhead=1.2;
7592 player[closest].proportionbody=1.05;
7593 player[closest].proportionarms=1.00;
7594 player[closest].proportionlegs=1.1;
7595 player[closest].proportionlegs.y=1.05;
7596 player[closest].scale=.2*5*player[0].scale;
7598 player[closest].damagetolerance=200;
7601 if(player[closest].creature==wolftype){
7602 player[closest].proportionhead=1.1*headprop;
7603 player[closest].proportionbody=1.1*bodyprop;
7604 player[closest].proportionarms=1.1*armprop;
7605 player[closest].proportionlegs=1.1*legprop;
7608 if(player[closest].creature==rabbittype){
7609 player[closest].proportionhead=1.2*headprop;
7610 player[closest].proportionbody=1.05*bodyprop;
7611 player[closest].proportionarms=1.00*armprop;
7612 player[closest].proportionlegs=1.1*legprop;
7613 player[closest].proportionlegs.y=1.05*legprop;
7617 detailtogglekeydown=1;
7620 if(!IsKeyDown(theKeyMap, MAC_X_KEY)){
7621 detailtogglekeydown=0;
7624 if(IsKeyDown(theKeyMap, MAC_B_KEY)&&!slomotogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7627 slomotogglekeydown=1;
7631 if(((IsKeyDown(theKeyMap, MAC_I_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY))/*||buttons[1]*/)&&!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);
7640 if(distance<144&&!player[i].headless)
7641 if(closestdist==-1||distance<closestdist){
7642 closestdist=distance;
7644 blah = player[i].coords;
7649 XYZ headspurtdirection;
7650 int i = player[closest].skeleton.jointlabels[head];
7651 for(k=0;k<player[closest].skeleton.num_joints; k++){
7652 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7653 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7654 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;
7655 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7656 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7657 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7658 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7659 headspurtdirection=player[closest].skeleton.joints[player[closest].skeleton.jointlabels[head]].position-player[closest].skeleton.joints[player[closest].skeleton.jointlabels[neck]].position;
7660 Normalise(&headspurtdirection);
7661 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, .6, 1);
7662 flatvelocity2+=headspurtdirection*8;
7663 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2/2, 1,1,1, .16, 1);
7665 sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
7675 PlaySoundEx( splattersound, samp[splattersound], NULL, TRUE);
7676 FSOUND_3D_SetAttributes(channels[splattersound], gLoc, vel);
7677 FSOUND_SetVolume(channels[splattersound], 256);
7678 FSOUND_SetPaused(channels[splattersound], FALSE);
7680 PlaySoundEx( breaksound2, samp[breaksound2], NULL, TRUE);
7681 FSOUND_3D_SetAttributes(channels[breaksound2], gLoc, vel);
7682 FSOUND_SetVolume(channels[breaksound2], 100);
7683 FSOUND_SetPaused(channels[breaksound2], FALSE);
7685 if(player[closest].skeleton.free==2)player[closest].skeleton.free=0;
7686 player[closest].RagDoll(0);
7687 player[closest].dead=2;
7688 player[closest].headless=1;
7689 player[closest].DoBloodBig(3,165);
7694 explodetogglekeydown=1;
7697 if(((IsKeyDown(theKeyMap, MAC_I_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY))/*||buttons[2]*/)&&!explodetogglekeydown&&debugmode){
7699 float closestdist=-1;
7701 XYZ flatfacing2,flatvelocity2;
7704 for(i=1;i<numplayers;i++){
7705 distance=findDistancefast(&player[i].coords,&player[0].coords);
7707 if(closestdist==-1||distance<closestdist){
7708 closestdist=distance;
7710 blah=player[i].coords;
7724 PlaySoundEx( splattersound, samp[splattersound], NULL, TRUE);
7725 FSOUND_3D_SetAttributes(channels[splattersound], gLoc, vel);
7726 FSOUND_SetVolume(channels[splattersound], 256);
7727 FSOUND_SetPaused(channels[splattersound], FALSE);
7729 PlaySoundEx( breaksound2, samp[breaksound2], NULL, TRUE);
7730 FSOUND_3D_SetAttributes(channels[breaksound2], gLoc, vel);
7731 FSOUND_SetVolume(channels[breaksound2], 600);
7732 FSOUND_SetPaused(channels[breaksound2], FALSE);
7734 for(i=0;i<player[closest].skeleton.num_joints; i++){
7735 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7736 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7737 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;
7738 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7739 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7740 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7741 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7742 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
7743 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .3, 1);
7744 sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
7747 for(i=0;i<player[closest].skeleton.num_joints; i++){
7748 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7749 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7750 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;
7751 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7752 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7753 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7754 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7755 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
7756 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
7759 for(i=0;i<player[closest].skeleton.num_joints; i++){
7760 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7761 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7762 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;
7763 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7764 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7765 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7766 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7767 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
7768 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
7771 for(i=0;i<player[closest].skeleton.num_joints; i++){
7772 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7773 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7774 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;
7775 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7776 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7777 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7778 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7779 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
7780 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
7784 for(j=0;j<numplayers; j++){
7786 if(findDistancefast(&player[j].coords,&player[closest].coords)<25){
7787 player[j].DoDamage((25-findDistancefast(&player[j].coords,&player[closest].coords))*60);
7788 if(player[j].skeleton.free==2)player[j].skeleton.free=1;
7789 player[j].skeleton.longdead=0;
7790 player[j].RagDoll(0);
7791 for(i=0;i<player[j].skeleton.num_joints; i++){
7792 temppos=player[j].skeleton.joints[i].position+player[j].coords;
7793 if(findDistancefast(&temppos,&player[closest].coords)<25){
7794 flatvelocity2=temppos-player[closest].coords;
7795 Normalise(&flatvelocity2);
7796 player[j].skeleton.joints[i].velocity+=flatvelocity2*((20-findDistancefast(&temppos,&player[closest].coords))*20);
7803 player[closest].DoDamage(10000);
7804 player[closest].RagDoll(0);
7805 player[closest].dead=2;
7806 player[closest].coords=20;
7807 player[closest].skeleton.free=2;
7813 explodetogglekeydown=1;
7816 if(!IsKeyDown(theKeyMap, MAC_I_KEY)){
7817 explodetogglekeydown=0;
7821 if(IsKeyDown(theKeyMap, MAC_S_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)&&!slomotogglekeydown){
7823 //tfile=fopen( ":Data:Maps:mapsave", "wb" );
7824 if(whichlevel==0)tfile=fopen( ":Data:Maps:map1", "wb" );
7825 else if(whichlevel==1)tfile=fopen( ":Data:Maps:map2", "wb" );
7826 else if(whichlevel==2)tfile=fopen( ":Data:Maps:map3", "wb" );
7827 else if(whichlevel==3)tfile=fopen( ":Data:Maps:map4", "wb" );
7828 else if(whichlevel==4)tfile=fopen( ":Data:Maps:map5", "wb" );
7829 else tfile=fopen( ":Data:Maps:mapsave", "wb" );
7831 fwrite( &player[0].coords, 1, sizeof(XYZ), tfile );
7832 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
7833 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
7834 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
7835 for(j=0;j<player[0].num_weapons;j++){
7836 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
7838 fwrite( &environment, 1, sizeof(int), tfile );
7840 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
7841 fwrite( &objects.type, 1, sizeof(int)*objects.numobjects, tfile );
7842 fwrite( &objects.rotation, 1, sizeof(float)*objects.numobjects, tfile );
7843 fwrite( &objects.position, 1, sizeof(XYZ)*objects.numobjects, tfile );
7844 fwrite( &objects.scale, 1, sizeof(float)*objects.numobjects, tfile );
7846 fwrite( &numplayers, 1, sizeof(int), tfile );
7847 if(numplayers>1&&numplayers<maxplayers)
7848 for(i=1;i<numplayers;i++){
7849 fwrite( &player[i].coords, 1, sizeof(XYZ), tfile );
7850 fwrite( &player[i].num_weapons, 1, sizeof(int), tfile );
7851 for(j=0;j<player[i].num_weapons;j++){
7852 fwrite( &weapons.type[player[i].weaponids[j]], 1, sizeof(int), tfile );
7854 if(player[i].numwaypoints<30){
7855 fwrite( &player[i].numwaypoints, 1, sizeof(int), tfile );
7856 fwrite( &player[i].waypoints, 1, sizeof(XYZ)*player[i].numwaypoints, tfile );
7857 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7858 //fwrite( &player[i].jumppath, 1, sizeof(bool), tfile );
7861 player[i].numwaypoints=0;
7862 player[i].waypoint=0;
7863 fwrite( &player[i].numwaypoints, 1, sizeof(int), tfile );
7864 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7865 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7871 slomotogglekeydown=1;
7874 if(!IsKeyDown(theKeyMap, MAC_B_KEY)&&!IsKeyDown(theKeyMap, MAC_F_KEY)&&!IsKeyDown(theKeyMap, MAC_K_KEY)&&!IsKeyDown(theKeyMap, MAC_S_KEY)){
7875 slomotogglekeydown=0;
7879 if(IsKeyDown(theKeyMap, MAC_F_KEY)&&!slomotogglekeydown&&debugmode){
7880 player[0].onfire=1-player[0].onfire;
7881 if(player[0].onfire){
7882 player[0].CatchFire();
7884 if(!player[0].onfire){
7887 gLoc[0]=player[0].coords.x;
7888 gLoc[1]=player[0].coords.y;
7889 gLoc[2]=player[0].coords.z;
7893 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
7894 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
7895 FSOUND_SetVolume(channels[fireendsound], 256);
7896 FSOUND_SetPaused(channels[fireendsound], FALSE);
7897 FSOUND_SetPaused(channels[stream_firesound], TRUE);
7899 slomotogglekeydown=1;
7902 if(IsKeyDown(theKeyMap, MAC_L_KEY)){
7903 if(player[0].bleeding<=0)
7904 player[0].DoBlood(1,255);
7908 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)){
7910 float closestdist=-1;
7913 for(i=1;i<numplayers;i++){
7914 distance=findDistancefast(&player[i].coords,&player[0].coords);
7915 if(closestdist==-1||distance<closestdist){
7916 closestdist=distance;
7920 if(closestdist>0&&closest>=0){
7921 //player[closest]=player[numplayers-1];
7922 //player[closest].skeleton=player[numplayers-1].skeleton;
7925 drawmodetogglekeydown=1;
7928 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7930 float closestdist=-1;
7933 for(i=1;i<max_objects;i++){
7934 distance=findDistancefast(&objects.position[i],&player[0].coords);
7935 if(closestdist==-1||distance<closestdist){
7936 closestdist=distance;
7940 if(closestdist>0&&closest>=0){
7941 objects.position[closest].y-=500;
7943 drawmodetogglekeydown=1;
7946 if(IsKeyDown(theKeyMap, MAC_M_KEY)&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&editorenabled&&debugmode){
7948 //if(drawmode>2)drawmode=0;
7949 if(objects.numobjects<max_objects-1){
7951 boxcoords.x=player[0].coords.x;
7952 boxcoords.z=player[0].coords.z;
7953 boxcoords.y=player[0].coords.y-3;
7954 if(editortype==bushtype)boxcoords.y=player[0].coords.y-.5;
7955 if(editortype==firetype)boxcoords.y=player[0].coords.y-.5;
7956 //objects.MakeObject(abs(Random()%3),boxcoords,Random()%360);
7957 float temprotat,temprotat2;
7958 temprotat=editorrotation;
7959 temprotat2=editorrotation2;
7960 if(temprotat<0||editortype==bushtype)temprotat=Random()%360;
7961 if(temprotat2<0)temprotat2=Random()%360;
7963 objects.MakeObject(editortype,boxcoords,(int)temprotat-((int)temprotat)%30,(int)temprotat2,editorsize);
7964 if(editortype==treetrunktype)
7965 objects.MakeObject(treeleavestype,boxcoords,Random()%360*(temprotat2<2)+(int)editorrotation-((int)editorrotation)%30,editorrotation2,editorsize);
7968 drawmodetogglekeydown=1;
7971 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&editorenabled){
7972 if(numplayers<maxplayers-1){
7973 player[numplayers].scale=.2*5*player[0].scale;
7974 player[numplayers].creature=rabbittype;
7975 player[numplayers].howactive=editoractive;
7976 player[numplayers].skeleton.id=numplayers;
7977 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);
7979 //texsize=512*512*3/texdetail/texdetail;
7980 //if(!player[numplayers].loaded)player[numplayers].skeleton.skinText = new GLubyte[texsize];
7981 //player[numplayers].skeleton.skinText.resize(texsize);
7983 k=abs(Random()%2)+1;
7985 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7986 player[numplayers].whichskin=0;
7989 LoadTextureSave(":Data:Textures:Fur.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7990 player[numplayers].whichskin=1;
7993 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7994 player[numplayers].whichskin=2;
7997 LoadTexture(":Data:Textures:Belt.png",&player[numplayers].skeleton.drawmodelclothes.textureptr,1,1);
7998 player[numplayers].power=1;
7999 player[numplayers].speedmult=1;
8000 player[numplayers].currentanimation=bounceidleanim;
8001 player[numplayers].targetanimation=bounceidleanim;
8002 player[numplayers].currentframe=0;
8003 player[numplayers].targetframe=1;
8004 player[numplayers].target=0;
8005 player[numplayers].bled=0;
8006 player[numplayers].speed=1+(float)(Random()%100)/1000;
8008 player[numplayers].targetrotation=player[0].targetrotation;
8009 player[numplayers].rotation=player[0].rotation;
8011 player[numplayers].velocity=0;
8012 player[numplayers].coords=player[0].coords;
8013 player[numplayers].oldcoords=player[numplayers].coords;
8014 player[numplayers].realoldcoords=player[numplayers].coords;
8016 player[numplayers].id=numplayers;
8017 player[numplayers].skeleton.id=numplayers;
8018 player[numplayers].updatedelay=0;
8019 player[numplayers].normalsupdatedelay=0;
8021 player[numplayers].aitype=passivetype;
8022 player[numplayers].aitarget=0;
8024 if(player[0].creature==wolftype){
8025 headprop=player[0].proportionhead.x/1.1;
8026 bodyprop=player[0].proportionbody.x/1.1;
8027 armprop=player[0].proportionarms.x/1.1;
8028 legprop=player[0].proportionlegs.x/1.1;
8031 if(player[0].creature==rabbittype){
8032 headprop=player[0].proportionhead.x/1.2;
8033 bodyprop=player[0].proportionbody.x/1.05;
8034 armprop=player[0].proportionarms.x/1.00;
8035 legprop=player[0].proportionlegs.x/1.1;
8038 if(player[numplayers].creature==wolftype){
8039 player[numplayers].proportionhead=1.1*headprop;
8040 player[numplayers].proportionbody=1.1*bodyprop;
8041 player[numplayers].proportionarms=1.1*armprop;
8042 player[numplayers].proportionlegs=1.1*legprop;
8045 if(player[numplayers].creature==rabbittype){
8046 player[numplayers].proportionhead=1.2*headprop;
8047 player[numplayers].proportionbody=1.05*bodyprop;
8048 player[numplayers].proportionarms=1.00*armprop;
8049 player[numplayers].proportionlegs=1.1*legprop;
8050 player[numplayers].proportionlegs.y=1.05*legprop;
8053 player[numplayers].headless=0;
8054 player[numplayers].onfire=0;
8057 player[numplayers].proportionhead.z=0;
8058 player[numplayers].proportionbody.z=0;
8059 player[numplayers].proportionarms.z=0;
8060 player[numplayers].proportionlegs.z=0;
8063 player[numplayers].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0);
8065 player[numplayers].damagetolerance=200;
8067 player[numplayers].protectionhead=player[0].protectionhead;
8068 player[numplayers].protectionhigh=player[0].protectionhigh;
8069 player[numplayers].protectionlow=player[0].protectionlow;
8070 player[numplayers].armorhead=player[0].armorhead;
8071 player[numplayers].armorhigh=player[0].armorhigh;
8072 player[numplayers].armorlow=player[0].armorlow;
8073 player[numplayers].metalhead=player[0].metalhead;
8074 player[numplayers].metalhigh=player[0].metalhigh;
8075 player[numplayers].metallow=player[0].metallow;
8077 player[numplayers].immobile=player[0].immobile;
8079 player[numplayers].numclothes=player[0].numclothes;
8080 if(player[numplayers].numclothes)
8081 for(i=0;i<player[numplayers].numclothes;i++){
8082 strcpy(player[numplayers].clothes[i], player[0].clothes[i]);
8083 player[numplayers].clothestintr[i]=player[0].clothestintr[i];
8084 player[numplayers].clothestintg[i]=player[0].clothestintg[i];
8085 player[numplayers].clothestintb[i]=player[0].clothestintb[i];
8086 tintr=player[numplayers].clothestintr[i];
8087 tintg=player[numplayers].clothestintg[i];
8088 tintb=player[numplayers].clothestintb[i];
8089 AddClothes((char *)player[numplayers].clothes[i],0,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
8091 if(player[numplayers].numclothes){
8092 player[numplayers].DoMipmaps(5,0,0,player[numplayers].skeleton.skinsize,player[numplayers].skeleton.skinsize);
8095 player[numplayers].power=player[0].power;
8096 player[numplayers].speedmult=player[0].speedmult;
8098 player[numplayers].damage=0;
8099 player[numplayers].permanentdamage=0;
8100 player[numplayers].superpermanentdamage=0;
8101 player[numplayers].deathbleeding=0;
8102 player[numplayers].bleeding=0;
8103 player[numplayers].numwaypoints=0;
8104 player[numplayers].waypoint=0;
8105 player[numplayers].jumppath=0;
8106 player[numplayers].weaponstuck=-1;
8107 player[numplayers].weaponactive=-1;
8108 player[numplayers].num_weapons=0;
8109 player[numplayers].bloodloss=0;
8110 player[numplayers].dead=0;
8112 player[numplayers].loaded=1;
8116 drawmodetogglekeydown=1;
8119 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&editorenabled){
8120 if(player[numplayers-1].numwaypoints<90){
8121 player[numplayers-1].waypoints[player[numplayers-1].numwaypoints]=player[0].coords;
8122 player[numplayers-1].waypointtype[player[numplayers-1].numwaypoints]=editorpathtype;
8123 player[numplayers-1].numwaypoints++;
8125 drawmodetogglekeydown=1;
8128 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&editorenabled){
8129 if(numpathpoints<30){
8130 bool connected,alreadyconnected;
8133 for(i=0;i<numpathpoints;i++){
8134 if(findDistancefast(&pathpoint[i],&player[0].coords)<.5&&i!=pathpointselected&&!connected){
8136 for(j=0;j<numpathpointconnect[pathpointselected];j++){
8137 if(pathpointconnect[pathpointselected][j]==i)alreadyconnected=1;
8139 if(!alreadyconnected){
8140 numpathpointconnect[pathpointselected]++;
8142 pathpointconnect[pathpointselected][numpathpointconnect[pathpointselected]-1]=i;
8148 pathpoint[numpathpoints-1]=player[0].coords;
8149 numpathpointconnect[numpathpoints-1]=0;
8150 if(numpathpoints>1&&pathpointselected!=-1){
8151 numpathpointconnect[pathpointselected]++;
8152 pathpointconnect[pathpointselected][numpathpointconnect[pathpointselected]-1]=numpathpoints-1;
8154 pathpointselected=numpathpoints-1;
8157 drawmodetogglekeydown=1;
8160 if(IsKeyDown(theKeyMap, MAC_PERIOD_KEY)&&!drawmodetogglekeydown&&editorenabled){
8161 pathpointselected++;
8162 if(pathpointselected>=numpathpoints)pathpointselected=-1;
8163 drawmodetogglekeydown=1;
8165 if(IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!drawmodetogglekeydown&&editorenabled){
8166 pathpointselected--;
8167 if(pathpointselected<=-2)pathpointselected=numpathpoints-1;
8168 drawmodetogglekeydown=1;
8170 if(IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!drawmodetogglekeydown&&editorenabled){
8171 if(pathpointselected!=-1){
8173 pathpoint[pathpointselected]=pathpoint[numpathpoints];
8174 numpathpointconnect[pathpointselected]=numpathpointconnect[numpathpoints];
8175 for(i=0;i<numpathpointconnect[pathpointselected];i++){
8176 pathpointconnect[pathpointselected][i]=pathpointconnect[numpathpoints][i];
8178 for(i=0;i<numpathpoints;i++){
8179 for(j=0;j<numpathpointconnect[i];j++){
8180 if(pathpointconnect[i][j]==pathpointselected){
8181 pathpointconnect[i][j]=pathpointconnect[i][numpathpointconnect[i]-1];
8182 numpathpointconnect[i]--;
8184 if(pathpointconnect[i][j]==numpathpoints){
8185 pathpointconnect[i][j]=pathpointselected;
8189 pathpointselected=numpathpoints-1;
8191 drawmodetogglekeydown=1;
8194 if(IsKeyDown(theKeyMap, MAC_M_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
8195 editorenabled=1-editorenabled;
8197 player[0].damagetolerance=100000;
8199 player[0].superpermanentdamage=0;
8200 player[0].bloodloss=0;
8201 player[0].deathbleeding=0;
8204 player[0].damagetolerance=200;
8206 player[0].permanentdamage=0;
8207 player[0].superpermanentdamage=0;
8208 player[0].bloodloss=0;
8209 player[0].deathbleeding=0;
8211 drawmodetogglekeydown=1;
8214 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8216 if(editortype==treeleavestype||editortype==10)editortype--;
8217 if(editortype<0)editortype=firetype;
8218 drawmodetogglekeydown=1;
8221 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8223 if(editortype==treeleavestype||editortype==10)editortype++;
8224 if(editortype>firetype)editortype=0;
8225 drawmodetogglekeydown=1;
8228 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8229 editorrotation-=multiplier*100;
8230 if(editorrotation<-.01)editorrotation=-.01;
8231 drawmodetogglekeydown=1;
8234 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8235 editorrotation+=multiplier*100;
8236 drawmodetogglekeydown=1;
8239 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8240 editorsize+=multiplier;
8241 drawmodetogglekeydown=1;
8244 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8245 editorsize-=multiplier;
8246 if(editorsize<.1)editorsize=.1;
8247 drawmodetogglekeydown=1;
8251 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8252 mapradius-=multiplier*10;
8255 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8256 mapradius+=multiplier*10;
8259 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8260 mapcenter.x+=multiplier*20;
8263 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8264 mapcenter.x-=multiplier*20;
8267 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8268 mapcenter.z+=multiplier*20;
8271 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8272 mapcenter.z-=multiplier*20;
8275 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8276 editorrotation2+=multiplier*100;
8279 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8280 editorrotation2-=multiplier*100;
8281 if(editorrotation2<-.01)editorrotation2=-.01;
8283 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&objects.numobjects&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)){
8285 float closestdist=-1;
8287 for(i=0;i<objects.numobjects;i++){
8288 distance=findDistancefast(&objects.position[i],&player[0].coords);
8289 if(closestdist==-1||distance<closestdist){
8290 closestdist=distance;
8294 if(closestdist>0&&closest>=0)objects.DeleteObject(closest);
8295 drawmodetogglekeydown=1;
8299 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)){
8300 drawmodetogglekeydown=0;
8303 if(IsKeyDown(theKeyMap, MAC_N_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&!texturesizetogglekeydown&&debugmode){
8304 //if(!player[0].skeleton.free)player[0].damage+=500;
8305 player[0].RagDoll(0);
8306 //player[0].spurt=1;
8307 //player[0].DoDamage(1000);
8311 gLoc[0]=player[0].coords.x;
8312 gLoc[1]=player[0].coords.y;
8313 gLoc[2]=player[0].coords.z;
8314 vel[0]=player[0].velocity.x;
8315 vel[1]=player[0].velocity.y;
8316 vel[2]=player[0].velocity.z;
8317 PlaySoundEx( whooshsound, samp[whooshsound], NULL, TRUE);
8318 FSOUND_3D_SetAttributes(channels[whooshsound], gLoc, vel);
8319 FSOUND_SetVolume(channels[whooshsound], 128);
8320 FSOUND_SetPaused(channels[whooshsound], FALSE);
8321 //FSOUND_SetPaused(channels[whooshsound], TRUE);
8323 texturesizetogglekeydown=1;
8326 if(IsKeyDown(theKeyMap, MAC_N_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&!texturesizetogglekeydown&&debugmode){
8329 float closestdist=-1;
8331 for(i=0;i<objects.numobjects;i++){
8332 if(objects.type[i]==treeleavestype){
8333 objects.scale[i]*=.9;
8336 texturesizetogglekeydown=1;
8339 static XYZ relative;
8340 static int randattack;
8342 static bool playerrealattackkeydown=0;
8344 if(!buttons[0])oldbutton=0;
8345 if(!IsKeyDown(theKeyMap, attackkey))oldattackkey=0;
8346 if(oldattackkey)player[0].attackkeydown=0;
8347 if(oldattackkey)playerrealattackkeydown=0;
8348 if(!oldattackkey)playerrealattackkeydown=IsKeyDown(theKeyMap, attackkey);
8349 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);
8350 if(IsKeyDown(theKeyMap, attackkey)&&!oldattackkey&&!player[0].backkeydown){
8351 for(k=0;k<numplayers;k++){
8352 if((player[k].targetanimation==swordslashanim||player[k].targetanimation==staffhitanim||player[k].targetanimation==staffspinhitanim)&&player[0].currentanimation!=dodgebackanim&&!player[k].skeleton.free)
8353 player[k].Reverse();
8357 if(!hostile||indialogue!=-1)player[0].attackkeydown=0;
8359 for(k=0;k<numplayers;k++){
8360 if(indialogue!=-1)player[k].attackkeydown=0;
8361 if(player[k].targetanimation!=rabbitrunninganim&&player[k].targetanimation!=wolfrunninganim){
8362 if(player[k].aitype!=playercontrolled)player[k].victim=&player[0];
8363 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)){
8364 player[k].jumppower-=2;
8366 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)){
8367 for(i=0;i<numplayers;i++){
8369 if(player[i].targetanimation==swordslashanim||player[i].targetanimation==knifeslashstartanim||player[i].targetanimation==staffhitanim||player[i].targetanimation==staffspinhitanim)
8370 if(findDistancefast(&player[k].coords,&player[i].coords)<6.5&&!player[i].skeleton.free){
8371 player[k].targetanimation=dodgebackanim;
8373 player[k].targetframe=0;
8374 rotatetarget=player[i].coords-player[k].coords;
8375 Normalise(&rotatetarget);
8376 player[k].targetrotation=-asin(0-rotatetarget.x);
8377 player[k].targetrotation*=360/6.28;
8378 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8380 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;
8383 if(player[k].targetanimation!=dodgebackanim){
8384 if(k==0)numflipped++;
8385 player[k].targetanimation=backhandspringanim;
8387 player[k].targetframe=0;
8388 player[k].targetrotation=-rotation+180;
8389 if(player[k].leftkeydown)player[k].targetrotation-=45;
8390 if(player[k].rightkeydown)player[k].targetrotation+=45;
8391 player[k].rotation=player[k].targetrotation;
8392 player[k].jumppower-=2;
8395 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())){
8396 player[k].hasvictim=0;
8398 for(i=0;i<numplayers;i++){
8400 if(!player[k].hasvictim)
8401 if((k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack!=reversal){
8402 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){
8403 player[k].victim=&player[i];
8404 player[k].hasvictim=1;
8405 if(player[k].aitype==playercontrolled){
8406 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;
8407 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;
8408 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;
8409 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;
8410 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;
8411 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;
8412 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;
8413 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;
8414 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;
8415 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;
8418 if(findDistancefast(&player[k].coords,&player[i].coords)<4.5*(player[k].scale*5)*(player[k].scale*5)){
8419 if(player[k].weaponactive==-1)randattack=abs(Random()%5);
8420 else randattack=abs(Random()%5);
8421 if(player[k].weaponactive==-1&&findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)){
8422 if(randattack==0&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=sweepanim;
8423 else if(randattack==1&&animation[player[i].targetanimation].height!=lowheight&&player[k].weaponactive==-1)player[k].targetanimation=upunchanim;
8424 else if(randattack==2&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=spinkickanim;
8425 else if(animation[player[i].targetanimation].height==lowheight)player[k].targetanimation=lowkickanim;
8427 if(player[k].weaponactive!=-1){
8428 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;
8429 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;
8430 //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;
8431 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;
8432 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;
8433 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;
8434 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;
8435 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;
8439 if(player[k].targetanimation==upunchanim&&player[k].creature==wolftype)player[k].targetanimation=wolfslapanim;
8441 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)){
8442 if(player[k].weaponactive==-1){
8443 player[i].targetanimation=sneakattackedanim;
8444 player[i].currentanimation=sneakattackedanim;
8445 player[k].currentanimation=sneakattackanim;
8446 player[k].targetanimation=sneakattackanim;
8447 player[k].oldcoords=player[k].coords;
8448 player[k].coords=player[i].coords;
8450 if(player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==knife){
8451 player[i].targetanimation=knifesneakattackedanim;
8452 player[i].currentanimation=knifesneakattackedanim;
8453 player[k].currentanimation=knifesneakattackanim;
8454 player[k].targetanimation=knifesneakattackanim;
8455 player[i].oldcoords=player[i].coords;
8456 player[i].coords=player[k].coords;
8458 if(player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==sword){
8459 player[i].targetanimation=swordsneakattackedanim;
8460 player[i].currentanimation=swordsneakattackedanim;
8461 player[k].currentanimation=swordsneakattackanim;
8462 player[k].targetanimation=swordsneakattackanim;
8463 player[i].oldcoords=player[i].coords;
8464 player[i].coords=player[k].coords;
8466 if(player[k].weaponactive==-1||weapons.type[player[k].weaponids[player[k].weaponactive]]!=staff){
8467 player[k].victim=&player[i];
8468 player[k].hasvictim=1;
8469 player[i].targettilt2=0;
8470 player[i].targetframe=1;
8471 player[i].currentframe=0;
8473 player[i].velocity=0;
8474 player[k].targettilt2=player[i].targettilt2;
8475 player[k].currentframe=player[i].currentframe;
8476 player[k].targetframe=player[i].targetframe;
8477 player[k].target=player[i].target;
8478 player[k].velocity=0;
8479 player[k].targetrotation=player[i].rotation;
8480 player[k].rotation=player[i].rotation;
8481 player[i].targetrotation=player[i].rotation;
8484 if(animation[player[k].targetanimation].attack==normalattack&&player[k].victim==&player[i]&&(!player[i].skeleton.free)){
8486 player[k].targetframe=0;
8488 //player[k].velocity=0;
8490 rotatetarget=player[i].coords-player[k].coords;
8491 Normalise(&rotatetarget);
8492 player[k].targetrotation=-asin(0-rotatetarget.x);
8493 player[k].targetrotation*=360/6.28;
8494 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8496 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8498 player[k].lastattack3=player[k].lastattack2;
8499 player[k].lastattack2=player[k].lastattack;
8500 player[k].lastattack=player[k].targetanimation;
8501 //player[k].targettilt2=0;
8505 if(player[k].targetanimation==knifefollowanim&&player[k].victim==&player[i]){
8506 rotatetarget=player[i].coords-player[k].coords;
8507 Normalise(&rotatetarget);
8508 player[k].targetrotation=-asin(0-rotatetarget.x);
8509 player[k].targetrotation*=360/6.28;
8510 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8511 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8513 player[k].victim=&player[i];
8514 player[k].hasvictim=1;
8515 player[i].targetanimation=knifefollowedanim;
8516 player[i].currentanimation=knifefollowedanim;
8517 player[i].targettilt2=0;
8518 player[i].targettilt2=player[k].targettilt2;
8519 player[i].targetframe=1;
8520 player[i].currentframe=0;
8522 player[i].velocity=0;
8523 player[k].currentanimation=knifefollowanim;
8524 player[k].targetanimation=knifefollowanim;
8525 player[k].targettilt2=player[i].targettilt2;
8526 player[k].currentframe=player[i].currentframe;
8527 player[k].targetframe=player[i].targetframe;
8528 player[k].target=player[i].target;
8529 player[k].velocity=0;
8530 player[k].oldcoords=player[k].coords;
8531 player[i].coords=player[k].coords;
8532 player[i].targetrotation=player[k].targetrotation;
8533 player[i].rotation=player[k].targetrotation;
8534 player[k].rotation=player[k].targetrotation;
8535 player[i].rotation=player[k].targetrotation;
8540 if(player[k].weaponactive!=-1){
8541 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==staff)hasstaff=1;
8544 for(i=0;i<numplayers;i++){
8546 if((playerrealattackkeydown||player[i].dead||!hasstaff)&&(k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack==neutral&&k==0){
8547 if(!player[i].dead||!realthreat||(player[k].weaponactive==-1&&player[k].crouchkeydown))
8548 if(player[i].skeleton.free)
8549 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)))){
8550 player[k].victim=&player[i];
8551 player[k].hasvictim=1;
8552 if(player[k].weaponactive!=-1&&tutoriallevel!=1){
8553 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;
8554 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;
8555 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;
8557 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){
8558 player[k].targetanimation=killanim;
8559 for(j=0;j<terrain.numdecals;j++){
8560 if((terrain.decaltype[j]==blooddecal||terrain.decaltype[j]==blooddecalslow)&&terrain.decalalivetime[j]<2){
8561 terrain.DeleteDecal(j);
8564 for(l=0;l<objects.numobjects;l++){
8565 if(objects.model[l].type==decalstype)
8566 for(j=0;j<objects.model[l].numdecals;j++){
8567 if((objects.model[l].decaltype[j]==blooddecal||objects.model[l].decaltype[j]==blooddecalslow)&&objects.model[l].decalalivetime[j]<2){
8568 objects.model[l].DeleteDecal(j);
8573 if(!player[i].dead||musictype!=2)
8574 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)){
8575 player[k].targetanimation=dropkickanim;
8576 for(j=0;j<terrain.numdecals;j++){
8577 if((terrain.decaltype[j]==blooddecal||terrain.decaltype[j]==blooddecalslow)&&terrain.decalalivetime[j]<2){
8578 terrain.DeleteDecal(j);
8581 for(l=0;l<objects.numobjects;l++){
8582 if(objects.model[l].type==decalstype)
8583 for(j=0;j<objects.model[l].numdecals;j++){
8584 if((objects.model[l].decaltype[j]==blooddecal||objects.model[l].decaltype[j]==blooddecalslow)&&objects.model[l].decalalivetime[j]<2){
8585 objects.model[l].DeleteDecal(j);
8591 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)){
8593 player[k].targetframe=0;
8595 //player[k].velocity=0;
8597 rotatetarget=player[i].coords-player[k].coords;
8598 if(player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim||player[k].targetanimation==staffgroundsmashanim){
8599 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;
8601 Normalise(&rotatetarget);
8602 player[k].targetrotation=-asin(0-rotatetarget.x);
8603 player[k].targetrotation*=360/6.28;
8604 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8606 if(player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim){
8607 player[k].targetrotation+=(float)(abs(Random()%100)-50)/4;
8610 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8611 if(player[k].targetanimation==staffgroundsmashanim)player[k].targettilt2+=10;
8613 player[k].lastattack3=player[k].lastattack2;
8614 player[k].lastattack2=player[k].lastattack;
8615 player[k].lastattack=player[k].targetanimation;
8617 if(player[k].targetanimation==swordgroundstabanim){
8618 player[k].targetrotation+=30;
8620 //player[k].targettilt2=0;
8626 if(!player[k].hasvictim){
8627 for(i=0;i<numplayers;i++){
8628 if((player[k].hasvictim==0)&&i!=k&&(i==0||k==0)&&!player[i].skeleton.free){
8629 player[k].victim=&player[i];
8630 player[k].hasvictim=1;
8632 if(player[k].hasvictim&&!player[i].skeleton.free)
8633 if(findDistancefast(&player[k].coords,&player[i].coords)<findDistancefast(&player[k].coords,&player[k].victim->coords)&&i!=k&&(i==0||k==0)){
8634 player[k].victim=&player[i];
8638 if(player[k].aitype==playercontrolled)
8639 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)){
8641 player[k].targetanimation=rabbitkickanim;
8642 player[k].targetframe=0;
8645 if(animation[player[k].targetanimation].attack&&k==0){
8648 if(player[k].weaponactive!=-1){
8649 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==staff)armedstaff=1;
8652 if(player[k].weaponactive!=-1){
8653 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==sword)armedsword=1;
8656 if(player[k].weaponactive!=-1){
8657 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==knife)armedknife=1;
8659 if(armedstaff)numstaffattack++;
8660 else if(armedsword)numswordattack++;
8661 else if(armedknife)numknifeattack++;
8662 else numunarmedattack++;
8669 static float collisionradius;
8671 for(k=0;k<numplayers;k++){
8672 for(i=k;i<numplayers;i++){
8675 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))
8676 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))
8677 if(player[i].howactive<=typesleeping&&player[k].howactive<=typesleeping)
8678 if(player[i].howactive!=typesittingwall&&player[k].howactive!=typesittingwall)
8679 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)
8680 if(player[i].coords.y>player[k].coords.y-3)
8681 if(player[i].coords.y<player[k].coords.y+3)
8682 if(player[i].coords.x>player[k].coords.x-3)
8683 if(player[i].coords.x<player[k].coords.x+3)
8684 if(player[i].coords.z>player[k].coords.z-3)
8685 if(player[i].coords.z<player[k].coords.z+3){
8686 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)){
8687 if(player[i].onfire||player[k].onfire){
8688 if(!player[i].onfire)player[i].CatchFire();
8689 if(!player[k].onfire)player[k].CatchFire();
8693 tempcoords1=player[i].coords;
8694 tempcoords2=player[k].coords;
8695 if(!player[i].skeleton.oldfree)tempcoords1.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[abdomen]].position.y*player[i].scale;
8696 if(!player[k].skeleton.oldfree)tempcoords2.y+=player[k].skeleton.joints[player[k].skeleton.jointlabels[abdomen]].position.y*player[k].scale;
8697 collisionradius=1.2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5);
8698 if(player[0].hasvictim)
8699 if(player[0].targetanimation==rabbitkickanim&&(k==0||i==0)&&!player[0].victim->skeleton.free)collisionradius=3;
8700 if((!player[i].skeleton.oldfree||!player[k].skeleton.oldfree)&&(findDistancefast(&tempcoords1,&tempcoords2)<collisionradius||findDistancefast(&player[i].coords,&player[k].coords)<collisionradius)){
8702 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)){
8703 player[k].coords.y=player[i].coords.y;
8704 player[i].velocity=player[k].velocity;
8705 player[i].skeleton.free=0;
8706 player[i].rotation=0;
8707 player[i].RagDoll(0);
8708 player[i].DoDamage(20);
8709 if(k==0)camerashake+=.3;
8710 player[i].skeleton.longdead=0;
8711 player[k].lastcollide=1;
8714 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)){
8715 player[i].coords.y=player[k].coords.y;
8716 player[k].velocity=player[i].velocity;
8717 player[k].skeleton.free=0;
8718 player[k].rotation=0;
8719 player[k].RagDoll(0);
8720 player[k].DoDamage(20);
8721 if(i==0)camerashake+=.3;
8722 player[k].skeleton.longdead=0;
8723 player[i].lastcollide=1;
8726 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)){
8727 rotatetarget=player[k].velocity-player[i].velocity;
8728 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))
8729 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))){
8731 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)){
8732 static float gLoc[3];
8733 static float vel[3];
8734 gLoc[0]=player[i].coords.x;
8735 gLoc[1]=player[i].coords.y;
8736 gLoc[2]=player[i].coords.z;
8737 vel[0]=player[i].velocity.x;
8738 vel[1]=player[i].velocity.y;
8739 vel[2]=player[i].velocity.z;
8740 if(tutoriallevel!=1){
8741 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, TRUE);
8742 FSOUND_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
8743 FSOUND_SetVolume(channels[heavyimpactsound], 256);
8744 FSOUND_SetPaused(channels[heavyimpactsound], FALSE);
8746 //player[i].velocity=player[k].velocity;
8747 //player[k].velocity=player[i].velocity;
8749 player[i].RagDoll(0);
8750 if(player[i].damage>player[i].damagetolerance-findLengthfast(&rotatetarget)/4&&!player[i].dead){
8755 player[i].DoDamage(findLengthfast(&rotatetarget)/4);
8756 player[k].RagDoll(0);
8757 if(player[k].damage>player[k].damagetolerance-findLengthfast(&rotatetarget)/4&&!player[k].dead){
8762 player[k].DoDamage(findLengthfast(&rotatetarget)/4);
8764 //if(player[i].skeleton.oldfree){
8765 for(j=0;j<player[i].skeleton.num_joints;j++){
8766 player[i].skeleton.joints[j].velocity=player[i].skeleton.joints[j].velocity/5+player[k].velocity;
8769 //if(player[k].skeleton.oldfree){
8770 for(j=0;j<player[k].skeleton.num_joints;j++){
8771 player[k].skeleton.joints[j].velocity=player[k].skeleton.joints[j].velocity/5+player[i].velocity;
8777 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)){
8779 if(player[i].skeleton.oldfree==0&&player[k].skeleton.oldfree==0){
8780 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)){
8781 rotatetarget=player[k].coords-player[i].coords;
8782 Normalise(&rotatetarget);
8783 player[k].coords=(player[k].coords+player[i].coords)/2;
8784 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);
8785 player[k].coords+=rotatetarget*fast_sqrt(.6)/2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5);
8786 if(player[k].howactive==typeactive||hostile)
8787 if(player[k].isIdle()){
8788 if(player[k].howactive<typesleeping){
8789 player[k].targetanimation=player[k].getStop();
8790 player[k].targetframe=0;
8793 else if(player[k].howactive==typesleeping)
8795 player[k].targetanimation=getupfromfrontanim;
8796 player[k].targetframe=0;
8799 if(!editorenabled)player[k].howactive=typeactive;
8801 if(player[i].howactive==typeactive||hostile)
8802 if(player[i].isIdle()){
8803 if(player[i].howactive<typesleeping){
8804 player[i].targetanimation=player[i].getStop();
8805 player[i].targetframe=0;
8810 player[i].targetanimation=getupfromfrontanim;
8811 player[i].targetframe=0;
8814 if(!editorenabled)player[i].howactive=typeactive;
8818 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){
8819 player[i].velocity=player[k].velocity;
8820 player[k].velocity=player[k].velocity*-.5;
8821 //player[i].velocity.y-=10;
8822 player[k].velocity.y=player[i].velocity.y;
8823 player[i].DoDamage(20);
8824 player[i].RagDoll(0);
8825 player[k].lastcollide=1;
8832 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){
8833 player[k].velocity=player[i].velocity;
8834 player[i].velocity=player[i].velocity*-.3;
8835 //player[k].velocity.y-=10;
8836 player[i].velocity.y=player[k].velocity.y;
8837 player[k].DoDamage(20);
8838 player[k].RagDoll(0);
8839 player[i].lastcollide=1;
8850 player[i].CheckKick();
8851 player[k].CheckKick();
8857 for(k=0;k<numplayers;k++){
8858 for(i=k;i<numplayers;i++){
8860 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))){
8861 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)){
8862 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)){
8863 player[i].victim=&player[k];
8864 player[i].targetanimation=jumpreversedanim;
8865 player[i].currentanimation=jumpreversedanim;
8866 player[k].currentanimation=jumpreversalanim;
8867 player[k].targetanimation=jumpreversalanim;
8868 player[i].targettilt2=0;
8869 player[i].currentframe=0;
8870 player[i].targetframe=1;
8871 player[k].currentframe=0;
8872 player[k].targetframe=1;
8873 if(player[i].coords.y<player[k].coords.y+1){
8874 player[i].targetanimation=rabbitkickreversedanim;
8875 player[i].currentanimation=rabbitkickreversedanim;
8876 player[k].currentanimation=rabbitkickreversalanim;
8877 player[k].targetanimation=rabbitkickreversalanim;
8878 player[k].currentframe=1;
8879 player[k].targetframe=2;
8880 player[i].currentframe=1;
8881 player[i].targetframe=2;
8883 player[k].targettilt2=0;
8885 player[i].velocity=0;
8886 player[k].velocity=0;
8887 player[k].oldcoords=player[k].coords;
8888 player[i].coords=player[k].coords;
8889 player[k].targetrotation=player[i].targetrotation;
8890 player[k].rotation=player[i].targetrotation;
8891 player[k].victim=&player[i];
8892 if(player[k].aitype==attacktypecutoff)player[k].stunned=.5;
8894 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)){
8895 player[k].victim=&player[i];
8896 player[k].targetanimation=jumpreversedanim;
8897 player[k].currentanimation=jumpreversedanim;
8898 player[i].currentanimation=jumpreversalanim;
8899 player[i].targetanimation=jumpreversalanim;
8900 player[k].targettilt2=0;
8901 player[i].targettilt2=0;
8902 player[k].currentframe=0;
8903 player[k].targetframe=1;
8904 player[i].currentframe=0;
8905 player[i].targetframe=1;
8906 if(player[k].coords.y<player[i].coords.y+1){
8907 player[k].targetanimation=rabbitkickreversedanim;
8908 player[k].currentanimation=rabbitkickreversedanim;
8909 player[i].currentanimation=rabbitkickreversalanim;
8910 player[i].targetanimation=rabbitkickreversalanim;
8911 player[k].currentframe=1;
8912 player[k].targetframe=2;
8913 player[i].currentframe=1;
8914 player[i].targetframe=2;
8917 player[k].velocity=0;
8918 player[i].velocity=0;
8919 player[i].oldcoords=player[i].coords;
8920 player[k].coords=player[i].coords;
8921 player[i].targetrotation=player[k].targetrotation;
8922 player[i].rotation=player[k].targetrotation;
8923 player[i].victim=&player[k];
8924 if(player[i].aitype==attacktypecutoff)player[i].stunned=.5;
8931 for(k=0;k<numplayers;k++)
8932 if(player[k].immobile&&k!=0)player[k].coords=player[k].realoldcoords;
8941 static float checkdelay;
8942 checkdelay-=multiplier;
8944 static bool checkedcoll[maxplayers][maxplayers];
8945 static bool above[maxplayers];
8947 for(i=0;i<maxplayers;i++){
8948 for(j=0;j<maxplayers;j++){
8949 checkedcoll[i][j]=0;
8953 if(numplayers>1&&checkdelay<=0){
8955 for(k=0;k<numplayers;k++){
8956 if(player[k].skeleton.free!=2)above[k]=-1;
8958 for(i=k;i<numplayers;i++){
8961 if(!checkedcoll[i][k]){
8962 checkedcoll[i][k]=1;
8963 checkedcoll[k][i]=1;
8964 if(player[i].skeleton.free&&player[k].skeleton.free)
8965 if(player[i].skeleton.free!=2||player[k].skeleton.free!=2)
8966 if(i!=k&&player[i].whichpatchx==player[k].whichpatchx&&player[i].whichpatchz==player[k].whichpatchz)
8967 if(player[i].coords.y>player[k].coords.y-3)
8968 if(player[i].coords.y<player[k].coords.y+3)
8969 if(player[i].coords.x>player[k].coords.x-3)
8970 if(player[i].coords.x<player[k].coords.x+3)
8971 if(player[i].coords.z>player[k].coords.z-3)
8972 if(player[i].coords.z<player[k].coords.z+3)
8973 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)){
8975 if((player[i].skeleton.longdead>player[k].skeleton.longdead&&player[k].skeleton.free!=2)||player[i].skeleton.free==2){
8987 above[moving]=stuck;
8988 for(l=0;l<player[moving].skeleton.num_joints;l++){
8989 for(m=0;m<player[stuck].skeleton.num_joints;m++){
8990 while(findDistancefast(player[moving].skeleton.joints[l].position+player[moving].coords,player[stuck].skeleton.joints[m].position+player[stuck].coords)<.25)
8992 player[moving].skeleton.joints[l].position.y+=.003;
8993 if(player[moving].skeleton.joints[l].velocity.y<-.05)player[moving].skeleton.joints[l].velocity.y+=.003/.015/2;
9007 if(!IsKeyDown(theKeyMap, MAC_N_KEY)){
9008 texturesizetogglekeydown=0;
9011 for(k=0;k<numplayers;k++){
9012 if(!isnormal(player[k].coords.x)||!isnormal(player[k].coords.y)||!isnormal(player[k].coords.z)){
9013 if(!isnormal(player[k].coords.x)||!isnormal(player[k].coords.y)||!isnormal(player[k].coords.z)){
9014 player[k].DoDamage(1000);
9019 static bool respawnkeydown;
9020 if(!editorenabled&&(whichlevel!=-2&&(IsKeyDown(theKeyMap, MAC_Z_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)&&debugmode&&!editorenabled)||(IsKeyDown(theKeyMap, jumpkey)&&!respawnkeydown&&!oldattackkey&&player[0].dead))){
9021 targetlevel=whichlevel;
9025 if(!IsKeyDown(theKeyMap, jumpkey))respawnkeydown=0;
9026 if(IsKeyDown(theKeyMap, jumpkey))respawnkeydown=1;
9031 if(whichlevel!=-2&&IsKeyDown(theKeyMap, MAC_K_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!slomotogglekeydown&&debugmode&&!editorenabled){
9033 if(targetlevel>numchallengelevels-1)targetlevel=0;
9036 slomotogglekeydown=1;
9040 if(IsKeyDown(theKeyMap, MAC_Z_KEY)){
9042 FSOUND_SetPaused(channels[whooshsound], TRUE);
9044 for(k=0;k<numplayers;k++){
9047 player[k].permanentdamage=0;
9048 if(player[k].skeleton.free==2)player[k].skeleton.free=1;
9049 player[k].aitype=passivetype;
9051 player[0].aitype=playercontrolled;
9055 static bool movekey;
9056 static bool connected;
9057 /*player[0].forwardkeydown=IsKeyDown(theKeyMap, MAC_W_KEY);
9058 player[0].leftkeydown=IsKeyDown(theKeyMap, MAC_A_KEY);
9059 player[0].backkeydown=IsKeyDown(theKeyMap, MAC_S_KEY);
9060 player[0].rightkeydown=IsKeyDown(theKeyMap, MAC_D_KEY);
9061 player[0].jumpkeydown=IsKeyDown(theKeyMap, MAC_SPACE_KEY);
9062 player[0].crouchkeydown=IsKeyDown(theKeyMap, MAC_SHIFT_KEY);*/
9064 //if(!player[0].crouchkeydown)player[0].crouchkeydown=IsKeyDown(theKeyMap, MAC_CONTROL_KEY);
9066 for(int i=0;i<numplayers;i++){
9067 if(!player[i].skeleton.free){
9068 oldtargetrotation=player[i].targetrotation;
9069 if(i==0&&indialogue==-1){
9070 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){
9071 if(!cameramode)player[0].targetrotation=-rotation+180;
9072 if(cameramode)player[0].targetrotation=0;
9078 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
9079 if(cameramode){facing=flatfacing;}
9081 facing=DoRotation(facing,-rotation2,0,0);
9082 facing=DoRotation(facing,0,0-rotation,0);
9085 player[0].lookrotation=-rotation;
9087 player[i].targetheadrotation=rotation;
9088 player[i].targetheadrotation2=rotation2;
9090 if(i!=0&&player[i].aitype==playercontrolled&&indialogue==-1){
9091 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){
9092 player[i].targetrotation=-player[i].lookrotation+180;
9098 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
9100 facing=DoRotation(facing,-player[i].lookrotation2,0,0);
9101 facing=DoRotation(facing,0,0-player[i].lookrotation,0);
9103 player[i].targetheadrotation=player[i].lookrotation;
9104 player[i].targetheadrotation2=player[i].lookrotation2;
9107 rotatetarget=participantfacing[whichdialogue][indialogue][i];
9108 Normalise(&rotatetarget);
9109 player[i].targetheadrotation=-asin(0-rotatetarget.x);
9110 player[i].targetheadrotation*=360/6.28;
9111 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
9113 player[i].targetheadrotation*=-1;
9114 player[i].targetheadrotation+=180;
9115 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
9123 player[i].avoidsomething=0;
9125 for(j=0;j<objects.numobjects;j++){
9126 if(objects.onfire[j]){
9127 if(findDistancefast(&objects.position[j],&player[i].coords)<objects.scale[j]*objects.scale[j]*200)
9129 if(findDistancefast(&player[i].coords,&objects.position[j])<findDistancefast(&player[i].coords,&player[0].coords)){
9130 player[i].collided=0;
9131 player[i].avoidcollided=1;
9132 if(player[i].avoidsomething==0||findDistancefast(&objects.position[j],&player[i].coords)<findDistancefast(&player[i].coords,&player[i].avoidwhere))
9133 player[i].avoidwhere=objects.position[j];
9139 //Add avoidwhere to players
9141 for(j=0;j<numplayers;j++){
9142 if(player[j].onfire){
9143 if(findDistancefast(&player[j].coords,&player[i].coords)<0.3*0.3*200)
9145 if(findDistancefast(&player[i].coords,&player[j].coords)<findDistancefast(&player[i].coords,&player[0].coords)){
9146 player[i].collided=0;
9147 player[i].avoidcollided=1;
9148 if(player[i].avoidsomething==0||findDistancefast(&player[j].coords,&player[i].coords)<findDistancefast(&player[i].coords,&player[i].avoidwhere))
9149 player[i].avoidwhere=objects.position[j];
9155 if(player[i].collided>.8)player[i].avoidcollided=0;
9156 if(player[i].aitype!=playercontrolled&&indialogue==-1){
9157 player[i].jumpclimb=0;
9159 if(editorenabled)player[i].stunned=1;
9162 //if(findDistancefastflat(&player[i].coords,&player[0].coords)<3/*&&player[0].coords.y>player[i].coords.y+.1*/)player[i].pause=1;
9163 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;
9165 /*if(player[i].aitype==passivetype&&player[i].numwaypoints<=1){
9166 player[i].forwardkeydown=0;
9167 player[i].leftkeydown=0;
9168 player[i].backkeydown=0;
9169 player[i].rightkeydown=0;
9170 player[i].crouchkeydown=0;
9171 player[i].attackkeydown=0;
9172 player[i].jumpkeydown=0;
9173 player[i].throwkeydown=0;
9176 if(player[i].aitype==pathfindtype){
9177 if(player[i].finalpathfindpoint==-1){
9178 float closestdistance;
9184 for(j=0;j<numpathpoints;j++){
9185 if(closest==-1||findDistancefast(&player[i].finalfinaltarget,&pathpoint[j])<closestdistance){
9186 closestdistance=findDistancefast(&player[i].finalfinaltarget,&pathpoint[j]);
9188 player[i].finaltarget=pathpoint[j];
9191 player[i].finalpathfindpoint=closest;
9192 for(j=0;j<numpathpoints;j++){
9193 if(numpathpointconnect[j])
9194 for(k=0;k<numpathpointconnect[j];k++){
9195 DistancePointLine(&player[i].finalfinaltarget, &pathpoint[j], &pathpoint[pathpointconnect[j][k]], &tempdist,&colpoint );
9196 if(tempdist*tempdist<closestdistance){
9197 if(findDistance(&colpoint,&pathpoint[j])+findDistance(&colpoint,&pathpoint[pathpointconnect[j][k]])<findDistance(&pathpoint[j],&pathpoint[pathpointconnect[j][k]])+.1){
9198 closestdistance=tempdist*tempdist;
9200 player[i].finaltarget=colpoint;
9205 player[i].finalpathfindpoint=closest;
9208 if(player[i].targetpathfindpoint==-1){
9209 float closestdistance;
9215 if(player[i].lastpathfindpoint==-1){
9216 for(j=0;j<numpathpoints;j++){
9217 if(j!=player[i].lastpathfindpoint)
9218 if(closest==-1||(findDistancefast(&player[i].coords,&pathpoint[j])<closestdistance/*&&findDistancefast(&player[i].finaltarget,&pathpoint[j])<findDistancefast(&player[i].finaltarget,&player[i].coords)*/)){
9219 closestdistance=findDistancefast(&player[i].coords,&pathpoint[j]);
9223 player[i].targetpathfindpoint=closest;
9224 for(j=0;j<numpathpoints;j++){
9225 if(j!=player[i].lastpathfindpoint)
9226 if(numpathpointconnect[j])
9227 for(k=0;k<numpathpointconnect[j];k++){
9228 DistancePointLine(&player[i].coords, &pathpoint[j], &pathpoint[pathpointconnect[j][k]], &tempdist,&colpoint );
9229 if(tempdist*tempdist<closestdistance){
9230 if(findDistance(&colpoint,&pathpoint[j])+findDistance(&colpoint,&pathpoint[pathpointconnect[j][k]])<findDistance(&pathpoint[j],&pathpoint[pathpointconnect[j][k]])+.1){
9231 //if(findDistancefast(&player[i].finaltarget,&colpoint)<findDistancefast(&player[i].finaltarget,&player[i].coords)){
9232 closestdistance=tempdist*tempdist;
9239 player[i].targetpathfindpoint=closest;
9243 for(j=0;j<numpathpoints;j++){
9244 if(j!=player[i].lastpathfindpoint&&j!=player[i].lastpathfindpoint2&&j!=player[i].lastpathfindpoint3&&j!=player[i].lastpathfindpoint4)
9247 if(numpathpointconnect[j])
9248 for(k=0;k<numpathpointconnect[j];k++){
9249 if(pathpointconnect[j][k]==player[i].lastpathfindpoint)connected=1;
9252 if(numpathpointconnect[player[i].lastpathfindpoint])
9253 for(k=0;k<numpathpointconnect[player[i].lastpathfindpoint];k++){
9254 if(pathpointconnect[player[i].lastpathfindpoint][k]==j)connected=1;
9257 tempdist=findPathDist(j,player[i].finalpathfindpoint);
9258 if(closest==-1||tempdist<closestdistance){
9259 closestdistance=tempdist;
9265 player[i].targetpathfindpoint=closest;
9268 player[i].losupdatedelay-=multiplier;
9270 rotatetarget=pathpoint[player[i].targetpathfindpoint]-player[i].coords;
9271 Normalise(&rotatetarget);
9272 player[i].targetrotation=-asin(0-rotatetarget.x);
9273 player[i].targetrotation*=360/6.28;
9274 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9275 player[i].lookrotation=player[i].targetrotation;
9276 //player[i].aiupdatedelay=.05;
9278 if(findDistancefastflat(&player[i].coords,&pathpoint[player[i].targetpathfindpoint])<.6){
9279 player[i].lastpathfindpoint4=player[i].lastpathfindpoint3;
9280 player[i].lastpathfindpoint3=player[i].lastpathfindpoint2;
9281 player[i].lastpathfindpoint2=player[i].lastpathfindpoint;
9282 player[i].lastpathfindpoint=player[i].targetpathfindpoint;
9283 if(player[i].lastpathfindpoint2==-1)player[i].lastpathfindpoint2=player[i].lastpathfindpoint;
9284 if(player[i].lastpathfindpoint3==-1)player[i].lastpathfindpoint3=player[i].lastpathfindpoint2;
9285 if(player[i].lastpathfindpoint4==-1)player[i].lastpathfindpoint4=player[i].lastpathfindpoint3;
9286 player[i].targetpathfindpoint=-1;
9288 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){
9289 player[i].aitype=passivetype;
9292 player[i].forwardkeydown=1;
9293 player[i].leftkeydown=0;
9294 player[i].backkeydown=0;
9295 player[i].rightkeydown=0;
9296 player[i].crouchkeydown=0;
9297 player[i].attackkeydown=0;
9298 player[i].throwkeydown=0;
9300 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9302 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9303 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9305 if((tutoriallevel!=1||cananger)&&hostile&&!player[0].dead&&findDistancefast(&player[i].coords,&player[0].coords)<400&&player[i].occluded<25){
9306 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))
9307 player[i].aitype=attacktypecutoff;
9308 if(findDistancefast(&player[i].coords,&player[0].coords)<30&&animation[player[0].targetanimation].height==highheight&&!editorenabled)
9309 player[i].aitype=attacktypecutoff;
9311 if(player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2){
9312 player[i].losupdatedelay=.2;
9313 for(j=0;j<numplayers;j++){
9314 if(j==0||player[j].skeleton.free||player[j].aitype!=passivetype){
9315 if(abs(Random()%2)||animation[player[j].targetanimation].height!=lowheight||j!=0)
9316 if(findDistancefast(&player[i].coords,&player[j].coords)<400)
9317 if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0)
9318 if(player[j].coords.y<player[i].coords.y+5||player[j].onterrain)
9319 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)){
9320 player[i].aitype=searchtype;
9321 player[i].lastchecktime=12;
9322 player[i].lastseen=player[j].coords;
9323 player[i].lastseentime=12;
9329 if(player[i].aitype==attacktypecutoff&&musictype!=2){
9330 if(player[i].creature!=wolftype){
9331 player[i].stunned=.6;
9332 player[i].surprised=.6;
9337 if(player[i].aitype!=passivetype&&leveltime>.5){
9338 player[i].howactive=typeactive;
9341 if(player[i].aitype==passivetype){
9342 player[i].aiupdatedelay-=multiplier;
9343 player[i].losupdatedelay-=multiplier;
9344 player[i].lastseentime+=multiplier;
9345 player[i].pausetime-=multiplier;
9346 if(player[i].lastseentime>1)player[i].lastseentime=1;
9348 if(player[i].aiupdatedelay<0){
9349 if(player[i].numwaypoints>1&&player[i].howactive==typeactive&&player[i].pausetime<=0){
9350 rotatetarget=player[i].waypoints[player[i].waypoint]-player[i].coords;
9351 Normalise(&rotatetarget);
9352 player[i].targetrotation=-asin(0-rotatetarget.x);
9353 player[i].targetrotation*=360/6.28;
9354 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9355 player[i].lookrotation=player[i].targetrotation;
9356 player[i].aiupdatedelay=.05;
9358 if(findDistancefastflat(&player[i].coords,&player[i].waypoints[player[i].waypoint])<1){
9359 if(player[i].waypointtype[player[i].waypoint]==wppause)player[i].pausetime=4;
9360 player[i].waypoint++;
9361 if(player[i].waypoint>player[i].numwaypoints-1)player[i].waypoint=0;
9366 if(player[i].numwaypoints>1&&player[i].howactive==typeactive&&player[i].pausetime<=0)player[i].forwardkeydown=1;
9367 else player[i].forwardkeydown=0;
9368 player[i].leftkeydown=0;
9369 player[i].backkeydown=0;
9370 player[i].rightkeydown=0;
9371 player[i].crouchkeydown=0;
9372 player[i].attackkeydown=0;
9373 player[i].throwkeydown=0;
9375 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9376 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9378 XYZ leftpos,rightpos;
9379 float leftdist,rightdist;
9380 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9381 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9382 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9383 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9384 if(leftdist<rightdist)player[i].targetrotation+=90;
9385 else player[i].targetrotation-=90;
9389 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9390 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9394 if(player[i].howactive<typesleeping)
9395 if(numenvsounds>0&&(tutoriallevel!=1||cananger)&&hostile)
9396 for(j=0;j<numenvsounds;j++){
9397 if(findDistancefast(&player[i].coords,&envsound[j])<2*(envsoundvol[j]+envsoundvol[j]*(player[i].creature==rabbittype)*3)){
9398 player[i].aitype=attacktypecutoff;
9402 if(player[i].howactive==typesleeping)
9403 if(numenvsounds>0&&(tutoriallevel!=1||cananger)&&hostile)
9404 for(j=0;j<numenvsounds;j++){
9405 if(envsoundvol[j]>14)
9406 if(findDistancefast(&player[i].coords,&envsound[j])<2*((envsoundvol[j]-14)+(envsoundvol[j]-14)*(player[i].creature==rabbittype)*3)){
9407 player[i].aitype=attacktypecutoff;
9411 if(player[i].aitype!=passivetype){
9412 if(player[i].howactive==typesleeping){
9413 player[i].targetanimation=getupfromfrontanim;
9414 player[i].targetframe=0;
9418 player[i].howactive=typeactive;
9422 if(player[i].howactive<typesleeping&&((tutoriallevel!=1||cananger)&&hostile)&&!player[0].dead&&findDistancefast(&player[i].coords,&player[0].coords)<400&&player[i].occluded<25){
9423 if(findDistancefast(&player[i].coords,&player[0].coords)<12&&animation[player[0].targetanimation].height!=lowheight&&!editorenabled)
9424 player[i].aitype=attacktypecutoff;
9425 if(findDistancefast(&player[i].coords,&player[0].coords)<30&&animation[player[0].targetanimation].height==highheight&&!editorenabled)
9426 player[i].aitype=attacktypecutoff;
9428 if(player[i].creature==wolftype){
9430 float smelldistance;
9432 for(j=0;j<numplayers;j++){
9433 if(j==0||(player[j].dead&&player[j].bloodloss>0)){
9434 if(j==0&&player[j].num_weapons>0){
9435 if(weapons.bloody[player[j].weaponids[0]])smelldistance=100;
9436 if(player[j].num_weapons==2)
9437 if(weapons.bloody[player[j].weaponids[1]])smelldistance=100;
9442 windsmell=windvector;
9443 Normalise(&windsmell);
9444 windsmell=windsmell*2+player[j].coords;
9445 if(findDistancefast(&player[i].coords,&windsmell)<smelldistance&&!editorenabled)
9446 player[i].aitype=attacktypecutoff;
9451 if(player[i].howactive<typesleeping&&player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2){
9452 player[i].losupdatedelay=.2;
9453 for(j=0;j<numplayers;j++){
9454 if(j==0||player[j].skeleton.free||player[j].aitype!=passivetype){
9455 if(abs(Random()%2)||animation[player[j].targetanimation].height!=lowheight||j!=0)
9456 if(findDistancefast(&player[i].coords,&player[j].coords)<400)
9457 if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0)
9458 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)){
9459 player[i].lastseentime-=.2;
9460 if(j==0&&animation[player[j].targetanimation].height==lowheight)player[i].lastseentime-=.4;
9461 else player[i].lastseentime-=.6;
9463 if(player[i].lastseentime<=0){
9464 player[i].aitype=searchtype;
9465 player[i].lastchecktime=12;
9466 player[i].lastseen=player[j].coords;
9467 player[i].lastseentime=12;
9473 if(player[i].aitype==attacktypecutoff&&musictype!=2){
9474 if(player[i].creature!=wolftype){
9475 player[i].stunned=.6;
9476 player[i].surprised=.6;
9478 if(player[i].creature==wolftype){
9479 player[i].stunned=.47;
9480 player[i].surprised=.47;
9486 if(player[i].aitype==searchtype){
9487 player[i].aiupdatedelay-=multiplier;
9488 player[i].losupdatedelay-=multiplier;
9489 if(!player[i].pause)player[i].lastseentime-=multiplier;
9490 player[i].lastchecktime-=multiplier;
9492 if(player[i].isRun()&&!player[i].onground){
9493 if(player[i].coords.y>terrain.getHeight(player[i].coords.x,player[i].coords.z)+10){
9494 test2=player[i].coords+player[i].facing;
9496 test=player[i].coords+player[i].facing;
9498 j=checkcollide(test2,test,player[i].laststanding);
9499 if(j==-1)j=checkcollide(test2,test);
9501 player[i].velocity=0;
9502 player[i].targetanimation=player[i].getStop();
9503 player[i].targetframe=0;
9505 player[i].targetrotation+=180;
9506 player[i].stunned=.5;
9507 //player[i].aitype=passivetype;
9508 player[i].aitype=pathfindtype;
9509 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9510 player[i].finalpathfindpoint=-1;
9511 player[i].targetpathfindpoint=-1;
9512 player[i].lastpathfindpoint=-1;
9513 player[i].lastpathfindpoint2=-1;
9514 player[i].lastpathfindpoint3=-1;
9515 player[i].lastpathfindpoint4=-1;
9517 else player[i].laststanding=j;
9520 if(player[i].aiupdatedelay<0){
9521 rotatetarget=player[i].lastseen-player[i].coords;
9522 Normalise(&rotatetarget);
9523 player[i].targetrotation=-asin(0-rotatetarget.x);
9524 player[i].targetrotation*=360/6.28;
9525 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9526 player[i].lookrotation=player[i].targetrotation;
9527 player[i].aiupdatedelay=.05;
9528 player[i].forwardkeydown=1;
9530 if(findDistancefastflat(&player[i].coords,&player[i].lastseen)<1*(player[i].scale*5)*(player[i].scale*5)||player[i].lastchecktime<0){
9531 player[i].forwardkeydown=0;
9532 player[i].aiupdatedelay=1;
9533 player[i].lastseen.x+=(float(Random()%100)-50)/25;
9534 player[i].lastseen.z+=(float(Random()%100)-50)/25;
9535 player[i].lastchecktime=3;
9538 player[i].leftkeydown=0;
9539 player[i].backkeydown=0;
9540 player[i].rightkeydown=0;
9541 player[i].crouchkeydown=0;
9542 player[i].attackkeydown=0;
9543 player[i].throwkeydown=0;
9545 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9546 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9548 XYZ leftpos,rightpos;
9549 float leftdist,rightdist;
9550 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9551 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9552 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9553 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9554 if(leftdist<rightdist)player[i].targetrotation+=90;
9555 else player[i].targetrotation-=90;
9559 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9560 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9562 if(numenvsounds>0&&((tutoriallevel!=1||cananger)&&hostile))
9563 for(j=0;j<numenvsounds;j++){
9564 if(findDistancefast(&player[i].coords,&envsound[j])<2*(envsoundvol[j]+envsoundvol[j]*(player[i].creature==rabbittype)*3)){
9565 player[i].aitype=attacktypecutoff;
9569 if(!player[0].dead&&player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2&&((tutoriallevel!=1||cananger)&&hostile)){
9570 player[i].losupdatedelay=.2;
9571 if(findDistancefast(&player[i].coords,&player[0].coords)<4&&animation[player[i].targetanimation].height!=lowheight)
9572 {player[i].aitype=attacktypecutoff;
9573 player[i].lastseentime=1;}
9574 if(abs(Random()%2)||animation[player[i].targetanimation].height!=lowheight)
9575 if(findDistancefast(&player[i].coords,&player[0].coords)<400)
9576 if(normaldotproduct(player[i].facing,player[0].coords-player[i].coords)>0)
9577 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)){
9578 player[i].aitype=attacktypecutoff;
9579 player[i].lastseentime=1;
9582 if(player[i].lastseentime<0){
9583 //player[i].aitype=passivetype;
9585 player[i].aitype=pathfindtype;
9586 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9587 player[i].finalpathfindpoint=-1;
9588 player[i].targetpathfindpoint=-1;
9589 player[i].lastpathfindpoint=-1;
9590 player[i].lastpathfindpoint2=-1;
9591 player[i].lastpathfindpoint3=-1;
9592 player[i].lastpathfindpoint4=-1;
9596 if(player[i].aitype!=gethelptype){
9597 player[i].runninghowlong=0;
9600 if(player[i].aitype==gethelptype){
9601 player[i].runninghowlong+=multiplier;
9602 player[i].aiupdatedelay-=multiplier;
9604 if(player[i].aiupdatedelay<0||player[i].ally==0){
9605 player[i].aiupdatedelay=.2;
9613 if(!player[i].ally){
9614 for(j=0;j<numplayers;j++){
9615 if(j!=i&&j!=0&&!player[j].dead&&player[j].howactive<typedead1&&!player[j].skeleton.free&&player[j].aitype==passivetype){
9616 distance=findDistancefast(&player[i].coords,&player[j].coords);
9617 if(closestdist==-1||distance<closestdist){
9618 closestdist=distance;
9624 if(closest!=-1)player[i].ally=closest;
9625 else player[i].ally=0;
9626 player[i].lastseen=player[0].coords;
9627 player[i].lastseentime=12;
9631 player[i].lastchecktime=12;
9632 //player[i].lastseentime-=.5;
9634 facing=player[i].coords;
9635 flatfacing=player[player[i].ally].coords;
9636 facing.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position.y*player[i].scale;
9637 flatfacing.y+=player[player[i].ally].skeleton.joints[player[player[i].ally].skeleton.jointlabels[head]].position.y*player[player[i].ally].scale;
9638 if(-1!=checkcollide(facing,flatfacing))
9639 player[i].lastseentime-=.1;
9641 if(player[i].ally<=0||player[player[i].ally].skeleton.free||player[player[i].ally].aitype!=passivetype||player[i].lastseentime<=0){
9642 player[i].aitype=searchtype;
9643 player[i].lastseentime=12;
9646 if(player[i].ally>0){
9647 rotatetarget=player[player[i].ally].coords-player[i].coords;
9648 Normalise(&rotatetarget);
9649 player[i].targetrotation=-asin(0-rotatetarget.x);
9650 player[i].targetrotation*=360/6.28;
9651 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9652 player[i].lookrotation=player[i].targetrotation;
9653 player[i].aiupdatedelay=.05;
9654 player[i].forwardkeydown=1;
9656 if(findDistancefastflat(&player[i].coords,&player[player[i].ally].coords)<3){
9657 player[i].aitype=searchtype;
9658 player[i].lastseentime=12;
9659 player[player[i].ally].aitype=searchtype;
9660 if(player[player[i].ally].lastseentime<player[i].lastseentime){
9661 player[player[i].ally].lastseen=player[i].lastseen;
9662 player[player[i].ally].lastseentime=player[i].lastseentime;
9663 player[player[i].ally].lastchecktime=player[i].lastchecktime;
9667 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9668 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9670 XYZ leftpos,rightpos;
9671 float leftdist,rightdist;
9672 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9673 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9674 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9675 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9676 if(leftdist<rightdist)player[i].targetrotation+=90;
9677 else player[i].targetrotation-=90;
9682 player[i].leftkeydown=0;
9683 player[i].backkeydown=0;
9684 player[i].rightkeydown=0;
9685 player[i].crouchkeydown=0;
9686 player[i].attackkeydown=0;
9688 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9689 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9692 if(player[i].aitype==getweapontype){
9693 player[i].aiupdatedelay-=multiplier;
9694 player[i].lastchecktime-=multiplier;
9696 if(player[i].aiupdatedelay<0){
9697 player[i].aiupdatedelay=.2;
9705 if(player[i].ally<0){
9706 for(j=0;j<weapons.numweapons;j++){
9707 if(weapons.owner[j]==-1){
9708 distance=findDistancefast(&player[i].coords,&weapons.position[j]);
9709 if(closestdist==-1||distance<closestdist){
9710 closestdist=distance;
9716 if(closest!=-1)player[i].ally=closest;
9717 else player[i].ally=-1;
9720 player[i].lastseentime=12;
9722 if(!player[0].dead&&((tutoriallevel!=1||cananger)&&hostile))
9723 if(player[i].ally<0||player[i].weaponactive!=-1||player[i].lastchecktime<=0){
9724 player[i].aitype=attacktypecutoff;
9725 player[i].lastseentime=1;
9728 if(player[i].ally>=0){
9729 if(weapons.owner[player[i].ally]!=-1||findDistancefast(&player[i].coords,&weapons.position[player[i].ally])>16){
9730 player[i].aitype=attacktypecutoff;
9731 player[i].lastseentime=1;
9733 rotatetarget=weapons.position[player[i].ally]-player[i].coords;
9734 Normalise(&rotatetarget);
9735 player[i].targetrotation=-asin(0-rotatetarget.x);
9736 player[i].targetrotation*=360/6.28;
9737 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9738 player[i].lookrotation=player[i].targetrotation;
9739 player[i].aiupdatedelay=.05;
9740 player[i].forwardkeydown=1;
9743 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9744 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9746 XYZ leftpos,rightpos;
9747 float leftdist,rightdist;
9748 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9749 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9750 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9751 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9752 if(leftdist<rightdist)player[i].targetrotation+=90;
9753 else player[i].targetrotation-=90;
9756 /*if(findDistancefast(&player[i].coords,&weapons.position[player[i].ally])<3){
9757 if(abs(Random()%6)){
9758 player[i].crouchkeydown=1;
9759 if(!findDistancefast(&player[i].coords,&weapons.position[player[i].ally])<1){
9760 if(player[i].isRun()){
9761 player[i].targetframe=0;
9763 player[i].targetanimation=sneakanim;
9766 else player[i].forwardkeydown=0;
9768 else player[i].crouchkeydown=0;
9770 else player[i].crouchkeydown=0;*/
9773 player[i].leftkeydown=0;
9774 player[i].backkeydown=0;
9775 player[i].rightkeydown=0;
9776 player[i].attackkeydown=0;
9777 player[i].throwkeydown=1;
9778 player[i].crouchkeydown=0;
9779 if(player[i].targetanimation!=crouchremoveknifeanim&&player[i].targetanimation!=removeknifeanim)player[i].throwtogglekeydown=0;
9780 player[i].drawkeydown=0;
9782 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9783 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9786 if(player[i].aitype==attacktypecutoff){
9787 player[i].aiupdatedelay-=multiplier;
9788 if(player[i].damage<player[i].damagetolerance*2/3)
9789 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)){
9790 player[i].attackkeydown=0;
9791 if(player[i].isIdle())player[i].crouchkeydown=1;
9792 if(player[0].targetanimation!=rabbitkickanim&&player[0].weaponactive!=-1){
9793 if(weapons.type[player[0].weaponids[0]]==knife){
9794 if(player[i].isIdle()||player[i].isCrouch()||player[i].isRun()||player[i].isFlip()){
9795 if(abs(Random()%2==0))player[i].targetanimation=backhandspringanim;
9796 else player[i].targetanimation=rollanim;
9798 player[i].targetframe=0;
9799 player[i].targetrotation+=90*(abs(Random()%2)*2-1);
9800 player[i].wentforweapon=0;
9802 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim){
9803 player[i].targetanimation=flipanim;
9805 player[i].targetframe=0;
9809 player[i].forwardkeydown=0;
9810 player[i].aiupdatedelay=.02;
9812 if(player[0].isFlip()&&!player[0].skeleton.free&&player[0].targetanimation!=walljumprightkickanim&&player[0].targetanimation!=walljumpleftkickanim){
9813 if(findDistancefast(&player[0].coords,&player[i].coords)<25)
9814 if((1-player[i].damage/player[i].damagetolerance)>.5)player[i].stunned=1;
9816 if(player[i].wentforweapon<3)
9817 for(j=0;j<weapons.numweapons;j++){
9818 if(player[i].creature!=wolftype)
9819 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){
9820 if(findDistancefast(&player[i].coords,&weapons.position[j])<16){
9821 player[i].wentforweapon++;
9822 player[i].lastchecktime=6;
9823 player[i].aitype=getweapontype;
9828 if(player[i].damage<player[i].damagetolerance/2)
9829 if(animation[player[i].targetanimation].height!=highheight)
9830 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)))){
9831 player[i].crouchkeydown=1;
9833 if(player[i].isRun()&&!player[i].onground){
9834 if(player[i].coords.y>terrain.getHeight(player[i].coords.x,player[i].coords.z)+10){
9835 test2=player[i].coords+player[i].facing;
9837 test=player[i].coords+player[i].facing;
9839 j=checkcollide(test2,test,player[i].laststanding);
9840 if(j==-1)j=checkcollide(test2,test);
9842 player[i].velocity=0;
9843 player[i].targetanimation=player[i].getStop();
9844 player[i].targetframe=0;
9846 player[i].targetrotation+=180;
9847 player[i].stunned=.5;
9848 //player[i].aitype=passivetype;
9849 player[i].aitype=pathfindtype;
9850 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9851 player[i].finalpathfindpoint=-1;
9852 player[i].targetpathfindpoint=-1;
9853 player[i].lastpathfindpoint=-1;
9854 player[i].lastpathfindpoint2=-1;
9855 player[i].lastpathfindpoint3=-1;
9856 player[i].lastpathfindpoint4=-1;
9858 else player[i].laststanding=j;
9861 if(player[0].coords.y>player[i].coords.y+5&&animation[player[0].targetanimation].height!=highheight&&!player[0].onterrain){
9862 player[i].aitype=pathfindtype;
9863 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9864 player[i].finalpathfindpoint=-1;
9865 player[i].targetpathfindpoint=-1;
9866 player[i].lastpathfindpoint=-1;
9867 player[i].lastpathfindpoint2=-1;
9868 player[i].lastpathfindpoint3=-1;
9869 player[i].lastpathfindpoint4=-1;
9871 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){
9872 if(player[i].weaponactive==-1&&player[i].num_weapons>0)player[i].drawkeydown=Random()%2;
9873 else player[i].drawkeydown=0;
9874 player[i].rabbitkickenabled=Random()%2;
9875 rotatetarget=player[player[i].aitarget].coords+player[player[i].aitarget].velocity;
9876 if(findDistancefast(&player[player[i].aitarget].coords,&player[i].coords)<findDistancefast(&rotatetarget,&player[i].coords))
9877 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;
9878 else rotatetarget=player[player[i].aitarget].coords-player[i].coords;
9879 Normalise(&rotatetarget);
9880 player[i].targetrotation=-asin(0-rotatetarget.x);
9881 player[i].targetrotation*=360/6.28;
9882 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9883 player[i].lookrotation=player[i].targetrotation;
9884 player[i].aiupdatedelay=.2+abs((float)(Random()%100)/1000);
9886 oldkey=player[i].forwardkeydown;
9887 if(findDistancefast(&player[i].coords,&player[0].coords)>5&&(player[0].weaponactive==-1||player[i].weaponactive!=-1))player[i].forwardkeydown=1;
9888 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;
9889 else if(Random()%6==0||(player[i].creature==wolftype&&Random()%3==0))player[i].forwardkeydown=1;
9890 else player[i].forwardkeydown=0;
9892 player[i].forwardkeydown=0;
9893 if(Random()%10==0)player[i].forwardkeydown=1;
9894 if(Random()%100==0){
9895 player[i].aitype=pathfindtype;
9896 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9897 player[i].finalpathfindpoint=-1;
9898 player[i].targetpathfindpoint=-1;
9899 player[i].lastpathfindpoint=-1;
9900 player[i].lastpathfindpoint2=-1;
9901 player[i].lastpathfindpoint3=-1;
9902 player[i].lastpathfindpoint4=-1;
9905 player[i].leftkeydown=0;
9906 player[i].backkeydown=0;
9907 player[i].rightkeydown=0;
9908 player[i].crouchkeydown=0;
9909 player[i].throwkeydown=0;
9911 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9912 /*for(j=0;j<numplayers;j++){
9913 if(player[j].victim->id==i&&(player[j].targetanimation==spinkickanim&&player[j].targetframe<3)){
9914 player[i].crouchkeydown=1;
9917 if(Random()%2==0/*||player[0].weaponactive!=-1*/||player[i].weaponactive!=-1||player[i].creature==wolftype)player[i].attackkeydown=1;
9918 else player[i].attackkeydown=0;
9919 if((player[i].isRun())&&Random()%6&&findDistancefast(&player[i].coords,&player[0].coords)>7)player[i].attackkeydown=0;
9920 //if(player[i].attackkeydown&&findDistancefast(&player[i].coords,&player[0].coords)<3&&player[i].targetanimation!=runanim&&!player[0].skeleton.free)player[i].crouchkeydown=1;
9921 /*if(player[0].targetanimation==rabbitkickanim&&!player[0].skeleton.free){
9922 player[i].attackkeydown=0;
9923 if(player[i].isIdle())player[i].crouchkeydown=1;
9924 player[i].forwardkeydown=0;
9925 player[i].aiupdatedelay=.02;
9928 if(player[i].aitype!=playercontrolled&&(player[i].isIdle()||player[i].isCrouch()||player[i].isRun())){
9930 for(j=0;j<numplayers;j++){
9931 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)){
9932 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))))){
9933 if(target>=0)target=-1;
9938 if(target>=0)player[target].Reverse();
9941 if(player[i].collided<1)player[i].jumpkeydown=0;
9942 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;
9943 if(normaldotproduct(player[i].facing,player[0].coords-player[i].coords)>0)
9944 player[0].jumpkeydown=0;
9945 if(player[0].targetanimation==jumpdownanim&&findDistancefast(&player[0].coords,&player[i].coords)<40)player[i].crouchkeydown=1;
9946 if(player[i].jumpkeydown)player[i].attackkeydown=0;
9947 //if(animation[player[i].targetanimation].attack==reversed)player[i].crouchkeydown=1;
9949 if(tutoriallevel==1){
9950 if(!canattack)player[i].attackkeydown=0;
9954 facing=player[i].coords;
9955 flatfacing=player[0].coords;
9956 facing.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position.y*player[i].scale;
9957 flatfacing.y+=player[0].skeleton.joints[player[0].skeleton.jointlabels[head]].position.y*player[0].scale;
9958 if(player[i].occluded>=2)
9959 if(-1!=checkcollide(facing,flatfacing)){
9960 if(!player[i].pause)player[i].lastseentime-=.2;
9961 if(player[i].lastseentime<=0&&(player[i].creature!=wolftype||player[i].weaponstuck==-1)){
9962 player[i].aitype=searchtype;
9963 player[i].lastchecktime=12;
9964 player[i].lastseen=player[0].coords;
9965 player[i].lastseentime=12;
9968 else player[i].lastseentime=1;
9971 if(animation[player[0].targetanimation].height==highheight&&(player[i].aitype==attacktypecutoff||player[i].aitype==searchtype)){
9972 if(player[0].coords.y>terrain.getHeight(player[0].coords.x,player[0].coords.z)+10){
9973 test=player[0].coords;
9975 if(-1==checkcollide(player[0].coords,test))player[i].stunned=1;
9978 // NOTE: Ask about logic of this call : NOTE
9979 if((player[i].aitype==passivetype && !(player[i].numwaypoints>1)) ||
9980 player[i].stunned>0 ||
9981 (player[i].pause && (player[i].damage > player[i].superpermanentdamage)))
9983 if(/*player[i].aitype==attacktypecutoff&&*/player[i].pause)player[i].lastseentime=1;
9984 player[i].targetrotation=player[i].rotation;
9985 player[i].forwardkeydown=0;
9986 player[i].leftkeydown=0;
9987 player[i].backkeydown=0;
9988 player[i].rightkeydown=0;
9989 player[i].jumpkeydown=0;
9990 player[i].attackkeydown=0;
9991 player[i].crouchkeydown=0;
9992 player[i].throwkeydown=0;
9999 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
10002 if(player[i].aitype==attacktypecutoff){
10003 rotatetarget=player[0].coords-player[i].coords;
10004 Normalise(&rotatetarget);
10005 player[i].targetheadrotation=-asin(0-rotatetarget.x);
10006 player[i].targetheadrotation*=360/6.28;
10007 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
10009 player[i].targetheadrotation*=-1;
10010 player[i].targetheadrotation+=180;
10011 //player[i].targetheadrotation2=0;
10012 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
10014 else if(player[i].howactive>=typesleeping){
10015 player[i].targetheadrotation=player[i].targetrotation;
10016 player[i].targetheadrotation2=0;
10019 if(player[i].interestdelay<=0){
10020 player[i].interestdelay=.7+(float)(abs(Random()%100))/100;
10021 player[i].headtarget=player[i].coords;
10022 player[i].headtarget.x+=(float)(abs(Random()%200)-100)/100;
10023 player[i].headtarget.z+=(float)(abs(Random()%200)-100)/100;
10024 player[i].headtarget.y+=(float)(abs(Random()%200)-100)/300;
10025 player[i].headtarget+=player[i].facing*1.5;
10027 rotatetarget=player[i].headtarget-player[i].coords;
10028 Normalise(&rotatetarget);
10029 player[i].targetheadrotation=-asin(0-rotatetarget.x);
10030 player[i].targetheadrotation*=360/6.28;
10031 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
10033 player[i].targetheadrotation*=-1;
10034 player[i].targetheadrotation+=180;
10035 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
10037 //if(whichlevel==2)player[i].jumpkeydown=0;
10039 if(animation[player[i].targetanimation].attack==reversed){
10040 //player[i].targetrotation=player[i].rotation;
10041 player[i].forwardkeydown=0;
10042 player[i].leftkeydown=0;
10043 player[i].backkeydown=0;
10044 player[i].rightkeydown=0;
10045 player[i].jumpkeydown=0;
10046 player[i].attackkeydown=0;
10047 //player[i].crouchkeydown=0;
10048 player[i].throwkeydown=0;
10051 if(indialogue!=-1){
10052 player[i].forwardkeydown=0;
10053 player[i].leftkeydown=0;
10054 player[i].backkeydown=0;
10055 player[i].rightkeydown=0;
10056 player[i].jumpkeydown=0;
10057 player[i].crouchkeydown=0;
10058 player[i].drawkeydown=0;
10059 player[i].throwkeydown=0;
10062 if(player[i].collided<-.3)player[i].collided=-.3;
10063 if(player[i].collided>1)player[i].collided=1;
10064 player[i].collided-=multiplier*4;
10065 player[i].whichdirectiondelay-=multiplier;
10066 if(player[i].avoidcollided<-.3||player[i].whichdirectiondelay<=0){
10067 player[i].avoidcollided=-.3;
10068 player[i].whichdirection=abs(Random()%2);
10069 player[i].whichdirectiondelay=.4;
10071 if(player[i].avoidcollided>1)player[i].avoidcollided=1;
10072 player[i].avoidcollided-=multiplier/4;
10073 if(!player[i].skeleton.free)player[i].stunned-=multiplier;
10074 if(!player[i].skeleton.free)player[i].surprised-=multiplier;
10075 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;
10077 if(!player[i].throwkeydown){
10078 player[i].throwtogglekeydown=0;
10080 if(player[i].throwkeydown&&!player[i].throwtogglekeydown){
10081 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)){
10082 for(j=0;j<weapons.numweapons;j++){
10083 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)
10084 if(findDistancefastflat(&player[i].coords,&weapons.position[j])<2){
10085 if(findDistancefast(&player[i].coords,&weapons.position[j])<2){
10086 if(player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isRun()||player[i].isIdle()||player[i].aitype!=playercontrolled){
10087 player[i].throwtogglekeydown=1;
10088 player[i].targetanimation=crouchremoveknifeanim;
10089 player[i].target=0;
10090 player[i].targetframe=0;
10091 rotatetarget=weapons.position[j]-player[i].coords;
10092 Normalise(&rotatetarget);
10093 player[i].targetrotation=-asin(0-rotatetarget.x);
10094 player[i].targetrotation*=360/6.28;
10095 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10096 player[i].hasvictim=0;
10098 if(player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
10099 player[i].throwtogglekeydown=1;
10100 player[i].hasvictim=0;
10102 //for(i=0;i<weapons.numweapons;i++){
10103 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))
10104 if(findDistancefastflat(&player[i].coords,&weapons.position[j])<2&&player[i].weaponactive==-1){
10105 if(findDistancefast(&player[i].coords,&weapons.position[j])<1||player[i].victim){
10108 gLoc[0]=player[i].coords.x;
10109 gLoc[1]=player[i].coords.y;
10110 gLoc[2]=player[i].coords.z;
10111 vel[0]=player[i].velocity.x;
10112 vel[1]=player[i].velocity.y;
10113 vel[2]=player[i].velocity.z;
10114 if(weapons.type[j]!=staff){
10115 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, TRUE);
10116 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
10117 FSOUND_SetVolume(channels[knifedrawsound], 128);
10118 FSOUND_SetPaused(channels[knifedrawsound], FALSE);
10121 player[i].weaponactive=0;
10122 weapons.owner[j]=player[i].id;
10123 if(player[i].num_weapons>0){
10124 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
10126 player[i].num_weapons++;
10127 player[i].weaponids[0]=j;
10133 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){
10134 if(!player[i].isFlip()){
10135 player[i].throwtogglekeydown=1;
10136 player[i].targetanimation=removeknifeanim;
10137 player[i].target=0;
10138 player[i].targetframe=0;
10139 rotatetarget=weapons.position[j]-player[i].coords;
10140 Normalise(&rotatetarget);
10141 player[i].targetrotation=-asin(0-rotatetarget.x);
10142 player[i].targetrotation*=360/6.28;
10143 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10145 if(player[i].isFlip()){
10146 player[i].throwtogglekeydown=1;
10147 player[i].hasvictim=0;
10149 for(k=0;k<weapons.numweapons;k++){
10150 if(player[i].weaponactive==-1)
10151 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))
10152 if(findDistancefastflat(&player[i].coords,&weapons.position[k])<3&&player[i].weaponactive==-1){
10155 gLoc[0]=player[i].coords.x;
10156 gLoc[1]=player[i].coords.y;
10157 gLoc[2]=player[i].coords.z;
10158 vel[0]=player[i].velocity.x;
10159 vel[1]=player[i].velocity.y;
10160 vel[2]=player[i].velocity.z;
10161 if(weapons.type[k]!=staff){
10162 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, TRUE);
10163 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
10164 FSOUND_SetVolume(channels[knifedrawsound], 128);
10165 FSOUND_SetPaused(channels[knifedrawsound], FALSE);
10168 player[i].weaponactive=0;
10169 weapons.owner[k]=player[i].id;
10170 if(player[i].num_weapons>0){
10171 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
10173 player[i].num_weapons++;
10174 player[i].weaponids[0]=k;
10181 if(player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isRun()||player[i].isIdle()||player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
10183 for(j=0;j<numplayers;j++){
10184 if(player[i].weaponactive==-1)
10186 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)){
10187 if(player[i].targetanimation!=rollanim&&player[i].targetanimation!=backhandspringanim){
10188 player[i].throwtogglekeydown=1;
10189 player[i].victim=&player[j];
10190 player[i].hasvictim=1;
10191 player[i].targetanimation=crouchremoveknifeanim;
10192 player[i].target=0;
10193 player[i].targetframe=0;
10194 rotatetarget=player[j].coords-player[i].coords;
10195 Normalise(&rotatetarget);
10196 player[i].targetrotation=-asin(0-rotatetarget.x);
10197 player[i].targetrotation*=360/6.28;
10198 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10200 if(player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
10201 player[i].throwtogglekeydown=1;
10202 player[i].victim=&player[j];
10203 player[i].hasvictim=1;
10204 int k = player[j].weaponids[0];
10205 if(player[i].hasvictim){
10208 gLoc[0]=player[i].coords.x;
10209 gLoc[1]=player[i].coords.y;
10210 gLoc[2]=player[i].coords.z;
10211 vel[0]=player[i].velocity.x;
10212 vel[1]=player[i].velocity.y;
10213 vel[2]=player[i].velocity.z;
10216 if(player[i].victim->weaponstuck!=-1){
10217 if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){
10222 if(weapons.type[k]!=staff){
10223 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, TRUE);
10224 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
10225 FSOUND_SetVolume(channels[knifedrawsound], 128);
10226 FSOUND_SetPaused(channels[knifedrawsound], FALSE);
10230 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, TRUE);
10231 FSOUND_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
10232 FSOUND_SetVolume(channels[fleshstabremovesound], 128);
10233 FSOUND_SetPaused(channels[fleshstabremovesound], FALSE);
10236 player[i].weaponactive=0;
10237 if(weapons.owner[k]!=-1){
10238 if(player[i].victim->num_weapons==1)player[i].victim->num_weapons=0;
10239 else player[i].victim->num_weapons=1;
10241 player[i].victim->skeleton.longdead=0;
10242 player[i].victim->skeleton.free=1;
10243 player[i].victim->skeleton.broken=0;
10245 for(int l=0;l<player[i].victim->skeleton.num_joints;l++){
10246 player[i].victim->skeleton.joints[l].velchange=0;
10247 player[i].victim->skeleton.joints[l].locked=0;
10253 Normalise(&relative);
10254 XYZ footvel,footpoint;
10256 footpoint=weapons.position[k];
10257 if(player[i].victim->weaponstuck!=-1){
10258 if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){
10259 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
10260 weapons.bloody[k]=2;
10261 weapons.blooddrip[k]=5;
10262 player[i].victim->weaponstuck=-1;
10263 player[i].victim->bloodloss+=2000;
10264 player[i].victim->DoDamage(2000);
10267 if(player[i].victim->num_weapons>0){
10268 if(player[i].victim->weaponstuck!=0&&player[i].victim->weaponstuck!=-1)player[i].victim->weaponstuck=0;
10269 if(player[i].victim->weaponids[0]==k)
10270 player[i].victim->weaponids[0]=player[i].victim->weaponids[player[i].victim->num_weapons];
10273 player[i].victim->weaponactive=-1;
10275 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[abdomen]].velocity+=relative*6;
10276 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[neck]].velocity+=relative*6;
10277 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6;
10278 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6;
10280 weapons.owner[k]=i;
10281 if(player[i].num_weapons>0){
10282 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
10284 player[i].num_weapons++;
10285 player[i].weaponids[0]=k;
10292 if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){
10293 if(weapons.type[player[i].weaponids[0]]==knife){
10294 if(player[i].isIdle()||player[i].isRun()||player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isFlip())
10296 for(j=0;j<numplayers;j++){
10298 if(tutoriallevel!=1||tutorialstage==49)
10300 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)){
10301 if(!player[i].isFlip()){
10302 player[i].throwtogglekeydown=1;
10303 player[i].victim=&player[j];
10304 player[i].targetanimation=knifethrowanim;
10305 player[i].target=0;
10306 player[i].targetframe=0;
10307 rotatetarget=player[j].coords-player[i].coords;
10308 Normalise(&rotatetarget);
10309 player[i].targetrotation=-asin(0-rotatetarget.x);
10310 player[i].targetrotation*=360/6.28;
10311 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10313 player[i].targettilt2=-asin(rotatetarget.y)*360/6.28;
10315 if(player[i].isFlip()){
10316 if(player[i].weaponactive!=-1){
10317 player[i].throwtogglekeydown=1;
10318 player[i].victim=&player[j];
10320 weapons.owner[player[i].weaponids[0]]=-1;
10321 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);
10324 aim=DoRotation(aim,(float)abs(Random()%30)-15,(float)abs(Random()%30)-15,0);
10326 weapons.velocity[player[i].weaponids[0]]=aim*50;
10327 weapons.tipvelocity[player[i].weaponids[0]]=aim*50;
10328 weapons.missed[player[i].weaponids[0]]=0;
10329 weapons.freetime[player[i].weaponids[0]]=0;
10330 weapons.firstfree[player[i].weaponids[0]]=1;
10331 weapons.physics[player[i].weaponids[0]]=0;
10332 player[i].num_weapons--;
10333 if(player[i].num_weapons){
10334 player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons];
10336 player[i].weaponactive=-1;
10343 if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){
10344 if(player[i].isCrouch()||player[i].targetanimation==sneakanim)
10346 player[i].throwtogglekeydown=1;
10347 weapons.owner[player[i].weaponids[0]]=-1;
10348 weapons.velocity[player[i].weaponids[0]]=player[i].velocity*.2;
10349 if(weapons.velocity[player[i].weaponids[0]].x==0)weapons.velocity[player[i].weaponids[0]].x=.1;
10350 weapons.tipvelocity[player[i].weaponids[0]]=weapons.velocity[player[i].weaponids[0]];
10351 weapons.missed[player[i].weaponids[0]]=1;
10352 weapons.freetime[player[i].weaponids[0]]=0;
10353 weapons.firstfree[player[i].weaponids[0]]=1;
10354 weapons.physics[player[i].weaponids[0]]=1;
10355 player[i].num_weapons--;
10356 if(player[i].num_weapons){
10357 player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons];
10358 if(player[i].weaponstuck==player[i].num_weapons)player[i].weaponstuck=0;
10361 player[i].weaponactive=-1;
10362 for(j=0;j<numplayers;j++){
10363 player[j].wentforweapon=0;
10370 if(i==0||!player[0].dead||player[i].weaponactive!=-1)
10371 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)){
10372 //Setenvironment(1-environment);
10375 if(player[i].weaponactive!=-1){
10376 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==staff)isgood=0;
10378 if(/*(player[i].weaponactive==-1||player[i].num_weapons==1)&&*/isgood&&player[i].creature!=wolftype){
10379 if(player[i].isIdle()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){
10380 player[i].targetanimation=drawrightanim;
10381 player[i].targetframe=0;
10382 player[i].target=0;
10383 player[i].drawtogglekeydown=1;
10385 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){
10386 player[i].targetanimation=drawleftanim;
10387 player[i].targetframe=0;
10388 player[i].target=0;
10389 player[i].drawtogglekeydown=1;
10391 if(player[i].isCrouch()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){
10392 player[i].targetanimation=crouchdrawrightanim;
10393 player[i].targetframe=0;
10394 player[i].target=0;
10395 player[i].drawtogglekeydown=1;
10399 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){
10400 if(weapons.bloody[player[i].weaponids[player[i].weaponactive]]&&player[i].onterrain&&bloodtoggle&&musictype!=stream_music2){
10401 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==knife)player[i].targetanimation=crouchstabanim;
10402 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==sword)player[i].targetanimation=swordgroundstabanim;
10403 player[i].targetframe=0;
10404 player[i].target=0;
10405 player[i].hasvictim=0;
10406 //player[i].attacktogglekeydown=1;
10410 if(!player[i].drawkeydown){
10411 player[i].drawtogglekeydown=0;
10416 absflatfacing.z=-1;
10418 absflatfacing=DoRotation(absflatfacing,0,-rotation,0);
10420 else absflatfacing=flatfacing;
10422 if(indialogue!=-1){
10423 player[i].forwardkeydown=0;
10424 player[i].leftkeydown=0;
10425 player[i].backkeydown=0;
10426 player[i].rightkeydown=0;
10427 player[i].jumpkeydown=0;
10428 player[i].crouchkeydown=0;
10429 player[i].drawkeydown=0;
10430 player[i].throwkeydown=0;
10434 if(!animation[player[i].targetanimation].attack&&player[i].targetanimation!=staggerbackhighanim&&player[i].targetanimation!=staggerbackhardanim&&player[i].targetanimation!=backhandspringanim&&player[i].targetanimation!=dodgebackanim){
10435 if(!player[i].forwardkeydown){
10436 player[i].forwardstogglekeydown=0;
10438 if(player[i].crouchkeydown){
10442 player[i].superruntoggle=1;
10444 for(j=0;j<numplayers;j++){
10445 if(j!=i&&!player[j].skeleton.free&&player[j].aitype==passivetype){
10446 if(findDistancefast(&player[j].coords,&player[i].coords)<16){
10447 player[i].superruntoggle=0;
10454 for(j=0;j<numplayers;j++){
10455 if(j!=i&&!player[j].skeleton.free&&player[j].victim&&player[i].lowreversaldelay<=0){
10456 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))){
10457 if(target>=0)target=-1;
10462 if(target>=0)player[target].Reverse();
10463 player[i].lowreversaldelay=.5;
10465 if(player[i].isIdle()){
10466 player[i].targetanimation=player[i].getCrouch();
10467 player[i].target=0;
10468 player[i].targetframe=0;
10469 player[i].transspeed=10;
10471 if(player[i].isRun()||(player[i].isStop()&&(player[i].leftkeydown||player[i].rightkeydown||player[i].forwardkeydown||player[i].backkeydown))){
10472 player[i].targetanimation=rollanim;
10473 player[i].target=0;
10474 player[i].targetframe=0;
10475 player[i].transspeed=20;
10478 if(!player[i].crouchkeydown){
10480 if(!player[i].isRun()&&player[i].targetanimation!=sneakanim&&i==0)player[i].superruntoggle=0;
10482 if(player[i].isCrouch()){
10484 for(j=0;j<numplayers;j++){
10485 if(j!=i&&!player[j].skeleton.free&&player[j].victim&&player[i].highreversaldelay<=0){
10486 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<3&&player[j].victim==&player[i]&&(player[j].targetanimation==spinkickanim)&&player[i].isCrouch()){
10487 if(target>=0)target=-1;
10492 if(target>=0)player[target].Reverse();
10493 player[i].highreversaldelay=.5;
10495 if(player[i].isCrouch()){
10496 if(!player[i].wasCrouch()){
10497 player[i].currentanimation=player[i].getCrouch();
10498 player[i].currentframe=0;
10500 player[i].target=0;
10501 player[i].targetanimation=player[i].getIdle();
10502 player[i].targetframe=0;
10503 player[i].transspeed=10;
10506 if(player[i].targetanimation==sneakanim){
10507 player[i].targetanimation=player[i].getIdle();
10508 player[i].target=0;
10509 player[i].targetframe=0;
10510 player[i].transspeed=10;
10513 if(player[i].forwardkeydown){
10514 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)){
10515 if(player[i].aitype==passivetype)player[i].targetanimation=walkanim;
10516 else player[i].targetanimation=player[i].getRun();
10517 player[i].target=0;
10518 player[i].targetframe=0;
10520 if(player[i].isCrouch()){
10521 player[i].targetanimation=sneakanim;
10522 if(player[i].wasCrouch())player[i].target=0;
10523 player[i].targetframe=0;
10525 if(player[i].targetanimation==hanganim/*&&(!player[i].forwardstogglekeydown||player[i].aitype!=playercontrolled)*/){
10526 player[i].targetanimation=climbanim;
10527 player[i].target=0;
10528 player[i].targetframe=1;
10529 player[i].jumpclimb=1;
10531 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10532 player[i].velocity+=absflatfacing*5*multiplier;
10534 player[i].forwardstogglekeydown=1;
10537 if (player[i].rightkeydown){
10538 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)){
10539 player[i].targetanimation=player[i].getRun();
10540 player[i].target=0;
10541 player[i].targetframe=0;
10543 if(player[i].isCrouch()){
10544 player[i].targetanimation=sneakanim;
10545 if(player[i].wasCrouch()) player[i].target=0;
10546 player[i].targetframe=0;
10548 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10549 player[i].velocity+=DoRotation(absflatfacing*5*multiplier,0,-90,0);
10551 player[i].targetrotation-=90;
10552 if(player[i].forwardkeydown)player[i].targetrotation+=45;
10553 if(player[i].backkeydown)player[i].targetrotation-=45;
10556 if ( player[i].leftkeydown){
10557 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)){
10558 player[i].targetanimation=player[i].getRun();
10559 player[i].target=0;
10560 player[i].targetframe=0;
10562 if(player[i].isCrouch()){
10563 player[i].targetanimation=sneakanim;
10564 if(player[i].wasCrouch())player[i].target=0;
10565 player[i].targetframe=0;
10567 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10568 player[i].velocity-=DoRotation(absflatfacing*5*multiplier,0,-90,0);
10570 player[i].targetrotation+=90;
10571 if(player[i].forwardkeydown)player[i].targetrotation-=45;
10572 if(player[i].backkeydown)player[i].targetrotation+=45;
10575 if(player[i].backkeydown){
10576 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)){
10577 player[i].targetanimation=player[i].getRun();
10578 player[i].target=0;
10579 player[i].targetframe=0;
10581 if(player[i].isCrouch()){
10582 player[i].targetanimation=sneakanim;
10583 if(player[i].wasCrouch())player[i].target=0;
10584 player[i].targetframe=0;
10586 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10587 player[i].velocity-=absflatfacing*5*multiplier;
10589 if(player[i].targetanimation==hanganim){
10590 player[i].currentanimation=jumpdownanim;
10591 player[i].targetanimation=jumpdownanim;
10592 player[i].target=0;
10593 player[i].currentframe=0;
10594 player[i].targetframe=1;
10595 player[i].velocity=0;
10596 player[i].velocity.y+=gravity;
10597 player[i].coords.y-=1.4;
10598 player[i].grabdelay=1;
10600 if ( !player[i].leftkeydown&&!player[i].rightkeydown)
10601 player[i].targetrotation+=180;
10604 if((player[i].jumpkeydown&&!player[i].jumpclimb)||player[i].jumpstart){
10605 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)){
10606 player[i].jumpstart=0;
10607 player[i].targetanimation=jumpupanim;
10608 player[i].target=0;
10609 player[i].targetframe=0;
10610 player[i].rotation=player[i].targetrotation;
10611 player[i].transspeed=20;
10612 player[i].FootLand(0,1);
10613 player[i].FootLand(1,1);
10617 flatfacing=DoRotation(facing,0,player[i].targetrotation+180,0);
10619 if(movekey)player[i].velocity=flatfacing*player[i].speed*45*player[i].scale;
10620 if(!movekey)player[i].velocity=0;
10625 for(j=0;j<numplayers;j++){
10626 if(j!=i&&!player[j].skeleton.free&&player[j].victim){
10627 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<3&&player[j].victim==&player[i]&&(player[j].targetanimation==sweepanim)){
10628 if(target>=0)target=-1;
10633 if(target>=0)player[i].velocity.y=1;
10634 else if(player[i].crouchkeydown||player[i].aitype!=playercontrolled){
10635 player[i].velocity.y=7;
10636 player[i].crouchtogglekeydown=1;
10638 else player[i].velocity.y=5;
10640 if(mousejump&&i==0&&debugmode){
10641 if(!player[i].isLanding())player[i].tempdeltav=deltav;
10642 if(player[i].tempdeltav<0)player[i].velocity.y-=(float)(player[i].tempdeltav)/multiplier/1000;
10645 player[i].coords.y+=.2;
10646 player[i].jumppower-=1;
10648 static float gLoc[3];
10649 static float vel[3];
10650 gLoc[0]=player[i].coords.x;
10651 gLoc[1]=player[i].coords.y;
10652 gLoc[2]=player[i].coords.z;
10653 vel[0]=player[i].velocity.x;
10654 vel[1]=player[i].velocity.y;
10655 vel[2]=player[i].velocity.z;
10658 PlaySoundEx( whooshsound, samp[whooshsound], NULL, TRUE);
10659 FSOUND_3D_SetAttributes(channels[whooshsound], gLoc, vel);
10660 FSOUND_SetVolume(channels[whooshsound], 128);
10661 FSOUND_SetPaused(channels[whooshsound], FALSE);
10664 PlaySoundEx( jumpsound, samp[jumpsound], NULL, TRUE);
10665 FSOUND_3D_SetAttributes(channels[jumpsound], gLoc, vel);
10666 FSOUND_SetVolume(channels[jumpsound], 128);
10667 FSOUND_SetPaused(channels[jumpsound], FALSE);
10669 if((player[i].isIdle())&&player[i].jumppower>1){
10670 player[i].targetanimation=player[i].getLanding();
10671 player[i].landhard=0;
10672 player[i].target=0;
10673 player[i].targetframe=2;
10674 player[i].jumpstart=1;
10675 player[i].tempdeltav=deltav;
10677 if(player[i].targetanimation==jumpupanim&&(((!floatjump&&!editorenabled)||!debugmode)||player[i].aitype!=playercontrolled)){
10678 if(player[i].jumppower>multiplier*6){
10679 player[i].velocity.y+=multiplier*6;
10680 player[i].jumppower-=multiplier*6;
10682 if(player[i].jumppower<=multiplier*6){
10683 player[i].velocity.y+=player[i].jumppower;
10684 player[i].jumppower=0;
10687 if(((floatjump||editorenabled)&&debugmode)&&i==0)player[i].velocity.y+=multiplier*30;
10691 if(player[i].isRun()||player[i].targetanimation==walkanim){
10692 player[i].targetanimation=player[i].getStop();
10693 player[i].target=0;
10694 player[i].targetframe=0;
10696 if(player[i].targetanimation==sneakanim){
10697 player[i].targetanimation=player[i].getCrouch();
10698 if(player[i].currentanimation==sneakanim)player[i].target=0;
10699 player[i].targetframe=0;
10702 if(player[i].targetanimation==walkanim&&(player[i].aitype==attacktypecutoff||player[i].aitype==searchtype||(player[i].aitype==passivetype&&player[i].numwaypoints<=1))){
10703 player[i].targetanimation=player[i].getStop();
10704 player[i].target=0;
10705 player[i].targetframe=0;
10707 if(player[i].isRun()&&(player[i].aitype==passivetype)){
10708 player[i].targetanimation=player[i].getStop();
10709 player[i].target=0;
10710 player[i].targetframe=0;
10714 if(player[i].targetanimation==rollanim)player[i].targetrotation=oldtargetrotation;
10718 for(k=0;k<numplayers;k++){
10719 if(abs(player[k].rotation-player[k].targetrotation)>180){
10720 if(player[k].rotation>player[k].targetrotation)player[k].rotation-=360;
10721 else player[k].rotation+=360;
10724 if(abs(player[k].rotation-player[k].targetrotation)>90&&(player[k].isRun()||player[k].targetanimation==walkanim)){
10725 player[k].targetanimation=player[k].getStop();
10726 player[k].targetframe=0;
10727 player[k].target=0;
10730 if(player[k].targetanimation==backhandspringanim||player[k].targetanimation==dodgebackanim){
10731 player[k].targettilt=0;
10733 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=backhandspringanim&&player[k].targetanimation!=jumpdownanim&&!player[k].isFlip()){
10734 player[k].targettilt=0;
10735 if(player[k].jumppower<0&&!player[k].jumpkeydown)player[k].jumppower=0;
10736 player[k].jumppower+=multiplier*7;
10737 if(player[k].isCrouch())player[k].jumppower+=multiplier*7;
10738 //*(1-(player[k].damage/player[k].damagetolerance))
10739 if(player[k].jumppower>5)player[k].jumppower=5;
10742 if(player[k].isRun()){
10743 player[k].targettilt=(player[k].rotation-player[k].targetrotation)/4;
10746 if(abs(player[k].tilt-player[k].targettilt)<multiplier*150)player[k].tilt=player[k].targettilt;
10747 else if(player[k].tilt>player[k].targettilt){
10748 player[k].tilt-=multiplier*150;
10750 else if(player[k].tilt<player[k].targettilt){
10751 player[k].tilt+=multiplier*150;
10754 player[k].grabdelay-=multiplier;
10757 for(k=0;k<numplayers;k++){
10758 player[k].DoAnimations();
10759 player[k].whichpatchx=player[k].coords.x/(terrain.size/subdivision*terrain.scale*terraindetail);
10760 player[k].whichpatchz=player[k].coords.z/(terrain.size/subdivision*terrain.scale*terraindetail);
10765 player[0].righthandmorphstart=0;
10766 player[0].righthandmorphend=1;
10767 player[0].lefthandmorphstart=0;
10768 player[0].lefthandmorphend=1;
10769 player[0].headmorphstart=0;
10770 player[0].headmorphend=2;*/
10773 if(IsKeyDown( theKeyMap, MAC_P_KEY )){
10774 if(player[0].righthandmorphend!=1)player[0].righthandmorphness=0;
10775 player[0].righthandmorphend=1;
10776 player[0].targetrighthandmorphness=1;
10778 if(player[0].lefthandmorphend!=0)player[0].lefthandmorphness=0;
10779 player[0].lefthandmorphend=0;
10780 player[0].targetlefthandmorphness=1;
10782 if(player[0].headmorphend!=2)player[0].headmorphness=0;
10783 player[0].headmorphend=2;
10784 player[0].targetheadmorphness=1;
10786 if(IsKeyDown( theKeyMap, MAC_L_KEY )){
10787 if(player[0].righthandmorphend!=0)player[0].righthandmorphness=0;
10788 player[0].righthandmorphend=0;
10789 player[0].targetrighthandmorphness=1;
10791 if(player[0].lefthandmorphend!=1)player[0].lefthandmorphness=0;
10792 player[0].lefthandmorphend=1;
10793 player[0].targetlefthandmorphness=1;
10795 if(player[0].headmorphend!=0)player[0].headmorphness=0;
10796 player[0].headmorphend=0;
10797 player[0].targetheadmorphness=1;
10800 if(numenvsounds!=0)
10801 for(j=numenvsounds-1;j>=0;j--){
10802 envsoundlife[j]-=multiplier;
10803 if(envsoundlife[j]<0){
10805 envsoundlife[j]=envsoundlife[numenvsounds];
10806 envsound[j]=envsound[numenvsounds];
10809 if(!slomo)FSOUND_SetFrequency(FSOUND_ALL, 22050);
10810 if(slomo)FSOUND_SetFrequency(FSOUND_ALL, slomofreq);
10812 if(tutoriallevel==1){
10829 if(tutorialstage>=51)
10830 if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
10831 FSOUND_StopSound(FSOUND_ALL); // hack...OpenAL renderer isn't stopping music after tutorial goes to level menu...
10832 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
10834 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
10835 FSOUND_SetPaused(channels[stream_music3], FALSE);
10836 FSOUND_SetVolume(channels[stream_music3], 256);
10841 float gLoc[3]={0,0,0};
10842 float vel[3]={0,0,0};
10843 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10844 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
10845 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10846 FSOUND_SetVolume(channels[fireendsound], 256);
10847 FSOUND_SetPaused(channels[fireendsound], FALSE);
10848 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
10856 if(tutorialstage<51)
10857 if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
10860 gLoc[0]=player[0].coords.x;
10861 gLoc[1]=player[0].coords.y;
10862 gLoc[2]=player[0].coords.z;
10866 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
10867 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10868 FSOUND_SetVolume(channels[fireendsound], 256);
10869 FSOUND_SetPaused(channels[fireendsound], FALSE);
10871 player[0].coords=(oldtemp+oldtemp2)/2;
10879 if(tutorialstage>=14&&tutorialstage<50)
10880 if(findDistancefast(&temp,&player[1].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[1].coords)<4){
10883 gLoc[0]=player[1].coords.x;
10884 gLoc[1]=player[1].coords.y;
10885 gLoc[2]=player[1].coords.z;
10889 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
10890 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10891 FSOUND_SetVolume(channels[fireendsound], 256);
10892 FSOUND_SetPaused(channels[fireendsound], FALSE);
10894 for(int i=0;i<player[1].skeleton.num_joints;i++){
10896 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
10897 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
10898 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;
10899 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
10900 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
10904 player[1].coords=(oldtemp+oldtemp2)/2;
10905 for(int i=0;i<player[1].skeleton.num_joints;i++){
10906 player[1].skeleton.joints[i].velocity=0;
10908 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
10909 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
10910 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;
10911 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
10912 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
10920 static float gLoc[3];
10924 static float vel[3];
10925 vel[0]=(viewer.x-oldviewer.x)/multiplier;
10926 vel[1]=(viewer.y-oldviewer.y)/multiplier;
10927 vel[2]=(viewer.z-oldviewer.z)/multiplier;
10929 //Set orientation with forward and up vectors
10930 static XYZ upvector;
10934 upvector=DoRotation(upvector,-rotation2+90,0,0);
10935 upvector=DoRotation(upvector,0,0-rotation,0);
10940 facing=DoRotation(facing,-rotation2,0,0);
10941 facing=DoRotation(facing,0,0-rotation,0);
10944 static float ori[6];
10945 ori[0] = -facing.x;
10947 ori[2] = -facing.z;
10948 ori[3] = -upvector.x;
10949 ori[4] = upvector.y;
10950 ori[5] = -upvector.z;
10952 FSOUND_3D_Listener_SetAttributes(&gLoc[0], &vel[0], ori[0], ori[1], ori[2], ori[3], ori[4], ori[5]);
10959 if(IsKeyDown(theKeyMap, MAC_F1_KEY)&&!freezetogglekeydown){
10961 freezetogglekeydown=1;
10965 void Game::TickOnce(){
10968 if(directing||indialogue==-1){
10969 rotation+=deltah*.7;
10970 if(!invertmouse)rotation2+=deltav*.7;
10971 if(invertmouse)rotation2-=deltav*.7;
10972 if(rotation2>90)rotation2=90;
10973 if(rotation2<-70)rotation2=-70;
10975 if(mainmenu)rotation+=multiplier*5;
10976 if(!mainmenu&&!indemo&&!registered){
10977 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
10978 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
10979 FSOUND_SetPaused(channels[stream_music3], FALSE);
10980 FSOUND_SetVolume(channels[stream_music3], 256);
10985 float gLoc[3]={0,0,0};
10986 float vel[3]={0,0,0};
10987 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10988 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
10989 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10990 FSOUND_SetVolume(channels[fireendsound], 256);
10991 FSOUND_SetPaused(channels[fireendsound], FALSE);
10992 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
11001 if(tryquit==1&&!registered&&mainmenu!=12){
11002 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
11003 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
11004 FSOUND_SetPaused(channels[stream_music3], FALSE);
11005 FSOUND_SetVolume(channels[stream_music3], 256);
11010 float gLoc[3]={0,0,0};
11011 float vel[3]={0,0,0};
11012 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
11013 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
11014 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
11015 FSOUND_SetVolume(channels[fireendsound], 256);
11016 FSOUND_SetPaused(channels[fireendsound], FALSE);
11017 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
11028 void Game::TickOnceAfter(){
11029 static XYZ colviewer;
11030 static XYZ coltarget;
11033 static float brotate;
11036 static float changedelay;
11037 static bool alldead;
11038 static float unseendelay;
11039 static float cameraspeed;
11043 if(environment==snowyenvironment)music1=stream_music1snow;
11044 if(environment==grassyenvironment)music1=stream_music1grass;
11045 if(environment==desertenvironment)music1=stream_music1desert;
11050 for(i=0;i<numplayers;i++){
11051 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)){
11052 musictype=stream_music2;
11056 if(player[0].dead)musictype=stream_music3;
11059 if(musictype==stream_music2){
11063 if(oldmusictype==stream_music2&&musictype!=stream_music2){
11064 unseendelay-=multiplier;
11066 musictype=stream_music2;
11072 musictype=stream_music3;
11073 musicvolume[2]=512;
11080 if(musictype!=oldmusictype&&musictype==stream_music2){
11081 static float gLoc[3];
11082 static float vel[3];
11083 gLoc[0]=cameraloc.x;
11084 gLoc[1]=cameraloc.y;
11085 gLoc[2]=cameraloc.z;
11089 PlaySoundEx( alarmsound, samp[alarmsound], NULL, TRUE);
11090 FSOUND_SetVolume(channels[alarmsound], 512);
11091 FSOUND_SetPaused(channels[alarmsound], FALSE);
11095 musicselected=musictype;
11097 if(musicselected==music1)musicvolume[0]+=multiplier*450;
11098 else musicvolume[0]-=multiplier*450;
11099 if(musicselected==stream_music2)musicvolume[1]+=multiplier*450;
11100 else musicvolume[1]-=multiplier*450;
11101 if(musicselected==stream_music3)musicvolume[2]+=multiplier*450;
11102 else musicvolume[2]-=multiplier*450;
11104 if(musicselected==music1)musicvolume[0]+=multiplier*100;
11105 else musicvolume[0]-=multiplier*450;
11106 if(musicselected==music2)musicvolume[1]+=multiplier*150;
11107 else if(player[0].dead)musicvolume[1]-=multiplier*450;
11108 else musicvolume[1]-=multiplier*100;
11109 if(musicselected==music3)musicvolume[2]+=multiplier*450;
11110 else musicvolume[2]-=multiplier*450;*/
11113 if(musicvolume[i]<0)musicvolume[i]=0;
11114 if(musicvolume[i]>512)musicvolume[i]=512;
11117 if(musicvolume[2]>128&&!loading&&!mainmenu)musicvolume[2]=128;
11120 if(musicvolume[0]>0&&oldmusicvolume[0]<=0){
11121 PlayStreamEx( music1, strm[music1], NULL, TRUE);
11122 FSOUND_SetPaused(channels[music1], FALSE);
11124 if(musicvolume[1]>0&&oldmusicvolume[1]<=0){
11125 PlayStreamEx( stream_music2, strm[stream_music2], NULL, TRUE);
11126 FSOUND_SetPaused(channels[stream_music2], FALSE);
11128 if(musicvolume[2]>0&&oldmusicvolume[2]<=0){
11129 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
11130 FSOUND_SetPaused(channels[stream_music3], FALSE);
11135 FSOUND_SetPaused(channels[music1], TRUE);
11136 FSOUND_SetPaused(channels[stream_music2], TRUE);
11137 FSOUND_SetPaused(channels[stream_music3], TRUE);
11140 oldmusicvolume[i]=0;
11146 if(musicvolume[0]<=0&&oldmusicvolume[0]>0){
11147 FSOUND_SetPaused(channels[music1], TRUE);
11149 if(musicvolume[1]<=0&&oldmusicvolume[1]>0){
11150 FSOUND_SetPaused(channels[stream_music2], TRUE);
11152 if(musicvolume[2]<=0&&oldmusicvolume[2]>0){
11153 FSOUND_SetPaused(channels[stream_music3], TRUE);
11156 if(musicvolume[0]!=oldmusicvolume[0]){
11157 FSOUND_SetVolume(channels[music1], musicvolume[0]);
11159 if(musicvolume[1]!=oldmusicvolume[1]){
11160 FSOUND_SetVolume(channels[stream_music2], musicvolume[1]);
11162 if(musicvolume[2]!=oldmusicvolume[2]){
11163 FSOUND_SetVolume(channels[stream_music3], musicvolume[2]);
11167 oldmusicvolume[i]=musicvolume[i];
11173 for(i=0;i<numhotspots;i++){
11174 if(hotspottype[i]>10&&hotspottype[i]<20){
11175 if(player[hotspottype[i]-10].dead==0){
11178 else if(killhotspot==2)
11182 if(killhotspot==2)killhotspot=0;
11187 for(i=0;i<numhotspots;i++){
11188 if(hotspottype[i]==-1){
11189 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i])
11196 for(i=1;i<numplayers;i++){
11197 if(!player[i].dead&&player[i].aitype==attacktypecutoff&&player[i].surprised<=0)numalarmed++;
11199 if(numalarmed>maxalarmed)maxalarmed=numalarmed;
11201 if(changedelay<=0&&!loading&&!editorenabled&&gameon&&!tutoriallevel&&changedelay!=-999&&!won){
11202 if(player[0].dead&&changedelay<=0){
11204 targetlevel=whichlevel;
11208 for(i=1;i<numplayers;i++){
11209 if(!player[i].dead&&player[i].howactive<typedead1)alldead=0;
11213 if(alldead&&!player[0].dead&&maptype==mapkilleveryone){
11215 targetlevel=whichlevel+1;
11216 if(targetlevel>numchallengelevels-1)targetlevel=0;
11218 if(winhotspot||windialogue){
11220 targetlevel=whichlevel+1;
11221 if(targetlevel>numchallengelevels-1)targetlevel=0;
11227 targetlevel=whichlevel+1;
11228 if(targetlevel>numchallengelevels-1)targetlevel=0;
11231 if(changedelay>0&&!player[0].dead&&!won){
11232 //high scores, awards, win
11235 accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
11236 accountcampaignchoicesmade[accountactive]++;
11237 accountcampaignscore[accountactive]+=bonustotal;
11239 accountcampaigntime[accountactive]+=leveltime;
11240 if(accountcampaignscore[accountactive]>accountcampaignhighscore[accountactive])accountcampaignhighscore[accountactive]=accountcampaignscore[accountactive];
11242 //if(accountprogress[accountactive]<whichlevel+1)accountprogress[accountactive]=whichlevel+1;
11248 if(bonustotal-startbonustotal>accounthighscore[accountactive][whichlevel])accounthighscore[accountactive][whichlevel]=bonustotal-startbonustotal;
11249 if(accountfasttime[accountactive][whichlevel]==0||leveltime<accountfasttime[accountactive][whichlevel])accountfasttime[accountactive][whichlevel]=leveltime;
11251 if(accountprogress[accountactive]<whichlevel+1)accountprogress[accountactive]=whichlevel+1;
11267 if(!editorenabled&&gameon&&!mainmenu){
11268 if(changedelay!=-999)changedelay-=multiplier/7;
11269 if(player[0].dead)targetlevel=whichlevel;
11270 if(loading==2&&!campaign){
11278 float gLoc[3]={0,0,0};
11279 float vel[3]={0,0,0};
11280 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
11281 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
11282 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
11283 FSOUND_SetVolume(channels[firestartsound], 256);
11284 FSOUND_SetPaused(channels[firestartsound], FALSE);
11285 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
11287 if(!player[0].dead&&targetlevel!=whichlevel){
11288 startbonustotal=bonustotal;
11290 if(!player[0].dead)Loadlevel(targetlevel);
11291 if(player[0].dead)Loadlevel(whichlevel);
11293 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
11294 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
11295 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
11296 FSOUND_SetVolume(channels[fireendsound], 256);
11297 FSOUND_SetPaused(channels[fireendsound], FALSE);
11298 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
11302 if(loading==2&&targetlevel==whichlevel){
11310 float gLoc[3]={0,0,0};
11311 float vel[3]={0,0,0};
11312 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
11313 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
11314 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
11315 FSOUND_SetVolume(channels[firestartsound], 256);
11316 FSOUND_SetPaused(channels[firestartsound], FALSE);
11317 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
11319 for(i=0;i<255;i++){
11333 strcat(mapname,campaignmapname[levelorder[accountcampaignchoicesmade[accountactive]]]);//[campaignchoicewhich[whichchoice]]);
11334 Loadlevel(mapname);
11336 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
11337 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
11338 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
11339 FSOUND_SetVolume(channels[fireendsound], 256);
11340 FSOUND_SetPaused(channels[fireendsound], FALSE);
11341 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
11345 if(changedelay<=-999&&whichlevel!=-2&&!loading&&(player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(killhotspot))&&!winfreeze)loading=1;
11346 if((player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(windialogue)||(killhotspot))&&changedelay<=0){
11347 if(accountprogress[accountactive]>3&&!registered){
11348 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
11349 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
11350 FSOUND_SetPaused(channels[stream_music3], FALSE);
11351 FSOUND_SetVolume(channels[stream_music3], 256);
11355 accountprogress[accountactive]=3;
11357 float gLoc[3]={0,0,0};
11358 float vel[3]={0,0,0};
11359 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
11360 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
11361 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
11362 FSOUND_SetVolume(channels[fireendsound], 256);
11363 FSOUND_SetPaused(channels[fireendsound], FALSE);
11364 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
11373 if(whichlevel!=-2&&!loading&&!player[0].dead){
11377 if(player[0].dead)loading=1;
11383 if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1){
11384 if(campaignnumnext[campaignchoicewhich[whichchoice]]==0){
11388 else if(mainmenu==0&&winfreeze){
11389 if(campaignchoosenext[campaignchoicewhich[whichchoice]]==2)
11391 else stealthloading=0;
11393 if(!stealthloading){
11394 float gLoc[3]={0,0,0};
11395 float vel[3]={0,0,0};
11396 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
11397 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
11398 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
11399 FSOUND_SetVolume(channels[firestartsound], 256);
11400 FSOUND_SetPaused(channels[firestartsound], FALSE);
11401 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
11412 ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
11413 //campaignnumlevels=0;
11414 //accountcampaignchoicesmade[accountactive]=0;
11415 ipstream.ignore(256,':');
11416 ipstream >> campaignnumlevels;
11417 for(i=0;i<campaignnumlevels;i++){
11418 ipstream.ignore(256,':');
11419 ipstream.ignore(256,':');
11420 ipstream.ignore(256,' ');
11421 ipstream >> campaignmapname[i];
11422 ipstream.ignore(256,':');
11423 ipstream >> campaigndescription[i];
11424 for(j=0;j<256;j++){
11425 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
11427 ipstream.ignore(256,':');
11428 ipstream >> campaignchoosenext[i];
11429 ipstream.ignore(256,':');
11430 ipstream >> campaignnumnext[i];
11431 if(campaignnumnext[i])
11432 for(j=0;j<campaignnumnext[i];j++){
11433 ipstream.ignore(256,':');
11434 ipstream >> campaignnextlevel[i][j];
11435 campaignnextlevel[i][j]-=1;
11437 ipstream.ignore(256,':');
11438 ipstream >> campaignlocationx[i];
11439 ipstream.ignore(256,':');
11440 ipstream >> campaignlocationy[i];
11444 for(i=0;i<campaignnumlevels;i++){
11446 levelhighlight[i]=0;
11450 for(i=0;i<campaignnumlevels;i++){
11452 levelhighlight[i]=0;
11457 if(accountcampaignchoicesmade[accountactive])
11458 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
11459 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
11460 levelvisible[levelorder[i+1]]=1;
11462 int whichlevelstart;
11463 whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
11464 if(whichlevelstart<0){
11465 campaignchoicenum=1;
11466 campaignchoicewhich[0]=0;
11470 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
11471 if(campaignchoicenum)
11472 for(i=0;i<campaignchoicenum;i++){
11473 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
11474 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
11475 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
11482 //if(firstload)TickOnceAfter();
11483 if(!firstload)LoadStuff();
11485 for(i=0;i<255;i++){
11500 //accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
11501 //accountcampaignchoicesmade[accountactive]++;
11504 strcat(mapname,campaignmapname[campaignchoicewhich[0]]);
11508 Loadlevel(mapname);
11512 FSOUND_SetPaused(channels[stream_music3], TRUE);
11517 if(loading==3)loading=0;
11521 oldmusictype=musictype;
11527 facing=DoRotation(facing,-rotation2,0,0);
11528 facing=DoRotation(facing,0,0-rotation,0);
11529 viewerfacing=facing;
11533 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;
11534 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;
11536 if(player[0].skeleton.free){
11537 for(i=0;i<player[0].skeleton.num_joints;i++){
11538 if(player[0].skeleton.joints[i].position.y*player[0].scale+player[0].coords.y>target.y)
11539 target.y=player[0].skeleton.joints[i].position.y*player[0].scale+player[0].coords.y;
11543 if(player[0].skeleton.free!=2&&!autocam){
11545 if(findLengthfast(&player[0].velocity)>400){
11546 cameraspeed=20+(findLength(&player[0].velocity)-20)*.96;
11548 if(player[0].skeleton.free==0&&player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim)target.y+=1.4;
11549 coltarget=target-cameraloc;
11550 if(findLengthfast(&coltarget)<multiplier*multiplier*400)cameraloc=target;
11552 Normalise(&coltarget);
11553 if(player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim&&player[0].currentanimation!=climbanim&&player[0].currentoffset.x==0)cameraloc=cameraloc+coltarget*multiplier*cameraspeed;
11554 else cameraloc=cameraloc+coltarget*multiplier*8;
11556 if(editorenabled)cameraloc=target;
11557 cameradist+=multiplier*5;
11558 if(cameradist>2.3)cameradist=2.3;
11559 viewer=cameraloc-facing*cameradist;
11561 coltarget=cameraloc;
11562 objects.SphereCheckPossible(&colviewer, findDistance(&colviewer,&coltarget));
11563 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11564 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11565 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11567 coltarget=cameraloc;
11568 if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;
11570 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11571 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11572 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11574 if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.rotation[i])!=-1){
11578 cameradist=findDistance(&viewer,&target);
11579 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.6){
11580 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.6;
11582 if(cameraloc.y<terrain.getHeight(cameraloc.x,cameraloc.z)){
11583 cameraloc.y=terrain.getHeight(cameraloc.x,cameraloc.z);
11586 if(player[0].skeleton.free!=2&&autocam){
11588 if(findLengthfast(&player[0].velocity)>400){
11589 cameraspeed=20+(findLength(&player[0].velocity)-20)*.96;
11591 if(player[0].skeleton.free==0&&player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim)target.y+=1.4;
11592 cameradist+=multiplier*5;
11593 if(cameradist>3.3)cameradist=3.3;
11594 coltarget=target-cameraloc;
11595 if(findLengthfast(&coltarget)<multiplier*multiplier*400)cameraloc=target;
11596 else if(findLengthfast(&coltarget)>1)
11598 Normalise(&coltarget);
11599 if(player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim&&player[0].currentanimation!=climbanim&&player[0].currentoffset.x==0)cameraloc=cameraloc+coltarget*multiplier*cameraspeed;
11600 else cameraloc=cameraloc+coltarget*multiplier*8;
11602 if(editorenabled)cameraloc=target;
11605 coltarget=cameraloc;
11606 objects.SphereCheckPossible(&colviewer, findDistance(&colviewer,&coltarget));
11607 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11608 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11609 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11611 coltarget=cameraloc;
11612 if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;
11614 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11615 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11616 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11618 if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.rotation[i])!=-1){
11622 cameradist=findDistance(&viewer,&target);
11623 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.6){
11624 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.6;
11626 if(cameraloc.y<terrain.getHeight(cameraloc.x,cameraloc.z)){
11627 cameraloc.y=terrain.getHeight(cameraloc.x,cameraloc.z);
11630 if(camerashake>.8)camerashake=.8;
11631 //if(woozy>10)woozy=10;
11632 //woozy+=multiplier;
11634 if(player[0].dead)camerashake=0;
11635 if(player[0].dead)woozy=0;
11636 camerashake-=multiplier*2;
11637 blackout-=multiplier*2;
11638 //if(player[0].isCrouch())woozy-=multiplier*8;
11639 if(camerashake<0)camerashake=0;
11640 if(blackout<0)blackout=0;
11641 //if(woozy<0)woozy=0;
11643 viewer.x+=(float)(Random()%100)*.0005*camerashake;
11644 viewer.y+=(float)(Random()%100)*.0005*camerashake;
11645 viewer.z+=(float)(Random()%100)*.0005*camerashake;