14 extern float multiplier;
16 extern int environment;
17 extern float texscale;
18 extern Terrain terrain;
19 extern FSOUND_SAMPLE *samp[100];
20 extern int channels[100];
21 extern Sprites sprites;
22 extern int kTextureSize;
23 extern float screenwidth,screenheight;
26 extern float texdetail;
27 extern Objects objects;
29 extern float slomodelay;
30 extern bool floatjump;
32 extern Animation animation[animation_count];
34 extern float texdetail;
35 extern GLubyte bloodText[512*512*3];
36 extern GLubyte wolfbloodText[512*512*3];
37 extern float terraindetail;
38 extern float camerashake;
40 extern float blackout;
41 extern bool cellophane;
42 extern bool musictoggle;
43 extern int difficulty;
44 extern Weapons weapons;
45 extern Person player[maxplayers];
46 extern int numplayers;
47 extern int bloodtoggle;
48 extern bool invertmouse;
50 extern float precipdelay;
51 extern XYZ viewerfacing;
52 extern bool ambientsound;
53 extern bool mousejump;
54 extern float viewdistance;
56 extern bool autoslomo;
57 extern int newnetmessages;
58 extern char netmessages[256];
59 extern bool keyboardfrozen;
60 extern int netdatanew;
61 extern bool loadingstuff;
62 extern char mapname[256];
63 extern XYZ windvector;
64 extern bool buttons[3];
65 extern bool debugmode;
68 extern int oldmainmenu;
69 extern bool visibleloading;
70 extern int loadscreencolor;
71 extern float flashamount,flashr,flashg,flashb;
72 extern int flashdelay;
73 extern XYZ envsound[30];
74 extern float envsoundvol[30];
75 extern int numenvsounds;
76 extern float envsoundlife[30];
77 extern float usermousesensitivity;
78 extern bool ismotionblur;
80 extern bool trilinear;
81 extern bool damageeffects;
82 extern bool showpoints;
83 extern bool texttoggle;
84 extern bool alwaysblur;
85 extern float gamespeed;
88 extern bool immediate;
89 extern bool velocityblur;
92 extern float bonusvalue;
93 extern float bonustotal;
94 extern float bonustime;
95 extern float startbonustotal;
96 extern float tintr,tintg,tintb;
97 extern float bonusnum[100];
98 extern bool skyboxtexture;
100 extern float skyboxg;
101 extern float skyboxb;
102 extern float skyboxlightr;
103 extern float skyboxlightg;
104 extern float skyboxlightb;
105 extern float fadestart;
106 extern float slomospeed;
107 extern float slomofreq;
108 extern int tutoriallevel;
109 extern float smoketex;
110 extern float tutorialstagetime;
111 extern int tutorialstage;
112 extern float tutorialmaxtime;
113 extern float tutorialsuccess;
114 extern bool againbonus;
115 extern bool reversaltrain;
116 extern bool canattack;
117 extern bool cananger;
118 extern float damagedealt;
119 extern float damagetaken;
121 extern int editoractive;
122 extern int editorpathtype;
123 extern bool oldbuttons[3];
125 extern float hostiletime;
127 extern bool gamestarted;
129 extern int numhotspots;
130 extern int winhotspot;
131 extern int windialogue;
132 extern int killhotspot;
133 extern XYZ hotspot[40];
134 extern int hotspottype[40];
135 extern float hotspotsize[40];
136 extern char hotspottext[40][256];
137 extern int currenthotspot;
139 extern int kBitsPerPixel;
142 extern int numaccounts;
143 extern int accountactive;
144 extern int accountdifficulty[10];
145 extern int accountprogress[10];
146 extern float accountpoints[10];
147 extern float accounthighscore[10][50];
148 extern float accountfasttime[10][50];
149 extern bool accountunlocked[10][60];
150 extern char accountname[10][256];
152 extern bool stillloading;
153 extern bool winfreeze;
156 extern int numflipfail;
158 extern int numstaffattack;
159 extern int numswordattack;
160 extern int numknifeattack;
161 extern int numunarmedattack;
162 extern int numescaped;
163 extern int numflipped;
164 extern int numwallflipped;
165 extern int numthrowkill;
166 extern int numafterkill;
167 extern int numreversals;
168 extern int numattacks;
169 extern int maxalarmed;
170 extern int numresponded;
172 extern int numdialogues;
173 extern int numdialogueboxes[max_dialogues];
174 extern int dialoguetype[max_dialogues];
175 extern int dialogueboxlocation[max_dialogues][max_dialoguelength];
176 extern float dialogueboxcolor[max_dialogues][max_dialoguelength][3];
177 extern int dialogueboxsound[max_dialogues][max_dialoguelength];
178 extern char dialoguetext[max_dialogues][max_dialoguelength][128];
179 extern char dialoguename[max_dialogues][max_dialoguelength][64];
180 extern XYZ dialoguecamera[max_dialogues][max_dialoguelength];
181 extern XYZ participantlocation[max_dialogues][10];
182 extern int participantfocus[max_dialogues][max_dialoguelength];
183 extern int participantaction[max_dialogues][max_dialoguelength];
184 extern float participantrotation[max_dialogues][10];
185 extern XYZ participantfacing[max_dialogues][max_dialoguelength][10];
186 extern float dialoguecamerarotation[max_dialogues][max_dialoguelength];
187 extern float dialoguecamerarotation2[max_dialogues][max_dialoguelength];
188 extern int indialogue;
189 extern int whichdialogue;
190 extern int directing;
191 extern float dialoguetime;
192 extern int dialoguegonethrough[20];
194 extern bool campaign;
196 extern float oldgamespeed;
198 extern float accountcampaignhighscore[10];
199 extern float accountcampaignfasttime[10];
200 extern float accountcampaignscore[10];
201 extern float accountcampaigntime[10];
203 extern int accountcampaignchoicesmade[10];
204 extern int accountcampaignchoices[10][5000];
205 /********************> Tick() <*****/
206 extern FSOUND_STREAM * strm[20];
207 extern "C" void PlaySoundEx(int channel, FSOUND_SAMPLE *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused);
208 extern "C" void PlayStreamEx(int chan, FSOUND_STREAM *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused);
210 extern void ScreenShot(const char * fname);
211 void Screenshot (void)
214 time_t t = time(NULL);
215 struct tm *tme = localtime(&t);
216 sprintf(temp, "Screenshots\\Screenshot_%04d_%02d_%02d--%02d_%02d_%02d.png", tme->tm_year + 1900, tme->tm_mon + 1, tme->tm_mday, tme->tm_hour, tme->tm_min, tme->tm_sec);
218 mkdir("Screenshots", S_IRWXU);
219 ScreenShot(temp/*"Screenshots\\Screenshot.png"*/);
222 GraphicsExportComponent QT_exporter;
223 OSErr MAC_error_code;
224 CGrafPtr MAC_currentPort;
225 GDHandle MAC_currentDevice;
226 unsigned char* MAC_pixels;
227 Rect MAC_picture_rectangle;
228 GWorldPtr MAC_offscreen_graphics_port;
230 static int numscreenshots=0;
233 static char buf[256];
234 if(numscreenshots==0){
265 FSMakeFSSpec(0, 0, (unsigned char*)buf, &MAC_file);
266 while(!FSpGetFInfo (&MAC_file, fndrInfo)){
267 FSMakeFSSpec(0, 0, (unsigned char*)buf, &MAC_file);
268 if(!FSpGetFInfo (&MAC_file, fndrInfo)){
289 GWorldPtr MAC_gWorld = (CGrafPtr) FrontWindow();
290 //assert(MAC_gWorld != NULL);
292 // Allocate memory for loading image
293 MAC_pixels = new unsigned char[(int)(screenheight * screenwidth * 4)];
294 if (MAC_pixels == NULL) {
295 //UTIL_Error("Could not create Texture data.");
300 ::GetGWorld(&MAC_currentPort, &MAC_currentDevice);
302 // Make a picture Rectangle
303 MAC_picture_rectangle.left = 0;
304 MAC_picture_rectangle.right = screenwidth;
305 MAC_picture_rectangle.top = 0;
306 MAC_picture_rectangle.bottom = screenheight;
308 // Create new offscreen GWorld
309 MAC_error_code = ::QTNewGWorldFromPtr (&MAC_offscreen_graphics_port, k32ARGBPixelFormat, &MAC_picture_rectangle, NULL, NULL, 0, (char *) MAC_pixels, screenwidth * 4);
310 if (MAC_error_code) {
311 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
313 //UTIL_Error("Could not create offscreen GWorld. ");
318 // Copy OpenGL Context to new GWorld
319 glReadBuffer(GL_FRONT);
320 glReadPixels(0,0,screenwidth,screenheight,GL_RGBA,GL_UNSIGNED_BYTE,MAC_pixels);
323 for (unsigned long byte = 0; byte < screenheight * screenwidth * 4; byte+=4) {
324 unsigned char temp = MAC_pixels[byte+0];
325 MAC_pixels[byte+0] = MAC_pixels[byte+3];
326 MAC_pixels[byte+3] = MAC_pixels[byte+2];
327 MAC_pixels[byte+2] = MAC_pixels[byte+1];
328 MAC_pixels[byte+1] = temp;
331 // Flip the image :( This could probably be optimized
336 for (int horz = 0; horz < screenwidth; ++horz)
337 for (vert = 0; vert < screenheight / 2; ++vert) {
338 src_index = (screenwidth * vert + horz) * 4;
339 dst_index = (screenwidth * (screenheight - vert - 1) + horz) * 4;
341 temp=MAC_pixels[src_index+0];
342 MAC_pixels[src_index+0]=MAC_pixels[dst_index+0];
343 MAC_pixels[dst_index+0]=temp;
345 temp=MAC_pixels[src_index+1];
346 MAC_pixels[src_index+1]=MAC_pixels[dst_index+1];
347 MAC_pixels[dst_index+1]=temp;
349 temp=MAC_pixels[src_index+2];
350 MAC_pixels[src_index+2]=MAC_pixels[dst_index+2];
351 MAC_pixels[dst_index+2]=temp;
353 temp=MAC_pixels[src_index+3];
354 MAC_pixels[src_index+3]=MAC_pixels[dst_index+3];
355 MAC_pixels[dst_index+3]=temp;
361 MAC_error_code = OpenADefaultComponent(GraphicsExporterComponentType, kQTFileTypeBMP, &QT_exporter);
362 if (MAC_error_code) {
363 //UTIL_Warning("Unable to export screenshot.");
364 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
365 ::DisposeGWorld(MAC_offscreen_graphics_port);
370 MAC_error_code = GraphicsExportSetInputGWorld(QT_exporter,MAC_offscreen_graphics_port);
371 if (MAC_error_code) {
372 ::CloseComponent(QT_exporter);
373 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
374 ::DisposeGWorld(MAC_offscreen_graphics_port);
376 //UTIL_Warning("Unable to export screenshot.");
380 MAC_error_code = GraphicsExportSetOutputFile(QT_exporter,&MAC_file);
381 if (MAC_error_code) {
382 ::CloseComponent(QT_exporter);
383 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
384 ::DisposeGWorld(MAC_offscreen_graphics_port);
386 //UTIL_Warning("Unable to export screenshot.");
390 MAC_error_code = GraphicsExportDoExport(QT_exporter,NULL);
391 if (MAC_error_code) {
392 ::CloseComponent(QT_exporter);
393 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
394 ::DisposeGWorld(MAC_offscreen_graphics_port);
396 //UTIL_Warning("Unable to export screenshot.");
400 ::CloseComponent(QT_exporter);
401 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
402 ::DisposeGWorld(MAC_offscreen_graphics_port);
409 void Game::SetUpLighting(){
410 if(environment==snowyenvironment){
416 light.ambient[2]=.44;
418 if(environment==desertenvironment){
423 light.ambient[1]=.35;
427 if(environment==grassyenvironment){
433 light.ambient[2]=.44;
444 average=(skyboxlightr+skyboxlightg+skyboxlightb)/3;
445 light.color[0]*=(skyboxlightr+average)/2;
446 light.color[1]*=(skyboxlightg+average)/2;
447 light.color[2]*=(skyboxlightb+average)/2;
448 light.ambient[0]=light.ambient[0]*(skyboxlightr+average)/2*1;
449 light.ambient[1]=light.ambient[1]*(skyboxlightg+average)/2*1;
450 light.ambient[2]=light.ambient[2]*(skyboxlightb+average)/2*1;
454 light.ambient[2]=0; */
457 int Game::findPathDist(int start,int end){
458 int i,j,k,smallestcount,count,connected;
459 int last,last2,last3,last4;
469 while(last!=end&&count<30){
471 for(j=0;j<numpathpoints;j++){
472 if(j!=last&&j!=last2&&j!=last3&&j!=last4)
475 if(numpathpointconnect[j])
476 for(k=0;k<numpathpointconnect[j];k++){
477 if(pathpointconnect[j][k]==last)connected=1;
480 if(numpathpointconnect[last])
481 for(k=0;k<numpathpointconnect[last];k++){
482 if(pathpointconnect[last][k]==j)connected=1;
485 if(closest==-1||Random()%2==0){
496 if(count<smallestcount)smallestcount=count;
498 return smallestcount;
501 int Game::checkcollide(XYZ startpoint,XYZ endpoint){
502 static XYZ colpoint,colviewer,coltarget;
503 static float minx,minz,maxx,maxz,miny,maxy;
512 if(minx>endpoint.x)minx=endpoint.x;
514 if(miny>endpoint.y)miny=endpoint.y;
516 if(minz>endpoint.z)minz=endpoint.z;
519 if(maxx<endpoint.x)maxx=endpoint.x;
521 if(maxy<endpoint.y)maxy=endpoint.y;
523 if(maxz<endpoint.z)maxz=endpoint.z;
532 for(i=0;i<objects.numobjects;i++){
533 if(objects.position[i].x>minx-objects.model[i].boundingsphereradius&&objects.position[i].x<maxx+objects.model[i].boundingsphereradius&&objects.position[i].y>miny-objects.model[i].boundingsphereradius&&objects.position[i].y<maxy+objects.model[i].boundingsphereradius&&objects.position[i].z>minz-objects.model[i].boundingsphereradius&&objects.position[i].z<maxz+objects.model[i].boundingsphereradius){
534 if(objects.type[i]!=treeleavestype&&objects.type[i]!=bushtype&&objects.type[i]!=firetype){
535 colviewer=startpoint;
537 if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)return i;
542 //if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)return 1000;
547 int Game::checkcollide(XYZ startpoint,XYZ endpoint,int what){
548 static XYZ colpoint,colviewer,coltarget;
549 static float minx,minz,maxx,maxz,miny,maxy;
558 if(minx>endpoint.x)minx=endpoint.x;
560 if(miny>endpoint.y)miny=endpoint.y;
562 if(minz>endpoint.z)minz=endpoint.z;
565 if(maxx<endpoint.x)maxx=endpoint.x;
567 if(maxy<endpoint.y)maxy=endpoint.y;
569 if(maxz<endpoint.z)maxz=endpoint.z;
579 if(objects.position[what].x>minx-objects.model[what].boundingsphereradius&&objects.position[what].x<maxx+objects.model[what].boundingsphereradius&&objects.position[what].y>miny-objects.model[what].boundingsphereradius&&objects.position[what].y<maxy+objects.model[what].boundingsphereradius&&objects.position[what].z>minz-objects.model[what].boundingsphereradius&&objects.position[what].z<maxz+objects.model[what].boundingsphereradius){
580 if(objects.type[what]!=treeleavestype&&objects.type[what]!=bushtype&&objects.type[what]!=firetype){
581 colviewer=startpoint;
583 if(objects.model[what].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[what],&objects.rotation[what])!=-1)return i;
588 if(what==1000)if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)return 1000;
593 void Game::Setenvironment(int which)
597 LOG(" Setting environment...");
602 FSOUND_SetPaused(channels[music1snow], TRUE);
603 FSOUND_SetPaused(channels[music1grass], TRUE);
604 FSOUND_SetPaused(channels[music1desert], TRUE);
605 FSOUND_SetPaused(channels[wind], TRUE);
606 FSOUND_SetPaused(channels[desertambient], TRUE);
608 FSOUND_SetPaused(channels[stream_music1snow], TRUE);
609 FSOUND_SetPaused(channels[stream_music1grass], TRUE);
610 FSOUND_SetPaused(channels[stream_music1desert], TRUE);
611 FSOUND_SetPaused(channels[stream_wind], TRUE);
612 FSOUND_SetPaused(channels[stream_desertambient], TRUE);
615 if(environment==snowyenvironment){
619 //PlaySoundEx( wind, samp[wind], NULL, TRUE);
620 PlayStreamEx(stream_wind, strm[stream_wind], 0, TRUE);
621 FSOUND_SetPaused(channels[stream_wind], FALSE);
622 FSOUND_SetVolume(channels[stream_wind], 256);
625 LoadTexture(":Data:Textures:snowtree.png",&objects.treetextureptr,0,1);
626 LoadTexture(":Data:Textures:bushsnow.png",&objects.bushtextureptr,0,1);
627 LoadTexture(":Data:Textures:bouldersnow.jpg",&objects.rocktextureptr,1,0);
628 LoadTexture(":Data:Textures:snowbox.jpg",&objects.boxtextureptr,1,0);
630 FSOUND_Sample_Free(samp[footstepsound]);
631 FSOUND_Sample_Free(samp[footstepsound2]);
632 FSOUND_Sample_Free(samp[footstepsound3]);
633 FSOUND_Sample_Free(samp[footstepsound4]);
634 samp[footstepsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow1.ogg", FSOUND_HW3D, 0, 0);
635 samp[footstepsound2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow2.ogg", FSOUND_HW3D, 0, 0);
636 samp[footstepsound3] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone1.ogg", FSOUND_HW3D, 0, 0);
637 samp[footstepsound4] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone2.ogg", FSOUND_HW3D, 0, 0);
638 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
639 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
640 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
641 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
643 LoadTexture(":Data:Textures:snow.jpg",&terraintexture,1,0);
645 LoadTexture(":Data:Textures:rock.jpg",&terraintexture2,1,0);
647 //LoadTexture(":Data:Textures:detailgrain.png",&terraintexture3,1);
652 temptexdetail=texdetail;
653 if(texdetail>1)texdetail=4;
654 skybox.load( ":Data:Textures:Skybox(snow):Front.jpg",
655 ":Data:Textures:Skybox(snow):Left.jpg",
656 ":Data:Textures:Skybox(snow):Back.jpg",
657 ":Data:Textures:Skybox(snow):Right.jpg",
658 ":Data:Textures:Skybox(snow):Up.jpg",
659 ":Data:Textures:Skybox(snow):Down.jpg",
660 ":Data:Textures:Skybox(snow):Cloud.jpg",
661 ":Data:Textures:Skybox(snow):Reflect.jpg");
666 texdetail=temptexdetail;
668 if(environment==desertenvironment){
671 LoadTexture(":Data:Textures:deserttree.png",&objects.treetextureptr,0,1);
672 LoadTexture(":Data:Textures:bushdesert.png",&objects.bushtextureptr,0,1);
673 LoadTexture(":Data:Textures:boulderdesert.jpg",&objects.rocktextureptr,1,0);
674 LoadTexture(":Data:Textures:desertbox.jpg",&objects.boxtextureptr,1,0);
678 //PlaySoundEx( desertambient, samp[desertambient], NULL, TRUE);
679 PlayStreamEx( stream_desertambient, strm[stream_desertambient], NULL, TRUE);
680 FSOUND_SetPaused(channels[stream_desertambient], FALSE);
681 FSOUND_SetVolume(channels[stream_desertambient], 256);
684 FSOUND_Sample_Free(samp[footstepsound]);
685 FSOUND_Sample_Free(samp[footstepsound2]);
686 FSOUND_Sample_Free(samp[footstepsound3]);
687 FSOUND_Sample_Free(samp[footstepsound4]);
688 samp[footstepsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow1.ogg", FSOUND_HW3D, 0, 0);
689 samp[footstepsound2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow2.ogg", FSOUND_HW3D, 0, 0);
690 samp[footstepsound3] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow1.ogg", FSOUND_HW3D, 0, 0);
691 samp[footstepsound4] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow2.ogg", FSOUND_HW3D, 0, 0);
692 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
693 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
694 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
695 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
697 LoadTexture(":Data:Textures:sand.jpg",&terraintexture,1,0);
699 LoadTexture(":Data:Textures:sandslope.jpg",&terraintexture2,1,0);
701 //LoadTexture(":Data:Textures:detailgrain.png",&terraintexture3,1);
705 temptexdetail=texdetail;
706 if(texdetail>1)texdetail=4;
707 skybox.load( ":Data:Textures:Skybox(sand):Front.jpg",
708 ":Data:Textures:Skybox(sand):Left.jpg",
709 ":Data:Textures:Skybox(sand):Back.jpg",
710 ":Data:Textures:Skybox(sand):Right.jpg",
711 ":Data:Textures:Skybox(sand):Up.jpg",
712 ":Data:Textures:Skybox(sand):Down.jpg",
713 ":Data:Textures:Skybox(sand):Cloud.jpg",
714 ":Data:Textures:Skybox(sand):Reflect.jpg");
719 texdetail=temptexdetail;
721 if(environment==grassyenvironment){
724 LoadTexture(":Data:Textures:tree.png",&objects.treetextureptr,0,1);
725 LoadTexture(":Data:Textures:bush.png",&objects.bushtextureptr,0,1);
726 LoadTexture(":Data:Textures:boulder.jpg",&objects.rocktextureptr,1,0);
727 LoadTexture(":Data:Textures:grassbox.jpg",&objects.boxtextureptr,1,0);
730 PlayStreamEx( stream_wind, strm[stream_wind], NULL, TRUE);
731 FSOUND_SetPaused(channels[stream_wind], FALSE);
732 FSOUND_SetVolume(channels[stream_wind], 100);
735 FSOUND_Sample_Free(samp[footstepsound]);
736 FSOUND_Sample_Free(samp[footstepsound2]);
737 FSOUND_Sample_Free(samp[footstepsound3]);
738 FSOUND_Sample_Free(samp[footstepsound4]);
739 samp[footstepsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepgrass1.ogg", FSOUND_HW3D, 0, 0);
740 samp[footstepsound2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepgrass2.ogg", FSOUND_HW3D, 0, 0);
741 samp[footstepsound3] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone1.ogg", FSOUND_HW3D, 0, 0);
742 samp[footstepsound4] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone2.ogg", FSOUND_HW3D, 0, 0);
743 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
744 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
745 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
746 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
748 LoadTexture(":Data:Textures:grassdirt.jpg",&terraintexture,1,0);
750 LoadTexture(":Data:Textures:mossrock.jpg",&terraintexture2,1,0);
752 //LoadTexture(":Data:Textures:detail.png",&terraintexture3,1);
756 temptexdetail=texdetail;
757 if(texdetail>1)texdetail=4;
758 skybox.load( ":Data:Textures:Skybox(grass):Front.jpg",
759 ":Data:Textures:Skybox(grass):Left.jpg",
760 ":Data:Textures:Skybox(grass):Back.jpg",
761 ":Data:Textures:Skybox(grass):Right.jpg",
762 ":Data:Textures:Skybox(grass):Up.jpg",
763 ":Data:Textures:Skybox(grass):Down.jpg",
764 ":Data:Textures:Skybox(grass):Cloud.jpg",
765 ":Data:Textures:Skybox(grass):Reflect.jpg");
769 texdetail=temptexdetail;
771 temptexdetail=texdetail;
773 terrain.load(":Data:Textures:heightmap.png");
775 texdetail=temptexdetail;
779 void Game::Loadlevel(int which){
782 if(which==0)Loadlevel((char *)":Data:Maps:map1");
783 else if(which==1)Loadlevel((char *)":Data:Maps:map2");
784 else if(which==2)Loadlevel((char *)":Data:Maps:map3");
785 else if(which==3)Loadlevel((char *)":Data:Maps:map4");
786 else if(which==4)Loadlevel((char *)":Data:Maps:map5");
787 else if(which==5)Loadlevel((char *)":Data:Maps:map6");
788 else if(which==6)Loadlevel((char *)":Data:Maps:map7");
789 else if(which==7)Loadlevel((char *)":Data:Maps:map8");
790 else if(which==8)Loadlevel((char *)":Data:Maps:map9");
791 else if(which==9)Loadlevel((char *)":Data:Maps:map10");
792 else if(which==10)Loadlevel((char *)":Data:Maps:map11");
793 else if(which==11)Loadlevel((char *)":Data:Maps:map12");
794 else if(which==12)Loadlevel((char *)":Data:Maps:map13");
795 else if(which==13)Loadlevel((char *)":Data:Maps:map14");
796 else if(which==14)Loadlevel((char *)":Data:Maps:map15");
797 else if(which==15)Loadlevel((char *)":Data:Maps:map16");
798 else if(which==-1){tutoriallevel=-1;Loadlevel((char *)":Data:Maps:tutorial");}
799 else Loadlevel((char *)":Data:Maps:mapsave");
804 /*char * Game::MD5_string (unsigned char *string){
808 strcpy(temp2,(const char *)string);
809 strcat((char *)temp2,(const char *)"Lugaru");
810 sprintf (temp, "%d",strlen((char *)temp2));
811 strcat((char *)temp2,temp);
814 unsigned int len = strlen ( (char *)temp2);
816 context.update ((unsigned char *)temp2, len);
819 return context.hex_digest();
824 void Game::Loadlevel(char *name){
831 float headprop,legprop,armprop,bodyprop;
835 LOG(std::string("Loading level...") + name);
837 if(!gameon)visibleloading=1;
839 if(stealthloading)visibleloading=0;
841 if(!stillloading)loadtime=0;
846 if(tutoriallevel!=-1)tutoriallevel=0;
847 else tutoriallevel=1;
849 if(tutoriallevel==1)tutorialstage=0;
850 if(tutorialstage==0){
858 FSOUND_SetPaused(channels[whooshsound], TRUE);
859 FSOUND_SetPaused(channels[stream_firesound], TRUE);
863 tfile=fopen( name, "rb" );
866 FSOUND_SetPaused(channels[stream_firesound], TRUE);
877 animation[bounceidleanim].Load((char *)":Data:Animations:Idle",middleheight,neutral);
883 dialoguegonethrough[i]=0;
892 if(accountactive!=-1)difficulty=accountdifficulty[accountactive];
894 if(difficulty!=2)minimap=1;
931 bonustotal=startbonustotal;
937 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
938 FSOUND_SetVolume(channels[consolesuccesssound], 256);
939 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
947 sprites.numsprites=0;
948 for(i=0;i<objects.numobjects;i++)
950 objects.model[i].numdecals=0;
953 j=objects.numobjects;
956 objects.DeleteObject(0);
957 if(visibleloading){loadscreencolor=4; LoadingScreen();}
960 for(i=0;i<subdivision;i++)
962 for(j=0;j<subdivision;j++)
964 terrain.patchobjectnum[i][j]=0;
967 if(visibleloading){loadscreencolor=4; LoadingScreen();}
970 weapons.numweapons=0;
972 funpackf(tfile, "Bi", &mapvers);
973 if(mapvers>=15)funpackf(tfile, "Bi", &indemo);
975 if(mapvers>=5)funpackf(tfile, "Bi", &maptype);
976 else maptype=mapkilleveryone;
977 if(mapvers>=6)funpackf(tfile, "Bi", &hostile);
979 if(mapvers>=4)funpackf(tfile, "Bf Bf", &viewdistance, &fadestart);
985 if(mapvers>=2)funpackf(tfile, "Bb Bf Bf Bf", &skyboxtexture, &skyboxr, &skyboxg, &skyboxb);
993 if(mapvers>=10)funpackf(tfile, "Bf Bf Bf", &skyboxlightr, &skyboxlightg, &skyboxlightb);
996 skyboxlightr=skyboxr;
997 skyboxlightg=skyboxg;
998 skyboxlightb=skyboxb;
1000 if(!stealthloading)funpackf(tfile, "Bf Bf Bf Bf Bf Bi", &player[0].coords.x,&player[0].coords.y,&player[0].coords.z,&player[0].rotation,&player[0].targetrotation, &player[0].num_weapons);
1001 if(stealthloading)funpackf(tfile, "Bf Bf Bf Bf Bf Bi", &lamefloat,&lamefloat,&lamefloat,&lamefloat,&lamefloat, &player[0].num_weapons);
1002 player[0].originalcoords=player[0].coords;
1003 if(player[0].num_weapons>0&&player[0].num_weapons<5)
1005 for(j=0;j<player[0].num_weapons;j++)
1007 player[0].weaponids[j]=weapons.numweapons;
1008 funpackf(tfile, "Bi", &weapons.type[weapons.numweapons]);
1009 weapons.owner[weapons.numweapons]=0;
1010 weapons.numweapons++;
1014 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1016 funpackf(tfile, "Bf Bf Bf", &player[0].armorhead, &player[0].armorhigh, &player[0].armorlow);
1017 funpackf(tfile, "Bf Bf Bf", &player[0].protectionhead, &player[0].protectionhigh, &player[0].protectionlow);
1018 funpackf(tfile, "Bf Bf Bf", &player[0].metalhead, &player[0].metalhigh, &player[0].metallow);
1019 funpackf(tfile, "Bf Bf", &player[0].power, &player[0].speedmult);
1021 funpackf(tfile, "Bi", &player[0].numclothes);
1025 funpackf(tfile, "Bi Bi", &player[0].whichskin, &player[0].creature);
1029 player[0].whichskin=0;
1030 player[0].creature=rabbittype;
1033 for(i=0;i<max_dialogues;i++)
1035 for(j=0;j<max_dialoguelength;j++)
1039 dialoguetext[i][j][k]='\0';
1043 dialoguename[i][j][k]='\0';
1048 player[0].lastattack=-1;
1049 player[0].lastattack2=-1;
1050 player[0].lastattack3=-1;
1054 funpackf(tfile, "Bi", &numdialogues);
1057 for(k=0;k<numdialogues;k++)
1059 funpackf(tfile, "Bi", &numdialogueboxes[k]);
1060 funpackf(tfile, "Bi", &dialoguetype[k]);
1063 funpackf(tfile, "Bf Bf Bf", &participantlocation[k][l].x, &participantlocation[k][l].y, &participantlocation[k][l].z);
1064 funpackf(tfile, "Bf", &participantrotation[k][l]);
1066 if(numdialogueboxes)
1068 for(l=0;l<numdialogueboxes[k];l++)
1070 funpackf(tfile, "Bi", &dialogueboxlocation[k][l]);
1071 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][0]);
1072 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][1]);
1073 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][2]);
1074 funpackf(tfile, "Bi", &dialogueboxsound[k][l]);
1078 funpackf(tfile, "Bi",&templength);
1079 if(templength>128||templength<=0)templength=128;
1080 for(m=0;m<templength;m++){
1081 funpackf(tfile, "Bb", &dialoguetext[k][l][m]);
1082 if(dialoguetext[k][l][m]=='\0')break;
1085 funpackf(tfile, "Bi",&templength);
1086 if(templength>64||templength<=0)templength=64;
1087 for(m=0;m<templength;m++){
1088 funpackf(tfile, "Bb", &dialoguename[k][l][m]);
1089 if(dialoguename[k][l][m]=='\0'){
1093 funpackf(tfile, "Bf Bf Bf", &dialoguecamera[k][l].x, &dialoguecamera[k][l].y, &dialoguecamera[k][l].z);
1094 funpackf(tfile, "Bi", &participantfocus[k][l]);
1095 funpackf(tfile, "Bi", &participantaction[k][l]);
1098 funpackf(tfile, "Bf Bf Bf", &participantfacing[k][l][m].x, &participantfacing[k][l][m].y, &participantfacing[k][l][m].z);
1100 funpackf(tfile, "Bf Bf",&dialoguecamerarotation[k][l],&dialoguecamerarotation2[k][l]);
1106 else numdialogues=0;
1108 if(player[0].numclothes)
1110 for(k=0;k<player[0].numclothes;k++)
1112 funpackf(tfile, "Bi", &templength);
1113 for(l=0;l<templength;l++)
1114 funpackf(tfile, "Bb", &player[0].clothes[k][l]);
1115 player[0].clothes[k][templength]='\0';
1116 funpackf(tfile, "Bf Bf Bf", &player[0].clothestintr[k], &player[0].clothestintg[k], &player[0].clothestintb[k]);
1120 funpackf(tfile, "Bi", &environment);
1122 funpackf(tfile, "Bi", &objects.numobjects);
1123 if(objects.numobjects)
1125 for(i=0;i<objects.numobjects;i++)
1127 funpackf(tfile, "Bi Bf Bf Bf Bf Bf Bf", &objects.type[i],&objects.rotation[i],&objects.rotation2[i], &objects.position[i].x, &objects.position[i].y, &objects.position[i].z,&objects.scale[i]);
1128 if(objects.type[i]==treeleavestype)objects.scale[i]=objects.scale[i-1];
1134 funpackf(tfile, "Bi", &numhotspots);
1137 for(i=0;i<numhotspots;i++)
1139 funpackf(tfile, "Bi Bf Bf Bf Bf", &hotspottype[i],&hotspotsize[i],&hotspot[i].x,&hotspot[i].y,&hotspot[i].z);
1140 funpackf(tfile, "Bi", &templength);
1142 for(l=0;l<templength;l++)
1143 funpackf(tfile, "Bb", &hotspottext[i][l]);
1144 hotspottext[i][templength]='\0';
1145 if(hotspottype[i]==-111)indemo=1;
1151 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1156 for(i=0;i<objects.numobjects;i++)
1158 objects.center+=objects.position[i];
1160 objects.center/=objects.numobjects;
1163 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1165 float maxdistance=0;
1168 for(i=0;i<objects.numobjects;i++)
1170 tempdist=findDistancefast(&objects.center,&objects.position[i]);
1171 if(tempdist>maxdistance)
1174 maxdistance=tempdist;
1177 objects.radius=fast_sqrt(maxdistance);
1180 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1181 //mapcenter=objects.center;
1182 //mapradius=objects.radius;
1184 funpackf(tfile, "Bi", &numplayers);
1185 int howmanyremoved=0;
1186 bool removeanother=0;
1187 if(numplayers>1&&numplayers<maxplayers)
1189 for(i=1;i<numplayers;i++)
1191 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1194 funpackf(tfile, "Bi Bi Bf Bf Bf Bi",&player[i-howmanyremoved].whichskin,&player[i-howmanyremoved].creature, &player[i-howmanyremoved].coords.x,&player[i-howmanyremoved].coords.y,&player[i-howmanyremoved].coords.z,&player[i-howmanyremoved].num_weapons);
1195 if(mapvers>=5)funpackf(tfile, "Bi", &player[i-howmanyremoved].howactive);
1196 else player[i-howmanyremoved].howactive=typeactive;
1197 if(mapvers>=3)funpackf(tfile, "Bf",&player[i-howmanyremoved].scale);
1198 else player[i-howmanyremoved].scale=-1;
1199 if(mapvers>=11)funpackf(tfile, "Bb",&player[i-howmanyremoved].immobile);
1200 else player[i-howmanyremoved].immobile=0;
1201 if(mapvers>=12)funpackf(tfile, "Bf",&player[i-howmanyremoved].rotation);
1202 else player[i-howmanyremoved].rotation=0;
1203 player[i-howmanyremoved].targetrotation=player[i-howmanyremoved].rotation;
1204 if(player[i-howmanyremoved].num_weapons<0||player[i-howmanyremoved].num_weapons>5){
1210 if(player[i-howmanyremoved].num_weapons>0&&player[i-howmanyremoved].num_weapons<5)
1212 for(j=0;j<player[i-howmanyremoved].num_weapons;j++)
1214 player[i-howmanyremoved].weaponids[j]=weapons.numweapons;
1215 funpackf(tfile, "Bi", &weapons.type[player[i-howmanyremoved].weaponids[j]]);
1216 weapons.owner[player[i-howmanyremoved].weaponids[j]]=i;
1217 weapons.numweapons++;
1220 funpackf(tfile, "Bi", &player[i-howmanyremoved].numwaypoints);
1221 //player[i-howmanyremoved].numwaypoints=10;
1222 for(j=0;j<player[i-howmanyremoved].numwaypoints;j++)
1224 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].x);
1225 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].y);
1226 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].z);
1227 if(mapvers>=5)funpackf(tfile, "Bi", &player[i-howmanyremoved].waypointtype[j]);
1228 else player[i-howmanyremoved].waypointtype[j] = wpkeepwalking;
1231 funpackf(tfile, "Bi", &player[i-howmanyremoved].waypoint);
1232 if(player[i-howmanyremoved].waypoint>player[i-howmanyremoved].numwaypoints-1)player[i-howmanyremoved].waypoint=0;
1234 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].armorhead, &player[i-howmanyremoved].armorhigh, &player[i-howmanyremoved].armorlow);
1235 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].protectionhead, &player[i-howmanyremoved].protectionhigh, &player[i-howmanyremoved].protectionlow);
1236 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].metalhead, &player[i-howmanyremoved].metalhigh, &player[i-howmanyremoved].metallow);
1237 funpackf(tfile, "Bf Bf", &player[i-howmanyremoved].power, &player[i-howmanyremoved].speedmult);
1239 if(mapvers>=4)funpackf(tfile, "Bf Bf Bf Bf", &headprop, &bodyprop, &armprop, &legprop);
1247 if(player[i-howmanyremoved].creature==wolftype)
1249 player[i-howmanyremoved].proportionhead=1.1*headprop;
1250 player[i-howmanyremoved].proportionbody=1.1*bodyprop;
1251 player[i-howmanyremoved].proportionarms=1.1*armprop;
1252 player[i-howmanyremoved].proportionlegs=1.1*legprop;
1255 if(player[i-howmanyremoved].creature==rabbittype)
1257 player[i-howmanyremoved].proportionhead=1.2*headprop;
1258 player[i-howmanyremoved].proportionbody=1.05*bodyprop;
1259 player[i-howmanyremoved].proportionarms=1.00*armprop;
1260 player[i-howmanyremoved].proportionlegs=1.1*legprop;
1261 player[i-howmanyremoved].proportionlegs.y=1.05*legprop;
1264 funpackf(tfile, "Bi", &player[i-howmanyremoved].numclothes);
1265 if(player[i-howmanyremoved].numclothes)
1267 for(k=0;k<player[i-howmanyremoved].numclothes;k++)
1270 funpackf(tfile, "Bi", &templength);
1271 for(l=0;l<templength;l++)
1272 funpackf(tfile, "Bb", &player[i-howmanyremoved].clothes[k][l]);
1273 player[i-howmanyremoved].clothes[k][templength]='\0';
1274 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].clothestintr[k], &player[i-howmanyremoved].clothestintg[k], &player[i-howmanyremoved].clothestintb[k]);
1280 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1282 numplayers-=howmanyremoved;
1283 funpackf(tfile, "Bi", &numpathpoints);
1284 if(numpathpoints>30||numpathpoints<0)
1288 for(j=0;j<numpathpoints;j++)
1290 funpackf(tfile, "Bf Bf Bf Bi", &pathpoint[j].x,&pathpoint[j].y,&pathpoint[j].z,&numpathpointconnect[j]);
1291 for(k=0;k<numpathpointconnect[j];k++){
1292 funpackf(tfile, "Bi", &pathpointconnect[j][k]);
1296 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1298 funpackf(tfile, "Bf Bf Bf Bf", &mapcenter.x,&mapcenter.y,&mapcenter.z,&mapradius);
1301 if(environment!=oldenvironment)Setenvironment(environment);
1302 oldenvironment=environment;
1306 j=objects.numobjects;
1307 objects.numobjects=0;
1310 //if(objects.type[i]!=spiketype)
1311 objects.MakeObject(objects.type[i],objects.position[i],objects.rotation[i],objects.rotation2[i],objects.scale[i]);
1312 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1315 //if(skyboxtexture){
1316 terrain.DoShadows();
1317 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1318 objects.DoShadows();
1319 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1321 else terrain.DoLighting();
1327 oldlevel=whichlevel;
1330 if(numplayers>maxplayers-1)numplayers=maxplayers-1;
1331 for(i=0;i<numplayers;i++)
1333 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1337 if(i==0||player[i].scale<0)player[i].scale=.2;
1338 player[i].skeleton.free=0;
1339 player[i].skeleton.id=i;
1340 //if(Random()%2==0)player[i].creature=wolftype;
1341 //else player[i].creature=rabbittype;
1342 if(i==0&&mapvers<9)player[i].creature=rabbittype;
1343 if(player[i].creature!=wolftype)player[i].skeleton.Load((char *)":Data:Skeleton:Basic Figure",(char *)":Data:Skeleton:Basic Figurelow",(char *)":Data:Skeleton:Rabbitbelt",(char *)":Data:Models:Body.solid",(char *)":Data:Models:Body2.solid",(char *)":Data:Models:Body3.solid",(char *)":Data:Models:Body4.solid",(char *)":Data:Models:Body5.solid",(char *)":Data:Models:Body6.solid",(char *)":Data:Models:Body7.solid",(char *)":Data:Models:Bodylow.solid",(char *)":Data:Models:Belt.solid",0);
1346 if(player[i].creature!=wolftype){
1347 player[i].skeleton.Load((char *)":Data:Skeleton:Basic Figure",(char *)":Data:Skeleton:Basic Figurelow",(char *)":Data:Skeleton:Rabbitbelt",(char *)":Data:Models:Body.solid",(char *)":Data:Models:Body2.solid",(char *)":Data:Models:Body3.solid",(char *)":Data:Models:Body4.solid",(char *)":Data:Models:Body5.solid",(char *)":Data:Models:Body6.solid",(char *)":Data:Models:Body7.solid",(char *)":Data:Models:Bodylow.solid",(char *)":Data:Models:Belt.solid",1);
1348 LoadTexture(":Data:Textures:Belt.png",&player[i].skeleton.drawmodelclothes.textureptr,1,1);
1350 if(player[i].creature==wolftype){
1351 player[i].skeleton.Load((char *)":Data:Skeleton:Basic Figure Wolf",(char *)":Data:Skeleton:Basic Figure Wolf Low",(char *)":Data:Skeleton:Rabbitbelt",(char *)":Data:Models:Wolf.solid",(char *)":Data:Models:Wolf2.solid",(char *)":Data:Models:Wolf3.solid",(char *)":Data:Models:Wolf4.solid",(char *)":Data:Models:Wolf5.solid",(char *)":Data:Models:Wolf6.solid",(char *)":Data:Models:Wolf7.solid",(char *)":Data:Models:Wolflow.solid",(char *)":Data:Models:Belt.solid",0);
1357 texsize=512*512*3/texdetail/texdetail;
1358 //if(!player[i].loaded)player[i].skeleton.skinText = new GLubyte[texsize];
1359 //player[i].skeleton.skinText.resize(texsize);
1361 if(player[i].creature==rabbittype)
1363 if(player[i].whichskin==0){
1364 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1366 else if(player[i].whichskin==1){
1367 LoadTextureSave(":Data:Textures:Fur.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1369 else if(player[i].whichskin==2){
1370 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1372 else if(player[i].whichskin==3){
1373 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1375 else if(player[i].whichskin==4){
1376 LoadTextureSave(":Data:Textures:Otter.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1378 else if(player[i].whichskin==5){
1379 LoadTextureSave(":Data:Textures:Opal.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1381 else if(player[i].whichskin==6){
1382 LoadTextureSave(":Data:Textures:Sable.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1384 else if(player[i].whichskin==7){
1385 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1387 else if(player[i].whichskin==8){
1388 LoadTextureSave(":Data:Textures:BW2.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1390 else if(player[i].whichskin==9){
1391 LoadTextureSave(":Data:Textures:WB2.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1394 if(player[i].creature==wolftype)
1396 //k=abs(Random()%3);
1397 if(player[i].whichskin==0){
1398 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1400 else if(player[i].whichskin==1){
1401 LoadTextureSave(":Data:Textures:Darkwolf.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1403 else if(player[i].whichskin==2){
1404 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1408 if(player[i].numclothes)
1410 for(j=0;j<player[i].numclothes;j++)
1412 tintr=player[i].clothestintr[j];
1413 tintg=player[i].clothestintg[j];
1414 tintb=player[i].clothestintb[j];
1415 AddClothes((char *)player[i].clothes[j],0,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1417 player[i].DoMipmaps(5,0,0,player[i].skeleton.skinsize,player[i].skeleton.skinsize);
1420 player[i].currentanimation=bounceidleanim;
1421 player[i].targetanimation=bounceidleanim;
1422 player[i].currentframe=0;
1423 player[i].targetframe=1;
1425 player[i].speed=1+(float)(Random()%100)/1000;
1426 if(difficulty==0)player[i].speed-=.2;
1427 if(difficulty==1)player[i].speed-=.1;
1429 player[i].velocity=0;
1430 player[i].oldcoords=player[i].coords;
1431 player[i].realoldcoords=player[i].coords;
1434 player[i].skeleton.id=i;
1435 player[i].updatedelay=0;
1436 player[i].normalsupdatedelay=0;
1438 player[i].aitype=passivetype;
1439 player[i].aitarget=0;
1440 player[i].madskills=0;
1444 player[i].proportionhead=1.2;
1445 player[i].proportionbody=1.05;
1446 player[i].proportionarms=1.00;
1447 player[i].proportionlegs=1.1;
1448 player[i].proportionlegs.y=1.05;
1450 player[i].headless=0;
1451 player[i].currentoffset=0;
1452 player[i].targetoffset=0;
1453 /*player[i].armorhead=1;
1454 player[i].armorhigh=1;
1455 player[i].armorlow=1;
1456 player[i].protectionhead=1;
1457 player[i].protectionhigh=1;
1458 player[i].protectionlow=1;
1459 player[i].metalhead=1;
1460 player[i].metalhigh=1;
1461 player[i].metallow=1;
1463 player[i].speedmult=1;*/
1465 player[i].damagetolerance=200;
1467 if(player[i].creature==wolftype)
1469 /*player[i].proportionhead=1.1;
1470 player[i].proportionbody=1.1;
1471 player[i].proportionarms=1.1;
1472 player[i].proportionlegs=1.1;
1473 player[i].proportionlegs.y=1.1;*/
1474 if(i==0||player[i].scale<0)player[i].scale=.23;
1476 player[i].damagetolerance=300;
1479 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1482 player[i].proportionhead.z=0;
1483 player[i].proportionbody.z=0;
1484 player[i].proportionarms.z=0;
1485 player[i].proportionlegs.z=0;
1488 player[i].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0);
1490 player[i].headmorphness=0;
1491 player[i].targetheadmorphness=1;
1492 player[i].headmorphstart=0;
1493 player[i].headmorphend=0;
1495 player[i].pausetime=0;
1498 player[i].jumppower=5;
1500 player[i].permanentdamage=0;
1501 player[i].superpermanentdamage=0;
1503 player[i].forwardkeydown=0;
1504 player[i].leftkeydown=0;
1505 player[i].backkeydown=0;
1506 player[i].rightkeydown=0;
1507 player[i].jumpkeydown=0;
1508 player[i].crouchkeydown=0;
1509 player[i].throwkeydown=0;
1511 player[i].collided=-10;
1513 player[i].bloodloss=0;
1514 player[i].weaponactive=-1;
1515 player[i].weaponstuck=-1;
1516 player[i].bleeding=0;
1517 player[i].deathbleeding=0;
1518 player[i].stunned=0;
1519 player[i].hasvictim=0;
1520 player[i].wentforweapon=0;
1523 player[0].aitype=playercontrolled;
1524 player[0].weaponactive=-1;
1528 //player[0].speedmult=1/.9;
1529 player[0].power=1/.9;
1534 //player[0].speedmult=1/.8;
1535 player[0].power=1/.8;
1538 //player[0].weaponstuck=1;
1540 if(difficulty==1)player[0].damagetolerance=250;
1541 if(difficulty==0)player[0].damagetolerance=300;
1542 if(difficulty==0)player[0].armorhead*=1.5;
1543 if(difficulty==0)player[0].armorhigh*=1.5;
1544 if(difficulty==0)player[0].armorlow*=1.5;
1545 cameraloc=player[0].coords;
1547 rotation=player[0].rotation;
1549 hawkcoords=player[0].coords;
1552 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1553 //weapons.numweapons=numplayers;
1554 for(i=0;i<weapons.numweapons;i++)
1556 weapons.bloody[i]=0;
1557 weapons.blooddrip[i]=0;
1558 weapons.blooddripdelay[i]=0;
1559 weapons.onfire[i]=0;
1560 weapons.flamedelay[i]=0;
1561 weapons.damage[i]=0;
1562 //weapons.type[i]=sword;
1563 if(weapons.type[i]==sword){
1564 weapons.mass[i]=1.5;
1565 weapons.tipmass[i]=1;
1566 weapons.length[i]=.8;
1568 if(weapons.type[i]==staff){
1570 weapons.tipmass[i]=1;
1571 weapons.length[i]=1.5;
1573 if(weapons.type[i]==knife){
1575 weapons.tipmass[i]=1.2;
1576 weapons.length[i]=.25;
1578 weapons.position[i]=-1000;
1579 weapons.tippoint[i]=-1000;
1582 /* for(i=0;i<32;i++){
1584 FSOUND_StopSound(i);
1587 LOG("Starting background music...");
1589 FSOUND_StopSound(FSOUND_ALL);
1590 if(environment==snowyenvironment)
1594 PlayStreamEx(stream_wind, strm[stream_wind], NULL, TRUE);
1595 FSOUND_SetPaused(channels[stream_wind], FALSE);
1596 FSOUND_SetVolume(channels[stream_wind], 256);
1599 else if(environment==desertenvironment)
1603 //PlaySoundEx(desertambient,
1604 // samp[desertambient], NULL, TRUE);
1605 PlayStreamEx(stream_desertambient,
1606 strm[stream_desertambient], NULL, TRUE);
1607 FSOUND_SetPaused(channels[stream_desertambient], FALSE);
1608 FSOUND_SetVolume(channels[stream_desertambient], 256);
1611 else if(environment==grassyenvironment)
1615 //PlaySoundEx(wind, samp[wind], NULL, TRUE);
1616 PlayStreamEx(stream_wind, strm[stream_wind], NULL, TRUE);
1617 FSOUND_SetPaused(channels[stream_wind], FALSE);
1618 FSOUND_SetVolume(channels[stream_wind], 100);
1621 oldmusicvolume[0]=0;
1622 oldmusicvolume[1]=0;
1623 oldmusicvolume[2]=0;
1624 oldmusicvolume[3]=0;
1627 /*LoadTexture(":Data:Textures:cloud.png",&sprites.cloudtexture,1,1);
1628 LoadTexture(":Data:Textures:cloudimpact.png",&sprites.cloudimpacttexture,1,1);
1629 LoadTexture(":Data:Textures:bloodparticle.png",&sprites.bloodtexture,1,1);
1630 LoadTexture(":Data:Textures:snowflake.png",&sprites.snowflaketexture,1,1);
1631 LoadTexture(":Data:Textures:flame.png",&sprites.flametexture,1,1);
1632 LoadTexture(":Data:Textures:bloodflame.png",&sprites.bloodflametexture,1,1);
1633 LoadTexture(":Data:Textures:smoke.png",&sprites.smoketexture,1,1);
1634 LoadTexture(":Data:Textures:shine.png",&sprites.shinetexture,1,0);
1649 static int i,k,j,l,m;
1650 static XYZ facing,flatfacing,absflatfacing;
1651 static XYZ rotatetarget;
1653 static float oldtargetrotation;
1654 static int target, numgood;
1655 static XYZ tempcoords1,tempcoords2;
1658 static XYZ lowpoint,lowpointtarget,lowpoint2,lowpointtarget2,lowpoint3,lowpointtarget3,lowpoint4,lowpointtarget4,lowpoint5,lowpointtarget5,lowpoint6,lowpointtarget6,lowpoint7,lowpointtarget7,colpoint,colpoint2;
1659 static int whichhit;
1660 static bool donesomething;
1661 static bool oldjumpkeydown;
1665 float headprop,bodyprop,armprop,legprop;
1669 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
1670 FSOUND_SetVolume(channels[consolesuccesssound], 256);
1671 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
1675 consoletext[k][j]=consoletext[k-1][j];
1677 consolechars[k]=consolechars[k-1];
1681 displaytext[k][j]=displaytext[k-1][j];
1683 displaychars[k]=displaychars[k-1];
1684 displaytime[k]=displaytime[k-1];
1687 consoletext[1][j]=' ';
1688 displaytext[1][j]=' ';
1690 sprintf (consoletext[1], netmessages);
1691 sprintf (displaytext[1], netmessages);
1692 consolechars[1]=255;
1693 displaychars[1]=255;
1698 displaytime[i]+=multiplier;
1701 static unsigned char theKeyMap[16];
1702 GetKeys( theKeyMap );
1707 static bool mainmenutogglekeydown;
1709 if(mainmenu&&endgame==1)mainmenu=10;
1710 if(IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)&&!mainmenutogglekeydown&&(mainmenu==7&&entername)){
1712 displaytext[0][j]=' ';
1717 mainmenutogglekeydown=1;
1719 if((IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)||(mainmenu==0&&((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY)||(campaign)))&&!oldjumpkeydown&&campaign&&winfreeze))&&!mainmenutogglekeydown&&(!mainmenu||gameon||mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||(mainmenu==7&&!entername)||mainmenu==9||mainmenu==11||(mainmenu==12&&!tryquit)||mainmenu==13||mainmenu==14||mainmenu==15||mainmenu==16||mainmenu==17||mainmenu==10)){
1721 if(mainmenu==1||mainmenu==2||mainmenu==0){
1722 if(mainmenu==0&&!winfreeze)mainmenu=2;
1723 else if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1)mainmenu=100;
1724 else if(mainmenu==0&&winfreeze){
1725 /* if(campaignchoosenext[campaignchoicewhich[whichchoice]]==2)
1727 else stealthloading=0;
1729 if(!stealthloading){
1730 float gLoc[3]={0,0,0};
1731 float vel[3]={0,0,0};
1732 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
1733 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
1734 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
1735 FSOUND_SetVolume(channels[firestartsound], 256);
1736 FSOUND_SetPaused(channels[firestartsound], FALSE);
1737 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
1748 for(i=0;i<campaignnumlevels;i++){
1750 levelhighlight[i]=0;
1755 if(accountcampaignchoicesmade[accountactive])
1756 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
1757 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
1758 levelvisible[levelorder[i+1]]=1;
1760 int whichlevelstart;
1761 whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
1762 if(whichlevelstart<0){
1763 campaignchoicenum=1;
1764 campaignchoicewhich[0]=0;
1768 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
1769 if(campaignchoicenum)
1770 for(i=0;i<campaignchoicenum;i++){
1771 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
1772 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
1773 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
1780 if(firstload)TickOnceAfter();
1781 if(!firstload)LoadStuff();
1798 //accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
1799 //accountcampaignchoicesmade[accountactive]++;
1802 strcat(mapname,campaignmapname[campaignchoicewhich[0]]);
1810 FSOUND_SetPaused(channels[music3], TRUE);
1814 else if(mainmenu==1||mainmenu==2)mainmenu=0;
1815 if(mainmenu&&musictoggle){
1816 if(mainmenu==1||mainmenu==2||mainmenu==100){
1817 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
1818 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
1819 FSOUND_SetPaused(channels[stream_music3], FALSE);
1820 FSOUND_SetVolume(channels[stream_music3], 256);
1821 FSOUND_SetPaused(channels[music1], TRUE);
1825 FSOUND_SetPaused(channels[stream_music3], TRUE);
1826 FSOUND_SetPaused(channels[music1], FALSE);
1830 float gLoc[3]={0,0,0};
1831 float vel[3]={0,0,0};
1832 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
1833 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
1834 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1835 FSOUND_SetVolume(channels[fireendsound], 256);
1836 FSOUND_SetPaused(channels[fireendsound], FALSE);
1837 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1845 if(newdetail>2)newdetail=detail;
1846 if(newdetail<0)newdetail=detail;
1847 if(newscreenwidth>3000)newscreenwidth=screenwidth;
1848 if(newscreenwidth<0)newscreenwidth=screenwidth;
1849 if(newscreenheight>3000)newscreenheight=screenheight;
1850 if(newscreenheight<0)newscreenheight=screenheight;
1852 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
1853 opstream << "Screenwidth:\n";
1854 opstream << newscreenwidth;
1855 opstream << "\nScreenheight:\n";
1856 opstream << newscreenheight;
1857 opstream << "\nMouse sensitivity:\n";
1858 opstream << usermousesensitivity;
1859 opstream << "\nBlur(0,1):\n";
1860 opstream << ismotionblur;
1861 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
1862 opstream << newdetail;
1863 opstream << "\nFloating jump:\n";
1864 opstream << floatjump;
1865 opstream << "\nMouse jump:\n";
1866 opstream << mousejump;
1867 opstream << "\nAmbient sound:\n";
1868 opstream << ambientsound;
1869 opstream << "\nBlood (0,1,2):\n";
1870 opstream << bloodtoggle;
1871 opstream << "\nAuto slomo:\n";
1872 opstream << autoslomo;
1873 opstream << "\nFoliage:\n";
1874 opstream << foliage;
1875 opstream << "\nMusic:\n";
1876 opstream << musictoggle;
1877 opstream << "\nTrilinear:\n";
1878 opstream << trilinear;
1879 opstream << "\nDecals(shadows,blood puddles,etc):\n";
1881 opstream << "\nInvert mouse:\n";
1882 opstream << invertmouse;
1883 opstream << "\nGamespeed:\n";
1884 if(oldgamespeed==0)oldgamespeed=1;
1885 opstream << oldgamespeed;
1886 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
1887 opstream << difficulty;
1888 opstream << "\nDamage effects(blackout, doublevision):\n";
1889 opstream << damageeffects;
1890 opstream << "\nText:\n";
1891 opstream << texttoggle;
1892 opstream << "\nDebug:\n";
1893 opstream << debugmode;
1894 opstream << "\nVBL Sync:\n";
1895 opstream << vblsync;
1896 opstream << "\nShow Points:\n";
1897 opstream << showpoints;
1898 opstream << "\nAlways Blur:\n";
1899 opstream << alwaysblur;
1900 opstream << "\nImmediate mode (turn on on G5):\n";
1901 opstream << immediate;
1902 opstream << "\nVelocity blur:\n";
1903 opstream << velocityblur;
1904 opstream << "\nVolume:\n";
1906 opstream << "\nForward key:\n";
1907 opstream << KeyToChar(forwardkey);
1908 opstream << "\nBack key:\n";
1909 opstream << KeyToChar(backkey);
1910 opstream << "\nLeft key:\n";
1911 opstream << KeyToChar(leftkey);
1912 opstream << "\nRight key:\n";
1913 opstream << KeyToChar(rightkey);
1914 opstream << "\nJump key:\n";
1915 opstream << KeyToChar(jumpkey);
1916 opstream << "\nCrouch key:\n";
1917 opstream << KeyToChar(crouchkey);
1918 opstream << "\nDraw key:\n";
1919 opstream << KeyToChar(drawkey);
1920 opstream << "\nThrow key:\n";
1921 opstream << KeyToChar(throwkey);
1922 opstream << "\nAttack key:\n";
1923 opstream << KeyToChar(attackkey);
1924 opstream << "\nChat key:\n";
1925 opstream << KeyToChar(chatkey);
1928 if(mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==9||mainmenu==12||mainmenu==13||mainmenu==14||mainmenu==10||mainmenu==11||mainmenu==100){
1929 float gLoc[3]={0,0,0};
1930 float vel[3]={0,0,0};
1931 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
1932 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
1933 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1934 FSOUND_SetVolume(channels[fireendsound], 256);
1935 FSOUND_SetPaused(channels[fireendsound], FALSE);
1936 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1944 if(mainmenu==3&&gameon)mainmenu=2;
1945 if(mainmenu==3&&!gameon)mainmenu=1;
1946 if(mainmenu==5&&gameon)mainmenu=2;
1947 if(mainmenu==5&&!gameon)mainmenu=1;
1948 if(mainmenu==4)mainmenu=3;
1949 if(mainmenu==6)mainmenu=5;
1950 if(mainmenu==7)mainmenu=1;
1951 if(mainmenu==9)mainmenu=5;
1952 if(mainmenu==11)mainmenu=5;
1953 if(mainmenu==12)mainmenu=5;
1954 if(mainmenu==13)mainmenu=12;
1955 if(mainmenu==14)mainmenu=13;
1956 if(mainmenu==10)mainmenu=5;
1962 mainmenutogglekeydown=1;
1964 if(!IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)){
1965 mainmenutogglekeydown=0;
1969 /*static bool minimaptogglekeydown;
1970 if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!minimaptogglekeydown){
1972 minimaptogglekeydown=1;
1974 if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)){
1975 minimaptogglekeydown=0;
1979 static bool minimaptogglekeydown;
1980 if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!minimaptogglekeydown&&tutoriallevel){
1981 if(tutorialstage!=51)
1982 tutorialstagetime=tutorialmaxtime;
1983 PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, TRUE);
1984 FSOUND_SetVolume(channels[consolefailsound], 128);
1985 FSOUND_SetPaused(channels[consolefailsound], FALSE);
1986 minimaptogglekeydown=1;
1988 if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)){
1989 minimaptogglekeydown=0;
1994 if(mainmenu==1||mainmenu==2){
1995 if(Button()&&!oldbutton&&selected==1){
1997 float gLoc[3]={0,0,0};
1998 float vel[3]={0,0,0};
1999 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2000 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2001 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2002 FSOUND_SetVolume(channels[firestartsound], 256);
2003 FSOUND_SetPaused(channels[firestartsound], FALSE);
2004 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2013 if(accountactive!=-1)mainmenu=5;
2020 if(firstload)TickOnceAfter();
2021 if(!firstload)LoadStuff();
2027 FSOUND_SetPaused(channels[music3], TRUE); */
2033 FSOUND_SetPaused(channels[stream_music3], TRUE);
2034 FSOUND_SetPaused(channels[music1], FALSE);
2038 if(Button()&&!oldbutton&&selected==2){
2039 float gLoc[3]={0,0,0};
2040 float vel[3]={0,0,0};
2041 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2042 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2043 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2044 FSOUND_SetVolume(channels[firestartsound], 256);
2045 FSOUND_SetPaused(channels[firestartsound], FALSE);
2046 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2058 if(newdetail>2)newdetail=detail;
2059 if(newdetail<0)newdetail=detail;
2060 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2061 if(newscreenwidth<0)newscreenwidth=screenwidth;
2062 if(newscreenheight>3000)newscreenheight=screenheight;
2063 if(newscreenheight<0)newscreenheight=screenheight;
2066 if(Button()&&!oldbutton&&selected==3){
2067 float gLoc[3]={0,0,0};
2068 float vel[3]={0,0,0};
2069 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2070 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2071 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2072 FSOUND_SetVolume(channels[fireendsound], 256);
2073 FSOUND_SetPaused(channels[fireendsound], FALSE);
2074 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2085 if(registered)FSOUND_SetPaused(channels[stream_music3], TRUE);
2093 if(Button())oldbutton=1;
2098 if(Button()&&!oldbutton&&selected!=-1){
2099 float gLoc[3]={0,0,0};
2100 float vel[3]={0,0,0};
2101 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2102 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2103 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2104 FSOUND_SetVolume(channels[firestartsound], 256);
2105 FSOUND_SetPaused(channels[firestartsound], FALSE);
2106 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2108 if(Button()&&!oldbutton&&selected==0){
2111 if(newscreenwidth==640&&newscreenheight==480)whichres=0;
2112 if(newscreenwidth==800&&newscreenheight==600)whichres=1;
2113 if(newscreenwidth==1024&&newscreenheight==768)whichres=2;
2114 if(newscreenwidth==1280&&newscreenheight==1024)whichres=3;
2115 if(newscreenwidth==1600&&newscreenheight==1200)whichres=4;
2116 if(newscreenwidth==840&&newscreenheight==524)whichres=5;
2117 if(newscreenwidth==1024&&newscreenheight==640)whichres=6;
2118 if(newscreenwidth==1344&&newscreenheight==840)whichres=7;
2119 if(newscreenwidth==1920&&newscreenheight==1200)whichres=8;
2121 if(whichres==-1||whichres==8){
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 newscreenwidth=1920;
2155 newscreenheight=1200;
2158 if(Button()&&!oldbutton&&selected==1){
2160 if(newdetail>2)newdetail=0;
2162 if(Button()&&!oldbutton&&selected==2){
2164 if(bloodtoggle>2)bloodtoggle=0;
2166 if(Button()&&!oldbutton&&selected==3){
2168 if(difficulty>2)difficulty=0;
2170 if(Button()&&!oldbutton&&selected==4){
2171 ismotionblur=1-ismotionblur;
2173 if(Button()&&!oldbutton&&selected==5){
2176 if(Button()&&!oldbutton&&selected==6){
2177 musictoggle=1-musictoggle;
2180 FSOUND_SetPaused(channels[music1], TRUE);
2181 FSOUND_SetPaused(channels[stream_music2], TRUE);
2182 FSOUND_SetPaused(channels[stream_music3], TRUE);
2185 oldmusicvolume[i]=0;
2191 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
2192 FSOUND_SetPaused(channels[stream_music3], FALSE);
2193 FSOUND_SetVolume(channels[stream_music3], 256);
2196 if(Button()&&!oldbutton&&selected==9){
2197 invertmouse=1-invertmouse;
2199 if(Button()&&!oldbutton&&selected==10){
2200 usermousesensitivity+=.2;
2201 if(usermousesensitivity>2)usermousesensitivity=.2;
2203 if(Button()&&!oldbutton&&selected==11){
2205 if(volume>1.0001f)volume=0;
2206 FSOUND_SetSFXMasterVolume((int)(volume*255));
2208 if(Button()&&!oldbutton&&selected==7){
2209 /*float gLoc[3]={0,0,0};
2210 float vel[3]={0,0,0};
2211 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2212 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2213 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2214 FSOUND_SetVolume(channels[firestartsound], 256);
2215 FSOUND_SetPaused(channels[firestartsound], FALSE);
2216 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2229 if(Button()&&!oldbutton&&selected==8){
2230 float gLoc[3]={0,0,0};
2231 float vel[3]={0,0,0};
2232 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2233 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2234 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2235 FSOUND_SetVolume(channels[fireendsound], 256);
2236 FSOUND_SetPaused(channels[fireendsound], FALSE);
2237 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2245 if(newdetail>2)newdetail=detail;
2246 if(newdetail<0)newdetail=detail;
2247 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2248 if(newscreenwidth<0)newscreenwidth=screenwidth;
2249 if(newscreenheight>3000)newscreenheight=screenheight;
2250 if(newscreenheight<0)newscreenheight=screenheight;
2253 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
2254 opstream << "Screenwidth:\n";
2255 opstream << newscreenwidth;
2256 opstream << "\nScreenheight:\n";
2257 opstream << newscreenheight;
2258 opstream << "\nMouse sensitivity:\n";
2259 opstream << usermousesensitivity;
2260 opstream << "\nBlur(0,1):\n";
2261 opstream << ismotionblur;
2262 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
2263 opstream << newdetail;
2264 opstream << "\nFloating jump:\n";
2265 opstream << floatjump;
2266 opstream << "\nMouse jump:\n";
2267 opstream << mousejump;
2268 opstream << "\nAmbient sound:\n";
2269 opstream << ambientsound;
2270 opstream << "\nBlood (0,1,2):\n";
2271 opstream << bloodtoggle;
2272 opstream << "\nAuto slomo:\n";
2273 opstream << autoslomo;
2274 opstream << "\nFoliage:\n";
2275 opstream << foliage;
2276 opstream << "\nMusic:\n";
2277 opstream << musictoggle;
2278 opstream << "\nTrilinear:\n";
2279 opstream << trilinear;
2280 opstream << "\nDecals(shadows,blood puddles,etc):\n";
2282 opstream << "\nInvert mouse:\n";
2283 opstream << invertmouse;
2284 opstream << "\nGamespeed:\n";
2285 if(oldgamespeed==0)oldgamespeed=1;
2286 opstream << oldgamespeed;
2287 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
2288 opstream << difficulty;
2289 opstream << "\nDamage effects(blackout, doublevision):\n";
2290 opstream << damageeffects;
2291 opstream << "\nText:\n";
2292 opstream << texttoggle;
2293 opstream << "\nDebug:\n";
2294 opstream << debugmode;
2295 opstream << "\nVBL Sync:\n";
2296 opstream << vblsync;
2297 opstream << "\nShow Points:\n";
2298 opstream << showpoints;
2299 opstream << "\nAlways Blur:\n";
2300 opstream << alwaysblur;
2301 opstream << "\nImmediate mode (turn on on G5):\n";
2302 opstream << immediate;
2303 opstream << "\nVelocity blur:\n";
2304 opstream << velocityblur;
2305 opstream << "\nVolume:\n";
2307 opstream << "\nForward key:\n";
2308 opstream << KeyToChar(forwardkey);
2309 opstream << "\nBack key:\n";
2310 opstream << KeyToChar(backkey);
2311 opstream << "\nLeft key:\n";
2312 opstream << KeyToChar(leftkey);
2313 opstream << "\nRight key:\n";
2314 opstream << KeyToChar(rightkey);
2315 opstream << "\nJump key:\n";
2316 opstream << KeyToChar(jumpkey);
2317 opstream << "\nCrouch key:\n";
2318 opstream << KeyToChar(crouchkey);
2319 opstream << "\nDraw key:\n";
2320 opstream << KeyToChar(drawkey);
2321 opstream << "\nThrow key:\n";
2322 opstream << KeyToChar(throwkey);
2323 opstream << "\nAttack key:\n";
2324 opstream << KeyToChar(attackkey);
2325 opstream << "\nChat key:\n";
2326 opstream << KeyToChar(chatkey);
2329 if(mainmenu==3&&gameon)mainmenu=2;
2330 if(mainmenu==3&&!gameon)mainmenu=1;
2332 if(Button())oldbutton=1;
2336 if(Button()&&!oldbutton&&selected!=-1&&keyselect==-1){
2337 float gLoc[3]={0,0,0};
2338 float vel[3]={0,0,0};
2339 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2340 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2341 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2342 FSOUND_SetVolume(channels[firestartsound], 256);
2343 FSOUND_SetPaused(channels[firestartsound], FALSE);
2344 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2346 if(Button()&&!oldbutton&&selected<9&&keyselect==-1){
2354 if(!buttons[i]&&!oldbutton&&!Button())oldbuttons[i]=0;
2356 if((IsKeyDown(theKeyMap, i)||(buttons[0]&&!oldbuttons[0]&&!oldbutton)||(buttons[1]&&!oldbuttons[1]&&!oldbutton))&&keyselect!=-1){
2357 if(i!=MAC_ESCAPE_KEY&&(strcmp(KeyToChar(i),"unknown")||(buttons[0]&&!oldbuttons[0]&&!oldbutton)||(buttons[1]&&!oldbuttons[1]&&!oldbutton))){
2358 float gLoc[3]={0,0,0};
2359 float vel[3]={0,0,0};
2360 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2361 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2362 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2363 FSOUND_SetVolume(channels[fireendsound], 256);
2364 FSOUND_SetPaused(channels[fireendsound], FALSE);
2365 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2369 if(buttons[0]&&!oldbuttons[0])keynum=MAC_MOUSEBUTTON1;
2370 if(buttons[1]&&!oldbuttons[1])keynum=MAC_MOUSEBUTTON2;
2374 if(keyselect==0)forwardkey=keynum;
2375 if(keyselect==1)backkey=keynum;
2376 if(keyselect==2)leftkey=keynum;
2377 if(keyselect==3)rightkey=keynum;
2378 if(keyselect==4)crouchkey=keynum;
2379 if(keyselect==5)jumpkey=keynum;
2380 if(keyselect==6)drawkey=keynum;
2381 if(keyselect==7)throwkey=keynum;
2382 if(keyselect==8)attackkey=keynum;
2387 if(Button()&&!oldbutton&&selected==9){
2388 float gLoc[3]={0,0,0};
2389 float vel[3]={0,0,0};
2390 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2391 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2392 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2393 FSOUND_SetVolume(channels[fireendsound], 256);
2394 FSOUND_SetPaused(channels[fireendsound], FALSE);
2395 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2405 if(newdetail>2)newdetail=detail;
2406 if(newdetail<0)newdetail=detail;
2407 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2408 if(newscreenwidth<0)newscreenwidth=screenwidth;
2409 if(newscreenheight>3000)newscreenheight=screenheight;
2410 if(newscreenheight<0)newscreenheight=screenheight;
2415 if(accountcampaignchoicesmade[accountactive]>8&&!registered){
2416 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
2417 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
2418 FSOUND_SetPaused(channels[stream_music3], FALSE);
2419 FSOUND_SetVolume(channels[stream_music3], 256);
2423 accountcampaignchoicesmade[accountactive]=0;
2424 accountcampaignscore[accountactive]=0;
2425 accountcampaigntime[accountactive]=0;
2427 float gLoc[3]={0,0,0};
2428 float vel[3]={0,0,0};
2429 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2430 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2431 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2432 FSOUND_SetVolume(channels[fireendsound], 256);
2433 FSOUND_SetPaused(channels[fireendsound], FALSE);
2434 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2444 accountcampaignchoicesmade[accountactive]=0;
2445 accountcampaignscore[accountactive]=0;
2446 accountcampaigntime[accountactive]=0;
2450 if(Button()&&!oldbutton&&selected==1){
2451 float gLoc[3]={0,0,0};
2452 float vel[3]={0,0,0};
2453 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2454 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2455 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2456 FSOUND_SetVolume(channels[firestartsound], 256);
2457 FSOUND_SetPaused(channels[firestartsound], FALSE);
2458 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2471 if(firstload)TickOnceAfter();
2472 if(!firstload)LoadStuff();
2479 FSOUND_SetPaused(channels[stream_music3], TRUE);
2481 if(Button()&&!oldbutton&&selected-7>=accountcampaignchoicesmade[accountactive]){//selected>=7&&(selected-7<=campaignnumchoices)){
2482 float gLoc[3]={0,0,0};
2483 float vel[3]={0,0,0};
2484 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2485 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2486 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2487 FSOUND_SetVolume(channels[firestartsound], 256);
2488 FSOUND_SetPaused(channels[firestartsound], FALSE);
2489 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2502 if(firstload)TickOnceAfter();
2503 if(!firstload)LoadStuff();
2519 strcat(mapname,campaignmapname[campaignchoicewhich[selected-7-accountcampaignchoicesmade[accountactive]]]);
2520 whichchoice=selected-7-accountcampaignchoicesmade[accountactive];
2524 //Loadlevel(campaignmapname[levelorder[selected-7]]);
2529 FSOUND_SetPaused(channels[stream_music3], TRUE);
2531 if(Button()&&!oldbutton&&selected==4){
2532 float gLoc[3]={0,0,0};
2533 float vel[3]={0,0,0};
2534 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2535 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2536 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2537 FSOUND_SetVolume(channels[fireendsound], 256);
2538 FSOUND_SetPaused(channels[fireendsound], FALSE);
2539 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2547 if(mainmenu==5&&gameon)mainmenu=2;
2548 if(mainmenu==5&&!gameon)mainmenu=1;
2550 if(Button()&&!oldbutton&&selected==5){
2551 float gLoc[3]={0,0,0};
2552 float vel[3]={0,0,0};
2553 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2554 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2555 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2556 FSOUND_SetVolume(channels[fireendsound], 256);
2557 FSOUND_SetPaused(channels[fireendsound], FALSE);
2558 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2568 if(Button()&&!oldbutton&&selected==3){
2569 float gLoc[3]={0,0,0};
2570 float vel[3]={0,0,0};
2571 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2572 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2573 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2574 FSOUND_SetVolume(channels[firestartsound], 256);
2575 FSOUND_SetPaused(channels[firestartsound], FALSE);
2576 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2586 if(Button()&&!oldbutton&&selected==2){
2587 float gLoc[3]={0,0,0};
2588 float vel[3]={0,0,0};
2589 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2590 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2591 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2592 FSOUND_SetVolume(channels[firestartsound], 256);
2593 FSOUND_SetPaused(channels[firestartsound], FALSE);
2594 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2604 if(Button())oldbutton=1;
2608 if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountprogress[accountactive]){
2609 float gLoc[3]={0,0,0};
2610 float vel[3]={0,0,0};
2611 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2612 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2613 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2614 FSOUND_SetVolume(channels[firestartsound], 256);
2615 FSOUND_SetPaused(channels[firestartsound], FALSE);
2616 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2628 targetlevel=selected;
2629 if(firstload)TickOnceAfter();
2630 if(!firstload)LoadStuff();
2632 Loadlevel(selected);
2638 FSOUND_SetPaused(channels[stream_music3], TRUE);
2640 if(Button()&&!oldbutton&&selected==numchallengelevels){
2641 float gLoc[3]={0,0,0};
2642 float vel[3]={0,0,0};
2643 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2644 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2645 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2646 FSOUND_SetVolume(channels[fireendsound], 256);
2647 FSOUND_SetPaused(channels[fireendsound], FALSE);
2648 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2658 if(Button())oldbutton=1;
2662 if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountprogress[accountactive]){
2663 float gLoc[3]={0,0,0};
2664 float vel[3]={0,0,0};
2665 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2666 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2667 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2668 FSOUND_SetVolume(channels[firestartsound], 256);
2669 FSOUND_SetPaused(channels[firestartsound], FALSE);
2670 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2682 targetlevel=selected;
2683 if(firstload)TickOnceAfter();
2684 if(!firstload)LoadStuff();
2686 Loadlevel(selected);
2692 FSOUND_SetPaused(channels[stream_music3], TRUE);
2694 if(Button()&&!oldbutton&&selected==numchallengelevels){
2695 float gLoc[3]={0,0,0};
2696 float vel[3]={0,0,0};
2697 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2698 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2699 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2700 FSOUND_SetVolume(channels[fireendsound], 256);
2701 FSOUND_SetPaused(channels[fireendsound], FALSE);
2702 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2712 if(Button())oldbutton=1;
2717 if(Button()&&!oldbutton&&selected==3){
2718 float gLoc[3]={0,0,0};
2719 float vel[3]={0,0,0};
2720 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2721 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2722 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2723 FSOUND_SetVolume(channels[fireendsound], 256);
2724 FSOUND_SetPaused(channels[fireendsound], FALSE);
2725 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2735 if(Button())oldbutton=1;
2739 if(mainmenu==15||mainmenu==16){
2740 if(Button()&&!oldbutton&&selected==1){
2741 float gLoc[3]={0,0,0};
2742 float vel[3]={0,0,0};
2743 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2744 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2745 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2746 FSOUND_SetVolume(channels[fireendsound], 256);
2747 FSOUND_SetPaused(channels[fireendsound], FALSE);
2748 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2756 if(mainmenu==15)mainmenu=5;
2759 if(Button())oldbutton=1;
2765 if(Button()&&!oldbutton&&selected==3){
2767 float gLoc[3]={0,0,0};
2768 float vel[3]={0,0,0};
2769 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2770 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2771 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2772 FSOUND_SetVolume(channels[fireendsound], 256);
2773 FSOUND_SetPaused(channels[fireendsound], FALSE);
2774 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2785 if(Button()&&!oldbutton&&selected==4){
2788 float gLoc[3]={0,0,0};
2789 float vel[3]={0,0,0};
2790 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2791 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2792 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2793 FSOUND_SetVolume(channels[fireendsound], 256);
2794 FSOUND_SetPaused(channels[fireendsound], FALSE);
2795 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2805 if(Button()&&!oldbutton&&selected==5){
2807 float gLoc[3]={0,0,0};
2808 float vel[3]={0,0,0};
2809 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2810 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2811 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2812 FSOUND_SetVolume(channels[fireendsound], 256);
2813 FSOUND_SetPaused(channels[fireendsound], FALSE);
2814 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2824 if(Button())oldbutton=1;
2828 if(Button()&&!oldbutton&&selected!=-1){
2829 float gLoc[3]={0,0,0};
2830 float vel[3]={0,0,0};
2831 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2832 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2833 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2834 FSOUND_SetVolume(channels[firestartsound], 256);
2835 FSOUND_SetPaused(channels[firestartsound], FALSE);
2836 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2838 if(Button()&&!oldbutton&&selected==1){
2839 float gLoc[3]={0,0,0};
2840 float vel[3]={0,0,0};
2841 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2842 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2843 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2844 FSOUND_SetVolume(channels[fireendsound], 256);
2845 FSOUND_SetPaused(channels[fireendsound], FALSE);
2846 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2854 for(i=accountactive;i<numaccounts-1;i++){
2855 accountdifficulty[i]=accountdifficulty[i+1];
2856 accountcampaignchoicesmade[i]=accountcampaignchoicesmade[i+1];
2857 for(j=0;j<accountcampaignchoicesmade[i+1];j++){
2858 accountcampaignchoices[i][j]=accountcampaignchoices[i+1][j];
2860 accountpoints[i]=accountpoints[i+1];
2862 accounthighscore[i][j]=accounthighscore[i+1][j];
2863 accountfasttime[i][j]=accountfasttime[i+1][j];
2866 accountunlocked[i][j]=accountunlocked[i+1][j];
2869 accountname[i][j]=accountname[i+1][j];
2871 accountcampaignhighscore[i]=accountcampaignhighscore[i+1];
2872 accountprogress[i]=accountprogress[i+1];
2873 accountcampaignfasttime[i]=accountcampaignfasttime[i+1];
2874 accountcampaignscore[i]=accountcampaignscore[i+1];
2875 accountcampaigntime[i]=accountcampaigntime[i+1];
2884 if(Button()&&!oldbutton&&selected==2){
2885 float gLoc[3]={0,0,0};
2886 float vel[3]={0,0,0};
2887 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2888 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2889 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2890 FSOUND_SetVolume(channels[fireendsound], 256);
2891 FSOUND_SetPaused(channels[fireendsound], FALSE);
2892 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2902 if(Button())oldbutton=1;
2906 if(Button()&&!oldbutton&&selected!=-1){
2907 float gLoc[3]={0,0,0};
2908 float vel[3]={0,0,0};
2909 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2910 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2911 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2912 FSOUND_SetVolume(channels[firestartsound], 256);
2913 FSOUND_SetPaused(channels[firestartsound], FALSE);
2914 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2916 if(Button()&&!oldbutton&&selected==0&&numaccounts<8){
2919 if(Button()&&!oldbutton&&selected>0&&selected<numaccounts+1){
2920 accountactive=selected-1;
2928 if(Button()&&!oldbutton&&selected==numaccounts+1){
2929 float gLoc[3]={0,0,0};
2930 float vel[3]={0,0,0};
2931 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2932 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2933 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2934 FSOUND_SetVolume(channels[fireendsound], 256);
2935 FSOUND_SetPaused(channels[fireendsound], FALSE);
2936 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2947 displaytext[0][j]=' ';
2953 if(Button())oldbutton=1;
2957 if(Button()&&!oldbutton&&selected!=-1){
2958 float gLoc[3]={0,0,0};
2959 float vel[3]={0,0,0};
2960 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2961 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2962 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2963 FSOUND_SetVolume(channels[firestartsound], 256);
2964 FSOUND_SetPaused(channels[firestartsound], FALSE);
2965 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2967 if(selected==0)accountdifficulty[accountactive]=0;
2968 if(selected==1)accountdifficulty[accountactive]=1;
2969 if(selected==2)accountdifficulty[accountactive]=2;
2980 if(Button())oldbutton=1;
2985 if(Button())oldbutton=1;
2988 if(IsKeyDown(theKeyMap, MAC_Q_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)){
2991 if(newdetail>2)newdetail=detail;
2992 if(newdetail<0)newdetail=detail;
2993 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2994 if(newscreenwidth<0)newscreenwidth=screenwidth;
2995 if(newscreenheight>3000)newscreenheight=screenheight;
2996 if(newscreenheight<0)newscreenheight=screenheight;
2998 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
2999 opstream << "Screenwidth:\n";
3000 opstream << newscreenwidth;
3001 opstream << "\nScreenheight:\n";
3002 opstream << newscreenheight;
3003 opstream << "\nMouse sensitivity:\n";
3004 opstream << usermousesensitivity;
3005 opstream << "\nBlur(0,1):\n";
3006 opstream << ismotionblur;
3007 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
3008 opstream << newdetail;
3009 opstream << "\nFloating jump:\n";
3010 opstream << floatjump;
3011 opstream << "\nMouse jump:\n";
3012 opstream << mousejump;
3013 opstream << "\nAmbient sound:\n";
3014 opstream << ambientsound;
3015 opstream << "\nBlood (0,1,2):\n";
3016 opstream << bloodtoggle;
3017 opstream << "\nAuto slomo:\n";
3018 opstream << autoslomo;
3019 opstream << "\nFoliage:\n";
3020 opstream << foliage;
3021 opstream << "\nMusic:\n";
3022 opstream << musictoggle;
3023 opstream << "\nTrilinear:\n";
3024 opstream << trilinear;
3025 opstream << "\nDecals(shadows,blood puddles,etc):\n";
3027 opstream << "\nInvert mouse:\n";
3028 opstream << invertmouse;
3029 opstream << "\nGamespeed:\n";
3030 if(oldgamespeed==0)oldgamespeed=1;
3031 opstream << oldgamespeed;
3032 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
3033 opstream << difficulty;
3034 opstream << "\nDamage effects(blackout, doublevision):\n";
3035 opstream << damageeffects;
3036 opstream << "\nText:\n";
3037 opstream << texttoggle;
3038 opstream << "\nDebug:\n";
3039 opstream << debugmode;
3040 opstream << "\nVBL Sync:\n";
3041 opstream << vblsync;
3042 opstream << "\nShow Points:\n";
3043 opstream << showpoints;
3044 opstream << "\nAlways Blur:\n";
3045 opstream << alwaysblur;
3046 opstream << "\nImmediate mode (turn on on G5):\n";
3047 opstream << immediate;
3048 opstream << "\nVelocity blur:\n";
3049 opstream << velocityblur;
3050 opstream << "\nVolume:\n";
3052 opstream << "\nForward key:\n";
3053 opstream << KeyToChar(forwardkey);
3054 opstream << "\nBack key:\n";
3055 opstream << KeyToChar(backkey);
3056 opstream << "\nLeft key:\n";
3057 opstream << KeyToChar(leftkey);
3058 opstream << "\nRight key:\n";
3059 opstream << KeyToChar(rightkey);
3060 opstream << "\nJump key:\n";
3061 opstream << KeyToChar(jumpkey);
3062 opstream << "\nCrouch key:\n";
3063 opstream << KeyToChar(crouchkey);
3064 opstream << "\nDraw key:\n";
3065 opstream << KeyToChar(drawkey);
3066 opstream << "\nThrow key:\n";
3067 opstream << KeyToChar(throwkey);
3068 opstream << "\nAttack key:\n";
3069 opstream << KeyToChar(attackkey);
3070 opstream << "\nChat key:\n";
3071 opstream << KeyToChar(chatkey);
3076 if(mainmenu==1||mainmenu==2){
3077 if(loaddistrib>4)transition+=multiplier/8;
3085 FSOUND_SetFrequency(channels[stream_music3], 22050);
3087 if(entername||mainmenu==13||mainmenu==14){
3089 if(IsKeyDown(theKeyMap, i)){
3090 togglekeydelay[i]+=multiplier;
3091 if(togglekeydelay[i]>.4){
3093 togglekeydelay[i]=.36;
3096 if(KeyToSingleChar(i)!='\0'&&displaychars[0]<60){
3097 for(j=255;j>=displayselected+1;j--){
3098 displaytext[0][j]=displaytext[0][j-1];
3100 displaytext[0][displayselected]=KeyToSingleChar(i);
3101 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]);
3105 if(i==MAC_DELETE_KEY&&displayselected!=0){
3106 for(j=displayselected-1;j<255;j++){
3107 displaytext[0][j]=displaytext[0][j+1];
3109 displaytext[0][255]=' ';
3113 if(i==MAC_ARROW_LEFT_KEY&&displayselected!=0){
3116 if(i==MAC_ARROW_RIGHT_KEY&&displayselected<displaychars[0]){
3119 if(i==MAC_RETURN_KEY&&entername){
3120 if(displaychars[0]){
3122 strcpy(accountname[numaccounts-1],displaytext[0]);
3123 accountactive=numaccounts-1;
3124 accountdifficulty[accountactive]=1;
3125 accountprogress[accountactive]=0;
3126 accountpoints[accountactive]=0;
3127 accountcampaigntime[accountactive]=0;
3128 accountcampaignscore[accountactive]=0;
3129 accountcampaignfasttime[accountactive]=0;
3130 accountcampaignhighscore[accountactive]=0;
3132 accounthighscore[accountactive][j]=0;
3133 accountfasttime[accountactive][j]=0;
3136 accountunlocked[accountactive][j]=0;
3138 accountcampaignchoicesmade[accountactive]=0;
3141 displaytext[0][j]=' ';
3155 float gLoc[3]={0,0,0};
3156 float vel[3]={0,0,0};
3157 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3158 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
3159 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3160 FSOUND_SetVolume(channels[firestartsound], 256);
3161 FSOUND_SetPaused(channels[firestartsound], FALSE);
3162 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3165 displaytext[0][j]=' ';
3173 if(i==MAC_RETURN_KEY&&mainmenu==14){
3174 if(displaychars[0]){
3175 char serialstring[256];
3176 char tempstring[256];
3177 #if defined(__APPLE__)
3178 sprintf (tempstring, "%s", registrationname);
3179 #elif defined(_MSC_VER) || defined(__linux__)
3180 sprintf (tempstring, "%s-windows", registrationname);
3182 #error Please make sure you have the right registration key stuff here!
3189 longnum = MD5_string ( tempstring);
3190 //longnum = 1111111111111111;
3191 num1 = longnum/100000000;
3192 num2 = longnum%100000000;
3193 sprintf (tempstring, "%d-%d-%d-%d\0\0\0\0\0", num1/10000, num1%10000, num2/10000, num2%10000);
3197 if(num1/10000>999)numchars+=4;
3198 else if(num1/10000>99)numchars+=3;
3199 else if(num1/10000>9)numchars+=2;
3201 if(num1%10000>999)numchars+=4;
3202 else if(num1%10000>99)numchars+=3;
3203 else if(num1%10000>9)numchars+=2;
3205 if(num2/10000>999)numchars+=4;
3206 else if(num2/10000>99)numchars+=3;
3207 else if(num2/10000>9)numchars+=2;
3209 if(num2%10000>999)numchars+=4;
3210 else if(num2%10000>99)numchars+=3;
3211 else if(num2%10000>9)numchars+=2;
3216 for(j=0;j<numchars;j++){
3217 if(displaytext[0][j]!=tempstring[j]&&tempstring[j]!=' '&&tempstring[j]!='\0')goodcode--;
3220 if(longnum==LONGLONGCONST(5077041556214789))goodcode=-1;
3222 if(goodcode<0)goodcode=0;
3229 tfile=fopen( ":Data:Sounds:flame.ogg", "wb" );
3233 numchars=strlen(registrationname);
3234 fpackf(tfile, "Bb", registered);
3235 fpackf(tfile, "Bi", numchars);
3238 for(j=0;j<numchars;j++)
3240 fpackf(tfile, "Bb", registrationname[j]);
3243 fpackf(tfile, "Bi", num1);
3244 fpackf(tfile, "Bi", num2);
3258 float gLoc[3]={0,0,0};
3259 float vel[3]={0,0,0};
3260 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3261 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
3262 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3263 FSOUND_SetVolume(channels[firestartsound], 256);
3264 FSOUND_SetPaused(channels[firestartsound], FALSE);
3265 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3268 displaytext[0][j]=' ';
3274 if(i==MAC_RETURN_KEY&&mainmenu==13){
3275 if(displaychars[0]){
3276 sprintf (registrationname, "%s", displaytext[0]);
3277 if(displaychars[0]<254)registrationname[displaychars[0]]='\0';
3287 float gLoc[3]={0,0,0};
3288 float vel[3]={0,0,0};
3289 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3290 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
3291 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3292 FSOUND_SetVolume(channels[firestartsound], 256);
3293 FSOUND_SetPaused(channels[firestartsound], FALSE);
3294 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3297 displaytext[0][j]=' ';
3301 /*char tempstring[50];
3302 sprintf (tempstring, registrationname);
3308 longnum = MD5_string ( tempstring);
3309 num1 = longnum/100000000;
3310 num2 = longnum%100000000;
3311 sprintf (displaytext[0], "%d-%d-%d-%d", num1/10000, num1%10000, num2/10000, num2%10000);
3313 displaychars[0]=strlen(displaytext[0]);
3322 togglekeydelay[i]=0;
3326 displayblinkdelay-=multiplier;
3327 if(displayblinkdelay<=0){
3328 displayblinkdelay=.3;
3329 displayblink=1-displayblink;
3335 if(hostile==1)hostiletime+=multiplier;
3337 if(!winfreeze)leveltime+=multiplier;
3338 if(IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)){
3345 if(IsKeyDown(theKeyMap, chatkey)&&!chattogglekeydown&&!console&&!chatting&&debugmode){
3347 chattogglekeydown=1;
3348 togglekey[chatkey]=1;
3349 togglekeydelay[chatkey]=-20;
3352 if(!IsKeyDown(theKeyMap, chatkey)){
3353 chattogglekeydown=0;
3358 if(IsKeyDown(theKeyMap, i)){
3359 togglekeydelay[i]+=multiplier;
3360 if(togglekeydelay[i]>.4){
3362 togglekeydelay[i]=.36;
3365 if(KeyToSingleChar(i)!='\0'&&displaychars[0]<60){
3366 for(j=255;j>=displayselected+1;j--){
3367 displaytext[0][j]=displaytext[0][j-1];
3369 displaytext[0][displayselected]=KeyToSingleChar(i);
3370 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]);
3374 if(i==MAC_DELETE_KEY&&displayselected!=0){
3375 for(j=displayselected-1;j<255;j++){
3376 displaytext[0][j]=displaytext[0][j+1];
3378 displaytext[0][255]=' ';
3382 if(i==MAC_ARROW_LEFT_KEY&&displayselected!=0){
3385 if(i==MAC_ARROW_RIGHT_KEY&&displayselected<displaychars[0]){
3388 if(i==MAC_RETURN_KEY){
3389 if(displaychars[0]){
3390 /*for(j=0;j<displaychars[0];j++){
3391 talkname[j]=displaytext[0][j];
3393 talkname[displaychars[0]]='\0';
3394 sprintf (chatname, "%s: %s",playerName,talkname);
3395 //NetworkSendInformation(chatname);
3398 displaytext[0][j]=' ';
3410 togglekeydelay[i]=0;
3414 displayblinkdelay-=multiplier;
3415 if(displayblinkdelay<=0){
3416 displayblinkdelay=.3;
3417 displayblink=1-displayblink;
3421 if(chatting)keyboardfrozen=1;
3423 if(IsKeyDown(theKeyMap, MAC_V_KEY)&&!freezetogglekeydown&&debugmode){
3426 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
3428 freezetogglekeydown=1;
3431 if(!IsKeyDown(theKeyMap, MAC_V_KEY)&&!IsKeyDown(theKeyMap, MAC_F1_KEY)){
3432 freezetogglekeydown=0;
3435 if(IsKeyDown(theKeyMap, MAC_TILDE_KEY)&&!consoletogglekeydown&&debugmode){
3437 if(!console)freeze=0;
3439 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
3441 consoletogglekeydown=1;
3444 if(!IsKeyDown(theKeyMap, MAC_TILDE_KEY)){
3445 consoletogglekeydown=0;
3448 if(console)freeze=1;
3450 if(console&&!IsKeyDown(theKeyMap,MAC_COMMAND_KEY)){
3452 if(IsKeyDown(theKeyMap, i)){
3453 togglekeydelay[i]+=multiplier;
3454 if(togglekeydelay[i]>.4){
3456 togglekeydelay[i]=.36;
3459 if(KeyToSingleChar(i)!='\0'&&consolechars[0]<255){
3460 for(j=255;j>=consoleselected+1;j--){
3461 consoletext[0][j]=consoletext[0][j-1];
3463 consoletext[0][consoleselected]=KeyToSingleChar(i);
3464 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))consoletext[0][consoleselected]=Shift(consoletext[0][consoleselected]);
3468 else if(i==MAC_ENTER_KEY){
3469 for(j=255;j>=consoleselected+1;j--){
3470 consoletext[0][j]=consoletext[0][j-1];
3472 consoletext[0][consoleselected]='\n';
3476 if(i==MAC_DELETE_KEY&&consoleselected!=0){
3477 for(j=consoleselected-1;j<255;j++){
3478 consoletext[0][j]=consoletext[0][j+1];
3480 consoletext[0][255]=' ';
3484 if(i==MAC_ARROW_UP_KEY){
3485 if(archiveselected<14)archiveselected++;
3487 consolechars[0]=consolechars[archiveselected];
3488 consoletext[0][j]=consoletext[archiveselected][j];
3489 consoleselected=consolechars[0];
3492 if(i==MAC_ARROW_DOWN_KEY){
3493 if(archiveselected>0)archiveselected--;
3495 consolechars[0]=consolechars[archiveselected];
3496 consoletext[0][j]=consoletext[archiveselected][j];
3497 consoleselected=consolechars[0];
3500 if(i==MAC_ARROW_LEFT_KEY&&consoleselected!=0){
3503 if(i==MAC_ARROW_RIGHT_KEY&&consoleselected<consolechars[0]){
3506 if(i==MAC_RETURN_KEY){
3509 if(Compare(consoletext[0],"quit ",0,4)||Compare(consoletext[0],"exit ",0,4)){
3510 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
3511 FSOUND_SetVolume(channels[consolesuccesssound], 256);
3512 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
3516 /*if(Compare(consoletext[0],"send ",0,4)){
3517 for(j=5;j<consolechars[0];j++){
3518 talkname[j-5]=consoletext[0][j];
3520 talkname[consolechars[0]-5]='\0';
3521 sprintf (chatname, "%s: %s",playerName,talkname);
3522 //NetworkSendInformation(chatname);
3525 if(Compare(consoletext[0],"name ",0,4)){
3527 numchars=consolechars[0]-5;
3528 if(numchars>32)numchars=32;
3529 for(j=5;j<numchars+5;j++){
3530 talkname[j-5]=consoletext[0][j];
3532 talkname[numchars]='\0';
3533 sprintf (chatname, "Player %s is now known as %s.",playerName,talkname);
3534 //NetworkSendInformation(chatname);
3535 sprintf (playerName, "%s",talkname);
3536 //NetworkSendName(playerName);
3539 if(Compare(consoletext[0],"map ",0,3)){
3551 for(j=4;j<consolechars[0];j++){
3552 mapname[j-4+11]=consoletext[0][j];
3554 mapname[consolechars[0]-4+11]='\0';
3560 /*if(Compare(consoletext[0],"connect ",0,7)&&!ishost){
3562 unsigned char playerNameStr[32];
3563 char theIPAddress[256];
3565 NMUInt32 port = 25710;
3567 strcpy(playerName, "Client");
3568 GameC2PStr( playerName, playerNameStr );
3570 for(j=0;j<consolechars[0]-8;j++){
3571 theIPAddress[j]=consoletext[0][j+8];
3573 theIPAddress[consolechars[0]-8]='\0';
3575 sprintf( thePort, "%li", port );
3576 v=NetworkStartClient( theIPAddress, thePort, playerNameStr );
3579 if(consolechars[0]>0){
3582 consoletext[k][j]=consoletext[k-1][j];
3584 consolechars[k]=consolechars[k-1];
3587 consoletext[0][j]=' ';
3589 if(v!=-4994)sprintf (consoletext[0], "Error #%d!!!",v);
3590 else sprintf (consoletext[0], "Could not open connection");
3592 consolechars[0]=255;
3599 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
3600 FSOUND_SetVolume(channels[consolesuccesssound], 256);
3601 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
3603 if(consolechars[0]>0){
3606 consoletext[k][j]=consoletext[k-1][j];
3608 consolechars[k]=consolechars[k-1];
3611 consoletext[0][j]=' ';
3613 sprintf (consoletext[0], "Connected to %s",theIPAddress);
3615 consolechars[0]=255;
3621 if(Compare(consoletext[0],"host ",0,4)){
3622 unsigned char gameNameStr[32], playerNameStr[32];
3623 char gameName[32];//, playerName[32];
3631 strcpy(gameName, "Host's game");
3632 strcpy(playerName, "Host");
3633 GameC2PStr( gameName, gameNameStr );
3634 GameC2PStr( playerName, playerNameStr );
3636 v=NetworkStartServer( (NMUInt16)port, players, gameNameStr, playerNameStr );
3639 if(consolechars[0]>0){
3642 consoletext[k][j]=consoletext[k-1][j];
3644 consolechars[k]=consolechars[k-1];
3647 consoletext[0][j]=' ';
3649 sprintf (consoletext[0], "Error #%d!!!",v);
3651 consolechars[0]=255;
3658 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
3659 FSOUND_SetVolume(channels[consolesuccesssound], 256);
3660 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
3662 if(consolechars[0]>0){
3665 consoletext[k][j]=consoletext[k-1][j];
3667 consolechars[k]=consolechars[k-1];
3670 consoletext[0][j]=' ';
3672 sprintf (consoletext[0], "Game hosted");
3674 consolechars[0]=255;
3680 if(Compare(consoletext[0],"save ",0,4)){
3692 for(j=5;j<consolechars[0];j++){
3693 mapname[j-5+11]=consoletext[0][j];
3695 mapname[consolechars[0]-5+11]='\0';
3697 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
3698 FSOUND_SetVolume(channels[consolesuccesssound], 256);
3699 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
3706 tfile=fopen( mapname, "wb" );
3707 fpackf(tfile, "Bi", mapvers);
3708 //fpackf(tfile, "Bi", indemo);
3709 fpackf(tfile, "Bi", maptype);
3710 fpackf(tfile, "Bi", hostile);
3711 fpackf(tfile, "Bf Bf", viewdistance, fadestart);
3712 fpackf(tfile, "Bb Bf Bf Bf", skyboxtexture, skyboxr, skyboxg, skyboxb);
3713 fpackf(tfile, "Bf Bf Bf", skyboxlightr, skyboxlightg, skyboxlightb);
3714 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);
3715 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3716 for(j=0;j<player[0].num_weapons;j++){
3717 fpackf(tfile, "Bi", weapons.type[player[0].weaponids[j]]);
3720 fpackf(tfile, "Bf Bf Bf", player[0].armorhead, player[0].armorhigh, player[0].armorlow);
3721 fpackf(tfile, "Bf Bf Bf", player[0].protectionhead, player[0].protectionhigh, player[0].protectionlow);
3722 fpackf(tfile, "Bf Bf Bf", player[0].metalhead, player[0].metalhigh, player[0].metallow);
3723 fpackf(tfile, "Bf Bf", player[0].power, player[0].speedmult);
3725 fpackf(tfile, "Bi", player[0].numclothes);
3727 fpackf(tfile, "Bi Bi", player[0].whichskin, player[0].creature);
3729 fpackf(tfile, "Bi", numdialogues);
3731 for(k=0;k<numdialogues;k++){
3732 fpackf(tfile, "Bi", numdialogueboxes[k]);
3733 fpackf(tfile, "Bi", dialoguetype[k]);
3735 fpackf(tfile, "Bf Bf Bf", participantlocation[k][l].x, participantlocation[k][l].y, participantlocation[k][l].z);
3736 fpackf(tfile, "Bf", participantrotation[k][l]);
3738 if(numdialogueboxes)
3739 for(l=0;l<numdialogueboxes[k];l++){
3740 fpackf(tfile, "Bi", dialogueboxlocation[k][l]);
3741 fpackf(tfile, "Bf", dialogueboxcolor[k][l][0]);
3742 fpackf(tfile, "Bf", dialogueboxcolor[k][l][1]);
3743 fpackf(tfile, "Bf", dialogueboxcolor[k][l][2]);
3744 fpackf(tfile, "Bi", dialogueboxsound[k][l]);
3746 templength=strlen(dialoguetext[k][l]);
3747 fpackf(tfile, "Bi",(templength));
3748 for(m=0;m<templength;m++){
3749 fpackf(tfile, "Bb", dialoguetext[k][l][m]);
3750 if(dialoguetext[k][l][m]=='\0')break;
3753 templength=strlen(dialoguename[k][l]);
3754 fpackf(tfile, "Bi",templength);
3755 for(m=0;m<templength;m++){
3756 fpackf(tfile, "Bb", dialoguename[k][l][m]);
3757 if(dialoguename[k][l][m]=='\0')break;
3760 fpackf(tfile, "Bf Bf Bf", dialoguecamera[k][l].x, dialoguecamera[k][l].y, dialoguecamera[k][l].z);
3761 fpackf(tfile, "Bi", participantfocus[k][l]);
3762 fpackf(tfile, "Bi", participantaction[k][l]);
3765 fpackf(tfile, "Bf Bf Bf", participantfacing[k][l][m].x, participantfacing[k][l][m].y, participantfacing[k][l][m].z);
3767 fpackf(tfile, "Bf Bf",dialoguecamerarotation[k][l],dialoguecamerarotation2[k][l]);
3771 if(player[0].numclothes)
3772 for(k=0;k<player[0].numclothes;k++){
3773 templength=strlen(player[0].clothes[k]);
3774 fpackf(tfile, "Bi", templength);
3775 for(l=0;l<templength;l++)
3776 fpackf(tfile, "Bb", player[0].clothes[k][l]);
3777 fpackf(tfile, "Bf Bf Bf", player[0].clothestintr[k], player[0].clothestintg[k], player[0].clothestintb[k]);
3780 fpackf(tfile, "Bi", environment);
3782 fpackf(tfile, "Bi", objects.numobjects);
3784 if(objects.numobjects)
3785 for(k=0;k<objects.numobjects;k++){
3786 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]);
3789 fpackf(tfile, "Bi", numhotspots);
3791 for(i=0;i<numhotspots;i++){
3792 fpackf(tfile, "Bi Bf Bf Bf Bf", hotspottype[i],hotspotsize[i],hotspot[i].x,hotspot[i].y,hotspot[i].z);
3793 templength=strlen(hotspottext[i]);
3794 fpackf(tfile, "Bi",templength);
3795 for(l=0;l<templength;l++)
3796 fpackf(tfile, "Bb", hotspottext[i][l]);
3799 fpackf(tfile, "Bi", numplayers);
3800 if(numplayers>1&&numplayers<maxplayers)
3801 for(j=1;j<numplayers;j++){
3802 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);
3803 if(player[j].num_weapons>0&&player[j].num_weapons<5)
3804 for(k=0;k<player[j].num_weapons;k++){
3805 fpackf(tfile, "Bi", weapons.type[player[j].weaponids[k]]);
3807 if(player[j].numwaypoints<30){
3808 fpackf(tfile, "Bi", player[j].numwaypoints);
3809 for(k=0;k<player[j].numwaypoints;k++){
3810 fpackf(tfile, "Bf", player[j].waypoints[k].x);
3811 fpackf(tfile, "Bf", player[j].waypoints[k].y);
3812 fpackf(tfile, "Bf", player[j].waypoints[k].z);
3813 fpackf(tfile, "Bi", player[j].waypointtype[k]);
3815 fpackf(tfile, "Bi", player[j].waypoint);
3818 player[j].numwaypoints=0;
3819 player[j].waypoint=0;
3820 fpackf(tfile, "Bi Bi Bi", player[j].numwaypoints, player[j].waypoint, player[j].waypoint);
3823 fpackf(tfile, "Bf Bf Bf", player[j].armorhead, player[j].armorhigh, player[j].armorlow);
3824 fpackf(tfile, "Bf Bf Bf", player[j].protectionhead, player[j].protectionhigh, player[j].protectionlow);
3825 fpackf(tfile, "Bf Bf Bf", player[j].metalhead, player[j].metalhigh, player[j].metallow);
3826 fpackf(tfile, "Bf Bf", player[j].power, player[j].speedmult);
3828 if(player[j].creature==wolftype){
3829 headprop=player[j].proportionhead.x/1.1;
3830 bodyprop=player[j].proportionbody.x/1.1;
3831 armprop=player[j].proportionarms.x/1.1;
3832 legprop=player[j].proportionlegs.x/1.1;
3835 if(player[j].creature==rabbittype){
3836 headprop=player[j].proportionhead.x/1.2;
3837 bodyprop=player[j].proportionbody.x/1.05;
3838 armprop=player[j].proportionarms.x/1.00;
3839 legprop=player[j].proportionlegs.x/1.1;
3842 fpackf(tfile, "Bf Bf Bf Bf", headprop, bodyprop, armprop, legprop);
3846 fpackf(tfile, "Bi", player[j].numclothes);
3847 if(player[j].numclothes)
3848 for(k=0;k<player[j].numclothes;k++){
3850 templength=strlen(player[j].clothes[k]);
3851 fpackf(tfile, "Bi", templength);
3852 for(l=0;l<templength;l++)
3853 fpackf(tfile, "Bb", player[j].clothes[k][l]);
3854 fpackf(tfile, "Bf Bf Bf", player[j].clothestintr[k], player[j].clothestintg[k], player[j].clothestintb[k]);
3858 fpackf(tfile, "Bi", numpathpoints);
3860 for(j=0;j<numpathpoints;j++){
3861 fpackf(tfile, "Bf Bf Bf Bi", pathpoint[j].x, pathpoint[j].y, pathpoint[j].z, numpathpointconnect[j]);
3862 for(k=0;k<numpathpointconnect[j];k++){
3863 fpackf(tfile, "Bi", pathpointconnect[j][k]);
3867 fpackf(tfile, "Bf Bf Bf Bf", mapcenter.x, mapcenter.y, mapcenter.z, mapradius);
3875 tfile=fopen( mapname, "wb" );
3876 fwrite( &mapvers, 1, sizeof(int), tfile );
3877 fwrite( &player[0].coords.x, 1, sizeof(float), tfile );
3878 fwrite( &player[0].coords.y, 1, sizeof(float), tfile );
3879 fwrite( &player[0].coords.z, 1, sizeof(float), tfile );
3880 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
3881 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
3882 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
3883 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3884 for(j=0;j<player[0].num_weapons;j++){
3885 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
3888 fwrite( &player[0].armorhead, 1, sizeof(int), tfile );
3889 fwrite( &player[0].armorhigh, 1, sizeof(int), tfile );
3890 fwrite( &player[0].armorlow, 1, sizeof(int), tfile );
3891 fwrite( &player[0].protectionhead, 1, sizeof(int), tfile );
3892 fwrite( &player[0].protectionhigh, 1, sizeof(int), tfile );
3893 fwrite( &player[0].protectionlow, 1, sizeof(int), tfile );
3894 fwrite( &player[0].metalhead, 1, sizeof(int), tfile );
3895 fwrite( &player[0].metalhigh, 1, sizeof(int), tfile );
3896 fwrite( &player[0].metallow, 1, sizeof(int), tfile );
3897 fwrite( &player[0].power, 1, sizeof(int), tfile );
3898 fwrite( &player[0].speedmult, 1, sizeof(int), tfile );
3900 fwrite( &player[0].numclothes, 1, sizeof(int), tfile );
3901 if(player[0].numclothes)
3902 for(k=0;k<player[0].numclothes;k++){
3904 templength=strlen(player[0].clothes[k]);
3905 fwrite( &templength,1,sizeof(int),tfile);
3906 for(l=0;l<templength;l++)
3907 fwrite( &player[0].clothes[k][l],1,sizeof(char),tfile);
3908 fwrite( &player[0].clothestintr[k],1,sizeof(float),tfile);
3909 fwrite( &player[0].clothestintg[k],1,sizeof(float),tfile);
3910 fwrite( &player[0].clothestintb[k],1,sizeof(float),tfile);
3913 fwrite( &environment, 1, sizeof(int), tfile );
3915 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
3917 for(k=0;k<objects.numobjects;k++){
3918 fwrite( &objects.type[k], 1, sizeof(int), tfile );
3919 fwrite( &objects.rotation[k], 1, sizeof(float), tfile );
3920 fwrite( &objects.rotation2[k], 1, sizeof(float), tfile );
3921 fwrite( &objects.position[k].x, 1, sizeof(float), tfile );
3922 fwrite( &objects.position[k].y, 1, sizeof(float), tfile );
3923 fwrite( &objects.position[k].z, 1, sizeof(float), tfile );
3924 fwrite( &objects.scale[k], 1, sizeof(float), tfile );
3927 fwrite( &numplayers, 1, sizeof(int), tfile );
3928 if(numplayers>1&&numplayers<maxplayers)
3929 for(j=1;j<numplayers;j++){
3930 fwrite( &player[j].whichskin, 1, sizeof(int), tfile );
3931 fwrite( &player[j].creature, 1, sizeof(int), tfile );
3932 fwrite( &player[j].coords.x, 1, sizeof(float), tfile );
3933 fwrite( &player[j].coords.y, 1, sizeof(float), tfile );
3934 fwrite( &player[j].coords.z, 1, sizeof(float), tfile );
3935 fwrite( &player[j].num_weapons, 1, sizeof(int), tfile );
3936 if(player[j].num_weapons>0&&player[j].num_weapons<5)
3937 for(k=0;k<player[j].num_weapons;k++){
3938 fwrite( &weapons.type[player[j].weaponids[k]], 1, sizeof(int), tfile );
3940 if(player[j].numwaypoints<30){
3941 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
3942 for(k=0;k<player[j].numwaypoints;k++){
3943 fwrite( &player[j].waypoints[k].x, 1, sizeof(float), tfile );
3944 fwrite( &player[j].waypoints[k].y, 1, sizeof(float), tfile );
3945 fwrite( &player[j].waypoints[k].z, 1, sizeof(float), tfile );
3947 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3948 //fwrite( &player[j].jumppath, 1, sizeof(bool), tfile );
3951 player[j].numwaypoints=0;
3952 player[j].waypoint=0;
3953 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
3954 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3955 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3957 fwrite( &player[j].armorhead, 1, sizeof(int), tfile );
3958 fwrite( &player[j].armorhigh, 1, sizeof(int), tfile );
3959 fwrite( &player[j].armorlow, 1, sizeof(int), tfile );
3960 fwrite( &player[j].protectionhead, 1, sizeof(int), tfile );
3961 fwrite( &player[j].protectionhigh, 1, sizeof(int), tfile );
3962 fwrite( &player[j].protectionlow, 1, sizeof(int), tfile );
3963 fwrite( &player[j].metalhead, 1, sizeof(int), tfile );
3964 fwrite( &player[j].metalhigh, 1, sizeof(int), tfile );
3965 fwrite( &player[j].metallow, 1, sizeof(int), tfile );
3966 fwrite( &player[j].power, 1, sizeof(int), tfile );
3967 fwrite( &player[j].speedmult, 1, sizeof(int), tfile );
3969 fwrite( &player[j].numclothes, 1, sizeof(int), tfile );
3970 if(player[j].numclothes)
3971 for(k=0;k<player[j].numclothes;k++){
3973 templength=strlen(player[j].clothes[k]);
3974 fwrite( &templength,1,sizeof(int),tfile);
3975 for(l=0;l<templength;l++)
3976 fwrite( &player[j].clothes[k][l],1,sizeof(char),tfile);
3977 fwrite( &player[j].clothestintr[k],1,sizeof(float),tfile);
3978 fwrite( &player[j].clothestintg[k],1,sizeof(float),tfile);
3979 fwrite( &player[j].clothestintb[k],1,sizeof(float),tfile);
3982 fwrite( &numpathpoints, 1, sizeof(int), tfile );
3984 for(j=0;j<numpathpoints;j++){
3985 fwrite( &pathpoint[j].x, 1, sizeof(float), tfile );
3986 fwrite( &pathpoint[j].y, 1, sizeof(float), tfile );
3987 fwrite( &pathpoint[j].z, 1, sizeof(float), tfile );
3988 fwrite( &numpathpointconnect[j], 1, sizeof(int), tfile );
3989 for(k=0;k<numpathpointconnect[j];k++){
3990 fwrite( &pathpointconnect[j][k], 1, sizeof(int), tfile );
3994 fwrite( &mapcenter.x, 1, sizeof(float), tfile );
3995 fwrite( &mapcenter.y, 1, sizeof(float), tfile );
3996 fwrite( &mapcenter.z, 1, sizeof(float), tfile );
3998 fwrite( &mapradius, 1, sizeof(float), tfile );
4004 if(Compare(consoletext[0],"save ",0,4)){
4016 for(j=5;j<consolechars[0];j++){
4017 mapname[j-5+11]=consoletext[0][j];
4019 mapname[consolechars[0]-5+11]='\0';
4021 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
4022 FSOUND_SetVolume(channels[consolesuccesssound], 256);
4023 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
4026 tfile=fopen( mapname, "wb" );
4027 fwrite( &player[0].coords, 1, sizeof(XYZ), tfile );
4028 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
4029 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
4030 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
4031 if(player[0].num_weapons>0&&player[0].num_weapons<5)
4032 for(j=0;j<player[0].num_weapons;j++){
4033 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
4035 fwrite( &environment, 1, sizeof(int), tfile );
4037 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
4038 fwrite( &objects.type, 1, sizeof(int)*objects.numobjects, tfile );
4039 fwrite( &objects.rotation, 1, sizeof(float)*objects.numobjects, tfile );
4040 fwrite( &objects.position, 1, sizeof(XYZ)*objects.numobjects, tfile );
4041 fwrite( &objects.scale, 1, sizeof(float)*objects.numobjects, tfile );
4043 fwrite( &numplayers, 1, sizeof(int), tfile );
4044 if(numplayers>1&&numplayers<maxplayers)
4045 for(j=1;j<numplayers;j++){
4046 fwrite( &player[j].coords, 1, sizeof(XYZ), tfile );
4047 fwrite( &player[j].num_weapons, 1, sizeof(int), tfile );
4048 if(player[j].num_weapons>0&&player[j].num_weapons<5)
4049 for(k=0;k<player[j].num_weapons;k++){
4050 fwrite( &weapons.type[player[j].weaponids[k]], 1, sizeof(int), tfile );
4052 if(player[j].numwaypoints<30){
4053 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
4054 fwrite( &player[j].waypoints, 1, sizeof(XYZ)*player[j].numwaypoints, tfile );
4055 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4056 //fwrite( &player[j].jumppath, 1, sizeof(bool), tfile );
4059 player[j].numwaypoints=0;
4060 player[j].waypoint=0;
4061 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
4062 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4063 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4066 fwrite( &numpathpoints, 1, sizeof(int), tfile );
4068 for(j=0;j<numpathpoints;j++){
4069 fwrite( &pathpoint[j], 1, sizeof(XYZ), tfile );
4070 fwrite( &numpathpointconnect[j], 1, sizeof(int), tfile );
4071 for(k=0;k<numpathpointconnect[j];k++){
4072 fwrite( &pathpointconnect[j][k], 1, sizeof(int), tfile );
4078 if(Compare(consoletext[0],"cellar door ",0,11)||Compare(consoletext[0],"cellardoor ",0,10)){
4079 LoadTextureSave(":Data:Textures:Furdarko.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4082 /*if(Compare(consoletext[0],"Pants ",0,5)){
4083 AddClothes(":Data:Textures:Pants.png",0,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
4084 player[i].DoMipmaps(5,0,0,player[i].skeleton.skinsize,player[i].skeleton.skinsize);
4088 if(Compare(consoletext[0],"tintr ",0,5)||Compare(consoletext[0],"Tintr ",0,5)){
4089 for(j=6;j<consolechars[0];j++){
4090 mapname[j-6]=consoletext[0][j];
4093 tintr=atof(mapname);
4098 if(Compare(consoletext[0],"speed ",0,5)||Compare(consoletext[0],"Speed ",0,5)){
4099 for(j=6;j<consolechars[0];j++){
4100 mapname[j-6]=consoletext[0][j];
4103 player[0].speedmult=atof(mapname);
4108 if(Compare(consoletext[0],"strength ",0,8)||Compare(consoletext[0],"Strength ",0,8)){
4109 for(j=9;j<consolechars[0];j++){
4110 mapname[j-9]=consoletext[0][j];
4113 player[0].power=atof(mapname);
4118 if(Compare(consoletext[0],"viewdistance ",0,12)||Compare(consoletext[0],"Viewdistance ",0,12)){
4119 for(j=13;j<consolechars[0];j++){
4120 mapname[j-13]=consoletext[0][j];
4123 viewdistance=atof(mapname)*100;
4128 if(Compare(consoletext[0],"fadestart ",0,9)||Compare(consoletext[0],"Fadestart ",0,9)){
4129 for(j=10;j<consolechars[0];j++){
4130 mapname[j-10]=consoletext[0][j];
4133 fadestart=atof(mapname);
4138 if(Compare(consoletext[0],"power ",0,5)||Compare(consoletext[0],"Power ",0,5)){
4139 for(j=6;j<consolechars[0];j++){
4140 mapname[j-6]=consoletext[0][j];
4143 player[0].power=atof(mapname);
4148 if(Compare(consoletext[0],"slomo ",0,5)||Compare(consoletext[0],"Slomo ",0,5)){
4149 for(j=6;j<consolechars[0];j++){
4150 mapname[j-6]=consoletext[0][j];
4153 slomospeed=atof(mapname);
4160 if(Compare(consoletext[0],"slofreq ",0,7)||Compare(consoletext[0],"Slofreq ",0,7)){
4161 for(j=8;j<consolechars[0];j++){
4162 mapname[j-8]=consoletext[0][j];
4165 slomofreq=atoi(mapname);
4170 if(Compare(consoletext[0],"size ",0,4)||Compare(consoletext[0],"Size ",0,4)){
4171 for(j=5;j<consolechars[0];j++){
4172 mapname[j-5]=consoletext[0][j];
4175 player[0].scale=atof(mapname)*.2;
4180 if(Compare(consoletext[0],"sizenear ",0,8)||Compare(consoletext[0],"Sizenear ",0,8)){
4182 float closestdist=-1;
4185 for(i=1;i<numplayers;i++){
4186 distance=findDistancefast(&player[i].coords,&player[0].coords);
4187 if(closestdist==-1||distance<closestdist){
4188 closestdist=distance;
4193 for(j=9;j<consolechars[0];j++){
4194 mapname[j-9]=consoletext[0][j];
4197 player[closest].scale=atof(mapname)*.2;
4202 if(Compare(consoletext[0],"proportionnear ",0,14)||Compare(consoletext[0],"Proportionnear ",0,14)){
4207 float closestdist=-1;
4210 for(i=1;i<numplayers;i++){
4211 distance=findDistancefast(&player[i].coords,&player[0].coords);
4212 if(closestdist==-1||distance<closestdist){
4213 closestdist=distance;
4221 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4222 mapname[j-startpoint]=consoletext[0][j];
4224 if(consoletext[0][j]=='\0')alldone=1;
4226 mapname[j-startpoint]='\0';
4228 headprop=atof(mapname);
4232 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4233 mapname[j-startpoint]=consoletext[0][j];
4235 if(consoletext[0][j]=='\0')alldone=1;
4237 mapname[j-startpoint]='\0';
4239 bodyprop=atof(mapname);
4243 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4244 mapname[j-startpoint]=consoletext[0][j];
4246 if(consoletext[0][j]=='\0')alldone=1;
4248 mapname[j-startpoint]='\0';
4250 armprop=atof(mapname);
4254 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4255 mapname[j-startpoint]=consoletext[0][j];
4257 if(consoletext[0][j]=='\0')alldone=1;
4259 mapname[j-startpoint]='\0';
4261 legprop=atof(mapname);
4263 if(player[closest].creature==wolftype){
4264 player[closest].proportionhead=1.1*headprop;
4265 player[closest].proportionbody=1.1*bodyprop;
4266 player[closest].proportionarms=1.1*armprop;
4267 player[closest].proportionlegs=1.1*legprop;
4270 if(player[closest].creature==rabbittype){
4271 player[closest].proportionhead=1.2*headprop;
4272 player[closest].proportionbody=1.05*bodyprop;
4273 player[closest].proportionarms=1.00*armprop;
4274 player[closest].proportionlegs=1.1*legprop;
4275 player[closest].proportionlegs.y=1.05*legprop;
4282 if(Compare(consoletext[0],"sizemin ",0,7)||Compare(consoletext[0],"Sizemin ",0,7)){
4283 for(i=1;i<numplayers;i++){
4284 if(player[i].scale<0.8*0.2)player[i].scale=0.8*0.2;
4290 if(Compare(consoletext[0],"tutorial ",0,8)||Compare(consoletext[0],"Tutorial ",0,8)){
4291 for(j=9;j<consolechars[0];j++){
4292 mapname[j-9]=consoletext[0][j];
4295 tutoriallevel=atoi(mapname);
4301 if(Compare(consoletext[0],"tintg ",0,5)||Compare(consoletext[0],"Tintg ",0,5)){
4302 for(j=6;j<consolechars[0];j++){
4303 mapname[j-6]=consoletext[0][j];
4306 tintg=atof(mapname);
4311 if(Compare(consoletext[0],"tintb ",0,5)||Compare(consoletext[0],"Tintb ",0,5)){
4312 for(j=6;j<consolechars[0];j++){
4313 mapname[j-6]=consoletext[0][j];
4316 tintb=atof(mapname);
4321 if(Compare(consoletext[0],"hostile ",0,7)){
4322 for(j=8;j<consolechars[0];j++){
4323 mapname[j-8]=consoletext[0][j];
4326 hostile=atoi(mapname);
4332 if(Compare(consoletext[0],"type active ",0,11)){
4333 editoractive=typeactive;
4338 if(Compare(consoletext[0],"indemo ",0,6)){
4340 hotspot[numhotspots]=player[0].coords;
4341 hotspotsize[numhotspots]=0;
4342 hotspottype[numhotspots]=-111;
4344 strcpy(hotspottext[numhotspots],"mapname");
4350 if(Compare(consoletext[0],"notindemo ",0,9)){
4357 if(Compare(consoletext[0],"type sitting ",0,12)){
4358 editoractive=typesitting;
4363 if(Compare(consoletext[0],"type sitting wall ",0,17)){
4364 editoractive=typesittingwall;
4369 if(Compare(consoletext[0],"type sleeping ",0,13)){
4370 editoractive=typesleeping;
4374 if(Compare(consoletext[0],"type dead1 ",0,10)){
4375 editoractive=typedead1;
4379 if(Compare(consoletext[0],"type dead2 ",0,10)){
4380 editoractive=typedead2;
4384 if(Compare(consoletext[0],"type dead3 ",0,10)){
4385 editoractive=typedead3;
4388 if(Compare(consoletext[0],"type dead4 ",0,10)){
4389 editoractive=typedead4;
4394 if(Compare(consoletext[0],"path keepwalking ",0,16)){
4395 editorpathtype=wpkeepwalking;
4400 if(Compare(consoletext[0],"path pause ",0,10)){
4401 editorpathtype=wppause;
4406 if(Compare(consoletext[0],"mapkilleveryone ",0,15)){
4407 maptype=mapkilleveryone;
4412 if(Compare(consoletext[0],"mapgosomewhere ",0,14)){
4413 maptype=mapgosomewhere;
4418 if(Compare(consoletext[0],"mapkillsomeone ",0,14)){
4419 maptype=mapkillsomeone;
4425 if(Compare(consoletext[0],"mapkillmost ",0,11)){
4426 maptype=mapkillmost;
4432 if(Compare(consoletext[0],"hs ",0,2)){
4436 hotspot[numhotspots]=player[0].coords;
4441 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4442 mapname[j-startpoint]=consoletext[0][j];
4444 if(consoletext[0][j]=='\0')alldone=1;
4446 mapname[j-startpoint]='\0';
4448 hotspotsize[numhotspots]=atof(mapname);
4452 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4453 mapname[j-startpoint]=consoletext[0][j];
4455 if(consoletext[0][j]=='\0')alldone=1;
4457 mapname[j-startpoint]='\0';
4459 hotspottype[numhotspots]=atoi(mapname);
4463 while(consoletext[0][j]!='\0'&&!alldone&&j<255){
4464 mapname[j-startpoint]=consoletext[0][j];
4466 if(consoletext[0][j]=='\0')alldone=1;
4468 mapname[j-startpoint]='\n';
4469 mapname[j-startpoint+1]='\0';
4471 strcpy(hotspottext[numhotspots],mapname);
4478 if(Compare(consoletext[0],"dialogue ",0,8)){
4485 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4486 mapname[j-startpoint]=consoletext[0][j];
4488 if(consoletext[0][j]=='\0')alldone=1;
4490 mapname[j-startpoint]='\0';
4493 dialoguetype[numdialogues]=atoi(mapname);
4511 for(j=startpoint;j<consolechars[0];j++){
4512 mapname[j-startpoint+16]=consoletext[0][j];
4514 mapname[consolechars[0]-startpoint+16]='.';
4515 mapname[consolechars[0]-startpoint+17]='t';
4516 mapname[consolechars[0]-startpoint+18]='x';
4517 mapname[consolechars[0]-startpoint+19]='t';
4518 mapname[consolechars[0]-startpoint+20]='\0';
4520 for(j=0;j<max_dialoguelength;j++){
4522 dialoguetext[numdialogues][j][k]='\0';
4525 dialoguename[numdialogues][j][k]='\0';
4529 ifstream ipstream(ConvertFileName(mapname));
4530 ipstream.ignore(256,':');
4531 ipstream >> numdialogueboxes[numdialogues];
4532 for(i=0;i<numdialogueboxes[numdialogues];i++){
4533 ipstream.ignore(256,':');
4534 ipstream.ignore(256,':');
4535 ipstream.ignore(256,' ');
4536 ipstream >> dialogueboxlocation[numdialogues][i];
4537 ipstream.ignore(256,':');
4538 ipstream >> dialogueboxcolor[numdialogues][i][0];
4539 ipstream >> dialogueboxcolor[numdialogues][i][1];
4540 ipstream >> dialogueboxcolor[numdialogues][i][2];
4541 ipstream.ignore(256,':');
4542 ipstream.getline(dialoguename[numdialogues][i],64);
4543 ipstream.ignore(256,':');
4544 ipstream.ignore(256,' ');
4545 ipstream.getline(dialoguetext[numdialogues][i],128);
4547 if(dialoguetext[numdialogues][i][j]=='\\')dialoguetext[numdialogues][i][j]='\n';
4549 ipstream.ignore(256,':');
4550 ipstream >> dialogueboxsound[numdialogues][i];
4553 for(i=0;i<numdialogueboxes[numdialogues];i++){
4554 for(j=0;j<numplayers;j++){
4555 participantfacing[numdialogues][i][j]=player[j].facing;
4562 whichdialogue=numdialogues;
4570 if(Compare(consoletext[0],"fixdialogue ",0,11)){
4578 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4579 mapname[j-startpoint]=consoletext[0][j];
4581 if(consoletext[0][j]=='\0')alldone=1;
4583 mapname[j-startpoint]='\0';
4586 whichdi=atoi(mapname);
4604 for(j=startpoint;j<consolechars[0];j++){
4605 mapname[j-startpoint+16]=consoletext[0][j];
4607 mapname[consolechars[0]-startpoint+16]='.';
4608 mapname[consolechars[0]-startpoint+17]='t';
4609 mapname[consolechars[0]-startpoint+18]='x';
4610 mapname[consolechars[0]-startpoint+19]='t';
4611 mapname[consolechars[0]-startpoint+20]='\0';
4613 for(j=0;j<max_dialoguelength;j++){
4615 dialoguetext[whichdi][j][k]='\0';
4618 dialoguename[whichdi][j][k]='\0';
4622 ifstream ipstream(ConvertFileName(mapname));
4623 ipstream.ignore(256,':');
4624 ipstream >> numdialogueboxes[whichdi];
4625 for(i=0;i<numdialogueboxes[whichdi];i++){
4626 ipstream.ignore(256,':');
4627 ipstream.ignore(256,':');
4628 ipstream.ignore(256,' ');
4629 ipstream >> dialogueboxlocation[whichdi][i];
4630 ipstream.ignore(256,':');
4631 ipstream >> dialogueboxcolor[whichdi][i][0];
4632 ipstream >> dialogueboxcolor[whichdi][i][1];
4633 ipstream >> dialogueboxcolor[whichdi][i][2];
4634 ipstream.ignore(256,':');
4635 ipstream.getline(dialoguename[whichdi][i],64);
4636 ipstream.ignore(256,':');
4637 ipstream.ignore(256,' ');
4638 ipstream.getline(dialoguetext[whichdi][i],128);
4640 if(dialoguetext[whichdi][i][j]=='\\')dialoguetext[whichdi][i][j]='\n';
4642 ipstream.ignore(256,':');
4643 ipstream >> dialogueboxsound[whichdi][i];
4651 if(Compare(consoletext[0],"fixtype ",0,7)){
4659 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4660 mapname[j-startpoint]=consoletext[0][j];
4662 if(consoletext[0][j]=='\0')alldone=1;
4664 mapname[j-startpoint]='\0';
4665 dialoguetype[0]=atoi(mapname);
4673 if(Compare(consoletext[0],"fixrotation ",0,11)){
4674 participantrotation[whichdialogue][participantfocus[whichdialogue][indialogue]]=player[participantfocus[whichdialogue][indialogue]].rotation;
4679 if(Compare(consoletext[0],"ddialogue ",0,9)){
4681 if(numdialogues<0)numdialogues=0;
4686 if(Compare(consoletext[0],"immobile ",0,8)){
4687 player[0].immobile=1;
4691 if(Compare(consoletext[0],"mobile ",0,6)){
4692 player[0].immobile=0;
4696 if(Compare(consoletext[0],"play ",0,4)){
4703 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4704 mapname[j-startpoint]=consoletext[0][j];
4706 if(consoletext[0][j]=='\0')alldone=1;
4708 mapname[j-startpoint]='\0';
4711 whichdialogue=atoi(mapname);
4713 if(numdialogues>whichdialogue){
4714 for(i=0;i<numdialogueboxes[whichdialogue];i++){
4715 player[participantfocus[whichdialogue][i]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][i]];
4716 player[participantfocus[whichdialogue][i]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
4717 player[participantfocus[whichdialogue][i]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
4718 player[participantfocus[whichdialogue][i]].velocity=0;
4719 player[participantfocus[whichdialogue][i]].targetanimation=player[participantfocus[whichdialogue][i]].getIdle();
4720 player[participantfocus[whichdialogue][i]].targetframe=0;
4728 //if(dialogueboxsound[whichdialogue][indialogue]!=0){
4732 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
4733 temppos=temppos-viewer;
4734 Normalise(&temppos);
4744 whichsoundplay=rabbitchitter;
4745 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
4746 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
4747 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
4748 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
4749 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
4750 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
4751 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
4752 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
4753 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
4754 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
4755 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
4756 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
4757 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
4758 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
4759 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
4760 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
4761 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
4762 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
4763 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
4764 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, TRUE);
4765 FSOUND_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
4766 FSOUND_SetVolume(channels[whichsoundplay], 256);
4767 FSOUND_SetPaused(channels[whichsoundplay], FALSE);
4775 if(Compare(consoletext[0],"dhs ",0,3)){
4777 if(numhotspots<0)numhotspots=0;
4782 if(Compare(consoletext[0],"proportion ",0,10)||Compare(consoletext[0],"Proportion ",0,4)){
4789 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4790 mapname[j-startpoint]=consoletext[0][j];
4792 if(consoletext[0][j]=='\0')alldone=1;
4794 mapname[j-startpoint]='\0';
4796 headprop=atof(mapname);
4800 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4801 mapname[j-startpoint]=consoletext[0][j];
4803 if(consoletext[0][j]=='\0')alldone=1;
4805 mapname[j-startpoint]='\0';
4807 bodyprop=atof(mapname);
4811 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4812 mapname[j-startpoint]=consoletext[0][j];
4814 if(consoletext[0][j]=='\0')alldone=1;
4816 mapname[j-startpoint]='\0';
4818 armprop=atof(mapname);
4822 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4823 mapname[j-startpoint]=consoletext[0][j];
4825 if(consoletext[0][j]=='\0')alldone=1;
4827 mapname[j-startpoint]='\0';
4829 legprop=atof(mapname);
4831 if(player[0].creature==wolftype){
4832 player[0].proportionhead=1.1*headprop;
4833 player[0].proportionbody=1.1*bodyprop;
4834 player[0].proportionarms=1.1*armprop;
4835 player[0].proportionlegs=1.1*legprop;
4838 if(player[0].creature==rabbittype){
4839 player[0].proportionhead=1.2*headprop;
4840 player[0].proportionbody=1.05*bodyprop;
4841 player[0].proportionarms=1.00*armprop;
4842 player[0].proportionlegs=1.1*legprop;
4843 player[0].proportionlegs.y=1.05*legprop;
4849 if(Compare(consoletext[0],"allimmobile ",0,11)||Compare(consoletext[0],"Allimmobile ",0,11)){
4850 for(i=0;i<numplayers;i++){
4851 if(i>0)player[i].immobile=1;
4857 if(Compare(consoletext[0],"default ",0,7)||Compare(consoletext[0],"Default ",0,7)){
4858 player[0].armorhead=1;
4859 player[0].armorhigh=1;
4860 player[0].armorlow=1;
4861 player[0].protectionhead=1;
4862 player[0].protectionhigh=1;
4863 player[0].protectionlow=1;
4864 player[0].metalhead=1;
4865 player[0].metalhigh=1;
4866 player[0].metallow=1;
4868 player[0].speedmult=1;
4871 if(player[0].creature==wolftype){
4872 player[0].proportionhead=1.1;
4873 player[0].proportionbody=1.1;
4874 player[0].proportionarms=1.1;
4875 player[0].proportionlegs=1.1;
4878 if(player[0].creature==rabbittype){
4879 player[0].proportionhead=1.2;
4880 player[0].proportionbody=1.05;
4881 player[0].proportionarms=1.00;
4882 player[0].proportionlegs=1.1;
4883 player[0].proportionlegs.y=1.05;
4886 player[0].numclothes=0;
4887 if(player[0].whichskin==0){
4888 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4890 else if(player[0].whichskin==1){
4891 LoadTextureSave(":Data:Textures:Fur.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4893 else if(player[0].whichskin==2){
4894 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4896 else if(player[0].whichskin==3){
4897 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4899 else if(player[0].whichskin==4){
4900 LoadTextureSave(":Data:Textures:Otter.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4902 else if(player[0].whichskin==5){
4903 LoadTextureSave(":Data:Textures:Opal.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4905 else if(player[0].whichskin==6){
4906 LoadTextureSave(":Data:Textures:Sable.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4908 else if(player[0].whichskin==7){
4909 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4911 else if(player[0].whichskin==8){
4912 LoadTextureSave(":Data:Textures:BW2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4914 else if(player[0].whichskin==9){
4915 LoadTextureSave(":Data:Textures:WB2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4918 editoractive=typeactive;
4919 player[0].immobile=0;
4926 if(Compare(consoletext[0],"tint ",0,4)||Compare(consoletext[0],"Tint ",0,4)){
4932 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4933 mapname[j-startpoint]=consoletext[0][j];
4935 if(consoletext[0][j]=='\0')alldone=1;
4937 mapname[j-startpoint]='\0';
4939 tintr=atof(mapname);
4943 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4944 mapname[j-startpoint]=consoletext[0][j];
4946 if(consoletext[0][j]=='\0')alldone=1;
4948 mapname[j-startpoint]='\0';
4950 tintg=atof(mapname);
4954 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4955 mapname[j-startpoint]=consoletext[0][j];
4957 if(consoletext[0][j]=='\0')alldone=1;
4959 mapname[j-startpoint]='\0';
4961 tintb=atof(mapname);
4966 if(Compare(consoletext[0],"sky tint ",0,8)||Compare(consoletext[0],"Sky Tint ",0,8)){
4972 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4973 mapname[j-startpoint]=consoletext[0][j];
4975 if(consoletext[0][j]=='\0')alldone=1;
4977 mapname[j-startpoint]='\0';
4979 skyboxr=atof(mapname);
4983 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4984 mapname[j-startpoint]=consoletext[0][j];
4986 if(consoletext[0][j]=='\0')alldone=1;
4988 mapname[j-startpoint]='\0';
4990 skyboxg=atof(mapname);
4994 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4995 mapname[j-startpoint]=consoletext[0][j];
4997 if(consoletext[0][j]=='\0')alldone=1;
4999 mapname[j-startpoint]='\0';
5001 skyboxb=atof(mapname);
5003 skyboxlightr=skyboxr;
5004 skyboxlightg=skyboxg;
5005 skyboxlightb=skyboxb;
5009 //if(skyboxtexture){
5010 terrain.DoShadows();
5011 objects.DoShadows();
5013 else terrain.DoLighting();
5018 if(Compare(consoletext[0],"sky light ",0,9)||Compare(consoletext[0],"Sky Light ",0,9)){
5024 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5025 mapname[j-startpoint]=consoletext[0][j];
5027 if(consoletext[0][j]=='\0')alldone=1;
5029 mapname[j-startpoint]='\0';
5031 skyboxlightr=atof(mapname);
5035 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5036 mapname[j-startpoint]=consoletext[0][j];
5038 if(consoletext[0][j]=='\0')alldone=1;
5040 mapname[j-startpoint]='\0';
5042 skyboxlightg=atof(mapname);
5046 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5047 mapname[j-startpoint]=consoletext[0][j];
5049 if(consoletext[0][j]=='\0')alldone=1;
5051 mapname[j-startpoint]='\0';
5053 skyboxlightb=atof(mapname);
5057 //if(skyboxtexture){
5058 terrain.DoShadows();
5059 objects.DoShadows();
5061 else terrain.DoLighting();
5066 if(Compare(consoletext[0],"skybox ",0,6)||Compare(consoletext[0],"Skybox ",0,6)){
5067 skyboxtexture=1-skyboxtexture;
5070 //if(skyboxtexture){
5071 terrain.DoShadows();
5072 objects.DoShadows();
5074 else terrain.DoLighting();
5079 if(Compare(consoletext[0],"protection ",0,10)||Compare(consoletext[0],"Protection ",0,10)){
5085 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5086 mapname[j-startpoint]=consoletext[0][j];
5088 if(consoletext[0][j]=='\0')alldone=1;
5090 mapname[j-startpoint]='\0';
5092 player[0].protectionhead=atof(mapname);
5096 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5097 mapname[j-startpoint]=consoletext[0][j];
5099 if(consoletext[0][j]=='\0')alldone=1;
5101 mapname[j-startpoint]='\0';
5103 player[0].protectionhigh=atof(mapname);
5107 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5108 mapname[j-startpoint]=consoletext[0][j];
5110 if(consoletext[0][j]=='\0')alldone=1;
5112 mapname[j-startpoint]='\0';
5114 player[0].protectionlow=atof(mapname);
5119 if(Compare(consoletext[0],"armor ",0,5)||Compare(consoletext[0],"Armor ",0,5)){
5125 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5126 mapname[j-startpoint]=consoletext[0][j];
5128 if(consoletext[0][j]=='\0')alldone=1;
5130 mapname[j-startpoint]='\0';
5132 player[0].armorhead=atof(mapname);
5136 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5137 mapname[j-startpoint]=consoletext[0][j];
5139 if(consoletext[0][j]=='\0')alldone=1;
5141 mapname[j-startpoint]='\0';
5143 player[0].armorhigh=atof(mapname);
5147 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5148 mapname[j-startpoint]=consoletext[0][j];
5150 if(consoletext[0][j]=='\0')alldone=1;
5152 mapname[j-startpoint]='\0';
5154 player[0].armorlow=atof(mapname);
5159 if(Compare(consoletext[0],"protectionreset ",0,15)||Compare(consoletext[0],"Protectionreset ",0,15)){
5160 for(i=0;i<numplayers;i++){
5161 player[i].protectionhead=1.0;
5162 player[i].protectionhigh=1.0;
5163 player[i].protectionlow=1.0;
5164 player[i].armorhead=1.0;
5165 player[i].armorhigh=1.0;
5166 player[i].armorlow=1.0;
5172 if(Compare(consoletext[0],"protectionnear ",0,14)||Compare(consoletext[0],"Protectionnear ",0,14)){
5174 float closestdist=-1;
5177 for(i=1;i<numplayers;i++){
5178 distance=findDistancefast(&player[i].coords,&player[0].coords);
5179 if(closestdist==-1||distance<closestdist){
5180 closestdist=distance;
5190 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5191 mapname[j-startpoint]=consoletext[0][j];
5193 if(consoletext[0][j]=='\0')alldone=1;
5195 mapname[j-startpoint]='\0';
5197 player[closest].protectionhead=atof(mapname);
5201 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5202 mapname[j-startpoint]=consoletext[0][j];
5204 if(consoletext[0][j]=='\0')alldone=1;
5206 mapname[j-startpoint]='\0';
5208 player[closest].protectionhigh=atof(mapname);
5212 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5213 mapname[j-startpoint]=consoletext[0][j];
5215 if(consoletext[0][j]=='\0')alldone=1;
5217 mapname[j-startpoint]='\0';
5219 player[closest].protectionlow=atof(mapname);
5224 if(Compare(consoletext[0],"armornear ",0,9)||Compare(consoletext[0],"Armornear ",0,9)){
5226 float closestdist=-1;
5229 for(i=1;i<numplayers;i++){
5230 distance=findDistancefast(&player[i].coords,&player[0].coords);
5231 if(closestdist==-1||distance<closestdist){
5232 closestdist=distance;
5241 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5242 mapname[j-startpoint]=consoletext[0][j];
5244 if(consoletext[0][j]=='\0')alldone=1;
5246 mapname[j-startpoint]='\0';
5248 player[closest].armorhead=atof(mapname);
5252 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5253 mapname[j-startpoint]=consoletext[0][j];
5255 if(consoletext[0][j]=='\0')alldone=1;
5257 mapname[j-startpoint]='\0';
5259 player[closest].armorhigh=atof(mapname);
5263 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5264 mapname[j-startpoint]=consoletext[0][j];
5266 if(consoletext[0][j]=='\0')alldone=1;
5268 mapname[j-startpoint]='\0';
5270 player[closest].armorlow=atof(mapname);
5276 if(Compare(consoletext[0],"metal ",0,5)||Compare(consoletext[0],"Metal ",0,5)){
5282 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5283 mapname[j-startpoint]=consoletext[0][j];
5285 if(consoletext[0][j]=='\0')alldone=1;
5287 mapname[j-startpoint]='\0';
5289 player[0].metalhead=atof(mapname);
5293 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5294 mapname[j-startpoint]=consoletext[0][j];
5296 if(consoletext[0][j]=='\0')alldone=1;
5298 mapname[j-startpoint]='\0';
5300 player[0].metalhigh=atof(mapname);
5304 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5305 mapname[j-startpoint]=consoletext[0][j];
5307 if(consoletext[0][j]=='\0')alldone=1;
5310 mapname[j-startpoint]='\0';
5312 player[0].metallow=atof(mapname);
5317 if(Compare(consoletext[0],"noclothesnear ",0,13)||Compare(consoletext[0],"Noclothesnear ",0,13)){
5319 float closestdist=-1;
5322 for(i=1;i<numplayers;i++){
5323 distance=findDistancefast(&player[i].coords,&player[0].coords);
5324 if(closestdist==-1||distance<closestdist){
5325 closestdist=distance;
5329 player[closest].numclothes=0;
5330 if(player[closest].whichskin==0){
5331 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5333 else if(player[closest].whichskin==1){
5334 LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5336 else if(player[closest].whichskin==2){
5337 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5339 else if(player[closest].whichskin==3){
5340 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5342 else if(player[closest].whichskin==4){
5343 LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5345 else if(player[closest].whichskin==5){
5346 LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5348 else if(player[closest].whichskin==6){
5349 LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5351 else if(player[closest].whichskin==7){
5352 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5354 else if(player[closest].whichskin==8){
5355 LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5357 else if(player[closest].whichskin==9){
5358 LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5364 if(Compare(consoletext[0],"noclothes ",0,9)||Compare(consoletext[0],"Noclothes ",0,9)){
5367 player[closest].numclothes=0;
5368 if(player[closest].whichskin==0){
5369 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5371 else if(player[closest].whichskin==1){
5372 LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5374 else if(player[closest].whichskin==2){
5375 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5377 else if(player[closest].whichskin==3){
5378 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5380 else if(player[closest].whichskin==4){
5381 LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5383 else if(player[closest].whichskin==5){
5384 LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5386 else if(player[closest].whichskin==6){
5387 LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5389 else if(player[closest].whichskin==7){
5390 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5392 else if(player[closest].whichskin==8){
5393 LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5395 else if(player[closest].whichskin==9){
5396 LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5402 if((Compare(consoletext[0],"Clothes ",0,7)||Compare(consoletext[0],"clothes ",0,7))){
5418 for(j=8;j<consolechars[0];j++){
5419 mapname[j-8+15]=consoletext[0][j];
5421 mapname[consolechars[0]-8+15]='.';
5422 mapname[consolechars[0]-8+16]='p';
5423 mapname[consolechars[0]-8+17]='n';
5424 mapname[consolechars[0]-8+18]='g';
5425 mapname[consolechars[0]-8+19]='\0';
5427 //:Data:Textures:Pants.png
5429 if(AddClothes((char *)mapname,0,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize)){
5430 player[0].DoMipmaps(5,0,0,player[0].skeleton.skinsize,player[0].skeleton.skinsize);
5431 strcpy(player[0].clothes[player[0].numclothes],mapname);
5432 player[0].clothestintr[player[0].numclothes]=tintr;
5433 player[0].clothestintg[player[0].numclothes]=tintg;
5434 player[0].clothestintb[player[0].numclothes]=tintb;
5435 player[0].numclothes++;
5441 if(Compare(consoletext[0],"belt ",0,4)||Compare(consoletext[0],"belt ",0,4)){
5442 player[0].skeleton.clothes = 1-player[0].skeleton.clothes;
5447 if(Compare(consoletext[0],"Cellophane ",0,10)||Compare(consoletext[0],"cellophane ",0,10)){
5448 cellophane=1-cellophane;
5451 for(i=0;i<numplayers;i++){
5452 player[i].proportionhead.z=0;
5453 player[i].proportionbody.z=0;
5454 player[i].proportionarms.z=0;
5455 player[i].proportionlegs.z=0;
5460 for(i=0;i<numplayers;i++){
5461 player[i].proportionhead.z=player[i].proportionhead.x;
5462 player[i].proportionbody.z=player[i].proportionbody.x;
5463 player[i].proportionarms.z=player[i].proportionarms.x;
5464 player[i].proportionlegs.z=player[i].proportionlegs.x;
5471 if((Compare(consoletext[0],"Clothesnear ",0,11)||Compare(consoletext[0],"clothesnear ",0,11))){
5487 for(j=12;j<consolechars[0];j++){
5488 mapname[j-12+15]=consoletext[0][j];
5490 mapname[consolechars[0]-12+15]='.';
5491 mapname[consolechars[0]-12+16]='p';
5492 mapname[consolechars[0]-12+17]='n';
5493 mapname[consolechars[0]-12+18]='g';
5494 mapname[consolechars[0]-12+19]='\0';
5496 //:Data:Textures:Pants.png
5498 float closestdist=-1;
5501 for(i=1;i<numplayers;i++){
5502 distance=findDistancefast(&player[i].coords,&player[0].coords);
5503 if(closestdist==-1||distance<closestdist){
5504 closestdist=distance;
5509 if(AddClothes((char *)mapname,0,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize)){
5510 player[closest].DoMipmaps(5,0,0,player[closest].skeleton.skinsize,player[closest].skeleton.skinsize);
5511 strcpy(player[closest].clothes[player[closest].numclothes],mapname);
5512 player[closest].clothestintr[player[closest].numclothes]=tintr;
5513 player[closest].clothestintg[player[closest].numclothes]=tintg;
5514 player[closest].clothestintb[player[closest].numclothes]=tintb;
5515 player[closest].numclothes++;
5521 if(Compare(consoletext[0],"funnybunny ",0,10)||Compare(consoletext[0],"funny bunny ",0,11)){
5522 player[0].skeleton.id=0;
5523 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);
5524 LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5525 player[0].creature=rabbittype;
5528 player[0].proportionhead=1.2;
5529 player[0].proportionbody=1.05;
5530 player[0].proportionarms=1.00;
5531 player[0].proportionlegs=1.1;
5532 player[0].proportionlegs.y=1.05;
5533 player[0].headless=0;
5535 player[0].damagetolerance=200;
5539 if(Compare(consoletext[0],"wolfieisgod ",0,11)||Compare(consoletext[0],"wolfie is god ",0,12)){
5540 player[0].skeleton.id=0;
5541 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);
5542 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5543 player[0].creature=wolftype;
5545 player[0].proportionhead=1.1;
5546 player[0].proportionbody=1.1;
5547 player[0].proportionarms=1.1;
5548 player[0].proportionlegs=1.1;
5549 player[0].proportionlegs.y=1.1;
5550 player[0].scale=.23;
5552 player[0].damagetolerance=300;
5556 /*if(Compare(consoletext[0],"kungfu ",0,6)||Compare(consoletext[0],"kung fu ",0,7)){
5557 LoadTextureSave(":Data:Textures:Kungfu.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5560 if(Compare(consoletext[0],"rambo ",0,5)){
5561 LoadTextureSave(":Data:Textures:Leather.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5564 if(Compare(consoletext[0],"david ",0,5)){
5565 LoadTextureSave(":Data:Textures:David.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5568 if(Compare(consoletext[0],"wolf ",0,4)){
5569 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5572 if(Compare(consoletext[0],"darkwolf ",0,8)){
5573 LoadTextureSave(":Data:Textures:DarkWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5576 if(Compare(consoletext[0],"snowwolf ",0,8)){
5577 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5580 if(Compare(consoletext[0],"lizardwolf ",0,10)){
5581 LoadTextureSave(":Data:Textures:Lizardwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5584 if(Compare(consoletext[0],"white ",0,5)){
5585 LoadTextureSave(":Data:Textures:fur.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5588 if(Compare(consoletext[0],"brown ",0,5)){
5589 LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5592 if(Compare(consoletext[0],"black ",0,5)){
5593 LoadTextureSave(":Data:Textures:fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5596 if(consolechars[0]>0){
5599 consoletext[k][j]=consoletext[k-1][j];
5601 consolechars[k]=consolechars[k-1];
5604 consoletext[0][j]=' ';
5610 PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, TRUE);
5611 FSOUND_SetVolume(channels[consolefailsound], 256);
5612 FSOUND_SetPaused(channels[consolefailsound], FALSE);
5621 togglekeydelay[i]=0;
5625 consoleblinkdelay-=multiplier;
5626 if(consoleblinkdelay<=0){
5627 consoleblinkdelay=.3;
5628 consoleblink=1-consoleblink;
5632 if(IsKeyDown(theKeyMap, MAC_Q_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)){
5635 if(newdetail>2)newdetail=detail;
5636 if(newdetail<0)newdetail=detail;
5637 if(newscreenwidth>3000)newscreenwidth=screenwidth;
5638 if(newscreenwidth<0)newscreenwidth=screenwidth;
5639 if(newscreenheight>3000)newscreenheight=screenheight;
5640 if(newscreenheight<0)newscreenheight=screenheight;
5642 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
5643 opstream << "Screenwidth:\n";
5644 opstream << newscreenwidth;
5645 opstream << "\nScreenheight:\n";
5646 opstream << newscreenheight;
5647 opstream << "\nMouse sensitivity:\n";
5648 opstream << usermousesensitivity;
5649 opstream << "\nBlur(0,1):\n";
5650 opstream << ismotionblur;
5651 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
5652 opstream << newdetail;
5653 opstream << "\nFloating jump:\n";
5654 opstream << floatjump;
5655 opstream << "\nMouse jump:\n";
5656 opstream << mousejump;
5657 opstream << "\nAmbient sound:\n";
5658 opstream << ambientsound;
5659 opstream << "\nBlood (0,1,2):\n";
5660 opstream << bloodtoggle;
5661 opstream << "\nAuto slomo:\n";
5662 opstream << autoslomo;
5663 opstream << "\nFoliage:\n";
5664 opstream << foliage;
5665 opstream << "\nMusic:\n";
5666 opstream << musictoggle;
5667 opstream << "\nTrilinear:\n";
5668 opstream << trilinear;
5669 opstream << "\nDecals(shadows,blood puddles,etc):\n";
5671 opstream << "\nInvert mouse:\n";
5672 opstream << invertmouse;
5673 opstream << "\nGamespeed:\n";
5674 if(oldgamespeed==0)oldgamespeed=1;
5675 opstream << oldgamespeed;
5676 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
5677 opstream << difficulty;
5678 opstream << "\nDamage effects(blackout, doublevision):\n";
5679 opstream << damageeffects;
5680 opstream << "\nText:\n";
5681 opstream << texttoggle;
5682 opstream << "\nDebug:\n";
5683 opstream << debugmode;
5684 opstream << "\nVBL Sync:\n";
5685 opstream << vblsync;
5686 opstream << "\nShow Points:\n";
5687 opstream << showpoints;
5688 opstream << "\nAlways Blur:\n";
5689 opstream << alwaysblur;
5690 opstream << "\nImmediate mode (turn on on G5):\n";
5691 opstream << immediate;
5692 opstream << "\nVelocity blur:\n";
5693 opstream << velocityblur;
5694 opstream << "\nVolume:\n";
5696 opstream << "\nForward key:\n";
5697 opstream << KeyToChar(forwardkey);
5698 opstream << "\nBack key:\n";
5699 opstream << KeyToChar(backkey);
5700 opstream << "\nLeft key:\n";
5701 opstream << KeyToChar(leftkey);
5702 opstream << "\nRight key:\n";
5703 opstream << KeyToChar(rightkey);
5704 opstream << "\nJump key:\n";
5705 opstream << KeyToChar(jumpkey);
5706 opstream << "\nCrouch key:\n";
5707 opstream << KeyToChar(crouchkey);
5708 opstream << "\nDraw key:\n";
5709 opstream << KeyToChar(drawkey);
5710 opstream << "\nThrow key:\n";
5711 opstream << KeyToChar(throwkey);
5712 opstream << "\nAttack key:\n";
5713 opstream << KeyToChar(attackkey);
5714 opstream << "\nChat key:\n";
5715 opstream << KeyToChar(chatkey);
5720 static int oldwinfreeze;
5721 if(winfreeze&&!oldwinfreeze){
5722 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
5723 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
5724 FSOUND_SetVolume(channels[consolesuccesssound], 256);
5725 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
5727 if(winfreeze==0)oldwinfreeze=winfreeze;
5728 else oldwinfreeze++;
5730 if((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY))&&!oldjumpkeydown&&!campaign){
5731 if(winfreeze)winfreeze=0;
5734 if((IsKeyDown(theKeyMap, MAC_ESCAPE_KEY))&&!campaign&&gameon){
5740 if((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY))){
5743 if(!IsKeyDown(theKeyMap, jumpkey)&&!IsKeyDown(theKeyMap, MAC_SPACE_KEY))oldjumpkeydown=0;
5745 if(!freeze&&!winfreeze&&!(mainmenu&&gameon)&&(gameon||!gamestarted)){
5747 static bool oldbuttondialogue;
5749 if(indialogue!=-1)talkdelay=1;
5750 talkdelay-=multiplier;
5753 if(indialogue==-1&&(animation[player[0].targetanimation].height!=highheight)/*&&!hostile*/)
5754 for(i=0;i<numdialogues;i++){
5755 int realdialoguetype;
5757 if(dialoguetype[i]>49){
5758 realdialoguetype=dialoguetype[i]-50;
5761 else if(dialoguetype[i]>39){
5762 realdialoguetype=dialoguetype[i]-40;
5765 else if(dialoguetype[i]>29){
5766 realdialoguetype=dialoguetype[i]-30;
5769 else if(dialoguetype[i]>19){
5770 realdialoguetype=dialoguetype[i]-20;
5773 else if(dialoguetype[i]>9){
5774 realdialoguetype=dialoguetype[i]-10;
5778 realdialoguetype=dialoguetype[i];
5781 if((!hostile||(dialoguetype[i]>40&&dialoguetype[i]<50))&&realdialoguetype<numplayers&&realdialoguetype>0&&(dialoguegonethrough[i]==0||!special)&&(special||(IsKeyDown(theKeyMap, attackkey)&&!oldbuttondialogue))){
5782 if(findDistancefast(&player[0].coords,&player[realdialoguetype].coords)<6||player[realdialoguetype].howactive>=typedead1||(dialoguetype[i]>40&&dialoguetype[i]<50)){
5784 for(j=0;j<numdialogueboxes[whichdialogue];j++){
5785 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
5786 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
5787 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
5788 player[participantfocus[whichdialogue][j]].velocity=0;
5789 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
5790 player[participantfocus[whichdialogue][j]].targetframe=0;
5795 dialoguegonethrough[i]++;
5796 if(dialogueboxsound[whichdialogue][indialogue]!=0){
5797 static float gLoc[3];
5798 static float vel[3];
5800 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
5801 temppos=temppos-viewer;
5802 Normalise(&temppos);
5807 gLoc[2]=temppos.z;vel[0]=0;
5811 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
5812 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
5813 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
5814 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
5815 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
5816 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
5817 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
5818 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
5819 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
5820 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
5821 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
5822 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
5823 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
5824 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
5825 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
5826 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
5827 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
5828 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
5829 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
5830 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
5831 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, TRUE);
5832 FSOUND_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
5833 FSOUND_SetVolume(channels[whichsoundplay], 256);
5834 FSOUND_SetPaused(channels[whichsoundplay], FALSE);
5836 if(IsKeyDown(theKeyMap, attackkey))oldbuttondialogue=1;
5841 windvar+=multiplier;
5842 smoketex+=multiplier;
5843 tutorialstagetime+=multiplier;
5845 static float hotspotvisual[40];
5849 for(i=0;i<numhotspots;i++)
5850 hotspotvisual[i]-=multiplier/320;
5852 for(i=0;i<numhotspots;i++){
5853 //if(hotspottype[i]<=10)
5854 while(hotspotvisual[i]<0){
5856 hotspotsprite.x=float(abs(Random()%100000))/100000*hotspotsize[i];
5857 hotspotsprite=DoRotation(hotspotsprite,0,0,Random()%360);
5858 hotspotsprite=DoRotation(hotspotsprite,0,Random()%360,0);
5859 hotspotsprite+=hotspot[i];
5860 sprites.MakeSprite(breathsprite, hotspotsprite, hotspotsprite*0, 1,0.5,0, 7, 0.4);
5861 hotspotvisual[i]+=0.1/hotspotsize[i]/hotspotsize[i]/hotspotsize[i];
5865 for(i=0;i<numhotspots;i++){
5866 if(hotspottype[i]<=10&&hotspottype[i]>0){
5867 hotspot[i]=player[hotspottype[i]].coords;
5873 if(tutoriallevel&&tutorialstagetime>tutorialmaxtime){
5876 if(tutorialstage<=1){
5881 if(tutorialstage==1){
5884 if(tutorialstage==2){
5887 if(tutorialstage==3){
5888 tutorialmaxtime=600;
5890 if(tutorialstage==4){
5891 tutorialmaxtime=1000;
5893 if(tutorialstage==5){
5894 tutorialmaxtime=600;
5896 if(tutorialstage==6){
5897 tutorialmaxtime=600;
5899 if(tutorialstage==7){
5900 tutorialmaxtime=600;
5902 if(tutorialstage==8){
5903 tutorialmaxtime=600;
5905 if(tutorialstage==9){
5906 tutorialmaxtime=600;
5908 if(tutorialstage==10){
5911 if(tutorialstage==11){
5912 tutorialmaxtime=1000;
5914 if(tutorialstage==12){
5915 tutorialmaxtime=1000;
5917 if(tutorialstage==13){
5920 if(tutorialstage==14){
5932 player[1].coords=(temp+temp2)/2;
5936 gLoc[0]=player[1].coords.x;
5937 gLoc[1]=player[1].coords.y;
5938 gLoc[2]=player[1].coords.z;
5942 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
5943 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
5944 FSOUND_SetVolume(channels[fireendsound], 256);
5945 FSOUND_SetPaused(channels[fireendsound], FALSE);
5947 for(i=0;i<player[1].skeleton.num_joints;i++){
5949 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
5950 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
5951 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;
5952 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
5953 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
5958 if(tutorialstage==15){
5959 tutorialmaxtime=500;
5961 if(tutorialstage==16){
5962 tutorialmaxtime=500;
5964 if(tutorialstage==17){
5965 tutorialmaxtime=500;
5967 if(tutorialstage==18){
5968 tutorialmaxtime=500;
5970 if(tutorialstage==19){
5972 //tutorialmaxtime=500;
5974 if(tutorialstage==20){
5975 tutorialmaxtime=500;
5977 if(tutorialstage==21){
5978 tutorialmaxtime=500;
5985 if(tutorialstage==22){
5986 tutorialmaxtime=500;
5988 if(tutorialstage==23){
5989 tutorialmaxtime=500;
5991 if(tutorialstage==24){
5992 tutorialmaxtime=500;
5994 if(tutorialstage==25){
5995 tutorialmaxtime=500;
5997 if(tutorialstage==26){
6000 if(tutorialstage==27){
6004 player[1].aitype=attacktypecutoff;
6006 if(tutorialstage==28){
6007 tutorialmaxtime=400;
6009 if(tutorialstage==29){
6010 tutorialmaxtime=400;
6011 player[0].escapednum=0;
6013 if(tutorialstage==30){
6017 player[1].aitype=passivetype;
6019 if(tutorialstage==31){
6022 if(tutorialstage==32){
6025 if(tutorialstage==33){
6026 tutorialmaxtime=400;
6029 player[1].aitype=attacktypecutoff;
6031 if(tutorialstage==34){
6032 tutorialmaxtime=400;
6034 if(tutorialstage==35){
6035 tutorialmaxtime=400;
6037 if(tutorialstage==36){
6041 player[1].aitype=passivetype;
6043 if(tutorialstage==37){
6049 player[1].aitype=attacktypecutoff;
6051 if(tutorialstage==38){
6055 player[1].aitype=passivetype;
6057 if(tutorialstage==39){
6068 weapons.owner[weapons.numweapons]=-1;
6069 weapons.type[weapons.numweapons]=knife;
6070 weapons.damage[weapons.numweapons]=0;
6071 weapons.mass[weapons.numweapons]=1;
6072 weapons.tipmass[weapons.numweapons]=1.2;
6073 weapons.length[weapons.numweapons]=.25;
6074 weapons.position[weapons.numweapons]=(temp+temp2)/2;
6075 weapons.tippoint[weapons.numweapons]=(temp+temp2)/2;
6077 weapons.velocity[weapons.numweapons]=0.1;
6078 weapons.tipvelocity[weapons.numweapons]=0.1;
6079 weapons.missed[weapons.numweapons]=1;
6080 weapons.hitsomething[weapons.numweapons]=0;
6081 weapons.freetime[weapons.numweapons]=0;
6082 weapons.firstfree[weapons.numweapons]=1;
6083 weapons.physics[weapons.numweapons]=1;
6085 weapons.numweapons++;
6087 if(tutorialstage==40){
6088 tutorialmaxtime=300;
6090 if(tutorialstage==41){
6091 tutorialmaxtime=300;
6093 if(tutorialstage==42){
6096 if(tutorialstage==43){
6097 tutorialmaxtime=300;
6099 if(tutorialstage==44){
6101 player[0].weaponactive=-1;
6102 player[0].num_weapons=0;
6103 player[1].weaponactive=0;
6104 player[1].num_weapons=1;
6105 player[1].weaponids[0]=0;
6109 player[1].aitype=attacktypecutoff;
6111 tutorialmaxtime=300;
6113 if(tutorialstage==45){
6115 player[0].weaponactive=-1;
6116 player[0].num_weapons=0;
6117 player[1].weaponactive=0;
6118 player[1].num_weapons=1;
6119 player[1].weaponids[0]=0;
6121 tutorialmaxtime=300;
6123 if(tutorialstage==46){
6125 player[0].weaponactive=-1;
6126 player[0].num_weapons=0;
6127 player[1].weaponactive=0;
6128 player[1].num_weapons=1;
6129 player[1].weaponids[0]=0;
6131 weapons.type[0]=sword;
6133 tutorialmaxtime=300;
6136 if(tutorialstage==47){
6148 weapons.owner[weapons.numweapons]=-1;
6149 weapons.type[weapons.numweapons]=sword;
6150 weapons.damage[weapons.numweapons]=0;
6151 weapons.mass[weapons.numweapons]=1;
6152 weapons.tipmass[weapons.numweapons]=1.2;
6153 weapons.length[weapons.numweapons]=.25;
6154 weapons.position[weapons.numweapons]=(temp+temp2)/2;
6155 weapons.tippoint[weapons.numweapons]=(temp+temp2)/2;
6157 weapons.velocity[weapons.numweapons]=0.1;
6158 weapons.tipvelocity[weapons.numweapons]=0.1;
6159 weapons.missed[weapons.numweapons]=1;
6160 weapons.hitsomething[weapons.numweapons]=0;
6161 weapons.freetime[weapons.numweapons]=0;
6162 weapons.firstfree[weapons.numweapons]=1;
6163 weapons.physics[weapons.numweapons]=1;
6167 player[0].weaponactive=0;
6168 player[0].num_weapons=1;
6169 player[0].weaponids[0]=1;
6170 player[1].weaponactive=0;
6171 player[1].num_weapons=1;
6172 player[1].weaponids[0]=0;
6174 weapons.numweapons++;
6176 if(tutorialstage==48){
6179 player[1].aitype=passivetype;
6185 player[0].weaponactive=0;
6186 player[0].num_weapons=1;
6187 player[0].weaponids[0]=1;
6188 player[1].weaponactive=0;
6189 player[1].num_weapons=1;
6190 player[1].weaponids[0]=0;
6192 if(player[0].weaponactive!=-1)weapons.type[player[0].weaponids[player[0].weaponactive]]=staff;
6193 else weapons.type[0]=staff;
6195 weapons.numweapons++;
6197 if(tutorialstage==49){
6200 player[1].aitype=passivetype;
6202 tutorialmaxtime=200;
6204 weapons.position[1]=1000;
6205 weapons.tippoint[1]=1000;
6207 weapons.numweapons=1;
6209 player[1].weaponactive=-1;
6210 player[1].num_weapons=0;
6211 player[0].weaponactive=0;
6212 player[0].num_weapons=1;
6213 player[0].weaponids[0]=0;
6215 weapons.type[0]=knife;
6217 weapons.numweapons++;
6219 if(tutorialstage==50){
6225 gLoc[0]=player[1].coords.x;
6226 gLoc[1]=player[1].coords.y;
6227 gLoc[2]=player[1].coords.z;
6231 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
6232 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
6233 FSOUND_SetVolume(channels[fireendsound], 256);
6234 FSOUND_SetPaused(channels[fireendsound], FALSE);
6236 for(i=0;i<player[1].skeleton.num_joints;i++){
6238 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
6239 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
6240 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;
6241 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
6242 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
6246 player[1].num_weapons=0;
6247 player[1].weaponstuck=-1;
6248 player[1].weaponactive=-1;
6250 weapons.numweapons=0;
6252 weapons.owner[0]=-1;
6253 weapons.velocity[0]=0.1;
6254 weapons.tipvelocity[0]=-0.1;
6255 weapons.missed[0]=1;
6256 weapons.hitsomething[0]=0;
6257 weapons.freetime[0]=0;
6258 weapons.firstfree[0]=1;
6259 weapons.physics[0]=1;
6261 if(tutorialstage==51){
6262 tutorialmaxtime=80000;
6264 if(tutorialstage<=51)tutorialstagetime=0;
6268 if(tutoriallevel&&tutorialstagetime<tutorialmaxtime-3){
6269 if(tutorialstage==3){
6270 if(deltah||deltav)tutorialsuccess+=multiplier;
6272 if(tutorialstage==4){
6273 if(player[0].forwardkeydown||player[0].backkeydown||player[0].leftkeydown||player[0].rightkeydown)tutorialsuccess+=multiplier;
6275 if(tutorialstage==5){
6276 if(player[0].jumpkeydown)tutorialsuccess=1;
6278 if(tutorialstage==6){
6279 if(player[0].isCrouch())tutorialsuccess=1;
6281 if(tutorialstage==7){
6282 if(player[0].targetanimation==rollanim)tutorialsuccess=1;
6284 if(tutorialstage==8){
6285 if(player[0].targetanimation==sneakanim)tutorialsuccess+=multiplier;
6287 if(tutorialstage==9){
6288 if(player[0].targetanimation==rabbitrunninganim||player[0].targetanimation==wolfrunninganim)tutorialsuccess+=multiplier;
6290 if(tutorialstage==11){
6291 if(player[0].isWallJump())tutorialsuccess=1;
6293 if(tutorialstage==12){
6294 if(player[0].targetanimation==flipanim)tutorialsuccess=1;
6296 if(tutorialstage==15){
6297 if(player[0].targetanimation==upunchanim||player[0].targetanimation==winduppunchanim)tutorialsuccess=1;
6299 if(tutorialstage==16){
6300 if(player[0].targetanimation==winduppunchanim)tutorialsuccess=1;
6302 if(tutorialstage==17){
6303 if(player[0].targetanimation==spinkickanim)tutorialsuccess=1;
6305 if(tutorialstage==18){
6306 if(player[0].targetanimation==sweepanim)tutorialsuccess=1;
6308 if(tutorialstage==19){
6309 if(player[0].targetanimation==dropkickanim)tutorialsuccess=1;
6311 if(tutorialstage==20){
6312 if(player[0].targetanimation==rabbitkickanim)tutorialsuccess=1;
6314 if(tutorialstage==21){
6315 if(bonus==cannon)tutorialsuccess=1;
6317 if(tutorialstage==22){
6318 if(bonus==spinecrusher)tutorialsuccess=1;
6320 if(tutorialstage==23){
6321 if(player[0].targetanimation==walljumprightkickanim||player[0].targetanimation==walljumpleftkickanim)tutorialsuccess=1;
6323 if(tutorialstage==24){
6324 if(player[0].targetanimation==rabbittacklinganim)tutorialsuccess=1;
6326 if(tutorialstage==25){
6327 if(player[0].targetanimation==backhandspringanim)tutorialsuccess=1;
6329 if(tutorialstage==28){
6330 if(animation[player[0].targetanimation].attack==reversed&&player[0].feint)tutorialsuccess=1;
6332 if(tutorialstage==29){
6333 if(player[0].escapednum==2){
6337 player[1].aitype=passivetype;
6340 if(tutorialstage==33){
6341 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6343 if(tutorialstage==34){
6344 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6346 if(tutorialstage==35){
6347 if(animation[player[0].targetanimation].attack==reversal){
6351 player[1].aitype=passivetype;
6354 if(tutorialstage==40){
6355 if(player[0].num_weapons>0)tutorialsuccess=1;
6357 if(tutorialstage==41){
6358 if(player[0].weaponactive==-1&&player[0].num_weapons>0)tutorialsuccess=1;
6360 if(tutorialstage==43){
6361 if(player[0].targetanimation==knifeslashstartanim)tutorialsuccess=1;
6363 if(tutorialstage==44){
6364 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6366 if(tutorialstage==45){
6367 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6369 if(tutorialstage==46){
6370 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6372 if(tutorialstage==49){
6373 if(player[1].weaponstuck!=-1)tutorialsuccess=1;
6375 if(tutorialsuccess>=1)tutorialstagetime=tutorialmaxtime-3;
6378 if(tutorialstagetime==tutorialmaxtime-3){
6379 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
6380 FSOUND_SetVolume(channels[consolesuccesssound], 256);
6381 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
6384 if(tutorialsuccess>=1){
6385 if(tutorialstage==34||tutorialstage==35)
6386 tutorialstagetime=tutorialmaxtime-1;
6391 if(tutorialstage<14||tutorialstage>=50){
6392 player[1].coords.y=300;
6393 player[1].velocity=0;
6397 if(tutoriallevel!=1){
6398 if(bonustime==0&&bonus!=solidhit&&bonus!=spinecrusher&&bonus!=tracheotomy&&bonus!=backstab&&bonusvalue>10){
6399 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
6400 FSOUND_SetVolume(channels[consolesuccesssound], 256);
6401 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
6406 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
6407 FSOUND_SetVolume(channels[fireendsound], 256);
6408 FSOUND_SetPaused(channels[fireendsound], FALSE);
6411 if(bonus!=solidhit&&bonus!=twoxcombo&&bonus!=threexcombo&&bonus!=fourxcombo&&bonus!=megacombo)bonusnum[bonus]++;
6412 else bonusnum[bonus]+=0.15;
6413 if(tutoriallevel)bonusvalue=0;
6414 bonusvalue/=bonusnum[bonus];
6415 bonustotal+=bonusvalue;
6417 bonustime+=multiplier;
6419 if(environment==snowyenvironment){
6420 precipdelay-=multiplier;
6421 while(precipdelay<0){
6423 if(!detail)precipdelay+=.04;
6424 XYZ footvel,footpoint;
6427 footpoint=viewer+viewerfacing*6;
6428 footpoint.y+=((float)abs(Random()%1200))/100-6;
6429 footpoint.x+=((float)abs(Random()%1200))/100-6;
6430 footpoint.z+=((float)abs(Random()%1200))/100-6;
6431 sprites.MakeSprite(snowsprite, footpoint,footvel, 1,1,1, .1, 1);
6434 for(k=0;k<numplayers;k++){
6435 if(player[k].aitype==playercontrolled)player[k].turnspeed=500;
6436 if(player[k].aitype!=playercontrolled)player[k].turnspeed=500;
6438 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){
6439 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6440 else if(player[k].rotation>player[k].targetrotation){
6441 player[k].rotation-=multiplier*player[k].turnspeed;
6443 else if(player[k].rotation<player[k].targetrotation){
6444 player[k].rotation+=multiplier*player[k].turnspeed;
6449 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))){
6450 player[k].turnspeed*=2;
6451 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6452 else if(player[k].rotation>player[k].targetrotation){
6453 player[k].rotation-=multiplier*player[k].turnspeed;
6455 else if(player[k].rotation<player[k].targetrotation){
6456 player[k].rotation+=multiplier*player[k].turnspeed;
6458 player[k].turnspeed/=2;
6461 if(player[k].targetanimation==sneakanim&&player[k].currentanimation!=sneakanim){
6462 player[k].turnspeed*=4;
6463 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6464 else if(player[k].rotation>player[k].targetrotation){
6465 player[k].rotation-=multiplier*player[k].turnspeed;
6467 else if(player[k].rotation<player[k].targetrotation){
6468 player[k].rotation+=multiplier*player[k].turnspeed;
6470 player[k].turnspeed/=4;
6473 /*if(player[k].aitype!=passivetype||(findDistancefast(&player[k].coords,&viewer)<viewdistance*viewdistance))*/ player[k].DoStuff();
6474 if(player[k].immobile&&k!=0)player[k].coords=player[k].realoldcoords;
6476 if(findDistancefast(&player[k].coords,&player[k].realoldcoords)>0){
6477 if(!player[k].skeleton.free&&player[k].targetanimation!=climbanim&&player[k].targetanimation!=hanganim){
6480 if(player[k].collide<-.3)player[k].collide=-.3;
6481 if(player[k].collide>1)player[k].collide=1;
6482 player[k].collide-=multiplier*30;
6484 if(player[k].coords.y<terrain.getHeight(player[k].coords.x,player[k].coords.z)){
6485 player[k].coords.y=terrain.getHeight(player[k].coords.x,player[k].coords.z);
6487 if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
6488 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
6489 i=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
6490 if(objects.type[i]!=rocktype||(((objects.scale[i]>.5&&player[k].aitype==playercontrolled)||objects.position[i].y>player[k].coords.y))){
6491 lowpoint=player[k].coords;
6492 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&!player[k].isFlip())lowpoint.y+=1.25;
6493 else lowpoint.y+=1.3;
6494 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){
6495 player[k].coords.y=terrain.getHeight(player[k].coords.x,player[k].coords.z);
6497 /*while(player[k].coords.y<terrain.getHeight(player[k].coords.x,player[k].coords.z))
6498 player[k].coords+=terrain.getNormal(player[k].coords.x,player[k].coords.z)/50;
6500 if(player[k].SphereCheck(&lowpoint, 1.3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
6501 flatfacing=lowpoint-player[k].coords;
6502 player[k].coords=lowpoint;
6503 player[k].coords.y-=1.3;
6504 player[k].collide=1;
6506 if(player[k].aitype==playercontrolled&&(player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim||player[k].isFlip())&&!player[k].jumptogglekeydown&&player[k].jumpkeydown){
6507 lowpointtarget=lowpoint+DoRotation(player[k].facing,0,-90,0)*1.5;
6508 tempcoords1=lowpoint;
6509 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6510 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6512 player[k].targetanimation=walljumpleftanim;
6513 player[k].targetframe=0;
6516 gLoc[0]=player[k].coords.x;
6517 gLoc[1]=player[k].coords.y;
6518 gLoc[2]=player[k].coords.z;
6522 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, TRUE);
6523 FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6524 FSOUND_SetVolume(channels[movewhooshsound], 256);
6525 FSOUND_SetPaused(channels[movewhooshsound], FALSE);
6526 if(k==0)FSOUND_SetPaused(channels[whooshsound], TRUE);
6528 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6529 player[k].rotation=-asin(0-lowpointtarget.x);
6530 player[k].rotation*=360/6.28;
6531 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6532 player[k].targetrotation=player[k].rotation;
6533 player[k].lowrotation=player[k].rotation;
6534 if(k==0)numwallflipped++;
6538 lowpoint=tempcoords1;
6539 lowpointtarget=lowpoint+DoRotation(player[k].facing,0,90,0)*1.5;
6540 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6541 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6543 player[k].targetanimation=walljumprightanim;
6544 player[k].targetframe=0;
6547 gLoc[0]=player[k].coords.x;
6548 gLoc[1]=player[k].coords.y;
6549 gLoc[2]=player[k].coords.z;
6553 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, TRUE);
6554 FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6555 FSOUND_SetVolume(channels[movewhooshsound], 256);
6556 FSOUND_SetPaused(channels[movewhooshsound], FALSE);
6557 if(k==0)FSOUND_SetPaused(channels[whooshsound], TRUE);
6559 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6560 player[k].rotation=-asin(0-lowpointtarget.x);
6561 player[k].rotation*=360/6.28;
6562 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6563 player[k].targetrotation=player[k].rotation;
6564 player[k].lowrotation=player[k].rotation;
6565 if(k==0)numwallflipped++;
6569 lowpoint=tempcoords1;
6570 lowpointtarget=lowpoint+player[k].facing*2;
6571 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6572 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6574 player[k].targetanimation=walljumpbackanim;
6575 player[k].targetframe=0;
6578 gLoc[0]=player[k].coords.x;
6579 gLoc[1]=player[k].coords.y;
6580 gLoc[2]=player[k].coords.z;
6584 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, TRUE);
6585 FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6586 FSOUND_SetVolume(channels[movewhooshsound], 256);
6587 FSOUND_SetPaused(channels[movewhooshsound], FALSE);
6588 if(k==0)FSOUND_SetPaused(channels[whooshsound], TRUE);
6590 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6591 player[k].rotation=-asin(0-lowpointtarget.x);
6592 player[k].rotation*=360/6.28;
6593 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6594 player[k].targetrotation=player[k].rotation;
6595 player[k].lowrotation=player[k].rotation;
6596 if(k==0)numwallflipped++;
6600 lowpoint=tempcoords1;
6601 lowpointtarget=lowpoint-player[k].facing*2;
6602 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6603 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6605 player[k].targetanimation=walljumpfrontanim;
6606 player[k].targetframe=0;
6609 gLoc[0]=player[k].coords.x;
6610 gLoc[1]=player[k].coords.y;
6611 gLoc[2]=player[k].coords.z;
6615 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, TRUE);
6616 FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6617 FSOUND_SetVolume(channels[movewhooshsound], 256);
6618 FSOUND_SetPaused(channels[movewhooshsound], FALSE);
6619 if(k==0)FSOUND_SetPaused(channels[whooshsound], TRUE);
6621 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6622 player[k].rotation=-asin(0-lowpointtarget.x);
6623 player[k].rotation*=360/6.28;
6624 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6625 player[k].rotation+=180;
6626 player[k].targetrotation=player[k].rotation;
6627 player[k].lowrotation=player[k].rotation;
6628 if(k==0)numwallflipped++;
6636 else if(objects.type[i]==rocktype){
6637 lowpoint2=player[k].coords;
6638 lowpoint=player[k].coords;
6640 if(objects.model[i].LineCheck(&lowpoint,&lowpoint2,&colpoint,&objects.position[i],&objects.rotation[i])!=-1){
6641 player[k].coords=colpoint;
6642 player[k].collide=1;
6645 if((player[k].targetanimation==jumpdownanim||player[k].isFlip())){
6646 if(player[k].isFlip()&&animation[player[k].targetanimation].label[player[k].targetframe]==7)player[k].RagDoll(0);
6648 if(player[k].targetanimation==jumpupanim){player[k].jumppower=-4;player[k].targetanimation=player[k].getIdle();}
6650 player[k].targetframe=0;
6651 player[k].onterrain=1;
6653 if(player[k].id==0){
6654 FSOUND_SetPaused(channels[whooshsound], TRUE);
6655 FSOUND_SetVolume(channels[whooshsound], 0);
6658 if((player[k].targetanimation==jumpdownanim||player[k].isFlip())&&!player[k].wasLanding()){
6659 if(player[k].isFlip())player[k].jumppower=-4;
6660 player[k].targetanimation=player[k].getLanding();
6663 gLoc[0]=player[k].coords.x;
6664 gLoc[1]=player[k].coords.y;
6665 gLoc[2]=player[k].coords.z;
6666 vel[0]=player[k].velocity.x;
6667 vel[1]=player[k].velocity.y;
6668 vel[2]=player[k].velocity.z;
6669 PlaySoundEx( landsound, samp[landsound], NULL, TRUE);
6670 FSOUND_3D_SetAttributes(channels[landsound], gLoc, vel);
6671 FSOUND_SetVolume(channels[landsound], 128);
6672 FSOUND_SetPaused(channels[landsound], FALSE);
6674 envsound[numenvsounds]=player[k].coords;
6675 envsoundvol[numenvsounds]=16;
6676 envsoundlife[numenvsounds]=.4;
6685 if(tempcollide&&terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz]&&(/*player[k].jumptogglekeydown*/1==1||player[k].aitype!=playercontrolled))
6686 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
6687 i=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
6688 lowpoint=player[k].coords;
6690 if(objects.type[i]!=rocktype)
6691 if(player[k].SphereCheck(&lowpoint, 1.33, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
6692 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&player[k].onterrain)player[k].avoidcollided=1;
6693 player[k].coords=lowpoint;
6694 player[k].coords.y-=1.35;
6695 player[k].collide=1;
6697 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)){
6698 lowpoint=player[k].coords;
6699 objects.model[i].SphereCheckPossible(&lowpoint, 1.5, &objects.position[i], &objects.rotation[i]);
6700 lowpoint=player[k].coords;
6704 facing=DoRotation(facing,0,player[k].targetrotation+180,0);
6705 lowpointtarget=lowpoint+facing*1.4;
6706 whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6708 lowpoint=player[k].coords;
6710 lowpointtarget=lowpoint+facing*1.4;
6712 lowpointtarget2=lowpointtarget;
6714 lowpointtarget3=lowpointtarget;
6716 lowpointtarget4=lowpointtarget;
6718 lowpointtarget5=lowpointtarget;
6720 lowpointtarget6=lowpointtarget;
6722 lowpointtarget7=lowpoint;
6724 lowpointtarget2.x+=.1;
6726 lowpointtarget3.z+=.1;
6728 lowpointtarget4.x-=.1;
6730 lowpointtarget5.z-=.1;
6732 lowpointtarget6.y+=45/13;
6733 lowpointtarget6+=facing*.6;
6734 lowpointtarget7.y+=90/13;
6735 whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6736 if(objects.friction[i]>.5)
6739 if(whichhit!=-1)if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim)player[k].collided=1;
6740 if(checkcollide(lowpoint7,lowpointtarget7)==-1)
6741 if(checkcollide(lowpoint6,lowpointtarget6)==-1)
6742 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)
6744 lowpoint=player[k].coords;
6745 lowpoint.y+=(float)j/13;
6746 lowpointtarget=lowpoint+facing*1.4;
6747 if(objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint2,&objects.position[i],&objects.rotation[i])==-1){
6751 /*if(j>=25&&(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)){
6754 if(j<=25&&player[k].targetanimation==jumpdownanim){
6757 if(j!=100&&(/*j>25||(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)||*/player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim)){
6758 lowpoint=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0);
6759 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)*/){
6760 lowpoint=player[k].coords;
6761 lowpoint.y+=(float)j/13;
6762 lowpointtarget=lowpoint+facing*1.3;
6763 flatfacing=player[k].coords;
6764 player[k].coords=colpoint-DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0)*.01;
6765 player[k].coords.y=lowpointtarget.y-.07;
6766 player[k].currentoffset=(flatfacing-player[k].coords)/player[k].scale;
6768 if(j>10||!player[k].isRun()){
6769 if(player[k].targetanimation==jumpdownanim||player[k].targetanimation==jumpupanim){
6770 if(k==0)FSOUND_SetPaused(channels[whooshsound], TRUE);
6774 gLoc[0]=player[k].coords.x;
6775 gLoc[1]=player[k].coords.y;
6776 gLoc[2]=player[k].coords.z;
6777 vel[0]=player[k].velocity.x;
6778 vel[1]=player[k].velocity.y;
6779 vel[2]=player[k].velocity.z;
6780 PlaySoundEx( jumpsound, samp[jumpsound], NULL, TRUE);
6781 FSOUND_3D_SetAttributes(channels[jumpsound], gLoc, vel);
6782 FSOUND_SetVolume(channels[jumpsound], 128);
6783 FSOUND_SetPaused(channels[jumpsound], FALSE);
6785 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6786 player[k].rotation=-asin(0-lowpointtarget.x);
6787 player[k].rotation*=360/6.28;
6788 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6789 player[k].targetrotation=player[k].rotation;
6790 player[k].lowrotation=player[k].rotation;
6792 //player[k].velocity=lowpointtarget*.03;
6793 player[k].velocity=0;
6795 if(/*(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)||*/player[k].targetanimation==jumpupanim){
6796 //player[k].currentanimation=climbanim;
6797 player[k].targetanimation=climbanim;
6798 player[k].jumppower=0;
6799 player[k].jumpclimb=1;
6801 player[k].transspeed=6;
6804 //player[k].currentframe=1;
6805 player[k].targetframe=1;
6807 //player[k].currentframe=0;
6808 player[k].targetframe=0;
6809 //player[k].currentanimation=hanganim;
6810 player[k].targetanimation=hanganim;
6811 player[k].jumppower=0;
6825 if(player[k].collide<=0){
6826 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()){
6827 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)){
6828 if(player[k].targetanimation==staggerbackhighanim||player[k].targetanimation==staggerbackhardanim)player[k].RagDoll(0);
6829 player[k].targetanimation=jumpdownanim;
6830 player[k].targetframe=0;
6835 gLoc[0]=player[k].coords.x;
6836 gLoc[1]=player[k].coords.y;
6837 gLoc[2]=player[k].coords.z;
6838 vel[0]=player[k].velocity.x;
6839 vel[1]=player[k].velocity.y;
6840 vel[2]=player[k].velocity.z;
6842 PlaySoundEx( whooshsound, samp[whooshsound], NULL, TRUE);
6843 FSOUND_3D_SetAttributes(channels[whooshsound], gLoc, vel);
6844 FSOUND_SetVolume(channels[whooshsound], 128);
6845 FSOUND_SetPaused(channels[whooshsound], FALSE);
6848 player[k].velocity.y+=gravity;
6853 player[k].realoldcoords=player[k].coords;
6856 static XYZ oldviewer;
6859 player[0].forwardkeydown=IsKeyDown(theKeyMap, forwardkey);
6860 player[0].leftkeydown=IsKeyDown(theKeyMap, leftkey);
6861 player[0].backkeydown=IsKeyDown(theKeyMap, backkey);
6862 player[0].rightkeydown=IsKeyDown(theKeyMap, rightkey);
6863 player[0].jumpkeydown=IsKeyDown(theKeyMap, jumpkey);
6864 player[0].crouchkeydown=IsKeyDown(theKeyMap, crouchkey);
6865 player[0].drawkeydown=IsKeyDown(theKeyMap, drawkey);
6866 player[0].throwkeydown=IsKeyDown(theKeyMap, throwkey);
6870 player[0].forwardkeydown=0;
6871 player[0].leftkeydown=0;
6872 player[0].backkeydown=0;
6873 player[0].rightkeydown=0;
6874 player[0].jumpkeydown=0;
6875 player[0].crouchkeydown=0;
6876 player[0].drawkeydown=0;
6877 player[0].throwkeydown=0;
6880 if(!player[0].jumpkeydown)player[0].jumpclimb=0;
6883 static bool endkeydown;
6890 facing=DoRotation(facing,-rotation2,0,0);
6891 facing=DoRotation(facing,0,0-rotation,0);
6896 flatfacing=DoRotation(flatfacing,0,-rotation,0);
6898 if(IsKeyDown(theKeyMap, forwardkey))viewer+=facing*multiplier*4;
6899 if(IsKeyDown(theKeyMap, backkey))viewer-=facing*multiplier*4;
6900 if(IsKeyDown(theKeyMap, leftkey))viewer+=DoRotation(flatfacing*multiplier,0,90,0)*4;
6901 if(IsKeyDown(theKeyMap, rightkey))viewer+=DoRotation(flatfacing*multiplier,0,-90,0)*4;
6902 if(IsKeyDown(theKeyMap, jumpkey))viewer.y+=multiplier*4;
6903 if(IsKeyDown(theKeyMap, crouchkey))viewer.y-=multiplier*4;
6904 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)
6905 ||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)
6906 ||IsKeyDown(theKeyMap, MAC_MINUS_KEY))){
6908 if(IsKeyDown(theKeyMap, MAC_1_KEY))whichend=1;
6909 if(IsKeyDown(theKeyMap, MAC_2_KEY))whichend=2;
6910 if(IsKeyDown(theKeyMap, MAC_3_KEY))whichend=3;
6911 if(IsKeyDown(theKeyMap, MAC_4_KEY))whichend=4;
6912 if(IsKeyDown(theKeyMap, MAC_5_KEY))whichend=5;
6913 if(IsKeyDown(theKeyMap, MAC_6_KEY))whichend=6;
6914 if(IsKeyDown(theKeyMap, MAC_7_KEY))whichend=7;
6915 if(IsKeyDown(theKeyMap, MAC_8_KEY))whichend=8;
6916 if(IsKeyDown(theKeyMap, MAC_9_KEY))whichend=9;
6917 if(IsKeyDown(theKeyMap, MAC_0_KEY))whichend=0;
6918 if(IsKeyDown(theKeyMap, MAC_MINUS_KEY))whichend=-1;
6920 participantfocus[whichdialogue][indialogue]=whichend;
6921 participantlocation[whichdialogue][whichend]=player[whichend].coords;
6922 participantrotation[whichdialogue][whichend]=player[whichend].rotation;
6925 participantfocus[whichdialogue][indialogue]=-1;
6927 if(player[participantfocus[whichdialogue][indialogue]].dead){
6932 dialoguecamera[whichdialogue][indialogue]=viewer;
6933 dialoguecamerarotation[whichdialogue][indialogue]=rotation;
6934 dialoguecamerarotation2[whichdialogue][indialogue]=rotation2;
6936 if(indialogue<numdialogueboxes[whichdialogue]){
6937 if(dialogueboxsound[whichdialogue][indialogue]!=0){
6938 static float gLoc[3];
6939 static float vel[3];
6941 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
6942 temppos=temppos-viewer;
6943 Normalise(&temppos);
6948 gLoc[2]=temppos.z;vel[0]=0;
6952 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
6953 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
6954 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
6955 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
6956 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
6957 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
6958 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
6959 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
6960 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
6961 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
6962 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
6963 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
6964 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
6965 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
6966 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
6967 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
6968 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
6969 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
6970 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
6971 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
6972 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, TRUE);
6973 FSOUND_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
6974 FSOUND_SetVolume(channels[whichsoundplay], 256);
6975 FSOUND_SetPaused(channels[whichsoundplay], FALSE);
6979 for(j=0;j<numplayers;j++){
6980 participantfacing[whichdialogue][indialogue][j]=participantfacing[whichdialogue][indialogue-1][j];
6985 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)
6986 ||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)
6989 if(IsKeyDown(theKeyMap, MAC_NUMPAD_1_KEY))whichend=1;
6990 if(IsKeyDown(theKeyMap, MAC_NUMPAD_2_KEY))whichend=2;
6991 if(IsKeyDown(theKeyMap, MAC_NUMPAD_3_KEY))whichend=3;
6992 if(IsKeyDown(theKeyMap, MAC_NUMPAD_4_KEY))whichend=4;
6993 if(IsKeyDown(theKeyMap, MAC_NUMPAD_5_KEY))whichend=5;
6994 if(IsKeyDown(theKeyMap, MAC_NUMPAD_6_KEY))whichend=6;
6995 if(IsKeyDown(theKeyMap, MAC_NUMPAD_7_KEY))whichend=7;
6996 if(IsKeyDown(theKeyMap, MAC_NUMPAD_8_KEY))whichend=8;
6997 if(IsKeyDown(theKeyMap, MAC_NUMPAD_9_KEY))whichend=9;
6998 if(IsKeyDown(theKeyMap, MAC_NUMPAD_0_KEY))whichend=0;
6999 participantfacing[whichdialogue][indialogue][whichend]=facing;
7001 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)
7002 &&!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)
7003 &&!IsKeyDown(theKeyMap, MAC_MINUS_KEY)){
7006 if(indialogue>=numdialogueboxes[whichdialogue]){
7013 FSOUND_SetPaused(channels[whooshsound], TRUE);
7014 viewer=dialoguecamera[whichdialogue][indialogue];
7015 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.1){
7016 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.1;
7018 rotation=dialoguecamerarotation[whichdialogue][indialogue];
7019 rotation2=dialoguecamerarotation2[whichdialogue][indialogue];
7020 if(dialoguetime>0.5)
7021 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)
7022 ||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)
7023 ||IsKeyDown(theKeyMap, MAC_MINUS_KEY)))||(IsKeyDown(theKeyMap, attackkey)&&!oldbuttondialogue)){
7026 if(indialogue<numdialogueboxes[whichdialogue]){
7027 if(dialogueboxsound[whichdialogue][indialogue]!=0){
7028 static float gLoc[3];
7029 static float vel[3];
7031 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
7032 temppos=temppos-viewer;
7033 Normalise(&temppos);
7038 gLoc[2]=temppos.z;vel[0]=0;
7042 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
7043 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
7044 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
7045 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
7046 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
7047 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
7048 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
7049 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
7050 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
7051 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
7052 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
7053 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
7054 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
7055 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
7056 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
7057 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
7058 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
7059 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
7060 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
7061 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
7062 if(dialogueboxsound[whichdialogue][indialogue]==-6)whichsoundplay=alarmsound;
7063 if(dialogueboxsound[whichdialogue][indialogue]!=-5){
7064 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, TRUE);
7065 FSOUND_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
7066 FSOUND_SetVolume(channels[whichsoundplay], 256);
7067 FSOUND_SetPaused(channels[whichsoundplay], FALSE);
7069 if(dialogueboxsound[whichdialogue][indialogue]==-5){
7070 hotspot[numhotspots]=player[0].coords;
7071 hotspotsize[numhotspots]=10;
7072 hotspottype[numhotspots]=-1;
7076 if(dialogueboxsound[whichdialogue][indialogue]==-6){
7080 if(player[participantfocus[whichdialogue][indialogue]].dead){
7088 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)
7089 &&!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)
7090 &&!IsKeyDown(theKeyMap, MAC_MINUS_KEY)){
7093 if(indialogue>=numdialogueboxes[whichdialogue]){
7097 if(dialoguetype[whichdialogue]>19&&dialoguetype[whichdialogue]<30){
7100 if(dialoguetype[whichdialogue]>29&&dialoguetype[whichdialogue]<40){
7103 if(dialoguetype[whichdialogue]>49&&dialoguetype[whichdialogue]<60){
7105 for(i=1;i<numplayers;i++){
7106 player[i].aitype = attacktypecutoff;
7113 if(!IsKeyDown(theKeyMap, attackkey))oldbuttondialogue=0;
7114 else oldbuttondialogue=1;
7116 static float keyrefreshdelay=0,bigrefreshdelay=0;
7120 /*keyrefreshdelay-=multiplier;
7121 bigrefreshdelay-=multiplier;
7123 if(keyrefreshdelay<=0){
7124 static int concat[4];
7126 concat[0]=player[0].forwardkeydown;
7127 concat[0]=concat[0]*2+player[0].forwardstogglekeydown;
7128 concat[0]=concat[0]*2+player[0].rightkeydown;
7129 concat[0]=concat[0]*2+player[0].leftkeydown;
7130 concat[0]=concat[0]*2+player[0].backkeydown;
7131 concat[0]=concat[0]*2+player[0].jumpkeydown;
7132 concat[0]=concat[0]*2+player[0].jumptogglekeydown;
7133 concat[0]=concat[0]*2+player[0].crouchkeydown;
7135 concat[1]=player[0].crouchtogglekeydown;
7136 concat[1]=concat[1]*2+player[0].drawkeydown;
7137 concat[1]=concat[1]*2+player[0].drawtogglekeydown;
7138 concat[1]=concat[1]*2+player[0].throwkeydown;
7139 concat[1]=concat[1]*2+player[0].throwtogglekeydown;
7140 concat[1]=concat[1]*2+player[0].attackkeydown;
7142 //concat[2]=(char)((int)(rotation/2)%180);
7144 //concat[3]=(char)((int)(rotation2/2)%180);
7146 chatname[0]=concat[0]-128;
7147 chatname[1]=concat[1]-128;
7148 //chatname[2]=concat[2]-128;
7149 //chatname[3]=concat[3]-128;
7151 memcpy(chatname+temppoint,&rotation,sizeof(float));
7152 temppoint+=sizeof(float);
7153 memcpy(chatname+temppoint,&rotation2,sizeof(float));
7154 temppoint+=sizeof(float);
7156 chatname[temppoint]='\0';
7158 //if(!ishost)NetworkSendPlayerMessage( chatname, kMessageType_Keys );
7159 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_Keys );
7160 //keyrefreshdelay=.01;
7161 keyrefreshdelay=.03;
7164 if(bigrefreshdelay<=0){
7167 memcpy(chatname+temppoint,&i,sizeof(int));
7168 temppoint+=sizeof(int);
7169 memcpy(chatname+temppoint,&player[i].coords.x,sizeof(float));
7170 temppoint+=sizeof(float);
7171 memcpy(chatname+temppoint,&player[i].coords.y,sizeof(float));
7172 temppoint+=sizeof(float);
7173 memcpy(chatname+temppoint,&player[i].coords.z,sizeof(float));
7174 temppoint+=sizeof(float);
7175 memcpy(chatname+temppoint,&player[i].damage,sizeof(float));
7176 temppoint+=sizeof(float);
7177 memcpy(chatname+temppoint,&player[i].target,sizeof(float));
7178 temppoint+=sizeof(float);
7179 memcpy(chatname+temppoint,&player[i].targetanimation,sizeof(int));
7180 temppoint+=sizeof(int);
7181 memcpy(chatname+temppoint,&player[i].currentanimation,sizeof(int));
7182 temppoint+=sizeof(int);
7183 memcpy(chatname+temppoint,&player[i].velocity.x,sizeof(float));
7184 temppoint+=sizeof(float);
7185 memcpy(chatname+temppoint,&player[i].velocity.y,sizeof(float));
7186 temppoint+=sizeof(float);
7187 memcpy(chatname+temppoint,&player[i].velocity.z,sizeof(float));
7188 temppoint+=sizeof(float);
7189 memcpy(chatname+temppoint,&player[i].targetframe,sizeof(int));
7190 temppoint+=sizeof(int);
7191 memcpy(chatname+temppoint,&player[i].currentframe,sizeof(int));
7192 temppoint+=sizeof(int);
7193 memcpy(chatname+temppoint,&player[i].rotation,sizeof(float));
7194 temppoint+=sizeof(float);
7195 memcpy(chatname+temppoint,&player[i].targetrotation,sizeof(float));
7196 temppoint+=sizeof(float);
7197 memcpy(chatname+temppoint,&player[i].bloodloss,sizeof(float));
7198 temppoint+=sizeof(float);
7199 memcpy(chatname+temppoint,&player[i].weaponactive,sizeof(int));
7200 temppoint+=sizeof(int);
7201 memcpy(chatname+temppoint,&player[i].num_weapons,sizeof(int));
7202 temppoint+=sizeof(int);
7203 memcpy(chatname+temppoint,&player[i].weaponids[0],sizeof(int));
7204 temppoint+=sizeof(int);
7205 memcpy(chatname+temppoint,&player[i].weaponids[1],sizeof(int));
7206 temppoint+=sizeof(int);
7207 memcpy(chatname+temppoint,&player[i].weaponids[2],sizeof(int));
7208 temppoint+=sizeof(int);
7209 memcpy(chatname+temppoint,&player[i].weaponids[3],sizeof(int));
7210 temppoint+=sizeof(int);
7211 chatname[temppoint]='\0';
7213 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);
7214 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_PlayerState );
7215 //else NetworkSendPlayerMessage( chatname, kMessageType_PlayerState );
7217 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);
7219 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_PlayerStateMisc );
7220 //else NetworkSendPlayerMessage( chatname, kMessageType_PlayerStateMisc );
7222 //bigrefreshdelay=.02;
7227 if(!player[0].jumpkeydown){
7228 player[0].jumptogglekeydown=0;
7230 if(player[0].jumpkeydown&&player[0].targetanimation!=jumpupanim&&player[0].targetanimation!=jumpdownanim&&!player[0].isFlip())player[0].jumptogglekeydown=1;
7233 dialoguetime+=multiplier;
7234 skybox.cloudmove+=multiplier;
7235 hawkrotation+=multiplier*25;
7237 realhawkcoords.x=25;
7238 realhawkcoords=DoRotation(realhawkcoords,0,hawkrotation,0)+hawkcoords;
7239 hawkcalldelay-=multiplier/2;
7241 if(hawkcalldelay<=0)
7243 static float gLoc[3];
7244 static float vel[3];
7245 gLoc[0]=realhawkcoords.x;
7246 gLoc[1]=realhawkcoords.y;
7247 gLoc[2]=realhawkcoords.z;
7251 PlaySoundEx( hawksound, samp[hawksound], NULL, TRUE);
7252 FSOUND_3D_SetAttributes(channels[hawksound], gLoc, vel);
7253 FSOUND_SetVolume(channels[hawksound], 128);
7254 FSOUND_SetPaused(channels[hawksound], FALSE);
7256 hawkcalldelay=16+abs(Random()%8);
7258 static float temptexdetail;
7261 if(IsKeyDown(theKeyMap, MAC_H_KEY)&&debugmode){
7262 player[0].damagetolerance=200000;
7265 player[0].permanentdamage=0;
7266 player[0].superpermanentdamage=0;
7269 whichchar = abs(Random()%7);
7270 registrationname[whichchar]+=1;
7274 if(IsKeyDown(theKeyMap, MAC_J_KEY)&&!envtogglekeydown&&debugmode){
7276 if(environment>2)environment=0;
7277 Setenvironment(environment);
7283 if(!IsKeyDown(theKeyMap, MAC_J_KEY)){
7287 if(IsKeyDown(theKeyMap, MAC_C_KEY)&&!cameratogglekeydown&&debugmode){
7288 cameramode=1-cameramode;
7289 cameratogglekeydown=1;
7292 if(!IsKeyDown(theKeyMap, MAC_C_KEY)){
7293 cameratogglekeydown=0;
7296 if(IsKeyDown(theKeyMap, MAC_X_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!detailtogglekeydown&&debugmode){
7297 if(player[0].num_weapons>0){
7298 if(weapons.type[player[0].weaponids[0]]==sword)weapons.type[player[0].weaponids[0]]=staff;
7299 else if(weapons.type[player[0].weaponids[0]]==staff)weapons.type[player[0].weaponids[0]]=knife;
7300 else weapons.type[player[0].weaponids[0]]=sword;
7301 if(weapons.type[player[0].weaponids[0]]==sword){
7302 weapons.mass[player[0].weaponids[0]]=1.5;
7303 weapons.tipmass[player[0].weaponids[0]]=1;
7304 weapons.length[player[0].weaponids[0]]=.8;
7306 if(weapons.type[player[0].weaponids[0]]==staff){
7307 weapons.mass[player[0].weaponids[0]]=2;
7308 weapons.tipmass[player[0].weaponids[0]]=1;
7309 weapons.length[player[0].weaponids[0]]=1.5;
7312 if(weapons.type[player[0].weaponids[0]]==knife){
7313 weapons.mass[player[0].weaponids[0]]=1;
7314 weapons.tipmass[player[0].weaponids[0]]=1.2;
7315 weapons.length[player[0].weaponids[0]]=.25;
7319 /*for(i=0;i<objects.numobjects;i++){
7320 if(objects.type[i]==treeleavestype){
7321 for(j=0;j<objects.numobjects;j++){
7322 if(objects.type[j]==treetrunktype)
7323 if(findDistancefast(&objects.position[i],&objects.position[j])<.5)
7324 objects.scale[i]=objects.scale[j];
7328 detailtogglekeydown=1;
7331 if(IsKeyDown(theKeyMap, MAC_X_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!detailtogglekeydown&&debugmode){
7333 float closestdist=-1;
7336 for(i=1;i<numplayers;i++){
7337 distance=findDistancefast(&player[i].coords,&player[0].coords);
7338 if(closestdist==-1||distance<closestdist){
7339 closestdist=distance;
7344 if(player[closest].num_weapons)
7346 if(weapons.type[player[closest].weaponids[0]]==sword)weapons.type[player[closest].weaponids[0]]=staff;
7347 else if(weapons.type[player[closest].weaponids[0]]==staff)weapons.type[player[closest].weaponids[0]]=knife;
7348 else weapons.type[player[closest].weaponids[0]]=sword;
7349 if(weapons.type[player[closest].weaponids[0]]==sword){
7350 weapons.mass[player[closest].weaponids[0]]=1.5;
7351 weapons.tipmass[player[closest].weaponids[0]]=1;
7352 weapons.length[player[closest].weaponids[0]]=.8;
7354 if(weapons.type[player[0].weaponids[0]]==staff){
7355 weapons.mass[player[0].weaponids[0]]=2;
7356 weapons.tipmass[player[0].weaponids[0]]=1;
7357 weapons.length[player[0].weaponids[0]]=1.5;
7359 if(weapons.type[player[closest].weaponids[0]]==knife){
7360 weapons.mass[player[closest].weaponids[0]]=1;
7361 weapons.tipmass[player[closest].weaponids[0]]=1.2;
7362 weapons.length[player[closest].weaponids[0]]=.25;
7365 if(!player[closest].num_weapons)
7367 player[closest].weaponids[0]=weapons.numweapons;
7368 weapons.owner[weapons.numweapons]=closest;
7369 weapons.type[weapons.numweapons]=knife;
7370 weapons.damage[weapons.numweapons]=0;
7371 weapons.numweapons++;
7372 player[closest].num_weapons=1;
7373 if(weapons.type[player[closest].weaponids[0]]==sword){
7374 weapons.mass[player[closest].weaponids[0]]=1.5;
7375 weapons.tipmass[player[closest].weaponids[0]]=1;
7376 weapons.length[player[closest].weaponids[0]]=.8;
7378 if(weapons.type[player[closest].weaponids[0]]==knife){
7379 weapons.mass[player[closest].weaponids[0]]=1;
7380 weapons.tipmass[player[closest].weaponids[0]]=1.2;
7381 weapons.length[player[closest].weaponids[0]]=.25;
7385 detailtogglekeydown=1;
7388 if(IsKeyDown(theKeyMap, MAC_U_KEY)&&debugmode){
7390 float closestdist=-1;
7393 for(i=1;i<numplayers;i++){
7394 distance=findDistancefast(&player[i].coords,&player[0].coords);
7395 if(closestdist==-1||distance<closestdist){
7396 closestdist=distance;
7401 player[closest].rotation+=multiplier*50;
7402 player[closest].targetrotation=player[closest].rotation;
7406 if(IsKeyDown(theKeyMap, MAC_O_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7408 float closestdist=-1;
7411 for(i=1;i<numplayers;i++){
7412 distance=findDistancefast(&player[i].coords,&player[0].coords);
7413 if(closestdist==-1||distance<closestdist){
7414 closestdist=distance;
7418 if(IsKeyDown(theKeyMap, MAC_CONTROL_KEY))closest=0;
7421 player[closest].whichskin++;
7422 if(player[closest].whichskin>9)player[closest].whichskin=0;
7423 if(player[closest].whichskin>2&&player[closest].creature==wolftype)player[closest].whichskin=0;
7425 if(player[closest].creature==rabbittype){
7426 if(player[closest].whichskin==0){
7427 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7429 else if(player[closest].whichskin==1){
7430 LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7432 else if(player[closest].whichskin==2){
7433 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7435 else if(player[closest].whichskin==3){
7436 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7438 else if(player[closest].whichskin==4){
7439 LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7441 else if(player[closest].whichskin==5){
7442 LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7444 else if(player[closest].whichskin==6){
7445 LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7447 else if(player[closest].whichskin==7){
7448 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7450 else if(player[closest].whichskin==8){
7451 LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7453 else if(player[closest].whichskin==9){
7454 LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7457 if(player[closest].creature==wolftype){
7459 if(player[closest].whichskin==0){
7460 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7462 else if(player[closest].whichskin==1){
7463 LoadTextureSave(":Data:Textures:Darkwolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7465 else if(player[closest].whichskin==2){
7466 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7471 if(player[closest].numclothes){
7472 for(i=0;i<player[closest].numclothes;i++){
7473 tintr=player[closest].clothestintr[i];
7474 tintg=player[closest].clothestintg[i];
7475 tintb=player[closest].clothestintb[i];
7476 AddClothes((char *)player[closest].clothes[i],0,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7478 player[closest].DoMipmaps(5,0,0,player[closest].skeleton.skinsize,player[closest].skeleton.skinsize);
7481 detailtogglekeydown=1;
7484 if(IsKeyDown(theKeyMap, MAC_O_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7486 float closestdist=-1;
7489 for(i=1;i<numplayers;i++){
7490 distance=findDistancefast(&player[i].coords,&player[0].coords);
7491 if(closestdist==-1||distance<closestdist){
7492 closestdist=distance;
7497 if(player[closest].creature==wolftype){
7498 headprop=player[closest].proportionhead.x/1.1;
7499 bodyprop=player[closest].proportionbody.x/1.1;
7500 armprop=player[closest].proportionarms.x/1.1;
7501 legprop=player[closest].proportionlegs.x/1.1;
7504 if(player[closest].creature==rabbittype){
7505 headprop=player[closest].proportionhead.x/1.2;
7506 bodyprop=player[closest].proportionbody.x/1.05;
7507 armprop=player[closest].proportionarms.x/1.00;
7508 legprop=player[closest].proportionlegs.x/1.1;
7512 if(player[closest].creature==rabbittype){
7513 player[closest].skeleton.id=closest;
7514 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);
7515 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[closest],&player[closest].skeleton.skinsize);
7516 player[closest].whichskin=0;
7517 player[closest].creature=wolftype;
7519 player[closest].proportionhead=1.1;
7520 player[closest].proportionbody=1.1;
7521 player[closest].proportionarms=1.1;
7522 player[closest].proportionlegs=1.1;
7523 player[closest].proportionlegs.y=1.1;
7524 player[closest].scale=.23*5*player[0].scale;
7526 player[closest].damagetolerance=300;
7530 player[closest].skeleton.id=closest;
7531 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);
7532 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7533 player[closest].whichskin=0;
7534 player[closest].creature=rabbittype;
7536 player[closest].proportionhead=1.2;
7537 player[closest].proportionbody=1.05;
7538 player[closest].proportionarms=1.00;
7539 player[closest].proportionlegs=1.1;
7540 player[closest].proportionlegs.y=1.05;
7541 player[closest].scale=.2*5*player[0].scale;
7543 player[closest].damagetolerance=200;
7546 if(player[closest].creature==wolftype){
7547 player[closest].proportionhead=1.1*headprop;
7548 player[closest].proportionbody=1.1*bodyprop;
7549 player[closest].proportionarms=1.1*armprop;
7550 player[closest].proportionlegs=1.1*legprop;
7553 if(player[closest].creature==rabbittype){
7554 player[closest].proportionhead=1.2*headprop;
7555 player[closest].proportionbody=1.05*bodyprop;
7556 player[closest].proportionarms=1.00*armprop;
7557 player[closest].proportionlegs=1.1*legprop;
7558 player[closest].proportionlegs.y=1.05*legprop;
7562 detailtogglekeydown=1;
7565 if(!IsKeyDown(theKeyMap, MAC_X_KEY)){
7566 detailtogglekeydown=0;
7569 if(IsKeyDown(theKeyMap, MAC_B_KEY)&&!slomotogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7572 slomotogglekeydown=1;
7576 if(((IsKeyDown(theKeyMap, MAC_I_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY))/*||buttons[1]*/)&&!explodetogglekeydown&&debugmode){
7578 float closestdist=-1;
7580 XYZ flatfacing2,flatvelocity2;
7583 for(i=1;i<numplayers;i++){
7584 distance=findDistancefast(&player[i].coords,&player[0].coords);
7585 if(distance<144&&!player[i].headless)
7586 if(closestdist==-1||distance<closestdist){
7587 closestdist=distance;
7589 blah = player[i].coords;
7594 XYZ headspurtdirection;
7595 int i = player[closest].skeleton.jointlabels[head];
7596 for(k=0;k<player[closest].skeleton.num_joints; k++){
7597 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7598 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7599 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;
7600 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7601 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7602 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7603 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7604 headspurtdirection=player[closest].skeleton.joints[player[closest].skeleton.jointlabels[head]].position-player[closest].skeleton.joints[player[closest].skeleton.jointlabels[neck]].position;
7605 Normalise(&headspurtdirection);
7606 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, .6, 1);
7607 flatvelocity2+=headspurtdirection*8;
7608 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2/2, 1,1,1, .16, 1);
7610 sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
7620 PlaySoundEx( splattersound, samp[splattersound], NULL, TRUE);
7621 FSOUND_3D_SetAttributes(channels[splattersound], gLoc, vel);
7622 FSOUND_SetVolume(channels[splattersound], 256);
7623 FSOUND_SetPaused(channels[splattersound], FALSE);
7625 PlaySoundEx( breaksound2, samp[breaksound2], NULL, TRUE);
7626 FSOUND_3D_SetAttributes(channels[breaksound2], gLoc, vel);
7627 FSOUND_SetVolume(channels[breaksound2], 100);
7628 FSOUND_SetPaused(channels[breaksound2], FALSE);
7630 if(player[closest].skeleton.free==2)player[closest].skeleton.free=0;
7631 player[closest].RagDoll(0);
7632 player[closest].dead=2;
7633 player[closest].headless=1;
7634 player[closest].DoBloodBig(3,165);
7639 explodetogglekeydown=1;
7642 if(((IsKeyDown(theKeyMap, MAC_I_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY))/*||buttons[2]*/)&&!explodetogglekeydown&&debugmode){
7644 float closestdist=-1;
7646 XYZ flatfacing2,flatvelocity2;
7649 for(i=1;i<numplayers;i++){
7650 distance=findDistancefast(&player[i].coords,&player[0].coords);
7652 if(closestdist==-1||distance<closestdist){
7653 closestdist=distance;
7655 blah=player[i].coords;
7669 PlaySoundEx( splattersound, samp[splattersound], NULL, TRUE);
7670 FSOUND_3D_SetAttributes(channels[splattersound], gLoc, vel);
7671 FSOUND_SetVolume(channels[splattersound], 256);
7672 FSOUND_SetPaused(channels[splattersound], FALSE);
7674 PlaySoundEx( breaksound2, samp[breaksound2], NULL, TRUE);
7675 FSOUND_3D_SetAttributes(channels[breaksound2], gLoc, vel);
7676 FSOUND_SetVolume(channels[breaksound2], 600);
7677 FSOUND_SetPaused(channels[breaksound2], FALSE);
7679 for(i=0;i<player[closest].skeleton.num_joints; i++){
7680 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7681 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7682 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;
7683 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7684 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7685 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7686 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7687 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
7688 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .3, 1);
7689 sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
7692 for(i=0;i<player[closest].skeleton.num_joints; i++){
7693 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7694 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7695 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;
7696 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7697 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7698 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7699 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7700 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
7701 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
7704 for(i=0;i<player[closest].skeleton.num_joints; i++){
7705 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7706 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7707 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;
7708 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7709 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7710 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7711 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7712 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
7713 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
7716 for(i=0;i<player[closest].skeleton.num_joints; i++){
7717 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7718 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7719 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;
7720 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7721 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7722 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7723 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7724 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
7725 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
7729 for(j=0;j<numplayers; j++){
7731 if(findDistancefast(&player[j].coords,&player[closest].coords)<25){
7732 player[j].DoDamage((25-findDistancefast(&player[j].coords,&player[closest].coords))*60);
7733 if(player[j].skeleton.free==2)player[j].skeleton.free=1;
7734 player[j].skeleton.longdead=0;
7735 player[j].RagDoll(0);
7736 for(i=0;i<player[j].skeleton.num_joints; i++){
7737 temppos=player[j].skeleton.joints[i].position+player[j].coords;
7738 if(findDistancefast(&temppos,&player[closest].coords)<25){
7739 flatvelocity2=temppos-player[closest].coords;
7740 Normalise(&flatvelocity2);
7741 player[j].skeleton.joints[i].velocity+=flatvelocity2*((20-findDistancefast(&temppos,&player[closest].coords))*20);
7748 player[closest].DoDamage(10000);
7749 player[closest].RagDoll(0);
7750 player[closest].dead=2;
7751 player[closest].coords=20;
7752 player[closest].skeleton.free=2;
7758 explodetogglekeydown=1;
7761 if(!IsKeyDown(theKeyMap, MAC_I_KEY)){
7762 explodetogglekeydown=0;
7766 if(IsKeyDown(theKeyMap, MAC_S_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)&&!slomotogglekeydown){
7768 //tfile=fopen( ":Data:Maps:mapsave", "wb" );
7769 if(whichlevel==0)tfile=fopen( ":Data:Maps:map1", "wb" );
7770 else if(whichlevel==1)tfile=fopen( ":Data:Maps:map2", "wb" );
7771 else if(whichlevel==2)tfile=fopen( ":Data:Maps:map3", "wb" );
7772 else if(whichlevel==3)tfile=fopen( ":Data:Maps:map4", "wb" );
7773 else if(whichlevel==4)tfile=fopen( ":Data:Maps:map5", "wb" );
7774 else tfile=fopen( ":Data:Maps:mapsave", "wb" );
7776 fwrite( &player[0].coords, 1, sizeof(XYZ), tfile );
7777 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
7778 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
7779 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
7780 for(j=0;j<player[0].num_weapons;j++){
7781 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
7783 fwrite( &environment, 1, sizeof(int), tfile );
7785 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
7786 fwrite( &objects.type, 1, sizeof(int)*objects.numobjects, tfile );
7787 fwrite( &objects.rotation, 1, sizeof(float)*objects.numobjects, tfile );
7788 fwrite( &objects.position, 1, sizeof(XYZ)*objects.numobjects, tfile );
7789 fwrite( &objects.scale, 1, sizeof(float)*objects.numobjects, tfile );
7791 fwrite( &numplayers, 1, sizeof(int), tfile );
7792 if(numplayers>1&&numplayers<maxplayers)
7793 for(i=1;i<numplayers;i++){
7794 fwrite( &player[i].coords, 1, sizeof(XYZ), tfile );
7795 fwrite( &player[i].num_weapons, 1, sizeof(int), tfile );
7796 for(j=0;j<player[i].num_weapons;j++){
7797 fwrite( &weapons.type[player[i].weaponids[j]], 1, sizeof(int), tfile );
7799 if(player[i].numwaypoints<30){
7800 fwrite( &player[i].numwaypoints, 1, sizeof(int), tfile );
7801 fwrite( &player[i].waypoints, 1, sizeof(XYZ)*player[i].numwaypoints, tfile );
7802 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7803 //fwrite( &player[i].jumppath, 1, sizeof(bool), tfile );
7806 player[i].numwaypoints=0;
7807 player[i].waypoint=0;
7808 fwrite( &player[i].numwaypoints, 1, sizeof(int), tfile );
7809 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7810 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7816 slomotogglekeydown=1;
7819 if(!IsKeyDown(theKeyMap, MAC_B_KEY)&&!IsKeyDown(theKeyMap, MAC_F_KEY)&&!IsKeyDown(theKeyMap, MAC_K_KEY)&&!IsKeyDown(theKeyMap, MAC_S_KEY)){
7820 slomotogglekeydown=0;
7824 if(IsKeyDown(theKeyMap, MAC_F_KEY)&&!slomotogglekeydown&&debugmode){
7825 player[0].onfire=1-player[0].onfire;
7826 if(player[0].onfire){
7827 player[0].CatchFire();
7829 if(!player[0].onfire){
7832 gLoc[0]=player[0].coords.x;
7833 gLoc[1]=player[0].coords.y;
7834 gLoc[2]=player[0].coords.z;
7838 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
7839 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
7840 FSOUND_SetVolume(channels[fireendsound], 256);
7841 FSOUND_SetPaused(channels[fireendsound], FALSE);
7842 FSOUND_SetPaused(channels[stream_firesound], TRUE);
7844 slomotogglekeydown=1;
7847 if(IsKeyDown(theKeyMap, MAC_L_KEY)){
7848 if(player[0].bleeding<=0)
7849 player[0].DoBlood(1,255);
7853 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)){
7855 float closestdist=-1;
7858 for(i=1;i<numplayers;i++){
7859 distance=findDistancefast(&player[i].coords,&player[0].coords);
7860 if(closestdist==-1||distance<closestdist){
7861 closestdist=distance;
7865 if(closestdist>0&&closest>=0){
7866 //player[closest]=player[numplayers-1];
7867 //player[closest].skeleton=player[numplayers-1].skeleton;
7870 drawmodetogglekeydown=1;
7873 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7875 float closestdist=-1;
7878 for(i=1;i<max_objects;i++){
7879 distance=findDistancefast(&objects.position[i],&player[0].coords);
7880 if(closestdist==-1||distance<closestdist){
7881 closestdist=distance;
7885 if(closestdist>0&&closest>=0){
7886 objects.position[closest].y-=500;
7888 drawmodetogglekeydown=1;
7891 if(IsKeyDown(theKeyMap, MAC_M_KEY)&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&editorenabled&&debugmode){
7893 //if(drawmode>2)drawmode=0;
7894 if(objects.numobjects<max_objects-1){
7896 boxcoords.x=player[0].coords.x;
7897 boxcoords.z=player[0].coords.z;
7898 boxcoords.y=player[0].coords.y-3;
7899 if(editortype==bushtype)boxcoords.y=player[0].coords.y-.5;
7900 if(editortype==firetype)boxcoords.y=player[0].coords.y-.5;
7901 //objects.MakeObject(abs(Random()%3),boxcoords,Random()%360);
7902 float temprotat,temprotat2;
7903 temprotat=editorrotation;
7904 temprotat2=editorrotation2;
7905 if(temprotat<0||editortype==bushtype)temprotat=Random()%360;
7906 if(temprotat2<0)temprotat2=Random()%360;
7908 objects.MakeObject(editortype,boxcoords,(int)temprotat-((int)temprotat)%30,(int)temprotat2,editorsize);
7909 if(editortype==treetrunktype)
7910 objects.MakeObject(treeleavestype,boxcoords,Random()%360*(temprotat2<2)+(int)editorrotation-((int)editorrotation)%30,editorrotation2,editorsize);
7913 drawmodetogglekeydown=1;
7916 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&editorenabled){
7917 if(numplayers<maxplayers-1){
7918 player[numplayers].scale=.2*5*player[0].scale;
7919 player[numplayers].creature=rabbittype;
7920 player[numplayers].howactive=editoractive;
7921 player[numplayers].skeleton.id=numplayers;
7922 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);
7924 //texsize=512*512*3/texdetail/texdetail;
7925 //if(!player[numplayers].loaded)player[numplayers].skeleton.skinText = new GLubyte[texsize];
7926 //player[numplayers].skeleton.skinText.resize(texsize);
7928 k=abs(Random()%2)+1;
7930 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7931 player[numplayers].whichskin=0;
7934 LoadTextureSave(":Data:Textures:Fur.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7935 player[numplayers].whichskin=1;
7938 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7939 player[numplayers].whichskin=2;
7942 LoadTexture(":Data:Textures:Belt.png",&player[numplayers].skeleton.drawmodelclothes.textureptr,1,1);
7943 player[numplayers].power=1;
7944 player[numplayers].speedmult=1;
7945 player[numplayers].currentanimation=bounceidleanim;
7946 player[numplayers].targetanimation=bounceidleanim;
7947 player[numplayers].currentframe=0;
7948 player[numplayers].targetframe=1;
7949 player[numplayers].target=0;
7950 player[numplayers].bled=0;
7951 player[numplayers].speed=1+(float)(Random()%100)/1000;
7953 player[numplayers].targetrotation=player[0].targetrotation;
7954 player[numplayers].rotation=player[0].rotation;
7956 player[numplayers].velocity=0;
7957 player[numplayers].coords=player[0].coords;
7958 player[numplayers].oldcoords=player[numplayers].coords;
7959 player[numplayers].realoldcoords=player[numplayers].coords;
7961 player[numplayers].id=numplayers;
7962 player[numplayers].skeleton.id=numplayers;
7963 player[numplayers].updatedelay=0;
7964 player[numplayers].normalsupdatedelay=0;
7966 player[numplayers].aitype=passivetype;
7967 player[numplayers].aitarget=0;
7969 if(player[0].creature==wolftype){
7970 headprop=player[0].proportionhead.x/1.1;
7971 bodyprop=player[0].proportionbody.x/1.1;
7972 armprop=player[0].proportionarms.x/1.1;
7973 legprop=player[0].proportionlegs.x/1.1;
7976 if(player[0].creature==rabbittype){
7977 headprop=player[0].proportionhead.x/1.2;
7978 bodyprop=player[0].proportionbody.x/1.05;
7979 armprop=player[0].proportionarms.x/1.00;
7980 legprop=player[0].proportionlegs.x/1.1;
7983 if(player[numplayers].creature==wolftype){
7984 player[numplayers].proportionhead=1.1*headprop;
7985 player[numplayers].proportionbody=1.1*bodyprop;
7986 player[numplayers].proportionarms=1.1*armprop;
7987 player[numplayers].proportionlegs=1.1*legprop;
7990 if(player[numplayers].creature==rabbittype){
7991 player[numplayers].proportionhead=1.2*headprop;
7992 player[numplayers].proportionbody=1.05*bodyprop;
7993 player[numplayers].proportionarms=1.00*armprop;
7994 player[numplayers].proportionlegs=1.1*legprop;
7995 player[numplayers].proportionlegs.y=1.05*legprop;
7998 player[numplayers].headless=0;
7999 player[numplayers].onfire=0;
8002 player[numplayers].proportionhead.z=0;
8003 player[numplayers].proportionbody.z=0;
8004 player[numplayers].proportionarms.z=0;
8005 player[numplayers].proportionlegs.z=0;
8008 player[numplayers].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0);
8010 player[numplayers].damagetolerance=200;
8012 player[numplayers].protectionhead=player[0].protectionhead;
8013 player[numplayers].protectionhigh=player[0].protectionhigh;
8014 player[numplayers].protectionlow=player[0].protectionlow;
8015 player[numplayers].armorhead=player[0].armorhead;
8016 player[numplayers].armorhigh=player[0].armorhigh;
8017 player[numplayers].armorlow=player[0].armorlow;
8018 player[numplayers].metalhead=player[0].metalhead;
8019 player[numplayers].metalhigh=player[0].metalhigh;
8020 player[numplayers].metallow=player[0].metallow;
8022 player[numplayers].immobile=player[0].immobile;
8024 player[numplayers].numclothes=player[0].numclothes;
8025 if(player[numplayers].numclothes)
8026 for(i=0;i<player[numplayers].numclothes;i++){
8027 strcpy(player[numplayers].clothes[i], player[0].clothes[i]);
8028 player[numplayers].clothestintr[i]=player[0].clothestintr[i];
8029 player[numplayers].clothestintg[i]=player[0].clothestintg[i];
8030 player[numplayers].clothestintb[i]=player[0].clothestintb[i];
8031 tintr=player[numplayers].clothestintr[i];
8032 tintg=player[numplayers].clothestintg[i];
8033 tintb=player[numplayers].clothestintb[i];
8034 AddClothes((char *)player[numplayers].clothes[i],0,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
8036 if(player[numplayers].numclothes){
8037 player[numplayers].DoMipmaps(5,0,0,player[numplayers].skeleton.skinsize,player[numplayers].skeleton.skinsize);
8040 player[numplayers].power=player[0].power;
8041 player[numplayers].speedmult=player[0].speedmult;
8043 player[numplayers].damage=0;
8044 player[numplayers].permanentdamage=0;
8045 player[numplayers].superpermanentdamage=0;
8046 player[numplayers].deathbleeding=0;
8047 player[numplayers].bleeding=0;
8048 player[numplayers].numwaypoints=0;
8049 player[numplayers].waypoint=0;
8050 player[numplayers].jumppath=0;
8051 player[numplayers].weaponstuck=-1;
8052 player[numplayers].weaponactive=-1;
8053 player[numplayers].num_weapons=0;
8054 player[numplayers].bloodloss=0;
8055 player[numplayers].dead=0;
8057 player[numplayers].loaded=1;
8061 drawmodetogglekeydown=1;
8064 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&editorenabled){
8065 if(player[numplayers-1].numwaypoints<90){
8066 player[numplayers-1].waypoints[player[numplayers-1].numwaypoints]=player[0].coords;
8067 player[numplayers-1].waypointtype[player[numplayers-1].numwaypoints]=editorpathtype;
8068 player[numplayers-1].numwaypoints++;
8070 drawmodetogglekeydown=1;
8073 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&editorenabled){
8074 if(numpathpoints<30){
8075 bool connected,alreadyconnected;
8078 for(i=0;i<numpathpoints;i++){
8079 if(findDistancefast(&pathpoint[i],&player[0].coords)<.5&&i!=pathpointselected&&!connected){
8081 for(j=0;j<numpathpointconnect[pathpointselected];j++){
8082 if(pathpointconnect[pathpointselected][j]==i)alreadyconnected=1;
8084 if(!alreadyconnected){
8085 numpathpointconnect[pathpointselected]++;
8087 pathpointconnect[pathpointselected][numpathpointconnect[pathpointselected]-1]=i;
8093 pathpoint[numpathpoints-1]=player[0].coords;
8094 numpathpointconnect[numpathpoints-1]=0;
8095 if(numpathpoints>1&&pathpointselected!=-1){
8096 numpathpointconnect[pathpointselected]++;
8097 pathpointconnect[pathpointselected][numpathpointconnect[pathpointselected]-1]=numpathpoints-1;
8099 pathpointselected=numpathpoints-1;
8102 drawmodetogglekeydown=1;
8105 if(IsKeyDown(theKeyMap, MAC_PERIOD_KEY)&&!drawmodetogglekeydown&&editorenabled){
8106 pathpointselected++;
8107 if(pathpointselected>=numpathpoints)pathpointselected=-1;
8108 drawmodetogglekeydown=1;
8110 if(IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!drawmodetogglekeydown&&editorenabled){
8111 pathpointselected--;
8112 if(pathpointselected<=-2)pathpointselected=numpathpoints-1;
8113 drawmodetogglekeydown=1;
8115 if(IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!drawmodetogglekeydown&&editorenabled){
8116 if(pathpointselected!=-1){
8118 pathpoint[pathpointselected]=pathpoint[numpathpoints];
8119 numpathpointconnect[pathpointselected]=numpathpointconnect[numpathpoints];
8120 for(i=0;i<numpathpointconnect[pathpointselected];i++){
8121 pathpointconnect[pathpointselected][i]=pathpointconnect[numpathpoints][i];
8123 for(i=0;i<numpathpoints;i++){
8124 for(j=0;j<numpathpointconnect[i];j++){
8125 if(pathpointconnect[i][j]==pathpointselected){
8126 pathpointconnect[i][j]=pathpointconnect[i][numpathpointconnect[i]-1];
8127 numpathpointconnect[i]--;
8129 if(pathpointconnect[i][j]==numpathpoints){
8130 pathpointconnect[i][j]=pathpointselected;
8134 pathpointselected=numpathpoints-1;
8136 drawmodetogglekeydown=1;
8139 if(IsKeyDown(theKeyMap, MAC_M_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
8140 editorenabled=1-editorenabled;
8142 player[0].damagetolerance=100000;
8144 player[0].superpermanentdamage=0;
8145 player[0].bloodloss=0;
8146 player[0].deathbleeding=0;
8149 player[0].damagetolerance=200;
8151 player[0].permanentdamage=0;
8152 player[0].superpermanentdamage=0;
8153 player[0].bloodloss=0;
8154 player[0].deathbleeding=0;
8156 drawmodetogglekeydown=1;
8159 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8161 if(editortype==treeleavestype||editortype==10)editortype--;
8162 if(editortype<0)editortype=firetype;
8163 drawmodetogglekeydown=1;
8166 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8168 if(editortype==treeleavestype||editortype==10)editortype++;
8169 if(editortype>firetype)editortype=0;
8170 drawmodetogglekeydown=1;
8173 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8174 editorrotation-=multiplier*100;
8175 if(editorrotation<-.01)editorrotation=-.01;
8176 drawmodetogglekeydown=1;
8179 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8180 editorrotation+=multiplier*100;
8181 drawmodetogglekeydown=1;
8184 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8185 editorsize+=multiplier;
8186 drawmodetogglekeydown=1;
8189 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8190 editorsize-=multiplier;
8191 if(editorsize<.1)editorsize=.1;
8192 drawmodetogglekeydown=1;
8196 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8197 mapradius-=multiplier*10;
8200 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8201 mapradius+=multiplier*10;
8204 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8205 mapcenter.x+=multiplier*20;
8208 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8209 mapcenter.x-=multiplier*20;
8212 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8213 mapcenter.z+=multiplier*20;
8216 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8217 mapcenter.z-=multiplier*20;
8220 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8221 editorrotation2+=multiplier*100;
8224 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8225 editorrotation2-=multiplier*100;
8226 if(editorrotation2<-.01)editorrotation2=-.01;
8228 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&objects.numobjects&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)){
8230 float closestdist=-1;
8232 for(i=0;i<objects.numobjects;i++){
8233 distance=findDistancefast(&objects.position[i],&player[0].coords);
8234 if(closestdist==-1||distance<closestdist){
8235 closestdist=distance;
8239 if(closestdist>0&&closest>=0)objects.DeleteObject(closest);
8240 drawmodetogglekeydown=1;
8244 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)){
8245 drawmodetogglekeydown=0;
8248 if(IsKeyDown(theKeyMap, MAC_N_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&!texturesizetogglekeydown&&debugmode){
8249 //if(!player[0].skeleton.free)player[0].damage+=500;
8250 player[0].RagDoll(0);
8251 //player[0].spurt=1;
8252 //player[0].DoDamage(1000);
8256 gLoc[0]=player[0].coords.x;
8257 gLoc[1]=player[0].coords.y;
8258 gLoc[2]=player[0].coords.z;
8259 vel[0]=player[0].velocity.x;
8260 vel[1]=player[0].velocity.y;
8261 vel[2]=player[0].velocity.z;
8262 PlaySoundEx( whooshsound, samp[whooshsound], NULL, TRUE);
8263 FSOUND_3D_SetAttributes(channels[whooshsound], gLoc, vel);
8264 FSOUND_SetVolume(channels[whooshsound], 128);
8265 FSOUND_SetPaused(channels[whooshsound], FALSE);
8266 //FSOUND_SetPaused(channels[whooshsound], TRUE);
8268 texturesizetogglekeydown=1;
8271 if(IsKeyDown(theKeyMap, MAC_N_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&!texturesizetogglekeydown&&debugmode){
8274 float closestdist=-1;
8276 for(i=0;i<objects.numobjects;i++){
8277 if(objects.type[i]==treeleavestype){
8278 objects.scale[i]*=.9;
8281 texturesizetogglekeydown=1;
8284 static XYZ relative;
8285 static int randattack;
8287 static bool playerrealattackkeydown=0;
8289 if(!buttons[0])oldbutton=0;
8290 if(!IsKeyDown(theKeyMap, attackkey))oldattackkey=0;
8291 if(oldattackkey)player[0].attackkeydown=0;
8292 if(oldattackkey)playerrealattackkeydown=0;
8293 if(!oldattackkey)playerrealattackkeydown=IsKeyDown(theKeyMap, attackkey);
8294 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);
8295 if(IsKeyDown(theKeyMap, attackkey)&&!oldattackkey&&!player[0].backkeydown){
8296 for(k=0;k<numplayers;k++){
8297 if((player[k].targetanimation==swordslashanim||player[k].targetanimation==staffhitanim||player[k].targetanimation==staffspinhitanim)&&player[0].currentanimation!=dodgebackanim&&!player[k].skeleton.free)
8298 player[k].Reverse();
8302 if(!hostile||indialogue!=-1)player[0].attackkeydown=0;
8304 for(k=0;k<numplayers;k++){
8305 if(indialogue!=-1)player[k].attackkeydown=0;
8306 if(player[k].targetanimation!=rabbitrunninganim&&player[k].targetanimation!=wolfrunninganim){
8307 if(player[k].aitype!=playercontrolled)player[k].victim=&player[0];
8308 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)){
8309 player[k].jumppower-=2;
8311 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)){
8312 for(i=0;i<numplayers;i++){
8314 if(player[i].targetanimation==swordslashanim||player[i].targetanimation==knifeslashstartanim||player[i].targetanimation==staffhitanim||player[i].targetanimation==staffspinhitanim)
8315 if(findDistancefast(&player[k].coords,&player[i].coords)<6.5&&!player[i].skeleton.free){
8316 player[k].targetanimation=dodgebackanim;
8318 player[k].targetframe=0;
8319 rotatetarget=player[i].coords-player[k].coords;
8320 Normalise(&rotatetarget);
8321 player[k].targetrotation=-asin(0-rotatetarget.x);
8322 player[k].targetrotation*=360/6.28;
8323 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8325 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;
8328 if(player[k].targetanimation!=dodgebackanim){
8329 if(k==0)numflipped++;
8330 player[k].targetanimation=backhandspringanim;
8332 player[k].targetframe=0;
8333 player[k].targetrotation=-rotation+180;
8334 if(player[k].leftkeydown)player[k].targetrotation-=45;
8335 if(player[k].rightkeydown)player[k].targetrotation+=45;
8336 player[k].rotation=player[k].targetrotation;
8337 player[k].jumppower-=2;
8340 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())){
8341 player[k].hasvictim=0;
8343 for(i=0;i<numplayers;i++){
8345 if(!player[k].hasvictim)
8346 if((k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack!=reversal){
8347 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){
8348 player[k].victim=&player[i];
8349 player[k].hasvictim=1;
8350 if(player[k].aitype==playercontrolled){
8351 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;
8352 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;
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&&!player[k].forwardkeydown&&!player[k].leftkeydown&&!player[k].rightkeydown&&!player[k].crouchkeydown&&player[k].weaponactive==-1)player[k].targetanimation=upunchanim;
8354 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;
8355 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;
8356 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;
8357 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;
8358 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;
8359 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;
8360 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;
8363 if(findDistancefast(&player[k].coords,&player[i].coords)<4.5*(player[k].scale*5)*(player[k].scale*5)){
8364 if(player[k].weaponactive==-1)randattack=abs(Random()%5);
8365 else randattack=abs(Random()%5);
8366 if(player[k].weaponactive==-1&&findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)){
8367 if(randattack==0&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=sweepanim;
8368 else if(randattack==1&&animation[player[i].targetanimation].height!=lowheight&&player[k].weaponactive==-1)player[k].targetanimation=upunchanim;
8369 else if(randattack==2&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=spinkickanim;
8370 else if(animation[player[i].targetanimation].height==lowheight)player[k].targetanimation=lowkickanim;
8372 if(player[k].weaponactive!=-1){
8373 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;
8374 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;
8375 //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;
8376 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;
8377 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;
8378 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;
8379 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;
8380 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;
8384 if(player[k].targetanimation==upunchanim&&player[k].creature==wolftype)player[k].targetanimation=wolfslapanim;
8386 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)){
8387 if(player[k].weaponactive==-1){
8388 player[i].targetanimation=sneakattackedanim;
8389 player[i].currentanimation=sneakattackedanim;
8390 player[k].currentanimation=sneakattackanim;
8391 player[k].targetanimation=sneakattackanim;
8392 player[k].oldcoords=player[k].coords;
8393 player[k].coords=player[i].coords;
8395 if(player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==knife){
8396 player[i].targetanimation=knifesneakattackedanim;
8397 player[i].currentanimation=knifesneakattackedanim;
8398 player[k].currentanimation=knifesneakattackanim;
8399 player[k].targetanimation=knifesneakattackanim;
8400 player[i].oldcoords=player[i].coords;
8401 player[i].coords=player[k].coords;
8403 if(player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==sword){
8404 player[i].targetanimation=swordsneakattackedanim;
8405 player[i].currentanimation=swordsneakattackedanim;
8406 player[k].currentanimation=swordsneakattackanim;
8407 player[k].targetanimation=swordsneakattackanim;
8408 player[i].oldcoords=player[i].coords;
8409 player[i].coords=player[k].coords;
8411 if(player[k].weaponactive==-1||weapons.type[player[k].weaponids[player[k].weaponactive]]!=staff){
8412 player[k].victim=&player[i];
8413 player[k].hasvictim=1;
8414 player[i].targettilt2=0;
8415 player[i].targetframe=1;
8416 player[i].currentframe=0;
8418 player[i].velocity=0;
8419 player[k].targettilt2=player[i].targettilt2;
8420 player[k].currentframe=player[i].currentframe;
8421 player[k].targetframe=player[i].targetframe;
8422 player[k].target=player[i].target;
8423 player[k].velocity=0;
8424 player[k].targetrotation=player[i].rotation;
8425 player[k].rotation=player[i].rotation;
8426 player[i].targetrotation=player[i].rotation;
8429 if(animation[player[k].targetanimation].attack==normalattack&&player[k].victim==&player[i]&&(!player[i].skeleton.free)){
8431 player[k].targetframe=0;
8433 //player[k].velocity=0;
8435 rotatetarget=player[i].coords-player[k].coords;
8436 Normalise(&rotatetarget);
8437 player[k].targetrotation=-asin(0-rotatetarget.x);
8438 player[k].targetrotation*=360/6.28;
8439 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8441 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8443 player[k].lastattack3=player[k].lastattack2;
8444 player[k].lastattack2=player[k].lastattack;
8445 player[k].lastattack=player[k].targetanimation;
8446 //player[k].targettilt2=0;
8450 if(player[k].targetanimation==knifefollowanim&&player[k].victim==&player[i]){
8451 rotatetarget=player[i].coords-player[k].coords;
8452 Normalise(&rotatetarget);
8453 player[k].targetrotation=-asin(0-rotatetarget.x);
8454 player[k].targetrotation*=360/6.28;
8455 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8456 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8458 player[k].victim=&player[i];
8459 player[k].hasvictim=1;
8460 player[i].targetanimation=knifefollowedanim;
8461 player[i].currentanimation=knifefollowedanim;
8462 player[i].targettilt2=0;
8463 player[i].targettilt2=player[k].targettilt2;
8464 player[i].targetframe=1;
8465 player[i].currentframe=0;
8467 player[i].velocity=0;
8468 player[k].currentanimation=knifefollowanim;
8469 player[k].targetanimation=knifefollowanim;
8470 player[k].targettilt2=player[i].targettilt2;
8471 player[k].currentframe=player[i].currentframe;
8472 player[k].targetframe=player[i].targetframe;
8473 player[k].target=player[i].target;
8474 player[k].velocity=0;
8475 player[k].oldcoords=player[k].coords;
8476 player[i].coords=player[k].coords;
8477 player[i].targetrotation=player[k].targetrotation;
8478 player[i].rotation=player[k].targetrotation;
8479 player[k].rotation=player[k].targetrotation;
8480 player[i].rotation=player[k].targetrotation;
8485 if(player[k].weaponactive!=-1){
8486 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==staff)hasstaff=1;
8489 for(i=0;i<numplayers;i++){
8491 if((playerrealattackkeydown||player[i].dead||!hasstaff)&&(k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack==neutral&&k==0){
8492 if(!player[i].dead||!realthreat||(player[k].weaponactive==-1&&player[k].crouchkeydown))
8493 if(player[i].skeleton.free)
8494 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)))){
8495 player[k].victim=&player[i];
8496 player[k].hasvictim=1;
8497 if(player[k].weaponactive!=-1&&tutoriallevel!=1){
8498 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;
8499 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;
8500 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;
8502 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){
8503 player[k].targetanimation=killanim;
8504 for(j=0;j<terrain.numdecals;j++){
8505 if((terrain.decaltype[j]==blooddecal||terrain.decaltype[j]==blooddecalslow)&&terrain.decalalivetime[j]<2){
8506 terrain.DeleteDecal(j);
8509 for(l=0;l<objects.numobjects;l++){
8510 if(objects.model[l].type==decalstype)
8511 for(j=0;j<objects.model[l].numdecals;j++){
8512 if((objects.model[l].decaltype[j]==blooddecal||objects.model[l].decaltype[j]==blooddecalslow)&&objects.model[l].decalalivetime[j]<2){
8513 objects.model[l].DeleteDecal(j);
8518 if(!player[i].dead||musictype!=2)
8519 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)){
8520 player[k].targetanimation=dropkickanim;
8521 for(j=0;j<terrain.numdecals;j++){
8522 if((terrain.decaltype[j]==blooddecal||terrain.decaltype[j]==blooddecalslow)&&terrain.decalalivetime[j]<2){
8523 terrain.DeleteDecal(j);
8526 for(l=0;l<objects.numobjects;l++){
8527 if(objects.model[l].type==decalstype)
8528 for(j=0;j<objects.model[l].numdecals;j++){
8529 if((objects.model[l].decaltype[j]==blooddecal||objects.model[l].decaltype[j]==blooddecalslow)&&objects.model[l].decalalivetime[j]<2){
8530 objects.model[l].DeleteDecal(j);
8536 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)){
8538 player[k].targetframe=0;
8540 //player[k].velocity=0;
8542 rotatetarget=player[i].coords-player[k].coords;
8543 if(player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim||player[k].targetanimation==staffgroundsmashanim){
8544 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;
8546 Normalise(&rotatetarget);
8547 player[k].targetrotation=-asin(0-rotatetarget.x);
8548 player[k].targetrotation*=360/6.28;
8549 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8551 if(player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim){
8552 player[k].targetrotation+=(float)(abs(Random()%100)-50)/4;
8555 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8556 if(player[k].targetanimation==staffgroundsmashanim)player[k].targettilt2+=10;
8558 player[k].lastattack3=player[k].lastattack2;
8559 player[k].lastattack2=player[k].lastattack;
8560 player[k].lastattack=player[k].targetanimation;
8562 if(player[k].targetanimation==swordgroundstabanim){
8563 player[k].targetrotation+=30;
8565 //player[k].targettilt2=0;
8571 if(!player[k].hasvictim){
8572 for(i=0;i<numplayers;i++){
8573 if((player[k].hasvictim==0)&&i!=k&&(i==0||k==0)&&!player[i].skeleton.free){
8574 player[k].victim=&player[i];
8575 player[k].hasvictim=1;
8577 if(player[k].hasvictim&&!player[i].skeleton.free)
8578 if(findDistancefast(&player[k].coords,&player[i].coords)<findDistancefast(&player[k].coords,&player[k].victim->coords)&&i!=k&&(i==0||k==0)){
8579 player[k].victim=&player[i];
8583 if(player[k].aitype==playercontrolled)
8584 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)){
8586 player[k].targetanimation=rabbitkickanim;
8587 player[k].targetframe=0;
8590 if(animation[player[k].targetanimation].attack&&k==0){
8593 if(player[k].weaponactive!=-1){
8594 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==staff)armedstaff=1;
8597 if(player[k].weaponactive!=-1){
8598 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==sword)armedsword=1;
8601 if(player[k].weaponactive!=-1){
8602 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==knife)armedknife=1;
8604 if(armedstaff)numstaffattack++;
8605 else if(armedsword)numswordattack++;
8606 else if(armedknife)numknifeattack++;
8607 else numunarmedattack++;
8614 static float collisionradius;
8616 for(k=0;k<numplayers;k++){
8617 for(i=k;i<numplayers;i++){
8620 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))
8621 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))
8622 if(player[i].howactive<=typesleeping&&player[k].howactive<=typesleeping)
8623 if(player[i].howactive!=typesittingwall&&player[k].howactive!=typesittingwall)
8624 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)
8625 if(player[i].coords.y>player[k].coords.y-3)
8626 if(player[i].coords.y<player[k].coords.y+3)
8627 if(player[i].coords.x>player[k].coords.x-3)
8628 if(player[i].coords.x<player[k].coords.x+3)
8629 if(player[i].coords.z>player[k].coords.z-3)
8630 if(player[i].coords.z<player[k].coords.z+3){
8631 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)){
8632 if(player[i].onfire||player[k].onfire){
8633 if(!player[i].onfire)player[i].CatchFire();
8634 if(!player[k].onfire)player[k].CatchFire();
8638 tempcoords1=player[i].coords;
8639 tempcoords2=player[k].coords;
8640 if(!player[i].skeleton.oldfree)tempcoords1.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[abdomen]].position.y*player[i].scale;
8641 if(!player[k].skeleton.oldfree)tempcoords2.y+=player[k].skeleton.joints[player[k].skeleton.jointlabels[abdomen]].position.y*player[k].scale;
8642 collisionradius=1.2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5);
8643 if(player[0].hasvictim)
8644 if(player[0].targetanimation==rabbitkickanim&&(k==0||i==0)&&!player[0].victim->skeleton.free)collisionradius=3;
8645 if((!player[i].skeleton.oldfree||!player[k].skeleton.oldfree)&&(findDistancefast(&tempcoords1,&tempcoords2)<collisionradius||findDistancefast(&player[i].coords,&player[k].coords)<collisionradius)){
8647 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)){
8648 player[k].coords.y=player[i].coords.y;
8649 player[i].velocity=player[k].velocity;
8650 player[i].skeleton.free=0;
8651 player[i].rotation=0;
8652 player[i].RagDoll(0);
8653 player[i].DoDamage(20);
8654 if(k==0)camerashake+=.3;
8655 player[i].skeleton.longdead=0;
8656 player[k].lastcollide=1;
8659 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)){
8660 player[i].coords.y=player[k].coords.y;
8661 player[k].velocity=player[i].velocity;
8662 player[k].skeleton.free=0;
8663 player[k].rotation=0;
8664 player[k].RagDoll(0);
8665 player[k].DoDamage(20);
8666 if(i==0)camerashake+=.3;
8667 player[k].skeleton.longdead=0;
8668 player[i].lastcollide=1;
8671 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)){
8672 rotatetarget=player[k].velocity-player[i].velocity;
8673 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))
8674 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))){
8676 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)){
8677 static float gLoc[3];
8678 static float vel[3];
8679 gLoc[0]=player[i].coords.x;
8680 gLoc[1]=player[i].coords.y;
8681 gLoc[2]=player[i].coords.z;
8682 vel[0]=player[i].velocity.x;
8683 vel[1]=player[i].velocity.y;
8684 vel[2]=player[i].velocity.z;
8685 if(tutoriallevel!=1){
8686 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, TRUE);
8687 FSOUND_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
8688 FSOUND_SetVolume(channels[heavyimpactsound], 256);
8689 FSOUND_SetPaused(channels[heavyimpactsound], FALSE);
8691 //player[i].velocity=player[k].velocity;
8692 //player[k].velocity=player[i].velocity;
8694 player[i].RagDoll(0);
8695 if(player[i].damage>player[i].damagetolerance-findLengthfast(&rotatetarget)/4&&!player[i].dead){
8700 player[i].DoDamage(findLengthfast(&rotatetarget)/4);
8701 player[k].RagDoll(0);
8702 if(player[k].damage>player[k].damagetolerance-findLengthfast(&rotatetarget)/4&&!player[k].dead){
8707 player[k].DoDamage(findLengthfast(&rotatetarget)/4);
8709 //if(player[i].skeleton.oldfree){
8710 for(j=0;j<player[i].skeleton.num_joints;j++){
8711 player[i].skeleton.joints[j].velocity=player[i].skeleton.joints[j].velocity/5+player[k].velocity;
8714 //if(player[k].skeleton.oldfree){
8715 for(j=0;j<player[k].skeleton.num_joints;j++){
8716 player[k].skeleton.joints[j].velocity=player[k].skeleton.joints[j].velocity/5+player[i].velocity;
8722 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)){
8724 if(player[i].skeleton.oldfree==0&&player[k].skeleton.oldfree==0){
8725 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)){
8726 rotatetarget=player[k].coords-player[i].coords;
8727 Normalise(&rotatetarget);
8728 player[k].coords=(player[k].coords+player[i].coords)/2;
8729 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);
8730 player[k].coords+=rotatetarget*fast_sqrt(.6)/2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5);
8731 if(player[k].howactive==typeactive||hostile)
8732 if(player[k].isIdle()){
8733 if(player[k].howactive<typesleeping){
8734 player[k].targetanimation=player[k].getStop();
8735 player[k].targetframe=0;
8738 else if(player[k].howactive==typesleeping)
8740 player[k].targetanimation=getupfromfrontanim;
8741 player[k].targetframe=0;
8744 if(!editorenabled)player[k].howactive=typeactive;
8746 if(player[i].howactive==typeactive||hostile)
8747 if(player[i].isIdle()){
8748 if(player[i].howactive<typesleeping){
8749 player[i].targetanimation=player[i].getStop();
8750 player[i].targetframe=0;
8755 player[i].targetanimation=getupfromfrontanim;
8756 player[i].targetframe=0;
8759 if(!editorenabled)player[i].howactive=typeactive;
8763 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){
8764 player[i].velocity=player[k].velocity;
8765 player[k].velocity=player[k].velocity*-.5;
8766 //player[i].velocity.y-=10;
8767 player[k].velocity.y=player[i].velocity.y;
8768 player[i].DoDamage(20);
8769 player[i].RagDoll(0);
8770 player[k].lastcollide=1;
8777 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){
8778 player[k].velocity=player[i].velocity;
8779 player[i].velocity=player[i].velocity*-.3;
8780 //player[k].velocity.y-=10;
8781 player[i].velocity.y=player[k].velocity.y;
8782 player[k].DoDamage(20);
8783 player[k].RagDoll(0);
8784 player[i].lastcollide=1;
8795 player[i].CheckKick();
8796 player[k].CheckKick();
8802 for(k=0;k<numplayers;k++){
8803 for(i=k;i<numplayers;i++){
8805 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))){
8806 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)){
8807 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)){
8808 player[i].victim=&player[k];
8809 player[i].targetanimation=jumpreversedanim;
8810 player[i].currentanimation=jumpreversedanim;
8811 player[k].currentanimation=jumpreversalanim;
8812 player[k].targetanimation=jumpreversalanim;
8813 player[i].targettilt2=0;
8814 player[i].currentframe=0;
8815 player[i].targetframe=1;
8816 player[k].currentframe=0;
8817 player[k].targetframe=1;
8818 if(player[i].coords.y<player[k].coords.y+1){
8819 player[i].targetanimation=rabbitkickreversedanim;
8820 player[i].currentanimation=rabbitkickreversedanim;
8821 player[k].currentanimation=rabbitkickreversalanim;
8822 player[k].targetanimation=rabbitkickreversalanim;
8823 player[k].currentframe=1;
8824 player[k].targetframe=2;
8825 player[i].currentframe=1;
8826 player[i].targetframe=2;
8828 player[k].targettilt2=0;
8830 player[i].velocity=0;
8831 player[k].velocity=0;
8832 player[k].oldcoords=player[k].coords;
8833 player[i].coords=player[k].coords;
8834 player[k].targetrotation=player[i].targetrotation;
8835 player[k].rotation=player[i].targetrotation;
8836 player[k].victim=&player[i];
8837 if(player[k].aitype==attacktypecutoff)player[k].stunned=.5;
8839 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)){
8840 player[k].victim=&player[i];
8841 player[k].targetanimation=jumpreversedanim;
8842 player[k].currentanimation=jumpreversedanim;
8843 player[i].currentanimation=jumpreversalanim;
8844 player[i].targetanimation=jumpreversalanim;
8845 player[k].targettilt2=0;
8846 player[i].targettilt2=0;
8847 player[k].currentframe=0;
8848 player[k].targetframe=1;
8849 player[i].currentframe=0;
8850 player[i].targetframe=1;
8851 if(player[k].coords.y<player[i].coords.y+1){
8852 player[k].targetanimation=rabbitkickreversedanim;
8853 player[k].currentanimation=rabbitkickreversedanim;
8854 player[i].currentanimation=rabbitkickreversalanim;
8855 player[i].targetanimation=rabbitkickreversalanim;
8856 player[k].currentframe=1;
8857 player[k].targetframe=2;
8858 player[i].currentframe=1;
8859 player[i].targetframe=2;
8862 player[k].velocity=0;
8863 player[i].velocity=0;
8864 player[i].oldcoords=player[i].coords;
8865 player[k].coords=player[i].coords;
8866 player[i].targetrotation=player[k].targetrotation;
8867 player[i].rotation=player[k].targetrotation;
8868 player[i].victim=&player[k];
8869 if(player[i].aitype==attacktypecutoff)player[i].stunned=.5;
8876 for(k=0;k<numplayers;k++)
8877 if(player[k].immobile&&k!=0)player[k].coords=player[k].realoldcoords;
8886 static float checkdelay;
8887 checkdelay-=multiplier;
8889 static bool checkedcoll[maxplayers][maxplayers];
8890 static bool above[maxplayers];
8892 for(i=0;i<maxplayers;i++){
8893 for(j=0;j<maxplayers;j++){
8894 checkedcoll[i][j]=0;
8898 if(numplayers>1&&checkdelay<=0){
8900 for(k=0;k<numplayers;k++){
8901 if(player[k].skeleton.free!=2)above[k]=-1;
8903 for(i=k;i<numplayers;i++){
8906 if(!checkedcoll[i][k]){
8907 checkedcoll[i][k]=1;
8908 checkedcoll[k][i]=1;
8909 if(player[i].skeleton.free&&player[k].skeleton.free)
8910 if(player[i].skeleton.free!=2||player[k].skeleton.free!=2)
8911 if(i!=k&&player[i].whichpatchx==player[k].whichpatchx&&player[i].whichpatchz==player[k].whichpatchz)
8912 if(player[i].coords.y>player[k].coords.y-3)
8913 if(player[i].coords.y<player[k].coords.y+3)
8914 if(player[i].coords.x>player[k].coords.x-3)
8915 if(player[i].coords.x<player[k].coords.x+3)
8916 if(player[i].coords.z>player[k].coords.z-3)
8917 if(player[i].coords.z<player[k].coords.z+3)
8918 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)){
8920 if((player[i].skeleton.longdead>player[k].skeleton.longdead&&player[k].skeleton.free!=2)||player[i].skeleton.free==2){
8932 above[moving]=stuck;
8933 for(l=0;l<player[moving].skeleton.num_joints;l++){
8934 for(m=0;m<player[stuck].skeleton.num_joints;m++){
8935 while(findDistancefast(player[moving].skeleton.joints[l].position+player[moving].coords,player[stuck].skeleton.joints[m].position+player[stuck].coords)<.25)
8937 player[moving].skeleton.joints[l].position.y+=.003;
8938 if(player[moving].skeleton.joints[l].velocity.y<-.05)player[moving].skeleton.joints[l].velocity.y+=.003/.015/2;
8952 if(!IsKeyDown(theKeyMap, MAC_N_KEY)){
8953 texturesizetogglekeydown=0;
8956 for(k=0;k<numplayers;k++){
8957 if(!isnormal(player[k].coords.x)||!isnormal(player[k].coords.y)||!isnormal(player[k].coords.z)){
8958 if(!isnormal(player[k].coords.x)||!isnormal(player[k].coords.y)||!isnormal(player[k].coords.z)){
8959 player[k].DoDamage(1000);
8964 static bool respawnkeydown;
8965 if(!editorenabled&&(whichlevel!=-2&&(IsKeyDown(theKeyMap, MAC_Z_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)&&debugmode&&!editorenabled)||(IsKeyDown(theKeyMap, jumpkey)&&!respawnkeydown&&!oldattackkey&&player[0].dead))){
8966 targetlevel=whichlevel;
8970 if(!IsKeyDown(theKeyMap, jumpkey))respawnkeydown=0;
8971 if(IsKeyDown(theKeyMap, jumpkey))respawnkeydown=1;
8976 if(whichlevel!=-2&&IsKeyDown(theKeyMap, MAC_K_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!slomotogglekeydown&&debugmode&&!editorenabled){
8978 if(targetlevel>numchallengelevels-1)targetlevel=0;
8981 slomotogglekeydown=1;
8985 if(IsKeyDown(theKeyMap, MAC_Z_KEY)){
8987 FSOUND_SetPaused(channels[whooshsound], TRUE);
8989 for(k=0;k<numplayers;k++){
8992 player[k].permanentdamage=0;
8993 if(player[k].skeleton.free==2)player[k].skeleton.free=1;
8994 player[k].aitype=passivetype;
8996 player[0].aitype=playercontrolled;
9000 static bool movekey;
9001 static bool connected;
9002 /*player[0].forwardkeydown=IsKeyDown(theKeyMap, MAC_W_KEY);
9003 player[0].leftkeydown=IsKeyDown(theKeyMap, MAC_A_KEY);
9004 player[0].backkeydown=IsKeyDown(theKeyMap, MAC_S_KEY);
9005 player[0].rightkeydown=IsKeyDown(theKeyMap, MAC_D_KEY);
9006 player[0].jumpkeydown=IsKeyDown(theKeyMap, MAC_SPACE_KEY);
9007 player[0].crouchkeydown=IsKeyDown(theKeyMap, MAC_SHIFT_KEY);*/
9009 //if(!player[0].crouchkeydown)player[0].crouchkeydown=IsKeyDown(theKeyMap, MAC_CONTROL_KEY);
9011 for(int i=0;i<numplayers;i++){
9012 if(!player[i].skeleton.free){
9013 oldtargetrotation=player[i].targetrotation;
9014 if(i==0&&indialogue==-1){
9015 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){
9016 if(!cameramode)player[0].targetrotation=-rotation+180;
9017 if(cameramode)player[0].targetrotation=0;
9023 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
9024 if(cameramode){facing=flatfacing;}
9026 facing=DoRotation(facing,-rotation2,0,0);
9027 facing=DoRotation(facing,0,0-rotation,0);
9030 player[0].lookrotation=-rotation;
9032 player[i].targetheadrotation=rotation;
9033 player[i].targetheadrotation2=rotation2;
9035 if(i!=0&&player[i].aitype==playercontrolled&&indialogue==-1){
9036 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){
9037 player[i].targetrotation=-player[i].lookrotation+180;
9043 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
9045 facing=DoRotation(facing,-player[i].lookrotation2,0,0);
9046 facing=DoRotation(facing,0,0-player[i].lookrotation,0);
9048 player[i].targetheadrotation=player[i].lookrotation;
9049 player[i].targetheadrotation2=player[i].lookrotation2;
9052 rotatetarget=participantfacing[whichdialogue][indialogue][i];
9053 Normalise(&rotatetarget);
9054 player[i].targetheadrotation=-asin(0-rotatetarget.x);
9055 player[i].targetheadrotation*=360/6.28;
9056 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
9058 player[i].targetheadrotation*=-1;
9059 player[i].targetheadrotation+=180;
9060 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
9068 player[i].avoidsomething=0;
9070 for(j=0;j<objects.numobjects;j++){
9071 if(objects.onfire[j]){
9072 if(findDistancefast(&objects.position[j],&player[i].coords)<objects.scale[j]*objects.scale[j]*200)
9074 if(findDistancefast(&player[i].coords,&objects.position[j])<findDistancefast(&player[i].coords,&player[0].coords)){
9075 player[i].collided=0;
9076 player[i].avoidcollided=1;
9077 if(player[i].avoidsomething==0||findDistancefast(&objects.position[j],&player[i].coords)<findDistancefast(&player[i].coords,&player[i].avoidwhere))
9078 player[i].avoidwhere=objects.position[j];
9084 //Add avoidwhere to players
9086 for(j=0;j<numplayers;j++){
9087 if(player[j].onfire){
9088 if(findDistancefast(&player[j].coords,&player[i].coords)<0.3*0.3*200)
9090 if(findDistancefast(&player[i].coords,&player[j].coords)<findDistancefast(&player[i].coords,&player[0].coords)){
9091 player[i].collided=0;
9092 player[i].avoidcollided=1;
9093 if(player[i].avoidsomething==0||findDistancefast(&player[j].coords,&player[i].coords)<findDistancefast(&player[i].coords,&player[i].avoidwhere))
9094 player[i].avoidwhere=objects.position[j];
9100 if(player[i].collided>.8)player[i].avoidcollided=0;
9101 if(player[i].aitype!=playercontrolled&&indialogue==-1){
9102 player[i].jumpclimb=0;
9104 if(editorenabled)player[i].stunned=1;
9107 //if(findDistancefastflat(&player[i].coords,&player[0].coords)<3/*&&player[0].coords.y>player[i].coords.y+.1*/)player[i].pause=1;
9108 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;
9110 /*if(player[i].aitype==passivetype&&player[i].numwaypoints<=1){
9111 player[i].forwardkeydown=0;
9112 player[i].leftkeydown=0;
9113 player[i].backkeydown=0;
9114 player[i].rightkeydown=0;
9115 player[i].crouchkeydown=0;
9116 player[i].attackkeydown=0;
9117 player[i].jumpkeydown=0;
9118 player[i].throwkeydown=0;
9121 if(player[i].aitype==pathfindtype){
9122 if(player[i].finalpathfindpoint==-1){
9123 float closestdistance;
9129 for(j=0;j<numpathpoints;j++){
9130 if(closest==-1||findDistancefast(&player[i].finalfinaltarget,&pathpoint[j])<closestdistance){
9131 closestdistance=findDistancefast(&player[i].finalfinaltarget,&pathpoint[j]);
9133 player[i].finaltarget=pathpoint[j];
9136 player[i].finalpathfindpoint=closest;
9137 for(j=0;j<numpathpoints;j++){
9138 if(numpathpointconnect[j])
9139 for(k=0;k<numpathpointconnect[j];k++){
9140 DistancePointLine(&player[i].finalfinaltarget, &pathpoint[j], &pathpoint[pathpointconnect[j][k]], &tempdist,&colpoint );
9141 if(tempdist*tempdist<closestdistance){
9142 if(findDistance(&colpoint,&pathpoint[j])+findDistance(&colpoint,&pathpoint[pathpointconnect[j][k]])<findDistance(&pathpoint[j],&pathpoint[pathpointconnect[j][k]])+.1){
9143 closestdistance=tempdist*tempdist;
9145 player[i].finaltarget=colpoint;
9150 player[i].finalpathfindpoint=closest;
9153 if(player[i].targetpathfindpoint==-1){
9154 float closestdistance;
9160 if(player[i].lastpathfindpoint==-1){
9161 for(j=0;j<numpathpoints;j++){
9162 if(j!=player[i].lastpathfindpoint)
9163 if(closest==-1||(findDistancefast(&player[i].coords,&pathpoint[j])<closestdistance/*&&findDistancefast(&player[i].finaltarget,&pathpoint[j])<findDistancefast(&player[i].finaltarget,&player[i].coords)*/)){
9164 closestdistance=findDistancefast(&player[i].coords,&pathpoint[j]);
9168 player[i].targetpathfindpoint=closest;
9169 for(j=0;j<numpathpoints;j++){
9170 if(j!=player[i].lastpathfindpoint)
9171 if(numpathpointconnect[j])
9172 for(k=0;k<numpathpointconnect[j];k++){
9173 DistancePointLine(&player[i].coords, &pathpoint[j], &pathpoint[pathpointconnect[j][k]], &tempdist,&colpoint );
9174 if(tempdist*tempdist<closestdistance){
9175 if(findDistance(&colpoint,&pathpoint[j])+findDistance(&colpoint,&pathpoint[pathpointconnect[j][k]])<findDistance(&pathpoint[j],&pathpoint[pathpointconnect[j][k]])+.1){
9176 //if(findDistancefast(&player[i].finaltarget,&colpoint)<findDistancefast(&player[i].finaltarget,&player[i].coords)){
9177 closestdistance=tempdist*tempdist;
9184 player[i].targetpathfindpoint=closest;
9188 for(j=0;j<numpathpoints;j++){
9189 if(j!=player[i].lastpathfindpoint&&j!=player[i].lastpathfindpoint2&&j!=player[i].lastpathfindpoint3&&j!=player[i].lastpathfindpoint4)
9192 if(numpathpointconnect[j])
9193 for(k=0;k<numpathpointconnect[j];k++){
9194 if(pathpointconnect[j][k]==player[i].lastpathfindpoint)connected=1;
9197 if(numpathpointconnect[player[i].lastpathfindpoint])
9198 for(k=0;k<numpathpointconnect[player[i].lastpathfindpoint];k++){
9199 if(pathpointconnect[player[i].lastpathfindpoint][k]==j)connected=1;
9202 tempdist=findPathDist(j,player[i].finalpathfindpoint);
9203 if(closest==-1||tempdist<closestdistance){
9204 closestdistance=tempdist;
9210 player[i].targetpathfindpoint=closest;
9213 player[i].losupdatedelay-=multiplier;
9215 rotatetarget=pathpoint[player[i].targetpathfindpoint]-player[i].coords;
9216 Normalise(&rotatetarget);
9217 player[i].targetrotation=-asin(0-rotatetarget.x);
9218 player[i].targetrotation*=360/6.28;
9219 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9220 player[i].lookrotation=player[i].targetrotation;
9221 //player[i].aiupdatedelay=.05;
9223 if(findDistancefastflat(&player[i].coords,&pathpoint[player[i].targetpathfindpoint])<.6){
9224 player[i].lastpathfindpoint4=player[i].lastpathfindpoint3;
9225 player[i].lastpathfindpoint3=player[i].lastpathfindpoint2;
9226 player[i].lastpathfindpoint2=player[i].lastpathfindpoint;
9227 player[i].lastpathfindpoint=player[i].targetpathfindpoint;
9228 if(player[i].lastpathfindpoint2==-1)player[i].lastpathfindpoint2=player[i].lastpathfindpoint;
9229 if(player[i].lastpathfindpoint3==-1)player[i].lastpathfindpoint3=player[i].lastpathfindpoint2;
9230 if(player[i].lastpathfindpoint4==-1)player[i].lastpathfindpoint4=player[i].lastpathfindpoint3;
9231 player[i].targetpathfindpoint=-1;
9233 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){
9234 player[i].aitype=passivetype;
9237 player[i].forwardkeydown=1;
9238 player[i].leftkeydown=0;
9239 player[i].backkeydown=0;
9240 player[i].rightkeydown=0;
9241 player[i].crouchkeydown=0;
9242 player[i].attackkeydown=0;
9243 player[i].throwkeydown=0;
9245 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9247 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9248 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9250 if((tutoriallevel!=1||cananger)&&hostile&&!player[0].dead&&findDistancefast(&player[i].coords,&player[0].coords)<400&&player[i].occluded<25){
9251 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))
9252 player[i].aitype=attacktypecutoff;
9253 if(findDistancefast(&player[i].coords,&player[0].coords)<30&&animation[player[0].targetanimation].height==highheight&&!editorenabled)
9254 player[i].aitype=attacktypecutoff;
9256 if(player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2){
9257 player[i].losupdatedelay=.2;
9258 for(j=0;j<numplayers;j++){
9259 if(j==0||player[j].skeleton.free||player[j].aitype!=passivetype){
9260 if(abs(Random()%2)||animation[player[j].targetanimation].height!=lowheight||j!=0)
9261 if(findDistancefast(&player[i].coords,&player[j].coords)<400)
9262 if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0)
9263 if(player[j].coords.y<player[i].coords.y+5||player[j].onterrain)
9264 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)){
9265 player[i].aitype=searchtype;
9266 player[i].lastchecktime=12;
9267 player[i].lastseen=player[j].coords;
9268 player[i].lastseentime=12;
9274 if(player[i].aitype==attacktypecutoff&&musictype!=2){
9275 if(player[i].creature!=wolftype){
9276 player[i].stunned=.6;
9277 player[i].surprised=.6;
9282 if(player[i].aitype!=passivetype&&leveltime>.5){
9283 player[i].howactive=typeactive;
9286 if(player[i].aitype==passivetype){
9287 player[i].aiupdatedelay-=multiplier;
9288 player[i].losupdatedelay-=multiplier;
9289 player[i].lastseentime+=multiplier;
9290 player[i].pausetime-=multiplier;
9291 if(player[i].lastseentime>1)player[i].lastseentime=1;
9293 if(player[i].aiupdatedelay<0){
9294 if(player[i].numwaypoints>1&&player[i].howactive==typeactive&&player[i].pausetime<=0){
9295 rotatetarget=player[i].waypoints[player[i].waypoint]-player[i].coords;
9296 Normalise(&rotatetarget);
9297 player[i].targetrotation=-asin(0-rotatetarget.x);
9298 player[i].targetrotation*=360/6.28;
9299 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9300 player[i].lookrotation=player[i].targetrotation;
9301 player[i].aiupdatedelay=.05;
9303 if(findDistancefastflat(&player[i].coords,&player[i].waypoints[player[i].waypoint])<1){
9304 if(player[i].waypointtype[player[i].waypoint]==wppause)player[i].pausetime=4;
9305 player[i].waypoint++;
9306 if(player[i].waypoint>player[i].numwaypoints-1)player[i].waypoint=0;
9311 if(player[i].numwaypoints>1&&player[i].howactive==typeactive&&player[i].pausetime<=0)player[i].forwardkeydown=1;
9312 else player[i].forwardkeydown=0;
9313 player[i].leftkeydown=0;
9314 player[i].backkeydown=0;
9315 player[i].rightkeydown=0;
9316 player[i].crouchkeydown=0;
9317 player[i].attackkeydown=0;
9318 player[i].throwkeydown=0;
9320 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9321 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9323 XYZ leftpos,rightpos;
9324 float leftdist,rightdist;
9325 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9326 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9327 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9328 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9329 if(leftdist<rightdist)player[i].targetrotation+=90;
9330 else player[i].targetrotation-=90;
9334 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9335 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9339 if(player[i].howactive<typesleeping)
9340 if(numenvsounds>0&&(tutoriallevel!=1||cananger)&&hostile)
9341 for(j=0;j<numenvsounds;j++){
9342 if(findDistancefast(&player[i].coords,&envsound[j])<2*(envsoundvol[j]+envsoundvol[j]*(player[i].creature==rabbittype)*3)){
9343 player[i].aitype=attacktypecutoff;
9347 if(player[i].howactive==typesleeping)
9348 if(numenvsounds>0&&(tutoriallevel!=1||cananger)&&hostile)
9349 for(j=0;j<numenvsounds;j++){
9350 if(envsoundvol[j]>14)
9351 if(findDistancefast(&player[i].coords,&envsound[j])<2*((envsoundvol[j]-14)+(envsoundvol[j]-14)*(player[i].creature==rabbittype)*3)){
9352 player[i].aitype=attacktypecutoff;
9356 if(player[i].aitype!=passivetype){
9357 if(player[i].howactive==typesleeping){
9358 player[i].targetanimation=getupfromfrontanim;
9359 player[i].targetframe=0;
9363 player[i].howactive=typeactive;
9367 if(player[i].howactive<typesleeping&&((tutoriallevel!=1||cananger)&&hostile)&&!player[0].dead&&findDistancefast(&player[i].coords,&player[0].coords)<400&&player[i].occluded<25){
9368 if(findDistancefast(&player[i].coords,&player[0].coords)<12&&animation[player[0].targetanimation].height!=lowheight&&!editorenabled)
9369 player[i].aitype=attacktypecutoff;
9370 if(findDistancefast(&player[i].coords,&player[0].coords)<30&&animation[player[0].targetanimation].height==highheight&&!editorenabled)
9371 player[i].aitype=attacktypecutoff;
9373 if(player[i].creature==wolftype){
9375 float smelldistance;
9377 for(j=0;j<numplayers;j++){
9378 if(j==0||(player[j].dead&&player[j].bloodloss>0)){
9379 if(j==0&&player[j].num_weapons>0){
9380 if(weapons.bloody[player[j].weaponids[0]])smelldistance=100;
9381 if(player[j].num_weapons==2)
9382 if(weapons.bloody[player[j].weaponids[1]])smelldistance=100;
9387 windsmell=windvector;
9388 Normalise(&windsmell);
9389 windsmell=windsmell*2+player[j].coords;
9390 if(findDistancefast(&player[i].coords,&windsmell)<smelldistance&&!editorenabled)
9391 player[i].aitype=attacktypecutoff;
9396 if(player[i].howactive<typesleeping&&player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2){
9397 player[i].losupdatedelay=.2;
9398 for(j=0;j<numplayers;j++){
9399 if(j==0||player[j].skeleton.free||player[j].aitype!=passivetype){
9400 if(abs(Random()%2)||animation[player[j].targetanimation].height!=lowheight||j!=0)
9401 if(findDistancefast(&player[i].coords,&player[j].coords)<400)
9402 if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0)
9403 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)){
9404 player[i].lastseentime-=.2;
9405 if(j==0&&animation[player[j].targetanimation].height==lowheight)player[i].lastseentime-=.4;
9406 else player[i].lastseentime-=.6;
9408 if(player[i].lastseentime<=0){
9409 player[i].aitype=searchtype;
9410 player[i].lastchecktime=12;
9411 player[i].lastseen=player[j].coords;
9412 player[i].lastseentime=12;
9418 if(player[i].aitype==attacktypecutoff&&musictype!=2){
9419 if(player[i].creature!=wolftype){
9420 player[i].stunned=.6;
9421 player[i].surprised=.6;
9423 if(player[i].creature==wolftype){
9424 player[i].stunned=.47;
9425 player[i].surprised=.47;
9431 if(player[i].aitype==searchtype){
9432 player[i].aiupdatedelay-=multiplier;
9433 player[i].losupdatedelay-=multiplier;
9434 if(!player[i].pause)player[i].lastseentime-=multiplier;
9435 player[i].lastchecktime-=multiplier;
9437 if(player[i].isRun()&&!player[i].onground){
9438 if(player[i].coords.y>terrain.getHeight(player[i].coords.x,player[i].coords.z)+10){
9439 test2=player[i].coords+player[i].facing;
9441 test=player[i].coords+player[i].facing;
9443 j=checkcollide(test2,test,player[i].laststanding);
9444 if(j==-1)j=checkcollide(test2,test);
9446 player[i].velocity=0;
9447 player[i].targetanimation=player[i].getStop();
9448 player[i].targetframe=0;
9450 player[i].targetrotation+=180;
9451 player[i].stunned=.5;
9452 //player[i].aitype=passivetype;
9453 player[i].aitype=pathfindtype;
9454 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9455 player[i].finalpathfindpoint=-1;
9456 player[i].targetpathfindpoint=-1;
9457 player[i].lastpathfindpoint=-1;
9458 player[i].lastpathfindpoint2=-1;
9459 player[i].lastpathfindpoint3=-1;
9460 player[i].lastpathfindpoint4=-1;
9462 else player[i].laststanding=j;
9465 if(player[i].aiupdatedelay<0){
9466 rotatetarget=player[i].lastseen-player[i].coords;
9467 Normalise(&rotatetarget);
9468 player[i].targetrotation=-asin(0-rotatetarget.x);
9469 player[i].targetrotation*=360/6.28;
9470 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9471 player[i].lookrotation=player[i].targetrotation;
9472 player[i].aiupdatedelay=.05;
9473 player[i].forwardkeydown=1;
9475 if(findDistancefastflat(&player[i].coords,&player[i].lastseen)<1*(player[i].scale*5)*(player[i].scale*5)||player[i].lastchecktime<0){
9476 player[i].forwardkeydown=0;
9477 player[i].aiupdatedelay=1;
9478 player[i].lastseen.x+=(float(Random()%100)-50)/25;
9479 player[i].lastseen.z+=(float(Random()%100)-50)/25;
9480 player[i].lastchecktime=3;
9483 player[i].leftkeydown=0;
9484 player[i].backkeydown=0;
9485 player[i].rightkeydown=0;
9486 player[i].crouchkeydown=0;
9487 player[i].attackkeydown=0;
9488 player[i].throwkeydown=0;
9490 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9491 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9493 XYZ leftpos,rightpos;
9494 float leftdist,rightdist;
9495 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9496 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9497 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9498 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9499 if(leftdist<rightdist)player[i].targetrotation+=90;
9500 else player[i].targetrotation-=90;
9504 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9505 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9507 if(numenvsounds>0&&((tutoriallevel!=1||cananger)&&hostile))
9508 for(j=0;j<numenvsounds;j++){
9509 if(findDistancefast(&player[i].coords,&envsound[j])<2*(envsoundvol[j]+envsoundvol[j]*(player[i].creature==rabbittype)*3)){
9510 player[i].aitype=attacktypecutoff;
9514 if(!player[0].dead&&player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2&&((tutoriallevel!=1||cananger)&&hostile)){
9515 player[i].losupdatedelay=.2;
9516 if(findDistancefast(&player[i].coords,&player[0].coords)<4&&animation[player[i].targetanimation].height!=lowheight)
9517 {player[i].aitype=attacktypecutoff;
9518 player[i].lastseentime=1;}
9519 if(abs(Random()%2)||animation[player[i].targetanimation].height!=lowheight)
9520 if(findDistancefast(&player[i].coords,&player[0].coords)<400)
9521 if(normaldotproduct(player[i].facing,player[0].coords-player[i].coords)>0)
9522 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)){
9523 player[i].aitype=attacktypecutoff;
9524 player[i].lastseentime=1;
9527 if(player[i].lastseentime<0){
9528 //player[i].aitype=passivetype;
9530 player[i].aitype=pathfindtype;
9531 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9532 player[i].finalpathfindpoint=-1;
9533 player[i].targetpathfindpoint=-1;
9534 player[i].lastpathfindpoint=-1;
9535 player[i].lastpathfindpoint2=-1;
9536 player[i].lastpathfindpoint3=-1;
9537 player[i].lastpathfindpoint4=-1;
9541 if(player[i].aitype!=gethelptype){
9542 player[i].runninghowlong=0;
9545 if(player[i].aitype==gethelptype){
9546 player[i].runninghowlong+=multiplier;
9547 player[i].aiupdatedelay-=multiplier;
9549 if(player[i].aiupdatedelay<0||player[i].ally==0){
9550 player[i].aiupdatedelay=.2;
9558 if(!player[i].ally){
9559 for(j=0;j<numplayers;j++){
9560 if(j!=i&&j!=0&&!player[j].dead&&player[j].howactive<typedead1&&!player[j].skeleton.free&&player[j].aitype==passivetype){
9561 distance=findDistancefast(&player[i].coords,&player[j].coords);
9562 if(closestdist==-1||distance<closestdist){
9563 closestdist=distance;
9569 if(closest!=-1)player[i].ally=closest;
9570 else player[i].ally=0;
9571 player[i].lastseen=player[0].coords;
9572 player[i].lastseentime=12;
9576 player[i].lastchecktime=12;
9577 //player[i].lastseentime-=.5;
9579 facing=player[i].coords;
9580 flatfacing=player[player[i].ally].coords;
9581 facing.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position.y*player[i].scale;
9582 flatfacing.y+=player[player[i].ally].skeleton.joints[player[player[i].ally].skeleton.jointlabels[head]].position.y*player[player[i].ally].scale;
9583 if(-1!=checkcollide(facing,flatfacing))
9584 player[i].lastseentime-=.1;
9586 if(player[i].ally<=0||player[player[i].ally].skeleton.free||player[player[i].ally].aitype!=passivetype||player[i].lastseentime<=0){
9587 player[i].aitype=searchtype;
9588 player[i].lastseentime=12;
9591 if(player[i].ally>0){
9592 rotatetarget=player[player[i].ally].coords-player[i].coords;
9593 Normalise(&rotatetarget);
9594 player[i].targetrotation=-asin(0-rotatetarget.x);
9595 player[i].targetrotation*=360/6.28;
9596 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9597 player[i].lookrotation=player[i].targetrotation;
9598 player[i].aiupdatedelay=.05;
9599 player[i].forwardkeydown=1;
9601 if(findDistancefastflat(&player[i].coords,&player[player[i].ally].coords)<3){
9602 player[i].aitype=searchtype;
9603 player[i].lastseentime=12;
9604 player[player[i].ally].aitype=searchtype;
9605 if(player[player[i].ally].lastseentime<player[i].lastseentime){
9606 player[player[i].ally].lastseen=player[i].lastseen;
9607 player[player[i].ally].lastseentime=player[i].lastseentime;
9608 player[player[i].ally].lastchecktime=player[i].lastchecktime;
9612 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9613 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9615 XYZ leftpos,rightpos;
9616 float leftdist,rightdist;
9617 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9618 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9619 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9620 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9621 if(leftdist<rightdist)player[i].targetrotation+=90;
9622 else player[i].targetrotation-=90;
9627 player[i].leftkeydown=0;
9628 player[i].backkeydown=0;
9629 player[i].rightkeydown=0;
9630 player[i].crouchkeydown=0;
9631 player[i].attackkeydown=0;
9633 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9634 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9637 if(player[i].aitype==getweapontype){
9638 player[i].aiupdatedelay-=multiplier;
9639 player[i].lastchecktime-=multiplier;
9641 if(player[i].aiupdatedelay<0){
9642 player[i].aiupdatedelay=.2;
9650 if(player[i].ally<0){
9651 for(j=0;j<weapons.numweapons;j++){
9652 if(weapons.owner[j]==-1){
9653 distance=findDistancefast(&player[i].coords,&weapons.position[j]);
9654 if(closestdist==-1||distance<closestdist){
9655 closestdist=distance;
9661 if(closest!=-1)player[i].ally=closest;
9662 else player[i].ally=-1;
9665 player[i].lastseentime=12;
9667 if(!player[0].dead&&((tutoriallevel!=1||cananger)&&hostile))
9668 if(player[i].ally<0||player[i].weaponactive!=-1||player[i].lastchecktime<=0){
9669 player[i].aitype=attacktypecutoff;
9670 player[i].lastseentime=1;
9673 if(player[i].ally>=0){
9674 if(weapons.owner[player[i].ally]!=-1||findDistancefast(&player[i].coords,&weapons.position[player[i].ally])>16){
9675 player[i].aitype=attacktypecutoff;
9676 player[i].lastseentime=1;
9678 rotatetarget=weapons.position[player[i].ally]-player[i].coords;
9679 Normalise(&rotatetarget);
9680 player[i].targetrotation=-asin(0-rotatetarget.x);
9681 player[i].targetrotation*=360/6.28;
9682 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9683 player[i].lookrotation=player[i].targetrotation;
9684 player[i].aiupdatedelay=.05;
9685 player[i].forwardkeydown=1;
9688 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9689 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9691 XYZ leftpos,rightpos;
9692 float leftdist,rightdist;
9693 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9694 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9695 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9696 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9697 if(leftdist<rightdist)player[i].targetrotation+=90;
9698 else player[i].targetrotation-=90;
9701 /*if(findDistancefast(&player[i].coords,&weapons.position[player[i].ally])<3){
9702 if(abs(Random()%6)){
9703 player[i].crouchkeydown=1;
9704 if(!findDistancefast(&player[i].coords,&weapons.position[player[i].ally])<1){
9705 if(player[i].isRun()){
9706 player[i].targetframe=0;
9708 player[i].targetanimation=sneakanim;
9711 else player[i].forwardkeydown=0;
9713 else player[i].crouchkeydown=0;
9715 else player[i].crouchkeydown=0;*/
9718 player[i].leftkeydown=0;
9719 player[i].backkeydown=0;
9720 player[i].rightkeydown=0;
9721 player[i].attackkeydown=0;
9722 player[i].throwkeydown=1;
9723 player[i].crouchkeydown=0;
9724 if(player[i].targetanimation!=crouchremoveknifeanim&&player[i].targetanimation!=removeknifeanim)player[i].throwtogglekeydown=0;
9725 player[i].drawkeydown=0;
9727 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9728 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9731 if(player[i].aitype==attacktypecutoff){
9732 player[i].aiupdatedelay-=multiplier;
9733 if(player[i].damage<player[i].damagetolerance*2/3)
9734 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)){
9735 player[i].attackkeydown=0;
9736 if(player[i].isIdle())player[i].crouchkeydown=1;
9737 if(player[0].targetanimation!=rabbitkickanim&&player[0].weaponactive!=-1){
9738 if(weapons.type[player[0].weaponids[0]]==knife){
9739 if(player[i].isIdle()||player[i].isCrouch()||player[i].isRun()||player[i].isFlip()){
9740 if(abs(Random()%2==0))player[i].targetanimation=backhandspringanim;
9741 else player[i].targetanimation=rollanim;
9743 player[i].targetframe=0;
9744 player[i].targetrotation+=90*(abs(Random()%2)*2-1);
9745 player[i].wentforweapon=0;
9747 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim){
9748 player[i].targetanimation=flipanim;
9750 player[i].targetframe=0;
9754 player[i].forwardkeydown=0;
9755 player[i].aiupdatedelay=.02;
9757 if(player[0].isFlip()&&!player[0].skeleton.free&&player[0].targetanimation!=walljumprightkickanim&&player[0].targetanimation!=walljumpleftkickanim){
9758 if(findDistancefast(&player[0].coords,&player[i].coords)<25)
9759 if((1-player[i].damage/player[i].damagetolerance)>.5)player[i].stunned=1;
9761 if(player[i].wentforweapon<3)
9762 for(j=0;j<weapons.numweapons;j++){
9763 if(player[i].creature!=wolftype)
9764 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){
9765 if(findDistancefast(&player[i].coords,&weapons.position[j])<16){
9766 player[i].wentforweapon++;
9767 player[i].lastchecktime=6;
9768 player[i].aitype=getweapontype;
9773 if(player[i].damage<player[i].damagetolerance/2)
9774 if(animation[player[i].targetanimation].height!=highheight)
9775 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)))){
9776 player[i].crouchkeydown=1;
9778 if(player[i].isRun()&&!player[i].onground){
9779 if(player[i].coords.y>terrain.getHeight(player[i].coords.x,player[i].coords.z)+10){
9780 test2=player[i].coords+player[i].facing;
9782 test=player[i].coords+player[i].facing;
9784 j=checkcollide(test2,test,player[i].laststanding);
9785 if(j==-1)j=checkcollide(test2,test);
9787 player[i].velocity=0;
9788 player[i].targetanimation=player[i].getStop();
9789 player[i].targetframe=0;
9791 player[i].targetrotation+=180;
9792 player[i].stunned=.5;
9793 //player[i].aitype=passivetype;
9794 player[i].aitype=pathfindtype;
9795 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9796 player[i].finalpathfindpoint=-1;
9797 player[i].targetpathfindpoint=-1;
9798 player[i].lastpathfindpoint=-1;
9799 player[i].lastpathfindpoint2=-1;
9800 player[i].lastpathfindpoint3=-1;
9801 player[i].lastpathfindpoint4=-1;
9803 else player[i].laststanding=j;
9806 if(player[0].coords.y>player[i].coords.y+5&&animation[player[0].targetanimation].height!=highheight&&!player[0].onterrain){
9807 player[i].aitype=pathfindtype;
9808 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9809 player[i].finalpathfindpoint=-1;
9810 player[i].targetpathfindpoint=-1;
9811 player[i].lastpathfindpoint=-1;
9812 player[i].lastpathfindpoint2=-1;
9813 player[i].lastpathfindpoint3=-1;
9814 player[i].lastpathfindpoint4=-1;
9816 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){
9817 if(player[i].weaponactive==-1&&player[i].num_weapons>0)player[i].drawkeydown=Random()%2;
9818 else player[i].drawkeydown=0;
9819 player[i].rabbitkickenabled=Random()%2;
9820 rotatetarget=player[player[i].aitarget].coords+player[player[i].aitarget].velocity;
9821 if(findDistancefast(&player[player[i].aitarget].coords,&player[i].coords)<findDistancefast(&rotatetarget,&player[i].coords))
9822 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;
9823 else rotatetarget=player[player[i].aitarget].coords-player[i].coords;
9824 Normalise(&rotatetarget);
9825 player[i].targetrotation=-asin(0-rotatetarget.x);
9826 player[i].targetrotation*=360/6.28;
9827 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9828 player[i].lookrotation=player[i].targetrotation;
9829 player[i].aiupdatedelay=.2+abs((float)(Random()%100)/1000);
9831 oldkey=player[i].forwardkeydown;
9832 if(findDistancefast(&player[i].coords,&player[0].coords)>5&&(player[0].weaponactive==-1||player[i].weaponactive!=-1))player[i].forwardkeydown=1;
9833 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;
9834 else if(Random()%6==0||(player[i].creature==wolftype&&Random()%3==0))player[i].forwardkeydown=1;
9835 else player[i].forwardkeydown=0;
9837 player[i].forwardkeydown=0;
9838 if(Random()%10==0)player[i].forwardkeydown=1;
9839 if(Random()%100==0){
9840 player[i].aitype=pathfindtype;
9841 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9842 player[i].finalpathfindpoint=-1;
9843 player[i].targetpathfindpoint=-1;
9844 player[i].lastpathfindpoint=-1;
9845 player[i].lastpathfindpoint2=-1;
9846 player[i].lastpathfindpoint3=-1;
9847 player[i].lastpathfindpoint4=-1;
9850 player[i].leftkeydown=0;
9851 player[i].backkeydown=0;
9852 player[i].rightkeydown=0;
9853 player[i].crouchkeydown=0;
9854 player[i].throwkeydown=0;
9856 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9857 /*for(j=0;j<numplayers;j++){
9858 if(player[j].victim->id==i&&(player[j].targetanimation==spinkickanim&&player[j].targetframe<3)){
9859 player[i].crouchkeydown=1;
9862 if(Random()%2==0/*||player[0].weaponactive!=-1*/||player[i].weaponactive!=-1||player[i].creature==wolftype)player[i].attackkeydown=1;
9863 else player[i].attackkeydown=0;
9864 if((player[i].isRun())&&Random()%6&&findDistancefast(&player[i].coords,&player[0].coords)>7)player[i].attackkeydown=0;
9865 //if(player[i].attackkeydown&&findDistancefast(&player[i].coords,&player[0].coords)<3&&player[i].targetanimation!=runanim&&!player[0].skeleton.free)player[i].crouchkeydown=1;
9866 /*if(player[0].targetanimation==rabbitkickanim&&!player[0].skeleton.free){
9867 player[i].attackkeydown=0;
9868 if(player[i].isIdle())player[i].crouchkeydown=1;
9869 player[i].forwardkeydown=0;
9870 player[i].aiupdatedelay=.02;
9873 if(player[i].aitype!=playercontrolled&&(player[i].isIdle()||player[i].isCrouch()||player[i].isRun())){
9875 for(j=0;j<numplayers;j++){
9876 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)){
9877 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))))){
9878 if(target>=0)target=-1;
9883 if(target>=0)player[target].Reverse();
9886 if(player[i].collided<1)player[i].jumpkeydown=0;
9887 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;
9888 if(normaldotproduct(player[i].facing,player[0].coords-player[i].coords)>0)
9889 player[0].jumpkeydown=0;
9890 if(player[0].targetanimation==jumpdownanim&&findDistancefast(&player[0].coords,&player[i].coords)<40)player[i].crouchkeydown=1;
9891 if(player[i].jumpkeydown)player[i].attackkeydown=0;
9892 //if(animation[player[i].targetanimation].attack==reversed)player[i].crouchkeydown=1;
9894 if(tutoriallevel==1){
9895 if(!canattack)player[i].attackkeydown=0;
9899 facing=player[i].coords;
9900 flatfacing=player[0].coords;
9901 facing.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position.y*player[i].scale;
9902 flatfacing.y+=player[0].skeleton.joints[player[0].skeleton.jointlabels[head]].position.y*player[0].scale;
9903 if(player[i].occluded>=2)
9904 if(-1!=checkcollide(facing,flatfacing)){
9905 if(!player[i].pause)player[i].lastseentime-=.2;
9906 if(player[i].lastseentime<=0&&(player[i].creature!=wolftype||player[i].weaponstuck==-1)){
9907 player[i].aitype=searchtype;
9908 player[i].lastchecktime=12;
9909 player[i].lastseen=player[0].coords;
9910 player[i].lastseentime=12;
9913 else player[i].lastseentime=1;
9916 if(animation[player[0].targetanimation].height==highheight&&(player[i].aitype==attacktypecutoff||player[i].aitype==searchtype)){
9917 if(player[0].coords.y>terrain.getHeight(player[0].coords.x,player[0].coords.z)+10){
9918 test=player[0].coords;
9920 if(-1==checkcollide(player[0].coords,test))player[i].stunned=1;
9923 // NOTE: Ask about logic of this call : NOTE
9924 if((player[i].aitype==passivetype && !(player[i].numwaypoints>1)) ||
9925 player[i].stunned>0 ||
9926 (player[i].pause && (player[i].damage > player[i].superpermanentdamage)))
9928 if(/*player[i].aitype==attacktypecutoff&&*/player[i].pause)player[i].lastseentime=1;
9929 player[i].targetrotation=player[i].rotation;
9930 player[i].forwardkeydown=0;
9931 player[i].leftkeydown=0;
9932 player[i].backkeydown=0;
9933 player[i].rightkeydown=0;
9934 player[i].jumpkeydown=0;
9935 player[i].attackkeydown=0;
9936 player[i].crouchkeydown=0;
9937 player[i].throwkeydown=0;
9944 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
9947 if(player[i].aitype==attacktypecutoff){
9948 rotatetarget=player[0].coords-player[i].coords;
9949 Normalise(&rotatetarget);
9950 player[i].targetheadrotation=-asin(0-rotatetarget.x);
9951 player[i].targetheadrotation*=360/6.28;
9952 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
9954 player[i].targetheadrotation*=-1;
9955 player[i].targetheadrotation+=180;
9956 //player[i].targetheadrotation2=0;
9957 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
9959 else if(player[i].howactive>=typesleeping){
9960 player[i].targetheadrotation=player[i].targetrotation;
9961 player[i].targetheadrotation2=0;
9964 if(player[i].interestdelay<=0){
9965 player[i].interestdelay=.7+(float)(abs(Random()%100))/100;
9966 player[i].headtarget=player[i].coords;
9967 player[i].headtarget.x+=(float)(abs(Random()%200)-100)/100;
9968 player[i].headtarget.z+=(float)(abs(Random()%200)-100)/100;
9969 player[i].headtarget.y+=(float)(abs(Random()%200)-100)/300;
9970 player[i].headtarget+=player[i].facing*1.5;
9972 rotatetarget=player[i].headtarget-player[i].coords;
9973 Normalise(&rotatetarget);
9974 player[i].targetheadrotation=-asin(0-rotatetarget.x);
9975 player[i].targetheadrotation*=360/6.28;
9976 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
9978 player[i].targetheadrotation*=-1;
9979 player[i].targetheadrotation+=180;
9980 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
9982 //if(whichlevel==2)player[i].jumpkeydown=0;
9984 if(animation[player[i].targetanimation].attack==reversed){
9985 //player[i].targetrotation=player[i].rotation;
9986 player[i].forwardkeydown=0;
9987 player[i].leftkeydown=0;
9988 player[i].backkeydown=0;
9989 player[i].rightkeydown=0;
9990 player[i].jumpkeydown=0;
9991 player[i].attackkeydown=0;
9992 //player[i].crouchkeydown=0;
9993 player[i].throwkeydown=0;
9997 player[i].forwardkeydown=0;
9998 player[i].leftkeydown=0;
9999 player[i].backkeydown=0;
10000 player[i].rightkeydown=0;
10001 player[i].jumpkeydown=0;
10002 player[i].crouchkeydown=0;
10003 player[i].drawkeydown=0;
10004 player[i].throwkeydown=0;
10007 if(player[i].collided<-.3)player[i].collided=-.3;
10008 if(player[i].collided>1)player[i].collided=1;
10009 player[i].collided-=multiplier*4;
10010 player[i].whichdirectiondelay-=multiplier;
10011 if(player[i].avoidcollided<-.3||player[i].whichdirectiondelay<=0){
10012 player[i].avoidcollided=-.3;
10013 player[i].whichdirection=abs(Random()%2);
10014 player[i].whichdirectiondelay=.4;
10016 if(player[i].avoidcollided>1)player[i].avoidcollided=1;
10017 player[i].avoidcollided-=multiplier/4;
10018 if(!player[i].skeleton.free)player[i].stunned-=multiplier;
10019 if(!player[i].skeleton.free)player[i].surprised-=multiplier;
10020 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;
10022 if(!player[i].throwkeydown){
10023 player[i].throwtogglekeydown=0;
10025 if(player[i].throwkeydown&&!player[i].throwtogglekeydown){
10026 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)){
10027 for(j=0;j<weapons.numweapons;j++){
10028 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)
10029 if(findDistancefastflat(&player[i].coords,&weapons.position[j])<2){
10030 if(findDistancefast(&player[i].coords,&weapons.position[j])<2){
10031 if(player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isRun()||player[i].isIdle()||player[i].aitype!=playercontrolled){
10032 player[i].throwtogglekeydown=1;
10033 player[i].targetanimation=crouchremoveknifeanim;
10034 player[i].target=0;
10035 player[i].targetframe=0;
10036 rotatetarget=weapons.position[j]-player[i].coords;
10037 Normalise(&rotatetarget);
10038 player[i].targetrotation=-asin(0-rotatetarget.x);
10039 player[i].targetrotation*=360/6.28;
10040 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10041 player[i].hasvictim=0;
10043 if(player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
10044 player[i].throwtogglekeydown=1;
10045 player[i].hasvictim=0;
10047 //for(i=0;i<weapons.numweapons;i++){
10048 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))
10049 if(findDistancefastflat(&player[i].coords,&weapons.position[j])<2&&player[i].weaponactive==-1){
10050 if(findDistancefast(&player[i].coords,&weapons.position[j])<1||player[i].victim){
10053 gLoc[0]=player[i].coords.x;
10054 gLoc[1]=player[i].coords.y;
10055 gLoc[2]=player[i].coords.z;
10056 vel[0]=player[i].velocity.x;
10057 vel[1]=player[i].velocity.y;
10058 vel[2]=player[i].velocity.z;
10059 if(weapons.type[j]!=staff){
10060 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, TRUE);
10061 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
10062 FSOUND_SetVolume(channels[knifedrawsound], 128);
10063 FSOUND_SetPaused(channels[knifedrawsound], FALSE);
10066 player[i].weaponactive=0;
10067 weapons.owner[j]=player[i].id;
10068 if(player[i].num_weapons>0){
10069 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
10071 player[i].num_weapons++;
10072 player[i].weaponids[0]=j;
10078 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){
10079 if(!player[i].isFlip()){
10080 player[i].throwtogglekeydown=1;
10081 player[i].targetanimation=removeknifeanim;
10082 player[i].target=0;
10083 player[i].targetframe=0;
10084 rotatetarget=weapons.position[j]-player[i].coords;
10085 Normalise(&rotatetarget);
10086 player[i].targetrotation=-asin(0-rotatetarget.x);
10087 player[i].targetrotation*=360/6.28;
10088 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10090 if(player[i].isFlip()){
10091 player[i].throwtogglekeydown=1;
10092 player[i].hasvictim=0;
10094 for(k=0;k<weapons.numweapons;k++){
10095 if(player[i].weaponactive==-1)
10096 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))
10097 if(findDistancefastflat(&player[i].coords,&weapons.position[k])<3&&player[i].weaponactive==-1){
10100 gLoc[0]=player[i].coords.x;
10101 gLoc[1]=player[i].coords.y;
10102 gLoc[2]=player[i].coords.z;
10103 vel[0]=player[i].velocity.x;
10104 vel[1]=player[i].velocity.y;
10105 vel[2]=player[i].velocity.z;
10106 if(weapons.type[k]!=staff){
10107 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, TRUE);
10108 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
10109 FSOUND_SetVolume(channels[knifedrawsound], 128);
10110 FSOUND_SetPaused(channels[knifedrawsound], FALSE);
10113 player[i].weaponactive=0;
10114 weapons.owner[k]=player[i].id;
10115 if(player[i].num_weapons>0){
10116 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
10118 player[i].num_weapons++;
10119 player[i].weaponids[0]=k;
10126 if(player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isRun()||player[i].isIdle()||player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
10128 for(j=0;j<numplayers;j++){
10129 if(player[i].weaponactive==-1)
10131 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)){
10132 if(player[i].targetanimation!=rollanim&&player[i].targetanimation!=backhandspringanim){
10133 player[i].throwtogglekeydown=1;
10134 player[i].victim=&player[j];
10135 player[i].hasvictim=1;
10136 player[i].targetanimation=crouchremoveknifeanim;
10137 player[i].target=0;
10138 player[i].targetframe=0;
10139 rotatetarget=player[j].coords-player[i].coords;
10140 Normalise(&rotatetarget);
10141 player[i].targetrotation=-asin(0-rotatetarget.x);
10142 player[i].targetrotation*=360/6.28;
10143 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10145 if(player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
10146 player[i].throwtogglekeydown=1;
10147 player[i].victim=&player[j];
10148 player[i].hasvictim=1;
10149 int k = player[j].weaponids[0];
10150 if(player[i].hasvictim){
10153 gLoc[0]=player[i].coords.x;
10154 gLoc[1]=player[i].coords.y;
10155 gLoc[2]=player[i].coords.z;
10156 vel[0]=player[i].velocity.x;
10157 vel[1]=player[i].velocity.y;
10158 vel[2]=player[i].velocity.z;
10161 if(player[i].victim->weaponstuck!=-1){
10162 if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){
10167 if(weapons.type[k]!=staff){
10168 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, TRUE);
10169 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
10170 FSOUND_SetVolume(channels[knifedrawsound], 128);
10171 FSOUND_SetPaused(channels[knifedrawsound], FALSE);
10175 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, TRUE);
10176 FSOUND_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
10177 FSOUND_SetVolume(channels[fleshstabremovesound], 128);
10178 FSOUND_SetPaused(channels[fleshstabremovesound], FALSE);
10181 player[i].weaponactive=0;
10182 if(weapons.owner[k]!=-1){
10183 if(player[i].victim->num_weapons==1)player[i].victim->num_weapons=0;
10184 else player[i].victim->num_weapons=1;
10186 player[i].victim->skeleton.longdead=0;
10187 player[i].victim->skeleton.free=1;
10188 player[i].victim->skeleton.broken=0;
10190 for(int l=0;l<player[i].victim->skeleton.num_joints;l++){
10191 player[i].victim->skeleton.joints[l].velchange=0;
10192 player[i].victim->skeleton.joints[l].locked=0;
10198 Normalise(&relative);
10199 XYZ footvel,footpoint;
10201 footpoint=weapons.position[k];
10202 if(player[i].victim->weaponstuck!=-1){
10203 if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){
10204 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
10205 weapons.bloody[k]=2;
10206 weapons.blooddrip[k]=5;
10207 player[i].victim->weaponstuck=-1;
10208 player[i].victim->bloodloss+=2000;
10209 player[i].victim->DoDamage(2000);
10212 if(player[i].victim->num_weapons>0){
10213 if(player[i].victim->weaponstuck!=0&&player[i].victim->weaponstuck!=-1)player[i].victim->weaponstuck=0;
10214 if(player[i].victim->weaponids[0]==k)
10215 player[i].victim->weaponids[0]=player[i].victim->weaponids[player[i].victim->num_weapons];
10218 player[i].victim->weaponactive=-1;
10220 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[abdomen]].velocity+=relative*6;
10221 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[neck]].velocity+=relative*6;
10222 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6;
10223 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6;
10225 weapons.owner[k]=i;
10226 if(player[i].num_weapons>0){
10227 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
10229 player[i].num_weapons++;
10230 player[i].weaponids[0]=k;
10237 if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){
10238 if(weapons.type[player[i].weaponids[0]]==knife){
10239 if(player[i].isIdle()||player[i].isRun()||player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isFlip())
10241 for(j=0;j<numplayers;j++){
10243 if(tutoriallevel!=1||tutorialstage==49)
10245 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)){
10246 if(!player[i].isFlip()){
10247 player[i].throwtogglekeydown=1;
10248 player[i].victim=&player[j];
10249 player[i].targetanimation=knifethrowanim;
10250 player[i].target=0;
10251 player[i].targetframe=0;
10252 rotatetarget=player[j].coords-player[i].coords;
10253 Normalise(&rotatetarget);
10254 player[i].targetrotation=-asin(0-rotatetarget.x);
10255 player[i].targetrotation*=360/6.28;
10256 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10258 player[i].targettilt2=-asin(rotatetarget.y)*360/6.28;
10260 if(player[i].isFlip()){
10261 if(player[i].weaponactive!=-1){
10262 player[i].throwtogglekeydown=1;
10263 player[i].victim=&player[j];
10265 weapons.owner[player[i].weaponids[0]]=-1;
10266 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);
10269 aim=DoRotation(aim,(float)abs(Random()%30)-15,(float)abs(Random()%30)-15,0);
10271 weapons.velocity[player[i].weaponids[0]]=aim*50;
10272 weapons.tipvelocity[player[i].weaponids[0]]=aim*50;
10273 weapons.missed[player[i].weaponids[0]]=0;
10274 weapons.freetime[player[i].weaponids[0]]=0;
10275 weapons.firstfree[player[i].weaponids[0]]=1;
10276 weapons.physics[player[i].weaponids[0]]=0;
10277 player[i].num_weapons--;
10278 if(player[i].num_weapons){
10279 player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons];
10281 player[i].weaponactive=-1;
10288 if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){
10289 if(player[i].isCrouch()||player[i].targetanimation==sneakanim)
10291 player[i].throwtogglekeydown=1;
10292 weapons.owner[player[i].weaponids[0]]=-1;
10293 weapons.velocity[player[i].weaponids[0]]=player[i].velocity*.2;
10294 if(weapons.velocity[player[i].weaponids[0]].x==0)weapons.velocity[player[i].weaponids[0]].x=.1;
10295 weapons.tipvelocity[player[i].weaponids[0]]=weapons.velocity[player[i].weaponids[0]];
10296 weapons.missed[player[i].weaponids[0]]=1;
10297 weapons.freetime[player[i].weaponids[0]]=0;
10298 weapons.firstfree[player[i].weaponids[0]]=1;
10299 weapons.physics[player[i].weaponids[0]]=1;
10300 player[i].num_weapons--;
10301 if(player[i].num_weapons){
10302 player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons];
10303 if(player[i].weaponstuck==player[i].num_weapons)player[i].weaponstuck=0;
10306 player[i].weaponactive=-1;
10307 for(j=0;j<numplayers;j++){
10308 player[j].wentforweapon=0;
10315 if(i==0||!player[0].dead||player[i].weaponactive!=-1)
10316 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)){
10317 //Setenvironment(1-environment);
10320 if(player[i].weaponactive!=-1){
10321 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==staff)isgood=0;
10323 if(/*(player[i].weaponactive==-1||player[i].num_weapons==1)&&*/isgood&&player[i].creature!=wolftype){
10324 if(player[i].isIdle()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){
10325 player[i].targetanimation=drawrightanim;
10326 player[i].targetframe=0;
10327 player[i].target=0;
10328 player[i].drawtogglekeydown=1;
10330 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){
10331 player[i].targetanimation=drawleftanim;
10332 player[i].targetframe=0;
10333 player[i].target=0;
10334 player[i].drawtogglekeydown=1;
10336 if(player[i].isCrouch()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){
10337 player[i].targetanimation=crouchdrawrightanim;
10338 player[i].targetframe=0;
10339 player[i].target=0;
10340 player[i].drawtogglekeydown=1;
10344 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){
10345 if(weapons.bloody[player[i].weaponids[player[i].weaponactive]]&&player[i].onterrain&&bloodtoggle&&musictype!=stream_music2){
10346 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==knife)player[i].targetanimation=crouchstabanim;
10347 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==sword)player[i].targetanimation=swordgroundstabanim;
10348 player[i].targetframe=0;
10349 player[i].target=0;
10350 player[i].hasvictim=0;
10351 //player[i].attacktogglekeydown=1;
10355 if(!player[i].drawkeydown){
10356 player[i].drawtogglekeydown=0;
10361 absflatfacing.z=-1;
10363 absflatfacing=DoRotation(absflatfacing,0,-rotation,0);
10365 else absflatfacing=flatfacing;
10367 if(indialogue!=-1){
10368 player[i].forwardkeydown=0;
10369 player[i].leftkeydown=0;
10370 player[i].backkeydown=0;
10371 player[i].rightkeydown=0;
10372 player[i].jumpkeydown=0;
10373 player[i].crouchkeydown=0;
10374 player[i].drawkeydown=0;
10375 player[i].throwkeydown=0;
10379 if(!animation[player[i].targetanimation].attack&&player[i].targetanimation!=staggerbackhighanim&&player[i].targetanimation!=staggerbackhardanim&&player[i].targetanimation!=backhandspringanim&&player[i].targetanimation!=dodgebackanim){
10380 if(!player[i].forwardkeydown){
10381 player[i].forwardstogglekeydown=0;
10383 if(player[i].crouchkeydown){
10387 player[i].superruntoggle=1;
10389 for(j=0;j<numplayers;j++){
10390 if(j!=i&&!player[j].skeleton.free&&player[j].aitype==passivetype){
10391 if(findDistancefast(&player[j].coords,&player[i].coords)<16){
10392 player[i].superruntoggle=0;
10399 for(j=0;j<numplayers;j++){
10400 if(j!=i&&!player[j].skeleton.free&&player[j].victim&&player[i].lowreversaldelay<=0){
10401 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))){
10402 if(target>=0)target=-1;
10407 if(target>=0)player[target].Reverse();
10408 player[i].lowreversaldelay=.5;
10410 if(player[i].isIdle()){
10411 player[i].targetanimation=player[i].getCrouch();
10412 player[i].target=0;
10413 player[i].targetframe=0;
10414 player[i].transspeed=10;
10416 if(player[i].isRun()||(player[i].isStop()&&(player[i].leftkeydown||player[i].rightkeydown||player[i].forwardkeydown||player[i].backkeydown))){
10417 player[i].targetanimation=rollanim;
10418 player[i].target=0;
10419 player[i].targetframe=0;
10420 player[i].transspeed=20;
10423 if(!player[i].crouchkeydown){
10425 if(!player[i].isRun()&&player[i].targetanimation!=sneakanim&&i==0)player[i].superruntoggle=0;
10427 if(player[i].isCrouch()){
10429 for(j=0;j<numplayers;j++){
10430 if(j!=i&&!player[j].skeleton.free&&player[j].victim&&player[i].highreversaldelay<=0){
10431 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<3&&player[j].victim==&player[i]&&(player[j].targetanimation==spinkickanim)&&player[i].isCrouch()){
10432 if(target>=0)target=-1;
10437 if(target>=0)player[target].Reverse();
10438 player[i].highreversaldelay=.5;
10440 if(player[i].isCrouch()){
10441 if(!player[i].wasCrouch()){
10442 player[i].currentanimation=player[i].getCrouch();
10443 player[i].currentframe=0;
10445 player[i].target=0;
10446 player[i].targetanimation=player[i].getIdle();
10447 player[i].targetframe=0;
10448 player[i].transspeed=10;
10451 if(player[i].targetanimation==sneakanim){
10452 player[i].targetanimation=player[i].getIdle();
10453 player[i].target=0;
10454 player[i].targetframe=0;
10455 player[i].transspeed=10;
10458 if(player[i].forwardkeydown){
10459 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)){
10460 if(player[i].aitype==passivetype)player[i].targetanimation=walkanim;
10461 else player[i].targetanimation=player[i].getRun();
10462 player[i].target=0;
10463 player[i].targetframe=0;
10465 if(player[i].isCrouch()){
10466 player[i].targetanimation=sneakanim;
10467 if(player[i].wasCrouch())player[i].target=0;
10468 player[i].targetframe=0;
10470 if(player[i].targetanimation==hanganim/*&&(!player[i].forwardstogglekeydown||player[i].aitype!=playercontrolled)*/){
10471 player[i].targetanimation=climbanim;
10472 player[i].target=0;
10473 player[i].targetframe=1;
10474 player[i].jumpclimb=1;
10476 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10477 player[i].velocity+=absflatfacing*5*multiplier;
10479 player[i].forwardstogglekeydown=1;
10482 if (player[i].rightkeydown){
10483 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)){
10484 player[i].targetanimation=player[i].getRun();
10485 player[i].target=0;
10486 player[i].targetframe=0;
10488 if(player[i].isCrouch()){
10489 player[i].targetanimation=sneakanim;
10490 if(player[i].wasCrouch()) player[i].target=0;
10491 player[i].targetframe=0;
10493 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10494 player[i].velocity+=DoRotation(absflatfacing*5*multiplier,0,-90,0);
10496 player[i].targetrotation-=90;
10497 if(player[i].forwardkeydown)player[i].targetrotation+=45;
10498 if(player[i].backkeydown)player[i].targetrotation-=45;
10501 if ( player[i].leftkeydown){
10502 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)){
10503 player[i].targetanimation=player[i].getRun();
10504 player[i].target=0;
10505 player[i].targetframe=0;
10507 if(player[i].isCrouch()){
10508 player[i].targetanimation=sneakanim;
10509 if(player[i].wasCrouch())player[i].target=0;
10510 player[i].targetframe=0;
10512 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10513 player[i].velocity-=DoRotation(absflatfacing*5*multiplier,0,-90,0);
10515 player[i].targetrotation+=90;
10516 if(player[i].forwardkeydown)player[i].targetrotation-=45;
10517 if(player[i].backkeydown)player[i].targetrotation+=45;
10520 if(player[i].backkeydown){
10521 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)){
10522 player[i].targetanimation=player[i].getRun();
10523 player[i].target=0;
10524 player[i].targetframe=0;
10526 if(player[i].isCrouch()){
10527 player[i].targetanimation=sneakanim;
10528 if(player[i].wasCrouch())player[i].target=0;
10529 player[i].targetframe=0;
10531 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10532 player[i].velocity-=absflatfacing*5*multiplier;
10534 if(player[i].targetanimation==hanganim){
10535 player[i].currentanimation=jumpdownanim;
10536 player[i].targetanimation=jumpdownanim;
10537 player[i].target=0;
10538 player[i].currentframe=0;
10539 player[i].targetframe=1;
10540 player[i].velocity=0;
10541 player[i].velocity.y+=gravity;
10542 player[i].coords.y-=1.4;
10543 player[i].grabdelay=1;
10545 if ( !player[i].leftkeydown&&!player[i].rightkeydown)
10546 player[i].targetrotation+=180;
10549 if((player[i].jumpkeydown&&!player[i].jumpclimb)||player[i].jumpstart){
10550 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)){
10551 player[i].jumpstart=0;
10552 player[i].targetanimation=jumpupanim;
10553 player[i].target=0;
10554 player[i].targetframe=0;
10555 player[i].rotation=player[i].targetrotation;
10556 player[i].transspeed=20;
10557 player[i].FootLand(0,1);
10558 player[i].FootLand(1,1);
10562 flatfacing=DoRotation(facing,0,player[i].targetrotation+180,0);
10564 if(movekey)player[i].velocity=flatfacing*player[i].speed*45*player[i].scale;
10565 if(!movekey)player[i].velocity=0;
10570 for(j=0;j<numplayers;j++){
10571 if(j!=i&&!player[j].skeleton.free&&player[j].victim){
10572 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<3&&player[j].victim==&player[i]&&(player[j].targetanimation==sweepanim)){
10573 if(target>=0)target=-1;
10578 if(target>=0)player[i].velocity.y=1;
10579 else if(player[i].crouchkeydown||player[i].aitype!=playercontrolled){
10580 player[i].velocity.y=7;
10581 player[i].crouchtogglekeydown=1;
10583 else player[i].velocity.y=5;
10585 if(mousejump&&i==0&&debugmode){
10586 if(!player[i].isLanding())player[i].tempdeltav=deltav;
10587 if(player[i].tempdeltav<0)player[i].velocity.y-=(float)(player[i].tempdeltav)/multiplier/1000;
10590 player[i].coords.y+=.2;
10591 player[i].jumppower-=1;
10593 static float gLoc[3];
10594 static float vel[3];
10595 gLoc[0]=player[i].coords.x;
10596 gLoc[1]=player[i].coords.y;
10597 gLoc[2]=player[i].coords.z;
10598 vel[0]=player[i].velocity.x;
10599 vel[1]=player[i].velocity.y;
10600 vel[2]=player[i].velocity.z;
10603 PlaySoundEx( whooshsound, samp[whooshsound], NULL, TRUE);
10604 FSOUND_3D_SetAttributes(channels[whooshsound], gLoc, vel);
10605 FSOUND_SetVolume(channels[whooshsound], 128);
10606 FSOUND_SetPaused(channels[whooshsound], FALSE);
10609 PlaySoundEx( jumpsound, samp[jumpsound], NULL, TRUE);
10610 FSOUND_3D_SetAttributes(channels[jumpsound], gLoc, vel);
10611 FSOUND_SetVolume(channels[jumpsound], 128);
10612 FSOUND_SetPaused(channels[jumpsound], FALSE);
10614 if((player[i].isIdle())&&player[i].jumppower>1){
10615 player[i].targetanimation=player[i].getLanding();
10616 player[i].landhard=0;
10617 player[i].target=0;
10618 player[i].targetframe=2;
10619 player[i].jumpstart=1;
10620 player[i].tempdeltav=deltav;
10622 if(player[i].targetanimation==jumpupanim&&(((!floatjump&&!editorenabled)||!debugmode)||player[i].aitype!=playercontrolled)){
10623 if(player[i].jumppower>multiplier*6){
10624 player[i].velocity.y+=multiplier*6;
10625 player[i].jumppower-=multiplier*6;
10627 if(player[i].jumppower<=multiplier*6){
10628 player[i].velocity.y+=player[i].jumppower;
10629 player[i].jumppower=0;
10632 if(((floatjump||editorenabled)&&debugmode)&&i==0)player[i].velocity.y+=multiplier*30;
10636 if(player[i].isRun()||player[i].targetanimation==walkanim){
10637 player[i].targetanimation=player[i].getStop();
10638 player[i].target=0;
10639 player[i].targetframe=0;
10641 if(player[i].targetanimation==sneakanim){
10642 player[i].targetanimation=player[i].getCrouch();
10643 if(player[i].currentanimation==sneakanim)player[i].target=0;
10644 player[i].targetframe=0;
10647 if(player[i].targetanimation==walkanim&&(player[i].aitype==attacktypecutoff||player[i].aitype==searchtype||(player[i].aitype==passivetype&&player[i].numwaypoints<=1))){
10648 player[i].targetanimation=player[i].getStop();
10649 player[i].target=0;
10650 player[i].targetframe=0;
10652 if(player[i].isRun()&&(player[i].aitype==passivetype)){
10653 player[i].targetanimation=player[i].getStop();
10654 player[i].target=0;
10655 player[i].targetframe=0;
10659 if(player[i].targetanimation==rollanim)player[i].targetrotation=oldtargetrotation;
10663 for(k=0;k<numplayers;k++){
10664 if(abs(player[k].rotation-player[k].targetrotation)>180){
10665 if(player[k].rotation>player[k].targetrotation)player[k].rotation-=360;
10666 else player[k].rotation+=360;
10669 if(abs(player[k].rotation-player[k].targetrotation)>90&&(player[k].isRun()||player[k].targetanimation==walkanim)){
10670 player[k].targetanimation=player[k].getStop();
10671 player[k].targetframe=0;
10672 player[k].target=0;
10675 if(player[k].targetanimation==backhandspringanim||player[k].targetanimation==dodgebackanim){
10676 player[k].targettilt=0;
10678 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=backhandspringanim&&player[k].targetanimation!=jumpdownanim&&!player[k].isFlip()){
10679 player[k].targettilt=0;
10680 if(player[k].jumppower<0&&!player[k].jumpkeydown)player[k].jumppower=0;
10681 player[k].jumppower+=multiplier*7;
10682 if(player[k].isCrouch())player[k].jumppower+=multiplier*7;
10683 //*(1-(player[k].damage/player[k].damagetolerance))
10684 if(player[k].jumppower>5)player[k].jumppower=5;
10687 if(player[k].isRun()){
10688 player[k].targettilt=(player[k].rotation-player[k].targetrotation)/4;
10691 if(abs(player[k].tilt-player[k].targettilt)<multiplier*150)player[k].tilt=player[k].targettilt;
10692 else if(player[k].tilt>player[k].targettilt){
10693 player[k].tilt-=multiplier*150;
10695 else if(player[k].tilt<player[k].targettilt){
10696 player[k].tilt+=multiplier*150;
10699 player[k].grabdelay-=multiplier;
10702 for(k=0;k<numplayers;k++){
10703 player[k].DoAnimations();
10704 player[k].whichpatchx=player[k].coords.x/(terrain.size/subdivision*terrain.scale*terraindetail);
10705 player[k].whichpatchz=player[k].coords.z/(terrain.size/subdivision*terrain.scale*terraindetail);
10710 player[0].righthandmorphstart=0;
10711 player[0].righthandmorphend=1;
10712 player[0].lefthandmorphstart=0;
10713 player[0].lefthandmorphend=1;
10714 player[0].headmorphstart=0;
10715 player[0].headmorphend=2;*/
10718 if(IsKeyDown( theKeyMap, MAC_P_KEY )){
10719 if(player[0].righthandmorphend!=1)player[0].righthandmorphness=0;
10720 player[0].righthandmorphend=1;
10721 player[0].targetrighthandmorphness=1;
10723 if(player[0].lefthandmorphend!=0)player[0].lefthandmorphness=0;
10724 player[0].lefthandmorphend=0;
10725 player[0].targetlefthandmorphness=1;
10727 if(player[0].headmorphend!=2)player[0].headmorphness=0;
10728 player[0].headmorphend=2;
10729 player[0].targetheadmorphness=1;
10731 if(IsKeyDown( theKeyMap, MAC_L_KEY )){
10732 if(player[0].righthandmorphend!=0)player[0].righthandmorphness=0;
10733 player[0].righthandmorphend=0;
10734 player[0].targetrighthandmorphness=1;
10736 if(player[0].lefthandmorphend!=1)player[0].lefthandmorphness=0;
10737 player[0].lefthandmorphend=1;
10738 player[0].targetlefthandmorphness=1;
10740 if(player[0].headmorphend!=0)player[0].headmorphness=0;
10741 player[0].headmorphend=0;
10742 player[0].targetheadmorphness=1;
10745 if(numenvsounds!=0)
10746 for(j=numenvsounds-1;j>=0;j--){
10747 envsoundlife[j]-=multiplier;
10748 if(envsoundlife[j]<0){
10750 envsoundlife[j]=envsoundlife[numenvsounds];
10751 envsound[j]=envsound[numenvsounds];
10754 if(!slomo)FSOUND_SetFrequency(FSOUND_ALL, 22050);
10755 if(slomo)FSOUND_SetFrequency(FSOUND_ALL, slomofreq);
10757 if(tutoriallevel==1){
10774 if(tutorialstage>=51)
10775 if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
10776 FSOUND_StopSound(FSOUND_ALL); // hack...OpenAL renderer isn't stopping music after tutorial goes to level menu...
10777 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
10779 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
10780 FSOUND_SetPaused(channels[stream_music3], FALSE);
10781 FSOUND_SetVolume(channels[stream_music3], 256);
10786 float gLoc[3]={0,0,0};
10787 float vel[3]={0,0,0};
10788 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10789 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
10790 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10791 FSOUND_SetVolume(channels[fireendsound], 256);
10792 FSOUND_SetPaused(channels[fireendsound], FALSE);
10793 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
10801 if(tutorialstage<51)
10802 if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
10805 gLoc[0]=player[0].coords.x;
10806 gLoc[1]=player[0].coords.y;
10807 gLoc[2]=player[0].coords.z;
10811 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
10812 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10813 FSOUND_SetVolume(channels[fireendsound], 256);
10814 FSOUND_SetPaused(channels[fireendsound], FALSE);
10816 player[0].coords=(oldtemp+oldtemp2)/2;
10824 if(tutorialstage>=14&&tutorialstage<50)
10825 if(findDistancefast(&temp,&player[1].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[1].coords)<4){
10828 gLoc[0]=player[1].coords.x;
10829 gLoc[1]=player[1].coords.y;
10830 gLoc[2]=player[1].coords.z;
10834 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
10835 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10836 FSOUND_SetVolume(channels[fireendsound], 256);
10837 FSOUND_SetPaused(channels[fireendsound], FALSE);
10839 for(int i=0;i<player[1].skeleton.num_joints;i++){
10841 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
10842 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
10843 if(!player[1].skeleton.free)temp=DoRotation(DoRotation(DoRotation(player[1].skeleton.joints[i].position,0,0,player[1].tilt),player[1].tilt2,0,0),0,player[1].rotation,0)*player[1].scale+player[1].coords;
10844 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
10845 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
10849 player[1].coords=(oldtemp+oldtemp2)/2;
10850 for(int i=0;i<player[1].skeleton.num_joints;i++){
10851 player[1].skeleton.joints[i].velocity=0;
10853 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
10854 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
10855 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;
10856 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
10857 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
10865 static float gLoc[3];
10869 static float vel[3];
10870 vel[0]=(viewer.x-oldviewer.x)/multiplier;
10871 vel[1]=(viewer.y-oldviewer.y)/multiplier;
10872 vel[2]=(viewer.z-oldviewer.z)/multiplier;
10874 //Set orientation with forward and up vectors
10875 static XYZ upvector;
10879 upvector=DoRotation(upvector,-rotation2+90,0,0);
10880 upvector=DoRotation(upvector,0,0-rotation,0);
10885 facing=DoRotation(facing,-rotation2,0,0);
10886 facing=DoRotation(facing,0,0-rotation,0);
10889 static float ori[6];
10890 ori[0] = -facing.x;
10892 ori[2] = -facing.z;
10893 ori[3] = -upvector.x;
10894 ori[4] = upvector.y;
10895 ori[5] = -upvector.z;
10897 FSOUND_3D_Listener_SetAttributes(&gLoc[0], &vel[0], ori[0], ori[1], ori[2], ori[3], ori[4], ori[5]);
10904 if(IsKeyDown(theKeyMap, MAC_F1_KEY)&&!freezetogglekeydown){
10906 freezetogglekeydown=1;
10910 void Game::TickOnce(){
10913 if(directing||indialogue==-1){
10914 rotation+=deltah*.7;
10915 if(!invertmouse)rotation2+=deltav*.7;
10916 if(invertmouse)rotation2-=deltav*.7;
10917 if(rotation2>90)rotation2=90;
10918 if(rotation2<-70)rotation2=-70;
10920 if(mainmenu)rotation+=multiplier*5;
10921 if(!mainmenu&&!indemo&&!registered){
10922 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
10923 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
10924 FSOUND_SetPaused(channels[stream_music3], FALSE);
10925 FSOUND_SetVolume(channels[stream_music3], 256);
10930 float gLoc[3]={0,0,0};
10931 float vel[3]={0,0,0};
10932 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10933 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
10934 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10935 FSOUND_SetVolume(channels[fireendsound], 256);
10936 FSOUND_SetPaused(channels[fireendsound], FALSE);
10937 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
10946 if(tryquit==1&&!registered&&mainmenu!=12){
10947 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
10948 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
10949 FSOUND_SetPaused(channels[stream_music3], FALSE);
10950 FSOUND_SetVolume(channels[stream_music3], 256);
10955 float gLoc[3]={0,0,0};
10956 float vel[3]={0,0,0};
10957 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10958 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
10959 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10960 FSOUND_SetVolume(channels[fireendsound], 256);
10961 FSOUND_SetPaused(channels[fireendsound], FALSE);
10962 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
10973 void Game::TickOnceAfter(){
10974 static XYZ colviewer;
10975 static XYZ coltarget;
10978 static float brotate;
10981 static float changedelay;
10982 static bool alldead;
10983 static float unseendelay;
10984 static float cameraspeed;
10988 if(environment==snowyenvironment)music1=stream_music1snow;
10989 if(environment==grassyenvironment)music1=stream_music1grass;
10990 if(environment==desertenvironment)music1=stream_music1desert;
10995 for(i=0;i<numplayers;i++){
10996 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)){
10997 musictype=stream_music2;
11001 if(player[0].dead)musictype=stream_music3;
11004 if(musictype==stream_music2){
11008 if(oldmusictype==stream_music2&&musictype!=stream_music2){
11009 unseendelay-=multiplier;
11011 musictype=stream_music2;
11017 musictype=stream_music3;
11018 musicvolume[2]=512;
11025 if(musictype!=oldmusictype&&musictype==stream_music2){
11026 static float gLoc[3];
11027 static float vel[3];
11028 gLoc[0]=cameraloc.x;
11029 gLoc[1]=cameraloc.y;
11030 gLoc[2]=cameraloc.z;
11034 PlaySoundEx( alarmsound, samp[alarmsound], NULL, TRUE);
11035 FSOUND_SetVolume(channels[alarmsound], 512);
11036 FSOUND_SetPaused(channels[alarmsound], FALSE);
11040 musicselected=musictype;
11042 if(musicselected==music1)musicvolume[0]+=multiplier*450;
11043 else musicvolume[0]-=multiplier*450;
11044 if(musicselected==stream_music2)musicvolume[1]+=multiplier*450;
11045 else musicvolume[1]-=multiplier*450;
11046 if(musicselected==stream_music3)musicvolume[2]+=multiplier*450;
11047 else musicvolume[2]-=multiplier*450;
11049 if(musicselected==music1)musicvolume[0]+=multiplier*100;
11050 else musicvolume[0]-=multiplier*450;
11051 if(musicselected==music2)musicvolume[1]+=multiplier*150;
11052 else if(player[0].dead)musicvolume[1]-=multiplier*450;
11053 else musicvolume[1]-=multiplier*100;
11054 if(musicselected==music3)musicvolume[2]+=multiplier*450;
11055 else musicvolume[2]-=multiplier*450;*/
11058 if(musicvolume[i]<0)musicvolume[i]=0;
11059 if(musicvolume[i]>512)musicvolume[i]=512;
11062 if(musicvolume[2]>128&&!loading&&!mainmenu)musicvolume[2]=128;
11065 if(musicvolume[0]>0&&oldmusicvolume[0]<=0){
11066 PlayStreamEx( music1, strm[music1], NULL, TRUE);
11067 FSOUND_SetPaused(channels[music1], FALSE);
11069 if(musicvolume[1]>0&&oldmusicvolume[1]<=0){
11070 PlayStreamEx( stream_music2, strm[stream_music2], NULL, TRUE);
11071 FSOUND_SetPaused(channels[stream_music2], FALSE);
11073 if(musicvolume[2]>0&&oldmusicvolume[2]<=0){
11074 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
11075 FSOUND_SetPaused(channels[stream_music3], FALSE);
11080 FSOUND_SetPaused(channels[music1], TRUE);
11081 FSOUND_SetPaused(channels[stream_music2], TRUE);
11082 FSOUND_SetPaused(channels[stream_music3], TRUE);
11085 oldmusicvolume[i]=0;
11091 if(musicvolume[0]<=0&&oldmusicvolume[0]>0){
11092 FSOUND_SetPaused(channels[music1], TRUE);
11094 if(musicvolume[1]<=0&&oldmusicvolume[1]>0){
11095 FSOUND_SetPaused(channels[stream_music2], TRUE);
11097 if(musicvolume[2]<=0&&oldmusicvolume[2]>0){
11098 FSOUND_SetPaused(channels[stream_music3], TRUE);
11101 if(musicvolume[0]!=oldmusicvolume[0]){
11102 FSOUND_SetVolume(channels[music1], musicvolume[0]);
11104 if(musicvolume[1]!=oldmusicvolume[1]){
11105 FSOUND_SetVolume(channels[stream_music2], musicvolume[1]);
11107 if(musicvolume[2]!=oldmusicvolume[2]){
11108 FSOUND_SetVolume(channels[stream_music3], musicvolume[2]);
11112 oldmusicvolume[i]=musicvolume[i];
11118 for(i=0;i<numhotspots;i++){
11119 if(hotspottype[i]>10&&hotspottype[i]<20){
11120 if(player[hotspottype[i]-10].dead==0){
11123 else if(killhotspot==2)
11127 if(killhotspot==2)killhotspot=0;
11132 for(i=0;i<numhotspots;i++){
11133 if(hotspottype[i]==-1){
11134 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i])
11141 for(i=1;i<numplayers;i++){
11142 if(!player[i].dead&&player[i].aitype==attacktypecutoff&&player[i].surprised<=0)numalarmed++;
11144 if(numalarmed>maxalarmed)maxalarmed=numalarmed;
11146 if(changedelay<=0&&!loading&&!editorenabled&&gameon&&!tutoriallevel&&changedelay!=-999&&!won){
11147 if(player[0].dead&&changedelay<=0){
11149 targetlevel=whichlevel;
11153 for(i=1;i<numplayers;i++){
11154 if(!player[i].dead&&player[i].howactive<typedead1)alldead=0;
11158 if(alldead&&!player[0].dead&&maptype==mapkilleveryone){
11160 targetlevel=whichlevel+1;
11161 if(targetlevel>numchallengelevels-1)targetlevel=0;
11163 if(winhotspot||windialogue){
11165 targetlevel=whichlevel+1;
11166 if(targetlevel>numchallengelevels-1)targetlevel=0;
11172 targetlevel=whichlevel+1;
11173 if(targetlevel>numchallengelevels-1)targetlevel=0;
11176 if(changedelay>0&&!player[0].dead&&!won){
11177 //high scores, awards, win
11180 accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
11181 accountcampaignchoicesmade[accountactive]++;
11182 accountcampaignscore[accountactive]+=bonustotal;
11184 accountcampaigntime[accountactive]+=leveltime;
11185 if(accountcampaignscore[accountactive]>accountcampaignhighscore[accountactive])accountcampaignhighscore[accountactive]=accountcampaignscore[accountactive];
11187 //if(accountprogress[accountactive]<whichlevel+1)accountprogress[accountactive]=whichlevel+1;
11193 if(bonustotal-startbonustotal>accounthighscore[accountactive][whichlevel])accounthighscore[accountactive][whichlevel]=bonustotal-startbonustotal;
11194 if(accountfasttime[accountactive][whichlevel]==0||leveltime<accountfasttime[accountactive][whichlevel])accountfasttime[accountactive][whichlevel]=leveltime;
11196 if(accountprogress[accountactive]<whichlevel+1)accountprogress[accountactive]=whichlevel+1;
11212 if(!editorenabled&&gameon&&!mainmenu){
11213 if(changedelay!=-999)changedelay-=multiplier/7;
11214 if(player[0].dead)targetlevel=whichlevel;
11215 if(loading==2&&!campaign){
11223 float gLoc[3]={0,0,0};
11224 float vel[3]={0,0,0};
11225 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
11226 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
11227 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
11228 FSOUND_SetVolume(channels[firestartsound], 256);
11229 FSOUND_SetPaused(channels[firestartsound], FALSE);
11230 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
11232 if(!player[0].dead&&targetlevel!=whichlevel){
11233 startbonustotal=bonustotal;
11235 if(!player[0].dead)Loadlevel(targetlevel);
11236 if(player[0].dead)Loadlevel(whichlevel);
11238 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
11239 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
11240 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
11241 FSOUND_SetVolume(channels[fireendsound], 256);
11242 FSOUND_SetPaused(channels[fireendsound], FALSE);
11243 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
11247 if(loading==2&&targetlevel==whichlevel){
11255 float gLoc[3]={0,0,0};
11256 float vel[3]={0,0,0};
11257 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
11258 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
11259 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
11260 FSOUND_SetVolume(channels[firestartsound], 256);
11261 FSOUND_SetPaused(channels[firestartsound], FALSE);
11262 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
11264 for(i=0;i<255;i++){
11278 strcat(mapname,campaignmapname[levelorder[accountcampaignchoicesmade[accountactive]]]);//[campaignchoicewhich[whichchoice]]);
11279 Loadlevel(mapname);
11281 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
11282 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
11283 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
11284 FSOUND_SetVolume(channels[fireendsound], 256);
11285 FSOUND_SetPaused(channels[fireendsound], FALSE);
11286 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
11290 if(changedelay<=-999&&whichlevel!=-2&&!loading&&(player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(killhotspot))&&!winfreeze)loading=1;
11291 if((player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(windialogue)||(killhotspot))&&changedelay<=0){
11292 if(accountprogress[accountactive]>3&&!registered){
11293 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
11294 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
11295 FSOUND_SetPaused(channels[stream_music3], FALSE);
11296 FSOUND_SetVolume(channels[stream_music3], 256);
11300 accountprogress[accountactive]=3;
11302 float gLoc[3]={0,0,0};
11303 float vel[3]={0,0,0};
11304 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
11305 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
11306 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
11307 FSOUND_SetVolume(channels[fireendsound], 256);
11308 FSOUND_SetPaused(channels[fireendsound], FALSE);
11309 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
11318 if(whichlevel!=-2&&!loading&&!player[0].dead){
11322 if(player[0].dead)loading=1;
11328 if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1){
11329 if(campaignnumnext[campaignchoicewhich[whichchoice]]==0){
11333 else if(mainmenu==0&&winfreeze){
11334 if(campaignchoosenext[campaignchoicewhich[whichchoice]]==2)
11336 else stealthloading=0;
11338 if(!stealthloading){
11339 float gLoc[3]={0,0,0};
11340 float vel[3]={0,0,0};
11341 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
11342 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
11343 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
11344 FSOUND_SetVolume(channels[firestartsound], 256);
11345 FSOUND_SetPaused(channels[firestartsound], FALSE);
11346 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
11357 ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
11358 //campaignnumlevels=0;
11359 //accountcampaignchoicesmade[accountactive]=0;
11360 ipstream.ignore(256,':');
11361 ipstream >> campaignnumlevels;
11362 for(i=0;i<campaignnumlevels;i++){
11363 ipstream.ignore(256,':');
11364 ipstream.ignore(256,':');
11365 ipstream.ignore(256,' ');
11366 ipstream >> campaignmapname[i];
11367 ipstream.ignore(256,':');
11368 ipstream >> campaigndescription[i];
11369 for(j=0;j<256;j++){
11370 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
11372 ipstream.ignore(256,':');
11373 ipstream >> campaignchoosenext[i];
11374 ipstream.ignore(256,':');
11375 ipstream >> campaignnumnext[i];
11376 if(campaignnumnext[i])
11377 for(j=0;j<campaignnumnext[i];j++){
11378 ipstream.ignore(256,':');
11379 ipstream >> campaignnextlevel[i][j];
11380 campaignnextlevel[i][j]-=1;
11382 ipstream.ignore(256,':');
11383 ipstream >> campaignlocationx[i];
11384 ipstream.ignore(256,':');
11385 ipstream >> campaignlocationy[i];
11389 for(i=0;i<campaignnumlevels;i++){
11391 levelhighlight[i]=0;
11395 for(i=0;i<campaignnumlevels;i++){
11397 levelhighlight[i]=0;
11402 if(accountcampaignchoicesmade[accountactive])
11403 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
11404 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
11405 levelvisible[levelorder[i+1]]=1;
11407 int whichlevelstart;
11408 whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
11409 if(whichlevelstart<0){
11410 campaignchoicenum=1;
11411 campaignchoicewhich[0]=0;
11415 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
11416 if(campaignchoicenum)
11417 for(i=0;i<campaignchoicenum;i++){
11418 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
11419 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
11420 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
11427 //if(firstload)TickOnceAfter();
11428 if(!firstload)LoadStuff();
11430 for(i=0;i<255;i++){
11445 //accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
11446 //accountcampaignchoicesmade[accountactive]++;
11449 strcat(mapname,campaignmapname[campaignchoicewhich[0]]);
11453 Loadlevel(mapname);
11457 FSOUND_SetPaused(channels[stream_music3], TRUE);
11462 if(loading==3)loading=0;
11466 oldmusictype=musictype;
11472 facing=DoRotation(facing,-rotation2,0,0);
11473 facing=DoRotation(facing,0,0-rotation,0);
11474 viewerfacing=facing;
11478 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;
11479 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;
11481 if(player[0].skeleton.free){
11482 for(i=0;i<player[0].skeleton.num_joints;i++){
11483 if(player[0].skeleton.joints[i].position.y*player[0].scale+player[0].coords.y>target.y)
11484 target.y=player[0].skeleton.joints[i].position.y*player[0].scale+player[0].coords.y;
11488 if(player[0].skeleton.free!=2&&!autocam){
11490 if(findLengthfast(&player[0].velocity)>400){
11491 cameraspeed=20+(findLength(&player[0].velocity)-20)*.96;
11493 if(player[0].skeleton.free==0&&player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim)target.y+=1.4;
11494 coltarget=target-cameraloc;
11495 if(findLengthfast(&coltarget)<multiplier*multiplier*400)cameraloc=target;
11497 Normalise(&coltarget);
11498 if(player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim&&player[0].currentanimation!=climbanim&&player[0].currentoffset.x==0)cameraloc=cameraloc+coltarget*multiplier*cameraspeed;
11499 else cameraloc=cameraloc+coltarget*multiplier*8;
11501 if(editorenabled)cameraloc=target;
11502 cameradist+=multiplier*5;
11503 if(cameradist>2.3)cameradist=2.3;
11504 viewer=cameraloc-facing*cameradist;
11506 coltarget=cameraloc;
11507 objects.SphereCheckPossible(&colviewer, findDistance(&colviewer,&coltarget));
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 coltarget=cameraloc;
11513 if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;
11515 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11516 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11517 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11519 if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.rotation[i])!=-1){
11523 cameradist=findDistance(&viewer,&target);
11524 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.6){
11525 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.6;
11527 if(cameraloc.y<terrain.getHeight(cameraloc.x,cameraloc.z)){
11528 cameraloc.y=terrain.getHeight(cameraloc.x,cameraloc.z);
11531 if(player[0].skeleton.free!=2&&autocam){
11533 if(findLengthfast(&player[0].velocity)>400){
11534 cameraspeed=20+(findLength(&player[0].velocity)-20)*.96;
11536 if(player[0].skeleton.free==0&&player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim)target.y+=1.4;
11537 cameradist+=multiplier*5;
11538 if(cameradist>3.3)cameradist=3.3;
11539 coltarget=target-cameraloc;
11540 if(findLengthfast(&coltarget)<multiplier*multiplier*400)cameraloc=target;
11541 else if(findLengthfast(&coltarget)>1)
11543 Normalise(&coltarget);
11544 if(player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim&&player[0].currentanimation!=climbanim&&player[0].currentoffset.x==0)cameraloc=cameraloc+coltarget*multiplier*cameraspeed;
11545 else cameraloc=cameraloc+coltarget*multiplier*8;
11547 if(editorenabled)cameraloc=target;
11550 coltarget=cameraloc;
11551 objects.SphereCheckPossible(&colviewer, findDistance(&colviewer,&coltarget));
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 coltarget=cameraloc;
11557 if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;
11559 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11560 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11561 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11563 if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.rotation[i])!=-1){
11567 cameradist=findDistance(&viewer,&target);
11568 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.6){
11569 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.6;
11571 if(cameraloc.y<terrain.getHeight(cameraloc.x,cameraloc.z)){
11572 cameraloc.y=terrain.getHeight(cameraloc.x,cameraloc.z);
11575 if(camerashake>.8)camerashake=.8;
11576 //if(woozy>10)woozy=10;
11577 //woozy+=multiplier;
11579 if(player[0].dead)camerashake=0;
11580 if(player[0].dead)woozy=0;
11581 camerashake-=multiplier*2;
11582 blackout-=multiplier*2;
11583 //if(player[0].isCrouch())woozy-=multiplier*8;
11584 if(camerashake<0)camerashake=0;
11585 if(blackout<0)blackout=0;
11586 //if(woozy<0)woozy=0;
11588 viewer.x+=(float)(Random()%100)*.0005*camerashake;
11589 viewer.y+=(float)(Random()%100)*.0005*camerashake;
11590 viewer.z+=(float)(Random()%100)*.0005*camerashake;