14 extern float multiplier;
16 extern int environment;
17 extern float texscale;
18 extern Terrain terrain;
19 extern FSOUND_SAMPLE *samp[100];
20 extern int channels[100];
21 extern Sprites sprites;
22 extern int kTextureSize;
23 extern float screenwidth,screenheight;
26 extern float texdetail;
27 extern Objects objects;
29 extern float slomodelay;
30 extern bool floatjump;
32 extern Animation animation[animation_count];
34 extern float texdetail;
35 extern GLubyte bloodText[512*512*3];
36 extern GLubyte wolfbloodText[512*512*3];
37 extern float terraindetail;
38 extern float camerashake;
40 extern float blackout;
41 extern bool cellophane;
42 extern bool musictoggle;
43 extern int difficulty;
44 extern Weapons weapons;
45 extern Person player[maxplayers];
46 extern int numplayers;
47 extern int bloodtoggle;
48 extern bool invertmouse;
50 extern float precipdelay;
51 extern XYZ viewerfacing;
52 extern bool ambientsound;
53 extern bool mousejump;
54 extern float viewdistance;
56 extern bool autoslomo;
57 extern int newnetmessages;
58 extern char netmessages[256];
59 extern bool keyboardfrozen;
60 extern int netdatanew;
61 extern bool loadingstuff;
62 extern char mapname[256];
63 extern XYZ windvector;
64 extern bool buttons[3];
65 extern bool debugmode;
68 extern int oldmainmenu;
69 extern bool visibleloading;
70 extern int loadscreencolor;
71 extern float flashamount,flashr,flashg,flashb;
72 extern int flashdelay;
73 extern XYZ envsound[30];
74 extern float envsoundvol[30];
75 extern int numenvsounds;
76 extern float envsoundlife[30];
77 extern float usermousesensitivity;
78 extern bool ismotionblur;
80 extern bool trilinear;
81 extern bool damageeffects;
82 extern bool showpoints;
83 extern bool texttoggle;
84 extern bool alwaysblur;
85 extern float gamespeed;
88 extern bool immediate;
89 extern bool velocityblur;
92 extern float bonusvalue;
93 extern float bonustotal;
94 extern float bonustime;
95 extern float startbonustotal;
96 extern float tintr,tintg,tintb;
97 extern float bonusnum[100];
98 extern bool skyboxtexture;
100 extern float skyboxg;
101 extern float skyboxb;
102 extern float skyboxlightr;
103 extern float skyboxlightg;
104 extern float skyboxlightb;
105 extern float fadestart;
106 extern float slomospeed;
107 extern float slomofreq;
108 extern int tutoriallevel;
109 extern float smoketex;
110 extern float tutorialstagetime;
111 extern int tutorialstage;
112 extern float tutorialmaxtime;
113 extern float tutorialsuccess;
114 extern bool againbonus;
115 extern bool reversaltrain;
116 extern bool canattack;
117 extern bool cananger;
118 extern float damagedealt;
119 extern float damagetaken;
121 extern int editoractive;
122 extern int editorpathtype;
123 extern bool oldbuttons[3];
125 extern float hostiletime;
127 extern bool gamestarted;
129 extern int numhotspots;
130 extern int winhotspot;
131 extern int windialogue;
132 extern int killhotspot;
133 extern XYZ hotspot[40];
134 extern int hotspottype[40];
135 extern float hotspotsize[40];
136 extern char hotspottext[40][256];
137 extern int currenthotspot;
139 extern int kBitsPerPixel;
142 extern int numaccounts;
143 extern int accountactive;
144 extern int accountdifficulty[10];
145 extern int accountprogress[10];
146 extern float accountpoints[10];
147 extern float accounthighscore[10][50];
148 extern float accountfasttime[10][50];
149 extern bool accountunlocked[10][60];
150 extern char accountname[10][256];
152 extern bool stillloading;
153 extern bool winfreeze;
156 extern int numflipfail;
158 extern int numstaffattack;
159 extern int numswordattack;
160 extern int numknifeattack;
161 extern int numunarmedattack;
162 extern int numescaped;
163 extern int numflipped;
164 extern int numwallflipped;
165 extern int numthrowkill;
166 extern int numafterkill;
167 extern int numreversals;
168 extern int numattacks;
169 extern int maxalarmed;
170 extern int numresponded;
172 extern int numdialogues;
173 extern int numdialogueboxes[max_dialogues];
174 extern int dialoguetype[max_dialogues];
175 extern int dialogueboxlocation[max_dialogues][max_dialoguelength];
176 extern float dialogueboxcolor[max_dialogues][max_dialoguelength][3];
177 extern int dialogueboxsound[max_dialogues][max_dialoguelength];
178 extern char dialoguetext[max_dialogues][max_dialoguelength][128];
179 extern char dialoguename[max_dialogues][max_dialoguelength][64];
180 extern XYZ dialoguecamera[max_dialogues][max_dialoguelength];
181 extern XYZ participantlocation[max_dialogues][10];
182 extern int participantfocus[max_dialogues][max_dialoguelength];
183 extern int participantaction[max_dialogues][max_dialoguelength];
184 extern float participantrotation[max_dialogues][10];
185 extern XYZ participantfacing[max_dialogues][max_dialoguelength][10];
186 extern float dialoguecamerarotation[max_dialogues][max_dialoguelength];
187 extern float dialoguecamerarotation2[max_dialogues][max_dialoguelength];
188 extern int indialogue;
189 extern int whichdialogue;
190 extern int directing;
191 extern float dialoguetime;
192 extern int dialoguegonethrough[20];
194 extern bool campaign;
196 extern float oldgamespeed;
198 extern float accountcampaignhighscore[10];
199 extern float accountcampaignfasttime[10];
200 extern float accountcampaignscore[10];
201 extern float accountcampaigntime[10];
203 extern int accountcampaignchoicesmade[10];
204 extern int accountcampaignchoices[10][5000];
205 /********************> Tick() <*****/
206 extern FSOUND_STREAM * strm[10];
207 extern "C" void PlaySoundEx(int channel, FSOUND_SAMPLE *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused);
208 extern "C" void PlayStreamEx(int chan, FSOUND_STREAM *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused);
210 extern void ScreenShot(const char * fname);
211 void Screenshot (void)
214 time_t t = time(NULL);
215 struct tm *tme = localtime(&t);
216 sprintf(temp, "Screenshots\\Screenshot_%04d_%02d_%02d--%02d_%02d_%02d.png", tme->tm_year + 1900, tme->tm_mon + 1, tme->tm_mday, tme->tm_hour, tme->tm_min, tme->tm_sec);
218 mkdir("Screenshots", S_IRWXU);
219 ScreenShot(temp/*"Screenshots\\Screenshot.png"*/);
222 GraphicsExportComponent QT_exporter;
223 OSErr MAC_error_code;
224 CGrafPtr MAC_currentPort;
225 GDHandle MAC_currentDevice;
226 unsigned char* MAC_pixels;
227 Rect MAC_picture_rectangle;
228 GWorldPtr MAC_offscreen_graphics_port;
230 static int numscreenshots=0;
233 static char buf[256];
234 if(numscreenshots==0){
265 FSMakeFSSpec(0, 0, (unsigned char*)buf, &MAC_file);
266 while(!FSpGetFInfo (&MAC_file, fndrInfo)){
267 FSMakeFSSpec(0, 0, (unsigned char*)buf, &MAC_file);
268 if(!FSpGetFInfo (&MAC_file, fndrInfo)){
289 GWorldPtr MAC_gWorld = (CGrafPtr) FrontWindow();
290 //assert(MAC_gWorld != NULL);
292 // Allocate memory for loading image
293 MAC_pixels = new unsigned char[(int)(screenheight * screenwidth * 4)];
294 if (MAC_pixels == NULL) {
295 //UTIL_Error("Could not create Texture data.");
300 ::GetGWorld(&MAC_currentPort, &MAC_currentDevice);
302 // Make a picture Rectangle
303 MAC_picture_rectangle.left = 0;
304 MAC_picture_rectangle.right = screenwidth;
305 MAC_picture_rectangle.top = 0;
306 MAC_picture_rectangle.bottom = screenheight;
308 // Create new offscreen GWorld
309 MAC_error_code = ::QTNewGWorldFromPtr (&MAC_offscreen_graphics_port, k32ARGBPixelFormat, &MAC_picture_rectangle, NULL, NULL, 0, (char *) MAC_pixels, screenwidth * 4);
310 if (MAC_error_code) {
311 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
313 //UTIL_Error("Could not create offscreen GWorld. ");
318 // Copy OpenGL Context to new GWorld
319 glReadBuffer(GL_FRONT);
320 glReadPixels(0,0,screenwidth,screenheight,GL_RGBA,GL_UNSIGNED_BYTE,MAC_pixels);
323 for (unsigned long byte = 0; byte < screenheight * screenwidth * 4; byte+=4) {
324 unsigned char temp = MAC_pixels[byte+0];
325 MAC_pixels[byte+0] = MAC_pixels[byte+3];
326 MAC_pixels[byte+3] = MAC_pixels[byte+2];
327 MAC_pixels[byte+2] = MAC_pixels[byte+1];
328 MAC_pixels[byte+1] = temp;
331 // Flip the image :( This could probably be optimized
336 for (int horz = 0; horz < screenwidth; ++horz)
337 for (vert = 0; vert < screenheight / 2; ++vert) {
338 src_index = (screenwidth * vert + horz) * 4;
339 dst_index = (screenwidth * (screenheight - vert - 1) + horz) * 4;
341 temp=MAC_pixels[src_index+0];
342 MAC_pixels[src_index+0]=MAC_pixels[dst_index+0];
343 MAC_pixels[dst_index+0]=temp;
345 temp=MAC_pixels[src_index+1];
346 MAC_pixels[src_index+1]=MAC_pixels[dst_index+1];
347 MAC_pixels[dst_index+1]=temp;
349 temp=MAC_pixels[src_index+2];
350 MAC_pixels[src_index+2]=MAC_pixels[dst_index+2];
351 MAC_pixels[dst_index+2]=temp;
353 temp=MAC_pixels[src_index+3];
354 MAC_pixels[src_index+3]=MAC_pixels[dst_index+3];
355 MAC_pixels[dst_index+3]=temp;
361 MAC_error_code = OpenADefaultComponent(GraphicsExporterComponentType, kQTFileTypeBMP, &QT_exporter);
362 if (MAC_error_code) {
363 //UTIL_Warning("Unable to export screenshot.");
364 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
365 ::DisposeGWorld(MAC_offscreen_graphics_port);
370 MAC_error_code = GraphicsExportSetInputGWorld(QT_exporter,MAC_offscreen_graphics_port);
371 if (MAC_error_code) {
372 ::CloseComponent(QT_exporter);
373 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
374 ::DisposeGWorld(MAC_offscreen_graphics_port);
376 //UTIL_Warning("Unable to export screenshot.");
380 MAC_error_code = GraphicsExportSetOutputFile(QT_exporter,&MAC_file);
381 if (MAC_error_code) {
382 ::CloseComponent(QT_exporter);
383 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
384 ::DisposeGWorld(MAC_offscreen_graphics_port);
386 //UTIL_Warning("Unable to export screenshot.");
390 MAC_error_code = GraphicsExportDoExport(QT_exporter,NULL);
391 if (MAC_error_code) {
392 ::CloseComponent(QT_exporter);
393 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
394 ::DisposeGWorld(MAC_offscreen_graphics_port);
396 //UTIL_Warning("Unable to export screenshot.");
400 ::CloseComponent(QT_exporter);
401 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
402 ::DisposeGWorld(MAC_offscreen_graphics_port);
409 void Game::SetUpLighting(){
410 if(environment==snowyenvironment){
416 light.ambient[2]=.44;
418 if(environment==desertenvironment){
423 light.ambient[1]=.35;
427 if(environment==grassyenvironment){
433 light.ambient[2]=.44;
444 average=(skyboxlightr+skyboxlightg+skyboxlightb)/3;
445 light.color[0]*=(skyboxlightr+average)/2;
446 light.color[1]*=(skyboxlightg+average)/2;
447 light.color[2]*=(skyboxlightb+average)/2;
448 light.ambient[0]=light.ambient[0]*(skyboxlightr+average)/2*1;
449 light.ambient[1]=light.ambient[1]*(skyboxlightg+average)/2*1;
450 light.ambient[2]=light.ambient[2]*(skyboxlightb+average)/2*1;
454 light.ambient[2]=0; */
457 int Game::findPathDist(int start,int end){
458 int i,j,k,smallestcount,count,connected;
459 int last,last2,last3,last4;
469 while(last!=end&&count<30){
471 for(j=0;j<numpathpoints;j++){
472 if(j!=last&&j!=last2&&j!=last3&&j!=last4)
475 if(numpathpointconnect[j])
476 for(k=0;k<numpathpointconnect[j];k++){
477 if(pathpointconnect[j][k]==last)connected=1;
480 if(numpathpointconnect[last])
481 for(k=0;k<numpathpointconnect[last];k++){
482 if(pathpointconnect[last][k]==j)connected=1;
485 if(closest==-1||Random()%2==0){
496 if(count<smallestcount)smallestcount=count;
498 return smallestcount;
501 int Game::checkcollide(XYZ startpoint,XYZ endpoint){
502 static XYZ colpoint,colviewer,coltarget;
503 static float minx,minz,maxx,maxz,miny,maxy;
512 if(minx>endpoint.x)minx=endpoint.x;
514 if(miny>endpoint.y)miny=endpoint.y;
516 if(minz>endpoint.z)minz=endpoint.z;
519 if(maxx<endpoint.x)maxx=endpoint.x;
521 if(maxy<endpoint.y)maxy=endpoint.y;
523 if(maxz<endpoint.z)maxz=endpoint.z;
532 for(i=0;i<objects.numobjects;i++){
533 if(objects.position[i].x>minx-objects.model[i].boundingsphereradius&&objects.position[i].x<maxx+objects.model[i].boundingsphereradius&&objects.position[i].y>miny-objects.model[i].boundingsphereradius&&objects.position[i].y<maxy+objects.model[i].boundingsphereradius&&objects.position[i].z>minz-objects.model[i].boundingsphereradius&&objects.position[i].z<maxz+objects.model[i].boundingsphereradius){
534 if(objects.type[i]!=treeleavestype&&objects.type[i]!=bushtype&&objects.type[i]!=firetype){
535 colviewer=startpoint;
537 if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)return i;
542 //if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)return 1000;
547 int Game::checkcollide(XYZ startpoint,XYZ endpoint,int what){
548 static XYZ colpoint,colviewer,coltarget;
549 static float minx,minz,maxx,maxz,miny,maxy;
558 if(minx>endpoint.x)minx=endpoint.x;
560 if(miny>endpoint.y)miny=endpoint.y;
562 if(minz>endpoint.z)minz=endpoint.z;
565 if(maxx<endpoint.x)maxx=endpoint.x;
567 if(maxy<endpoint.y)maxy=endpoint.y;
569 if(maxz<endpoint.z)maxz=endpoint.z;
579 if(objects.position[what].x>minx-objects.model[what].boundingsphereradius&&objects.position[what].x<maxx+objects.model[what].boundingsphereradius&&objects.position[what].y>miny-objects.model[what].boundingsphereradius&&objects.position[what].y<maxy+objects.model[what].boundingsphereradius&&objects.position[what].z>minz-objects.model[what].boundingsphereradius&&objects.position[what].z<maxz+objects.model[what].boundingsphereradius){
580 if(objects.type[what]!=treeleavestype&&objects.type[what]!=bushtype&&objects.type[what]!=firetype){
581 colviewer=startpoint;
583 if(objects.model[what].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[what],&objects.rotation[what])!=-1)return i;
588 if(what==1000)if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)return 1000;
593 void Game::Setenvironment(int which)
597 LOG(" Setting environment...");
602 FSOUND_SetPaused(channels[music1snow], TRUE);
603 FSOUND_SetPaused(channels[music1grass], TRUE);
604 FSOUND_SetPaused(channels[music1desert], TRUE);
605 FSOUND_SetPaused(channels[wind], TRUE);
606 FSOUND_SetPaused(channels[desertambient], TRUE);
608 FSOUND_SetPaused(channels[stream_music1snow], TRUE);
609 FSOUND_SetPaused(channels[stream_music1grass], TRUE);
610 FSOUND_SetPaused(channels[stream_music1desert], TRUE);
611 FSOUND_SetPaused(channels[stream_wind], TRUE);
612 FSOUND_SetPaused(channels[stream_desertambient], TRUE);
615 if(environment==snowyenvironment){
619 //PlaySoundEx( wind, samp[wind], NULL, TRUE);
620 PlayStreamEx(stream_wind, strm[stream_wind], 0, TRUE);
621 FSOUND_SetPaused(channels[stream_wind], FALSE);
622 FSOUND_SetVolume(channels[stream_wind], 256);
625 LoadTexture(":Data:Textures:snowtree.png",&objects.treetextureptr,0,1);
626 LoadTexture(":Data:Textures:bushsnow.png",&objects.bushtextureptr,0,1);
627 LoadTexture(":Data:Textures:bouldersnow.jpg",&objects.rocktextureptr,1,0);
628 LoadTexture(":Data:Textures:snowbox.jpg",&objects.boxtextureptr,1,0);
630 FSOUND_Sample_Free(samp[footstepsound]);
631 FSOUND_Sample_Free(samp[footstepsound2]);
632 FSOUND_Sample_Free(samp[footstepsound3]);
633 FSOUND_Sample_Free(samp[footstepsound4]);
634 samp[footstepsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow1.ogg", FSOUND_HW3D, 0, 0);
635 samp[footstepsound2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow2.ogg", FSOUND_HW3D, 0, 0);
636 samp[footstepsound3] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone1.ogg", FSOUND_HW3D, 0, 0);
637 samp[footstepsound4] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone2.ogg", FSOUND_HW3D, 0, 0);
638 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
639 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
640 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
641 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
643 LoadTexture(":Data:Textures:snow.jpg",&terraintexture,1,0);
645 LoadTexture(":Data:Textures:rock.jpg",&terraintexture2,1,0);
647 //LoadTexture(":Data:Textures:detailgrain.png",&terraintexture3,1);
652 temptexdetail=texdetail;
653 if(texdetail>1)texdetail=4;
654 skybox.load( ":Data:Textures:Skybox(snow):Front.jpg",
655 ":Data:Textures:Skybox(snow):Left.jpg",
656 ":Data:Textures:Skybox(snow):Back.jpg",
657 ":Data:Textures:Skybox(snow):Right.jpg",
658 ":Data:Textures:Skybox(snow):Up.jpg",
659 ":Data:Textures:Skybox(snow):Down.jpg",
660 ":Data:Textures:Skybox(snow):Cloud.jpg",
661 ":Data:Textures:Skybox(snow):Reflect.jpg");
666 texdetail=temptexdetail;
668 if(environment==desertenvironment){
671 LoadTexture(":Data:Textures:deserttree.png",&objects.treetextureptr,0,1);
672 LoadTexture(":Data:Textures:bushdesert.png",&objects.bushtextureptr,0,1);
673 LoadTexture(":Data:Textures:boulderdesert.jpg",&objects.rocktextureptr,1,0);
674 LoadTexture(":Data:Textures:desertbox.jpg",&objects.boxtextureptr,1,0);
678 //PlaySoundEx( desertambient, samp[desertambient], NULL, TRUE);
679 PlayStreamEx( stream_desertambient, strm[stream_desertambient], NULL, TRUE);
680 FSOUND_SetPaused(channels[stream_desertambient], FALSE);
681 FSOUND_SetVolume(channels[stream_desertambient], 256);
684 FSOUND_Sample_Free(samp[footstepsound]);
685 FSOUND_Sample_Free(samp[footstepsound2]);
686 FSOUND_Sample_Free(samp[footstepsound3]);
687 FSOUND_Sample_Free(samp[footstepsound4]);
688 samp[footstepsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow1.ogg", FSOUND_HW3D, 0, 0);
689 samp[footstepsound2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow2.ogg", FSOUND_HW3D, 0, 0);
690 samp[footstepsound3] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow1.ogg", FSOUND_HW3D, 0, 0);
691 samp[footstepsound4] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow2.ogg", FSOUND_HW3D, 0, 0);
692 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
693 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
694 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
695 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
697 LoadTexture(":Data:Textures:sand.jpg",&terraintexture,1,0);
699 LoadTexture(":Data:Textures:sandslope.jpg",&terraintexture2,1,0);
701 //LoadTexture(":Data:Textures:detailgrain.png",&terraintexture3,1);
705 temptexdetail=texdetail;
706 if(texdetail>1)texdetail=4;
707 skybox.load( ":Data:Textures:Skybox(sand):Front.jpg",
708 ":Data:Textures:Skybox(sand):Left.jpg",
709 ":Data:Textures:Skybox(sand):Back.jpg",
710 ":Data:Textures:Skybox(sand):Right.jpg",
711 ":Data:Textures:Skybox(sand):Up.jpg",
712 ":Data:Textures:Skybox(sand):Down.jpg",
713 ":Data:Textures:Skybox(sand):Cloud.jpg",
714 ":Data:Textures:Skybox(sand):Reflect.jpg");
719 texdetail=temptexdetail;
721 if(environment==grassyenvironment){
724 LoadTexture(":Data:Textures:tree.png",&objects.treetextureptr,0,1);
725 LoadTexture(":Data:Textures:bush.png",&objects.bushtextureptr,0,1);
726 LoadTexture(":Data:Textures:boulder.jpg",&objects.rocktextureptr,1,0);
727 LoadTexture(":Data:Textures:grassbox.jpg",&objects.boxtextureptr,1,0);
730 PlayStreamEx( stream_wind, strm[stream_wind], NULL, TRUE);
731 FSOUND_SetPaused(channels[stream_wind], FALSE);
732 FSOUND_SetVolume(channels[stream_wind], 100);
735 FSOUND_Sample_Free(samp[footstepsound]);
736 FSOUND_Sample_Free(samp[footstepsound2]);
737 FSOUND_Sample_Free(samp[footstepsound3]);
738 FSOUND_Sample_Free(samp[footstepsound4]);
739 samp[footstepsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepgrass1.ogg", FSOUND_HW3D, 0, 0);
740 samp[footstepsound2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepgrass2.ogg", FSOUND_HW3D, 0, 0);
741 samp[footstepsound3] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone1.ogg", FSOUND_HW3D, 0, 0);
742 samp[footstepsound4] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone2.ogg", FSOUND_HW3D, 0, 0);
743 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
744 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
745 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
746 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
748 LoadTexture(":Data:Textures:grassdirt.jpg",&terraintexture,1,0);
750 LoadTexture(":Data:Textures:mossrock.jpg",&terraintexture2,1,0);
752 //LoadTexture(":Data:Textures:detail.png",&terraintexture3,1);
756 temptexdetail=texdetail;
757 if(texdetail>1)texdetail=4;
758 skybox.load( ":Data:Textures:Skybox(grass):Front.jpg",
759 ":Data:Textures:Skybox(grass):Left.jpg",
760 ":Data:Textures:Skybox(grass):Back.jpg",
761 ":Data:Textures:Skybox(grass):Right.jpg",
762 ":Data:Textures:Skybox(grass):Up.jpg",
763 ":Data:Textures:Skybox(grass):Down.jpg",
764 ":Data:Textures:Skybox(grass):Cloud.jpg",
765 ":Data:Textures:Skybox(grass):Reflect.jpg");
769 texdetail=temptexdetail;
771 temptexdetail=texdetail;
773 terrain.load(":Data:Textures:heightmap.png");
775 texdetail=temptexdetail;
779 void Game::Loadlevel(int which){
782 if(which==0)Loadlevel((char *)":Data:Maps:map1");
783 else if(which==1)Loadlevel((char *)":Data:Maps:map2");
784 else if(which==2)Loadlevel((char *)":Data:Maps:map3");
785 else if(which==3)Loadlevel((char *)":Data:Maps:map4");
786 else if(which==4)Loadlevel((char *)":Data:Maps:map5");
787 else if(which==5)Loadlevel((char *)":Data:Maps:map6");
788 else if(which==6)Loadlevel((char *)":Data:Maps:map7");
789 else if(which==7)Loadlevel((char *)":Data:Maps:map8");
790 else if(which==8)Loadlevel((char *)":Data:Maps:map9");
791 else if(which==9)Loadlevel((char *)":Data:Maps:map10");
792 else if(which==10)Loadlevel((char *)":Data:Maps:map11");
793 else if(which==11)Loadlevel((char *)":Data:Maps:map12");
794 else if(which==12)Loadlevel((char *)":Data:Maps:map13");
795 else if(which==13)Loadlevel((char *)":Data:Maps:map14");
796 else if(which==14)Loadlevel((char *)":Data:Maps:map15");
797 else if(which==15)Loadlevel((char *)":Data:Maps:map16");
798 else if(which==-1){tutoriallevel=-1;Loadlevel((char *)":Data:Maps:tutorial");}
799 else Loadlevel((char *)":Data:Maps:mapsave");
804 /*char * Game::MD5_string (unsigned char *string){
808 strcpy(temp2,(const char *)string);
809 strcat((char *)temp2,(const char *)"Lugaru");
810 sprintf (temp, "%d",strlen((char *)temp2));
811 strcat((char *)temp2,temp);
814 unsigned int len = strlen ( (char *)temp2);
816 context.update ((unsigned char *)temp2, len);
819 return context.hex_digest();
824 void Game::Loadlevel(char *name){
831 float headprop,legprop,armprop,bodyprop;
835 LOG(std::string("Loading level...") + name);
837 if(!gameon)visibleloading=1;
839 if(stealthloading)visibleloading=0;
841 if(!stillloading)loadtime=0;
846 if(tutoriallevel!=-1)tutoriallevel=0;
847 else tutoriallevel=1;
849 if(tutoriallevel==1)tutorialstage=0;
850 if(tutorialstage==0){
858 FSOUND_SetPaused(channels[whooshsound], TRUE);
859 FSOUND_SetPaused(channels[stream_firesound], TRUE);
863 tfile=fopen( name, "rb" );
866 FSOUND_SetPaused(channels[stream_firesound], TRUE);
877 animation[bounceidleanim].Load((char *)":Data:Animations:Idle",middleheight,neutral);
883 dialoguegonethrough[i]=0;
892 if(accountactive!=-1)difficulty=accountdifficulty[accountactive];
894 if(difficulty!=2)minimap=1;
931 bonustotal=startbonustotal;
937 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
938 FSOUND_SetVolume(channels[consolesuccesssound], 256);
939 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
947 sprites.numsprites=0;
948 for(i=0;i<objects.numobjects;i++)
950 objects.model[i].numdecals=0;
953 j=objects.numobjects;
956 objects.DeleteObject(0);
957 if(visibleloading){loadscreencolor=4; LoadingScreen();}
960 for(i=0;i<subdivision;i++)
962 for(j=0;j<subdivision;j++)
964 terrain.patchobjectnum[i][j]=0;
967 if(visibleloading){loadscreencolor=4; LoadingScreen();}
970 weapons.numweapons=0;
972 funpackf(tfile, "Bi", &mapvers);
973 if(mapvers>=15)funpackf(tfile, "Bi", &indemo);
975 if(mapvers>=5)funpackf(tfile, "Bi", &maptype);
976 else maptype=mapkilleveryone;
977 if(mapvers>=6)funpackf(tfile, "Bi", &hostile);
979 if(mapvers>=4)funpackf(tfile, "Bf Bf", &viewdistance, &fadestart);
985 if(mapvers>=2)funpackf(tfile, "Bb Bf Bf Bf", &skyboxtexture, &skyboxr, &skyboxg, &skyboxb);
993 if(mapvers>=10)funpackf(tfile, "Bf Bf Bf", &skyboxlightr, &skyboxlightg, &skyboxlightb);
996 skyboxlightr=skyboxr;
997 skyboxlightg=skyboxg;
998 skyboxlightb=skyboxb;
1000 if(!stealthloading)funpackf(tfile, "Bf Bf Bf Bf Bf Bi", &player[0].coords.x,&player[0].coords.y,&player[0].coords.z,&player[0].rotation,&player[0].targetrotation, &player[0].num_weapons);
1001 if(stealthloading)funpackf(tfile, "Bf Bf Bf Bf Bf Bi", &lamefloat,&lamefloat,&lamefloat,&lamefloat,&lamefloat, &player[0].num_weapons);
1002 player[0].originalcoords=player[0].coords;
1003 if(player[0].num_weapons>0&&player[0].num_weapons<5)
1005 for(j=0;j<player[0].num_weapons;j++)
1007 player[0].weaponids[j]=weapons.numweapons;
1008 funpackf(tfile, "Bi", &weapons.type[weapons.numweapons]);
1009 weapons.owner[weapons.numweapons]=0;
1010 weapons.numweapons++;
1014 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1016 funpackf(tfile, "Bf Bf Bf", &player[0].armorhead, &player[0].armorhigh, &player[0].armorlow);
1017 funpackf(tfile, "Bf Bf Bf", &player[0].protectionhead, &player[0].protectionhigh, &player[0].protectionlow);
1018 funpackf(tfile, "Bf Bf Bf", &player[0].metalhead, &player[0].metalhigh, &player[0].metallow);
1019 funpackf(tfile, "Bf Bf", &player[0].power, &player[0].speedmult);
1021 funpackf(tfile, "Bi", &player[0].numclothes);
1025 funpackf(tfile, "Bi Bi", &player[0].whichskin, &player[0].creature);
1029 player[0].whichskin=0;
1030 player[0].creature=rabbittype;
1033 for(i=0;i<max_dialogues;i++)
1035 for(j=0;j<max_dialoguelength;j++)
1039 dialoguetext[i][j][k]='\0';
1043 dialoguename[i][j][k]='\0';
1048 player[0].lastattack=-1;
1049 player[0].lastattack2=-1;
1050 player[0].lastattack3=-1;
1054 funpackf(tfile, "Bi", &numdialogues);
1057 for(k=0;k<numdialogues;k++)
1059 funpackf(tfile, "Bi", &numdialogueboxes[k]);
1060 funpackf(tfile, "Bi", &dialoguetype[k]);
1063 funpackf(tfile, "Bf Bf Bf", &participantlocation[k][l].x, &participantlocation[k][l].y, &participantlocation[k][l].z);
1064 funpackf(tfile, "Bf", &participantrotation[k][l]);
1066 if(numdialogueboxes)
1068 for(l=0;l<numdialogueboxes[k];l++)
1070 funpackf(tfile, "Bi", &dialogueboxlocation[k][l]);
1071 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][0]);
1072 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][1]);
1073 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][2]);
1074 funpackf(tfile, "Bi", &dialogueboxsound[k][l]);
1078 funpackf(tfile, "Bi",&templength);
1079 if(templength>128||templength<=0)templength=128;
1080 for(m=0;m<templength;m++){
1081 funpackf(tfile, "Bb", &dialoguetext[k][l][m]);
1082 if(dialoguetext[k][l][m]=='\0')break;
1085 funpackf(tfile, "Bi",&templength);
1086 if(templength>64||templength<=0)templength=64;
1087 for(m=0;m<templength;m++){
1088 funpackf(tfile, "Bb", &dialoguename[k][l][m]);
1089 if(dialoguename[k][l][m]=='\0'){
1093 funpackf(tfile, "Bf Bf Bf", &dialoguecamera[k][l].x, &dialoguecamera[k][l].y, &dialoguecamera[k][l].z);
1094 funpackf(tfile, "Bi", &participantfocus[k][l]);
1095 funpackf(tfile, "Bi", &participantaction[k][l]);
1098 funpackf(tfile, "Bf Bf Bf", &participantfacing[k][l][m].x, &participantfacing[k][l][m].y, &participantfacing[k][l][m].z);
1100 funpackf(tfile, "Bf Bf",&dialoguecamerarotation[k][l],&dialoguecamerarotation2[k][l]);
1106 else numdialogues=0;
1108 if(player[0].numclothes)
1110 for(k=0;k<player[0].numclothes;k++)
1112 funpackf(tfile, "Bi", &templength);
1113 for(l=0;l<templength;l++)
1114 funpackf(tfile, "Bb", &player[0].clothes[k][l]);
1115 player[0].clothes[k][templength]='\0';
1116 funpackf(tfile, "Bf Bf Bf", &player[0].clothestintr[k], &player[0].clothestintg[k], &player[0].clothestintb[k]);
1120 funpackf(tfile, "Bi", &environment);
1122 funpackf(tfile, "Bi", &objects.numobjects);
1123 if(objects.numobjects)
1125 for(i=0;i<objects.numobjects;i++)
1127 funpackf(tfile, "Bi Bf Bf Bf Bf Bf Bf", &objects.type[i],&objects.rotation[i],&objects.rotation2[i], &objects.position[i].x, &objects.position[i].y, &objects.position[i].z,&objects.scale[i]);
1128 if(objects.type[i]==treeleavestype)objects.scale[i]=objects.scale[i-1];
1134 funpackf(tfile, "Bi", &numhotspots);
1137 for(i=0;i<numhotspots;i++)
1139 funpackf(tfile, "Bi Bf Bf Bf Bf", &hotspottype[i],&hotspotsize[i],&hotspot[i].x,&hotspot[i].y,&hotspot[i].z);
1140 funpackf(tfile, "Bi", &templength);
1142 for(l=0;l<templength;l++)
1143 funpackf(tfile, "Bb", &hotspottext[i][l]);
1144 hotspottext[i][templength]='\0';
1145 if(hotspottype[i]==-111)indemo=1;
1151 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1156 for(i=0;i<objects.numobjects;i++)
1158 objects.center+=objects.position[i];
1160 objects.center/=objects.numobjects;
1163 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1165 float maxdistance=0;
1168 for(i=0;i<objects.numobjects;i++)
1170 tempdist=findDistancefast(&objects.center,&objects.position[i]);
1171 if(tempdist>maxdistance)
1174 maxdistance=tempdist;
1177 objects.radius=fast_sqrt(maxdistance);
1180 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1181 //mapcenter=objects.center;
1182 //mapradius=objects.radius;
1184 funpackf(tfile, "Bi", &numplayers);
1185 int howmanyremoved=0;
1186 bool removeanother=0;
1187 if(numplayers>1&&numplayers<maxplayers)
1189 for(i=1;i<numplayers;i++)
1191 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1194 funpackf(tfile, "Bi Bi Bf Bf Bf Bi",&player[i-howmanyremoved].whichskin,&player[i-howmanyremoved].creature, &player[i-howmanyremoved].coords.x,&player[i-howmanyremoved].coords.y,&player[i-howmanyremoved].coords.z,&player[i-howmanyremoved].num_weapons);
1195 if(mapvers>=5)funpackf(tfile, "Bi", &player[i-howmanyremoved].howactive);
1196 else player[i-howmanyremoved].howactive=typeactive;
1197 if(mapvers>=3)funpackf(tfile, "Bf",&player[i-howmanyremoved].scale);
1198 else player[i-howmanyremoved].scale=-1;
1199 if(mapvers>=11)funpackf(tfile, "Bb",&player[i-howmanyremoved].immobile);
1200 else player[i-howmanyremoved].immobile=0;
1201 if(mapvers>=12)funpackf(tfile, "Bf",&player[i-howmanyremoved].rotation);
1202 else player[i-howmanyremoved].rotation=0;
1203 player[i-howmanyremoved].targetrotation=player[i-howmanyremoved].rotation;
1204 if(player[i-howmanyremoved].num_weapons<0||player[i-howmanyremoved].num_weapons>5){
1210 if(player[i-howmanyremoved].num_weapons>0&&player[i-howmanyremoved].num_weapons<5)
1212 for(j=0;j<player[i-howmanyremoved].num_weapons;j++)
1214 player[i-howmanyremoved].weaponids[j]=weapons.numweapons;
1215 funpackf(tfile, "Bi", &weapons.type[player[i-howmanyremoved].weaponids[j]]);
1216 weapons.owner[player[i-howmanyremoved].weaponids[j]]=i;
1217 weapons.numweapons++;
1220 funpackf(tfile, "Bi", &player[i-howmanyremoved].numwaypoints);
1221 //player[i-howmanyremoved].numwaypoints=10;
1222 for(j=0;j<player[i-howmanyremoved].numwaypoints;j++)
1224 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].x);
1225 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].y);
1226 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].z);
1227 if(mapvers>=5)funpackf(tfile, "Bi", &player[i-howmanyremoved].waypointtype[j]);
1228 else player[i-howmanyremoved].waypointtype[j] = wpkeepwalking;
1231 funpackf(tfile, "Bi", &player[i-howmanyremoved].waypoint);
1232 if(player[i-howmanyremoved].waypoint>player[i-howmanyremoved].numwaypoints-1)player[i-howmanyremoved].waypoint=0;
1234 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].armorhead, &player[i-howmanyremoved].armorhigh, &player[i-howmanyremoved].armorlow);
1235 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].protectionhead, &player[i-howmanyremoved].protectionhigh, &player[i-howmanyremoved].protectionlow);
1236 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].metalhead, &player[i-howmanyremoved].metalhigh, &player[i-howmanyremoved].metallow);
1237 funpackf(tfile, "Bf Bf", &player[i-howmanyremoved].power, &player[i-howmanyremoved].speedmult);
1239 if(mapvers>=4)funpackf(tfile, "Bf Bf Bf Bf", &headprop, &bodyprop, &armprop, &legprop);
1247 if(player[i-howmanyremoved].creature==wolftype)
1249 player[i-howmanyremoved].proportionhead=1.1*headprop;
1250 player[i-howmanyremoved].proportionbody=1.1*bodyprop;
1251 player[i-howmanyremoved].proportionarms=1.1*armprop;
1252 player[i-howmanyremoved].proportionlegs=1.1*legprop;
1255 if(player[i-howmanyremoved].creature==rabbittype)
1257 player[i-howmanyremoved].proportionhead=1.2*headprop;
1258 player[i-howmanyremoved].proportionbody=1.05*bodyprop;
1259 player[i-howmanyremoved].proportionarms=1.00*armprop;
1260 player[i-howmanyremoved].proportionlegs=1.1*legprop;
1261 player[i-howmanyremoved].proportionlegs.y=1.05*legprop;
1264 funpackf(tfile, "Bi", &player[i-howmanyremoved].numclothes);
1265 if(player[i-howmanyremoved].numclothes)
1267 for(k=0;k<player[i-howmanyremoved].numclothes;k++)
1270 funpackf(tfile, "Bi", &templength);
1271 for(l=0;l<templength;l++)
1272 funpackf(tfile, "Bb", &player[i-howmanyremoved].clothes[k][l]);
1273 player[i-howmanyremoved].clothes[k][templength]='\0';
1274 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].clothestintr[k], &player[i-howmanyremoved].clothestintg[k], &player[i-howmanyremoved].clothestintb[k]);
1280 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1282 numplayers-=howmanyremoved;
1283 funpackf(tfile, "Bi", &numpathpoints);
1284 if(numpathpoints>30||numpathpoints<0)
1288 for(j=0;j<numpathpoints;j++)
1290 funpackf(tfile, "Bf Bf Bf Bi", &pathpoint[j].x,&pathpoint[j].y,&pathpoint[j].z,&numpathpointconnect[j]);
1291 for(k=0;k<numpathpointconnect[j];k++){
1292 funpackf(tfile, "Bi", &pathpointconnect[j][k]);
1296 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1298 funpackf(tfile, "Bf Bf Bf Bf", &mapcenter.x,&mapcenter.y,&mapcenter.z,&mapradius);
1301 if(environment!=oldenvironment)Setenvironment(environment);
1302 oldenvironment=environment;
1306 j=objects.numobjects;
1307 objects.numobjects=0;
1310 //if(objects.type[i]!=spiketype)
1311 objects.MakeObject(objects.type[i],objects.position[i],objects.rotation[i],objects.rotation2[i],objects.scale[i]);
1312 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1315 //if(skyboxtexture){
1316 terrain.DoShadows();
1317 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1318 objects.DoShadows();
1319 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1321 else terrain.DoLighting();
1327 oldlevel=whichlevel;
1330 if(numplayers>maxplayers-1)numplayers=maxplayers-1;
1331 for(i=0;i<numplayers;i++)
1333 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1337 if(i==0||player[i].scale<0)player[i].scale=.2;
1338 player[i].skeleton.free=0;
1339 player[i].skeleton.id=i;
1340 //if(Random()%2==0)player[i].creature=wolftype;
1341 //else player[i].creature=rabbittype;
1342 if(i==0&&mapvers<9)player[i].creature=rabbittype;
1343 if(player[i].creature!=wolftype)player[i].skeleton.Load((char *)":Data:Skeleton:Basic Figure",(char *)":Data:Skeleton:Basic Figurelow",(char *)":Data:Skeleton:Rabbitbelt",(char *)":Data:Models:Body.solid",(char *)":Data:Models:Body2.solid",(char *)":Data:Models:Body3.solid",(char *)":Data:Models:Body4.solid",(char *)":Data:Models:Body5.solid",(char *)":Data:Models:Body6.solid",(char *)":Data:Models:Body7.solid",(char *)":Data:Models:Bodylow.solid",(char *)":Data:Models:Belt.solid",0);
1346 if(player[i].creature!=wolftype){
1347 player[i].skeleton.Load((char *)":Data:Skeleton:Basic Figure",(char *)":Data:Skeleton:Basic Figurelow",(char *)":Data:Skeleton:Rabbitbelt",(char *)":Data:Models:Body.solid",(char *)":Data:Models:Body2.solid",(char *)":Data:Models:Body3.solid",(char *)":Data:Models:Body4.solid",(char *)":Data:Models:Body5.solid",(char *)":Data:Models:Body6.solid",(char *)":Data:Models:Body7.solid",(char *)":Data:Models:Bodylow.solid",(char *)":Data:Models:Belt.solid",1);
1348 LoadTexture(":Data:Textures:Belt.png",&player[i].skeleton.drawmodelclothes.textureptr,1,1);
1350 if(player[i].creature==wolftype){
1351 player[i].skeleton.Load((char *)":Data:Skeleton:Basic Figure Wolf",(char *)":Data:Skeleton:Basic Figure Wolf Low",(char *)":Data:Skeleton:Rabbitbelt",(char *)":Data:Models:Wolf.solid",(char *)":Data:Models:Wolf2.solid",(char *)":Data:Models:Wolf3.solid",(char *)":Data:Models:Wolf4.solid",(char *)":Data:Models:Wolf5.solid",(char *)":Data:Models:Wolf6.solid",(char *)":Data:Models:Wolf7.solid",(char *)":Data:Models:Wolflow.solid",(char *)":Data:Models:Belt.solid",0);
1357 texsize=512*512*3/texdetail/texdetail;
1358 //if(!player[i].loaded)player[i].skeleton.skinText = new GLubyte[texsize];
1359 //player[i].skeleton.skinText.resize(texsize);
1361 if(player[i].creature==rabbittype)
1363 if(player[i].whichskin==0){
1364 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1366 else if(player[i].whichskin==1){
1367 LoadTextureSave(":Data:Textures:Fur.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1369 else if(player[i].whichskin==2){
1370 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1372 else if(player[i].whichskin==3){
1373 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1375 else if(player[i].whichskin==4){
1376 LoadTextureSave(":Data:Textures:Otter.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1378 else if(player[i].whichskin==5){
1379 LoadTextureSave(":Data:Textures:Opal.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1381 else if(player[i].whichskin==6){
1382 LoadTextureSave(":Data:Textures:Sable.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1384 else if(player[i].whichskin==7){
1385 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1387 else if(player[i].whichskin==8){
1388 LoadTextureSave(":Data:Textures:BW2.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1390 else if(player[i].whichskin==9){
1391 LoadTextureSave(":Data:Textures:WB2.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1394 if(player[i].creature==wolftype)
1396 //k=abs(Random()%3);
1397 if(player[i].whichskin==0){
1398 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1400 else if(player[i].whichskin==1){
1401 LoadTextureSave(":Data:Textures:Darkwolf.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1403 else if(player[i].whichskin==2){
1404 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1408 if(player[i].numclothes)
1410 for(j=0;j<player[i].numclothes;j++)
1412 tintr=player[i].clothestintr[j];
1413 tintg=player[i].clothestintg[j];
1414 tintb=player[i].clothestintb[j];
1415 AddClothes((char *)player[i].clothes[j],0,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1417 player[i].DoMipmaps(5,0,0,player[i].skeleton.skinsize,player[i].skeleton.skinsize);
1420 player[i].currentanimation=bounceidleanim;
1421 player[i].targetanimation=bounceidleanim;
1422 player[i].currentframe=0;
1423 player[i].targetframe=1;
1425 player[i].speed=1+(float)(Random()%100)/1000;
1426 if(difficulty==0)player[i].speed-=.2;
1427 if(difficulty==1)player[i].speed-=.1;
1429 player[i].velocity=0;
1430 player[i].oldcoords=player[i].coords;
1431 player[i].realoldcoords=player[i].coords;
1434 player[i].skeleton.id=i;
1435 player[i].updatedelay=0;
1436 player[i].normalsupdatedelay=0;
1438 player[i].aitype=passivetype;
1439 player[i].aitarget=0;
1440 player[i].madskills=0;
1444 player[i].proportionhead=1.2;
1445 player[i].proportionbody=1.05;
1446 player[i].proportionarms=1.00;
1447 player[i].proportionlegs=1.1;
1448 player[i].proportionlegs.y=1.05;
1450 player[i].headless=0;
1451 player[i].currentoffset=0;
1452 player[i].targetoffset=0;
1453 /*player[i].armorhead=1;
1454 player[i].armorhigh=1;
1455 player[i].armorlow=1;
1456 player[i].protectionhead=1;
1457 player[i].protectionhigh=1;
1458 player[i].protectionlow=1;
1459 player[i].metalhead=1;
1460 player[i].metalhigh=1;
1461 player[i].metallow=1;
1463 player[i].speedmult=1;*/
1465 player[i].damagetolerance=200;
1467 if(player[i].creature==wolftype)
1469 /*player[i].proportionhead=1.1;
1470 player[i].proportionbody=1.1;
1471 player[i].proportionarms=1.1;
1472 player[i].proportionlegs=1.1;
1473 player[i].proportionlegs.y=1.1;*/
1474 if(i==0||player[i].scale<0)player[i].scale=.23;
1476 player[i].damagetolerance=300;
1479 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1482 player[i].proportionhead.z=0;
1483 player[i].proportionbody.z=0;
1484 player[i].proportionarms.z=0;
1485 player[i].proportionlegs.z=0;
1488 player[i].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0);
1490 player[i].headmorphness=0;
1491 player[i].targetheadmorphness=1;
1492 player[i].headmorphstart=0;
1493 player[i].headmorphend=0;
1495 player[i].pausetime=0;
1498 player[i].jumppower=5;
1500 player[i].permanentdamage=0;
1501 player[i].superpermanentdamage=0;
1503 player[i].forwardkeydown=0;
1504 player[i].leftkeydown=0;
1505 player[i].backkeydown=0;
1506 player[i].rightkeydown=0;
1507 player[i].jumpkeydown=0;
1508 player[i].crouchkeydown=0;
1509 player[i].throwkeydown=0;
1511 player[i].collided=-10;
1513 player[i].bloodloss=0;
1514 player[i].weaponactive=-1;
1515 player[i].weaponstuck=-1;
1516 player[i].bleeding=0;
1517 player[i].deathbleeding=0;
1518 player[i].stunned=0;
1519 player[i].hasvictim=0;
1520 player[i].wentforweapon=0;
1523 player[0].aitype=playercontrolled;
1524 player[0].weaponactive=-1;
1528 //player[0].speedmult=1/.9;
1529 player[0].power=1/.9;
1534 //player[0].speedmult=1/.8;
1535 player[0].power=1/.8;
1538 //player[0].weaponstuck=1;
1540 if(difficulty==1)player[0].damagetolerance=250;
1541 if(difficulty==0)player[0].damagetolerance=300;
1542 if(difficulty==0)player[0].armorhead*=1.5;
1543 if(difficulty==0)player[0].armorhigh*=1.5;
1544 if(difficulty==0)player[0].armorlow*=1.5;
1545 cameraloc=player[0].coords;
1547 rotation=player[0].rotation;
1549 hawkcoords=player[0].coords;
1552 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1553 //weapons.numweapons=numplayers;
1554 for(i=0;i<weapons.numweapons;i++)
1556 weapons.bloody[i]=0;
1557 weapons.blooddrip[i]=0;
1558 weapons.blooddripdelay[i]=0;
1559 weapons.onfire[i]=0;
1560 weapons.flamedelay[i]=0;
1561 weapons.damage[i]=0;
1562 //weapons.type[i]=sword;
1563 if(weapons.type[i]==sword){
1564 weapons.mass[i]=1.5;
1565 weapons.tipmass[i]=1;
1566 weapons.length[i]=.8;
1568 if(weapons.type[i]==staff){
1570 weapons.tipmass[i]=1;
1571 weapons.length[i]=1.5;
1573 if(weapons.type[i]==knife){
1575 weapons.tipmass[i]=1.2;
1576 weapons.length[i]=.25;
1578 weapons.position[i]=-1000;
1579 weapons.tippoint[i]=-1000;
1582 /* for(i=0;i<32;i++){
1584 FSOUND_StopSound(i);
1587 LOG("Starting background music...");
1589 FSOUND_StopSound(FSOUND_ALL);
1590 if(environment==snowyenvironment)
1594 PlayStreamEx(stream_wind, strm[stream_wind], NULL, TRUE);
1595 FSOUND_SetPaused(channels[stream_wind], FALSE);
1596 FSOUND_SetVolume(channels[stream_wind], 256);
1599 else if(environment==desertenvironment)
1603 //PlaySoundEx(desertambient,
1604 // samp[desertambient], NULL, TRUE);
1605 PlayStreamEx(stream_desertambient,
1606 strm[stream_desertambient], NULL, TRUE);
1607 FSOUND_SetPaused(channels[stream_desertambient], FALSE);
1608 FSOUND_SetVolume(channels[stream_desertambient], 256);
1611 else if(environment==grassyenvironment)
1615 //PlaySoundEx(wind, samp[wind], NULL, TRUE);
1616 PlayStreamEx(stream_wind, strm[stream_wind], NULL, TRUE);
1617 FSOUND_SetPaused(channels[stream_wind], FALSE);
1618 FSOUND_SetVolume(channels[stream_wind], 100);
1621 oldmusicvolume[0]=0;
1622 oldmusicvolume[1]=0;
1623 oldmusicvolume[2]=0;
1624 oldmusicvolume[3]=0;
1627 /*LoadTexture(":Data:Textures:cloud.png",&sprites.cloudtexture,1,1);
1628 LoadTexture(":Data:Textures:cloudimpact.png",&sprites.cloudimpacttexture,1,1);
1629 LoadTexture(":Data:Textures:bloodparticle.png",&sprites.bloodtexture,1,1);
1630 LoadTexture(":Data:Textures:snowflake.png",&sprites.snowflaketexture,1,1);
1631 LoadTexture(":Data:Textures:flame.png",&sprites.flametexture,1,1);
1632 LoadTexture(":Data:Textures:bloodflame.png",&sprites.bloodflametexture,1,1);
1633 LoadTexture(":Data:Textures:smoke.png",&sprites.smoketexture,1,1);
1634 LoadTexture(":Data:Textures:shine.png",&sprites.shinetexture,1,0);
1649 static int i,k,j,l,m;
1650 static XYZ facing,flatfacing,absflatfacing;
1651 static XYZ rotatetarget;
1653 static float oldtargetrotation;
1654 static int target, numgood;
1655 static XYZ tempcoords1,tempcoords2;
1658 static XYZ lowpoint,lowpointtarget,lowpoint2,lowpointtarget2,lowpoint3,lowpointtarget3,lowpoint4,lowpointtarget4,lowpoint5,lowpointtarget5,lowpoint6,lowpointtarget6,lowpoint7,lowpointtarget7,colpoint,colpoint2;
1659 static int whichhit;
1660 static bool donesomething;
1661 static bool oldjumpkeydown;
1665 float headprop,bodyprop,armprop,legprop;
1669 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
1670 FSOUND_SetVolume(channels[consolesuccesssound], 256);
1671 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
1675 consoletext[k][j]=consoletext[k-1][j];
1677 consolechars[k]=consolechars[k-1];
1681 displaytext[k][j]=displaytext[k-1][j];
1683 displaychars[k]=displaychars[k-1];
1684 displaytime[k]=displaytime[k-1];
1687 consoletext[1][j]=' ';
1688 displaytext[1][j]=' ';
1690 sprintf (consoletext[1], netmessages);
1691 sprintf (displaytext[1], netmessages);
1692 consolechars[1]=255;
1693 displaychars[1]=255;
1698 displaytime[i]+=multiplier;
1701 static unsigned char theKeyMap[16];
1702 GetKeys( theKeyMap );
1707 static bool mainmenutogglekeydown;
1709 if(mainmenu&&endgame==1)mainmenu=10;
1710 if(IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)&&!mainmenutogglekeydown&&(mainmenu==7&&entername)){
1712 displaytext[0][j]=' ';
1717 mainmenutogglekeydown=1;
1719 if((IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)||(mainmenu==0&&((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY)||(campaign)))&&!oldjumpkeydown&&campaign&&winfreeze))&&!mainmenutogglekeydown&&(!mainmenu||gameon||mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||(mainmenu==7&&!entername)||mainmenu==9||mainmenu==11||(mainmenu==12&&!tryquit)||mainmenu==13||mainmenu==14||mainmenu==15||mainmenu==16||mainmenu==17||mainmenu==10)){
1721 if(mainmenu==1||mainmenu==2||mainmenu==0){
1722 if(mainmenu==0&&!winfreeze)mainmenu=2;
1723 else if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1)mainmenu=100;
1724 else if(mainmenu==0&&winfreeze){
1725 /* if(campaignchoosenext[campaignchoicewhich[whichchoice]]==2)
1727 else stealthloading=0;
1729 if(!stealthloading){
1730 float gLoc[3]={0,0,0};
1731 float vel[3]={0,0,0};
1732 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
1733 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
1734 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
1735 FSOUND_SetVolume(channels[firestartsound], 256);
1736 FSOUND_SetPaused(channels[firestartsound], FALSE);
1737 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
1748 for(i=0;i<campaignnumlevels;i++){
1750 levelhighlight[i]=0;
1755 if(accountcampaignchoicesmade[accountactive])
1756 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
1757 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
1758 levelvisible[levelorder[i+1]]=1;
1760 int whichlevelstart;
1761 whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
1762 if(whichlevelstart<0){
1763 campaignchoicenum=1;
1764 campaignchoicewhich[0]=0;
1768 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
1769 if(campaignchoicenum)
1770 for(i=0;i<campaignchoicenum;i++){
1771 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
1772 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
1773 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
1780 if(firstload)TickOnceAfter();
1781 if(!firstload)LoadStuff();
1798 //accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
1799 //accountcampaignchoicesmade[accountactive]++;
1802 strcat(mapname,campaignmapname[campaignchoicewhich[0]]);
1810 FSOUND_SetPaused(channels[music3], TRUE);
1814 else if(mainmenu==1||mainmenu==2)mainmenu=0;
1815 if(mainmenu&&musictoggle){
1816 if(mainmenu==1||mainmenu==2||mainmenu==100){
1817 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
1818 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
1819 FSOUND_SetPaused(channels[stream_music3], FALSE);
1820 FSOUND_SetVolume(channels[stream_music3], 256);
1821 FSOUND_SetPaused(channels[music1], TRUE);
1825 FSOUND_SetPaused(channels[stream_music3], TRUE);
1826 FSOUND_SetPaused(channels[music1], FALSE);
1830 float gLoc[3]={0,0,0};
1831 float vel[3]={0,0,0};
1832 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
1833 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
1834 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1835 FSOUND_SetVolume(channels[fireendsound], 256);
1836 FSOUND_SetPaused(channels[fireendsound], FALSE);
1837 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1845 if(newdetail>2)newdetail=detail;
1846 if(newdetail<0)newdetail=detail;
1847 if(newscreenwidth>3000)newscreenwidth=screenwidth;
1848 if(newscreenwidth<0)newscreenwidth=screenwidth;
1849 if(newscreenheight>3000)newscreenheight=screenheight;
1850 if(newscreenheight<0)newscreenheight=screenheight;
1852 //ofstream opstream(":Data:config.txt");
1853 ofstream opstream("./Data/config.txt");
1854 opstream << "Screenwidth:\n";
1855 opstream << newscreenwidth;
1856 opstream << "\nScreenheight:\n";
1857 opstream << newscreenheight;
1858 opstream << "\nMouse sensitivity:\n";
1859 opstream << usermousesensitivity;
1860 opstream << "\nBlur(0,1):\n";
1861 opstream << ismotionblur;
1862 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
1863 opstream << newdetail;
1864 opstream << "\nFloating jump:\n";
1865 opstream << floatjump;
1866 opstream << "\nMouse jump:\n";
1867 opstream << mousejump;
1868 opstream << "\nAmbient sound:\n";
1869 opstream << ambientsound;
1870 opstream << "\nBlood (0,1,2):\n";
1871 opstream << bloodtoggle;
1872 opstream << "\nAuto slomo:\n";
1873 opstream << autoslomo;
1874 opstream << "\nFoliage:\n";
1875 opstream << foliage;
1876 opstream << "\nMusic:\n";
1877 opstream << musictoggle;
1878 opstream << "\nTrilinear:\n";
1879 opstream << trilinear;
1880 opstream << "\nDecals(shadows,blood puddles,etc):\n";
1882 opstream << "\nInvert mouse:\n";
1883 opstream << invertmouse;
1884 opstream << "\nGamespeed:\n";
1885 if(oldgamespeed==0)oldgamespeed=1;
1886 opstream << oldgamespeed;
1887 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
1888 opstream << difficulty;
1889 opstream << "\nDamage effects(blackout, doublevision):\n";
1890 opstream << damageeffects;
1891 opstream << "\nText:\n";
1892 opstream << texttoggle;
1893 opstream << "\nDebug:\n";
1894 opstream << debugmode;
1895 opstream << "\nVBL Sync:\n";
1896 opstream << vblsync;
1897 opstream << "\nShow Points:\n";
1898 opstream << showpoints;
1899 opstream << "\nAlways Blur:\n";
1900 opstream << alwaysblur;
1901 opstream << "\nImmediate mode (turn on on G5):\n";
1902 opstream << immediate;
1903 opstream << "\nVelocity blur:\n";
1904 opstream << velocityblur;
1905 opstream << "\nVolume:\n";
1907 opstream << "\nForward key:\n";
1908 opstream << KeyToChar(forwardkey);
1909 opstream << "\nBack key:\n";
1910 opstream << KeyToChar(backkey);
1911 opstream << "\nLeft key:\n";
1912 opstream << KeyToChar(leftkey);
1913 opstream << "\nRight key:\n";
1914 opstream << KeyToChar(rightkey);
1915 opstream << "\nJump key:\n";
1916 opstream << KeyToChar(jumpkey);
1917 opstream << "\nCrouch key:\n";
1918 opstream << KeyToChar(crouchkey);
1919 opstream << "\nDraw key:\n";
1920 opstream << KeyToChar(drawkey);
1921 opstream << "\nThrow key:\n";
1922 opstream << KeyToChar(throwkey);
1923 opstream << "\nAttack key:\n";
1924 opstream << KeyToChar(attackkey);
1925 opstream << "\nChat key:\n";
1926 opstream << KeyToChar(chatkey);
1929 if(mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==9||mainmenu==12||mainmenu==13||mainmenu==14||mainmenu==10||mainmenu==11||mainmenu==100){
1930 float gLoc[3]={0,0,0};
1931 float vel[3]={0,0,0};
1932 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
1933 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
1934 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1935 FSOUND_SetVolume(channels[fireendsound], 256);
1936 FSOUND_SetPaused(channels[fireendsound], FALSE);
1937 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1945 if(mainmenu==3&&gameon)mainmenu=2;
1946 if(mainmenu==3&&!gameon)mainmenu=1;
1947 if(mainmenu==5&&gameon)mainmenu=2;
1948 if(mainmenu==5&&!gameon)mainmenu=1;
1949 if(mainmenu==4)mainmenu=3;
1950 if(mainmenu==6)mainmenu=5;
1951 if(mainmenu==7)mainmenu=1;
1952 if(mainmenu==9)mainmenu=5;
1953 if(mainmenu==11)mainmenu=5;
1954 if(mainmenu==12)mainmenu=5;
1955 if(mainmenu==13)mainmenu=12;
1956 if(mainmenu==14)mainmenu=13;
1957 if(mainmenu==10)mainmenu=5;
1963 mainmenutogglekeydown=1;
1965 if(!IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)){
1966 mainmenutogglekeydown=0;
1970 /*static bool minimaptogglekeydown;
1971 if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!minimaptogglekeydown){
1973 minimaptogglekeydown=1;
1975 if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)){
1976 minimaptogglekeydown=0;
1980 static bool minimaptogglekeydown;
1981 if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!minimaptogglekeydown&&tutoriallevel){
1982 if(tutorialstage!=51)
1983 tutorialstagetime=tutorialmaxtime;
1984 PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, TRUE);
1985 FSOUND_SetVolume(channels[consolefailsound], 128);
1986 FSOUND_SetPaused(channels[consolefailsound], FALSE);
1987 minimaptogglekeydown=1;
1989 if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)){
1990 minimaptogglekeydown=0;
1995 if(mainmenu==1||mainmenu==2){
1996 if(Button()&&!oldbutton&&selected==1){
1998 float gLoc[3]={0,0,0};
1999 float vel[3]={0,0,0};
2000 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2001 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2002 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2003 FSOUND_SetVolume(channels[firestartsound], 256);
2004 FSOUND_SetPaused(channels[firestartsound], FALSE);
2005 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2014 if(accountactive!=-1)mainmenu=5;
2021 if(firstload)TickOnceAfter();
2022 if(!firstload)LoadStuff();
2028 FSOUND_SetPaused(channels[music3], TRUE); */
2034 FSOUND_SetPaused(channels[stream_music3], TRUE);
2035 FSOUND_SetPaused(channels[music1], FALSE);
2039 if(Button()&&!oldbutton&&selected==2){
2040 float gLoc[3]={0,0,0};
2041 float vel[3]={0,0,0};
2042 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2043 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2044 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2045 FSOUND_SetVolume(channels[firestartsound], 256);
2046 FSOUND_SetPaused(channels[firestartsound], FALSE);
2047 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2059 if(newdetail>2)newdetail=detail;
2060 if(newdetail<0)newdetail=detail;
2061 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2062 if(newscreenwidth<0)newscreenwidth=screenwidth;
2063 if(newscreenheight>3000)newscreenheight=screenheight;
2064 if(newscreenheight<0)newscreenheight=screenheight;
2067 if(Button()&&!oldbutton&&selected==3){
2068 float gLoc[3]={0,0,0};
2069 float vel[3]={0,0,0};
2070 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2071 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2072 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2073 FSOUND_SetVolume(channels[fireendsound], 256);
2074 FSOUND_SetPaused(channels[fireendsound], FALSE);
2075 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2086 if(registered)FSOUND_SetPaused(channels[stream_music3], TRUE);
2094 if(Button())oldbutton=1;
2099 if(Button()&&!oldbutton&&selected!=-1){
2100 float gLoc[3]={0,0,0};
2101 float vel[3]={0,0,0};
2102 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2103 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2104 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2105 FSOUND_SetVolume(channels[firestartsound], 256);
2106 FSOUND_SetPaused(channels[firestartsound], FALSE);
2107 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2109 if(Button()&&!oldbutton&&selected==0){
2112 if(newscreenwidth==640&&newscreenheight==480)whichres=0;
2113 if(newscreenwidth==800&&newscreenheight==600)whichres=1;
2114 if(newscreenwidth==1024&&newscreenheight==768)whichres=2;
2115 if(newscreenwidth==1280&&newscreenheight==1024)whichres=3;
2116 if(newscreenwidth==1600&&newscreenheight==1200)whichres=4;
2117 if(newscreenwidth==840&&newscreenheight==524)whichres=5;
2118 if(newscreenwidth==1024&&newscreenheight==640)whichres=6;
2119 if(newscreenwidth==1344&&newscreenheight==840)whichres=7;
2121 if(whichres==-1||whichres==7){
2123 newscreenheight=480;
2127 newscreenheight=600;
2130 newscreenwidth=1024;
2131 newscreenheight=768;
2134 newscreenwidth=1280;
2135 newscreenheight=1024;
2138 newscreenwidth=1600;
2139 newscreenheight=1200;
2143 newscreenheight=524;
2146 newscreenwidth=1024;
2147 newscreenheight=640;
2150 newscreenwidth=1344;
2151 newscreenheight=840;
2154 if(Button()&&!oldbutton&&selected==1){
2156 if(newdetail>2)newdetail=0;
2158 if(Button()&&!oldbutton&&selected==2){
2160 if(bloodtoggle>2)bloodtoggle=0;
2162 if(Button()&&!oldbutton&&selected==3){
2164 if(difficulty>2)difficulty=0;
2166 if(Button()&&!oldbutton&&selected==4){
2167 ismotionblur=1-ismotionblur;
2169 if(Button()&&!oldbutton&&selected==5){
2172 if(Button()&&!oldbutton&&selected==6){
2173 musictoggle=1-musictoggle;
2176 FSOUND_SetPaused(channels[music1], TRUE);
2177 FSOUND_SetPaused(channels[stream_music2], TRUE);
2178 FSOUND_SetPaused(channels[stream_music3], TRUE);
2181 oldmusicvolume[i]=0;
2187 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
2188 FSOUND_SetPaused(channels[stream_music3], FALSE);
2189 FSOUND_SetVolume(channels[stream_music3], 256);
2192 if(Button()&&!oldbutton&&selected==9){
2193 invertmouse=1-invertmouse;
2195 if(Button()&&!oldbutton&&selected==10){
2196 usermousesensitivity+=.2;
2197 if(usermousesensitivity>2)usermousesensitivity=.2;
2199 if(Button()&&!oldbutton&&selected==11){
2201 if(volume>1.0001f)volume=0;
2202 FSOUND_SetSFXMasterVolume((int)(volume*255));
2204 if(Button()&&!oldbutton&&selected==7){
2205 /*float gLoc[3]={0,0,0};
2206 float vel[3]={0,0,0};
2207 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2208 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2209 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2210 FSOUND_SetVolume(channels[firestartsound], 256);
2211 FSOUND_SetPaused(channels[firestartsound], FALSE);
2212 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2225 if(Button()&&!oldbutton&&selected==8){
2226 float gLoc[3]={0,0,0};
2227 float vel[3]={0,0,0};
2228 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2229 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2230 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2231 FSOUND_SetVolume(channels[fireendsound], 256);
2232 FSOUND_SetPaused(channels[fireendsound], FALSE);
2233 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2241 if(newdetail>2)newdetail=detail;
2242 if(newdetail<0)newdetail=detail;
2243 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2244 if(newscreenwidth<0)newscreenwidth=screenwidth;
2245 if(newscreenheight>3000)newscreenheight=screenheight;
2246 if(newscreenheight<0)newscreenheight=screenheight;
2249 //ofstream opstream(":Data:config.txt");
2250 ofstream opstream("./Data/config.txt");
2251 opstream << "Screenwidth:\n";
2252 opstream << newscreenwidth;
2253 opstream << "\nScreenheight:\n";
2254 opstream << newscreenheight;
2255 opstream << "\nMouse sensitivity:\n";
2256 opstream << usermousesensitivity;
2257 opstream << "\nBlur(0,1):\n";
2258 opstream << ismotionblur;
2259 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
2260 opstream << newdetail;
2261 opstream << "\nFloating jump:\n";
2262 opstream << floatjump;
2263 opstream << "\nMouse jump:\n";
2264 opstream << mousejump;
2265 opstream << "\nAmbient sound:\n";
2266 opstream << ambientsound;
2267 opstream << "\nBlood (0,1,2):\n";
2268 opstream << bloodtoggle;
2269 opstream << "\nAuto slomo:\n";
2270 opstream << autoslomo;
2271 opstream << "\nFoliage:\n";
2272 opstream << foliage;
2273 opstream << "\nMusic:\n";
2274 opstream << musictoggle;
2275 opstream << "\nTrilinear:\n";
2276 opstream << trilinear;
2277 opstream << "\nDecals(shadows,blood puddles,etc):\n";
2279 opstream << "\nInvert mouse:\n";
2280 opstream << invertmouse;
2281 opstream << "\nGamespeed:\n";
2282 if(oldgamespeed==0)oldgamespeed=1;
2283 opstream << oldgamespeed;
2284 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
2285 opstream << difficulty;
2286 opstream << "\nDamage effects(blackout, doublevision):\n";
2287 opstream << damageeffects;
2288 opstream << "\nText:\n";
2289 opstream << texttoggle;
2290 opstream << "\nDebug:\n";
2291 opstream << debugmode;
2292 opstream << "\nVBL Sync:\n";
2293 opstream << vblsync;
2294 opstream << "\nShow Points:\n";
2295 opstream << showpoints;
2296 opstream << "\nAlways Blur:\n";
2297 opstream << alwaysblur;
2298 opstream << "\nImmediate mode (turn on on G5):\n";
2299 opstream << immediate;
2300 opstream << "\nVelocity blur:\n";
2301 opstream << velocityblur;
2302 opstream << "\nVolume:\n";
2304 opstream << "\nForward key:\n";
2305 opstream << KeyToChar(forwardkey);
2306 opstream << "\nBack key:\n";
2307 opstream << KeyToChar(backkey);
2308 opstream << "\nLeft key:\n";
2309 opstream << KeyToChar(leftkey);
2310 opstream << "\nRight key:\n";
2311 opstream << KeyToChar(rightkey);
2312 opstream << "\nJump key:\n";
2313 opstream << KeyToChar(jumpkey);
2314 opstream << "\nCrouch key:\n";
2315 opstream << KeyToChar(crouchkey);
2316 opstream << "\nDraw key:\n";
2317 opstream << KeyToChar(drawkey);
2318 opstream << "\nThrow key:\n";
2319 opstream << KeyToChar(throwkey);
2320 opstream << "\nAttack key:\n";
2321 opstream << KeyToChar(attackkey);
2322 opstream << "\nChat key:\n";
2323 opstream << KeyToChar(chatkey);
2326 if(mainmenu==3&&gameon)mainmenu=2;
2327 if(mainmenu==3&&!gameon)mainmenu=1;
2329 if(Button())oldbutton=1;
2333 if(Button()&&!oldbutton&&selected!=-1&&keyselect==-1){
2334 float gLoc[3]={0,0,0};
2335 float vel[3]={0,0,0};
2336 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2337 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2338 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2339 FSOUND_SetVolume(channels[firestartsound], 256);
2340 FSOUND_SetPaused(channels[firestartsound], FALSE);
2341 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2343 if(Button()&&!oldbutton&&selected<9&&keyselect==-1){
2351 if(!buttons[i]&&!oldbutton&&!Button())oldbuttons[i]=0;
2353 if((IsKeyDown(theKeyMap, i)||(buttons[0]&&!oldbuttons[0]&&!oldbutton)||(buttons[1]&&!oldbuttons[1]&&!oldbutton))&&keyselect!=-1){
2354 if(i!=MAC_ESCAPE_KEY&&(strcmp(KeyToChar(i),"unknown")||(buttons[0]&&!oldbuttons[0]&&!oldbutton)||(buttons[1]&&!oldbuttons[1]&&!oldbutton))){
2355 float gLoc[3]={0,0,0};
2356 float vel[3]={0,0,0};
2357 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2358 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2359 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2360 FSOUND_SetVolume(channels[fireendsound], 256);
2361 FSOUND_SetPaused(channels[fireendsound], FALSE);
2362 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2366 if(buttons[0]&&!oldbuttons[0])keynum=MAC_MOUSEBUTTON1;
2367 if(buttons[1]&&!oldbuttons[1])keynum=MAC_MOUSEBUTTON2;
2371 if(keyselect==0)forwardkey=keynum;
2372 if(keyselect==1)backkey=keynum;
2373 if(keyselect==2)leftkey=keynum;
2374 if(keyselect==3)rightkey=keynum;
2375 if(keyselect==4)crouchkey=keynum;
2376 if(keyselect==5)jumpkey=keynum;
2377 if(keyselect==6)drawkey=keynum;
2378 if(keyselect==7)throwkey=keynum;
2379 if(keyselect==8)attackkey=keynum;
2384 if(Button()&&!oldbutton&&selected==9){
2385 float gLoc[3]={0,0,0};
2386 float vel[3]={0,0,0};
2387 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2388 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2389 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2390 FSOUND_SetVolume(channels[fireendsound], 256);
2391 FSOUND_SetPaused(channels[fireendsound], FALSE);
2392 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2402 if(newdetail>2)newdetail=detail;
2403 if(newdetail<0)newdetail=detail;
2404 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2405 if(newscreenwidth<0)newscreenwidth=screenwidth;
2406 if(newscreenheight>3000)newscreenheight=screenheight;
2407 if(newscreenheight<0)newscreenheight=screenheight;
2412 if(accountcampaignchoicesmade[accountactive]>8&&!registered){
2413 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
2414 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
2415 FSOUND_SetPaused(channels[stream_music3], FALSE);
2416 FSOUND_SetVolume(channels[stream_music3], 256);
2420 accountcampaignchoicesmade[accountactive]=0;
2421 accountcampaignscore[accountactive]=0;
2422 accountcampaigntime[accountactive]=0;
2424 float gLoc[3]={0,0,0};
2425 float vel[3]={0,0,0};
2426 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2427 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2428 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2429 FSOUND_SetVolume(channels[fireendsound], 256);
2430 FSOUND_SetPaused(channels[fireendsound], FALSE);
2431 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2441 accountcampaignchoicesmade[accountactive]=0;
2442 accountcampaignscore[accountactive]=0;
2443 accountcampaigntime[accountactive]=0;
2447 if(Button()&&!oldbutton&&selected==1){
2448 float gLoc[3]={0,0,0};
2449 float vel[3]={0,0,0};
2450 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2451 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2452 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2453 FSOUND_SetVolume(channels[firestartsound], 256);
2454 FSOUND_SetPaused(channels[firestartsound], FALSE);
2455 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2468 if(firstload)TickOnceAfter();
2469 if(!firstload)LoadStuff();
2476 FSOUND_SetPaused(channels[stream_music3], TRUE);
2478 if(Button()&&!oldbutton&&selected-7>=accountcampaignchoicesmade[accountactive]){//selected>=7&&(selected-7<=campaignnumchoices)){
2479 float gLoc[3]={0,0,0};
2480 float vel[3]={0,0,0};
2481 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2482 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2483 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2484 FSOUND_SetVolume(channels[firestartsound], 256);
2485 FSOUND_SetPaused(channels[firestartsound], FALSE);
2486 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2499 if(firstload)TickOnceAfter();
2500 if(!firstload)LoadStuff();
2516 strcat(mapname,campaignmapname[campaignchoicewhich[selected-7-accountcampaignchoicesmade[accountactive]]]);
2517 whichchoice=selected-7-accountcampaignchoicesmade[accountactive];
2521 //Loadlevel(campaignmapname[levelorder[selected-7]]);
2526 FSOUND_SetPaused(channels[stream_music3], TRUE);
2528 if(Button()&&!oldbutton&&selected==4){
2529 float gLoc[3]={0,0,0};
2530 float vel[3]={0,0,0};
2531 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2532 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2533 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2534 FSOUND_SetVolume(channels[fireendsound], 256);
2535 FSOUND_SetPaused(channels[fireendsound], FALSE);
2536 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2544 if(mainmenu==5&&gameon)mainmenu=2;
2545 if(mainmenu==5&&!gameon)mainmenu=1;
2547 if(Button()&&!oldbutton&&selected==5){
2548 float gLoc[3]={0,0,0};
2549 float vel[3]={0,0,0};
2550 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2551 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2552 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2553 FSOUND_SetVolume(channels[fireendsound], 256);
2554 FSOUND_SetPaused(channels[fireendsound], FALSE);
2555 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2565 if(Button()&&!oldbutton&&selected==3){
2566 float gLoc[3]={0,0,0};
2567 float vel[3]={0,0,0};
2568 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2569 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2570 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2571 FSOUND_SetVolume(channels[firestartsound], 256);
2572 FSOUND_SetPaused(channels[firestartsound], FALSE);
2573 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2583 if(Button()&&!oldbutton&&selected==2){
2584 float gLoc[3]={0,0,0};
2585 float vel[3]={0,0,0};
2586 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2587 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2588 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2589 FSOUND_SetVolume(channels[firestartsound], 256);
2590 FSOUND_SetPaused(channels[firestartsound], FALSE);
2591 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2601 if(Button())oldbutton=1;
2605 if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountprogress[accountactive]){
2606 float gLoc[3]={0,0,0};
2607 float vel[3]={0,0,0};
2608 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2609 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2610 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2611 FSOUND_SetVolume(channels[firestartsound], 256);
2612 FSOUND_SetPaused(channels[firestartsound], FALSE);
2613 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2625 targetlevel=selected;
2626 if(firstload)TickOnceAfter();
2627 if(!firstload)LoadStuff();
2629 Loadlevel(selected);
2635 FSOUND_SetPaused(channels[stream_music3], TRUE);
2637 if(Button()&&!oldbutton&&selected==numchallengelevels){
2638 float gLoc[3]={0,0,0};
2639 float vel[3]={0,0,0};
2640 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2641 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2642 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2643 FSOUND_SetVolume(channels[fireendsound], 256);
2644 FSOUND_SetPaused(channels[fireendsound], FALSE);
2645 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 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;
2714 if(Button()&&!oldbutton&&selected==3){
2715 float gLoc[3]={0,0,0};
2716 float vel[3]={0,0,0};
2717 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2718 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2719 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2720 FSOUND_SetVolume(channels[fireendsound], 256);
2721 FSOUND_SetPaused(channels[fireendsound], FALSE);
2722 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2732 if(Button())oldbutton=1;
2736 if(mainmenu==15||mainmenu==16){
2737 if(Button()&&!oldbutton&&selected==1){
2738 float gLoc[3]={0,0,0};
2739 float vel[3]={0,0,0};
2740 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2741 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2742 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2743 FSOUND_SetVolume(channels[fireendsound], 256);
2744 FSOUND_SetPaused(channels[fireendsound], FALSE);
2745 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2753 if(mainmenu==15)mainmenu=5;
2756 if(Button())oldbutton=1;
2762 if(Button()&&!oldbutton&&selected==3){
2764 float gLoc[3]={0,0,0};
2765 float vel[3]={0,0,0};
2766 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2767 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2768 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2769 FSOUND_SetVolume(channels[fireendsound], 256);
2770 FSOUND_SetPaused(channels[fireendsound], FALSE);
2771 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2782 if(Button()&&!oldbutton&&selected==4){
2785 float gLoc[3]={0,0,0};
2786 float vel[3]={0,0,0};
2787 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2788 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2789 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2790 FSOUND_SetVolume(channels[fireendsound], 256);
2791 FSOUND_SetPaused(channels[fireendsound], FALSE);
2792 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2802 if(Button()&&!oldbutton&&selected==5){
2804 float gLoc[3]={0,0,0};
2805 float vel[3]={0,0,0};
2806 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2807 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2808 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2809 FSOUND_SetVolume(channels[fireendsound], 256);
2810 FSOUND_SetPaused(channels[fireendsound], FALSE);
2811 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2821 if(Button())oldbutton=1;
2825 if(Button()&&!oldbutton&&selected!=-1){
2826 float gLoc[3]={0,0,0};
2827 float vel[3]={0,0,0};
2828 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2829 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2830 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2831 FSOUND_SetVolume(channels[firestartsound], 256);
2832 FSOUND_SetPaused(channels[firestartsound], FALSE);
2833 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2835 if(Button()&&!oldbutton&&selected==1){
2836 float gLoc[3]={0,0,0};
2837 float vel[3]={0,0,0};
2838 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2839 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2840 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2841 FSOUND_SetVolume(channels[fireendsound], 256);
2842 FSOUND_SetPaused(channels[fireendsound], FALSE);
2843 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2851 for(i=accountactive;i<numaccounts-1;i++){
2852 accountdifficulty[i]=accountdifficulty[i+1];
2853 accountcampaignchoicesmade[i]=accountcampaignchoicesmade[i+1];
2854 for(j=0;j<accountcampaignchoicesmade[i+1];j++){
2855 accountcampaignchoices[i][j]=accountcampaignchoices[i+1][j];
2857 accountpoints[i]=accountpoints[i+1];
2859 accounthighscore[i][j]=accounthighscore[i+1][j];
2860 accountfasttime[i][j]=accountfasttime[i+1][j];
2863 accountunlocked[i][j]=accountunlocked[i+1][j];
2866 accountname[i][j]=accountname[i+1][j];
2868 accountcampaignhighscore[i]=accountcampaignhighscore[i+1];
2869 accountprogress[i]=accountprogress[i+1];
2870 accountcampaignfasttime[i]=accountcampaignfasttime[i+1];
2871 accountcampaignscore[i]=accountcampaignscore[i+1];
2872 accountcampaigntime[i]=accountcampaigntime[i+1];
2881 if(Button()&&!oldbutton&&selected==2){
2882 float gLoc[3]={0,0,0};
2883 float vel[3]={0,0,0};
2884 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2885 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2886 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2887 FSOUND_SetVolume(channels[fireendsound], 256);
2888 FSOUND_SetPaused(channels[fireendsound], FALSE);
2889 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2899 if(Button())oldbutton=1;
2903 if(Button()&&!oldbutton&&selected!=-1){
2904 float gLoc[3]={0,0,0};
2905 float vel[3]={0,0,0};
2906 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2907 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2908 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2909 FSOUND_SetVolume(channels[firestartsound], 256);
2910 FSOUND_SetPaused(channels[firestartsound], FALSE);
2911 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2913 if(Button()&&!oldbutton&&selected==0&&numaccounts<8){
2916 if(Button()&&!oldbutton&&selected>0&&selected<numaccounts+1){
2917 accountactive=selected-1;
2925 if(Button()&&!oldbutton&&selected==numaccounts+1){
2926 float gLoc[3]={0,0,0};
2927 float vel[3]={0,0,0};
2928 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2929 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2930 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2931 FSOUND_SetVolume(channels[fireendsound], 256);
2932 FSOUND_SetPaused(channels[fireendsound], FALSE);
2933 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2944 displaytext[0][j]=' ';
2950 if(Button())oldbutton=1;
2954 if(Button()&&!oldbutton&&selected!=-1){
2955 float gLoc[3]={0,0,0};
2956 float vel[3]={0,0,0};
2957 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2958 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2959 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2960 FSOUND_SetVolume(channels[firestartsound], 256);
2961 FSOUND_SetPaused(channels[firestartsound], FALSE);
2962 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2964 if(selected==0)accountdifficulty[accountactive]=0;
2965 if(selected==1)accountdifficulty[accountactive]=1;
2966 if(selected==2)accountdifficulty[accountactive]=2;
2977 if(Button())oldbutton=1;
2982 if(Button())oldbutton=1;
2985 if(IsKeyDown(theKeyMap, MAC_Q_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)){
2988 if(newdetail>2)newdetail=detail;
2989 if(newdetail<0)newdetail=detail;
2990 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2991 if(newscreenwidth<0)newscreenwidth=screenwidth;
2992 if(newscreenheight>3000)newscreenheight=screenheight;
2993 if(newscreenheight<0)newscreenheight=screenheight;
2995 //ofstream opstream(":Data:config.txt");
2996 ofstream opstream("./Data/config.txt");
2997 opstream << "Screenwidth:\n";
2998 opstream << newscreenwidth;
2999 opstream << "\nScreenheight:\n";
3000 opstream << newscreenheight;
3001 opstream << "\nMouse sensitivity:\n";
3002 opstream << usermousesensitivity;
3003 opstream << "\nBlur(0,1):\n";
3004 opstream << ismotionblur;
3005 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
3006 opstream << newdetail;
3007 opstream << "\nFloating jump:\n";
3008 opstream << floatjump;
3009 opstream << "\nMouse jump:\n";
3010 opstream << mousejump;
3011 opstream << "\nAmbient sound:\n";
3012 opstream << ambientsound;
3013 opstream << "\nBlood (0,1,2):\n";
3014 opstream << bloodtoggle;
3015 opstream << "\nAuto slomo:\n";
3016 opstream << autoslomo;
3017 opstream << "\nFoliage:\n";
3018 opstream << foliage;
3019 opstream << "\nMusic:\n";
3020 opstream << musictoggle;
3021 opstream << "\nTrilinear:\n";
3022 opstream << trilinear;
3023 opstream << "\nDecals(shadows,blood puddles,etc):\n";
3025 opstream << "\nInvert mouse:\n";
3026 opstream << invertmouse;
3027 opstream << "\nGamespeed:\n";
3028 if(oldgamespeed==0)oldgamespeed=1;
3029 opstream << oldgamespeed;
3030 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
3031 opstream << difficulty;
3032 opstream << "\nDamage effects(blackout, doublevision):\n";
3033 opstream << damageeffects;
3034 opstream << "\nText:\n";
3035 opstream << texttoggle;
3036 opstream << "\nDebug:\n";
3037 opstream << debugmode;
3038 opstream << "\nVBL Sync:\n";
3039 opstream << vblsync;
3040 opstream << "\nShow Points:\n";
3041 opstream << showpoints;
3042 opstream << "\nAlways Blur:\n";
3043 opstream << alwaysblur;
3044 opstream << "\nImmediate mode (turn on on G5):\n";
3045 opstream << immediate;
3046 opstream << "\nVelocity blur:\n";
3047 opstream << velocityblur;
3048 opstream << "\nVolume:\n";
3050 opstream << "\nForward key:\n";
3051 opstream << KeyToChar(forwardkey);
3052 opstream << "\nBack key:\n";
3053 opstream << KeyToChar(backkey);
3054 opstream << "\nLeft key:\n";
3055 opstream << KeyToChar(leftkey);
3056 opstream << "\nRight key:\n";
3057 opstream << KeyToChar(rightkey);
3058 opstream << "\nJump key:\n";
3059 opstream << KeyToChar(jumpkey);
3060 opstream << "\nCrouch key:\n";
3061 opstream << KeyToChar(crouchkey);
3062 opstream << "\nDraw key:\n";
3063 opstream << KeyToChar(drawkey);
3064 opstream << "\nThrow key:\n";
3065 opstream << KeyToChar(throwkey);
3066 opstream << "\nAttack key:\n";
3067 opstream << KeyToChar(attackkey);
3068 opstream << "\nChat key:\n";
3069 opstream << KeyToChar(chatkey);
3074 if(mainmenu==1||mainmenu==2){
3075 if(loaddistrib>4)transition+=multiplier/8;
3083 FSOUND_SetFrequency(channels[stream_music3], 22050);
3085 if(entername||mainmenu==13||mainmenu==14){
3087 if(IsKeyDown(theKeyMap, i)){
3088 togglekeydelay[i]+=multiplier;
3089 if(togglekeydelay[i]>.4){
3091 togglekeydelay[i]=.36;
3094 if(KeyToSingleChar(i)!='\0'&&displaychars[0]<60){
3095 for(j=255;j>=displayselected+1;j--){
3096 displaytext[0][j]=displaytext[0][j-1];
3098 displaytext[0][displayselected]=KeyToSingleChar(i);
3099 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]);
3103 if(i==MAC_DELETE_KEY&&displayselected!=0){
3104 for(j=displayselected-1;j<255;j++){
3105 displaytext[0][j]=displaytext[0][j+1];
3107 displaytext[0][255]=' ';
3111 if(i==MAC_ARROW_LEFT_KEY&&displayselected!=0){
3114 if(i==MAC_ARROW_RIGHT_KEY&&displayselected<displaychars[0]){
3117 if(i==MAC_RETURN_KEY&&entername){
3118 if(displaychars[0]){
3120 strcpy(accountname[numaccounts-1],displaytext[0]);
3121 accountactive=numaccounts-1;
3122 accountdifficulty[accountactive]=1;
3123 accountprogress[accountactive]=0;
3124 accountpoints[accountactive]=0;
3125 accountcampaigntime[accountactive]=0;
3126 accountcampaignscore[accountactive]=0;
3127 accountcampaignfasttime[accountactive]=0;
3128 accountcampaignhighscore[accountactive]=0;
3130 accounthighscore[accountactive][j]=0;
3131 accountfasttime[accountactive][j]=0;
3134 accountunlocked[accountactive][j]=0;
3136 accountcampaignchoicesmade[accountactive]=0;
3139 displaytext[0][j]=' ';
3153 float gLoc[3]={0,0,0};
3154 float vel[3]={0,0,0};
3155 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3156 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
3157 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3158 FSOUND_SetVolume(channels[firestartsound], 256);
3159 FSOUND_SetPaused(channels[firestartsound], FALSE);
3160 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3163 displaytext[0][j]=' ';
3171 if(i==MAC_RETURN_KEY&&mainmenu==14){
3172 if(displaychars[0]){
3173 char serialstring[256];
3174 char tempstring[256];
3175 sprintf (tempstring, "%s-windows", registrationname);
3181 longnum = MD5_string ( tempstring);
3182 //longnum = 1111111111111111;
3183 num1 = longnum/100000000;
3184 num2 = longnum%100000000;
3185 sprintf (tempstring, "%d-%d-%d-%d\0\0\0\0\0", num1/10000, num1%10000, num2/10000, num2%10000);
3189 if(num1/10000>999)numchars+=4;
3190 else if(num1/10000>99)numchars+=3;
3191 else if(num1/10000>9)numchars+=2;
3193 if(num1%10000>999)numchars+=4;
3194 else if(num1%10000>99)numchars+=3;
3195 else if(num1%10000>9)numchars+=2;
3197 if(num2/10000>999)numchars+=4;
3198 else if(num2/10000>99)numchars+=3;
3199 else if(num2/10000>9)numchars+=2;
3201 if(num2%10000>999)numchars+=4;
3202 else if(num2%10000>99)numchars+=3;
3203 else if(num2%10000>9)numchars+=2;
3208 for(j=0;j<numchars;j++){
3209 if(displaytext[0][j]!=tempstring[j]&&tempstring[j]!=' '&&tempstring[j]!='\0')goodcode--;
3212 if(longnum==LONGLONGCONST(5077041556214789))goodcode=-1;
3214 if(goodcode<0)goodcode=0;
3221 tfile=fopen( ":Data:Sounds:flame.ogg", "wb" );
3225 numchars=strlen(registrationname);
3226 fpackf(tfile, "Bb", registered);
3227 fpackf(tfile, "Bi", numchars);
3230 for(j=0;j<numchars;j++)
3232 fpackf(tfile, "Bb", registrationname[j]);
3235 fpackf(tfile, "Bi", num1);
3236 fpackf(tfile, "Bi", num2);
3250 float gLoc[3]={0,0,0};
3251 float vel[3]={0,0,0};
3252 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3253 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
3254 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3255 FSOUND_SetVolume(channels[firestartsound], 256);
3256 FSOUND_SetPaused(channels[firestartsound], FALSE);
3257 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3260 displaytext[0][j]=' ';
3266 if(i==MAC_RETURN_KEY&&mainmenu==13){
3267 if(displaychars[0]){
3268 sprintf (registrationname, "%s", displaytext[0]);
3269 if(displaychars[0]<254)registrationname[displaychars[0]]='\0';
3279 float gLoc[3]={0,0,0};
3280 float vel[3]={0,0,0};
3281 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3282 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
3283 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3284 FSOUND_SetVolume(channels[firestartsound], 256);
3285 FSOUND_SetPaused(channels[firestartsound], FALSE);
3286 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3289 displaytext[0][j]=' ';
3293 /*char tempstring[50];
3294 sprintf (tempstring, registrationname);
3300 longnum = MD5_string ( tempstring);
3301 num1 = longnum/100000000;
3302 num2 = longnum%100000000;
3303 sprintf (displaytext[0], "%d-%d-%d-%d", num1/10000, num1%10000, num2/10000, num2%10000);
3305 displaychars[0]=strlen(displaytext[0]);
3314 togglekeydelay[i]=0;
3318 displayblinkdelay-=multiplier;
3319 if(displayblinkdelay<=0){
3320 displayblinkdelay=.3;
3321 displayblink=1-displayblink;
3327 if(hostile==1)hostiletime+=multiplier;
3329 if(!winfreeze)leveltime+=multiplier;
3330 if(IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)){
3337 if(IsKeyDown(theKeyMap, chatkey)&&!chattogglekeydown&&!console&&!chatting&&debugmode){
3339 chattogglekeydown=1;
3340 togglekey[chatkey]=1;
3341 togglekeydelay[chatkey]=-20;
3344 if(!IsKeyDown(theKeyMap, chatkey)){
3345 chattogglekeydown=0;
3350 if(IsKeyDown(theKeyMap, i)){
3351 togglekeydelay[i]+=multiplier;
3352 if(togglekeydelay[i]>.4){
3354 togglekeydelay[i]=.36;
3357 if(KeyToSingleChar(i)!='\0'&&displaychars[0]<60){
3358 for(j=255;j>=displayselected+1;j--){
3359 displaytext[0][j]=displaytext[0][j-1];
3361 displaytext[0][displayselected]=KeyToSingleChar(i);
3362 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]);
3366 if(i==MAC_DELETE_KEY&&displayselected!=0){
3367 for(j=displayselected-1;j<255;j++){
3368 displaytext[0][j]=displaytext[0][j+1];
3370 displaytext[0][255]=' ';
3374 if(i==MAC_ARROW_LEFT_KEY&&displayselected!=0){
3377 if(i==MAC_ARROW_RIGHT_KEY&&displayselected<displaychars[0]){
3380 if(i==MAC_RETURN_KEY){
3381 if(displaychars[0]){
3382 /*for(j=0;j<displaychars[0];j++){
3383 talkname[j]=displaytext[0][j];
3385 talkname[displaychars[0]]='\0';
3386 sprintf (chatname, "%s: %s",playerName,talkname);
3387 //NetworkSendInformation(chatname);
3390 displaytext[0][j]=' ';
3402 togglekeydelay[i]=0;
3406 displayblinkdelay-=multiplier;
3407 if(displayblinkdelay<=0){
3408 displayblinkdelay=.3;
3409 displayblink=1-displayblink;
3413 if(chatting)keyboardfrozen=1;
3415 if(IsKeyDown(theKeyMap, MAC_V_KEY)&&!freezetogglekeydown&&debugmode){
3418 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
3420 freezetogglekeydown=1;
3423 if(!IsKeyDown(theKeyMap, MAC_V_KEY)&&!IsKeyDown(theKeyMap, MAC_F1_KEY)){
3424 freezetogglekeydown=0;
3427 if(IsKeyDown(theKeyMap, MAC_TILDE_KEY)&&!consoletogglekeydown&&debugmode){
3429 if(!console)freeze=0;
3431 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
3433 consoletogglekeydown=1;
3436 if(!IsKeyDown(theKeyMap, MAC_TILDE_KEY)){
3437 consoletogglekeydown=0;
3440 if(console)freeze=1;
3442 if(console&&!IsKeyDown(theKeyMap,MAC_COMMAND_KEY)){
3444 if(IsKeyDown(theKeyMap, i)){
3445 togglekeydelay[i]+=multiplier;
3446 if(togglekeydelay[i]>.4){
3448 togglekeydelay[i]=.36;
3451 if(KeyToSingleChar(i)!='\0'&&consolechars[0]<255){
3452 for(j=255;j>=consoleselected+1;j--){
3453 consoletext[0][j]=consoletext[0][j-1];
3455 consoletext[0][consoleselected]=KeyToSingleChar(i);
3456 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))consoletext[0][consoleselected]=Shift(consoletext[0][consoleselected]);
3460 else if(i==MAC_ENTER_KEY){
3461 for(j=255;j>=consoleselected+1;j--){
3462 consoletext[0][j]=consoletext[0][j-1];
3464 consoletext[0][consoleselected]='\n';
3468 if(i==MAC_DELETE_KEY&&consoleselected!=0){
3469 for(j=consoleselected-1;j<255;j++){
3470 consoletext[0][j]=consoletext[0][j+1];
3472 consoletext[0][255]=' ';
3476 if(i==MAC_ARROW_UP_KEY){
3477 if(archiveselected<14)archiveselected++;
3479 consolechars[0]=consolechars[archiveselected];
3480 consoletext[0][j]=consoletext[archiveselected][j];
3481 consoleselected=consolechars[0];
3484 if(i==MAC_ARROW_DOWN_KEY){
3485 if(archiveselected>0)archiveselected--;
3487 consolechars[0]=consolechars[archiveselected];
3488 consoletext[0][j]=consoletext[archiveselected][j];
3489 consoleselected=consolechars[0];
3492 if(i==MAC_ARROW_LEFT_KEY&&consoleselected!=0){
3495 if(i==MAC_ARROW_RIGHT_KEY&&consoleselected<consolechars[0]){
3498 if(i==MAC_RETURN_KEY){
3501 if(Compare(consoletext[0],"quit ",0,4)||Compare(consoletext[0],"exit ",0,4)){
3502 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
3503 FSOUND_SetVolume(channels[consolesuccesssound], 256);
3504 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
3508 /*if(Compare(consoletext[0],"send ",0,4)){
3509 for(j=5;j<consolechars[0];j++){
3510 talkname[j-5]=consoletext[0][j];
3512 talkname[consolechars[0]-5]='\0';
3513 sprintf (chatname, "%s: %s",playerName,talkname);
3514 //NetworkSendInformation(chatname);
3517 if(Compare(consoletext[0],"name ",0,4)){
3519 numchars=consolechars[0]-5;
3520 if(numchars>32)numchars=32;
3521 for(j=5;j<numchars+5;j++){
3522 talkname[j-5]=consoletext[0][j];
3524 talkname[numchars]='\0';
3525 sprintf (chatname, "Player %s is now known as %s.",playerName,talkname);
3526 //NetworkSendInformation(chatname);
3527 sprintf (playerName, "%s",talkname);
3528 //NetworkSendName(playerName);
3531 if(Compare(consoletext[0],"map ",0,3)){
3543 for(j=4;j<consolechars[0];j++){
3544 mapname[j-4+11]=consoletext[0][j];
3546 mapname[consolechars[0]-4+11]='\0';
3552 /*if(Compare(consoletext[0],"connect ",0,7)&&!ishost){
3554 unsigned char playerNameStr[32];
3555 char theIPAddress[256];
3557 NMUInt32 port = 25710;
3559 strcpy(playerName, "Client");
3560 GameC2PStr( playerName, playerNameStr );
3562 for(j=0;j<consolechars[0]-8;j++){
3563 theIPAddress[j]=consoletext[0][j+8];
3565 theIPAddress[consolechars[0]-8]='\0';
3567 sprintf( thePort, "%li", port );
3568 v=NetworkStartClient( theIPAddress, thePort, playerNameStr );
3571 if(consolechars[0]>0){
3574 consoletext[k][j]=consoletext[k-1][j];
3576 consolechars[k]=consolechars[k-1];
3579 consoletext[0][j]=' ';
3581 if(v!=-4994)sprintf (consoletext[0], "Error #%d!!!",v);
3582 else sprintf (consoletext[0], "Could not open connection");
3584 consolechars[0]=255;
3591 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
3592 FSOUND_SetVolume(channels[consolesuccesssound], 256);
3593 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
3595 if(consolechars[0]>0){
3598 consoletext[k][j]=consoletext[k-1][j];
3600 consolechars[k]=consolechars[k-1];
3603 consoletext[0][j]=' ';
3605 sprintf (consoletext[0], "Connected to %s",theIPAddress);
3607 consolechars[0]=255;
3613 if(Compare(consoletext[0],"host ",0,4)){
3614 unsigned char gameNameStr[32], playerNameStr[32];
3615 char gameName[32];//, playerName[32];
3623 strcpy(gameName, "Host's game");
3624 strcpy(playerName, "Host");
3625 GameC2PStr( gameName, gameNameStr );
3626 GameC2PStr( playerName, playerNameStr );
3628 v=NetworkStartServer( (NMUInt16)port, players, gameNameStr, playerNameStr );
3631 if(consolechars[0]>0){
3634 consoletext[k][j]=consoletext[k-1][j];
3636 consolechars[k]=consolechars[k-1];
3639 consoletext[0][j]=' ';
3641 sprintf (consoletext[0], "Error #%d!!!",v);
3643 consolechars[0]=255;
3650 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
3651 FSOUND_SetVolume(channels[consolesuccesssound], 256);
3652 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
3654 if(consolechars[0]>0){
3657 consoletext[k][j]=consoletext[k-1][j];
3659 consolechars[k]=consolechars[k-1];
3662 consoletext[0][j]=' ';
3664 sprintf (consoletext[0], "Game hosted");
3666 consolechars[0]=255;
3672 if(Compare(consoletext[0],"save ",0,4)){
3684 for(j=5;j<consolechars[0];j++){
3685 mapname[j-5+11]=consoletext[0][j];
3687 mapname[consolechars[0]-5+11]='\0';
3689 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
3690 FSOUND_SetVolume(channels[consolesuccesssound], 256);
3691 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
3698 tfile=fopen( mapname, "wb" );
3699 fpackf(tfile, "Bi", mapvers);
3700 //fpackf(tfile, "Bi", indemo);
3701 fpackf(tfile, "Bi", maptype);
3702 fpackf(tfile, "Bi", hostile);
3703 fpackf(tfile, "Bf Bf", viewdistance, fadestart);
3704 fpackf(tfile, "Bb Bf Bf Bf", skyboxtexture, skyboxr, skyboxg, skyboxb);
3705 fpackf(tfile, "Bf Bf Bf", skyboxlightr, skyboxlightg, skyboxlightb);
3706 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);
3707 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3708 for(j=0;j<player[0].num_weapons;j++){
3709 fpackf(tfile, "Bi", weapons.type[player[0].weaponids[j]]);
3712 fpackf(tfile, "Bf Bf Bf", player[0].armorhead, player[0].armorhigh, player[0].armorlow);
3713 fpackf(tfile, "Bf Bf Bf", player[0].protectionhead, player[0].protectionhigh, player[0].protectionlow);
3714 fpackf(tfile, "Bf Bf Bf", player[0].metalhead, player[0].metalhigh, player[0].metallow);
3715 fpackf(tfile, "Bf Bf", player[0].power, player[0].speedmult);
3717 fpackf(tfile, "Bi", player[0].numclothes);
3719 fpackf(tfile, "Bi Bi", player[0].whichskin, player[0].creature);
3721 fpackf(tfile, "Bi", numdialogues);
3723 for(k=0;k<numdialogues;k++){
3724 fpackf(tfile, "Bi", numdialogueboxes[k]);
3725 fpackf(tfile, "Bi", dialoguetype[k]);
3727 fpackf(tfile, "Bf Bf Bf", participantlocation[k][l].x, participantlocation[k][l].y, participantlocation[k][l].z);
3728 fpackf(tfile, "Bf", participantrotation[k][l]);
3730 if(numdialogueboxes)
3731 for(l=0;l<numdialogueboxes[k];l++){
3732 fpackf(tfile, "Bi", dialogueboxlocation[k][l]);
3733 fpackf(tfile, "Bf", dialogueboxcolor[k][l][0]);
3734 fpackf(tfile, "Bf", dialogueboxcolor[k][l][1]);
3735 fpackf(tfile, "Bf", dialogueboxcolor[k][l][2]);
3736 fpackf(tfile, "Bi", dialogueboxsound[k][l]);
3738 templength=strlen(dialoguetext[k][l]);
3739 fpackf(tfile, "Bi",(templength));
3740 for(m=0;m<templength;m++){
3741 fpackf(tfile, "Bb", dialoguetext[k][l][m]);
3742 if(dialoguetext[k][l][m]=='\0')break;
3745 templength=strlen(dialoguename[k][l]);
3746 fpackf(tfile, "Bi",templength);
3747 for(m=0;m<templength;m++){
3748 fpackf(tfile, "Bb", dialoguename[k][l][m]);
3749 if(dialoguename[k][l][m]=='\0')break;
3752 fpackf(tfile, "Bf Bf Bf", dialoguecamera[k][l].x, dialoguecamera[k][l].y, dialoguecamera[k][l].z);
3753 fpackf(tfile, "Bi", participantfocus[k][l]);
3754 fpackf(tfile, "Bi", participantaction[k][l]);
3757 fpackf(tfile, "Bf Bf Bf", participantfacing[k][l][m].x, participantfacing[k][l][m].y, participantfacing[k][l][m].z);
3759 fpackf(tfile, "Bf Bf",dialoguecamerarotation[k][l],dialoguecamerarotation2[k][l]);
3763 if(player[0].numclothes)
3764 for(k=0;k<player[0].numclothes;k++){
3765 templength=strlen(player[0].clothes[k]);
3766 fpackf(tfile, "Bi", templength);
3767 for(l=0;l<templength;l++)
3768 fpackf(tfile, "Bb", player[0].clothes[k][l]);
3769 fpackf(tfile, "Bf Bf Bf", player[0].clothestintr[k], player[0].clothestintg[k], player[0].clothestintb[k]);
3772 fpackf(tfile, "Bi", environment);
3774 fpackf(tfile, "Bi", objects.numobjects);
3776 if(objects.numobjects)
3777 for(k=0;k<objects.numobjects;k++){
3778 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]);
3781 fpackf(tfile, "Bi", numhotspots);
3783 for(i=0;i<numhotspots;i++){
3784 fpackf(tfile, "Bi Bf Bf Bf Bf", hotspottype[i],hotspotsize[i],hotspot[i].x,hotspot[i].y,hotspot[i].z);
3785 templength=strlen(hotspottext[i]);
3786 fpackf(tfile, "Bi",templength);
3787 for(l=0;l<templength;l++)
3788 fpackf(tfile, "Bb", hotspottext[i][l]);
3791 fpackf(tfile, "Bi", numplayers);
3792 if(numplayers>1&&numplayers<maxplayers)
3793 for(j=1;j<numplayers;j++){
3794 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);
3795 if(player[j].num_weapons>0&&player[j].num_weapons<5)
3796 for(k=0;k<player[j].num_weapons;k++){
3797 fpackf(tfile, "Bi", weapons.type[player[j].weaponids[k]]);
3799 if(player[j].numwaypoints<30){
3800 fpackf(tfile, "Bi", player[j].numwaypoints);
3801 for(k=0;k<player[j].numwaypoints;k++){
3802 fpackf(tfile, "Bf", player[j].waypoints[k].x);
3803 fpackf(tfile, "Bf", player[j].waypoints[k].y);
3804 fpackf(tfile, "Bf", player[j].waypoints[k].z);
3805 fpackf(tfile, "Bi", player[j].waypointtype[k]);
3807 fpackf(tfile, "Bi", player[j].waypoint);
3810 player[j].numwaypoints=0;
3811 player[j].waypoint=0;
3812 fpackf(tfile, "Bi Bi Bi", player[j].numwaypoints, player[j].waypoint, player[j].waypoint);
3815 fpackf(tfile, "Bf Bf Bf", player[j].armorhead, player[j].armorhigh, player[j].armorlow);
3816 fpackf(tfile, "Bf Bf Bf", player[j].protectionhead, player[j].protectionhigh, player[j].protectionlow);
3817 fpackf(tfile, "Bf Bf Bf", player[j].metalhead, player[j].metalhigh, player[j].metallow);
3818 fpackf(tfile, "Bf Bf", player[j].power, player[j].speedmult);
3820 if(player[j].creature==wolftype){
3821 headprop=player[j].proportionhead.x/1.1;
3822 bodyprop=player[j].proportionbody.x/1.1;
3823 armprop=player[j].proportionarms.x/1.1;
3824 legprop=player[j].proportionlegs.x/1.1;
3827 if(player[j].creature==rabbittype){
3828 headprop=player[j].proportionhead.x/1.2;
3829 bodyprop=player[j].proportionbody.x/1.05;
3830 armprop=player[j].proportionarms.x/1.00;
3831 legprop=player[j].proportionlegs.x/1.1;
3834 fpackf(tfile, "Bf Bf Bf Bf", headprop, bodyprop, armprop, legprop);
3838 fpackf(tfile, "Bi", player[j].numclothes);
3839 if(player[j].numclothes)
3840 for(k=0;k<player[j].numclothes;k++){
3842 templength=strlen(player[j].clothes[k]);
3843 fpackf(tfile, "Bi", templength);
3844 for(l=0;l<templength;l++)
3845 fpackf(tfile, "Bb", player[j].clothes[k][l]);
3846 fpackf(tfile, "Bf Bf Bf", player[j].clothestintr[k], player[j].clothestintg[k], player[j].clothestintb[k]);
3850 fpackf(tfile, "Bi", numpathpoints);
3852 for(j=0;j<numpathpoints;j++){
3853 fpackf(tfile, "Bf Bf Bf Bi", pathpoint[j].x, pathpoint[j].y, pathpoint[j].z, numpathpointconnect[j]);
3854 for(k=0;k<numpathpointconnect[j];k++){
3855 fpackf(tfile, "Bi", pathpointconnect[j][k]);
3859 fpackf(tfile, "Bf Bf Bf Bf", mapcenter.x, mapcenter.y, mapcenter.z, mapradius);
3867 tfile=fopen( mapname, "wb" );
3868 fwrite( &mapvers, 1, sizeof(int), tfile );
3869 fwrite( &player[0].coords.x, 1, sizeof(float), tfile );
3870 fwrite( &player[0].coords.y, 1, sizeof(float), tfile );
3871 fwrite( &player[0].coords.z, 1, sizeof(float), tfile );
3872 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
3873 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
3874 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
3875 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3876 for(j=0;j<player[0].num_weapons;j++){
3877 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
3880 fwrite( &player[0].armorhead, 1, sizeof(int), tfile );
3881 fwrite( &player[0].armorhigh, 1, sizeof(int), tfile );
3882 fwrite( &player[0].armorlow, 1, sizeof(int), tfile );
3883 fwrite( &player[0].protectionhead, 1, sizeof(int), tfile );
3884 fwrite( &player[0].protectionhigh, 1, sizeof(int), tfile );
3885 fwrite( &player[0].protectionlow, 1, sizeof(int), tfile );
3886 fwrite( &player[0].metalhead, 1, sizeof(int), tfile );
3887 fwrite( &player[0].metalhigh, 1, sizeof(int), tfile );
3888 fwrite( &player[0].metallow, 1, sizeof(int), tfile );
3889 fwrite( &player[0].power, 1, sizeof(int), tfile );
3890 fwrite( &player[0].speedmult, 1, sizeof(int), tfile );
3892 fwrite( &player[0].numclothes, 1, sizeof(int), tfile );
3893 if(player[0].numclothes)
3894 for(k=0;k<player[0].numclothes;k++){
3896 templength=strlen(player[0].clothes[k]);
3897 fwrite( &templength,1,sizeof(int),tfile);
3898 for(l=0;l<templength;l++)
3899 fwrite( &player[0].clothes[k][l],1,sizeof(char),tfile);
3900 fwrite( &player[0].clothestintr[k],1,sizeof(float),tfile);
3901 fwrite( &player[0].clothestintg[k],1,sizeof(float),tfile);
3902 fwrite( &player[0].clothestintb[k],1,sizeof(float),tfile);
3905 fwrite( &environment, 1, sizeof(int), tfile );
3907 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
3909 for(k=0;k<objects.numobjects;k++){
3910 fwrite( &objects.type[k], 1, sizeof(int), tfile );
3911 fwrite( &objects.rotation[k], 1, sizeof(float), tfile );
3912 fwrite( &objects.rotation2[k], 1, sizeof(float), tfile );
3913 fwrite( &objects.position[k].x, 1, sizeof(float), tfile );
3914 fwrite( &objects.position[k].y, 1, sizeof(float), tfile );
3915 fwrite( &objects.position[k].z, 1, sizeof(float), tfile );
3916 fwrite( &objects.scale[k], 1, sizeof(float), tfile );
3919 fwrite( &numplayers, 1, sizeof(int), tfile );
3920 if(numplayers>1&&numplayers<maxplayers)
3921 for(j=1;j<numplayers;j++){
3922 fwrite( &player[j].whichskin, 1, sizeof(int), tfile );
3923 fwrite( &player[j].creature, 1, sizeof(int), tfile );
3924 fwrite( &player[j].coords.x, 1, sizeof(float), tfile );
3925 fwrite( &player[j].coords.y, 1, sizeof(float), tfile );
3926 fwrite( &player[j].coords.z, 1, sizeof(float), tfile );
3927 fwrite( &player[j].num_weapons, 1, sizeof(int), tfile );
3928 if(player[j].num_weapons>0&&player[j].num_weapons<5)
3929 for(k=0;k<player[j].num_weapons;k++){
3930 fwrite( &weapons.type[player[j].weaponids[k]], 1, sizeof(int), tfile );
3932 if(player[j].numwaypoints<30){
3933 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
3934 for(k=0;k<player[j].numwaypoints;k++){
3935 fwrite( &player[j].waypoints[k].x, 1, sizeof(float), tfile );
3936 fwrite( &player[j].waypoints[k].y, 1, sizeof(float), tfile );
3937 fwrite( &player[j].waypoints[k].z, 1, sizeof(float), tfile );
3939 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3940 //fwrite( &player[j].jumppath, 1, sizeof(bool), tfile );
3943 player[j].numwaypoints=0;
3944 player[j].waypoint=0;
3945 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
3946 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3947 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3949 fwrite( &player[j].armorhead, 1, sizeof(int), tfile );
3950 fwrite( &player[j].armorhigh, 1, sizeof(int), tfile );
3951 fwrite( &player[j].armorlow, 1, sizeof(int), tfile );
3952 fwrite( &player[j].protectionhead, 1, sizeof(int), tfile );
3953 fwrite( &player[j].protectionhigh, 1, sizeof(int), tfile );
3954 fwrite( &player[j].protectionlow, 1, sizeof(int), tfile );
3955 fwrite( &player[j].metalhead, 1, sizeof(int), tfile );
3956 fwrite( &player[j].metalhigh, 1, sizeof(int), tfile );
3957 fwrite( &player[j].metallow, 1, sizeof(int), tfile );
3958 fwrite( &player[j].power, 1, sizeof(int), tfile );
3959 fwrite( &player[j].speedmult, 1, sizeof(int), tfile );
3961 fwrite( &player[j].numclothes, 1, sizeof(int), tfile );
3962 if(player[j].numclothes)
3963 for(k=0;k<player[j].numclothes;k++){
3965 templength=strlen(player[j].clothes[k]);
3966 fwrite( &templength,1,sizeof(int),tfile);
3967 for(l=0;l<templength;l++)
3968 fwrite( &player[j].clothes[k][l],1,sizeof(char),tfile);
3969 fwrite( &player[j].clothestintr[k],1,sizeof(float),tfile);
3970 fwrite( &player[j].clothestintg[k],1,sizeof(float),tfile);
3971 fwrite( &player[j].clothestintb[k],1,sizeof(float),tfile);
3974 fwrite( &numpathpoints, 1, sizeof(int), tfile );
3976 for(j=0;j<numpathpoints;j++){
3977 fwrite( &pathpoint[j].x, 1, sizeof(float), tfile );
3978 fwrite( &pathpoint[j].y, 1, sizeof(float), tfile );
3979 fwrite( &pathpoint[j].z, 1, sizeof(float), tfile );
3980 fwrite( &numpathpointconnect[j], 1, sizeof(int), tfile );
3981 for(k=0;k<numpathpointconnect[j];k++){
3982 fwrite( &pathpointconnect[j][k], 1, sizeof(int), tfile );
3986 fwrite( &mapcenter.x, 1, sizeof(float), tfile );
3987 fwrite( &mapcenter.y, 1, sizeof(float), tfile );
3988 fwrite( &mapcenter.z, 1, sizeof(float), tfile );
3990 fwrite( &mapradius, 1, sizeof(float), tfile );
3996 if(Compare(consoletext[0],"save ",0,4)){
4008 for(j=5;j<consolechars[0];j++){
4009 mapname[j-5+11]=consoletext[0][j];
4011 mapname[consolechars[0]-5+11]='\0';
4013 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
4014 FSOUND_SetVolume(channels[consolesuccesssound], 256);
4015 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
4018 tfile=fopen( mapname, "wb" );
4019 fwrite( &player[0].coords, 1, sizeof(XYZ), tfile );
4020 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
4021 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
4022 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
4023 if(player[0].num_weapons>0&&player[0].num_weapons<5)
4024 for(j=0;j<player[0].num_weapons;j++){
4025 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
4027 fwrite( &environment, 1, sizeof(int), tfile );
4029 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
4030 fwrite( &objects.type, 1, sizeof(int)*objects.numobjects, tfile );
4031 fwrite( &objects.rotation, 1, sizeof(float)*objects.numobjects, tfile );
4032 fwrite( &objects.position, 1, sizeof(XYZ)*objects.numobjects, tfile );
4033 fwrite( &objects.scale, 1, sizeof(float)*objects.numobjects, tfile );
4035 fwrite( &numplayers, 1, sizeof(int), tfile );
4036 if(numplayers>1&&numplayers<maxplayers)
4037 for(j=1;j<numplayers;j++){
4038 fwrite( &player[j].coords, 1, sizeof(XYZ), tfile );
4039 fwrite( &player[j].num_weapons, 1, sizeof(int), tfile );
4040 if(player[j].num_weapons>0&&player[j].num_weapons<5)
4041 for(k=0;k<player[j].num_weapons;k++){
4042 fwrite( &weapons.type[player[j].weaponids[k]], 1, sizeof(int), tfile );
4044 if(player[j].numwaypoints<30){
4045 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
4046 fwrite( &player[j].waypoints, 1, sizeof(XYZ)*player[j].numwaypoints, tfile );
4047 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4048 //fwrite( &player[j].jumppath, 1, sizeof(bool), tfile );
4051 player[j].numwaypoints=0;
4052 player[j].waypoint=0;
4053 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
4054 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4055 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4058 fwrite( &numpathpoints, 1, sizeof(int), tfile );
4060 for(j=0;j<numpathpoints;j++){
4061 fwrite( &pathpoint[j], 1, sizeof(XYZ), tfile );
4062 fwrite( &numpathpointconnect[j], 1, sizeof(int), tfile );
4063 for(k=0;k<numpathpointconnect[j];k++){
4064 fwrite( &pathpointconnect[j][k], 1, sizeof(int), tfile );
4070 if(Compare(consoletext[0],"cellar door ",0,11)||Compare(consoletext[0],"cellardoor ",0,10)){
4071 LoadTextureSave(":Data:Textures:Furdarko.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4074 /*if(Compare(consoletext[0],"Pants ",0,5)){
4075 AddClothes(":Data:Textures:Pants.png",0,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
4076 player[i].DoMipmaps(5,0,0,player[i].skeleton.skinsize,player[i].skeleton.skinsize);
4080 if(Compare(consoletext[0],"tintr ",0,5)||Compare(consoletext[0],"Tintr ",0,5)){
4081 for(j=6;j<consolechars[0];j++){
4082 mapname[j-6]=consoletext[0][j];
4085 tintr=atof(mapname);
4090 if(Compare(consoletext[0],"speed ",0,5)||Compare(consoletext[0],"Speed ",0,5)){
4091 for(j=6;j<consolechars[0];j++){
4092 mapname[j-6]=consoletext[0][j];
4095 player[0].speedmult=atof(mapname);
4100 if(Compare(consoletext[0],"strength ",0,8)||Compare(consoletext[0],"Strength ",0,8)){
4101 for(j=9;j<consolechars[0];j++){
4102 mapname[j-9]=consoletext[0][j];
4105 player[0].power=atof(mapname);
4110 if(Compare(consoletext[0],"viewdistance ",0,12)||Compare(consoletext[0],"Viewdistance ",0,12)){
4111 for(j=13;j<consolechars[0];j++){
4112 mapname[j-13]=consoletext[0][j];
4115 viewdistance=atof(mapname)*100;
4120 if(Compare(consoletext[0],"fadestart ",0,9)||Compare(consoletext[0],"Fadestart ",0,9)){
4121 for(j=10;j<consolechars[0];j++){
4122 mapname[j-10]=consoletext[0][j];
4125 fadestart=atof(mapname);
4130 if(Compare(consoletext[0],"power ",0,5)||Compare(consoletext[0],"Power ",0,5)){
4131 for(j=6;j<consolechars[0];j++){
4132 mapname[j-6]=consoletext[0][j];
4135 player[0].power=atof(mapname);
4140 if(Compare(consoletext[0],"slomo ",0,5)||Compare(consoletext[0],"Slomo ",0,5)){
4141 for(j=6;j<consolechars[0];j++){
4142 mapname[j-6]=consoletext[0][j];
4145 slomospeed=atof(mapname);
4152 if(Compare(consoletext[0],"slofreq ",0,7)||Compare(consoletext[0],"Slofreq ",0,7)){
4153 for(j=8;j<consolechars[0];j++){
4154 mapname[j-8]=consoletext[0][j];
4157 slomofreq=atoi(mapname);
4162 if(Compare(consoletext[0],"size ",0,4)||Compare(consoletext[0],"Size ",0,4)){
4163 for(j=5;j<consolechars[0];j++){
4164 mapname[j-5]=consoletext[0][j];
4167 player[0].scale=atof(mapname)*.2;
4172 if(Compare(consoletext[0],"sizenear ",0,8)||Compare(consoletext[0],"Sizenear ",0,8)){
4174 float closestdist=-1;
4177 for(i=1;i<numplayers;i++){
4178 distance=findDistancefast(&player[i].coords,&player[0].coords);
4179 if(closestdist==-1||distance<closestdist){
4180 closestdist=distance;
4185 for(j=9;j<consolechars[0];j++){
4186 mapname[j-9]=consoletext[0][j];
4189 player[closest].scale=atof(mapname)*.2;
4194 if(Compare(consoletext[0],"proportionnear ",0,14)||Compare(consoletext[0],"Proportionnear ",0,14)){
4199 float closestdist=-1;
4202 for(i=1;i<numplayers;i++){
4203 distance=findDistancefast(&player[i].coords,&player[0].coords);
4204 if(closestdist==-1||distance<closestdist){
4205 closestdist=distance;
4213 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4214 mapname[j-startpoint]=consoletext[0][j];
4216 if(consoletext[0][j]=='\0')alldone=1;
4218 mapname[j-startpoint]='\0';
4220 headprop=atof(mapname);
4224 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4225 mapname[j-startpoint]=consoletext[0][j];
4227 if(consoletext[0][j]=='\0')alldone=1;
4229 mapname[j-startpoint]='\0';
4231 bodyprop=atof(mapname);
4235 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4236 mapname[j-startpoint]=consoletext[0][j];
4238 if(consoletext[0][j]=='\0')alldone=1;
4240 mapname[j-startpoint]='\0';
4242 armprop=atof(mapname);
4246 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4247 mapname[j-startpoint]=consoletext[0][j];
4249 if(consoletext[0][j]=='\0')alldone=1;
4251 mapname[j-startpoint]='\0';
4253 legprop=atof(mapname);
4255 if(player[closest].creature==wolftype){
4256 player[closest].proportionhead=1.1*headprop;
4257 player[closest].proportionbody=1.1*bodyprop;
4258 player[closest].proportionarms=1.1*armprop;
4259 player[closest].proportionlegs=1.1*legprop;
4262 if(player[closest].creature==rabbittype){
4263 player[closest].proportionhead=1.2*headprop;
4264 player[closest].proportionbody=1.05*bodyprop;
4265 player[closest].proportionarms=1.00*armprop;
4266 player[closest].proportionlegs=1.1*legprop;
4267 player[closest].proportionlegs.y=1.05*legprop;
4274 if(Compare(consoletext[0],"sizemin ",0,7)||Compare(consoletext[0],"Sizemin ",0,7)){
4275 for(i=1;i<numplayers;i++){
4276 if(player[i].scale<0.8*0.2)player[i].scale=0.8*0.2;
4282 if(Compare(consoletext[0],"tutorial ",0,8)||Compare(consoletext[0],"Tutorial ",0,8)){
4283 for(j=9;j<consolechars[0];j++){
4284 mapname[j-9]=consoletext[0][j];
4287 tutoriallevel=atoi(mapname);
4293 if(Compare(consoletext[0],"tintg ",0,5)||Compare(consoletext[0],"Tintg ",0,5)){
4294 for(j=6;j<consolechars[0];j++){
4295 mapname[j-6]=consoletext[0][j];
4298 tintg=atof(mapname);
4303 if(Compare(consoletext[0],"tintb ",0,5)||Compare(consoletext[0],"Tintb ",0,5)){
4304 for(j=6;j<consolechars[0];j++){
4305 mapname[j-6]=consoletext[0][j];
4308 tintb=atof(mapname);
4313 if(Compare(consoletext[0],"hostile ",0,7)){
4314 for(j=8;j<consolechars[0];j++){
4315 mapname[j-8]=consoletext[0][j];
4318 hostile=atoi(mapname);
4324 if(Compare(consoletext[0],"type active ",0,11)){
4325 editoractive=typeactive;
4330 if(Compare(consoletext[0],"indemo ",0,6)){
4332 hotspot[numhotspots]=player[0].coords;
4333 hotspotsize[numhotspots]=0;
4334 hotspottype[numhotspots]=-111;
4336 strcpy(hotspottext[numhotspots],"mapname");
4342 if(Compare(consoletext[0],"notindemo ",0,9)){
4349 if(Compare(consoletext[0],"type sitting ",0,12)){
4350 editoractive=typesitting;
4355 if(Compare(consoletext[0],"type sitting wall ",0,17)){
4356 editoractive=typesittingwall;
4361 if(Compare(consoletext[0],"type sleeping ",0,13)){
4362 editoractive=typesleeping;
4366 if(Compare(consoletext[0],"type dead1 ",0,10)){
4367 editoractive=typedead1;
4371 if(Compare(consoletext[0],"type dead2 ",0,10)){
4372 editoractive=typedead2;
4376 if(Compare(consoletext[0],"type dead3 ",0,10)){
4377 editoractive=typedead3;
4380 if(Compare(consoletext[0],"type dead4 ",0,10)){
4381 editoractive=typedead4;
4386 if(Compare(consoletext[0],"path keepwalking ",0,16)){
4387 editorpathtype=wpkeepwalking;
4392 if(Compare(consoletext[0],"path pause ",0,10)){
4393 editorpathtype=wppause;
4398 if(Compare(consoletext[0],"mapkilleveryone ",0,15)){
4399 maptype=mapkilleveryone;
4404 if(Compare(consoletext[0],"mapgosomewhere ",0,14)){
4405 maptype=mapgosomewhere;
4410 if(Compare(consoletext[0],"mapkillsomeone ",0,14)){
4411 maptype=mapkillsomeone;
4417 if(Compare(consoletext[0],"mapkillmost ",0,11)){
4418 maptype=mapkillmost;
4424 if(Compare(consoletext[0],"hs ",0,2)){
4428 hotspot[numhotspots]=player[0].coords;
4433 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4434 mapname[j-startpoint]=consoletext[0][j];
4436 if(consoletext[0][j]=='\0')alldone=1;
4438 mapname[j-startpoint]='\0';
4440 hotspotsize[numhotspots]=atof(mapname);
4444 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4445 mapname[j-startpoint]=consoletext[0][j];
4447 if(consoletext[0][j]=='\0')alldone=1;
4449 mapname[j-startpoint]='\0';
4451 hotspottype[numhotspots]=atoi(mapname);
4455 while(consoletext[0][j]!='\0'&&!alldone&&j<255){
4456 mapname[j-startpoint]=consoletext[0][j];
4458 if(consoletext[0][j]=='\0')alldone=1;
4460 mapname[j-startpoint]='\n';
4461 mapname[j-startpoint+1]='\0';
4463 strcpy(hotspottext[numhotspots],mapname);
4470 if(Compare(consoletext[0],"dialogue ",0,8)){
4477 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4478 mapname[j-startpoint]=consoletext[0][j];
4480 if(consoletext[0][j]=='\0')alldone=1;
4482 mapname[j-startpoint]='\0';
4485 dialoguetype[numdialogues]=atoi(mapname);
4503 for(j=startpoint;j<consolechars[0];j++){
4504 mapname[j-startpoint+16]=consoletext[0][j];
4506 mapname[consolechars[0]-startpoint+16]='.';
4507 mapname[consolechars[0]-startpoint+17]='t';
4508 mapname[consolechars[0]-startpoint+18]='x';
4509 mapname[consolechars[0]-startpoint+19]='t';
4510 mapname[consolechars[0]-startpoint+20]='\0';
4512 for(j=0;j<max_dialoguelength;j++){
4514 dialoguetext[numdialogues][j][k]='\0';
4517 dialoguename[numdialogues][j][k]='\0';
4521 ifstream ipstream(mapname);
4522 ipstream.ignore(256,':');
4523 ipstream >> numdialogueboxes[numdialogues];
4524 for(i=0;i<numdialogueboxes[numdialogues];i++){
4525 ipstream.ignore(256,':');
4526 ipstream.ignore(256,':');
4527 ipstream.ignore(256,' ');
4528 ipstream >> dialogueboxlocation[numdialogues][i];
4529 ipstream.ignore(256,':');
4530 ipstream >> dialogueboxcolor[numdialogues][i][0];
4531 ipstream >> dialogueboxcolor[numdialogues][i][1];
4532 ipstream >> dialogueboxcolor[numdialogues][i][2];
4533 ipstream.ignore(256,':');
4534 ipstream.getline(dialoguename[numdialogues][i],64);
4535 ipstream.ignore(256,':');
4536 ipstream.ignore(256,' ');
4537 ipstream.getline(dialoguetext[numdialogues][i],128);
4539 if(dialoguetext[numdialogues][i][j]=='\\')dialoguetext[numdialogues][i][j]='\n';
4541 ipstream.ignore(256,':');
4542 ipstream >> dialogueboxsound[numdialogues][i];
4545 for(i=0;i<numdialogueboxes[numdialogues];i++){
4546 for(j=0;j<numplayers;j++){
4547 participantfacing[numdialogues][i][j]=player[j].facing;
4554 whichdialogue=numdialogues;
4562 if(Compare(consoletext[0],"fixdialogue ",0,11)){
4570 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4571 mapname[j-startpoint]=consoletext[0][j];
4573 if(consoletext[0][j]=='\0')alldone=1;
4575 mapname[j-startpoint]='\0';
4578 whichdi=atoi(mapname);
4596 for(j=startpoint;j<consolechars[0];j++){
4597 mapname[j-startpoint+16]=consoletext[0][j];
4599 mapname[consolechars[0]-startpoint+16]='.';
4600 mapname[consolechars[0]-startpoint+17]='t';
4601 mapname[consolechars[0]-startpoint+18]='x';
4602 mapname[consolechars[0]-startpoint+19]='t';
4603 mapname[consolechars[0]-startpoint+20]='\0';
4605 for(j=0;j<max_dialoguelength;j++){
4607 dialoguetext[whichdi][j][k]='\0';
4610 dialoguename[whichdi][j][k]='\0';
4614 ifstream ipstream(mapname);
4615 ipstream.ignore(256,':');
4616 ipstream >> numdialogueboxes[whichdi];
4617 for(i=0;i<numdialogueboxes[whichdi];i++){
4618 ipstream.ignore(256,':');
4619 ipstream.ignore(256,':');
4620 ipstream.ignore(256,' ');
4621 ipstream >> dialogueboxlocation[whichdi][i];
4622 ipstream.ignore(256,':');
4623 ipstream >> dialogueboxcolor[whichdi][i][0];
4624 ipstream >> dialogueboxcolor[whichdi][i][1];
4625 ipstream >> dialogueboxcolor[whichdi][i][2];
4626 ipstream.ignore(256,':');
4627 ipstream.getline(dialoguename[whichdi][i],64);
4628 ipstream.ignore(256,':');
4629 ipstream.ignore(256,' ');
4630 ipstream.getline(dialoguetext[whichdi][i],128);
4632 if(dialoguetext[whichdi][i][j]=='\\')dialoguetext[whichdi][i][j]='\n';
4634 ipstream.ignore(256,':');
4635 ipstream >> dialogueboxsound[whichdi][i];
4643 if(Compare(consoletext[0],"fixtype ",0,7)){
4651 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4652 mapname[j-startpoint]=consoletext[0][j];
4654 if(consoletext[0][j]=='\0')alldone=1;
4656 mapname[j-startpoint]='\0';
4657 dialoguetype[0]=atoi(mapname);
4665 if(Compare(consoletext[0],"fixrotation ",0,11)){
4666 participantrotation[whichdialogue][participantfocus[whichdialogue][indialogue]]=player[participantfocus[whichdialogue][indialogue]].rotation;
4671 if(Compare(consoletext[0],"ddialogue ",0,9)){
4673 if(numdialogues<0)numdialogues=0;
4678 if(Compare(consoletext[0],"immobile ",0,8)){
4679 player[0].immobile=1;
4683 if(Compare(consoletext[0],"mobile ",0,6)){
4684 player[0].immobile=0;
4688 if(Compare(consoletext[0],"play ",0,4)){
4695 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4696 mapname[j-startpoint]=consoletext[0][j];
4698 if(consoletext[0][j]=='\0')alldone=1;
4700 mapname[j-startpoint]='\0';
4703 whichdialogue=atoi(mapname);
4705 if(numdialogues>whichdialogue){
4706 for(i=0;i<numdialogueboxes[whichdialogue];i++){
4707 player[participantfocus[whichdialogue][i]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][i]];
4708 player[participantfocus[whichdialogue][i]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
4709 player[participantfocus[whichdialogue][i]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
4710 player[participantfocus[whichdialogue][i]].velocity=0;
4711 player[participantfocus[whichdialogue][i]].targetanimation=player[participantfocus[whichdialogue][i]].getIdle();
4712 player[participantfocus[whichdialogue][i]].targetframe=0;
4720 //if(dialogueboxsound[whichdialogue][indialogue]!=0){
4724 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
4725 temppos=temppos-viewer;
4726 Normalise(&temppos);
4736 whichsoundplay=rabbitchitter;
4737 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
4738 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
4739 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
4740 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
4741 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
4742 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
4743 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
4744 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
4745 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
4746 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
4747 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
4748 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
4749 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
4750 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
4751 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
4752 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
4753 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
4754 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
4755 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
4756 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, TRUE);
4757 FSOUND_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
4758 FSOUND_SetVolume(channels[whichsoundplay], 256);
4759 FSOUND_SetPaused(channels[whichsoundplay], FALSE);
4767 if(Compare(consoletext[0],"dhs ",0,3)){
4769 if(numhotspots<0)numhotspots=0;
4774 if(Compare(consoletext[0],"proportion ",0,10)||Compare(consoletext[0],"Proportion ",0,4)){
4781 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4782 mapname[j-startpoint]=consoletext[0][j];
4784 if(consoletext[0][j]=='\0')alldone=1;
4786 mapname[j-startpoint]='\0';
4788 headprop=atof(mapname);
4792 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4793 mapname[j-startpoint]=consoletext[0][j];
4795 if(consoletext[0][j]=='\0')alldone=1;
4797 mapname[j-startpoint]='\0';
4799 bodyprop=atof(mapname);
4803 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4804 mapname[j-startpoint]=consoletext[0][j];
4806 if(consoletext[0][j]=='\0')alldone=1;
4808 mapname[j-startpoint]='\0';
4810 armprop=atof(mapname);
4814 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4815 mapname[j-startpoint]=consoletext[0][j];
4817 if(consoletext[0][j]=='\0')alldone=1;
4819 mapname[j-startpoint]='\0';
4821 legprop=atof(mapname);
4823 if(player[0].creature==wolftype){
4824 player[0].proportionhead=1.1*headprop;
4825 player[0].proportionbody=1.1*bodyprop;
4826 player[0].proportionarms=1.1*armprop;
4827 player[0].proportionlegs=1.1*legprop;
4830 if(player[0].creature==rabbittype){
4831 player[0].proportionhead=1.2*headprop;
4832 player[0].proportionbody=1.05*bodyprop;
4833 player[0].proportionarms=1.00*armprop;
4834 player[0].proportionlegs=1.1*legprop;
4835 player[0].proportionlegs.y=1.05*legprop;
4841 if(Compare(consoletext[0],"allimmobile ",0,11)||Compare(consoletext[0],"Allimmobile ",0,11)){
4842 for(i=0;i<numplayers;i++){
4843 if(i>0)player[i].immobile=1;
4849 if(Compare(consoletext[0],"default ",0,7)||Compare(consoletext[0],"Default ",0,7)){
4850 player[0].armorhead=1;
4851 player[0].armorhigh=1;
4852 player[0].armorlow=1;
4853 player[0].protectionhead=1;
4854 player[0].protectionhigh=1;
4855 player[0].protectionlow=1;
4856 player[0].metalhead=1;
4857 player[0].metalhigh=1;
4858 player[0].metallow=1;
4860 player[0].speedmult=1;
4863 if(player[0].creature==wolftype){
4864 player[0].proportionhead=1.1;
4865 player[0].proportionbody=1.1;
4866 player[0].proportionarms=1.1;
4867 player[0].proportionlegs=1.1;
4870 if(player[0].creature==rabbittype){
4871 player[0].proportionhead=1.2;
4872 player[0].proportionbody=1.05;
4873 player[0].proportionarms=1.00;
4874 player[0].proportionlegs=1.1;
4875 player[0].proportionlegs.y=1.05;
4878 player[0].numclothes=0;
4879 if(player[0].whichskin==0){
4880 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4882 else if(player[0].whichskin==1){
4883 LoadTextureSave(":Data:Textures:Fur.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4885 else if(player[0].whichskin==2){
4886 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4888 else if(player[0].whichskin==3){
4889 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4891 else if(player[0].whichskin==4){
4892 LoadTextureSave(":Data:Textures:Otter.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4894 else if(player[0].whichskin==5){
4895 LoadTextureSave(":Data:Textures:Opal.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4897 else if(player[0].whichskin==6){
4898 LoadTextureSave(":Data:Textures:Sable.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4900 else if(player[0].whichskin==7){
4901 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4903 else if(player[0].whichskin==8){
4904 LoadTextureSave(":Data:Textures:BW2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4906 else if(player[0].whichskin==9){
4907 LoadTextureSave(":Data:Textures:WB2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4910 editoractive=typeactive;
4911 player[0].immobile=0;
4918 if(Compare(consoletext[0],"tint ",0,4)||Compare(consoletext[0],"Tint ",0,4)){
4924 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4925 mapname[j-startpoint]=consoletext[0][j];
4927 if(consoletext[0][j]=='\0')alldone=1;
4929 mapname[j-startpoint]='\0';
4931 tintr=atof(mapname);
4935 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4936 mapname[j-startpoint]=consoletext[0][j];
4938 if(consoletext[0][j]=='\0')alldone=1;
4940 mapname[j-startpoint]='\0';
4942 tintg=atof(mapname);
4946 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4947 mapname[j-startpoint]=consoletext[0][j];
4949 if(consoletext[0][j]=='\0')alldone=1;
4951 mapname[j-startpoint]='\0';
4953 tintb=atof(mapname);
4958 if(Compare(consoletext[0],"sky tint ",0,8)||Compare(consoletext[0],"Sky Tint ",0,8)){
4964 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4965 mapname[j-startpoint]=consoletext[0][j];
4967 if(consoletext[0][j]=='\0')alldone=1;
4969 mapname[j-startpoint]='\0';
4971 skyboxr=atof(mapname);
4975 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4976 mapname[j-startpoint]=consoletext[0][j];
4978 if(consoletext[0][j]=='\0')alldone=1;
4980 mapname[j-startpoint]='\0';
4982 skyboxg=atof(mapname);
4986 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4987 mapname[j-startpoint]=consoletext[0][j];
4989 if(consoletext[0][j]=='\0')alldone=1;
4991 mapname[j-startpoint]='\0';
4993 skyboxb=atof(mapname);
4995 skyboxlightr=skyboxr;
4996 skyboxlightg=skyboxg;
4997 skyboxlightb=skyboxb;
5001 //if(skyboxtexture){
5002 terrain.DoShadows();
5003 objects.DoShadows();
5005 else terrain.DoLighting();
5010 if(Compare(consoletext[0],"sky light ",0,9)||Compare(consoletext[0],"Sky Light ",0,9)){
5016 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5017 mapname[j-startpoint]=consoletext[0][j];
5019 if(consoletext[0][j]=='\0')alldone=1;
5021 mapname[j-startpoint]='\0';
5023 skyboxlightr=atof(mapname);
5027 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5028 mapname[j-startpoint]=consoletext[0][j];
5030 if(consoletext[0][j]=='\0')alldone=1;
5032 mapname[j-startpoint]='\0';
5034 skyboxlightg=atof(mapname);
5038 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5039 mapname[j-startpoint]=consoletext[0][j];
5041 if(consoletext[0][j]=='\0')alldone=1;
5043 mapname[j-startpoint]='\0';
5045 skyboxlightb=atof(mapname);
5049 //if(skyboxtexture){
5050 terrain.DoShadows();
5051 objects.DoShadows();
5053 else terrain.DoLighting();
5058 if(Compare(consoletext[0],"skybox ",0,6)||Compare(consoletext[0],"Skybox ",0,6)){
5059 skyboxtexture=1-skyboxtexture;
5062 //if(skyboxtexture){
5063 terrain.DoShadows();
5064 objects.DoShadows();
5066 else terrain.DoLighting();
5071 if(Compare(consoletext[0],"protection ",0,10)||Compare(consoletext[0],"Protection ",0,10)){
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 player[0].protectionhead=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 player[0].protectionhigh=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 player[0].protectionlow=atof(mapname);
5111 if(Compare(consoletext[0],"armor ",0,5)||Compare(consoletext[0],"Armor ",0,5)){
5117 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5118 mapname[j-startpoint]=consoletext[0][j];
5120 if(consoletext[0][j]=='\0')alldone=1;
5122 mapname[j-startpoint]='\0';
5124 player[0].armorhead=atof(mapname);
5128 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5129 mapname[j-startpoint]=consoletext[0][j];
5131 if(consoletext[0][j]=='\0')alldone=1;
5133 mapname[j-startpoint]='\0';
5135 player[0].armorhigh=atof(mapname);
5139 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5140 mapname[j-startpoint]=consoletext[0][j];
5142 if(consoletext[0][j]=='\0')alldone=1;
5144 mapname[j-startpoint]='\0';
5146 player[0].armorlow=atof(mapname);
5151 if(Compare(consoletext[0],"protectionreset ",0,15)||Compare(consoletext[0],"Protectionreset ",0,15)){
5152 for(i=0;i<numplayers;i++){
5153 player[i].protectionhead=1.0;
5154 player[i].protectionhigh=1.0;
5155 player[i].protectionlow=1.0;
5156 player[i].armorhead=1.0;
5157 player[i].armorhigh=1.0;
5158 player[i].armorlow=1.0;
5164 if(Compare(consoletext[0],"protectionnear ",0,14)||Compare(consoletext[0],"Protectionnear ",0,14)){
5166 float closestdist=-1;
5169 for(i=1;i<numplayers;i++){
5170 distance=findDistancefast(&player[i].coords,&player[0].coords);
5171 if(closestdist==-1||distance<closestdist){
5172 closestdist=distance;
5182 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5183 mapname[j-startpoint]=consoletext[0][j];
5185 if(consoletext[0][j]=='\0')alldone=1;
5187 mapname[j-startpoint]='\0';
5189 player[closest].protectionhead=atof(mapname);
5193 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5194 mapname[j-startpoint]=consoletext[0][j];
5196 if(consoletext[0][j]=='\0')alldone=1;
5198 mapname[j-startpoint]='\0';
5200 player[closest].protectionhigh=atof(mapname);
5204 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5205 mapname[j-startpoint]=consoletext[0][j];
5207 if(consoletext[0][j]=='\0')alldone=1;
5209 mapname[j-startpoint]='\0';
5211 player[closest].protectionlow=atof(mapname);
5216 if(Compare(consoletext[0],"armornear ",0,9)||Compare(consoletext[0],"Armornear ",0,9)){
5218 float closestdist=-1;
5221 for(i=1;i<numplayers;i++){
5222 distance=findDistancefast(&player[i].coords,&player[0].coords);
5223 if(closestdist==-1||distance<closestdist){
5224 closestdist=distance;
5233 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5234 mapname[j-startpoint]=consoletext[0][j];
5236 if(consoletext[0][j]=='\0')alldone=1;
5238 mapname[j-startpoint]='\0';
5240 player[closest].armorhead=atof(mapname);
5244 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5245 mapname[j-startpoint]=consoletext[0][j];
5247 if(consoletext[0][j]=='\0')alldone=1;
5249 mapname[j-startpoint]='\0';
5251 player[closest].armorhigh=atof(mapname);
5255 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5256 mapname[j-startpoint]=consoletext[0][j];
5258 if(consoletext[0][j]=='\0')alldone=1;
5260 mapname[j-startpoint]='\0';
5262 player[closest].armorlow=atof(mapname);
5268 if(Compare(consoletext[0],"metal ",0,5)||Compare(consoletext[0],"Metal ",0,5)){
5274 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5275 mapname[j-startpoint]=consoletext[0][j];
5277 if(consoletext[0][j]=='\0')alldone=1;
5279 mapname[j-startpoint]='\0';
5281 player[0].metalhead=atof(mapname);
5285 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5286 mapname[j-startpoint]=consoletext[0][j];
5288 if(consoletext[0][j]=='\0')alldone=1;
5290 mapname[j-startpoint]='\0';
5292 player[0].metalhigh=atof(mapname);
5296 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5297 mapname[j-startpoint]=consoletext[0][j];
5299 if(consoletext[0][j]=='\0')alldone=1;
5302 mapname[j-startpoint]='\0';
5304 player[0].metallow=atof(mapname);
5309 if(Compare(consoletext[0],"noclothesnear ",0,13)||Compare(consoletext[0],"Noclothesnear ",0,13)){
5311 float closestdist=-1;
5314 for(i=1;i<numplayers;i++){
5315 distance=findDistancefast(&player[i].coords,&player[0].coords);
5316 if(closestdist==-1||distance<closestdist){
5317 closestdist=distance;
5321 player[closest].numclothes=0;
5322 if(player[closest].whichskin==0){
5323 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5325 else if(player[closest].whichskin==1){
5326 LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5328 else if(player[closest].whichskin==2){
5329 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5331 else if(player[closest].whichskin==3){
5332 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5334 else if(player[closest].whichskin==4){
5335 LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5337 else if(player[closest].whichskin==5){
5338 LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5340 else if(player[closest].whichskin==6){
5341 LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5343 else if(player[closest].whichskin==7){
5344 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5346 else if(player[closest].whichskin==8){
5347 LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5349 else if(player[closest].whichskin==9){
5350 LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5356 if(Compare(consoletext[0],"noclothes ",0,9)||Compare(consoletext[0],"Noclothes ",0,9)){
5359 player[closest].numclothes=0;
5360 if(player[closest].whichskin==0){
5361 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5363 else if(player[closest].whichskin==1){
5364 LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5366 else if(player[closest].whichskin==2){
5367 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5369 else if(player[closest].whichskin==3){
5370 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5372 else if(player[closest].whichskin==4){
5373 LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5375 else if(player[closest].whichskin==5){
5376 LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5378 else if(player[closest].whichskin==6){
5379 LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5381 else if(player[closest].whichskin==7){
5382 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5384 else if(player[closest].whichskin==8){
5385 LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5387 else if(player[closest].whichskin==9){
5388 LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5394 if((Compare(consoletext[0],"Clothes ",0,7)||Compare(consoletext[0],"clothes ",0,7))){
5410 for(j=8;j<consolechars[0];j++){
5411 mapname[j-8+15]=consoletext[0][j];
5413 mapname[consolechars[0]-8+15]='.';
5414 mapname[consolechars[0]-8+16]='p';
5415 mapname[consolechars[0]-8+17]='n';
5416 mapname[consolechars[0]-8+18]='g';
5417 mapname[consolechars[0]-8+19]='\0';
5419 //:Data:Textures:Pants.png
5421 if(AddClothes((char *)mapname,0,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize)){
5422 player[0].DoMipmaps(5,0,0,player[0].skeleton.skinsize,player[0].skeleton.skinsize);
5423 strcpy(player[0].clothes[player[0].numclothes],mapname);
5424 player[0].clothestintr[player[0].numclothes]=tintr;
5425 player[0].clothestintg[player[0].numclothes]=tintg;
5426 player[0].clothestintb[player[0].numclothes]=tintb;
5427 player[0].numclothes++;
5433 if(Compare(consoletext[0],"belt ",0,4)||Compare(consoletext[0],"belt ",0,4)){
5434 player[0].skeleton.clothes = 1-player[0].skeleton.clothes;
5439 if(Compare(consoletext[0],"Cellophane ",0,10)||Compare(consoletext[0],"cellophane ",0,10)){
5440 cellophane=1-cellophane;
5443 for(i=0;i<numplayers;i++){
5444 player[i].proportionhead.z=0;
5445 player[i].proportionbody.z=0;
5446 player[i].proportionarms.z=0;
5447 player[i].proportionlegs.z=0;
5452 for(i=0;i<numplayers;i++){
5453 player[i].proportionhead.z=player[i].proportionhead.x;
5454 player[i].proportionbody.z=player[i].proportionbody.x;
5455 player[i].proportionarms.z=player[i].proportionarms.x;
5456 player[i].proportionlegs.z=player[i].proportionlegs.x;
5463 if((Compare(consoletext[0],"Clothesnear ",0,11)||Compare(consoletext[0],"clothesnear ",0,11))){
5479 for(j=12;j<consolechars[0];j++){
5480 mapname[j-12+15]=consoletext[0][j];
5482 mapname[consolechars[0]-12+15]='.';
5483 mapname[consolechars[0]-12+16]='p';
5484 mapname[consolechars[0]-12+17]='n';
5485 mapname[consolechars[0]-12+18]='g';
5486 mapname[consolechars[0]-12+19]='\0';
5488 //:Data:Textures:Pants.png
5490 float closestdist=-1;
5493 for(i=1;i<numplayers;i++){
5494 distance=findDistancefast(&player[i].coords,&player[0].coords);
5495 if(closestdist==-1||distance<closestdist){
5496 closestdist=distance;
5501 if(AddClothes((char *)mapname,0,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize)){
5502 player[closest].DoMipmaps(5,0,0,player[closest].skeleton.skinsize,player[closest].skeleton.skinsize);
5503 strcpy(player[closest].clothes[player[closest].numclothes],mapname);
5504 player[closest].clothestintr[player[closest].numclothes]=tintr;
5505 player[closest].clothestintg[player[closest].numclothes]=tintg;
5506 player[closest].clothestintb[player[closest].numclothes]=tintb;
5507 player[closest].numclothes++;
5513 if(Compare(consoletext[0],"funnybunny ",0,10)||Compare(consoletext[0],"funny bunny ",0,11)){
5514 player[0].skeleton.id=0;
5515 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);
5516 LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5517 player[0].creature=rabbittype;
5520 player[0].proportionhead=1.2;
5521 player[0].proportionbody=1.05;
5522 player[0].proportionarms=1.00;
5523 player[0].proportionlegs=1.1;
5524 player[0].proportionlegs.y=1.05;
5525 player[0].headless=0;
5527 player[0].damagetolerance=200;
5531 if(Compare(consoletext[0],"wolfieisgod ",0,11)||Compare(consoletext[0],"wolfie is god ",0,12)){
5532 player[0].skeleton.id=0;
5533 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);
5534 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5535 player[0].creature=wolftype;
5537 player[0].proportionhead=1.1;
5538 player[0].proportionbody=1.1;
5539 player[0].proportionarms=1.1;
5540 player[0].proportionlegs=1.1;
5541 player[0].proportionlegs.y=1.1;
5542 player[0].scale=.23;
5544 player[0].damagetolerance=300;
5548 /*if(Compare(consoletext[0],"kungfu ",0,6)||Compare(consoletext[0],"kung fu ",0,7)){
5549 LoadTextureSave(":Data:Textures:Kungfu.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5552 if(Compare(consoletext[0],"rambo ",0,5)){
5553 LoadTextureSave(":Data:Textures:Leather.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5556 if(Compare(consoletext[0],"david ",0,5)){
5557 LoadTextureSave(":Data:Textures:David.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5560 if(Compare(consoletext[0],"wolf ",0,4)){
5561 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5564 if(Compare(consoletext[0],"darkwolf ",0,8)){
5565 LoadTextureSave(":Data:Textures:DarkWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5568 if(Compare(consoletext[0],"snowwolf ",0,8)){
5569 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5572 if(Compare(consoletext[0],"lizardwolf ",0,10)){
5573 LoadTextureSave(":Data:Textures:Lizardwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5576 if(Compare(consoletext[0],"white ",0,5)){
5577 LoadTextureSave(":Data:Textures:fur.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5580 if(Compare(consoletext[0],"brown ",0,5)){
5581 LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5584 if(Compare(consoletext[0],"black ",0,5)){
5585 LoadTextureSave(":Data:Textures:fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5588 if(consolechars[0]>0){
5591 consoletext[k][j]=consoletext[k-1][j];
5593 consolechars[k]=consolechars[k-1];
5596 consoletext[0][j]=' ';
5602 PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, TRUE);
5603 FSOUND_SetVolume(channels[consolefailsound], 256);
5604 FSOUND_SetPaused(channels[consolefailsound], FALSE);
5613 togglekeydelay[i]=0;
5617 consoleblinkdelay-=multiplier;
5618 if(consoleblinkdelay<=0){
5619 consoleblinkdelay=.3;
5620 consoleblink=1-consoleblink;
5624 if(IsKeyDown(theKeyMap, MAC_Q_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)){
5627 if(newdetail>2)newdetail=detail;
5628 if(newdetail<0)newdetail=detail;
5629 if(newscreenwidth>3000)newscreenwidth=screenwidth;
5630 if(newscreenwidth<0)newscreenwidth=screenwidth;
5631 if(newscreenheight>3000)newscreenheight=screenheight;
5632 if(newscreenheight<0)newscreenheight=screenheight;
5634 //ofstream opstream(":Data:config.txt");
5635 ofstream opstream("./Data/config.txt");
5636 opstream << "Screenwidth:\n";
5637 opstream << newscreenwidth;
5638 opstream << "\nScreenheight:\n";
5639 opstream << newscreenheight;
5640 opstream << "\nMouse sensitivity:\n";
5641 opstream << usermousesensitivity;
5642 opstream << "\nBlur(0,1):\n";
5643 opstream << ismotionblur;
5644 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
5645 opstream << newdetail;
5646 opstream << "\nFloating jump:\n";
5647 opstream << floatjump;
5648 opstream << "\nMouse jump:\n";
5649 opstream << mousejump;
5650 opstream << "\nAmbient sound:\n";
5651 opstream << ambientsound;
5652 opstream << "\nBlood (0,1,2):\n";
5653 opstream << bloodtoggle;
5654 opstream << "\nAuto slomo:\n";
5655 opstream << autoslomo;
5656 opstream << "\nFoliage:\n";
5657 opstream << foliage;
5658 opstream << "\nMusic:\n";
5659 opstream << musictoggle;
5660 opstream << "\nTrilinear:\n";
5661 opstream << trilinear;
5662 opstream << "\nDecals(shadows,blood puddles,etc):\n";
5664 opstream << "\nInvert mouse:\n";
5665 opstream << invertmouse;
5666 opstream << "\nGamespeed:\n";
5667 if(oldgamespeed==0)oldgamespeed=1;
5668 opstream << oldgamespeed;
5669 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
5670 opstream << difficulty;
5671 opstream << "\nDamage effects(blackout, doublevision):\n";
5672 opstream << damageeffects;
5673 opstream << "\nText:\n";
5674 opstream << texttoggle;
5675 opstream << "\nDebug:\n";
5676 opstream << debugmode;
5677 opstream << "\nVBL Sync:\n";
5678 opstream << vblsync;
5679 opstream << "\nShow Points:\n";
5680 opstream << showpoints;
5681 opstream << "\nAlways Blur:\n";
5682 opstream << alwaysblur;
5683 opstream << "\nImmediate mode (turn on on G5):\n";
5684 opstream << immediate;
5685 opstream << "\nVelocity blur:\n";
5686 opstream << velocityblur;
5687 opstream << "\nVolume:\n";
5689 opstream << "\nForward key:\n";
5690 opstream << KeyToChar(forwardkey);
5691 opstream << "\nBack key:\n";
5692 opstream << KeyToChar(backkey);
5693 opstream << "\nLeft key:\n";
5694 opstream << KeyToChar(leftkey);
5695 opstream << "\nRight key:\n";
5696 opstream << KeyToChar(rightkey);
5697 opstream << "\nJump key:\n";
5698 opstream << KeyToChar(jumpkey);
5699 opstream << "\nCrouch key:\n";
5700 opstream << KeyToChar(crouchkey);
5701 opstream << "\nDraw key:\n";
5702 opstream << KeyToChar(drawkey);
5703 opstream << "\nThrow key:\n";
5704 opstream << KeyToChar(throwkey);
5705 opstream << "\nAttack key:\n";
5706 opstream << KeyToChar(attackkey);
5707 opstream << "\nChat key:\n";
5708 opstream << KeyToChar(chatkey);
5713 static int oldwinfreeze;
5714 if(winfreeze&&!oldwinfreeze){
5715 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
5716 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
5717 FSOUND_SetVolume(channels[consolesuccesssound], 256);
5718 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
5720 if(winfreeze==0)oldwinfreeze=winfreeze;
5721 else oldwinfreeze++;
5723 if((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY))&&!oldjumpkeydown&&!campaign){
5724 if(winfreeze)winfreeze=0;
5727 if((IsKeyDown(theKeyMap, MAC_ESCAPE_KEY))&&!campaign&&gameon){
5733 if((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY))){
5736 if(!IsKeyDown(theKeyMap, jumpkey)&&!IsKeyDown(theKeyMap, MAC_SPACE_KEY))oldjumpkeydown=0;
5738 if(!freeze&&!winfreeze&&!(mainmenu&&gameon)&&(gameon||!gamestarted)){
5740 static bool oldbuttondialogue;
5742 if(indialogue!=-1)talkdelay=1;
5743 talkdelay-=multiplier;
5746 if(indialogue==-1&&(animation[player[0].targetanimation].height!=highheight)/*&&!hostile*/)
5747 for(i=0;i<numdialogues;i++){
5748 int realdialoguetype;
5750 if(dialoguetype[i]>49){
5751 realdialoguetype=dialoguetype[i]-50;
5754 else if(dialoguetype[i]>39){
5755 realdialoguetype=dialoguetype[i]-40;
5758 else if(dialoguetype[i]>29){
5759 realdialoguetype=dialoguetype[i]-30;
5762 else if(dialoguetype[i]>19){
5763 realdialoguetype=dialoguetype[i]-20;
5766 else if(dialoguetype[i]>9){
5767 realdialoguetype=dialoguetype[i]-10;
5771 realdialoguetype=dialoguetype[i];
5774 if((!hostile||(dialoguetype[i]>40&&dialoguetype[i]<50))&&realdialoguetype<numplayers&&realdialoguetype>0&&(dialoguegonethrough[i]==0||!special)&&(special||(IsKeyDown(theKeyMap, attackkey)&&!oldbuttondialogue))){
5775 if(findDistancefast(&player[0].coords,&player[realdialoguetype].coords)<6||player[realdialoguetype].howactive>=typedead1||(dialoguetype[i]>40&&dialoguetype[i]<50)){
5777 for(j=0;j<numdialogueboxes[whichdialogue];j++){
5778 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
5779 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
5780 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
5781 player[participantfocus[whichdialogue][j]].velocity=0;
5782 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
5783 player[participantfocus[whichdialogue][j]].targetframe=0;
5788 dialoguegonethrough[i]++;
5789 if(dialogueboxsound[whichdialogue][indialogue]!=0){
5790 static float gLoc[3];
5791 static float vel[3];
5793 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
5794 temppos=temppos-viewer;
5795 Normalise(&temppos);
5800 gLoc[2]=temppos.z;vel[0]=0;
5804 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
5805 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
5806 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
5807 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
5808 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
5809 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
5810 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
5811 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
5812 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
5813 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
5814 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
5815 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
5816 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
5817 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
5818 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
5819 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
5820 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
5821 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
5822 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
5823 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
5824 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, TRUE);
5825 FSOUND_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
5826 FSOUND_SetVolume(channels[whichsoundplay], 256);
5827 FSOUND_SetPaused(channels[whichsoundplay], FALSE);
5829 if(IsKeyDown(theKeyMap, attackkey))oldbuttondialogue=1;
5834 windvar+=multiplier;
5835 smoketex+=multiplier;
5836 tutorialstagetime+=multiplier;
5838 static float hotspotvisual[40];
5842 for(i=0;i<numhotspots;i++)
5843 hotspotvisual[i]-=multiplier/320;
5845 for(i=0;i<numhotspots;i++){
5846 //if(hotspottype[i]<=10)
5847 while(hotspotvisual[i]<0){
5849 hotspotsprite.x=float(abs(Random()%100000))/100000*hotspotsize[i];
5850 hotspotsprite=DoRotation(hotspotsprite,0,0,Random()%360);
5851 hotspotsprite=DoRotation(hotspotsprite,0,Random()%360,0);
5852 hotspotsprite+=hotspot[i];
5853 sprites.MakeSprite(breathsprite, hotspotsprite, hotspotsprite*0, 1,0.5,0, 7, 0.4);
5854 hotspotvisual[i]+=0.1/hotspotsize[i]/hotspotsize[i]/hotspotsize[i];
5858 for(i=0;i<numhotspots;i++){
5859 if(hotspottype[i]<=10&&hotspottype[i]>0){
5860 hotspot[i]=player[hotspottype[i]].coords;
5866 if(tutoriallevel&&tutorialstagetime>tutorialmaxtime){
5869 if(tutorialstage<=1){
5874 if(tutorialstage==1){
5877 if(tutorialstage==2){
5880 if(tutorialstage==3){
5881 tutorialmaxtime=600;
5883 if(tutorialstage==4){
5884 tutorialmaxtime=1000;
5886 if(tutorialstage==5){
5887 tutorialmaxtime=600;
5889 if(tutorialstage==6){
5890 tutorialmaxtime=600;
5892 if(tutorialstage==7){
5893 tutorialmaxtime=600;
5895 if(tutorialstage==8){
5896 tutorialmaxtime=600;
5898 if(tutorialstage==9){
5899 tutorialmaxtime=600;
5901 if(tutorialstage==10){
5904 if(tutorialstage==11){
5905 tutorialmaxtime=1000;
5907 if(tutorialstage==12){
5908 tutorialmaxtime=1000;
5910 if(tutorialstage==13){
5913 if(tutorialstage==14){
5925 player[1].coords=(temp+temp2)/2;
5929 gLoc[0]=player[1].coords.x;
5930 gLoc[1]=player[1].coords.y;
5931 gLoc[2]=player[1].coords.z;
5935 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
5936 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
5937 FSOUND_SetVolume(channels[fireendsound], 256);
5938 FSOUND_SetPaused(channels[fireendsound], FALSE);
5940 for(i=0;i<player[1].skeleton.num_joints;i++){
5942 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
5943 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
5944 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;
5945 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
5946 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
5951 if(tutorialstage==15){
5952 tutorialmaxtime=500;
5954 if(tutorialstage==16){
5955 tutorialmaxtime=500;
5957 if(tutorialstage==17){
5958 tutorialmaxtime=500;
5960 if(tutorialstage==18){
5961 tutorialmaxtime=500;
5963 if(tutorialstage==19){
5965 //tutorialmaxtime=500;
5967 if(tutorialstage==20){
5968 tutorialmaxtime=500;
5970 if(tutorialstage==21){
5971 tutorialmaxtime=500;
5978 if(tutorialstage==22){
5979 tutorialmaxtime=500;
5981 if(tutorialstage==23){
5982 tutorialmaxtime=500;
5984 if(tutorialstage==24){
5985 tutorialmaxtime=500;
5987 if(tutorialstage==25){
5988 tutorialmaxtime=500;
5990 if(tutorialstage==26){
5993 if(tutorialstage==27){
5997 player[1].aitype=attacktypecutoff;
5999 if(tutorialstage==28){
6000 tutorialmaxtime=400;
6002 if(tutorialstage==29){
6003 tutorialmaxtime=400;
6004 player[0].escapednum=0;
6006 if(tutorialstage==30){
6010 player[1].aitype=passivetype;
6012 if(tutorialstage==31){
6015 if(tutorialstage==32){
6018 if(tutorialstage==33){
6019 tutorialmaxtime=400;
6022 player[1].aitype=attacktypecutoff;
6024 if(tutorialstage==34){
6025 tutorialmaxtime=400;
6027 if(tutorialstage==35){
6028 tutorialmaxtime=400;
6030 if(tutorialstage==36){
6034 player[1].aitype=passivetype;
6036 if(tutorialstage==37){
6042 player[1].aitype=attacktypecutoff;
6044 if(tutorialstage==38){
6048 player[1].aitype=passivetype;
6050 if(tutorialstage==39){
6061 weapons.owner[weapons.numweapons]=-1;
6062 weapons.type[weapons.numweapons]=knife;
6063 weapons.damage[weapons.numweapons]=0;
6064 weapons.mass[weapons.numweapons]=1;
6065 weapons.tipmass[weapons.numweapons]=1.2;
6066 weapons.length[weapons.numweapons]=.25;
6067 weapons.position[weapons.numweapons]=(temp+temp2)/2;
6068 weapons.tippoint[weapons.numweapons]=(temp+temp2)/2;
6070 weapons.velocity[weapons.numweapons]=0.1;
6071 weapons.tipvelocity[weapons.numweapons]=0.1;
6072 weapons.missed[weapons.numweapons]=1;
6073 weapons.hitsomething[weapons.numweapons]=0;
6074 weapons.freetime[weapons.numweapons]=0;
6075 weapons.firstfree[weapons.numweapons]=1;
6076 weapons.physics[weapons.numweapons]=1;
6078 weapons.numweapons++;
6080 if(tutorialstage==40){
6081 tutorialmaxtime=300;
6083 if(tutorialstage==41){
6084 tutorialmaxtime=300;
6086 if(tutorialstage==42){
6089 if(tutorialstage==43){
6090 tutorialmaxtime=300;
6092 if(tutorialstage==44){
6094 player[0].weaponactive=-1;
6095 player[0].num_weapons=0;
6096 player[1].weaponactive=0;
6097 player[1].num_weapons=1;
6098 player[1].weaponids[0]=0;
6102 player[1].aitype=attacktypecutoff;
6104 tutorialmaxtime=300;
6106 if(tutorialstage==45){
6108 player[0].weaponactive=-1;
6109 player[0].num_weapons=0;
6110 player[1].weaponactive=0;
6111 player[1].num_weapons=1;
6112 player[1].weaponids[0]=0;
6114 tutorialmaxtime=300;
6116 if(tutorialstage==46){
6118 player[0].weaponactive=-1;
6119 player[0].num_weapons=0;
6120 player[1].weaponactive=0;
6121 player[1].num_weapons=1;
6122 player[1].weaponids[0]=0;
6124 weapons.type[0]=sword;
6126 tutorialmaxtime=300;
6129 if(tutorialstage==47){
6141 weapons.owner[weapons.numweapons]=-1;
6142 weapons.type[weapons.numweapons]=sword;
6143 weapons.damage[weapons.numweapons]=0;
6144 weapons.mass[weapons.numweapons]=1;
6145 weapons.tipmass[weapons.numweapons]=1.2;
6146 weapons.length[weapons.numweapons]=.25;
6147 weapons.position[weapons.numweapons]=(temp+temp2)/2;
6148 weapons.tippoint[weapons.numweapons]=(temp+temp2)/2;
6150 weapons.velocity[weapons.numweapons]=0.1;
6151 weapons.tipvelocity[weapons.numweapons]=0.1;
6152 weapons.missed[weapons.numweapons]=1;
6153 weapons.hitsomething[weapons.numweapons]=0;
6154 weapons.freetime[weapons.numweapons]=0;
6155 weapons.firstfree[weapons.numweapons]=1;
6156 weapons.physics[weapons.numweapons]=1;
6160 player[0].weaponactive=0;
6161 player[0].num_weapons=1;
6162 player[0].weaponids[0]=1;
6163 player[1].weaponactive=0;
6164 player[1].num_weapons=1;
6165 player[1].weaponids[0]=0;
6167 weapons.numweapons++;
6169 if(tutorialstage==48){
6172 player[1].aitype=passivetype;
6178 player[0].weaponactive=0;
6179 player[0].num_weapons=1;
6180 player[0].weaponids[0]=1;
6181 player[1].weaponactive=0;
6182 player[1].num_weapons=1;
6183 player[1].weaponids[0]=0;
6185 if(player[0].weaponactive!=-1)weapons.type[player[0].weaponids[player[0].weaponactive]]=staff;
6186 else weapons.type[0]=staff;
6188 weapons.numweapons++;
6190 if(tutorialstage==49){
6193 player[1].aitype=passivetype;
6195 tutorialmaxtime=200;
6197 weapons.position[1]=1000;
6198 weapons.tippoint[1]=1000;
6200 weapons.numweapons=1;
6202 player[1].weaponactive=-1;
6203 player[1].num_weapons=0;
6204 player[0].weaponactive=0;
6205 player[0].num_weapons=1;
6206 player[0].weaponids[0]=0;
6208 weapons.type[0]=knife;
6210 weapons.numweapons++;
6212 if(tutorialstage==50){
6218 gLoc[0]=player[1].coords.x;
6219 gLoc[1]=player[1].coords.y;
6220 gLoc[2]=player[1].coords.z;
6224 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
6225 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
6226 FSOUND_SetVolume(channels[fireendsound], 256);
6227 FSOUND_SetPaused(channels[fireendsound], FALSE);
6229 for(i=0;i<player[1].skeleton.num_joints;i++){
6231 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
6232 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
6233 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;
6234 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
6235 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
6239 player[1].num_weapons=0;
6240 player[1].weaponstuck=-1;
6241 player[1].weaponactive=-1;
6243 weapons.numweapons=0;
6245 weapons.owner[0]=-1;
6246 weapons.velocity[0]=0.1;
6247 weapons.tipvelocity[0]=-0.1;
6248 weapons.missed[0]=1;
6249 weapons.hitsomething[0]=0;
6250 weapons.freetime[0]=0;
6251 weapons.firstfree[0]=1;
6252 weapons.physics[0]=1;
6254 if(tutorialstage==51){
6255 tutorialmaxtime=80000;
6257 if(tutorialstage<=51)tutorialstagetime=0;
6261 if(tutoriallevel&&tutorialstagetime<tutorialmaxtime-3){
6262 if(tutorialstage==3){
6263 if(deltah||deltav)tutorialsuccess+=multiplier;
6265 if(tutorialstage==4){
6266 if(player[0].forwardkeydown||player[0].backkeydown||player[0].leftkeydown||player[0].rightkeydown)tutorialsuccess+=multiplier;
6268 if(tutorialstage==5){
6269 if(player[0].jumpkeydown)tutorialsuccess=1;
6271 if(tutorialstage==6){
6272 if(player[0].isCrouch())tutorialsuccess=1;
6274 if(tutorialstage==7){
6275 if(player[0].targetanimation==rollanim)tutorialsuccess=1;
6277 if(tutorialstage==8){
6278 if(player[0].targetanimation==sneakanim)tutorialsuccess+=multiplier;
6280 if(tutorialstage==9){
6281 if(player[0].targetanimation==rabbitrunninganim||player[0].targetanimation==wolfrunninganim)tutorialsuccess+=multiplier;
6283 if(tutorialstage==11){
6284 if(player[0].isWallJump())tutorialsuccess=1;
6286 if(tutorialstage==12){
6287 if(player[0].targetanimation==flipanim)tutorialsuccess=1;
6289 if(tutorialstage==15){
6290 if(player[0].targetanimation==upunchanim||player[0].targetanimation==winduppunchanim)tutorialsuccess=1;
6292 if(tutorialstage==16){
6293 if(player[0].targetanimation==winduppunchanim)tutorialsuccess=1;
6295 if(tutorialstage==17){
6296 if(player[0].targetanimation==spinkickanim)tutorialsuccess=1;
6298 if(tutorialstage==18){
6299 if(player[0].targetanimation==sweepanim)tutorialsuccess=1;
6301 if(tutorialstage==19){
6302 if(player[0].targetanimation==dropkickanim)tutorialsuccess=1;
6304 if(tutorialstage==20){
6305 if(player[0].targetanimation==rabbitkickanim)tutorialsuccess=1;
6307 if(tutorialstage==21){
6308 if(bonus==cannon)tutorialsuccess=1;
6310 if(tutorialstage==22){
6311 if(bonus==spinecrusher)tutorialsuccess=1;
6313 if(tutorialstage==23){
6314 if(player[0].targetanimation==walljumprightkickanim||player[0].targetanimation==walljumpleftkickanim)tutorialsuccess=1;
6316 if(tutorialstage==24){
6317 if(player[0].targetanimation==rabbittacklinganim)tutorialsuccess=1;
6319 if(tutorialstage==25){
6320 if(player[0].targetanimation==backhandspringanim)tutorialsuccess=1;
6322 if(tutorialstage==28){
6323 if(animation[player[0].targetanimation].attack==reversed&&player[0].feint)tutorialsuccess=1;
6325 if(tutorialstage==29){
6326 if(player[0].escapednum==2){
6330 player[1].aitype=passivetype;
6333 if(tutorialstage==33){
6334 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6336 if(tutorialstage==34){
6337 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6339 if(tutorialstage==35){
6340 if(animation[player[0].targetanimation].attack==reversal){
6344 player[1].aitype=passivetype;
6347 if(tutorialstage==40){
6348 if(player[0].num_weapons>0)tutorialsuccess=1;
6350 if(tutorialstage==41){
6351 if(player[0].weaponactive==-1&&player[0].num_weapons>0)tutorialsuccess=1;
6353 if(tutorialstage==43){
6354 if(player[0].targetanimation==knifeslashstartanim)tutorialsuccess=1;
6356 if(tutorialstage==44){
6357 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6359 if(tutorialstage==45){
6360 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6362 if(tutorialstage==46){
6363 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6365 if(tutorialstage==49){
6366 if(player[1].weaponstuck!=-1)tutorialsuccess=1;
6368 if(tutorialsuccess>=1)tutorialstagetime=tutorialmaxtime-3;
6371 if(tutorialstagetime==tutorialmaxtime-3){
6372 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
6373 FSOUND_SetVolume(channels[consolesuccesssound], 256);
6374 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
6377 if(tutorialsuccess>=1){
6378 if(tutorialstage==34||tutorialstage==35)
6379 tutorialstagetime=tutorialmaxtime-1;
6384 if(tutorialstage<14||tutorialstage>=50){
6385 player[1].coords.y=300;
6386 player[1].velocity=0;
6390 if(tutoriallevel!=1){
6391 if(bonustime==0&&bonus!=solidhit&&bonus!=spinecrusher&&bonus!=tracheotomy&&bonus!=backstab&&bonusvalue>10){
6392 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
6393 FSOUND_SetVolume(channels[consolesuccesssound], 256);
6394 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
6399 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
6400 FSOUND_SetVolume(channels[fireendsound], 256);
6401 FSOUND_SetPaused(channels[fireendsound], FALSE);
6404 if(bonus!=solidhit&&bonus!=twoxcombo&&bonus!=threexcombo&&bonus!=fourxcombo&&bonus!=megacombo)bonusnum[bonus]++;
6405 else bonusnum[bonus]+=0.15;
6406 if(tutoriallevel)bonusvalue=0;
6407 bonusvalue/=bonusnum[bonus];
6408 bonustotal+=bonusvalue;
6410 bonustime+=multiplier;
6412 if(environment==snowyenvironment){
6413 precipdelay-=multiplier;
6414 while(precipdelay<0){
6416 if(!detail)precipdelay+=.04;
6417 XYZ footvel,footpoint;
6420 footpoint=viewer+viewerfacing*6;
6421 footpoint.y+=((float)abs(Random()%1200))/100-6;
6422 footpoint.x+=((float)abs(Random()%1200))/100-6;
6423 footpoint.z+=((float)abs(Random()%1200))/100-6;
6424 sprites.MakeSprite(snowsprite, footpoint,footvel, 1,1,1, .1, 1);
6427 for(k=0;k<numplayers;k++){
6428 if(player[k].aitype==playercontrolled)player[k].turnspeed=500;
6429 if(player[k].aitype!=playercontrolled)player[k].turnspeed=500;
6431 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){
6432 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6433 else if(player[k].rotation>player[k].targetrotation){
6434 player[k].rotation-=multiplier*player[k].turnspeed;
6436 else if(player[k].rotation<player[k].targetrotation){
6437 player[k].rotation+=multiplier*player[k].turnspeed;
6442 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))){
6443 player[k].turnspeed*=2;
6444 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6445 else if(player[k].rotation>player[k].targetrotation){
6446 player[k].rotation-=multiplier*player[k].turnspeed;
6448 else if(player[k].rotation<player[k].targetrotation){
6449 player[k].rotation+=multiplier*player[k].turnspeed;
6451 player[k].turnspeed/=2;
6454 if(player[k].targetanimation==sneakanim&&player[k].currentanimation!=sneakanim){
6455 player[k].turnspeed*=4;
6456 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6457 else if(player[k].rotation>player[k].targetrotation){
6458 player[k].rotation-=multiplier*player[k].turnspeed;
6460 else if(player[k].rotation<player[k].targetrotation){
6461 player[k].rotation+=multiplier*player[k].turnspeed;
6463 player[k].turnspeed/=4;
6466 /*if(player[k].aitype!=passivetype||(findDistancefast(&player[k].coords,&viewer)<viewdistance*viewdistance))*/ player[k].DoStuff();
6467 if(player[k].immobile&&k!=0)player[k].coords=player[k].realoldcoords;
6469 if(findDistancefast(&player[k].coords,&player[k].realoldcoords)>0){
6470 if(!player[k].skeleton.free&&player[k].targetanimation!=climbanim&&player[k].targetanimation!=hanganim){
6473 if(player[k].collide<-.3)player[k].collide=-.3;
6474 if(player[k].collide>1)player[k].collide=1;
6475 player[k].collide-=multiplier*30;
6477 if(player[k].coords.y<terrain.getHeight(player[k].coords.x,player[k].coords.z)){
6478 player[k].coords.y=terrain.getHeight(player[k].coords.x,player[k].coords.z);
6480 if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
6481 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
6482 i=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
6483 if(objects.type[i]!=rocktype||(((objects.scale[i]>.5&&player[k].aitype==playercontrolled)||objects.position[i].y>player[k].coords.y))){
6484 lowpoint=player[k].coords;
6485 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&!player[k].isFlip())lowpoint.y+=1.25;
6486 else lowpoint.y+=1.3;
6487 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){
6488 player[k].coords.y=terrain.getHeight(player[k].coords.x,player[k].coords.z);
6490 /*while(player[k].coords.y<terrain.getHeight(player[k].coords.x,player[k].coords.z))
6491 player[k].coords+=terrain.getNormal(player[k].coords.x,player[k].coords.z)/50;
6493 if(player[k].SphereCheck(&lowpoint, 1.3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
6494 flatfacing=lowpoint-player[k].coords;
6495 player[k].coords=lowpoint;
6496 player[k].coords.y-=1.3;
6497 player[k].collide=1;
6499 if(player[k].aitype==playercontrolled&&(player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim||player[k].isFlip())&&!player[k].jumptogglekeydown&&player[k].jumpkeydown){
6500 lowpointtarget=lowpoint+DoRotation(player[k].facing,0,-90,0)*1.5;
6501 tempcoords1=lowpoint;
6502 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6503 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6505 player[k].targetanimation=walljumpleftanim;
6506 player[k].targetframe=0;
6509 gLoc[0]=player[k].coords.x;
6510 gLoc[1]=player[k].coords.y;
6511 gLoc[2]=player[k].coords.z;
6515 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, TRUE);
6516 FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6517 FSOUND_SetVolume(channels[movewhooshsound], 256);
6518 FSOUND_SetPaused(channels[movewhooshsound], FALSE);
6519 if(k==0)FSOUND_SetPaused(channels[whooshsound], TRUE);
6521 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6522 player[k].rotation=-asin(0-lowpointtarget.x);
6523 player[k].rotation*=360/6.28;
6524 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6525 player[k].targetrotation=player[k].rotation;
6526 player[k].lowrotation=player[k].rotation;
6527 if(k==0)numwallflipped++;
6531 lowpoint=tempcoords1;
6532 lowpointtarget=lowpoint+DoRotation(player[k].facing,0,90,0)*1.5;
6533 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6534 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6536 player[k].targetanimation=walljumprightanim;
6537 player[k].targetframe=0;
6540 gLoc[0]=player[k].coords.x;
6541 gLoc[1]=player[k].coords.y;
6542 gLoc[2]=player[k].coords.z;
6546 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, TRUE);
6547 FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6548 FSOUND_SetVolume(channels[movewhooshsound], 256);
6549 FSOUND_SetPaused(channels[movewhooshsound], FALSE);
6550 if(k==0)FSOUND_SetPaused(channels[whooshsound], TRUE);
6552 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6553 player[k].rotation=-asin(0-lowpointtarget.x);
6554 player[k].rotation*=360/6.28;
6555 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6556 player[k].targetrotation=player[k].rotation;
6557 player[k].lowrotation=player[k].rotation;
6558 if(k==0)numwallflipped++;
6562 lowpoint=tempcoords1;
6563 lowpointtarget=lowpoint+player[k].facing*2;
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=walljumpbackanim;
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-player[k].facing*2;
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=walljumpfrontanim;
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].rotation+=180;
6619 player[k].targetrotation=player[k].rotation;
6620 player[k].lowrotation=player[k].rotation;
6621 if(k==0)numwallflipped++;
6629 else if(objects.type[i]==rocktype){
6630 lowpoint2=player[k].coords;
6631 lowpoint=player[k].coords;
6633 if(objects.model[i].LineCheck(&lowpoint,&lowpoint2,&colpoint,&objects.position[i],&objects.rotation[i])!=-1){
6634 player[k].coords=colpoint;
6635 player[k].collide=1;
6638 if((player[k].targetanimation==jumpdownanim||player[k].isFlip())){
6639 if(player[k].isFlip()&&animation[player[k].targetanimation].label[player[k].targetframe]==7)player[k].RagDoll(0);
6641 if(player[k].targetanimation==jumpupanim){player[k].jumppower=-4;player[k].targetanimation=player[k].getIdle();}
6643 player[k].targetframe=0;
6644 player[k].onterrain=1;
6646 if(player[k].id==0){
6647 FSOUND_SetPaused(channels[whooshsound], TRUE);
6648 FSOUND_SetVolume(channels[whooshsound], 0);
6651 if((player[k].targetanimation==jumpdownanim||player[k].isFlip())&&!player[k].wasLanding()){
6652 if(player[k].isFlip())player[k].jumppower=-4;
6653 player[k].targetanimation=player[k].getLanding();
6656 gLoc[0]=player[k].coords.x;
6657 gLoc[1]=player[k].coords.y;
6658 gLoc[2]=player[k].coords.z;
6659 vel[0]=player[k].velocity.x;
6660 vel[1]=player[k].velocity.y;
6661 vel[2]=player[k].velocity.z;
6662 PlaySoundEx( landsound, samp[landsound], NULL, TRUE);
6663 FSOUND_3D_SetAttributes(channels[landsound], gLoc, vel);
6664 FSOUND_SetVolume(channels[landsound], 128);
6665 FSOUND_SetPaused(channels[landsound], FALSE);
6667 envsound[numenvsounds]=player[k].coords;
6668 envsoundvol[numenvsounds]=16;
6669 envsoundlife[numenvsounds]=.4;
6678 if(tempcollide&&terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz]&&(/*player[k].jumptogglekeydown*/1==1||player[k].aitype!=playercontrolled))
6679 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
6680 i=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
6681 lowpoint=player[k].coords;
6683 if(objects.type[i]!=rocktype)
6684 if(player[k].SphereCheck(&lowpoint, 1.33, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
6685 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&player[k].onterrain)player[k].avoidcollided=1;
6686 player[k].coords=lowpoint;
6687 player[k].coords.y-=1.35;
6688 player[k].collide=1;
6690 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)){
6691 lowpoint=player[k].coords;
6692 objects.model[i].SphereCheckPossible(&lowpoint, 1.5, &objects.position[i], &objects.rotation[i]);
6693 lowpoint=player[k].coords;
6697 facing=DoRotation(facing,0,player[k].targetrotation+180,0);
6698 lowpointtarget=lowpoint+facing*1.4;
6699 whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6701 lowpoint=player[k].coords;
6703 lowpointtarget=lowpoint+facing*1.4;
6705 lowpointtarget2=lowpointtarget;
6707 lowpointtarget3=lowpointtarget;
6709 lowpointtarget4=lowpointtarget;
6711 lowpointtarget5=lowpointtarget;
6713 lowpointtarget6=lowpointtarget;
6715 lowpointtarget7=lowpoint;
6717 lowpointtarget2.x+=.1;
6719 lowpointtarget3.z+=.1;
6721 lowpointtarget4.x-=.1;
6723 lowpointtarget5.z-=.1;
6725 lowpointtarget6.y+=45/13;
6726 lowpointtarget6+=facing*.6;
6727 lowpointtarget7.y+=90/13;
6728 whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6729 if(objects.friction[i]>.5)
6732 if(whichhit!=-1)if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim)player[k].collided=1;
6733 if(checkcollide(lowpoint7,lowpointtarget7)==-1)
6734 if(checkcollide(lowpoint6,lowpointtarget6)==-1)
6735 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)
6737 lowpoint=player[k].coords;
6738 lowpoint.y+=(float)j/13;
6739 lowpointtarget=lowpoint+facing*1.4;
6740 if(objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint2,&objects.position[i],&objects.rotation[i])==-1){
6744 /*if(j>=25&&(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)){
6747 if(j<=25&&player[k].targetanimation==jumpdownanim){
6750 if(j!=100&&(/*j>25||(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)||*/player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim)){
6751 lowpoint=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0);
6752 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)*/){
6753 lowpoint=player[k].coords;
6754 lowpoint.y+=(float)j/13;
6755 lowpointtarget=lowpoint+facing*1.3;
6756 flatfacing=player[k].coords;
6757 player[k].coords=colpoint-DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0)*.01;
6758 player[k].coords.y=lowpointtarget.y-.07;
6759 player[k].currentoffset=(flatfacing-player[k].coords)/player[k].scale;
6761 if(j>10||!player[k].isRun()){
6762 if(player[k].targetanimation==jumpdownanim||player[k].targetanimation==jumpupanim){
6763 if(k==0)FSOUND_SetPaused(channels[whooshsound], TRUE);
6767 gLoc[0]=player[k].coords.x;
6768 gLoc[1]=player[k].coords.y;
6769 gLoc[2]=player[k].coords.z;
6770 vel[0]=player[k].velocity.x;
6771 vel[1]=player[k].velocity.y;
6772 vel[2]=player[k].velocity.z;
6773 PlaySoundEx( jumpsound, samp[jumpsound], NULL, TRUE);
6774 FSOUND_3D_SetAttributes(channels[jumpsound], gLoc, vel);
6775 FSOUND_SetVolume(channels[jumpsound], 128);
6776 FSOUND_SetPaused(channels[jumpsound], FALSE);
6778 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6779 player[k].rotation=-asin(0-lowpointtarget.x);
6780 player[k].rotation*=360/6.28;
6781 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6782 player[k].targetrotation=player[k].rotation;
6783 player[k].lowrotation=player[k].rotation;
6785 //player[k].velocity=lowpointtarget*.03;
6786 player[k].velocity=0;
6788 if(/*(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)||*/player[k].targetanimation==jumpupanim){
6789 //player[k].currentanimation=climbanim;
6790 player[k].targetanimation=climbanim;
6791 player[k].jumppower=0;
6792 player[k].jumpclimb=1;
6794 player[k].transspeed=6;
6797 //player[k].currentframe=1;
6798 player[k].targetframe=1;
6800 //player[k].currentframe=0;
6801 player[k].targetframe=0;
6802 //player[k].currentanimation=hanganim;
6803 player[k].targetanimation=hanganim;
6804 player[k].jumppower=0;
6818 if(player[k].collide<=0){
6819 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()){
6820 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)){
6821 if(player[k].targetanimation==staggerbackhighanim||player[k].targetanimation==staggerbackhardanim)player[k].RagDoll(0);
6822 player[k].targetanimation=jumpdownanim;
6823 player[k].targetframe=0;
6828 gLoc[0]=player[k].coords.x;
6829 gLoc[1]=player[k].coords.y;
6830 gLoc[2]=player[k].coords.z;
6831 vel[0]=player[k].velocity.x;
6832 vel[1]=player[k].velocity.y;
6833 vel[2]=player[k].velocity.z;
6835 PlaySoundEx( whooshsound, samp[whooshsound], NULL, TRUE);
6836 FSOUND_3D_SetAttributes(channels[whooshsound], gLoc, vel);
6837 FSOUND_SetVolume(channels[whooshsound], 128);
6838 FSOUND_SetPaused(channels[whooshsound], FALSE);
6841 player[k].velocity.y+=gravity;
6846 player[k].realoldcoords=player[k].coords;
6849 static XYZ oldviewer;
6852 player[0].forwardkeydown=IsKeyDown(theKeyMap, forwardkey);
6853 player[0].leftkeydown=IsKeyDown(theKeyMap, leftkey);
6854 player[0].backkeydown=IsKeyDown(theKeyMap, backkey);
6855 player[0].rightkeydown=IsKeyDown(theKeyMap, rightkey);
6856 player[0].jumpkeydown=IsKeyDown(theKeyMap, jumpkey);
6857 player[0].crouchkeydown=IsKeyDown(theKeyMap, crouchkey);
6858 player[0].drawkeydown=IsKeyDown(theKeyMap, drawkey);
6859 player[0].throwkeydown=IsKeyDown(theKeyMap, throwkey);
6863 player[0].forwardkeydown=0;
6864 player[0].leftkeydown=0;
6865 player[0].backkeydown=0;
6866 player[0].rightkeydown=0;
6867 player[0].jumpkeydown=0;
6868 player[0].crouchkeydown=0;
6869 player[0].drawkeydown=0;
6870 player[0].throwkeydown=0;
6873 if(!player[0].jumpkeydown)player[0].jumpclimb=0;
6876 static bool endkeydown;
6883 facing=DoRotation(facing,-rotation2,0,0);
6884 facing=DoRotation(facing,0,0-rotation,0);
6889 flatfacing=DoRotation(flatfacing,0,-rotation,0);
6891 if(IsKeyDown(theKeyMap, forwardkey))viewer+=facing*multiplier*4;
6892 if(IsKeyDown(theKeyMap, backkey))viewer-=facing*multiplier*4;
6893 if(IsKeyDown(theKeyMap, leftkey))viewer+=DoRotation(flatfacing*multiplier,0,90,0)*4;
6894 if(IsKeyDown(theKeyMap, rightkey))viewer+=DoRotation(flatfacing*multiplier,0,-90,0)*4;
6895 if(IsKeyDown(theKeyMap, jumpkey))viewer.y+=multiplier*4;
6896 if(IsKeyDown(theKeyMap, crouchkey))viewer.y-=multiplier*4;
6897 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)
6898 ||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)
6899 ||IsKeyDown(theKeyMap, MAC_MINUS_KEY))){
6901 if(IsKeyDown(theKeyMap, MAC_1_KEY))whichend=1;
6902 if(IsKeyDown(theKeyMap, MAC_2_KEY))whichend=2;
6903 if(IsKeyDown(theKeyMap, MAC_3_KEY))whichend=3;
6904 if(IsKeyDown(theKeyMap, MAC_4_KEY))whichend=4;
6905 if(IsKeyDown(theKeyMap, MAC_5_KEY))whichend=5;
6906 if(IsKeyDown(theKeyMap, MAC_6_KEY))whichend=6;
6907 if(IsKeyDown(theKeyMap, MAC_7_KEY))whichend=7;
6908 if(IsKeyDown(theKeyMap, MAC_8_KEY))whichend=8;
6909 if(IsKeyDown(theKeyMap, MAC_9_KEY))whichend=9;
6910 if(IsKeyDown(theKeyMap, MAC_0_KEY))whichend=0;
6911 if(IsKeyDown(theKeyMap, MAC_MINUS_KEY))whichend=-1;
6913 participantfocus[whichdialogue][indialogue]=whichend;
6914 participantlocation[whichdialogue][whichend]=player[whichend].coords;
6915 participantrotation[whichdialogue][whichend]=player[whichend].rotation;
6918 participantfocus[whichdialogue][indialogue]=-1;
6920 if(player[participantfocus[whichdialogue][indialogue]].dead){
6925 dialoguecamera[whichdialogue][indialogue]=viewer;
6926 dialoguecamerarotation[whichdialogue][indialogue]=rotation;
6927 dialoguecamerarotation2[whichdialogue][indialogue]=rotation2;
6929 if(indialogue<numdialogueboxes[whichdialogue]){
6930 if(dialogueboxsound[whichdialogue][indialogue]!=0){
6931 static float gLoc[3];
6932 static float vel[3];
6934 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
6935 temppos=temppos-viewer;
6936 Normalise(&temppos);
6941 gLoc[2]=temppos.z;vel[0]=0;
6945 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
6946 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
6947 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
6948 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
6949 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
6950 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
6951 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
6952 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
6953 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
6954 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
6955 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
6956 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
6957 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
6958 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
6959 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
6960 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
6961 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
6962 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
6963 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
6964 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
6965 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, TRUE);
6966 FSOUND_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
6967 FSOUND_SetVolume(channels[whichsoundplay], 256);
6968 FSOUND_SetPaused(channels[whichsoundplay], FALSE);
6972 for(j=0;j<numplayers;j++){
6973 participantfacing[whichdialogue][indialogue][j]=participantfacing[whichdialogue][indialogue-1][j];
6978 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)
6979 ||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)
6982 if(IsKeyDown(theKeyMap, MAC_NUMPAD_1_KEY))whichend=1;
6983 if(IsKeyDown(theKeyMap, MAC_NUMPAD_2_KEY))whichend=2;
6984 if(IsKeyDown(theKeyMap, MAC_NUMPAD_3_KEY))whichend=3;
6985 if(IsKeyDown(theKeyMap, MAC_NUMPAD_4_KEY))whichend=4;
6986 if(IsKeyDown(theKeyMap, MAC_NUMPAD_5_KEY))whichend=5;
6987 if(IsKeyDown(theKeyMap, MAC_NUMPAD_6_KEY))whichend=6;
6988 if(IsKeyDown(theKeyMap, MAC_NUMPAD_7_KEY))whichend=7;
6989 if(IsKeyDown(theKeyMap, MAC_NUMPAD_8_KEY))whichend=8;
6990 if(IsKeyDown(theKeyMap, MAC_NUMPAD_9_KEY))whichend=9;
6991 if(IsKeyDown(theKeyMap, MAC_NUMPAD_0_KEY))whichend=0;
6992 participantfacing[whichdialogue][indialogue][whichend]=facing;
6994 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)
6995 &&!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)
6996 &&!IsKeyDown(theKeyMap, MAC_MINUS_KEY)){
6999 if(indialogue>=numdialogueboxes[whichdialogue]){
7006 FSOUND_SetPaused(channels[whooshsound], TRUE);
7007 viewer=dialoguecamera[whichdialogue][indialogue];
7008 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.1){
7009 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.1;
7011 rotation=dialoguecamerarotation[whichdialogue][indialogue];
7012 rotation2=dialoguecamerarotation2[whichdialogue][indialogue];
7013 if(dialoguetime>0.5)
7014 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)
7015 ||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)
7016 ||IsKeyDown(theKeyMap, MAC_MINUS_KEY)))||(IsKeyDown(theKeyMap, attackkey)&&!oldbuttondialogue)){
7019 if(indialogue<numdialogueboxes[whichdialogue]){
7020 if(dialogueboxsound[whichdialogue][indialogue]!=0){
7021 static float gLoc[3];
7022 static float vel[3];
7024 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
7025 temppos=temppos-viewer;
7026 Normalise(&temppos);
7031 gLoc[2]=temppos.z;vel[0]=0;
7035 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
7036 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
7037 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
7038 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
7039 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
7040 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
7041 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
7042 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
7043 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
7044 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
7045 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
7046 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
7047 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
7048 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
7049 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
7050 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
7051 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
7052 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
7053 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
7054 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
7055 if(dialogueboxsound[whichdialogue][indialogue]==-6)whichsoundplay=alarmsound;
7056 if(dialogueboxsound[whichdialogue][indialogue]!=-5){
7057 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, TRUE);
7058 FSOUND_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
7059 FSOUND_SetVolume(channels[whichsoundplay], 256);
7060 FSOUND_SetPaused(channels[whichsoundplay], FALSE);
7062 if(dialogueboxsound[whichdialogue][indialogue]==-5){
7063 hotspot[numhotspots]=player[0].coords;
7064 hotspotsize[numhotspots]=10;
7065 hotspottype[numhotspots]=-1;
7069 if(dialogueboxsound[whichdialogue][indialogue]==-6){
7073 if(player[participantfocus[whichdialogue][indialogue]].dead){
7081 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)
7082 &&!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)
7083 &&!IsKeyDown(theKeyMap, MAC_MINUS_KEY)){
7086 if(indialogue>=numdialogueboxes[whichdialogue]){
7090 if(dialoguetype[whichdialogue]>19&&dialoguetype[whichdialogue]<30){
7093 if(dialoguetype[whichdialogue]>29&&dialoguetype[whichdialogue]<40){
7096 if(dialoguetype[whichdialogue]>49&&dialoguetype[whichdialogue]<60){
7098 for(i=1;i<numplayers;i++){
7099 player[i].aitype = attacktypecutoff;
7106 if(!IsKeyDown(theKeyMap, attackkey))oldbuttondialogue=0;
7107 else oldbuttondialogue=1;
7109 static float keyrefreshdelay=0,bigrefreshdelay=0;
7113 /*keyrefreshdelay-=multiplier;
7114 bigrefreshdelay-=multiplier;
7116 if(keyrefreshdelay<=0){
7117 static int concat[4];
7119 concat[0]=player[0].forwardkeydown;
7120 concat[0]=concat[0]*2+player[0].forwardstogglekeydown;
7121 concat[0]=concat[0]*2+player[0].rightkeydown;
7122 concat[0]=concat[0]*2+player[0].leftkeydown;
7123 concat[0]=concat[0]*2+player[0].backkeydown;
7124 concat[0]=concat[0]*2+player[0].jumpkeydown;
7125 concat[0]=concat[0]*2+player[0].jumptogglekeydown;
7126 concat[0]=concat[0]*2+player[0].crouchkeydown;
7128 concat[1]=player[0].crouchtogglekeydown;
7129 concat[1]=concat[1]*2+player[0].drawkeydown;
7130 concat[1]=concat[1]*2+player[0].drawtogglekeydown;
7131 concat[1]=concat[1]*2+player[0].throwkeydown;
7132 concat[1]=concat[1]*2+player[0].throwtogglekeydown;
7133 concat[1]=concat[1]*2+player[0].attackkeydown;
7135 //concat[2]=(char)((int)(rotation/2)%180);
7137 //concat[3]=(char)((int)(rotation2/2)%180);
7139 chatname[0]=concat[0]-128;
7140 chatname[1]=concat[1]-128;
7141 //chatname[2]=concat[2]-128;
7142 //chatname[3]=concat[3]-128;
7144 memcpy(chatname+temppoint,&rotation,sizeof(float));
7145 temppoint+=sizeof(float);
7146 memcpy(chatname+temppoint,&rotation2,sizeof(float));
7147 temppoint+=sizeof(float);
7149 chatname[temppoint]='\0';
7151 //if(!ishost)NetworkSendPlayerMessage( chatname, kMessageType_Keys );
7152 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_Keys );
7153 //keyrefreshdelay=.01;
7154 keyrefreshdelay=.03;
7157 if(bigrefreshdelay<=0){
7160 memcpy(chatname+temppoint,&i,sizeof(int));
7161 temppoint+=sizeof(int);
7162 memcpy(chatname+temppoint,&player[i].coords.x,sizeof(float));
7163 temppoint+=sizeof(float);
7164 memcpy(chatname+temppoint,&player[i].coords.y,sizeof(float));
7165 temppoint+=sizeof(float);
7166 memcpy(chatname+temppoint,&player[i].coords.z,sizeof(float));
7167 temppoint+=sizeof(float);
7168 memcpy(chatname+temppoint,&player[i].damage,sizeof(float));
7169 temppoint+=sizeof(float);
7170 memcpy(chatname+temppoint,&player[i].target,sizeof(float));
7171 temppoint+=sizeof(float);
7172 memcpy(chatname+temppoint,&player[i].targetanimation,sizeof(int));
7173 temppoint+=sizeof(int);
7174 memcpy(chatname+temppoint,&player[i].currentanimation,sizeof(int));
7175 temppoint+=sizeof(int);
7176 memcpy(chatname+temppoint,&player[i].velocity.x,sizeof(float));
7177 temppoint+=sizeof(float);
7178 memcpy(chatname+temppoint,&player[i].velocity.y,sizeof(float));
7179 temppoint+=sizeof(float);
7180 memcpy(chatname+temppoint,&player[i].velocity.z,sizeof(float));
7181 temppoint+=sizeof(float);
7182 memcpy(chatname+temppoint,&player[i].targetframe,sizeof(int));
7183 temppoint+=sizeof(int);
7184 memcpy(chatname+temppoint,&player[i].currentframe,sizeof(int));
7185 temppoint+=sizeof(int);
7186 memcpy(chatname+temppoint,&player[i].rotation,sizeof(float));
7187 temppoint+=sizeof(float);
7188 memcpy(chatname+temppoint,&player[i].targetrotation,sizeof(float));
7189 temppoint+=sizeof(float);
7190 memcpy(chatname+temppoint,&player[i].bloodloss,sizeof(float));
7191 temppoint+=sizeof(float);
7192 memcpy(chatname+temppoint,&player[i].weaponactive,sizeof(int));
7193 temppoint+=sizeof(int);
7194 memcpy(chatname+temppoint,&player[i].num_weapons,sizeof(int));
7195 temppoint+=sizeof(int);
7196 memcpy(chatname+temppoint,&player[i].weaponids[0],sizeof(int));
7197 temppoint+=sizeof(int);
7198 memcpy(chatname+temppoint,&player[i].weaponids[1],sizeof(int));
7199 temppoint+=sizeof(int);
7200 memcpy(chatname+temppoint,&player[i].weaponids[2],sizeof(int));
7201 temppoint+=sizeof(int);
7202 memcpy(chatname+temppoint,&player[i].weaponids[3],sizeof(int));
7203 temppoint+=sizeof(int);
7204 chatname[temppoint]='\0';
7206 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);
7207 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_PlayerState );
7208 //else NetworkSendPlayerMessage( chatname, kMessageType_PlayerState );
7210 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);
7212 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_PlayerStateMisc );
7213 //else NetworkSendPlayerMessage( chatname, kMessageType_PlayerStateMisc );
7215 //bigrefreshdelay=.02;
7220 if(!player[0].jumpkeydown){
7221 player[0].jumptogglekeydown=0;
7223 if(player[0].jumpkeydown&&player[0].targetanimation!=jumpupanim&&player[0].targetanimation!=jumpdownanim&&!player[0].isFlip())player[0].jumptogglekeydown=1;
7226 dialoguetime+=multiplier;
7227 skybox.cloudmove+=multiplier;
7228 hawkrotation+=multiplier*25;
7230 realhawkcoords.x=25;
7231 realhawkcoords=DoRotation(realhawkcoords,0,hawkrotation,0)+hawkcoords;
7232 hawkcalldelay-=multiplier/2;
7234 if(hawkcalldelay<=0)
7236 static float gLoc[3];
7237 static float vel[3];
7238 gLoc[0]=realhawkcoords.x;
7239 gLoc[1]=realhawkcoords.y;
7240 gLoc[2]=realhawkcoords.z;
7244 PlaySoundEx( hawksound, samp[hawksound], NULL, TRUE);
7245 FSOUND_3D_SetAttributes(channels[hawksound], gLoc, vel);
7246 FSOUND_SetVolume(channels[hawksound], 128);
7247 FSOUND_SetPaused(channels[hawksound], FALSE);
7249 hawkcalldelay=16+abs(Random()%8);
7251 static float temptexdetail;
7254 if(IsKeyDown(theKeyMap, MAC_H_KEY)&&debugmode){
7255 player[0].damagetolerance=200000;
7258 player[0].permanentdamage=0;
7259 player[0].superpermanentdamage=0;
7262 whichchar = abs(Random()%7);
7263 registrationname[whichchar]+=1;
7267 if(IsKeyDown(theKeyMap, MAC_J_KEY)&&!envtogglekeydown&&debugmode){
7269 if(environment>2)environment=0;
7270 Setenvironment(environment);
7276 if(!IsKeyDown(theKeyMap, MAC_J_KEY)){
7280 if(IsKeyDown(theKeyMap, MAC_C_KEY)&&!cameratogglekeydown&&debugmode){
7281 cameramode=1-cameramode;
7282 cameratogglekeydown=1;
7285 if(!IsKeyDown(theKeyMap, MAC_C_KEY)){
7286 cameratogglekeydown=0;
7289 if(IsKeyDown(theKeyMap, MAC_X_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!detailtogglekeydown&&debugmode){
7290 if(player[0].num_weapons>0){
7291 if(weapons.type[player[0].weaponids[0]]==sword)weapons.type[player[0].weaponids[0]]=staff;
7292 else if(weapons.type[player[0].weaponids[0]]==staff)weapons.type[player[0].weaponids[0]]=knife;
7293 else weapons.type[player[0].weaponids[0]]=sword;
7294 if(weapons.type[player[0].weaponids[0]]==sword){
7295 weapons.mass[player[0].weaponids[0]]=1.5;
7296 weapons.tipmass[player[0].weaponids[0]]=1;
7297 weapons.length[player[0].weaponids[0]]=.8;
7299 if(weapons.type[player[0].weaponids[0]]==staff){
7300 weapons.mass[player[0].weaponids[0]]=2;
7301 weapons.tipmass[player[0].weaponids[0]]=1;
7302 weapons.length[player[0].weaponids[0]]=1.5;
7305 if(weapons.type[player[0].weaponids[0]]==knife){
7306 weapons.mass[player[0].weaponids[0]]=1;
7307 weapons.tipmass[player[0].weaponids[0]]=1.2;
7308 weapons.length[player[0].weaponids[0]]=.25;
7312 /*for(i=0;i<objects.numobjects;i++){
7313 if(objects.type[i]==treeleavestype){
7314 for(j=0;j<objects.numobjects;j++){
7315 if(objects.type[j]==treetrunktype)
7316 if(findDistancefast(&objects.position[i],&objects.position[j])<.5)
7317 objects.scale[i]=objects.scale[j];
7321 detailtogglekeydown=1;
7324 if(IsKeyDown(theKeyMap, MAC_X_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!detailtogglekeydown&&debugmode){
7326 float closestdist=-1;
7329 for(i=1;i<numplayers;i++){
7330 distance=findDistancefast(&player[i].coords,&player[0].coords);
7331 if(closestdist==-1||distance<closestdist){
7332 closestdist=distance;
7337 if(player[closest].num_weapons)
7339 if(weapons.type[player[closest].weaponids[0]]==sword)weapons.type[player[closest].weaponids[0]]=staff;
7340 else if(weapons.type[player[closest].weaponids[0]]==staff)weapons.type[player[closest].weaponids[0]]=knife;
7341 else weapons.type[player[closest].weaponids[0]]=sword;
7342 if(weapons.type[player[closest].weaponids[0]]==sword){
7343 weapons.mass[player[closest].weaponids[0]]=1.5;
7344 weapons.tipmass[player[closest].weaponids[0]]=1;
7345 weapons.length[player[closest].weaponids[0]]=.8;
7347 if(weapons.type[player[0].weaponids[0]]==staff){
7348 weapons.mass[player[0].weaponids[0]]=2;
7349 weapons.tipmass[player[0].weaponids[0]]=1;
7350 weapons.length[player[0].weaponids[0]]=1.5;
7352 if(weapons.type[player[closest].weaponids[0]]==knife){
7353 weapons.mass[player[closest].weaponids[0]]=1;
7354 weapons.tipmass[player[closest].weaponids[0]]=1.2;
7355 weapons.length[player[closest].weaponids[0]]=.25;
7358 if(!player[closest].num_weapons)
7360 player[closest].weaponids[0]=weapons.numweapons;
7361 weapons.owner[weapons.numweapons]=closest;
7362 weapons.type[weapons.numweapons]=knife;
7363 weapons.damage[weapons.numweapons]=0;
7364 weapons.numweapons++;
7365 player[closest].num_weapons=1;
7366 if(weapons.type[player[closest].weaponids[0]]==sword){
7367 weapons.mass[player[closest].weaponids[0]]=1.5;
7368 weapons.tipmass[player[closest].weaponids[0]]=1;
7369 weapons.length[player[closest].weaponids[0]]=.8;
7371 if(weapons.type[player[closest].weaponids[0]]==knife){
7372 weapons.mass[player[closest].weaponids[0]]=1;
7373 weapons.tipmass[player[closest].weaponids[0]]=1.2;
7374 weapons.length[player[closest].weaponids[0]]=.25;
7378 detailtogglekeydown=1;
7381 if(IsKeyDown(theKeyMap, MAC_U_KEY)&&debugmode){
7383 float closestdist=-1;
7386 for(i=1;i<numplayers;i++){
7387 distance=findDistancefast(&player[i].coords,&player[0].coords);
7388 if(closestdist==-1||distance<closestdist){
7389 closestdist=distance;
7394 player[closest].rotation+=multiplier*50;
7395 player[closest].targetrotation=player[closest].rotation;
7399 if(IsKeyDown(theKeyMap, MAC_O_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7401 float closestdist=-1;
7404 for(i=1;i<numplayers;i++){
7405 distance=findDistancefast(&player[i].coords,&player[0].coords);
7406 if(closestdist==-1||distance<closestdist){
7407 closestdist=distance;
7411 if(IsKeyDown(theKeyMap, MAC_CONTROL_KEY))closest=0;
7414 player[closest].whichskin++;
7415 if(player[closest].whichskin>9)player[closest].whichskin=0;
7416 if(player[closest].whichskin>2&&player[closest].creature==wolftype)player[closest].whichskin=0;
7418 if(player[closest].creature==rabbittype){
7419 if(player[closest].whichskin==0){
7420 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7422 else if(player[closest].whichskin==1){
7423 LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7425 else if(player[closest].whichskin==2){
7426 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7428 else if(player[closest].whichskin==3){
7429 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7431 else if(player[closest].whichskin==4){
7432 LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7434 else if(player[closest].whichskin==5){
7435 LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7437 else if(player[closest].whichskin==6){
7438 LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7440 else if(player[closest].whichskin==7){
7441 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7443 else if(player[closest].whichskin==8){
7444 LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7446 else if(player[closest].whichskin==9){
7447 LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7450 if(player[closest].creature==wolftype){
7452 if(player[closest].whichskin==0){
7453 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7455 else if(player[closest].whichskin==1){
7456 LoadTextureSave(":Data:Textures:Darkwolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7458 else if(player[closest].whichskin==2){
7459 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7464 if(player[closest].numclothes){
7465 for(i=0;i<player[closest].numclothes;i++){
7466 tintr=player[closest].clothestintr[i];
7467 tintg=player[closest].clothestintg[i];
7468 tintb=player[closest].clothestintb[i];
7469 AddClothes((char *)player[closest].clothes[i],0,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7471 player[closest].DoMipmaps(5,0,0,player[closest].skeleton.skinsize,player[closest].skeleton.skinsize);
7474 detailtogglekeydown=1;
7477 if(IsKeyDown(theKeyMap, MAC_O_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7479 float closestdist=-1;
7482 for(i=1;i<numplayers;i++){
7483 distance=findDistancefast(&player[i].coords,&player[0].coords);
7484 if(closestdist==-1||distance<closestdist){
7485 closestdist=distance;
7490 if(player[closest].creature==wolftype){
7491 headprop=player[closest].proportionhead.x/1.1;
7492 bodyprop=player[closest].proportionbody.x/1.1;
7493 armprop=player[closest].proportionarms.x/1.1;
7494 legprop=player[closest].proportionlegs.x/1.1;
7497 if(player[closest].creature==rabbittype){
7498 headprop=player[closest].proportionhead.x/1.2;
7499 bodyprop=player[closest].proportionbody.x/1.05;
7500 armprop=player[closest].proportionarms.x/1.00;
7501 legprop=player[closest].proportionlegs.x/1.1;
7505 if(player[closest].creature==rabbittype){
7506 player[closest].skeleton.id=closest;
7507 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);
7508 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[closest],&player[closest].skeleton.skinsize);
7509 player[closest].whichskin=0;
7510 player[closest].creature=wolftype;
7512 player[closest].proportionhead=1.1;
7513 player[closest].proportionbody=1.1;
7514 player[closest].proportionarms=1.1;
7515 player[closest].proportionlegs=1.1;
7516 player[closest].proportionlegs.y=1.1;
7517 player[closest].scale=.23*5*player[0].scale;
7519 player[closest].damagetolerance=300;
7523 player[closest].skeleton.id=closest;
7524 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);
7525 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7526 player[closest].whichskin=0;
7527 player[closest].creature=rabbittype;
7529 player[closest].proportionhead=1.2;
7530 player[closest].proportionbody=1.05;
7531 player[closest].proportionarms=1.00;
7532 player[closest].proportionlegs=1.1;
7533 player[closest].proportionlegs.y=1.05;
7534 player[closest].scale=.2*5*player[0].scale;
7536 player[closest].damagetolerance=200;
7539 if(player[closest].creature==wolftype){
7540 player[closest].proportionhead=1.1*headprop;
7541 player[closest].proportionbody=1.1*bodyprop;
7542 player[closest].proportionarms=1.1*armprop;
7543 player[closest].proportionlegs=1.1*legprop;
7546 if(player[closest].creature==rabbittype){
7547 player[closest].proportionhead=1.2*headprop;
7548 player[closest].proportionbody=1.05*bodyprop;
7549 player[closest].proportionarms=1.00*armprop;
7550 player[closest].proportionlegs=1.1*legprop;
7551 player[closest].proportionlegs.y=1.05*legprop;
7555 detailtogglekeydown=1;
7558 if(!IsKeyDown(theKeyMap, MAC_X_KEY)){
7559 detailtogglekeydown=0;
7562 if(IsKeyDown(theKeyMap, MAC_B_KEY)&&!slomotogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7565 slomotogglekeydown=1;
7569 if(((IsKeyDown(theKeyMap, MAC_I_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY))/*||buttons[1]*/)&&!explodetogglekeydown&&debugmode){
7571 float closestdist=-1;
7573 XYZ flatfacing2,flatvelocity2;
7576 for(i=1;i<numplayers;i++){
7577 distance=findDistancefast(&player[i].coords,&player[0].coords);
7578 if(distance<144&&!player[i].headless)
7579 if(closestdist==-1||distance<closestdist){
7580 closestdist=distance;
7582 blah = player[i].coords;
7587 XYZ headspurtdirection;
7588 int i = player[closest].skeleton.jointlabels[head];
7589 for(k=0;k<player[closest].skeleton.num_joints; k++){
7590 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7591 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7592 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;
7593 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7594 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7595 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7596 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7597 headspurtdirection=player[closest].skeleton.joints[player[closest].skeleton.jointlabels[head]].position-player[closest].skeleton.joints[player[closest].skeleton.jointlabels[neck]].position;
7598 Normalise(&headspurtdirection);
7599 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, .6, 1);
7600 flatvelocity2+=headspurtdirection*8;
7601 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2/2, 1,1,1, .16, 1);
7603 sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
7613 PlaySoundEx( splattersound, samp[splattersound], NULL, TRUE);
7614 FSOUND_3D_SetAttributes(channels[splattersound], gLoc, vel);
7615 FSOUND_SetVolume(channels[splattersound], 256);
7616 FSOUND_SetPaused(channels[splattersound], FALSE);
7618 PlaySoundEx( breaksound2, samp[breaksound2], NULL, TRUE);
7619 FSOUND_3D_SetAttributes(channels[breaksound2], gLoc, vel);
7620 FSOUND_SetVolume(channels[breaksound2], 100);
7621 FSOUND_SetPaused(channels[breaksound2], FALSE);
7623 if(player[closest].skeleton.free==2)player[closest].skeleton.free=0;
7624 player[closest].RagDoll(0);
7625 player[closest].dead=2;
7626 player[closest].headless=1;
7627 player[closest].DoBloodBig(3,165);
7632 explodetogglekeydown=1;
7635 if(((IsKeyDown(theKeyMap, MAC_I_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY))/*||buttons[2]*/)&&!explodetogglekeydown&&debugmode){
7637 float closestdist=-1;
7639 XYZ flatfacing2,flatvelocity2;
7642 for(i=1;i<numplayers;i++){
7643 distance=findDistancefast(&player[i].coords,&player[0].coords);
7645 if(closestdist==-1||distance<closestdist){
7646 closestdist=distance;
7648 blah=player[i].coords;
7662 PlaySoundEx( splattersound, samp[splattersound], NULL, TRUE);
7663 FSOUND_3D_SetAttributes(channels[splattersound], gLoc, vel);
7664 FSOUND_SetVolume(channels[splattersound], 256);
7665 FSOUND_SetPaused(channels[splattersound], FALSE);
7667 PlaySoundEx( breaksound2, samp[breaksound2], NULL, TRUE);
7668 FSOUND_3D_SetAttributes(channels[breaksound2], gLoc, vel);
7669 FSOUND_SetVolume(channels[breaksound2], 600);
7670 FSOUND_SetPaused(channels[breaksound2], FALSE);
7672 for(i=0;i<player[closest].skeleton.num_joints; i++){
7673 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7674 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7675 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;
7676 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7677 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7678 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7679 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7680 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
7681 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .3, 1);
7682 sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
7685 for(i=0;i<player[closest].skeleton.num_joints; i++){
7686 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7687 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7688 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;
7689 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7690 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7691 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7692 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7693 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
7694 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
7697 for(i=0;i<player[closest].skeleton.num_joints; i++){
7698 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7699 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7700 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;
7701 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7702 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7703 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7704 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7705 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
7706 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
7709 for(i=0;i<player[closest].skeleton.num_joints; i++){
7710 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7711 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7712 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;
7713 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7714 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7715 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7716 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7717 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
7718 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
7722 for(j=0;j<numplayers; j++){
7724 if(findDistancefast(&player[j].coords,&player[closest].coords)<25){
7725 player[j].DoDamage((25-findDistancefast(&player[j].coords,&player[closest].coords))*60);
7726 if(player[j].skeleton.free==2)player[j].skeleton.free=1;
7727 player[j].skeleton.longdead=0;
7728 player[j].RagDoll(0);
7729 for(i=0;i<player[j].skeleton.num_joints; i++){
7730 temppos=player[j].skeleton.joints[i].position+player[j].coords;
7731 if(findDistancefast(&temppos,&player[closest].coords)<25){
7732 flatvelocity2=temppos-player[closest].coords;
7733 Normalise(&flatvelocity2);
7734 player[j].skeleton.joints[i].velocity+=flatvelocity2*((20-findDistancefast(&temppos,&player[closest].coords))*20);
7741 player[closest].DoDamage(10000);
7742 player[closest].RagDoll(0);
7743 player[closest].dead=2;
7744 player[closest].coords=20;
7745 player[closest].skeleton.free=2;
7751 explodetogglekeydown=1;
7754 if(!IsKeyDown(theKeyMap, MAC_I_KEY)){
7755 explodetogglekeydown=0;
7759 if(IsKeyDown(theKeyMap, MAC_S_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)&&!slomotogglekeydown){
7761 //tfile=fopen( ":Data:Maps:mapsave", "wb" );
7762 if(whichlevel==0)tfile=fopen( ":Data:Maps:map1", "wb" );
7763 else if(whichlevel==1)tfile=fopen( ":Data:Maps:map2", "wb" );
7764 else if(whichlevel==2)tfile=fopen( ":Data:Maps:map3", "wb" );
7765 else if(whichlevel==3)tfile=fopen( ":Data:Maps:map4", "wb" );
7766 else if(whichlevel==4)tfile=fopen( ":Data:Maps:map5", "wb" );
7767 else tfile=fopen( ":Data:Maps:mapsave", "wb" );
7769 fwrite( &player[0].coords, 1, sizeof(XYZ), tfile );
7770 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
7771 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
7772 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
7773 for(j=0;j<player[0].num_weapons;j++){
7774 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
7776 fwrite( &environment, 1, sizeof(int), tfile );
7778 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
7779 fwrite( &objects.type, 1, sizeof(int)*objects.numobjects, tfile );
7780 fwrite( &objects.rotation, 1, sizeof(float)*objects.numobjects, tfile );
7781 fwrite( &objects.position, 1, sizeof(XYZ)*objects.numobjects, tfile );
7782 fwrite( &objects.scale, 1, sizeof(float)*objects.numobjects, tfile );
7784 fwrite( &numplayers, 1, sizeof(int), tfile );
7785 if(numplayers>1&&numplayers<maxplayers)
7786 for(i=1;i<numplayers;i++){
7787 fwrite( &player[i].coords, 1, sizeof(XYZ), tfile );
7788 fwrite( &player[i].num_weapons, 1, sizeof(int), tfile );
7789 for(j=0;j<player[i].num_weapons;j++){
7790 fwrite( &weapons.type[player[i].weaponids[j]], 1, sizeof(int), tfile );
7792 if(player[i].numwaypoints<30){
7793 fwrite( &player[i].numwaypoints, 1, sizeof(int), tfile );
7794 fwrite( &player[i].waypoints, 1, sizeof(XYZ)*player[i].numwaypoints, tfile );
7795 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7796 //fwrite( &player[i].jumppath, 1, sizeof(bool), tfile );
7799 player[i].numwaypoints=0;
7800 player[i].waypoint=0;
7801 fwrite( &player[i].numwaypoints, 1, sizeof(int), tfile );
7802 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7803 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7809 slomotogglekeydown=1;
7812 if(!IsKeyDown(theKeyMap, MAC_B_KEY)&&!IsKeyDown(theKeyMap, MAC_F_KEY)&&!IsKeyDown(theKeyMap, MAC_K_KEY)&&!IsKeyDown(theKeyMap, MAC_S_KEY)){
7813 slomotogglekeydown=0;
7817 if(IsKeyDown(theKeyMap, MAC_F_KEY)&&!slomotogglekeydown&&debugmode){
7818 player[0].onfire=1-player[0].onfire;
7819 if(player[0].onfire){
7820 player[0].CatchFire();
7822 if(!player[0].onfire){
7825 gLoc[0]=player[0].coords.x;
7826 gLoc[1]=player[0].coords.y;
7827 gLoc[2]=player[0].coords.z;
7831 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
7832 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
7833 FSOUND_SetVolume(channels[fireendsound], 256);
7834 FSOUND_SetPaused(channels[fireendsound], FALSE);
7835 FSOUND_SetPaused(channels[stream_firesound], TRUE);
7837 slomotogglekeydown=1;
7840 if(IsKeyDown(theKeyMap, MAC_L_KEY)){
7841 if(player[0].bleeding<=0)
7842 player[0].DoBlood(1,255);
7846 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)){
7848 float closestdist=-1;
7851 for(i=1;i<numplayers;i++){
7852 distance=findDistancefast(&player[i].coords,&player[0].coords);
7853 if(closestdist==-1||distance<closestdist){
7854 closestdist=distance;
7858 if(closestdist>0&&closest>=0){
7859 //player[closest]=player[numplayers-1];
7860 //player[closest].skeleton=player[numplayers-1].skeleton;
7863 drawmodetogglekeydown=1;
7866 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7868 float closestdist=-1;
7871 for(i=1;i<max_objects;i++){
7872 distance=findDistancefast(&objects.position[i],&player[0].coords);
7873 if(closestdist==-1||distance<closestdist){
7874 closestdist=distance;
7878 if(closestdist>0&&closest>=0){
7879 objects.position[closest].y-=500;
7881 drawmodetogglekeydown=1;
7884 if(IsKeyDown(theKeyMap, MAC_M_KEY)&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&editorenabled&&debugmode){
7886 //if(drawmode>2)drawmode=0;
7887 if(objects.numobjects<max_objects-1){
7889 boxcoords.x=player[0].coords.x;
7890 boxcoords.z=player[0].coords.z;
7891 boxcoords.y=player[0].coords.y-3;
7892 if(editortype==bushtype)boxcoords.y=player[0].coords.y-.5;
7893 if(editortype==firetype)boxcoords.y=player[0].coords.y-.5;
7894 //objects.MakeObject(abs(Random()%3),boxcoords,Random()%360);
7895 float temprotat,temprotat2;
7896 temprotat=editorrotation;
7897 temprotat2=editorrotation2;
7898 if(temprotat<0||editortype==bushtype)temprotat=Random()%360;
7899 if(temprotat2<0)temprotat2=Random()%360;
7901 objects.MakeObject(editortype,boxcoords,(int)temprotat-((int)temprotat)%30,(int)temprotat2,editorsize);
7902 if(editortype==treetrunktype)
7903 objects.MakeObject(treeleavestype,boxcoords,Random()%360*(temprotat2<2)+(int)editorrotation-((int)editorrotation)%30,editorrotation2,editorsize);
7906 drawmodetogglekeydown=1;
7909 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&editorenabled){
7910 if(numplayers<maxplayers-1){
7911 player[numplayers].scale=.2*5*player[0].scale;
7912 player[numplayers].creature=rabbittype;
7913 player[numplayers].howactive=editoractive;
7914 player[numplayers].skeleton.id=numplayers;
7915 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);
7917 //texsize=512*512*3/texdetail/texdetail;
7918 //if(!player[numplayers].loaded)player[numplayers].skeleton.skinText = new GLubyte[texsize];
7919 //player[numplayers].skeleton.skinText.resize(texsize);
7921 k=abs(Random()%2)+1;
7923 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7924 player[numplayers].whichskin=0;
7927 LoadTextureSave(":Data:Textures:Fur.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7928 player[numplayers].whichskin=1;
7931 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7932 player[numplayers].whichskin=2;
7935 LoadTexture(":Data:Textures:Belt.png",&player[numplayers].skeleton.drawmodelclothes.textureptr,1,1);
7936 player[numplayers].power=1;
7937 player[numplayers].speedmult=1;
7938 player[numplayers].currentanimation=bounceidleanim;
7939 player[numplayers].targetanimation=bounceidleanim;
7940 player[numplayers].currentframe=0;
7941 player[numplayers].targetframe=1;
7942 player[numplayers].target=0;
7943 player[numplayers].bled=0;
7944 player[numplayers].speed=1+(float)(Random()%100)/1000;
7946 player[numplayers].targetrotation=player[0].targetrotation;
7947 player[numplayers].rotation=player[0].rotation;
7949 player[numplayers].velocity=0;
7950 player[numplayers].coords=player[0].coords;
7951 player[numplayers].oldcoords=player[numplayers].coords;
7952 player[numplayers].realoldcoords=player[numplayers].coords;
7954 player[numplayers].id=numplayers;
7955 player[numplayers].skeleton.id=numplayers;
7956 player[numplayers].updatedelay=0;
7957 player[numplayers].normalsupdatedelay=0;
7959 player[numplayers].aitype=passivetype;
7960 player[numplayers].aitarget=0;
7962 if(player[0].creature==wolftype){
7963 headprop=player[0].proportionhead.x/1.1;
7964 bodyprop=player[0].proportionbody.x/1.1;
7965 armprop=player[0].proportionarms.x/1.1;
7966 legprop=player[0].proportionlegs.x/1.1;
7969 if(player[0].creature==rabbittype){
7970 headprop=player[0].proportionhead.x/1.2;
7971 bodyprop=player[0].proportionbody.x/1.05;
7972 armprop=player[0].proportionarms.x/1.00;
7973 legprop=player[0].proportionlegs.x/1.1;
7976 if(player[numplayers].creature==wolftype){
7977 player[numplayers].proportionhead=1.1*headprop;
7978 player[numplayers].proportionbody=1.1*bodyprop;
7979 player[numplayers].proportionarms=1.1*armprop;
7980 player[numplayers].proportionlegs=1.1*legprop;
7983 if(player[numplayers].creature==rabbittype){
7984 player[numplayers].proportionhead=1.2*headprop;
7985 player[numplayers].proportionbody=1.05*bodyprop;
7986 player[numplayers].proportionarms=1.00*armprop;
7987 player[numplayers].proportionlegs=1.1*legprop;
7988 player[numplayers].proportionlegs.y=1.05*legprop;
7991 player[numplayers].headless=0;
7992 player[numplayers].onfire=0;
7995 player[numplayers].proportionhead.z=0;
7996 player[numplayers].proportionbody.z=0;
7997 player[numplayers].proportionarms.z=0;
7998 player[numplayers].proportionlegs.z=0;
8001 player[numplayers].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0);
8003 player[numplayers].damagetolerance=200;
8005 player[numplayers].protectionhead=player[0].protectionhead;
8006 player[numplayers].protectionhigh=player[0].protectionhigh;
8007 player[numplayers].protectionlow=player[0].protectionlow;
8008 player[numplayers].armorhead=player[0].armorhead;
8009 player[numplayers].armorhigh=player[0].armorhigh;
8010 player[numplayers].armorlow=player[0].armorlow;
8011 player[numplayers].metalhead=player[0].metalhead;
8012 player[numplayers].metalhigh=player[0].metalhigh;
8013 player[numplayers].metallow=player[0].metallow;
8015 player[numplayers].immobile=player[0].immobile;
8017 player[numplayers].numclothes=player[0].numclothes;
8018 if(player[numplayers].numclothes)
8019 for(i=0;i<player[numplayers].numclothes;i++){
8020 strcpy(player[numplayers].clothes[i], player[0].clothes[i]);
8021 player[numplayers].clothestintr[i]=player[0].clothestintr[i];
8022 player[numplayers].clothestintg[i]=player[0].clothestintg[i];
8023 player[numplayers].clothestintb[i]=player[0].clothestintb[i];
8024 tintr=player[numplayers].clothestintr[i];
8025 tintg=player[numplayers].clothestintg[i];
8026 tintb=player[numplayers].clothestintb[i];
8027 AddClothes((char *)player[numplayers].clothes[i],0,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
8029 if(player[numplayers].numclothes){
8030 player[numplayers].DoMipmaps(5,0,0,player[numplayers].skeleton.skinsize,player[numplayers].skeleton.skinsize);
8033 player[numplayers].power=player[0].power;
8034 player[numplayers].speedmult=player[0].speedmult;
8036 player[numplayers].damage=0;
8037 player[numplayers].permanentdamage=0;
8038 player[numplayers].superpermanentdamage=0;
8039 player[numplayers].deathbleeding=0;
8040 player[numplayers].bleeding=0;
8041 player[numplayers].numwaypoints=0;
8042 player[numplayers].waypoint=0;
8043 player[numplayers].jumppath=0;
8044 player[numplayers].weaponstuck=-1;
8045 player[numplayers].weaponactive=-1;
8046 player[numplayers].num_weapons=0;
8047 player[numplayers].bloodloss=0;
8048 player[numplayers].dead=0;
8050 player[numplayers].loaded=1;
8054 drawmodetogglekeydown=1;
8057 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&editorenabled){
8058 if(player[numplayers-1].numwaypoints<90){
8059 player[numplayers-1].waypoints[player[numplayers-1].numwaypoints]=player[0].coords;
8060 player[numplayers-1].waypointtype[player[numplayers-1].numwaypoints]=editorpathtype;
8061 player[numplayers-1].numwaypoints++;
8063 drawmodetogglekeydown=1;
8066 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&editorenabled){
8067 if(numpathpoints<30){
8068 bool connected,alreadyconnected;
8071 for(i=0;i<numpathpoints;i++){
8072 if(findDistancefast(&pathpoint[i],&player[0].coords)<.5&&i!=pathpointselected&&!connected){
8074 for(j=0;j<numpathpointconnect[pathpointselected];j++){
8075 if(pathpointconnect[pathpointselected][j]==i)alreadyconnected=1;
8077 if(!alreadyconnected){
8078 numpathpointconnect[pathpointselected]++;
8080 pathpointconnect[pathpointselected][numpathpointconnect[pathpointselected]-1]=i;
8086 pathpoint[numpathpoints-1]=player[0].coords;
8087 numpathpointconnect[numpathpoints-1]=0;
8088 if(numpathpoints>1&&pathpointselected!=-1){
8089 numpathpointconnect[pathpointselected]++;
8090 pathpointconnect[pathpointselected][numpathpointconnect[pathpointselected]-1]=numpathpoints-1;
8092 pathpointselected=numpathpoints-1;
8095 drawmodetogglekeydown=1;
8098 if(IsKeyDown(theKeyMap, MAC_PERIOD_KEY)&&!drawmodetogglekeydown&&editorenabled){
8099 pathpointselected++;
8100 if(pathpointselected>=numpathpoints)pathpointselected=-1;
8101 drawmodetogglekeydown=1;
8103 if(IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!drawmodetogglekeydown&&editorenabled){
8104 pathpointselected--;
8105 if(pathpointselected<=-2)pathpointselected=numpathpoints-1;
8106 drawmodetogglekeydown=1;
8108 if(IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!drawmodetogglekeydown&&editorenabled){
8109 if(pathpointselected!=-1){
8111 pathpoint[pathpointselected]=pathpoint[numpathpoints];
8112 numpathpointconnect[pathpointselected]=numpathpointconnect[numpathpoints];
8113 for(i=0;i<numpathpointconnect[pathpointselected];i++){
8114 pathpointconnect[pathpointselected][i]=pathpointconnect[numpathpoints][i];
8116 for(i=0;i<numpathpoints;i++){
8117 for(j=0;j<numpathpointconnect[i];j++){
8118 if(pathpointconnect[i][j]==pathpointselected){
8119 pathpointconnect[i][j]=pathpointconnect[i][numpathpointconnect[i]-1];
8120 numpathpointconnect[i]--;
8122 if(pathpointconnect[i][j]==numpathpoints){
8123 pathpointconnect[i][j]=pathpointselected;
8127 pathpointselected=numpathpoints-1;
8129 drawmodetogglekeydown=1;
8132 if(IsKeyDown(theKeyMap, MAC_M_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
8133 editorenabled=1-editorenabled;
8135 player[0].damagetolerance=100000;
8137 player[0].superpermanentdamage=0;
8138 player[0].bloodloss=0;
8139 player[0].deathbleeding=0;
8142 player[0].damagetolerance=200;
8144 player[0].permanentdamage=0;
8145 player[0].superpermanentdamage=0;
8146 player[0].bloodloss=0;
8147 player[0].deathbleeding=0;
8149 drawmodetogglekeydown=1;
8152 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8154 if(editortype==treeleavestype||editortype==10)editortype--;
8155 if(editortype<0)editortype=firetype;
8156 drawmodetogglekeydown=1;
8159 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8161 if(editortype==treeleavestype||editortype==10)editortype++;
8162 if(editortype>firetype)editortype=0;
8163 drawmodetogglekeydown=1;
8166 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8167 editorrotation-=multiplier*100;
8168 if(editorrotation<-.01)editorrotation=-.01;
8169 drawmodetogglekeydown=1;
8172 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8173 editorrotation+=multiplier*100;
8174 drawmodetogglekeydown=1;
8177 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8178 editorsize+=multiplier;
8179 drawmodetogglekeydown=1;
8182 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8183 editorsize-=multiplier;
8184 if(editorsize<.1)editorsize=.1;
8185 drawmodetogglekeydown=1;
8189 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8190 mapradius-=multiplier*10;
8193 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8194 mapradius+=multiplier*10;
8197 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8198 mapcenter.x+=multiplier*20;
8201 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8202 mapcenter.x-=multiplier*20;
8205 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8206 mapcenter.z+=multiplier*20;
8209 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8210 mapcenter.z-=multiplier*20;
8213 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8214 editorrotation2+=multiplier*100;
8217 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8218 editorrotation2-=multiplier*100;
8219 if(editorrotation2<-.01)editorrotation2=-.01;
8221 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&objects.numobjects&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)){
8223 float closestdist=-1;
8225 for(i=0;i<objects.numobjects;i++){
8226 distance=findDistancefast(&objects.position[i],&player[0].coords);
8227 if(closestdist==-1||distance<closestdist){
8228 closestdist=distance;
8232 if(closestdist>0&&closest>=0)objects.DeleteObject(closest);
8233 drawmodetogglekeydown=1;
8237 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)){
8238 drawmodetogglekeydown=0;
8241 if(IsKeyDown(theKeyMap, MAC_N_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&!texturesizetogglekeydown&&debugmode){
8242 //if(!player[0].skeleton.free)player[0].damage+=500;
8243 player[0].RagDoll(0);
8244 //player[0].spurt=1;
8245 //player[0].DoDamage(1000);
8249 gLoc[0]=player[0].coords.x;
8250 gLoc[1]=player[0].coords.y;
8251 gLoc[2]=player[0].coords.z;
8252 vel[0]=player[0].velocity.x;
8253 vel[1]=player[0].velocity.y;
8254 vel[2]=player[0].velocity.z;
8255 PlaySoundEx( whooshsound, samp[whooshsound], NULL, TRUE);
8256 FSOUND_3D_SetAttributes(channels[whooshsound], gLoc, vel);
8257 FSOUND_SetVolume(channels[whooshsound], 128);
8258 FSOUND_SetPaused(channels[whooshsound], FALSE);
8259 //FSOUND_SetPaused(channels[whooshsound], TRUE);
8261 texturesizetogglekeydown=1;
8264 if(IsKeyDown(theKeyMap, MAC_N_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&!texturesizetogglekeydown&&debugmode){
8267 float closestdist=-1;
8269 for(i=0;i<objects.numobjects;i++){
8270 if(objects.type[i]==treeleavestype){
8271 objects.scale[i]*=.9;
8274 texturesizetogglekeydown=1;
8277 static XYZ relative;
8278 static int randattack;
8280 static bool playerrealattackkeydown=0;
8282 if(!buttons[0])oldbutton=0;
8283 if(!IsKeyDown(theKeyMap, attackkey))oldattackkey=0;
8284 if(oldattackkey)player[0].attackkeydown=0;
8285 if(oldattackkey)playerrealattackkeydown=0;
8286 if(!oldattackkey)playerrealattackkeydown=IsKeyDown(theKeyMap, attackkey);
8287 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);
8288 if(IsKeyDown(theKeyMap, attackkey)&&!oldattackkey&&!player[0].backkeydown){
8289 for(k=0;k<numplayers;k++){
8290 if((player[k].targetanimation==swordslashanim||player[k].targetanimation==staffhitanim||player[k].targetanimation==staffspinhitanim)&&player[0].currentanimation!=dodgebackanim&&!player[k].skeleton.free)
8291 player[k].Reverse();
8295 if(!hostile||indialogue!=-1)player[0].attackkeydown=0;
8297 for(k=0;k<numplayers;k++){
8298 if(indialogue!=-1)player[k].attackkeydown=0;
8299 if(player[k].targetanimation!=rabbitrunninganim&&player[k].targetanimation!=wolfrunninganim){
8300 if(player[k].aitype!=playercontrolled)player[k].victim=&player[0];
8301 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)){
8302 player[k].jumppower-=2;
8304 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)){
8305 for(i=0;i<numplayers;i++){
8307 if(player[i].targetanimation==swordslashanim||player[i].targetanimation==knifeslashstartanim||player[i].targetanimation==staffhitanim||player[i].targetanimation==staffspinhitanim)
8308 if(findDistancefast(&player[k].coords,&player[i].coords)<6.5&&!player[i].skeleton.free){
8309 player[k].targetanimation=dodgebackanim;
8311 player[k].targetframe=0;
8312 rotatetarget=player[i].coords-player[k].coords;
8313 Normalise(&rotatetarget);
8314 player[k].targetrotation=-asin(0-rotatetarget.x);
8315 player[k].targetrotation*=360/6.28;
8316 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8318 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;
8321 if(player[k].targetanimation!=dodgebackanim){
8322 if(k==0)numflipped++;
8323 player[k].targetanimation=backhandspringanim;
8325 player[k].targetframe=0;
8326 player[k].targetrotation=-rotation+180;
8327 if(player[k].leftkeydown)player[k].targetrotation-=45;
8328 if(player[k].rightkeydown)player[k].targetrotation+=45;
8329 player[k].rotation=player[k].targetrotation;
8330 player[k].jumppower-=2;
8333 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())){
8334 player[k].hasvictim=0;
8336 for(i=0;i<numplayers;i++){
8338 if(!player[k].hasvictim)
8339 if((k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack!=reversal){
8340 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){
8341 player[k].victim=&player[i];
8342 player[k].hasvictim=1;
8343 if(player[k].aitype==playercontrolled){
8344 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;
8345 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;
8346 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;
8347 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;
8348 else if(findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)&&animation[player[i].targetanimation].height!=lowheight&&!player[k].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;
8349 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;
8350 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;
8351 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;
8352 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;
8353 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;
8356 if(findDistancefast(&player[k].coords,&player[i].coords)<4.5*(player[k].scale*5)*(player[k].scale*5)){
8357 if(player[k].weaponactive==-1)randattack=abs(Random()%5);
8358 else randattack=abs(Random()%5);
8359 if(player[k].weaponactive==-1&&findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)){
8360 if(randattack==0&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=sweepanim;
8361 else if(randattack==1&&animation[player[i].targetanimation].height!=lowheight&&player[k].weaponactive==-1)player[k].targetanimation=upunchanim;
8362 else if(randattack==2&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=spinkickanim;
8363 else if(animation[player[i].targetanimation].height==lowheight)player[k].targetanimation=lowkickanim;
8365 if(player[k].weaponactive!=-1){
8366 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;
8367 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;
8368 //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;
8369 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;
8370 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;
8371 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;
8372 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;
8373 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;
8377 if(player[k].targetanimation==upunchanim&&player[k].creature==wolftype)player[k].targetanimation=wolfslapanim;
8379 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)){
8380 if(player[k].weaponactive==-1){
8381 player[i].targetanimation=sneakattackedanim;
8382 player[i].currentanimation=sneakattackedanim;
8383 player[k].currentanimation=sneakattackanim;
8384 player[k].targetanimation=sneakattackanim;
8385 player[k].oldcoords=player[k].coords;
8386 player[k].coords=player[i].coords;
8388 if(player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==knife){
8389 player[i].targetanimation=knifesneakattackedanim;
8390 player[i].currentanimation=knifesneakattackedanim;
8391 player[k].currentanimation=knifesneakattackanim;
8392 player[k].targetanimation=knifesneakattackanim;
8393 player[i].oldcoords=player[i].coords;
8394 player[i].coords=player[k].coords;
8396 if(player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==sword){
8397 player[i].targetanimation=swordsneakattackedanim;
8398 player[i].currentanimation=swordsneakattackedanim;
8399 player[k].currentanimation=swordsneakattackanim;
8400 player[k].targetanimation=swordsneakattackanim;
8401 player[i].oldcoords=player[i].coords;
8402 player[i].coords=player[k].coords;
8404 if(player[k].weaponactive==-1||weapons.type[player[k].weaponids[player[k].weaponactive]]!=staff){
8405 player[k].victim=&player[i];
8406 player[k].hasvictim=1;
8407 player[i].targettilt2=0;
8408 player[i].targetframe=1;
8409 player[i].currentframe=0;
8411 player[i].velocity=0;
8412 player[k].targettilt2=player[i].targettilt2;
8413 player[k].currentframe=player[i].currentframe;
8414 player[k].targetframe=player[i].targetframe;
8415 player[k].target=player[i].target;
8416 player[k].velocity=0;
8417 player[k].targetrotation=player[i].rotation;
8418 player[k].rotation=player[i].rotation;
8419 player[i].targetrotation=player[i].rotation;
8422 if(animation[player[k].targetanimation].attack==normalattack&&player[k].victim==&player[i]&&(!player[i].skeleton.free)){
8424 player[k].targetframe=0;
8426 //player[k].velocity=0;
8428 rotatetarget=player[i].coords-player[k].coords;
8429 Normalise(&rotatetarget);
8430 player[k].targetrotation=-asin(0-rotatetarget.x);
8431 player[k].targetrotation*=360/6.28;
8432 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8434 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8436 player[k].lastattack3=player[k].lastattack2;
8437 player[k].lastattack2=player[k].lastattack;
8438 player[k].lastattack=player[k].targetanimation;
8439 //player[k].targettilt2=0;
8443 if(player[k].targetanimation==knifefollowanim&&player[k].victim==&player[i]){
8444 rotatetarget=player[i].coords-player[k].coords;
8445 Normalise(&rotatetarget);
8446 player[k].targetrotation=-asin(0-rotatetarget.x);
8447 player[k].targetrotation*=360/6.28;
8448 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8449 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8451 player[k].victim=&player[i];
8452 player[k].hasvictim=1;
8453 player[i].targetanimation=knifefollowedanim;
8454 player[i].currentanimation=knifefollowedanim;
8455 player[i].targettilt2=0;
8456 player[i].targettilt2=player[k].targettilt2;
8457 player[i].targetframe=1;
8458 player[i].currentframe=0;
8460 player[i].velocity=0;
8461 player[k].currentanimation=knifefollowanim;
8462 player[k].targetanimation=knifefollowanim;
8463 player[k].targettilt2=player[i].targettilt2;
8464 player[k].currentframe=player[i].currentframe;
8465 player[k].targetframe=player[i].targetframe;
8466 player[k].target=player[i].target;
8467 player[k].velocity=0;
8468 player[k].oldcoords=player[k].coords;
8469 player[i].coords=player[k].coords;
8470 player[i].targetrotation=player[k].targetrotation;
8471 player[i].rotation=player[k].targetrotation;
8472 player[k].rotation=player[k].targetrotation;
8473 player[i].rotation=player[k].targetrotation;
8478 if(player[k].weaponactive!=-1){
8479 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==staff)hasstaff=1;
8482 for(i=0;i<numplayers;i++){
8484 if((playerrealattackkeydown||player[i].dead||!hasstaff)&&(k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack==neutral&&k==0){
8485 if(!player[i].dead||!realthreat||(player[k].weaponactive==-1&&player[k].crouchkeydown))
8486 if(player[i].skeleton.free)
8487 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)))){
8488 player[k].victim=&player[i];
8489 player[k].hasvictim=1;
8490 if(player[k].weaponactive!=-1&&tutoriallevel!=1){
8491 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;
8492 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;
8493 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;
8495 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){
8496 player[k].targetanimation=killanim;
8497 for(j=0;j<terrain.numdecals;j++){
8498 if((terrain.decaltype[j]==blooddecal||terrain.decaltype[j]==blooddecalslow)&&terrain.decalalivetime[j]<2){
8499 terrain.DeleteDecal(j);
8502 for(l=0;l<objects.numobjects;l++){
8503 if(objects.model[l].type==decalstype)
8504 for(j=0;j<objects.model[l].numdecals;j++){
8505 if((objects.model[l].decaltype[j]==blooddecal||objects.model[l].decaltype[j]==blooddecalslow)&&objects.model[l].decalalivetime[j]<2){
8506 objects.model[l].DeleteDecal(j);
8511 if(!player[i].dead||musictype!=2)
8512 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)){
8513 player[k].targetanimation=dropkickanim;
8514 for(j=0;j<terrain.numdecals;j++){
8515 if((terrain.decaltype[j]==blooddecal||terrain.decaltype[j]==blooddecalslow)&&terrain.decalalivetime[j]<2){
8516 terrain.DeleteDecal(j);
8519 for(l=0;l<objects.numobjects;l++){
8520 if(objects.model[l].type==decalstype)
8521 for(j=0;j<objects.model[l].numdecals;j++){
8522 if((objects.model[l].decaltype[j]==blooddecal||objects.model[l].decaltype[j]==blooddecalslow)&&objects.model[l].decalalivetime[j]<2){
8523 objects.model[l].DeleteDecal(j);
8529 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)){
8531 player[k].targetframe=0;
8533 //player[k].velocity=0;
8535 rotatetarget=player[i].coords-player[k].coords;
8536 if(player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim||player[k].targetanimation==staffgroundsmashanim){
8537 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;
8539 Normalise(&rotatetarget);
8540 player[k].targetrotation=-asin(0-rotatetarget.x);
8541 player[k].targetrotation*=360/6.28;
8542 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8544 if(player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim){
8545 player[k].targetrotation+=(float)(abs(Random()%100)-50)/4;
8548 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8549 if(player[k].targetanimation==staffgroundsmashanim)player[k].targettilt2+=10;
8551 player[k].lastattack3=player[k].lastattack2;
8552 player[k].lastattack2=player[k].lastattack;
8553 player[k].lastattack=player[k].targetanimation;
8555 if(player[k].targetanimation==swordgroundstabanim){
8556 player[k].targetrotation+=30;
8558 //player[k].targettilt2=0;
8564 if(!player[k].hasvictim){
8565 for(i=0;i<numplayers;i++){
8566 if((player[k].hasvictim==0)&&i!=k&&(i==0||k==0)&&!player[i].skeleton.free){
8567 player[k].victim=&player[i];
8568 player[k].hasvictim=1;
8570 if(player[k].hasvictim&&!player[i].skeleton.free)
8571 if(findDistancefast(&player[k].coords,&player[i].coords)<findDistancefast(&player[k].coords,&player[k].victim->coords)&&i!=k&&(i==0||k==0)){
8572 player[k].victim=&player[i];
8576 if(player[k].aitype==playercontrolled)
8577 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)){
8579 player[k].targetanimation=rabbitkickanim;
8580 player[k].targetframe=0;
8583 if(animation[player[k].targetanimation].attack&&k==0){
8586 if(player[k].weaponactive!=-1){
8587 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==staff)armedstaff=1;
8590 if(player[k].weaponactive!=-1){
8591 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==sword)armedsword=1;
8594 if(player[k].weaponactive!=-1){
8595 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==knife)armedknife=1;
8597 if(armedstaff)numstaffattack++;
8598 else if(armedsword)numswordattack++;
8599 else if(armedknife)numknifeattack++;
8600 else numunarmedattack++;
8607 static float collisionradius;
8609 for(k=0;k<numplayers;k++){
8610 for(i=k;i<numplayers;i++){
8613 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))
8614 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))
8615 if(player[i].howactive<=typesleeping&&player[k].howactive<=typesleeping)
8616 if(player[i].howactive!=typesittingwall&&player[k].howactive!=typesittingwall)
8617 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)
8618 if(player[i].coords.y>player[k].coords.y-3)
8619 if(player[i].coords.y<player[k].coords.y+3)
8620 if(player[i].coords.x>player[k].coords.x-3)
8621 if(player[i].coords.x<player[k].coords.x+3)
8622 if(player[i].coords.z>player[k].coords.z-3)
8623 if(player[i].coords.z<player[k].coords.z+3){
8624 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)){
8625 if(player[i].onfire||player[k].onfire){
8626 if(!player[i].onfire)player[i].CatchFire();
8627 if(!player[k].onfire)player[k].CatchFire();
8631 tempcoords1=player[i].coords;
8632 tempcoords2=player[k].coords;
8633 if(!player[i].skeleton.oldfree)tempcoords1.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[abdomen]].position.y*player[i].scale;
8634 if(!player[k].skeleton.oldfree)tempcoords2.y+=player[k].skeleton.joints[player[k].skeleton.jointlabels[abdomen]].position.y*player[k].scale;
8635 collisionradius=1.2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5);
8636 if(player[0].hasvictim)
8637 if(player[0].targetanimation==rabbitkickanim&&(k==0||i==0)&&!player[0].victim->skeleton.free)collisionradius=3;
8638 if((!player[i].skeleton.oldfree||!player[k].skeleton.oldfree)&&(findDistancefast(&tempcoords1,&tempcoords2)<collisionradius||findDistancefast(&player[i].coords,&player[k].coords)<collisionradius)){
8640 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)){
8641 player[k].coords.y=player[i].coords.y;
8642 player[i].velocity=player[k].velocity;
8643 player[i].skeleton.free=0;
8644 player[i].rotation=0;
8645 player[i].RagDoll(0);
8646 player[i].DoDamage(20);
8647 if(k==0)camerashake+=.3;
8648 player[i].skeleton.longdead=0;
8649 player[k].lastcollide=1;
8652 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)){
8653 player[i].coords.y=player[k].coords.y;
8654 player[k].velocity=player[i].velocity;
8655 player[k].skeleton.free=0;
8656 player[k].rotation=0;
8657 player[k].RagDoll(0);
8658 player[k].DoDamage(20);
8659 if(i==0)camerashake+=.3;
8660 player[k].skeleton.longdead=0;
8661 player[i].lastcollide=1;
8664 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)){
8665 rotatetarget=player[k].velocity-player[i].velocity;
8666 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))
8667 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))){
8669 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)){
8670 static float gLoc[3];
8671 static float vel[3];
8672 gLoc[0]=player[i].coords.x;
8673 gLoc[1]=player[i].coords.y;
8674 gLoc[2]=player[i].coords.z;
8675 vel[0]=player[i].velocity.x;
8676 vel[1]=player[i].velocity.y;
8677 vel[2]=player[i].velocity.z;
8678 if(tutoriallevel!=1){
8679 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, TRUE);
8680 FSOUND_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
8681 FSOUND_SetVolume(channels[heavyimpactsound], 256);
8682 FSOUND_SetPaused(channels[heavyimpactsound], FALSE);
8684 //player[i].velocity=player[k].velocity;
8685 //player[k].velocity=player[i].velocity;
8687 player[i].RagDoll(0);
8688 if(player[i].damage>player[i].damagetolerance-findLengthfast(&rotatetarget)/4&&!player[i].dead){
8693 player[i].DoDamage(findLengthfast(&rotatetarget)/4);
8694 player[k].RagDoll(0);
8695 if(player[k].damage>player[k].damagetolerance-findLengthfast(&rotatetarget)/4&&!player[k].dead){
8700 player[k].DoDamage(findLengthfast(&rotatetarget)/4);
8702 //if(player[i].skeleton.oldfree){
8703 for(j=0;j<player[i].skeleton.num_joints;j++){
8704 player[i].skeleton.joints[j].velocity=player[i].skeleton.joints[j].velocity/5+player[k].velocity;
8707 //if(player[k].skeleton.oldfree){
8708 for(j=0;j<player[k].skeleton.num_joints;j++){
8709 player[k].skeleton.joints[j].velocity=player[k].skeleton.joints[j].velocity/5+player[i].velocity;
8715 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)){
8717 if(player[i].skeleton.oldfree==0&&player[k].skeleton.oldfree==0){
8718 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)){
8719 rotatetarget=player[k].coords-player[i].coords;
8720 Normalise(&rotatetarget);
8721 player[k].coords=(player[k].coords+player[i].coords)/2;
8722 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);
8723 player[k].coords+=rotatetarget*fast_sqrt(.6)/2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5);
8724 if(player[k].howactive==typeactive||hostile)
8725 if(player[k].isIdle()){
8726 if(player[k].howactive<typesleeping){
8727 player[k].targetanimation=player[k].getStop();
8728 player[k].targetframe=0;
8731 else if(player[k].howactive==typesleeping)
8733 player[k].targetanimation=getupfromfrontanim;
8734 player[k].targetframe=0;
8737 if(!editorenabled)player[k].howactive=typeactive;
8739 if(player[i].howactive==typeactive||hostile)
8740 if(player[i].isIdle()){
8741 if(player[i].howactive<typesleeping){
8742 player[i].targetanimation=player[i].getStop();
8743 player[i].targetframe=0;
8748 player[i].targetanimation=getupfromfrontanim;
8749 player[i].targetframe=0;
8752 if(!editorenabled)player[i].howactive=typeactive;
8756 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){
8757 player[i].velocity=player[k].velocity;
8758 player[k].velocity=player[k].velocity*-.5;
8759 //player[i].velocity.y-=10;
8760 player[k].velocity.y=player[i].velocity.y;
8761 player[i].DoDamage(20);
8762 player[i].RagDoll(0);
8763 player[k].lastcollide=1;
8770 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){
8771 player[k].velocity=player[i].velocity;
8772 player[i].velocity=player[i].velocity*-.3;
8773 //player[k].velocity.y-=10;
8774 player[i].velocity.y=player[k].velocity.y;
8775 player[k].DoDamage(20);
8776 player[k].RagDoll(0);
8777 player[i].lastcollide=1;
8788 player[i].CheckKick();
8789 player[k].CheckKick();
8795 for(k=0;k<numplayers;k++){
8796 for(i=k;i<numplayers;i++){
8798 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))){
8799 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)){
8800 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)){
8801 player[i].victim=&player[k];
8802 player[i].targetanimation=jumpreversedanim;
8803 player[i].currentanimation=jumpreversedanim;
8804 player[k].currentanimation=jumpreversalanim;
8805 player[k].targetanimation=jumpreversalanim;
8806 player[i].targettilt2=0;
8807 player[i].currentframe=0;
8808 player[i].targetframe=1;
8809 player[k].currentframe=0;
8810 player[k].targetframe=1;
8811 if(player[i].coords.y<player[k].coords.y+1){
8812 player[i].targetanimation=rabbitkickreversedanim;
8813 player[i].currentanimation=rabbitkickreversedanim;
8814 player[k].currentanimation=rabbitkickreversalanim;
8815 player[k].targetanimation=rabbitkickreversalanim;
8816 player[k].currentframe=1;
8817 player[k].targetframe=2;
8818 player[i].currentframe=1;
8819 player[i].targetframe=2;
8821 player[k].targettilt2=0;
8823 player[i].velocity=0;
8824 player[k].velocity=0;
8825 player[k].oldcoords=player[k].coords;
8826 player[i].coords=player[k].coords;
8827 player[k].targetrotation=player[i].targetrotation;
8828 player[k].rotation=player[i].targetrotation;
8829 player[k].victim=&player[i];
8830 if(player[k].aitype==attacktypecutoff)player[k].stunned=.5;
8832 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)){
8833 player[k].victim=&player[i];
8834 player[k].targetanimation=jumpreversedanim;
8835 player[k].currentanimation=jumpreversedanim;
8836 player[i].currentanimation=jumpreversalanim;
8837 player[i].targetanimation=jumpreversalanim;
8838 player[k].targettilt2=0;
8839 player[i].targettilt2=0;
8840 player[k].currentframe=0;
8841 player[k].targetframe=1;
8842 player[i].currentframe=0;
8843 player[i].targetframe=1;
8844 if(player[k].coords.y<player[i].coords.y+1){
8845 player[k].targetanimation=rabbitkickreversedanim;
8846 player[k].currentanimation=rabbitkickreversedanim;
8847 player[i].currentanimation=rabbitkickreversalanim;
8848 player[i].targetanimation=rabbitkickreversalanim;
8849 player[k].currentframe=1;
8850 player[k].targetframe=2;
8851 player[i].currentframe=1;
8852 player[i].targetframe=2;
8855 player[k].velocity=0;
8856 player[i].velocity=0;
8857 player[i].oldcoords=player[i].coords;
8858 player[k].coords=player[i].coords;
8859 player[i].targetrotation=player[k].targetrotation;
8860 player[i].rotation=player[k].targetrotation;
8861 player[i].victim=&player[k];
8862 if(player[i].aitype==attacktypecutoff)player[i].stunned=.5;
8869 for(k=0;k<numplayers;k++)
8870 if(player[k].immobile&&k!=0)player[k].coords=player[k].realoldcoords;
8879 static float checkdelay;
8880 checkdelay-=multiplier;
8882 static bool checkedcoll[maxplayers][maxplayers];
8883 static bool above[maxplayers];
8885 for(i=0;i<maxplayers;i++){
8886 for(j=0;j<maxplayers;j++){
8887 checkedcoll[i][j]=0;
8891 if(numplayers>1&&checkdelay<=0){
8893 for(k=0;k<numplayers;k++){
8894 if(player[k].skeleton.free!=2)above[k]=-1;
8896 for(i=k;i<numplayers;i++){
8899 if(!checkedcoll[i][k]){
8900 checkedcoll[i][k]=1;
8901 checkedcoll[k][i]=1;
8902 if(player[i].skeleton.free&&player[k].skeleton.free)
8903 if(player[i].skeleton.free!=2||player[k].skeleton.free!=2)
8904 if(i!=k&&player[i].whichpatchx==player[k].whichpatchx&&player[i].whichpatchz==player[k].whichpatchz)
8905 if(player[i].coords.y>player[k].coords.y-3)
8906 if(player[i].coords.y<player[k].coords.y+3)
8907 if(player[i].coords.x>player[k].coords.x-3)
8908 if(player[i].coords.x<player[k].coords.x+3)
8909 if(player[i].coords.z>player[k].coords.z-3)
8910 if(player[i].coords.z<player[k].coords.z+3)
8911 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)){
8913 if((player[i].skeleton.longdead>player[k].skeleton.longdead&&player[k].skeleton.free!=2)||player[i].skeleton.free==2){
8925 above[moving]=stuck;
8926 for(l=0;l<player[moving].skeleton.num_joints;l++){
8927 for(m=0;m<player[stuck].skeleton.num_joints;m++){
8928 while(findDistancefast(player[moving].skeleton.joints[l].position+player[moving].coords,player[stuck].skeleton.joints[m].position+player[stuck].coords)<.25)
8930 player[moving].skeleton.joints[l].position.y+=.003;
8931 if(player[moving].skeleton.joints[l].velocity.y<-.05)player[moving].skeleton.joints[l].velocity.y+=.003/.015/2;
8945 if(!IsKeyDown(theKeyMap, MAC_N_KEY)){
8946 texturesizetogglekeydown=0;
8949 for(k=0;k<numplayers;k++){
8950 if(!isnormal(player[k].coords.x)||!isnormal(player[k].coords.y)||!isnormal(player[k].coords.z)){
8951 if(!isnormal(player[k].coords.x)||!isnormal(player[k].coords.y)||!isnormal(player[k].coords.z)){
8952 player[k].DoDamage(1000);
8957 static bool respawnkeydown;
8958 if(!editorenabled&&(whichlevel!=-2&&(IsKeyDown(theKeyMap, MAC_Z_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)&&debugmode&&!editorenabled)||(IsKeyDown(theKeyMap, jumpkey)&&!respawnkeydown&&!oldattackkey&&player[0].dead))){
8959 targetlevel=whichlevel;
8963 if(!IsKeyDown(theKeyMap, jumpkey))respawnkeydown=0;
8964 if(IsKeyDown(theKeyMap, jumpkey))respawnkeydown=1;
8969 if(whichlevel!=-2&&IsKeyDown(theKeyMap, MAC_K_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!slomotogglekeydown&&debugmode&&!editorenabled){
8971 if(targetlevel>numchallengelevels-1)targetlevel=0;
8974 slomotogglekeydown=1;
8978 if(IsKeyDown(theKeyMap, MAC_Z_KEY)){
8980 FSOUND_SetPaused(channels[whooshsound], TRUE);
8982 for(k=0;k<numplayers;k++){
8985 player[k].permanentdamage=0;
8986 if(player[k].skeleton.free==2)player[k].skeleton.free=1;
8987 player[k].aitype=passivetype;
8989 player[0].aitype=playercontrolled;
8993 static bool movekey;
8994 static bool connected;
8995 /*player[0].forwardkeydown=IsKeyDown(theKeyMap, MAC_W_KEY);
8996 player[0].leftkeydown=IsKeyDown(theKeyMap, MAC_A_KEY);
8997 player[0].backkeydown=IsKeyDown(theKeyMap, MAC_S_KEY);
8998 player[0].rightkeydown=IsKeyDown(theKeyMap, MAC_D_KEY);
8999 player[0].jumpkeydown=IsKeyDown(theKeyMap, MAC_SPACE_KEY);
9000 player[0].crouchkeydown=IsKeyDown(theKeyMap, MAC_SHIFT_KEY);*/
9002 //if(!player[0].crouchkeydown)player[0].crouchkeydown=IsKeyDown(theKeyMap, MAC_CONTROL_KEY);
9004 for(int i=0;i<numplayers;i++){
9005 if(!player[i].skeleton.free){
9006 oldtargetrotation=player[i].targetrotation;
9007 if(i==0&&indialogue==-1){
9008 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){
9009 if(!cameramode)player[0].targetrotation=-rotation+180;
9010 if(cameramode)player[0].targetrotation=0;
9016 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
9017 if(cameramode){facing=flatfacing;}
9019 facing=DoRotation(facing,-rotation2,0,0);
9020 facing=DoRotation(facing,0,0-rotation,0);
9023 player[0].lookrotation=-rotation;
9025 player[i].targetheadrotation=rotation;
9026 player[i].targetheadrotation2=rotation2;
9028 if(i!=0&&player[i].aitype==playercontrolled&&indialogue==-1){
9029 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){
9030 player[i].targetrotation=-player[i].lookrotation+180;
9036 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
9038 facing=DoRotation(facing,-player[i].lookrotation2,0,0);
9039 facing=DoRotation(facing,0,0-player[i].lookrotation,0);
9041 player[i].targetheadrotation=player[i].lookrotation;
9042 player[i].targetheadrotation2=player[i].lookrotation2;
9045 rotatetarget=participantfacing[whichdialogue][indialogue][i];
9046 Normalise(&rotatetarget);
9047 player[i].targetheadrotation=-asin(0-rotatetarget.x);
9048 player[i].targetheadrotation*=360/6.28;
9049 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
9051 player[i].targetheadrotation*=-1;
9052 player[i].targetheadrotation+=180;
9053 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
9061 player[i].avoidsomething=0;
9063 for(j=0;j<objects.numobjects;j++){
9064 if(objects.onfire[j]){
9065 if(findDistancefast(&objects.position[j],&player[i].coords)<objects.scale[j]*objects.scale[j]*200)
9067 if(findDistancefast(&player[i].coords,&objects.position[j])<findDistancefast(&player[i].coords,&player[0].coords)){
9068 player[i].collided=0;
9069 player[i].avoidcollided=1;
9070 if(player[i].avoidsomething==0||findDistancefast(&objects.position[j],&player[i].coords)<findDistancefast(&player[i].coords,&player[i].avoidwhere))
9071 player[i].avoidwhere=objects.position[j];
9077 //Add avoidwhere to players
9079 for(j=0;j<numplayers;j++){
9080 if(player[j].onfire){
9081 if(findDistancefast(&player[j].coords,&player[i].coords)<0.3*0.3*200)
9083 if(findDistancefast(&player[i].coords,&player[j].coords)<findDistancefast(&player[i].coords,&player[0].coords)){
9084 player[i].collided=0;
9085 player[i].avoidcollided=1;
9086 if(player[i].avoidsomething==0||findDistancefast(&player[j].coords,&player[i].coords)<findDistancefast(&player[i].coords,&player[i].avoidwhere))
9087 player[i].avoidwhere=objects.position[j];
9093 if(player[i].collided>.8)player[i].avoidcollided=0;
9094 if(player[i].aitype!=playercontrolled&&indialogue==-1){
9095 player[i].jumpclimb=0;
9097 if(editorenabled)player[i].stunned=1;
9100 //if(findDistancefastflat(&player[i].coords,&player[0].coords)<3/*&&player[0].coords.y>player[i].coords.y+.1*/)player[i].pause=1;
9101 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;
9103 /*if(player[i].aitype==passivetype&&player[i].numwaypoints<=1){
9104 player[i].forwardkeydown=0;
9105 player[i].leftkeydown=0;
9106 player[i].backkeydown=0;
9107 player[i].rightkeydown=0;
9108 player[i].crouchkeydown=0;
9109 player[i].attackkeydown=0;
9110 player[i].jumpkeydown=0;
9111 player[i].throwkeydown=0;
9114 if(player[i].aitype==pathfindtype){
9115 if(player[i].finalpathfindpoint==-1){
9116 float closestdistance;
9122 for(j=0;j<numpathpoints;j++){
9123 if(closest==-1||findDistancefast(&player[i].finalfinaltarget,&pathpoint[j])<closestdistance){
9124 closestdistance=findDistancefast(&player[i].finalfinaltarget,&pathpoint[j]);
9126 player[i].finaltarget=pathpoint[j];
9129 player[i].finalpathfindpoint=closest;
9130 for(j=0;j<numpathpoints;j++){
9131 if(numpathpointconnect[j])
9132 for(k=0;k<numpathpointconnect[j];k++){
9133 DistancePointLine(&player[i].finalfinaltarget, &pathpoint[j], &pathpoint[pathpointconnect[j][k]], &tempdist,&colpoint );
9134 if(tempdist*tempdist<closestdistance){
9135 if(findDistance(&colpoint,&pathpoint[j])+findDistance(&colpoint,&pathpoint[pathpointconnect[j][k]])<findDistance(&pathpoint[j],&pathpoint[pathpointconnect[j][k]])+.1){
9136 closestdistance=tempdist*tempdist;
9138 player[i].finaltarget=colpoint;
9143 player[i].finalpathfindpoint=closest;
9146 if(player[i].targetpathfindpoint==-1){
9147 float closestdistance;
9153 if(player[i].lastpathfindpoint==-1){
9154 for(j=0;j<numpathpoints;j++){
9155 if(j!=player[i].lastpathfindpoint)
9156 if(closest==-1||(findDistancefast(&player[i].coords,&pathpoint[j])<closestdistance/*&&findDistancefast(&player[i].finaltarget,&pathpoint[j])<findDistancefast(&player[i].finaltarget,&player[i].coords)*/)){
9157 closestdistance=findDistancefast(&player[i].coords,&pathpoint[j]);
9161 player[i].targetpathfindpoint=closest;
9162 for(j=0;j<numpathpoints;j++){
9163 if(j!=player[i].lastpathfindpoint)
9164 if(numpathpointconnect[j])
9165 for(k=0;k<numpathpointconnect[j];k++){
9166 DistancePointLine(&player[i].coords, &pathpoint[j], &pathpoint[pathpointconnect[j][k]], &tempdist,&colpoint );
9167 if(tempdist*tempdist<closestdistance){
9168 if(findDistance(&colpoint,&pathpoint[j])+findDistance(&colpoint,&pathpoint[pathpointconnect[j][k]])<findDistance(&pathpoint[j],&pathpoint[pathpointconnect[j][k]])+.1){
9169 //if(findDistancefast(&player[i].finaltarget,&colpoint)<findDistancefast(&player[i].finaltarget,&player[i].coords)){
9170 closestdistance=tempdist*tempdist;
9177 player[i].targetpathfindpoint=closest;
9181 for(j=0;j<numpathpoints;j++){
9182 if(j!=player[i].lastpathfindpoint&&j!=player[i].lastpathfindpoint2&&j!=player[i].lastpathfindpoint3&&j!=player[i].lastpathfindpoint4)
9185 if(numpathpointconnect[j])
9186 for(k=0;k<numpathpointconnect[j];k++){
9187 if(pathpointconnect[j][k]==player[i].lastpathfindpoint)connected=1;
9190 if(numpathpointconnect[player[i].lastpathfindpoint])
9191 for(k=0;k<numpathpointconnect[player[i].lastpathfindpoint];k++){
9192 if(pathpointconnect[player[i].lastpathfindpoint][k]==j)connected=1;
9195 tempdist=findPathDist(j,player[i].finalpathfindpoint);
9196 if(closest==-1||tempdist<closestdistance){
9197 closestdistance=tempdist;
9203 player[i].targetpathfindpoint=closest;
9206 player[i].losupdatedelay-=multiplier;
9208 rotatetarget=pathpoint[player[i].targetpathfindpoint]-player[i].coords;
9209 Normalise(&rotatetarget);
9210 player[i].targetrotation=-asin(0-rotatetarget.x);
9211 player[i].targetrotation*=360/6.28;
9212 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9213 player[i].lookrotation=player[i].targetrotation;
9214 //player[i].aiupdatedelay=.05;
9216 if(findDistancefastflat(&player[i].coords,&pathpoint[player[i].targetpathfindpoint])<.6){
9217 player[i].lastpathfindpoint4=player[i].lastpathfindpoint3;
9218 player[i].lastpathfindpoint3=player[i].lastpathfindpoint2;
9219 player[i].lastpathfindpoint2=player[i].lastpathfindpoint;
9220 player[i].lastpathfindpoint=player[i].targetpathfindpoint;
9221 if(player[i].lastpathfindpoint2==-1)player[i].lastpathfindpoint2=player[i].lastpathfindpoint;
9222 if(player[i].lastpathfindpoint3==-1)player[i].lastpathfindpoint3=player[i].lastpathfindpoint2;
9223 if(player[i].lastpathfindpoint4==-1)player[i].lastpathfindpoint4=player[i].lastpathfindpoint3;
9224 player[i].targetpathfindpoint=-1;
9226 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){
9227 player[i].aitype=passivetype;
9230 player[i].forwardkeydown=1;
9231 player[i].leftkeydown=0;
9232 player[i].backkeydown=0;
9233 player[i].rightkeydown=0;
9234 player[i].crouchkeydown=0;
9235 player[i].attackkeydown=0;
9236 player[i].throwkeydown=0;
9238 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9240 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9241 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9243 if((tutoriallevel!=1||cananger)&&hostile&&!player[0].dead&&findDistancefast(&player[i].coords,&player[0].coords)<400&&player[i].occluded<25){
9244 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))
9245 player[i].aitype=attacktypecutoff;
9246 if(findDistancefast(&player[i].coords,&player[0].coords)<30&&animation[player[0].targetanimation].height==highheight&&!editorenabled)
9247 player[i].aitype=attacktypecutoff;
9249 if(player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2){
9250 player[i].losupdatedelay=.2;
9251 for(j=0;j<numplayers;j++){
9252 if(j==0||player[j].skeleton.free||player[j].aitype!=passivetype){
9253 if(abs(Random()%2)||animation[player[j].targetanimation].height!=lowheight||j!=0)
9254 if(findDistancefast(&player[i].coords,&player[j].coords)<400)
9255 if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0)
9256 if(player[j].coords.y<player[i].coords.y+5||player[j].onterrain)
9257 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)){
9258 player[i].aitype=searchtype;
9259 player[i].lastchecktime=12;
9260 player[i].lastseen=player[j].coords;
9261 player[i].lastseentime=12;
9267 if(player[i].aitype==attacktypecutoff&&musictype!=2){
9268 if(player[i].creature!=wolftype){
9269 player[i].stunned=.6;
9270 player[i].surprised=.6;
9275 if(player[i].aitype!=passivetype&&leveltime>.5){
9276 player[i].howactive=typeactive;
9279 if(player[i].aitype==passivetype){
9280 player[i].aiupdatedelay-=multiplier;
9281 player[i].losupdatedelay-=multiplier;
9282 player[i].lastseentime+=multiplier;
9283 player[i].pausetime-=multiplier;
9284 if(player[i].lastseentime>1)player[i].lastseentime=1;
9286 if(player[i].aiupdatedelay<0){
9287 if(player[i].numwaypoints>1&&player[i].howactive==typeactive&&player[i].pausetime<=0){
9288 rotatetarget=player[i].waypoints[player[i].waypoint]-player[i].coords;
9289 Normalise(&rotatetarget);
9290 player[i].targetrotation=-asin(0-rotatetarget.x);
9291 player[i].targetrotation*=360/6.28;
9292 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9293 player[i].lookrotation=player[i].targetrotation;
9294 player[i].aiupdatedelay=.05;
9296 if(findDistancefastflat(&player[i].coords,&player[i].waypoints[player[i].waypoint])<1){
9297 if(player[i].waypointtype[player[i].waypoint]==wppause)player[i].pausetime=4;
9298 player[i].waypoint++;
9299 if(player[i].waypoint>player[i].numwaypoints-1)player[i].waypoint=0;
9304 if(player[i].numwaypoints>1&&player[i].howactive==typeactive&&player[i].pausetime<=0)player[i].forwardkeydown=1;
9305 else player[i].forwardkeydown=0;
9306 player[i].leftkeydown=0;
9307 player[i].backkeydown=0;
9308 player[i].rightkeydown=0;
9309 player[i].crouchkeydown=0;
9310 player[i].attackkeydown=0;
9311 player[i].throwkeydown=0;
9313 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9314 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9316 XYZ leftpos,rightpos;
9317 float leftdist,rightdist;
9318 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9319 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9320 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9321 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9322 if(leftdist<rightdist)player[i].targetrotation+=90;
9323 else player[i].targetrotation-=90;
9327 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9328 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9332 if(player[i].howactive<typesleeping)
9333 if(numenvsounds>0&&(tutoriallevel!=1||cananger)&&hostile)
9334 for(j=0;j<numenvsounds;j++){
9335 if(findDistancefast(&player[i].coords,&envsound[j])<2*(envsoundvol[j]+envsoundvol[j]*(player[i].creature==rabbittype)*3)){
9336 player[i].aitype=attacktypecutoff;
9340 if(player[i].howactive==typesleeping)
9341 if(numenvsounds>0&&(tutoriallevel!=1||cananger)&&hostile)
9342 for(j=0;j<numenvsounds;j++){
9343 if(envsoundvol[j]>14)
9344 if(findDistancefast(&player[i].coords,&envsound[j])<2*((envsoundvol[j]-14)+(envsoundvol[j]-14)*(player[i].creature==rabbittype)*3)){
9345 player[i].aitype=attacktypecutoff;
9349 if(player[i].aitype!=passivetype){
9350 if(player[i].howactive==typesleeping){
9351 player[i].targetanimation=getupfromfrontanim;
9352 player[i].targetframe=0;
9356 player[i].howactive=typeactive;
9360 if(player[i].howactive<typesleeping&&((tutoriallevel!=1||cananger)&&hostile)&&!player[0].dead&&findDistancefast(&player[i].coords,&player[0].coords)<400&&player[i].occluded<25){
9361 if(findDistancefast(&player[i].coords,&player[0].coords)<12&&animation[player[0].targetanimation].height!=lowheight&&!editorenabled)
9362 player[i].aitype=attacktypecutoff;
9363 if(findDistancefast(&player[i].coords,&player[0].coords)<30&&animation[player[0].targetanimation].height==highheight&&!editorenabled)
9364 player[i].aitype=attacktypecutoff;
9366 if(player[i].creature==wolftype){
9368 float smelldistance;
9370 for(j=0;j<numplayers;j++){
9371 if(j==0||(player[j].dead&&player[j].bloodloss>0)){
9372 if(j==0&&player[j].num_weapons>0){
9373 if(weapons.bloody[player[j].weaponids[0]])smelldistance=100;
9374 if(player[j].num_weapons==2)
9375 if(weapons.bloody[player[j].weaponids[1]])smelldistance=100;
9380 windsmell=windvector;
9381 Normalise(&windsmell);
9382 windsmell=windsmell*2+player[j].coords;
9383 if(findDistancefast(&player[i].coords,&windsmell)<smelldistance&&!editorenabled)
9384 player[i].aitype=attacktypecutoff;
9389 if(player[i].howactive<typesleeping&&player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2){
9390 player[i].losupdatedelay=.2;
9391 for(j=0;j<numplayers;j++){
9392 if(j==0||player[j].skeleton.free||player[j].aitype!=passivetype){
9393 if(abs(Random()%2)||animation[player[j].targetanimation].height!=lowheight||j!=0)
9394 if(findDistancefast(&player[i].coords,&player[j].coords)<400)
9395 if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0)
9396 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)){
9397 player[i].lastseentime-=.2;
9398 if(j==0&&animation[player[j].targetanimation].height==lowheight)player[i].lastseentime-=.4;
9399 else player[i].lastseentime-=.6;
9401 if(player[i].lastseentime<=0){
9402 player[i].aitype=searchtype;
9403 player[i].lastchecktime=12;
9404 player[i].lastseen=player[j].coords;
9405 player[i].lastseentime=12;
9411 if(player[i].aitype==attacktypecutoff&&musictype!=2){
9412 if(player[i].creature!=wolftype){
9413 player[i].stunned=.6;
9414 player[i].surprised=.6;
9416 if(player[i].creature==wolftype){
9417 player[i].stunned=.47;
9418 player[i].surprised=.47;
9424 if(player[i].aitype==searchtype){
9425 player[i].aiupdatedelay-=multiplier;
9426 player[i].losupdatedelay-=multiplier;
9427 if(!player[i].pause)player[i].lastseentime-=multiplier;
9428 player[i].lastchecktime-=multiplier;
9430 if(player[i].isRun()&&!player[i].onground){
9431 if(player[i].coords.y>terrain.getHeight(player[i].coords.x,player[i].coords.z)+10){
9432 test2=player[i].coords+player[i].facing;
9434 test=player[i].coords+player[i].facing;
9436 j=checkcollide(test2,test,player[i].laststanding);
9437 if(j==-1)j=checkcollide(test2,test);
9439 player[i].velocity=0;
9440 player[i].targetanimation=player[i].getStop();
9441 player[i].targetframe=0;
9443 player[i].targetrotation+=180;
9444 player[i].stunned=.5;
9445 //player[i].aitype=passivetype;
9446 player[i].aitype=pathfindtype;
9447 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9448 player[i].finalpathfindpoint=-1;
9449 player[i].targetpathfindpoint=-1;
9450 player[i].lastpathfindpoint=-1;
9451 player[i].lastpathfindpoint2=-1;
9452 player[i].lastpathfindpoint3=-1;
9453 player[i].lastpathfindpoint4=-1;
9455 else player[i].laststanding=j;
9458 if(player[i].aiupdatedelay<0){
9459 rotatetarget=player[i].lastseen-player[i].coords;
9460 Normalise(&rotatetarget);
9461 player[i].targetrotation=-asin(0-rotatetarget.x);
9462 player[i].targetrotation*=360/6.28;
9463 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9464 player[i].lookrotation=player[i].targetrotation;
9465 player[i].aiupdatedelay=.05;
9466 player[i].forwardkeydown=1;
9468 if(findDistancefastflat(&player[i].coords,&player[i].lastseen)<1*(player[i].scale*5)*(player[i].scale*5)||player[i].lastchecktime<0){
9469 player[i].forwardkeydown=0;
9470 player[i].aiupdatedelay=1;
9471 player[i].lastseen.x+=(float(Random()%100)-50)/25;
9472 player[i].lastseen.z+=(float(Random()%100)-50)/25;
9473 player[i].lastchecktime=3;
9476 player[i].leftkeydown=0;
9477 player[i].backkeydown=0;
9478 player[i].rightkeydown=0;
9479 player[i].crouchkeydown=0;
9480 player[i].attackkeydown=0;
9481 player[i].throwkeydown=0;
9483 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9484 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9486 XYZ leftpos,rightpos;
9487 float leftdist,rightdist;
9488 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9489 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9490 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9491 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9492 if(leftdist<rightdist)player[i].targetrotation+=90;
9493 else player[i].targetrotation-=90;
9497 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9498 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9500 if(numenvsounds>0&&((tutoriallevel!=1||cananger)&&hostile))
9501 for(j=0;j<numenvsounds;j++){
9502 if(findDistancefast(&player[i].coords,&envsound[j])<2*(envsoundvol[j]+envsoundvol[j]*(player[i].creature==rabbittype)*3)){
9503 player[i].aitype=attacktypecutoff;
9507 if(!player[0].dead&&player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2&&((tutoriallevel!=1||cananger)&&hostile)){
9508 player[i].losupdatedelay=.2;
9509 if(findDistancefast(&player[i].coords,&player[0].coords)<4&&animation[player[i].targetanimation].height!=lowheight)
9510 {player[i].aitype=attacktypecutoff;
9511 player[i].lastseentime=1;}
9512 if(abs(Random()%2)||animation[player[i].targetanimation].height!=lowheight)
9513 if(findDistancefast(&player[i].coords,&player[0].coords)<400)
9514 if(normaldotproduct(player[i].facing,player[0].coords-player[i].coords)>0)
9515 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)){
9516 player[i].aitype=attacktypecutoff;
9517 player[i].lastseentime=1;
9520 if(player[i].lastseentime<0){
9521 //player[i].aitype=passivetype;
9523 player[i].aitype=pathfindtype;
9524 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9525 player[i].finalpathfindpoint=-1;
9526 player[i].targetpathfindpoint=-1;
9527 player[i].lastpathfindpoint=-1;
9528 player[i].lastpathfindpoint2=-1;
9529 player[i].lastpathfindpoint3=-1;
9530 player[i].lastpathfindpoint4=-1;
9534 if(player[i].aitype!=gethelptype){
9535 player[i].runninghowlong=0;
9538 if(player[i].aitype==gethelptype){
9539 player[i].runninghowlong+=multiplier;
9540 player[i].aiupdatedelay-=multiplier;
9542 if(player[i].aiupdatedelay<0||player[i].ally==0){
9543 player[i].aiupdatedelay=.2;
9551 if(!player[i].ally){
9552 for(j=0;j<numplayers;j++){
9553 if(j!=i&&j!=0&&!player[j].dead&&player[j].howactive<typedead1&&!player[j].skeleton.free&&player[j].aitype==passivetype){
9554 distance=findDistancefast(&player[i].coords,&player[j].coords);
9555 if(closestdist==-1||distance<closestdist){
9556 closestdist=distance;
9562 if(closest!=-1)player[i].ally=closest;
9563 else player[i].ally=0;
9564 player[i].lastseen=player[0].coords;
9565 player[i].lastseentime=12;
9569 player[i].lastchecktime=12;
9570 //player[i].lastseentime-=.5;
9572 facing=player[i].coords;
9573 flatfacing=player[player[i].ally].coords;
9574 facing.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position.y*player[i].scale;
9575 flatfacing.y+=player[player[i].ally].skeleton.joints[player[player[i].ally].skeleton.jointlabels[head]].position.y*player[player[i].ally].scale;
9576 if(-1!=checkcollide(facing,flatfacing))
9577 player[i].lastseentime-=.1;
9579 if(player[i].ally<=0||player[player[i].ally].skeleton.free||player[player[i].ally].aitype!=passivetype||player[i].lastseentime<=0){
9580 player[i].aitype=searchtype;
9581 player[i].lastseentime=12;
9584 if(player[i].ally>0){
9585 rotatetarget=player[player[i].ally].coords-player[i].coords;
9586 Normalise(&rotatetarget);
9587 player[i].targetrotation=-asin(0-rotatetarget.x);
9588 player[i].targetrotation*=360/6.28;
9589 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9590 player[i].lookrotation=player[i].targetrotation;
9591 player[i].aiupdatedelay=.05;
9592 player[i].forwardkeydown=1;
9594 if(findDistancefastflat(&player[i].coords,&player[player[i].ally].coords)<3){
9595 player[i].aitype=searchtype;
9596 player[i].lastseentime=12;
9597 player[player[i].ally].aitype=searchtype;
9598 if(player[player[i].ally].lastseentime<player[i].lastseentime){
9599 player[player[i].ally].lastseen=player[i].lastseen;
9600 player[player[i].ally].lastseentime=player[i].lastseentime;
9601 player[player[i].ally].lastchecktime=player[i].lastchecktime;
9605 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9606 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9608 XYZ leftpos,rightpos;
9609 float leftdist,rightdist;
9610 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9611 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9612 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9613 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9614 if(leftdist<rightdist)player[i].targetrotation+=90;
9615 else player[i].targetrotation-=90;
9620 player[i].leftkeydown=0;
9621 player[i].backkeydown=0;
9622 player[i].rightkeydown=0;
9623 player[i].crouchkeydown=0;
9624 player[i].attackkeydown=0;
9626 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9627 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9630 if(player[i].aitype==getweapontype){
9631 player[i].aiupdatedelay-=multiplier;
9632 player[i].lastchecktime-=multiplier;
9634 if(player[i].aiupdatedelay<0){
9635 player[i].aiupdatedelay=.2;
9643 if(player[i].ally<0){
9644 for(j=0;j<weapons.numweapons;j++){
9645 if(weapons.owner[j]==-1){
9646 distance=findDistancefast(&player[i].coords,&weapons.position[j]);
9647 if(closestdist==-1||distance<closestdist){
9648 closestdist=distance;
9654 if(closest!=-1)player[i].ally=closest;
9655 else player[i].ally=-1;
9658 player[i].lastseentime=12;
9660 if(!player[0].dead&&((tutoriallevel!=1||cananger)&&hostile))
9661 if(player[i].ally<0||player[i].weaponactive!=-1||player[i].lastchecktime<=0){
9662 player[i].aitype=attacktypecutoff;
9663 player[i].lastseentime=1;
9666 if(player[i].ally>=0){
9667 if(weapons.owner[player[i].ally]!=-1||findDistancefast(&player[i].coords,&weapons.position[player[i].ally])>16){
9668 player[i].aitype=attacktypecutoff;
9669 player[i].lastseentime=1;
9671 rotatetarget=weapons.position[player[i].ally]-player[i].coords;
9672 Normalise(&rotatetarget);
9673 player[i].targetrotation=-asin(0-rotatetarget.x);
9674 player[i].targetrotation*=360/6.28;
9675 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9676 player[i].lookrotation=player[i].targetrotation;
9677 player[i].aiupdatedelay=.05;
9678 player[i].forwardkeydown=1;
9681 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9682 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9684 XYZ leftpos,rightpos;
9685 float leftdist,rightdist;
9686 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9687 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9688 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9689 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9690 if(leftdist<rightdist)player[i].targetrotation+=90;
9691 else player[i].targetrotation-=90;
9694 /*if(findDistancefast(&player[i].coords,&weapons.position[player[i].ally])<3){
9695 if(abs(Random()%6)){
9696 player[i].crouchkeydown=1;
9697 if(!findDistancefast(&player[i].coords,&weapons.position[player[i].ally])<1){
9698 if(player[i].isRun()){
9699 player[i].targetframe=0;
9701 player[i].targetanimation=sneakanim;
9704 else player[i].forwardkeydown=0;
9706 else player[i].crouchkeydown=0;
9708 else player[i].crouchkeydown=0;*/
9711 player[i].leftkeydown=0;
9712 player[i].backkeydown=0;
9713 player[i].rightkeydown=0;
9714 player[i].attackkeydown=0;
9715 player[i].throwkeydown=1;
9716 player[i].crouchkeydown=0;
9717 if(player[i].targetanimation!=crouchremoveknifeanim&&player[i].targetanimation!=removeknifeanim)player[i].throwtogglekeydown=0;
9718 player[i].drawkeydown=0;
9720 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9721 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9724 if(player[i].aitype==attacktypecutoff){
9725 player[i].aiupdatedelay-=multiplier;
9726 if(player[i].damage<player[i].damagetolerance*2/3)
9727 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)){
9728 player[i].attackkeydown=0;
9729 if(player[i].isIdle())player[i].crouchkeydown=1;
9730 if(player[0].targetanimation!=rabbitkickanim&&player[0].weaponactive!=-1){
9731 if(weapons.type[player[0].weaponids[0]]==knife){
9732 if(player[i].isIdle()||player[i].isCrouch()||player[i].isRun()||player[i].isFlip()){
9733 if(abs(Random()%2==0))player[i].targetanimation=backhandspringanim;
9734 else player[i].targetanimation=rollanim;
9736 player[i].targetframe=0;
9737 player[i].targetrotation+=90*(abs(Random()%2)*2-1);
9738 player[i].wentforweapon=0;
9740 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim){
9741 player[i].targetanimation=flipanim;
9743 player[i].targetframe=0;
9747 player[i].forwardkeydown=0;
9748 player[i].aiupdatedelay=.02;
9750 if(player[0].isFlip()&&!player[0].skeleton.free&&player[0].targetanimation!=walljumprightkickanim&&player[0].targetanimation!=walljumpleftkickanim){
9751 if(findDistancefast(&player[0].coords,&player[i].coords)<25)
9752 if((1-player[i].damage/player[i].damagetolerance)>.5)player[i].stunned=1;
9754 if(player[i].wentforweapon<3)
9755 for(j=0;j<weapons.numweapons;j++){
9756 if(player[i].creature!=wolftype)
9757 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){
9758 if(findDistancefast(&player[i].coords,&weapons.position[j])<16){
9759 player[i].wentforweapon++;
9760 player[i].lastchecktime=6;
9761 player[i].aitype=getweapontype;
9766 if(player[i].damage<player[i].damagetolerance/2)
9767 if(animation[player[i].targetanimation].height!=highheight)
9768 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)))){
9769 player[i].crouchkeydown=1;
9771 if(player[i].isRun()&&!player[i].onground){
9772 if(player[i].coords.y>terrain.getHeight(player[i].coords.x,player[i].coords.z)+10){
9773 test2=player[i].coords+player[i].facing;
9775 test=player[i].coords+player[i].facing;
9777 j=checkcollide(test2,test,player[i].laststanding);
9778 if(j==-1)j=checkcollide(test2,test);
9780 player[i].velocity=0;
9781 player[i].targetanimation=player[i].getStop();
9782 player[i].targetframe=0;
9784 player[i].targetrotation+=180;
9785 player[i].stunned=.5;
9786 //player[i].aitype=passivetype;
9787 player[i].aitype=pathfindtype;
9788 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9789 player[i].finalpathfindpoint=-1;
9790 player[i].targetpathfindpoint=-1;
9791 player[i].lastpathfindpoint=-1;
9792 player[i].lastpathfindpoint2=-1;
9793 player[i].lastpathfindpoint3=-1;
9794 player[i].lastpathfindpoint4=-1;
9796 else player[i].laststanding=j;
9799 if(player[0].coords.y>player[i].coords.y+5&&animation[player[0].targetanimation].height!=highheight&&!player[0].onterrain){
9800 player[i].aitype=pathfindtype;
9801 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9802 player[i].finalpathfindpoint=-1;
9803 player[i].targetpathfindpoint=-1;
9804 player[i].lastpathfindpoint=-1;
9805 player[i].lastpathfindpoint2=-1;
9806 player[i].lastpathfindpoint3=-1;
9807 player[i].lastpathfindpoint4=-1;
9809 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){
9810 if(player[i].weaponactive==-1&&player[i].num_weapons>0)player[i].drawkeydown=Random()%2;
9811 else player[i].drawkeydown=0;
9812 player[i].rabbitkickenabled=Random()%2;
9813 rotatetarget=player[player[i].aitarget].coords+player[player[i].aitarget].velocity;
9814 if(findDistancefast(&player[player[i].aitarget].coords,&player[i].coords)<findDistancefast(&rotatetarget,&player[i].coords))
9815 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;
9816 else rotatetarget=player[player[i].aitarget].coords-player[i].coords;
9817 Normalise(&rotatetarget);
9818 player[i].targetrotation=-asin(0-rotatetarget.x);
9819 player[i].targetrotation*=360/6.28;
9820 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9821 player[i].lookrotation=player[i].targetrotation;
9822 player[i].aiupdatedelay=.2+abs((float)(Random()%100)/1000);
9824 oldkey=player[i].forwardkeydown;
9825 if(findDistancefast(&player[i].coords,&player[0].coords)>5&&(player[0].weaponactive==-1||player[i].weaponactive!=-1))player[i].forwardkeydown=1;
9826 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;
9827 else if(Random()%6==0||(player[i].creature==wolftype&&Random()%3==0))player[i].forwardkeydown=1;
9828 else player[i].forwardkeydown=0;
9830 player[i].forwardkeydown=0;
9831 if(Random()%10==0)player[i].forwardkeydown=1;
9832 if(Random()%100==0){
9833 player[i].aitype=pathfindtype;
9834 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9835 player[i].finalpathfindpoint=-1;
9836 player[i].targetpathfindpoint=-1;
9837 player[i].lastpathfindpoint=-1;
9838 player[i].lastpathfindpoint2=-1;
9839 player[i].lastpathfindpoint3=-1;
9840 player[i].lastpathfindpoint4=-1;
9843 player[i].leftkeydown=0;
9844 player[i].backkeydown=0;
9845 player[i].rightkeydown=0;
9846 player[i].crouchkeydown=0;
9847 player[i].throwkeydown=0;
9849 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9850 /*for(j=0;j<numplayers;j++){
9851 if(player[j].victim->id==i&&(player[j].targetanimation==spinkickanim&&player[j].targetframe<3)){
9852 player[i].crouchkeydown=1;
9855 if(Random()%2==0/*||player[0].weaponactive!=-1*/||player[i].weaponactive!=-1||player[i].creature==wolftype)player[i].attackkeydown=1;
9856 else player[i].attackkeydown=0;
9857 if((player[i].isRun())&&Random()%6&&findDistancefast(&player[i].coords,&player[0].coords)>7)player[i].attackkeydown=0;
9858 //if(player[i].attackkeydown&&findDistancefast(&player[i].coords,&player[0].coords)<3&&player[i].targetanimation!=runanim&&!player[0].skeleton.free)player[i].crouchkeydown=1;
9859 /*if(player[0].targetanimation==rabbitkickanim&&!player[0].skeleton.free){
9860 player[i].attackkeydown=0;
9861 if(player[i].isIdle())player[i].crouchkeydown=1;
9862 player[i].forwardkeydown=0;
9863 player[i].aiupdatedelay=.02;
9866 if(player[i].aitype!=playercontrolled&&(player[i].isIdle()||player[i].isCrouch()||player[i].isRun())){
9868 for(j=0;j<numplayers;j++){
9869 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)){
9870 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))))){
9871 if(target>=0)target=-1;
9876 if(target>=0)player[target].Reverse();
9879 if(player[i].collided<1)player[i].jumpkeydown=0;
9880 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;
9881 if(normaldotproduct(player[i].facing,player[0].coords-player[i].coords)>0)
9882 player[0].jumpkeydown=0;
9883 if(player[0].targetanimation==jumpdownanim&&findDistancefast(&player[0].coords,&player[i].coords)<40)player[i].crouchkeydown=1;
9884 if(player[i].jumpkeydown)player[i].attackkeydown=0;
9885 //if(animation[player[i].targetanimation].attack==reversed)player[i].crouchkeydown=1;
9887 if(tutoriallevel==1){
9888 if(!canattack)player[i].attackkeydown=0;
9892 facing=player[i].coords;
9893 flatfacing=player[0].coords;
9894 facing.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position.y*player[i].scale;
9895 flatfacing.y+=player[0].skeleton.joints[player[0].skeleton.jointlabels[head]].position.y*player[0].scale;
9896 if(player[i].occluded>=2)
9897 if(-1!=checkcollide(facing,flatfacing)){
9898 if(!player[i].pause)player[i].lastseentime-=.2;
9899 if(player[i].lastseentime<=0&&(player[i].creature!=wolftype||player[i].weaponstuck==-1)){
9900 player[i].aitype=searchtype;
9901 player[i].lastchecktime=12;
9902 player[i].lastseen=player[0].coords;
9903 player[i].lastseentime=12;
9906 else player[i].lastseentime=1;
9909 if(animation[player[0].targetanimation].height==highheight&&(player[i].aitype==attacktypecutoff||player[i].aitype==searchtype)){
9910 if(player[0].coords.y>terrain.getHeight(player[0].coords.x,player[0].coords.z)+10){
9911 test=player[0].coords;
9913 if(-1==checkcollide(player[0].coords,test))player[i].stunned=1;
9916 // NOTE: Ask about logic of this call : NOTE
9917 if((player[i].aitype==passivetype && !(player[i].numwaypoints>1)) ||
9918 player[i].stunned>0 ||
9919 (player[i].pause && (player[i].damage > player[i].superpermanentdamage)))
9921 if(/*player[i].aitype==attacktypecutoff&&*/player[i].pause)player[i].lastseentime=1;
9922 player[i].targetrotation=player[i].rotation;
9923 player[i].forwardkeydown=0;
9924 player[i].leftkeydown=0;
9925 player[i].backkeydown=0;
9926 player[i].rightkeydown=0;
9927 player[i].jumpkeydown=0;
9928 player[i].attackkeydown=0;
9929 player[i].crouchkeydown=0;
9930 player[i].throwkeydown=0;
9937 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
9940 if(player[i].aitype==attacktypecutoff){
9941 rotatetarget=player[0].coords-player[i].coords;
9942 Normalise(&rotatetarget);
9943 player[i].targetheadrotation=-asin(0-rotatetarget.x);
9944 player[i].targetheadrotation*=360/6.28;
9945 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
9947 player[i].targetheadrotation*=-1;
9948 player[i].targetheadrotation+=180;
9949 //player[i].targetheadrotation2=0;
9950 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
9952 else if(player[i].howactive>=typesleeping){
9953 player[i].targetheadrotation=player[i].targetrotation;
9954 player[i].targetheadrotation2=0;
9957 if(player[i].interestdelay<=0){
9958 player[i].interestdelay=.7+(float)(abs(Random()%100))/100;
9959 player[i].headtarget=player[i].coords;
9960 player[i].headtarget.x+=(float)(abs(Random()%200)-100)/100;
9961 player[i].headtarget.z+=(float)(abs(Random()%200)-100)/100;
9962 player[i].headtarget.y+=(float)(abs(Random()%200)-100)/300;
9963 player[i].headtarget+=player[i].facing*1.5;
9965 rotatetarget=player[i].headtarget-player[i].coords;
9966 Normalise(&rotatetarget);
9967 player[i].targetheadrotation=-asin(0-rotatetarget.x);
9968 player[i].targetheadrotation*=360/6.28;
9969 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
9971 player[i].targetheadrotation*=-1;
9972 player[i].targetheadrotation+=180;
9973 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
9975 //if(whichlevel==2)player[i].jumpkeydown=0;
9977 if(animation[player[i].targetanimation].attack==reversed){
9978 //player[i].targetrotation=player[i].rotation;
9979 player[i].forwardkeydown=0;
9980 player[i].leftkeydown=0;
9981 player[i].backkeydown=0;
9982 player[i].rightkeydown=0;
9983 player[i].jumpkeydown=0;
9984 player[i].attackkeydown=0;
9985 //player[i].crouchkeydown=0;
9986 player[i].throwkeydown=0;
9990 player[i].forwardkeydown=0;
9991 player[i].leftkeydown=0;
9992 player[i].backkeydown=0;
9993 player[i].rightkeydown=0;
9994 player[i].jumpkeydown=0;
9995 player[i].crouchkeydown=0;
9996 player[i].drawkeydown=0;
9997 player[i].throwkeydown=0;
10000 if(player[i].collided<-.3)player[i].collided=-.3;
10001 if(player[i].collided>1)player[i].collided=1;
10002 player[i].collided-=multiplier*4;
10003 player[i].whichdirectiondelay-=multiplier;
10004 if(player[i].avoidcollided<-.3||player[i].whichdirectiondelay<=0){
10005 player[i].avoidcollided=-.3;
10006 player[i].whichdirection=abs(Random()%2);
10007 player[i].whichdirectiondelay=.4;
10009 if(player[i].avoidcollided>1)player[i].avoidcollided=1;
10010 player[i].avoidcollided-=multiplier/4;
10011 if(!player[i].skeleton.free)player[i].stunned-=multiplier;
10012 if(!player[i].skeleton.free)player[i].surprised-=multiplier;
10013 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;
10015 if(!player[i].throwkeydown){
10016 player[i].throwtogglekeydown=0;
10018 if(player[i].throwkeydown&&!player[i].throwtogglekeydown){
10019 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)){
10020 for(j=0;j<weapons.numweapons;j++){
10021 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)
10022 if(findDistancefastflat(&player[i].coords,&weapons.position[j])<2){
10023 if(findDistancefast(&player[i].coords,&weapons.position[j])<2){
10024 if(player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isRun()||player[i].isIdle()||player[i].aitype!=playercontrolled){
10025 player[i].throwtogglekeydown=1;
10026 player[i].targetanimation=crouchremoveknifeanim;
10027 player[i].target=0;
10028 player[i].targetframe=0;
10029 rotatetarget=weapons.position[j]-player[i].coords;
10030 Normalise(&rotatetarget);
10031 player[i].targetrotation=-asin(0-rotatetarget.x);
10032 player[i].targetrotation*=360/6.28;
10033 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10034 player[i].hasvictim=0;
10036 if(player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
10037 player[i].throwtogglekeydown=1;
10038 player[i].hasvictim=0;
10040 //for(i=0;i<weapons.numweapons;i++){
10041 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))
10042 if(findDistancefastflat(&player[i].coords,&weapons.position[j])<2&&player[i].weaponactive==-1){
10043 if(findDistancefast(&player[i].coords,&weapons.position[j])<1||player[i].victim){
10046 gLoc[0]=player[i].coords.x;
10047 gLoc[1]=player[i].coords.y;
10048 gLoc[2]=player[i].coords.z;
10049 vel[0]=player[i].velocity.x;
10050 vel[1]=player[i].velocity.y;
10051 vel[2]=player[i].velocity.z;
10052 if(weapons.type[j]!=staff){
10053 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, TRUE);
10054 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
10055 FSOUND_SetVolume(channels[knifedrawsound], 128);
10056 FSOUND_SetPaused(channels[knifedrawsound], FALSE);
10059 player[i].weaponactive=0;
10060 weapons.owner[j]=player[i].id;
10061 if(player[i].num_weapons>0){
10062 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
10064 player[i].num_weapons++;
10065 player[i].weaponids[0]=j;
10071 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){
10072 if(!player[i].isFlip()){
10073 player[i].throwtogglekeydown=1;
10074 player[i].targetanimation=removeknifeanim;
10075 player[i].target=0;
10076 player[i].targetframe=0;
10077 rotatetarget=weapons.position[j]-player[i].coords;
10078 Normalise(&rotatetarget);
10079 player[i].targetrotation=-asin(0-rotatetarget.x);
10080 player[i].targetrotation*=360/6.28;
10081 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10083 if(player[i].isFlip()){
10084 player[i].throwtogglekeydown=1;
10085 player[i].hasvictim=0;
10087 for(k=0;k<weapons.numweapons;k++){
10088 if(player[i].weaponactive==-1)
10089 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))
10090 if(findDistancefastflat(&player[i].coords,&weapons.position[k])<3&&player[i].weaponactive==-1){
10093 gLoc[0]=player[i].coords.x;
10094 gLoc[1]=player[i].coords.y;
10095 gLoc[2]=player[i].coords.z;
10096 vel[0]=player[i].velocity.x;
10097 vel[1]=player[i].velocity.y;
10098 vel[2]=player[i].velocity.z;
10099 if(weapons.type[k]!=staff){
10100 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, TRUE);
10101 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
10102 FSOUND_SetVolume(channels[knifedrawsound], 128);
10103 FSOUND_SetPaused(channels[knifedrawsound], FALSE);
10106 player[i].weaponactive=0;
10107 weapons.owner[k]=player[i].id;
10108 if(player[i].num_weapons>0){
10109 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
10111 player[i].num_weapons++;
10112 player[i].weaponids[0]=k;
10119 if(player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isRun()||player[i].isIdle()||player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
10121 for(j=0;j<numplayers;j++){
10122 if(player[i].weaponactive==-1)
10124 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)){
10125 if(player[i].targetanimation!=rollanim&&player[i].targetanimation!=backhandspringanim){
10126 player[i].throwtogglekeydown=1;
10127 player[i].victim=&player[j];
10128 player[i].hasvictim=1;
10129 player[i].targetanimation=crouchremoveknifeanim;
10130 player[i].target=0;
10131 player[i].targetframe=0;
10132 rotatetarget=player[j].coords-player[i].coords;
10133 Normalise(&rotatetarget);
10134 player[i].targetrotation=-asin(0-rotatetarget.x);
10135 player[i].targetrotation*=360/6.28;
10136 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10138 if(player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
10139 player[i].throwtogglekeydown=1;
10140 player[i].victim=&player[j];
10141 player[i].hasvictim=1;
10142 int k = player[j].weaponids[0];
10143 if(player[i].hasvictim){
10146 gLoc[0]=player[i].coords.x;
10147 gLoc[1]=player[i].coords.y;
10148 gLoc[2]=player[i].coords.z;
10149 vel[0]=player[i].velocity.x;
10150 vel[1]=player[i].velocity.y;
10151 vel[2]=player[i].velocity.z;
10154 if(player[i].victim->weaponstuck!=-1){
10155 if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){
10160 if(weapons.type[k]!=staff){
10161 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, TRUE);
10162 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
10163 FSOUND_SetVolume(channels[knifedrawsound], 128);
10164 FSOUND_SetPaused(channels[knifedrawsound], FALSE);
10168 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, TRUE);
10169 FSOUND_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
10170 FSOUND_SetVolume(channels[fleshstabremovesound], 128);
10171 FSOUND_SetPaused(channels[fleshstabremovesound], FALSE);
10174 player[i].weaponactive=0;
10175 if(weapons.owner[k]!=-1){
10176 if(player[i].victim->num_weapons==1)player[i].victim->num_weapons=0;
10177 else player[i].victim->num_weapons=1;
10179 player[i].victim->skeleton.longdead=0;
10180 player[i].victim->skeleton.free=1;
10181 player[i].victim->skeleton.broken=0;
10183 for(int l=0;l<player[i].victim->skeleton.num_joints;l++){
10184 player[i].victim->skeleton.joints[l].velchange=0;
10185 player[i].victim->skeleton.joints[l].locked=0;
10191 Normalise(&relative);
10192 XYZ footvel,footpoint;
10194 footpoint=weapons.position[k];
10195 if(player[i].victim->weaponstuck!=-1){
10196 if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){
10197 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
10198 weapons.bloody[k]=2;
10199 weapons.blooddrip[k]=5;
10200 player[i].victim->weaponstuck=-1;
10201 player[i].victim->bloodloss+=2000;
10202 player[i].victim->DoDamage(2000);
10205 if(player[i].victim->num_weapons>0){
10206 if(player[i].victim->weaponstuck!=0&&player[i].victim->weaponstuck!=-1)player[i].victim->weaponstuck=0;
10207 if(player[i].victim->weaponids[0]==k)
10208 player[i].victim->weaponids[0]=player[i].victim->weaponids[player[i].victim->num_weapons];
10211 player[i].victim->weaponactive=-1;
10213 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[abdomen]].velocity+=relative*6;
10214 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[neck]].velocity+=relative*6;
10215 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6;
10216 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6;
10218 weapons.owner[k]=i;
10219 if(player[i].num_weapons>0){
10220 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
10222 player[i].num_weapons++;
10223 player[i].weaponids[0]=k;
10230 if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){
10231 if(weapons.type[player[i].weaponids[0]]==knife){
10232 if(player[i].isIdle()||player[i].isRun()||player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isFlip())
10234 for(j=0;j<numplayers;j++){
10236 if(tutoriallevel!=1||tutorialstage==49)
10238 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)){
10239 if(!player[i].isFlip()){
10240 player[i].throwtogglekeydown=1;
10241 player[i].victim=&player[j];
10242 player[i].targetanimation=knifethrowanim;
10243 player[i].target=0;
10244 player[i].targetframe=0;
10245 rotatetarget=player[j].coords-player[i].coords;
10246 Normalise(&rotatetarget);
10247 player[i].targetrotation=-asin(0-rotatetarget.x);
10248 player[i].targetrotation*=360/6.28;
10249 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10251 player[i].targettilt2=-asin(rotatetarget.y)*360/6.28;
10253 if(player[i].isFlip()){
10254 if(player[i].weaponactive!=-1){
10255 player[i].throwtogglekeydown=1;
10256 player[i].victim=&player[j];
10258 weapons.owner[player[i].weaponids[0]]=-1;
10259 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);
10262 aim=DoRotation(aim,(float)abs(Random()%30)-15,(float)abs(Random()%30)-15,0);
10264 weapons.velocity[player[i].weaponids[0]]=aim*50;
10265 weapons.tipvelocity[player[i].weaponids[0]]=aim*50;
10266 weapons.missed[player[i].weaponids[0]]=0;
10267 weapons.freetime[player[i].weaponids[0]]=0;
10268 weapons.firstfree[player[i].weaponids[0]]=1;
10269 weapons.physics[player[i].weaponids[0]]=0;
10270 player[i].num_weapons--;
10271 if(player[i].num_weapons){
10272 player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons];
10274 player[i].weaponactive=-1;
10281 if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){
10282 if(player[i].isCrouch()||player[i].targetanimation==sneakanim)
10284 player[i].throwtogglekeydown=1;
10285 weapons.owner[player[i].weaponids[0]]=-1;
10286 weapons.velocity[player[i].weaponids[0]]=player[i].velocity*.2;
10287 if(weapons.velocity[player[i].weaponids[0]].x==0)weapons.velocity[player[i].weaponids[0]].x=.1;
10288 weapons.tipvelocity[player[i].weaponids[0]]=weapons.velocity[player[i].weaponids[0]];
10289 weapons.missed[player[i].weaponids[0]]=1;
10290 weapons.freetime[player[i].weaponids[0]]=0;
10291 weapons.firstfree[player[i].weaponids[0]]=1;
10292 weapons.physics[player[i].weaponids[0]]=1;
10293 player[i].num_weapons--;
10294 if(player[i].num_weapons){
10295 player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons];
10296 if(player[i].weaponstuck==player[i].num_weapons)player[i].weaponstuck=0;
10299 player[i].weaponactive=-1;
10300 for(j=0;j<numplayers;j++){
10301 player[j].wentforweapon=0;
10308 if(i==0||!player[0].dead||player[i].weaponactive!=-1)
10309 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)){
10310 //Setenvironment(1-environment);
10313 if(player[i].weaponactive!=-1){
10314 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==staff)isgood=0;
10316 if(/*(player[i].weaponactive==-1||player[i].num_weapons==1)&&*/isgood&&player[i].creature!=wolftype){
10317 if(player[i].isIdle()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){
10318 player[i].targetanimation=drawrightanim;
10319 player[i].targetframe=0;
10320 player[i].target=0;
10321 player[i].drawtogglekeydown=1;
10323 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){
10324 player[i].targetanimation=drawleftanim;
10325 player[i].targetframe=0;
10326 player[i].target=0;
10327 player[i].drawtogglekeydown=1;
10329 if(player[i].isCrouch()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){
10330 player[i].targetanimation=crouchdrawrightanim;
10331 player[i].targetframe=0;
10332 player[i].target=0;
10333 player[i].drawtogglekeydown=1;
10337 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){
10338 if(weapons.bloody[player[i].weaponids[player[i].weaponactive]]&&player[i].onterrain&&bloodtoggle&&musictype!=stream_music2){
10339 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==knife)player[i].targetanimation=crouchstabanim;
10340 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==sword)player[i].targetanimation=swordgroundstabanim;
10341 player[i].targetframe=0;
10342 player[i].target=0;
10343 player[i].hasvictim=0;
10344 //player[i].attacktogglekeydown=1;
10348 if(!player[i].drawkeydown){
10349 player[i].drawtogglekeydown=0;
10354 absflatfacing.z=-1;
10356 absflatfacing=DoRotation(absflatfacing,0,-rotation,0);
10358 else absflatfacing=flatfacing;
10360 if(indialogue!=-1){
10361 player[i].forwardkeydown=0;
10362 player[i].leftkeydown=0;
10363 player[i].backkeydown=0;
10364 player[i].rightkeydown=0;
10365 player[i].jumpkeydown=0;
10366 player[i].crouchkeydown=0;
10367 player[i].drawkeydown=0;
10368 player[i].throwkeydown=0;
10372 if(!animation[player[i].targetanimation].attack&&player[i].targetanimation!=staggerbackhighanim&&player[i].targetanimation!=staggerbackhardanim&&player[i].targetanimation!=backhandspringanim&&player[i].targetanimation!=dodgebackanim){
10373 if(!player[i].forwardkeydown){
10374 player[i].forwardstogglekeydown=0;
10376 if(player[i].crouchkeydown){
10380 player[i].superruntoggle=1;
10382 for(j=0;j<numplayers;j++){
10383 if(j!=i&&!player[j].skeleton.free&&player[j].aitype==passivetype){
10384 if(findDistancefast(&player[j].coords,&player[i].coords)<16){
10385 player[i].superruntoggle=0;
10392 for(j=0;j<numplayers;j++){
10393 if(j!=i&&!player[j].skeleton.free&&player[j].victim&&player[i].lowreversaldelay<=0){
10394 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))){
10395 if(target>=0)target=-1;
10400 if(target>=0)player[target].Reverse();
10401 player[i].lowreversaldelay=.5;
10403 if(player[i].isIdle()){
10404 player[i].targetanimation=player[i].getCrouch();
10405 player[i].target=0;
10406 player[i].targetframe=0;
10407 player[i].transspeed=10;
10409 if(player[i].isRun()||(player[i].isStop()&&(player[i].leftkeydown||player[i].rightkeydown||player[i].forwardkeydown||player[i].backkeydown))){
10410 player[i].targetanimation=rollanim;
10411 player[i].target=0;
10412 player[i].targetframe=0;
10413 player[i].transspeed=20;
10416 if(!player[i].crouchkeydown){
10418 if(!player[i].isRun()&&player[i].targetanimation!=sneakanim&&i==0)player[i].superruntoggle=0;
10420 if(player[i].isCrouch()){
10422 for(j=0;j<numplayers;j++){
10423 if(j!=i&&!player[j].skeleton.free&&player[j].victim&&player[i].highreversaldelay<=0){
10424 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<3&&player[j].victim==&player[i]&&(player[j].targetanimation==spinkickanim)&&player[i].isCrouch()){
10425 if(target>=0)target=-1;
10430 if(target>=0)player[target].Reverse();
10431 player[i].highreversaldelay=.5;
10433 if(player[i].isCrouch()){
10434 if(!player[i].wasCrouch()){
10435 player[i].currentanimation=player[i].getCrouch();
10436 player[i].currentframe=0;
10438 player[i].target=0;
10439 player[i].targetanimation=player[i].getIdle();
10440 player[i].targetframe=0;
10441 player[i].transspeed=10;
10444 if(player[i].targetanimation==sneakanim){
10445 player[i].targetanimation=player[i].getIdle();
10446 player[i].target=0;
10447 player[i].targetframe=0;
10448 player[i].transspeed=10;
10451 if(player[i].forwardkeydown){
10452 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)){
10453 if(player[i].aitype==passivetype)player[i].targetanimation=walkanim;
10454 else player[i].targetanimation=player[i].getRun();
10455 player[i].target=0;
10456 player[i].targetframe=0;
10458 if(player[i].isCrouch()){
10459 player[i].targetanimation=sneakanim;
10460 if(player[i].wasCrouch())player[i].target=0;
10461 player[i].targetframe=0;
10463 if(player[i].targetanimation==hanganim/*&&(!player[i].forwardstogglekeydown||player[i].aitype!=playercontrolled)*/){
10464 player[i].targetanimation=climbanim;
10465 player[i].target=0;
10466 player[i].targetframe=1;
10467 player[i].jumpclimb=1;
10469 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10470 player[i].velocity+=absflatfacing*5*multiplier;
10472 player[i].forwardstogglekeydown=1;
10475 if (player[i].rightkeydown){
10476 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)){
10477 player[i].targetanimation=player[i].getRun();
10478 player[i].target=0;
10479 player[i].targetframe=0;
10481 if(player[i].isCrouch()){
10482 player[i].targetanimation=sneakanim;
10483 if(player[i].wasCrouch()) player[i].target=0;
10484 player[i].targetframe=0;
10486 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10487 player[i].velocity+=DoRotation(absflatfacing*5*multiplier,0,-90,0);
10489 player[i].targetrotation-=90;
10490 if(player[i].forwardkeydown)player[i].targetrotation+=45;
10491 if(player[i].backkeydown)player[i].targetrotation-=45;
10494 if ( player[i].leftkeydown){
10495 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)){
10496 player[i].targetanimation=player[i].getRun();
10497 player[i].target=0;
10498 player[i].targetframe=0;
10500 if(player[i].isCrouch()){
10501 player[i].targetanimation=sneakanim;
10502 if(player[i].wasCrouch())player[i].target=0;
10503 player[i].targetframe=0;
10505 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10506 player[i].velocity-=DoRotation(absflatfacing*5*multiplier,0,-90,0);
10508 player[i].targetrotation+=90;
10509 if(player[i].forwardkeydown)player[i].targetrotation-=45;
10510 if(player[i].backkeydown)player[i].targetrotation+=45;
10513 if(player[i].backkeydown){
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 player[i].targetanimation=player[i].getRun();
10516 player[i].target=0;
10517 player[i].targetframe=0;
10519 if(player[i].isCrouch()){
10520 player[i].targetanimation=sneakanim;
10521 if(player[i].wasCrouch())player[i].target=0;
10522 player[i].targetframe=0;
10524 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10525 player[i].velocity-=absflatfacing*5*multiplier;
10527 if(player[i].targetanimation==hanganim){
10528 player[i].currentanimation=jumpdownanim;
10529 player[i].targetanimation=jumpdownanim;
10530 player[i].target=0;
10531 player[i].currentframe=0;
10532 player[i].targetframe=1;
10533 player[i].velocity=0;
10534 player[i].velocity.y+=gravity;
10535 player[i].coords.y-=1.4;
10536 player[i].grabdelay=1;
10538 if ( !player[i].leftkeydown&&!player[i].rightkeydown)
10539 player[i].targetrotation+=180;
10542 if((player[i].jumpkeydown&&!player[i].jumpclimb)||player[i].jumpstart){
10543 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)){
10544 player[i].jumpstart=0;
10545 player[i].targetanimation=jumpupanim;
10546 player[i].target=0;
10547 player[i].targetframe=0;
10548 player[i].rotation=player[i].targetrotation;
10549 player[i].transspeed=20;
10550 player[i].FootLand(0,1);
10551 player[i].FootLand(1,1);
10555 flatfacing=DoRotation(facing,0,player[i].targetrotation+180,0);
10557 if(movekey)player[i].velocity=flatfacing*player[i].speed*45*player[i].scale;
10558 if(!movekey)player[i].velocity=0;
10563 for(j=0;j<numplayers;j++){
10564 if(j!=i&&!player[j].skeleton.free&&player[j].victim){
10565 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<3&&player[j].victim==&player[i]&&(player[j].targetanimation==sweepanim)){
10566 if(target>=0)target=-1;
10571 if(target>=0)player[i].velocity.y=1;
10572 else if(player[i].crouchkeydown||player[i].aitype!=playercontrolled){
10573 player[i].velocity.y=7;
10574 player[i].crouchtogglekeydown=1;
10576 else player[i].velocity.y=5;
10578 if(mousejump&&i==0&&debugmode){
10579 if(!player[i].isLanding())player[i].tempdeltav=deltav;
10580 if(player[i].tempdeltav<0)player[i].velocity.y-=(float)(player[i].tempdeltav)/multiplier/1000;
10583 player[i].coords.y+=.2;
10584 player[i].jumppower-=1;
10586 static float gLoc[3];
10587 static float vel[3];
10588 gLoc[0]=player[i].coords.x;
10589 gLoc[1]=player[i].coords.y;
10590 gLoc[2]=player[i].coords.z;
10591 vel[0]=player[i].velocity.x;
10592 vel[1]=player[i].velocity.y;
10593 vel[2]=player[i].velocity.z;
10596 PlaySoundEx( whooshsound, samp[whooshsound], NULL, TRUE);
10597 FSOUND_3D_SetAttributes(channels[whooshsound], gLoc, vel);
10598 FSOUND_SetVolume(channels[whooshsound], 128);
10599 FSOUND_SetPaused(channels[whooshsound], FALSE);
10602 PlaySoundEx( jumpsound, samp[jumpsound], NULL, TRUE);
10603 FSOUND_3D_SetAttributes(channels[jumpsound], gLoc, vel);
10604 FSOUND_SetVolume(channels[jumpsound], 128);
10605 FSOUND_SetPaused(channels[jumpsound], FALSE);
10607 if((player[i].isIdle())&&player[i].jumppower>1){
10608 player[i].targetanimation=player[i].getLanding();
10609 player[i].landhard=0;
10610 player[i].target=0;
10611 player[i].targetframe=2;
10612 player[i].jumpstart=1;
10613 player[i].tempdeltav=deltav;
10615 if(player[i].targetanimation==jumpupanim&&(((!floatjump&&!editorenabled)||!debugmode)||player[i].aitype!=playercontrolled)){
10616 if(player[i].jumppower>multiplier*6){
10617 player[i].velocity.y+=multiplier*6;
10618 player[i].jumppower-=multiplier*6;
10620 if(player[i].jumppower<=multiplier*6){
10621 player[i].velocity.y+=player[i].jumppower;
10622 player[i].jumppower=0;
10625 if(((floatjump||editorenabled)&&debugmode)&&i==0)player[i].velocity.y+=multiplier*30;
10629 if(player[i].isRun()||player[i].targetanimation==walkanim){
10630 player[i].targetanimation=player[i].getStop();
10631 player[i].target=0;
10632 player[i].targetframe=0;
10634 if(player[i].targetanimation==sneakanim){
10635 player[i].targetanimation=player[i].getCrouch();
10636 if(player[i].currentanimation==sneakanim)player[i].target=0;
10637 player[i].targetframe=0;
10640 if(player[i].targetanimation==walkanim&&(player[i].aitype==attacktypecutoff||player[i].aitype==searchtype||(player[i].aitype==passivetype&&player[i].numwaypoints<=1))){
10641 player[i].targetanimation=player[i].getStop();
10642 player[i].target=0;
10643 player[i].targetframe=0;
10645 if(player[i].isRun()&&(player[i].aitype==passivetype)){
10646 player[i].targetanimation=player[i].getStop();
10647 player[i].target=0;
10648 player[i].targetframe=0;
10652 if(player[i].targetanimation==rollanim)player[i].targetrotation=oldtargetrotation;
10656 for(k=0;k<numplayers;k++){
10657 if(abs(player[k].rotation-player[k].targetrotation)>180){
10658 if(player[k].rotation>player[k].targetrotation)player[k].rotation-=360;
10659 else player[k].rotation+=360;
10662 if(abs(player[k].rotation-player[k].targetrotation)>90&&(player[k].isRun()||player[k].targetanimation==walkanim)){
10663 player[k].targetanimation=player[k].getStop();
10664 player[k].targetframe=0;
10665 player[k].target=0;
10668 if(player[k].targetanimation==backhandspringanim||player[k].targetanimation==dodgebackanim){
10669 player[k].targettilt=0;
10671 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=backhandspringanim&&player[k].targetanimation!=jumpdownanim&&!player[k].isFlip()){
10672 player[k].targettilt=0;
10673 if(player[k].jumppower<0&&!player[k].jumpkeydown)player[k].jumppower=0;
10674 player[k].jumppower+=multiplier*7;
10675 if(player[k].isCrouch())player[k].jumppower+=multiplier*7;
10676 //*(1-(player[k].damage/player[k].damagetolerance))
10677 if(player[k].jumppower>5)player[k].jumppower=5;
10680 if(player[k].isRun()){
10681 player[k].targettilt=(player[k].rotation-player[k].targetrotation)/4;
10684 if(abs(player[k].tilt-player[k].targettilt)<multiplier*150)player[k].tilt=player[k].targettilt;
10685 else if(player[k].tilt>player[k].targettilt){
10686 player[k].tilt-=multiplier*150;
10688 else if(player[k].tilt<player[k].targettilt){
10689 player[k].tilt+=multiplier*150;
10692 player[k].grabdelay-=multiplier;
10695 for(k=0;k<numplayers;k++){
10696 player[k].DoAnimations();
10697 player[k].whichpatchx=player[k].coords.x/(terrain.size/subdivision*terrain.scale*terraindetail);
10698 player[k].whichpatchz=player[k].coords.z/(terrain.size/subdivision*terrain.scale*terraindetail);
10703 player[0].righthandmorphstart=0;
10704 player[0].righthandmorphend=1;
10705 player[0].lefthandmorphstart=0;
10706 player[0].lefthandmorphend=1;
10707 player[0].headmorphstart=0;
10708 player[0].headmorphend=2;*/
10711 if(IsKeyDown( theKeyMap, MAC_P_KEY )){
10712 if(player[0].righthandmorphend!=1)player[0].righthandmorphness=0;
10713 player[0].righthandmorphend=1;
10714 player[0].targetrighthandmorphness=1;
10716 if(player[0].lefthandmorphend!=0)player[0].lefthandmorphness=0;
10717 player[0].lefthandmorphend=0;
10718 player[0].targetlefthandmorphness=1;
10720 if(player[0].headmorphend!=2)player[0].headmorphness=0;
10721 player[0].headmorphend=2;
10722 player[0].targetheadmorphness=1;
10724 if(IsKeyDown( theKeyMap, MAC_L_KEY )){
10725 if(player[0].righthandmorphend!=0)player[0].righthandmorphness=0;
10726 player[0].righthandmorphend=0;
10727 player[0].targetrighthandmorphness=1;
10729 if(player[0].lefthandmorphend!=1)player[0].lefthandmorphness=0;
10730 player[0].lefthandmorphend=1;
10731 player[0].targetlefthandmorphness=1;
10733 if(player[0].headmorphend!=0)player[0].headmorphness=0;
10734 player[0].headmorphend=0;
10735 player[0].targetheadmorphness=1;
10738 if(numenvsounds!=0)
10739 for(j=numenvsounds-1;j>=0;j--){
10740 envsoundlife[j]-=multiplier;
10741 if(envsoundlife[j]<0){
10743 envsoundlife[j]=envsoundlife[numenvsounds];
10744 envsound[j]=envsound[numenvsounds];
10747 if(!slomo)FSOUND_SetFrequency(FSOUND_ALL, 22050);
10748 if(slomo)FSOUND_SetFrequency(FSOUND_ALL, slomofreq);
10750 if(tutoriallevel==1){
10767 if(tutorialstage>=51)
10768 if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
10769 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
10771 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
10772 FSOUND_SetPaused(channels[stream_music3], FALSE);
10773 FSOUND_SetVolume(channels[stream_music3], 256);
10778 float gLoc[3]={0,0,0};
10779 float vel[3]={0,0,0};
10780 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10781 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
10782 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10783 FSOUND_SetVolume(channels[fireendsound], 256);
10784 FSOUND_SetPaused(channels[fireendsound], FALSE);
10785 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
10793 if(tutorialstage<51)
10794 if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
10797 gLoc[0]=player[0].coords.x;
10798 gLoc[1]=player[0].coords.y;
10799 gLoc[2]=player[0].coords.z;
10803 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
10804 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10805 FSOUND_SetVolume(channels[fireendsound], 256);
10806 FSOUND_SetPaused(channels[fireendsound], FALSE);
10808 player[0].coords=(oldtemp+oldtemp2)/2;
10816 if(tutorialstage>=14&&tutorialstage<50)
10817 if(findDistancefast(&temp,&player[1].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[1].coords)<4){
10820 gLoc[0]=player[1].coords.x;
10821 gLoc[1]=player[1].coords.y;
10822 gLoc[2]=player[1].coords.z;
10826 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
10827 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10828 FSOUND_SetVolume(channels[fireendsound], 256);
10829 FSOUND_SetPaused(channels[fireendsound], FALSE);
10831 for(int i=0;i<player[1].skeleton.num_joints;i++){
10833 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
10834 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
10835 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;
10836 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
10837 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
10841 player[1].coords=(oldtemp+oldtemp2)/2;
10842 for(int i=0;i<player[1].skeleton.num_joints;i++){
10843 player[1].skeleton.joints[i].velocity=0;
10845 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
10846 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
10847 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;
10848 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
10849 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
10857 static float gLoc[3];
10861 static float vel[3];
10862 vel[0]=(viewer.x-oldviewer.x)/multiplier;
10863 vel[1]=(viewer.y-oldviewer.y)/multiplier;
10864 vel[2]=(viewer.z-oldviewer.z)/multiplier;
10866 //Set orientation with forward and up vectors
10867 static XYZ upvector;
10871 upvector=DoRotation(upvector,-rotation2+90,0,0);
10872 upvector=DoRotation(upvector,0,0-rotation,0);
10877 facing=DoRotation(facing,-rotation2,0,0);
10878 facing=DoRotation(facing,0,0-rotation,0);
10881 static float ori[6];
10882 ori[0] = -facing.x;
10884 ori[2] = -facing.z;
10885 ori[3] = -upvector.x;
10886 ori[4] = upvector.y;
10887 ori[5] = -upvector.z;
10889 FSOUND_3D_Listener_SetAttributes(&gLoc[0], &vel[0], ori[0], ori[1], ori[2], ori[3], ori[4], ori[5]);
10896 if(IsKeyDown(theKeyMap, MAC_F1_KEY)&&!freezetogglekeydown){
10898 freezetogglekeydown=1;
10902 void Game::TickOnce(){
10905 if(directing||indialogue==-1){
10906 rotation+=deltah*.7;
10907 if(!invertmouse)rotation2+=deltav*.7;
10908 if(invertmouse)rotation2-=deltav*.7;
10909 if(rotation2>90)rotation2=90;
10910 if(rotation2<-70)rotation2=-70;
10912 if(mainmenu)rotation+=multiplier*5;
10913 if(!mainmenu&&!indemo&&!registered){
10914 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
10915 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
10916 FSOUND_SetPaused(channels[stream_music3], FALSE);
10917 FSOUND_SetVolume(channels[stream_music3], 256);
10922 float gLoc[3]={0,0,0};
10923 float vel[3]={0,0,0};
10924 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10925 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
10926 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10927 FSOUND_SetVolume(channels[fireendsound], 256);
10928 FSOUND_SetPaused(channels[fireendsound], FALSE);
10929 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
10938 if(tryquit==1&&!registered&&mainmenu!=12){
10939 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
10940 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
10941 FSOUND_SetPaused(channels[stream_music3], FALSE);
10942 FSOUND_SetVolume(channels[stream_music3], 256);
10947 float gLoc[3]={0,0,0};
10948 float vel[3]={0,0,0};
10949 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10950 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
10951 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10952 FSOUND_SetVolume(channels[fireendsound], 256);
10953 FSOUND_SetPaused(channels[fireendsound], FALSE);
10954 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
10965 void Game::TickOnceAfter(){
10966 static XYZ colviewer;
10967 static XYZ coltarget;
10970 static float brotate;
10973 static float changedelay;
10974 static bool alldead;
10975 static float unseendelay;
10976 static float cameraspeed;
10980 if(environment==snowyenvironment)music1=stream_music1snow;
10981 if(environment==grassyenvironment)music1=stream_music1grass;
10982 if(environment==desertenvironment)music1=stream_music1desert;
10987 for(i=0;i<numplayers;i++){
10988 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)){
10989 musictype=stream_music2;
10993 if(player[0].dead)musictype=stream_music3;
10996 if(musictype==stream_music2){
11000 if(oldmusictype==stream_music2&&musictype!=stream_music2){
11001 unseendelay-=multiplier;
11003 musictype=stream_music2;
11009 musictype=stream_music3;
11010 musicvolume[2]=512;
11017 if(musictype!=oldmusictype&&musictype==stream_music2){
11018 static float gLoc[3];
11019 static float vel[3];
11020 gLoc[0]=cameraloc.x;
11021 gLoc[1]=cameraloc.y;
11022 gLoc[2]=cameraloc.z;
11026 PlaySoundEx( alarmsound, samp[alarmsound], NULL, TRUE);
11027 FSOUND_SetVolume(channels[alarmsound], 512);
11028 FSOUND_SetPaused(channels[alarmsound], FALSE);
11032 musicselected=musictype;
11034 if(musicselected==music1)musicvolume[0]+=multiplier*450;
11035 else musicvolume[0]-=multiplier*450;
11036 if(musicselected==stream_music2)musicvolume[1]+=multiplier*450;
11037 else musicvolume[1]-=multiplier*450;
11038 if(musicselected==stream_music3)musicvolume[2]+=multiplier*450;
11039 else musicvolume[2]-=multiplier*450;
11041 if(musicselected==music1)musicvolume[0]+=multiplier*100;
11042 else musicvolume[0]-=multiplier*450;
11043 if(musicselected==music2)musicvolume[1]+=multiplier*150;
11044 else if(player[0].dead)musicvolume[1]-=multiplier*450;
11045 else musicvolume[1]-=multiplier*100;
11046 if(musicselected==music3)musicvolume[2]+=multiplier*450;
11047 else musicvolume[2]-=multiplier*450;*/
11050 if(musicvolume[i]<0)musicvolume[i]=0;
11051 if(musicvolume[i]>512)musicvolume[i]=512;
11054 if(musicvolume[2]>128&&!loading&&!mainmenu)musicvolume[2]=128;
11057 if(musicvolume[0]>0&&oldmusicvolume[0]<=0){
11058 PlayStreamEx( music1, strm[music1], NULL, TRUE);
11059 FSOUND_SetPaused(channels[music1], FALSE);
11061 if(musicvolume[1]>0&&oldmusicvolume[1]<=0){
11062 PlayStreamEx( stream_music2, strm[stream_music2], NULL, TRUE);
11063 FSOUND_SetPaused(channels[stream_music2], FALSE);
11065 if(musicvolume[2]>0&&oldmusicvolume[2]<=0){
11066 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
11067 FSOUND_SetPaused(channels[stream_music3], FALSE);
11072 FSOUND_SetPaused(channels[music1], TRUE);
11073 FSOUND_SetPaused(channels[stream_music2], TRUE);
11074 FSOUND_SetPaused(channels[stream_music3], TRUE);
11077 oldmusicvolume[i]=0;
11083 if(musicvolume[0]<=0&&oldmusicvolume[0]>0){
11084 FSOUND_SetPaused(channels[music1], TRUE);
11086 if(musicvolume[1]<=0&&oldmusicvolume[1]>0){
11087 FSOUND_SetPaused(channels[stream_music2], TRUE);
11089 if(musicvolume[2]<=0&&oldmusicvolume[2]>0){
11090 FSOUND_SetPaused(channels[stream_music3], TRUE);
11093 if(musicvolume[0]!=oldmusicvolume[0]){
11094 FSOUND_SetVolume(channels[music1], musicvolume[0]);
11096 if(musicvolume[1]!=oldmusicvolume[1]){
11097 FSOUND_SetVolume(channels[stream_music2], musicvolume[1]);
11099 if(musicvolume[2]!=oldmusicvolume[2]){
11100 FSOUND_SetVolume(channels[stream_music3], musicvolume[2]);
11104 oldmusicvolume[i]=musicvolume[i];
11110 for(i=0;i<numhotspots;i++){
11111 if(hotspottype[i]>10&&hotspottype[i]<20){
11112 if(player[hotspottype[i]-10].dead==0){
11115 else if(killhotspot==2)
11119 if(killhotspot==2)killhotspot=0;
11124 for(i=0;i<numhotspots;i++){
11125 if(hotspottype[i]==-1){
11126 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i])
11133 for(i=1;i<numplayers;i++){
11134 if(!player[i].dead&&player[i].aitype==attacktypecutoff&&player[i].surprised<=0)numalarmed++;
11136 if(numalarmed>maxalarmed)maxalarmed=numalarmed;
11138 if(changedelay<=0&&!loading&&!editorenabled&&gameon&&!tutoriallevel&&changedelay!=-999&&!won){
11139 if(player[0].dead&&changedelay<=0){
11141 targetlevel=whichlevel;
11145 for(i=1;i<numplayers;i++){
11146 if(!player[i].dead&&player[i].howactive<typedead1)alldead=0;
11150 if(alldead&&!player[0].dead&&maptype==mapkilleveryone){
11152 targetlevel=whichlevel+1;
11153 if(targetlevel>numchallengelevels-1)targetlevel=0;
11155 if(winhotspot||windialogue){
11157 targetlevel=whichlevel+1;
11158 if(targetlevel>numchallengelevels-1)targetlevel=0;
11164 targetlevel=whichlevel+1;
11165 if(targetlevel>numchallengelevels-1)targetlevel=0;
11168 if(changedelay>0&&!player[0].dead&&!won){
11169 //high scores, awards, win
11172 accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
11173 accountcampaignchoicesmade[accountactive]++;
11174 accountcampaignscore[accountactive]+=bonustotal;
11176 accountcampaigntime[accountactive]+=leveltime;
11177 if(accountcampaignscore[accountactive]>accountcampaignhighscore[accountactive])accountcampaignhighscore[accountactive]=accountcampaignscore[accountactive];
11179 //if(accountprogress[accountactive]<whichlevel+1)accountprogress[accountactive]=whichlevel+1;
11185 if(bonustotal-startbonustotal>accounthighscore[accountactive][whichlevel])accounthighscore[accountactive][whichlevel]=bonustotal-startbonustotal;
11186 if(accountfasttime[accountactive][whichlevel]==0||leveltime<accountfasttime[accountactive][whichlevel])accountfasttime[accountactive][whichlevel]=leveltime;
11188 if(accountprogress[accountactive]<whichlevel+1)accountprogress[accountactive]=whichlevel+1;
11204 if(!editorenabled&&gameon&&!mainmenu){
11205 if(changedelay!=-999)changedelay-=multiplier/7;
11206 if(player[0].dead)targetlevel=whichlevel;
11207 if(loading==2&&!campaign){
11215 float gLoc[3]={0,0,0};
11216 float vel[3]={0,0,0};
11217 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
11218 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
11219 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
11220 FSOUND_SetVolume(channels[firestartsound], 256);
11221 FSOUND_SetPaused(channels[firestartsound], FALSE);
11222 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
11224 if(!player[0].dead&&targetlevel!=whichlevel){
11225 startbonustotal=bonustotal;
11227 if(!player[0].dead)Loadlevel(targetlevel);
11228 if(player[0].dead)Loadlevel(whichlevel);
11230 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
11231 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
11232 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
11233 FSOUND_SetVolume(channels[fireendsound], 256);
11234 FSOUND_SetPaused(channels[fireendsound], FALSE);
11235 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
11239 if(loading==2&&targetlevel==whichlevel){
11247 float gLoc[3]={0,0,0};
11248 float vel[3]={0,0,0};
11249 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
11250 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
11251 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
11252 FSOUND_SetVolume(channels[firestartsound], 256);
11253 FSOUND_SetPaused(channels[firestartsound], FALSE);
11254 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
11256 for(i=0;i<255;i++){
11270 strcat(mapname,campaignmapname[levelorder[accountcampaignchoicesmade[accountactive]]]);//[campaignchoicewhich[whichchoice]]);
11271 Loadlevel(mapname);
11273 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
11274 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
11275 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
11276 FSOUND_SetVolume(channels[fireendsound], 256);
11277 FSOUND_SetPaused(channels[fireendsound], FALSE);
11278 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
11282 if(changedelay<=-999&&whichlevel!=-2&&!loading&&(player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(killhotspot))&&!winfreeze)loading=1;
11283 if((player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(windialogue)||(killhotspot))&&changedelay<=0){
11284 if(accountprogress[accountactive]>3&&!registered){
11285 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
11286 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
11287 FSOUND_SetPaused(channels[stream_music3], FALSE);
11288 FSOUND_SetVolume(channels[stream_music3], 256);
11292 accountprogress[accountactive]=3;
11294 float gLoc[3]={0,0,0};
11295 float vel[3]={0,0,0};
11296 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
11297 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
11298 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
11299 FSOUND_SetVolume(channels[fireendsound], 256);
11300 FSOUND_SetPaused(channels[fireendsound], FALSE);
11301 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
11310 if(whichlevel!=-2&&!loading&&!player[0].dead){
11314 if(player[0].dead)loading=1;
11320 if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1){
11321 if(campaignnumnext[campaignchoicewhich[whichchoice]]==0){
11325 else if(mainmenu==0&&winfreeze){
11326 if(campaignchoosenext[campaignchoicewhich[whichchoice]]==2)
11328 else stealthloading=0;
11330 if(!stealthloading){
11331 float gLoc[3]={0,0,0};
11332 float vel[3]={0,0,0};
11333 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
11334 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
11335 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
11336 FSOUND_SetVolume(channels[firestartsound], 256);
11337 FSOUND_SetPaused(channels[firestartsound], FALSE);
11338 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
11349 // ifstream ipstream(":Data:Campaigns:main.txt");
11350 ifstream ipstream("./Data/Campaigns/main.txt");
11351 //campaignnumlevels=0;
11352 //accountcampaignchoicesmade[accountactive]=0;
11353 ipstream.ignore(256,':');
11354 ipstream >> campaignnumlevels;
11355 for(i=0;i<campaignnumlevels;i++){
11356 ipstream.ignore(256,':');
11357 ipstream.ignore(256,':');
11358 ipstream.ignore(256,' ');
11359 ipstream >> campaignmapname[i];
11360 ipstream.ignore(256,':');
11361 ipstream >> campaigndescription[i];
11362 for(j=0;j<256;j++){
11363 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
11365 ipstream.ignore(256,':');
11366 ipstream >> campaignchoosenext[i];
11367 ipstream.ignore(256,':');
11368 ipstream >> campaignnumnext[i];
11369 if(campaignnumnext[i])
11370 for(j=0;j<campaignnumnext[i];j++){
11371 ipstream.ignore(256,':');
11372 ipstream >> campaignnextlevel[i][j];
11373 campaignnextlevel[i][j]-=1;
11375 ipstream.ignore(256,':');
11376 ipstream >> campaignlocationx[i];
11377 ipstream.ignore(256,':');
11378 ipstream >> campaignlocationy[i];
11382 for(i=0;i<campaignnumlevels;i++){
11384 levelhighlight[i]=0;
11388 for(i=0;i<campaignnumlevels;i++){
11390 levelhighlight[i]=0;
11395 if(accountcampaignchoicesmade[accountactive])
11396 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
11397 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
11398 levelvisible[levelorder[i+1]]=1;
11400 int whichlevelstart;
11401 whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
11402 if(whichlevelstart<0){
11403 campaignchoicenum=1;
11404 campaignchoicewhich[0]=0;
11408 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
11409 if(campaignchoicenum)
11410 for(i=0;i<campaignchoicenum;i++){
11411 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
11412 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
11413 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
11420 //if(firstload)TickOnceAfter();
11421 if(!firstload)LoadStuff();
11423 for(i=0;i<255;i++){
11438 //accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
11439 //accountcampaignchoicesmade[accountactive]++;
11442 strcat(mapname,campaignmapname[campaignchoicewhich[0]]);
11446 Loadlevel(mapname);
11450 FSOUND_SetPaused(channels[stream_music3], TRUE);
11455 if(loading==3)loading=0;
11459 oldmusictype=musictype;
11465 facing=DoRotation(facing,-rotation2,0,0);
11466 facing=DoRotation(facing,0,0-rotation,0);
11467 viewerfacing=facing;
11471 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;
11472 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;
11474 if(player[0].skeleton.free){
11475 for(i=0;i<player[0].skeleton.num_joints;i++){
11476 if(player[0].skeleton.joints[i].position.y*player[0].scale+player[0].coords.y>target.y)
11477 target.y=player[0].skeleton.joints[i].position.y*player[0].scale+player[0].coords.y;
11481 if(player[0].skeleton.free!=2&&!autocam){
11483 if(findLengthfast(&player[0].velocity)>400){
11484 cameraspeed=20+(findLength(&player[0].velocity)-20)*.96;
11486 if(player[0].skeleton.free==0&&player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim)target.y+=1.4;
11487 coltarget=target-cameraloc;
11488 if(findLengthfast(&coltarget)<multiplier*multiplier*400)cameraloc=target;
11490 Normalise(&coltarget);
11491 if(player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim&&player[0].currentanimation!=climbanim&&player[0].currentoffset.x==0)cameraloc=cameraloc+coltarget*multiplier*cameraspeed;
11492 else cameraloc=cameraloc+coltarget*multiplier*8;
11494 if(editorenabled)cameraloc=target;
11495 cameradist+=multiplier*5;
11496 if(cameradist>2.3)cameradist=2.3;
11497 viewer=cameraloc-facing*cameradist;
11499 coltarget=cameraloc;
11500 objects.SphereCheckPossible(&colviewer, findDistance(&colviewer,&coltarget));
11501 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11502 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11503 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11505 coltarget=cameraloc;
11506 if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;
11508 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11509 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11510 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11512 if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.rotation[i])!=-1){
11516 cameradist=findDistance(&viewer,&target);
11517 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.6){
11518 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.6;
11520 if(cameraloc.y<terrain.getHeight(cameraloc.x,cameraloc.z)){
11521 cameraloc.y=terrain.getHeight(cameraloc.x,cameraloc.z);
11524 if(player[0].skeleton.free!=2&&autocam){
11526 if(findLengthfast(&player[0].velocity)>400){
11527 cameraspeed=20+(findLength(&player[0].velocity)-20)*.96;
11529 if(player[0].skeleton.free==0&&player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim)target.y+=1.4;
11530 cameradist+=multiplier*5;
11531 if(cameradist>3.3)cameradist=3.3;
11532 coltarget=target-cameraloc;
11533 if(findLengthfast(&coltarget)<multiplier*multiplier*400)cameraloc=target;
11534 else if(findLengthfast(&coltarget)>1)
11536 Normalise(&coltarget);
11537 if(player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim&&player[0].currentanimation!=climbanim&&player[0].currentoffset.x==0)cameraloc=cameraloc+coltarget*multiplier*cameraspeed;
11538 else cameraloc=cameraloc+coltarget*multiplier*8;
11540 if(editorenabled)cameraloc=target;
11543 coltarget=cameraloc;
11544 objects.SphereCheckPossible(&colviewer, findDistance(&colviewer,&coltarget));
11545 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11546 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11547 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11549 coltarget=cameraloc;
11550 if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;
11552 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11553 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11554 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11556 if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.rotation[i])!=-1){
11560 cameradist=findDistance(&viewer,&target);
11561 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.6){
11562 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.6;
11564 if(cameraloc.y<terrain.getHeight(cameraloc.x,cameraloc.z)){
11565 cameraloc.y=terrain.getHeight(cameraloc.x,cameraloc.z);
11568 if(camerashake>.8)camerashake=.8;
11569 //if(woozy>10)woozy=10;
11570 //woozy+=multiplier;
11572 if(player[0].dead)camerashake=0;
11573 if(player[0].dead)woozy=0;
11574 camerashake-=multiplier*2;
11575 blackout-=multiplier*2;
11576 //if(player[0].isCrouch())woozy-=multiplier*8;
11577 if(camerashake<0)camerashake=0;
11578 if(blackout<0)blackout=0;
11579 //if(woozy<0)woozy=0;
11581 viewer.x+=(float)(Random()%100)*.0005*camerashake;
11582 viewer.y+=(float)(Random()%100)*.0005*camerashake;
11583 viewer.z+=(float)(Random()%100)*.0005*camerashake;